diff --git a/binaries/data/mods/public/simulation/ai/petra/headquarters.js b/binaries/data/mods/public/simulation/ai/petra/headquarters.js index a6604d7e5c..fe202bf87a 100644 --- a/binaries/data/mods/public/simulation/ai/petra/headquarters.js +++ b/binaries/data/mods/public/simulation/ai/petra/headquarters.js @@ -526,9 +526,6 @@ m.HQ.prototype.tryResearchTechs = function(gameState, queues) if (techName.indexOf("heal_rate") !== -1 || techName.indexOf("heal_range") !== -1 || techName.indexOf("heal_temple") !== -1 || techName.indexOf("unlock_females_house") !== -1) possibilities.splice(i--, 1); - // temporary hack for upgrade problem TODO fix that - else if (techName.slice(0, 12) === "upgrade_rank") - possibilities.splice(i--, 1); } if (possibilities.length === 0) return; diff --git a/binaries/data/mods/public/simulation/helpers/Commands.js b/binaries/data/mods/public/simulation/helpers/Commands.js index c51875ab62..0d8ce93087 100644 --- a/binaries/data/mods/public/simulation/helpers/Commands.js +++ b/binaries/data/mods/public/simulation/helpers/Commands.js @@ -260,6 +260,22 @@ var commands = { { var queue = Engine.QueryInterface(ent, IID_ProductionQueue); // Check if the building can train the unit + // TODO: the AI API does not take promotion technologies into account for the list of trainable units + // (it is taken directly from the unit template). Here is a temporary fix. + if (queue && data.cmpPlayer.IsAI()) + { + var len = cmd.template.length; + var list = queue.GetEntitiesList(); + if (cmd.template.substr(len-2,2) === "_b" && list.indexOf(cmd.template) === -1) + { + var promo_a = cmd.template.substr(0,len-2) + "_a"; + var promo_e = cmd.template.substr(0,len-2) + "_e"; + if (list.indexOf(promo_a) !== -1) + cmd.template = promo_a; + else if (list.indexOf(promo_e) !== -1) + cmd.template = promo_e; + } + } if (queue && queue.GetEntitiesList().indexOf(cmd.template) != -1) if ("metadata" in cmd) queue.AddBatch(cmd.template, "unit", +cmd.count, cmd.metadata);