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 @@ -2419,6 +2419,11 @@ "APPROACHING": { "enter": function() { this.gatheringTarget = this.order.data.target; // temporary, deleted in "leave". + if (this.CheckRange(this.order.data, IID_ResourceGatherer)) + { + this.SetNextState("GATHERING"); + return true; + } // If we can't move, assume we'll fail any subsequent order // and finish the order entirely to avoid an infinite loop. @@ -2449,11 +2454,6 @@ this.SetNextState("FINDINGNEWTARGET"); return true; } - if (this.CheckRange(this.order.data, IID_ResourceGatherer)) - { - this.SetNextState("GATHERING"); - return true; - } this.SetAnimationVariant("approach_" + this.order.data.type.specific); return false; }, @@ -2523,13 +2523,13 @@ this.order.data.force = false; this.order.data.autoharvest = true; + this.FaceTowardsTarget(this.order.data.target); if (!cmpResourceGatherer.StartGathering(this.order.data.target, IID_UnitAI)) { this.ProcessMessage("TargetInvalidated"); return true; } - this.FaceTowardsTarget(this.order.data.target); return false; }, @@ -2661,12 +2661,13 @@ } this.order.data.formerTarget = this.order.data.target; this.order.data.target = nearestDropsite; + this.SetDefaultAnimationVariant(); + if (this.CheckTargetRange(this.order.data.target, IID_ResourceGatherer)) { this.SetNextState("DROPPINGRESOURCES"); return true; } - this.SetDefaultAnimationVariant(); this.SetNextState("APPROACHING"); return true; }, @@ -2683,6 +2684,7 @@ cmpResourceGatherer.IsTargetInRange(this.order.data.target)) { cmpResourceGatherer.CommitResources(this.order.data.target); + this.SetDefaultAnimationVariant(); this.SetNextState("GATHER.APPROACHING"); } else