From 7fbab6dd10fedfbf59eaa6ed42abb31dc71ef69b Mon Sep 17 00:00:00 2001 From: mimo Date: Sat, 11 Apr 2015 18:26:47 +0000 Subject: [PATCH] Petra: update the target of an attack when it has been captured This was SVN commit r16532. --- .../public/simulation/ai/petra/attackPlan.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/binaries/data/mods/public/simulation/ai/petra/attackPlan.js b/binaries/data/mods/public/simulation/ai/petra/attackPlan.js index 0e52b46bc8..e09113645f 100644 --- a/binaries/data/mods/public/simulation/ai/petra/attackPlan.js +++ b/binaries/data/mods/public/simulation/ai/petra/attackPlan.js @@ -1663,22 +1663,22 @@ m.AttackPlan.prototype.removeUnit = function(ent, update) m.AttackPlan.prototype.checkEvents = function(gameState, events) { - if (this.target) + let renameEvents = events["EntityRenamed"]; + for (let evt of renameEvents) { - let renameEvents = events["EntityRenamed"]; - for (let evt of renameEvents) + if (this.target && this.target.id() == evt.entity) { - if (this.target.id() == evt.entity) - { - this.target = gameState.getEntityById(evt.newentity); - if (this.target) - this.targetPos = this.target.position(); - else - this.targetPos = undefined; - } + this.target = gameState.getEntityById(evt.newentity); + if (this.target) + this.targetPos = this.target.position(); } } + let captureEvents = events["OwnershipChanged"]; + for (let evt of captureEvents) + if (this.target && this.target.id() == evt.entity && gameState.isPlayerAlly(evt.to)) + this.target = undefined; + if (this.state === "unexecuted") return;