1 Engine.LoadLibrary("rmgen");
2 Engine.LoadLibrary("rmgen-common");
4 function* GenerateMap()
6 const tPrimary = "temp_grass_long";
7 const tGrass = ["temp_grass", "temp_grass", "temp_grass_d"];
8 const tGrassDForest = "temp_plants_bog";
9 const tGrassA = "temp_grass_plants";
10 const tGrassB = "temp_plants_bog";
11 const tGrassC = "temp_mud_a";
12 const tHill = ["temp_highlands", "temp_grass_long_b"];
13 const tCliff = ["temp_cliff_a", "temp_cliff_b"];
14 const tRoad = "temp_road";
15 const tRoadWild = "temp_road_overgrown";
16 const tGrassPatchBlend = "temp_grass_long_b";
17 const tGrassPatch = ["temp_grass_d", "temp_grass_clovers"];
18 const tShore = "temp_dirt_gravel";
19 const tWater = "temp_dirt_gravel_b";
21 const oBeech = "gaia/tree/euro_beech";
22 const oPoplar = "gaia/tree/poplar";
23 const oApple = "gaia/fruit/apple";
24 const oOak = "gaia/tree/oak";
25 const oBerryBush = "gaia/fruit/berry_01";
26 const oDeer = "gaia/fauna_deer";
27 const oFish = "gaia/fish/generic";
28 const oGoat = "gaia/fauna_goat";
29 const oBoar = "gaia/fauna_boar";
30 const oStoneLarge = "gaia/rock/temperate_large";
31 const oStoneSmall = "gaia/rock/temperate_small";
32 const oMetalLarge = "gaia/ore/temperate_large";
34 const aGrass = "actor|props/flora/grass_soft_large_tall.xml";
35 const aGrassShort = "actor|props/flora/grass_soft_large.xml";
36 const aRockLarge = "actor|geology/stone_granite_large.xml";
37 const aRockMedium = "actor|geology/stone_granite_med.xml";
38 const aBushMedium = "actor|props/flora/bush_medit_me_lush.xml";
39 const aBushSmall = "actor|props/flora/bush_medit_sm_lush.xml";
40 const aReeds = "actor|props/flora/reeds_pond_lush_a.xml";
41 const aLillies = "actor|props/flora/water_lillies.xml";
43 const pForestD = [tGrassDForest + TERRAIN_SEPARATOR + oBeech, tGrassDForest];
45 const heightSeaGround = -4;
46 const heightShore = 1;
49 globalThis.g_Map = new RandomMap(heightShore, tPrimary);
51 const numPlayers = getNumPlayers();
52 const mapCenter = g_Map.getCenter();
53 const mapBounds = g_Map.getBounds();
55 const clPlayer = g_Map.createTileClass();
56 const clHill = g_Map.createTileClass();
57 const clForest = g_Map.createTileClass();
58 const clWater = g_Map.createTileClass();
59 const clDirt = g_Map.createTileClass();
60 const clRock = g_Map.createTileClass();
61 const clMetal = g_Map.createTileClass();
62 const clFood = g_Map.createTileClass();
63 const clBaseResource = g_Map.createTileClass();
64 const clShallow = g_Map.createTileClass();
66 const startAngle = randomAngle();
69 "PlayerPlacement": playerPlacementRiver(startAngle + Math.PI / 2, fractionToTiles(0.6)),
70 "PlayerTileClass": clPlayer,
71 "BaseResourceClass": clBaseResource,
73 "outerTerrain": tRoadWild,
79 "template": oBerryBush
83 { "template": oMetalLarge },
84 { "template": oStoneLarge }
92 "template": aGrassShort
99 "start": new Vector2D(mapBounds.left, mapCenter.y).rotateAround(startAngle, mapCenter),
100 "end": new Vector2D(mapBounds.right, mapCenter.y).rotateAround(startAngle, mapCenter),
101 "width": fractionToTiles(0.25),
102 "fadeDist": scaleByMapSize(3, 10),
104 "heightRiverbed": heightSeaGround,
105 "heightLand": heightLand,
108 "waterFunc": (position, height, riverFraction) => {
109 createTerrain(height < -1.5 ? tWater : tShore).place(position);
111 "landFunc": (position, shoreDist1, shoreDist2) => {
112 g_Map.setHeight(position, heightLand + 0.1);
118 createTributaryRivers(
120 randIntInclusive(9, scaleByMapSize(13, 21)),
121 scaleByMapSize(10, 20),
127 avoidClasses(clPlayer, 8, clBaseResource, 4));
129 paintTerrainBasedOnHeight(-5, 1, 1, tWater);
130 paintTerrainBasedOnHeight(1, heightLand, 1, tShore);
131 paintTileClassBasedOnHeight(-6, 0.5, 1, clWater);
134 createBumps(avoidClasses(clWater, 5, clPlayer, 20));
137 createHills([tCliff, tCliff, tHill], avoidClasses(clPlayer, 20, clHill, 15, clWater, 5), clHill,
138 scaleByMapSize(1, 4) * numPlayers);
141 const [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7);
143 [tGrass, tGrassDForest, tGrassDForest, pForestD, pForestD],
144 avoidClasses(clPlayer, 20, clForest, 17, clHill, 0, clWater, 6),
149 g_Map.log("Creating dirt patches");
150 createLayeredPatches(
151 [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
152 [[tGrass, tGrassA], tGrassB, [tGrassB, tGrassC]],
154 avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 6),
155 scaleByMapSize(15, 45),
158 g_Map.log("Creating grass patches");
160 [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
161 [tGrassPatchBlend, tGrassPatch],
163 avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 6),
164 scaleByMapSize(15, 45),
168 g_Map.log("Creating stone mines");
172 new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1),
173 new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)
175 [new SimpleObject(oStoneSmall, 2, 5, 1, 3)]
177 avoidClasses(clWater, 2, clForest, 1, clPlayer, 20, clRock, 10, clHill, 2),
180 g_Map.log("Creating metal mines");
183 [new SimpleObject(oMetalLarge, 1, 1, 0, 4)]
185 avoidClasses(clWater, 2, clForest, 1, clPlayer, 20, clMetal, 10, clRock, 5, clHill, 2),
192 [new SimpleObject(aRockMedium, 1, 3, 0, 1)],
193 [new SimpleObject(aRockLarge, 1, 2, 0, 1), new SimpleObject(aRockMedium, 1, 3, 0, 2)],
194 [new SimpleObject(aGrassShort, 1, 2, 0, 1)],
195 [new SimpleObject(aGrass, 2, 4, 0, 1.8), new SimpleObject(aGrassShort, 3, 6, 1.2, 2.5)],
196 [new SimpleObject(aBushMedium, 1, 2, 0, 2), new SimpleObject(aBushSmall, 2, 4, 0, 2)]
199 scaleByMapAreaAbsolute(16),
200 scaleByMapAreaAbsolute(8),
201 scaleByMapAreaAbsolute(13),
202 scaleByMapAreaAbsolute(13),
203 scaleByMapAreaAbsolute(13)
205 avoidClasses(clWater, 1, clForest, 0, clPlayer, 0, clHill, 0));
209 [new SimpleObject(aReeds, 1, 3, 0, 1)],
210 [new SimpleObject(aLillies, 1, 2, 0, 1)]
213 scaleByMapSize(800, 12800),
214 scaleByMapSize(800, 12800)
216 stayClasses(clShallow, 0));
220 [new SimpleObject(oDeer, 5, 7, 0, 4)],
221 [new SimpleObject(oGoat, 2, 3, 0, 2)],
222 [new SimpleObject(oBoar, 2, 3, 0, 2)]
229 avoidClasses(clWater, 1, clForest, 0, clPlayer, 20, clHill, 0, clFood, 15),
234 [new SimpleObject(oBerryBush, 5, 7, 0, 4)]
237 randIntInclusive(1, 4) * numPlayers + 2
239 avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10),
244 [new SimpleObject(oFish, 2, 3, 0, 2)]
246 [scaleByMapSize(3, 25) * numPlayers],
247 [avoidClasses(clFood, 6), stayClasses(clWater, 4)],
250 createStragglerTrees(
251 [oBeech, oPoplar, oApple],
252 avoidClasses(clWater, 1, clForest, 1, clHill, 1, clPlayer, 8, clMetal, 6, clRock, 6),
257 setWaterColor(0.114, 0.192, 0.463);
258 setWaterTint(0.255, 0.361, 0.651);
259 setWaterWaviness(3.0);
260 setWaterType("ocean");
261 setWaterMurkiness(0.83);
263 setFogThickness(0.35);
267 setPPSaturation(0.62);
271 placePlayersNomad(clPlayer,
272 avoidClasses(clWater, 4, clForest, 1, clMetal, 4, clRock, 4, clHill, 4, clFood, 2));