diff --git a/binaries/data/mods/public/simulation/ai/petra/worker.js b/binaries/data/mods/public/simulation/ai/petra/worker.js index 9bae66f62e..110c2cf450 100644 --- a/binaries/data/mods/public/simulation/ai/petra/worker.js +++ b/binaries/data/mods/public/simulation/ai/petra/worker.js @@ -52,10 +52,24 @@ m.Worker.prototype.update = function(gameState, ent) let unitAIStateOrder = unitAIState.split(".")[1]; // If we're fighting or hunting, let's not start gathering // but for fishers where UnitAI must have made us target a moving whale. + // Also, if we are attacking, do not capture if (unitAIStateOrder === "COMBAT") { if (subrole === "fisher") this.startFishing(gameState); + else if (unitAIState === "INDIVIDUAL.COMBAT.ATTACKING" && ent.unitAIOrderData().length && + !ent.getMetadata(PlayerID, "PartOfArmy")) + { + let orderData = ent.unitAIOrderData()[0]; + if (orderData && orderData.target && orderData.attackType && orderData.attackType === "Capture") + { + // If we are here, an enemy structure must have targeted one of our workers + // and UnitAI sent it fight back with allowCapture=true + let target = gameState.getEntityById(orderData.target); + if (target && target.owner() > 0 && !gameState.isPlayerAlly(target.owner())) + ent.attack(orderData.target, false); + } + } return; }