diff --git a/binaries/data/mods/public/simulation/ai/petra/attackManager.js b/binaries/data/mods/public/simulation/ai/petra/attackManager.js index e2130f3814..f2fbe1a496 100644 --- a/binaries/data/mods/public/simulation/ai/petra/attackManager.js +++ b/binaries/data/mods/public/simulation/ai/petra/attackManager.js @@ -55,11 +55,11 @@ m.AttackManager.prototype.update = function(gameState, queues, events) API3.warn(" upcoming attacks ================="); for (var attackType in this.upcomingAttacks) for (let attack of this.upcomingAttacks[attackType]) - API3.warn(" type " + attackType + " state " + attack.state + " units " + attack.unitCollection.length); + API3.warn(" plan " + attack.name + " type " + attackType + " state " + attack.state + " units " + attack.unitCollection.length); API3.warn(" started attacks =================="); for (var attackType in this.startedAttacks) for (let attack of this.startedAttacks[attackType]) - API3.warn(" type " + attackType + " state " + attack.state + " units " + attack.unitCollection.length); + API3.warn(" plan " + attack.name + " type " + attackType + " state " + attack.state + " units " + attack.unitCollection.length); API3.warn(" =================================="); } diff --git a/binaries/data/mods/public/simulation/ai/petra/attackPlan.js b/binaries/data/mods/public/simulation/ai/petra/attackPlan.js index 3c8e2a540b..e0b802d7c4 100644 --- a/binaries/data/mods/public/simulation/ai/petra/attackPlan.js +++ b/binaries/data/mods/public/simulation/ai/petra/attackPlan.js @@ -475,6 +475,7 @@ m.AttackPlan.prototype.updatePreparation = function(gameState, events) { if (this.canStart()) { + this.removeTrainingUnitsFromPlan(gameState); this.queue.empty(); this.queueChamp.empty(); this.queueSiege.empty(); @@ -1694,6 +1695,7 @@ m.AttackPlan.prototype.Abort = function(gameState) for (let unitCat in this.unitStat) this.unit[unitCat].unregister(); + this.removeTrainingUnitsFromPlan(gameState); gameState.ai.queueManager.removeQueue("plan_" + this.name); gameState.ai.queueManager.removeQueue("plan_" + this.name + "_champ"); gameState.ai.queueManager.removeQueue("plan_" + this.name + "_siege"); @@ -1786,6 +1788,14 @@ m.AttackPlan.prototype.debugAttack = function() API3.warn("------------------------------"); }; +m.AttackPlan.prototype.removeTrainingUnitsFromPlan = function(gameState) +{ + for (let trainer of gameState.getOwnTrainingFacilities().values()) + for (let item of trainer.trainingQueue()) + if (item.metadata && item.metadata.plan == this.name) + item.metadata.plan = undefined; +}; + m.AttackPlan.prototype.Serialize = function() { let properties = { diff --git a/binaries/data/mods/public/simulation/ai/petra/queueplan-building.js b/binaries/data/mods/public/simulation/ai/petra/queueplan-building.js index adc4afa94b..9a27053a41 100644 --- a/binaries/data/mods/public/simulation/ai/petra/queueplan-building.js +++ b/binaries/data/mods/public/simulation/ai/petra/queueplan-building.js @@ -246,7 +246,7 @@ m.ConstructionPlan.prototype.findGoodPosition = function(gameState) // requires to be inside our territory, and inside our base territory if required // and if our first market, put it on border if possible to maximize distance with next market var favorBorder = template.hasClass("BarterMarket"); - var disfavorBorder = (template.buildCategory() === "Dock" || + var disfavorBorder = (gameState.currentPhase() > 1 && (!template.getDefaultArrow() && !template.getArrowMultiplier())); var preferredBase = (this.metadata && this.metadata.preferredBase); if (this.metadata && this.metadata.base !== undefined)