Merge 'remotes/trunk'
[0ad.git] / binaries / data / mods / public / maps / random / english_channel.js
blobf43496f465f7c943cdf58b957dd2e0f36677dda7
1 Engine.LoadLibrary("rmgen");
2 Engine.LoadLibrary("rmgen-common");
4 function* GenerateMap()
6         const tPrimary = "temp_grass_long";
7         const tGrass = ["temp_grass", "temp_grass", "temp_grass_d"];
8         const tGrassDForest = "temp_plants_bog";
9         const tGrassA = "temp_grass_plants";
10         const tGrassB = "temp_plants_bog";
11         const tGrassC = "temp_mud_a";
12         const tHill = ["temp_highlands", "temp_grass_long_b"];
13         const tCliff = ["temp_cliff_a", "temp_cliff_b"];
14         const tRoad = "temp_road";
15         const tRoadWild = "temp_road_overgrown";
16         const tGrassPatchBlend = "temp_grass_long_b";
17         const tGrassPatch = ["temp_grass_d", "temp_grass_clovers"];
18         const tShore = "temp_dirt_gravel";
19         const tWater = "temp_dirt_gravel_b";
21         const oBeech = "gaia/tree/euro_beech";
22         const oPoplar = "gaia/tree/poplar";
23         const oApple = "gaia/fruit/apple";
24         const oOak = "gaia/tree/oak";
25         const oBerryBush = "gaia/fruit/berry_01";
26         const oDeer = "gaia/fauna_deer";
27         const oFish = "gaia/fish/generic";
28         const oGoat = "gaia/fauna_goat";
29         const oBoar = "gaia/fauna_boar";
30         const oStoneLarge = "gaia/rock/temperate_large";
31         const oStoneSmall = "gaia/rock/temperate_small";
32         const oMetalLarge = "gaia/ore/temperate_large";
34         const aGrass = "actor|props/flora/grass_soft_large_tall.xml";
35         const aGrassShort = "actor|props/flora/grass_soft_large.xml";
36         const aRockLarge = "actor|geology/stone_granite_large.xml";
37         const aRockMedium = "actor|geology/stone_granite_med.xml";
38         const aBushMedium = "actor|props/flora/bush_medit_me_lush.xml";
39         const aBushSmall = "actor|props/flora/bush_medit_sm_lush.xml";
40         const aReeds = "actor|props/flora/reeds_pond_lush_a.xml";
41         const aLillies = "actor|props/flora/water_lillies.xml";
43         const pForestD = [tGrassDForest + TERRAIN_SEPARATOR + oBeech, tGrassDForest];
45         const heightSeaGround = -4;
46         const heightShore = 1;
47         const heightLand = 3;
49         globalThis.g_Map = new RandomMap(heightShore, tPrimary);
51         const numPlayers = getNumPlayers();
52         const mapCenter = g_Map.getCenter();
53         const mapBounds = g_Map.getBounds();
55         const clPlayer = g_Map.createTileClass();
56         const clHill = g_Map.createTileClass();
57         const clForest = g_Map.createTileClass();
58         const clWater = g_Map.createTileClass();
59         const clDirt = g_Map.createTileClass();
60         const clRock = g_Map.createTileClass();
61         const clMetal = g_Map.createTileClass();
62         const clFood = g_Map.createTileClass();
63         const clBaseResource = g_Map.createTileClass();
64         const clShallow = g_Map.createTileClass();
66         const startAngle = randomAngle();
68         placePlayerBases({
69                 "PlayerPlacement": playerPlacementRiver(startAngle + Math.PI / 2, fractionToTiles(0.6)),
70                 "PlayerTileClass": clPlayer,
71                 "BaseResourceClass": clBaseResource,
72                 "CityPatch": {
73                         "outerTerrain": tRoadWild,
74                         "innerTerrain": tRoad
75                 },
76                 "StartingAnimal": {
77                 },
78                 "Berries": {
79                         "template": oBerryBush
80                 },
81                 "Mines": {
82                         "types": [
83                                 { "template": oMetalLarge },
84                                 { "template": oStoneLarge }
85                         ]
86                 },
87                 "Trees": {
88                         "template": oOak,
89                         "count": 2
90                 },
91                 "Decoratives": {
92                         "template": aGrassShort
93                 }
94         });
95         yield 10;
97         paintRiver({
98                 "parallel": false,
99                 "start": new Vector2D(mapBounds.left, mapCenter.y).rotateAround(startAngle, mapCenter),
100                 "end": new Vector2D(mapBounds.right, mapCenter.y).rotateAround(startAngle, mapCenter),
101                 "width": fractionToTiles(0.25),
102                 "fadeDist": scaleByMapSize(3, 10),
103                 "deviation": 0,
104                 "heightRiverbed": heightSeaGround,
105                 "heightLand": heightLand,
106                 "meanderShort": 20,
107                 "meanderLong": 0,
108                 "waterFunc": (position, height, riverFraction) => {
109                         createTerrain(height < -1.5 ? tWater : tShore).place(position);
110                 },
111                 "landFunc": (position, shoreDist1, shoreDist2) => {
112                         g_Map.setHeight(position, heightLand + 0.1);
113                 }
114         });
116         yield 20;
118         createTributaryRivers(
119                 startAngle,
120                 randIntInclusive(9, scaleByMapSize(13, 21)),
121                 scaleByMapSize(10, 20),
122                 heightSeaGround,
123                 [-6, -1.5],
124                 Math.PI / 5,
125                 clWater,
126                 clShallow,
127                 avoidClasses(clPlayer, 8, clBaseResource, 4));
129         paintTerrainBasedOnHeight(-5, 1, 1, tWater);
130         paintTerrainBasedOnHeight(1, heightLand, 1, tShore);
131         paintTileClassBasedOnHeight(-6, 0.5, 1, clWater);
132         yield 25;
134         createBumps(avoidClasses(clWater, 5, clPlayer, 20));
135         yield 30;
137         createHills([tCliff, tCliff, tHill], avoidClasses(clPlayer, 20, clHill, 15, clWater, 5), clHill,
138                 scaleByMapSize(1, 4) * numPlayers);
139         yield 50;
141         const [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7);
142         createForests(
143                 [tGrass, tGrassDForest, tGrassDForest, pForestD, pForestD],
144                 avoidClasses(clPlayer, 20, clForest, 17, clHill, 0, clWater, 6),
145                 clForest,
146                 forestTrees);
147         yield 70;
149         g_Map.log("Creating dirt patches");
150         createLayeredPatches(
151                 [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
152                 [[tGrass, tGrassA], tGrassB, [tGrassB, tGrassC]],
153                 [1, 1],
154                 avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 6),
155                 scaleByMapSize(15, 45),
156                 clDirt);
158         g_Map.log("Creating grass patches");
159         createPatches(
160                 [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
161                 [tGrassPatchBlend, tGrassPatch],
162                 [1],
163                 avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 6),
164                 scaleByMapSize(15, 45),
165                 clDirt);
166         yield 80;
168         g_Map.log("Creating stone mines");
169         createMines(
170                 [
171                         [
172                                 new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1),
173                                 new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)
174                         ],
175                         [new SimpleObject(oStoneSmall, 2, 5, 1, 3)]
176                 ],
177                 avoidClasses(clWater, 2, clForest, 1, clPlayer, 20, clRock, 10, clHill, 2),
178                 clRock);
180         g_Map.log("Creating metal mines");
181         createMines(
182                 [
183                         [new SimpleObject(oMetalLarge, 1, 1, 0, 4)]
184                 ],
185                 avoidClasses(clWater, 2, clForest, 1, clPlayer, 20, clMetal, 10, clRock, 5, clHill, 2),
186                 clMetal
187         );
188         yield 85;
190         createDecoration(
191                 [
192                         [new SimpleObject(aRockMedium, 1, 3, 0, 1)],
193                         [new SimpleObject(aRockLarge, 1, 2, 0, 1), new SimpleObject(aRockMedium, 1, 3, 0, 2)],
194                         [new SimpleObject(aGrassShort, 1, 2, 0, 1)],
195                         [new SimpleObject(aGrass, 2, 4, 0, 1.8), new SimpleObject(aGrassShort, 3, 6, 1.2, 2.5)],
196                         [new SimpleObject(aBushMedium, 1, 2, 0, 2), new SimpleObject(aBushSmall, 2, 4, 0, 2)]
197                 ],
198                 [
199                         scaleByMapAreaAbsolute(16),
200                         scaleByMapAreaAbsolute(8),
201                         scaleByMapAreaAbsolute(13),
202                         scaleByMapAreaAbsolute(13),
203                         scaleByMapAreaAbsolute(13)
204                 ],
205                 avoidClasses(clWater, 1, clForest, 0, clPlayer, 0, clHill, 0));
207         createDecoration(
208                 [
209                         [new SimpleObject(aReeds, 1, 3, 0, 1)],
210                         [new SimpleObject(aLillies, 1, 2, 0, 1)]
211                 ],
212                 [
213                         scaleByMapSize(800, 12800),
214                         scaleByMapSize(800, 12800)
215                 ],
216                 stayClasses(clShallow, 0));
218         createFood(
219                 [
220                         [new SimpleObject(oDeer, 5, 7, 0, 4)],
221                         [new SimpleObject(oGoat, 2, 3, 0, 2)],
222                         [new SimpleObject(oBoar, 2, 3, 0, 2)]
223                 ],
224                 [
225                         3 * numPlayers,
226                         3 * numPlayers,
227                         3 * numPlayers
228                 ],
229                 avoidClasses(clWater, 1, clForest, 0, clPlayer, 20, clHill, 0, clFood, 15),
230                 clFood);
232         createFood(
233                 [
234                         [new SimpleObject(oBerryBush, 5, 7, 0, 4)]
235                 ],
236                 [
237                         randIntInclusive(1, 4) * numPlayers + 2
238                 ],
239                 avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10),
240                 clFood);
242         createFood(
243                 [
244                         [new SimpleObject(oFish, 2, 3, 0, 2)]
245                 ],
246                 [scaleByMapSize(3, 25) * numPlayers],
247                 [avoidClasses(clFood, 6), stayClasses(clWater, 4)],
248                 clFood);
250         createStragglerTrees(
251                 [oBeech, oPoplar, oApple],
252                 avoidClasses(clWater, 1, clForest, 1, clHill, 1, clPlayer, 8, clMetal, 6, clRock, 6),
253                 clForest,
254                 stragglerTrees);
256         setSkySet("cirrus");
257         setWaterColor(0.114, 0.192, 0.463);
258         setWaterTint(0.255, 0.361, 0.651);
259         setWaterWaviness(3.0);
260         setWaterType("ocean");
261         setWaterMurkiness(0.83);
263         setFogThickness(0.35);
264         setFogFactor(0.55);
266         setPPEffect("hdr");
267         setPPSaturation(0.62);
268         setPPContrast(0.62);
269         setPPBloom(0.37);
271         placePlayersNomad(clPlayer,
272                 avoidClasses(clWater, 4, clForest, 1, clMetal, 4, clRock, 4, clHill, 4, clFood, 2));
274         return g_Map;