1
0
forked from 0ad/0ad

petra: minor attack tweaks

This was SVN commit r16873.
This commit is contained in:
mimo 2015-07-21 19:30:54 +00:00
parent b0a5087dda
commit a61c7560eb

View File

@ -647,12 +647,12 @@ m.AttackPlan.prototype.assignUnits = function(gameState)
} }
// Finally add also some workers, // Finally add also some workers,
// If Rush, assign all kind of workers, keeping a minimum number of defenders // If Rush, assign all kind of workers, keeping only a minimum number of defenders
// Otherwise, assign only idle workers if too much of them // Otherwise, assign only some idle workers if too much of them
let worker = gameState.getOwnEntitiesByRole("worker", true);
let num = 0; let num = 0;
let numbase = {}; let numbase = {};
for (let ent of worker.values()) let keep = this.type === "Rush" ? Math.round(this.Config.popScaling * (12 + 4*this.Config.personality.defensive)) : 6;
for (let ent of gameState.getOwnEntitiesByRole("worker", true).values())
{ {
if (!ent.position()) if (!ent.position())
continue; continue;
@ -673,7 +673,7 @@ m.AttackPlan.prototype.assignUnits = function(gameState)
} }
if (this.type !== "Rush" && ent.getMetadata(PlayerID, "subrole") !== "idle") if (this.type !== "Rush" && ent.getMetadata(PlayerID, "subrole") !== "idle")
continue; continue;
if (num++ < 9 || numbase[baseID] < 5) if (num++ < keep || numbase[baseID] < 5)
continue; continue;
ent.setMetadata(PlayerID, "plan", plan); ent.setMetadata(PlayerID, "plan", plan);
this.unitCollection.updateEnt(ent); this.unitCollection.updateEnt(ent);