[Petra] update usage of Elephant class
Remove Champion class from siege functions related to melee elephants. Improve mobile dropsite code by replacing Elephant class with Unit class. Remove code related to fact support elephants can build as it is not case anymore. Differential Revision: https://code.wildfiregames.com/D2964 Patch by: Nescio Reviewed by: Angen This was SVN commit r24027.
This commit is contained in:
parent
29e2a44f75
commit
87ec9457c3
@ -355,7 +355,7 @@ PETRA.AttackPlan.prototype.addSiegeUnits = function(gameState)
|
||||
return false;
|
||||
|
||||
let civ = gameState.getPlayerCiv();
|
||||
let classes = [[ "Siege", "Melee"], ["Siege", "Ranged"], ["Elephant", "Melee", "Champion"]];
|
||||
let classes = [["Siege", "Melee"], ["Siege", "Ranged"], ["Elephant", "Melee"]];
|
||||
let hasTrainer = [false, false, false];
|
||||
for (let ent of gameState.getOwnTrainingFacilities().values())
|
||||
{
|
||||
|
@ -82,7 +82,7 @@ PETRA.BaseManager.prototype.assignEntity = function(gameState, ent)
|
||||
this.units.updateEnt(ent);
|
||||
this.workers.updateEnt(ent);
|
||||
this.buildings.updateEnt(ent);
|
||||
if (ent.resourceDropsiteTypes() && !ent.hasClass("Elephant"))
|
||||
if (ent.resourceDropsiteTypes() && !ent.hasClass("Unit"))
|
||||
this.assignResourceToDropsite(gameState, ent);
|
||||
};
|
||||
|
||||
@ -512,8 +512,6 @@ PETRA.BaseManager.prototype.assignRolelessUnits = function(gameState, roleless)
|
||||
{
|
||||
if (ent.hasClass("Worker") || ent.hasClass("CitizenSoldier") || ent.hasClass("FishingBoat"))
|
||||
ent.setMetadata(PlayerID, "role", "worker");
|
||||
else if (ent.hasClass("Support") && ent.hasClass("Elephant"))
|
||||
ent.setMetadata(PlayerID, "role", "worker");
|
||||
}
|
||||
};
|
||||
|
||||
@ -618,12 +616,6 @@ PETRA.BaseManager.prototype.reassignIdleWorkers = function(gameState, idleWorker
|
||||
// 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"))
|
||||
{
|
||||
@ -848,15 +840,10 @@ PETRA.BaseManager.prototype.assignToFoundations = function(gameState, noRepair)
|
||||
let time = target.buildTime();
|
||||
nonBuilderWorkers.sort((workerA, workerB) => {
|
||||
let coeffA = API3.SquareVectorDistance(target.position(), workerA.position());
|
||||
// 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")
|
||||
if (workerA.getMetadata(PlayerID, "gather-type") == "food")
|
||||
coeffA *= 3;
|
||||
let coeffB = API3.SquareVectorDistance(target.position(), workerB.position());
|
||||
if (workerB.hasClass("Elephant"))
|
||||
coeffB *= 0.5 * (1 + Math.sqrt(coeffB)/5/time);
|
||||
else if (workerB.getMetadata(PlayerID, "gather-type") == "food")
|
||||
if (workerB.getMetadata(PlayerID, "gather-type") == "food")
|
||||
coeffB *= 3;
|
||||
return coeffA - coeffB;
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
/** returns true if this unit should be considered as a siege unit */
|
||||
PETRA.isSiegeUnit = function(ent)
|
||||
{
|
||||
return ent.hasClass("Siege") || ent.hasClass("Elephant") && ent.hasClass("Melee") && ent.hasClass("Champion");
|
||||
return ent.hasClass("Siege") || ent.hasClass("Elephant") && ent.hasClass("Melee");
|
||||
};
|
||||
|
||||
/** returns true if this unit should be considered as "fast". */
|
||||
|
@ -950,7 +950,7 @@ PETRA.HQ.prototype.findEconomicCCLocation = function(gameState, template, resour
|
||||
halfSize = +template.get("Footprint/Circle/@radius");
|
||||
|
||||
let ccEnts = gameState.updatingGlobalCollection("allCCs", API3.Filters.byClass("CivCentre"));
|
||||
let dpEnts = gameState.getOwnDropsites().filter(API3.Filters.not(API3.Filters.byClassesOr(["CivCentre", "Elephant"])));
|
||||
let dpEnts = gameState.getOwnDropsites().filter(API3.Filters.not(API3.Filters.byClassesOr(["CivCentre", "Unit"])));
|
||||
let ccList = [];
|
||||
for (let cc of ccEnts.values())
|
||||
ccList.push({ "ent": cc, "pos": cc.position(), "ally": gameState.isPlayerAlly(cc.owner()) });
|
||||
|
@ -304,7 +304,7 @@ PETRA.HQ.prototype.buildFirstBase = function(gameState)
|
||||
let startingPoint = [];
|
||||
for (let ent of gameState.getOwnUnits().values())
|
||||
{
|
||||
if (!ent.hasClass("Worker") && !(ent.hasClass("Support") && ent.hasClass("Elephant")))
|
||||
if (!ent.hasClass("Worker"))
|
||||
continue;
|
||||
if (PETRA.isFastMoving(ent))
|
||||
continue;
|
||||
@ -317,7 +317,7 @@ PETRA.HQ.prototype.buildFirstBase = function(gameState)
|
||||
pos = holder.position();
|
||||
}
|
||||
let gamepos = gameState.ai.accessibility.gamePosToMapPos(pos);
|
||||
let index = gamepos[0] + gamepos[1]*gameState.ai.accessibility.width;
|
||||
let index = gamepos[0] + gamepos[1] * gameState.ai.accessibility.width;
|
||||
let land = gameState.ai.accessibility.landPassMap[index];
|
||||
let sea = gameState.ai.accessibility.navalPassMap[index];
|
||||
let found = false;
|
||||
|
@ -331,10 +331,7 @@ PETRA.Worker.prototype.update = function(gameState, ent)
|
||||
{
|
||||
ent.setMetadata(PlayerID, "subrole", "idle");
|
||||
ent.setMetadata(PlayerID, "target-foundation", undefined);
|
||||
// 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.baseManagers[0].ID)
|
||||
if (this.baseID != gameState.ai.HQ.baseManagers[0].ID)
|
||||
{
|
||||
// reassign it to something useful
|
||||
this.base.reassignIdleWorkers(gameState, [ent]);
|
||||
|
Loading…
Reference in New Issue
Block a user