Randomize map angle on random maps with linear playerposition pattern, refs #4855, #4845.

This was SVN commit r20933.
This commit is contained in:
elexis
2018-01-20 02:21:22 +00:00
parent 5519742e7f
commit 903e094f62
7 changed files with 74 additions and 51 deletions
@@ -62,10 +62,13 @@ var clFood = createTileClass();
var clBaseResource = createTileClass();
var clHighlands = createTileClass();
var highlandsPosition = fractionToTiles(0.25);
var waterPosition = fractionToTiles(0.25)
var highlandsPosition = fractionToTiles(0.75);
var startAngle = randomAngle();
placePlayerBases({
"PlayerPlacement": playerPlacementLine(true, mapCenter, fractionToTiles(0.2)),
"PlayerPlacement": [sortAllPlayers(), playerPlacementLine(startAngle, mapCenter, fractionToTiles(0.2))],
"PlayerTileClass": clPlayer,
"BaseResourceClass": clBaseResource,
"CityPatch": {
@@ -95,15 +98,20 @@ Engine.SetProgress(10);
paintRiver({
"parallel": true,
"start": new Vector2D(mapBounds.left, mapBounds.top),
"end": new Vector2D(mapBounds.right, mapBounds.top),
"width": fractionToTiles(0.5),
"start": new Vector2D(mapBounds.left, mapBounds.top).rotateAround(startAngle, mapCenter),
"end": new Vector2D(mapBounds.right, mapBounds.top).rotateAround(startAngle, mapCenter),
"width": 2 * waterPosition,
"fadeDist": scaleByMapSize(6, 25),
"deviation": 0,
"heightRiverbed": heightSeaGround1,
"heightLand": heightLand,
"meanderShort": 20,
"meanderLong": 0,
"landFunc": (ix, iz, shoreDist1, shoreDist2) => {
if (waterPosition + shoreDist1 > highlandsPosition)
addToClass(ix, iz, clHighlands);
},
"waterFunc": (ix, iz, height, riverFraction) => {
if (height < heightShore2)
@@ -124,10 +132,6 @@ for (let i = 0; i < scaleByMapSize(10, 20); ++i)
50);
Engine.SetProgress(25);
createArea(
new RectPlacer(mapBounds.left, mapBounds.bottom + highlandsPosition, mapBounds.right, mapBounds.bottom),
paintClass(clHighlands));
log("Creating bumps...");
createAreas(
new ClumpPlacer(scaleByMapSize(10, 60), 0.3, 0.06, 1),
+17 -14
View File
@@ -54,10 +54,16 @@ var clBaseResource = createTileClass();
var clMountains = createTileClass();
var waterPosition = fractionToTiles(0.31);
var playerPosition = fractionToTiles(0.55);
var mountainPosition = fractionToTiles(0.69);
var startAngle = randomAngle();
placePlayerBases({
"PlayerPlacement": playerPlacementLine(false, new Vector2D(fractionToTiles(0.55), mapCenter.y), fractionToTiles(0.2)),
"PlayerPlacement": [
sortAllPlayers(),
playerPlacementLine(0, new Vector2D(mapCenter.x, playerPosition), fractionToTiles(0.2)).map(pos => pos.rotateAround(startAngle, mapCenter))
],
"PlayerTileClass": clPlayer,
"BaseResourceClass": clBaseResource,
"CityPatch": {
@@ -89,8 +95,8 @@ Engine.SetProgress(15);
paintRiver({
"parallel": true,
"start": new Vector2D(mapBounds.left, mapBounds.top),
"end": new Vector2D(mapBounds.left, mapBounds.bottom),
"start": new Vector2D(mapBounds.left, mapBounds.top).rotateAround(startAngle - Math.PI / 2, mapCenter),
"end": new Vector2D(mapBounds.left, mapBounds.bottom).rotateAround(startAngle - Math.PI / 2, mapCenter),
"width": 2 * waterPosition,
"fadeDist": 8,
"deviation": 0,
@@ -98,30 +104,27 @@ paintRiver({
"heightLand": heightLand,
"meanderShort": 20,
"meanderLong": 0,
"landFunc": (ix, iz, shoreDist1, shoreDist2) => {
if (waterPosition + shoreDist1 > mountainPosition)
addToClass(ix, iz, clMountains);
},
"waterFunc": (ix, iz, height, riverFraction) => {
addToClass(ix, iz, clWater);
}
});
createArea(
new RectPlacer(mountainPosition, mapBounds.top, mapBounds.right, mapBounds.bottom),
paintClass(clMountains));
log("Creating shores...");
for (let i = 0; i < scaleByMapSize(20, 120); ++i)
{
let position = new Vector2D(fractionToTiles(randFloat(0.28, 0.34)), fractionToTiles(randFloat(0.1, 0.9))).rotateAround(startAngle - Math.PI / 2, mapCenter).round();
createArea(
new ChainPlacer(
1,
Math.floor(scaleByMapSize(4, 6)),
Math.floor(scaleByMapSize(16, 30)),
1,
Math.floor(fractionToTiles(randFloat(0.28, 0.34))),
Math.floor(fractionToTiles(randFloat(0.1, 0.9)))),
new ChainPlacer(1, Math.floor(scaleByMapSize(4, 6)), Math.floor(scaleByMapSize(16, 30)), 1, position.x, position.y),
[
new LayeredPainter([tGrass, tGrass], [2]),
new SmoothElevationPainter(ELEVATION_SET, heightLand, 3),
unPaintClass(clWater)
]);
}
paintTerrainBasedOnHeight(-6, 1, 1, tWater);
paintTerrainBasedOnHeight(1, 2.8, 1, tShoreBlend);
@@ -49,8 +49,14 @@ var clMetal = createTileClass();
var clFood = createTileClass();
var clBaseResource = createTileClass();
var startAngle = randomAngle();
placePlayerBases({
"PlayerPlacement": playerPlacementLine(true, new Vector2D(fractionToTiles(0.45), mapCenter.y), fractionToTiles(0.2)),
"PlayerPlacement": [
sortAllPlayers(),
playerPlacementLine(0, new Vector2D(mapCenter.x, fractionToTiles(0.45)), fractionToTiles(0.2)).map(
pos => pos.rotateAround(startAngle, mapCenter))
],
"PlayerTileClass": clPlayer,
"BaseResourceClass": clBaseResource,
"CityPatch": {
@@ -74,8 +80,8 @@ Engine.SetProgress(15);
paintRiver({
"parallel": true,
"start": new Vector2D(mapBounds.left, mapBounds.top),
"end": new Vector2D(mapBounds.right, mapBounds.top),
"start": new Vector2D(mapBounds.left, mapBounds.top).rotateAround(startAngle, mapCenter),
"end": new Vector2D(mapBounds.right, mapBounds.top).rotateAround(startAngle, mapCenter),
"width": 2 * fractionToTiles(0.31),
"fadeDist": 8,
"deviation": 0,
@@ -89,19 +95,16 @@ paintTileClassBasedOnHeight(-Infinity, 0.5, Elevation_ExcludeMin_ExcludeMax, clW
log("Creating shores...");
for (let i = 0; i < scaleByMapSize(20, 120); ++i)
{
let position = new Vector2D(fractionToTiles(randFloat(0.1, 0.9)), fractionToTiles(randFloat(0.67, 0.74))).rotateAround(startAngle, mapCenter).round();
createArea(
new ChainPlacer(
1,
Math.floor(scaleByMapSize(4, 6)),
Math.floor(scaleByMapSize(16, 30)),
1,
Math.floor(fractionToTiles(randFloat(0.1, 0.9))),
Math.floor(fractionToTiles(randFloat(0.67, 0.74)))),
new ChainPlacer(1, Math.floor(scaleByMapSize(4, 6)), Math.floor(scaleByMapSize(16, 30)), 1, position.x, position.y),
[
new LayeredPainter([tSnowA, tSnowA], [2]),
new SmoothElevationPainter(ELEVATION_SET, heightLand, 3),
unPaintClass(clWater)
]);
}
log("Creating islands...");
createAreas(
@@ -65,8 +65,14 @@ var clGrass = createTileClass();
var clHill = createTileClass();
var clIsland = createTileClass();
var startAngle = randIntInclusive(0, 3) * Math.PI / 2;
placePlayerBases({
"PlayerPlacement": playerPlacementLine(false, new Vector2D(fractionToTiles(0.76), mapCenter.y), fractionToTiles(0.2)),
"PlayerPlacement": [
sortAllPlayers(),
playerPlacementLine(Math.PI / 2, new Vector2D(fractionToTiles(0.76), mapCenter.y), fractionToTiles(0.2)).map(pos =>
pos.rotateAround(startAngle, mapCenter))
],
"PlayerTileClass": clPlayer,
"BaseResourceClass": clBaseResource,
"CityPatch": {
@@ -96,8 +102,8 @@ Engine.SetProgress(30);
paintRiver({
"parallel": true,
"start": new Vector2D(mapBounds.left, mapBounds.top),
"end": new Vector2D(mapBounds.left, mapBounds.bottom),
"start": new Vector2D(mapBounds.left, mapBounds.top).rotateAround(startAngle, mapCenter),
"end": new Vector2D(mapBounds.left, mapBounds.bottom).rotateAround(startAngle, mapCenter),
"width": mapSize,
"fadeDist": scaleByMapSize(6, 25),
"deviation": 0,
@@ -47,6 +47,7 @@ InitMap(heightSeaGround, tGrass);
const numPlayers = getNumPlayers();
const mapCenter = getMapCenter();
const mapBounds = getMapBounds();
var clPlayer = createTileClass();
var clPlayerTerritory = createTileClass();
@@ -61,6 +62,7 @@ var clBaseResource = createTileClass();
var clGaia = createTileClass();
var clStrip = [];
var startAngle = randomAngle();
var connectPlayers = randBool();
// Map layout
@@ -82,26 +84,32 @@ for (let i = 0; i < stripWidths.length; ++i)
let isPlayerStrip = i == 2 || i == 3;
for (let j = 0; j < scaleByMapSize(20, 100); ++j)
{
let position = new Vector2D(
randFloat(mapBounds.bottom, mapBounds.top),
fractionToTiles(randFloat(...stripWidths[i]))).rotateAround(startAngle, mapCenter).round();
createArea(
new ChainPlacer(
1,
Math.floor(scaleByMapSize(3, connectPlayers && isPlayerStrip ? 8 : 7)),
Math.floor(scaleByMapSize(30, 60)),
1,
Math.floor(fractionToTiles(randFloat(...stripWidths[i]))),
Math.floor(fractionToTiles(randFloat(0, 1)))),
position.x,
position.y),
[
new LayeredPainter([tGrass, tGrass], [2]),
new SmoothElevationPainter(ELEVATION_SET, heightLand, 3),
paintClass(clStrip[i])
]);
}
}
Engine.SetProgress(20);
var [playerIDs, playerPosition] = playerPlacementLine(false, mapCenter, fractionToTiles(1 - stripWidthsLeft[2][0] - stripWidthsLeft[2][1]));
var playerPosition = playerPlacementLine(startAngle, mapCenter, fractionToTiles(1 - stripWidthsLeft[2][0] - stripWidthsLeft[2][1]));
// Either left vs right or top vs bottom
playerIDs = randBool() ? sortAllPlayers() : primeSortAllPlayers();
var playerIDs = randBool() ? sortAllPlayers() : primeSortAllPlayers();
log("Ensuring player territory...");
var playerRadius = scaleByMapSize(12, 20);
@@ -567,9 +567,8 @@ function playerPlacementRiver(angle, width, center = undefined)
/***
* Returns starting positions located on two parallel lines.
* The locations on the first line are shifted in comparison to the other line.
* The players are grouped per team and hence they can be found on both lines.
*/
function playerPlacementLine(horizontal, center, width)
function playerPlacementLine(angle, center, width)
{
let playerPosition = [];
let numPlayers = getNumPlayers();
@@ -579,9 +578,11 @@ function playerPlacementLine(horizontal, center, width)
center,
new Vector2D(
fractionToTiles((i + 1) / (numPlayers + 1) - 0.5),
width * (i % 2 - 1/2))).rotateAround(horizontal ? 0 : Math.PI / 2, center).round();
width * (i % 2 - 1/2)
).rotate(angle)
).round();
return [sortAllPlayers(), playerPosition];
return playerPosition;
}
/**
@@ -487,21 +487,20 @@ function unknownEdgeSeas()
new MapBoundsPlacer(),
new ElevationPainter(heightLand));
let horizontal = randBool();
let startAngle = randomAngle();
if (!isNomad())
{
[playerIDs, playerPosition] = playerPlacementLine(horizontal, mapCenter, fractionToTiles(0.2));
playerIDs = sortAllPlayers();
playerPosition = playerPlacementLine(startAngle + Math.PI / 2, mapCenter, fractionToTiles(0.2));
// Don't place the shoreline inside the CC, but possibly into the players territory
markPlayerArea("small");
}
for (let side of pickRandom([[0], [Math.PI], [0, Math.PI]]))
{
let angle = side + (horizontal ? 0 : Math.PI / 2);
paintRiver({
"parallel": true,
"start": new Vector2D(mapBounds.left, mapBounds.top).rotateAround(angle, mapCenter),
"end": new Vector2D(mapBounds.left, mapBounds.bottom).rotateAround(angle, mapCenter),
"start": new Vector2D(mapBounds.left, mapBounds.top).rotateAround(side + startAngle, mapCenter),
"end": new Vector2D(mapBounds.left, mapBounds.bottom).rotateAround(side + startAngle, mapCenter),
"width": scaleByMapSize(80, randFloat(270, 320)),
"fadeDist": scaleByMapSize(2, 8),
"deviation": 0,
@@ -510,7 +509,6 @@ function unknownEdgeSeas()
"meanderShort": 20,
"meanderLong": 0
});
}
createExtensionsOrIslands();
paintTileClassBasedOnHeight(0, heightCliff, 1, clLand);