1 Engine.LoadLibrary("rmgen");
2 Engine.LoadLibrary("rmgen-common");
4 const tMainTerrain = "alpine_snow_a";
5 const tTier1Terrain = "snow rough";
6 const tTier2Terrain = "snow_01";
7 const tTier3Terrain = "snow rocks";
8 const tForestFloor1 = "alpine_forrestfloor_snow";
9 const tForestFloor2 = "polar_snow_rocks";
10 const tCliff = ["alpine_cliff_a", "alpine_cliff_b"];
11 const tHill = "alpine_snow_glacial";
12 const tRoad = "new_alpine_citytile";
13 const tRoadWild = "alpine_snow_rocky";
14 const tShore = "alpine_shore_rocks_icy";
15 const tWater = "polar_ice_b";
17 const oTreeDead = "gaia/flora_tree_dead";
18 const oOak = "gaia/flora_tree_oak_dead";
19 const oPine = "gaia/flora_tree_pine";
20 const oGrapes = "gaia/flora_bush_grapes";
21 const oBush = "gaia/flora_bush_badlands";
22 const oDeer = "gaia/fauna_deer";
23 const oRabbit = "gaia/fauna_rabbit";
24 const oWolf1 = "gaia/fauna_wolf";
25 const oWolf2 = "gaia/fauna_arctic_wolf";
26 const oFox = "gaia/fauna_fox_arctic";
27 const oHawk = "gaia/fauna_hawk";
28 const oFish = "gaia/fauna_fish";
29 const oStoneLarge = "gaia/geology_stonemine_alpine_quarry";
30 const oStoneSmall = "gaia/geology_stone_alpine_a";
31 const oMetalLarge = "gaia/geology_metal_alpine_slabs";
33 const aRockLarge = "actor|geology/stone_granite_large.xml";
34 const aRockMedium = "actor|geology/stone_granite_med.xml";
35 const aBushMedium = "actor|props/flora/plant_desert_a.xml";
36 const aBushSmall = "actor|props/flora/bush_desert_a.xml";
37 const aReeds = "actor|props/flora/reeds_pond_lush_a.xml";
38 const aOutpostPalisade = "actor|props/structures/britons/outpost_palisade.xml";
39 const aWorkshopChariot= "actor|props/structures/britons/workshop_chariot_01.xml";
41 const pForest1 = [tForestFloor2 + TERRAIN_SEPARATOR + oTreeDead, tForestFloor2 + TERRAIN_SEPARATOR + oOak, tForestFloor2];
42 const pForest2 = [tForestFloor1 + TERRAIN_SEPARATOR + oTreeDead, tForestFloor1];
44 var heightSeaGround = -2;
45 var heightShoreLower = 0.7;
46 var heightShoreUpper = 1;
48 var heightSnowline = 12;
49 var heightOffsetLargeBumps = 4;
51 var g_Map = new RandomMap(heightShoreUpper, tMainTerrain);
53 const numPlayers = getNumPlayers();
54 const mapCenter = g_Map.getCenter();
55 const mapBounds = g_Map.getBounds();
57 var clPlayer = g_Map.createTileClass();
58 var clForest = 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 clHill = g_Map.createTileClass();
64 var clDirt = g_Map.createTileClass();
65 var clRiver = g_Map.createTileClass();
66 var clWater = g_Map.createTileClass();
67 var clShallowsFlora = g_Map.createTileClass();
69 var riverWidth = fractionToTiles(0.1);
71 var startAngle = randomAngle();
73 var [playerIDs, playerPosition] = playerPlacementRiver(startAngle, fractionToTiles(0.6));
76 for (let position of playerPosition)
77 addCivicCenterAreaToClass(position, clPlayer);
81 "start": new Vector2D(mapCenter.x, mapBounds.top).rotateAround(startAngle, mapCenter),
82 "end": new Vector2D(mapCenter.x, mapBounds.bottom).rotateAround(startAngle, mapCenter),
84 "fadeDist": scaleByMapSize(3, 14),
86 "heightRiverbed": heightSeaGround,
87 "heightLand": heightLand,
91 Engine.SetProgress(10);
93 paintTileClassBasedOnHeight(-Infinity, heightShoreUpper, Elevation_ExcludeMin_ExcludeMax, clRiver);
94 Engine.SetProgress(15);
96 createTributaryRivers(
97 startAngle + Math.PI / 2,
101 [-Infinity, heightSeaGround],
105 avoidClasses(clPlayer, 4));
107 Engine.SetProgress(25);
110 "PlayerPlacement": [playerIDs, playerPosition],
111 "PlayerTileClass": clPlayer,
112 "BaseResourceClass": clBaseResource,
113 "baseResourceConstraint": avoidClasses(clWater, 4),
115 "outerTerrain": tRoadWild,
116 "innerTerrain": tRoad
121 "minGroupDistance": 2,
122 "maxGroupDistance": 4,
133 { "template": oMetalLarge },
134 { "template": oStoneLarge }
138 "template": oTreeDead,
142 "template": aBushSmall,
147 Engine.SetProgress(30);
149 g_Map.log("Creating pools");
151 new ChainPlacer(1, Math.floor(scaleByMapSize(2, 5)), Math.floor(scaleByMapSize(15, 60)), 0.8),
152 new SmoothElevationPainter(ELEVATION_SET, heightSeaGround, 3),
153 avoidClasses(clPlayer, 20),
154 scaleByMapSize(6, 20));
156 Engine.SetProgress(40);
158 createBumps(avoidClasses(clPlayer, 2));
161 createHills([tCliff, tCliff, tHill], avoidClasses(clPlayer, 20, clWater, 1, clHill, 15, clRiver, 10), clHill, scaleByMapSize(3, 15));
163 createMountains(tCliff, avoidClasses(clPlayer, 20, clWater, 1, clHill, 15, clRiver, 10), clHill, scaleByMapSize(3, 15));
165 g_Map.log("Creating large bumps");
167 new ClumpPlacer(scaleByMapSize(20, 50), 0.3, 0.06, Infinity),
168 new SmoothElevationPainter(ELEVATION_MODIFY, heightOffsetLargeBumps, 3),
169 avoidClasses(clPlayer, 2),
170 scaleByMapSize(100, 800));
172 createBumps(avoidClasses(clPlayer, 20));
174 paintTileClassBasedOnHeight(-Infinity, heightShoreUpper, Elevation_ExcludeMin_ExcludeMax, clWater);
175 paintTerrainBasedOnHeight(-Infinity, heightShoreUpper, Elevation_ExcludeMin_ExcludeMax, tWater);
176 paintTerrainBasedOnHeight(heightShoreUpper, heightShoreLower, Elevation_ExcludeMin_ExcludeMax, tShore);
177 paintTerrainBasedOnHeight(heightSnowline, Infinity, Elevation_ExcludeMin_ExcludeMax, tMainTerrain);
179 Engine.SetProgress(50);
181 g_Map.log("Creating dirt patches");
182 createLayeredPatches(
183 [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
184 [[tMainTerrain, tTier1Terrain], [tTier1Terrain, tTier2Terrain], [tTier2Terrain, tTier3Terrain]],
186 avoidClasses(clHill, 2, clDirt, 5, clPlayer, 12, clWater, 5, clForest, 4),
187 scaleByMapSize(25, 55),
190 var [forestTrees, stragglerTrees] = getTreeCounts(200, 1200, 0.7);
192 [tForestFloor1, tForestFloor2, tForestFloor1, pForest1, pForest2],
193 avoidClasses(clPlayer, 20, clWater, 2, clHill, 2, clForest, 12),
197 createStragglerTrees(
198 [oTreeDead, oOak, oPine, oBush],
199 avoidClasses(clPlayer, 17, clWater, 2, clHill, 2, clForest, 1, clRiver, 4),
203 Engine.SetProgress(55);
205 g_Map.log("Creating stone mines");
206 // Allow mines on the bumps at the river
209 [new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1), new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)],
210 [new SimpleObject(oStoneSmall, 2, 5, 1, 3)]
212 avoidClasses(clForest, 4, clWater, 1, clPlayer, 20, clRock, 15, clHill, 1),
215 g_Map.log("Creating metal mines");
218 [new SimpleObject(oMetalLarge, 1, 1, 0, 4)]
220 avoidClasses(clForest, 4, clWater, 1, clPlayer, 20, clMetal, 15, clRock, 5, clHill, 1),
223 Engine.SetProgress(65);
228 new SimpleObject(aRockMedium, 1, 3, 0, 1)
231 new SimpleObject(aBushSmall, 1, 2, 0, 1),
232 new SimpleObject(aBushMedium, 1, 3, 0, 2),
233 new SimpleObject(aRockLarge, 1, 2, 0, 1)
237 scaleByMapSize(16, 262),
238 scaleByMapSize(40, 360)
240 avoidClasses(clWater, 2, clForest, 0, clPlayer, 20, clHill, 1));
242 Engine.SetProgress(70);
246 [new SimpleObject(oHawk, 1, 1, 0, 3)],
247 [new SimpleObject(oWolf1, 4, 6, 0, 4)],
248 [new SimpleObject(oWolf2, 4, 8, 0, 4)],
249 [new SimpleObject(oFox, 2, 3, 0, 4)],
250 [new SimpleObject(oDeer, 4, 6, 0, 2)],
251 [new SimpleObject(oRabbit, 1, 3, 4, 6)]
254 scaleByMapSize(3, 10),
255 scaleByMapSize(3, 10),
256 scaleByMapSize(3, 10),
257 scaleByMapSize(5, 20),
258 scaleByMapSize(5, 20),
259 scaleByMapSize(5, 20)
261 avoidClasses(clWater, 3, clPlayer, 20, clHill, 1, clFood, 10));
263 Engine.SetProgress(75);
267 [new SimpleObject(oFish, 1, 2, 0, 2)]
272 [avoidClasses(clPlayer, 8, clForest, 1, clHill, 4), stayClasses (clWater, 6)],
275 g_Map.log("Creating shallow flora");
276 createObjectGroupsDeprecated(
277 new SimpleGroup([new SimpleObject(aReeds, 6, 14, 1, 5)], false, clShallowsFlora),
280 new HeightConstraint(-1, 0),
281 avoidClasses(clShallowsFlora, 25),
283 20 * scaleByMapSize(13, 200),
286 g_Map.log("Creating gallic decoratives");
289 [new SimpleObject(aOutpostPalisade, 1, 1, 0, 1)],
290 [new SimpleObject(aWorkshopChariot, 1, 1, 0, 1)],
293 scaleByMapSize(2, 7),
296 avoidClasses(clForest, 1, clPlayer, 20, clBaseResource, 5, clHill, 4, clFood, 4, clWater, 5, clRock, 9, clMetal, 9));
299 placePlayersNomad(clPlayer, avoidClasses(clForest, 1, clMetal, 4, clRock, 4, clHill, 4, clFood, 10, clWater, 5));
301 setSkySet(pickRandom(["fog", "stormy", "sunset"]));
302 setSunElevation(0.27);
303 setSunRotation(randomAngle());
304 setSunColor(0.746, 0.718, 0.539);
305 setWaterColor(0.292, 0.347, 0.691);
306 setWaterTint(0.550, 0.543, 0.437);
307 setWaterMurkiness(0.83);
308 setWaterType("clap");
310 setWindAngle(startAngle);
312 setFogColor(0.8, 0.76, 0.61);
318 setPPSaturation(0.42);