Index: ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js +++ ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js @@ -2795,9 +2795,8 @@ "GARRISONED": { "enter": function() { - if (this.order.data.target) - var target = this.order.data.target; - else + let target = this.order.data.target; + if (!target) { this.FinishOrder(); return true; @@ -2808,7 +2807,6 @@ // Check that we can garrison here if (this.CanGarrison(target)) - { // Check that we're in range of the garrison target if (this.CheckGarrisonRange(target)) { @@ -2859,7 +2857,10 @@ } if (this.IsTurret()) + { this.SetNextState("IDLE"); + return true; + } return false; } @@ -2878,13 +2879,9 @@ } } - if (!this.CheckTargetRangeExplicit(target, 0, 0) && this.MoveToTarget(target)) - { - this.SetNextState("APPROACHING"); - return false; - } + this.SetNextState("APPROACHING"); + return true; } - } // Garrisoning failed for some reason, so finish the order this.FinishOrder(); return true; @@ -3045,7 +3042,7 @@ "ROAMING": { "enter": function() { // Walk in a random direction - this.SelectAnimation("walk", false, 1); + this.SelectAnimation("move", false, 1); this.SetFacePointAfterMove(false); this.MoveRandomly(+this.template.RoamDistance); // Set a random timer to switch to feeding state @@ -5199,7 +5196,7 @@ } this.waypoints = undefined; - return this.MoveToTarget(targetMarket); + return this.MoveToTargetRange(targetMarket, IID_Trader); }; UnitAI.prototype.PerformTradeAndMoveToNextMarket = function(currentMarket)