Fix the two incorrect replacements in rP21434, refs #4950.
[0ad.git] / binaries / data / mods / public / maps / random / ratumacos.js
blob52d400aa75702b2dba7a4270855833b8979f2bee
1 /**
2  * Heightmap image source:
3  * Imagery by Jesse Allen, NASA's Earth Observatory,
4  * using data from the General Bathymetric Chart of the Oceans (GEBCO)
5  * produced by the British Oceanographic Data Centre.
6  * https://visibleearth.nasa.gov/view.php?id=73934
7  *
8  * Licensing: Public Domain, https://visibleearth.nasa.gov/useterms.php
9  *
10  * The heightmap image is reproduced using:
11  * wget https://eoimages.gsfc.nasa.gov/images/imagerecords/73000/73934/gebco_08_rev_elev_C1_grey_geo.tif
12  * lat=49.31; lon=1.1; width=1
13  * lat1=$(bc <<< ";scale=5;$lat-$width/2"); lon1=$(bc <<< ";scale=5;$lon+$width/2"); lat2=$(bc <<< ";scale=5;$lat+$width/2"); lon2=$(bc <<< ";scale=5;$lon-$width/2")
14  * gdal_translate -projwin $lon2 $lat2 $lon1 $lat1 gebco_08_rev_elev_C1_grey_geo.tif ratumacos.tif
15  * convert ratumacos.tif -resize 512 -contrast-stretch 0 ratumacos.png
16  * No further changes should be applied to the image to keep it easily interchangeable.
17  */
19 Engine.LoadLibrary("rmgen");
20 Engine.LoadLibrary("rmgen-common");
21 Engine.LoadLibrary("rmgen2");
22 Engine.LoadLibrary("rmbiome");
24 setBiome("generic/alpine");
26 g_Terrains.mainTerrain = "new_alpine_grass_d";
27 g_Terrains.forestFloor1 = "alpine_grass_d";
28 g_Terrains.forestFloor2 = "alpine_grass_c";
29 g_Terrains.tier1Terrain = "new_alpine_grass_c";
30 g_Terrains.tier2Terrain = "new_alpine_grass_b";
31 g_Terrains.tier3Terrain = "alpine_grass_a";
32 g_Terrains.tier4Terrain = "new_alpine_grass_e";
34 g_Gaia.mainHuntableAnimal = "gaia/fauna_deer";
35 g_Gaia.secondaryHuntableAnimal = "gaia/fauna_pig";
36 g_Gaia.fish = "gaia/fauna_fish_tilapia";
37 g_Gaia.tree1 = "gaia/flora_tree_poplar";
38 g_Gaia.tree2 = "gaia/flora_tree_toona";
39 g_Gaia.tree3 = "gaia/flora_tree_apple";
40 g_Gaia.tree4 = "gaia/flora_tree_acacia";
41 g_Gaia.tree5 = "gaia/flora_tree_carob";
43 g_Decoratives.grass = "actor|props/flora/grass_soft_large.xml";
44 g_Decoratives.grassShort = "actor|props/flora/grass_tufts_a.xml";
45 g_Decoratives.rockLarge = "actor|geology/stone_granite_med.xml";
46 g_Decoratives.rockMedium = "actor|geology/stone_granite_small.xml";
47 g_Decoratives.bushMedium = "actor|props/flora/bush_tempe_a.xml";
48 g_Decoratives.bushSmall = "actor|props/flora/bush_tempe_b.xml";
49 g_Decoratives.reeds = "actor|props/flora/reeds_pond_lush_a.xml";
50 g_Decoratives.lillies = "actor|props/flora/water_lillies.xml";
52 const heightScale = num => num * g_MapSettings.Size / 320;
54 const heightReedsMin = heightScale(-2);
55 const heightShallow = heightScale(-1);
56 const heightWaterLevel = heightScale(0);
57 const heightShoreline = heightScale(3);
58 const heightPlayer = heightScale(10);
60 const g_Map = new RandomMap(0, g_Terrains.mainTerrain);
61 const mapBounds = g_Map.getBounds();
62 const mapCenter = g_Map.getCenter();
64 const riverAngle = 0.65 * Math.PI;
66 initTileClasses(["shoreline", "shallows"]);
68 g_Map.LoadHeightmapImage("ratumacos.png", -3, 20);
69 Engine.SetProgress(15);
71 g_Map.log("Smoothing heightmap");
72 createArea(
73         new MapBoundsPlacer(),
74         new SmoothingPainter(1, 0.1, 1));
75 Engine.SetProgress(25);
77 g_Map.log("Creating shallows");
78 for (let i = 0; i < scaleByMapSize(5, 12); ++i)
80         let x = fractionToTiles(randFloat(0, 1));
81         createPassage({
82                 "start": new Vector2D(x, mapBounds.bottom).rotateAround(riverAngle + Math.PI / 2 * randFloat(0.8, 1.2), mapCenter),
83                 "end": new Vector2D(x, mapBounds.top).rotateAround(riverAngle + Math.PI / 2 * randFloat(0.8, 1.2), mapCenter),
84                 "startWidth": scaleByMapSize(8, 12),
85                 "endWidth": scaleByMapSize(8, 12),
86                 "smoothWidth": 2,
87                 "startHeight": heightShallow,
88                 "endHeight": heightShallow,
89                 "constraints": new HeightConstraint(-Infinity, heightShallow)
90         });
93 g_Map.log("Painting water");
94 createArea(
95         new MapBoundsPlacer(),
96         [
97                 new TerrainPainter(g_Terrains.water),
98                 new TileClassPainter(g_TileClasses.water)
99         ],
100         new HeightConstraint(-Infinity, heightWaterLevel));
101 Engine.SetProgress(30);
103 g_Map.log("Marking land");
104 createArea(
105         new MapBoundsPlacer(),
106         new TileClassPainter(g_TileClasses.land),
107         avoidClasses(g_TileClasses.water, 0));
108 Engine.SetProgress(35);
110 g_Map.log("Painting shoreline");
111 createArea(
112         new MapBoundsPlacer(),
113         [
114                 new TerrainPainter(g_Terrains.shore),
115                 new TileClassPainter(g_TileClasses.shoreline)
116         ],
117         new HeightConstraint(heightWaterLevel, heightShoreline));
118 Engine.SetProgress(40);
120 placePlayerBases({
121         "PlayerPlacement": playerPlacementRiver(riverAngle, fractionToTiles(0.6)),
122         "PlayerTileClass": g_TileClasses.player,
123         "BaseResourceClass": g_TileClasses.baseResource,
124         "Walls": "towers",
125         "CityPatch": {
126                 "outerTerrain": g_Terrains.roadWild,
127                 "innerTerrain": g_Terrains.road,
128                 "painters": [
129                         new SmoothElevationPainter(ELEVATION_SET, heightPlayer, 2)
130                 ]
131         },
132         "Chicken": {
133         },
134         "Berries": {
135                 "template": g_Gaia.fruitBush
136         },
137         "Mines": {
138                 "types": [
139                         { "template": g_Gaia.metalLarge },
140                         { "template": g_Gaia.stoneLarge }
141                 ]
142         },
143         "Trees": {
144                 "template": g_Gaia.tree1,
145                 "count": 2
146         },
147         "Decoratives": {
148                 "template": g_Decoratives.rockMedium
149         }
152 addElements([
153         {
154                 "func": addLayeredPatches,
155                 "avoid": [
156                         g_TileClasses.dirt, 5,
157                         g_TileClasses.forest, 2,
158                         g_TileClasses.mountain, 2,
159                         g_TileClasses.player, 12,
160                         g_TileClasses.water, 3,
161                         g_TileClasses.shoreline, 3
162                 ],
163                 "sizes": ["normal"],
164                 "mixes": ["normal"],
165                 "amounts": ["many"]
166         },
167         {
168                 "func": addDecoration,
169                 "avoid": [
170                         g_TileClasses.forest, 2,
171                         g_TileClasses.mountain, 2,
172                         g_TileClasses.player, 12,
173                         g_TileClasses.water, 3,
174                         g_TileClasses.shoreline, 3
175                 ],
176                 "sizes": ["normal"],
177                 "mixes": ["normal"],
178                 "amounts": ["many"]
179         }
182 addElements(shuffleArray([
183         {
184                 "func": addSmallMetal,
185                 "avoid": [
186                         g_TileClasses.berries, 5,
187                         g_TileClasses.forest, 3,
188                         g_TileClasses.mountain, 6,
189                         g_TileClasses.player, 30,
190                         g_TileClasses.rock, 20,
191                         g_TileClasses.metal, 30,
192                         g_TileClasses.water, 3,
193                         g_TileClasses.shoreline, 3
194                 ],
195                 "sizes": ["normal"],
196                 "mixes": ["same"],
197                 "amounts": ["few"]
198         },
199         {
200                 "func": addMetal,
201                 "avoid": [
202                         g_TileClasses.berries, 5,
203                         g_TileClasses.forest, 3,
204                         g_TileClasses.mountain, 6,
205                         g_TileClasses.player, 30,
206                         g_TileClasses.rock, 30,
207                         g_TileClasses.metal, 20,
208                         g_TileClasses.water, 3,
209                         g_TileClasses.shoreline, 3
210                 ],
211                 "sizes": ["normal"],
212                 "mixes": ["same"],
213                 "amounts": ["normal"]
214         },
215         {
216                 "func": addStone,
217                 "avoid": [
218                         g_TileClasses.berries, 5,
219                         g_TileClasses.forest, 3,
220                         g_TileClasses.mountain, 6,
221                         g_TileClasses.player, 30,
222                         g_TileClasses.rock, 30,
223                         g_TileClasses.metal, 20,
224                         g_TileClasses.water, 3,
225                         g_TileClasses.shoreline, 3
226                 ],
227                 "sizes": ["normal"],
228                 "mixes": ["same"],
229                 "amounts": ["normal"]
230         },
231         {
232                 "func": addForests,
233                 "avoid": [
234                         g_TileClasses.berries, 5,
235                         g_TileClasses.forest, 8,
236                         g_TileClasses.metal, 3,
237                         g_TileClasses.mountain, 6,
238                         g_TileClasses.player, 20,
239                         g_TileClasses.rock, 3,
240                         g_TileClasses.water, 2,
241                         g_TileClasses.shoreline, 2
242                 ],
243                 "sizes": ["normal"],
244                 "mixes": ["same"],
245                 "amounts": ["many"]
246         }
247 ]));
249 addElements(shuffleArray([
250         {
251                 "func": addAnimals,
252                 "avoid": [
253                         g_TileClasses.animals, 20,
254                         g_TileClasses.forest, 2,
255                         g_TileClasses.metal, 2,
256                         g_TileClasses.mountain, 6,
257                         g_TileClasses.player, 20,
258                         g_TileClasses.rock, 2,
259                         g_TileClasses.water, 3,
260                         g_TileClasses.shoreline, 3
261                 ],
262                 "sizes": ["huge"],
263                 "mixes": ["similar"],
264                 "amounts": ["tons"]
265         },
266         {
267                 "func": addAnimals,
268                 "avoid": [
269                         g_TileClasses.animals, 20,
270                         g_TileClasses.forest, 2,
271                         g_TileClasses.metal, 2,
272                         g_TileClasses.mountain, 6,
273                         g_TileClasses.player, 20,
274                         g_TileClasses.rock, 2,
275                         g_TileClasses.water, 3,
276                         g_TileClasses.shoreline, 3
277                 ],
278                 "sizes": ["huge"],
279                 "mixes": ["similar"],
280                 "amounts": ["tons"]
281         },
282         {
283                 "func": addBerries,
284                 "avoid": [
285                         g_TileClasses.berries, 30,
286                         g_TileClasses.forest, 5,
287                         g_TileClasses.metal, 10,
288                         g_TileClasses.mountain, 2,
289                         g_TileClasses.player, 20,
290                         g_TileClasses.rock, 10,
291                         g_TileClasses.water, 3,
292                         g_TileClasses.shoreline, 3
293                 ],
294                 "sizes": ["normal"],
295                 "mixes": ["same"],
296                 "amounts": ["many"]
297         },
298         {
299                 "func": addStragglerTrees,
300                 "avoid": [
301                         g_TileClasses.berries, 5,
302                         g_TileClasses.forest, 4,
303                         g_TileClasses.metal, 2,
304                         g_TileClasses.mountain, 6,
305                         g_TileClasses.player, 12,
306                         g_TileClasses.rock, 2,
307                         g_TileClasses.water, 5,
308                         g_TileClasses.shoreline, 3
309                 ],
310                 "sizes": ["normal"],
311                 "mixes": ["same"],
312                 "amounts": ["tons"]
313         }
314 ]));
315 Engine.SetProgress(80);
317 createDecoration(
318         [
319                 [new SimpleObject(g_Decoratives.reeds, 1, 3, 0, 1)],
320                 [new SimpleObject(g_Decoratives.lillies, 1, 2, 0, 1)]
321         ],
322         [
323                 200 * Math.pow(scaleByMapSize(3, 12), 2),
324                 100 * Math.pow(scaleByMapSize(3, 12), 2)
325         ],
326         new HeightConstraint(heightReedsMin, heightShoreline)
328 Engine.SetProgress(90);
330 g_Map.log("Placing fish");
331 addElements([
332         {
333                 "func": addFish,
334                 "avoid": [
335                         g_TileClasses.fish, 10,
336                 ],
337                 "stay": [g_TileClasses.water, 4],
338                 "sizes": ["normal"],
339                 "mixes": ["similar"],
340                 "amounts": ["few"]
341         }
343 Engine.SetProgress(95);
345 placePlayersNomad(
346         g_Map.createTileClass(),
347         [
348                 stayClasses(g_TileClasses.land, 4),
349                 avoidClasses(
350                         g_TileClasses.forest, 1,
351                         g_TileClasses.rock, 4,
352                         g_TileClasses.metal, 4,
353                         g_TileClasses.animals, 1)
354         ]);
356 setSunColor(0.733, 0.746, 0.574);
358 setWaterHeight(20 + heightWaterLevel);
359 setWaterTint(0.224, 0.271, 0.270);
360 setWaterColor(0.224, 0.271, 0.270);
361 setWaterWaviness(8);
362 setWaterMurkiness(0.87);
363 setWaterType("clap");
365 setTerrainAmbientColor(0.521, 0.475, 0.322);
367 setSunRotation(-Math.PI);
368 setSunElevation(Math.PI / 6.25);
370 setFogFactor(0);
371 setFogThickness(0);
372 setFogColor(0.69, 0.616, 0.541);
374 setPPEffect("hdr");
375 setPPContrast(0.67);
376 setPPSaturation(0.42);
377 setPPBloom(0.23);
379 g_Map.ExportMap();