Page MenuHomeWildfire Games

Gather using ResourceGatherer instead of UnitAI.
Needs ReviewPublic

Authored by Freagarach on Mar 23 2020, 2:19 PM.

Details

Reviewers
wraitii
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Summary

This diff moves the logic for gathering from UnitAI to ResourceGatherer. It would make it easier to allow modders to let e.g. structures gather resources.

Downsides:

  • There are two timers per entity now, perhaps the one in UnitAI can be removed by checking the range in ResourceGatherer?
  • There is an extra message sent now, although not often.

(See also #4293.)

Test Plan

Verify that:

  • Normal gathering behaviour remains the same.
  • Gathering from moving targets is also still possible.
  • Back-to-work still works.

Event Timeline

Freagarach created this revision.Mar 23 2020, 2:19 PM
Freagarach added inline comments.Mar 23 2020, 2:47 PM
binaries/data/mods/public/simulation/components/UnitAI.js
2295–2300

Probably not needed anymore.

2342–2343

Can be removed.

2357

We could get it from the order data.

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

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

Freagarach updated this revision to Diff 11530.Mar 24 2020, 8:22 AM

Remove redundant variables in UnitAI.

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

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1887/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-extra-semi):
|    | Unnecessary semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
|  47|  47| 	cmpResourceGatherer = ConstructComponent(gathererID, "ResourceGatherer", template);
|  48|  48| 	cmpResourceGatherer.RecalculateGatherRatesAndCapacities(); // Force updating values.
|  49|  49| 	cmpTimer = ConstructComponent(SYSTEM_ENTITY, "Timer", {});
|  50|    |-};
|    |  50|+}
|  51|  51| 
|  52|  52| // General getters.
|  53|  53| TS_ASSERT_UNEVAL_EQUALS(cmpResourceGatherer.GetCarryingStatus(), []);
|    | [NORMAL] ESLintBear (no-extra-semi):
|    | Unnecessary semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
|  90|  90| 	});
|  91|  91| 
|  92|  92| 	TS_ASSERT(cmpResourceGatherer.TryInstantGather(supplyID));
|  93|    |-};
|    |  93|+}
|  94|  94| testTreasure();
|  95|  95| 
|  96|  96| function testNormalGathering()
|    | [NORMAL] ESLintBear (no-extra-semi):
|    | Unnecessary semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
| 154| 154| 		[{ "type": "food", "amount": 2, "max": 10 }]);
| 155| 155| 	TS_ASSERT(cmpResourceGatherer.IsCarrying("food"));
| 156| 156| 	TS_ASSERT(cmpResourceGatherer.CanCarryMore("food"));
| 157|    |-};
|    | 157|+}
| 158| 158| testNormalGathering();
| 159| 159| 
| 160| 160| function testSecondTypeDitchesFirst()
|    | [NORMAL] ESLintBear (no-extra-semi):
|    | Unnecessary semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
| 199| 199| 	TS_ASSERT(cmpResourceGatherer.CanCarryMore("food"));
| 200| 200| 	TS_ASSERT(cmpResourceGatherer.IsCarrying("wood"));
| 201| 201| 	TS_ASSERT(cmpResourceGatherer.CanCarryMore("wood"));
| 202|    |-};
|    | 202|+}
| 203| 203| testSecondTypeDitchesFirst();
| 204| 204| 
| 205| 205| function testStopIfExhausted()
|    | [NORMAL] ESLintBear (no-extra-semi):
|    | Unnecessary semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
| 224| 224| 	cmpTimer.OnUpdate({ "turnLength": 1 });
| 225| 225| 	TS_ASSERT_UNEVAL_EQUALS(cmpResourceGatherer.GetCarryingStatus(),
| 226| 226| 		[{ "type": "food", "amount": 1, "max": 10 }]);
| 227|    |-};
|    | 227|+}
| 228| 228| testStopIfExhausted();
| 229| 229| 
| 230| 230| function testStopIfFilled()
|    | [NORMAL] ESLintBear (no-extra-semi):
|    | Unnecessary semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
| 249| 249| 	cmpTimer.OnUpdate({ "turnLength": 1 });
| 250| 250| 	TS_ASSERT_UNEVAL_EQUALS(cmpResourceGatherer.GetCarryingStatus(),
| 251| 251| 		[{ "type": "food", "amount": 10, "max": 10 }]);
| 252|    |-};
|    | 252|+}
| 253| 253| testStopIfFilled();
| 254| 254| 
| 255| 255| function testAddingTwiceDoesntMatter()
|    | [NORMAL] ESLintBear (no-extra-semi):
|    | Unnecessary semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
| 281| 281| 	cmpTimer.OnUpdate({ "turnLength": 1 });
| 282| 282| 	TS_ASSERT_UNEVAL_EQUALS(cmpResourceGatherer.GetCarryingStatus(),
| 283| 283| 		[{ "type": "food", "amount": 4, "max": 10 }]);
| 284|    |-};
|    | 284|+}
| 285| 285| testAddingTwiceDoesntMatter();

binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
|  86| »   »   "TakeResources":·(value)·=>·{·return·{
|    | [NORMAL] ESLintBear (brace-rules/brace-on-same-line):
|    | Statement inside of curly braces should be on next line.

binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
| 135| »   »   "TakeResources":·(amount)·=>·{·return·{
|    | [NORMAL] ESLintBear (brace-rules/brace-on-same-line):
|    | Statement inside of curly braces should be on next line.

binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
| 168| »   »   "TakeResources":·(amount)·=>·{·return·{
|    | [NORMAL] ESLintBear (brace-rules/brace-on-same-line):
|    | Statement inside of curly braces should be on next line.

binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
| 186| »   »   "TakeResources":·(amount)·=>·{·return·{
|    | [NORMAL] ESLintBear (brace-rules/brace-on-same-line):
|    | Statement inside of curly braces should be on next line.

binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
| 213| »   »   "TakeResources":·(amount)·=>·{·return·{
|    | [NORMAL] ESLintBear (brace-rules/brace-on-same-line):
|    | Statement inside of curly braces should be on next line.

binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
| 238| »   »   "TakeResources":·(amount)·=>·{·return·{
|    | [NORMAL] ESLintBear (brace-rules/brace-on-same-line):
|    | Statement inside of curly braces should be on next line.

binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
| 263| »   »   "TakeResources":·(amount)·=>·{·return·{
|    | [NORMAL] ESLintBear (brace-rules/brace-on-same-line):
|    | Statement inside of curly braces should be on next line.

binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
|  50| };
|    | [NORMAL] JSHintBear:
|    | Unnecessary semicolon.

binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
|  93| };
|    | [NORMAL] JSHintBear:
|    | Unnecessary semicolon.

binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
| 157| };
|    | [NORMAL] JSHintBear:
|    | Unnecessary semicolon.

binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
| 202| };
|    | [NORMAL] JSHintBear:
|    | Unnecessary semicolon.

binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
| 227| };
|    | [NORMAL] JSHintBear:
|    | Unnecessary semicolon.

binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
| 252| };
|    | [NORMAL] JSHintBear:
|    | Unnecessary semicolon.

binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
| 284| };
|    | [NORMAL] JSHintBear:
|    | Unnecessary semicolon.
|    | [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
|2748|2748| 					{
|2749|2749| 						// The building was already finished/fully repaired before we arrived;
|2750|2750| 						// let the ConstructionFinished handler handle this.
|2751|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2751|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2752|2752| 						return true;
|2753|2753| 					}
|2754|2754| 
|    | [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
|2748|2748| 					{
|2749|2749| 						// The building was already finished/fully repaired before we arrived;
|2750|2750| 						// let the ConstructionFinished handler handle this.
|2751|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2751|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2752|2752| 						return true;
|2753|2753| 					}
|2754|2754| 
|    | [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
|3046|3046| 				this.StopTimer();
|3047|3047| 				this.ResetAnimation();
|3048|3048| 				if (this.formationAnimationVariant)
|3049|    |-					this.SetAnimationVariant(this.formationAnimationVariant)
|    |3049|+					this.SetAnimationVariant(this.formationAnimationVariant);
|3050|3050| 				else
|3051|3051| 					this.SetDefaultAnimationVariant();
|3052|3052| 				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
|3272|3272| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3273|3273| 
|3274|3274| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3275|    |-							// only used for domestic animals
|    |3275|+		// only used for domestic animals
|3276|3276| 
|3277|3277| 		// Reuse the same garrison behaviour for animals.
|3278|3278| 		"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
|3334|3334| 
|3335|3335| UnitAI.prototype.IsAnimal = function()
|3336|3336| {
|3337|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3337|+	return (!!this.template.NaturalBehaviour);
|3338|3338| };
|3339|3339| 
|3340|3340| 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
|3450|3450| 		{
|3451|3451| 			let index = this.GetCurrentState().indexOf(".");
|3452|3452| 			if (index != -1)
|3453|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3453|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3454|3454| 			this.Stop(false);
|3455|3455| 		}
|3456|3456| 
|    | [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
|3506|3506| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3507|3507| 			continue;
|3508|3508| 		if (i == 0)
|3509|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3509|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3510|3510| 		else
|3511|3511| 			this.orderQueue.splice(i, 1);
|3512|3512| 		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
|3506|3506| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3507|3507| 			continue;
|3508|3508| 		if (i == 0)
|3509|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3509|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3510|3510| 		else
|3511|3511| 			this.orderQueue.splice(i, 1);
|3512|3512| 		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
|3593|3593| };
|3594|3594| 
|3595|3595| 
|3596|    |-//// FSM linkage functions ////
|    |3596|+// // FSM linkage functions ////
|3597|3597| 
|3598|3598| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3599|3599| 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
|3764|3764| 				continue;
|3765|3765| 			if (this.orderQueue[i].type == type)
|3766|3766| 				continue;
|3767|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3767|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3768|3768| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3769|3769| 			return;
|3770|3770| 		}
|    | [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
|3764|3764| 				continue;
|3765|3765| 			if (this.orderQueue[i].type == type)
|3766|3766| 				continue;
|3767|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3767|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3768|3768| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3769|3769| 			return;
|3770|3770| 		}
|    | [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
|4006|4006| 	if (data.timerRepeat === undefined)
|4007|4007| 		this.timer = undefined;
|4008|4008| 
|4009|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4009|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|4010|4010| };
|4011|4011| 
|4012|4012| /**
|    | [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
|4006|4006| 	if (data.timerRepeat === undefined)
|4007|4007| 		this.timer = undefined;
|4008|4008| 
|4009|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4009|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|4010|4010| };
|4011|4011| 
|4012|4012| /**
|    | [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
|4051|4051| 	// TODO: This is a bit inefficient since every unit listens to every
|4052|4052| 	// construction message - ideally we could scope it to only the one we're building
|4053|4053| 
|4054|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4054|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|4055|4055| };
|4056|4056| 
|4057|4057| 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
|4051|4051| 	// TODO: This is a bit inefficient since every unit listens to every
|4052|4052| 	// construction message - ideally we could scope it to only the one we're building
|4053|4053| 
|4054|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4054|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|4055|4055| };
|4056|4056| 
|4057|4057| 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
|4082|4082| 	if (msg.fromStatusEffect)
|4083|4083| 		return;
|4084|4084| 
|4085|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4085|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|4086|4086| };
|4087|4087| 
|4088|4088| 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
|4082|4082| 	if (msg.fromStatusEffect)
|4083|4083| 		return;
|4084|4084| 
|4085|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4085|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|4086|4086| };
|4087|4087| 
|4088|4088| 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
|4087|4087| 
|4088|4088| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4089|4089| {
|4090|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4090|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|4091|4091| };
|4092|4092| 
|4093|4093| 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
|4087|4087| 
|4088|4088| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4089|4089| {
|4090|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4090|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|4091|4091| };
|4092|4092| 
|4093|4093| 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
|4092|4092| 
|4093|4093| UnitAI.prototype.OnHealthChanged = function(msg)
|4094|4094| {
|4095|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4095|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|4096|4096| };
|4097|4097| 
|4098|4098| 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
|4092|4092| 
|4093|4093| UnitAI.prototype.OnHealthChanged = function(msg)
|4094|4094| {
|4095|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4095|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|4096|4096| };
|4097|4097| 
|4098|4098| 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
|4098|4098| UnitAI.prototype.OnRangeUpdate = function(msg)
|4099|4099| {
|4100|4100| 	if (msg.tag == this.losRangeQuery)
|4101|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4101|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|4102|4102| 	else if (msg.tag == this.losHealRangeQuery)
|4103|4103| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4104|4104| };
|    | [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
|4098|4098| UnitAI.prototype.OnRangeUpdate = function(msg)
|4099|4099| {
|4100|4100| 	if (msg.tag == this.losRangeQuery)
|4101|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4101|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|4102|4102| 	else if (msg.tag == this.losHealRangeQuery)
|4103|4103| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4104|4104| };
|    | [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
|4100|4100| 	if (msg.tag == this.losRangeQuery)
|4101|4101| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4102|4102| 	else if (msg.tag == this.losHealRangeQuery)
|4103|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4103|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|4104|4104| };
|4105|4105| 
|4106|4106| 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
|4100|4100| 	if (msg.tag == this.losRangeQuery)
|4101|4101| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4102|4102| 	else if (msg.tag == this.losHealRangeQuery)
|4103|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4103|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|4104|4104| };
|4105|4105| 
|4106|4106| 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
|4105|4105| 
|4106|4106| UnitAI.prototype.OnPackFinished = function(msg)
|4107|4107| {
|4108|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4108|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|4109|4109| };
|4110|4110| 
|4111|4111| UnitAI.prototype.OnGatheringStateChanged = 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
|4105|4105| 
|4106|4106| UnitAI.prototype.OnPackFinished = function(msg)
|4107|4107| {
|4108|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4108|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|4109|4109| };
|4110|4110| 
|4111|4111| UnitAI.prototype.OnGatheringStateChanged = function(msg)
|    | [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
|4113|4113| 	this.UnitFsm.ProcessMessage(this, { "type": "GatheringStateChanged", "data": msg });
|4114|4114| };
|4115|4115| 
|4116|    |-//// Helper functions to be called by the FSM ////
|    |4116|+// // Helper functions to be called by the FSM ////
|4117|4117| 
|4118|4118| UnitAI.prototype.GetWalkSpeed = function()
|4119|4119| {
|    | [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
|4780|4780| UnitAI.prototype.AttackEntityInZone = function(ents)
|4781|4781| {
|4782|4782| 	var target = ents.find(target =>
|4783|    |-		this.CanAttack(target)
|4784|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4783|+		this.CanAttack(target) &&
|    |4784|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4785|4785| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4786|4786| 	);
|4787|4787| 	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
|4781|4781| {
|4782|4782| 	var target = ents.find(target =>
|4783|4783| 		this.CanAttack(target)
|4784|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4785|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4784|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4785|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4786|4786| 	);
|4787|4787| 	if (!target)
|4788|4788| 		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
|4845|4845| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|4846|4846| 	if (this.isGuardOf)
|4847|4847| 	{
|4848|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4848|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4849|4849| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4850|4850| 		if (cmpUnitAI && cmpAttack &&
|4851|4851| 		    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
|4849|4849| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4850|4850| 		if (cmpUnitAI && cmpAttack &&
|4851|4851| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|4852|    |-				return false;
|    |4852|+			return false;
|4853|4853| 	}
|4854|4854| 
|4855|4855| 	// 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
|4887|4887| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|4888|4888| 	if (this.isGuardOf)
|4889|4889| 	{
|4890|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4890|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4891|4891| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4892|4892| 		if (cmpUnitAI && cmpAttack &&
|4893|4893| 		    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
|4900|4900| 	return false;
|4901|4901| };
|4902|4902| 
|4903|    |-//// External interface functions ////
|    |4903|+// // External interface functions ////
|4904|4904| 
|4905|4905| UnitAI.prototype.SetFormationController = function(ent)
|4906|4906| {
|    | [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
|5056|5056| 	{
|5057|5057| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|5058|5058| 			return;
|5059|    |-		else
|5060|    |-			this.RemoveGuard();
|    |5059|+		this.RemoveGuard();
|5061|5060| 	}
|5062|5061| 
|5063|5062| 	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
|5387|5387| 
|5388|5388| 	if (this.IsFormationController())
|5389|5389| 		this.CallMemberFunction("CancelSetupTradeRoute", [target]);
|5390|    |-}
|    |5390|+};
|5391|5391| /**
|5392|5392|  * Adds trade order to the queue. Either walk to the first market, or
|5393|5393|  * 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
|5408|5408| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5409|5409| 	{
|5410|5410| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5411|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5411|+		if (cmpTrader.HasBothMarkets() &&
|5412|5412| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5413|5413| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5414|5414| 		{
|    | [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
|5689|5689| 				{
|5690|5690| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5691|5691| 					var targetClasses = this.order.data.targetClasses;
|5692|    |-					if (targetClasses.attack && cmpIdentity
|5693|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5692|+					if (targetClasses.attack && cmpIdentity &&
|    |5693|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5694|5694| 						continue;
|5695|5695| 					if (targetClasses.avoid && cmpIdentity
|5696|5696| 						&& 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
|5692|5692| 					if (targetClasses.attack && cmpIdentity
|5693|5693| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5694|5694| 						continue;
|5695|    |-					if (targetClasses.avoid && cmpIdentity
|5696|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5695|+					if (targetClasses.avoid && cmpIdentity &&
|    |5696|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5697|5697| 						continue;
|5698|5698| 					// Only used by the AIs to prevent some choices of targets
|5699|5699| 					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
|5715|5715| 		{
|5716|5716| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5717|5717| 			var targetClasses = this.order.data.targetClasses;
|5718|    |-			if (cmpIdentity && targetClasses.attack
|5719|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5718|+			if (cmpIdentity && targetClasses.attack &&
|    |5719|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5720|5720| 				continue;
|5721|5721| 			if (cmpIdentity && targetClasses.avoid
|5722|5722| 				&& 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
|5718|5718| 			if (cmpIdentity && targetClasses.attack
|5719|5719| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5720|5720| 				continue;
|5721|    |-			if (cmpIdentity && targetClasses.avoid
|5722|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5721|+			if (cmpIdentity && targetClasses.avoid &&
|    |5722|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5723|5723| 				continue;
|5724|5724| 			// Only used by the AIs to prevent some choices of targets
|5725|5725| 			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
|5861|5861| 
|5862|5862| UnitAI.prototype.SetHeldPosition = function(x, z)
|5863|5863| {
|5864|    |-	this.heldPosition = {"x": x, "z": z};
|    |5864|+	this.heldPosition = { "x": x, "z": z};
|5865|5865| };
|5866|5866| 
|5867|5867| 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
|5861|5861| 
|5862|5862| UnitAI.prototype.SetHeldPosition = function(x, z)
|5863|5863| {
|5864|    |-	this.heldPosition = {"x": x, "z": z};
|    |5864|+	this.heldPosition = {"x": x, "z": z };
|5865|5865| };
|5866|5866| 
|5867|5867| 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
|5888|5888| 	return false;
|5889|5889| };
|5890|5890| 
|5891|    |-//// Helper functions ////
|    |5891|+// // Helper functions ////
|5892|5892| 
|5893|5893| /**
|5894|5894|  * 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
|5907|5907| 		return undefined;
|5908|5908| 
|5909|5909| 	return component.GetRange(type);
|5910|    |-}
|    |5910|+};
|5911|5911| 
|5912|5912| UnitAI.prototype.CanAttack = function(target)
|5913|5913| {
|    | [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
|6105|6105| 	return cmpPack && cmpPack.IsPacking();
|6106|6106| };
|6107|6107| 
|6108|    |-//// Formation specific functions ////
|    |6108|+// // Formation specific functions ////
|6109|6109| 
|6110|6110| UnitAI.prototype.IsAttackingAsFormation = function()
|6111|6111| {
|    | [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
|6110|6110| UnitAI.prototype.IsAttackingAsFormation = function()
|6111|6111| {
|6112|6112| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|6113|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|6114|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |6113|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |6114|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6115|6115| };
|6116|6116| 
|6117|6117| //// 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
|6114|6114| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6115|6115| };
|6116|6116| 
|6117|    |-//// Animal specific functions ////
|    |6117|+// // Animal specific functions ////
|6118|6118| 
|6119|6119| UnitAI.prototype.MoveRandomly = function(distance)
|6120|6120| {

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
|3911| »   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
|4767| »   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
|4782| »   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
|4828| »   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
|4851| »   »   ····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
|3049| »   »   »   »   »   this.SetAnimationVariant(this.formationAnimationVariant)
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|4784| »   »   &&·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
|4785| »   »   &&·(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
|5390| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|5693| »   »   »   »   »   »   &&·!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
|5696| »   »   »   »   »   »   &&·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
|5709| »   var·targets·=·this.GetTargetsFromUnit();
|    | [NORMAL] JSHintBear:
|    | 'targets' is already defined.

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

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|5719| »   »   »   »   &&·!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
|5722| »   »   »   »   &&·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
|5910| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|6114| »   »   &&·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/1892/display/redirect

Freagarach edited the summary of this revision. (Show Details)Mar 24 2020, 8:23 PM
  • Linter issues.
  • Handle message in default.
  • Store target as INVALID_ENTITY when unused.

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
| 792| 792| 					this.FinishOrder();
| 793| 793| 					return;
| 794| 794| 				}
| 795|    |-				else
| 796|    |-				{
|    | 795|+				
| 797| 796| 					this.SetNextState("GARRISON.APPROACHING");
| 798| 797| 					return;
| 799|    |-				}
|    | 798|+				
| 800| 799| 			}
| 801| 800| 
| 802| 801| 			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
|1064|1064| 			},
|1065|1065| 		},
|1066|1066| 
|1067|    |-		"GARRISON":{
|    |1067|+		"GARRISON": {
|1068|1068| 			"APPROACHING": {
|1069|1069| 				"enter": function() {
|1070|1070| 					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
|2042|2042| 
|2043|2043| 				"Attacked": function(msg) {
|2044|2044| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|2045|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|2046|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |2045|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |2046|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|2047|2047| 						this.RespondToTargetedEntities([msg.data.attacker]);
|2048|2048| 				},
|2049|2049| 			},
|    | [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
|2738|2738| 					{
|2739|2739| 						// The building was already finished/fully repaired before we arrived;
|2740|2740| 						// let the ConstructionFinished handler handle this.
|2741|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2741|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2742|2742| 						return true;
|2743|2743| 					}
|2744|2744| 
|    | [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
|2738|2738| 					{
|2739|2739| 						// The building was already finished/fully repaired before we arrived;
|2740|2740| 						// let the ConstructionFinished handler handle this.
|2741|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2741|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2742|2742| 						return true;
|2743|2743| 					}
|2744|2744| 
|    | [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
|3036|3036| 				this.StopTimer();
|3037|3037| 				this.ResetAnimation();
|3038|3038| 				if (this.formationAnimationVariant)
|3039|    |-					this.SetAnimationVariant(this.formationAnimationVariant)
|    |3039|+					this.SetAnimationVariant(this.formationAnimationVariant);
|3040|3040| 				else
|3041|3041| 					this.SetDefaultAnimationVariant();
|3042|3042| 				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
|3262|3262| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3263|3263| 
|3264|3264| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3265|    |-							// only used for domestic animals
|    |3265|+		// only used for domestic animals
|3266|3266| 
|3267|3267| 		// Reuse the same garrison behaviour for animals.
|3268|3268| 		"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
|3324|3324| 
|3325|3325| UnitAI.prototype.IsAnimal = function()
|3326|3326| {
|3327|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3327|+	return (!!this.template.NaturalBehaviour);
|3328|3328| };
|3329|3329| 
|3330|3330| 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
|3440|3440| 		{
|3441|3441| 			let index = this.GetCurrentState().indexOf(".");
|3442|3442| 			if (index != -1)
|3443|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3443|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3444|3444| 			this.Stop(false);
|3445|3445| 		}
|3446|3446| 
|    | [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
|3496|3496| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3497|3497| 			continue;
|3498|3498| 		if (i == 0)
|3499|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3499|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3500|3500| 		else
|3501|3501| 			this.orderQueue.splice(i, 1);
|3502|3502| 		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
|3496|3496| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3497|3497| 			continue;
|3498|3498| 		if (i == 0)
|3499|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3499|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3500|3500| 		else
|3501|3501| 			this.orderQueue.splice(i, 1);
|3502|3502| 		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
|3583|3583| };
|3584|3584| 
|3585|3585| 
|3586|    |-//// FSM linkage functions ////
|    |3586|+// // FSM linkage functions ////
|3587|3587| 
|3588|3588| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3589|3589| 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
|3754|3754| 				continue;
|3755|3755| 			if (this.orderQueue[i].type == type)
|3756|3756| 				continue;
|3757|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3757|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3758|3758| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3759|3759| 			return;
|3760|3760| 		}
|    | [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
|3754|3754| 				continue;
|3755|3755| 			if (this.orderQueue[i].type == type)
|3756|3756| 				continue;
|3757|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3757|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3758|3758| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3759|3759| 			return;
|3760|3760| 		}
|    | [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
|3996|3996| 	if (data.timerRepeat === undefined)
|3997|3997| 		this.timer = undefined;
|3998|3998| 
|3999|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |3999|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|4000|4000| };
|4001|4001| 
|4002|4002| /**
|    | [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
|3996|3996| 	if (data.timerRepeat === undefined)
|3997|3997| 		this.timer = undefined;
|3998|3998| 
|3999|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |3999|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|4000|4000| };
|4001|4001| 
|4002|4002| /**
|    | [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
|4041|4041| 	// TODO: This is a bit inefficient since every unit listens to every
|4042|4042| 	// construction message - ideally we could scope it to only the one we're building
|4043|4043| 
|4044|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4044|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|4045|4045| };
|4046|4046| 
|4047|4047| 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
|4041|4041| 	// TODO: This is a bit inefficient since every unit listens to every
|4042|4042| 	// construction message - ideally we could scope it to only the one we're building
|4043|4043| 
|4044|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4044|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|4045|4045| };
|4046|4046| 
|4047|4047| 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
|4072|4072| 	if (msg.fromStatusEffect)
|4073|4073| 		return;
|4074|4074| 
|4075|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4075|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|4076|4076| };
|4077|4077| 
|4078|4078| 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
|4072|4072| 	if (msg.fromStatusEffect)
|4073|4073| 		return;
|4074|4074| 
|4075|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4075|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|4076|4076| };
|4077|4077| 
|4078|4078| 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
|4077|4077| 
|4078|4078| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4079|4079| {
|4080|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4080|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|4081|4081| };
|4082|4082| 
|4083|4083| 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
|4077|4077| 
|4078|4078| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4079|4079| {
|4080|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4080|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|4081|4081| };
|4082|4082| 
|4083|4083| 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
|4082|4082| 
|4083|4083| UnitAI.prototype.OnHealthChanged = function(msg)
|4084|4084| {
|4085|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4085|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|4086|4086| };
|4087|4087| 
|4088|4088| 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
|4082|4082| 
|4083|4083| UnitAI.prototype.OnHealthChanged = function(msg)
|4084|4084| {
|4085|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4085|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|4086|4086| };
|4087|4087| 
|4088|4088| 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
|4088|4088| UnitAI.prototype.OnRangeUpdate = function(msg)
|4089|4089| {
|4090|4090| 	if (msg.tag == this.losRangeQuery)
|4091|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4091|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|4092|4092| 	else if (msg.tag == this.losHealRangeQuery)
|4093|4093| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4094|4094| };
|    | [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
|4088|4088| UnitAI.prototype.OnRangeUpdate = function(msg)
|4089|4089| {
|4090|4090| 	if (msg.tag == this.losRangeQuery)
|4091|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4091|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|4092|4092| 	else if (msg.tag == this.losHealRangeQuery)
|4093|4093| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4094|4094| };
|    | [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 (msg.tag == this.losRangeQuery)
|4091|4091| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4092|4092| 	else if (msg.tag == this.losHealRangeQuery)
|4093|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4093|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|4094|4094| };
|4095|4095| 
|4096|4096| 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
|4090|4090| 	if (msg.tag == this.losRangeQuery)
|4091|4091| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4092|4092| 	else if (msg.tag == this.losHealRangeQuery)
|4093|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4093|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|4094|4094| };
|4095|4095| 
|4096|4096| 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
|4095|4095| 
|4096|4096| UnitAI.prototype.OnPackFinished = function(msg)
|4097|4097| {
|4098|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4098|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|4099|4099| };
|4100|4100| 
|4101|4101| UnitAI.prototype.OnGatheringStateChanged = 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
|4095|4095| 
|4096|4096| UnitAI.prototype.OnPackFinished = function(msg)
|4097|4097| {
|4098|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4098|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|4099|4099| };
|4100|4100| 
|4101|4101| UnitAI.prototype.OnGatheringStateChanged = function(msg)
|    | [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
|4103|4103| 	this.UnitFsm.ProcessMessage(this, { "type": "GatheringStateChanged", "data": msg });
|4104|4104| };
|4105|4105| 
|4106|    |-//// Helper functions to be called by the FSM ////
|    |4106|+// // Helper functions to be called by the FSM ////
|4107|4107| 
|4108|4108| UnitAI.prototype.GetWalkSpeed = function()
|4109|4109| {
|    | [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
|4770|4770| UnitAI.prototype.AttackEntityInZone = function(ents)
|4771|4771| {
|4772|4772| 	var target = ents.find(target =>
|4773|    |-		this.CanAttack(target)
|4774|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4773|+		this.CanAttack(target) &&
|    |4774|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4775|4775| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4776|4776| 	);
|4777|4777| 	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
|4771|4771| {
|4772|4772| 	var target = ents.find(target =>
|4773|4773| 		this.CanAttack(target)
|4774|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4775|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4774|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4775|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4776|4776| 	);
|4777|4777| 	if (!target)
|4778|4778| 		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
|4835|4835| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|4836|4836| 	if (this.isGuardOf)
|4837|4837| 	{
|4838|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4838|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4839|4839| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4840|4840| 		if (cmpUnitAI && cmpAttack &&
|4841|4841| 		    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
|4839|4839| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4840|4840| 		if (cmpUnitAI && cmpAttack &&
|4841|4841| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|4842|    |-				return false;
|    |4842|+			return false;
|4843|4843| 	}
|4844|4844| 
|4845|4845| 	// 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
|4877|4877| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|4878|4878| 	if (this.isGuardOf)
|4879|4879| 	{
|4880|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4880|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4881|4881| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4882|4882| 		if (cmpUnitAI && cmpAttack &&
|4883|4883| 		    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
|4890|4890| 	return false;
|4891|4891| };
|4892|4892| 
|4893|    |-//// External interface functions ////
|    |4893|+// // External interface functions ////
|4894|4894| 
|4895|4895| UnitAI.prototype.SetFormationController = function(ent)
|4896|4896| {
|    | [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
|5046|5046| 	{
|5047|5047| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|5048|5048| 			return;
|5049|    |-		else
|5050|    |-			this.RemoveGuard();
|    |5049|+		this.RemoveGuard();
|5051|5050| 	}
|5052|5051| 
|5053|5052| 	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
|5377|5377| 
|5378|5378| 	if (this.IsFormationController())
|5379|5379| 		this.CallMemberFunction("CancelSetupTradeRoute", [target]);
|5380|    |-}
|    |5380|+};
|5381|5381| /**
|5382|5382|  * Adds trade order to the queue. Either walk to the first market, or
|5383|5383|  * 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
|5398|5398| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5399|5399| 	{
|5400|5400| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5401|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5401|+		if (cmpTrader.HasBothMarkets() &&
|5402|5402| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5403|5403| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5404|5404| 		{
|    | [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
|5679|5679| 				{
|5680|5680| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5681|5681| 					var targetClasses = this.order.data.targetClasses;
|5682|    |-					if (targetClasses.attack && cmpIdentity
|5683|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5682|+					if (targetClasses.attack && cmpIdentity &&
|    |5683|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5684|5684| 						continue;
|5685|5685| 					if (targetClasses.avoid && cmpIdentity
|5686|5686| 						&& 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
|5682|5682| 					if (targetClasses.attack && cmpIdentity
|5683|5683| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5684|5684| 						continue;
|5685|    |-					if (targetClasses.avoid && cmpIdentity
|5686|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5685|+					if (targetClasses.avoid && cmpIdentity &&
|    |5686|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5687|5687| 						continue;
|5688|5688| 					// Only used by the AIs to prevent some choices of targets
|5689|5689| 					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
|5705|5705| 		{
|5706|5706| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5707|5707| 			var targetClasses = this.order.data.targetClasses;
|5708|    |-			if (cmpIdentity && targetClasses.attack
|5709|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5708|+			if (cmpIdentity && targetClasses.attack &&
|    |5709|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5710|5710| 				continue;
|5711|5711| 			if (cmpIdentity && targetClasses.avoid
|5712|5712| 				&& 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
|5708|5708| 			if (cmpIdentity && targetClasses.attack
|5709|5709| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5710|5710| 				continue;
|5711|    |-			if (cmpIdentity && targetClasses.avoid
|5712|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5711|+			if (cmpIdentity && targetClasses.avoid &&
|    |5712|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5713|5713| 				continue;
|5714|5714| 			// Only used by the AIs to prevent some choices of targets
|5715|5715| 			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
|5851|5851| 
|5852|5852| UnitAI.prototype.SetHeldPosition = function(x, z)
|5853|5853| {
|5854|    |-	this.heldPosition = {"x": x, "z": z};
|    |5854|+	this.heldPosition = { "x": x, "z": z};
|5855|5855| };
|5856|5856| 
|5857|5857| 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
|5851|5851| 
|5852|5852| UnitAI.prototype.SetHeldPosition = function(x, z)
|5853|5853| {
|5854|    |-	this.heldPosition = {"x": x, "z": z};
|    |5854|+	this.heldPosition = {"x": x, "z": z };
|5855|5855| };
|5856|5856| 
|5857|5857| 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
|5878|5878| 	return false;
|5879|5879| };
|5880|5880| 
|5881|    |-//// Helper functions ////
|    |5881|+// // Helper functions ////
|5882|5882| 
|5883|5883| /**
|5884|5884|  * 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
|5897|5897| 		return undefined;
|5898|5898| 
|5899|5899| 	return component.GetRange(type);
|5900|    |-}
|    |5900|+};
|5901|5901| 
|5902|5902| UnitAI.prototype.CanAttack = function(target)
|5903|5903| {
|    | [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
|6095|6095| 	return cmpPack && cmpPack.IsPacking();
|6096|6096| };
|6097|6097| 
|6098|    |-//// Formation specific functions ////
|    |6098|+// // Formation specific functions ////
|6099|6099| 
|6100|6100| UnitAI.prototype.IsAttackingAsFormation = function()
|6101|6101| {
|    | [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
|6100|6100| UnitAI.prototype.IsAttackingAsFormation = function()
|6101|6101| {
|6102|6102| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|6103|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|6104|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |6103|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |6104|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6105|6105| };
|6106|6106| 
|6107|6107| //// 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
|6104|6104| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6105|6105| };
|6106|6106| 
|6107|    |-//// Animal specific functions ////
|    |6107|+// // Animal specific functions ////
|6108|6108| 
|6109|6109| UnitAI.prototype.MoveRandomly = function(distance)
|6110|6110| {

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|3901| »   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
|4757| »   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
|4772| »   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
|4818| »   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
|4841| »   »   ····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
|2046| »   »   »   »   »   »   &&·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
|3039| »   »   »   »   »   this.SetAnimationVariant(this.formationAnimationVariant)
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|4774| »   »   &&·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
|4775| »   »   &&·(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
|5380| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|5683| »   »   »   »   »   »   &&·!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
|5686| »   »   »   »   »   »   &&·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
|5699| »   var·targets·=·this.GetTargetsFromUnit();
|    | [NORMAL] JSHintBear:
|    | 'targets' is already defined.

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

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|5709| »   »   »   »   &&·!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
|5712| »   »   »   »   &&·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
|5900| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|6104| »   »   &&·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/1914/display/redirect

Freagarach updated this revision to Diff 11577.Mar 27 2020, 9:32 AM

Send the stopped message only after invalidating the target.

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
| 792| 792| 					this.FinishOrder();
| 793| 793| 					return;
| 794| 794| 				}
| 795|    |-				else
| 796|    |-				{
|    | 795|+				
| 797| 796| 					this.SetNextState("GARRISON.APPROACHING");
| 798| 797| 					return;
| 799|    |-				}
|    | 798|+				
| 800| 799| 			}
| 801| 800| 
| 802| 801| 			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
|1064|1064| 			},
|1065|1065| 		},
|1066|1066| 
|1067|    |-		"GARRISON":{
|    |1067|+		"GARRISON": {
|1068|1068| 			"APPROACHING": {
|1069|1069| 				"enter": function() {
|1070|1070| 					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
|2042|2042| 
|2043|2043| 				"Attacked": function(msg) {
|2044|2044| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|2045|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|2046|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |2045|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |2046|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|2047|2047| 						this.RespondToTargetedEntities([msg.data.attacker]);
|2048|2048| 				},
|2049|2049| 			},
|    | [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
|2738|2738| 					{
|2739|2739| 						// The building was already finished/fully repaired before we arrived;
|2740|2740| 						// let the ConstructionFinished handler handle this.
|2741|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2741|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2742|2742| 						return true;
|2743|2743| 					}
|2744|2744| 
|    | [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
|2738|2738| 					{
|2739|2739| 						// The building was already finished/fully repaired before we arrived;
|2740|2740| 						// let the ConstructionFinished handler handle this.
|2741|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2741|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2742|2742| 						return true;
|2743|2743| 					}
|2744|2744| 
|    | [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
|3036|3036| 				this.StopTimer();
|3037|3037| 				this.ResetAnimation();
|3038|3038| 				if (this.formationAnimationVariant)
|3039|    |-					this.SetAnimationVariant(this.formationAnimationVariant)
|    |3039|+					this.SetAnimationVariant(this.formationAnimationVariant);
|3040|3040| 				else
|3041|3041| 					this.SetDefaultAnimationVariant();
|3042|3042| 				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
|3262|3262| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3263|3263| 
|3264|3264| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3265|    |-							// only used for domestic animals
|    |3265|+		// only used for domestic animals
|3266|3266| 
|3267|3267| 		// Reuse the same garrison behaviour for animals.
|3268|3268| 		"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
|3324|3324| 
|3325|3325| UnitAI.prototype.IsAnimal = function()
|3326|3326| {
|3327|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3327|+	return (!!this.template.NaturalBehaviour);
|3328|3328| };
|3329|3329| 
|3330|3330| 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
|3440|3440| 		{
|3441|3441| 			let index = this.GetCurrentState().indexOf(".");
|3442|3442| 			if (index != -1)
|3443|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3443|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3444|3444| 			this.Stop(false);
|3445|3445| 		}
|3446|3446| 
|    | [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
|3496|3496| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3497|3497| 			continue;
|3498|3498| 		if (i == 0)
|3499|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3499|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3500|3500| 		else
|3501|3501| 			this.orderQueue.splice(i, 1);
|3502|3502| 		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
|3496|3496| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3497|3497| 			continue;
|3498|3498| 		if (i == 0)
|3499|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3499|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3500|3500| 		else
|3501|3501| 			this.orderQueue.splice(i, 1);
|3502|3502| 		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
|3583|3583| };
|3584|3584| 
|3585|3585| 
|3586|    |-//// FSM linkage functions ////
|    |3586|+// // FSM linkage functions ////
|3587|3587| 
|3588|3588| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3589|3589| 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
|3754|3754| 				continue;
|3755|3755| 			if (this.orderQueue[i].type == type)
|3756|3756| 				continue;
|3757|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3757|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3758|3758| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3759|3759| 			return;
|3760|3760| 		}
|    | [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
|3754|3754| 				continue;
|3755|3755| 			if (this.orderQueue[i].type == type)
|3756|3756| 				continue;
|3757|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3757|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3758|3758| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3759|3759| 			return;
|3760|3760| 		}
|    | [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
|3996|3996| 	if (data.timerRepeat === undefined)
|3997|3997| 		this.timer = undefined;
|3998|3998| 
|3999|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |3999|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|4000|4000| };
|4001|4001| 
|4002|4002| /**
|    | [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
|3996|3996| 	if (data.timerRepeat === undefined)
|3997|3997| 		this.timer = undefined;
|3998|3998| 
|3999|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |3999|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|4000|4000| };
|4001|4001| 
|4002|4002| /**
|    | [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
|4041|4041| 	// TODO: This is a bit inefficient since every unit listens to every
|4042|4042| 	// construction message - ideally we could scope it to only the one we're building
|4043|4043| 
|4044|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4044|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|4045|4045| };
|4046|4046| 
|4047|4047| 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
|4041|4041| 	// TODO: This is a bit inefficient since every unit listens to every
|4042|4042| 	// construction message - ideally we could scope it to only the one we're building
|4043|4043| 
|4044|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4044|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|4045|4045| };
|4046|4046| 
|4047|4047| 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
|4072|4072| 	if (msg.fromStatusEffect)
|4073|4073| 		return;
|4074|4074| 
|4075|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4075|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|4076|4076| };
|4077|4077| 
|4078|4078| 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
|4072|4072| 	if (msg.fromStatusEffect)
|4073|4073| 		return;
|4074|4074| 
|4075|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4075|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|4076|4076| };
|4077|4077| 
|4078|4078| 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
|4077|4077| 
|4078|4078| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4079|4079| {
|4080|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4080|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|4081|4081| };
|4082|4082| 
|4083|4083| 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
|4077|4077| 
|4078|4078| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4079|4079| {
|4080|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4080|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|4081|4081| };
|4082|4082| 
|4083|4083| 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
|4082|4082| 
|4083|4083| UnitAI.prototype.OnHealthChanged = function(msg)
|4084|4084| {
|4085|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4085|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|4086|4086| };
|4087|4087| 
|4088|4088| 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
|4082|4082| 
|4083|4083| UnitAI.prototype.OnHealthChanged = function(msg)
|4084|4084| {
|4085|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4085|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|4086|4086| };
|4087|4087| 
|4088|4088| 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
|4088|4088| UnitAI.prototype.OnRangeUpdate = function(msg)
|4089|4089| {
|4090|4090| 	if (msg.tag == this.losRangeQuery)
|4091|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4091|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|4092|4092| 	else if (msg.tag == this.losHealRangeQuery)
|4093|4093| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4094|4094| };
|    | [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
|4088|4088| UnitAI.prototype.OnRangeUpdate = function(msg)
|4089|4089| {
|4090|4090| 	if (msg.tag == this.losRangeQuery)
|4091|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4091|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|4092|4092| 	else if (msg.tag == this.losHealRangeQuery)
|4093|4093| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4094|4094| };
|    | [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 (msg.tag == this.losRangeQuery)
|4091|4091| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4092|4092| 	else if (msg.tag == this.losHealRangeQuery)
|4093|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4093|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|4094|4094| };
|4095|4095| 
|4096|4096| 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
|4090|4090| 	if (msg.tag == this.losRangeQuery)
|4091|4091| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4092|4092| 	else if (msg.tag == this.losHealRangeQuery)
|4093|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4093|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|4094|4094| };
|4095|4095| 
|4096|4096| 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
|4095|4095| 
|4096|4096| UnitAI.prototype.OnPackFinished = function(msg)
|4097|4097| {
|4098|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4098|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|4099|4099| };
|4100|4100| 
|4101|4101| UnitAI.prototype.OnGatheringStateChanged = 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
|4095|4095| 
|4096|4096| UnitAI.prototype.OnPackFinished = function(msg)
|4097|4097| {
|4098|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4098|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|4099|4099| };
|4100|4100| 
|4101|4101| UnitAI.prototype.OnGatheringStateChanged = function(msg)
|    | [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
|4103|4103| 	this.UnitFsm.ProcessMessage(this, { "type": "GatheringStateChanged", "data": msg });
|4104|4104| };
|4105|4105| 
|4106|    |-//// Helper functions to be called by the FSM ////
|    |4106|+// // Helper functions to be called by the FSM ////
|4107|4107| 
|4108|4108| UnitAI.prototype.GetWalkSpeed = function()
|4109|4109| {
|    | [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
|4770|4770| UnitAI.prototype.AttackEntityInZone = function(ents)
|4771|4771| {
|4772|4772| 	var target = ents.find(target =>
|4773|    |-		this.CanAttack(target)
|4774|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4773|+		this.CanAttack(target) &&
|    |4774|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4775|4775| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4776|4776| 	);
|4777|4777| 	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
|4771|4771| {
|4772|4772| 	var target = ents.find(target =>
|4773|4773| 		this.CanAttack(target)
|4774|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4775|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4774|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4775|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4776|4776| 	);
|4777|4777| 	if (!target)
|4778|4778| 		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
|4835|4835| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|4836|4836| 	if (this.isGuardOf)
|4837|4837| 	{
|4838|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4838|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4839|4839| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4840|4840| 		if (cmpUnitAI && cmpAttack &&
|4841|4841| 		    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
|4839|4839| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4840|4840| 		if (cmpUnitAI && cmpAttack &&
|4841|4841| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|4842|    |-				return false;
|    |4842|+			return false;
|4843|4843| 	}
|4844|4844| 
|4845|4845| 	// 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
|4877|4877| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|4878|4878| 	if (this.isGuardOf)
|4879|4879| 	{
|4880|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4880|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4881|4881| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4882|4882| 		if (cmpUnitAI && cmpAttack &&
|4883|4883| 		    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
|4890|4890| 	return false;
|4891|4891| };
|4892|4892| 
|4893|    |-//// External interface functions ////
|    |4893|+// // External interface functions ////
|4894|4894| 
|4895|4895| UnitAI.prototype.SetFormationController = function(ent)
|4896|4896| {
|    | [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
|5046|5046| 	{
|5047|5047| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|5048|5048| 			return;
|5049|    |-		else
|5050|    |-			this.RemoveGuard();
|    |5049|+		this.RemoveGuard();
|5051|5050| 	}
|5052|5051| 
|5053|5052| 	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
|5377|5377| 
|5378|5378| 	if (this.IsFormationController())
|5379|5379| 		this.CallMemberFunction("CancelSetupTradeRoute", [target]);
|5380|    |-}
|    |5380|+};
|5381|5381| /**
|5382|5382|  * Adds trade order to the queue. Either walk to the first market, or
|5383|5383|  * 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
|5398|5398| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5399|5399| 	{
|5400|5400| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5401|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5401|+		if (cmpTrader.HasBothMarkets() &&
|5402|5402| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5403|5403| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5404|5404| 		{
|    | [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
|5679|5679| 				{
|5680|5680| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5681|5681| 					var targetClasses = this.order.data.targetClasses;
|5682|    |-					if (targetClasses.attack && cmpIdentity
|5683|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5682|+					if (targetClasses.attack && cmpIdentity &&
|    |5683|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5684|5684| 						continue;
|5685|5685| 					if (targetClasses.avoid && cmpIdentity
|5686|5686| 						&& 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
|5682|5682| 					if (targetClasses.attack && cmpIdentity
|5683|5683| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5684|5684| 						continue;
|5685|    |-					if (targetClasses.avoid && cmpIdentity
|5686|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5685|+					if (targetClasses.avoid && cmpIdentity &&
|    |5686|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5687|5687| 						continue;
|5688|5688| 					// Only used by the AIs to prevent some choices of targets
|5689|5689| 					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
|5705|5705| 		{
|5706|5706| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5707|5707| 			var targetClasses = this.order.data.targetClasses;
|5708|    |-			if (cmpIdentity && targetClasses.attack
|5709|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5708|+			if (cmpIdentity && targetClasses.attack &&
|    |5709|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5710|5710| 				continue;
|5711|5711| 			if (cmpIdentity && targetClasses.avoid
|5712|5712| 				&& 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
|5708|5708| 			if (cmpIdentity && targetClasses.attack
|5709|5709| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5710|5710| 				continue;
|5711|    |-			if (cmpIdentity && targetClasses.avoid
|5712|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5711|+			if (cmpIdentity && targetClasses.avoid &&
|    |5712|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5713|5713| 				continue;
|5714|5714| 			// Only used by the AIs to prevent some choices of targets
|5715|5715| 			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
|5851|5851| 
|5852|5852| UnitAI.prototype.SetHeldPosition = function(x, z)
|5853|5853| {
|5854|    |-	this.heldPosition = {"x": x, "z": z};
|    |5854|+	this.heldPosition = { "x": x, "z": z};
|5855|5855| };
|5856|5856| 
|5857|5857| 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
|5851|5851| 
|5852|5852| UnitAI.prototype.SetHeldPosition = function(x, z)
|5853|5853| {
|5854|    |-	this.heldPosition = {"x": x, "z": z};
|    |5854|+	this.heldPosition = {"x": x, "z": z };
|5855|5855| };
|5856|5856| 
|5857|5857| 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
|5878|5878| 	return false;
|5879|5879| };
|5880|5880| 
|5881|    |-//// Helper functions ////
|    |5881|+// // Helper functions ////
|5882|5882| 
|5883|5883| /**
|5884|5884|  * 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
|5897|5897| 		return undefined;
|5898|5898| 
|5899|5899| 	return component.GetRange(type);
|5900|    |-}
|    |5900|+};
|5901|5901| 
|5902|5902| UnitAI.prototype.CanAttack = function(target)
|5903|5903| {
|    | [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
|6095|6095| 	return cmpPack && cmpPack.IsPacking();
|6096|6096| };
|6097|6097| 
|6098|    |-//// Formation specific functions ////
|    |6098|+// // Formation specific functions ////
|6099|6099| 
|6100|6100| UnitAI.prototype.IsAttackingAsFormation = function()
|6101|6101| {
|    | [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
|6100|6100| UnitAI.prototype.IsAttackingAsFormation = function()
|6101|6101| {
|6102|6102| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|6103|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|6104|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |6103|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |6104|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6105|6105| };
|6106|6106| 
|6107|6107| //// 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
|6104|6104| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6105|6105| };
|6106|6106| 
|6107|    |-//// Animal specific functions ////
|    |6107|+// // Animal specific functions ////
|6108|6108| 
|6109|6109| UnitAI.prototype.MoveRandomly = function(distance)
|6110|6110| {

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|3901| »   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
|4757| »   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
|4772| »   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
|4818| »   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
|4841| »   »   ····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
|2046| »   »   »   »   »   »   &&·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
|3039| »   »   »   »   »   this.SetAnimationVariant(this.formationAnimationVariant)
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|4774| »   »   &&·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
|4775| »   »   &&·(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
|5380| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|5683| »   »   »   »   »   »   &&·!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
|5686| »   »   »   »   »   »   &&·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
|5699| »   var·targets·=·this.GetTargetsFromUnit();
|    | [NORMAL] JSHintBear:
|    | 'targets' is already defined.

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

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|5709| »   »   »   »   &&·!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
|5712| »   »   »   »   &&·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
|5900| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|6104| »   »   &&·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/1929/display/redirect

Freagarach edited the test plan for this revision. (Show Details)Mar 27 2020, 9:42 AM
bb added a subscriber: bb.May 16 2020, 6:10 PM
bb added inline comments.
binaries/data/mods/public/simulation/components/UnitAI.js
2349

Don't like the fact we have two timers running now. Since this patch will set the defaults for many future patches we have to think about the design.

Wouldn't it be much cleaner if the gather components sends a message when it is out of range? Then unitAI can decide how to act upon that. This also allows (in theory) for "multi-actions" (e.g. walking and gathering) since in that case we can simply ignore the out of range messages.

2354–2355

This sounds like useless, we should check whether we can gather from a target anyway, when approaching an old target (the target can exhaust too while returning the resource)

binaries/data/mods/public/simulation/components/tests/test_ResourceGatherer.js
79

"GetType": () => ({ "generic": "bogus" })

wraitii added inline comments.
binaries/data/mods/public/simulation/components/UnitAI.js
2349

It is also possible to "soft code" a dependency on unitAI, by fetching the component and calling ProcessMessage directly. This is probably better when we want to have a channel between two components only.

Can't comment on the rest so far, but I need to look at this patch.

Freagarach updated this revision to Diff 11919.EditedMay 18 2020, 8:35 PM
Freagarach marked 2 inline comments as done.
  • Move range check to cmpResourceGatherer.
  • Change test.
  • Remove most logic from UnitAI-timer.

Questions:

  • Should the range check become a global? For we're going to use it for more components.
  • The animation to use sounds like it belongs in the cmpResourceGatherer as well?
  • UnitAI Still needs a timer to turn towards the target? Or we ought to check the rotation in cmpResourceGatherer as well.

ToDo:

  • Direct call to UnitAI for performance reasons.

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
| 792| 792| 					this.FinishOrder();
| 793| 793| 					return;
| 794| 794| 				}
| 795|    |-				else
| 796|    |-				{
|    | 795|+				
| 797| 796| 					this.SetNextState("GARRISON.APPROACHING");
| 798| 797| 					return;
| 799|    |-				}
|    | 798|+				
| 800| 799| 			}
| 801| 800| 
| 802| 801| 			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
|1064|1064| 			},
|1065|1065| 		},
|1066|1066| 
|1067|    |-		"GARRISON":{
|    |1067|+		"GARRISON": {
|1068|1068| 			"APPROACHING": {
|1069|1069| 				"enter": function() {
|1070|1070| 					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
|2046|2046| 
|2047|2047| 				"Attacked": function(msg) {
|2048|2048| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|2049|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|2050|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |2049|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |2050|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|2051|2051| 						this.RespondToTargetedEntities([msg.data.attacker]);
|2052|2052| 				},
|2053|2053| 			},
|    | [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
|2205|2205| 					"MovementUpdate": function(msg) {
|2206|2206| 						// If it looks like the path is failing, and we are close enough (3 tiles) from wanted range
|2207|2207| 						// stop anyways. This avoids pathing for an unreachable goal and reduces lag considerably.
|2208|    |-						if (msg.likelyFailure || 
|    |2208|+						if (msg.likelyFailure ||
|2209|2209| 							msg.obstructed && this.RelaxedMaxRangeCheck(this.order.data, this.order.data.max + this.DefaultRelaxedMaxRange) ||
|2210|2210| 							!msg.obstructed && this.CheckRange(this.order.data))
|2211|2211| 							this.FinishOrder();
|    | [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 (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3082|3082| 				this.StopTimer();
|3083|3083| 				this.ResetAnimation();
|3084|3084| 				if (this.formationAnimationVariant)
|3085|    |-					this.SetAnimationVariant(this.formationAnimationVariant)
|    |3085|+					this.SetAnimationVariant(this.formationAnimationVariant);
|3086|3086| 				else
|3087|3087| 					this.SetDefaultAnimationVariant();
|3088|3088| 				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
|3308|3308| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3309|3309| 
|3310|3310| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3311|    |-							// only used for domestic animals
|    |3311|+		// only used for domestic animals
|3312|3312| 
|3313|3313| 		// Reuse the same garrison behaviour for animals.
|3314|3314| 		"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
|3370|3370| 
|3371|3371| UnitAI.prototype.IsAnimal = function()
|3372|3372| {
|3373|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3373|+	return (!!this.template.NaturalBehaviour);
|3374|3374| };
|3375|3375| 
|3376|3376| 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
|3486|3486| 		{
|3487|3487| 			let index = this.GetCurrentState().indexOf(".");
|3488|3488| 			if (index != -1)
|3489|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3489|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3490|3490| 			this.Stop(false);
|3491|3491| 		}
|3492|3492| 
|    | [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
|3542|3542| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3543|3543| 			continue;
|3544|3544| 		if (i == 0)
|3545|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3545|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3546|3546| 		else
|3547|3547| 			this.orderQueue.splice(i, 1);
|3548|3548| 		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
|3542|3542| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3543|3543| 			continue;
|3544|3544| 		if (i == 0)
|3545|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3545|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3546|3546| 		else
|3547|3547| 			this.orderQueue.splice(i, 1);
|3548|3548| 		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
|3629|3629| };
|3630|3630| 
|3631|3631| 
|3632|    |-//// FSM linkage functions ////
|    |3632|+// // FSM linkage functions ////
|3633|3633| 
|3634|3634| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3635|3635| 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
|3800|3800| 				continue;
|3801|3801| 			if (this.orderQueue[i].type == type)
|3802|3802| 				continue;
|3803|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3803|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3804|3804| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3805|3805| 			return;
|3806|3806| 		}
|    | [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
|3800|3800| 				continue;
|3801|3801| 			if (this.orderQueue[i].type == type)
|3802|3802| 				continue;
|3803|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3803|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3804|3804| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3805|3805| 			return;
|3806|3806| 		}
|    | [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
|4042|4042| 	if (data.timerRepeat === undefined)
|4043|4043| 		this.timer = undefined;
|4044|4044| 
|4045|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4045|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|4046|4046| };
|4047|4047| 
|4048|4048| /**
|    | [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
|4042|4042| 	if (data.timerRepeat === undefined)
|4043|4043| 		this.timer = undefined;
|4044|4044| 
|4045|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4045|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|4046|4046| };
|4047|4047| 
|4048|4048| /**
|    | [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| 	// TODO: This is a bit inefficient since every unit listens to every
|4088|4088| 	// construction message - ideally we could scope it to only the one we're building
|4089|4089| 
|4090|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4090|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|4091|4091| };
|4092|4092| 
|4093|4093| 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
|4087|4087| 	// TODO: This is a bit inefficient since every unit listens to every
|4088|4088| 	// construction message - ideally we could scope it to only the one we're building
|4089|4089| 
|4090|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4090|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|4091|4091| };
|4092|4092| 
|4093|4093| 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
|4118|4118| 	if (msg.fromStatusEffect)
|4119|4119| 		return;
|4120|4120| 
|4121|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4121|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|4122|4122| };
|4123|4123| 
|4124|4124| 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
|4118|4118| 	if (msg.fromStatusEffect)
|4119|4119| 		return;
|4120|4120| 
|4121|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4121|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|4122|4122| };
|4123|4123| 
|4124|4124| 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
|4123|4123| 
|4124|4124| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4125|4125| {
|4126|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4126|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|4127|4127| };
|4128|4128| 
|4129|4129| 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
|4123|4123| 
|4124|4124| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4125|4125| {
|4126|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4126|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|4127|4127| };
|4128|4128| 
|4129|4129| 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
|4128|4128| 
|4129|4129| UnitAI.prototype.OnHealthChanged = function(msg)
|4130|4130| {
|4131|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4131|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|4132|4132| };
|4133|4133| 
|4134|4134| 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
|4128|4128| 
|4129|4129| UnitAI.prototype.OnHealthChanged = function(msg)
|4130|4130| {
|4131|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4131|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|4132|4132| };
|4133|4133| 
|4134|4134| 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
|4134|4134| UnitAI.prototype.OnRangeUpdate = function(msg)
|4135|4135| {
|4136|4136| 	if (msg.tag == this.losRangeQuery)
|4137|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4137|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|4138|4138| 	else if (msg.tag == this.losHealRangeQuery)
|4139|4139| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4140|4140| };
|    | [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
|4134|4134| UnitAI.prototype.OnRangeUpdate = function(msg)
|4135|4135| {
|4136|4136| 	if (msg.tag == this.losRangeQuery)
|4137|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4137|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|4138|4138| 	else if (msg.tag == this.losHealRangeQuery)
|4139|4139| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4140|4140| };
|    | [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
|4136|4136| 	if (msg.tag == this.losRangeQuery)
|4137|4137| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4138|4138| 	else if (msg.tag == this.losHealRangeQuery)
|4139|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4139|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|4140|4140| };
|4141|4141| 
|4142|4142| 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
|4136|4136| 	if (msg.tag == this.losRangeQuery)
|4137|4137| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4138|4138| 	else if (msg.tag == this.losHealRangeQuery)
|4139|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4139|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|4140|4140| };
|4141|4141| 
|4142|4142| 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
|4141|4141| 
|4142|4142| UnitAI.prototype.OnPackFinished = function(msg)
|4143|4143| {
|4144|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4144|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|4145|4145| };
|4146|4146| 
|4147|4147| UnitAI.prototype.OnGatheringStopped = 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| 
|4142|4142| UnitAI.prototype.OnPackFinished = function(msg)
|4143|4143| {
|4144|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4144|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|4145|4145| };
|4146|4146| 
|4147|4147| UnitAI.prototype.OnGatheringStopped = function(msg)
|    | [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
|4149|4149| 	this.UnitFsm.ProcessMessage(this, { "type": "GatheringStopped", "data": msg });
|4150|4150| };
|4151|4151| 
|4152|    |-//// Helper functions to be called by the FSM ////
|    |4152|+// // Helper functions to be called by the FSM ////
|4153|4153| 
|4154|4154| UnitAI.prototype.GetWalkSpeed = function()
|4155|4155| {
|    | [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
|4861|4861| UnitAI.prototype.AttackEntityInZone = function(ents)
|4862|4862| {
|4863|4863| 	var target = ents.find(target =>
|4864|    |-		this.CanAttack(target)
|4865|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4864|+		this.CanAttack(target) &&
|    |4865|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4866|4866| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4867|4867| 	);
|4868|4868| 	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
|4862|4862| {
|4863|4863| 	var target = ents.find(target =>
|4864|4864| 		this.CanAttack(target)
|4865|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4866|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4865|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4866|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4867|4867| 	);
|4868|4868| 	if (!target)
|4869|4869| 		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
|4928|4928| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|4929|4929| 	if (this.isGuardOf)
|4930|4930| 	{
|4931|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4931|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4932|4932| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4933|4933| 		if (cmpUnitAI && cmpAttack &&
|4934|4934| 		    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
|4932|4932| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4933|4933| 		if (cmpUnitAI && cmpAttack &&
|4934|4934| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|4935|    |-				return false;
|    |4935|+			return false;
|4936|4936| 	}
|4937|4937| 
|4938|4938| 	// 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
|4970|4970| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|4971|4971| 	if (this.isGuardOf)
|4972|4972| 	{
|4973|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4973|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4974|4974| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4975|4975| 		if (cmpUnitAI && cmpAttack &&
|4976|4976| 		    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
|4983|4983| 	return false;
|4984|4984| };
|4985|4985| 
|4986|    |-//// External interface functions ////
|    |4986|+// // External interface functions ////
|4987|4987| 
|4988|4988| UnitAI.prototype.SetFormationController = function(ent)
|4989|4989| {
|    | [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
|5139|5139| 	{
|5140|5140| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|5141|5141| 			return;
|5142|    |-		else
|5143|    |-			this.RemoveGuard();
|    |5142|+		this.RemoveGuard();
|5144|5143| 	}
|5145|5144| 
|5146|5145| 	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
|5470|5470| 
|5471|5471| 	if (this.IsFormationController())
|5472|5472| 		this.CallMemberFunction("CancelSetupTradeRoute", [target]);
|5473|    |-}
|    |5473|+};
|5474|5474| /**
|5475|5475|  * Adds trade order to the queue. Either walk to the first market, or
|5476|5476|  * 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
|5491|5491| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5492|5492| 	{
|5493|5493| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5494|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5494|+		if (cmpTrader.HasBothMarkets() &&
|5495|5495| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5496|5496| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5497|5497| 		{
|    | [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
|5772|5772| 				{
|5773|5773| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5774|5774| 					var targetClasses = this.order.data.targetClasses;
|5775|    |-					if (targetClasses.attack && cmpIdentity
|5776|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5775|+					if (targetClasses.attack && cmpIdentity &&
|    |5776|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5777|5777| 						continue;
|5778|5778| 					if (targetClasses.avoid && cmpIdentity
|5779|5779| 						&& 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
|5775|5775| 					if (targetClasses.attack && cmpIdentity
|5776|5776| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5777|5777| 						continue;
|5778|    |-					if (targetClasses.avoid && cmpIdentity
|5779|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5778|+					if (targetClasses.avoid && cmpIdentity &&
|    |5779|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5780|5780| 						continue;
|5781|5781| 					// Only used by the AIs to prevent some choices of targets
|5782|5782| 					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
|5798|5798| 		{
|5799|5799| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5800|5800| 			var targetClasses = this.order.data.targetClasses;
|5801|    |-			if (cmpIdentity && targetClasses.attack
|5802|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5801|+			if (cmpIdentity && targetClasses.attack &&
|    |5802|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5803|5803| 				continue;
|5804|5804| 			if (cmpIdentity && targetClasses.avoid
|5805|5805| 				&& 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
|5801|5801| 			if (cmpIdentity && targetClasses.attack
|5802|5802| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5803|5803| 				continue;
|5804|    |-			if (cmpIdentity && targetClasses.avoid
|5805|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5804|+			if (cmpIdentity && targetClasses.avoid &&
|    |5805|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5806|5806| 				continue;
|5807|5807| 			// Only used by the AIs to prevent some choices of targets
|5808|5808| 			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
|5944|5944| 
|5945|5945| UnitAI.prototype.SetHeldPosition = function(x, z)
|5946|5946| {
|5947|    |-	this.heldPosition = {"x": x, "z": z};
|    |5947|+	this.heldPosition = { "x": x, "z": z};
|5948|5948| };
|5949|5949| 
|5950|5950| 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
|5944|5944| 
|5945|5945| UnitAI.prototype.SetHeldPosition = function(x, z)
|5946|5946| {
|5947|    |-	this.heldPosition = {"x": x, "z": z};
|    |5947|+	this.heldPosition = {"x": x, "z": z };
|5948|5948| };
|5949|5949| 
|5950|5950| 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
|5971|5971| 	return false;
|5972|5972| };
|5973|5973| 
|5974|    |-//// Helper functions ////
|    |5974|+// // Helper functions ////
|5975|5975| 
|5976|5976| /**
|5977|5977|  * 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
|5990|5990| 		return undefined;
|5991|5991| 
|5992|5992| 	return component.GetRange(type);
|5993|    |-}
|    |5993|+};
|5994|5994| 
|5995|5995| UnitAI.prototype.CanAttack = function(target)
|5996|5996| {
|    | [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
|6158|6158| 	return cmpPack && cmpPack.IsPacking();
|6159|6159| };
|6160|6160| 
|6161|    |-//// Formation specific functions ////
|    |6161|+// // Formation specific functions ////
|6162|6162| 
|6163|6163| UnitAI.prototype.IsAttackingAsFormation = function()
|6164|6164| {
|    | [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
|6163|6163| UnitAI.prototype.IsAttackingAsFormation = function()
|6164|6164| {
|6165|6165| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|6166|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|6167|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |6166|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |6167|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6168|6168| };
|6169|6169| 
|6170|6170| //// 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
|6167|6167| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6168|6168| };
|6169|6169| 
|6170|    |-//// Animal specific functions ////
|    |6170|+// // Animal specific functions ////
|6171|6171| 
|6172|6172| UnitAI.prototype.MoveRandomly = function(distance)
|6173|6173| {

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|3947| »   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
|4848| »   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
|4863| »   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
|4911| »   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
|4934| »   »   ····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
|2050| »   »   »   »   »   »   &&·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
|3085| »   »   »   »   »   this.SetAnimationVariant(this.formationAnimationVariant)
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|4865| »   »   &&·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
|4866| »   »   &&·(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
|5473| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|5776| »   »   »   »   »   »   &&·!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
|5779| »   »   »   »   »   »   &&·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
|5792| »   var·targets·=·this.GetTargetsFromUnit();
|    | [NORMAL] JSHintBear:
|    | 'targets' is already defined.

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

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|5802| »   »   »   »   &&·!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
|5805| »   »   »   »   &&·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
|5993| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|6167| »   »   &&·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/2158/display/redirect

wraitii requested changes to this revision.May 21 2020, 2:36 PM

I like the idea of trying to make unitAI easier to reason about, and thanks for even trying this out :)
That being said, my initial reaction was "no, this isn' t it".
Then I wrote this review saying why, and now... Now I'm less sure. I think you do need to rework some of this, and I'd remove the timer & message thing from there for sure, at least for now.


My main concern is that it now requires reading two files to understand what happens in unitAI instead of one, which doesn't seem like much of an improvement.


To recap the big picture:

  • We have ResourceGatherer, a component that grants the ability to an entity to "gather from a resource" (i.e. take resources from the resource-supply-entity, and give them to a player).
  • We have UnitAI, a component that deals with 'clever' AI; i.e. deciding what to do exactly in a given order/state.

I think you'll agree that, technically, being a ResourceGatherer does not require Unit AI and vice-versa. A building could gather resources in its vicinity. A unit can be unable to gather resources.

Currently, ResourceGatherer only deals with actual gathering-related tasks: calculating gather rates, giving resources to a player, gathering resources (i.e. taking them from target resource-supply into our carrying capacity). (On a sidenote, the carrying capacity could be abstracted away in an Inventory component for a more RPG-like game.)
Unit AI deals with things such as deciding what to do when the entity can't gather from a given target, and so on. These are similar to attacking AI, except for gathering.

If we want to split this in very basic components, the question of "Can I gather X" is ResourceGatherer material, the question of "If I can't gather X, what do I do?" is UnitAI material.

Taking StartGathering as an example, we have a few failures cases and corresponding returns (some are intertwined):

  1. Do we have an owner?
  2. Is the target a resource supply?
  3. Is there room for a new gatherer?
  4. Do we have gather rates (= can we gather) from this supply.
  5. Is this an instant-gathering-resource?

Let's break it down:

  • 1> why are there owner checks here? What has that got to do with gathering?
    • The answer BTW is that the ownership check should really be directly in ResourceSupply.prototype.AddGatherer and not an argument. This is poor design in ResourceSupply and should be fixed there. I know because I've committed this...
  • 2> OK, this is a ResourceGatherer concern.
  • 3> Trickier, but I guess OK.
  • 4> OK, this is a ResourceGatherer concern.
  • 5> ??? This doesn't _seem_ like it should prevent "start gathering" at all :p. Seems more of a unitAI thing, but really seems more like this whole needs refactoring.

Anyways, I think you'd agree that we might want a unit to react differently on each of these failure cases. Now, with your patch, you'd have to return different "enum-like" values, and check in UnitAI. That would be cleaner, but this is javascript and we don't have enum types, and passing strings seems sub-optimal. Putting UnitAI code in ResourceGatherer is a no-no anyways (though you don't. But your new version is inflexible).
I feel like, as a "middle-ground", you might want to make mini-functions for each concern, and call those from unitAI instead. Or, as I also suggest below, perhaps pass lambdas for each failure case ? Then unitAI concerns are written in unitAI, resourceGatherer concerns there, and there's still no need to check two files to see what happens.

Further, those all look more fit for a "CanGather" function than for a "StartGathering" function anyways.


With that being said, one could argue that PerformGather should handle its preconditions (range check, ...). But as said above, we want to react differently in UnitAI, and doing them both is not acceptable, performance wise. And we run in the enum-issue again...
Maybe there's something clever to do with lambdas and arguments for each failure cases.


On specifically the timer. If you strip away the setup/cleanup, and the "can gather" functions, there's not much left. I understand why you'd want to put this in the component instead of unitAI, since as I said in introduction you could gather with no unitAI, but given that you have to call unitAI-Timer anyways, it seems wasteful.
If we had units that could passively gather resources, then it'd make sense (and it would, indeed, be necessary), but at the moment it doesn't seem that useful, and it forces you to do the awkward "gathering stopped" message thing.


I wager that you can actually implement your tests in the UnitAI FSM quite easily. I would actually invite you to try it, as more tests for UnitAI sounds good :) .

This revision now requires changes to proceed.May 21 2020, 2:36 PM
bb added a comment.May 21 2020, 3:27 PM

The design I have in mind is the following:
UnitAI chooses "cleverly" what the unit is doing, other components perform the tasks.
UnitAI should be allowed to let several components perform different tasks (i.e. unitAI could allow a unit to attack and walk at the same moment).
UnitAI can be replaced by BuildingAI, turretAI and whatnot, but all those should be able to access the same "other components" and let them perform the tasks (otherAI components just choose differently what tasks are done)

For this most timers in UnitAI should be moved to specific components, since different components want different timers. Now the components will report back to unitAI in case there is a problem (targetOutOfRange, targetDeath, etc). The unitAI will process this message and act on that (this can be some arbitrary function, ignoring is allowed too). Having 1 handler function (GatheringStopped) seems sub-ideal (I think wraitii and me agree on this), I would propose to have a function for each type of problem and call that instead. However I am open for other solutions (passing the handler functions in some object when calling "startGather" is another option).

WRT the two file problem: IMO that isn't changed by this patch, yes things are moved, but one needed to read two files anyway. unitAI was calling Gather, so to know that unitAI does one needs to read gather too.

binaries/data/mods/public/simulation/components/UnitAI.js
2378–2379

This is a pain, might be good to have a function in the position component that follows the rotation of a unit (so it faces keeps facing to a target whatever movement is present). Needs some proper design there probably

UnitAI should be allowed to let several components perform different tasks (i.e. unitAI could allow a unit to attack and walk at the same moment).

This is equivalent to switching unitAI to a multiple-state FSM, and running multiple timers there.

UnitAI can be replaced by BuildingAI, turretAI and whatnot, but all those should be able to access the same "other components" and let them perform the tasks (otherAI components just choose differently what tasks are done)

This is equivalent to all being the same multiple-state FSM, with FSM states being defined in the components instead of unitAI.

I would prefer an explicit multiple-state FSM over a single unitAI and timers in all components, that sounds like a mess. I've implemented that for https://github.com/wraitii/Nomads/tree/master/source and it worked rather well.

That being said, there not that many states that make sense at once. Gathering _and_ attacking? Does your entity have 2 heads :p ? Sub-entities might tackle a number of these issues anyways, by de-facto allowing a multiple-state FSM.

I think timers in every component adds complexity for the usual case, which will still be "units are in one state at a time", and the added complexity doesn't seem worth it to me. I would prefer to first clean up the rest, and then perhaps start considering that.


I think wraitii and me agree on this

We do.

I would propose to have a function for each type of problem and call that instead. However I am open for other solutions (passing the handler functions in some object when calling "startGather" is another option).

I'm also open to both. I think performance should be the biggest concern here.

WRT the two file problem: IMO that isn't changed by this patch, yes things are moved, but one needed to read two files anyway. unitAI was calling Gather, so to know that unitAI does one needs to read gather too.

Well, you could more easily abstract what "PerformGather" was doing than what "StartGathering" is now doing. Though it that is split in multiple functions, I think the problem goes away to an extent.

First of all, both of you thanks for looking into this!

Multiple files: I think it makes the distinction clearer now. Want to know what UnitAI does? Look in UnitAI. Want to know what an entity does when gathering? Look in ResourceGatherer. Or at least that is the goal of the patch, it is by no means perfect yet ^^

Instant gathering is more of a resource gatherer thing, that should be in the timer actually. As far as UnitAI is concerned it is just a resource supply that happens to be emptied immediately. (Refs. rP8670.)

Anyways, I think you'd agree that we might want a unit to react differently on each of these failure cases.

Do we? For UnitAI those cases (1-4) seem equal: We can't gather from this target.
I think those checks in StartGathering should return just false.

I also think the one GatheringStopped is not nice. So I'll update that.

Freagarach updated this revision to Diff 11961.May 21 2020, 8:36 PM
  • Separate UnitAI-calls. (To be revised.)
  • Gather treasure in cmpResourceGatherer.
Freagarach planned changes to this revision.May 21 2020, 8:37 PM

Use a callback.

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
| 800| 800| 					this.FinishOrder();
| 801| 801| 					return;
| 802| 802| 				}
| 803|    |-				else
| 804|    |-				{
|    | 803|+				
| 805| 804| 					this.SetNextState("GARRISON.APPROACHING");
| 806| 805| 					return;
| 807|    |-				}
|    | 806|+				
| 808| 807| 			}
| 809| 808| 
| 810| 809| 			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
|1072|1072| 			},
|1073|1073| 		},
|1074|1074| 
|1075|    |-		"GARRISON":{
|    |1075|+		"GARRISON": {
|1076|1076| 			"APPROACHING": {
|1077|1077| 				"enter": function() {
|1078|1078| 					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
|2046|2046| 
|2047|2047| 				"Attacked": function(msg) {
|2048|2048| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|2049|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|2050|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |2049|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |2050|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|2051|2051| 						this.RespondToTargetedEntities([msg.data.attacker]);
|2052|2052| 				},
|2053|2053| 			},
|    | [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
|2205|2205| 					"MovementUpdate": function(msg) {
|2206|2206| 						// If it looks like the path is failing, and we are close enough (3 tiles) from wanted range
|2207|2207| 						// stop anyways. This avoids pathing for an unreachable goal and reduces lag considerably.
|2208|    |-						if (msg.likelyFailure || 
|    |2208|+						if (msg.likelyFailure ||
|2209|2209| 							msg.obstructed && this.RelaxedMaxRangeCheck(this.order.data, this.order.data.max + this.DefaultRelaxedMaxRange) ||
|2210|2210| 							!msg.obstructed && this.CheckRange(this.order.data))
|2211|2211| 							this.FinishOrder();
|    | [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
|2776|2776| 					{
|2777|2777| 						// The building was already finished/fully repaired before we arrived;
|2778|2778| 						// let the ConstructionFinished handler handle this.
|2779|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2779|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2780|2780| 						return true;
|2781|2781| 					}
|2782|2782| 
|    | [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
|2776|2776| 					{
|2777|2777| 						// The building was already finished/fully repaired before we arrived;
|2778|2778| 						// let the ConstructionFinished handler handle this.
|2779|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2779|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2780|2780| 						return true;
|2781|2781| 					}
|2782|2782| 
|    | [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
|3074|3074| 				this.StopTimer();
|3075|3075| 				this.ResetAnimation();
|3076|3076| 				if (this.formationAnimationVariant)
|3077|    |-					this.SetAnimationVariant(this.formationAnimationVariant)
|    |3077|+					this.SetAnimationVariant(this.formationAnimationVariant);
|3078|3078| 				else
|3079|3079| 					this.SetDefaultAnimationVariant();
|3080|3080| 				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
|3300|3300| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3301|3301| 
|3302|3302| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3303|    |-							// only used for domestic animals
|    |3303|+		// only used for domestic animals
|3304|3304| 
|3305|3305| 		// Reuse the same garrison behaviour for animals.
|3306|3306| 		"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
|3362|3362| 
|3363|3363| UnitAI.prototype.IsAnimal = function()
|3364|3364| {
|3365|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3365|+	return (!!this.template.NaturalBehaviour);
|3366|3366| };
|3367|3367| 
|3368|3368| 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
|3478|3478| 		{
|3479|3479| 			let index = this.GetCurrentState().indexOf(".");
|3480|3480| 			if (index != -1)
|3481|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3481|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3482|3482| 			this.Stop(false);
|3483|3483| 		}
|3484|3484| 
|    | [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
|3534|3534| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3535|3535| 			continue;
|3536|3536| 		if (i == 0)
|3537|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3537|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3538|3538| 		else
|3539|3539| 			this.orderQueue.splice(i, 1);
|3540|3540| 		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
|3534|3534| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3535|3535| 			continue;
|3536|3536| 		if (i == 0)
|3537|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3537|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3538|3538| 		else
|3539|3539| 			this.orderQueue.splice(i, 1);
|3540|3540| 		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
|3621|3621| };
|3622|3622| 
|3623|3623| 
|3624|    |-//// FSM linkage functions ////
|    |3624|+// // FSM linkage functions ////
|3625|3625| 
|3626|3626| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3627|3627| 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
|3792|3792| 				continue;
|3793|3793| 			if (this.orderQueue[i].type == type)
|3794|3794| 				continue;
|3795|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3795|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3796|3796| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3797|3797| 			return;
|3798|3798| 		}
|    | [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
|3792|3792| 				continue;
|3793|3793| 			if (this.orderQueue[i].type == type)
|3794|3794| 				continue;
|3795|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3795|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3796|3796| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3797|3797| 			return;
|3798|3798| 		}
|    | [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
|4034|4034| 	if (data.timerRepeat === undefined)
|4035|4035| 		this.timer = undefined;
|4036|4036| 
|4037|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4037|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|4038|4038| };
|4039|4039| 
|4040|4040| /**
|    | [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
|4034|4034| 	if (data.timerRepeat === undefined)
|4035|4035| 		this.timer = undefined;
|4036|4036| 
|4037|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4037|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|4038|4038| };
|4039|4039| 
|4040|4040| /**
|    | [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
|4079|4079| 	// TODO: This is a bit inefficient since every unit listens to every
|4080|4080| 	// construction message - ideally we could scope it to only the one we're building
|4081|4081| 
|4082|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4082|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|4083|4083| };
|4084|4084| 
|4085|4085| 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
|4079|4079| 	// TODO: This is a bit inefficient since every unit listens to every
|4080|4080| 	// construction message - ideally we could scope it to only the one we're building
|4081|4081| 
|4082|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4082|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|4083|4083| };
|4084|4084| 
|4085|4085| 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
|4110|4110| 	if (msg.fromStatusEffect)
|4111|4111| 		return;
|4112|4112| 
|4113|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4113|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|4114|4114| };
|4115|4115| 
|4116|4116| 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
|4110|4110| 	if (msg.fromStatusEffect)
|4111|4111| 		return;
|4112|4112| 
|4113|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4113|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|4114|4114| };
|4115|4115| 
|4116|4116| 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
|4115|4115| 
|4116|4116| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4117|4117| {
|4118|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4118|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|4119|4119| };
|4120|4120| 
|4121|4121| 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
|4115|4115| 
|4116|4116| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4117|4117| {
|4118|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4118|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|4119|4119| };
|4120|4120| 
|4121|4121| 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
|4120|4120| 
|4121|4121| UnitAI.prototype.OnHealthChanged = function(msg)
|4122|4122| {
|4123|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4123|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|4124|4124| };
|4125|4125| 
|4126|4126| 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
|4120|4120| 
|4121|4121| UnitAI.prototype.OnHealthChanged = function(msg)
|4122|4122| {
|4123|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4123|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|4124|4124| };
|4125|4125| 
|4126|4126| 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
|4126|4126| UnitAI.prototype.OnRangeUpdate = function(msg)
|4127|4127| {
|4128|4128| 	if (msg.tag == this.losRangeQuery)
|4129|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4129|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|4130|4130| 	else if (msg.tag == this.losHealRangeQuery)
|4131|4131| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4132|4132| };
|    | [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
|4126|4126| UnitAI.prototype.OnRangeUpdate = function(msg)
|4127|4127| {
|4128|4128| 	if (msg.tag == this.losRangeQuery)
|4129|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4129|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|4130|4130| 	else if (msg.tag == this.losHealRangeQuery)
|4131|4131| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4132|4132| };
|    | [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
|4128|4128| 	if (msg.tag == this.losRangeQuery)
|4129|4129| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4130|4130| 	else if (msg.tag == this.losHealRangeQuery)
|4131|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4131|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|4132|4132| };
|4133|4133| 
|4134|4134| 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
|4128|4128| 	if (msg.tag == this.losRangeQuery)
|4129|4129| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4130|4130| 	else if (msg.tag == this.losHealRangeQuery)
|4131|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4131|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|4132|4132| };
|4133|4133| 
|4134|4134| 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
|4133|4133| 
|4134|4134| UnitAI.prototype.OnPackFinished = function(msg)
|4135|4135| {
|4136|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4136|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|4137|4137| };
|4138|4138| 
|4139|4139| UnitAI.prototype.OnOutOfRange = 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
|4133|4133| 
|4134|4134| UnitAI.prototype.OnPackFinished = function(msg)
|4135|4135| {
|4136|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4136|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|4137|4137| };
|4138|4138| 
|4139|4139| UnitAI.prototype.OnOutOfRange = function(msg)
|    | [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
|4151|4151| 	this.UnitFsm.ProcessMessage(this, { "type": "InventoryFilled", "data": msg });
|4152|4152| };
|4153|4153| 
|4154|    |-//// Helper functions to be called by the FSM ////
|    |4154|+// // Helper functions to be called by the FSM ////
|4155|4155| 
|4156|4156| UnitAI.prototype.GetWalkSpeed = function()
|4157|4157| {
|    | [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
|4863|4863| UnitAI.prototype.AttackEntityInZone = function(ents)
|4864|4864| {
|4865|4865| 	var target = ents.find(target =>
|4866|    |-		this.CanAttack(target)
|4867|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4866|+		this.CanAttack(target) &&
|    |4867|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4868|4868| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4869|4869| 	);
|4870|4870| 	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
|4864|4864| {
|4865|4865| 	var target = ents.find(target =>
|4866|4866| 		this.CanAttack(target)
|4867|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4868|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4867|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4868|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4869|4869| 	);
|4870|4870| 	if (!target)
|4871|4871| 		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
|5963|5963| 
|5964|5964| UnitAI.prototype.SetHeldPosition = function(x, z)
|5965|5965| {
|5966|    |-	this.heldPosition = {"x": x, "z": z};
|    |5966|+	this.heldPosition = { "x": x, "z": z};
|5967|5967| };
|5968|5968| 
|5969|5969| 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
|5963|5963| 
|5964|5964| UnitAI.prototype.SetHeldPosition = function(x, z)
|5965|5965| {
|5966|    |-	this.heldPosition = {"x": x, "z": z};
|    |5966|+	this.heldPosition = {"x": x, "z": z };
|5967|5967| };
|5968|5968| 
|5969|5969| 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
|5990|5990| 	return false;
|5991|5991| };
|5992|5992| 
|5993|    |-//// Helper functions ////
|    |5993|+// // Helper functions ////
|5994|5994| 
|5995|5995| /**
|5996|5996|  * 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
|6009|6009| 		return undefined;
|6010|6010| 
|6011|6011| 	return component.GetRange(type);
|6012|    |-}
|    |6012|+};
|6013|6013| 
|6014|6014| UnitAI.prototype.CanAttack = function(target)
|6015|6015| {
|    | [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
|6177|6177| 	return cmpPack && cmpPack.IsPacking();
|6178|6178| };
|6179|6179| 
|6180|    |-//// Formation specific functions ////
|    |6180|+// // Formation specific functions ////
|6181|6181| 
|6182|6182| UnitAI.prototype.IsAttackingAsFormation = function()
|6183|6183| {
|    | [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
|6182|6182| UnitAI.prototype.IsAttackingAsFormation = function()
|6183|6183| {
|6184|6184| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|6185|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|6186|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |6185|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |6186|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6187|6187| };
|6188|6188| 
|6189|6189| //// 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
|6186|6186| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6187|6187| };
|6188|6188| 
|6189|    |-//// Animal specific functions ////
|    |6189|+// // Animal specific functions ////
|6190|6190| 
|6191|6191| UnitAI.prototype.MoveRandomly = function(distance)
|6192|6192| {

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|3939| »   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
|4850| »   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
|4865| »   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
|2050| »   »   »   »   »   »   &&·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
|3077| »   »   »   »   »   this.SetAnimationVariant(this.formationAnimationVariant)
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|4867| »   »   &&·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
|4868| »   »   &&·(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
|6012| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|6186| »   »   &&·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/2188/display/redirect

Freagarach updated this revision to Diff 11962.May 21 2020, 9:22 PM

Some sort of callback.

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
| 800| 800| 					this.FinishOrder();
| 801| 801| 					return;
| 802| 802| 				}
| 803|    |-				else
| 804|    |-				{
|    | 803|+				
| 805| 804| 					this.SetNextState("GARRISON.APPROACHING");
| 806| 805| 					return;
| 807|    |-				}
|    | 806|+				
| 808| 807| 			}
| 809| 808| 
| 810| 809| 			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
|1072|1072| 			},
|1073|1073| 		},
|1074|1074| 
|1075|    |-		"GARRISON":{
|    |1075|+		"GARRISON": {
|1076|1076| 			"APPROACHING": {
|1077|1077| 				"enter": function() {
|1078|1078| 					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
|2046|2046| 
|2047|2047| 				"Attacked": function(msg) {
|2048|2048| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|2049|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|2050|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |2049|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |2050|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|2051|2051| 						this.RespondToTargetedEntities([msg.data.attacker]);
|2052|2052| 				},
|2053|2053| 			},
|    | [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
|2205|2205| 					"MovementUpdate": function(msg) {
|2206|2206| 						// If it looks like the path is failing, and we are close enough (3 tiles) from wanted range
|2207|2207| 						// stop anyways. This avoids pathing for an unreachable goal and reduces lag considerably.
|2208|    |-						if (msg.likelyFailure || 
|    |2208|+						if (msg.likelyFailure ||
|2209|2209| 							msg.obstructed && this.RelaxedMaxRangeCheck(this.order.data, this.order.data.max + this.DefaultRelaxedMaxRange) ||
|2210|2210| 							!msg.obstructed && this.CheckRange(this.order.data))
|2211|2211| 							this.FinishOrder();
|    | [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
|2781|2781| 					{
|2782|2782| 						// The building was already finished/fully repaired before we arrived;
|2783|2783| 						// let the ConstructionFinished handler handle this.
|2784|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2784|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2785|2785| 						return true;
|2786|2786| 					}
|2787|2787| 
|    | [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
|2781|2781| 					{
|2782|2782| 						// The building was already finished/fully repaired before we arrived;
|2783|2783| 						// let the ConstructionFinished handler handle this.
|2784|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2784|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2785|2785| 						return true;
|2786|2786| 					}
|2787|2787| 
|    | [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
|3079|3079| 				this.StopTimer();
|3080|3080| 				this.ResetAnimation();
|3081|3081| 				if (this.formationAnimationVariant)
|3082|    |-					this.SetAnimationVariant(this.formationAnimationVariant)
|    |3082|+					this.SetAnimationVariant(this.formationAnimationVariant);
|3083|3083| 				else
|3084|3084| 					this.SetDefaultAnimationVariant();
|3085|3085| 				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
|3305|3305| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3306|3306| 
|3307|3307| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3308|    |-							// only used for domestic animals
|    |3308|+		// only used for domestic animals
|3309|3309| 
|3310|3310| 		// Reuse the same garrison behaviour for animals.
|3311|3311| 		"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
|3367|3367| 
|3368|3368| UnitAI.prototype.IsAnimal = function()
|3369|3369| {
|3370|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3370|+	return (!!this.template.NaturalBehaviour);
|3371|3371| };
|3372|3372| 
|3373|3373| 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
|3483|3483| 		{
|3484|3484| 			let index = this.GetCurrentState().indexOf(".");
|3485|3485| 			if (index != -1)
|3486|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3486|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3487|3487| 			this.Stop(false);
|3488|3488| 		}
|3489|3489| 
|    | [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
|3539|3539| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3540|3540| 			continue;
|3541|3541| 		if (i == 0)
|3542|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3542|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3543|3543| 		else
|3544|3544| 			this.orderQueue.splice(i, 1);
|3545|3545| 		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
|3539|3539| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3540|3540| 			continue;
|3541|3541| 		if (i == 0)
|3542|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3542|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3543|3543| 		else
|3544|3544| 			this.orderQueue.splice(i, 1);
|3545|3545| 		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
|3626|3626| };
|3627|3627| 
|3628|3628| 
|3629|    |-//// FSM linkage functions ////
|    |3629|+// // FSM linkage functions ////
|3630|3630| 
|3631|3631| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3632|3632| 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
|3797|3797| 				continue;
|3798|3798| 			if (this.orderQueue[i].type == type)
|3799|3799| 				continue;
|3800|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3800|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3801|3801| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3802|3802| 			return;
|3803|3803| 		}
|    | [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
|3797|3797| 				continue;
|3798|3798| 			if (this.orderQueue[i].type == type)
|3799|3799| 				continue;
|3800|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3800|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3801|3801| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3802|3802| 			return;
|3803|3803| 		}
|    | [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
|4039|4039| 	if (data.timerRepeat === undefined)
|4040|4040| 		this.timer = undefined;
|4041|4041| 
|4042|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4042|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|4043|4043| };
|4044|4044| 
|4045|4045| /**
|    | [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
|4039|4039| 	if (data.timerRepeat === undefined)
|4040|4040| 		this.timer = undefined;
|4041|4041| 
|4042|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4042|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|4043|4043| };
|4044|4044| 
|4045|4045| /**
|    | [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
|4084|4084| 	// TODO: This is a bit inefficient since every unit listens to every
|4085|4085| 	// construction message - ideally we could scope it to only the one we're building
|4086|4086| 
|4087|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4087|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|4088|4088| };
|4089|4089| 
|4090|4090| 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
|4084|4084| 	// TODO: This is a bit inefficient since every unit listens to every
|4085|4085| 	// construction message - ideally we could scope it to only the one we're building
|4086|4086| 
|4087|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4087|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|4088|4088| };
|4089|4089| 
|4090|4090| 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
|4115|4115| 	if (msg.fromStatusEffect)
|4116|4116| 		return;
|4117|4117| 
|4118|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4118|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|4119|4119| };
|4120|4120| 
|4121|4121| 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
|4115|4115| 	if (msg.fromStatusEffect)
|4116|4116| 		return;
|4117|4117| 
|4118|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4118|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|4119|4119| };
|4120|4120| 
|4121|4121| 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
|4120|4120| 
|4121|4121| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4122|4122| {
|4123|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4123|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|4124|4124| };
|4125|4125| 
|4126|4126| 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
|4120|4120| 
|4121|4121| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4122|4122| {
|4123|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4123|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|4124|4124| };
|4125|4125| 
|4126|4126| 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
|4125|4125| 
|4126|4126| UnitAI.prototype.OnHealthChanged = function(msg)
|4127|4127| {
|4128|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4128|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|4129|4129| };
|4130|4130| 
|4131|4131| 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
|4125|4125| 
|4126|4126| UnitAI.prototype.OnHealthChanged = function(msg)
|4127|4127| {
|4128|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4128|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|4129|4129| };
|4130|4130| 
|4131|4131| 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
|4131|4131| UnitAI.prototype.OnRangeUpdate = function(msg)
|4132|4132| {
|4133|4133| 	if (msg.tag == this.losRangeQuery)
|4134|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4134|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|4135|4135| 	else if (msg.tag == this.losHealRangeQuery)
|4136|4136| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4137|4137| };
|    | [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
|4131|4131| UnitAI.prototype.OnRangeUpdate = function(msg)
|4132|4132| {
|4133|4133| 	if (msg.tag == this.losRangeQuery)
|4134|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4134|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|4135|4135| 	else if (msg.tag == this.losHealRangeQuery)
|4136|4136| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4137|4137| };
|    | [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
|4133|4133| 	if (msg.tag == this.losRangeQuery)
|4134|4134| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4135|4135| 	else if (msg.tag == this.losHealRangeQuery)
|4136|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4136|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|4137|4137| };
|4138|4138| 
|4139|4139| 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
|4133|4133| 	if (msg.tag == this.losRangeQuery)
|4134|4134| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4135|4135| 	else if (msg.tag == this.losHealRangeQuery)
|4136|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4136|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|4137|4137| };
|4138|4138| 
|4139|4139| 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
|4138|4138| 
|4139|4139| UnitAI.prototype.OnPackFinished = function(msg)
|4140|4140| {
|4141|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4141|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|4142|4142| };
|4143|4143| 
|4144|4144| UnitAI.prototype.OnOutOfRange = 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
|4138|4138| 
|4139|4139| UnitAI.prototype.OnPackFinished = function(msg)
|4140|4140| {
|4141|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4141|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|4142|4142| };
|4143|4143| 
|4144|4144| UnitAI.prototype.OnOutOfRange = function(msg)
|    | [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
|4156|4156| 	this.UnitFsm.ProcessMessage(this, { "type": "InventoryFilled", "data": msg });
|4157|4157| };
|4158|4158| 
|4159|    |-//// Helper functions to be called by the FSM ////
|    |4159|+// // Helper functions to be called by the FSM ////
|4160|4160| 
|4161|4161| UnitAI.prototype.GetWalkSpeed = function()
|4162|4162| {
|    | [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
|4868|4868| UnitAI.prototype.AttackEntityInZone = function(ents)
|4869|4869| {
|4870|4870| 	var target = ents.find(target =>
|4871|    |-		this.CanAttack(target)
|4872|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4871|+		this.CanAttack(target) &&
|    |4872|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4873|4873| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4874|4874| 	);
|4875|4875| 	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
|4869|4869| {
|4870|4870| 	var target = ents.find(target =>
|4871|4871| 		this.CanAttack(target)
|4872|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4873|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4872|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4873|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4874|4874| 	);
|4875|4875| 	if (!target)
|4876|4876| 		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
|4935|4935| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|4936|4936| 	if (this.isGuardOf)
|4937|4937| 	{
|4938|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4938|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4939|4939| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4940|4940| 		if (cmpUnitAI && cmpAttack &&
|4941|4941| 		    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
|4939|4939| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4940|4940| 		if (cmpUnitAI && cmpAttack &&
|4941|4941| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|4942|    |-				return false;
|    |4942|+			return false;
|4943|4943| 	}
|4944|4944| 
|4945|4945| 	// 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
|4977|4977| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|4978|4978| 	if (this.isGuardOf)
|4979|4979| 	{
|4980|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4980|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4981|4981| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4982|4982| 		if (cmpUnitAI && cmpAttack &&
|4983|4983| 		    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
|4990|4990| 	return false;
|4991|4991| };
|4992|4992| 
|4993|    |-//// External interface functions ////
|    |4993|+// // External interface functions ////
|4994|4994| 
|4995|4995| UnitAI.prototype.SetFormationController = function(ent)
|4996|4996| {
|    | [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
|5146|5146| 	{
|5147|5147| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|5148|5148| 			return;
|5149|    |-		else
|5150|    |-			this.RemoveGuard();
|    |5149|+		this.RemoveGuard();
|5151|5150| 	}
|5152|5151| 
|5153|5152| 	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
|5477|5477| 
|5478|5478| 	if (this.IsFormationController())
|5479|5479| 		this.CallMemberFunction("CancelSetupTradeRoute", [target]);
|5480|    |-}
|    |5480|+};
|5481|5481| /**
|5482|5482|  * Adds trade order to the queue. Either walk to the first market, or
|5483|5483|  * 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
|5498|5498| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5499|5499| 	{
|5500|5500| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5501|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5501|+		if (cmpTrader.HasBothMarkets() &&
|5502|5502| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5503|5503| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5504|5504| 		{
|    | [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
|5779|5779| 				{
|5780|5780| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5781|5781| 					var targetClasses = this.order.data.targetClasses;
|5782|    |-					if (targetClasses.attack && cmpIdentity
|5783|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5782|+					if (targetClasses.attack && cmpIdentity &&
|    |5783|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5784|5784| 						continue;
|5785|5785| 					if (targetClasses.avoid && cmpIdentity
|5786|5786| 						&& 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
|5782|5782| 					if (targetClasses.attack && cmpIdentity
|5783|5783| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5784|5784| 						continue;
|5785|    |-					if (targetClasses.avoid && cmpIdentity
|5786|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5785|+					if (targetClasses.avoid && cmpIdentity &&
|    |5786|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5787|5787| 						continue;
|5788|5788| 					// Only used by the AIs to prevent some choices of targets
|5789|5789| 					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
|5805|5805| 		{
|5806|5806| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5807|5807| 			var targetClasses = this.order.data.targetClasses;
|5808|    |-			if (cmpIdentity && targetClasses.attack
|5809|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5808|+			if (cmpIdentity && targetClasses.attack &&
|    |5809|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5810|5810| 				continue;
|5811|5811| 			if (cmpIdentity && targetClasses.avoid
|5812|5812| 				&& 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
|5808|5808| 			if (cmpIdentity && targetClasses.attack
|5809|5809| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5810|5810| 				continue;
|5811|    |-			if (cmpIdentity && targetClasses.avoid
|5812|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5811|+			if (cmpIdentity && targetClasses.avoid &&
|    |5812|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5813|5813| 				continue;
|5814|5814| 			// Only used by the AIs to prevent some choices of targets
|5815|5815| 			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
|5968|5968| 
|5969|5969| UnitAI.prototype.SetHeldPosition = function(x, z)
|5970|5970| {
|5971|    |-	this.heldPosition = {"x": x, "z": z};
|    |5971|+	this.heldPosition = { "x": x, "z": z};
|5972|5972| };
|5973|5973| 
|5974|5974| 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
|5968|5968| 
|5969|5969| UnitAI.prototype.SetHeldPosition = function(x, z)
|5970|5970| {
|5971|    |-	this.heldPosition = {"x": x, "z": z};
|    |5971|+	this.heldPosition = {"x": x, "z": z };
|5972|5972| };
|5973|5973| 
|5974|5974| 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
|5995|5995| 	return false;
|5996|5996| };
|5997|5997| 
|5998|    |-//// Helper functions ////
|    |5998|+// // Helper functions ////
|5999|5999| 
|6000|6000| /**
|6001|6001|  * 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
|6014|6014| 		return undefined;
|6015|6015| 
|6016|6016| 	return component.GetRange(type);
|6017|    |-}
|    |6017|+};
|6018|6018| 
|6019|6019| UnitAI.prototype.CanAttack = function(target)
|6020|6020| {
|    | [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
|6182|6182| 	return cmpPack && cmpPack.IsPacking();
|6183|6183| };
|6184|6184| 
|6185|    |-//// Formation specific functions ////
|    |6185|+// // Formation specific functions ////
|6186|6186| 
|6187|6187| UnitAI.prototype.IsAttackingAsFormation = function()
|6188|6188| {
|    | [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
|6187|6187| UnitAI.prototype.IsAttackingAsFormation = function()
|6188|6188| {
|6189|6189| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|6190|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|6191|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |6190|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |6191|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6192|6192| };
|6193|6193| 
|6194|6194| //// 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
|6191|6191| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6192|6192| };
|6193|6193| 
|6194|    |-//// Animal specific functions ////
|    |6194|+// // Animal specific functions ////
|6195|6195| 
|6196|6196| UnitAI.prototype.MoveRandomly = function(distance)
|6197|6197| {

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|3944| »   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
|4855| »   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
|4870| »   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
|4918| »   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
|4941| »   »   ····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
|2050| »   »   »   »   »   »   &&·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
|3082| »   »   »   »   »   this.SetAnimationVariant(this.formationAnimationVariant)
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|4872| »   »   &&·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
|4873| »   »   &&·(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
|5480| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|5783| »   »   »   »   »   »   &&·!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
|5786| »   »   »   »   »   »   &&·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
|5799| »   var·targets·=·this.GetTargetsFromUnit();
|    | [NORMAL] JSHintBear:
|    | 'targets' is already defined.

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

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|5809| »   »   »   »   &&·!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
|5812| »   »   »   »   &&·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
|6017| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|6191| »   »   &&·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/2189/display/redirect

Freagarach updated this revision to Diff 12145.EditedFri, Jun 5, 4:23 PM
  • Update some documentation.

If UnitAI's face towards target would be moved to e.g. a global one can ditch the timer in UnitAI and use it from other components as well.

Vulcan added a comment.Fri, Jun 5, 4:33 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
| 796| 796| 					this.FinishOrder();
| 797| 797| 					return;
| 798| 798| 				}
| 799|    |-				else
| 800|    |-				{
|    | 799|+				
| 801| 800| 					this.SetNextState("GARRISON.APPROACHING");
| 802| 801| 					return;
| 803|    |-				}
|    | 802|+				
| 804| 803| 			}
| 805| 804| 
| 806| 805| 			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
|1068|1068| 			},
|1069|1069| 		},
|1070|1070| 
|1071|    |-		"GARRISON":{
|    |1071|+		"GARRISON": {
|1072|1072| 			"APPROACHING": {
|1073|1073| 				"enter": function() {
|1074|1074| 					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
|2042|2042| 
|2043|2043| 				"Attacked": function(msg) {
|2044|2044| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|2045|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|2046|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |2045|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |2046|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|2047|2047| 						this.RespondToTargetedEntities([msg.data.attacker]);
|2048|2048| 				},
|2049|2049| 			},
|    | [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
|2201|2201| 					"MovementUpdate": function(msg) {
|2202|2202| 						// If it looks like the path is failing, and we are close enough (3 tiles) from wanted range
|2203|2203| 						// stop anyways. This avoids pathing for an unreachable goal and reduces lag considerably.
|2204|    |-						if (msg.likelyFailure || 
|    |2204|+						if (msg.likelyFailure ||
|2205|2205| 							msg.obstructed && this.RelaxedMaxRangeCheck(this.order.data, this.order.data.max + this.DefaultRelaxedMaxRange) ||
|2206|2206| 							!msg.obstructed && this.CheckRange(this.order.data))
|2207|2207| 							this.FinishOrder();
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 7 tabs but found 6.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2438|2438| 
|2439|2439| 								return type.specific == resourceType.specific &&
|2440|2440| 								    (type.specific != "meat" || resourceTemplate == template);
|2441|    |-						});
|    |2441|+							});
|2442|2442| 
|2443|2443| 						if (nearbyResource)
|2444|2444| 						{
|    | [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
|2770|2770| 					{
|2771|2771| 						// The building was already finished/fully repaired before we arrived;
|2772|2772| 						// let the ConstructionFinished handler handle this.
|2773|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2773|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2774|2774| 						return true;
|2775|2775| 					}
|2776|2776| 
|    | [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
|2770|2770| 					{
|2771|2771| 						// The building was already finished/fully repaired before we arrived;
|2772|2772| 						// let the ConstructionFinished handler handle this.
|2773|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2773|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2774|2774| 						return true;
|2775|2775| 					}
|2776|2776| 
|    | [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
|3060|3060| 				this.StopTimer();
|3061|3061| 				this.ResetAnimation();
|3062|3062| 				if (this.formationAnimationVariant)
|3063|    |-					this.SetAnimationVariant(this.formationAnimationVariant)
|    |3063|+					this.SetAnimationVariant(this.formationAnimationVariant);
|3064|3064| 				else
|3065|3065| 					this.SetDefaultAnimationVariant();
|3066|3066| 				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
|3286|3286| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3287|3287| 
|3288|3288| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3289|    |-							// only used for domestic animals
|    |3289|+		// only used for domestic animals
|3290|3290| 
|3291|3291| 		// Reuse the same garrison behaviour for animals.
|3292|3292| 		"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
|3349|3349| 
|3350|3350| UnitAI.prototype.IsAnimal = function()
|3351|3351| {
|3352|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3352|+	return (!!this.template.NaturalBehaviour);
|3353|3353| };
|3354|3354| 
|3355|3355| 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
|3489|3489| 		{
|3490|3490| 			let index = this.GetCurrentState().indexOf(".");
|3491|3491| 			if (index != -1)
|3492|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3492|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3493|3493| 			this.Stop(false);
|3494|3494| 		}
|3495|3495| 
|    | [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
|3545|3545| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3546|3546| 			continue;
|3547|3547| 		if (i == 0)
|3548|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3548|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3549|3549| 		else
|3550|3550| 			this.orderQueue.splice(i, 1);
|3551|3551| 		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
|3545|3545| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3546|3546| 			continue;
|3547|3547| 		if (i == 0)
|3548|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3548|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3549|3549| 		else
|3550|3550| 			this.orderQueue.splice(i, 1);
|3551|3551| 		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
|3632|3632| };
|3633|3633| 
|3634|3634| 
|3635|    |-//// FSM linkage functions ////
|    |3635|+// // FSM linkage functions ////
|3636|3636| 
|3637|3637| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3638|3638| 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
|3803|3803| 				continue;
|3804|3804| 			if (this.orderQueue[i].type == type)
|3805|3805| 				continue;
|3806|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3806|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3807|3807| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3808|3808| 			return;
|3809|3809| 		}
|    | [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
|3803|3803| 				continue;
|3804|3804| 			if (this.orderQueue[i].type == type)
|3805|3805| 				continue;
|3806|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3806|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3807|3807| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3808|3808| 			return;
|3809|3809| 		}
|    | [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
|4044|4044| 	if (data.timerRepeat === undefined)
|4045|4045| 		this.timer = undefined;
|4046|4046| 
|4047|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4047|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|4048|4048| };
|4049|4049| 
|4050|4050| /**
|    | [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
|4044|4044| 	if (data.timerRepeat === undefined)
|4045|4045| 		this.timer = undefined;
|4046|4046| 
|4047|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4047|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|4048|4048| };
|4049|4049| 
|4050|4050| /**
|    | [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
|4089|4089| 	// TODO: This is a bit inefficient since every unit listens to every
|4090|4090| 	// construction message - ideally we could scope it to only the one we're building
|4091|4091| 
|4092|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4092|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|4093|4093| };
|4094|4094| 
|4095|4095| 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
|4089|4089| 	// TODO: This is a bit inefficient since every unit listens to every
|4090|4090| 	// construction message - ideally we could scope it to only the one we're building
|4091|4091| 
|4092|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4092|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|4093|4093| };
|4094|4094| 
|4095|4095| 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
|4120|4120| 	if (msg.fromStatusEffect)
|4121|4121| 		return;
|4122|4122| 
|4123|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4123|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|4124|4124| };
|4125|4125| 
|4126|4126| 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
|4120|4120| 	if (msg.fromStatusEffect)
|4121|4121| 		return;
|4122|4122| 
|4123|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4123|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|4124|4124| };
|4125|4125| 
|4126|4126| 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
|4125|4125| 
|4126|4126| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4127|4127| {
|4128|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4128|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|4129|4129| };
|4130|4130| 
|4131|4131| 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
|4125|4125| 
|4126|4126| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4127|4127| {
|4128|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4128|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|4129|4129| };
|4130|4130| 
|4131|4131| 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
|4130|4130| 
|4131|4131| UnitAI.prototype.OnHealthChanged = function(msg)
|4132|4132| {
|4133|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4133|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|4134|4134| };
|4135|4135| 
|4136|4136| 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
|4130|4130| 
|4131|4131| UnitAI.prototype.OnHealthChanged = function(msg)
|4132|4132| {
|4133|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4133|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|4134|4134| };
|4135|4135| 
|4136|4136| 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
|4136|4136| UnitAI.prototype.OnRangeUpdate = function(msg)
|4137|4137| {
|4138|4138| 	if (msg.tag == this.losRangeQuery)
|4139|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4139|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|4140|4140| 	else if (msg.tag == this.losHealRangeQuery)
|4141|4141| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4142|4142| };
|    | [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
|4136|4136| UnitAI.prototype.OnRangeUpdate = function(msg)
|4137|4137| {
|4138|4138| 	if (msg.tag == this.losRangeQuery)
|4139|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4139|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|4140|4140| 	else if (msg.tag == this.losHealRangeQuery)
|4141|4141| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4142|4142| };
|    | [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
|4138|4138| 	if (msg.tag == this.losRangeQuery)
|4139|4139| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4140|4140| 	else if (msg.tag == this.losHealRangeQuery)
|4141|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4141|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|4142|4142| };
|4143|4143| 
|4144|4144| 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
|4138|4138| 	if (msg.tag == this.losRangeQuery)
|4139|4139| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4140|4140| 	else if (msg.tag == this.losHealRangeQuery)
|4141|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4141|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|4142|4142| };
|4143|4143| 
|4144|4144| 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
|4143|4143| 
|4144|4144| UnitAI.prototype.OnPackFinished = function(msg)
|4145|4145| {
|4146|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4146|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|4147|4147| };
|4148|4148| 
|4149|4149| UnitAI.prototype.OnOutOfRange = 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
|4143|4143| 
|4144|4144| UnitAI.prototype.OnPackFinished = function(msg)
|4145|4145| {
|4146|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4146|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|4147|4147| };
|4148|4148| 
|4149|4149| UnitAI.prototype.OnOutOfRange = function(msg)
|    | [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
|4161|4161| 	this.UnitFsm.ProcessMessage(this, { "type": "InventoryFilled", "data": msg });
|4162|4162| };
|4163|4163| 
|4164|    |-//// Helper functions to be called by the FSM ////
|    |4164|+// // Helper functions to be called by the FSM ////
|4165|4165| 
|4166|4166| UnitAI.prototype.GetWalkSpeed = function()
|4167|4167| {
|    | [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
|4891|4891| UnitAI.prototype.AttackEntityInZone = function(ents)
|4892|4892| {
|4893|4893| 	var target = ents.find(target =>
|4894|    |-		this.CanAttack(target)
|4895|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4894|+		this.CanAttack(target) &&
|    |4895|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4896|4896| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4897|4897| 	);
|4898|4898| 	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
|4892|4892| {
|4893|4893| 	var target = ents.find(target =>
|4894|4894| 		this.CanAttack(target)
|4895|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4896|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4895|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4896|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4897|4897| 	);
|4898|4898| 	if (!target)
|4899|4899| 		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
|4958|4958| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|4959|4959| 	if (this.isGuardOf)
|4960|4960| 	{
|4961|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4961|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4962|4962| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4963|4963| 		if (cmpUnitAI && cmpAttack &&
|4964|4964| 		    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
|4962|4962| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4963|4963| 		if (cmpUnitAI && cmpAttack &&
|4964|4964| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|4965|    |-				return false;
|    |4965|+			return false;
|4966|4966| 	}
|4967|4967| 
|4968|4968| 	// 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
|5000|5000| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|5001|5001| 	if (this.isGuardOf)
|5002|5002| 	{
|5003|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |5003|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|5004|5004| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|5005|5005| 		if (cmpUnitAI && cmpAttack &&
|5006|5006| 		    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
|5013|5013| 	return false;
|5014|5014| };
|5015|5015| 
|5016|    |-//// External interface functions ////
|    |5016|+// // External interface functions ////
|5017|5017| 
|5018|5018| UnitAI.prototype.SetFormationController = function(ent)
|5019|5019| {
|    | [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
|5169|5169| 	{
|5170|5170| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|5171|5171| 			return;
|5172|    |-		else
|5173|    |-			this.RemoveGuard();
|    |5172|+		this.RemoveGuard();
|5174|5173| 	}
|5175|5174| 
|5176|5175| 	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
|5503|5503| 
|5504|5504| 	if (this.IsFormationController())
|5505|5505| 		this.CallMemberFunction("CancelSetupTradeRoute", [target]);
|5506|    |-}
|    |5506|+};
|5507|5507| /**
|5508|5508|  * Adds trade order to the queue. Either walk to the first market, or
|5509|5509|  * 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
|5524|5524| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5525|5525| 	{
|5526|5526| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5527|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5527|+		if (cmpTrader.HasBothMarkets() &&
|5528|5528| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5529|5529| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5530|5530| 		{
|    | [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
|5805|5805| 				{
|5806|5806| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5807|5807| 					var targetClasses = this.order.data.targetClasses;
|5808|    |-					if (targetClasses.attack && cmpIdentity
|5809|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5808|+					if (targetClasses.attack && cmpIdentity &&
|    |5809|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5810|5810| 						continue;
|5811|5811| 					if (targetClasses.avoid && cmpIdentity
|5812|5812| 						&& 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
|5808|5808| 					if (targetClasses.attack && cmpIdentity
|5809|5809| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5810|5810| 						continue;
|5811|    |-					if (targetClasses.avoid && cmpIdentity
|5812|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5811|+					if (targetClasses.avoid && cmpIdentity &&
|    |5812|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5813|5813| 						continue;
|5814|5814| 					// Only used by the AIs to prevent some choices of targets
|5815|5815| 					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
|5831|5831| 		{
|5832|5832| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5833|5833| 			var targetClasses = this.order.data.targetClasses;
|5834|    |-			if (cmpIdentity && targetClasses.attack
|5835|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5834|+			if (cmpIdentity && targetClasses.attack &&
|    |5835|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5836|5836| 				continue;
|5837|5837| 			if (cmpIdentity && targetClasses.avoid
|5838|5838| 				&& 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
|5834|5834| 			if (cmpIdentity && targetClasses.attack
|5835|5835| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5836|5836| 				continue;
|5837|    |-			if (cmpIdentity && targetClasses.avoid
|5838|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5837|+			if (cmpIdentity && targetClasses.avoid &&
|    |5838|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5839|5839| 				continue;
|5840|5840| 			// Only used by the AIs to prevent some choices of targets
|5841|5841| 			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
|5994|5994| 
|5995|5995| UnitAI.prototype.SetHeldPosition = function(x, z)
|5996|5996| {
|5997|    |-	this.heldPosition = {"x": x, "z": z};
|    |5997|+	this.heldPosition = { "x": x, "z": z};
|5998|5998| };
|5999|5999| 
|6000|6000| 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
|5994|5994| 
|5995|5995| UnitAI.prototype.SetHeldPosition = function(x, z)
|5996|5996| {
|5997|    |-	this.heldPosition = {"x": x, "z": z};
|    |5997|+	this.heldPosition = {"x": x, "z": z };
|5998|5998| };
|5999|5999| 
|6000|6000| 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
|6021|6021| 	return false;
|6022|6022| };
|6023|6023| 
|6024|    |-//// Helper functions ////
|    |6024|+// // Helper functions ////
|6025|6025| 
|6026|6026| /**
|6027|6027|  * 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
|6040|6040| 		return undefined;
|6041|6041| 
|6042|6042| 	return component.GetRange(type);
|6043|    |-}
|    |6043|+};
|6044|6044| 
|6045|6045| UnitAI.prototype.CanAttack = function(target)
|6046|6046| {
|    | [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
|6216|6216| 	return cmpPack && cmpPack.IsPacking();
|6217|6217| };
|6218|6218| 
|6219|    |-//// Formation specific functions ////
|    |6219|+// // Formation specific functions ////
|6220|6220| 
|6221|6221| UnitAI.prototype.IsAttackingAsFormation = function()
|6222|6222| {
|    | [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
|6221|6221| UnitAI.prototype.IsAttackingAsFormation = function()
|6222|6222| {
|6223|6223| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|6224|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|6225|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |6224|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |6225|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6226|6226| };
|6227|6227| 
|6228|6228| //// 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
|6225|6225| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6226|6226| };
|6227|6227| 
|6228|    |-//// Animal specific functions ////
|    |6228|+// // Animal specific functions ////
|6229|6229| 
|6230|6230| UnitAI.prototype.MoveRandomly = function(distance)
|6231|6231| {

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|3949| »   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
|4878| »   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
|4893| »   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
|4941| »   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
|4964| »   »   ····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
|2046| »   »   »   »   »   »   &&·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
|3063| »   »   »   »   »   this.SetAnimationVariant(this.formationAnimationVariant)
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|4895| »   »   &&·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
|4896| »   »   &&·(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
|5506| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|5809| »   »   »   »   »   »   &&·!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
|5812| »   »   »   »   »   »   &&·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
|5825| »   var·targets·=·this.GetTargetsFromUnit();
|    | [NORMAL] JSHintBear:
|    | 'targets' is already defined.

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

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|5835| »   »   »   »   &&·!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
|5838| »   »   »   »   &&·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
|6043| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|6225| »   »   &&·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/2323/display/redirect

Freagarach updated this revision to Diff 12245.Wed, Jun 10, 5:37 PM

Check range earlier.

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
| 803| 803| 					this.FinishOrder();
| 804| 804| 					return;
| 805| 805| 				}
| 806|    |-				else
| 807|    |-				{
|    | 806|+				
| 808| 807| 					this.SetNextState("GARRISON.APPROACHING");
| 809| 808| 					return;
| 810|    |-				}
|    | 809|+				
| 811| 810| 			}
| 812| 811| 
| 813| 812| 			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
|1069|1069| 			},
|1070|1070| 		},
|1071|1071| 
|1072|    |-		"GARRISON":{
|    |1072|+		"GARRISON": {
|1073|1073| 			"APPROACHING": {
|1074|1074| 				"enter": function() {
|1075|1075| 					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
|2039|2039| 
|2040|2040| 				"Attacked": function(msg) {
|2041|2041| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|2042|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|2043|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |2042|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |2043|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|2044|2044| 						this.RespondToTargetedEntities([msg.data.attacker]);
|2045|2045| 				},
|2046|2046| 			},
|    | [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
|2198|2198| 					"MovementUpdate": function(msg) {
|2199|2199| 						// If it looks like the path is failing, and we are close enough (3 tiles) from wanted range
|2200|2200| 						// stop anyways. This avoids pathing for an unreachable goal and reduces lag considerably.
|2201|    |-						if (msg.likelyFailure || 
|    |2201|+						if (msg.likelyFailure ||
|2202|2202| 							msg.obstructed && this.RelaxedMaxRangeCheck(this.order.data, this.order.data.max + this.DefaultRelaxedMaxRange) ||
|2203|2203| 							!msg.obstructed && this.CheckRange(this.order.data))
|2204|2204| 							this.FinishOrder();
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 7 tabs but found 6.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2431|2431| 
|2432|2432| 								return type.specific == resourceType.specific &&
|2433|2433| 								    (type.specific != "meat" || resourceTemplate == template);
|2434|    |-						});
|    |2434|+							});
|2435|2435| 
|2436|2436| 						if (nearbyResource)
|2437|2437| 						{
|    | [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
|2763|2763| 					{
|2764|2764| 						// The building was already finished/fully repaired before we arrived;
|2765|2765| 						// let the ConstructionFinished handler handle this.
|2766|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2766|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2767|2767| 						return true;
|2768|2768| 					}
|2769|2769| 
|    | [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
|2763|2763| 					{
|2764|2764| 						// The building was already finished/fully repaired before we arrived;
|2765|2765| 						// let the ConstructionFinished handler handle this.
|2766|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2766|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2767|2767| 						return true;
|2768|2768| 					}
|2769|2769| 
|    | [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
|3053|3053| 				this.StopTimer();
|3054|3054| 				this.ResetAnimation();
|3055|3055| 				if (this.formationAnimationVariant)
|3056|    |-					this.SetAnimationVariant(this.formationAnimationVariant)
|    |3056|+					this.SetAnimationVariant(this.formationAnimationVariant);
|3057|3057| 				else
|3058|3058| 					this.SetDefaultAnimationVariant();
|3059|3059| 				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
|3279|3279| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3280|3280| 
|3281|3281| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3282|    |-							// only used for domestic animals
|    |3282|+		// only used for domestic animals
|3283|3283| 
|3284|3284| 		// Reuse the same garrison behaviour for animals.
|3285|3285| 		"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
|3331|3331| 
|3332|3332| UnitAI.prototype.IsAnimal = function()
|3333|3333| {
|3334|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3334|+	return (!!this.template.NaturalBehaviour);
|3335|3335| };
|3336|3336| 
|3337|3337| 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
|3471|3471| 		{
|3472|3472| 			let index = this.GetCurrentState().indexOf(".");
|3473|3473| 			if (index != -1)
|3474|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3474|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3475|3475| 			this.Stop(false);
|3476|3476| 		}
|3477|3477| 
|    | [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
|3527|3527| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3528|3528| 			continue;
|3529|3529| 		if (i == 0)
|3530|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3530|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3531|3531| 		else
|3532|3532| 			this.orderQueue.splice(i, 1);
|3533|3533| 		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
|3527|3527| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3528|3528| 			continue;
|3529|3529| 		if (i == 0)
|3530|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3530|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3531|3531| 		else
|3532|3532| 			this.orderQueue.splice(i, 1);
|3533|3533| 		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
|3614|3614| };
|3615|3615| 
|3616|3616| 
|3617|    |-//// FSM linkage functions ////
|    |3617|+// // FSM linkage functions ////
|3618|3618| 
|3619|3619| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3620|3620| 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
|3786|3786| 				continue;
|3787|3787| 			if (this.orderQueue[i].type == type)
|3788|3788| 				continue;
|3789|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3789|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3790|3790| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3791|3791| 			return;
|3792|3792| 		}
|    | [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
|3786|3786| 				continue;
|3787|3787| 			if (this.orderQueue[i].type == type)
|3788|3788| 				continue;
|3789|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3789|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3790|3790| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3791|3791| 			return;
|3792|3792| 		}
|    | [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
|4027|4027| 	if (data.timerRepeat === undefined)
|4028|4028| 		this.timer = undefined;
|4029|4029| 
|4030|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4030|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|4031|4031| };
|4032|4032| 
|4033|4033| /**
|    | [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
|4027|4027| 	if (data.timerRepeat === undefined)
|4028|4028| 		this.timer = undefined;
|4029|4029| 
|4030|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4030|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|4031|4031| };
|4032|4032| 
|4033|4033| /**
|    | [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
|4072|4072| 	// TODO: This is a bit inefficient since every unit listens to every
|4073|4073| 	// construction message - ideally we could scope it to only the one we're building
|4074|4074| 
|4075|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4075|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|4076|4076| };
|4077|4077| 
|4078|4078| 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
|4072|4072| 	// TODO: This is a bit inefficient since every unit listens to every
|4073|4073| 	// construction message - ideally we could scope it to only the one we're building
|4074|4074| 
|4075|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4075|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|4076|4076| };
|4077|4077| 
|4078|4078| 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
|4111|4111| 	if (msg.fromStatusEffect)
|4112|4112| 		return;
|4113|4113| 
|4114|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4114|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|4115|4115| };
|4116|4116| 
|4117|4117| 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
|4111|4111| 	if (msg.fromStatusEffect)
|4112|4112| 		return;
|4113|4113| 
|4114|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4114|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|4115|4115| };
|4116|4116| 
|4117|4117| 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
|4116|4116| 
|4117|4117| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4118|4118| {
|4119|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4119|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|4120|4120| };
|4121|4121| 
|4122|4122| 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
|4116|4116| 
|4117|4117| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4118|4118| {
|4119|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4119|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|4120|4120| };
|4121|4121| 
|4122|4122| 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
|4121|4121| 
|4122|4122| UnitAI.prototype.OnHealthChanged = function(msg)
|4123|4123| {
|4124|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4124|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|4125|4125| };
|4126|4126| 
|4127|4127| 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
|4121|4121| 
|4122|4122| UnitAI.prototype.OnHealthChanged = function(msg)
|4123|4123| {
|4124|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4124|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|4125|4125| };
|4126|4126| 
|4127|4127| 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
|4127|4127| UnitAI.prototype.OnRangeUpdate = function(msg)
|4128|4128| {
|4129|4129| 	if (msg.tag == this.losRangeQuery)
|4130|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4130|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|4131|4131| 	else if (msg.tag == this.losHealRangeQuery)
|4132|4132| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4133|4133| };
|    | [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
|4127|4127| UnitAI.prototype.OnRangeUpdate = function(msg)
|4128|4128| {
|4129|4129| 	if (msg.tag == this.losRangeQuery)
|4130|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4130|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|4131|4131| 	else if (msg.tag == this.losHealRangeQuery)
|4132|4132| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4133|4133| };
|    | [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
|4129|4129| 	if (msg.tag == this.losRangeQuery)
|4130|4130| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4131|4131| 	else if (msg.tag == this.losHealRangeQuery)
|4132|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4132|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|4133|4133| };
|4134|4134| 
|4135|4135| 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
|4129|4129| 	if (msg.tag == this.losRangeQuery)
|4130|4130| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4131|4131| 	else if (msg.tag == this.losHealRangeQuery)
|4132|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4132|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|4133|4133| };
|4134|4134| 
|4135|4135| 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
|4134|4134| 
|4135|4135| UnitAI.prototype.OnPackFinished = function(msg)
|4136|4136| {
|4137|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4137|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|4138|4138| };
|4139|4139| 
|4140|4140| UnitAI.prototype.OnOutOfRange = 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
|4134|4134| 
|4135|4135| UnitAI.prototype.OnPackFinished = function(msg)
|4136|4136| {
|4137|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4137|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|4138|4138| };
|4139|4139| 
|4140|4140| UnitAI.prototype.OnOutOfRange = function(msg)
|    | [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
|4152|4152| 	this.UnitFsm.ProcessMessage(this, { "type": "InventoryFilled", "data": msg });
|4153|4153| };
|4154|4154| 
|4155|    |-//// Helper functions to be called by the FSM ////
|    |4155|+// // Helper functions to be called by the FSM ////
|4156|4156| 
|4157|4157| UnitAI.prototype.GetWalkSpeed = function()
|4158|4158| {
|    | [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
|4882|4882| UnitAI.prototype.AttackEntityInZone = function(ents)
|4883|4883| {
|4884|4884| 	var target = ents.find(target =>
|4885|    |-		this.CanAttack(target)
|4886|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4885|+		this.CanAttack(target) &&
|    |4886|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4887|4887| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4888|4888| 	);
|4889|4889| 	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
|4883|4883| {
|4884|4884| 	var target = ents.find(target =>
|4885|4885| 		this.CanAttack(target)
|4886|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4887|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4886|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4887|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4888|4888| 	);
|4889|4889| 	if (!target)
|4890|4890| 		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
|4949|4949| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|4950|4950| 	if (this.isGuardOf)
|4951|4951| 	{
|4952|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4952|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4953|4953| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4954|4954| 		if (cmpUnitAI && cmpAttack &&
|4955|4955| 		    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
|4953|4953| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4954|4954| 		if (cmpUnitAI && cmpAttack &&
|4955|4955| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|4956|    |-				return false;
|    |4956|+			return false;
|4957|4957| 	}
|4958|4958| 
|4959|4959| 	// 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
|4991|4991| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|4992|4992| 	if (this.isGuardOf)
|4993|4993| 	{
|4994|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4994|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4995|4995| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4996|4996| 		if (cmpUnitAI && cmpAttack &&
|4997|4997| 		    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
|5004|5004| 	return false;
|5005|5005| };
|5006|5006| 
|5007|    |-//// External interface functions ////
|    |5007|+// // External interface functions ////
|5008|5008| 
|5009|5009| UnitAI.prototype.SetFormationController = function(ent)
|5010|5010| {
|    | [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
|5160|5160| 	{
|5161|5161| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|5162|5162| 			return;
|5163|    |-		else
|5164|    |-			this.RemoveGuard();
|    |5163|+		this.RemoveGuard();
|5165|5164| 	}
|5166|5165| 
|5167|5166| 	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
|5494|5494| 
|5495|5495| 	if (this.IsFormationController())
|5496|5496| 		this.CallMemberFunction("CancelSetupTradeRoute", [target]);
|5497|    |-}
|    |5497|+};
|5498|5498| /**
|5499|5499|  * Adds trade order to the queue. Either walk to the first market, or
|5500|5500|  * 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
|5515|5515| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5516|5516| 	{
|5517|5517| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5518|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5518|+		if (cmpTrader.HasBothMarkets() &&
|5519|5519| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5520|5520| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5521|5521| 		{
|    | [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
|5796|5796| 				{
|5797|5797| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5798|5798| 					var targetClasses = this.order.data.targetClasses;
|5799|    |-					if (targetClasses.attack && cmpIdentity
|5800|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5799|+					if (targetClasses.attack && cmpIdentity &&
|    |5800|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5801|5801| 						continue;
|5802|5802| 					if (targetClasses.avoid && cmpIdentity
|5803|5803| 						&& 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
|5799|5799| 					if (targetClasses.attack && cmpIdentity
|5800|5800| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5801|5801| 						continue;
|5802|    |-					if (targetClasses.avoid && cmpIdentity
|5803|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5802|+					if (targetClasses.avoid && cmpIdentity &&
|    |5803|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5804|5804| 						continue;
|5805|5805| 					// Only used by the AIs to prevent some choices of targets
|5806|5806| 					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
|5822|5822| 		{
|5823|5823| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5824|5824| 			var targetClasses = this.order.data.targetClasses;
|5825|    |-			if (cmpIdentity && targetClasses.attack
|5826|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5825|+			if (cmpIdentity && targetClasses.attack &&
|    |5826|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5827|5827| 				continue;
|5828|5828| 			if (cmpIdentity && targetClasses.avoid
|5829|5829| 				&& 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
|5825|5825| 			if (cmpIdentity && targetClasses.attack
|5826|5826| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5827|5827| 				continue;
|5828|    |-			if (cmpIdentity && targetClasses.avoid
|5829|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5828|+			if (cmpIdentity && targetClasses.avoid &&
|    |5829|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5830|5830| 				continue;
|5831|5831| 			// Only used by the AIs to prevent some choices of targets
|5832|5832| 			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
|5985|5985| 
|5986|5986| UnitAI.prototype.SetHeldPosition = function(x, z)
|5987|5987| {
|5988|    |-	this.heldPosition = {"x": x, "z": z};
|    |5988|+	this.heldPosition = { "x": x, "z": z};
|5989|5989| };
|5990|5990| 
|5991|5991| 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
|5985|5985| 
|5986|5986| UnitAI.prototype.SetHeldPosition = function(x, z)
|5987|5987| {
|5988|    |-	this.heldPosition = {"x": x, "z": z};
|    |5988|+	this.heldPosition = {"x": x, "z": z };
|5989|5989| };
|5990|5990| 
|5991|5991| 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
|6012|6012| 	return false;
|6013|6013| };
|6014|6014| 
|6015|    |-//// Helper functions ////
|    |6015|+// // Helper functions ////
|6016|6016| 
|6017|6017| /**
|6018|6018|  * 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
|6031|6031| 		return undefined;
|6032|6032| 
|6033|6033| 	return component.GetRange(type);
|6034|    |-}
|    |6034|+};
|6035|6035| 
|6036|6036| UnitAI.prototype.CanAttack = function(target)
|6037|6037| {
|    | [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
|6207|6207| 	return cmpPack && cmpPack.IsPacking();
|6208|6208| };
|6209|6209| 
|6210|    |-//// Formation specific functions ////
|    |6210|+// // Formation specific functions ////
|6211|6211| 
|6212|6212| UnitAI.prototype.IsAttackingAsFormation = function()
|6213|6213| {
|    | [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
|6212|6212| UnitAI.prototype.IsAttackingAsFormation = function()
|6213|6213| {
|6214|6214| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|6215|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|6216|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |6215|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |6216|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6217|6217| };
|6218|6218| 
|6219|6219| //// 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
|6216|6216| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6217|6217| };
|6218|6218| 
|6219|    |-//// Animal specific functions ////
|    |6219|+// // Animal specific functions ////
|6220|6220| 
|6221|6221| UnitAI.prototype.MoveRandomly = function(distance)
|6222|6222| {

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|3932| »   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
|4869| »   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
|4884| »   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
|4932| »   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
|4955| »   »   ····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
|2043| »   »   »   »   »   »   &&·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
|3056| »   »   »   »   »   this.SetAnimationVariant(this.formationAnimationVariant)
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|4886| »   »   &&·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
|4887| »   »   &&·(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
|5497| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|5800| »   »   »   »   »   »   &&·!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
|5803| »   »   »   »   »   »   &&·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
|5816| »   var·targets·=·this.GetTargetsFromUnit();
|    | [NORMAL] JSHintBear:
|    | 'targets' is already defined.

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

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|5826| »   »   »   »   &&·!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
|5829| »   »   »   »   &&·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
|6034| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|6216| »   »   &&·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/2394/display/redirect