Page MenuHomeWildfire Games

Cache isHealer [UnitAi]
AbandonedPublic

Authored by Silier on Dec 28 2019, 11:12 PM.

Details

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

IID_Heal interface is still available or not.
It is not needed to call for it every time code is asking if entity is healer.

IsHealer() is called from timer in Idle state, setup range queries, update range queries, UnitAi.prototype.Attack, UnitAI.prototype.FindWalkAndFightTargets

Timer in idle state itself is called often per match.

Reducing number of callings to engine for healer interface.

Test Plan

Confirm it does not break anything.

Event Timeline

Silier created this revision.Dec 28 2019, 11:12 PM
Silier added a reviewer: Restricted Owners Package.

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

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

Stan added a subscriber: Stan.Dec 28 2019, 11:14 PM

Can a healer lose his ability to heal?

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

If using a ternary one should never have true: false :P

If you can remove/disable IID_Heal interface during match, then yes.

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
| 780| 780| 					this.FinishOrder();
| 781| 781| 					return;
| 782| 782| 				}
| 783|    |-				else
| 784|    |-				{
|    | 783|+				
| 785| 784| 					this.SetNextState("GARRISON.APPROACHING");
| 786| 785| 					return;
| 787|    |-				}
|    | 786|+				
| 788| 787| 			}
| 789| 788| 
| 790| 789| 			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
|1052|1052| 			},
|1053|1053| 		},
|1054|1054| 
|1055|    |-		"GARRISON":{
|    |1055|+		"GARRISON": {
|1056|1056| 			"APPROACHING": {
|1057|1057| 				"enter": function() {
|1058|1058| 					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
|2023|2023| 
|2024|2024| 				"Attacked": function(msg) {
|2025|2025| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|2026|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|2027|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |2026|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |2027|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|2028|2028| 						this.RespondToTargetedEntities([msg.data.attacker]);
|2029|2029| 				},
|2030|2030| 			},
|    | [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
|2758|2758| 					{
|2759|2759| 						// The building was already finished/fully repaired before we arrived;
|2760|2760| 						// let the ConstructionFinished handler handle this.
|2761|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2761|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2762|2762| 						return true;
|2763|2763| 					}
|2764|2764| 
|    | [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
|2758|2758| 					{
|2759|2759| 						// The building was already finished/fully repaired before we arrived;
|2760|2760| 						// let the ConstructionFinished handler handle this.
|2761|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2761|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2762|2762| 						return true;
|2763|2763| 					}
|2764|2764| 
|    | [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
|3278|3278| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3279|3279| 
|3280|3280| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3281|    |-							// only used for domestic animals
|    |3281|+		// only used for domestic animals
|3282|3282| 	},
|3283|3283| };
|3284|3284| 
|    | [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
|3337|3337| 
|3338|3338| UnitAI.prototype.IsAnimal = function()
|3339|3339| {
|3340|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3340|+	return (!!this.template.NaturalBehaviour);
|3341|3341| };
|3342|3342| 
|3343|3343| UnitAI.prototype.IsDangerousAnimal = function()
|    | [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
|3355|3355| UnitAI.prototype.IsHealer = function()
|3356|3356| {
|3357|3357| 	if (this.isHealer === undefined)
|3358|    |-		this.isHealer = Engine.QueryInterface(this.entity, IID_Heal) ? true : false;
|    |3358|+		this.isHealer = !!Engine.QueryInterface(this.entity, IID_Heal);
|3359|3359| 	return this.isHealer;
|3360|3360| };
|3361|3361| 
|    | [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
|3455|3455| 		{
|3456|3456| 			let index = this.GetCurrentState().indexOf(".");
|3457|3457| 			if (index != -1)
|3458|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3458|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3459|3459| 			this.Stop(false);
|3460|3460| 		}
|3461|3461| 
|    | [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
|3511|3511| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3512|3512| 			continue;
|3513|3513| 		if (i == 0)
|3514|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3514|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3515|3515| 		else
|3516|3516| 			this.orderQueue.splice(i, 1);
|3517|3517| 		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
|3511|3511| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3512|3512| 			continue;
|3513|3513| 		if (i == 0)
|3514|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3514|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3515|3515| 		else
|3516|3516| 			this.orderQueue.splice(i, 1);
|3517|3517| 		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
|3595|3595| };
|3596|3596| 
|3597|3597| 
|3598|    |-//// FSM linkage functions ////
|    |3598|+// // FSM linkage functions ////
|3599|3599| 
|3600|3600| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3601|3601| 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
|3765|3765| 				continue;
|3766|3766| 			if (this.orderQueue[i].type == type)
|3767|3767| 				continue;
|3768|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3768|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3769|3769| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3770|3770| 			return;
|3771|3771| 		}
|    | [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
|3765|3765| 				continue;
|3766|3766| 			if (this.orderQueue[i].type == type)
|3767|3767| 				continue;
|3768|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3768|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3769|3769| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3770|3770| 			return;
|3771|3771| 		}
|    | [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
|4007|4007| 	if (data.timerRepeat === undefined)
|4008|4008| 		this.timer = undefined;
|4009|4009| 
|4010|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4010|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|4011|4011| };
|4012|4012| 
|4013|4013| /**
|    | [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
|4007|4007| 	if (data.timerRepeat === undefined)
|4008|4008| 		this.timer = undefined;
|4009|4009| 
|4010|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4010|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|4011|4011| };
|4012|4012| 
|4013|4013| /**
|    | [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
|4052|4052| 	// TODO: This is a bit inefficient since every unit listens to every
|4053|4053| 	// construction message - ideally we could scope it to only the one we're building
|4054|4054| 
|4055|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4055|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|4056|4056| };
|4057|4057| 
|4058|4058| 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
|4052|4052| 	// TODO: This is a bit inefficient since every unit listens to every
|4053|4053| 	// construction message - ideally we could scope it to only the one we're building
|4054|4054| 
|4055|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4055|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|4056|4056| };
|4057|4057| 
|4058|4058| 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
|4077|4077| 
|4078|4078| UnitAI.prototype.OnAttacked = function(msg)
|4079|4079| {
|4080|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4080|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|4081|4081| };
|4082|4082| 
|4083|4083| 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
|4077|4077| 
|4078|4078| UnitAI.prototype.OnAttacked = function(msg)
|4079|4079| {
|4080|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4080|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|4081|4081| };
|4082|4082| 
|4083|4083| 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
|4082|4082| 
|4083|4083| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4084|4084| {
|4085|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4085|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|4086|4086| };
|4087|4087| 
|4088|4088| 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
|4082|4082| 
|4083|4083| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4084|4084| {
|4085|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4085|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|4086|4086| };
|4087|4087| 
|4088|4088| 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
|4087|4087| 
|4088|4088| UnitAI.prototype.OnHealthChanged = function(msg)
|4089|4089| {
|4090|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4090|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|4091|4091| };
|4092|4092| 
|4093|4093| 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
|4087|4087| 
|4088|4088| UnitAI.prototype.OnHealthChanged = function(msg)
|4089|4089| {
|4090|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4090|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|4091|4091| };
|4092|4092| 
|4093|4093| 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
|4093|4093| UnitAI.prototype.OnRangeUpdate = function(msg)
|4094|4094| {
|4095|4095| 	if (msg.tag == this.losRangeQuery)
|4096|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4096|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|4097|4097| 	else if (msg.tag == this.losHealRangeQuery)
|4098|4098| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4099|4099| };
|    | [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
|4093|4093| UnitAI.prototype.OnRangeUpdate = function(msg)
|4094|4094| {
|4095|4095| 	if (msg.tag == this.losRangeQuery)
|4096|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4096|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|4097|4097| 	else if (msg.tag == this.losHealRangeQuery)
|4098|4098| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4099|4099| };
|    | [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| 	if (msg.tag == this.losRangeQuery)
|4096|4096| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4097|4097| 	else if (msg.tag == this.losHealRangeQuery)
|4098|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4098|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|4099|4099| };
|4100|4100| 
|4101|4101| 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
|4095|4095| 	if (msg.tag == this.losRangeQuery)
|4096|4096| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4097|4097| 	else if (msg.tag == this.losHealRangeQuery)
|4098|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4098|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|4099|4099| };
|4100|4100| 
|4101|4101| 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
|4100|4100| 
|4101|4101| UnitAI.prototype.OnPackFinished = function(msg)
|4102|4102| {
|4103|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4103|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|4104|4104| };
|4105|4105| 
|4106|4106| //// 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
|4100|4100| 
|4101|4101| UnitAI.prototype.OnPackFinished = function(msg)
|4102|4102| {
|4103|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4103|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|4104|4104| };
|4105|4105| 
|4106|4106| //// 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
|4103|4103| 	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|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
|4771|4771| UnitAI.prototype.AttackEntityInZone = function(ents)
|4772|4772| {
|4773|4773| 	var target = ents.find(target =>
|4774|    |-		this.CanAttack(target)
|4775|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4774|+		this.CanAttack(target) &&
|    |4775|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4776|4776| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4777|4777| 	);
|4778|4778| 	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
|4772|4772| {
|4773|4773| 	var target = ents.find(target =>
|4774|4774| 		this.CanAttack(target)
|4775|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4776|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4775|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4776|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4777|4777| 	);
|4778|4778| 	if (!target)
|4779|4779| 		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
|4836|4836| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|4837|4837| 	if (this.isGuardOf)
|4838|4838| 	{
|4839|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4839|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4840|4840| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4841|4841| 		if (cmpUnitAI && cmpAttack &&
|4842|4842| 		    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
|4840|4840| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4841|4841| 		if (cmpUnitAI && cmpAttack &&
|4842|4842| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|4843|    |-				return false;
|    |4843|+			return false;
|4844|4844| 	}
|4845|4845| 
|4846|4846| 	// 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
|4878|4878| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|4879|4879| 	if (this.isGuardOf)
|4880|4880| 	{
|4881|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4881|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4882|4882| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4883|4883| 		if (cmpUnitAI && cmpAttack &&
|4884|4884| 		    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
|4891|4891| 	return false;
|4892|4892| };
|4893|4893| 
|4894|    |-//// External interface functions ////
|    |4894|+// // External interface functions ////
|4895|4895| 
|4896|4896| UnitAI.prototype.SetFormationController = function(ent)
|4897|4897| {
|    | [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
|5047|5047| 	{
|5048|5048| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|5049|5049| 			return;
|5050|    |-		else
|5051|    |-			this.RemoveGuard();
|    |5050|+		this.RemoveGuard();
|5052|5051| 	}
|5053|5052| 
|5054|5053| 	this.AddOrder("Guard", { "target": target, "force": false }, queued);
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5389|5389| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5390|5390| 	{
|5391|5391| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5392|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5392|+		if (cmpTrader.HasBothMarkets() &&
|5393|5393| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5394|5394| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5395|5395| 		{
|    | [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
|5670|5670| 				{
|5671|5671| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5672|5672| 					var targetClasses = this.order.data.targetClasses;
|5673|    |-					if (targetClasses.attack && cmpIdentity
|5674|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5673|+					if (targetClasses.attack && cmpIdentity &&
|    |5674|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5675|5675| 						continue;
|5676|5676| 					if (targetClasses.avoid && cmpIdentity
|5677|5677| 						&& 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
|5673|5673| 					if (targetClasses.attack && cmpIdentity
|5674|5674| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5675|5675| 						continue;
|5676|    |-					if (targetClasses.avoid && cmpIdentity
|5677|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5676|+					if (targetClasses.avoid && cmpIdentity &&
|    |5677|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5678|5678| 						continue;
|5679|5679| 					// Only used by the AIs to prevent some choices of targets
|5680|5680| 					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
|5696|5696| 		{
|5697|5697| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5698|5698| 			var targetClasses = this.order.data.targetClasses;
|5699|    |-			if (cmpIdentity && targetClasses.attack
|5700|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5699|+			if (cmpIdentity && targetClasses.attack &&
|    |5700|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5701|5701| 				continue;
|5702|5702| 			if (cmpIdentity && targetClasses.avoid
|5703|5703| 				&& 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
|5699|5699| 			if (cmpIdentity && targetClasses.attack
|5700|5700| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5701|5701| 				continue;
|5702|    |-			if (cmpIdentity && targetClasses.avoid
|5703|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5702|+			if (cmpIdentity && targetClasses.avoid &&
|    |5703|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5704|5704| 				continue;
|5705|5705| 			// Only used by the AIs to prevent some choices of targets
|5706|5706| 			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
|5856|5856| 
|5857|5857| UnitAI.prototype.SetHeldPosition = function(x, z)
|5858|5858| {
|5859|    |-	this.heldPosition = {"x": x, "z": z};
|    |5859|+	this.heldPosition = { "x": x, "z": z};
|5860|5860| };
|5861|5861| 
|5862|5862| 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
|5856|5856| 
|5857|5857| UnitAI.prototype.SetHeldPosition = function(x, z)
|5858|5858| {
|5859|    |-	this.heldPosition = {"x": x, "z": z};
|    |5859|+	this.heldPosition = {"x": x, "z": z };
|5860|5860| };
|5861|5861| 
|5862|5862| 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
|5883|5883| 	return false;
|5884|5884| };
|5885|5885| 
|5886|    |-//// Helper functions ////
|    |5886|+// // Helper functions ////
|5887|5887| 
|5888|5888| UnitAI.prototype.CanAttack = function(target)
|5889|5889| {
|    | [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
|6087|6087| 	return cmpPack && cmpPack.IsPacking();
|6088|6088| };
|6089|6089| 
|6090|    |-//// Formation specific functions ////
|    |6090|+// // Formation specific functions ////
|6091|6091| 
|6092|6092| UnitAI.prototype.IsAttackingAsFormation = function()
|6093|6093| {
|    | [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
|6092|6092| UnitAI.prototype.IsAttackingAsFormation = function()
|6093|6093| {
|6094|6094| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|6095|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|6096|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |6095|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |6096|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6097|6097| };
|6098|6098| 
|6099|6099| //// 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
|6096|6096| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6097|6097| };
|6098|6098| 
|6099|    |-//// Animal specific functions ////
|    |6099|+// // Animal specific functions ////
|6100|6100| 
|6101|6101| UnitAI.prototype.MoveRandomly = function(distance)
|6102|6102| {

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
|1240| »   »   »   »   return·false;
|    | [NORMAL] ESLintBear (consistent-return):
|    | Method 'Timer' expected no return value.

binaries/data/mods/public/simulation/components/UnitAI.js
|3912| »   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
|4758| »   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
|4773| »   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
|4819| »   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
|4842| »   »   ····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
|2027| »   »   »   »   »   »   &&·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
|3859| »   »   var·order·=·{·"type":·type,·"data":·data·};
|    | [NORMAL] JSHintBear:
|    | 'order' is already defined.

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

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

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

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

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

binaries/data/mods/public/simulation/components/UnitAI.js
|5700| »   »   »   »   &&·!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
|5703| »   »   »   »   &&·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
|5778| »   »   var·cmpVision·=·Engine.QueryInterface(this.entity,·IID_Vision);
|    | [NORMAL] JSHintBear:
|    | 'cmpVision' is already defined.

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

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

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

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

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

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

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

I did some testing with this:

UnitAI.prototype.IsHealerCached = function()
{
	if (this.isHealer === undefined)
		this.isHealer = !!Engine.QueryInterface(this.entity, IID_Heal);
	return this.isHealer;
}

UnitAI.prototype.IsHealerOld = function()
{
	return !!Engine.QueryInterface(this.entity, IID_Heal);
}

UnitAI.prototype.IsHealer = function()
{
	let now = Date.now();
	let ishc;
//	for (let i = 0; i < 10000; ++i)
		 ishc = this.IsHealerCached();
	let ishc_now = Date.now() - now;

	now = Date.now();
	let ish;
//	for (let i = 0; i < 10000; ++i)
		ish = this.IsHealerOld();
	let ish_now = Date.now() - now;

	this.ish_total += ish_now;
	this.ishc_total += ishc_now;

	if (ishc != ish)
		error("IsHealer WRONG");

	warn("cached = " + this.ishc_total + " normal = " + this.ish_total);

	return ishc;
};

Only difference per unit I noticed was when I had loops active.

elexis added a subscriber: elexis.Dec 31 2019, 6:11 PM
In D2521#105491, @Angen wrote:

Only difference per unit I noticed was when I had loops active.

Milliseconds were measured. If the function call would take a millisecond, a simulation turn would probably take several seconds if not much more.
So the question is how much difference there was exactly, how much it would accumulate with the realistic worst case scenario (2000 player units and 1000 gaia units or something).
Guess there arent that many healers, but other components are accessed more frequently which could use the same pattern.
One can make an estimate by computing the average time for this call (diving total time by loop count), although that sometimes lies too (optimizer).

As mentioned in D2520, one could cache Engine.QueryInterface(this.entity, IID_Heal) (and exclude it from the serialization), initialize that on Init and remove the the IsHealer function by a check for that for further improvements.

It will probably be a tiny improvement, but perhaps one can squeeze out half a microsecond (?) if this change was applied across the board (as the function call should be quite cheap and the returned JS object is cached on the C++ side).

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

(Should not serialize properties that can be derived from the template / don't change simstate during simulation #3834)

Guess there arent that many healers, but other components are accessed more frequently which could use the same pattern.

IsHealer is called even unit is not healer :)

Silier abandoned this revision.Jul 17 2020, 12:41 PM