mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-07-04 05:55:47 -07:00
petra: prevent UnitAI to give a useless capture attack
This was SVN commit r19088.
This commit is contained in:
parent
11ce52f8c5
commit
86cf621def
1 changed files with 14 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue