petra: do not impose anymore a specific base for fields/corrals

This was SVN commit r21569.
This commit is contained in:
mimo
2018-03-16 19:01:32 +00:00
parent 2d10c4374f
commit 0c3e080779
2 changed files with 8 additions and 6 deletions
@@ -387,7 +387,7 @@ m.BaseManager.prototype.checkResourceLevels = function(gameState, queues)
{
if (count < 600)
{
queues.field.addPlan(new m.ConstructionPlan(gameState, "structures/{civ}_field", { "base": this.ID }));
queues.field.addPlan(new m.ConstructionPlan(gameState, "structures/{civ}_field", { "favoredBase": this.ID }));
gameState.ai.HQ.needFarm = true;
}
}
@@ -398,11 +398,11 @@ m.BaseManager.prototype.checkResourceLevels = function(gameState, queues)
if (gameState.ai.HQ.saveResources || gameState.ai.HQ.saveSpace || count > 300 || numFarms > 5)
goal = Math.max(goal-1, 1);
if (numFound + numQueue < goal)
queues.field.addPlan(new m.ConstructionPlan(gameState, "structures/{civ}_field", { "base": this.ID }));
queues.field.addPlan(new m.ConstructionPlan(gameState, "structures/{civ}_field", { "favoredBase": this.ID }));
}
else if (gameState.ai.HQ.needCorral && !gameState.getOwnEntitiesByClass("Corral", true).hasEntities() &&
!queues.corral.hasQueuedUnits() && gameState.ai.HQ.canBuild(gameState, "structures/{civ}_corral"))
queues.corral.addPlan(new m.ConstructionPlan(gameState, "structures/{civ}_corral", { "base": this.ID }));
queues.corral.addPlan(new m.ConstructionPlan(gameState, "structures/{civ}_corral", { "favoredBase": this.ID }));
continue;
}
if (!gameState.isTemplateAvailable(gameState.applyCiv("structures/{civ}_field")) &&
@@ -412,7 +412,7 @@ m.BaseManager.prototype.checkResourceLevels = function(gameState, queues)
let count = this.getResourceLevel(gameState, type, gameState.currentPhase() > 1); // animals are not accounted
if (count < 600)
{
queues.corral.addPlan(new m.ConstructionPlan(gameState, "structures/{civ}_corral", { "base": this.ID }));
queues.corral.addPlan(new m.ConstructionPlan(gameState, "structures/{civ}_corral", { "favoredBase": this.ID }));
gameState.ai.HQ.needCorral = true;
}
}
@@ -262,7 +262,8 @@ m.ConstructionPlan.prototype.findGoodPosition = function(gameState)
// and if our first market, put it on border if possible to maximize distance with next market
let favorBorder = template.hasClass("BarterMarket");
let disfavorBorder = gameState.currentPhase() > 1 && !template.hasDefensiveFire();
let militaryBase = this.metadata && this.metadata.militaryBase ? HQ.findBestBaseForMilitary(gameState) : undefined;
let favoredBase = this.metadata && (this.metadata.favoredBase ||
(this.metadata.militaryBase ? HQ.findBestBaseForMilitary(gameState) : undefined));
if (this.metadata && this.metadata.base !== undefined)
{
let base = this.metadata.base;
@@ -301,8 +302,9 @@ m.ConstructionPlan.prototype.findGoodPosition = function(gameState)
let z = (Math.floor(j / placement.width) + 0.5) * cellSize;
if (HQ.isNearInvadingArmy([x, z]))
placement.map[j] = 0;
else if (militaryBase && HQ.basesMap.map[j] == militaryBase)
else if (favoredBase && HQ.basesMap.map[j] == favoredBase)
placement.map[j] += 200;
}
}
}