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 @@ -508,25 +508,6 @@ return; } - // If the unit is full go to the nearest dropsite instead of trying to gather. - // Unless our target is a treasure which we cannot be full enough with (we can't carry treasures). - let cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer); - if (msg.data.type.generic !== "treasure" && cmpResourceGatherer && !cmpResourceGatherer.CanCarryMore(msg.data.type.generic)) - { - let nearestDropsite = this.FindNearestDropsite(msg.data.type.generic); - if (nearestDropsite) - this.PushOrderFront("ReturnResource", { - "target": nearestDropsite, - "force": false, - "type": msg.data.type - }); - // Players expect the unit to move, so walk to the target instead of trying to gather. - else if (!this.FinishOrder()) - this.WalkToTarget(msg.data.target, false); - - return; - } - if (this.MustKillGatherTarget(this.order.data.target)) { // Make sure we can attack the target, else we'll get very stuck @@ -561,6 +542,26 @@ return; } + // If the unit is full go to the nearest dropsite instead of trying to gather. + // We also do not do it for hunting as you might want to kill animals for other units. + // Unless our target is a treasure which we cannot be full enough with (we can't carry treasures). + let cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer); + if (msg.data.type.generic !== "treasure" && cmpResourceGatherer && !cmpResourceGatherer.CanCarryMore(msg.data.type.generic)) + { + let nearestDropsite = this.FindNearestDropsite(msg.data.type.generic); + if (nearestDropsite) + this.PushOrderFront("ReturnResource", { + "target": nearestDropsite, + "force": false, + "type": msg.data.type + }); + // Players expect the unit to move, so walk to the target instead of trying to gather. + else if (!this.FinishOrder()) + this.WalkToTarget(msg.data.target, false); + + return; + } + this.PushOrderFront("Attack", { "target": this.order.data.target, "force": !!this.order.data.force, "hunting": true, "allowCapture": false }); return; }