1
0
forked from mirrors/0ad

Pass a vector to the ClumpPlacer instead of the vector components individually, refs #4992.

Support non-integer values and remove some unneeded floor / rounds.
Use more vector math in Caledonian Meadows, Oasis and Wild Lake, refs
#4845.

This was SVN commit r20971.
This commit is contained in:
elexis
2018-01-23 00:25:39 +00:00
parent 4dde7a4df5
commit de2f30c7b9
32 changed files with 141 additions and 147 deletions
@@ -185,7 +185,7 @@ MountainRangeBuilder.prototype.PaintCurrentEdge = function()
log("Creating circular mountains at both ends of that mountainrange...");
for (let point of [this.currentEdgeStart, this.currentEdgeEnd])
createArea(
new ClumpPlacer(Math.floor(diskArea(this.mountainWidth / 2)), 0.95, 0.6, 10, point.x, point.y),
new ClumpPlacer(diskArea(this.mountainWidth / 2), 0.95, 0.6, 10, point),
this.painters,
this.constraint);
@@ -71,7 +71,7 @@ var clHillDeco = createTileClass();
log("Creating the central dip...");
createArea(
new ClumpPlacer(diskArea(fractionToTiles(0.42)), 0.94, 0.05, 0.1, mapCenter.x, mapCenter.y),
new ClumpPlacer(diskArea(fractionToTiles(0.42)), 0.94, 0.05, 0.1, mapCenter),
[
new LayeredPainter([tCliff, tGrass], [3]),
new SmoothElevationPainter(ELEVATION_SET, heightLand, 3)
@@ -161,7 +161,7 @@ placePlayerBases({
log("Marking player territory larger than the city patch...");
for (let i = 0; i < numPlayers; ++i)
createArea(
new ClumpPlacer(250, 0.95, 0.3, 0.1, playerPosition[i].x, playerPosition[i].y),
new ClumpPlacer(250, 0.95, 0.3, 0.1, playerPosition[i]),
paintClass(clPlayer));
Engine.SetProgress(30);
@@ -19,10 +19,12 @@ function placeRandomPathToHeight(
if (texture)
{
let painters = [new TerrainPainter(texture)];
if (tileClass !== undefined)
painters.push(paintClass(tileClass));
createArea(
new ClumpPlacer(0.3 * Math.square(width), 1, 1, 1, Math.floor(position.x), Math.floor(position.y)),
new ClumpPlacer(diskArea(0.3 * width), 1, 1, 1, position),
painters);
}
pathPoints.push({ "x": position.x, "y": position.y, "dist": distance });
@@ -130,10 +132,14 @@ function placeGrove(point)
let objectList = groveEntities;
if (i % 3 == 0)
objectList = groveActors;
let x = point.x + dist * Math.cos(angle);
let y = point.y + dist * Math.sin(angle);
placeObject(x, y, pickRandom(objectList), 0, randomAngle());
createArea(new ClumpPlacer(5, 1, 1, 1, Math.floor(x), Math.floor(y)), [new TerrainPainter("temp_grass_plants"), paintClass(clGrove)]);
let position = Vector2D.add(point, new Vector2D(dist, 0).rotate(-angle));
placeObject(position.x, position.y, pickRandom(objectList), 0, randomAngle());
createArea(
new ClumpPlacer(5, 1, 1, 1, position),
[
new TerrainPainter("temp_grass_plants"),
paintClass(clGrove)
]);
}
}
@@ -162,11 +168,9 @@ function placeStartLocationResources(point, foodEntities = ["gaia/flora_bush_ber
let currentAngle = randomAngle();
// Stone and chicken
let dAngle = 4/9 * Math.PI;
let angle = currentAngle + randFloat(dAngle / 4, 3 * dAngle / 4);
let dist = 12;
let x = point.x + dist * Math.cos(angle);
let y = point.y + dist * Math.sin(angle);
placeMine({ "x": x, "y": y }, "gaia/geology_stonemine_temperate_quarry");
let angle = currentAngle + randFloat(1, 3) * dAngle / 4;
let stonePosition = Vector2D.add(point, new Vector2D(12, 0).rotate(-angle));
placeMine(stonePosition, "gaia/geology_stonemine_temperate_quarry");
currentAngle += dAngle;
@@ -176,24 +180,25 @@ function placeStartLocationResources(point, foodEntities = ["gaia/flora_bush_ber
for (let i = 0; i < quantity; ++i)
{
angle = currentAngle + randFloat(0, dAngle);
dist = randFloat(10, 15);
let objectList = groveEntities;
if (i % 2 == 0)
objectList = groveActors;
x = point.x + dist * Math.cos(angle);
y = point.y + dist * Math.sin(angle);
placeObject(x, y, pickRandom(objectList), 0, randomAngle());
createArea(new ClumpPlacer(5, 1, 1, 1, Math.floor(x), Math.floor(y)), [new TerrainPainter("temp_grass_plants"), paintClass(clGrove)]);
let woodPosition = Vector2D.add(point, new Vector2D(randFloat(10, 15), 0).rotate(-angle));
placeObject(woodPosition.x, woodPosition.y, pickRandom(objectList), 0, randomAngle());
createArea(
new ClumpPlacer(5, 1, 1, 1, woodPosition),
[
new TerrainPainter("temp_grass_plants"),
paintClass(clGrove)
]);
currentAngle += dAngle;
}
// Metal and chicken
dAngle = 2 * Math.PI * 2 / 9;
angle = currentAngle + randFloat(dAngle / 4, 3 * dAngle / 4);
dist = 13;
x = point.x + dist * Math.cos(angle);
y = point.y + dist * Math.sin(angle);
placeMine({ "x": x, "y": y }, "gaia/geology_metal_temperate_slabs");
angle = currentAngle + dAngle * randFloat(1, 3) / 4;
let metalPosition = Vector2D.add(point, new Vector2D(13, 0).rotate(-angle));
placeMine(metalPosition, "gaia/geology_metal_temperate_slabs");
currentAngle += dAngle;
// Berries
@@ -202,10 +207,8 @@ function placeStartLocationResources(point, foodEntities = ["gaia/flora_bush_ber
for (let i = 0; i < quantity; ++i)
{
angle = currentAngle + randFloat(0, dAngle);
dist = randFloat(10, 15);
x = point.x + dist * Math.cos(angle);
y = point.y + dist * Math.sin(angle);
placeObject(x, y, pickRandom(foodEntities), 0, randomAngle());
let berriesPosition = Vector2D.add(point, new Vector2D(randFloat(10, 15), 0).rotate(-angle));
placeObject(berriesPosition.x, berriesPosition.y, pickRandom(foodEntities), 0, randomAngle());
currentAngle += dAngle;
}
}
@@ -69,7 +69,7 @@ log("Creating player hills and ramps...");
for (let i = 0; i < numPlayers; ++i)
{
createArea(
new ClumpPlacer(diskArea(playerHillRadius), 0.95, 0.6, 10, playerPosition[i].x, playerPosition[i].y),
new ClumpPlacer(diskArea(playerHillRadius), 0.95, 0.6, 10, playerPosition[i]),
[
new LayeredPainter([tCliff, tHill], [2]),
new SmoothElevationPainter(ELEVATION_SET, heightHill, 2),
@@ -68,13 +68,7 @@ log("Reserving space for the players, their initial forests and some less space
for (let i = 0; i < numPlayers; ++i)
for (let j = 1; j <= 2; ++j)
createArea(
new ClumpPlacer(
diskArea(playerCanyonRadius / j),
0.65,
0.1,
10,
playerPosition[i].x,
playerPosition[i].y),
new ClumpPlacer(diskArea(playerCanyonRadius / j), 0.65, 0.1, 10, playerPosition[i]),
[
new LayeredPainter([tMainTerrain, tMainTerrain], [2]),
new SmoothElevationPainter(ELEVATION_SET, heightLand, 2),
@@ -83,7 +77,7 @@ for (let i = 0; i < numPlayers; ++i)
log("Creating center area...");
createArea(
new ClumpPlacer(diskArea(fractionToTiles(0.16)), 0.7, 0.1, 10, mapCenter.x, mapCenter.y),
new ClumpPlacer(diskArea(fractionToTiles(0.16)), 0.7, 0.1, 10, mapCenter),
[
new LayeredPainter([tMainTerrain, tMainTerrain], [3]),
new SmoothElevationPainter(ELEVATION_SET, heightLand, 3),
@@ -91,7 +85,7 @@ createArea(
]);
createArea(
new ClumpPlacer(150, 0.6, 0.3, 10, mapCenter.x, mapCenter.y),
new ClumpPlacer(150, 0.6, 0.3, 10, mapCenter),
paintClass(clHill));
log("Creating hills...");
@@ -116,7 +110,7 @@ for (let g = 0; g < scaleByMapSize(5, 30); ++g)
let position = new Vector2D(randIntInclusive(1, mapSize - 1), randIntInclusive(1, mapSize - 1));
let newarea = createArea(
new ClumpPlacer(diskArea(fractionToTiles(0.06)), 0.7, 0.1, 10, position.x, position.y),
new ClumpPlacer(diskArea(fractionToTiles(0.06)), 0.7, 0.1, 10, position),
[
new LayeredPainter([tMainTerrain, tMainTerrain], [3]),
new SmoothElevationPainter(ELEVATION_SET, heightLand, 3),
@@ -187,7 +181,7 @@ for (let i = 0; i < numPlayers; ++i)
log("Painting center place...");
createArea(
new ClumpPlacer(150, 0.6, 0.3, 10, mapCenter.x, mapCenter.y),
new ClumpPlacer(150, 0.6, 0.3, 10, mapCenter),
new LayeredPainter([tRoad, tRoad], [1]));
placePlayerBases({
@@ -74,7 +74,7 @@ createArea(
log("Creating small puddles at the map border to ensure players being separated...");
for (let point of [riverStart, riverEnd])
createArea(
new ClumpPlacer(Math.floor(diskArea(riverWidth / 2)), 0.95, 0.6, 10, point.x, point.y),
new ClumpPlacer(diskArea(riverWidth / 2), 0.95, 0.6, 10, point),
new SmoothElevationPainter(ELEVATION_SET, heightSeaGround, 4));
log("Creating passage connecting the two riversides...");
@@ -89,7 +89,7 @@ for (let island = 0; island < 2; ++island)
{
log("Creating island area...");
createArea(
new ClumpPlacer(diskArea(radiusIsland), 1, 0.5, 10, islandLocations[island].x, islandLocations[island].y),
new ClumpPlacer(diskArea(radiusIsland), 1, 0.5, 10, islandLocations[island]),
[
new LayeredPainter([tCliffs, tGrass], [2]),
new SmoothElevationPainter(ELEVATION_SET, heightMain, 0),
@@ -102,7 +102,7 @@ for (let island = 0; island < 2; ++island)
let angle = Math.PI * (island + i / (nbSubIsland * 2)) + swapAngle;
let location = Vector2D.add(islandLocations[island], new Vector2D(radiusIsland, 0).rotate(-angle));
createArea(
new ClumpPlacer(diskArea(fractionToTiles(0.09)), 0.6, 0.03, 10, location.x, location.y),
new ClumpPlacer(diskArea(fractionToTiles(0.09)), 0.6, 0.03, 10, location),
[
new LayeredPainter([tCliffs, tGrass], [2]),
new SmoothElevationPainter(ELEVATION_SET, heightMain, 1),
@@ -116,7 +116,7 @@ for (let island = 0; island < 2; ++island)
let angle = Math.PI * (island + i * (1 / (nbCreeks * 2))) + swapAngle;
let location = Vector2D.add(islandLocations[island], new Vector2D(radiusCreeks, 0).rotate(-angle));
createArea(
new ClumpPlacer(creeksArea(), 0.4, 0.01, 10, location.x, location.y),
new ClumpPlacer(creeksArea(), 0.4, 0.01, 10, location),
[
new TerrainPainter(tSteepCliffs),
new SmoothElevationPainter(ELEVATION_SET, heightCreeks, 0),
@@ -132,7 +132,7 @@ for (let island = 0; island < 2; ++island)
let end = Vector2D.add(islandLocations[island], new Vector2D(radiusBeach, 0).rotate(-angle));
createArea(
new ClumpPlacer(130, 0.7, 0.8, 10, Math.round((start.x + end.x * 3) / 4), Math.round((start.y + end.y * 3) / 4)),
new ClumpPlacer(130, 0.7, 0.8, 10, Vector2D.add(start, Vector2D.mult(end, 3)).div(4)),
new SmoothElevationPainter(ELEVATION_SET, heightBeaches, 5));
createPassage({
@@ -147,12 +147,12 @@ for (let island = 0; island < 2; ++island)
log("Creating main relief...");
createArea(
new ClumpPlacer(diskArea(radiusIsland), 1, 0.2, 10, islandLocations[island].x, islandLocations[island].y),
new ClumpPlacer(diskArea(radiusIsland), 1, 0.2, 10, islandLocations[island]),
new SmoothElevationPainter(ELEVATION_MODIFY, heightOffsetMainRelief, fractionToTiles(0.45)));
log("Creating first level plateau...");
createArea(
new ClumpPlacer(diskArea(radiusLevel1), 0.95, 0.02, 10, islandLocations[island].x, islandLocations[island].y),
new ClumpPlacer(diskArea(radiusLevel1), 0.95, 0.02, 10, islandLocations[island]),
new SmoothElevationPainter(ELEVATION_MODIFY, heightOffsetLevel1, 1));
log("Creating first level passages...");
@@ -173,7 +173,7 @@ for (let island = 0; island < 2; ++island)
{
log("Creating second level plateau...");
createArea(
new ClumpPlacer(diskArea(radiusLevel2), 0.98, 0.04, 10, islandLocations[island].x, islandLocations[island].y),
new ClumpPlacer(diskArea(radiusLevel2), 0.98, 0.04, 10, islandLocations[island]),
[
new LayeredPainter([tCliffs, tGrass], [2]),
new SmoothElevationPainter(ELEVATION_MODIFY, heightOffsetLevel2, 1)
@@ -90,7 +90,7 @@ function createCycladicArchipelagoIsland(position, tileClass, radius, coralRadiu
{
log("Creating deep ocean rocks...");
createArea(
new ClumpPlacer(diskArea(radius + coralRadius), 0.7, 0.1, 10, position.x, position.y),
new ClumpPlacer(diskArea(radius + coralRadius), 0.7, 0.1, 10, position),
[
new LayeredPainter([tOceanRockDeep, tOceanCoral], [5]),
paintClass(clCoral)
@@ -100,7 +100,7 @@ function createCycladicArchipelagoIsland(position, tileClass, radius, coralRadiu
log("Creating island...");
areas.push(
createArea(
new ClumpPlacer(diskArea(radius), 0.7, 0.1, 10, position.x, position.y),
new ClumpPlacer(diskArea(radius), 0.7, 0.1, 10, position),
[
new LayeredPainter([tOceanCoral, tBeachWet, tBeachDry, tBeach, tBeachBlend, tGrass], [1, 3, 1, 1, 2]),
new SmoothElevationPainter(ELEVATION_SET, heightLand, 5),
@@ -208,7 +208,7 @@ if (gallicCC)
// Create the meeting place near the shoreline at the end of the path
createArea(
new ClumpPlacer(diskArea(mRadius), 0.6, 0.3, 10, meetingPlacePosition.x, meetingPlacePosition.y),
new ClumpPlacer(diskArea(mRadius), 0.6, 0.3, 10, meetingPlacePosition),
[
new LayeredPainter([tShore, tShore], [1]),
paintClass(clPath),
@@ -257,7 +257,7 @@ if (gallicCC)
// Create the city patch
createArea(
new ClumpPlacer(diskArea(gaulCityRadius), 0.6, 0.3, 10, civicCenterPosition.x, civicCenterPosition.y),
new ClumpPlacer(diskArea(gaulCityRadius), 0.6, 0.3, 10, civicCenterPosition),
[
new LayeredPainter([tShore, tShore], [1]),
paintClass(clGauls)
@@ -137,7 +137,7 @@ for (let i = 0; i < numPlayers; ++i)
placeObject(position.x, position.y, resourcePerPlayer[rIndex], 0, randomAngle());
createArea(
new ClumpPlacer(40, 1/2, 1/8, 1, position.x, position.y),
new ClumpPlacer(40, 1/2, 1/8, 1, position),
[
new LayeredPainter([terrainHillBorder, terrainHill], [1]),
new ElevationPainter(randFloat(1, 2)),
@@ -152,7 +152,7 @@ addToClass(mapCenter.x, mapCenter.y, clBaseResource);
log("Creating central mountain...");
createArea(
new ClumpPlacer(Math.square(radiusEC), 1/2, 1/8, 1, mapCenter.x, mapCenter.y),
new ClumpPlacer(Math.square(radiusEC), 1/2, 1/8, 1, mapCenter),
[
new LayeredPainter([terrainHillBorder, terrainHill], [radiusEC/4]),
new ElevationPainter(randFloat(1, 2)),
@@ -181,7 +181,7 @@ for (var x = 0; x < mapSize; x++)
{
let border = tDensActual < randFloat(0, bushChance * maxTreeDensity);
createArea(
new ClumpPlacer(1, 1, 1, 1, x, z),
new RectPlacer(position.x, position.y, position.x + 1, position.y + 1)
[
new TerrainPainter(border ? terrainWoodBorder : terrainWood),
new ElevationPainter(randFloat(0, 1)),
@@ -97,7 +97,7 @@ if (!isNomad())
// Flatten the initial CC area
createArea(
new ClumpPlacer(diskArea(playerMountainSize), 0.95, 0.6, 10, playerPosition[i].x,playerPosition[i].y),
new ClumpPlacer(diskArea(playerMountainSize), 0.95, 0.6, 10, playerPosition[i]),
[
new LayeredPainter([tHillVeryDark, tHillMedium1], [playerMountainSize]),
new SmoothElevationPainter(ELEVATION_SET, heightPlayerHill, playerMountainSize),
@@ -71,13 +71,7 @@ var [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.38));
for (let i = 0; i < numPlayers; ++i)
createArea(
new ClumpPlacer(
2 * diskArea(defaultPlayerBaseRadius()),
0.8,
0.1,
10,
playerPosition[i].x,
playerPosition[i].y),
new ClumpPlacer(diskArea(1.4 * defaultPlayerBaseRadius()), 0.8, 0.1, 10, playerPosition[i]),
[
new LayeredPainter([tShore, tMainTerrain], [shoreRadius]),
new SmoothElevationPainter(ELEVATION_SET, heightLand, shoreRadius),
@@ -116,7 +116,7 @@ else if (mapSize == 448)
log("Creating big circular lake...");
createArea(
new ClumpPlacer(diskArea(radiusCentralLake), 1, 1, 10, mapCenter.x, mapCenter.y),
new ClumpPlacer(diskArea(radiusCentralLake), 1, 1, 10, mapCenter),
new SmoothElevationPainter(ELEVATION_SET, heightShallow, 4));
for (let m = 0; m < numPlayers * split; ++m)
@@ -141,22 +141,22 @@ for (let m = 0; m < numPlayers * split; ++m)
log("Creating ring of land connecting players...");
createArea(
new ClumpPlacer(diskArea(radiusCentralRingLand), 1, 1, 10, mapCenter.x, mapCenter.y),
new ClumpPlacer(diskArea(radiusCentralRingLand), 1, 1, 10, mapCenter),
new SmoothElevationPainter(ELEVATION_SET, heightRing, 4));
log("Creating ring of water separating the central hill from the ring...");
createArea(
new ClumpPlacer(diskArea(radiusCentralWaterRing), 1, 1, 10, mapCenter.x, mapCenter.y),
new ClumpPlacer(diskArea(radiusCentralWaterRing), 1, 1, 10, mapCenter),
new SmoothElevationPainter(ELEVATION_SET, heightShallow, 3));
log("Creating central island...");
createArea(
new ClumpPlacer(diskArea(radiusCentralIsland), 1, 1, 10, mapCenter.x, mapCenter.y),
new ClumpPlacer(diskArea(radiusCentralIsland), 1, 1, 10, mapCenter),
new SmoothElevationPainter(ELEVATION_SET, heightRing, 3));
log("Creating hill on the central island...");
createArea(
new ClumpPlacer(diskArea(radiusCentralHill), 1, 1, 10, mapCenter.x, mapCenter.y),
new ClumpPlacer(diskArea(radiusCentralHill), 1, 1, 10, mapCenter),
new SmoothElevationPainter(ELEVATION_SET, heightHill, 8));
paintTerrainBasedOnHeight(-6, 1, 1, tWater);
@@ -329,7 +329,7 @@ function addHarbors(players)
{
let harborPosition = Vector2D.add(player.position, Vector2D.sub(mapCenter, player.position).div(2.5).round());
createArea(
new ClumpPlacer(1200, 0.5, 0.5, 1, harborPosition.x, harborPosition.y),
new ClumpPlacer(1200, 0.5, 0.5, 1, harborPosition),
[
new LayeredPainter([g_Terrains.shore, g_Terrains.water], [2]),
new SmoothElevationPainter(ELEVATION_MODIFY, heightOffsetHarbor, 3),
@@ -75,7 +75,7 @@ if (!isNomad())
for (let i = 0; i < numPlayers; i++)
{
createArea(
new ClumpPlacer(diskArea(playerIslandRadius), 0.8, 0.1, 10, playerPosition[i].x, playerPosition[i].y),
new ClumpPlacer(diskArea(playerIslandRadius), 0.8, 0.1, 10, playerPosition[i]),
[
new LayeredPainter([tMainTerrain , tMainTerrain, tMainTerrain], [1, 6]),
new SmoothElevationPainter(ELEVATION_SET, heightLand, 6),
@@ -482,7 +482,7 @@ function createSunkenTerrain()
log("Creating central valley...");
createArea(
new ClumpPlacer(diskArea(fractionToTiles(0.29)), 1, 1, 1, mapCenter.x, mapCenter.y),
new ClumpPlacer(diskArea(fractionToTiles(0.29)), 1, 1, 1, mapCenter),
[
new LayeredPainter([g_Terrains.cliff, lower], [3]),
new SmoothElevationPainter(ELEVATION_SET, heightValley, 3),
@@ -491,7 +491,7 @@ function createSunkenTerrain()
log("Creating central hill...");
createArea(
new ClumpPlacer(diskArea(fractionToTiles(0.21)), 1, 1, 1, mapCenter.x, mapCenter.y),
new ClumpPlacer(diskArea(fractionToTiles(0.21)), 1, 1, 1, mapCenter),
[
new LayeredPainter([g_Terrains.cliff, topTerrain], [3]),
new SmoothElevationPainter(ELEVATION_SET, heightHill, 3),
@@ -533,7 +533,7 @@ function createSunkenTerrain()
log("Creating the den of the player...");
createArea(
new ClumpPlacer(diskArea(fractionToTiles(0.1)) / (isNomad() ? 2 : 1), 0.9, 0.3, 1, playerPosition.x, playerPosition.y),
new ClumpPlacer(diskArea(fractionToTiles(0.1)) / (isNomad() ? 2 : 1), 0.9, 0.3, 1, playerPosition),
[
new LayeredPainter([g_Terrains.cliff, base], [3]),
new SmoothElevationPainter(ELEVATION_SET, heightDen, 3),
@@ -542,7 +542,7 @@ function createSunkenTerrain()
log("Creating the expansion of the player...");
createArea(
new ClumpPlacer(expSize, 0.9, 0.3, 1, expansionPosition.x, expansionPosition.y),
new ClumpPlacer(expSize, 0.9, 0.3, 1, expansionPosition),
[
new LayeredPainter([g_Terrains.cliff, base], [3]),
new SmoothElevationPainter(ELEVATION_SET, heightDen, 3),
@@ -556,7 +556,7 @@ function createSunkenTerrain()
{
let position = getCoords(nExp, i, 0.5);
createArea(
new ClumpPlacer(expSize, 0.9, 0.3, 1, position.x, position.y),
new ClumpPlacer(expSize, 0.9, 0.3, 1, position),
[
new LayeredPainter([g_Terrains.cliff, lower], [3]),
new SmoothElevationPainter(ELEVATION_SET, heightValley, 3),
@@ -111,7 +111,7 @@ Engine.SetProgress(25);
log("Creating small puddles at the map border to ensure players being separated...");
for (let riverPosition of riverPositions)
createArea(
new ClumpPlacer(Math.floor(diskArea(scaleByMapSize(5, 10))), 0.95, 0.6, 10, riverPosition.x, riverPosition.y),
new ClumpPlacer(diskArea(scaleByMapSize(5, 10)), 0.95, 0.6, 10, riverPosition),
new SmoothElevationPainter(ELEVATION_SET, heightSeaGround, 2),
avoidClasses(clPlayer, 8));
Engine.SetProgress(30);
@@ -75,7 +75,7 @@ log("Creating player islands and docks...");
for (let i = 0; i < numPlayers; ++i)
{
createArea(
new ClumpPlacer(diskArea(defaultPlayerBaseRadius()), 0.8, 0.1, 10, playerPosition[i].x, playerPosition[i].y),
new ClumpPlacer(diskArea(defaultPlayerBaseRadius()), 0.8, 0.1, 10, playerPosition[i]),
[
new LayeredPainter([tWater, tShore, tMainTerrain], [1, 4]),
new SmoothElevationPainter(ELEVATION_SET, heightLand, 4),
@@ -129,7 +129,7 @@ Engine.SetProgress(15);
log("Create the continent body...");
var continentPosition = Vector2D.add(mapCenter, new Vector2D(0, fractionToTiles(0.38)).rotate(-startAngle)).round()
createArea(
new ClumpPlacer(diskArea(fractionToTiles(0.4)), 0.8, 0.08, 10, continentPosition.x, continentPosition.y),
new ClumpPlacer(diskArea(fractionToTiles(0.4)), 0.8, 0.08, 10, continentPosition),
[
new LayeredPainter([tWater, tShore, tMainTerrain], [4, 2]),
new SmoothElevationPainter(ELEVATION_SET, heightLand, 4),
@@ -68,13 +68,7 @@ var [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.35));
if (!isNomad())
for (let i = 0; i < numPlayers; ++i)
createArea(
new ClumpPlacer(
diskArea(defaultPlayerBaseRadius()),
0.9,
0.5,
10,
playerPosition[i].x,
playerPosition[i].y),
new ClumpPlacer(diskArea(defaultPlayerBaseRadius()), 0.9, 0.5, 10, playerPosition[i]),
paintClass(clPlayer));
placePlayerBases({
@@ -140,7 +134,7 @@ Engine.SetProgress(25);
log("Creating oasis...");
createArea(
new ClumpPlacer(diskArea(oasisRadius), 0.6, 0.15, 0, mapCenter.x, mapCenter.y),
new ClumpPlacer(diskArea(oasisRadius), 0.6, 0.15, 0, mapCenter),
[
new LayeredPainter([[tSand, pForest], [tGrassSand25, pForestOasis], tGrassSand25, tShore, tWaterDeep], [2, 3, 1, 1]),
new SmoothElevationPainter(ELEVATION_MODIFY, heightOffsetOasis, 8),
+16 -16
View File
@@ -65,50 +65,50 @@ var forestDist = 1.2 * defaultPlayerBaseRadius();
for (let i = 0; i < numPlayers; ++i)
{
// Create starting batches of wood
let forestX = 0;
let forestY = 0;
let forestAngle = 0
let forestPosition;
let forestAngle;
do {
forestAngle = Math.PI / 3 * randFloat(1, 2);
forestX = playerPosition[i].x + Math.round(forestDist * Math.cos(forestAngle));
forestY = playerPosition[i].y + Math.round(forestDist * Math.sin(forestAngle));
forestPosition = Vector2D.add(playerPosition[i], new Vector2D(forestDist, 0).rotate(-forestAngle));
} while (
!createArea(
new ClumpPlacer(70, 1, 0.5, 10, forestX, forestY),
new ClumpPlacer(70, 1, 0.5, 10, forestPosition),
[
new LayeredPainter([tForestFloor, pForestMain], [0]),
paintClass(clBaseResource)
],
avoidClasses(clBaseResource, 0)));
// Creating the water patch explaining the forest
log("Creating the water patch explaining the forest for player " + playerIDs[i] + "...");
let waterPosition;
do {
var watAngle = forestAngle + randFloat(1/3, 5/3) * Math.PI;
var watX = Math.round(forestX + 6 * Math.cos(watAngle));
var watY = Math.round(forestY + 6 * Math.sin(watAngle));
let waterAngle = forestAngle + randFloat(1, 5) / 3 * Math.PI;
waterPosition = Vector2D.add(forestPosition, new Vector2D(6, 0).rotate(-waterAngle)).round();
let flowerPosition = Vector2D.add(forestPosition, new Vector2D(3, 0).rotate(-waterAngle)).round();
createObjectGroup(
new SimpleGroup(
[new SimpleObject(aFlower1, 1, 5, 0, 3)],
true,
undefined,
Math.round(forestX + 3 * Math.cos(watAngle)),
Math.round(forestY + 3 * Math.sin(watAngle))),
flowerPosition.x,
flowerPosition.y),
0);
let reedsPosition = Vector2D.add(forestPosition, new Vector2D(5, 0).rotate(-waterAngle)).round();
createObjectGroup(
new SimpleGroup(
[new SimpleObject(aReedsA, 1, 3, 0, 0)],
true,
undefined,
Math.round(forestX + 5 * Math.cos(watAngle)),
Math.round(forestY + 5 * Math.sin(watAngle))),
reedsPosition.x,
reedsPosition.y),
0);
} while (
!createArea(
new ClumpPlacer(60, 0.9, 0.4, 5, watX, watY),
new ClumpPlacer(60, 0.9, 0.4, 5, waterPosition),
[
new LayeredPainter([tShore, tWater], [1]),
new SmoothElevationPainter(ELEVATION_SET, heightSeaGround, 3)
@@ -149,7 +149,7 @@ Engine.SetProgress(30);
log("Creating central oasis...");
createArea(
new ClumpPlacer(diskArea(forestDistance + shoreDistance + waterRadius), 0.8, 0.2, 10, mapCenter.x, mapCenter.y),
new ClumpPlacer(diskArea(forestDistance + shoreDistance + waterRadius), 0.8, 0.2, 10, mapCenter),
[
new LayeredPainter([pOasisForestLight, tWater], [forestDistance]),
new SmoothElevationPainter(ELEVATION_SET, heightSeaGround, forestDistance + shoreDistance),
@@ -291,7 +291,7 @@ for (let ix = 1; ix < mapSize - 1; ++ix)
log("Creating oceans...");
for (let ocean of distributePointsOnCircle(2, oceanAngle, fractionToTiles(0.48), mapCenter)[0])
createArea(
new ClumpPlacer(diskArea(fractionToTiles(0.18)), 0.9, 0.05, 10, ocean.x, ocean.y),
new ClumpPlacer(diskArea(fractionToTiles(0.18)), 0.9, 0.05, 10, ocean),
[
new ElevationPainter(heightOcean),
paintClass(clWater)
@@ -99,7 +99,7 @@ placePlayerBases({
log("Creating central lake...");
createArea(
new ClumpPlacer(diskArea(fractionToTiles(0.075)), 0.7, 0.1, 10, mapCenter.x, mapCenter.y),
new ClumpPlacer(diskArea(fractionToTiles(0.075)), 0.7, 0.1, 10, mapCenter),
[
new LayeredPainter([tShore, tWater, tWater, tWater], [1, 4, 2]),
new SmoothElevationPainter(ELEVATION_SET, heightSeaGround, 4),
@@ -252,7 +252,7 @@ function createVolcano(position, tileClass, terrainTexture, lavaTextures, smoke,
for (let i = 0; i < layers.length; ++i)
createArea(
new ClumpPlacer(layers[i].clumps, 0.7, 0.05, 100, position.x, position.y),
new ClumpPlacer(layers[i].clumps, 0.7, 0.05, 100, position),
[
layers[i].painter || new LayeredPainter([terrainTexture, terrainTexture], [3]),
new SmoothElevationPainter(elevationType, layers[i].elevation, layers[i].steepness),
@@ -492,7 +492,7 @@ function createTributaryRivers(riverAngle, riverCount, riverWidth, heightRiverbe
// Create small puddles at the map border to ensure players being separated
createArea(
new ClumpPlacer(Math.floor(diskArea(riverWidth / 2)), 0.95, 0.6, 10, end.x, end.y),
new ClumpPlacer(diskArea(riverWidth / 2), 0.95, 0.6, 10, end),
new SmoothElevationPainter(ELEVATION_SET, heightRiverbed, 3),
constraint);
}
@@ -16,14 +16,14 @@
//
/////////////////////////////////////////////////////////////////////////////////////////
function ClumpPlacer(size, coherence, smoothness, failFraction, x, z)
function ClumpPlacer(size, coherence, smoothness, failFraction = 0, position = undefined)
{
this.size = size;
this.coherence = coherence;
this.smoothness = smoothness;
this.failFraction = failFraction !== undefined ? failFraction : 0;
this.x = x !== undefined ? x : -1;
this.z = z !== undefined ? z : -1;
this.failFraction = failFraction;
this.x = position ? Math.round(position.x) : -1;
this.z = position ? Math.round(position.y) : -1;
}
ClumpPlacer.prototype.place = function(constraint)
@@ -200,8 +200,7 @@ function placePlayerBaseCityPatch(args)
get("coherence", 0.6),
get("smoothness", 0.3),
get("failFraction", 10),
Math.round(basePosition.x),
Math.round(basePosition.y)),
basePosition),
painters);
}
@@ -88,7 +88,7 @@ for (let i = 0; i < numPlayers; ++i)
{
let position = Vector2D.add(mapCenter, new Vector2D(oasisRadius, 0).rotate(-playerAngle[i]));
createArea(
new ClumpPlacer(diskArea(scaleByMapSize(16, 60)) * 0.185, 0.6, 0.15, 0, position.x, position.y),
new ClumpPlacer(diskArea(scaleByMapSize(16, 60)) * 0.185, 0.6, 0.15, 0, position),
[
new LayeredPainter(
[tSLush ,[tLush, pForest], [tLush, pForest], tShore, tShore, tWaterDeep],
@@ -99,7 +99,7 @@ for (let i = 0; i < numPlayers; ++i)
log("Creating lake near the center...");
createArea(
new ClumpPlacer(Math.floor(diskArea(scaleByMapSize(10, 50)) / 3), 0.95, 0.6, 10, riverStart[i].x, riverStart[i].y),
new ClumpPlacer(diskArea(scaleByMapSize(5, 30)), 0.95, 0.6, 10, riverStart[i]),
[
new SmoothElevationPainter(ELEVATION_SET, heightSeaGround, 4),
paintClass(clWater)
@@ -118,7 +118,7 @@ for (let i = 0; i < numPlayers; ++i)
log("Creating lake near the map border...");
createArea(
new ClumpPlacer(Math.floor(diskArea(scaleByMapSize(10, 50)) / 5), 0.95, 0.6, 10, riverEnd[i].x, riverEnd[i].y),
new ClumpPlacer(diskArea(scaleByMapSize(5, 22)), 0.95, 0.6, 10, riverEnd[i]),
[
new SmoothElevationPainter(ELEVATION_SET, heightSeaGround, 4),
paintClass(clWater)
@@ -81,7 +81,7 @@ function initIsConnected()
function createIsland(islandID, size, tileClass)
{
createArea(
new ClumpPlacer(size * diskArea(playerIslandRadius), 0.95, 0.6, 10, islandPos[islandID].x, islandPos[islandID].y),
new ClumpPlacer(size * diskArea(playerIslandRadius), 0.95, 0.6, 10, islandPos[islandID]),
[
new LayeredPainter([tCliff, tHill], [2]),
new SmoothElevationPainter(ELEVATION_SET, heightIsland, 2),
@@ -58,7 +58,7 @@ var clWomen = createTileClass();
log("Creating central area...");
createArea(
new ClumpPlacer(diskArea(fractionToTiles(0.15)), 0.7, 0.1, 10, mapCenter.x, mapCenter.y),
new ClumpPlacer(diskArea(fractionToTiles(0.15)), 0.7, 0.1, 10, mapCenter),
[
new LayeredPainter([tMainTerrain, tMainTerrain], [3]),
new SmoothElevationPainter(ELEVATION_SET, heightLand, 3),
@@ -56,7 +56,7 @@ for (let i = 0; i < numPlayers; ++i)
log("Marking player territory larger than the city patch...");
if (!isNomad())
createArea(
new ClumpPlacer(diskArea(defaultPlayerBaseRadius()), 0.9, 0.5, 10, playerPosition[i].x, playerPosition[i].y),
new ClumpPlacer(diskArea(defaultPlayerBaseRadius()), 0.9, 0.5, 10, playerPosition[i]),
paintClass(clPlayer));
log("Creating big grass patches surrounding the city patches...");
@@ -145,7 +145,7 @@ function unknownArchipelago()
let islandSize = diskArea(scaleByMapSize(17, 29));
for (let i = 0; i < numPlayers; ++i)
createArea(
new ClumpPlacer(islandSize, 0.8, 0.1, 10, islandPosition[i].x, islandPosition[i].y),
new ClumpPlacer(islandSize, 0.8, 0.1, 10, islandPosition[i]),
landElevationPainter);
let type = isNomad() ? randIntInclusive(1, 2) : randIntInclusive(1, 3);
@@ -153,7 +153,7 @@ function unknownArchipelago()
{
log("Creating archipelago...");
createAreas(
new ClumpPlacer(Math.floor(islandSize * randFloat(0.8, 1.2)), 0.8, 0.1, 10),
new ClumpPlacer(islandSize * randFloat(0.8, 1.2), 0.8, 0.1, 10),
[
landElevationPainter,
paintClass(clLand)
@@ -176,7 +176,7 @@ function unknownArchipelago()
{
log("Creating islands...");
createAreas(
new ClumpPlacer(Math.floor(islandSize * randFloat(0.6, 1.4)), 0.8, 0.1, randFloat(0.0, 0.2)),
new ClumpPlacer(islandSize * randFloat(0.6, 1.4), 0.8, 0.1, randFloat(0.0, 0.2)),
[
landElevationPainter,
paintClass(clLand)
@@ -186,7 +186,7 @@ function unknownArchipelago()
log("Creating small islands...");
createAreas(
new ClumpPlacer(Math.floor(islandSize * randFloat(0.3, 0.7)), 0.8, 0.1, 0.07),
new ClumpPlacer(islandSize * randFloat(0.3, 0.7), 0.8, 0.1, 0.07),
[
new SmoothElevationPainter(ELEVATION_SET, heightLand, 6),
paintClass(clLand)
@@ -199,7 +199,7 @@ function unknownArchipelago()
{
log("Creating tight islands...");
createAreas(
new ClumpPlacer(Math.floor(islandSize * randFloat(0.8, 1.2)), 0.8, 0.1, 10),
new ClumpPlacer(islandSize * randFloat(0.8, 1.2), 0.8, 0.1, 10),
[
landElevationPainter,
paintClass(clLand)
@@ -241,7 +241,7 @@ function unknownContinent()
log("Creating continent...");
createArea(
new ClumpPlacer(diskArea(fractionToTiles(0.38)), 0.9, 0.09, 10, mapCenter.x, mapCenter.y),
new ClumpPlacer(diskArea(fractionToTiles(0.38)), 0.9, 0.09, 10, mapCenter),
[
landElevationPainter,
paintClass(clLand)
@@ -253,7 +253,7 @@ function unknownContinent()
let angle = randomAngle();
let peninsulaPosition1 = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.25), 0).rotate(-angle));
createArea(
new ClumpPlacer(diskArea(fractionToTiles(0.38)), 0.9, 0.09, 10, peninsulaPosition1.x, peninsulaPosition1.y),
new ClumpPlacer(diskArea(fractionToTiles(0.38)), 0.9, 0.09, 10, peninsulaPosition1),
[
landElevationPainter,
paintClass(clLand)
@@ -262,7 +262,7 @@ function unknownContinent()
log("Remembering to not paint shorelines into the peninsula...");
let peninsulaPosition2 = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.35), 0).rotate(-angle));
createArea(
new ClumpPlacer(diskArea(fractionToTiles(0.33)), 0.9, 0.01, 10, peninsulaPosition2.x, peninsulaPosition2.y),
new ClumpPlacer(diskArea(fractionToTiles(0.33)), 0.9, 0.01, 10, peninsulaPosition2),
paintClass(clPeninsulaSteam));
}
@@ -361,7 +361,7 @@ function unknownCentralRiver()
log("Creating small water spots at the map border to ensure separation of players...");
for (let coord of [coord1, coord2])
createArea(
new ClumpPlacer(Math.floor(diskArea(scaleByMapSize(5, 10))), 0.95, 0.6, 10, coord.x, coord.y),
new ClumpPlacer(diskArea(scaleByMapSize(5, 10)), 0.95, 0.6, 10, coord),
new SmoothElevationPainter(ELEVATION_SET, waterHeight, 2),
avoidClasses(clPlayerTerritory, 8));
@@ -421,7 +421,7 @@ function unknownRiversAndLake()
{
log("Creating lake...");
createArea(
new ClumpPlacer(diskArea(fractionToTiles(0.17)), 0.7, 0.1, 10, mapCenter.x, mapCenter.y),
new ClumpPlacer(diskArea(fractionToTiles(0.17)), 0.7, 0.1, 10, mapCenter),
[
new SmoothElevationPainter(ELEVATION_SET, waterHeight, 4),
paintClass(clWater)
@@ -445,7 +445,7 @@ function unknownRiversAndLake()
avoidClasses(clPlayer, 5));
createArea(
new ClumpPlacer(Math.floor(diskArea(scaleByMapSize(10, 50)) / 5), 0.95, 0.6, 10, river.x, river.y),
new ClumpPlacer(diskArea(scaleByMapSize(4, 22)), 0.95, 0.6, 10, river),
[
new SmoothElevationPainter(ELEVATION_SET, waterHeight, 0),
paintClass(clWater)
@@ -455,7 +455,7 @@ function unknownRiversAndLake()
log("Creating lake...");
createArea(
new ClumpPlacer(Math.square(mapSize) * 0.005, 0.7, 0.1, 10, mapCenter.x, mapCenter.y),
new ClumpPlacer(diskArea(fractionToTiles(0.04)), 0.7, 0.1, 10, mapCenter),
[
new SmoothElevationPainter(ELEVATION_SET, waterHeight, 4),
paintClass(clWater)
@@ -466,7 +466,7 @@ function unknownRiversAndLake()
{
log("Creating small central island...");
createArea(
new ClumpPlacer(diskArea(fractionToTiles(0.05)), 0.7, 0.1, 10, mapCenter.x, mapCenter.y),
new ClumpPlacer(diskArea(fractionToTiles(0.05)), 0.7, 0.1, 10, mapCenter),
[
landElevationPainter,
paintClass(clWater)
@@ -547,7 +547,7 @@ function unknownGulf()
{
let position = Vector2D.sub(mapCenter, new Vector2D(gulfPart.distance, 0).rotate(-startAngle)).round();
createArea(
new ClumpPlacer(diskArea(gulfPart.radius), 0.7, 0.05, 10, position.x, position.y),
new ClumpPlacer(diskArea(gulfPart.radius), 0.7, 0.05, 10, position),
[
new SmoothElevationPainter(ELEVATION_SET, waterHeight, 4),
paintClass(clWater)
@@ -620,7 +620,7 @@ function unknownPasses()
log("Creating small mountain at the map border between the players to ensure separation of players...");
createArea(
new ClumpPlacer(Math.floor(diskArea(scaleByMapSize(10, 50)) / 5), 0.95, 0.6, 10, mountain.x, mountain.y),
new ClumpPlacer(diskArea(scaleByMapSize(4, 22)), 0.95, 0.6, 10, mountain),
new SmoothElevationPainter(ELEVATION_SET, heightMountain, 0),
avoidClasses(clPlayer, 5));
}
@@ -645,7 +645,7 @@ function unknownPasses()
{
log("Create central lake...");
createArea(
new ClumpPlacer(diskArea(fractionToTiles(0.1)), 0.7, 0.1, 10, mapCenter.x, mapCenter.y),
new ClumpPlacer(diskArea(fractionToTiles(0.1)), 0.7, 0.1, 10, mapCenter),
[
new SmoothElevationPainter(ELEVATION_SET, waterHeight, 3),
paintClass(clWater)
@@ -655,7 +655,7 @@ function unknownPasses()
{
log("Fill area between the paths...");
createArea(
new ClumpPlacer(diskArea(fractionToTiles(0.05)), 0.7, 0.1, 10, mapCenter.x, mapCenter.y),
new ClumpPlacer(diskArea(fractionToTiles(0.05)), 0.7, 0.1, 10, mapCenter),
[
new SmoothElevationPainter(ELEVATION_SET, heightMountain, 4),
paintClass(clWater)
@@ -698,7 +698,7 @@ function unknownLowlands()
{
log("Creating player valley...");
createArea(
new ClumpPlacer(diskArea(scaleByMapSize(18, 32)), 0.65, 0.1, 10, valley.x, valley.y),
new ClumpPlacer(diskArea(scaleByMapSize(18, 32)), 0.65, 0.1, 10, valley),
[
new SmoothElevationPainter(ELEVATION_SET, heightLand, 2),
paintClass(clLand)
@@ -715,7 +715,7 @@ function unknownLowlands()
log("Creating the big central area...");
createArea(
new ClumpPlacer(diskArea(fractionToTiles(0.18)), 0.7, 0.1, 10, mapCenter.x, mapCenter.y),
new ClumpPlacer(diskArea(fractionToTiles(0.18)), 0.7, 0.1, 10, mapCenter),
[
landElevationPainter,
paintClass(clWater)
@@ -806,7 +806,7 @@ function markPlayerArea(size)
if (size == "large")
createArea(
new ClumpPlacer(diskArea(scaleByMapSize(17, 29) / 3), 0.6, 0.3, 10, playerPosition[i].x, playerPosition[i].y),
new ClumpPlacer(diskArea(scaleByMapSize(17, 29) / 3), 0.6, 0.3, 10, playerPosition[i]),
paintClass(clPlayerTerritory));
}
}
@@ -248,13 +248,17 @@ function placeGrove(point,
let objectList = groveEntities;
if (i % 3 == 0)
objectList = groveActors;
let x = point.x + dist * Math.cos(angle);
let y = point.y + dist * Math.sin(angle);
placeObject(x, y, pickRandom(objectList), 0, randomAngle());
let position = Vector2D.add(point, new Vector2D(dist, 0).rotate(-angle));
placeObject(position.x, position.y, pickRandom(objectList), 0, randomAngle());
let painters = [new TerrainPainter(groveTerrainTexture)];
if (groveTileClass)
createArea(new ClumpPlacer(5, 1, 1, 1, Math.floor(x), Math.floor(y)), [new TerrainPainter(groveTerrainTexture), paintClass(groveTileClass)]);
else
createArea(new ClumpPlacer(5, 1, 1, 1, Math.floor(x), Math.floor(y)), [new TerrainPainter(groveTerrainTexture)]);
painters.push(paintClass(groveTileClass));
createArea(
new ClumpPlacer(5, 1, 1, 1, position),
painters);
}
}
@@ -372,10 +376,16 @@ function placeStartLocationResources(
let objectList = groveEntities;
if (i % 2 == 0)
objectList = groveActors;
let x = point.x + dist * Math.cos(angle);
let y = point.y + dist * Math.sin(angle);
placeObject(x, y, pickRandom(objectList), 0, randomAngle());
createArea(new ClumpPlacer(5, 1, 1, 1, Math.floor(x), Math.floor(y)), [new TerrainPainter(groveTerrainTexture), paintClass(clGrove)]);
let position = Vector2D.add(point, new Vector2D(dist, 0).rotate(-angle));
placeObject(position.x, position.y, pickRandom(objectList), 0, randomAngle());
createArea(
new ClumpPlacer(5, 1, 1, 1, position),
[
new TerrainPainter(groveTerrainTexture),
paintClass(clGrove)
]);
currentAngle += dAngle;
}