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 @@ -2761,11 +2761,15 @@ }, "MovementUpdate": function(msg) { - // Check the dropsite is in range and we can return our resource there - // (we didn't get stopped before reaching it) + if (msg.likelyFailure || this.CheckTargetRange(this.order.data.target, IID_ResourceGatherer)) + this.SetNextState("DROPPINGRESOURCES"); + }, + }, + + "DROPPINGRESOURCES": { + "enter": function() { let cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer); - if (this.CheckTargetRange(this.order.data.target, IID_ResourceGatherer) && - this.CanReturnResource(this.order.data.target, true, cmpResourceGatherer)) + if (this.CanReturnResource(this.order.data.target, true, cmpResourceGatherer)) { cmpResourceGatherer.CommitResources(this.order.data.target); @@ -2775,26 +2779,17 @@ // Our next order should always be a Gather, // so just switch back to that order. this.FinishOrder(); - return; + return true; } - - if (msg.obstructed) - return; - - // If we are here: we are in range but not carrying the right resources (or resources at all), - // the dropsite was destroyed, or we couldn't reach it, or ownership changed. - // Look for a new one. - let genericType = cmpResourceGatherer.GetMainCarryingType(); - let nearby = this.FindNearestDropsite(genericType); + let nearby = this.FindNearestDropsite(cmpResourceGatherer.GetMainCarryingType()); + this.FinishOrder(); if (nearby) - { - this.FinishOrder(); this.PushOrderFront("ReturnResource", { "target": nearby, "force": false }); - return; - } - // Oh no, couldn't find any drop sites. Give up on returning. - this.FinishOrder(); + return true; + }, + + "leave": function() { }, }, },