Differential D4192 Diff 18509 ps/trunk/binaries/data/mods/public/simulation/ai/petra/navalManager.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/ai/petra/navalManager.js
Show First 20 Lines • Show All 702 Lines • ▼ Show 20 Lines | for (let blockingShip of gameState.ai.HQ.tradeManager.traders.filter(API3.Filters.byClass("Ship")).values()) | ||||
else if (distSquare < 900) | else if (distSquare < 900) | ||||
blockingShip.moveToRange(shipPosition[0], shipPosition[1], 30, 35); | blockingShip.moveToRange(shipPosition[0], shipPosition[1], 30, 35); | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
PETRA.NavalManager.prototype.buildNavalStructures = function(gameState, queues) | PETRA.NavalManager.prototype.buildNavalStructures = function(gameState, queues) | ||||
{ | { | ||||
if (!gameState.ai.HQ.navalMap || !gameState.ai.HQ.baseManagers[1]) | if (!gameState.ai.HQ.navalMap || !gameState.ai.HQ.hasPotentialBase()) | ||||
return; | return; | ||||
if (gameState.ai.HQ.getAccountedPopulation(gameState) > this.Config.Economy.popForDock) | if (gameState.ai.HQ.getAccountedPopulation(gameState) > this.Config.Economy.popForDock) | ||||
{ | { | ||||
if (queues.dock.countQueuedUnitsWithClass("Dock") === 0 && | if (queues.dock.countQueuedUnitsWithClass("Dock") === 0 && | ||||
!gameState.getOwnStructures().filter(API3.Filters.and(API3.Filters.byClass("Dock"), API3.Filters.isFoundation())).hasEntities() && | !gameState.getOwnStructures().filter(API3.Filters.and(API3.Filters.byClass("Dock"), API3.Filters.isFoundation())).hasEntities() && | ||||
gameState.ai.HQ.canBuild(gameState, "structures/{civ}/dock")) | gameState.ai.HQ.canBuild(gameState, "structures/{civ}/dock")) | ||||
{ | { | ||||
let dockStarted = false; | let dockStarted = false; | ||||
for (let base of gameState.ai.HQ.baseManagers) | for (const base of gameState.ai.HQ.baseManagers()) | ||||
{ | { | ||||
if (dockStarted) | if (dockStarted) | ||||
break; | break; | ||||
if (!base.anchor || base.constructing) | if (!base.anchor || base.constructing) | ||||
continue; | continue; | ||||
let remaining = this.getUnconnectedSeas(gameState, base.accessIndex); | let remaining = this.getUnconnectedSeas(gameState, base.accessIndex); | ||||
for (let sea of remaining) | for (let sea of remaining) | ||||
{ | { | ||||
Show All 22 Lines | PETRA.NavalManager.prototype.buildNavalStructures = function(gameState, queues) | ||||
let template; | let template; | ||||
if (gameState.ai.HQ.canBuild(gameState, "structures/{civ}/super_dock")) | if (gameState.ai.HQ.canBuild(gameState, "structures/{civ}/super_dock")) | ||||
template = "structures/{civ}/super_dock"; | template = "structures/{civ}/super_dock"; | ||||
else if (gameState.ai.HQ.canBuild(gameState, "structures/{civ}/shipyard")) | else if (gameState.ai.HQ.canBuild(gameState, "structures/{civ}/shipyard")) | ||||
template = "structures/{civ}/shipyard"; | template = "structures/{civ}/shipyard"; | ||||
else | else | ||||
return; | return; | ||||
let wantedLand = {}; | let wantedLand = {}; | ||||
for (let base of gameState.ai.HQ.baseManagers) | for (const base of gameState.ai.HQ.baseManagers()) | ||||
if (base.anchor) | if (base.anchor) | ||||
wantedLand[base.accessIndex] = true; | wantedLand[base.accessIndex] = true; | ||||
let sea = this.docks.toEntityArray()[0].getMetadata(PlayerID, "sea"); | let sea = this.docks.toEntityArray()[0].getMetadata(PlayerID, "sea"); | ||||
queues.militaryBuilding.addPlan(new PETRA.ConstructionPlan(gameState, template, { "land": wantedLand, "sea": sea })); | queues.militaryBuilding.addPlan(new PETRA.ConstructionPlan(gameState, template, { "land": wantedLand, "sea": sea })); | ||||
}; | }; | ||||
/** goal can be either attack (choose ship with best arrowCount) or transport (choose ship with best capacity) */ | /** goal can be either attack (choose ship with best arrowCount) or transport (choose ship with best capacity) */ | ||||
PETRA.NavalManager.prototype.getBestShip = function(gameState, sea, goal) | PETRA.NavalManager.prototype.getBestShip = function(gameState, sea, goal) | ||||
▲ Show 20 Lines • Show All 120 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator