diff --git a/binaries/data/mods/public/simulation/ai/petra/defenseManager.js b/binaries/data/mods/public/simulation/ai/petra/defenseManager.js index d6d893e4e7..ce40c0cd99 100644 --- a/binaries/data/mods/public/simulation/ai/petra/defenseManager.js +++ b/binaries/data/mods/public/simulation/ai/petra/defenseManager.js @@ -399,6 +399,15 @@ m.DefenseManager.prototype.checkEvents = function(gameState, events) if (target.hasClass("Ship")) // TODO integrate ships later need to be sure it is accessible continue; + // If inside a started attack plan, let the plan deal with this unit + let plan = target.getMetadata(PlayerID, "plan"); + if (plan !== undefined && plan >= 0) + { + let attack = gameState.ai.HQ.attackManager.getPlan(plan); + if (attack && attack.state !== "unexecuted") + continue; + } + // Signal this attacker to our defense manager, except if we are in enemy territory // TODO treat ship attack if (attacker && attacker.position() && attacker.getMetadata(PlayerID, "PartOfArmy") === undefined && @@ -409,15 +418,6 @@ m.DefenseManager.prototype.checkEvents = function(gameState, events) this.makeIntoArmy(gameState, attacker.id()); } - // If inside a started attack plan, let the plan deal with this unit - let plan = target.getMetadata(PlayerID, "plan"); - if (plan !== undefined && plan >= 0) - { - let attack = gameState.ai.HQ.attackManager.getPlan(plan); - if (attack && attack.state !== "unexecuted") - continue; - } - if (target.getMetadata(PlayerID, "PartOfArmy") !== undefined) { let army = this.getArmy(target.getMetadata(PlayerID, "PartOfArmy"));