Differential D3876 Diff 17718 ps/trunk/binaries/data/mods/public/simulation/ai/petra/startingStrategy.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/ai/petra/startingStrategy.js
Show First 20 Lines • Show All 539 Lines • ▼ Show 20 Lines | if (gameState.isCeasefireActive()) | ||||
allowed = 0; | allowed = 0; | ||||
else if (gameState.ceasefireTimeRemaining > 600 && allowed > 1) | else if (gameState.ceasefireTimeRemaining > 600 && allowed > 1) | ||||
allowed = 1; | allowed = 1; | ||||
} | } | ||||
this.attackManager.setRushes(allowed); | this.attackManager.setRushes(allowed); | ||||
} | } | ||||
// immediatly build a wood dropsite if possible. | // immediatly build a wood dropsite if possible. | ||||
let template = gameState.applyCiv("structures/{civ}/storehouse"); | if (!gameState.getOwnEntitiesByClass("DropsiteWood", true).hasEntities()) | ||||
if (!gameState.getOwnEntitiesByClass("Storehouse", true).hasEntities() && this.canBuild(gameState, template)) | |||||
{ | { | ||||
let newDP = this.baseManagers[1].findBestDropsiteLocation(gameState, "wood"); | const newDP = this.baseManagers[1].findBestDropsiteAndLocation(gameState, "wood"); | ||||
if (newDP.quality > 40) | if (newDP.quality > 40 && this.canBuild(gameState, newDP.templateName)) | ||||
{ | { | ||||
// if we start with enough workers, put our available resources in this first dropsite | // if we start with enough workers, put our available resources in this first dropsite | ||||
// same thing if our pop exceed the allowed one, as we will need several houses | // same thing if our pop exceed the allowed one, as we will need several houses | ||||
let numWorkers = gameState.getOwnUnits().filter(API3.Filters.byClass("Worker")).length; | let numWorkers = gameState.getOwnUnits().filter(API3.Filters.byClass("Worker")).length; | ||||
if (numWorkers > 12 && newDP.quality > 60 || | if (numWorkers > 12 && newDP.quality > 60 || | ||||
gameState.getPopulation() > gameState.getPopulationLimit() + 20) | gameState.getPopulation() > gameState.getPopulationLimit() + 20) | ||||
{ | { | ||||
let cost = new API3.Resources(gameState.getTemplate(template).cost()); | const cost = new API3.Resources(gameState.getTemplate(newDP.templateName).cost()); | ||||
gameState.ai.queueManager.setAccounts(gameState, cost, "dropsites"); | gameState.ai.queueManager.setAccounts(gameState, cost, "dropsites"); | ||||
} | } | ||||
gameState.ai.queues.dropsites.addPlan(new PETRA.ConstructionPlan(gameState, template, { "base": this.baseManagers[1].ID }, newDP.pos)); | gameState.ai.queues.dropsites.addPlan(new PETRA.ConstructionPlan(gameState, newDP.templateName, { "base": this.baseManagers[1].ID }, newDP.pos)); | ||||
} | } | ||||
} | } | ||||
// and build immediately a corral if needed | // and build immediately a corral if needed | ||||
if (this.needCorral) | if (this.needCorral) | ||||
{ | { | ||||
template = gameState.applyCiv("structures/{civ}/corral"); | const template = gameState.applyCiv("structures/{civ}/corral"); | ||||
if (!gameState.getOwnEntitiesByClass("Corral", true).hasEntities() && this.canBuild(gameState, template)) | if (!gameState.getOwnEntitiesByClass("Corral", true).hasEntities() && this.canBuild(gameState, template)) | ||||
gameState.ai.queues.corral.addPlan(new PETRA.ConstructionPlan(gameState, template, { "base": this.baseManagers[1].ID })); | gameState.ai.queues.corral.addPlan(new PETRA.ConstructionPlan(gameState, template, { "base": this.baseManagers[1].ID })); | ||||
} | } | ||||
}; | }; |
Wildfire Games · Phabricator