diff --git a/binaries/data/mods/public/simulation/ai/petra/baseManager.js b/binaries/data/mods/public/simulation/ai/petra/baseManager.js index 68e1773f39..3ba07c198a 100644 --- a/binaries/data/mods/public/simulation/ai/petra/baseManager.js +++ b/binaries/data/mods/public/simulation/ai/petra/baseManager.js @@ -657,7 +657,7 @@ PETRA.BaseManager.prototype.reassignIdleWorkers = function(gameState, idleWorker // Support elephant can only be builders if (ent.hasClass("Support") && ent.hasClass("Elephant")) { - ent.setMetadata(PlayerID, "subrole", "idle"); + ent.setMetadata(PlayerID, "subrole", PETRA.Worker.SUBROLE_IDLE); continue; } diff --git a/binaries/data/mods/public/simulation/ai/petra/basesManager.js b/binaries/data/mods/public/simulation/ai/petra/basesManager.js index 33bd4bd3e1..90e4a26a1a 100644 --- a/binaries/data/mods/public/simulation/ai/petra/basesManager.js +++ b/binaries/data/mods/public/simulation/ai/petra/basesManager.js @@ -157,10 +157,17 @@ PETRA.BasesManager.prototype.checkEvents = function(gameState, events) const base = this.getBaseByID(baseID); // Promoted workers should be reset - their new gathering rates/capabilities might differ meaningfully. - if (ent.getMetadata(PlayerID, "role") === PETRA.Worker.ROLE_WORKER) { - ent.deleteAllMetadata(PlayerID); - ent.setMetadata(PlayerID, "base", baseID); - base.assignRolelessUnits(undefined, [ent]); + if (ent.getMetadata(PlayerID, "role") === PETRA.Worker.ROLE_WORKER) + { + ent.setMetadata(PlayerID, "subrole", PETRA.Worker.SUBROLE_IDLE); + if (!ent.isGatherer()) + { + // TODO: Find a way to properly reset the metadata, as this is currently done selectively + ent.setMetadata(PlayerID, "gather-type", undefined); + ent.setMetadata(PlayerID, "supply", undefined); + ent.setMetadata(PlayerID, "role", undefined); + base.assignRolelessUnits(gameState, [ent]); + } continue; }