Fix the two incorrect replacements in rP21434, refs #4950.
[0ad.git] / binaries / data / mods / public / maps / random / kerala.js
blob57f80b8a5836bfe097f8aef2dcfa17af278204e1
1 Engine.LoadLibrary("rmgen");
2 Engine.LoadLibrary("rmgen-common");
4 const tGrass = ["tropic_grass_c", "tropic_grass_c", "tropic_grass_c", "tropic_grass_c", "tropic_grass_plants", "tropic_plants", "tropic_plants_b"];
5 const tGrassA = "tropic_plants_c";
6 const tGrassB = "tropic_plants_c";
7 const tGrassC = "tropic_grass_c";
8 const tForestFloor = "tropic_grass_plants";
9 const tCliff = ["tropic_cliff_a", "tropic_cliff_a", "tropic_cliff_a", "tropic_cliff_a_plants"];
10 const tPlants = "tropic_plants";
11 const tRoad = "tropic_citytile_a";
12 const tRoadWild = "tropic_citytile_plants";
13 const tShoreBlend = "tropic_beach_dry_plants";
14 const tShore = "tropic_beach_dry";
15 const tWater = "tropic_beach_wet";
17 const oTree = "gaia/flora_tree_toona";
18 const oPalm = "gaia/flora_tree_palm_tropic";
19 const oStoneLarge = "gaia/geology_stonemine_tropic_quarry";
20 const oStoneSmall = "gaia/geology_stone_tropic_a";
21 const oMetalLarge = "gaia/geology_metal_tropic_slabs";
22 const oFish = "gaia/fauna_fish";
23 const oDeer = "gaia/fauna_deer";
24 const oSheep = "gaia/fauna_tiger";
25 const oBush = "gaia/flora_bush_berry";
27 const aRockLarge = "actor|geology/stone_granite_large.xml";
28 const aRockMedium = "actor|geology/stone_granite_med.xml";
29 const aBush1 = "actor|props/flora/plant_tropic_a.xml";
30 const aBush2 = "actor|props/flora/plant_lg.xml";
31 const aBush3 = "actor|props/flora/plant_tropic_large.xml";
33 const pForestD = [tForestFloor + TERRAIN_SEPARATOR + oTree, tForestFloor];
34 const pForestP = [tForestFloor + TERRAIN_SEPARATOR + oPalm, tForestFloor];
36 const heightSeaGround = -5;
37 const heightLand = 3;
38 const heightHill = 25;
40 var g_Map = new RandomMap(heightLand, tGrass);
42 const numPlayers = getNumPlayers();
43 const mapCenter = g_Map.getCenter();
44 const mapBounds = g_Map.getBounds();
46 var clPlayer = g_Map.createTileClass();
47 var clHill = g_Map.createTileClass();
48 var clForest = g_Map.createTileClass();
49 var clWater = g_Map.createTileClass();
50 var clDirt = g_Map.createTileClass();
51 var clRock = g_Map.createTileClass();
52 var clMetal = g_Map.createTileClass();
53 var clFood = g_Map.createTileClass();
54 var clBaseResource = g_Map.createTileClass();
56 var waterPosition = fractionToTiles(0.31);
57 var playerPosition = fractionToTiles(0.55);
58 var mountainPosition = fractionToTiles(0.69);
60 var startAngle = randomAngle();
62 placePlayerBases({
63         "PlayerPlacement": [
64                 sortAllPlayers(),
65                 playerPlacementLine(0, new Vector2D(mapCenter.x, playerPosition), fractionToTiles(0.2)).map(pos => pos.rotateAround(startAngle, mapCenter))
66         ],
67         "PlayerTileClass": clPlayer,
68         "BaseResourceClass": clBaseResource,
69         "CityPatch": {
70                 "outerTerrain": tRoadWild,
71                 "innerTerrain": tRoad
72         },
73         "Chicken": {
74         },
75         "Berries": {
76                 "template": oBush
77         },
78         "Mines": {
79                 "types": [
80                         { "template": oMetalLarge },
81                         { "template": oStoneLarge }
82                 ]
83         },
84         "Trees": {
85                 "template": oTree,
86                 "count": scaleByMapSize(12, 30),
87                 "minDist": 12,
88                 "maxDist": 14,
89                 "minDistGroup": 1,
90                 "maxDistGroup": 3
91         }
92         // No decoratives
93 });
94 Engine.SetProgress(15);
96 paintRiver({
97         "parallel": true,
98         "start": new Vector2D(mapBounds.left, mapBounds.top).rotateAround(startAngle - Math.PI / 2, mapCenter),
99         "end": new Vector2D(mapBounds.left, mapBounds.bottom).rotateAround(startAngle - Math.PI / 2, mapCenter),
100         "width": 2 * waterPosition,
101         "fadeDist": 8,
102         "deviation": 0,
103         "heightRiverbed": heightSeaGround,
104         "heightLand": heightLand,
105         "meanderShort": 20,
106         "meanderLong": 0,
107         "waterFunc": (position, height, riverFraction) => {
108                 clWater.add(position);
109         }
112 g_Map.log("Marking mountain area");
113 var areaMountains = createArea(
114         new ConvexPolygonPlacer(
115                 [
116                         new Vector2D(mountainPosition, mapBounds.top),
117                         new Vector2D(mountainPosition, mapBounds.bottom),
118                         new Vector2D(mapBounds.right, mapBounds.top),
119                         new Vector2D(mapBounds.right, mapBounds.bottom)
120                 ].map(pos => pos.rotateAround(startAngle - Math.PI / 2, mapCenter)),
121                 Infinity));
123 g_Map.log("Creating shores");
124 for (let i = 0; i < scaleByMapSize(20, 120); ++i)
126         let position = new Vector2D(fractionToTiles(randFloat(0.28, 0.34)), fractionToTiles(randFloat(0.1, 0.9))).rotateAround(startAngle - Math.PI / 2, mapCenter).round();
127         createArea(
128                 new ChainPlacer(1, Math.floor(scaleByMapSize(4, 6)), Math.floor(scaleByMapSize(16, 30)), Infinity, position),
129                 [
130                         new LayeredPainter([tGrass, tGrass], [2]),
131                         new SmoothElevationPainter(ELEVATION_SET, heightLand, 3),
132                         new TileClassUnPainter(clWater)
133                 ]);
136 paintTerrainBasedOnHeight(-6, 1, 1, tWater);
137 paintTerrainBasedOnHeight(1, 2.8, 1, tShoreBlend);
138 paintTerrainBasedOnHeight(0, 1, 1, tShore);
139 paintTileClassBasedOnHeight(-6, 0.5, 1, clWater);
141 Engine.SetProgress(45);
143 g_Map.log("Creating hills");
144 createAreasInAreas(
145         new ChainPlacer(1, Math.floor(scaleByMapSize(4, 6)), Math.floor(scaleByMapSize(16, 40)), 0.1),
146         [
147                 new LayeredPainter([tCliff, tGrass], [3]),
148                 new SmoothElevationPainter(ELEVATION_SET, heightHill, 3),
149                 new TileClassPainter(clHill)
150         ],
151         avoidClasses(clPlayer, 20, clHill, 5, clWater, 2, clBaseResource, 2),
152         scaleByMapSize(5, 100),
153         3,
154         [areaMountains]);
156 g_Map.log("Creating forests");
157 var [forestTrees, stragglerTrees] = getTreeCounts(1000, 6000, 0.7);
158 var types = [
159         [[tGrass, tGrass, tGrass, tGrass, pForestD], [tGrass, tGrass, tGrass, pForestD]],
160         [[tGrass, tGrass, tGrass, tGrass, pForestP], [tGrass, tGrass, tGrass, pForestP]]
162 var size = forestTrees / (scaleByMapSize(3,6) * numPlayers);
163 var num = Math.floor(size / types.length);
164 for (let type of types)
165         createAreas(
166                 new ChainPlacer(
167                         1,
168                         Math.floor(scaleByMapSize(3, 5)),
169                         forestTrees / (num * Math.floor(scaleByMapSize(2, 4))),
170                         0.5),
171                 [
172                         new LayeredPainter(type, [2]),
173                         new TileClassPainter(clForest)
174                 ],
175                 avoidClasses(clPlayer, 20, clForest, 10, clHill, 0, clWater, 8),
176                 num);
178 Engine.SetProgress(70);
180 g_Map.log("Creating grass patches");
181 for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)])
182         createAreas(
183                 new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5),
184                 [
185                         new LayeredPainter([tGrassC, tGrassA, tGrassB], [2, 1]),
186                         new TileClassPainter(clDirt)
187                 ],
188                 avoidClasses(clWater, 8, clForest, 0, clHill, 0, clPlayer, 12, clDirt, 16),
189                 scaleByMapSize(20, 80));
191 for (let size of [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)])
192         createAreas(
193                 new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5),
194                 [
195                         new TerrainPainter(tPlants),
196                         new TileClassPainter(clDirt)
197                 ],
198                 avoidClasses(clWater, 8, clForest, 0, clHill, 0, clPlayer, 12, clDirt, 16),
199                 scaleByMapSize(20, 80));
201 g_Map.log("Creating stone mines");
202 var group = new SimpleGroup([new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1), new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)], true, clRock);
203 createObjectGroupsDeprecated(group, 0,
204         avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1),
205         scaleByMapSize(4,16), 100
208 g_Map.log("Creating small stone quarries");
209 group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock);
210 createObjectGroupsDeprecated(group, 0,
211         avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1),
212         scaleByMapSize(4,16), 100
215 g_Map.log("Creating metal mines");
216 group = new SimpleGroup([new SimpleObject(oMetalLarge, 1,1, 0,4)], true, clMetal);
217 createObjectGroupsDeprecated(group, 0,
218         avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clMetal, 10, clRock, 5, clHill, 1),
219         scaleByMapSize(4,16), 100
222 g_Map.log("Creating small decorative rocks");
223 group = new SimpleGroup(
224         [new SimpleObject(aRockMedium, 1,3, 0,1)],
225         true
227 createObjectGroupsDeprecated(
228         group, 0,
229         avoidClasses(clWater, 0, clForest, 0, clPlayer, 0, clHill, 0),
230         3*scaleByMapSize(16, 262), 50
233 g_Map.log("Creating large decorative rocks");
234 group = new SimpleGroup(
235         [new SimpleObject(aRockLarge, 1,2, 0,1), new SimpleObject(aRockMedium, 1,3, 0,2)],
236         true
238 createObjectGroupsDeprecated(
239         group, 0,
240         avoidClasses(clWater, 0, clForest, 0, clPlayer, 0, clHill, 0),
241         3*scaleByMapSize(8, 131), 50
244 g_Map.log("Creating small grass tufts");
245 group = new SimpleGroup(
246         [new SimpleObject(aBush1, 1,2, 0,1, -Math.PI / 8, Math.PI / 8)]
248 createObjectGroupsDeprecated(group, 0,
249         avoidClasses(clWater, 2, clHill, 2, clPlayer, 2, clDirt, 0),
250         8 * scaleByMapSize(13, 200)
253 Engine.SetProgress(90);
255 g_Map.log("Creating large grass tufts");
256 group = new SimpleGroup(
257         [new SimpleObject(aBush2, 2,4, 0,1.8, -Math.PI / 8, Math.PI / 8), new SimpleObject(aBush1, 3,6, 1.2,2.5, -Math.PI / 8, Math.PI / 8)]
259 createObjectGroupsDeprecated(group, 0,
260         avoidClasses(clWater, 3, clHill, 2, clPlayer, 2, clDirt, 1, clForest, 0),
261         8 * scaleByMapSize(13, 200)
264 Engine.SetProgress(95);
266 g_Map.log("Creating bushes");
267 group = new SimpleGroup(
268         [new SimpleObject(aBush3, 1,2, 0,2), new SimpleObject(aBush2, 2,4, 0,2)]
270 createObjectGroupsDeprecated(group, 0,
271         avoidClasses(clWater, 1, clHill, 1, clPlayer, 1, clDirt, 1),
272         8 * scaleByMapSize(13, 200), 50
275 Engine.SetProgress(96);
277 createStragglerTrees(
278         [oTree, oPalm],
279         avoidClasses(clWater, 5, clForest, 1, clHill, 1, clPlayer, 12, clMetal, 6, clRock, 6),
280         clForest,
281         stragglerTrees);
283 g_Map.log("Creating deer");
284 group = new SimpleGroup(
285         [new SimpleObject(oDeer, 5,7, 0,4)],
286         true, clFood
288 createObjectGroupsDeprecated(group, 0,
289         avoidClasses(clWater, 3, clForest, 0, clPlayer, 10, clHill, 1, clFood, 20),
290         3 * numPlayers, 50
293 Engine.SetProgress(97);
295 g_Map.log("Creating berry bush");
296 group = new SimpleGroup(
297         [new SimpleObject(oBush, 5,7, 0,4)],
298         true, clFood
300 createObjectGroupsDeprecated(group, 0,
301         avoidClasses(clWater, 6, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10),
302         randIntInclusive(1, 4) * numPlayers + 2, 50
305 g_Map.log("Creating sheep");
306 group = new SimpleGroup(
307         [new SimpleObject(oSheep, 2,3, 0,2)],
308         true, clFood
310 createObjectGroupsDeprecated(group, 0,
311         avoidClasses(clWater, 3, clForest, 0, clPlayer, 22, clHill, 1, clFood, 20),
312         3 * numPlayers, 50
315 g_Map.log("Creating fish");
316 group = new SimpleGroup(
317         [new SimpleObject(oFish, 2,3, 0,2)],
318         true, clFood
320 createObjectGroupsDeprecated(group, 0,
321         [avoidClasses(clFood, 20), stayClasses(clWater, 6)],
322         25 * numPlayers, 60
325 placePlayersNomad(clPlayer, avoidClasses(clWater, 4, clHill, 2, clForest, 1, clMetal, 4, clRock, 4, clFood, 2));
327 setSunColor(0.6, 0.6, 0.6);
328 setSunElevation(Math.PI / 3);
330 setWaterColor(0.524,0.734,0.839);
331 setWaterTint(0.369,0.765,0.745);
332 setWaterWaviness(1.0);
333 setWaterType("ocean");
334 setWaterMurkiness(0.35);
336 setFogFactor(0.4);
337 setFogThickness(0.2);
339 setPPEffect("hdr");
340 setPPContrast(0.7);
341 setPPSaturation(0.65);
342 setPPBloom(0.6);
344 setSkySet("cirrus");
345 g_Map.ExportMap();