Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/maps/random/wild_lake.js
Show All 16 Lines | |||||
setSelectedBiome(); | setSelectedBiome(); | ||||
// Terrain, entities and actors | // Terrain, entities and actors | ||||
let wildLakeBiome = [ | let wildLakeBiome = [ | ||||
// 0 Deep water | // 0 Deep water | ||||
{ | { | ||||
"texture": getArray(g_Terrains.water), | "texture": getArray(g_Terrains.water), | ||||
"actor": [[g_Gaia.fish], 0.01], | "entity": [[g_Gaia.fish], 0.005], | ||||
"textureHS": getArray(g_Terrains.water), | "textureHS": getArray(g_Terrains.water), | ||||
"actorHS": [[g_Gaia.fish], 0.03] | "entityHS": [[g_Gaia.fish], 0.01] | ||||
}, | }, | ||||
// 1 Shallow water | // 1 Shallow water | ||||
{ | { | ||||
"texture": getArray(g_Terrains.water), | "texture": getArray(g_Terrains.water), | ||||
"actor": [[g_Decoratives.lillies, g_Decoratives.reeds], 0.3], | "entity": [[g_Decoratives.lillies, g_Decoratives.reeds], 0.3], | ||||
"textureHS": getArray(g_Terrains.water), | "textureHS": getArray(g_Terrains.water), | ||||
"actorHS": [[g_Decoratives.lillies], 0.1] | "entityHS": [[g_Decoratives.lillies], 0.1] | ||||
}, | }, | ||||
// 2 Shore | // 2 Shore | ||||
{ | { | ||||
"texture": getArray(g_Terrains.shore), | "texture": getArray(g_Terrains.shore), | ||||
"actor": [ | "entity": [ | ||||
[ | [ | ||||
g_Gaia.tree1, g_Gaia.tree1, | g_Gaia.tree1, g_Gaia.tree1, g_Gaia.tree1, g_Gaia.tree1, g_Gaia.tree1, | ||||
g_Gaia.tree2, g_Gaia.tree2, | g_Gaia.tree1, g_Gaia.tree1, g_Gaia.tree1, g_Gaia.tree1, g_Gaia.tree1, | ||||
g_Gaia.tree1, g_Gaia.tree1, g_Gaia.tree1, g_Gaia.tree1, g_Gaia.tree1, | |||||
g_Gaia.tree2, g_Gaia.tree2, g_Gaia.tree2, g_Gaia.tree2, g_Gaia.tree2, | |||||
g_Gaia.tree2, g_Gaia.tree2, g_Gaia.tree2, g_Gaia.tree2, g_Gaia.tree2, | |||||
g_Gaia.tree2, g_Gaia.tree2, g_Gaia.tree2, g_Gaia.tree2, g_Gaia.tree2, | |||||
g_Gaia.mainHuntableAnimal, | g_Gaia.mainHuntableAnimal, | ||||
g_Decoratives.grass, g_Decoratives.grass, | g_Decoratives.grass, g_Decoratives.grass, | ||||
g_Decoratives.rockMedium, g_Decoratives.rockMedium, | g_Decoratives.rockMedium, g_Decoratives.rockMedium, g_Decoratives.rockMedium, g_Decoratives.rockMedium, | ||||
g_Decoratives.bushMedium, g_Decoratives.bushMedium | g_Decoratives.rockMedium, g_Decoratives.rockMedium, g_Decoratives.rockMedium, g_Decoratives.rockMedium, | ||||
g_Decoratives.bushMedium, g_Decoratives.bushMedium, g_Decoratives.bushMedium, g_Decoratives.bushMedium, | |||||
g_Decoratives.bushMedium, g_Decoratives.bushMedium, g_Decoratives.bushMedium, g_Decoratives.bushMedium | |||||
], | ], | ||||
0.3 | 0.3 | ||||
], | ], | ||||
"textureHS": getArray(g_Terrains.cliff), | "textureHS": getArray(g_Terrains.cliff), | ||||
"actorHS": [[g_Decoratives.grassShort, g_Decoratives.rockMedium, g_Decoratives.bushSmall], 0.1] | "entityHS": [[g_Decoratives.grassShort, g_Decoratives.rockMedium, g_Decoratives.bushSmall], 0.05] | ||||
}, | }, | ||||
// 3 Low ground | // 3 Low ground | ||||
{ | { | ||||
"texture": getArray(g_Terrains.tier1Terrain), | "texture": getArray(g_Terrains.tier1Terrain), | ||||
"actor": [ | "entity": [ | ||||
[ | [ | ||||
g_Decoratives.grass, | g_Decoratives.grass, | ||||
g_Decoratives.grassShort, | g_Decoratives.grassShort, | ||||
g_Decoratives.rockLarge, | g_Decoratives.rockLarge, | ||||
g_Decoratives.rockMedium, | g_Decoratives.rockMedium, | ||||
g_Decoratives.bushMedium, | g_Decoratives.bushMedium, | ||||
g_Decoratives.bushSmall | g_Decoratives.bushSmall | ||||
], | ], | ||||
0.2 | 0.07 | ||||
], | ], | ||||
"textureHS": getArray(g_Terrains.cliff), | "textureHS": getArray(g_Terrains.cliff), | ||||
"actorHS": [[g_Decoratives.grassShort, g_Decoratives.rockMedium, g_Decoratives.bushSmall], 0.1] | "entityHS": [[g_Decoratives.grassShort, g_Decoratives.rockMedium, g_Decoratives.bushSmall], 0.05] | ||||
}, | }, | ||||
// 4 Mid ground. Player and path height | // 4 Mid ground. Player and path height | ||||
{ | { | ||||
"texture": getArray(g_Terrains.mainTerrain), | "texture": getArray(g_Terrains.mainTerrain), | ||||
"actor": [ | "entity": [ | ||||
[ | [ | ||||
g_Decoratives.grass, | g_Decoratives.grass, | ||||
g_Decoratives.grassShort, | g_Decoratives.grassShort, | ||||
g_Decoratives.rockLarge, | g_Decoratives.rockLarge, | ||||
g_Decoratives.rockMedium, | g_Decoratives.rockMedium, | ||||
g_Decoratives.bushMedium, | g_Decoratives.bushMedium, | ||||
g_Decoratives.bushSmall | g_Decoratives.bushSmall | ||||
], | ], | ||||
0.2 | 0.07 | ||||
], | ], | ||||
"textureHS": getArray(g_Terrains.cliff), | "textureHS": getArray(g_Terrains.cliff), | ||||
"actorHS": [[g_Decoratives.grassShort, g_Decoratives.rockMedium, g_Decoratives.bushSmall], 0.1] | "entityHS": [[g_Decoratives.grassShort, g_Decoratives.rockMedium, g_Decoratives.bushSmall], 0.05] | ||||
}, | }, | ||||
// 5 High ground | // 5 High ground | ||||
{ | { | ||||
"texture": getArray(g_Terrains.tier2Terrain), | "texture": getArray(g_Terrains.tier2Terrain), | ||||
"actor": [ | "entity": [ | ||||
[ | [ | ||||
g_Decoratives.grass, | g_Decoratives.grass, | ||||
g_Decoratives.grassShort, | g_Decoratives.grassShort, | ||||
g_Decoratives.rockLarge, | g_Decoratives.rockLarge, | ||||
g_Decoratives.rockMedium, | g_Decoratives.rockMedium, | ||||
g_Decoratives.bushMedium, | g_Decoratives.bushMedium, | ||||
g_Decoratives.bushSmall | g_Decoratives.bushSmall | ||||
], | ], | ||||
0.2 | 0.07 | ||||
], | ], | ||||
"textureHS": getArray(g_Terrains.cliff), | "textureHS": getArray(g_Terrains.cliff), | ||||
"actorHS": [[g_Decoratives.grassShort, g_Decoratives.rockMedium, g_Decoratives.bushSmall], 0.1] | "entityHS": [[g_Decoratives.grassShort, g_Decoratives.rockMedium, g_Decoratives.bushSmall], 0.05] | ||||
}, | }, | ||||
// 6 Lower hilltop forest border | // 6 Lower hilltop forest border | ||||
{ | { | ||||
"texture": getArray(g_Terrains.dirt), | "texture": getArray(g_Terrains.dirt), | ||||
"actor": [ | "entity": [ | ||||
[ | [ | ||||
g_Gaia.tree1, | g_Gaia.tree1, g_Gaia.tree1, | ||||
g_Gaia.tree3, | g_Gaia.tree3, g_Gaia.tree3, | ||||
g_Gaia.fruitBush, | g_Gaia.fruitBush, | ||||
g_Gaia.secondaryHuntableAnimal, | g_Gaia.secondaryHuntableAnimal, | ||||
g_Decoratives.grass, | g_Decoratives.grass, g_Decoratives.grass, | ||||
g_Decoratives.rockMedium, | g_Decoratives.rockMedium, g_Decoratives.rockMedium, | ||||
g_Decoratives.bushMedium | g_Decoratives.bushMedium, g_Decoratives.bushMedium | ||||
], | ], | ||||
0.3 | 0.25 | ||||
], | ], | ||||
"textureHS": getArray(g_Terrains.cliff), | "textureHS": getArray(g_Terrains.cliff), | ||||
"actorHS": [[g_Decoratives.grassShort, g_Decoratives.rockMedium, g_Decoratives.bushSmall], 0.1] | "entityHS": [[g_Decoratives.grassShort, g_Decoratives.rockMedium, g_Decoratives.bushSmall], 0.1] | ||||
}, | }, | ||||
// 7 Hilltop forest | // 7 Hilltop forest | ||||
{ | { | ||||
"texture": getArray(g_Terrains.forestFloor1), | "texture": getArray(g_Terrains.forestFloor1), | ||||
"actor": [ | "entity": [ | ||||
[ | [ | ||||
g_Gaia.tree1, | g_Gaia.tree1, | ||||
g_Gaia.tree2, | g_Gaia.tree2, | ||||
g_Gaia.tree3, | g_Gaia.tree3, | ||||
g_Gaia.tree4, | g_Gaia.tree4, | ||||
g_Gaia.tree5, | g_Gaia.tree5, | ||||
g_Decoratives.tree, | g_Decoratives.tree, | ||||
g_Decoratives.grass, | g_Decoratives.grass, | ||||
g_Decoratives.rockMedium, | g_Decoratives.rockMedium, | ||||
g_Decoratives.bushMedium | g_Decoratives.bushMedium | ||||
], | ], | ||||
0.5 | 0.3 | ||||
], | ], | ||||
"textureHS": getArray(g_Terrains.cliff), | "textureHS": getArray(g_Terrains.cliff), | ||||
"actorHS": [[g_Decoratives.grassShort, g_Decoratives.rockMedium, g_Decoratives.bushSmall], 0.1] | "entityHS": [[g_Decoratives.grassShort, g_Decoratives.rockMedium, g_Decoratives.bushSmall], 0.1] | ||||
} | } | ||||
]; | ]; | ||||
const wildLakeEntities = Engine.ReadJSONFile("maps/random/wild_lake_biomes.json"); | const wildLakeEntities = Engine.ReadJSONFile("maps/random/wild_lake_biomes.json"); | ||||
const farmEntities = wildLakeEntities[currentBiome()].farmEntities; | const farmEntities = wildLakeEntities[currentBiome()].farmEntities; | ||||
const mercenaryCampEntities = wildLakeEntities[currentBiome()].mercenaryCampEntities; | const mercenaryCampEntities = wildLakeEntities[currentBiome()].mercenaryCampEntities; | ||||
const guards = mercenaryCampEntities | const guards = mercenaryCampEntities | ||||
.map(ent => ent.Template) | .map(ent => ent.Template) | ||||
Show All 21 Lines | g_Map.placeEntityPassable( | ||||
pickRandom(decorativeActors), | pickRandom(decorativeActors), | ||||
0, | 0, | ||||
Vector2D.add(position, new Vector2D(randFloat(2, 5), 0).rotate(-dAngle * randFloat(i, i + 1))), | Vector2D.add(position, new Vector2D(randFloat(2, 5), 0).rotate(-dAngle * randFloat(i, i + 1))), | ||||
randomAngle()); | randomAngle()); | ||||
} | } | ||||
// Groves, only wood | // Groves, only wood | ||||
let groveActors = [g_Decoratives.grass, g_Decoratives.rockMedium, g_Decoratives.bushMedium]; | let groveActors = [g_Decoratives.grass, g_Decoratives.rockMedium, g_Decoratives.bushMedium]; | ||||
let clGrove = g_Map.createTileClass(); | |||||
let clGaiaCamp = g_Map.createTileClass(); | let clGaiaCamp = g_Map.createTileClass(); | ||||
function placeGrove(point, | function placeGrove(point, | ||||
groveEntities = [ | groveEntities = [ | ||||
g_Gaia.tree1, g_Gaia.tree1, g_Gaia.tree1, g_Gaia.tree1, g_Gaia.tree1, | g_Gaia.tree1, g_Gaia.tree1, g_Gaia.tree1, g_Gaia.tree1, g_Gaia.tree1, | ||||
g_Gaia.tree2, g_Gaia.tree2, g_Gaia.tree2, g_Gaia.tree2, | g_Gaia.tree2, g_Gaia.tree2, g_Gaia.tree2, g_Gaia.tree2, | ||||
g_Gaia.tree3, g_Gaia.tree3, g_Gaia.tree3, | g_Gaia.tree3, g_Gaia.tree3, g_Gaia.tree3, | ||||
g_Gaia.tree4, g_Gaia.tree4, g_Gaia.tree5 | g_Gaia.tree4, g_Gaia.tree4, g_Gaia.tree5 | ||||
▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | for (let i = 0; i < quantity; ++i) | ||||
if (i % 2 == 0) | if (i % 2 == 0) | ||||
objectList = groveActors; | objectList = groveActors; | ||||
let position = Vector2D.add(point, new Vector2D(dist, 0).rotate(-angle)); | let position = Vector2D.add(point, new Vector2D(dist, 0).rotate(-angle)); | ||||
g_Map.placeEntityPassable(pickRandom(objectList), 0, position, randomAngle()); | g_Map.placeEntityPassable(pickRandom(objectList), 0, position, randomAngle()); | ||||
createArea( | createArea( | ||||
new ClumpPlacer(5, 1, 1, Infinity, position), | new ClumpPlacer(5, 1, 1, Infinity, position), | ||||
[ | new TerrainPainter(groveTerrainTexture)); | ||||
new TerrainPainter(groveTerrainTexture), | |||||
new TileClassPainter(clGrove) | |||||
]); | |||||
currentAngle += dAngle; | currentAngle += dAngle; | ||||
} | } | ||||
// Metal | // Metal | ||||
dAngle = 4/9 * Math.PI; | dAngle = 4/9 * Math.PI; | ||||
angle = currentAngle + randFloat(dAngle / 4, 3 * dAngle / 4); | angle = currentAngle + randFloat(dAngle / 4, 3 * dAngle / 4); | ||||
placeMine(Vector2D.add(point, new Vector2D(averageDistToCC, 0).rotate(-angle)), g_Gaia.metalLarge); | placeMine(Vector2D.add(point, new Vector2D(averageDistToCC, 0).rotate(-angle)), g_Gaia.metalLarge); | ||||
currentAngle += dAngle; | currentAngle += dAngle; | ||||
▲ Show 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | if (slope < minSlope[h]) | ||||
minSlope[h] = slope; | minSlope[h] = slope; | ||||
} | } | ||||
} | } | ||||
g_Map.log("Paint areas by height and slope"); | g_Map.log("Paint areas by height and slope"); | ||||
for (let h = 0; h < heighLimits.length; ++h) | for (let h = 0; h < heighLimits.length; ++h) | ||||
for (let point of areas[h]) | for (let point of areas[h]) | ||||
{ | { | ||||
let actor; | let entity; | ||||
let texture = pickRandom(wildLakeBiome[h].texture); | let texture = pickRandom(wildLakeBiome[h].texture); | ||||
if (slopeMap[point.x][point.y] < (minSlope[h] + maxSlope[h]) / 2) | if (slopeMap[point.x][point.y] < (minSlope[h] + maxSlope[h]) / 2) | ||||
{ | { | ||||
if (randBool(wildLakeBiome[h].actor[1])) | if (randBool(wildLakeBiome[h].entity[1])) | ||||
actor = pickRandom(wildLakeBiome[h].actor[0]); | entity = pickRandom(wildLakeBiome[h].entity[0]); | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
texture = pickRandom(wildLakeBiome[h].textureHS); | texture = pickRandom(wildLakeBiome[h].textureHS); | ||||
if (randBool(wildLakeBiome[h].actorHS[1])) | if (randBool(wildLakeBiome[h].entityHS[1])) | ||||
actor = pickRandom(wildLakeBiome[h].actorHS[0]); | entity = pickRandom(wildLakeBiome[h].entityHS[0]); | ||||
} | } | ||||
g_Map.setTexture(point, texture); | g_Map.setTexture(point, texture); | ||||
if (actor) | if (entity) | ||||
g_Map.placeEntityAnywhere(actor, 0, randomPositionOnTile(point), randomAngle()); | g_Map.placeEntityPassable(entity, 0, randomPositionOnTile(point), randomAngle()); | ||||
} | } | ||||
Engine.SetProgress(40); | Engine.SetProgress(40); | ||||
g_Map.log("Placing resources"); | g_Map.log("Placing resources"); | ||||
let avoidPoints = playerPosition.map(pos => pos.clone()); | let avoidPoints = playerPosition.map(pos => pos.clone()); | ||||
for (let i = 0; i < avoidPoints.length; ++i) | for (let i = 0; i < avoidPoints.length; ++i) | ||||
avoidPoints[i].dist = 30; | avoidPoints[i].dist = 30; | ||||
let resourceSpots = getPointsByHeight(resourceSpotHeightRange, avoidPoints).map(point => new Vector2D(point.x, point.y)); | let resourceSpots = getPointsByHeight(resourceSpotHeightRange, avoidPoints).map(point => new Vector2D(point.x, point.y)); | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator