Page MenuHomeWildfire Games

Stop dodging arrows by patrol: Wait a few seconds between patrol waypoints.
Needs RevisionPublic

Authored by wraitii on Jul 27 2020, 11:41 AM.

Details

Reviewers
bb
Freagarach
Trac Tickets
#5106
Summary

Alternative to D2837 and D2767 for the patrol case.

This makes units wait a few seconds between each patrol waypoint. It negates the "dancing" aspect of patrol entirely.
It doesn't fix the order case, which isn't as bad but still problematic, so it should probably be used with one of the above two.

Also makes the formation and regular unit patrol code more similar.

Test Plan

Test that patrolling still works. Check that dancing-by-patrolling no longer does.

Diff Detail

Repository
rP 0 A.D. Public Repository
Branch
temp
Lint
Lint OK
SeverityLocationCodeMessage
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:354ESLintBear (consistent-return)ESLintBear (consistent-return)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:802ESLintBear (no-else-return)ESLintBear (no-else-return)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:2151ESLintBear (operator-linebreak)ESLintBear (operator-linebreak)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:2319ESLintBear (no-trailing-spaces)ESLintBear (no-trailing-spaces)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:2621ESLintBear (indent)ESLintBear (indent)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:3458ESLintBear (indent)ESLintBear (indent)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:3535ESLintBear (no-unneeded-ternary)ESLintBear (no-unneeded-ternary)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:3675ESLintBear (comma-spacing)ESLintBear (comma-spacing)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:3732ESLintBear (object-curly-spacing)ESLintBear (object-curly-spacing)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:3732ESLintBear (object-curly-spacing)ESLintBear (object-curly-spacing)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:3861ESLintBear (spaced-comment)ESLintBear (spaced-comment)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:4028ESLintBear (object-curly-spacing)ESLintBear (object-curly-spacing)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:4028ESLintBear (object-curly-spacing)ESLintBear (object-curly-spacing)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:4163ESLintBear (no-shadow)ESLintBear (no-shadow)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:4255ESLintBear (object-curly-spacing)ESLintBear (object-curly-spacing)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:4255ESLintBear (object-curly-spacing)ESLintBear (object-curly-spacing)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:4341ESLintBear (object-curly-spacing)ESLintBear (object-curly-spacing)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:4341ESLintBear (object-curly-spacing)ESLintBear (object-curly-spacing)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:4346ESLintBear (object-curly-spacing)ESLintBear (object-curly-spacing)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:4346ESLintBear (object-curly-spacing)ESLintBear (object-curly-spacing)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:4351ESLintBear (object-curly-spacing)ESLintBear (object-curly-spacing)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:4351ESLintBear (object-curly-spacing)ESLintBear (object-curly-spacing)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:4366ESLintBear (object-curly-spacing)ESLintBear (object-curly-spacing)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:4366ESLintBear (object-curly-spacing)ESLintBear (object-curly-spacing)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:4369ESLintBear (spaced-comment)ESLintBear (spaced-comment)
Unit
No Unit Test Coverage
Build Status
Buildable 13164
Build 26191: Vulcan BuildJenkins
Build 26190: Vulcan Build (macOS)Jenkins
Build 26189: Vulcan Build (Windows)Jenkins
Build 26188: arc lint + arc unit

Event Timeline

wraitii created this revision.Jul 27 2020, 11:41 AM

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
| 884| 884| 					this.FinishOrder();
| 885| 885| 					return;
| 886| 886| 				}
| 887|    |-				else
| 888|    |-				{
|    | 887|+				
| 889| 888| 					this.SetNextState("GARRISON.APPROACHING");
| 890| 889| 					return;
| 891|    |-				}
|    | 890|+				
| 892| 891| 			}
| 893| 892| 
| 894| 893| 			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
|1102|1102| 			return patrolState;
|1103|1103| 		})(),
|1104|1104| 
|1105|    |-		"GARRISON":{
|    |1105|+		"GARRISON": {
|1106|1106| 			"APPROACHING": {
|1107|1107| 				"enter": function() {
|1108|1108| 					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
|2062|2062| 
|2063|2063| 				"Attacked": function(msg) {
|2064|2064| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|2065|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|2066|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |2065|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |2066|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|2067|2067| 						this.RespondToTargetedEntities([msg.data.attacker]);
|2068|2068| 				},
|2069|2069| 			},
|    | [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
|2221|2221| 					"MovementUpdate": function(msg) {
|2222|2222| 						// If it looks like the path is failing, and we are close enough (3 tiles) from wanted range
|2223|2223| 						// stop anyways. This avoids pathing for an unreachable goal and reduces lag considerably.
|2224|    |-						if (msg.likelyFailure || 
|    |2224|+						if (msg.likelyFailure ||
|2225|2225| 							msg.obstructed && this.RelaxedMaxRangeCheck(this.order.data, this.order.data.max + this.DefaultRelaxedMaxRange) ||
|2226|2226| 							!msg.obstructed && this.CheckRange(this.order.data))
|2227|2227| 							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
|2524|2524| 
|2525|2525| 								return type.specific == resourceType.specific &&
|2526|2526| 								    (type.specific != "meat" || resourceTemplate == template);
|2527|    |-						});
|    |2527|+							});
|2528|2528| 
|2529|2529| 						if (nearbyResource)
|2530|2530| 						{
|    | [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
|2856|2856| 					{
|2857|2857| 						// The building was already finished/fully repaired before we arrived;
|2858|2858| 						// let the ConstructionFinished handler handle this.
|2859|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2859|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2860|2860| 						return true;
|2861|2861| 					}
|2862|2862| 
|    | [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
|2856|2856| 					{
|2857|2857| 						// The building was already finished/fully repaired before we arrived;
|2858|2858| 						// let the ConstructionFinished handler handle this.
|2859|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2859|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2860|2860| 						return true;
|2861|2861| 					}
|2862|2862| 
|    | [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
|3146|3146| 				this.StopTimer();
|3147|3147| 				this.ResetAnimation();
|3148|3148| 				if (this.formationAnimationVariant)
|3149|    |-					this.SetAnimationVariant(this.formationAnimationVariant)
|    |3149|+					this.SetAnimationVariant(this.formationAnimationVariant);
|3150|3150| 				else
|3151|3151| 					this.SetDefaultAnimationVariant();
|3152|3152| 				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
|3360|3360| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3361|3361| 
|3362|3362| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3363|    |-							// only used for domestic animals
|    |3363|+		// only used for domestic animals
|3364|3364| 
|3365|3365| 		// Reuse the same garrison behaviour for animals.
|3366|3366| 		"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
|3410|3410| 
|3411|3411| UnitAI.prototype.IsAnimal = function()
|3412|3412| {
|3413|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3413|+	return (!!this.template.NaturalBehaviour);
|3414|3414| };
|3415|3415| 
|3416|3416| 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
|3550|3550| 		{
|3551|3551| 			let index = this.GetCurrentState().indexOf(".");
|3552|3552| 			if (index != -1)
|3553|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3553|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3554|3554| 			this.Stop(false);
|3555|3555| 		}
|3556|3556| 
|    | [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
|3607|3607| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3608|3608| 			continue;
|3609|3609| 		if (i == 0)
|3610|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3610|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3611|3611| 		else
|3612|3612| 			this.orderQueue.splice(i, 1);
|3613|3613| 		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
|3607|3607| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3608|3608| 			continue;
|3609|3609| 		if (i == 0)
|3610|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3610|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3611|3611| 		else
|3612|3612| 			this.orderQueue.splice(i, 1);
|3613|3613| 		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
|3736|3736| };
|3737|3737| 
|3738|3738| 
|3739|    |-//// FSM linkage functions ////
|    |3739|+// // FSM linkage functions ////
|3740|3740| 
|3741|3741| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3742|3742| 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
|3909|3909| 				continue;
|3910|3910| 			if (this.orderQueue[i].type == type)
|3911|3911| 				continue;
|3912|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3912|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3913|3913| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3914|3914| 			return;
|3915|3915| 		}
|    | [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
|3909|3909| 				continue;
|3910|3910| 			if (this.orderQueue[i].type == type)
|3911|3911| 				continue;
|3912|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3912|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3913|3913| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3914|3914| 			return;
|3915|3915| 		}
|    | [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
|4150|4150| 	if (data.timerRepeat === undefined)
|4151|4151| 		this.timer = undefined;
|4152|4152| 
|4153|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4153|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|4154|4154| };
|4155|4155| 
|4156|4156| /**
|    | [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
|4150|4150| 	if (data.timerRepeat === undefined)
|4151|4151| 		this.timer = undefined;
|4152|4152| 
|4153|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4153|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|4154|4154| };
|4155|4155| 
|4156|4156| /**
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4195|4195| 	// TODO: This is a bit inefficient since every unit listens to every
|4196|4196| 	// construction message - ideally we could scope it to only the one we're building
|4197|4197| 
|4198|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4198|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|4199|4199| };
|4200|4200| 
|4201|4201| 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
|4195|4195| 	// TODO: This is a bit inefficient since every unit listens to every
|4196|4196| 	// construction message - ideally we could scope it to only the one we're building
|4197|4197| 
|4198|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4198|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|4199|4199| };
|4200|4200| 
|4201|4201| 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
|4234|4234| 	if (msg.fromStatusEffect)
|4235|4235| 		return;
|4236|4236| 
|4237|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4237|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|4238|4238| };
|4239|4239| 
|4240|4240| 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
|4234|4234| 	if (msg.fromStatusEffect)
|4235|4235| 		return;
|4236|4236| 
|4237|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4237|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|4238|4238| };
|4239|4239| 
|4240|4240| 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
|4239|4239| 
|4240|4240| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4241|4241| {
|4242|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4242|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|4243|4243| };
|4244|4244| 
|4245|4245| 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
|4239|4239| 
|4240|4240| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4241|4241| {
|4242|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4242|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|4243|4243| };
|4244|4244| 
|4245|4245| 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
|4244|4244| 
|4245|4245| UnitAI.prototype.OnHealthChanged = function(msg)
|4246|4246| {
|4247|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4247|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|4248|4248| };
|4249|4249| 
|4250|4250| 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
|4244|4244| 
|4245|4245| UnitAI.prototype.OnHealthChanged = function(msg)
|4246|4246| {
|4247|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4247|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|4248|4248| };
|4249|4249| 
|4250|4250| 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
|4259|4259| 
|4260|4260| UnitAI.prototype.OnPackFinished = function(msg)
|4261|4261| {
|4262|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4262|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|4263|4263| };
|4264|4264| 
|4265|4265| //// Helper functions to be called by the FSM ////
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4259|4259| 
|4260|4260| UnitAI.prototype.OnPackFinished = function(msg)
|4261|4261| {
|4262|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4262|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|4263|4263| };
|4264|4264| 
|4265|4265| //// Helper functions to be called by the FSM ////
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4262|4262| 	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|4263|4263| };
|4264|4264| 
|4265|    |-//// Helper functions to be called by the FSM ////
|    |4265|+// // Helper functions to be called by the FSM ////
|4266|4266| 
|4267|4267| UnitAI.prototype.GetWalkSpeed = function()
|4268|4268| {
|    | [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
|4992|4992| UnitAI.prototype.AttackEntityInZone = function(ents)
|4993|4993| {
|4994|4994| 	var target = ents.find(target =>
|4995|    |-		this.CanAttack(target)
|4996|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4995|+		this.CanAttack(target) &&
|    |4996|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4997|4997| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4998|4998| 	);
|4999|4999| 	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
|4993|4993| {
|4994|4994| 	var target = ents.find(target =>
|4995|4995| 		this.CanAttack(target)
|4996|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4997|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4996|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4997|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4998|4998| 	);
|4999|4999| 	if (!target)
|5000|5000| 		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
|5077|5077| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|5078|5078| 	if (this.isGuardOf)
|5079|5079| 	{
|5080|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |5080|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|5081|5081| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|5082|5082| 		if (cmpUnitAI && cmpAttack &&
|5083|5083| 		    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
|5081|5081| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|5082|5082| 		if (cmpUnitAI && cmpAttack &&
|5083|5083| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|5084|    |-				return false;
|    |5084|+			return false;
|5085|5085| 	}
|5086|5086| 
|5087|5087| 	// 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
|5119|5119| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|5120|5120| 	if (this.isGuardOf)
|5121|5121| 	{
|5122|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |5122|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|5123|5123| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|5124|5124| 		if (cmpUnitAI && cmpAttack &&
|5125|5125| 		    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
|5132|5132| 	return false;
|5133|5133| };
|5134|5134| 
|5135|    |-//// External interface functions ////
|    |5135|+// // External interface functions ////
|5136|5136| 
|5137|5137| UnitAI.prototype.SetFormationController = function(ent)
|5138|5138| {
|    | [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
|5288|5288| 	{
|5289|5289| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|5290|5290| 			return;
|5291|    |-		else
|5292|    |-			this.RemoveGuard();
|    |5291|+		this.RemoveGuard();
|5293|5292| 	}
|5294|5293| 
|5295|5294| 	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
|5622|5622| 
|5623|5623| 	if (this.IsFormationController())
|5624|5624| 		this.CallMemberFunction("CancelSetupTradeRoute", [target]);
|5625|    |-}
|    |5625|+};
|5626|5626| /**
|5627|5627|  * Adds trade order to the queue. Either walk to the first market, or
|5628|5628|  * 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
|5643|5643| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5644|5644| 	{
|5645|5645| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5646|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5646|+		if (cmpTrader.HasBothMarkets() &&
|5647|5647| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5648|5648| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5649|5649| 		{
|    | [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
|5950|5950| 				{
|5951|5951| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5952|5952| 					var targetClasses = this.order.data.targetClasses;
|5953|    |-					if (targetClasses.attack && cmpIdentity
|5954|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5953|+					if (targetClasses.attack && cmpIdentity &&
|    |5954|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5955|5955| 						continue;
|5956|5956| 					if (targetClasses.avoid && cmpIdentity
|5957|5957| 						&& 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
|5953|5953| 					if (targetClasses.attack && cmpIdentity
|5954|5954| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5955|5955| 						continue;
|5956|    |-					if (targetClasses.avoid && cmpIdentity
|5957|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5956|+					if (targetClasses.avoid && cmpIdentity &&
|    |5957|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5958|5958| 						continue;
|5959|5959| 					// Only used by the AIs to prevent some choices of targets
|5960|5960| 					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
|5976|5976| 		{
|5977|5977| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5978|5978| 			var targetClasses = this.order.data.targetClasses;
|5979|    |-			if (cmpIdentity && targetClasses.attack
|5980|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5979|+			if (cmpIdentity && targetClasses.attack &&
|    |5980|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5981|5981| 				continue;
|5982|5982| 			if (cmpIdentity && targetClasses.avoid
|5983|5983| 				&& 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
|5979|5979| 			if (cmpIdentity && targetClasses.attack
|5980|5980| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5981|5981| 				continue;
|5982|    |-			if (cmpIdentity && targetClasses.avoid
|5983|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5982|+			if (cmpIdentity && targetClasses.avoid &&
|    |5983|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5984|5984| 				continue;
|5985|5985| 			// Only used by the AIs to prevent some choices of targets
|5986|5986| 			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
|6132|6132| 
|6133|6133| UnitAI.prototype.SetHeldPosition = function(x, z)
|6134|6134| {
|6135|    |-	this.heldPosition = {"x": x, "z": z};
|    |6135|+	this.heldPosition = { "x": x, "z": z};
|6136|6136| };
|6137|6137| 
|6138|6138| 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
|6132|6132| 
|6133|6133| UnitAI.prototype.SetHeldPosition = function(x, z)
|6134|6134| {
|6135|    |-	this.heldPosition = {"x": x, "z": z};
|    |6135|+	this.heldPosition = {"x": x, "z": z };
|6136|6136| };
|6137|6137| 
|6138|6138| 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
|6159|6159| 	return false;
|6160|6160| };
|6161|6161| 
|6162|    |-//// Helper functions ////
|    |6162|+// // Helper functions ////
|6163|6163| 
|6164|6164| /**
|6165|6165|  * 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
|6178|6178| 		return undefined;
|6179|6179| 
|6180|6180| 	return component.GetRange(type);
|6181|    |-}
|    |6181|+};
|6182|6182| 
|6183|6183| UnitAI.prototype.CanAttack = function(target)
|6184|6184| {
|    | [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
|6354|6354| 	return cmpPack && cmpPack.IsPacking();
|6355|6355| };
|6356|6356| 
|6357|    |-//// Formation specific functions ////
|    |6357|+// // Formation specific functions ////
|6358|6358| 
|6359|6359| UnitAI.prototype.IsAttackingAsFormation = function()
|6360|6360| {
|    | [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
|6359|6359| UnitAI.prototype.IsAttackingAsFormation = function()
|6360|6360| {
|6361|6361| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|6362|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|6363|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |6362|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |6363|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6364|6364| };
|6365|6365| 
|6366|6366| //// 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
|6363|6363| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6364|6364| };
|6365|6365| 
|6366|    |-//// Animal specific functions ////
|    |6366|+// // Animal specific functions ////
|6367|6367| 
|6368|6368| UnitAI.prototype.MoveRandomly = function(distance)
|6369|6369| {
|    | [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
|6414|6414| {
|6415|6415| 	let cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion);
|6416|6416| 	return cmpUnitMotion && cmpUnitMotion.GetFacePointAfterMove();
|6417|    |-}
|    |6417|+};
|6418|6418| 
|6419|6419| UnitAI.prototype.AttackEntitiesByPreference = function(ents)
|6420|6420| {

binaries/data/mods/public/simulation/components/UnitAI.js
| 149| var·GetPatrolState·=·()·=>
|    | [NORMAL] ESLintBear (brace-rules/brace-on-same-line):
|    | Opening curly brace does not appear on the same line as controlling statement.

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|4055| »   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
|4979| »   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
|4994| »   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
|5060| »   let·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
|5083| »   »   ····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
|2066| »   »   »   »   »   »   &&·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
|3149| »   »   »   »   »   this.SetAnimationVariant(this.formationAnimationVariant)
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

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

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

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

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

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

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

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

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|6417| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.
Executing section cli...

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

None at all, “dodging” is not an issue in single-player.

Stan added inline comments.Aug 3 2020, 11:46 AM
binaries/data/mods/public/simulation/components/UnitAI.js
152

Any reason it's not in the prototype?

Nescio removed a subscriber: Nescio.Aug 3 2020, 11:47 AM
wraitii added inline comments.Aug 3 2020, 11:47 AM
binaries/data/mods/public/simulation/components/UnitAI.js
152

I don't need to store this, it's used to generate the FSM spec.

Stan added inline comments.Aug 3 2020, 11:49 AM
binaries/data/mods/public/simulation/components/UnitAI.js
152

I guess it could be const then also pretty sure you don't need the return ?

() => {return a } == () => a ?

bb added a comment.Wed, Aug 26, 9:37 PM

Code desperately asking for an animation, needs ticket or so.

The most important thing this fixes is formation dancing: patrolling extremely close distances with a formation, making the formation reform, rather than move. This is not fixed in D2837.

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

Don't think this is the way to avoid duplication in the unitAI. Also formations don;t need the animation changes. I rather go in the way of D2662, but that needs further designing. For now just clutter along in the messy fsm imo

225

slightly out of scope, but why aren't we using a rangeQuery here and depend on timers?

226

Instead of hardcoding it, rather make it a template value.

In D2913#129854, @bb wrote:

Code desperately asking for an animation, needs ticket or so.

Do you think the lack of animation blocks merging?
IMO it could be done later.

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

It makes it slightly easier to navigate for me since Sublime picks up on the dict better, but ay', I'll revert that change.

225

Mh, what do you mean? The point is to pretend we're looking around, so I don't see how a range query would help?

226

👍

bb added a comment.Fri, Aug 28, 8:18 PM
In D2913#129854, @bb wrote:

Code desperately asking for an animation, needs ticket or so.

Do you think the lack of animation blocks merging?
IMO it could be done later.

Absence of animation doesn't block merging, absence of ticket does ;)

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

Same comment applies to the (current) Patrolling state: we currently idle and check every 1000ms if there is some target near. But why we have this timer? Why not an active rangeQuery that informs us when a unit is close, so we react on that? Anyway seems out of scope for this patch though.

wraitii added inline comments.Mon, Aug 31, 11:29 AM
binaries/data/mods/public/simulation/components/UnitAI.js
225

Ah, yes, I see.
I need a timer here anyways because the unit needs to stop "looking around" after some time, but yes, a range query would make them react faster.

wraitii updated this revision to Diff 13355.Mon, Aug 31, 11:44 AM

I'll create the ticket before merging this then.

Address @bb's comments.

Owners added a subscriber: Restricted Owners Package.Mon, Aug 31, 11:45 AM
Freagarach requested changes to this revision.Thu, Sep 3, 10:14 AM
Freagarach added a subscriber: Freagarach.

The formation template needs an update.
Also formations don't patrol anymore.

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

Seconds, minutes, ms?

1005

Linter.

1070–1091

?

1678

Linter.

1751

This makes them wait at least one second (also birds).

binaries/data/mods/public/simulation/templates/template_unit.xml
129

This is misleading since they actually wait two seconds now.

This revision now requires changes to proceed.Thu, Sep 3, 10:14 AM
wraitii updated this revision to Diff 13465.Thu, Sep 10, 11:00 AM

Make formations walk again.

Fix remarks from the comments.

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

It's multiples of a second, I changed to an integer to enforce that.

1070–1091

Hm, to be honest I'd rather not keep using that FSM feature. Id anything, I'd go back to the "call a function that returns a dict" approach for this.

1751

Changed to >=

It looks much better with only one second waiting time :)

(You still have some cleaning to do here ^^ )

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

Any specific reason to limit it to integers?

225

slightly out of scope, but why aren't we using a rangeQuery here and depend on timers?

225
1070–1091

Well, it is still there and greatly reduces duplication, so IMHO there is no reason for not using it?

1751

Does one need a conversion to number here? (+this.template.PatrolWaitTime)

1757

?

binaries/data/mods/public/simulation/templates/template_bird.xml
29

(Doesn't really matter what is in here.)

binaries/data/mods/public/simulation/templates/template_formation.xml
66

Any specific reason for two seconds here instead of one?

wraitii marked 4 inline comments as done.Fri, Sep 11, 9:16 AM
wraitii added inline comments.
binaries/data/mods/public/simulation/components/UnitAI.js
27

Yes, since I'm using a timer of 1000 seconds you can't really use decimals in a meaningful way.

binaries/data/mods/public/simulation/templates/template_formation.xml
66

The formation controller ought to wait somewhat until all members are at the waypoint to carry on. However, it doesn't _actually_ check for that. So waiting one second more makes it more likely for all units to have some stoppage time.

wraitii added inline comments.Fri, Sep 11, 9:19 AM
binaries/data/mods/public/simulation/components/UnitAI.js
1070–1091

Core reason is I disagree that it "greatly reduces duplication" since the rest of the patrol state is also mostly duplicated, and in generation formations are duplicated.
Further, if we add animations, I think we need formation-specific code here, so I don't think it's a good move going forward.

wraitii marked 2 inline comments as done.Fri, Sep 11, 9:22 AM
wraitii updated this revision to Diff 13472.Fri, Sep 11, 9:22 AM

Possibly final cleanup.

Possibly final cleanup.

Did you try this in-game?

wraitii updated this revision to Diff 13473.Fri, Sep 11, 9:30 AM

Good thing I added a conditional there..

wraitii edited the summary of this revision. (Show Details)Fri, Sep 11, 9:30 AM
Freagarach accepted this revision.EditedFri, Sep 11, 9:43 AM

I'm not particularly fond of the the forced integer wait time, but I failed to device a better way without major changes (i.e. using a range query and just setting a single timer to go to the next waypoint).

Works as advertised, prevents dodging by patrol and looks quite okay with a one second wait time.

Code _can_ be improved, but only with significant effort it seems (see above; up to the creator of the patch to decide ;) ).

This revision is now accepted and ready to land.Fri, Sep 11, 9:43 AM
Freagarach added inline comments.Fri, Sep 11, 9:44 AM
binaries/data/mods/public/simulation/templates/template_formation.xml
3

And for the record.

Freagarach requested changes to this revision.Thu, Sep 17, 12:28 PM

See IRC on acceptance-day.

This revision now requires changes to proceed.Thu, Sep 17, 12:28 PM