1 Engine.LoadLibrary("rmgen");
2 Engine.LoadLibrary("rmgen-common");
4 function* GenerateMap()
6 TILE_CENTERED_HEIGHT_MAP = true;
8 const tCity = "medit_city_pavement";
9 const tCityPlaza = "medit_city_pavement";
12 "medit_rocks_grass_shrubs",
17 const tMainDirt = "medit_dirt";
18 const tCliff = "medit_cliff_aegean";
19 const tForestFloor = "medit_grass_shrubs";
20 const tGrass = "medit_grass_field";
21 const tGrassSand50 = "medit_grass_field_a";
22 const tGrassSand25 = "medit_grass_field_b";
23 const tDirt = "medit_dirt_b";
24 const tDirt2 = "medit_rocks_grass";
25 const tDirt3 = "medit_rocks_shrubs";
26 const tDirtCracks = "medit_dirt_c";
27 const tShoreUpper = "medit_sand";
28 const tShoreLower = "medit_sand_wet";
29 const tCoralsUpper = "medit_sea_coral_plants";
30 const tCoralsLower = "medit_sea_coral_deep";
31 const tSeaDepths = "medit_sea_depths";
33 const oBerryBush = "gaia/fruit/berry_01";
34 const oDeer = "gaia/fauna_deer";
35 const oFish = "gaia/fish/generic";
36 const oSheep = "gaia/fauna_sheep";
37 const oGoat = "gaia/fauna_goat";
38 const oStoneLarge = "gaia/rock/mediterranean_large";
39 const oStoneSmall = "gaia/rock/mediterranean_small";
40 const oMetalLarge = "gaia/ore/mediterranean_large";
41 const oDatePalm = "gaia/tree/cretan_date_palm_short";
42 const oSDatePalm = "gaia/tree/cretan_date_palm_tall";
43 const oCarob = "gaia/tree/carob";
44 const oFanPalm = "gaia/tree/medit_fan_palm";
45 const oPoplar = "gaia/tree/poplar_lombardy";
46 const oCypress = "gaia/tree/cypress";
48 const aBush1 = "actor|props/flora/bush_medit_sm.xml";
49 const aBush2 = "actor|props/flora/bush_medit_me.xml";
50 const aBush3 = "actor|props/flora/bush_medit_la.xml";
51 const aBush4 = "actor|props/flora/bush_medit_me.xml";
52 const aDecorativeRock = "actor|geology/stone_granite_med.xml";
56 tForestFloor + TERRAIN_SEPARATOR + oCarob,
57 tForestFloor + TERRAIN_SEPARATOR + oDatePalm,
58 tForestFloor + TERRAIN_SEPARATOR + oSDatePalm,
62 const heightSeaGround = -3;
63 const heightSeaBump = -2.5;
64 const heightCorralsLower = -2;
65 const heightCorralsUpper = -1.5;
66 const heightShore = 1;
68 const heightIsland = 6;
70 globalThis.g_Map = new RandomMap(heightShore, tHill);
72 const numPlayers = getNumPlayers();
73 const mapCenter = g_Map.getCenter();
74 const mapBounds = g_Map.getBounds();
76 const clPlayer = g_Map.createTileClass();
77 const clForest = g_Map.createTileClass();
78 const clWater = g_Map.createTileClass();
79 const clDirt = g_Map.createTileClass();
80 const clRock = g_Map.createTileClass();
81 const clMetal = g_Map.createTileClass();
82 const clFood = g_Map.createTileClass();
83 const clBaseResource = g_Map.createTileClass();
84 const clGrass = g_Map.createTileClass();
85 const clHill = g_Map.createTileClass();
86 const clIsland = g_Map.createTileClass();
88 const startAngle = randomAngle();
91 "PlayerPlacement": playerPlacementRiver(startAngle, fractionToTiles(0.6)),
92 "PlayerTileClass": clPlayer,
93 "BaseResourceClass": clBaseResource,
95 "outerTerrain": tCityPlaza,
101 "template": oBerryBush
105 { "template": oMetalLarge },
106 { "template": oStoneLarge }
121 "start": new Vector2D(mapCenter.x, mapBounds.top).rotateAround(startAngle, mapCenter),
122 "end": new Vector2D(mapCenter.x, mapBounds.bottom).rotateAround(startAngle, mapCenter),
123 "width": fractionToTiles(0.35),
124 "fadeDist": scaleByMapSize(6, 25),
126 "heightRiverbed": heightSeaGround,
127 "heightLand": heightLand,
132 paintTileClassBasedOnHeight(-Infinity, 0.7, Elevation_ExcludeMin_ExcludeMax, clWater);
134 paintTerrainBasedOnHeight(-Infinity, heightShore, Elevation_ExcludeMin_ExcludeMax, tShoreLower);
135 paintTerrainBasedOnHeight(heightShore, heightLand, Elevation_ExcludeMin_ExcludeMax, tShoreUpper);
138 createBumps(avoidClasses(clWater, 2, clPlayer, 20));
140 const [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7);
142 [tForestFloor, tForestFloor, tForestFloor, pForest, pForest],
143 avoidClasses(clPlayer, 20, clForest, 17, clWater, 2, clBaseResource, 3),
150 createHills([tGrass, tCliff, tHill],
151 avoidClasses(clPlayer, 20, clForest, 1, clHill, 15, clWater, 3),
153 scaleByMapSize(3, 15));
155 createMountains(tCliff,
156 avoidClasses(clPlayer, 20, clForest, 1, clHill, 15, clWater, 3),
158 scaleByMapSize(3, 15));
160 g_Map.log("Creating grass patches");
161 createLayeredPatches(
162 [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
163 [[tGrass, tGrassSand50], [tGrassSand50, tGrassSand25], [tGrassSand25, tGrass]],
165 avoidClasses(clForest, 0, clGrass, 2, clPlayer, 10, clWater, 2, clDirt, 2, clHill, 1),
166 scaleByMapSize(15, 45),
171 g_Map.log("Creating dirt patches");
172 createLayeredPatches(
173 [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
174 [tDirt3, tDirt2, [tDirt, tMainDirt], [tDirtCracks, tMainDirt]],
176 avoidClasses(clForest, 0, clDirt, 2, clPlayer, 10, clWater, 2, clGrass, 2, clHill, 1),
177 scaleByMapSize(15, 45),
182 g_Map.log("Creating undersea bumps");
184 new ChainPlacer(1, Math.floor(scaleByMapSize(4, 6)), Math.floor(scaleByMapSize(16, 40)), 0.5),
185 new SmoothElevationPainter(ELEVATION_SET, heightSeaBump, 3),
186 stayClasses(clWater, 6),
187 scaleByMapSize(10, 50));
189 g_Map.log("Creating islands");
191 new ChainPlacer(1, Math.floor(scaleByMapSize(4, 6)), Math.floor(scaleByMapSize(30, 80)), 0.5),
193 new LayeredPainter([tShoreLower, tShoreUpper, tHill], [2, 1]),
194 new SmoothElevationPainter(ELEVATION_SET, heightIsland, 4),
195 new TileClassPainter(clIsland)
197 [avoidClasses(clPlayer, 8, clForest, 1, clIsland, 15), stayClasses (clWater, 6)],
198 scaleByMapSize(1, 4) * numPlayers
201 paintTerrainBasedOnHeight(-Infinity, heightSeaGround, Elevation_IncludeMin_IncludeMax, tSeaDepths);
202 paintTerrainBasedOnHeight(heightSeaGround, heightCorralsLower, Elevation_ExcludeMin_IncludeMax,
204 paintTerrainBasedOnHeight(heightCorralsLower, heightCorralsUpper, Elevation_ExcludeMin_IncludeMax,
207 g_Map.log("Creating island stone mines");
211 new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1),
212 new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)
214 [new SimpleObject(oStoneSmall, 2, 5, 1, 3)]
216 stayClasses(clIsland, 4),
219 g_Map.log("Creating island metal mines");
222 [new SimpleObject(oMetalLarge, 1, 1, 0, 4)]
224 stayClasses(clIsland, 4),
228 g_Map.log("Creating stone mines");
232 new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1),
233 new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)
235 [new SimpleObject(oStoneSmall, 2, 5, 1, 3)]
237 avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clWater, 1, clHill, 1),
240 g_Map.log("Creating metal mines");
243 [new SimpleObject(oMetalLarge, 1, 1, 0, 4)]
245 avoidClasses(clForest, 1, clPlayer, 20, clMetal, 10, clRock, 5, clWater, 1, clHill, 1),
254 new SimpleObject(aDecorativeRock, 1, 3, 0, 1)
257 new SimpleObject(aBush2, 1, 2, 0, 1),
258 new SimpleObject(aBush1, 1, 3, 0, 2),
259 new SimpleObject(aBush4, 1, 2, 0, 1),
260 new SimpleObject(aBush3, 1, 3, 0, 2)
264 scaleByMapAreaAbsolute(16),
265 scaleByMapSize(40, 360)
267 avoidClasses(clWater, 2, clForest, 0, clPlayer, 0, clHill, 1));
273 [new SimpleObject(oFish, 2, 3, 0, 2)]
276 3 * scaleByMapSize(5, 20)
278 [avoidClasses(clIsland, 2, clFood, 10), stayClasses(clWater, 5)],
283 [new SimpleObject(oSheep, 5, 7, 0, 4)],
284 [new SimpleObject(oGoat, 2, 4, 0, 3)],
285 [new SimpleObject(oDeer, 2, 4, 0, 2)]
288 scaleByMapSize(5, 20),
289 scaleByMapSize(5, 20),
290 scaleByMapSize(5, 20)
292 avoidClasses(clForest, 0, clPlayer, 8, clBaseResource, 4, clWater, 1, clFood, 10, clHill, 1),
297 [new SimpleObject(oBerryBush, 5, 7, 0, 4)]
302 avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10),
307 const types = [oDatePalm, oSDatePalm, oCarob, oFanPalm, oPoplar, oCypress];
308 createStragglerTrees(
310 avoidClasses(clForest, 1, clWater, 2, clPlayer, 12, clMetal, 6, clHill, 1),
314 createStragglerTrees(
316 stayClasses(clIsland, 4),
318 stragglerTrees * 10);
320 placePlayersNomad(clPlayer,
330 setSkySet("cumulus");
331 setSunColor(0.866667, 0.776471, 0.486275);
332 setWaterColor(0, 0.501961, 1);
333 setWaterTint(0.501961, 1, 1);
334 setWaterWaviness(4.0);
335 setWaterType("ocean");
336 setWaterMurkiness(0.49);
339 setFogThickness(0.25);
343 setPPSaturation(0.51);