1 Engine.LoadLibrary("rmgen");
2 Engine.LoadLibrary("rmgen-common");
4 //TILE_CENTERED_HEIGHT_MAP = true;
6 const tCity = "medit_city_pavement";
7 const tCityPlaza = "medit_city_pavement";
8 const tHill = ["medit_dirt", "medit_dirt_b", "medit_dirt_c", "medit_rocks_grass", "medit_rocks_grass"];
9 const tMainDirt = "medit_dirt";
10 const tCliff = "medit_cliff_aegean";
11 const tForestFloor = "medit_rocks_shrubs";
12 const tGrass = "medit_rocks_grass";
13 const tRocksShrubs = "medit_rocks_shrubs";
14 const tRocksGrass = "medit_rocks_grass";
15 const tDirt = "medit_dirt_b";
16 const tDirtB = "medit_dirt_c";
17 const tShore = "medit_sand";
18 const tWater = "medit_sand_wet";
20 const oGrapeBush = "gaia/flora_bush_grapes";
21 const oDeer = "gaia/fauna_deer";
22 const oFish = "gaia/fauna_fish";
23 const oSheep = "gaia/fauna_sheep";
24 const oGoat = "gaia/fauna_goat";
25 const oStoneLarge = "gaia/geology_stonemine_medit_quarry";
26 const oStoneSmall = "gaia/geology_stone_mediterranean";
27 const oMetalLarge = "gaia/geology_metal_mediterranean_slabs";
28 const oDatePalm = "gaia/flora_tree_cretan_date_palm_short";
29 const oSDatePalm = "gaia/flora_tree_cretan_date_palm_tall";
30 const oCarob = "gaia/flora_tree_carob";
31 const oFanPalm = "gaia/flora_tree_medit_fan_palm";
32 const oPoplar = "gaia/flora_tree_poplar_lombardy";
33 const oCypress = "gaia/flora_tree_cypress";
35 const aBush1 = "actor|props/flora/bush_medit_sm.xml";
36 const aBush2 = "actor|props/flora/bush_medit_me.xml";
37 const aBush3 = "actor|props/flora/bush_medit_la.xml";
38 const aBush4 = "actor|props/flora/bush_medit_me.xml";
39 const aDecorativeRock = "actor|geology/stone_granite_med.xml";
41 const pForest = [tForestFloor + TERRAIN_SEPARATOR + oDatePalm, tForestFloor + TERRAIN_SEPARATOR + oSDatePalm, tForestFloor + TERRAIN_SEPARATOR + oCarob, tForestFloor, tForestFloor];
43 const heightSeaGround = -3;
44 const heightShore = -1.5;
46 const heightIsland = 6;
47 const heightHill = 15;
48 const heightOffsetBump = 2;
50 var g_Map = new RandomMap(heightLand, tHill);
52 const numPlayers = getNumPlayers();
53 const mapSize = g_Map.getSize();
54 const mapCenter = g_Map.getCenter();
55 const mapBounds = g_Map.getBounds();
57 var clPlayer = g_Map.createTileClass();
58 var clForest = g_Map.createTileClass();
59 var clWater = g_Map.createTileClass();
60 var clDirt = g_Map.createTileClass();
61 var clRock = g_Map.createTileClass();
62 var clMetal = g_Map.createTileClass();
63 var clFood = g_Map.createTileClass();
64 var clBaseResource = g_Map.createTileClass();
65 var clGrass = g_Map.createTileClass();
66 var clHill = g_Map.createTileClass();
67 var clIsland = g_Map.createTileClass();
69 var startAngle = randIntInclusive(0, 3) * Math.PI / 2;
74 playerPlacementLine(Math.PI / 2, new Vector2D(fractionToTiles(0.76), mapCenter.y), fractionToTiles(0.2)).map(pos =>
75 pos.rotateAround(startAngle, mapCenter))
77 "PlayerTileClass": clPlayer,
78 "BaseResourceClass": clBaseResource,
80 "outerTerrain": tCityPlaza,
86 "template": oGrapeBush
90 { "template": oMetalLarge },
91 { "template": oStoneLarge }
102 Engine.SetProgress(30);
106 "start": new Vector2D(mapBounds.left, mapBounds.top).rotateAround(startAngle, mapCenter),
107 "end": new Vector2D(mapBounds.left, mapBounds.bottom).rotateAround(startAngle, mapCenter),
109 "fadeDist": scaleByMapSize(6, 25),
111 "heightRiverbed": heightSeaGround,
112 "heightLand": heightLand,
116 Engine.SetProgress(40);
118 paintTileClassBasedOnHeight(-Infinity, heightLand, Elevation_ExcludeMin_ExcludeMax, clWater);
119 paintTerrainBasedOnHeight(-Infinity, heightShore, Elevation_ExcludeMin_ExcludeMax, tWater);
120 paintTerrainBasedOnHeight(heightShore, heightLand, Elevation_ExcludeMin_ExcludeMax, tShore);
122 g_Map.log("Creating bumps");
124 new ClumpPlacer(scaleByMapSize(20, 50), 0.3, 0.06, Infinity),
125 new SmoothElevationPainter(ELEVATION_MODIFY, heightOffsetBump, 2),
126 avoidClasses(clWater, 2, clPlayer, 20),
127 scaleByMapSize(100, 200));
129 g_Map.log("Creating hills");
131 new ChainPlacer(1, Math.floor(scaleByMapSize(4, 6)), Math.floor(scaleByMapSize(16, 40)), 0.5),
133 new LayeredPainter([tCliff, tHill], [2]),
134 new SmoothElevationPainter(ELEVATION_SET, heightHill, 2),
135 new TileClassPainter(clHill)
137 avoidClasses(clPlayer, 20, clForest, 1, clHill, 15, clWater, 0),
138 scaleByMapSize(1, 4) * numPlayers * 3);
140 g_Map.log("Creating forests");
141 var [forestTrees, stragglerTrees] = getTreeCounts(500, 2500, 0.5);
142 var num = scaleByMapSize(10,42);
144 new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), forestTrees / (num * Math.floor(scaleByMapSize(2, 5))), 0.5),
146 new TerrainPainter([tForestFloor, pForest]),
147 new TileClassPainter(clForest)
149 avoidClasses(clPlayer, 20, clForest, 10, clWater, 1, clHill, 1, clBaseResource, 3),
152 Engine.SetProgress(50);
154 g_Map.log("Creating grass patches");
155 for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)])
157 new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5),
160 [[tGrass, tRocksShrubs], [tRocksShrubs, tRocksGrass], [tRocksGrass, tGrass]],
162 new TileClassPainter(clDirt)
164 avoidClasses(clForest, 0, clGrass, 5, clPlayer, 10, clWater, 4, clDirt, 5, clHill, 1),
165 scaleByMapSize(15, 45));
166 Engine.SetProgress(55);
168 g_Map.log("Creating dirt patches");
169 for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)])
171 new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5),
174 [[tDirt, tDirtB], [tDirt, tMainDirt], [tDirtB, tMainDirt]],
176 new TileClassPainter(clDirt)
178 avoidClasses(clForest, 0, clDirt, 5, clPlayer, 10, clWater, 4, clGrass, 5, clHill, 1),
179 scaleByMapSize(15, 45));
180 Engine.SetProgress(60);
182 g_Map.log("Creating cyprus");
184 new ClumpPlacer(diskArea(fractionToTiles(0.08)), 0.2, 0.1, 0.01),
186 new LayeredPainter([tShore, tHill], [12]),
187 new SmoothElevationPainter(ELEVATION_SET, heightIsland, 8),
188 new TileClassPainter(clIsland),
189 new TileClassUnPainter(clWater)
191 [stayClasses (clWater, 8)],
195 g_Map.log("Creating cyprus mines");
197 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 new SimpleGroup([new SimpleObject(oMetalLarge, 1, 1, 0, 4)], true, clMetal),
199 new SimpleGroup([new SimpleObject(oStoneSmall, 2, 5, 1, 3)], true, clRock)
201 for (let mine of mines)
206 stayClasses(clIsland, 9),
207 avoidClasses(clForest, 1, clRock, 8, clMetal, 8)
209 scaleByMapSize(4, 16));
211 g_Map.log("Creating stone mines");
212 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);
213 createObjectGroupsDeprecated(group, 0,
214 avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clWater, 3, clHill, 1),
215 scaleByMapSize(4,16), 100
218 g_Map.log("Creating small stone quarries");
219 group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock);
220 createObjectGroupsDeprecated(group, 0,
221 avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clWater, 3, clHill, 1),
222 scaleByMapSize(4,16), 100
225 g_Map.log("Creating metal mines");
226 group = new SimpleGroup([new SimpleObject(oMetalLarge, 1,1, 0,4)], true, clMetal);
227 createObjectGroupsDeprecated(group, 0,
228 avoidClasses(clForest, 1, clPlayer, 20, clMetal, 10, clRock, 5, clWater, 3, clHill, 1),
229 scaleByMapSize(4,16), 100
232 Engine.SetProgress(65);
234 g_Map.log("Creating small decorative rocks");
235 group = new SimpleGroup(
236 [new SimpleObject(aDecorativeRock, 1,3, 0,1)],
239 createObjectGroupsDeprecated(
241 avoidClasses(clWater, 1, clForest, 0, clPlayer, 0, clHill, 1),
242 scaleByMapSize(16, 262), 50
245 g_Map.log("Creating shrubs");
246 group = new SimpleGroup(
247 [new SimpleObject(aBush2, 1,2, 0,1), new SimpleObject(aBush1, 1,3, 0,2), new SimpleObject(aBush4, 1,2, 0,1), new SimpleObject(aBush3, 1,3, 0,2)],
250 createObjectGroupsDeprecated(
252 avoidClasses(clWater, 3, clPlayer, 0, clHill, 1),
253 scaleByMapSize(40, 360), 50
255 Engine.SetProgress(70);
257 g_Map.log("Creating fish");
258 group = new SimpleGroup([new SimpleObject(oFish, 1,3, 2,6)], true, clFood);
259 createObjectGroupsDeprecated(group, 0,
260 [avoidClasses(clIsland, 2, clFood, 10), stayClasses(clWater, 5)],
261 3*scaleByMapSize(5,20), 50
264 g_Map.log("Creating sheeps");
265 group = new SimpleGroup([new SimpleObject(oSheep, 5,7, 0,4)], true, clFood);
266 createObjectGroupsDeprecated(group, 0,
267 avoidClasses(clForest, 0, clPlayer, 7, clWater, 3, clFood, 10, clHill, 1),
268 scaleByMapSize(5,20), 50
271 g_Map.log("Creating goats");
272 group = new SimpleGroup([new SimpleObject(oGoat, 2,4, 0,3)], true, clFood);
273 createObjectGroupsDeprecated(group, 0,
274 avoidClasses(clForest, 0, clPlayer, 7, clWater, 3, clFood, 10, clHill, 1),
275 scaleByMapSize(5,20), 50
278 g_Map.log("Creating deers");
279 group = new SimpleGroup([new SimpleObject(oDeer, 2,4, 0,2)], true, clFood);
280 createObjectGroupsDeprecated(group, 0,
281 avoidClasses(clForest, 0, clPlayer, 7, clWater, 3, clFood, 10, clHill, 1),
282 scaleByMapSize(5,20), 50
285 g_Map.log("Creating grape bushes");
286 group = new SimpleGroup(
287 [new SimpleObject(oGrapeBush, 5,7, 0,4)],
290 createObjectGroupsDeprecated(group, 0,
291 avoidClasses(clWater, 3, clForest, 0, clPlayer, 15, clHill, 1, clFood, 7),
292 randIntInclusive(1, 4) * numPlayers + 2, 50
294 Engine.SetProgress(90);
296 var stragglerTreeConfig = [
297 [1, avoidClasses(clForest, 0, clWater, 4, clPlayer, 8, clMetal, 6, clHill, 1)],
298 [3, [stayClasses(clIsland, 9), avoidClasses(clRock, 4, clMetal, 4)]]
301 for (let [amount, constraint] of stragglerTreeConfig)
302 createStragglerTrees(
303 [oDatePalm, oSDatePalm, oCarob, oFanPalm, oPoplar, oCypress],
306 amount * stragglerTrees);
309 setSunColor(0.917, 0.828, 0.734);
310 setWaterColor(0.263,0.314,0.631);
311 setWaterTint(0.133, 0.725,0.855);
312 setWaterWaviness(2.0);
313 setWaterType("ocean");
314 setWaterMurkiness(0.8);
316 setTerrainAmbientColor(0.57, 0.58, 0.55);
317 setUnitsAmbientColor(0.447059, 0.509804, 0.54902);
319 setSunElevation(0.671884);
320 setSunRotation(-0.582913);
323 setFogThickness(0.15);
324 setFogColor(0.8, 0.7, 0.6);
328 setPPSaturation(0.47);
331 placePlayersNomad(clPlayer, avoidClasses(clWater, 4, clForest, 1, clMetal, 4, clRock, 4, clHill, 4, clFood, 2));