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;
45 const heightHill = 25;
47 var g_Map = new RandomMap(heightSeaGround, tGrass);
49 const numPlayers = getNumPlayers();
50 const mapCenter = g_Map.getCenter();
51 const mapBounds = g_Map.getBounds();
53 var clPlayer = g_Map.createTileClass();
54 var clPlayerTerritory = g_Map.createTileClass();
55 var clHill = g_Map.createTileClass();
56 var clForest = g_Map.createTileClass();
57 var clWater = g_Map.createTileClass();
58 var clDirt = g_Map.createTileClass();
59 var clRock = g_Map.createTileClass();
60 var clMetal = g_Map.createTileClass();
61 var clFood = g_Map.createTileClass();
62 var clBaseResource = g_Map.createTileClass();
63 var clGaia = g_Map.createTileClass();
66 var startAngle = randomAngle();
67 var connectPlayers = randBool();
70 var stripWidthsLeft = connectPlayers ?
71 [[0.03, 0.09], [0.14, 0.25], [0.36, 0.46]] :
72 [[0, 0.06], [0.12, 0.23], [0.33, 0.43]];
75 var stripWidthsRight = clone(stripWidthsLeft);
76 stripWidthsRight.reverse();
77 stripWidthsRight = stripWidthsRight.map(strip => [1 - strip[1], 1 - strip[0]]);
79 var stripWidths = stripWidthsLeft.concat(stripWidthsRight);
81 g_Map.log("Creating strips");
82 for (let i = 0; i < stripWidths.length; ++i)
84 clStrip[i] = g_Map.createTileClass();
86 let isPlayerStrip = i == 2 || i == 3;
87 for (let j = 0; j < scaleByMapSize(20, 100); ++j)
89 let position = new Vector2D(
90 randFloat(mapBounds.bottom, mapBounds.top),
91 fractionToTiles(randFloat(...stripWidths[i]))).rotateAround(startAngle, mapCenter).round();
96 Math.floor(scaleByMapSize(3, connectPlayers && isPlayerStrip ? 8 : 7)),
97 Math.floor(scaleByMapSize(30, 60)),
101 new TerrainPainter(tGrass),
102 new SmoothElevationPainter(ELEVATION_SET, heightLand, 3),
103 new TileClassPainter(clStrip[i])
107 Engine.SetProgress(20);
109 var playerPosition = playerPlacementLine(startAngle, mapCenter, fractionToTiles(1 - stripWidthsLeft[2][0] - stripWidthsLeft[2][1]));
111 // Either left vs right or top vs bottom
112 var playerIDs = randBool() ? sortAllPlayers() : primeSortAllPlayers();
114 g_Map.log("Ensuring player territory");
115 var playerRadius = scaleByMapSize(12, 20);
116 for (let i = 0; i < numPlayers; ++i)
118 new ChainPlacer(1, 6, 40, 1, playerPosition[i], 0, [Math.floor(playerRadius)]),
120 new TerrainPainter(tGrass),
121 new SmoothElevationPainter(ELEVATION_SET, heightLand, 4),
122 new TileClassPainter(clPlayerTerritory)
126 "PlayerPlacement": [playerIDs, playerPosition],
127 "PlayerTileClass": clPlayer,
128 "BaseResourceClass": clBaseResource,
129 "baseResourceConstraint": stayClasses(clPlayerTerritory, 4),
132 "outerTerrain": tRoadWild,
133 "innerTerrain": tRoad,
134 "radius": playerRadius / 3
144 { "template": oMetalLarge },
145 { "template": oStoneLarge }
154 Engine.SetProgress(35);
156 paintTerrainBasedOnHeight(-10, 0, 1, tWater);
157 paintTileClassBasedOnHeight(-10, 0, 1, clWater);
158 paintTerrainBasedOnHeight(1, 2.8, 1, tShoreBlend);
159 paintTerrainBasedOnHeight(0, 1, 1, tShore);
160 Engine.SetProgress(40);
164 g_Map.log("Creating gaia");
165 for (let i = 0; i < 2; ++i)
166 for (let j = 0; j < scaleByMapSize(1, 8); ++j)
167 createObjectGroupsDeprecated(
170 new SimpleObject(oSpearman, 8, 12, 2, 3),
171 new SimpleObject(oArcher, 8, 12, 2, 3),
172 new SimpleObject(oArcherElephant, 2, 3, 4, 5)
181 clPlayerTerritory, 0,
184 stayClasses(clStrip[i == 0 ? 0 : stripWidths.length - 1], 1)
186 scaleByMapSize(5, 10),
190 g_Map.log("Creating hills");
192 new ChainPlacer(1, Math.floor(scaleByMapSize(4, 6)), Math.floor(scaleByMapSize(16, 40)), 0.1),
194 new LayeredPainter([tCliff, tGrass], [3]),
195 new SmoothElevationPainter(ELEVATION_SET, heightHill, 3),
196 new TileClassPainter(clHill)
200 clPlayerTerritory, 0,
205 scaleByMapSize(1, 5));
207 createBumps(avoidClasses(clPlayer, 8, clWater, 2), scaleByMapSize(20, 150), 2, 8, 4, 1, 4);
208 Engine.SetProgress(50);
210 g_Map.log("Creating forests");
211 var [forestTrees, stragglerTrees] = getTreeCounts(1000, 4000, 0.7);
213 [[tGrass, tGrass, tGrass, tGrass, pForestD], [tGrass, tGrass, tGrass, pForestD]],
214 [[tGrass, tGrass, tGrass, tGrass, pForestP1], [tGrass, tGrass, tGrass, pForestP1]],
215 [[tGrass, tGrass, tGrass, tGrass, pForestP2], [tGrass, tGrass, tGrass, pForestP2]]
217 var size = forestTrees / (scaleByMapSize(3, 6) * numPlayers);
218 var num = Math.floor(size / types.length);
219 for (let type of types)
223 Math.floor(scaleByMapSize(3, 5)),
224 forestTrees / (num * Math.floor(scaleByMapSize(2, 4))),
227 new LayeredPainter(type, [2]),
228 new TileClassPainter(clForest)
238 createStragglerTrees(
239 [oTree, oPalm1, oPalm2],
252 Engine.SetProgress(60);
254 g_Map.log("Creating grass patches");
255 for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)])
257 new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5),
259 new LayeredPainter([tGrassC, tGrassA, tGrassB], [2, 1]),
260 new TileClassPainter(clDirt)
267 clPlayerTerritory, 0,
269 scaleByMapSize(20, 80));
271 g_Map.log("Creating dirt patches");
272 for (let size of [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)])
274 new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5),
276 new TerrainPainter(tPlants),
277 new TileClassPainter(clDirt)
284 clPlayerTerritory, 0,
286 scaleByMapSize(20, 80));
288 g_Map.log("Creating stone mines");
289 createObjectGroupsDeprecated(
292 new SimpleObject(oStoneSmall, 0, 2, 0, 4),
293 new SimpleObject(oStoneLarge, 1, 1, 0, 4)
301 clPlayerTerritory, 0,
305 9 * scaleByMapSize(1, 4),
308 g_Map.log("Creating small stone mines");
309 createObjectGroupsDeprecated(
310 new SimpleGroup([new SimpleObject(oStoneSmall, 2, 5, 1, 3)], true, clRock),
315 clPlayerTerritory, 0,
319 9 * scaleByMapSize(1, 4),
322 g_Map.log("Creating metal mines");
323 createObjectGroupsDeprecated(
324 new SimpleGroup([new SimpleObject(oMetalLarge, 1, 1, 0, 4)], true, clMetal),
329 clPlayerTerritory, 0,
334 9 * scaleByMapSize(1, 4),
337 g_Map.log("Creating small decorative rocks");
338 createObjectGroupsDeprecated(
339 new SimpleGroup([new SimpleObject(aRockMedium, 1, 3, 0, 1)], true),
348 3 * scaleByMapSize(16, 262),
351 g_Map.log("Creating large decorative rocks");
352 createObjectGroupsDeprecated(
354 new SimpleObject(aRockLarge, 1, 2, 0, 1),
355 new SimpleObject(aRockMedium, 1, 3, 0, 2)
366 3 * scaleByMapSize(8, 131),
369 g_Map.log("Creating small grass tufts");
370 createObjectGroupsDeprecated(
371 new SimpleGroup([new SimpleObject(aBush1, 1, 2, 0, 1, -Math.PI / 8, Math.PI / 8)]),
380 8 * scaleByMapSize(13, 200));
381 Engine.SetProgress(70);
383 g_Map.log("Creating large grass tufts");
384 createObjectGroupsDeprecated(
386 new SimpleObject(aBush2, 2, 4, 0, 1.8, -Math.PI / 8, Math.PI / 8),
387 new SimpleObject(aBush1, 3, 6, 1.2, 2.5, -Math.PI / 8, Math.PI / 8)
398 8 * scaleByMapSize(13, 200));
399 Engine.SetProgress(85);
401 g_Map.log("Creating bushes");
402 createObjectGroupsDeprecated(
404 new SimpleObject(aBush3, 1, 2, 0, 2),
405 new SimpleObject(aBush2, 2, 4, 0, 2)
410 clPlayerTerritory, 0,
413 8 * scaleByMapSize(13, 200), 50);
415 g_Map.log("Creating deer");
416 createObjectGroupsDeprecated(
417 new SimpleGroup([new SimpleObject(oDeer, 5, 7, 0, 4)], true, clFood),
422 clPlayerTerritory, 0,
429 g_Map.log("Creating boar");
430 createObjectGroupsDeprecated(
431 new SimpleGroup([new SimpleObject(oBoar, 2, 4, 0, 4)], true, clFood),
436 clPlayerTerritory, 0,
443 g_Map.log("Creating tigers");
444 createObjectGroupsDeprecated(
445 new SimpleGroup([new SimpleObject(oTiger, 1, 1, 0, 4)], true, clFood),
450 clPlayerTerritory, 0,
456 Engine.SetProgress(95);
458 g_Map.log("Creating berry bush");
459 createObjectGroupsDeprecated(
460 new SimpleGroup([new SimpleObject(oBush, 5, 7, 0, 4)], true, clFood),
465 clPlayerTerritory, 0,
469 randIntInclusive(1, 4) * numPlayers + 2,
472 g_Map.log("Creating fish");
473 createObjectGroupsDeprecated(
474 new SimpleGroup([new SimpleObject(oFish, 2, 3, 0, 2)], true, clFood),
476 [avoidClasses(clFood, 15), stayClasses(clWater, 4)],
480 placePlayersNomad(clPlayer, avoidClasses(clWater, 4, clForest, 1, clMetal, 4, clRock, 4, clFood, 2));
482 setSunColor(0.6, 0.6, 0.6);
483 setSunElevation(Math.PI/ 3);
485 setWaterColor(0.424, 0.534, 0.639);
486 setWaterTint(0.369, 0.765, 0.745);
487 setWaterWaviness(1.0);
488 setWaterType("default");
489 setWaterMurkiness(0.35);
492 setFogThickness(0.2);
496 setPPSaturation(0.65);
499 setSkySet("stratus");