1 Engine.LoadLibrary("rmgen");
2 Engine.LoadLibrary("rmgen-common");
3 Engine.LoadLibrary("rmgen2");
4 Engine.LoadLibrary("rmbiome");
6 function* GenerateMap(mapSettings)
12 globalThis.g_Map = new RandomMap(heightLand, g_Terrains.mainTerrain);
13 const mapCenter = g_Map.getCenter();
14 const mapSize = g_Map.getSize();
16 initTileClasses(["bluffsPassage", "nomadArea"]);
18 new MapBoundsPlacer(),
19 new TileClassPainter(g_TileClasses.land));
23 const pattern = mapSettings.TeamPlacement ||
24 pickRandom(["line", "radial", "randomGroup", "stronghold"]);
25 const [playerIDs, playerPosition] =
27 ...playerPlacementByPattern(
29 fractionToTiles(randFloat(0.2, 0.35)),
30 fractionToTiles(randFloat(0.08, 0.1)),
33 g_PlayerbaseTypes[pattern].walls);
36 markPlayerAvoidanceArea(playerPosition, defaultPlayerBaseRadius());
43 "baseHeight": heightLand,
44 "avoid": [g_TileClasses.bluffIgnore, 0],
45 "sizes": ["normal", "big", "huge"],
52 g_TileClasses.bluff, 5,
53 g_TileClasses.hill, 15,
54 g_TileClasses.player, 20
56 "sizes": ["normal", "big"],
64 createBluffsPassages(playerPosition);
68 "func": addLayeredPatches,
70 g_TileClasses.bluff, 2,
71 g_TileClasses.bluffsPassage, 4,
72 g_TileClasses.dirt, 5,
73 g_TileClasses.forest, 2,
74 g_TileClasses.mountain, 2,
75 g_TileClasses.player, 12,
76 g_TileClasses.water, 3
83 "func": addDecoration,
85 g_TileClasses.bluff, 2,
86 g_TileClasses.bluffsPassage, 4,
87 g_TileClasses.forest, 2,
88 g_TileClasses.mountain, 2,
89 g_TileClasses.player, 12,
90 g_TileClasses.water, 3
99 addElements(shuffleArray([
103 g_TileClasses.bluffsPassage, 4,
104 g_TileClasses.berries, 5,
105 g_TileClasses.forest, 3,
106 g_TileClasses.mountain, 2,
107 g_TileClasses.player, 30,
108 g_TileClasses.rock, 10,
109 g_TileClasses.metal, 20,
110 g_TileClasses.water, 3
112 "stay": [g_TileClasses.bluff, 5],
120 g_TileClasses.bluffsPassage, 4,
121 g_TileClasses.berries, 5,
122 g_TileClasses.forest, 3,
123 g_TileClasses.mountain, 2,
124 g_TileClasses.player, 30,
125 g_TileClasses.rock, 20,
126 g_TileClasses.metal, 10,
127 g_TileClasses.water, 3
129 "stay": [g_TileClasses.bluff, 5],
138 g_TileClasses.bluffsPassage, 4,
139 g_TileClasses.forest, 6,
140 g_TileClasses.metal, 3,
141 g_TileClasses.mountain, 5,
142 g_TileClasses.player, 20,
143 g_TileClasses.rock, 3,
144 g_TileClasses.water, 2
146 "stay": [g_TileClasses.bluff, 5],
151 // Forests on mainland
155 g_TileClasses.bluffsPassage, 4,
156 g_TileClasses.bluff, 10,
157 g_TileClasses.forest, 10,
158 g_TileClasses.metal, 3,
159 g_TileClasses.mountain, 5,
160 g_TileClasses.player, 20,
161 g_TileClasses.rock, 3,
162 g_TileClasses.water, 2
166 "amounts": ["normal"]
171 addElements(shuffleArray([
175 g_TileClasses.bluff, 5,
176 g_TileClasses.bluffsPassage, 4,
177 g_TileClasses.forest, 5,
178 g_TileClasses.metal, 10,
179 g_TileClasses.mountain, 2,
180 g_TileClasses.player, 20,
181 g_TileClasses.rock, 10,
182 g_TileClasses.water, 3
191 g_TileClasses.bluff, 5,
192 g_TileClasses.bluffsPassage, 4,
193 g_TileClasses.forest, 2,
194 g_TileClasses.metal, 2,
195 g_TileClasses.mountain, 1,
196 g_TileClasses.player, 12,
197 g_TileClasses.rock, 2,
198 g_TileClasses.water, 3
201 "mixes": ["similar"],
205 "func": addStragglerTrees,
207 g_TileClasses.berries, 5,
208 g_TileClasses.bluff, 5,
209 g_TileClasses.bluffsPassage, 4,
210 g_TileClasses.forest, 7,
211 g_TileClasses.metal, 2,
212 g_TileClasses.mountain, 1,
213 g_TileClasses.player, 12,
214 g_TileClasses.rock, 2,
215 g_TileClasses.water, 5
226 g_Map.log("Preventing units to be spawned at the map border");
228 new DiskPlacer(mapSize / 2 - scaleByMapSize(15, 35), mapCenter),
229 new TileClassPainter(g_TileClasses.nomadArea));
232 g_TileClasses.player,
234 stayClasses(g_TileClasses.nomadArea, 0),
236 g_TileClasses.bluff, 2,
237 g_TileClasses.water, 4,
238 g_TileClasses.forest, 1,
239 g_TileClasses.metal, 4,
240 g_TileClasses.rock, 4,
241 g_TileClasses.mountain, 4,
242 g_TileClasses.animals, 2)