Merge 'remotes/trunk'
[0ad.git] / binaries / data / mods / public / maps / random / aegean_sea.js
blob8748fa124a45ee7bc709dd5eb15810028681162b
1 Engine.LoadLibrary("rmgen");
2 Engine.LoadLibrary("rmgen-common");
4 function* GenerateMap()
6         TILE_CENTERED_HEIGHT_MAP = true;
8         const tCity = "medit_city_pavement";
9         const tCityPlaza = "medit_city_pavement";
10         const tHill = [
11                 "medit_grass_shrubs",
12                 "medit_rocks_grass_shrubs",
13                 "medit_rocks_shrubs",
14                 "medit_rocks_grass",
15                 "medit_shrubs"
16         ];
17         const tMainDirt = "medit_dirt";
18         const tCliff = "medit_cliff_aegean";
19         const tForestFloor = "medit_grass_shrubs";
20         const tGrass = "medit_grass_field";
21         const tGrassSand50 = "medit_grass_field_a";
22         const tGrassSand25 = "medit_grass_field_b";
23         const tDirt = "medit_dirt_b";
24         const tDirt2 = "medit_rocks_grass";
25         const tDirt3 = "medit_rocks_shrubs";
26         const tDirtCracks = "medit_dirt_c";
27         const tShoreUpper = "medit_sand";
28         const tShoreLower = "medit_sand_wet";
29         const tCoralsUpper = "medit_sea_coral_plants";
30         const tCoralsLower = "medit_sea_coral_deep";
31         const tSeaDepths = "medit_sea_depths";
33         const oBerryBush = "gaia/fruit/berry_01";
34         const oDeer = "gaia/fauna_deer";
35         const oFish = "gaia/fish/generic";
36         const oSheep = "gaia/fauna_sheep";
37         const oGoat = "gaia/fauna_goat";
38         const oStoneLarge = "gaia/rock/mediterranean_large";
39         const oStoneSmall = "gaia/rock/mediterranean_small";
40         const oMetalLarge = "gaia/ore/mediterranean_large";
41         const oDatePalm = "gaia/tree/cretan_date_palm_short";
42         const oSDatePalm = "gaia/tree/cretan_date_palm_tall";
43         const oCarob = "gaia/tree/carob";
44         const oFanPalm = "gaia/tree/medit_fan_palm";
45         const oPoplar = "gaia/tree/poplar_lombardy";
46         const oCypress = "gaia/tree/cypress";
48         const aBush1 = "actor|props/flora/bush_medit_sm.xml";
49         const aBush2 = "actor|props/flora/bush_medit_me.xml";
50         const aBush3 = "actor|props/flora/bush_medit_la.xml";
51         const aBush4 = "actor|props/flora/bush_medit_me.xml";
52         const aDecorativeRock = "actor|geology/stone_granite_med.xml";
54         const pForest = [
55                 tForestFloor,
56                 tForestFloor + TERRAIN_SEPARATOR + oCarob,
57                 tForestFloor + TERRAIN_SEPARATOR + oDatePalm,
58                 tForestFloor + TERRAIN_SEPARATOR + oSDatePalm,
59                 tForestFloor
60         ];
62         const heightSeaGround = -3;
63         const heightSeaBump = -2.5;
64         const heightCorralsLower = -2;
65         const heightCorralsUpper = -1.5;
66         const heightShore = 1;
67         const heightLand = 2;
68         const heightIsland = 6;
70         globalThis.g_Map = new RandomMap(heightShore, tHill);
72         const numPlayers = getNumPlayers();
73         const mapCenter = g_Map.getCenter();
74         const mapBounds = g_Map.getBounds();
76         const clPlayer = g_Map.createTileClass();
77         const clForest = g_Map.createTileClass();
78         const clWater = g_Map.createTileClass();
79         const clDirt = g_Map.createTileClass();
80         const clRock = g_Map.createTileClass();
81         const clMetal = g_Map.createTileClass();
82         const clFood = g_Map.createTileClass();
83         const clBaseResource = g_Map.createTileClass();
84         const clGrass = g_Map.createTileClass();
85         const clHill = g_Map.createTileClass();
86         const clIsland = g_Map.createTileClass();
88         const startAngle = randomAngle();
90         placePlayerBases({
91                 "PlayerPlacement": playerPlacementRiver(startAngle, fractionToTiles(0.6)),
92                 "PlayerTileClass": clPlayer,
93                 "BaseResourceClass": clBaseResource,
94                 "CityPatch": {
95                         "outerTerrain": tCityPlaza,
96                         "innerTerrain": tCity
97                 },
98                 "StartingAnimal": {
99                 },
100                 "Berries": {
101                         "template": oBerryBush
102                 },
103                 "Mines": {
104                         "types": [
105                                 { "template": oMetalLarge },
106                                 { "template": oStoneLarge }
107                         ]
108                 },
109                 "Trees": {
110                         "template": oCarob,
111                         "count": 2
112                 },
113                 "Decoratives": {
114                         "template": aBush1
115                 }
116         });
117         yield 30;
119         paintRiver({
120                 "parallel": false,
121                 "start": new Vector2D(mapCenter.x, mapBounds.top).rotateAround(startAngle, mapCenter),
122                 "end": new Vector2D(mapCenter.x, mapBounds.bottom).rotateAround(startAngle, mapCenter),
123                 "width": fractionToTiles(0.35),
124                 "fadeDist": scaleByMapSize(6, 25),
125                 "deviation": 0,
126                 "heightRiverbed": heightSeaGround,
127                 "heightLand": heightLand,
128                 "meanderShort": 20,
129                 "meanderLong": 0
130         });
132         paintTileClassBasedOnHeight(-Infinity, 0.7, Elevation_ExcludeMin_ExcludeMax, clWater);
134         paintTerrainBasedOnHeight(-Infinity, heightShore, Elevation_ExcludeMin_ExcludeMax, tShoreLower);
135         paintTerrainBasedOnHeight(heightShore, heightLand, Elevation_ExcludeMin_ExcludeMax, tShoreUpper);
136         yield 40;
138         createBumps(avoidClasses(clWater, 2, clPlayer, 20));
140         const [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7);
141         createForests(
142                 [tForestFloor, tForestFloor, tForestFloor, pForest, pForest],
143                 avoidClasses(clPlayer, 20, clForest, 17, clWater, 2, clBaseResource, 3),
144                 clForest,
145                 forestTrees);
147         yield 50;
149         if (randBool())
150                 createHills([tGrass, tCliff, tHill],
151                         avoidClasses(clPlayer, 20, clForest, 1, clHill, 15, clWater, 3),
152                         clHill,
153                         scaleByMapSize(3, 15));
154         else
155                 createMountains(tCliff,
156                         avoidClasses(clPlayer, 20, clForest, 1, clHill, 15, clWater, 3),
157                         clHill,
158                         scaleByMapSize(3, 15));
160         g_Map.log("Creating grass patches");
161         createLayeredPatches(
162                 [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
163                 [[tGrass, tGrassSand50], [tGrassSand50, tGrassSand25], [tGrassSand25, tGrass]],
164                 [1, 1],
165                 avoidClasses(clForest, 0, clGrass, 2, clPlayer, 10, clWater, 2, clDirt, 2, clHill, 1),
166                 scaleByMapSize(15, 45),
167                 clDirt);
169         yield 55;
171         g_Map.log("Creating dirt patches");
172         createLayeredPatches(
173                 [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
174                 [tDirt3, tDirt2, [tDirt, tMainDirt], [tDirtCracks, tMainDirt]],
175                 [1, 1, 1],
176                 avoidClasses(clForest, 0, clDirt, 2, clPlayer, 10, clWater, 2, clGrass, 2, clHill, 1),
177                 scaleByMapSize(15, 45),
178                 clDirt);
180         yield 60;
182         g_Map.log("Creating undersea bumps");
183         createAreas(
184                 new ChainPlacer(1, Math.floor(scaleByMapSize(4, 6)), Math.floor(scaleByMapSize(16, 40)), 0.5),
185                 new SmoothElevationPainter(ELEVATION_SET, heightSeaBump, 3),
186                 stayClasses(clWater, 6),
187                 scaleByMapSize(10, 50));
189         g_Map.log("Creating islands");
190         createAreas(
191                 new ChainPlacer(1, Math.floor(scaleByMapSize(4, 6)), Math.floor(scaleByMapSize(30, 80)), 0.5),
192                 [
193                         new LayeredPainter([tShoreLower, tShoreUpper, tHill], [2, 1]),
194                         new SmoothElevationPainter(ELEVATION_SET, heightIsland, 4),
195                         new TileClassPainter(clIsland)
196                 ],
197                 [avoidClasses(clPlayer, 8, clForest, 1, clIsland, 15), stayClasses (clWater, 6)],
198                 scaleByMapSize(1, 4) * numPlayers
199         );
201         paintTerrainBasedOnHeight(-Infinity, heightSeaGround, Elevation_IncludeMin_IncludeMax, tSeaDepths);
202         paintTerrainBasedOnHeight(heightSeaGround, heightCorralsLower, Elevation_ExcludeMin_IncludeMax,
203                 tCoralsLower);
204         paintTerrainBasedOnHeight(heightCorralsLower, heightCorralsUpper, Elevation_ExcludeMin_IncludeMax,
205                 tCoralsUpper);
207         g_Map.log("Creating island stone mines");
208         createMines(
209                 [
210                         [
211                                 new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1),
212                                 new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)
213                         ],
214                         [new SimpleObject(oStoneSmall, 2, 5, 1, 3)]
215                 ],
216                 stayClasses(clIsland, 4),
217                 clRock);
219         g_Map.log("Creating island metal mines");
220         createMines(
221                 [
222                         [new SimpleObject(oMetalLarge, 1, 1, 0, 4)]
223                 ],
224                 stayClasses(clIsland, 4),
225                 clMetal
226         );
228         g_Map.log("Creating stone mines");
229         createMines(
230                 [
231                         [
232                                 new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1),
233                                 new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)
234                         ],
235                         [new SimpleObject(oStoneSmall, 2, 5, 1, 3)]
236                 ],
237                 avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clWater, 1, clHill, 1),
238                 clRock);
240         g_Map.log("Creating metal mines");
241         createMines(
242                 [
243                         [new SimpleObject(oMetalLarge, 1, 1, 0, 4)]
244                 ],
245                 avoidClasses(clForest, 1, clPlayer, 20, clMetal, 10, clRock, 5, clWater, 1, clHill, 1),
246                 clMetal
247         );
249         yield 65;
251         createDecoration(
252                 [
253                         [
254                                 new SimpleObject(aDecorativeRock, 1, 3, 0, 1)
255                         ],
256                         [
257                                 new SimpleObject(aBush2, 1, 2, 0, 1),
258                                 new SimpleObject(aBush1, 1, 3, 0, 2),
259                                 new SimpleObject(aBush4, 1, 2, 0, 1),
260                                 new SimpleObject(aBush3, 1, 3, 0, 2)
261                         ]
262                 ],
263                 [
264                         scaleByMapAreaAbsolute(16),
265                         scaleByMapSize(40, 360)
266                 ],
267                 avoidClasses(clWater, 2, clForest, 0, clPlayer, 0, clHill, 1));
269         yield 70;
271         createFood(
272                 [
273                         [new SimpleObject(oFish, 2, 3, 0, 2)]
274                 ],
275                 [
276                         3 * scaleByMapSize(5, 20)
277                 ],
278                 [avoidClasses(clIsland, 2, clFood, 10), stayClasses(clWater, 5)],
279                 clFood);
281         createFood(
282                 [
283                         [new SimpleObject(oSheep, 5, 7, 0, 4)],
284                         [new SimpleObject(oGoat, 2, 4, 0, 3)],
285                         [new SimpleObject(oDeer, 2, 4, 0, 2)]
286                 ],
287                 [
288                         scaleByMapSize(5, 20),
289                         scaleByMapSize(5, 20),
290                         scaleByMapSize(5, 20)
291                 ],
292                 avoidClasses(clForest, 0, clPlayer, 8, clBaseResource, 4, clWater, 1, clFood, 10, clHill, 1),
293                 clFood);
295         createFood(
296                 [
297                         [new SimpleObject(oBerryBush, 5, 7, 0, 4)]
298                 ],
299                 [
300                         3 * numPlayers
301                 ],
302                 avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10),
303                 clFood);
305         yield 90;
307         const types = [oDatePalm, oSDatePalm, oCarob, oFanPalm, oPoplar, oCypress];
308         createStragglerTrees(
309                 types,
310                 avoidClasses(clForest, 1, clWater, 2, clPlayer, 12, clMetal, 6, clHill, 1),
311                 clForest,
312                 stragglerTrees);
314         createStragglerTrees(
315                 types,
316                 stayClasses(clIsland, 4),
317                 clForest,
318                 stragglerTrees * 10);
320         placePlayersNomad(clPlayer,
321                 avoidClasses(
322                         clWater, 4,
323                         clIsland, 10,
324                         clForest, 1,
325                         clMetal, 4,
326                         clRock, 4,
327                         clHill, 4,
328                         clFood, 2));
330         setSkySet("cumulus");
331         setSunColor(0.866667, 0.776471, 0.486275);
332         setWaterColor(0, 0.501961, 1);
333         setWaterTint(0.501961, 1, 1);
334         setWaterWaviness(4.0);
335         setWaterType("ocean");
336         setWaterMurkiness(0.49);
338         setFogFactor(0.3);
339         setFogThickness(0.25);
341         setPPEffect("hdr");
342         setPPContrast(0.62);
343         setPPSaturation(0.51);
344         setPPBloom(0.12);
346         return g_Map;