Fix the two incorrect replacements in rP21434, refs #4950.
[0ad.git] / binaries / data / mods / public / maps / random / lorraine_plain.js
blob37f57079a2a1de3aa78bc170b41fdb19542c9df1
1 Engine.LoadLibrary("rmgen");
2 Engine.LoadLibrary("rmgen-common");
4 const tPrimary = "temp_grass_long";
5 const tGrass = ["temp_grass", "temp_grass", "temp_grass_d"];
6 const tGrassPForest = "temp_plants_bog";
7 const tGrassDForest = "temp_plants_bog";
8 const tGrassA = "temp_grass_plants";
9 const tGrassB = "temp_plants_bog";
10 const tGrassC = "temp_mud_a";
11 const tRoad = "temp_road";
12 const tRoadWild = "temp_road_overgrown";
13 const tGrassPatchBlend = "temp_grass_long_b";
14 const tGrassPatch = ["temp_grass_d", "temp_grass_clovers"];
15 const tShore = "temp_plants_bog";
16 const tWater = "temp_mud_a";
18 const oBeech = "gaia/flora_tree_euro_beech";
19 const oOak = "gaia/flora_tree_oak";
20 const oBerryBush = "gaia/flora_bush_berry";
21 const oDeer = "gaia/fauna_deer";
22 const oRabbit = "gaia/fauna_rabbit";
23 const oStoneLarge = "gaia/geology_stonemine_temperate_quarry";
24 const oStoneSmall = "gaia/geology_stone_temperate";
25 const oMetalLarge = "gaia/geology_metal_temperate_slabs";
27 const aGrass = "actor|props/flora/grass_soft_small_tall.xml";
28 const aGrassShort = "actor|props/flora/grass_soft_large.xml";
29 const aRockLarge = "actor|geology/stone_granite_med.xml";
30 const aRockMedium = "actor|geology/stone_granite_med.xml";
31 const aReeds = "actor|props/flora/reeds_pond_lush_a.xml";
32 const aLillies = "actor|props/flora/water_lillies.xml";
33 const aBushMedium = "actor|props/flora/bush_medit_me.xml";
34 const aBushSmall = "actor|props/flora/bush_medit_sm.xml";
36 const pForestB = [tGrassDForest + TERRAIN_SEPARATOR + oBeech, tGrassDForest];
37 const pForestO = [tGrassPForest + TERRAIN_SEPARATOR + oOak, tGrassPForest];
38 const pForestR = [tGrassDForest + TERRAIN_SEPARATOR + oBeech, tGrassDForest, tGrassDForest + TERRAIN_SEPARATOR + oOak, tGrassDForest, tGrassDForest, tGrassDForest];
40 const heightSeaGround = -4;
41 const heightShallows = -2;
42 const heightLand = 3;
43 const heightOffsetBump = 2;
45 var g_Map = new RandomMap(heightLand, tPrimary);
47 const numPlayers = getNumPlayers();
48 const mapSize = g_Map.getSize();
49 const mapCenter = g_Map.getCenter();
50 const mapBounds = g_Map.getBounds();
52 var clPlayer = g_Map.createTileClass();
53 var clHill = g_Map.createTileClass();
54 var clForest = g_Map.createTileClass();
55 var clWater = g_Map.createTileClass();
56 var clDirt = g_Map.createTileClass();
57 var clRock = g_Map.createTileClass();
58 var clMetal = g_Map.createTileClass();
59 var clFood = g_Map.createTileClass();
60 var clBaseResource = g_Map.createTileClass();
61 var clShallow = g_Map.createTileClass();
63 var shallowWidth = scaleByMapSize(8, 12);
65 var startAngle = randomAngle();
67 placePlayerBases({
68         "PlayerPlacement": playerPlacementRiver(startAngle + Math.PI / 2, fractionToTiles(0.5)),
69         // PlayerTileClass marked below
70         "BaseResourceClass": clBaseResource,
71         "Walls": "towers",
72         "CityPatch": {
73                 "outerTerrain": tRoadWild,
74                 "innerTerrain": tRoad,
75                 "painters": [
76                         new TileClassPainter(clPlayer)
77                 ]
78         },
79         "Chicken": {
80         },
81         "Berries": {
82                 "template": oBerryBush
83         },
84         "Mines": {
85                 "types": [
86                         { "template": oMetalLarge },
87                         { "template": oStoneLarge }
88                 ]
89         },
90         "Trees": {
91                 "template": oOak,
92                 "count": 3
93         },
94         "Decoratives": {
95                 "template": aGrassShort
96         }
97 });
98 Engine.SetProgress(20);
100 var riverPositions = [
101         new Vector2D(mapBounds.left + 1, mapCenter.y),
102         new Vector2D(mapBounds.right - 1, mapCenter.y)
103 ].map(v => v.rotateAround(startAngle, mapCenter));
105 g_Map.log("Creating the main river");
106 createArea(
107         new PathPlacer(riverPositions[0], riverPositions[1], scaleByMapSize(10, 20), 0.5, 3 * scaleByMapSize(1, 4), 0.1, 0.01),
108         new SmoothElevationPainter(ELEVATION_SET, heightSeaGround, 4),
109         avoidClasses(clPlayer, 4));
110 Engine.SetProgress(25);
112 g_Map.log("Creating small puddles at the map border to ensure players being separated");
113 for (let riverPosition of riverPositions)
114         createArea(
115                 new ClumpPlacer(diskArea(scaleByMapSize(5, 10)), 0.95, 0.6, Infinity, riverPosition),
116                 new SmoothElevationPainter(ELEVATION_SET, heightSeaGround, 2),
117                 avoidClasses(clPlayer, 8));
118 Engine.SetProgress(30);
120 g_Map.log("Creating the shallows of the main river");
121 for (let i = 0; i <= randIntInclusive(3, scaleByMapSize(4, 6)); ++i)
123         let location = fractionToTiles(randFloat(0.15, 0.85));
124         createPassage({
125                 "start": new Vector2D(location, mapBounds.top).rotateAround(startAngle, mapCenter),
126                 "end": new Vector2D(location, mapBounds.bottom).rotateAround(startAngle, mapCenter),
127                 "startWidth": shallowWidth,
128                 "endWidth": shallowWidth,
129                 "smoothWidth": 2,
130                 "startHeight": heightShallows,
131                 "endHeight": heightShallows,
132                 "constraints": new HeightConstraint(-Infinity, heightShallows),
133                 "tileClass": clShallow
134         });
136 Engine.SetProgress(35);
138 createTributaryRivers(
139         startAngle,
140         randIntInclusive(9, scaleByMapSize(13, 21)),
141         scaleByMapSize(10, 20),
142         heightSeaGround,
143         [-6, -1.5],
144         Math.PI / 5,
145         clWater,
146         clShallow,
147         avoidClasses(clPlayer, 3, clBaseResource, 4));
149 Engine.SetProgress(40);
151 paintTerrainBasedOnHeight(-5, 1, 1, tWater);
152 paintTerrainBasedOnHeight(1, 2, 1, pForestR);
153 paintTileClassBasedOnHeight(-6, 0.5, 1, clWater);
155 Engine.SetProgress(50);
157 g_Map.log("Creating bumps");
158 createAreas(
159         new ClumpPlacer(scaleByMapSize(20, 50), 0.3, 0.06, Infinity),
160         new SmoothElevationPainter(ELEVATION_MODIFY, heightOffsetBump, 2),
161         avoidClasses(clWater, 2, clPlayer, 15),
162         scaleByMapSize(100, 200)
164 Engine.SetProgress(55);
166 var [forestTrees, stragglerTrees] = getTreeCounts(500, 2500, 0.7);
167 createForests(
168         [tGrass, tGrassDForest, tGrassPForest, pForestB, pForestO],
169         avoidClasses(clPlayer, 15, clWater, 3, clForest, 16, clHill, 1),
170         clForest,
171         forestTrees);
172 Engine.SetProgress(70);
174 g_Map.log("Creating dirt patches");
175 for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)])
176         createAreas(
177                 new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5),
178                 [
179                         new LayeredPainter([[tGrass,tGrassA], tGrassB, [tGrassB,tGrassC]], [1, 1]),
180                         new TileClassPainter(clDirt)
181                 ],
182                 avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 6),
183                 scaleByMapSize(15, 45)
184         );
186 g_Map.log("Creating grass patches");
187 for (let size of [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)])
188         createAreas(
189                 new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5),
190                 new LayeredPainter([tGrassPatchBlend, tGrassPatch], [1]),
191                 avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 6),
192                 scaleByMapSize(15, 45)
193         );
194 Engine.SetProgress(80);
196 g_Map.log("Creating stone mines");
197 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);
198 createObjectGroupsDeprecated(group, 0,
199         [avoidClasses(clWater, 0, clForest, 1, clPlayer, 15, clRock, 10, clHill, 1)],
200         scaleByMapSize(4,16), 100
203 g_Map.log("Creating small stone quarries");
204 group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock);
205 createObjectGroupsDeprecated(group, 0,
206         [avoidClasses(clWater, 0, clForest, 1, clPlayer, 15, clRock, 10, clHill, 1)],
207         scaleByMapSize(4,16), 100
210 g_Map.log("Creating metal mines");
211 group = new SimpleGroup([new SimpleObject(oMetalLarge, 1,1, 0,4)], true, clMetal);
212 createObjectGroupsDeprecated(group, 0,
213         [avoidClasses(clWater, 0, clForest, 1, clPlayer, 15, clMetal, 10, clRock, 5, clHill, 1)],
214         scaleByMapSize(4,16), 100
217 Engine.SetProgress(86);
219 g_Map.log("Creating small decorative rocks");
220 group = new SimpleGroup(
221         [new SimpleObject(aRockMedium, 1,3, 0,1)],
222         true
224 createObjectGroupsDeprecated(
225         group, 0,
226         avoidClasses(clWater, 0, clForest, 0, clPlayer, 0, clHill, 0),
227         scaleByMapSize(16, 262), 50
230 g_Map.log("Creating large decorative rocks");
231 group = new SimpleGroup(
232         [new SimpleObject(aRockLarge, 1,2, 0,1), new SimpleObject(aRockMedium, 1,3, 0,2)],
233         true
235 createObjectGroupsDeprecated(
236         group, 0,
237         avoidClasses(clWater, 0, clForest, 0, clPlayer, 0, clHill, 0),
238         scaleByMapSize(8, 131), 50
241 g_Map.log("Creating deer");
242 group = new SimpleGroup(
243         [new SimpleObject(oDeer, 5,7, 0,4)],
244         true, clFood
246 createObjectGroupsDeprecated(group, 0,
247         avoidClasses(clWater, 0, clForest, 0, clPlayer, 15, clHill, 1, clFood, 20),
248         3 * numPlayers, 50
251 g_Map.log("Creating rabbits");
252 group = new SimpleGroup(
253         [new SimpleObject(oRabbit, 2,3, 0,2)],
254         true, clFood
256 createObjectGroupsDeprecated(group, 0,
257         avoidClasses(clWater, 0, clForest, 0, clPlayer, 15, clHill, 1, clFood, 20),
258         3 * numPlayers, 50
261 g_Map.log("Creating berry bush");
262 group = new SimpleGroup(
263         [new SimpleObject(oBerryBush, 5,7, 0,4)],
264         true, clFood
266 createObjectGroupsDeprecated(group, 0,
267         avoidClasses(clWater, 3, clForest, 0, clPlayer, 15, clHill, 1, clFood, 10),
268         randIntInclusive(1, 4) * numPlayers + 2, 50
271 createStragglerTrees(
272         [oOak, oBeech],
273         avoidClasses(clWater, 1, clForest, 7, clHill, 1, clPlayer, 5, clMetal, 6, clRock, 6),
274         clForest,
275         stragglerTrees);
277 g_Map.log("Creating small grass tufts");
278 group = new SimpleGroup(
279         [new SimpleObject(aGrassShort, 1,2, 0,1, -Math.PI / 8, Math.PI / 8)]
281 createObjectGroupsDeprecated(group, 0,
282         avoidClasses(clWater, 2, clHill, 2, clPlayer, 2, clDirt, 0),
283         scaleByMapSize(13, 200)
286 g_Map.log("Creating large grass tufts");
287 group = new SimpleGroup(
288         [new SimpleObject(aGrass, 2,4, 0,1.8, -Math.PI / 8, Math.PI / 8), new SimpleObject(aGrassShort, 3,6, 1.2,2.5, -Math.PI / 8, Math.PI / 8)]
290 createObjectGroupsDeprecated(group, 0,
291         avoidClasses(clWater, 3, clHill, 2, clPlayer, 2, clDirt, 1, clForest, 0),
292         scaleByMapSize(13, 200)
295 g_Map.log("Creating bushes");
296 group = new SimpleGroup(
297         [new SimpleObject(aBushMedium, 1,2, 0,2), new SimpleObject(aBushSmall, 2,4, 0,2)]
299 createObjectGroupsDeprecated(group, 0,
300         avoidClasses(clWater, 1, clHill, 1, clPlayer, 1, clDirt, 1),
301         scaleByMapSize(13, 200), 50
304 g_Map.log("Creating shallow flora");
305 group = new SimpleGroup(
306         [new SimpleObject(aLillies, 1,2, 0,2), new SimpleObject(aReeds, 2,4, 0,2)]
308 createObjectGroupsDeprecated(group, 0,
309         stayClasses(clShallow, 1),
310         60 * scaleByMapSize(13, 200), 80
313 placePlayersNomad(clPlayer, avoidClasses(clWater, 4, clForest, 1, clMetal, 4, clRock, 4, clHill, 4, clFood, 2));
315 setSkySet("cirrus");
316 setWaterColor(0.1,0.212,0.422);
317 setWaterTint(0.3,0.1,0.949);
318 setWaterWaviness(3.0);
319 setWaterType("lake");
320 setWaterMurkiness(0.80);
322 g_Map.ExportMap();