1 Engine.LoadLibrary("rmgen");
2 Engine.LoadLibrary("rmgen-common");
4 const tGrass = ["tropic_grass_c", "tropic_grass_c", "tropic_grass_c", "tropic_grass_c", "tropic_grass_plants", "tropic_plants", "tropic_plants_b"];
5 const tGrassA = "tropic_plants_c";
6 const tGrassB = "tropic_plants_c";
7 const tGrassC = "tropic_grass_c";
8 const tForestFloor = "tropic_grass_plants";
9 const tCliff = ["tropic_cliff_a", "tropic_cliff_a", "tropic_cliff_a", "tropic_cliff_a_plants"];
10 const tPlants = "tropic_plants";
11 const tRoad = "tropic_citytile_a";
12 const tRoadWild = "tropic_citytile_plants";
13 const tShoreBlend = "tropic_beach_dry_plants";
14 const tShore = "tropic_beach_dry";
15 const tWater = "tropic_beach_wet";
17 const oTree = "gaia/flora_tree_toona";
18 const oPalm1 = "gaia/flora_tree_palm_tropic";
19 const oPalm2 = "gaia/flora_tree_palm_tropical";
20 const oStoneLarge = "gaia/geology_stonemine_tropic_quarry";
21 const oStoneSmall = "gaia/geology_stone_tropic_a";
22 const oMetalLarge = "gaia/geology_metal_tropic_slabs";
23 const oFish = "gaia/fauna_fish";
24 const oDeer = "gaia/fauna_deer";
25 const oTiger = "gaia/fauna_tiger";
26 const oBoar = "gaia/fauna_boar";
27 const oPeacock = "gaia/fauna_peacock";
28 const oBush = "gaia/flora_bush_berry";
29 const oSpearman = "units/maur_infantry_spearman_b";
30 const oArcher = "units/maur_infantry_archer_b";
31 const oArcherElephant = "units/maur_elephant_archer_b";
33 const aRockLarge = "actor|geology/stone_granite_large.xml";
34 const aRockMedium = "actor|geology/stone_granite_med.xml";
35 const aBush1 = "actor|props/flora/plant_tropic_a.xml";
36 const aBush2 = "actor|props/flora/plant_lg.xml";
37 const aBush3 = "actor|props/flora/plant_tropic_large.xml";
39 const pForestD = [tForestFloor + TERRAIN_SEPARATOR + oTree, tForestFloor];
40 const pForestP1 = [tForestFloor + TERRAIN_SEPARATOR + oPalm1, tForestFloor];
41 const pForestP2 = [tForestFloor + TERRAIN_SEPARATOR + oPalm2, tForestFloor];
43 const heightSeaGround = -8;
44 const heightWaterLevel = 0;
45 const heightShore = 1;
46 const heightShoreBlend = 2.8;
48 const heightHill = 25;
50 var g_Map = new RandomMap(heightSeaGround, tGrass);
52 const numPlayers = getNumPlayers();
53 const mapCenter = g_Map.getCenter();
54 const mapBounds = g_Map.getBounds();
56 var clPlayer = g_Map.createTileClass();
57 var clPlayerTerritory = g_Map.createTileClass();
58 var clHill = g_Map.createTileClass();
59 var clForest = g_Map.createTileClass();
60 var clWater = g_Map.createTileClass();
61 var clDirt = g_Map.createTileClass();
62 var clRock = g_Map.createTileClass();
63 var clMetal = g_Map.createTileClass();
64 var clFood = g_Map.createTileClass();
65 var clBaseResource = g_Map.createTileClass();
66 var clGaia = g_Map.createTileClass();
69 var startAngle = randomAngle();
70 var connectPlayers = randBool();
73 var stripWidthsLeft = connectPlayers ?
74 [[0.03, 0.09], [0.14, 0.25], [0.36, 0.46]] :
75 [[0, 0.06], [0.12, 0.23], [0.33, 0.43]];
78 var stripWidthsRight = clone(stripWidthsLeft);
79 stripWidthsRight.reverse();
80 stripWidthsRight = stripWidthsRight.map(strip => [1 - strip[1], 1 - strip[0]]);
82 var stripWidths = stripWidthsLeft.concat(stripWidthsRight);
84 g_Map.log("Creating strips");
85 for (let i = 0; i < stripWidths.length; ++i)
87 clStrip[i] = g_Map.createTileClass();
89 let isPlayerStrip = i == 2 || i == 3;
90 for (let j = 0; j < scaleByMapSize(20, 100); ++j)
92 let position = new Vector2D(
93 randFloat(mapBounds.bottom, mapBounds.top),
94 fractionToTiles(randFloat(...stripWidths[i]))).rotateAround(startAngle, mapCenter).round();
99 Math.floor(scaleByMapSize(3, connectPlayers && isPlayerStrip ? 8 : 7)),
100 Math.floor(scaleByMapSize(30, 60)),
104 new TerrainPainter(tGrass),
105 new SmoothElevationPainter(ELEVATION_SET, heightLand, 3),
106 new TileClassPainter(clStrip[i])
110 Engine.SetProgress(20);
112 var playerPosition = playerPlacementLine(startAngle, mapCenter, fractionToTiles(1 - stripWidthsLeft[2][0] - stripWidthsLeft[2][1]));
114 // Either left vs right or top vs bottom
115 var playerIDs = randBool() ? sortAllPlayers() : primeSortAllPlayers();
117 g_Map.log("Ensuring player territory");
118 var playerRadius = scaleByMapSize(12, 20);
119 for (let i = 0; i < numPlayers; ++i)
121 new ChainPlacer(1, 6, 40, 1, playerPosition[i], 0, [Math.floor(playerRadius)]),
123 new TerrainPainter(tGrass),
124 new SmoothElevationPainter(ELEVATION_SET, heightLand, 4),
125 new TileClassPainter(clPlayerTerritory)
129 "PlayerPlacement": [playerIDs, playerPosition],
130 "PlayerTileClass": clPlayer,
131 "BaseResourceClass": clBaseResource,
132 "baseResourceConstraint": stayClasses(clPlayerTerritory, 4),
135 "outerTerrain": tRoadWild,
136 "innerTerrain": tRoad,
137 "radius": playerRadius / 3
147 { "template": oMetalLarge },
148 { "template": oStoneLarge }
157 Engine.SetProgress(35);
159 var areaWater = createArea(
160 new HeightPlacer(Elevation_IncludeMin_ExcludeMax, -Infinity, heightWaterLevel),
162 new TerrainPainter(tWater),
163 new TileClassPainter(clWater)
167 new HeightPlacer(Elevation_IncludeMin_ExcludeMax, heightWaterLevel, heightShore),
168 new TerrainPainter(tShore));
171 new HeightPlacer(Elevation_IncludeMin_ExcludeMax, heightShore, heightShoreBlend),
172 new TerrainPainter(tShoreBlend));
174 Engine.SetProgress(40);
178 g_Map.log("Creating gaia");
179 for (let i = 0; i < 2; ++i)
180 for (let j = 0; j < scaleByMapSize(1, 8); ++j)
184 new SimpleObject(oSpearman, 8, 12, 2, 3),
185 new SimpleObject(oArcher, 8, 12, 2, 3),
186 new SimpleObject(oArcherElephant, 2, 3, 4, 5)
195 clPlayerTerritory, 0,
198 stayClasses(clStrip[i == 0 ? 0 : stripWidths.length - 1], 1)
200 scaleByMapSize(5, 10),
204 g_Map.log("Creating hills");
206 new ChainPlacer(1, Math.floor(scaleByMapSize(4, 6)), Math.floor(scaleByMapSize(16, 40)), 0.1),
208 new LayeredPainter([tCliff, tGrass], [3]),
209 new SmoothElevationPainter(ELEVATION_SET, heightHill, 3),
210 new TileClassPainter(clHill)
214 clPlayerTerritory, 0,
219 scaleByMapSize(1, 5));
221 createBumps(avoidClasses(clPlayer, 8, clWater, 2), scaleByMapSize(20, 150), 2, 8, 4, 1, 4);
222 Engine.SetProgress(50);
224 g_Map.log("Creating forests");
225 var [forestTrees, stragglerTrees] = getTreeCounts(1000, 4000, 0.7);
227 [[tGrass, tGrass, tGrass, tGrass, pForestD], [tGrass, tGrass, tGrass, pForestD]],
228 [[tGrass, tGrass, tGrass, tGrass, pForestP1], [tGrass, tGrass, tGrass, pForestP1]],
229 [[tGrass, tGrass, tGrass, tGrass, pForestP2], [tGrass, tGrass, tGrass, pForestP2]]
231 var size = forestTrees / (scaleByMapSize(3, 6) * numPlayers);
232 var num = Math.floor(size / types.length);
233 for (let type of types)
237 Math.floor(scaleByMapSize(3, 5)),
238 forestTrees / (num * Math.floor(scaleByMapSize(2, 4))),
241 new LayeredPainter(type, [2]),
242 new TileClassPainter(clForest)
252 createStragglerTrees(
253 [oTree, oPalm1, oPalm2],
266 Engine.SetProgress(60);
268 g_Map.log("Creating grass patches");
269 for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)])
271 new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5),
273 new LayeredPainter([tGrassC, tGrassA, tGrassB], [2, 1]),
274 new TileClassPainter(clDirt)
281 clPlayerTerritory, 0,
283 scaleByMapSize(20, 80));
285 g_Map.log("Creating dirt patches");
286 for (let size of [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)])
288 new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5),
290 new TerrainPainter(tPlants),
291 new TileClassPainter(clDirt)
298 clPlayerTerritory, 0,
300 scaleByMapSize(20, 80));
302 g_Map.log("Creating stone mines");
306 new SimpleObject(oStoneSmall, 0, 2, 0, 4),
307 new SimpleObject(oStoneLarge, 1, 1, 0, 4)
315 clPlayerTerritory, 0,
319 scaleByMapSize(4, 16),
322 g_Map.log("Creating small stone mines");
324 new SimpleGroup([new SimpleObject(oStoneSmall, 2, 5, 1, 3)], true, clRock),
329 clPlayerTerritory, 0,
333 scaleByMapSize(2, 8),
336 g_Map.log("Creating metal mines");
338 new SimpleGroup([new SimpleObject(oMetalLarge, 1, 1, 0, 4)], true, clMetal),
343 clPlayerTerritory, 0,
348 scaleByMapSize(4, 16),
351 g_Map.log("Creating small decorative rocks");
353 new SimpleGroup([new SimpleObject(aRockMedium, 1, 3, 0, 1)], true),
362 scaleByMapSize(50, 800),
365 g_Map.log("Creating large decorative rocks");
368 new SimpleObject(aRockLarge, 1, 2, 0, 1),
369 new SimpleObject(aRockMedium, 1, 3, 0, 2)
380 scaleByMapSize(25, 400),
383 g_Map.log("Creating small grass tufts");
385 new SimpleGroup([new SimpleObject(aBush1, 1, 2, 0, 1)]),
394 scaleByMapSize(100, 500));
395 Engine.SetProgress(70);
397 g_Map.log("Creating large grass tufts");
400 new SimpleObject(aBush2, 2, 4, 0, 1.8, -Math.PI / 8, Math.PI / 8),
401 new SimpleObject(aBush1, 3, 6, 1.2, 2.5, -Math.PI / 8, Math.PI / 8)
412 scaleByMapSize(100, 500));
413 Engine.SetProgress(85);
415 g_Map.log("Creating bushes");
418 new SimpleObject(aBush3, 1, 2, 0, 2),
419 new SimpleObject(aBush2, 2, 4, 0, 2)
424 clPlayerTerritory, 0,
427 scaleByMapSize(100, 500));
429 g_Map.log("Creating deer");
431 new SimpleGroup([new SimpleObject(oDeer, 5, 7, 0, 4)], true, clFood),
436 clPlayerTerritory, 0,
443 g_Map.log("Creating boar");
445 new SimpleGroup([new SimpleObject(oBoar, 2, 4, 0, 4)], true, clFood),
450 clPlayerTerritory, 0,
459 g_Map.log("Creating tigers");
461 new SimpleGroup([new SimpleObject(oTiger, 1, 1, 0, 4)], true, clFood),
466 clPlayerTerritory, 0,
474 Engine.SetProgress(95);
476 g_Map.log("Creating berry bush");
478 new SimpleGroup([new SimpleObject(oBush, 5, 7, 0, 4)], true, clFood),
483 clPlayerTerritory, 0,
489 randIntInclusive(1, 4) * numPlayers,
492 g_Map.log("Creating fish");
493 createObjectGroupsByAreas(
494 new SimpleGroup([new SimpleObject(oFish, 2, 3, 0, 2)], true, clFood),
496 [avoidClasses(clFood, 15), stayClasses(clWater, 4)],
497 scaleByMapSize(20, 100),
501 placePlayersNomad(clPlayer, avoidClasses(clWater, 4, clForest, 1, clMetal, 4, clRock, 4, clFood, 2));
503 setSunColor(0.6, 0.6, 0.6);
504 setSunElevation(Math.PI/ 3);
506 setWaterColor(0.424, 0.534, 0.639);
507 setWaterTint(0.369, 0.765, 0.745);
508 setWaterWaviness(1.0);
509 setWaterType("default");
510 setWaterMurkiness(0.35);
513 setFogThickness(0.2);
517 setPPSaturation(0.65);
520 setSkySet("stratus");