Index: ps/trunk/binaries/data/mods/public/simulation/ai/petra/baseManager.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/ai/petra/baseManager.js +++ ps/trunk/binaries/data/mods/public/simulation/ai/petra/baseManager.js @@ -548,6 +548,8 @@ { if (ent.hasClasses(["Worker", "CitizenSoldier", "FishingBoat"])) ent.setMetadata(PlayerID, "role", PETRA.Worker.ROLE_WORKER); + else if (ent.hasClass("Support") && ent.hasClass("Elephant")) + ent.setMetadata(PlayerID, "role", "worker"); } }; @@ -652,6 +654,12 @@ // Check that the worker isn't garrisoned if (!ent.position()) continue; + // Support elephant can only be builders + if (ent.hasClass("Support") && ent.hasClass("Elephant")) + { + ent.setMetadata(PlayerID, "subrole", "idle"); + continue; + } if (ent.hasClass("Worker")) { @@ -874,10 +882,15 @@ let time = target.buildTime(); nonBuilderWorkers.sort((workerA, workerB) => { let coeffA = API3.SquareVectorDistance(target.position(), workerA.position()); - if (workerA.getMetadata(PlayerID, "gather-type") == "food") + // elephant moves slowly, so when far away they are only useful if build time is long + if (workerA.hasClass("Elephant")) + coeffA *= 0.5 * (1 + Math.sqrt(coeffA)/5/time); + else if (workerA.getMetadata(PlayerID, "gather-type") == "food") coeffA *= 3; let coeffB = API3.SquareVectorDistance(target.position(), workerB.position()); - if (workerB.getMetadata(PlayerID, "gather-type") == "food") + if (workerB.hasClass("Elephant")) + coeffB *= 0.5 * (1 + Math.sqrt(coeffB)/5/time); + else if (workerB.getMetadata(PlayerID, "gather-type") == "food") coeffB *= 3; return coeffA - coeffB; }); Index: ps/trunk/binaries/data/mods/public/simulation/ai/petra/worker.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/ai/petra/worker.js +++ ps/trunk/binaries/data/mods/public/simulation/ai/petra/worker.js @@ -348,7 +348,10 @@ { ent.setMetadata(PlayerID, "subrole", PETRA.Worker.SUBROLE_IDLE); ent.setMetadata(PlayerID, "target-foundation", undefined); - if (this.baseID != gameState.ai.HQ.basesManager.baselessBase().ID) + // If worker elephant, move away to avoid being trapped in between constructions + if (ent.hasClass("Elephant")) + this.moveToGatherer(gameState, ent, true); + else if (this.baseID != gameState.ai.HQ.basesManager.baselessBase().ID) { // reassign it to something useful this.base.reassignIdleWorkers(gameState, [ent]); Index: ps/trunk/binaries/data/mods/public/simulation/templates/template_unit_support_elephant.xml =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/templates/template_unit_support_elephant.xml +++ ps/trunk/binaries/data/mods/public/simulation/templates/template_unit_support_elephant.xml @@ -1,8 +1,5 @@ - - - units/elephant_worker - + 15