1 Engine.LoadLibrary("rmgen");
2 Engine.LoadLibrary("rmgen-common");
4 function* GenerateMap()
6 const tGrass = ["temp_grass", "temp_grass", "temp_grass_d"];
7 const tForestFloor = "temp_plants_bog";
8 const tGrassA = "temp_grass_plants";
9 const tGrassB = "temp_plants_bog";
10 const tMud = "temp_mud_a";
11 const tRoad = "temp_road";
12 const tRoadWild = "temp_road_overgrown";
13 const tShoreBlend = "temp_grass_plants";
14 const tShore = "temp_plants_bog";
15 const tWater = "temp_mud_a";
17 const oBeech = "gaia/tree/euro_beech";
18 const oOak = "gaia/tree/oak";
19 const oBerryBush = "gaia/fruit/berry_01";
20 const oDeer = "gaia/fauna_deer";
21 const oHorse = "gaia/fauna_horse";
22 const oWolf = "gaia/fauna_wolf";
23 const oRabbit = "gaia/fauna_rabbit";
24 const oStoneLarge = "gaia/rock/temperate_large";
25 const oStoneSmall = "gaia/rock/temperate_small";
26 const oMetalLarge = "gaia/ore/temperate_large";
28 const aGrass = "actor|props/flora/grass_soft_small_tall.xml";
29 const aGrassShort = "actor|props/flora/grass_soft_large.xml";
30 const aRockLarge = "actor|geology/stone_granite_med.xml";
31 const aRockMedium = "actor|geology/stone_granite_med.xml";
32 const aReeds = "actor|props/flora/reeds_pond_lush_a.xml";
33 const aLillies = "actor|props/flora/water_lillies.xml";
34 const aBushMedium = "actor|props/flora/bush_medit_me.xml";
35 const aBushSmall = "actor|props/flora/bush_medit_sm.xml";
37 const pForestD = [tForestFloor + TERRAIN_SEPARATOR + oBeech, tForestFloor];
38 const pForestP = [tForestFloor + TERRAIN_SEPARATOR + oOak, tForestFloor];
40 const heightMarsh = -2;
42 const heightOffsetBumpWater = 1;
43 const heightOffsetBumpLand = 2;
45 globalThis.g_Map = new RandomMap(heightLand, tGrass);
47 const numPlayers = getNumPlayers();
49 const clPlayer = g_Map.createTileClass();
50 const clForest = g_Map.createTileClass();
51 const clWater = g_Map.createTileClass();
52 const clDirt = g_Map.createTileClass();
53 const clRock = g_Map.createTileClass();
54 const clMetal = g_Map.createTileClass();
55 const clFood = g_Map.createTileClass();
56 const clBaseResource = g_Map.createTileClass();
59 "PlayerPlacement": playerPlacementCircle(fractionToTiles(0.35)),
60 "PlayerTileClass": clPlayer,
61 "BaseResourceClass": clBaseResource,
63 "outerTerrain": tRoadWild,
69 "template": oBerryBush
73 { "template": oMetalLarge },
74 { "template": oStoneLarge }
81 "template": aGrassShort
86 g_Map.log("Creating bumps");
88 new ClumpPlacer(scaleByMapSize(20, 50), 0.3, 0.06, Infinity),
89 new SmoothElevationPainter(ELEVATION_MODIFY, heightOffsetBumpLand, 2),
90 avoidClasses(clPlayer, 13),
91 scaleByMapSize(300, 800));
93 g_Map.log("Creating marshes");
94 for (let i = 0; i < 7; ++i)
96 new ChainPlacer(1, Math.floor(scaleByMapSize(6, 12)), Math.floor(scaleByMapSize(15, 60)),
99 new LayeredPainter([tShoreBlend, tShore, tWater], [1, 1]),
100 new SmoothElevationPainter(ELEVATION_SET, heightMarsh, 3),
101 new TileClassPainter(clWater)
105 clWater, Math.round(scaleByMapSize(7, 16) * randFloat(0.8, 1.35))),
106 scaleByMapSize(4, 20));
108 g_Map.log("Creating reeds");
109 createObjectGroupsDeprecated(
112 new SimpleObject(aReeds, 5, 10, 0, 4),
113 new SimpleObject(aLillies, 5, 10, 0, 4)
116 stayClasses(clWater, 1),
117 scaleByMapSize(400, 2000), 100);
120 g_Map.log("Creating bumps");
122 new ClumpPlacer(scaleByMapSize(20, 50), 0.3, 0.06, Infinity),
123 new SmoothElevationPainter(ELEVATION_MODIFY, heightOffsetBumpWater, 2),
124 stayClasses(clWater, 2),
125 scaleByMapSize(50, 100));
127 g_Map.log("Creating forests");
128 const [forestTrees, stragglerTrees] = getTreeCounts(500, 2500, 0.7);
130 [[tForestFloor, tGrass, pForestD], [tForestFloor, pForestD]],
131 [[tForestFloor, tGrass, pForestP], [tForestFloor, pForestP]]
133 const forestSize = forestTrees / (scaleByMapSize(3, 6) * numPlayers);
134 const num = Math.floor(forestSize / types.length);
135 for (const type of types)
137 new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)),
138 forestTrees / (num * Math.floor(scaleByMapSize(2, 4))), Infinity),
140 new LayeredPainter(type, [2]),
141 new TileClassPainter(clForest)
143 avoidClasses(clPlayer, 20, clWater, 0, clForest, 10),
147 g_Map.log("Creating mud patches");
148 for (const size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)])
150 new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, Infinity),
152 new LayeredPainter([tGrassA, tGrassB, tMud], [1, 1]),
153 new TileClassPainter(clDirt)
155 avoidClasses(clWater, 1, clForest, 0, clDirt, 5, clPlayer, 8),
156 scaleByMapSize(15, 45));
158 g_Map.log("Creating stone mines");
159 let group = new SimpleGroup(
161 new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1),
162 new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)
164 createObjectGroupsDeprecated(group, 0,
165 [avoidClasses(clWater, 0, clForest, 1, clPlayer, 20, clRock, 10)],
166 scaleByMapSize(4, 16), 100
169 g_Map.log("Creating small stone quarries");
170 group = new SimpleGroup([new SimpleObject(oStoneSmall, 2, 5, 1, 3)], true, clRock);
171 createObjectGroupsDeprecated(group, 0,
172 [avoidClasses(clWater, 0, clForest, 1, clPlayer, 20, clRock, 10)],
173 scaleByMapSize(4, 16), 100
176 g_Map.log("Creating metal mines");
177 group = new SimpleGroup([new SimpleObject(oMetalLarge, 1, 1, 0, 4)], true, clMetal);
178 createObjectGroupsDeprecated(group, 0,
179 [avoidClasses(clWater, 0, clForest, 1, clPlayer, 20, clMetal, 10, clRock, 5)],
180 scaleByMapSize(4, 16), 100
185 g_Map.log("Creating small decorative rocks");
186 group = new SimpleGroup(
187 [new SimpleObject(aRockMedium, 1, 3, 0, 1)],
190 createObjectGroupsDeprecated(
192 avoidClasses(clWater, 0, clForest, 0, clPlayer, 0),
193 scaleByMapSize(16, 262), 50
198 g_Map.log("Creating large decorative rocks");
199 group = new SimpleGroup(
200 [new SimpleObject(aRockLarge, 1, 2, 0, 1), new SimpleObject(aRockMedium, 1, 3, 0, 2)],
203 createObjectGroupsDeprecated(
205 avoidClasses(clWater, 0, clForest, 0, clPlayer, 0),
206 scaleByMapSize(8, 131), 50
211 g_Map.log("Creating deer");
212 group = new SimpleGroup(
213 [new SimpleObject(oDeer, 5, 7, 0, 4)],
216 createObjectGroupsDeprecated(group, 0,
217 avoidClasses(clWater, 0, clForest, 0, clPlayer, 20, clFood, 13),
221 g_Map.log("Creating horse");
222 group = new SimpleGroup(
223 [new SimpleObject(oHorse, 1, 3, 0, 4)],
226 createObjectGroupsDeprecated(group, 0,
227 avoidClasses(clWater, 0, clForest, 0, clPlayer, 20, clFood, 13),
233 g_Map.log("Creating rabbit");
234 group = new SimpleGroup(
235 [new SimpleObject(oRabbit, 5, 7, 0, 2)],
238 createObjectGroupsDeprecated(group, 0,
239 avoidClasses(clWater, 0, clForest, 0, clPlayer, 20, clFood, 13),
243 g_Map.log("Creating wolf");
244 group = new SimpleGroup(
245 [new SimpleObject(oWolf, 1, 3, 0, 4)],
248 createObjectGroupsDeprecated(group, 0,
249 avoidClasses(clWater, 0, clForest, 0, clPlayer, 20, clFood, 13),
253 g_Map.log("Creating berry bush");
254 group = new SimpleGroup(
255 [new SimpleObject(oBerryBush, 5, 7, 0, 4)],
258 createObjectGroupsDeprecated(group, 0,
259 avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clFood, 10),
260 randIntInclusive(1, 4) * numPlayers + 2, 50
265 createStragglerTrees(
267 avoidClasses(clForest, 1, clPlayer, 13, clMetal, 6, clRock, 6, clWater, 0),
273 g_Map.log("Creating small grass tufts");
274 createObjectGroupsDeprecated(
275 new SimpleGroup([new SimpleObject(aGrassShort, 1, 2, 0, 1)]),
277 avoidClasses(clWater, 2, clPlayer, 13, clDirt, 0),
278 scaleByMapSize(13, 200));
282 g_Map.log("Creating large grass tufts");
283 createObjectGroupsDeprecated(
286 new SimpleObject(aGrass, 2, 4, 0, 1.8),
287 new SimpleObject(aGrassShort, 3, 6, 1.2, 2.5)
290 avoidClasses(clWater, 3, clPlayer, 13, clDirt, 1, clForest, 0),
291 scaleByMapSize(13, 200));
295 g_Map.log("Creating bushes");
296 createObjectGroupsDeprecated(
299 new SimpleObject(aBushMedium, 1, 2, 0, 2),
300 new SimpleObject(aBushSmall, 2, 4, 0, 2)
303 avoidClasses(clWater, 1, clPlayer, 13, clDirt, 1),
304 scaleByMapSize(13, 200),
307 placePlayersNomad(clPlayer, avoidClasses(clWater, 4, clForest, 1, clMetal, 4, clRock, 4, clFood, 2));
311 setWaterColor(0.753, 0.635, 0.345);
312 // clear blue for blueness
313 setWaterTint(0.161, 0.514, 0.635);
314 setWaterMurkiness(0.8);
315 setWaterWaviness(1.0);
316 setWaterType("clap");
318 setFogThickness(0.25);
322 setPPSaturation(0.44);