Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/maps/random/deep_forest.js
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
var playerAngleStart = randomAngle(); | var playerAngleStart = randomAngle(); | ||||
var playerAngleAddAvrg = 2 * Math.PI / numPlayers; | var playerAngleAddAvrg = 2 * Math.PI / numPlayers; | ||||
var playerAngleMaxOff = playerAngleAddAvrg/4; | var playerAngleMaxOff = playerAngleAddAvrg/4; | ||||
var radiusEC = Math.max(mapRadius/8, baseRadius/2); | var radiusEC = Math.max(mapRadius/8, baseRadius/2); | ||||
var resourceRadius = fractionToTiles(1/3); | var resourceRadius = fractionToTiles(1/3); | ||||
var resourcePerPlayer = [templateStone, templateMetalMine]; | var resourcePerPlayer = [templateStone, templateMetalMine]; | ||||
// For large maps there are memory errors with too many trees. A density of 256*192/mapArea works with 0 players. | // For large maps there are memory errors with too many trees. A density of 256×192/mapArea works with 0 players. | ||||
Stan: This one too. | |||||
// Around each player there is an area without trees so with more players the max density can increase a bit. | // Around each player there is an area without trees so with more players the max density can increase a bit. | ||||
var maxTreeDensity = Math.min(256 * (192 + 8 * numPlayers) / Math.square(mapSize), 1); // Has to be tweeked but works ok | var maxTreeDensity = Math.min(256 * (192 + 8 * numPlayers) / Math.square(mapSize), 1); // Has to be tweeked but works ok | ||||
var bushChance = 1/3; // 1 means 50% chance in deepest wood, 0.5 means 25% chance in deepest wood | var bushChance = 1/3; // 1 means 50% chance in deepest wood, 0.5 means 25% chance in deepest wood | ||||
var playerIDs = sortAllPlayers(); | var playerIDs = sortAllPlayers(); | ||||
for (var i=0; i < numPlayers; i++) | for (var i=0; i < numPlayers; i++) | ||||
{ | { | ||||
playerAngle[i] = (playerAngleStart + i * playerAngleAddAvrg + randFloat(0, playerAngleMaxOff)) % (2 * Math.PI); | playerAngle[i] = (playerAngleStart + i * playerAngleAddAvrg + randFloat(0, playerAngleMaxOff)) % (2 * Math.PI); | ||||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | |||||
createArea( | createArea( | ||||
new ClumpPlacer(Math.square(radiusEC), 1/2, 1/8, Infinity, mapCenter), | new ClumpPlacer(Math.square(radiusEC), 1/2, 1/8, Infinity, mapCenter), | ||||
[ | [ | ||||
new LayeredPainter([terrainHillBorder, terrainHill], [radiusEC/4]), | new LayeredPainter([terrainHillBorder, terrainHill], [radiusEC/4]), | ||||
new ElevationPainter(randFloat(1, 2)), | new ElevationPainter(randFloat(1, 2)), | ||||
new TileClassPainter(clHill) | new TileClassPainter(clHill) | ||||
]); | ]); | ||||
// Woods and general hight map | // Woods and general height map | ||||
NescioAuthorUnsubmitted Done Inline ActionsAnd this? Nescio: And this? | |||||
for (var x = 0; x < mapSize; x++) | for (var x = 0; x < mapSize; x++) | ||||
for (var z = 0; z < mapSize; z++) | for (var z = 0; z < mapSize; z++) | ||||
{ | { | ||||
let position = new Vector2D(x, z); | let position = new Vector2D(x, z); | ||||
// The 0.5 is a correction for the entities placed on the center of tiles | // The 0.5 is a correction for the entities placed on the center of tiles | ||||
var radius = mapCenter.distanceTo(Vector2D.add(position, new Vector2D(0.5, 0.5))); | var radius = mapCenter.distanceTo(Vector2D.add(position, new Vector2D(0.5, 0.5))); | ||||
var minDistToSL = mapSize; | var minDistToSL = mapSize; | ||||
Show All 30 Lines |
Wildfire Games · Phabricator
This one too.