Index: binaries/data/mods/public/simulation/components/UnitAI.js =================================================================== --- binaries/data/mods/public/simulation/components/UnitAI.js +++ binaries/data/mods/public/simulation/components/UnitAI.js @@ -2132,7 +2132,7 @@ return; // don't use ownership because this is called after a conversion/resignation // and the ownership would be invalid then. - var cmpSupply = Engine.QueryInterface(this.gatheringTarget, IID_ResourceSupply); + let cmpSupply = Engine.QueryInterface(this.gatheringTarget, IID_ResourceSupply); if (cmpSupply) cmpSupply.RemoveGatherer(this.entity); delete this.gatheringTarget; @@ -2184,8 +2184,8 @@ // Calculate timing based on gather rates // This allows the gather rate to control how often we gather, instead of how much. - var cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer); - var rate = cmpResourceGatherer.GetTargetGatherRate(this.gatheringTarget); + let cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer); + let rate = cmpResourceGatherer.GetTargetGatherRate(this.gatheringTarget); if (!rate) { @@ -2203,9 +2203,8 @@ // Scale timing interval based on rate, and start timer // The offset should be at least as long as the repeat time so we use the same value for both. - var offset = 1000/rate; - var repeat = offset; - this.StartTimer(offset, repeat); + let offset = 1000 / rate; + this.StartTimer(offset, offset); // We want to start the gather animation as soon as possible, // but only if we're actually at the target and it's still alive @@ -2227,7 +2226,7 @@ // don't use ownership because this is called after a conversion/resignation // and the ownership would be invalid then. - var cmpSupply = Engine.QueryInterface(this.gatheringTarget, IID_ResourceSupply); + let cmpSupply = Engine.QueryInterface(this.gatheringTarget, IID_ResourceSupply); if (cmpSupply) cmpSupply.RemoveGatherer(this.entity); delete this.gatheringTarget; @@ -2299,8 +2298,8 @@ // return to the nearest dropsite if (status.filled) { - let nearby = this.FindNearestDropsite(resourceType.generic); - if (nearby) + let nearbyDropsite = this.FindNearestDropsite(resourceType.generic); + if (nearbyDropsite) { // (Keep this Gather order on the stack so we'll // continue gathering after returning) @@ -2308,7 +2307,7 @@ // trying to gather from it. if (status.exhausted) this.order.data.target = INVALID_ENTITY; - this.PushOrderFront("ReturnResource", { "target": nearby, "force": false }); + this.PushOrderFront("ReturnResource", { "target": nearbyDropsite, "force": false }); return; } @@ -2336,9 +2335,9 @@ this.orderQueue.length > 1 && this.orderQueue[1] !== "ReturnResource" && (this.orderQueue[1].type !== "Gather" || this.orderQueue[1].data.type.generic !== resourceType.generic)) { - let nearby = this.FindNearestDropsite(resourceType.generic); - if (nearby) - this.orderQueue.splice(1, 0, { "type": "ReturnResource", "data": { "target": nearby, "force": false } }); + let nearbyDropsite = this.FindNearestDropsite(resourceType.generic); + if (nearbyDropsite) + this.orderQueue.splice(1, 0, { "type": "ReturnResource", "data": { "target": nearbyDropsite, "force": false } }); } // Must go before FinishOrder or this.order will be undefined. @@ -2365,7 +2364,7 @@ { // Try to find a new resource of the same specific type near the initial resource position: // Also don't switch to a different type of huntable animal - let nearby = this.FindNearbyResource((ent, type, template) => { + let nearbyResource = this.FindNearbyResource((ent, type, template) => { if (previousTarget == ent) return false; @@ -2376,9 +2375,9 @@ (type.specific != "meat" || resourceTemplate == template); }, new Vector2D(initPos.x, initPos.z)); - if (nearby) + if (nearbyResource) { - this.PerformGather(nearby, false, false); + this.PerformGather(nearbyResource, false, false); return true; } @@ -2395,10 +2394,10 @@ // drop it off, and if not then we might as well head to the dropsite // anyway because that's a nice enough place to congregate and idle - let nearby = this.FindNearestDropsite(resourceType.generic); - if (nearby) + let nearbyDropsite = this.FindNearestDropsite(resourceType.generic); + if (nearbyDropsite) { - this.PushOrderFront("ReturnResource", { "target": nearby, "force": false }); + this.PushOrderFront("ReturnResource", { "target": nearbyDropsite, "force": false }); return true; }