diff --git a/binaries/data/mods/public/simulation/components/UnitAI.js b/binaries/data/mods/public/simulation/components/UnitAI.js index 4b06b38af5..53844d902e 100644 --- a/binaries/data/mods/public/simulation/components/UnitAI.js +++ b/binaries/data/mods/public/simulation/components/UnitAI.js @@ -2795,9 +2795,8 @@ UnitAI.prototype.UnitFsmSpec = { "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 @@ UnitAI.prototype.UnitFsmSpec = { // 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 @@ UnitAI.prototype.UnitFsmSpec = { } if (this.IsTurret()) + { this.SetNextState("IDLE"); + return true; + } return false; } @@ -2878,13 +2879,9 @@ UnitAI.prototype.UnitFsmSpec = { } } - 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 @@ UnitAI.prototype.UnitFsmSpec = { "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 @@ UnitAI.prototype.MoveToMarket = function(targetMarket) } this.waypoints = undefined; - return this.MoveToTarget(targetMarket); + return this.MoveToTargetRange(targetMarket, IID_Trader); }; UnitAI.prototype.PerformTradeAndMoveToNextMarket = function(currentMarket)