1
0
forked from 0ad/0ad

Remove references from the random mapgen library to terrain globals of maps.

Maps should not be required to define all these globals and use them
with the connotation implied by these utilities.

Split utilityfunctions.js to gaia_entities.js and gaia_terrain.js to
make it more transparent what files contain, refs #4804.
Document these functions #4831.

Refactor stoneMine placing and use for...of loops.
Fix Extinct Volcano call.
Forest utilities will be handled separately.

This was SVN commit r20405.
This commit is contained in:
elexis 2017-11-04 11:17:23 +00:00
parent 17b50a2aa7
commit 822e37f70c
30 changed files with 403 additions and 405 deletions

View File

@ -194,8 +194,9 @@ createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[[tGrass,tGrassSand50],[tGrassSand50,tGrassSand25], [tGrassSand25,tGrass]],
[1,1],
avoidClasses(clForest, 0, clGrass, 2, clPlayer, 10, clWater, 2, clDirt, 2, clHill, 1)
);
avoidClasses(clForest, 0, clGrass, 2, clPlayer, 10, clWater, 2, clDirt, 2, clHill, 1),
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(55);
@ -204,8 +205,9 @@ createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[tDirt3, tDirt2,[tDirt,tMainDirt], [tDirtCracks,tMainDirt]],
[1,1,1],
avoidClasses(clForest, 0, clDirt, 2, clPlayer, 10, clWater, 2, clGrass, 2, clHill, 1)
);
avoidClasses(clForest, 0, clDirt, 2, clPlayer, 10, clWater, 2, clGrass, 2, clHill, 1),
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(60);
@ -242,8 +244,8 @@ createMines(
[new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],
[new SimpleObject(oStoneSmall, 2,5, 1,3)]
],
stayClasses(clIsland, 4)
);
stayClasses(clIsland, 4),
clRock);
log("Creating island metal mines...");
createMines(
@ -260,8 +262,8 @@ createMines(
[new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],
[new SimpleObject(oStoneSmall, 2,5, 1,3)]
],
avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clWater, 1, clHill, 1)
);
avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clWater, 1, clHill, 1),
clRock);
log("Creating metal mines...");
createMines(

View File

@ -108,7 +108,7 @@ for (var i = 0; i < numPlayers; ++i)
mAngle += randFloat(PI/8, PI/4);
mX = round(fx + mDist * cos(mAngle));
mZ = round(fz + mDist * sin(mAngle));
createStoneMineFormation(mX, mZ, tDirt4);
createStoneMineFormation(mX, mZ, oStoneSmall, tDirt4);
addToClass(mX, mZ, clPlayer);
// create starting trees
@ -166,22 +166,25 @@ createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[[tDirt,tDirt3], [tDirt2,tDirt4]],
[2],
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12)
);
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12),
scaleByMapSize(15, 45),
clDirt);
log("Creating shrubs...");
createPatches(
[scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
tGrassShrubs,
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12)
);
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12),
scaleByMapSize(15, 45),
clDirt);
log("Creating grass patches...");
createPatches(
[scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
tSecondary,
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12)
);
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12),
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(60);
log("Creating stone mines...");
@ -190,8 +193,8 @@ createMines(
[new SimpleObject(oStoneSmall, 0,2, 0,4)],
[new SimpleObject(oStoneSmall, 2,5, 1,3)]
],
avoidClasses(clWater, 4, clForest, 4, clPlayer, 20, clRock, 10, clHill, 4)
);
avoidClasses(clWater, 4, clForest, 4, clPlayer, 20, clRock, 10, clHill, 4),
clRock);
log("Creating metal mines...");
createMines(
@ -261,8 +264,8 @@ createFood(
3 * numPlayers,
3 * numPlayers,
],
avoidClasses(clFood, 20, clWater, 5, clHill, 2, clPlayer, 16)
);
avoidClasses(clFood, 20, clWater, 5, clHill, 2, clPlayer, 16),
clFood);
createFood(
[
@ -271,8 +274,8 @@ createFood(
[
3 * numPlayers,
],
stayClasses(clWater, 6)
);
stayClasses(clWater, 6),
clFood);
createFood(
[
@ -281,8 +284,8 @@ createFood(
[
randIntInclusive(1, 4) * numPlayers + 2
],
avoidClasses(clWater, 3, clForest, 2, clPlayer, 20, clHill, 3, clFood, 10)
);
avoidClasses(clWater, 3, clForest, 2, clPlayer, 20, clHill, 3, clFood, 10),
clFood);
createFood(
[

View File

@ -250,16 +250,17 @@ createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[[tDirt,tHalfSnow], [tHalfSnow,tSnowLimited]],
[2],
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12)
);
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12),
scaleByMapSize(15, 45),
clDirt);
log("Creating grass patches...");
createPatches(
[scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
tSecondary,
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12)
);
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12),
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(65);
log("Creating stone mines...");
@ -268,8 +269,8 @@ createMines(
[new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],
[new SimpleObject(oStoneSmall, 2,5, 1,3)]
],
avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1)
);
avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1),
clRock);
log("Creating metal mines...");
createMines(

View File

@ -160,8 +160,7 @@ createLayeredPatches(
[1,1],
avoidClasses(clForest, 0, clHill, 0, clDirt, 2, clPlayer, 10),
scaleByMapSize(50, 70),
clDirt
);
clDirt);
log("Creating dirt patches...");
createLayeredPatches(
@ -170,8 +169,7 @@ createLayeredPatches(
[1],
avoidClasses(clForest, 0, clHill, 0, clDirt, 2, clPlayer, 10),
scaleByMapSize(50, 90),
clDirt
);
clDirt);
RMS.SetProgress(55);
@ -182,8 +180,7 @@ createLayeredPatches(
[1],
avoidClasses(clHill, 0, clPlayer, 8),
scaleByMapSize(30, 90),
clDirt
);
clDirt);
RMS.SetProgress(55);

View File

@ -208,15 +208,17 @@ createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[[tMainTerrain,tTier1Terrain],[tTier1Terrain,tTier2Terrain], [tTier2Terrain,tTier3Terrain]],
[1,1],
[avoidClasses(clForest, 0, clHill, 0, clDirt, 3, clPlayer, 12), stayClasses(clLand, 7)]
);
[avoidClasses(clForest, 0, clHill, 0, clDirt, 3, clPlayer, 12), stayClasses(clLand, 7)],
scaleByMapSize(15, 45),
clDirt);
log("Creating grass patches...");
createPatches(
[scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
tTier4Terrain,
[avoidClasses(clForest, 0, clHill, 0, clDirt, 3, clPlayer, 12), stayClasses(clLand, 7)]
);
[avoidClasses(clForest, 0, clHill, 0, clDirt, 3, clPlayer, 12), stayClasses(clLand, 7)],
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(55);
log("Creating stone mines...");
@ -225,7 +227,8 @@ createMines(
[new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],
[new SimpleObject(oStoneSmall, 2,5, 1,3)]
],
[avoidClasses(clForest, 1, clPlayer, 7, clRock, 10, clHill, 1), stayClasses(clLand, 6)]
[avoidClasses(clForest, 1, clPlayer, 7, clRock, 10, clHill, 1), stayClasses(clLand, 6)],
clRock
);
log("Creating metal mines...");
@ -238,7 +241,6 @@ createMines(
);
RMS.SetProgress(65);
log("Creating decoration...");
var planetm = currentBiome() == "tropic" ? 8 : 1;
createDecoration
(
@ -259,7 +261,6 @@ createDecoration
);
RMS.SetProgress(70);
log("Creating animals...");
createFood
(
[
@ -274,7 +275,6 @@ createFood
);
RMS.SetProgress(75);
log("Creating fruits...");
createFood
(
[
@ -287,7 +287,6 @@ createFood
);
RMS.SetProgress(80);
log("Creating fish...");
createFood
(
[

View File

@ -204,7 +204,9 @@ createLayeredPatches(
clForest, 0,
clHill, 0,
clDirt, 5,
clPlayer, 12));
clPlayer, 12),
scaleByMapSize(15, 45),
clDirt);
log("Creating shrubs...");
createPatches(
@ -215,7 +217,9 @@ createPatches(
clForest, 0,
clHill, 0,
clDirt, 5,
clPlayer, 12));
clPlayer, 12),
scaleByMapSize(15, 45),
clDirt);
log("Creating grass patches...");
createPatches(
@ -226,7 +230,9 @@ createPatches(
clForest, 0,
clHill, 0,
clDirt, 5,
clPlayer, 12));
clPlayer, 12),
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(65);
log("Creating stone mines...");
@ -240,7 +246,8 @@ createMines(
clForest, 1,
clPlayer, 20,
clRock, 18,
clHill, 1));
clHill, 1),
clRock);
log("Creating metal mines...");
createMines(
@ -294,10 +301,10 @@ createFood(
avoidClasses(
clFood, 20,
clHill, 5,
clWater, 5));
clWater, 5),
clFood);
createFood
(
createFood(
[
[new SimpleObject(oWhaleFin, 1, 1, 0, 3)],
[new SimpleObject(oWhaleHumpback, 1, 1, 0, 3)]
@ -309,10 +316,10 @@ createFood
[
avoidClasses(clFood, 20),
stayClasses(clWater, 6)
]);
],
clFood);
createFood
(
createFood(
[
[new SimpleObject(oBerryBush, 5, 7, 0, 4)]
],
@ -324,7 +331,8 @@ createFood
clForest, 0,
clPlayer, 20,
clHill, 1,
clFood, 10));
clFood, 10),
clFood);
createFood(
[
@ -336,7 +344,8 @@ createFood(
[
avoidClasses(clFood, 20),
stayClasses(clWater, 6)
]);
],
clFood);
RMS.SetProgress(85);

View File

@ -148,16 +148,18 @@ createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[tGrassDirt,tDirt],
[2],
avoidClasses(clForest, 0, clHill, 0, clDirt, 3, clPlayer, 10)
);
avoidClasses(clForest, 0, clHill, 0, clDirt, 3, clPlayer, 10),
scaleByMapSize(15, 45),
clDirt);
log("Creating grass patches...");
createLayeredPatches(
[scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
[tGrass2,tGrassPatch],
[1],
avoidClasses(clForest, 0, clHill, 0, clDirt, 3, clPlayer, 10, clGrass, 15)
);
avoidClasses(clForest, 0, clHill, 0, clDirt, 3, clPlayer, 10, clGrass, 15),
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(50);
@ -167,8 +169,8 @@ createMines(
[new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],
[new SimpleObject(oStoneSmall, 2,5, 1,3)]
],
avoidClasses(clForest, 1, clPlayer, 20, clMetal, 10, clRock, 5, clHill, 2)
);
avoidClasses(clForest, 1, clPlayer, 20, clMetal, 10, clRock, 5, clHill, 2),
clRock);
log("Creating metal mines...");
createMines(

View File

@ -221,8 +221,9 @@ createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[[tGrass,tGrassA],[tGrassA,tGrassB], [tGrassB,tGrassC]],
[1,1],
avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 0)
);
avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 0),
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(45);
log("Creating grass patches...");
@ -230,8 +231,9 @@ createLayeredPatches(
[scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
[tGrassPatchBlend, tGrassPatch],
[1],
avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 0)
);
avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 0),
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(50);
log("Creating stone mines...");
@ -240,8 +242,8 @@ createMines(
[new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],
[new SimpleObject(oStoneSmall, 2,5, 1,3)]
],
avoidClasses(clWater, 0, clForest, 1, clPlayer, 5, clRock, 10, clHill, 1)
);
avoidClasses(clWater, 0, clForest, 1, clPlayer, 5, clRock, 10, clHill, 1),
clRock);
RMS.SetProgress(55);
log("Creating metal mines...");

View File

@ -315,15 +315,17 @@ createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[[tMainTerrain,tTier1Terrain],[tTier1Terrain,tTier2Terrain], [tTier2Terrain,tTier3Terrain]],
[1,1],
[avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 4, clHill2, 0), stayClasses(clLand, 3)]
);
[avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 4, clHill2, 0), stayClasses(clLand, 3)],
scaleByMapSize(15, 45),
clDirt);
log("Creating grass patches...");
createPatches(
[scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
tTier4Terrain,
[avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 4, clHill2, 0), stayClasses(clLand, 3)]
);
[avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 4, clHill2, 0), stayClasses(clLand, 3)],
scaleByMapSize(15, 45),
clDirt);
log("Creating stone mines...");
createMines(
@ -331,8 +333,8 @@ createMines(
[new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],
[new SimpleObject(oStoneSmall, 2,5, 1,3)]
],
[avoidClasses(clForest, 1, clPlayer, 3, clRock, 10, clHill, 1, clHill2, 1), stayClasses(clLand, 2)]
);
[avoidClasses(clForest, 1, clPlayer, 3, clRock, 10, clHill, 1, clHill2, 1), stayClasses(clLand, 2)],
clRock);
log("Creating metal mines...");
createMines(

View File

@ -194,16 +194,17 @@ createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[[tMainTerrain,tTier1Terrain],[tTier1Terrain,tTier2Terrain], [tTier2Terrain,tTier3Terrain]],
[1,1],
[avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12), stayClasses(clLand, 5)]
);
[avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12), stayClasses(clLand, 5)],
scaleByMapSize(15, 45),
clDirt);
log("Creating grass patches...");
createPatches(
[scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
tTier4Terrain,
[avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12), stayClasses(clLand, 5)]
);
[avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12), stayClasses(clLand, 5)],
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(55);
log("Creating stone mines...");
@ -212,8 +213,8 @@ createMines(
[new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],
[new SimpleObject(oStoneSmall, 2,5, 1,3)]
],
[avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clHill, 1), stayClasses(clLand, 6)]
);
[avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clHill, 1), stayClasses(clLand, 6)],
clRock);
log("Creating metal mines...");
createMines(

View File

@ -211,8 +211,9 @@ createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[[tGrass,tGrassSand50],[tGrassSand50,tGrassSand25], [tGrassSand25,tGrass]],
[1,1],
avoidClasses(clForest, 0, clGrass, 2, clPlayer, 10, clWater, 2, clDirt, 2, clHill, 1)
);
avoidClasses(clForest, 0, clGrass, 2, clPlayer, 10, clWater, 2, clDirt, 2, clHill, 1),
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(55);
@ -221,8 +222,9 @@ createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[tDirt3, tDirt2,[tDirt,tMainDirt], [tDirtCracks,tMainDirt]],
[1,1,1],
avoidClasses(clForest, 0, clDirt, 2, clPlayer, 10, clWater, 2, clGrass, 2, clHill, 1)
);
avoidClasses(clForest, 0, clDirt, 2, clPlayer, 10, clWater, 2, clGrass, 2, clHill, 1),
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(60);
@ -232,8 +234,8 @@ createMines(
[new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],
[new SimpleObject(oStoneSmall, 2,5, 1,3)]
],
avoidClasses(clForest, 4, clPlayer, 15, clRock, 10, clWater, 4, clHill, 4)
);
avoidClasses(clForest, 4, clPlayer, 15, clRock, 10, clWater, 4, clHill, 4),
clRock);
log("Creating metal mines...");
createMines(

View File

@ -477,8 +477,7 @@ createLayeredPatches(
[1, 1],
avoidClasses(clForest, 0, clPlayer, 10, clWater, 2, clDirt, 2, clHill, 1, clGauls, 5, clPath, 1),
scaleByMapSize(15, 45),
clDirt
);
clDirt);
RMS.SetProgress(55);
log("Creating islands...");

View File

@ -255,16 +255,18 @@ createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[[tGrass,tGrassA], tGrassB, [tGrassB,tGrassC]],
[1,1],
avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 6)
);
avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 6),
scaleByMapSize(15, 45),
clDirt);
log("Creating grass patches...");
createPatches(
[scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
[tGrassPatchBlend, tGrassPatch],
[1],
avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 6)
);
avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 6),
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(80);
log("Creating stone mines...");
@ -273,8 +275,8 @@ createMines(
[new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],
[new SimpleObject(oStoneSmall, 2,5, 1,3)]
],
avoidClasses(clWater, 2, clForest, 1, clPlayer, 20, clRock, 10, clHill, 2)
);
avoidClasses(clWater, 2, clForest, 1, clPlayer, 20, clRock, 10, clHill, 2),
clRock);
log("Creating metal mines...");
createMines(

View File

@ -266,6 +266,7 @@ createLayeredPatches(
clGrass, 5,
clBumps, 0,
clPlayer, 0),
scaleByMapSize(3, 8),
clDirt);
RMS.SetProgress(50);

View File

@ -323,8 +323,8 @@ createFood(
[new SimpleObject(oSecondaryHuntableAnimal, 2, 3, 0, 2)]
],
[3 * numPlayers, 3 * numPlayers],
[avoidClasses(clForest, 0, clPlayer, 20, clMountain, 1, clFood, 4, clRock, 6, clMetal, 6), stayClasses(clHill, 2)]
);
[avoidClasses(clForest, 0, clPlayer, 20, clMountain, 1, clFood, 4, clRock, 6, clMetal, 6), stayClasses(clHill, 2)],
clFood);
RMS.SetProgress(75);
@ -333,8 +333,8 @@ createFood(
[new SimpleObject(oFruitBush, 5, 7, 0, 4)]
],
[3 * numPlayers],
[avoidClasses(clForest, 0, clPlayer, 15, clMountain, 1, clFood, 4, clRock, 6, clMetal, 6), stayClasses(clHill, 2)]
);
[avoidClasses(clForest, 0, clPlayer, 15, clMountain, 1, clFood, 4, clRock, 6, clMetal, 6), stayClasses(clHill, 2)],
clFood);
RMS.SetProgress(85);

View File

@ -234,16 +234,18 @@ createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[[tGrass,tGrassA],[tGrassA,tGrassB], [tGrassB,tGrassC]],
[1,1],
avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 1)
);
avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 1),
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(55);
log("Creating grass patches...");
createPatches(
[scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
tGrassPatch,
avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 1)
);
avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 1),
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(60);
log("Creating stone mines...");
@ -252,8 +254,8 @@ createMines(
[new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],
[new SimpleObject(oStoneSmall, 2,5, 1,3)]
],
avoidClasses(clWater, 0, clForest, 1, clPlayer, 5, clRock, 10, clHill, 1)
);
avoidClasses(clWater, 0, clForest, 1, clPlayer, 5, clRock, 10, clHill, 1),
clRock);
RMS.SetProgress(65);
log("Creating metal mines...");

View File

@ -285,16 +285,17 @@ createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[[tMainTerrain,tTier1Terrain],[tTier1Terrain,tTier2Terrain], [tTier2Terrain,tTier3Terrain]],
[1,1],
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12)
);
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12),
scaleByMapSize(15, 45),
clDirt);
log("Creating grass patches...");
createPatches(
[scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
tTier4Terrain,
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12)
);
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12),
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(55);
log("Creating stone mines...");
@ -303,8 +304,8 @@ createMines(
[new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],
[new SimpleObject(oStoneSmall, 2,5, 1,3)]
],
avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1)
);
avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1),
clRock);
log("Creating metal mines...");
createMines(

View File

@ -212,16 +212,17 @@ createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[[tGrass,tGrassA],[tGrassA,tGrassB], [tGrassB,tGrassC]],
[1,1],
[avoidClasses(clForest, 0, clHill, 0, clDirt, 3, clPlayer, 8, clRiver, 1), stayClasses(clLand, 7)]
);
[avoidClasses(clForest, 0, clHill, 0, clDirt, 3, clPlayer, 8, clRiver, 1), stayClasses(clLand, 7)],
scaleByMapSize(15, 45),
clDirt);
log("Creating grass patches...");
createPatches(
[scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
tGrassPatch,
[avoidClasses(clForest, 0, clHill, 0, clDirt, 3, clPlayer, 8, clRiver, 1), stayClasses(clLand, 7)]
);
[avoidClasses(clForest, 0, clHill, 0, clDirt, 3, clPlayer, 8, clRiver, 1), stayClasses(clLand, 7)],
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(55);
log("Creating stone mines...");
@ -230,8 +231,8 @@ createMines(
[new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],
[new SimpleObject(oStoneSmall, 2,5, 1,3)]
],
[avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clHill, 1, clRiver, 1), stayClasses(clLand, 5)]
);
[avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clHill, 1, clRiver, 1), stayClasses(clLand, 5)],
clRock);
log("Creating metal mines...");
createMines(

View File

@ -279,16 +279,17 @@ createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[[tPrimary,tSecondary],[tSecondary,tHalfSnow], [tHalfSnow,tSnowLimited]],
[1,1],
avoidClasses(clWater, 6, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12)
);
avoidClasses(clWater, 6, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12),
scaleByMapSize(15, 45),
clDirt);
log("Creating grass patches...");
createPatches(
[scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
tHalfSnow,
avoidClasses(clWater, 6, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12)
);
avoidClasses(clWater, 6, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12),
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(65);
log("Creating stone mines...");
@ -297,8 +298,8 @@ createMines(
[new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],
[new SimpleObject(oStoneSmall, 2,5, 1,3)]
],
avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1)
);
avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1),
clRock);
log("Creating metal mines...");
createMines(
@ -330,43 +331,30 @@ createDecoration(
avoidClasses(clWater, 0, clForest, 0, clPlayer, 5, clHill, 0, clBaseResource, 5));
RMS.SetProgress(75);
createFood
(
[
[new SimpleObject(oDeer, 5,7, 0,4)],
[new SimpleObject(oRabbit, 2,3, 0,2)]
],
[
3 * numPlayers,
3 * numPlayers
],
avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 20)
);
createFood(
[
[new SimpleObject(oDeer, 5, 7, 0, 4)],
[new SimpleObject(oRabbit, 2, 3, 0, 2)]
],
[
3 * numPlayers,
3 * numPlayers
],
avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 20),
clFood);
createFood
(
[
[new SimpleObject(oBerryBush, 5,7, 0,4)]
],
[
randIntInclusive(1, 4) * numPlayers + 2
],
avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10)
);
createFood(
[[new SimpleObject(oBerryBush, 5, 7, 0, 4)]],
[randIntInclusive(1, 4) * numPlayers + 2],
avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10),
clFood);
if (random_terrain !== 3)
{
createFood
(
[
[new SimpleObject(oFish, 2,3, 0,2)]
],
[
25 * numPlayers
],
[avoidClasses(clFood, 20), stayClasses(clWater, 6)]
);
}
if (random_terrain != 3)
createFood(
[[new SimpleObject(oFish, 2, 3, 0, 2)]],
[25 * numPlayers],
[avoidClasses(clFood, 20), stayClasses(clWater, 6)],
clFood);
RMS.SetProgress(85);

View File

@ -90,7 +90,7 @@ for (let i = 0; i < numPlayers; ++i)
mAngle += randFloat(PI/8, PI/4);
mX = Math.round(fx + mDist * Math.cos(mAngle));
mZ = Math.round(fz + mDist * Math.sin(mAngle));
createStoneMineFormation(mX, mZ, tDirt4);
createStoneMineFormation(mX, mZ, oStoneSmall, tDirt4);
addToClass(mX, mZ, clPlayer);
// Create starting trees
@ -162,7 +162,7 @@ for (let i = 0; i < scaleByMapSize(12, 30); ++i)
let mZ = randIntInclusive(1, mapSize - 1);
if (playerConstraint.allows(mX, mZ) && minesConstraint.allows(mX, mZ) && waterConstraint.allows(mX, mZ))
{
createStoneMineFormation(mX, mZ, tDirt4);
createStoneMineFormation(mX, mZ, oStoneSmall, tDirt4);
addToClass(mX, mZ, clRock);
}
}
@ -252,8 +252,8 @@ createFood(
[
25 * numPlayers
],
[avoidClasses(clFood, 20), stayClasses(clWater, 2)]
);
[avoidClasses(clFood, 20), stayClasses(clWater, 2)],
clFood);
log("Creating berry bush...");
createObjectGroupsDeprecated(

View File

@ -318,7 +318,7 @@ paintTileClassBasedOnHeight(0, 5, 3, clLand);
RMS.SetProgress(85);
createBumps();
createBumps(avoidClasses(clPlayer, 20));
createMines(
[
@ -370,16 +370,16 @@ createFood(
[new SimpleObject(oSecondaryHuntableAnimal, 2, 3, 0, 2)]
],
[3 * numPlayers, 3 * numPlayers],
[avoidClasses(clForest, 0, clPlayer, 20, clHill, 1, clRock, 6, clMetal, 6), stayClasses(clLand, 2)]
);
[avoidClasses(clForest, 0, clPlayer, 20, clHill, 1, clRock, 6, clMetal, 6), stayClasses(clLand, 2)],
clFood);
createFood(
[
[new SimpleObject(oFruitBush, 5, 7, 0, 4)]
],
[3 * numPlayers],
[avoidClasses(clForest, 0, clPlayer, 15, clHill, 1, clFood, 4, clRock, 6, clMetal, 6), stayClasses(clLand, 2)]
);
[avoidClasses(clForest, 0, clPlayer, 15, clHill, 1, clFood, 4, clRock, 6, clMetal, 6), stayClasses(clLand, 2)],
clFood);
if (currentBiome() == "desert")
{

View File

@ -199,16 +199,17 @@ createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[[tMainTerrain,tTier1Terrain],[tTier1Terrain,tTier2Terrain], [tTier2Terrain,tTier3Terrain]],
[1,1],
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12)
);
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12),
scaleByMapSize(15, 45),
clDirt);
log("Creating grass patches...");
createPatches(
[scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
tTier4Terrain,
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12)
);
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12),
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(55);
log("Creating stone mines...");
@ -217,8 +218,8 @@ createMines(
[new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],
[new SimpleObject(oStoneSmall, 2,5, 1,3)]
],
avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1)
);
avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1),
clRock);
log("Creating metal mines...");
createMines(

View File

@ -132,7 +132,7 @@ for (var i = 0; i < numPlayers; i++)
}
RMS.SetProgress(20);
createBumps();
createBumps(avoidClasses(clPlayer, 20));
if (randBool())
createHills([tCliff, tCliff, tHill], avoidClasses(clPlayer, 20, clHill, 15), clHill, scaleByMapSize(3, 15));
@ -152,15 +152,18 @@ log("Creating dirt patches...");
createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[[tMainTerrain,tTier1Terrain],[tTier1Terrain,tTier2Terrain], [tTier2Terrain,tTier3Terrain]],
[1,1]
);
[1, 1],
avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12),
scaleByMapSize(15, 45),
clDirt);
log("Creating grass patches...");
createPatches(
[scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
tTier4Terrain
);
tTier4Terrain,
avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12),
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(55);
log("Creating stone mines...");
@ -168,8 +171,9 @@ createMines(
[
[new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],
[new SimpleObject(oStoneSmall, 2,5, 1,3)]
]
);
],
avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clHill, 1),
clRock);
log("Creating metal mines...");
createMines(

View File

@ -186,13 +186,17 @@ createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[[tDirt,tHalfSnow], [tHalfSnow,tSnowLimited]],
[2],
avoidClasses(clWater, 3, clDirt, 5, clPlayer, 12));
avoidClasses(clWater, 3, clDirt, 5, clPlayer, 12),
scaleByMapSize(15, 45),
clDirt);
log("Creating glacier patches...");
createPatches(
[scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
tSecondary,
avoidClasses(clWater, 3, clDirt, 5, clPlayer, 12));
avoidClasses(clWater, 3, clDirt, 5, clPlayer, 12),
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(70);
log("Creating stone mines...");
@ -201,8 +205,8 @@ log("Creating stone mines...");
[new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],
[new SimpleObject(oStoneSmall, 2,5, 1,3)]
],
avoidClasses(clWater, 3, clPlayer, 20, clRock, 18, clHill, 2)
);
avoidClasses(clWater, 3, clPlayer, 20, clRock, 18, clHill, 2),
clRock);
log("Creating metal mines...");
createMines(
@ -250,8 +254,8 @@ createFood(
5 * numPlayers,
12 * numPlayers
],
avoidClasses(clPlayer, 35, clFood, 16, clWater, 2, clMetal, 4, clRock, 4, clHill, 2)
);
avoidClasses(clPlayer, 35, clFood, 16, clWater, 2, clMetal, 4, clRock, 4, clHill, 2),
clFood);
createFood(
[
@ -262,8 +266,8 @@ createFood(
scaleByMapSize(1, 6) * 3,
scaleByMapSize(1, 6) * 3,
],
[avoidClasses(clFood, 20, clHill, 5), stayClasses(clWater, 6)]
);
[avoidClasses(clFood, 20, clHill, 5), stayClasses(clWater, 6)],
clFood);
createFood(
[
@ -272,8 +276,8 @@ createFood(
[
100
],
[avoidClasses(clFood, 12, clHill, 5), stayClasses(clWater, 6)]
);
[avoidClasses(clFood, 12, clHill, 5), stayClasses(clWater, 6)],
clFood);
RMS.SetProgress(85);
// Create trigger points where wolves spawn

View File

@ -316,16 +316,17 @@ createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[[tMainTerrain,tTier1Terrain],[tTier1Terrain,tTier2Terrain], [tTier2Terrain,tTier3Terrain]],
[1,1],
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12)
);
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12),
scaleByMapSize(15, 45),
clDirt);
log("Creating grass patches...");
createPatches(
[scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
tTier4Terrain,
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12)
);
avoidClasses(clWater, 3, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12),
scaleByMapSize(15, 45),
clDirt);
RMS.SetProgress(55);
log("Creating stone mines...");
@ -334,8 +335,8 @@ createMines(
[new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],
[new SimpleObject(oStoneSmall, 2,5, 1,3)]
],
avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1)
);
avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1),
clRock);
log("Creating metal mines...");
createMines(

View File

@ -0,0 +1,73 @@
/**
* @file These functions are often used to place gaia entities, like forests, mines, animals or decorative bushes.
*/
/**
* Places a SimpleGroup consisting of the given number of the given Objects
* at random locations that meet the given Constraint.
*/
function createMines(objects, constraint, tileClass, count)
{
for (let object of objects)
createObjectGroupsDeprecated(
new SimpleGroup(object, true, tileClass),
0,
constraint,
count || scaleByMapSize(4, 16),
70);
}
/**
* Places Entities of the given templateName in a circular pattern (leaving out a quarter of the circle).
*/
function createStoneMineFormation(x, z, templateName, terrain, radius = 2.5, count = 8, startAngle = undefined, maxOffset = 1)
{
log("Creating small stone mine circle...");
createArea(
new ChainPlacer(radius / 2, radius, 2, 1, x, z, undefined, [5]),
new TerrainPainter(terrain),
null);
let angle = startAngle !== undefined ? startAngle : randFloat(0, 2 * Math.PI);
for (let i = 0; i < count; ++i)
{
placeObject(
Math.round(x + (radius + randFloat(0, maxOffset)) * Math.cos(angle)),
Math.round(z + (radius + randFloat(0, maxOffset)) * Math.sin(angle)),
templateName,
0,
randFloat(0, 2 * Math.PI));
angle += 3/2 * Math.PI / count;
}
}
/**
* Places the given amounts of the given Objects at random locations meeting the given Constraint.
*/
function createFood(objects, counts, constraint, tileClass)
{
log("Creating food...");
for (let i = 0; i < objects.length; ++i)
createObjectGroupsDeprecated(
new SimpleGroup(objects[i], true, tileClass),
0,
constraint,
counts[i],
50);
}
/**
* Same as createFood, but doesn't mark the terrain with a TileClass.
*/
function createDecoration(objects, counts, constraint)
{
log("Creating decoration...");
for (let i = 0; i < objects.length; ++i)
createObjectGroupsDeprecated(
new SimpleGroup(objects[i], true),
0,
constraint,
counts[i],
5);
}

View File

@ -0,0 +1,95 @@
/**
* @file These functions are often used to create a landscape, for instance shaping mountains, hills, rivers or grass and dirt patches.
*/
/**
* Bumps add slight, diverse elevation differences to otherwise completely level terrain.
*/
function createBumps(constraint, count, minSize, maxSize, spread, failFraction = 0, elevation = 2)
{
log("Creating bumps...");
createAreas(
new ChainPlacer(
minSize || 1,
maxSize || Math.floor(scaleByMapSize(4, 6)),
spread || Math.floor(scaleByMapSize(2, 5)),
failFraction),
new SmoothElevationPainter(ELEVATION_MODIFY, elevation, 2),
constraint,
count || scaleByMapSize(100, 200));
}
/**
* Hills are elevated, planar, impassable terrain areas.
*/
function createHills(terrainset, constraint, tileClass, count, minSize, maxSize, spread, failFraction = 0.5, elevation = 18, elevationSmoothing = 2)
{
log("Creating hills...");
createAreas(
new ChainPlacer(
minSize || 1,
maxSize || Math.floor(scaleByMapSize(4, 6)),
spread || Math.floor(scaleByMapSize(16, 40)),
failFraction),
[
new LayeredPainter(terrainset, [1, elevationSmoothing]),
new SmoothElevationPainter(ELEVATION_SET, elevation, elevationSmoothing),
paintClass(tileClass)
],
constraint,
count || scaleByMapSize(1, 4) * getNumPlayers());
}
/**
* Mountains are impassable smoothened cones.
*/
function createMountains(terrain, constraint, tileClass, count, maxHeight, minRadius, maxRadius, numCircles)
{
log("Creating mountains...");
let mapSize = getMapSize();
for (let i = 0; i < (count || scaleByMapSize(1, 4) * getNumPlayers()); ++i)
createMountain(
maxHeight !== undefined ? maxHeight : Math.floor(scaleByMapSize(30, 50)),
minRadius || Math.floor(scaleByMapSize(3, 4)),
maxRadius || Math.floor(scaleByMapSize(6, 12)),
numCircles || Math.floor(scaleByMapSize(4, 10)),
constraint,
randIntExclusive(0, mapSize),
randIntExclusive(0, mapSize),
terrain,
tileClass,
14);
}
/**
* Paint the given terrain texture in the given sizes at random places of the map to diversify monotone land texturing.
*/
function createPatches(sizes, terrain, constraint, count, tileClass, failFraction = 0.5)
{
for (let size of sizes)
createAreas(
new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, failFraction),
[
new TerrainPainter(terrain),
paintClass(tileClass)
],
constraint,
count);
}
/**
* Same as createPatches, but each patch consists of a set of textures drawn depending to the distance of the patch border.
*/
function createLayeredPatches(sizes, terrains, terrainWidths, constraint, count, tileClass, failFraction = 0.5)
{
for (let size of sizes)
createAreas(
new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, failFraction),
[
new LayeredPainter(terrains, terrainWidths),
paintClass(tileClass)
],
constraint,
count);
}

View File

@ -1,82 +1,5 @@
var g_numStragglerTrees = 0;
function createBumps(constraint, count, minsize, maxsize, spread, failfraction, elevation)
{
log("Creating bumps...");
constraint = (constraint !== undefined ? constraint : avoidClasses(clPlayer, 20));
minsize = (minsize !== undefined ? minsize : 1);
maxsize = (maxsize !== undefined ? maxsize : floor(scaleByMapSize(4, 6)));
spread = (spread !== undefined ? spread : floor(scaleByMapSize(2, 5)));
failfraction = (failfraction !== undefined ? failfraction : 0);
elevation = (elevation !== undefined ? elevation : 2);
count = (count !== undefined ? count : scaleByMapSize(100, 200));
var placer = new ChainPlacer(minsize, maxsize, spread, failfraction);
var painter = new SmoothElevationPainter(ELEVATION_MODIFY, elevation, 2);
createAreas(
placer,
painter,
constraint,
count
);
}
function createHills(terrainset, constraint, tileclass, count, minsize, maxsize, spread, failfraction, elevation, elevationsmooth)
{
log("Creating hills...");
tileclass = (tileclass !== undefined ? tileclass : clHill);
constraint = (constraint !== undefined ? constraint : avoidClasses(clPlayer, 20, clHill, 15));
count = (count !== undefined ? count : scaleByMapSize(1, 4) * getNumPlayers());
minsize = (minsize !== undefined ? minsize : 1);
maxsize = (maxsize !== undefined ? maxsize : floor(scaleByMapSize(4, 6)));
spread = (spread !== undefined ? spread : floor(scaleByMapSize(16, 40)));
failfraction = (failfraction !== undefined ? failfraction : 0.5);
elevation = (elevation !== undefined ? elevation : 18);
elevationsmooth = (elevationsmooth !== undefined ? elevationsmooth : 2);
var placer = new ChainPlacer(minsize, maxsize, spread, failfraction);
var terrainPainter = new LayeredPainter(
terrainset, // terrains
[1, elevationsmooth] // widths
);
var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, elevation, elevationsmooth);
createAreas(
placer,
[terrainPainter, elevationPainter, paintClass(clHill)],
constraint,
count
);
}
function createMountains(terrain, constraint, tileclass, count, maxHeight, minRadius, maxRadius, numCircles)
{
log("Creating mountains...");
tileclass = tileclass !== undefined ? tileclass : clHill;
constraint = constraint !== undefined ? constraint : avoidClasses(clPlayer, 20, clHill, 15);
count = count !== undefined ? count : scaleByMapSize(1, 4) * getNumPlayers();
maxHeight = maxHeight !== undefined ? maxHeight : floor(scaleByMapSize(30, 50));
minRadius = minRadius !== undefined ? minRadius : floor(scaleByMapSize(3, 4));
maxRadius = maxRadius !== undefined ? maxRadius : floor(scaleByMapSize(6, 12));
numCircles = numCircles !== undefined ? numCircles : floor(scaleByMapSize(4, 10));
var numHills = count;
for (var i = 0; i < numHills; ++i)
createMountain(
maxHeight,
minRadius,
maxRadius,
numCircles,
constraint,
randIntExclusive(0, getMapSize()),
randIntExclusive(0, getMapSize()),
terrain,
tileclass,
14
);
}
function createForests(terrainset, constraint, tileclass, numMultiplier = 1, minTrees = 500, maxTrees = 3000, forestProbability = 0.7)
{
log("Creating forests...");
@ -112,125 +35,6 @@ function createForests(terrainset, constraint, tileclass, numMultiplier = 1, min
);
}
function createLayeredPatches(sizes, terrainset, twidthset, constraint, count, tileclass, failfraction)
{
tileclass = (tileclass !== undefined ? tileclass : clDirt);
constraint = (constraint !== undefined ? constraint : avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12));
count = (count !== undefined ? count : scaleByMapSize(15, 45));
failfraction = (failfraction !== undefined ? failfraction : 0.5);
for (var i = 0; i < sizes.length; i++)
{
var placer = new ChainPlacer(1, floor(scaleByMapSize(3, 5)), sizes[i], failfraction);
var painter = new LayeredPainter(
terrainset, // terrains
twidthset // widths
);
createAreas(
placer,
[painter, paintClass(tileclass)],
constraint,
count
);
}
}
function createPatches(sizes, terrain, constraint, count, tileclass, failfraction)
{
tileclass = (tileclass !== undefined ? tileclass : clDirt);
constraint = (constraint !== undefined ? constraint : avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12));
count = (count !== undefined ? count : scaleByMapSize(15, 45));
failfraction = (failfraction !== undefined ? failfraction : 0.5);
for (var i = 0; i < sizes.length; i++)
{
var placer = new ChainPlacer(1, floor(scaleByMapSize(3, 5)), sizes[i], failfraction);
var painter = new TerrainPainter(terrain);
createAreas(
placer,
[painter, paintClass(tileclass)],
constraint,
count
);
}
}
function createMines(mines, constraint, tileclass, count)
{
tileclass = (tileclass !== undefined ? tileclass : clRock);
constraint = (constraint !== undefined ? constraint : avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clHill, 1));
count = (count !== undefined ? count : scaleByMapSize(4,16));
for (var i = 0; i < mines.length; ++i)
{
var group = new SimpleGroup(mines[i], true, tileclass);
createObjectGroupsDeprecated(group, 0,
constraint,
count, 70
);
}
}
/**
* Places 8 stone mines in a small circular shape.
*/
function createStoneMineFormation(x, z, tileclass)
{
var placer = new ChainPlacer(1, 2, 2, 1, x, z, undefined, [5]);
var painter = new TerrainPainter(tileclass);
createArea(placer, painter, null);
var bbAngle = randFloat(0, TWO_PI);
const bbDist = 2.5;
for (var i = 0; i < 8; ++i)
{
placeObject(
Math.round(x + randFloat(bbDist, bbDist + 1) * Math.cos(bbAngle)),
Math.round(z + randFloat(bbDist, bbDist + 1) * Math.sin(bbAngle)),
oStoneSmall,
0,
randFloat(0, 2 * PI));
bbAngle += PI / 6;
}
}
function createDecoration(objects, counts, constraint)
{
log("Creating decoration...");
constraint = (constraint !== undefined ? constraint : avoidClasses(clForest, 0, clPlayer, 0, clHill, 0));
for (var i = 0; i < objects.length; ++i)
{
var group = new SimpleGroup(
objects[i],
true
);
createObjectGroupsDeprecated(
group, 0,
constraint,
counts[i], 5
);
}
}
function createFood(objects, counts, constraint, tileclass)
{
log("Creating food...");
constraint = (constraint !== undefined ? constraint : avoidClasses(clForest, 0, clPlayer, 20, clHill, 1, clFood, 20));
tileclass = (tileclass !== undefined ? tileclass : clFood);
for (var i = 0; i < objects.length; ++i)
{
var group = new SimpleGroup(
objects[i],
true, tileclass
);
createObjectGroupsDeprecated(
group, 0,
constraint,
counts[i], 50
);
}
}
function createStragglerTrees(types, constraint, tileclass)
{
log("Creating straggler trees...");

View File

@ -91,7 +91,7 @@ for (var i = 0; i < numPlayers; i++)
mAngle += randFloat(PI/8, PI/4);
mX = round(fx + mDist * cos(mAngle));
mZ = round(fz + mDist * sin(mAngle));
createStoneMineFormation(mX, mZ, tDirt4);
createStoneMineFormation(mX, mZ, oStoneSmall, tDirt4);
addToClass(mX, mZ, clPlayer);
// create the city patch
var cityRadius = radius/3;
@ -157,7 +157,7 @@ for (var i = 0; i < scaleByMapSize(12,30); ++i)
var mZ = randIntExclusive(0, mapSize);
if (playerConstraint.allows(mX, mZ) && minesConstraint.allows(mX, mZ) && waterConstraint.allows(mX, mZ))
{
createStoneMineFormation(mX, mZ, tDirt4);
createStoneMineFormation(mX, mZ, oStoneSmall, tDirt4);
addToClass(mX, mZ, clRock);
}
}

View File

@ -203,15 +203,17 @@ createLayeredPatches(
[scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
[[tMainTerrain, tTier1Terrain], [tTier1Terrain, tTier2Terrain], [tTier2Terrain, tTier3Terrain]],
[1, 1],
[avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12, clWomen, 5), stayClasses(clLand, 5)]
);
[avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12, clWomen, 5), stayClasses(clLand, 5)],
scaleByMapSize(15, 45),
clDirt);
log("Creating grass patches...");
createPatches(
[scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
tTier4Terrain,
[avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12, clWomen, 5), stayClasses(clLand, 5)]
);
[avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12, clWomen, 5), stayClasses(clLand, 5)],
scaleByMapSize(15, 45),
clDirt);
var planetm = 1;
if (currentBiome() == "tropic")