1 RMS.LoadLibrary("rmgen");
2 RMS.LoadLibrary("rmbiome");
6 const tMainTerrain = g_Terrains.mainTerrain;
7 const tForestFloor1 = g_Terrains.forestFloor1;
8 const tForestFloor2 = g_Terrains.forestFloor2;
9 const tCliff = g_Terrains.cliff;
10 const tTier1Terrain = g_Terrains.tier1Terrain;
11 const tTier2Terrain = g_Terrains.tier2Terrain;
12 const tTier3Terrain = g_Terrains.tier3Terrain;
13 const tHill = g_Terrains.hill;
14 const tRoad = g_Terrains.road;
15 const tRoadWild = g_Terrains.roadWild;
16 const tTier4Terrain = g_Terrains.tier4Terrain;
17 const tShore = g_Terrains.shore;
18 const tWater = g_Terrains.water;
20 const oTree1 = g_Gaia.tree1;
21 const oTree2 = g_Gaia.tree2;
22 const oTree3 = g_Gaia.tree3;
23 const oTree4 = g_Gaia.tree4;
24 const oTree5 = g_Gaia.tree5;
25 const oFruitBush = g_Gaia.fruitBush;
26 const oMainHuntableAnimal = g_Gaia.mainHuntableAnimal;
27 const oFish = g_Gaia.fish;
28 const oSecondaryHuntableAnimal = g_Gaia.secondaryHuntableAnimal;
29 const oStoneLarge = g_Gaia.stoneLarge;
30 const oStoneSmall = g_Gaia.stoneSmall;
31 const oMetalLarge = g_Gaia.metalLarge;
32 const oWood = "gaia/special_treasure_wood";
34 const aGrass = g_Decoratives.grass;
35 const aGrassShort = g_Decoratives.grassShort;
36 const aRockLarge = g_Decoratives.rockLarge;
37 const aRockMedium = g_Decoratives.rockMedium;
38 const aBushMedium = g_Decoratives.bushMedium;
39 const aBushSmall = g_Decoratives.bushSmall;
41 const pForest1 = [tForestFloor2 + TERRAIN_SEPARATOR + oTree1, tForestFloor2 + TERRAIN_SEPARATOR + oTree2, tForestFloor2];
42 const pForest2 = [tForestFloor1 + TERRAIN_SEPARATOR + oTree4, tForestFloor1 + TERRAIN_SEPARATOR + oTree5, tForestFloor1];
46 const numPlayers = getNumPlayers();
47 const mapSize = getMapSize();
48 const mapArea = getMapArea();
50 var clPlayer = createTileClass();
51 var clHill = createTileClass();
52 var clForest = createTileClass();
53 var clDirt = createTileClass();
54 var clRock = createTileClass();
55 var clMetal = createTileClass();
56 var clFood = createTileClass();
57 var clBaseResource = createTileClass();
58 var clLand = createTileClass();
62 var playerIDs = sortAllPlayers();
69 var startAngle = PI/2 + PI/14;
70 for (var i = 0; i < numPlayers; i++)
72 playerAngle[i] = startAngle - (i+1)*(PI+ PI/7)/(numPlayers+1);
73 playerX[i] = 0.5 + 0.35*cos(playerAngle[i]);
74 playerZ[i] = 0.5 + 0.35*sin(playerAngle[i]);
77 for (var i = 0; i < numPlayers; i++)
79 var id = playerIDs[i];
80 log("Creating base for player " + id + "...");
82 var radius = scaleByMapSize(15,25);
86 var hillSize = PI * radius * radius;
87 // get the x and z in tiles
88 var fx = fractionToTiles(playerX[i]);
89 var fz = fractionToTiles(playerZ[i]);
93 var placer = new ClumpPlacer(hillSize, 0.80, 0.1, 10, ix, iz);
94 var terrainPainter = new LayeredPainter(
95 [tWater , tShore, tMainTerrain], // terrains
96 [1, shoreRadius] // widths
98 var elevationPainter = new SmoothElevationPainter(
99 ELEVATION_SET, // type
100 elevation, // elevation
101 shoreRadius // blend radius
103 createArea(placer, [terrainPainter, elevationPainter, paintClass(clPlayer)], null);
105 // create the city patch
106 var cityRadius = radius/3;
107 placer = new ClumpPlacer(PI*cityRadius*cityRadius, 0.6, 0.3, 10, ix, iz);
108 var painter = new LayeredPainter([tRoadWild, tRoad], [1]);
109 createArea(placer, painter, null);
111 placeCivDefaultEntities(fx, fz, id, { 'iberWall': false });
113 placeDefaultChicken(fx, fz, clBaseResource);
115 // create berry bushes
116 var bbAngle = randFloat(0, TWO_PI);
118 var bbX = round(fx + bbDist * cos(bbAngle));
119 var bbZ = round(fz + bbDist * sin(bbAngle));
120 var group = new SimpleGroup(
121 [new SimpleObject(oFruitBush, 5,5, 0,3)],
122 true, clBaseResource, bbX, bbZ
124 createObjectGroup(group, 0);
127 var bbAngle = randFloat(0, TWO_PI);
129 var bbX = round(fx + bbDist * cos(bbAngle));
130 var bbZ = round(fz + bbDist * sin(bbAngle));
131 group = new SimpleGroup(
132 [new SimpleObject(oWood, 14,14, 0,3)],
133 true, clBaseResource, bbX, bbZ
135 createObjectGroup(group, 0);
138 var mAngle = bbAngle;
139 while(abs(mAngle - bbAngle) < PI/3)
140 mAngle = randFloat(0, TWO_PI);
142 var mDist = radius - 4;
143 var mX = round(fx + mDist * cos(mAngle));
144 var mZ = round(fz + mDist * sin(mAngle));
145 group = new SimpleGroup(
146 [new SimpleObject(oMetalLarge, 1,1, 0,0)],
147 true, clBaseResource, mX, mZ
149 createObjectGroup(group, 0);
151 // create stone mines
152 mAngle += randFloat(PI/8, PI/4);
153 mX = round(fx + mDist * cos(mAngle));
154 mZ = round(fz + mDist * sin(mAngle));
155 group = new SimpleGroup(
156 [new SimpleObject(oStoneLarge, 1,1, 0,2)],
157 true, clBaseResource, mX, mZ
159 createObjectGroup(group, 0);
160 var hillSize = PI * radius * radius;
161 // create starting trees
162 var num = floor(hillSize / 60);
163 var tAngle = randFloat(-PI/3, 4*PI/3);
165 var tX = round(fx + tDist * cos(tAngle));
166 var tZ = round(fz + tDist * sin(tAngle));
167 group = new SimpleGroup(
168 [new SimpleObject(oTree1, num, num, 0,4)],
169 false, clBaseResource, tX, tZ
171 createObjectGroup(group, 0, avoidClasses(clBaseResource,2));
173 placeDefaultDecoratives(fx, fz, aGrassShort, clBaseResource, radius);
175 let dockLocation = getTIPIADBON([ix, iz], [mapSize / 2, mapSize / 2], [-3 , 2.6], 0.5, 3);
176 if (dockLocation === undefined)
178 warn("Could not place dock for player " + playerIDs[i])
185 "structures/" + getCivCode(playerIDs[i] - 1) + "_dock",
187 playerAngle[i] + Math.PI);
191 log("Create the continent body...");
193 new ClumpPlacer(mapArea * 0.50, 0.8, 0.08, 10, Math.round(fractionToTiles(0.12)), Math.round(fractionToTiles(0.5))),
195 new LayeredPainter([tWater, tShore, tMainTerrain], [4, 2]),
196 new SmoothElevationPainter(ELEVATION_SET, landHeight, 4),
199 avoidClasses(clPlayer, 8));
202 log("Creating shore jaggedness...");
204 new ClumpPlacer(scaleByMapSize(15, 80), 0.2, 0.1, 1),
206 new LayeredPainter([tMainTerrain, tMainTerrain], [2]),
207 new SmoothElevationPainter(ELEVATION_SET, landHeight, 4),
211 borderClasses(clLand, 6, 3),
212 avoidClasses(clPlayer, 8)
214 scaleByMapSize(2, 15) * 20,
217 paintTerrainBasedOnHeight(1, 3, 0, tShore);
218 paintTerrainBasedOnHeight(-8, 1, 2, tWater);
221 log("Creating bumps...");
223 new ClumpPlacer(scaleByMapSize(20, 50), 0.3, 0.06, 1),
224 new SmoothElevationPainter(ELEVATION_MODIFY, 2, 2),
225 [avoidClasses(clPlayer, 10), stayClasses(clLand, 3)],
226 scaleByMapSize(100, 200)
230 log("Creating hills...");
232 new ClumpPlacer(scaleByMapSize(20, 150), 0.2, 0.1, 1),
234 new LayeredPainter([tCliff, tHill], [2]),
235 new SmoothElevationPainter(ELEVATION_SET, 18, 2),
238 [avoidClasses(clPlayer, 10, clHill, 15), stayClasses(clLand, 7)],
239 scaleByMapSize(1, 4) * numPlayers
243 log("Creating forests...");
244 var [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1));
246 [[tForestFloor2, tMainTerrain, pForest1], [tForestFloor2, pForest1]],
247 [[tForestFloor1, tMainTerrain, pForest2], [tForestFloor1, pForest2]]
250 var size = forestTrees / (scaleByMapSize(2,8) * numPlayers) *
251 (currentBiome() == "savanna" ? 2 : 1);
253 var num = floor(size / types.length);
254 for (let type of types)
256 new ClumpPlacer(forestTrees / num, 0.1, 0.1, 1),
258 new LayeredPainter(type, [2]),
261 [avoidClasses(clPlayer, 6, clForest, 10, clHill, 0), stayClasses(clLand, 7)],
265 log("Creating dirt patches...");
266 for (let size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)])
268 new ClumpPlacer(size, 0.3, 0.06, 0.5),
271 [[tMainTerrain, tTier1Terrain], [tTier1Terrain, tTier2Terrain], [tTier2Terrain, tTier3Terrain]],
281 stayClasses(clLand, 7)
283 scaleByMapSize(15, 45));
287 log("Creating grass patches...");
288 for (let size of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)])
290 new ClumpPlacer(size, 0.3, 0.06, 0.5),
291 new TerrainPainter(tTier4Terrain),
292 [avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 0), stayClasses(clLand, 7)],
293 scaleByMapSize(15, 45));
296 log("Creating stone mines...");
297 var group = new SimpleGroup([new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)], true, clRock);
298 createObjectGroupsDeprecated(group, 0,
299 [avoidClasses(clForest, 1, clPlayer, 10, clRock, 10, clHill, 1), stayClasses(clLand, 7)],
300 scaleByMapSize(4,16), 100
304 log("Creating small stone quarries...");
305 group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock);
306 createObjectGroupsDeprecated(group, 0,
307 [avoidClasses(clForest, 1, clPlayer, 10, clRock, 10, clHill, 1), stayClasses(clLand, 7)],
308 scaleByMapSize(4,16), 100
312 log("Creating metal mines...");
313 group = new SimpleGroup([new SimpleObject(oMetalLarge, 1,1, 0,4)], true, clMetal);
314 createObjectGroupsDeprecated(group, 0,
315 [avoidClasses(clForest, 1, clPlayer, 10, clMetal, 10, clRock, 5, clHill, 1), stayClasses(clLand, 7)],
316 scaleByMapSize(4,16), 100
320 log("Creating small decorative rocks...");
321 group = new SimpleGroup(
322 [new SimpleObject(aRockMedium, 1,3, 0,1)],
325 createObjectGroupsDeprecated(
327 [avoidClasses(clForest, 0, clPlayer, 0, clHill, 0), stayClasses(clLand, 6)],
328 scaleByMapSize(16, 262), 50
332 log("Creating large decorative rocks...");
333 group = new SimpleGroup(
334 [new SimpleObject(aRockLarge, 1,2, 0,1), new SimpleObject(aRockMedium, 1,3, 0,2)],
337 createObjectGroupsDeprecated(
339 [avoidClasses(clForest, 0, clPlayer, 0, clHill, 0), stayClasses(clLand, 6)],
340 scaleByMapSize(8, 131), 50
344 log("Creating deer...");
345 group = new SimpleGroup(
346 [new SimpleObject(oMainHuntableAnimal, 5,7, 0,4)],
349 createObjectGroupsDeprecated(group, 0,
350 [avoidClasses(clForest, 0, clPlayer, 10, clHill, 1, clFood, 20), stayClasses(clLand, 7)],
355 log("Creating sheep...");
356 group = new SimpleGroup(
357 [new SimpleObject(oSecondaryHuntableAnimal, 2,3, 0,2)],
360 createObjectGroupsDeprecated(group, 0,
361 [avoidClasses(clForest, 0, clPlayer, 10, clHill, 1, clFood, 20), stayClasses(clLand, 7)],
366 log("Creating fruit bush...");
367 group = new SimpleGroup(
368 [new SimpleObject(oFruitBush, 5,7, 0,4)],
371 createObjectGroupsDeprecated(group, 0,
372 [avoidClasses(clForest, 0, clPlayer, 8, clHill, 1, clFood, 20), stayClasses(clLand, 7)],
373 randIntInclusive(1, 4) * numPlayers + 2, 50
377 log("Creating fish...");
378 createObjectGroupsDeprecated(
379 new SimpleGroup([new SimpleObject(oFish, 2,3, 0,2)], true, clFood),
381 avoidClasses(clLand, 2, clPlayer, 2, clHill, 0, clFood, 20),
386 createStragglerTrees(
387 [oTree1, oTree2, oTree4, oTree3],
388 [avoidClasses(clForest, 1, clHill, 1, clPlayer, 9, clMetal, 6, clRock, 6), stayClasses(clLand, 9)],
394 var planetm = currentBiome() == "tropic" ? 8 : 1;
396 log("Creating small grass tufts...");
397 group = new SimpleGroup(
398 [new SimpleObject(aGrassShort, 1,2, 0,1, -PI/8,PI/8)]
400 createObjectGroupsDeprecated(group, 0,
401 [avoidClasses(clHill, 2, clPlayer, 2, clDirt, 0), stayClasses(clLand, 6)],
402 planetm * scaleByMapSize(13, 200)
406 log("Creating large grass tufts...");
407 group = new SimpleGroup(
408 [new SimpleObject(aGrass, 2,4, 0,1.8, -PI/8,PI/8), new SimpleObject(aGrassShort, 3,6, 1.2,2.5, -PI/8,PI/8)]
410 createObjectGroupsDeprecated(group, 0,
411 [avoidClasses(clHill, 2, clPlayer, 2, clDirt, 1, clForest, 0), stayClasses(clLand, 6)],
412 planetm * scaleByMapSize(13, 200)
416 log("Creating bushes...");
417 group = new SimpleGroup(
418 [new SimpleObject(aBushMedium, 1,2, 0,2), new SimpleObject(aBushSmall, 2,4, 0,2)]
420 createObjectGroupsDeprecated(group, 0,
421 [avoidClasses(clHill, 1, clPlayer, 1, clDirt, 1), stayClasses(clLand, 6)],
422 planetm * scaleByMapSize(13, 200), 50
426 setSkySet(pickRandom(["cirrus", "cumulus", "sunny"]));
427 setSunRotation(randFloat(0, TWO_PI));
428 setSunElevation(randFloat(PI/ 5, PI / 3));