1 Engine.LoadLibrary("rmgen");
2 Engine.LoadLibrary("rmgen-common");
4 const tSnowA = ["polar_snow_b"];
5 const tSnowB = "polar_ice_snow";
6 const tSnowC = "polar_ice";
7 const tSnowD = "polar_snow_a";
8 const tForestFloor = "polar_tundra_snow";
9 const tCliff = "polar_snow_rocks";
10 const tSnowE = ["polar_snow_glacial"];
11 const tRoad = "new_alpine_citytile";
12 const tRoadWild = "new_alpine_citytile";
13 const tShoreBlend = "alpine_shore_rocks_icy";
14 const tShore = "alpine_shore_rocks";
15 const tWater = "alpine_shore_rocks";
17 const oPine = "gaia/flora_tree_pine_w";
18 const oStoneLarge = "gaia/geology_stonemine_alpine_quarry";
19 const oStoneSmall = "gaia/geology_stone_alpine_a";
20 const oMetalLarge = "gaia/geology_metal_alpine_slabs";
21 const oFish = "gaia/fauna_fish";
22 const oWalrus = "gaia/fauna_walrus";
23 const oArcticWolf = "gaia/fauna_arctic_wolf";
25 const aIceberg = "actor|props/special/eyecandy/iceberg.xml";
27 const pForestD = [tForestFloor + TERRAIN_SEPARATOR + oPine, tForestFloor, tForestFloor];
28 const pForestS = [tForestFloor + TERRAIN_SEPARATOR + oPine, tForestFloor, tForestFloor, tForestFloor];
30 const heightSeaGround = -5;
31 const heightLake = -4;
33 const heightHill = 25;
35 var g_Map = new RandomMap(heightLand, tSnowA);
37 const numPlayers = getNumPlayers();
38 const mapSize = g_Map.getSize();
39 const mapCenter = g_Map.getCenter();
40 const mapBounds = g_Map.getBounds();
42 var clPlayer = g_Map.createTileClass();
43 var clHill = g_Map.createTileClass();
44 var clForest = g_Map.createTileClass();
45 var clWater = g_Map.createTileClass();
46 var clIsland = g_Map.createTileClass();
47 var clDirt = g_Map.createTileClass();
48 var clRock = g_Map.createTileClass();
49 var clMetal = g_Map.createTileClass();
50 var clFood = g_Map.createTileClass();
51 var clBaseResource = g_Map.createTileClass();
53 var startAngle = randomAngle();
58 playerPlacementLine(0, new Vector2D(mapCenter.x, fractionToTiles(0.45)), fractionToTiles(0.2)).map(
59 pos => pos.rotateAround(startAngle, mapCenter))
61 "PlayerTileClass": clPlayer,
62 "BaseResourceClass": clBaseResource,
64 "outerTerrain": tRoadWild,
67 // No chicken, no berries
70 { "template": oMetalLarge },
71 { "template": oStoneLarge }
76 "count": scaleByMapSize(12, 30),
80 Engine.SetProgress(15);
84 "start": new Vector2D(mapBounds.left, mapBounds.top).rotateAround(startAngle, mapCenter),
85 "end": new Vector2D(mapBounds.right, mapBounds.top).rotateAround(startAngle, mapCenter),
86 "width": 2 * fractionToTiles(0.31),
89 "heightRiverbed": heightSeaGround,
90 "heightLand": heightLand,
95 paintTileClassBasedOnHeight(-Infinity, 0.5, Elevation_ExcludeMin_ExcludeMax, clWater);
97 g_Map.log("Creating shores");
98 for (let i = 0; i < scaleByMapSize(20, 120); ++i)
100 let position = new Vector2D(fractionToTiles(randFloat(0.1, 0.9)), fractionToTiles(randFloat(0.67, 0.74))).rotateAround(startAngle, mapCenter).round();
102 new ChainPlacer(1, Math.floor(scaleByMapSize(4, 6)), Math.floor(scaleByMapSize(16, 30)), Infinity, position),
104 new TerrainPainter(tSnowA),
105 new SmoothElevationPainter(ELEVATION_SET, heightLand, 3),
106 new TileClassUnPainter(clWater)
110 g_Map.log("Creating islands");
112 new ChainPlacer(1, Math.floor(scaleByMapSize(4, 6)), Math.floor(scaleByMapSize(16, 40)), 0.1),
114 new TerrainPainter(tSnowA),
115 new SmoothElevationPainter(ELEVATION_SET, heightLand, 3),
116 new TileClassPainter(clIsland),
117 new TileClassUnPainter(clWater)
119 stayClasses(clWater, 7),
120 scaleByMapSize(10, 80));
122 paintTerrainBasedOnHeight(-6, 1, 1, tWater);
124 g_Map.log("Creating lakes");
126 new ChainPlacer(1, Math.floor(scaleByMapSize(5, 7)), Math.floor(scaleByMapSize(20, 50)), 0.1),
128 new LayeredPainter([tShoreBlend, tShore, tWater], [1, 1]),
129 new SmoothElevationPainter(ELEVATION_SET, heightLake, 3),
130 new TileClassPainter(clWater)
132 avoidClasses(clPlayer, 20, clWater, 20),
133 Math.round(scaleByMapSize(1, 4) * numPlayers));
135 paintTerrainBasedOnHeight(1, 2.8, 1, tShoreBlend);
136 paintTileClassBasedOnHeight(-6, 0.5, 1, clWater);
138 Engine.SetProgress(45);
140 g_Map.log("Creating hills");
142 new ChainPlacer(1, Math.floor(scaleByMapSize(4, 6)), Math.floor(scaleByMapSize(16, 40)), 0.1),
144 new LayeredPainter([tCliff, tSnowA], [3]),
145 new SmoothElevationPainter(ELEVATION_SET, heightHill, 3),
146 new TileClassPainter(clHill)
148 avoidClasses(clPlayer, 20, clHill, 15, clWater, 2, clBaseResource, 2),
149 scaleByMapSize(1, 4) * numPlayers
152 g_Map.log("Creating forests");
153 var [forestTrees, stragglerTrees] = getTreeCounts(100, 625, 0.7);
155 [[tSnowA, tSnowA, tSnowA, tSnowA, pForestD], [tSnowA, tSnowA, tSnowA, pForestD]],
156 [[tSnowA, tSnowA, tSnowA, tSnowA, pForestS], [tSnowA, tSnowA, tSnowA, pForestS]]
159 var size = forestTrees / (scaleByMapSize(3,6) * numPlayers);
161 var num = Math.floor(size / types.length);
162 for (let type of types)
164 new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), forestTrees / (num * Math.floor(scaleByMapSize(2, 4))), Infinity),
166 new LayeredPainter(type, [2]),
167 new TileClassPainter(clForest)
169 avoidClasses(clPlayer, 20, clForest, 20, clHill, 0, clWater, 8),
172 g_Map.log("Creating iceberg");
173 createObjectGroupsDeprecated(
174 new SimpleGroup([new SimpleObject(aIceberg, 0, 2, 0, 4)], true, clRock),
176 [avoidClasses(clRock, 6), stayClasses(clWater, 4)],
177 scaleByMapSize(4, 16),
179 Engine.SetProgress(70);
181 g_Map.log("Creating dirt patches");
182 for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)])
184 new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5),
186 new LayeredPainter([tSnowD, tSnowB, tSnowC], [2, 1]),
187 new TileClassPainter(clDirt)
195 scaleByMapSize(20, 80));
197 for (let size of [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)])
199 new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5),
201 new TerrainPainter(tSnowE),
202 new TileClassPainter(clDirt)
210 scaleByMapSize(20, 80));
212 g_Map.log("Creating stone mines");
213 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);
214 createObjectGroupsDeprecated(group, 0,
215 avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1),
216 scaleByMapSize(8,32), 100
219 g_Map.log("Creating small stone quarries");
220 group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock);
221 createObjectGroupsDeprecated(group, 0,
222 avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1),
223 scaleByMapSize(8,32), 100
226 g_Map.log("Creating metal mines");
227 group = new SimpleGroup([new SimpleObject(oMetalLarge, 1,1, 0,4)], true, clMetal);
228 createObjectGroupsDeprecated(group, 0,
229 avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clMetal, 10, clRock, 5, clHill, 1),
230 scaleByMapSize(8,32), 100
232 Engine.SetProgress(80);
234 createStragglerTrees(
236 avoidClasses(clWater, 5, clForest, 1, clHill, 1, clPlayer, 12, clMetal, 6, clRock, 6),
240 g_Map.log("Creating deer");
241 group = new SimpleGroup(
242 [new SimpleObject(oWalrus, 5,7, 0,4)],
245 createObjectGroupsDeprecated(group, 0,
246 avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 20),
250 Engine.SetProgress(90);
252 g_Map.log("Creating sheep");
253 group = new SimpleGroup(
254 [new SimpleObject(oArcticWolf, 2,3, 0,2)],
257 createObjectGroupsDeprecated(group, 0,
258 avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 20),
262 g_Map.log("Creating fish");
263 group = new SimpleGroup(
264 [new SimpleObject(oFish, 2,3, 0,2)],
267 createObjectGroupsDeprecated(group, 0,
268 [avoidClasses(clFood, 20), stayClasses(clWater, 6)],
272 placePlayersNomad(clPlayer, avoidClasses(clWater, 4, clForest, 1, clMetal, 4, clRock, 4, clHill, 4, clFood, 2, clIsland, 4));
274 setSunColor(0.6, 0.6, 0.6);
275 setSunElevation(Math.PI/ 6);
277 setWaterColor(0.02, 0.17, 0.52);
278 setWaterTint(0.494, 0.682, 0.808);
279 setWaterMurkiness(0.82);
280 setWaterWaviness(0.5);
281 setWaterType("ocean");
284 setFogThickness(0.09);
285 setPPSaturation(0.28);