1
0
forked from mirrors/0ad

petra: reduce a bit the distance between ccs for defensive ai + some cleanup

This was SVN commit r20791.
This commit is contained in:
mimo
2018-01-07 17:44:01 +00:00
parent e50beaedc0
commit 67b76e6705
3 changed files with 8 additions and 14 deletions
@@ -435,9 +435,7 @@ m.AttackManager.prototype.unpauseAllPlans = function()
m.AttackManager.prototype.getAttackInPreparation = function(type)
{
if (!this.upcomingAttacks[type].length)
return undefined;
return this.upcomingAttacks[type][0];
return this.upcomingAttacks[type].length ? this.upcomingAttacks[type][0] : undefined;
};
/**
@@ -682,7 +682,7 @@ m.AttackPlan.prototype.assignUnits = function(gameState)
let num = 0;
let numbase = {};
let keep = this.type != "Rush" ?
6 + 4 * gameState.getNumPlayerEnemies() + 6 * this.Config.personality.defensive : 8;
6 + 4 * gameState.getNumPlayerEnemies() + 8 * this.Config.personality.defensive : 8;
keep = Math.round(this.Config.popScaling * keep);
for (let ent of gameState.getOwnEntitiesByRole("worker", true).values())
{
@@ -723,22 +723,18 @@ m.AttackPlan.prototype.isAvailableUnit = function(gameState, ent)
/** Reassign one (at each turn) Cav unit to fasten raid preparation. */
m.AttackPlan.prototype.reassignCavUnit = function(gameState)
{
let found;
for (let ent of this.unitCollection.values())
{
if (!ent.position() || ent.getMetadata(PlayerID, "transport") !== undefined)
continue;
if (!ent.hasClass("Cavalry") || !ent.hasClass("CitizenSoldier"))
continue;
found = ent;
break;
}
if (!found)
let raid = gameState.ai.HQ.attackManager.getAttackInPreparation("Raid");
ent.setMetadata(PlayerID, "plan", raid.name);
this.unitCollection.updateEnt(ent);
raid.unitCollection.updateEnt(ent);
return;
let raid = gameState.ai.HQ.attackManager.getAttackInPreparation("Raid");
found.setMetadata(PlayerID, "plan", raid.name);
this.unitCollection.updateEnt(found);
raid.unitCollection.updateEnt(found);
}
};
m.AttackPlan.prototype.chooseTarget = function(gameState)
@@ -1061,7 +1061,7 @@ m.HQ.prototype.findStrategicCCLocation = function(gameState, template)
let cellSize = this.territoryMap.cellSize;
let currentVal, delta;
let distcc0, distcc1, distcc2;
let favoredDistance = template.hasClass("Colony") ? 220 : 280;
let favoredDistance = (template.hasClass("Colony") ? 220 : 280) - 40 * this.Config.personality.defensive;
for (let j = 0; j < this.territoryMap.length; ++j)
{