Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
Show First 20 Lines • Show All 241 Lines • ▼ Show 20 Lines | if (!HQ.requireHouses || !template.hasClass("House")) | ||||
else if (template.genericName() == "Rotary Mill" && ent.hasClass("Field")) | else if (template.genericName() == "Rotary Mill" && ent.hasClass("Field")) | ||||
placement.addInfluence(x, z, 60 / cellSize, 40); | placement.addInfluence(x, z, 60 / cellSize, 40); | ||||
}); | }); | ||||
} | } | ||||
if (template.hasClass("Farmstead")) | if (template.hasClass("Farmstead")) | ||||
{ | { | ||||
for (let j = 0; j < placement.map.length; ++j) | for (let j = 0; j < placement.map.length; ++j) | ||||
{ | { | ||||
let value = placement.map[j] - gameState.sharedScript.resourceMaps.wood.map[j]/3; | let value = placement.map[j] - gameState.sharedScript.getResourcesMaps(PETRA.HQ.RESOURCE_MAP_IDENTIFIER).wood.map[j]/3; | ||||
if (HQ.borderMap.map[j] & PETRA.fullBorder_Mask) | if (HQ.borderMap.map[j] & PETRA.fullBorder_Mask) | ||||
value /= 2; // we need space around farmstead, so disfavor map border | value /= 2; // we need space around farmstead, so disfavor map border | ||||
placement.set(j, value); | placement.set(j, value); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// Requires to be inside our territory, and inside our base territory if required | // Requires to be inside our territory, and inside our base territory if required | ||||
▲ Show 20 Lines • Show All 571 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
/** | /** | ||||
* get the sum of the resources (except food) around, inside a given radius | * get the sum of the resources (except food) around, inside a given radius | ||||
* resources have a weight (1 if dist=0 and 0 if dist=size) doubled for wood | * resources have a weight (1 if dist=0 and 0 if dist=size) doubled for wood | ||||
*/ | */ | ||||
PETRA.ConstructionPlan.prototype.getResourcesAround = function(gameState, types, i, radius) | PETRA.ConstructionPlan.prototype.getResourcesAround = function(gameState, types, i, radius) | ||||
{ | { | ||||
let resourceMaps = gameState.sharedScript.resourceMaps; | const resourceMaps = gameState.sharedScript.getResourcesMaps(PETRA.HQ.RESOURCE_MAP_IDENTIFIER); | ||||
let w = resourceMaps.wood.width; | let w = resourceMaps.wood.width; | ||||
let cellSize = resourceMaps.wood.cellSize; | let cellSize = resourceMaps.wood.cellSize; | ||||
let size = Math.floor(radius / cellSize); | let size = Math.floor(radius / cellSize); | ||||
let ix = i % w; | let ix = i % w; | ||||
let iy = Math.floor(i / w); | let iy = Math.floor(i / w); | ||||
let total = 0; | let total = 0; | ||||
let nbcell = 0; | let nbcell = 0; | ||||
for (let k of types) | for (let k of types) | ||||
▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator