Nomad mode on all random map scripts (except Survival of the Fittest), fixes #3591.
[0ad.git] / binaries / data / mods / public / maps / random / india.js
blobf4b01b0138ff68197fc52f37c57776a025ca95e2
1 Engine.LoadLibrary("rmgen");
3 const tGrass1 = "savanna_grass_a";
4 const tDirt1 = "savanna_dirt_a";
5 const tDirt4 = "savanna_dirt_b";
6 const tCityTiles = "savanna_tile_a_dirt_red";
7 const tShore = "savanna_riparian_bank";
8 const tWater = "savanna_riparian_wet";
10 const oTree = "gaia/flora_tree_palm_tropic";
11 const oBerryBush = "gaia/flora_bush_berry";
12 const oRabbit = "gaia/fauna_rabbit";
13 const oTiger = "gaia/fauna_tiger";
14 const oCrocodile = "gaia/fauna_crocodile";
15 const oFish = "gaia/fauna_fish";
16 const oElephant = "gaia/fauna_elephant_asian";
17 const oElephantInfant = "gaia/fauna_elephant_asian_infant";
18 const oBoar = "gaia/fauna_boar";
19 const oStoneSmall = "gaia/geology_stone_savanna_small";
20 const oMetalLarge = "gaia/geology_metal_savanna_slabs";
22 const aBush = "actor|props/flora/bush_medit_sm_dry.xml";
23 const aRock = "actor|geology/stone_savanna_med.xml";
25 InitMap();
27 var numPlayers = getNumPlayers();
28 var mapSize = getMapSize();
30 var clPlayer = createTileClass();
31 var clForest = createTileClass();
32 var clWater = createTileClass();
33 var clRock = createTileClass();
34 var clMetal = createTileClass();
35 var clFood = createTileClass();
36 var clBaseResource = createTileClass();
38 placePlayerBases({
39         "PlayerPlacement": playerPlacementCircle(0.35),
40         "PlayerTileClass": clPlayer,
41         "BaseResourceClass": clBaseResource,
42         // No city patch
43         "Chicken": {
44         },
45         "Berries": {
46                 "template": oBerryBush
47         },
48         "Mines": {
49                 "types": [
50                         {
51                                 "template": oMetalLarge
52                         },
53                         {
54                                 "type": "stone_formation",
55                                 "template": oStoneSmall,
56                                 "terrain": tDirt1
57                         }
58                 ]
59         },
60         "Trees": {
61                 "template": oTree,
62                 "count": scaleByMapSize(3, 7),
63                 "minDist": 13,
64                 "maxDist": 15,
65                 "minDistGroup": 4,
66                 "maxDistGroup": 6
67         }
68         // No decoratives
69 });
70 Engine.SetProgress(20);
72 log("Creating bumps...");
73 createAreas(
74         new ClumpPlacer(scaleByMapSize(20, 50), 0.5, 0.08, 1),
75         new SmoothElevationPainter(ELEVATION_MODIFY, 2, 2),
76         avoidClasses(clPlayer, 13),
77         scaleByMapSize(300, 800)
80 log("Creating the half dried-up lake...");
81 createArea(
82         new ChainPlacer(
83                 2,
84                 Math.floor(scaleByMapSize(2, 16)),
85                 Math.floor(scaleByMapSize(35, 200)),
86                 1,
87                 Math.round(fractionToTiles(0.5)),
88                 Math.round(fractionToTiles(0.5)),
89                 0,
90                 [Math.floor(mapSize * 0.008 * Math.pow(scaleByMapSize(1, 66), 1/8))]),
91         [
92                 new SmoothElevationPainter(ELEVATION_SET, -3, 4),
93                 paintClass(clWater)
94         ],
95         avoidClasses(clPlayer, 20));
97 log("Creating more shore jaggedness...");
98 createAreas(
99         new ChainPlacer(2, Math.floor(scaleByMapSize(4, 6)), 3, 1),
100         [
101                 new SmoothElevationPainter(ELEVATION_SET, 3, 4),
102                 unPaintClass(clWater)
103         ],
104         borderClasses(clWater, 4, 7),
105         scaleByMapSize(12, 130) * 2, 150
108 paintTerrainBasedOnHeight(2.4, 3.4, 3, tGrass1);
109 paintTerrainBasedOnHeight(1, 2.4, 0, tShore);
110 paintTerrainBasedOnHeight(-8, 1, 2, tWater);
111 paintTileClassBasedOnHeight(-6, 0, 1, clWater);
112 Engine.SetProgress(55);
114 var playerConstraint = new AvoidTileClassConstraint(clPlayer, 30);
115 var minesConstraint = new AvoidTileClassConstraint(clRock, 25);
116 var waterConstraint = new AvoidTileClassConstraint(clWater, 10);
118 log("Creating stone mines...");
119 for (let i = 0; i < scaleByMapSize(12, 30); ++i)
121         let mX = randIntInclusive(1, mapSize - 1);
122         let mZ = randIntInclusive(1, mapSize - 1);
123         if (playerConstraint.allows(mX, mZ) && minesConstraint.allows(mX, mZ) && waterConstraint.allows(mX, mZ))
124         {
125                 createStoneMineFormation(mX, mZ, oStoneSmall, tDirt4);
126                 addToClass(mX, mZ, clRock);
127         }
130 log("Creating metal mines...");
131 createObjectGroupsDeprecated(
132         new SimpleGroup([new SimpleObject(oMetalLarge, 1, 1, 0, 4)], true, clMetal),
133         0,
134         avoidClasses(clPlayer, 20, clMetal, 10, clRock, 8, clWater, 4),
135         scaleByMapSize(2, 12), 100
137 Engine.SetProgress(65);
139 log("Creating small decorative rocks...");
140 createObjectGroupsDeprecated(
141         new SimpleGroup(
142                 [new SimpleObject(aRock, 1, 3, 0, 3)],
143                 true
144         ),
145         0,
146         avoidClasses(clPlayer, 7, clWater, 1),
147         scaleByMapSize(200, 1200), 1
149 Engine.SetProgress(70);
151 log("Creating boar...");
152 createObjectGroupsDeprecated(
153         new SimpleGroup(
154                 [new SimpleObject(oBoar, 1, 2, 0, 4)],
155                 true, clFood
156         ),
157         0,
158         avoidClasses(clWater, 1, clPlayer, 20, clFood, 11),
159         scaleByMapSize(4, 12), 50
162 log("Creating tigers...");
163 createObjectGroupsDeprecated(
164         new SimpleGroup(
165                 [new SimpleObject(oTiger, 2, 2, 0, 4)],
166                 true, clFood
167         ),
168         0,
169         avoidClasses(clWater, 1, clPlayer, 20, clFood, 11),
170         scaleByMapSize(4, 12), 50
173 log("Creating crocodiles...");
174 createObjectGroupsDeprecated(
175         new SimpleGroup(
176                 [new SimpleObject(oCrocodile, 2, 4, 0, 4)],
177                 true, clFood
178         ), 0,
179         stayClasses(clWater, 1),
180         scaleByMapSize(4, 12), 50
183 log("Creating elephants...");
184 createObjectGroupsDeprecated(
185         new SimpleGroup(
186                 [
187                         new SimpleObject(oElephant, 2, 4, 0, 4),
188                         new SimpleObject(oElephantInfant, 1, 2, 0, 4)
189                 ],
190                 true, clFood
191         ),
192         0,
193         avoidClasses(clWater, 1, clPlayer, 20, clFood, 11),
194         scaleByMapSize(4, 12), 50
197 log("Creating rabbits...");
198 createObjectGroupsDeprecated(
199         new SimpleGroup(
200                 [new SimpleObject(oRabbit, 5, 6, 0, 4)],
201                 true, clFood
202         ),
203         0,
204         avoidClasses(clWater, 1, clPlayer, 20, clFood, 11),
205         scaleByMapSize(4, 12), 50
208 createFood(
209         [
210                 [new SimpleObject(oFish, 2, 3, 0, 2)]
211         ],
212         [
213                 25 * numPlayers
214         ],
215         [avoidClasses(clFood, 20), stayClasses(clWater, 2)],
216         clFood);
218 log("Creating berry bush...");
219 createObjectGroupsDeprecated(
220         new SimpleGroup(
221                 [new SimpleObject(oBerryBush, 5, 7, 0, 4)],
222                 true, clFood
223         ),
224         0,
225         avoidClasses(clWater, 3, clPlayer, 20, clFood, 12, clRock, 7, clMetal, 2),
226         randIntInclusive(1, 4) * numPlayers + 2, 50
228 Engine.SetProgress(85);
230 log("Creating trees...");
231 createObjectGroupsDeprecated(
232         new SimpleGroup(
233                 [new SimpleObject(oTree, 1, 7, 0, 3)],
234                 true, clForest
235         ),
236         0,
237         avoidClasses(clForest, 1, clPlayer, 20, clMetal, 1, clRock, 7, clWater, 1),
238         scaleByMapSize(70, 500)
241 log("Creating large grass tufts...");
242 createObjectGroupsDeprecated(
243         new SimpleGroup(
244                 [new SimpleObject(aBush, 2, 4, 0, 1.8, -Math.PI/8, Math.PI/8)]
245         ),
246         0,
247         avoidClasses(clWater, 3, clPlayer, 2, clForest, 0),
248         scaleByMapSize(100, 1200)
251 placePlayersNomad(clPlayer, avoidClasses(clWater, 4, clForest, 1, clMetal, 4, clRock, 4, clFood, 2));
253 setSunColor(0.87451, 0.847059, 0.647059);
254 setWaterColor(0.741176, 0.592157, 0.27451);
255 setWaterTint(0.741176, 0.592157, 0.27451);
256 setWaterWaviness(2.0);
257 setWaterType("clap");
258 setWaterMurkiness(0.835938);
260 setUnitsAmbientColor(0.57, 0.58, 0.55);
261 setTerrainAmbientColor(0.447059, 0.509804, 0.54902);
263 setFogFactor(0.25);
264 setFogThickness(0.15);
265 setFogColor(0.847059, 0.737255, 0.482353);
267 setPPEffect("hdr");
268 setPPContrast(0.57031);
269 setPPBloom(0.34);
271 ExportMap();