Merge 'remotes/trunk'
[0ad.git] / binaries / data / mods / public / maps / random / rhine_marshlands.js
blobaaab4cd330c7a382530f443d214bd01032dc54af
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;
41         const heightLand = 1;
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();
58         placePlayerBases({
59                 "PlayerPlacement": playerPlacementCircle(fractionToTiles(0.35)),
60                 "PlayerTileClass": clPlayer,
61                 "BaseResourceClass": clBaseResource,
62                 "CityPatch": {
63                         "outerTerrain": tRoadWild,
64                         "innerTerrain": tRoad
65                 },
66                 "StartingAnimal": {
67                 },
68                 "Berries": {
69                         "template": oBerryBush
70                 },
71                 "Mines": {
72                         "types": [
73                                 { "template": oMetalLarge },
74                                 { "template": oStoneLarge }
75                         ]
76                 },
77                 "Trees": {
78                         "template": oBeech
79                 },
80                 "Decoratives": {
81                         "template": aGrassShort
82                 }
83         });
84         yield 15;
86         g_Map.log("Creating bumps");
87         createAreas(
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)
95                 createAreas(
96                         new ChainPlacer(1, Math.floor(scaleByMapSize(6, 12)), Math.floor(scaleByMapSize(15, 60)),
97                                 0.8),
98                         [
99                                 new LayeredPainter([tShoreBlend, tShore, tWater], [1, 1]),
100                                 new SmoothElevationPainter(ELEVATION_SET, heightMarsh, 3),
101                                 new TileClassPainter(clWater)
102                         ],
103                         avoidClasses(
104                                 clPlayer, 20,
105                                 clWater, Math.round(scaleByMapSize(7, 16) * randFloat(0.8, 1.35))),
106                         scaleByMapSize(4, 20));
108         g_Map.log("Creating reeds");
109         createObjectGroupsDeprecated(
110                 new SimpleGroup(
111                         [
112                                 new SimpleObject(aReeds, 5, 10, 0, 4),
113                                 new SimpleObject(aLillies, 5, 10, 0, 4)
114                         ], true),
115                 0,
116                 stayClasses(clWater, 1),
117                 scaleByMapSize(400, 2000), 100);
118         yield 40;
120         g_Map.log("Creating bumps");
121         createAreas(
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);
129         const types = [
130                 [[tForestFloor, tGrass, pForestD], [tForestFloor, pForestD]],
131                 [[tForestFloor, tGrass, pForestP], [tForestFloor, pForestP]]
132         ];
133         const forestSize = forestTrees / (scaleByMapSize(3, 6) * numPlayers);
134         const num = Math.floor(forestSize / types.length);
135         for (const type of types)
136                 createAreas(
137                         new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)),
138                                 forestTrees / (num * Math.floor(scaleByMapSize(2, 4))), Infinity),
139                         [
140                                 new LayeredPainter(type, [2]),
141                                 new TileClassPainter(clForest)
142                         ],
143                         avoidClasses(clPlayer, 20, clWater, 0, clForest, 10),
144                         num);
145         yield 50;
147         g_Map.log("Creating mud patches");
148         for (const size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)])
149                 createAreas(
150                         new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, Infinity),
151                         [
152                                 new LayeredPainter([tGrassA, tGrassB, tMud], [1, 1]),
153                                 new TileClassPainter(clDirt)
154                         ],
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(
160                 [
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)
163                 ], true, clRock);
164         createObjectGroupsDeprecated(group, 0,
165                 [avoidClasses(clWater, 0, clForest, 1, clPlayer, 20, clRock, 10)],
166                 scaleByMapSize(4, 16), 100
167         );
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
174         );
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
181         );
183         yield 60;
185         g_Map.log("Creating small decorative rocks");
186         group = new SimpleGroup(
187                 [new SimpleObject(aRockMedium, 1, 3, 0, 1)],
188                 true
189         );
190         createObjectGroupsDeprecated(
191                 group, 0,
192                 avoidClasses(clWater, 0, clForest, 0, clPlayer, 0),
193                 scaleByMapSize(16, 262), 50
194         );
196         yield 65;
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)],
201                 true
202         );
203         createObjectGroupsDeprecated(
204                 group, 0,
205                 avoidClasses(clWater, 0, clForest, 0, clPlayer, 0),
206                 scaleByMapSize(8, 131), 50
207         );
209         yield 70;
211         g_Map.log("Creating deer");
212         group = new SimpleGroup(
213                 [new SimpleObject(oDeer, 5, 7, 0, 4)],
214                 true, clFood
215         );
216         createObjectGroupsDeprecated(group, 0,
217                 avoidClasses(clWater, 0, clForest, 0, clPlayer, 20, clFood, 13),
218                 6 * numPlayers, 50
219         );
221         g_Map.log("Creating horse");
222         group = new SimpleGroup(
223                 [new SimpleObject(oHorse, 1, 3, 0, 4)],
224                 true, clFood
225         );
226         createObjectGroupsDeprecated(group, 0,
227                 avoidClasses(clWater, 0, clForest, 0, clPlayer, 20, clFood, 13),
228                 3 * numPlayers, 50
229         );
231         yield 75;
233         g_Map.log("Creating rabbit");
234         group = new SimpleGroup(
235                 [new SimpleObject(oRabbit, 5, 7, 0, 2)],
236                 true, clFood
237         );
238         createObjectGroupsDeprecated(group, 0,
239                 avoidClasses(clWater, 0, clForest, 0, clPlayer, 20, clFood, 13),
240                 6 * numPlayers, 50
241         );
243         g_Map.log("Creating wolf");
244         group = new SimpleGroup(
245                 [new SimpleObject(oWolf, 1, 3, 0, 4)],
246                 true, clFood
247         );
248         createObjectGroupsDeprecated(group, 0,
249                 avoidClasses(clWater, 0, clForest, 0, clPlayer, 20, clFood, 13),
250                 3 * numPlayers, 50
251         );
253         g_Map.log("Creating berry bush");
254         group = new SimpleGroup(
255                 [new SimpleObject(oBerryBush, 5, 7, 0, 4)],
256                 true, clFood
257         );
258         createObjectGroupsDeprecated(group, 0,
259                 avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clFood, 10),
260                 randIntInclusive(1, 4) * numPlayers + 2, 50
261         );
263         yield 80;
265         createStragglerTrees(
266                 [oOak, oBeech],
267                 avoidClasses(clForest, 1, clPlayer, 13, clMetal, 6, clRock, 6, clWater, 0),
268                 clForest,
269                 stragglerTrees);
271         yield 85;
273         g_Map.log("Creating small grass tufts");
274         createObjectGroupsDeprecated(
275                 new SimpleGroup([new SimpleObject(aGrassShort, 1, 2, 0, 1)]),
276                 0,
277                 avoidClasses(clWater, 2, clPlayer, 13, clDirt, 0),
278                 scaleByMapSize(13, 200));
280         yield 90;
282         g_Map.log("Creating large grass tufts");
283         createObjectGroupsDeprecated(
284                 new SimpleGroup(
285                         [
286                                 new SimpleObject(aGrass, 2, 4, 0, 1.8),
287                                 new SimpleObject(aGrassShort, 3, 6, 1.2, 2.5)
288                         ]),
289                 0,
290                 avoidClasses(clWater, 3, clPlayer, 13, clDirt, 1, clForest, 0),
291                 scaleByMapSize(13, 200));
293         yield 95;
295         g_Map.log("Creating bushes");
296         createObjectGroupsDeprecated(
297                 new SimpleGroup(
298                         [
299                                 new SimpleObject(aBushMedium, 1, 2, 0, 2),
300                                 new SimpleObject(aBushSmall, 2, 4, 0, 2)
301                         ]),
302                 0,
303                 avoidClasses(clWater, 1, clPlayer, 13, clDirt, 1),
304                 scaleByMapSize(13, 200),
305                 50);
307         placePlayersNomad(clPlayer, avoidClasses(clWater, 4, clForest, 1, clMetal, 4, clRock, 4, clFood, 2));
309         setSkySet("cirrus");
310         // muddy brown
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);
319         setFogFactor(0.6);
321         setPPEffect("hdr");
322         setPPSaturation(0.44);
323         setPPBloom(0.3);
325         return g_Map;