Delete an unneeded initForestFloor found by leper in rP20278.
[0ad.git] / binaries / data / mods / public / maps / random / mediterranean.js
blob6d198935fe29b9b74867036757f9c953a97d6835
1 // Coordinates: 49.665548, 10.541500
2 // Map Width: 5000km
4 RMS.LoadLibrary("rmgen");
5 RMS.LoadLibrary("rmgen2");
6 RMS.LoadLibrary("rmbiome");
8 InitMap();
10 log("Initializing environment...");
11 setBiome("temperate");
12 initTileClasses(["autumn", "desert", "medit", "polar", "steppe", "temp"]);
14 setSunColor(0.733, 0.746, 0.574);
16 setWindAngle(-0.589049);
17 setWaterTint(0.556863, 0.615686, 0.643137);
18 setWaterColor(0.494118, 0.639216, 0.713726);
19 setWaterWaviness(8);
20 setWaterMurkiness(0.87);
21 setWaterType("ocean");
23 setTerrainAmbientColor(0.72, 0.72, 0.82);
25 setSunRotation(PI * 0.95);
26 setSunElevation(PI / 6);
28 setSkySet("cumulus");
29 setFogFactor(0);
30 setFogThickness(0);
31 setFogColor(0.69, 0.616, 0.541);
33 setPPEffect("hdr");
34 setPPContrast(0.67);
35 setPPSaturation(0.42);
36 setPPBloom(0.23);
38 log("Resetting terrain...");
39 resetTerrain(g_Terrains.mainTerrain, g_TileClasses.land, getMapBaseHeight());
40 RMS.SetProgress(10);
42 var biomes = {
43         "autumn": {
44                 // terrains
45                 "mainTerrain": "temp_grass_d_aut",
46                 "forestFloor1": "temp_grass_long_b_aut",
47                 "forestFloor2": "temp_grass_long_b_aut",
48                 "roadWild": "road_rome_a",
49                 "road": "road_muddy",
50                 // gaia
51                 "tree1": "gaia/flora_tree_oak_aut_new",
52                 "tree2": "gaia/flora_tree_oak_dead",
53                 "tree3": "gaia/flora_tree_apple",
54                 "tree4": "gaia/flora_tree_euro_beech_aut",
55                 "tree5": "gaia/flora_tree_pine",
56                 "fruitBush": "gaia/flora_bush_berry",
57                 "mainHuntableAnimal": "gaia/fauna_sheep",
58                 "secondaryHuntableAnimal": "gaia/fauna_wolf",
59                 "stoneLarge": "gaia/geology_stonemine_temperate_quarry",
60                 "stoneSmall": "gaia/geology_stone_temperate",
61                 "metalLarge": "gaia/geology_metal_temperate_slabs",
62                 "metalSmall": "gaia/geology_metal_temperate",
63                 // decoratives
64                 "grass": "actor|props/flora/grass_soft_dry_small.xml",
65                 "grassShort": "actor|props/flora/grass_soft_dry_tuft_a.xml",
66                 "rockLarge": "actor|geology/stone_granite_med.xml",
67                 "rockMedium": "actor|geology/stone_granite_small.xml",
68                 "bushMedium": "actor|props/flora/bush_medit_me_dry.xml",
69                 "bushSmall": "actor|props/flora/bush_medit_sm_dry.xml",
70         },
71         "desert": {
72                 // terrains
73                 "mainTerrain": "sand_scrub_100",
74                 "forestFloor1": "sand_scrub_25",
75                 "forestFloor2": "sand_scrub_25",
76                 "roadWild": "desert_city_tile_pers",
77                 "road": "desert_city_tile_pers_dirt",
78                 // gaia
79                 "tree1": "gaia/flora_tree_cretan_date_palm_short",
80                 "tree2": "gaia/flora_tree_senegal_date_palm",
81                 "tree3": "gaia/flora_tree_date_palm",
82                 "tree4": "gaia/flora_tree_cretan_date_palm_tall",
83                 "tree5": "gaia/flora_tree_date_palm",
84                 "fruitBush": "gaia/flora_bush_grapes",
85                 "mainHuntableAnimal": "gaia/fauna_camel",
86                 "secondaryHuntableAnimal": "gaia/fauna_gazelle",
87                 "stoneLarge": "gaia/geology_stonemine_desert_quarry",
88                 "stoneSmall": "gaia/geology_stone_desert_small",
89                 "metalLarge": "gaia/geology_metal_desert_slabs",
90                 "metalSmall": "gaia/geology_metal_desert_small",
91                 // decoratives
92                 "grass": "actor|props/flora/grass_field_parched_tall.xml",
93                 "grassShort": "actor|props/flora/grass_soft_dry_tuft_a.xml",
94                 "rockLarge": "actor|structures/gravestone.xml",
95                 "rockMedium": "actor|geology/stone_desert_med.xml",
96                 "bushMedium": "actor|props/flora/bush_desert_dry_a.xml",
97                 "bushSmall": "actor|props/flora/plant_desert_a.xml",
98         },
99         "medit": {
100                 // terrains
101                 "mainTerrain": "medit_grass_field_a",
102                 "forestFloor1": "medit_grass_wild",
103                 "forestFloor2": "medit_grass_wild",
104                 "roadWild": "road_rome_a",
105                 "road": "road_muddy",
106                 // gaia
107                 "tree1": "gaia/flora_tree_poplar_lombardy",
108                 "tree2": "gaia/flora_tree_cypress",
109                 "tree3": "gaia/flora_tree_olive",
110                 "tree4": "gaia/flora_tree_carob",
111                 "tree5": "gaia/flora_tree_tamarix",
112                 "fruitBush": "gaia/flora_bush_grapes",
113                 "mainHuntableAnimal": "gaia/fauna_deer",
114                 "secondaryHuntableAnimal": "gaia/fauna_goat",
115                 "stoneLarge": "gaia/geology_stonemine_medit_quarry",
116                 "stoneSmall": "gaia/geology_stone_mediterranean",
117                 "metalLarge": "gaia/geology_metal_mediterranean_slabs",
118                 "metalSmall": "gaia/geology_metal_greek",
119                 // decoratives
120                 "grass": "actor|props/flora/grass_soft_small_tall.xml",
121                 "grassShort": "actor|props/flora/grass_soft_small.xml",
122                 "rockLarge": "actor|geology/stone_granite_greek_large.xml",
123                 "rockMedium": "actor|geology/stone_granite_greek_med.xml",
124                 "bushMedium": "actor|props/flora/bush_medit_underbrush.xml",
125                 "bushSmall": "actor|props/flora/bush_medit_me_lush.xml",
126         },
127         "polar": {
128                 // terrains
129                 "mainTerrain": "polar_tundra_snow",
130                 "forestFloor1": "ice_dirt",
131                 "forestFloor2": "ice_dirt",
132                 "roadWild": "road_flat",
133                 "road": "road1",
134                 // gaia
135                 "tree1": "gaia/flora_tree_pine_w",
136                 "tree2": "gaia/flora_tree_dead",
137                 "tree3": "gaia/flora_tree_dead",
138                 "tree4": "gaia/flora_tree_pine_w",
139                 "tree5": "gaia/flora_tree_pine_w",
140                 "fruitBush": "gaia/fauna_wolf_snow",
141                 "mainHuntableAnimal": "gaia/fauna_muskox",
142                 "secondaryHuntableAnimal": "gaia/fauna_wolf",
143                 "stoneLarge": "gaia/geology_stonemine_alpine_quarry",
144                 "stoneSmall": "gaia/geology_stone_alpine_a",
145                 "metalLarge": "gaia/geology_metal_alpine_slabs",
146                 "metalSmall": "gaia/geology_metal_alpine",
147                 // decoratives
148                 "grass": "actor|props/flora/grass_field_parched_short.xml",
149                 "grassShort": "actor|props/flora/grass_soft_dry_tuft_a.xml",
150                 "rockLarge": "actor|geology/stone_granite_med.xml",
151                 "rockMedium": "actor|geology/stone_granite_small.xml",
152                 "bushMedium": "actor|props/flora/bush_highlands.xml",
153                 "bushSmall": "actor|props/flora/bush_medit_sm.xml",
154         },
155         "steppe": {
156                 // terrains
157                 "mainTerrain": "steppe_grass_a",
158                 "forestFloor1": "steppe_grass_c",
159                 "forestFloor2": "steppe_grass_c",
160                 "roadWild": "road2",
161                 "road": "medit_city_tile_dirt",
162                 // gaia
163                 "tree1": "gaia/flora_tree_poplar",
164                 "tree2": "gaia/flora_tree_toona",
165                 "tree3": "gaia/flora_tree_dead",
166                 "tree4": "gaia/flora_tree_acacia",
167                 "tree5": "gaia/flora_tree_poplar_lombardy",
168                 "fruitBush": "gaia/flora_bush_grapes",
169                 "mainHuntableAnimal": "gaia/fauna_deer",
170                 "secondaryHuntableAnimal": "gaia/fauna_horse",
171                 "stoneLarge": "gaia/geology_stonemine_alpine_quarry",
172                 "stoneSmall": "gaia/geology_stone_alpine_a",
173                 "metalLarge": "gaia/geology_metal_alpine_slabs",
174                 "metalSmall": "gaia/geology_metal_alpine",
175                 // decoratives
176                 "grass": "actor|props/flora/grass_medit_flowering_tall.xml",
177                 "grassShort": "actor|props/flora/grass_field_bloom_short.xml",
178                 "rockLarge": "actor|geology/stone_granite_greek_med.xml",
179                 "rockMedium": "actor|geology/stone_granite_greek_small.xml",
180                 "bushMedium": "actor|props/flora/bush_dry_a.xml",
181                 "bushSmall": "actor|props/flora/bush_highlands.xml",
182         },
183         "temp": {
184                 // terrains
185                 "mainTerrain": "temp_grass_long",
186                 "forestFloor1": "temp_grass_clovers_2",
187                 "forestFloor2": "temp_grass_clovers_2",
188                 "roadWild": "temp_road_overgrown",
189                 "road": "temp_road",
190                 // gaia
191                 "tree1": "gaia/flora_tree_oak_new",
192                 "tree2": "gaia/flora_tree_oak_dead",
193                 "tree3": "gaia/flora_tree_apple",
194                 "tree4": "gaia/flora_tree_euro_beech",
195                 "tree5": "gaia/flora_tree_oak_large",
196                 "fruitBush": "gaia/flora_bush_berry",
197                 "mainHuntableAnimal": "gaia/fauna_pig",
198                 "secondaryHuntableAnimal": "gaia/fauna_boar",
199                 "stoneLarge": "gaia/geology_stonemine_temperate_quarry",
200                 "stoneSmall": "gaia/geology_stone_temperate",
201                 "metalLarge": "gaia/geology_metal_temperate_slabs",
202                 "metalSmall": "gaia/geology_metal_temperate",
203                 // decoratives
204                 "grass": "actor|props/flora/grass_soft_large_tall.xml",
205                 "grassShort": "actor|props/flora/grass_soft_large.xml",
206                 "rockLarge": "actor|geology/stone_granite_large.xml",
207                 "rockMedium": "actor|geology/stone_granite_med.xml",
208                 "bushMedium": "actor|props/flora/bush_tempe_b.xml",
209                 "bushSmall": "actor|props/flora/bush_tempe_underbrush.xml",
210         }
213 log("Copying heightmap...");
214 var scale = paintHeightmap("mediterranean", (tile, x, y) => {
216         if (tile.indexOf("cliff") >= 0)
217                 addToClass(x, y, g_TileClasses.mountain);
219         if (tile.indexOf("desert") >= 0)
220                 addToClass(x, y, g_TileClasses.desert);
222         if (tile.indexOf("medit") >= 0 && tile.indexOf("sand") < 0)
223                 addToClass(x, y, g_TileClasses.medit);
225         if (tile.indexOf("polar") >= 0)
226                 addToClass(x, y, g_TileClasses.polar);
228         if (tile.indexOf("steppe") >= 0)
229                 addToClass(x, y, g_TileClasses.steppe);
231         if (tile.indexOf("temp") >= 0)
232                 addToClass(x, y, g_TileClasses.temp);
234         if (tile.indexOf("aut") >= 0)
235                 addToClass(x, y, g_TileClasses.autumn);
237 RMS.SetProgress(30);
239 log("Rendering water...");
240 paintTileClassBasedOnHeight(-100, -1, 3, g_TileClasses.water);
241 RMS.SetProgress(40);
243 log("Placing player bases...");
244 // Coordinate system of the heightmap
245 var singleBases = [
246         [70,30],
247         [90,180],
248         [270,75],
249         [240,280],
250         [160,180]
253 if (getMapSize() >= 320 || getNumPlayers() > singleBases.length)
254         singleBases.push(
255                 [140,60],
256                 [170,250],
257                 [210, 35],
258                 [300,155],
259                 [50,105]
260         );
262 var strongholdBases = [
263         [110,50],
264         [180,260],
265         [260,55]
268 randomPlayerPlacementAt(getTeamsArray(), singleBases, strongholdBases, scale, 0.06, (tileX, tileY) => {
270         for (let biome in biomes)
271                 if (checkIfInClass(tileX, tileY, g_TileClasses[biome]))
272                 {
273                         setLocalBiome(biomes[biome]);
274                         break;
275                 }
277 RMS.SetProgress(50);
279 function setLocalBiome(b)
281         g_Terrains.mainTerrain = b.mainTerrain;
282         g_Terrains.forestFloor1 = b.forestFloor1;
283         g_Terrains.forestFloor2 = b.forestFloor2;
284         g_Terrains.roadWild = b.roadWild;
285         g_Terrains.road = b.road;
286         g_Gaia.tree1 = b.tree1;
287         g_Gaia.tree2 = b.tree2;
288         g_Gaia.tree3 = b.tree3;
289         g_Gaia.tree4 = b.tree4;
290         g_Gaia.tree5 = b.tree5;
291         g_Gaia.fruitBush = b.fruitBush;
292         g_Gaia.mainHuntableAnimal = b.mainHuntableAnimal;
293         g_Gaia.secondaryHuntableAnimal = b.secondaryHuntableAnimal;
294         g_Gaia.stoneLarge = b.stoneLarge;
295         g_Gaia.stoneSmall = b.stoneSmall;
296         g_Gaia.metalLarge = b.metalLarge;
297         g_Gaia.metalSmall = b.metalSmall;
298         g_Decoratives.grass = b.grass;
299         g_Decoratives.grassShort = b.grassShort;
300         g_Decoratives.rockLarge = b.rockLarge;
301         g_Decoratives.rockMedium = b.rockMedium;
302         g_Decoratives.bushMedium = b.bushMedium;
303         g_Decoratives.bushSmall = b.bushSmall;
306 log("Placing fish...");
307 g_Gaia.fish = "gaia/fauna_fish";
308 addElements([
309         {
310                 "func": addFish,
311                 "avoid": [
312                         g_TileClasses.fish, 10,
313                 ],
314                 "stay": [g_TileClasses.water, 4],
315                 "sizes": ["normal"],
316                 "mixes": ["similar"],
317                 "amounts": ["many"]
318         }
320 RMS.SetProgress(60);
322 log("Placing whale...");
323 g_Gaia.fish = "gaia/fauna_whale_fin";
324 addElements([
325         {
326                 "func": addFish,
327                 "avoid": [
328                         g_TileClasses.fish, 2,
329                         g_TileClasses.desert, 50,
330                         g_TileClasses.steppe, 50
331                 ],
332                 "stay": [g_TileClasses.water, 7],
333                 "sizes": ["normal"],
334                 "mixes": ["same"],
335                 "amounts": ["scarce"]
336         }
338 RMS.SetProgress(70);
340 log("Rendering local biomes...");
341 for (let biome in biomes)
343         setLocalBiome(biomes[biome]);
345         let localAvoid = g_TileClasses[biome == "temp" ? "plateau" : "autumn"];
347         addElements([
348                 {
349                         "func": addMetal,
350                         "avoid": [
351                                 g_TileClasses.berries, 5,
352                                 g_TileClasses.forest, 3,
353                                 g_TileClasses.mountain, 2,
354                                 g_TileClasses.player, 30,
355                                 g_TileClasses.rock, 10,
356                                 g_TileClasses.metal, 25,
357                                 g_TileClasses.water, 4,
358                                 localAvoid, 2
359                         ],
360                         "stay": [g_TileClasses[biome], 0],
361                         "sizes": ["normal"],
362                         "mixes": ["same"],
363                         "amounts": ["many"]
364                 },
365                 {
366                         "func": addStone,
367                         "avoid": [
368                                 g_TileClasses.berries, 5,
369                                 g_TileClasses.forest, 3,
370                                 g_TileClasses.mountain, 2,
371                                 g_TileClasses.player, 30,
372                                 g_TileClasses.rock, 10,
373                                 g_TileClasses.metal, 25,
374                                 g_TileClasses.water, 4,
375                                 localAvoid, 2
376                         ],
377                         "stay": [g_TileClasses[biome], 0],
378                         "sizes": ["normal"],
379                         "mixes": ["same"],
380                         "amounts": ["many"]
381                 },
382                 {
383                         "func": addForests,
384                         "avoid": [
385                                 g_TileClasses.berries, 3,
386                                 g_TileClasses.forest, 15,
387                                 g_TileClasses.metal, 3,
388                                 g_TileClasses.mountain, 2,
389                                 g_TileClasses.player, 12,
390                                 g_TileClasses.rock, 2,
391                                 g_TileClasses.water, 2,
392                                 localAvoid, 2
393                         ],
394                         "stay": [g_TileClasses[biome], 0],
395                         "sizes": ["normal"],
396                         "mixes": ["normal"],
397                         "amounts": ["normal"]
398                 },
399                 {
400                         "func": addSmallMetal,
401                         "avoid": [
402                                 g_TileClasses.berries, 5,
403                                 g_TileClasses.forest, 3,
404                                 g_TileClasses.mountain, 2,
405                                 g_TileClasses.player, 30,
406                                 g_TileClasses.rock, 10,
407                                 g_TileClasses.metal, 15,
408                                 g_TileClasses.water, 4,
409                                 localAvoid, 2
410                         ],
411                         "stay": [g_TileClasses[biome], 0],
412                         "sizes": ["normal"],
413                         "mixes": ["same"],
414                         "amounts": ["few", "normal", "many"]
415                 },
416                 {
417                         "func": addBerries,
418                         "avoid": [
419                                 g_TileClasses.berries, 30,
420                                 g_TileClasses.forest, 2,
421                                 g_TileClasses.metal, 4,
422                                 g_TileClasses.mountain, 2,
423                                 g_TileClasses.player, 20,
424                                 g_TileClasses.rock, 4,
425                                 g_TileClasses.water, 2,
426                                 localAvoid, 2
427                         ],
428                         "stay": [g_TileClasses[biome], 0],
429                         "sizes": ["normal"],
430                         "mixes": ["normal"],
431                         "amounts": ["tons"]
432                 },
433                 {
434                         "func": addAnimals,
435                         "avoid": [
436                                 g_TileClasses.animals, 10,
437                                 g_TileClasses.forest, 1,
438                                 g_TileClasses.metal, 2,
439                                 g_TileClasses.mountain, 1,
440                                 g_TileClasses.player, 15,
441                                 g_TileClasses.rock, 2,
442                                 g_TileClasses.water, 1,
443                                 localAvoid, 2
444                         ],
445                         "stay": [g_TileClasses[biome], 0],
446                         "sizes": ["normal"],
447                         "mixes": ["normal"],
448                         "amounts": ["tons"]
449                 },
450                                 {
451                         "func": addAnimals,
452                         "avoid": [
453                                 g_TileClasses.animals, 10,
454                                 g_TileClasses.forest, 1,
455                                 g_TileClasses.metal, 2,
456                                 g_TileClasses.mountain, 1,
457                                 g_TileClasses.player, 15,
458                                 g_TileClasses.rock, 2,
459                                 g_TileClasses.water, 1,
460                                 localAvoid, 2
461                         ],
462                         "stay": [g_TileClasses[biome], 0],
463                         "sizes": ["small"],
464                         "mixes": ["normal"],
465                         "amounts": ["tons"]
466                 },
467                 {
468                         "func": addStragglerTrees,
469                         "avoid": [
470                                 g_TileClasses.berries, 5,
471                                 g_TileClasses.forest, 5,
472                                 g_TileClasses.metal, 2,
473                                 g_TileClasses.mountain, 1,
474                                 g_TileClasses.player, 12,
475                                 g_TileClasses.rock, 2,
476                                 g_TileClasses.water, 3,
477                                 localAvoid, 2
478                         ],
479                         "stay": [g_TileClasses[biome], 0],
480                         "sizes": ["normal"],
481                         "mixes": ["normal"],
482                         "amounts": ["some"]
483                 },
484                 {
485                         "func": addDecoration,
486                         "avoid": [
487                                 g_TileClasses.forest, 2,
488                                 g_TileClasses.mountain, 2,
489                                 g_TileClasses.player, 12,
490                                 g_TileClasses.water, 4,
491                                 localAvoid, 2
492                         ],
493                         "stay": [g_TileClasses[biome], 0],
494                         "sizes": ["small"],
495                         "mixes": ["same"],
496                         "amounts": ["normal"]
497                 }
498         ]);
500 RMS.SetProgress(90);
502 ExportMap();