From df1d5d2260b652f343d4afd28d87b5a15c52f342 Mon Sep 17 00:00:00 2001 From: mimo Date: Mon, 11 Nov 2013 16:29:44 +0000 Subject: [PATCH] fix tag 2102648f7c which had unwanted changes This was SVN commit r14146. --- .../simulation/components/ProductionQueue.js | 2 +- .../public/simulation/components/UnitAI.js | 37 +++++++++++-------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/binaries/data/mods/public/simulation/components/ProductionQueue.js b/binaries/data/mods/public/simulation/components/ProductionQueue.js index ded6f8688d..68ecc2e685 100644 --- a/binaries/data/mods/public/simulation/components/ProductionQueue.js +++ b/binaries/data/mods/public/simulation/components/ProductionQueue.js @@ -526,7 +526,7 @@ ProductionQueue.prototype.SpawnUnits = function(templateName, count, metadata) createdEnts.push(ent); } - if (spawnedEnts.length > 0) + if (spawnedEnts.length > 0 && !cmpAutoGarrison) { // If a rally point is set, walk towards it (in formation) using a suitable command based on where the // rally point is placed. diff --git a/binaries/data/mods/public/simulation/components/UnitAI.js b/binaries/data/mods/public/simulation/components/UnitAI.js index 18eb6c728e..b435a6143b 100644 --- a/binaries/data/mods/public/simulation/components/UnitAI.js +++ b/binaries/data/mods/public/simulation/components/UnitAI.js @@ -774,26 +774,31 @@ var UnitFsmSpec = { }, "Order.Garrison": function(msg) { - // TODO: on what should we base this range? - // Check if we are already in range, otherwise walk there - if (!this.CheckTargetRangeExplicit(msg.data.target, 0, 10)) + if (!Engine.QueryInterface(msg.data.target, IID_GarrisonHolder)) { - if (!this.TargetIsAlive(msg.data.target) || !this.CheckTargetVisible(msg.data.target)) - // The target was destroyed - this.FinishOrder(); - else - // Out of range; move there in formation - this.PushOrderFront("WalkToTargetRange", { "target": msg.data.target, "min": 0, "max": 10 }); + this.FinishOrder(); return; } + // Check if we are already in range, otherwise walk there + if (!this.CheckGarrisonRange(msg.data.target)) + { + if (!this.CheckTargetVisible(msg.data.target)) + { + this.FinishOrder(); + return; + } + else + { + // Out of range; move there in formation + if (this.MoveToGarrisonRange(msg.data.target)) + { + this.SetNextState("GARRISON.APPROACHING"); + return; + } + } + } - var cmpFormation = Engine.QueryInterface(this.entity, IID_Formation); - // We don't want to rearrange the formation if the individual units are carrying - // out a task and one of the members dies/leaves the formation. - cmpFormation.SetRearrange(false); - cmpFormation.CallMemberFunction("Garrison", [msg.data.target, false]); - - this.SetNextStateAlwaysEntering("MEMBER"); + this.SetNextState("GARRISON.GARRISONING"); }, "Order.Gather": function(msg) {