Unify Caledonian Meadows and Wild Lake player location duplication from rP19704 ...
[0ad.git] / binaries / data / mods / public / maps / random / extinct_volcano.js
blobd6b40e6cd289d13a7953414fb990298bb1d432c8
1 RMS.LoadLibrary("rmgen");
3 const tHillDark = "cliff volcanic light";
4 const tHillMedium1 = "ocean_rock_a";
5 const tHillMedium2 = "ocean_rock_b";
6 const tHillVeryDark = ["cliff volcanic coarse", "cave_walls"];
7 const tRoad = "road1";
8 const tRoadWild = "road1";
9 const tForestFloor1 = tHillMedium1;
10 const tForestFloor2 = tHillMedium2;
11 const tGrassA = "cliff volcanic light";
12 const tGrassB = "ocean_rock_a";
13 const tGrassPatchBlend = "temp_grass_long_b";
14 const tGrassPatch = ["temp_grass_d", "temp_grass_clovers"];
15 const tShoreBlend = "cliff volcanic light";
16 const tShore = "ocean_rock_a";
17 const tWater = "ocean_rock_b";
19 // Gaia entities
20 const oTree = "gaia/flora_tree_dead";
21 const oTree2 = "gaia/flora_tree_euro_beech";
22 const oTree3 = "gaia/flora_tree_oak";
23 const oTree4 = "gaia/flora_tree_oak_dead";
24 const oBush = "gaia/flora_bush_temperate";
25 const oFruitBush = "gaia/flora_bush_berry";
26 const oRabbit = "gaia/fauna_rabbit";
27 const oGoat = "gaia/fauna_goat";
28 const oBear = "gaia/fauna_bear";
29 const oStoneLarge = "gaia/geology_stonemine_temperate_quarry";
30 const oStoneSmall = "gaia/geology_stone_temperate";
31 const oMetalLarge = "gaia/geology_metal_temperate_slabs";
32 const oTower = "other/palisades_rocks_fort";
34 // Decorative props
35 const aRockLarge = "actor|geology/stone_granite_med.xml";
36 const aRockMedium = "actor|geology/stone_granite_med.xml";
37 const aBushMedium = "actor|props/flora/bush_tempe_me.xml";
38 const aBushSmall = "actor|props/flora/bush_tempe_sm.xml";
39 const aGrass = "actor|props/flora/grass_soft_large_tall.xml";
40 const aGrassShort = "actor|props/flora/grass_soft_large.xml";
41 const aRain = "actor|particle/rain_shower.xml";
43 const pForestD = [
44         tForestFloor1 + TERRAIN_SEPARATOR + oTree,
45         tForestFloor2 + TERRAIN_SEPARATOR + oTree2,
46         tForestFloor1
49 const pForestP = [
50         tForestFloor1 + TERRAIN_SEPARATOR + oTree3,
51         tForestFloor2 + TERRAIN_SEPARATOR + oTree4,
52         tForestFloor1
55 InitMap();
57 var numPlayers = getNumPlayers();
59 var clPlayer = createTileClass();
60 var clHill = createTileClass();
61 var clFood = createTileClass();
62 var clForest = createTileClass();
63 var clWater = createTileClass();
64 var clDirt = createTileClass();
65 var clGrass = createTileClass();
66 var clRock = createTileClass();
67 var clMetal = createTileClass();
68 var clBaseResource = createTileClass();
69 var clBumps = createTileClass();
70 var clTower = createTileClass();
71 var clRain = createTileClass();
73 var ccMountainHeight = 25;
75 var [playerIDs, playerX, playerZ] = radialPlayerPlacement();
77 for (let i = 0; i < numPlayers; ++i)
79         let id = playerIDs[i];
80         log("Creating base for player " + id + "...");
81         let radius = scaleByMapSize(15, 25);
83         let fx = fractionToTiles(playerX[i]);
84         let fz = fractionToTiles(playerZ[i]);
85         let ix = Math.round(fx);
86         let iz = Math.round(fz);
88         // This one consists of many bumps, creating an omnidirectional ramp
89         createMountain(
90                 ccMountainHeight,
91                 Math.floor(scaleByMapSize(15, 15)),
92                 Math.floor(scaleByMapSize(15, 15)),
93                 Math.floor(scaleByMapSize(4, 10)),
94                 avoidClasses(),
95                 ix,
96                 iz,
97                 tHillDark,
98                 clPlayer,
99                 14);
101         // Flatten the initial CC area
102         let hillSize = PI * radius * radius;
103         createArea(
104                 new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz),
105                 [
106                         new LayeredPainter([tHillVeryDark, tHillMedium1], [radius]),
107                         new SmoothElevationPainter(ELEVATION_SET, ccMountainHeight, radius),
108                         paintClass(clPlayer)
109                 ],
110                 null);
112         // Create the city patch
113         let cityRadius = radius / 3;
114         createArea(
115                 new ClumpPlacer(PI * cityRadius * cityRadius, 0.6, 0.3, 10, ix, iz),
116                 new LayeredPainter([tRoadWild, tRoad], [1]),
117                 null);
119         placeCivDefaultEntities(fx, fz, id, { 'iberWall': 'towers' });
121         // Create metal mine
122         let mAngle = randFloat(0, 2 * PI);
123         let mDist = 12;
124         createObjectGroup(
125                 new SimpleGroup(
126                         [new SimpleObject(oMetalLarge, 1, 1, 0, 0)],
127                         true,
128                         clBaseResource,
129                         Math.round(fx + mDist * Math.cos(mAngle)),
130                         Math.round(fz + mDist * Math.sin(mAngle))),
131                 0);
133         // Create stone mines
134         mAngle += randFloat(PI/4, PI/3);
135         createObjectGroup(
136                 new SimpleGroup(
137                         [new SimpleObject(oStoneLarge, 1, 1, 0, 2)],
138                         true,
139                         clBaseResource,
140                         Math.round(fx + mDist * Math.cos(mAngle)),
141                         Math.round(fz + mDist * Math.sin(mAngle))),
142                 0);
144         placeDefaultChicken(fx, fz, clBaseResource);
146         // Create berry bushes
147         mAngle += randFloat(PI/4, PI/2);
148         let bbDist = 12;
149         createObjectGroup(
150                 new SimpleGroup(
151                         [new SimpleObject(oFruitBush, 5, 5, 0, 3)],
152                         true,
153                         clBaseResource,
154                         Math.round(fx + bbDist * Math.cos(mAngle)),
155                         Math.round(fz + bbDist * Math.sin(mAngle))),
156                 0);
158         // Create starting trees
159         let num = Math.floor(hillSize / 60);
160         let tries = 20;
161         for (let x = 0; x < tries; ++x)
162         {
163                 let tAngle = randFloat(0, 2 * PI);
164                 let tDist = randFloat(10, 12);
165                 if (createObjectGroup(
166                         new SimpleGroup(
167                                 [new SimpleObject(oTree2, num, num, 0, 3)],
168                                 false,
169                                 clBaseResource,
170                                 Math.round(fx + tDist * Math.cos(tAngle)),
171                                 Math.round(fz + tDist * Math.sin(tAngle))),
172                         0,
173                         avoidClasses(clBaseResource, 3)))
174                 {
175                         break;
176                 }
177         }
179 RMS.SetProgress(15);
181 createVolcano(0.5, 0.5, clHill, tHillVeryDark, undefined, false, ELEVATION_SET);
182 RMS.SetProgress(20);
184 log("Creating lakes...");
185 createAreas(
186         new ChainPlacer(5, 6, Math.floor(scaleByMapSize(10, 14)), 0.1),
187         [
188                 new LayeredPainter([tShoreBlend, tShore, tWater], [1, 1]),
189                 new SmoothElevationPainter(ELEVATION_SET, -4, 3),
190                 paintClass(clWater)
191         ],
192         avoidClasses(clPlayer, 0, clHill, 2, clWater, 12),
193         Math.round(scaleByMapSize(6, 12)));
194 RMS.SetProgress(25);
196 createBumps(avoidClasses(clPlayer, 0, clHill, 0), scaleByMapSize(50, 300), 1, 10, 3, 0, scaleByMapSize(4, 10));
197 paintTileClassBasedOnHeight(10, 100, 0, clBumps);
198 RMS.SetProgress(30);
200 log("Creating hills...");
201 createAreas(
202         new ClumpPlacer(scaleByMapSize(20, 150), 0.2, 0.1, 1),
203         [
204                 new LayeredPainter([tHillDark, tHillDark, tHillDark], [2, 2]),
205                 new SmoothElevationPainter(ELEVATION_SET, 18, 2),
206                 paintClass(clHill)
207         ],
208         avoidClasses(clPlayer, 0, clHill, 15, clWater, 2, clBaseResource, 2),
209         scaleByMapSize(2, 8) * numPlayers);
210 RMS.SetProgress(35);
212 log("Creating forests...");
213 var [forestTrees, stragglerTrees] = getTreeCounts(1200, 3000, 0.7);
214 var types = [
215         [[tGrassB, tGrassA, pForestD], [tGrassB, pForestD]],
216         [[tGrassB, tGrassA, pForestP], [tGrassB, pForestP]]
218 var size = forestTrees / (scaleByMapSize(4, 12) * numPlayers);
219 var num = Math.floor(size / types.length);
220 for (let type of types)
221         createAreas(
222                 new ClumpPlacer(forestTrees / num, 0.1, 0.1, 1),
223                 [
224                         new LayeredPainter(type, [2]),
225                         paintClass(clForest)
226                 ],
227                 avoidClasses(
228                         clPlayer, 4,
229                         clForest, 10,
230                         clHill, 0,
231                         clWater, 2),
232                 num);
233 RMS.SetProgress(40);
235 log("Creating hill patches...");
236 for (let size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)])
237         for (let type of [[tHillMedium1, tHillDark], [tHillDark, tHillMedium2], [tHillMedium1, tHillMedium2]])
238                 createAreas(
239                         new ClumpPlacer(size, 0.3, 0.06, 0.5),
240                         [
241                                 new LayeredPainter(type, [1]),
242                                 paintClass(clGrass)
243                         ],
244                         avoidClasses(
245                                 clWater, 3,
246                                 clForest, 0,
247                                 clHill, 0,
248                                 clBumps, 0,
249                                 clPlayer, 0),
250                         scaleByMapSize(20, 80));
251 RMS.SetProgress(45);
253 log("Creating grass patches...");
254 createLayeredPatches(
255         [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
256         [tGrassPatchBlend, tGrassPatch],
257         [1],
258         avoidClasses(
259                 clWater, 1,
260                 clForest, 0,
261                 clHill, 0,
262                 clGrass, 5,
263                 clBumps, 0,
264                 clPlayer, 0),
265         scaleByMapSize(3, 8),
266         clDirt);
267 RMS.SetProgress(50);
269 log("Creating stone mines...");
270 createObjectGroupsDeprecated(
271         new SimpleGroup(
272                 [
273                         new SimpleObject(oStoneSmall, 0, 2, 0, 4),
274                         new SimpleObject(oStoneLarge, 1, 1, 0, 4)
275                 ],
276                 true,
277                 clRock),
278         0,
279         [
280                 stayClasses(clBumps, 1),
281                 avoidClasses(
282                         clWater, 3,
283                         clForest, 1,
284                         clPlayer, 0,
285                         clRock, 15,
286                         clHill, 0)
287         ],
288         100,
289         100);
290 RMS.SetProgress(55);
292 log("Creating small stone quarries...");
293 createObjectGroupsDeprecated(
294         new SimpleGroup([new SimpleObject(oStoneSmall, 2, 5, 1, 3)], true, clRock),
295         0,
296         [
297                 stayClasses(clBumps, 1),
298                 avoidClasses(
299                         clWater, 3,
300                         clForest, 1,
301                         clPlayer, 0,
302                         clRock, 15,
303                         clHill, 0)
304         ],
305         100,
306         100);
307 RMS.SetProgress(60);
309 log("Creating metal mines...");
310 createObjectGroupsDeprecated(
311         new SimpleGroup([new SimpleObject(oMetalLarge, 1, 1, 0, 4)], true, clMetal),
312         0,
313         [
314                 stayClasses(clBumps, 1),
315                 avoidClasses(
316                         clWater, 3,
317                         clForest, 1,
318                         clPlayer, 0,
319                         clMetal, 15,
320                         clRock, 10,
321                         clHill, 0)
322         ],
323         100,
324         100);
325 RMS.SetProgress(65);
327 log("Creating towers...");
328 createObjectGroupsDeprecated(
329         new SimpleGroup([new SimpleObject(oTower, 1, 1, 0, 4)], true, clTower),
330         0,
331         [
332                 stayClasses(clBumps, 3),
333                 avoidClasses(
334                         clMetal, 5,
335                         clRock, 5,
336                         clHill, 0,
337                         clTower, 60,
338                         clPlayer, 10,
339                         clForest, 2)
340         ],
341         500,
342         1);
343 RMS.SetProgress(67);
345 createDecoration(
346                 [
347                         [new SimpleObject(aGrassShort, 1, 2, 0, 1)],
348                         [
349                                 new SimpleObject(aGrass, 2, 4, 0, 1.8),
350                                 new SimpleObject(aGrassShort, 3, 6, 1.2, 2.5)
351                         ],
352                         [
353                                 new SimpleObject(aBushMedium, 1, 2, 0, 2),
354                                 new SimpleObject(aBushSmall, 2, 4, 0, 2)
355                         ]
356                 ],
357                 [
358                         scaleByMapSize(15, 200),
359                         scaleByMapSize(15, 200),
360                         scaleByMapSize(15, 200)
361                 ],
362                 [
363                         stayClasses(clGrass, 0),
364                         avoidClasses(
365                                 clWater, 0,
366                                 clForest, 0,
367                                 clPlayer, 0,
368                                 clHill, 0)
369                 ]);
370 RMS.SetProgress(70);
372 createDecoration(
373                 [
374                         [
375                                 new SimpleObject(aRockMedium, 1, 3, 0, 1)
376                         ],
377                         [
378                                 new SimpleObject(aRockLarge, 1, 2, 0, 1),
379                                 new SimpleObject(aRockMedium, 1, 3, 0, 2)
380                         ]
381                 ],
382                 [
383                         scaleByMapSize(15, 250),
384                         scaleByMapSize(15, 150)
385                 ],
386                 avoidClasses(
387                         clWater, 0,
388                         clForest, 0,
389                         clPlayer, 0,
390                         clHill, 0
391                 ));
392 RMS.SetProgress(75);
394 createFood(
395         [
396                 [new SimpleObject(oRabbit, 5, 7, 2, 4)],
397                 [new SimpleObject(oGoat, 3, 5, 2, 4)]
398         ],
399         [
400                 scaleByMapSize(1, 6) * numPlayers,
401                 scaleByMapSize(3, 10) * numPlayers
402         ],
403         [
404                 avoidClasses(
405                         clWater, 1,
406                         clForest, 0,
407                         clPlayer, 0,
408                         clHill, 1,
409                         clFood, 20)
410         ],
411         clFood);
412 RMS.SetProgress(78);
414 createFood(
415         [
416                 [new SimpleObject(oBear, 1, 1, 0, 2)]
417         ],
418         [
419                 3 * numPlayers
420         ],
421         [
422                 avoidClasses(
423                         clWater, 1,
424                         clForest, 0,
425                         clPlayer, 0,
426                         clHill, 1,
427                         clFood, 20
428                 ),
429                 stayClasses(clForest, 2)
430         ],
431         clFood);
432 RMS.SetProgress(81);
434 createFood(
435         [
436                 [new SimpleObject(oFruitBush, 1, 2, 0, 4)]
437         ],
438         [
439                 3 * numPlayers
440         ],
441         [stayClasses(clGrass, 1), avoidClasses(clWater, 1, clForest, 0, clPlayer, 0, clHill, 1, clFood, 10)],
442         clFood);
443 RMS.SetProgress(85);
445 createStragglerTrees(
446         [oTree, oTree2, oTree3, oTree4, oBush],
447         [
448                 stayClasses(clGrass, 1),
449                 avoidClasses(
450                         clWater, 5,
451                         clForest, 1,
452                         clHill, 1,
453                         clPlayer, 0,
454                         clMetal, 1,
455                         clRock, 1)
456         ],
457         clForest,
458         stragglerTrees);
460 RMS.SetProgress(90);
462 log("Creating straggler bushes...");
463 createObjectGroupsDeprecated(
464         new SimpleGroup(
465                 [new SimpleObject(oBush, 1, 3, 0, 3)],
466                 true,
467                 clForest
468         ),
469         0,
470         [
471                 stayClasses(clGrass, 3),
472                 avoidClasses(
473                         clWater, 1,
474                         clForest, 1,
475                         clPlayer, 0,
476                         clMetal, 1,
477                         clRock, 1)
478         ],
479         stragglerTrees);
480 RMS.SetProgress(95);
482 log("Creating rain drops...");
483 createObjectGroupsDeprecated(
484         new SimpleGroup(
485                 [new SimpleObject(aRain, 2, 2, 1, 4)],
486                 true,
487                 clRain),
488         0,
489         avoidClasses(clRain, 5),
490         scaleByMapSize(80, 250));
491 RMS.SetProgress(95);
493 setSkySet("rain");
494 setWaterType("lake");
495 setWaterWaviness(2);
496 setWaterColor(0.1, 0.13, 0.15);
497 setWaterTint(0.058, 0.05, 0.035);
498 setWaterMurkiness(0.9);
500 setPPEffect("hdr");
502 ExportMap();