Page MenuHomeWildfire Games

React to target death properly when chasing
ClosedPublic

Authored by Silier on Dec 28 2019, 2:21 PM.

Details

Reviewers
Freagarach
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Commits
rP23566: React to target death properly when chasing
Trac Tickets
#5610
#5656
Summary

When unit is chasing someone and target dies, unit receives movement update with likelyFailure, but that case is not handled, so unit is stuck in chasing state forever.

Handling that case similar as in approaching. However as unit can run after fleeing target, it has to run to the its last known position instead walking because that would mean leaking information of target dead and that was refused to do earlier.

In order to approach target last seen position new substate is used to keep potential animation variant in tact and to keep current speed without additional checks, also this helps keep combat "Attacked" logic in case unit is attacked while finishing chasing.

Test Plan

Check that chasing fleeing animal while hunting that dies does not leave unit in chasing state and unit behaves correctly.
Check that chasing fleeing unit that dies does not leave unit in chasing state and unit runs to the last known position and behaves correctly after that based on stance, targets around, queued orders.

Event Timeline

Silier created this revision.Dec 28 2019, 2:21 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/904/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (no-else-return):
|    | Unnecessary 'else' after 'return'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
| 806| 806| 					this.FinishOrder();
| 807| 807| 					return;
| 808| 808| 				}
| 809|    |-				else
| 810|    |-				{
|    | 809|+				
| 811| 810| 					this.SetNextState("GARRISON.APPROACHING");
| 812| 811| 					return;
| 813|    |-				}
|    | 812|+				
| 814| 813| 			}
| 815| 814| 
| 816| 815| 			this.SetNextState("GARRISON.GARRISONING");
|    | [NORMAL] ESLintBear (key-spacing):
|    | Missing space before value for key 'GARRISON'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|1074|1074| 			},
|1075|1075| 		},
|1076|1076| 
|1077|    |-		"GARRISON":{
|    |1077|+		"GARRISON": {
|1078|1078| 			"APPROACHING": {
|1079|1079| 				"enter": function() {
|1080|1080| 					if (!this.MoveToGarrisonRange(this.order.data.target))
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2029|2029| 
|2030|2030| 				"Attacked": function(msg) {
|2031|2031| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|2032|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|2033|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |2032|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |2033|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|2034|2034| 						this.RespondToTargetedEntities([msg.data.attacker]);
|2035|2035| 				},
|2036|2036| 			},
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2137|2137| 						{
|2138|2138| 							let lastPos = this.order.data.lastPos;
|2139|2139| 							if (this.isRunning)
|2140|    |-								this.PushOrder("Run", { "x": lastPos.x, "z": lastPos.z, "force": false});
|    |2140|+								this.PushOrder("Run", { "x": lastPos.x, "z": lastPos.z, "force": false });
|2141|2141| 							else
|2142|2142| 								this.PushOrder("Walk", { "x": lastPos.x, "z": lastPos.z, "force": false });
|2143|2143| 							return;
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2784|2784| 					{
|2785|2785| 						// The building was already finished/fully repaired before we arrived;
|2786|2786| 						// let the ConstructionFinished handler handle this.
|2787|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2787|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2788|2788| 						return true;
|2789|2789| 					}
|2790|2790| 
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2784|2784| 					{
|2785|2785| 						// The building was already finished/fully repaired before we arrived;
|2786|2786| 						// let the ConstructionFinished handler handle this.
|2787|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2787|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2788|2788| 						return true;
|2789|2789| 					}
|2790|2790| 
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 7.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3297|3297| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3298|3298| 
|3299|3299| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3300|    |-							// only used for domestic animals
|    |3300|+		// only used for domestic animals
|3301|3301| 	},
|3302|3302| };
|3303|3303| 
|    | [NORMAL] ESLintBear (no-unneeded-ternary):
|    | Unnecessary use of boolean literals in conditional expression.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3354|3354| 
|3355|3355| UnitAI.prototype.IsAnimal = function()
|3356|3356| {
|3357|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3357|+	return (!!this.template.NaturalBehaviour);
|3358|3358| };
|3359|3359| 
|3360|3360| UnitAI.prototype.IsDangerousAnimal = function()
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3470|3470| 		{
|3471|3471| 			let index = this.GetCurrentState().indexOf(".");
|3472|3472| 			if (index != -1)
|3473|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3473|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3474|3474| 			this.Stop(false);
|3475|3475| 		}
|3476|3476| 
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3526|3526| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3527|3527| 			continue;
|3528|3528| 		if (i == 0)
|3529|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3529|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3530|3530| 		else
|3531|3531| 			this.orderQueue.splice(i, 1);
|3532|3532| 		Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3526|3526| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3527|3527| 			continue;
|3528|3528| 		if (i == 0)
|3529|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3529|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3530|3530| 		else
|3531|3531| 			this.orderQueue.splice(i, 1);
|3532|3532| 		Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3610|3610| };
|3611|3611| 
|3612|3612| 
|3613|    |-//// FSM linkage functions ////
|    |3613|+// // FSM linkage functions ////
|3614|3614| 
|3615|3615| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3616|3616| UnitAI.prototype.SetNextState = function(state)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3780|3780| 				continue;
|3781|3781| 			if (this.orderQueue[i].type == type)
|3782|3782| 				continue;
|3783|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3783|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3784|3784| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3785|3785| 			return;
|3786|3786| 		}
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3780|3780| 				continue;
|3781|3781| 			if (this.orderQueue[i].type == type)
|3782|3782| 				continue;
|3783|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3783|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3784|3784| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3785|3785| 			return;
|3786|3786| 		}
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4022|4022| 	if (data.timerRepeat === undefined)
|4023|4023| 		this.timer = undefined;
|4024|4024| 
|4025|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4025|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|4026|4026| };
|4027|4027| 
|4028|4028| /**
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4022|4022| 	if (data.timerRepeat === undefined)
|4023|4023| 		this.timer = undefined;
|4024|4024| 
|4025|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4025|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|4026|4026| };
|4027|4027| 
|4028|4028| /**
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4067|4067| 	// TODO: This is a bit inefficient since every unit listens to every
|4068|4068| 	// construction message - ideally we could scope it to only the one we're building
|4069|4069| 
|4070|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4070|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|4071|4071| };
|4072|4072| 
|4073|4073| UnitAI.prototype.OnGlobalEntityRenamed = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4067|4067| 	// TODO: This is a bit inefficient since every unit listens to every
|4068|4068| 	// construction message - ideally we could scope it to only the one we're building
|4069|4069| 
|4070|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4070|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|4071|4071| };
|4072|4072| 
|4073|4073| UnitAI.prototype.OnGlobalEntityRenamed = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4092|4092| 
|4093|4093| UnitAI.prototype.OnAttacked = function(msg)
|4094|4094| {
|4095|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4095|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|4096|4096| };
|4097|4097| 
|4098|4098| UnitAI.prototype.OnGuardedAttacked = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4092|4092| 
|4093|4093| UnitAI.prototype.OnAttacked = function(msg)
|4094|4094| {
|4095|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4095|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|4096|4096| };
|4097|4097| 
|4098|4098| UnitAI.prototype.OnGuardedAttacked = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4097|4097| 
|4098|4098| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4099|4099| {
|4100|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4100|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|4101|4101| };
|4102|4102| 
|4103|4103| UnitAI.prototype.OnHealthChanged = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4097|4097| 
|4098|4098| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4099|4099| {
|4100|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4100|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|4101|4101| };
|4102|4102| 
|4103|4103| UnitAI.prototype.OnHealthChanged = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4102|4102| 
|4103|4103| UnitAI.prototype.OnHealthChanged = function(msg)
|4104|4104| {
|4105|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4105|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|4106|4106| };
|4107|4107| 
|4108|4108| UnitAI.prototype.OnRangeUpdate = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4102|4102| 
|4103|4103| UnitAI.prototype.OnHealthChanged = function(msg)
|4104|4104| {
|4105|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4105|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|4106|4106| };
|4107|4107| 
|4108|4108| UnitAI.prototype.OnRangeUpdate = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4108|4108| UnitAI.prototype.OnRangeUpdate = function(msg)
|4109|4109| {
|4110|4110| 	if (msg.tag == this.losRangeQuery)
|4111|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4111|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|4112|4112| 	else if (msg.tag == this.losHealRangeQuery)
|4113|4113| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4114|4114| };
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4108|4108| UnitAI.prototype.OnRangeUpdate = function(msg)
|4109|4109| {
|4110|4110| 	if (msg.tag == this.losRangeQuery)
|4111|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4111|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|4112|4112| 	else if (msg.tag == this.losHealRangeQuery)
|4113|4113| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4114|4114| };
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4110|4110| 	if (msg.tag == this.losRangeQuery)
|4111|4111| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4112|4112| 	else if (msg.tag == this.losHealRangeQuery)
|4113|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4113|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|4114|4114| };
|4115|4115| 
|4116|4116| UnitAI.prototype.OnPackFinished = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4110|4110| 	if (msg.tag == this.losRangeQuery)
|4111|4111| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4112|4112| 	else if (msg.tag == this.losHealRangeQuery)
|4113|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4113|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|4114|4114| };
|4115|4115| 
|4116|4116| UnitAI.prototype.OnPackFinished = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4115|4115| 
|4116|4116| UnitAI.prototype.OnPackFinished = function(msg)
|4117|4117| {
|4118|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4118|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|4119|4119| };
|4120|4120| 
|4121|4121| //// Helper functions to be called by the FSM ////
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4115|4115| 
|4116|4116| UnitAI.prototype.OnPackFinished = function(msg)
|4117|4117| {
|4118|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4118|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|4119|4119| };
|4120|4120| 
|4121|4121| //// Helper functions to be called by the FSM ////
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4118|4118| 	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|4119|4119| };
|4120|4120| 
|4121|    |-//// Helper functions to be called by the FSM ////
|    |4121|+// // Helper functions to be called by the FSM ////
|4122|4122| 
|4123|4123| UnitAI.prototype.GetWalkSpeed = function()
|4124|4124| {
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4786|4786| UnitAI.prototype.AttackEntityInZone = function(ents)
|4787|4787| {
|4788|4788| 	var target = ents.find(target =>
|4789|    |-		this.CanAttack(target)
|4790|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4789|+		this.CanAttack(target) &&
|    |4790|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4791|4791| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4792|4792| 	);
|4793|4793| 	if (!target)
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4787|4787| {
|4788|4788| 	var target = ents.find(target =>
|4789|4789| 		this.CanAttack(target)
|4790|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4791|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4790|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4791|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4792|4792| 	);
|4793|4793| 	if (!target)
|4794|4794| 		return false;
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before 'Engine'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4851|4851| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|4852|4852| 	if (this.isGuardOf)
|4853|4853| 	{
|4854|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4854|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4855|4855| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4856|4856| 		if (cmpUnitAI && cmpAttack &&
|4857|4857| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 3 tabs but found 4.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4855|4855| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4856|4856| 		if (cmpUnitAI && cmpAttack &&
|4857|4857| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|4858|    |-				return false;
|    |4858|+			return false;
|4859|4859| 	}
|4860|4860| 
|4861|4861| 	// Stop if we're in hold-ground mode and it's too far from the holding point
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before 'Engine'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4893|4893| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|4894|4894| 	if (this.isGuardOf)
|4895|4895| 	{
|4896|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4896|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4897|4897| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4898|4898| 		if (cmpUnitAI && cmpAttack &&
|4899|4899| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4906|4906| 	return false;
|4907|4907| };
|4908|4908| 
|4909|    |-//// External interface functions ////
|    |4909|+// // External interface functions ////
|4910|4910| 
|4911|4911| UnitAI.prototype.SetFormationController = function(ent)
|4912|4912| {
|    | [NORMAL] ESLintBear (no-else-return):
|    | Unnecessary 'else' after 'return'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5062|5062| 	{
|5063|5063| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|5064|5064| 			return;
|5065|    |-		else
|5066|    |-			this.RemoveGuard();
|    |5065|+		this.RemoveGuard();
|5067|5066| 	}
|5068|5067| 
|5069|5068| 	this.AddOrder("Guard", { "target": target, "force": false }, queued);
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5404|5404| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5405|5405| 	{
|5406|5406| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5407|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5407|+		if (cmpTrader.HasBothMarkets() &&
|5408|5408| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5409|5409| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5410|5410| 		{
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5685|5685| 				{
|5686|5686| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5687|5687| 					var targetClasses = this.order.data.targetClasses;
|5688|    |-					if (targetClasses.attack && cmpIdentity
|5689|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5688|+					if (targetClasses.attack && cmpIdentity &&
|    |5689|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5690|5690| 						continue;
|5691|5691| 					if (targetClasses.avoid && cmpIdentity
|5692|5692| 						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5688|5688| 					if (targetClasses.attack && cmpIdentity
|5689|5689| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5690|5690| 						continue;
|5691|    |-					if (targetClasses.avoid && cmpIdentity
|5692|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5691|+					if (targetClasses.avoid && cmpIdentity &&
|    |5692|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5693|5693| 						continue;
|5694|5694| 					// Only used by the AIs to prevent some choices of targets
|5695|5695| 					if (targetClasses.vetoEntities && targetClasses.vetoEntities[targ])
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5711|5711| 		{
|5712|5712| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5713|5713| 			var targetClasses = this.order.data.targetClasses;
|5714|    |-			if (cmpIdentity && targetClasses.attack
|5715|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5714|+			if (cmpIdentity && targetClasses.attack &&
|    |5715|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5716|5716| 				continue;
|5717|5717| 			if (cmpIdentity && targetClasses.avoid
|5718|5718| 				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5714|5714| 			if (cmpIdentity && targetClasses.attack
|5715|5715| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5716|5716| 				continue;
|5717|    |-			if (cmpIdentity && targetClasses.avoid
|5718|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5717|+			if (cmpIdentity && targetClasses.avoid &&
|    |5718|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5719|5719| 				continue;
|5720|5720| 			// Only used by the AIs to prevent some choices of targets
|5721|5721| 			if (targetClasses.vetoEntities && targetClasses.vetoEntities[targ])
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5871|5871| 
|5872|5872| UnitAI.prototype.SetHeldPosition = function(x, z)
|5873|5873| {
|5874|    |-	this.heldPosition = {"x": x, "z": z};
|    |5874|+	this.heldPosition = { "x": x, "z": z};
|5875|5875| };
|5876|5876| 
|5877|5877| UnitAI.prototype.SetHeldPositionOnEntity = function(entity)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5871|5871| 
|5872|5872| UnitAI.prototype.SetHeldPosition = function(x, z)
|5873|5873| {
|5874|    |-	this.heldPosition = {"x": x, "z": z};
|    |5874|+	this.heldPosition = {"x": x, "z": z };
|5875|5875| };
|5876|5876| 
|5877|5877| UnitAI.prototype.SetHeldPositionOnEntity = function(entity)
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5898|5898| 	return false;
|5899|5899| };
|5900|5900| 
|5901|    |-//// Helper functions ////
|    |5901|+// // Helper functions ////
|5902|5902| 
|5903|5903| UnitAI.prototype.CanAttack = function(target)
|5904|5904| {
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6102|6102| 	return cmpPack && cmpPack.IsPacking();
|6103|6103| };
|6104|6104| 
|6105|    |-//// Formation specific functions ////
|    |6105|+// // Formation specific functions ////
|6106|6106| 
|6107|6107| UnitAI.prototype.IsAttackingAsFormation = function()
|6108|6108| {
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6107|6107| UnitAI.prototype.IsAttackingAsFormation = function()
|6108|6108| {
|6109|6109| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|6110|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|6111|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |6110|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |6111|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6112|6112| };
|6113|6113| 
|6114|6114| //// Animal specific functions ////
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6111|6111| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6112|6112| };
|6113|6113| 
|6114|    |-//// Animal specific functions ////
|    |6114|+// // Animal specific functions ////
|6115|6115| 
|6116|6116| UnitAI.prototype.MoveRandomly = function(distance)
|6117|6117| {

binaries/data/mods/public/simulation/components/UnitAI.js
| 364| »   »   »   return·true;
|    | [NORMAL] ESLintBear (consistent-return):
|    | Method 'Order.WalkToTarget' expected no return value.

binaries/data/mods/public/simulation/components/UnitAI.js
| 961| »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
| 986| »   »   »   "enter":·function(msg)·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|1036| »   »   »   »   »   return·true;
|    | [NORMAL] ESLintBear (consistent-return):
|    | Method 'enter' expected no return value.

binaries/data/mods/public/simulation/components/UnitAI.js
|1079| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|1124| »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|1156| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|1305| »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|1372| »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|1564| »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|1587| »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|1619| »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|1773| »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|1823| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|1901| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|2078| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|2221| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|2496| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|2529| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|2635| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|2701| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|2740| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|2940| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|3133| »   »   »   »   "enter":·function()·{
|    | [NORMAL] ESLintBear (consistent-return):
|    | Expected to return a value at the end of method 'enter'.

binaries/data/mods/public/simulation/components/UnitAI.js
|3927| »   var·isWorkType·=·type·=>·type·==·"Gather"·||·type·==·"Trade"·||·type·==·"Repair"·||·type·==·"ReturnResource";
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'type' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4773| »   var·target·=·ents.find(target·=>·this.CanAttack(target));
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'target' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4788| »   var·target·=·ents.find(target·=>
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'target' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4834| »   var·ent·=·ents.find(ent·=>·this.CanHeal(ent));
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'ent' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4857| »   »   ····cmpAttack.GetAttackTypes().some(type·=>·cmpUnitAI.CheckTargetAttackRange(this.isGuardOf,·type)))
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'type' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|2033| »   »   »   »   »   »   &&·this.order.data.target·!=·msg.data.attacker·&&·this.GetBestAttackAgainst(msg.data.attacker,·true)·!=·"Capture")
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|3874| »   »   var·order·=·{·"type":·type,·"data":·data·};
|    | [NORMAL] JSHintBear:
|    | 'order' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|3958| »   for·(var·i·=·0;·i·<·this.orderQueue.length;·++i)
|    | [NORMAL] JSHintBear:
|    | 'i' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|4790| »   »   &&·this.CheckTargetDistanceFromHeldPosition(target,·IID_Attack,·this.GetBestAttackAgainst(target,·true))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|4791| »   »   &&·(this.GetStance().respondChaseBeyondVision·||·this.CheckTargetIsInVisionRange(target))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5689| »   »   »   »   »   »   &&·!MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.attack))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5692| »   »   »   »   »   »   &&·MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.avoid))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5705| »   var·targets·=·this.GetTargetsFromUnit();
|    | [NORMAL] JSHintBear:
|    | 'targets' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5706| »   for·(var·targ·of·targets)
|    | [NORMAL] JSHintBear:
|    | 'targ' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5712| »   »   »   var·cmpIdentity·=·Engine.QueryInterface(targ,·IID_Identity);
|    | [NORMAL] JSHintBear:
|    | 'cmpIdentity' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5713| »   »   »   var·targetClasses·=·this.order.data.targetClasses;
|    | [NORMAL] JSHintBear:
|    | 'targetClasses' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5715| »   »   »   »   &&·!MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.attack))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5718| »   »   »   »   &&·MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.avoid))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5793| »   »   var·cmpVision·=·Engine.QueryInterface(this.entity,·IID_Vision);
|    | [NORMAL] JSHintBear:
|    | 'cmpVision' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5796| »   »   var·range·=·cmpVision.GetRange();
|    | [NORMAL] JSHintBear:
|    | 'range' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5801| »   »   var·cmpRanged·=·Engine.QueryInterface(this.entity,·iid);
|    | [NORMAL] JSHintBear:
|    | 'cmpRanged' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5804| »   »   var·range·=·iid·!==·IID_Attack·?·cmpRanged.GetRange()·:·cmpRanged.GetFullAttackRange();
|    | [NORMAL] JSHintBear:
|    | 'range' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5805| »   »   var·cmpVision·=·Engine.QueryInterface(this.entity,·IID_Vision);
|    | [NORMAL] JSHintBear:
|    | 'cmpVision' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5815| »   »   var·cmpVision·=·Engine.QueryInterface(this.entity,·IID_Vision);
|    | [NORMAL] JSHintBear:
|    | 'cmpVision' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5818| »   »   var·range·=·cmpVision.GetRange();
|    | [NORMAL] JSHintBear:
|    | 'range' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|6111| »   »   &&·this.GetCurrentState()·==·"FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1420/display/redirect

Stan added a subscriber: Stan.Dec 28 2019, 2:39 PM
Stan added inline comments.
binaries/data/mods/public/simulation/components/UnitAI.js
264

Missing '.'

2155

Should we push vector2D?

Silier added inline comments.Dec 28 2019, 2:47 PM
binaries/data/mods/public/simulation/components/UnitAI.js
2155

that would be not needed object i think,
and if i remember correctly vectors do not survive serialisation

elexis updated the Trac tickets for this revision.Dec 28 2019, 2:48 PM
Silier added a reviewer: Restricted Owners Package.Dec 28 2019, 2:51 PM
elexis added a subscriber: elexis.Dec 28 2019, 2:58 PM

That fixes a regression from r22526?

In order to run to the point, there have been added new order "Run" which sets running speed for the unit and reuses walking state.

(Question: should we have running state instead?)

Sounds odd (which can often cause further issues down the line), perhaps one can just have it as it was in a23b or was that leaking/bugged too?

binaries/data/mods/public/simulation/components/UnitAI.js
2155

(The prototype doesn't survive serialization (currently), so you'll get the the {x, z} but the Vector2D functions won't be available.

So you can actually still push the existing vector as long as there is no code using the prototype functions.

I suppose there is no performance advantage here since there are no less objects created when adding the object reference and going for consistency is okay.)

Silier added a comment.EditedDec 28 2019, 3:27 PM

Looking to code from r22526, yes it was leaking in case chased target died in fow, because it switched to attacking and that recognised unit is dead. (just tested, yes it does)

Target would die in fow if target is much faster than unit chasing it and non player owned unit would kill given target.

Generally what would be most reasonable would to stop immediately if position of dead target is visible by unit (or by player, both would work) else walk to the last known position. (then it cannot leak info because target dead is visible to player)
But I can imagine that would increase complexity of this part of the code.

Freagarach added a subscriber: Freagarach.EditedDec 28 2019, 3:29 PM

It partly fixes rP22526, this would only fix the chasing, not other orders which are affected.

And the fact that the unit didn't leave the CHASING state while apparently idling and not reacting to orders anymore was introduced in r22526?
The 'information leak' comes from that commit too? How was it handled in before/a23b then?

stop immediately if position of dead target is visible by unit

I would imagine that this will cause confusion for the player, since the player expects that the unit will move to the target position after sending an order, rather than stopping at a random position along the way.
Consider you select 10+ units, each at a very different location, sending an attack/whatever order. In a23b (afaik) they will all end up at the target position, but if they stop along the way, they'd end up in different positions.

And the fact that the unit didn't leave the CHASING state while apparently idling and not reacting to orders anymore was introduced in r22526?

Yes because unitmotion was rewriten.

The 'information leak' comes from that commit too? How was it handled in before/a23b then?

No. In a23b, if chased unit died in fow, chasing unit would stop because it would switch to attacking and then to idle because target is dead.

Silier added a comment.EditedJan 7 2020, 9:46 AM

Alternative approach would be to get unit to attack range instead directly to target position, where it would get if target would be alive, but for that it needs to know range to which it is trying to move.

Another alternative would be just simply abandon chase and return to last hold position if stance wants that, else if not forced order trying to find new targets like in approach else if forced order, just stay idle and do not move to expected position of the target.

Ideas which approach should be done?

Stan added a comment.Jan 7 2020, 11:43 AM
In D2517#106248, @Angen wrote:

Alternative approach would be to get unit to attack range instead directly to target position, where it would get if target would be alive, but for that it needs to know range to which it is trying to move.

Another alternative would be just simply abandon chase and return to last hold position if stance wants that, else if not forced order trying to find new targets like in approach else if forced order, just stay idle and do not move to expected position of the target.

Ideas ?

Maybe D1971?

Silier updated this revision to Diff 11246.Feb 1 2020, 2:34 PM

rebase, copy approaching logic in case of death

Vulcan added a comment.Feb 1 2020, 2:35 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1693/display/redirect

Silier added a reviewer: Restricted Owners Package.Feb 24 2020, 3:43 PM

I think a separate RUNNING-state won't be too bad. I just tested this and when going from chasing to "run" the speed is reset (L2136 I guess).

Requested replay.

Silier updated this revision to Diff 11483.Mar 15 2020, 10:09 AM
Silier edited the summary of this revision. (Show Details)

better approach

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (no-else-return):
|    | Unnecessary 'else' after 'return'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
| 788| 788| 					this.FinishOrder();
| 789| 789| 					return;
| 790| 790| 				}
| 791|    |-				else
| 792|    |-				{
|    | 791|+				
| 793| 792| 					this.SetNextState("GARRISON.APPROACHING");
| 794| 793| 					return;
| 795|    |-				}
|    | 794|+				
| 796| 795| 			}
| 797| 796| 
| 798| 797| 			this.SetNextState("GARRISON.GARRISONING");
|    | [NORMAL] ESLintBear (key-spacing):
|    | Missing space before value for key 'GARRISON'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|1060|1060| 			},
|1061|1061| 		},
|1062|1062| 
|1063|    |-		"GARRISON":{
|    |1063|+		"GARRISON": {
|1064|1064| 			"APPROACHING": {
|1065|1065| 				"enter": function() {
|1066|1066| 					if (!this.MoveToGarrisonRange(this.order.data.target))
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2038|2038| 
|2039|2039| 				"Attacked": function(msg) {
|2040|2040| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|2041|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|2042|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |2041|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |2042|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|2043|2043| 						this.RespondToTargetedEntities([msg.data.attacker]);
|2044|2044| 				},
|2045|2045| 			},
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2153|2153| 						else if (this.order.data.lastPos)
|2154|2154| 						{
|2155|2155| 							let lastPos = this.order.data.lastPos;
|2156|    |-							this.PushOrder("MoveToChasingPoint", { "x": lastPos.x, "z": lastPos.z, "force": true});
|    |2156|+							this.PushOrder("MoveToChasingPoint", { "x": lastPos.x, "z": lastPos.z, "force": true });
|2157|2157| 							return;
|2158|2158| 						}
|2159|2159| 					}
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2829|2829| 					{
|2830|2830| 						// The building was already finished/fully repaired before we arrived;
|2831|2831| 						// let the ConstructionFinished handler handle this.
|2832|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2832|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2833|2833| 						return true;
|2834|2834| 					}
|2835|2835| 
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2829|2829| 					{
|2830|2830| 						// The building was already finished/fully repaired before we arrived;
|2831|2831| 						// let the ConstructionFinished handler handle this.
|2832|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2832|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2833|2833| 						return true;
|2834|2834| 					}
|2835|2835| 
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3127|3127| 				this.StopTimer();
|3128|3128| 				this.ResetAnimation();
|3129|3129| 				if (this.formationAnimationVariant)
|3130|    |-					this.SetAnimationVariant(this.formationAnimationVariant)
|    |3130|+					this.SetAnimationVariant(this.formationAnimationVariant);
|3131|3131| 				else
|3132|3132| 					this.SetDefaultAnimationVariant();
|3133|3133| 				var cmpResistance = Engine.QueryInterface(this.entity, IID_Resistance);
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 7.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3353|3353| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3354|3354| 
|3355|3355| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3356|    |-							// only used for domestic animals
|    |3356|+		// only used for domestic animals
|3357|3357| 
|3358|3358| 		// Reuse the same garrison behaviour for animals.
|3359|3359| 		"GARRISON": "INDIVIDUAL.GARRISON",
|    | [NORMAL] ESLintBear (no-unneeded-ternary):
|    | Unnecessary use of boolean literals in conditional expression.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3415|3415| 
|3416|3416| UnitAI.prototype.IsAnimal = function()
|3417|3417| {
|3418|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3418|+	return (!!this.template.NaturalBehaviour);
|3419|3419| };
|3420|3420| 
|3421|3421| UnitAI.prototype.IsDangerousAnimal = function()
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3531|3531| 		{
|3532|3532| 			let index = this.GetCurrentState().indexOf(".");
|3533|3533| 			if (index != -1)
|3534|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3534|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3535|3535| 			this.Stop(false);
|3536|3536| 		}
|3537|3537| 
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3587|3587| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3588|3588| 			continue;
|3589|3589| 		if (i == 0)
|3590|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3590|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3591|3591| 		else
|3592|3592| 			this.orderQueue.splice(i, 1);
|3593|3593| 		Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3587|3587| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3588|3588| 			continue;
|3589|3589| 		if (i == 0)
|3590|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3590|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3591|3591| 		else
|3592|3592| 			this.orderQueue.splice(i, 1);
|3593|3593| 		Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3674|3674| };
|3675|3675| 
|3676|3676| 
|3677|    |-//// FSM linkage functions ////
|    |3677|+// // FSM linkage functions ////
|3678|3678| 
|3679|3679| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3680|3680| UnitAI.prototype.SetNextState = function(state)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3845|3845| 				continue;
|3846|3846| 			if (this.orderQueue[i].type == type)
|3847|3847| 				continue;
|3848|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3848|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3849|3849| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3850|3850| 			return;
|3851|3851| 		}
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3845|3845| 				continue;
|3846|3846| 			if (this.orderQueue[i].type == type)
|3847|3847| 				continue;
|3848|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3848|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3849|3849| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3850|3850| 			return;
|3851|3851| 		}
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4087|4087| 	if (data.timerRepeat === undefined)
|4088|4088| 		this.timer = undefined;
|4089|4089| 
|4090|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4090|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|4091|4091| };
|4092|4092| 
|4093|4093| /**
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4087|4087| 	if (data.timerRepeat === undefined)
|4088|4088| 		this.timer = undefined;
|4089|4089| 
|4090|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4090|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|4091|4091| };
|4092|4092| 
|4093|4093| /**
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4132|4132| 	// TODO: This is a bit inefficient since every unit listens to every
|4133|4133| 	// construction message - ideally we could scope it to only the one we're building
|4134|4134| 
|4135|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4135|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|4136|4136| };
|4137|4137| 
|4138|4138| UnitAI.prototype.OnGlobalEntityRenamed = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4132|4132| 	// TODO: This is a bit inefficient since every unit listens to every
|4133|4133| 	// construction message - ideally we could scope it to only the one we're building
|4134|4134| 
|4135|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4135|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|4136|4136| };
|4137|4137| 
|4138|4138| UnitAI.prototype.OnGlobalEntityRenamed = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4163|4163| 	if (msg.fromStatusEffect)
|4164|4164| 		return;
|4165|4165| 
|4166|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4166|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|4167|4167| };
|4168|4168| 
|4169|4169| UnitAI.prototype.OnGuardedAttacked = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4163|4163| 	if (msg.fromStatusEffect)
|4164|4164| 		return;
|4165|4165| 
|4166|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4166|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|4167|4167| };
|4168|4168| 
|4169|4169| UnitAI.prototype.OnGuardedAttacked = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4168|4168| 
|4169|4169| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4170|4170| {
|4171|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4171|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|4172|4172| };
|4173|4173| 
|4174|4174| UnitAI.prototype.OnHealthChanged = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4168|4168| 
|4169|4169| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4170|4170| {
|4171|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4171|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|4172|4172| };
|4173|4173| 
|4174|4174| UnitAI.prototype.OnHealthChanged = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4173|4173| 
|4174|4174| UnitAI.prototype.OnHealthChanged = function(msg)
|4175|4175| {
|4176|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4176|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|4177|4177| };
|4178|4178| 
|4179|4179| UnitAI.prototype.OnRangeUpdate = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4173|4173| 
|4174|4174| UnitAI.prototype.OnHealthChanged = function(msg)
|4175|4175| {
|4176|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4176|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|4177|4177| };
|4178|4178| 
|4179|4179| UnitAI.prototype.OnRangeUpdate = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4179|4179| UnitAI.prototype.OnRangeUpdate = function(msg)
|4180|4180| {
|4181|4181| 	if (msg.tag == this.losRangeQuery)
|4182|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4182|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|4183|4183| 	else if (msg.tag == this.losHealRangeQuery)
|4184|4184| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4185|4185| };
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4179|4179| UnitAI.prototype.OnRangeUpdate = function(msg)
|4180|4180| {
|4181|4181| 	if (msg.tag == this.losRangeQuery)
|4182|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4182|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|4183|4183| 	else if (msg.tag == this.losHealRangeQuery)
|4184|4184| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4185|4185| };
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4181|4181| 	if (msg.tag == this.losRangeQuery)
|4182|4182| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4183|4183| 	else if (msg.tag == this.losHealRangeQuery)
|4184|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4184|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|4185|4185| };
|4186|4186| 
|4187|4187| UnitAI.prototype.OnPackFinished = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4181|4181| 	if (msg.tag == this.losRangeQuery)
|4182|4182| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4183|4183| 	else if (msg.tag == this.losHealRangeQuery)
|4184|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4184|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|4185|4185| };
|4186|4186| 
|4187|4187| UnitAI.prototype.OnPackFinished = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4186|4186| 
|4187|4187| UnitAI.prototype.OnPackFinished = function(msg)
|4188|4188| {
|4189|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4189|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|4190|4190| };
|4191|4191| 
|4192|4192| //// Helper functions to be called by the FSM ////
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4186|4186| 
|4187|4187| UnitAI.prototype.OnPackFinished = function(msg)
|4188|4188| {
|4189|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4189|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|4190|4190| };
|4191|4191| 
|4192|4192| //// Helper functions to be called by the FSM ////
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4189|4189| 	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|4190|4190| };
|4191|4191| 
|4192|    |-//// Helper functions to be called by the FSM ////
|    |4192|+// // Helper functions to be called by the FSM ////
|4193|4193| 
|4194|4194| UnitAI.prototype.GetWalkSpeed = function()
|4195|4195| {
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4855|4855| UnitAI.prototype.AttackEntityInZone = function(ents)
|4856|4856| {
|4857|4857| 	var target = ents.find(target =>
|4858|    |-		this.CanAttack(target)
|4859|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4858|+		this.CanAttack(target) &&
|    |4859|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4860|4860| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4861|4861| 	);
|4862|4862| 	if (!target)
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4856|4856| {
|4857|4857| 	var target = ents.find(target =>
|4858|4858| 		this.CanAttack(target)
|4859|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4860|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4859|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4860|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4861|4861| 	);
|4862|4862| 	if (!target)
|4863|4863| 		return false;
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before 'Engine'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4920|4920| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|4921|4921| 	if (this.isGuardOf)
|4922|4922| 	{
|4923|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4923|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4924|4924| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4925|4925| 		if (cmpUnitAI && cmpAttack &&
|4926|4926| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 3 tabs but found 4.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4924|4924| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4925|4925| 		if (cmpUnitAI && cmpAttack &&
|4926|4926| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|4927|    |-				return false;
|    |4927|+			return false;
|4928|4928| 	}
|4929|4929| 
|4930|4930| 	// Stop if we're in hold-ground mode and it's too far from the holding point
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before 'Engine'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4962|4962| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|4963|4963| 	if (this.isGuardOf)
|4964|4964| 	{
|4965|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4965|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4966|4966| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4967|4967| 		if (cmpUnitAI && cmpAttack &&
|4968|4968| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4975|4975| 	return false;
|4976|4976| };
|4977|4977| 
|4978|    |-//// External interface functions ////
|    |4978|+// // External interface functions ////
|4979|4979| 
|4980|4980| UnitAI.prototype.SetFormationController = function(ent)
|4981|4981| {
|    | [NORMAL] ESLintBear (no-else-return):
|    | Unnecessary 'else' after 'return'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5131|5131| 	{
|5132|5132| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|5133|5133| 			return;
|5134|    |-		else
|5135|    |-			this.RemoveGuard();
|    |5134|+		this.RemoveGuard();
|5136|5135| 	}
|5137|5136| 
|5138|5137| 	this.AddOrder("Guard", { "target": target, "force": false }, queued);
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5462|5462| 
|5463|5463| 	if (this.IsFormationController())
|5464|5464| 		this.CallMemberFunction("CancelSetupTradeRoute", [target]);
|5465|    |-}
|    |5465|+};
|5466|5466| /**
|5467|5467|  * Adds trade order to the queue. Either walk to the first market, or
|5468|5468|  * start a new route. Not forced, so it can be interrupted by attacks.
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5483|5483| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5484|5484| 	{
|5485|5485| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5486|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5486|+		if (cmpTrader.HasBothMarkets() &&
|5487|5487| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5488|5488| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5489|5489| 		{
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5764|5764| 				{
|5765|5765| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5766|5766| 					var targetClasses = this.order.data.targetClasses;
|5767|    |-					if (targetClasses.attack && cmpIdentity
|5768|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5767|+					if (targetClasses.attack && cmpIdentity &&
|    |5768|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5769|5769| 						continue;
|5770|5770| 					if (targetClasses.avoid && cmpIdentity
|5771|5771| 						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5767|5767| 					if (targetClasses.attack && cmpIdentity
|5768|5768| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5769|5769| 						continue;
|5770|    |-					if (targetClasses.avoid && cmpIdentity
|5771|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5770|+					if (targetClasses.avoid && cmpIdentity &&
|    |5771|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5772|5772| 						continue;
|5773|5773| 					// Only used by the AIs to prevent some choices of targets
|5774|5774| 					if (targetClasses.vetoEntities && targetClasses.vetoEntities[targ])
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5790|5790| 		{
|5791|5791| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5792|5792| 			var targetClasses = this.order.data.targetClasses;
|5793|    |-			if (cmpIdentity && targetClasses.attack
|5794|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5793|+			if (cmpIdentity && targetClasses.attack &&
|    |5794|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5795|5795| 				continue;
|5796|5796| 			if (cmpIdentity && targetClasses.avoid
|5797|5797| 				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5793|5793| 			if (cmpIdentity && targetClasses.attack
|5794|5794| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5795|5795| 				continue;
|5796|    |-			if (cmpIdentity && targetClasses.avoid
|5797|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5796|+			if (cmpIdentity && targetClasses.avoid &&
|    |5797|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5798|5798| 				continue;
|5799|5799| 			// Only used by the AIs to prevent some choices of targets
|5800|5800| 			if (targetClasses.vetoEntities && targetClasses.vetoEntities[targ])
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5936|5936| 
|5937|5937| UnitAI.prototype.SetHeldPosition = function(x, z)
|5938|5938| {
|5939|    |-	this.heldPosition = {"x": x, "z": z};
|    |5939|+	this.heldPosition = { "x": x, "z": z};
|5940|5940| };
|5941|5941| 
|5942|5942| UnitAI.prototype.SetHeldPositionOnEntity = function(entity)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5936|5936| 
|5937|5937| UnitAI.prototype.SetHeldPosition = function(x, z)
|5938|5938| {
|5939|    |-	this.heldPosition = {"x": x, "z": z};
|    |5939|+	this.heldPosition = {"x": x, "z": z };
|5940|5940| };
|5941|5941| 
|5942|5942| UnitAI.prototype.SetHeldPositionOnEntity = function(entity)
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5963|5963| 	return false;
|5964|5964| };
|5965|5965| 
|5966|    |-//// Helper functions ////
|    |5966|+// // Helper functions ////
|5967|5967| 
|5968|5968| /**
|5969|5969|  * General getter for ranges.
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5982|5982| 		return undefined;
|5983|5983| 
|5984|5984| 	return component.GetRange(type);
|5985|    |-}
|    |5985|+};
|5986|5986| 
|5987|5987| UnitAI.prototype.CanAttack = function(target)
|5988|5988| {
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6180|6180| 	return cmpPack && cmpPack.IsPacking();
|6181|6181| };
|6182|6182| 
|6183|    |-//// Formation specific functions ////
|    |6183|+// // Formation specific functions ////
|6184|6184| 
|6185|6185| UnitAI.prototype.IsAttackingAsFormation = function()
|6186|6186| {
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6185|6185| UnitAI.prototype.IsAttackingAsFormation = function()
|6186|6186| {
|6187|6187| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|6188|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|6189|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |6188|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |6189|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6190|6190| };
|6191|6191| 
|6192|6192| //// Animal specific functions ////
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6189|6189| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6190|6190| };
|6191|6191| 
|6192|    |-//// Animal specific functions ////
|    |6192|+// // Animal specific functions ////
|6193|6193| 
|6194|6194| UnitAI.prototype.MoveRandomly = function(distance)
|6195|6195| {

binaries/data/mods/public/simulation/components/UnitAI.js
| 338| »   »   »   return·true;
|    | [NORMAL] ESLintBear (consistent-return):
|    | Method 'Order.WalkToTarget' expected no return value.

binaries/data/mods/public/simulation/components/UnitAI.js
|1248| »   »   »   »   return·false;
|    | [NORMAL] ESLintBear (consistent-return):
|    | Method 'Timer' expected no return value.

binaries/data/mods/public/simulation/components/UnitAI.js
|3992| »   var·isWorkType·=·type·=>·type·==·"Gather"·||·type·==·"Trade"·||·type·==·"Repair"·||·type·==·"ReturnResource";
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'type' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4842| »   var·target·=·ents.find(target·=>·this.CanAttack(target));
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'target' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4857| »   var·target·=·ents.find(target·=>
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'target' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4903| »   var·ent·=·ents.find(ent·=>·this.CanHeal(ent));
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'ent' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4926| »   »   ····cmpAttack.GetAttackTypes().some(type·=>·cmpUnitAI.CheckTargetAttackRange(this.isGuardOf,·type)))
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'type' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|2042| »   »   »   »   »   »   &&·this.order.data.target·!=·msg.data.attacker·&&·this.GetBestAttackAgainst(msg.data.attacker,·true)·!=·"Capture")
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|3130| »   »   »   »   »   this.SetAnimationVariant(this.formationAnimationVariant)
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|3939| »   »   var·order·=·{·"type":·type,·"data":·data·};
|    | [NORMAL] JSHintBear:
|    | 'order' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|4023| »   for·(var·i·=·0;·i·<·this.orderQueue.length;·++i)
|    | [NORMAL] JSHintBear:
|    | 'i' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|4859| »   »   &&·this.CheckTargetDistanceFromHeldPosition(target,·IID_Attack,·this.GetBestAttackAgainst(target,·true))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|4860| »   »   &&·(this.GetStance().respondChaseBeyondVision·||·this.CheckTargetIsInVisionRange(target))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5465| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|5768| »   »   »   »   »   »   &&·!MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.attack))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5771| »   »   »   »   »   »   &&·MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.avoid))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5784| »   var·targets·=·this.GetTargetsFromUnit();
|    | [NORMAL] JSHintBear:
|    | 'targets' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5785| »   for·(var·targ·of·targets)
|    | [NORMAL] JSHintBear:
|    | 'targ' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5791| »   »   »   var·cmpIdentity·=·Engine.QueryInterface(targ,·IID_Identity);
|    | [NORMAL] JSHintBear:
|    | 'cmpIdentity' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5792| »   »   »   var·targetClasses·=·this.order.data.targetClasses;
|    | [NORMAL] JSHintBear:
|    | 'targetClasses' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5794| »   »   »   »   &&·!MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.attack))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5797| »   »   »   »   &&·MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.avoid))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5985| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|6189| »   »   &&·this.GetCurrentState()·==·"FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1854/display/redirect

Silier planned changes to this revision.Mar 15 2020, 11:11 AM

warnings

Silier updated this revision to Diff 11484.Mar 15 2020, 11:21 AM

cancel CHASING timer

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1855/display/redirect

Silier removed a reviewer: Restricted Owners Package.Mar 16 2020, 6:17 PM

Looking good :)

  • Tasking a unit to chase a unit which later dies lets the former keep running to the last known position.
  • Otherwise no strange/different behaviour is observed.

Just one notion, perhaps/probably out of scope for this patch. When a unit chases another on its own and the target dies the former will stop in its tracks.

binaries/data/mods/public/simulation/components/UnitAI.js
2095

Is the comment necessary?

2109–2110

Same here, code seems self-explanatory?

the former will stop in its tracks

If you mean a32b (or before this diff), the goal here is to mimic combat.approach not leaking information behaviour. So if player says unit to attack target, attacker will end roughly at the spot of the target even target dies.

still need to check petra if i did not break something with that substate

Petra does not use Chasing string in her codebase -> ok.

Freagarach accepted this revision.Mar 21 2020, 5:25 PM
In D2517#111843, @Angen wrote:

If you mean a32b (or before this diff), the goal here is to mimic combat.approach not leaking information behaviour. So if player says unit to attack target, attacker will end roughly at the spot of the target even target dies.

Okay :)

This revision is now accepted and ready to land.Mar 21 2020, 5:25 PM
Silier updated this revision to Diff 11512.Mar 21 2020, 6:11 PM

remove comments

Silier marked 2 inline comments as done.Mar 21 2020, 6:11 PM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (no-else-return):
|    | Unnecessary 'else' after 'return'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
| 788| 788| 					this.FinishOrder();
| 789| 789| 					return;
| 790| 790| 				}
| 791|    |-				else
| 792|    |-				{
|    | 791|+				
| 793| 792| 					this.SetNextState("GARRISON.APPROACHING");
| 794| 793| 					return;
| 795|    |-				}
|    | 794|+				
| 796| 795| 			}
| 797| 796| 
| 798| 797| 			this.SetNextState("GARRISON.GARRISONING");
|    | [NORMAL] ESLintBear (key-spacing):
|    | Missing space before value for key 'GARRISON'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|1060|1060| 			},
|1061|1061| 		},
|1062|1062| 
|1063|    |-		"GARRISON":{
|    |1063|+		"GARRISON": {
|1064|1064| 			"APPROACHING": {
|1065|1065| 				"enter": function() {
|1066|1066| 					if (!this.MoveToGarrisonRange(this.order.data.target))
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2038|2038| 
|2039|2039| 				"Attacked": function(msg) {
|2040|2040| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|2041|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|2042|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |2041|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |2042|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|2043|2043| 						this.RespondToTargetedEntities([msg.data.attacker]);
|2044|2044| 				},
|2045|2045| 			},
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2156|2156| 						else if (this.order.data.lastPos)
|2157|2157| 						{
|2158|2158| 							let lastPos = this.order.data.lastPos;
|2159|    |-							this.PushOrder("MoveToChasingPoint", { "x": lastPos.x, "z": lastPos.z, "force": false});
|    |2159|+							this.PushOrder("MoveToChasingPoint", { "x": lastPos.x, "z": lastPos.z, "force": false });
|2160|2160| 							return;
|2161|2161| 						}
|2162|2162| 					}
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2832|2832| 					{
|2833|2833| 						// The building was already finished/fully repaired before we arrived;
|2834|2834| 						// let the ConstructionFinished handler handle this.
|2835|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2835|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2836|2836| 						return true;
|2837|2837| 					}
|2838|2838| 
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2832|2832| 					{
|2833|2833| 						// The building was already finished/fully repaired before we arrived;
|2834|2834| 						// let the ConstructionFinished handler handle this.
|2835|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2835|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2836|2836| 						return true;
|2837|2837| 					}
|2838|2838| 
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3130|3130| 				this.StopTimer();
|3131|3131| 				this.ResetAnimation();
|3132|3132| 				if (this.formationAnimationVariant)
|3133|    |-					this.SetAnimationVariant(this.formationAnimationVariant)
|    |3133|+					this.SetAnimationVariant(this.formationAnimationVariant);
|3134|3134| 				else
|3135|3135| 					this.SetDefaultAnimationVariant();
|3136|3136| 				var cmpResistance = Engine.QueryInterface(this.entity, IID_Resistance);
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 7.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3356|3356| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3357|3357| 
|3358|3358| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3359|    |-							// only used for domestic animals
|    |3359|+		// only used for domestic animals
|3360|3360| 
|3361|3361| 		// Reuse the same garrison behaviour for animals.
|3362|3362| 		"GARRISON": "INDIVIDUAL.GARRISON",
|    | [NORMAL] ESLintBear (no-unneeded-ternary):
|    | Unnecessary use of boolean literals in conditional expression.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3418|3418| 
|3419|3419| UnitAI.prototype.IsAnimal = function()
|3420|3420| {
|3421|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3421|+	return (!!this.template.NaturalBehaviour);
|3422|3422| };
|3423|3423| 
|3424|3424| UnitAI.prototype.IsDangerousAnimal = function()
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3534|3534| 		{
|3535|3535| 			let index = this.GetCurrentState().indexOf(".");
|3536|3536| 			if (index != -1)
|3537|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3537|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3538|3538| 			this.Stop(false);
|3539|3539| 		}
|3540|3540| 
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3590|3590| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3591|3591| 			continue;
|3592|3592| 		if (i == 0)
|3593|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3593|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3594|3594| 		else
|3595|3595| 			this.orderQueue.splice(i, 1);
|3596|3596| 		Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3590|3590| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3591|3591| 			continue;
|3592|3592| 		if (i == 0)
|3593|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3593|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3594|3594| 		else
|3595|3595| 			this.orderQueue.splice(i, 1);
|3596|3596| 		Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3677|3677| };
|3678|3678| 
|3679|3679| 
|3680|    |-//// FSM linkage functions ////
|    |3680|+// // FSM linkage functions ////
|3681|3681| 
|3682|3682| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3683|3683| UnitAI.prototype.SetNextState = function(state)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3848|3848| 				continue;
|3849|3849| 			if (this.orderQueue[i].type == type)
|3850|3850| 				continue;
|3851|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3851|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3852|3852| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3853|3853| 			return;
|3854|3854| 		}
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3848|3848| 				continue;
|3849|3849| 			if (this.orderQueue[i].type == type)
|3850|3850| 				continue;
|3851|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3851|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3852|3852| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3853|3853| 			return;
|3854|3854| 		}
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4090|4090| 	if (data.timerRepeat === undefined)
|4091|4091| 		this.timer = undefined;
|4092|4092| 
|4093|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4093|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|4094|4094| };
|4095|4095| 
|4096|4096| /**
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4090|4090| 	if (data.timerRepeat === undefined)
|4091|4091| 		this.timer = undefined;
|4092|4092| 
|4093|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4093|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|4094|4094| };
|4095|4095| 
|4096|4096| /**
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4135|4135| 	// TODO: This is a bit inefficient since every unit listens to every
|4136|4136| 	// construction message - ideally we could scope it to only the one we're building
|4137|4137| 
|4138|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4138|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|4139|4139| };
|4140|4140| 
|4141|4141| UnitAI.prototype.OnGlobalEntityRenamed = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4135|4135| 	// TODO: This is a bit inefficient since every unit listens to every
|4136|4136| 	// construction message - ideally we could scope it to only the one we're building
|4137|4137| 
|4138|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4138|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|4139|4139| };
|4140|4140| 
|4141|4141| UnitAI.prototype.OnGlobalEntityRenamed = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4166|4166| 	if (msg.fromStatusEffect)
|4167|4167| 		return;
|4168|4168| 
|4169|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4169|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|4170|4170| };
|4171|4171| 
|4172|4172| UnitAI.prototype.OnGuardedAttacked = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4166|4166| 	if (msg.fromStatusEffect)
|4167|4167| 		return;
|4168|4168| 
|4169|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4169|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|4170|4170| };
|4171|4171| 
|4172|4172| UnitAI.prototype.OnGuardedAttacked = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4171|4171| 
|4172|4172| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4173|4173| {
|4174|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4174|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|4175|4175| };
|4176|4176| 
|4177|4177| UnitAI.prototype.OnHealthChanged = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4171|4171| 
|4172|4172| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4173|4173| {
|4174|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4174|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|4175|4175| };
|4176|4176| 
|4177|4177| UnitAI.prototype.OnHealthChanged = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4176|4176| 
|4177|4177| UnitAI.prototype.OnHealthChanged = function(msg)
|4178|4178| {
|4179|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4179|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|4180|4180| };
|4181|4181| 
|4182|4182| UnitAI.prototype.OnRangeUpdate = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4176|4176| 
|4177|4177| UnitAI.prototype.OnHealthChanged = function(msg)
|4178|4178| {
|4179|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4179|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|4180|4180| };
|4181|4181| 
|4182|4182| UnitAI.prototype.OnRangeUpdate = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4182|4182| UnitAI.prototype.OnRangeUpdate = function(msg)
|4183|4183| {
|4184|4184| 	if (msg.tag == this.losRangeQuery)
|4185|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4185|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|4186|4186| 	else if (msg.tag == this.losHealRangeQuery)
|4187|4187| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4188|4188| };
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4182|4182| UnitAI.prototype.OnRangeUpdate = function(msg)
|4183|4183| {
|4184|4184| 	if (msg.tag == this.losRangeQuery)
|4185|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4185|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|4186|4186| 	else if (msg.tag == this.losHealRangeQuery)
|4187|4187| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4188|4188| };
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4184|4184| 	if (msg.tag == this.losRangeQuery)
|4185|4185| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4186|4186| 	else if (msg.tag == this.losHealRangeQuery)
|4187|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4187|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|4188|4188| };
|4189|4189| 
|4190|4190| UnitAI.prototype.OnPackFinished = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4184|4184| 	if (msg.tag == this.losRangeQuery)
|4185|4185| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4186|4186| 	else if (msg.tag == this.losHealRangeQuery)
|4187|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4187|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|4188|4188| };
|4189|4189| 
|4190|4190| UnitAI.prototype.OnPackFinished = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4189|4189| 
|4190|4190| UnitAI.prototype.OnPackFinished = function(msg)
|4191|4191| {
|4192|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4192|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|4193|4193| };
|4194|4194| 
|4195|4195| //// Helper functions to be called by the FSM ////
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4189|4189| 
|4190|4190| UnitAI.prototype.OnPackFinished = function(msg)
|4191|4191| {
|4192|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4192|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|4193|4193| };
|4194|4194| 
|4195|4195| //// Helper functions to be called by the FSM ////
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4192|4192| 	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|4193|4193| };
|4194|4194| 
|4195|    |-//// Helper functions to be called by the FSM ////
|    |4195|+// // Helper functions to be called by the FSM ////
|4196|4196| 
|4197|4197| UnitAI.prototype.GetWalkSpeed = function()
|4198|4198| {
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4859|4859| UnitAI.prototype.AttackEntityInZone = function(ents)
|4860|4860| {
|4861|4861| 	var target = ents.find(target =>
|4862|    |-		this.CanAttack(target)
|4863|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4862|+		this.CanAttack(target) &&
|    |4863|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4864|4864| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4865|4865| 	);
|4866|4866| 	if (!target)
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4860|4860| {
|4861|4861| 	var target = ents.find(target =>
|4862|4862| 		this.CanAttack(target)
|4863|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4864|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4863|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4864|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4865|4865| 	);
|4866|4866| 	if (!target)
|4867|4867| 		return false;
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before 'Engine'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4924|4924| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|4925|4925| 	if (this.isGuardOf)
|4926|4926| 	{
|4927|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4927|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4928|4928| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4929|4929| 		if (cmpUnitAI && cmpAttack &&
|4930|4930| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 3 tabs but found 4.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4928|4928| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4929|4929| 		if (cmpUnitAI && cmpAttack &&
|4930|4930| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|4931|    |-				return false;
|    |4931|+			return false;
|4932|4932| 	}
|4933|4933| 
|4934|4934| 	// Stop if we're in hold-ground mode and it's too far from the holding point
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before 'Engine'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4966|4966| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|4967|4967| 	if (this.isGuardOf)
|4968|4968| 	{
|4969|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4969|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4970|4970| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4971|4971| 		if (cmpUnitAI && cmpAttack &&
|4972|4972| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4979|4979| 	return false;
|4980|4980| };
|4981|4981| 
|4982|    |-//// External interface functions ////
|    |4982|+// // External interface functions ////
|4983|4983| 
|4984|4984| UnitAI.prototype.SetFormationController = function(ent)
|4985|4985| {
|    | [NORMAL] ESLintBear (no-else-return):
|    | Unnecessary 'else' after 'return'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5135|5135| 	{
|5136|5136| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|5137|5137| 			return;
|5138|    |-		else
|5139|    |-			this.RemoveGuard();
|    |5138|+		this.RemoveGuard();
|5140|5139| 	}
|5141|5140| 
|5142|5141| 	this.AddOrder("Guard", { "target": target, "force": false }, queued);
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5466|5466| 
|5467|5467| 	if (this.IsFormationController())
|5468|5468| 		this.CallMemberFunction("CancelSetupTradeRoute", [target]);
|5469|    |-}
|    |5469|+};
|5470|5470| /**
|5471|5471|  * Adds trade order to the queue. Either walk to the first market, or
|5472|5472|  * start a new route. Not forced, so it can be interrupted by attacks.
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5487|5487| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5488|5488| 	{
|5489|5489| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5490|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5490|+		if (cmpTrader.HasBothMarkets() &&
|5491|5491| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5492|5492| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5493|5493| 		{
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5768|5768| 				{
|5769|5769| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5770|5770| 					var targetClasses = this.order.data.targetClasses;
|5771|    |-					if (targetClasses.attack && cmpIdentity
|5772|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5771|+					if (targetClasses.attack && cmpIdentity &&
|    |5772|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5773|5773| 						continue;
|5774|5774| 					if (targetClasses.avoid && cmpIdentity
|5775|5775| 						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5771|5771| 					if (targetClasses.attack && cmpIdentity
|5772|5772| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5773|5773| 						continue;
|5774|    |-					if (targetClasses.avoid && cmpIdentity
|5775|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5774|+					if (targetClasses.avoid && cmpIdentity &&
|    |5775|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5776|5776| 						continue;
|5777|5777| 					// Only used by the AIs to prevent some choices of targets
|5778|5778| 					if (targetClasses.vetoEntities && targetClasses.vetoEntities[targ])
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5794|5794| 		{
|5795|5795| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5796|5796| 			var targetClasses = this.order.data.targetClasses;
|5797|    |-			if (cmpIdentity && targetClasses.attack
|5798|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5797|+			if (cmpIdentity && targetClasses.attack &&
|    |5798|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5799|5799| 				continue;
|5800|5800| 			if (cmpIdentity && targetClasses.avoid
|5801|5801| 				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5797|5797| 			if (cmpIdentity && targetClasses.attack
|5798|5798| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5799|5799| 				continue;
|5800|    |-			if (cmpIdentity && targetClasses.avoid
|5801|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5800|+			if (cmpIdentity && targetClasses.avoid &&
|    |5801|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5802|5802| 				continue;
|5803|5803| 			// Only used by the AIs to prevent some choices of targets
|5804|5804| 			if (targetClasses.vetoEntities && targetClasses.vetoEntities[targ])
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5940|5940| 
|5941|5941| UnitAI.prototype.SetHeldPosition = function(x, z)
|5942|5942| {
|5943|    |-	this.heldPosition = {"x": x, "z": z};
|    |5943|+	this.heldPosition = { "x": x, "z": z};
|5944|5944| };
|5945|5945| 
|5946|5946| UnitAI.prototype.SetHeldPositionOnEntity = function(entity)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5940|5940| 
|5941|5941| UnitAI.prototype.SetHeldPosition = function(x, z)
|5942|5942| {
|5943|    |-	this.heldPosition = {"x": x, "z": z};
|    |5943|+	this.heldPosition = {"x": x, "z": z };
|5944|5944| };
|5945|5945| 
|5946|5946| UnitAI.prototype.SetHeldPositionOnEntity = function(entity)
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5967|5967| 	return false;
|5968|5968| };
|5969|5969| 
|5970|    |-//// Helper functions ////
|    |5970|+// // Helper functions ////
|5971|5971| 
|5972|5972| /**
|5973|5973|  * General getter for ranges.
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5986|5986| 		return undefined;
|5987|5987| 
|5988|5988| 	return component.GetRange(type);
|5989|    |-}
|    |5989|+};
|5990|5990| 
|5991|5991| UnitAI.prototype.CanAttack = function(target)
|5992|5992| {
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6184|6184| 	return cmpPack && cmpPack.IsPacking();
|6185|6185| };
|6186|6186| 
|6187|    |-//// Formation specific functions ////
|    |6187|+// // Formation specific functions ////
|6188|6188| 
|6189|6189| UnitAI.prototype.IsAttackingAsFormation = function()
|6190|6190| {
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6189|6189| UnitAI.prototype.IsAttackingAsFormation = function()
|6190|6190| {
|6191|6191| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|6192|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|6193|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |6192|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |6193|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6194|6194| };
|6195|6195| 
|6196|6196| //// Animal specific functions ////
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6193|6193| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6194|6194| };
|6195|6195| 
|6196|    |-//// Animal specific functions ////
|    |6196|+// // Animal specific functions ////
|6197|6197| 
|6198|6198| UnitAI.prototype.MoveRandomly = function(distance)
|6199|6199| {

binaries/data/mods/public/simulation/components/UnitAI.js
| 338| »   »   »   return·true;
|    | [NORMAL] ESLintBear (consistent-return):
|    | Method 'Order.WalkToTarget' expected no return value.

binaries/data/mods/public/simulation/components/UnitAI.js
|1248| »   »   »   »   return·false;
|    | [NORMAL] ESLintBear (consistent-return):
|    | Method 'Timer' expected no return value.

binaries/data/mods/public/simulation/components/UnitAI.js
|3995| »   var·isWorkType·=·type·=>·type·==·"Gather"·||·type·==·"Trade"·||·type·==·"Repair"·||·type·==·"ReturnResource";
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'type' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4846| »   var·target·=·ents.find(target·=>·this.CanAttack(target));
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'target' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4861| »   var·target·=·ents.find(target·=>
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'target' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4907| »   var·ent·=·ents.find(ent·=>·this.CanHeal(ent));
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'ent' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4930| »   »   ····cmpAttack.GetAttackTypes().some(type·=>·cmpUnitAI.CheckTargetAttackRange(this.isGuardOf,·type)))
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'type' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|2042| »   »   »   »   »   »   &&·this.order.data.target·!=·msg.data.attacker·&&·this.GetBestAttackAgainst(msg.data.attacker,·true)·!=·"Capture")
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|3133| »   »   »   »   »   this.SetAnimationVariant(this.formationAnimationVariant)
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|3942| »   »   var·order·=·{·"type":·type,·"data":·data·};
|    | [NORMAL] JSHintBear:
|    | 'order' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|4026| »   for·(var·i·=·0;·i·<·this.orderQueue.length;·++i)
|    | [NORMAL] JSHintBear:
|    | 'i' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|4863| »   »   &&·this.CheckTargetDistanceFromHeldPosition(target,·IID_Attack,·this.GetBestAttackAgainst(target,·true))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|4864| »   »   &&·(this.GetStance().respondChaseBeyondVision·||·this.CheckTargetIsInVisionRange(target))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5469| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|5772| »   »   »   »   »   »   &&·!MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.attack))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5775| »   »   »   »   »   »   &&·MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.avoid))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5788| »   var·targets·=·this.GetTargetsFromUnit();
|    | [NORMAL] JSHintBear:
|    | 'targets' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5789| »   for·(var·targ·of·targets)
|    | [NORMAL] JSHintBear:
|    | 'targ' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5795| »   »   »   var·cmpIdentity·=·Engine.QueryInterface(targ,·IID_Identity);
|    | [NORMAL] JSHintBear:
|    | 'cmpIdentity' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5796| »   »   »   var·targetClasses·=·this.order.data.targetClasses;
|    | [NORMAL] JSHintBear:
|    | 'targetClasses' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5798| »   »   »   »   &&·!MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.attack))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5801| »   »   »   »   &&·MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.avoid))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5989| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|6193| »   »   &&·this.GetCurrentState()·==·"FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1876/display/redirect

Freagarach added inline comments.Mar 23 2020, 5:57 PM
binaries/data/mods/public/simulation/components/UnitAI.js
2159

Any reason why you changed from forced to unforced order?

Silier added inline comments.Mar 23 2020, 7:25 PM
binaries/data/mods/public/simulation/components/UnitAI.js
2159

they would not react to melee attacks while walking there unless in violent mode

Silier planned changes to this revision.Apr 1 2020, 9:07 PM
Silier updated this revision to Diff 11614.Apr 1 2020, 9:41 PM

Use attackType from order to get appropriate range we would end up if target would be alive.
Use relaxed range on top of it to reduce pathfinding lag when path is obstructed.
Keep forced order.

This revision is now accepted and ready to land.Apr 1 2020, 9:41 PM
Silier requested review of this revision.Apr 1 2020, 9:41 PM
Vulcan added a comment.Apr 1 2020, 9:51 PM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (no-else-return):
|    | Unnecessary 'else' after 'return'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
| 788| 788| 					this.FinishOrder();
| 789| 789| 					return;
| 790| 790| 				}
| 791|    |-				else
| 792|    |-				{
|    | 791|+				
| 793| 792| 					this.SetNextState("GARRISON.APPROACHING");
| 794| 793| 					return;
| 795|    |-				}
|    | 794|+				
| 796| 795| 			}
| 797| 796| 
| 798| 797| 			this.SetNextState("GARRISON.GARRISONING");
|    | [NORMAL] ESLintBear (key-spacing):
|    | Missing space before value for key 'GARRISON'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|1060|1060| 			},
|1061|1061| 		},
|1062|1062| 
|1063|    |-		"GARRISON":{
|    |1063|+		"GARRISON": {
|1064|1064| 			"APPROACHING": {
|1065|1065| 				"enter": function() {
|1066|1066| 					if (!this.MoveToGarrisonRange(this.order.data.target))
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2038|2038| 
|2039|2039| 				"Attacked": function(msg) {
|2040|2040| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|2041|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|2042|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |2041|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |2042|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|2043|2043| 						this.RespondToTargetedEntities([msg.data.attacker]);
|2044|2044| 				},
|2045|2045| 			},
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2838|2838| 					{
|2839|2839| 						// The building was already finished/fully repaired before we arrived;
|2840|2840| 						// let the ConstructionFinished handler handle this.
|2841|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2841|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2842|2842| 						return true;
|2843|2843| 					}
|2844|2844| 
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2838|2838| 					{
|2839|2839| 						// The building was already finished/fully repaired before we arrived;
|2840|2840| 						// let the ConstructionFinished handler handle this.
|2841|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2841|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2842|2842| 						return true;
|2843|2843| 					}
|2844|2844| 
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3136|3136| 				this.StopTimer();
|3137|3137| 				this.ResetAnimation();
|3138|3138| 				if (this.formationAnimationVariant)
|3139|    |-					this.SetAnimationVariant(this.formationAnimationVariant)
|    |3139|+					this.SetAnimationVariant(this.formationAnimationVariant);
|3140|3140| 				else
|3141|3141| 					this.SetDefaultAnimationVariant();
|3142|3142| 				var cmpResistance = Engine.QueryInterface(this.entity, IID_Resistance);
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 7.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3362|3362| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3363|3363| 
|3364|3364| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3365|    |-							// only used for domestic animals
|    |3365|+		// only used for domestic animals
|3366|3366| 
|3367|3367| 		// Reuse the same garrison behaviour for animals.
|3368|3368| 		"GARRISON": "INDIVIDUAL.GARRISON",
|    | [NORMAL] ESLintBear (no-unneeded-ternary):
|    | Unnecessary use of boolean literals in conditional expression.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3424|3424| 
|3425|3425| UnitAI.prototype.IsAnimal = function()
|3426|3426| {
|3427|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3427|+	return (!!this.template.NaturalBehaviour);
|3428|3428| };
|3429|3429| 
|3430|3430| UnitAI.prototype.IsDangerousAnimal = function()
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3540|3540| 		{
|3541|3541| 			let index = this.GetCurrentState().indexOf(".");
|3542|3542| 			if (index != -1)
|3543|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3543|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3544|3544| 			this.Stop(false);
|3545|3545| 		}
|3546|3546| 
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3596|3596| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3597|3597| 			continue;
|3598|3598| 		if (i == 0)
|3599|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3599|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3600|3600| 		else
|3601|3601| 			this.orderQueue.splice(i, 1);
|3602|3602| 		Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3596|3596| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3597|3597| 			continue;
|3598|3598| 		if (i == 0)
|3599|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3599|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3600|3600| 		else
|3601|3601| 			this.orderQueue.splice(i, 1);
|3602|3602| 		Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3683|3683| };
|3684|3684| 
|3685|3685| 
|3686|    |-//// FSM linkage functions ////
|    |3686|+// // FSM linkage functions ////
|3687|3687| 
|3688|3688| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3689|3689| UnitAI.prototype.SetNextState = function(state)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3854|3854| 				continue;
|3855|3855| 			if (this.orderQueue[i].type == type)
|3856|3856| 				continue;
|3857|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3857|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3858|3858| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3859|3859| 			return;
|3860|3860| 		}
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3854|3854| 				continue;
|3855|3855| 			if (this.orderQueue[i].type == type)
|3856|3856| 				continue;
|3857|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3857|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3858|3858| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3859|3859| 			return;
|3860|3860| 		}
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4096|4096| 	if (data.timerRepeat === undefined)
|4097|4097| 		this.timer = undefined;
|4098|4098| 
|4099|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4099|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|4100|4100| };
|4101|4101| 
|4102|4102| /**
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4096|4096| 	if (data.timerRepeat === undefined)
|4097|4097| 		this.timer = undefined;
|4098|4098| 
|4099|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4099|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|4100|4100| };
|4101|4101| 
|4102|4102| /**
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4141|4141| 	// TODO: This is a bit inefficient since every unit listens to every
|4142|4142| 	// construction message - ideally we could scope it to only the one we're building
|4143|4143| 
|4144|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4144|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|4145|4145| };
|4146|4146| 
|4147|4147| UnitAI.prototype.OnGlobalEntityRenamed = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4141|4141| 	// TODO: This is a bit inefficient since every unit listens to every
|4142|4142| 	// construction message - ideally we could scope it to only the one we're building
|4143|4143| 
|4144|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4144|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|4145|4145| };
|4146|4146| 
|4147|4147| UnitAI.prototype.OnGlobalEntityRenamed = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4172|4172| 	if (msg.fromStatusEffect)
|4173|4173| 		return;
|4174|4174| 
|4175|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4175|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|4176|4176| };
|4177|4177| 
|4178|4178| UnitAI.prototype.OnGuardedAttacked = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4172|4172| 	if (msg.fromStatusEffect)
|4173|4173| 		return;
|4174|4174| 
|4175|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4175|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|4176|4176| };
|4177|4177| 
|4178|4178| UnitAI.prototype.OnGuardedAttacked = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4177|4177| 
|4178|4178| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4179|4179| {
|4180|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4180|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|4181|4181| };
|4182|4182| 
|4183|4183| UnitAI.prototype.OnHealthChanged = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4177|4177| 
|4178|4178| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4179|4179| {
|4180|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4180|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|4181|4181| };
|4182|4182| 
|4183|4183| UnitAI.prototype.OnHealthChanged = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4182|4182| 
|4183|4183| UnitAI.prototype.OnHealthChanged = function(msg)
|4184|4184| {
|4185|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4185|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|4186|4186| };
|4187|4187| 
|4188|4188| UnitAI.prototype.OnRangeUpdate = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4182|4182| 
|4183|4183| UnitAI.prototype.OnHealthChanged = function(msg)
|4184|4184| {
|4185|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4185|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|4186|4186| };
|4187|4187| 
|4188|4188| UnitAI.prototype.OnRangeUpdate = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4188|4188| UnitAI.prototype.OnRangeUpdate = function(msg)
|4189|4189| {
|4190|4190| 	if (msg.tag == this.losRangeQuery)
|4191|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4191|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|4192|4192| 	else if (msg.tag == this.losHealRangeQuery)
|4193|4193| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4194|4194| };
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4188|4188| UnitAI.prototype.OnRangeUpdate = function(msg)
|4189|4189| {
|4190|4190| 	if (msg.tag == this.losRangeQuery)
|4191|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4191|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|4192|4192| 	else if (msg.tag == this.losHealRangeQuery)
|4193|4193| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4194|4194| };
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4190|4190| 	if (msg.tag == this.losRangeQuery)
|4191|4191| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4192|4192| 	else if (msg.tag == this.losHealRangeQuery)
|4193|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4193|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|4194|4194| };
|4195|4195| 
|4196|4196| UnitAI.prototype.OnPackFinished = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4190|4190| 	if (msg.tag == this.losRangeQuery)
|4191|4191| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4192|4192| 	else if (msg.tag == this.losHealRangeQuery)
|4193|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4193|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|4194|4194| };
|4195|4195| 
|4196|4196| UnitAI.prototype.OnPackFinished = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4195|4195| 
|4196|4196| UnitAI.prototype.OnPackFinished = function(msg)
|4197|4197| {
|4198|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4198|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|4199|4199| };
|4200|4200| 
|4201|4201| //// Helper functions to be called by the FSM ////
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4195|4195| 
|4196|4196| UnitAI.prototype.OnPackFinished = function(msg)
|4197|4197| {
|4198|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4198|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|4199|4199| };
|4200|4200| 
|4201|4201| //// Helper functions to be called by the FSM ////
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4198|4198| 	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|4199|4199| };
|4200|4200| 
|4201|    |-//// Helper functions to be called by the FSM ////
|    |4201|+// // Helper functions to be called by the FSM ////
|4202|4202| 
|4203|4203| UnitAI.prototype.GetWalkSpeed = function()
|4204|4204| {
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4865|4865| UnitAI.prototype.AttackEntityInZone = function(ents)
|4866|4866| {
|4867|4867| 	var target = ents.find(target =>
|4868|    |-		this.CanAttack(target)
|4869|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4868|+		this.CanAttack(target) &&
|    |4869|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4870|4870| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4871|4871| 	);
|4872|4872| 	if (!target)
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4866|4866| {
|4867|4867| 	var target = ents.find(target =>
|4868|4868| 		this.CanAttack(target)
|4869|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4870|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4869|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4870|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4871|4871| 	);
|4872|4872| 	if (!target)
|4873|4873| 		return false;
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before 'Engine'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4930|4930| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|4931|4931| 	if (this.isGuardOf)
|4932|4932| 	{
|4933|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4933|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4934|4934| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4935|4935| 		if (cmpUnitAI && cmpAttack &&
|4936|4936| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 3 tabs but found 4.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4934|4934| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4935|4935| 		if (cmpUnitAI && cmpAttack &&
|4936|4936| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|4937|    |-				return false;
|    |4937|+			return false;
|4938|4938| 	}
|4939|4939| 
|4940|4940| 	// Stop if we're in hold-ground mode and it's too far from the holding point
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before 'Engine'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4972|4972| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|4973|4973| 	if (this.isGuardOf)
|4974|4974| 	{
|4975|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4975|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4976|4976| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4977|4977| 		if (cmpUnitAI && cmpAttack &&
|4978|4978| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4985|4985| 	return false;
|4986|4986| };
|4987|4987| 
|4988|    |-//// External interface functions ////
|    |4988|+// // External interface functions ////
|4989|4989| 
|4990|4990| UnitAI.prototype.SetFormationController = function(ent)
|4991|4991| {
|    | [NORMAL] ESLintBear (no-else-return):
|    | Unnecessary 'else' after 'return'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5141|5141| 	{
|5142|5142| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|5143|5143| 			return;
|5144|    |-		else
|5145|    |-			this.RemoveGuard();
|    |5144|+		this.RemoveGuard();
|5146|5145| 	}
|5147|5146| 
|5148|5147| 	this.AddOrder("Guard", { "target": target, "force": false }, queued);
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5472|5472| 
|5473|5473| 	if (this.IsFormationController())
|5474|5474| 		this.CallMemberFunction("CancelSetupTradeRoute", [target]);
|5475|    |-}
|    |5475|+};
|5476|5476| /**
|5477|5477|  * Adds trade order to the queue. Either walk to the first market, or
|5478|5478|  * start a new route. Not forced, so it can be interrupted by attacks.
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5493|5493| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5494|5494| 	{
|5495|5495| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5496|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5496|+		if (cmpTrader.HasBothMarkets() &&
|5497|5497| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5498|5498| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5499|5499| 		{
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5774|5774| 				{
|5775|5775| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5776|5776| 					var targetClasses = this.order.data.targetClasses;
|5777|    |-					if (targetClasses.attack && cmpIdentity
|5778|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5777|+					if (targetClasses.attack && cmpIdentity &&
|    |5778|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5779|5779| 						continue;
|5780|5780| 					if (targetClasses.avoid && cmpIdentity
|5781|5781| 						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5777|5777| 					if (targetClasses.attack && cmpIdentity
|5778|5778| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5779|5779| 						continue;
|5780|    |-					if (targetClasses.avoid && cmpIdentity
|5781|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5780|+					if (targetClasses.avoid && cmpIdentity &&
|    |5781|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5782|5782| 						continue;
|5783|5783| 					// Only used by the AIs to prevent some choices of targets
|5784|5784| 					if (targetClasses.vetoEntities && targetClasses.vetoEntities[targ])
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5800|5800| 		{
|5801|5801| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5802|5802| 			var targetClasses = this.order.data.targetClasses;
|5803|    |-			if (cmpIdentity && targetClasses.attack
|5804|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5803|+			if (cmpIdentity && targetClasses.attack &&
|    |5804|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5805|5805| 				continue;
|5806|5806| 			if (cmpIdentity && targetClasses.avoid
|5807|5807| 				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5803|5803| 			if (cmpIdentity && targetClasses.attack
|5804|5804| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5805|5805| 				continue;
|5806|    |-			if (cmpIdentity && targetClasses.avoid
|5807|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5806|+			if (cmpIdentity && targetClasses.avoid &&
|    |5807|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5808|5808| 				continue;
|5809|5809| 			// Only used by the AIs to prevent some choices of targets
|5810|5810| 			if (targetClasses.vetoEntities && targetClasses.vetoEntities[targ])
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5946|5946| 
|5947|5947| UnitAI.prototype.SetHeldPosition = function(x, z)
|5948|5948| {
|5949|    |-	this.heldPosition = {"x": x, "z": z};
|    |5949|+	this.heldPosition = { "x": x, "z": z};
|5950|5950| };
|5951|5951| 
|5952|5952| UnitAI.prototype.SetHeldPositionOnEntity = function(entity)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5946|5946| 
|5947|5947| UnitAI.prototype.SetHeldPosition = function(x, z)
|5948|5948| {
|5949|    |-	this.heldPosition = {"x": x, "z": z};
|    |5949|+	this.heldPosition = {"x": x, "z": z };
|5950|5950| };
|5951|5951| 
|5952|5952| UnitAI.prototype.SetHeldPositionOnEntity = function(entity)
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5973|5973| 	return false;
|5974|5974| };
|5975|5975| 
|5976|    |-//// Helper functions ////
|    |5976|+// // Helper functions ////
|5977|5977| 
|5978|5978| /**
|5979|5979|  * General getter for ranges.
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5992|5992| 		return undefined;
|5993|5993| 
|5994|5994| 	return component.GetRange(type);
|5995|    |-}
|    |5995|+};
|5996|5996| 
|5997|5997| UnitAI.prototype.CanAttack = function(target)
|5998|5998| {
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6190|6190| 	return cmpPack && cmpPack.IsPacking();
|6191|6191| };
|6192|6192| 
|6193|    |-//// Formation specific functions ////
|    |6193|+// // Formation specific functions ////
|6194|6194| 
|6195|6195| UnitAI.prototype.IsAttackingAsFormation = function()
|6196|6196| {
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6195|6195| UnitAI.prototype.IsAttackingAsFormation = function()
|6196|6196| {
|6197|6197| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|6198|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|6199|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |6198|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |6199|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6200|6200| };
|6201|6201| 
|6202|6202| //// Animal specific functions ////
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6199|6199| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6200|6200| };
|6201|6201| 
|6202|    |-//// Animal specific functions ////
|    |6202|+// // Animal specific functions ////
|6203|6203| 
|6204|6204| UnitAI.prototype.MoveRandomly = function(distance)
|6205|6205| {

binaries/data/mods/public/simulation/components/UnitAI.js
| 338| »   »   »   return·true;
|    | [NORMAL] ESLintBear (consistent-return):
|    | Method 'Order.WalkToTarget' expected no return value.

binaries/data/mods/public/simulation/components/UnitAI.js
|1248| »   »   »   »   return·false;
|    | [NORMAL] ESLintBear (consistent-return):
|    | Method 'Timer' expected no return value.

binaries/data/mods/public/simulation/components/UnitAI.js
|4001| »   var·isWorkType·=·type·=>·type·==·"Gather"·||·type·==·"Trade"·||·type·==·"Repair"·||·type·==·"ReturnResource";
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'type' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4852| »   var·target·=·ents.find(target·=>·this.CanAttack(target));
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'target' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4867| »   var·target·=·ents.find(target·=>
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'target' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4913| »   var·ent·=·ents.find(ent·=>·this.CanHeal(ent));
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'ent' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4936| »   »   ····cmpAttack.GetAttackTypes().some(type·=>·cmpUnitAI.CheckTargetAttackRange(this.isGuardOf,·type)))
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'type' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|2042| »   »   »   »   »   »   &&·this.order.data.target·!=·msg.data.attacker·&&·this.GetBestAttackAgainst(msg.data.attacker,·true)·!=·"Capture")
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|3139| »   »   »   »   »   this.SetAnimationVariant(this.formationAnimationVariant)
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|3948| »   »   var·order·=·{·"type":·type,·"data":·data·};
|    | [NORMAL] JSHintBear:
|    | 'order' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|4032| »   for·(var·i·=·0;·i·<·this.orderQueue.length;·++i)
|    | [NORMAL] JSHintBear:
|    | 'i' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|4869| »   »   &&·this.CheckTargetDistanceFromHeldPosition(target,·IID_Attack,·this.GetBestAttackAgainst(target,·true))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|4870| »   »   &&·(this.GetStance().respondChaseBeyondVision·||·this.CheckTargetIsInVisionRange(target))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5475| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|5778| »   »   »   »   »   »   &&·!MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.attack))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5781| »   »   »   »   »   »   &&·MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.avoid))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5794| »   var·targets·=·this.GetTargetsFromUnit();
|    | [NORMAL] JSHintBear:
|    | 'targets' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5795| »   for·(var·targ·of·targets)
|    | [NORMAL] JSHintBear:
|    | 'targ' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5801| »   »   »   var·cmpIdentity·=·Engine.QueryInterface(targ,·IID_Identity);
|    | [NORMAL] JSHintBear:
|    | 'cmpIdentity' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5802| »   »   »   var·targetClasses·=·this.order.data.targetClasses;
|    | [NORMAL] JSHintBear:
|    | 'targetClasses' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5804| »   »   »   »   &&·!MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.attack))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5807| »   »   »   »   &&·MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.avoid))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5995| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|6199| »   »   &&·this.GetCurrentState()·==·"FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1955/display/redirect

Freagarach accepted this revision.EditedApr 2 2020, 2:24 PM
  • Units move out of CHASING-state when target dies.
  • Only the switch in target is slightly seen due to an entity stopping momentarily, but thereafter it continues to run/walk towards the last target position, meaning minimal FOW information leaking. (This only concerns a forced order.)
  • Chasing behaviour is good, whilst hunting as well as during combat.
This revision is now accepted and ready to land.Apr 2 2020, 2:24 PM
Silier added inline comments.Apr 3 2020, 9:14 AM
binaries/data/mods/public/simulation/components/UnitAI.js
2200

this should be rewritten so no double check if obstructed, i missed that one

This revision was automatically updated to reflect the committed changes.