1 Engine.LoadLibrary("rmgen");
2 Engine.LoadLibrary("rmgen-common");
4 const tGrass = ["tropic_grass_c", "tropic_grass_c", "tropic_grass_c", "tropic_grass_c", "tropic_grass_plants", "tropic_plants", "tropic_plants_b"];
5 const tGrassA = "tropic_plants_c";
6 const tGrassB = "tropic_plants_c";
7 const tGrassC = "tropic_grass_c";
8 const tForestFloor = "tropic_grass_plants";
9 const tCliff = ["tropic_cliff_a", "tropic_cliff_a", "tropic_cliff_a", "tropic_cliff_a_plants"];
10 const tPlants = "tropic_plants";
11 const tRoad = "tropic_citytile_a";
12 const tRoadWild = "tropic_citytile_plants";
13 const tShoreBlend = "tropic_beach_dry_plants";
14 const tShore = "tropic_beach_dry";
15 const tWater = "tropic_beach_wet";
17 const oTree = "gaia/flora_tree_toona";
18 const oPalm = "gaia/flora_tree_palm_tropic";
19 const oStoneLarge = "gaia/geology_stonemine_tropic_quarry";
20 const oStoneSmall = "gaia/geology_stone_tropic_a";
21 const oMetalLarge = "gaia/geology_metal_tropic_slabs";
22 const oFish = "gaia/fauna_fish";
23 const oDeer = "gaia/fauna_deer";
24 const oSheep = "gaia/fauna_tiger";
25 const oBush = "gaia/flora_bush_berry";
27 const aRockLarge = "actor|geology/stone_granite_large.xml";
28 const aRockMedium = "actor|geology/stone_granite_med.xml";
29 const aBush1 = "actor|props/flora/plant_tropic_a.xml";
30 const aBush2 = "actor|props/flora/plant_lg.xml";
31 const aBush3 = "actor|props/flora/plant_tropic_large.xml";
33 const pForestD = [tForestFloor + TERRAIN_SEPARATOR + oTree, tForestFloor];
34 const pForestP = [tForestFloor + TERRAIN_SEPARATOR + oPalm, tForestFloor];
36 const heightSeaGround = -5;
38 const heightHill = 25;
40 var g_Map = new RandomMap(heightLand, tGrass);
42 const numPlayers = getNumPlayers();
43 const mapCenter = g_Map.getCenter();
44 const mapBounds = g_Map.getBounds();
46 var clPlayer = g_Map.createTileClass();
47 var clHill = g_Map.createTileClass();
48 var clForest = g_Map.createTileClass();
49 var clWater = g_Map.createTileClass();
50 var clDirt = g_Map.createTileClass();
51 var clRock = g_Map.createTileClass();
52 var clMetal = g_Map.createTileClass();
53 var clFood = g_Map.createTileClass();
54 var clBaseResource = g_Map.createTileClass();
56 var waterPosition = fractionToTiles(0.31);
57 var playerPosition = fractionToTiles(0.55);
58 var mountainPosition = fractionToTiles(0.69);
60 var startAngle = randomAngle();
65 playerPlacementLine(0, new Vector2D(mapCenter.x, playerPosition), fractionToTiles(0.2)).map(pos => pos.rotateAround(startAngle, mapCenter))
67 "PlayerTileClass": clPlayer,
68 "BaseResourceClass": clBaseResource,
70 "outerTerrain": tRoadWild,
80 { "template": oMetalLarge },
81 { "template": oStoneLarge }
86 "count": scaleByMapSize(12, 30),
94 Engine.SetProgress(15);
98 "start": new Vector2D(mapBounds.left, mapBounds.top).rotateAround(startAngle - Math.PI / 2, mapCenter),
99 "end": new Vector2D(mapBounds.left, mapBounds.bottom).rotateAround(startAngle - Math.PI / 2, mapCenter),
100 "width": 2 * waterPosition,
103 "heightRiverbed": heightSeaGround,
104 "heightLand": heightLand,
107 "waterFunc": (position, height, riverFraction) => {
108 clWater.add(position);
112 g_Map.log("Marking mountain area");
113 var areaMountains = createArea(
114 new ConvexPolygonPlacer(
116 new Vector2D(mountainPosition, mapBounds.top),
117 new Vector2D(mountainPosition, mapBounds.bottom),
118 new Vector2D(mapBounds.right, mapBounds.top),
119 new Vector2D(mapBounds.right, mapBounds.bottom)
120 ].map(pos => pos.rotateAround(startAngle - Math.PI / 2, mapCenter)),
123 g_Map.log("Creating shores");
124 for (let i = 0; i < scaleByMapSize(20, 120); ++i)
126 let position = new Vector2D(fractionToTiles(randFloat(0.28, 0.34)), fractionToTiles(randFloat(0.1, 0.9))).rotateAround(startAngle - Math.PI / 2, mapCenter).round();
128 new ChainPlacer(1, Math.floor(scaleByMapSize(4, 6)), Math.floor(scaleByMapSize(16, 30)), Infinity, position),
130 new LayeredPainter([tGrass, tGrass], [2]),
131 new SmoothElevationPainter(ELEVATION_SET, heightLand, 3),
132 new TileClassUnPainter(clWater)
136 paintTerrainBasedOnHeight(-6, 1, 1, tWater);
137 paintTerrainBasedOnHeight(1, 2.8, 1, tShoreBlend);
138 paintTerrainBasedOnHeight(0, 1, 1, tShore);
139 paintTileClassBasedOnHeight(-6, 0.5, 1, clWater);
141 Engine.SetProgress(45);
143 g_Map.log("Creating hills");
145 new ChainPlacer(1, Math.floor(scaleByMapSize(4, 6)), Math.floor(scaleByMapSize(16, 40)), 0.1),
147 new LayeredPainter([tCliff, tGrass], [3]),
148 new SmoothElevationPainter(ELEVATION_SET, heightHill, 3),
149 new TileClassPainter(clHill)
151 avoidClasses(clPlayer, 20, clHill, 5, clWater, 2, clBaseResource, 2),
152 scaleByMapSize(5, 100),
156 g_Map.log("Creating forests");
157 var [forestTrees, stragglerTrees] = getTreeCounts(1000, 6000, 0.7);
159 [[tGrass, tGrass, tGrass, tGrass, pForestD], [tGrass, tGrass, tGrass, pForestD]],
160 [[tGrass, tGrass, tGrass, tGrass, pForestP], [tGrass, tGrass, tGrass, pForestP]]
162 var size = forestTrees / (scaleByMapSize(3,6) * numPlayers);
163 var num = Math.floor(size / types.length);
164 for (let type of types)
168 Math.floor(scaleByMapSize(3, 5)),
169 forestTrees / (num * Math.floor(scaleByMapSize(2, 4))),
172 new LayeredPainter(type, [2]),
173 new TileClassPainter(clForest)
175 avoidClasses(clPlayer, 20, clForest, 10, clHill, 0, clWater, 8),
178 Engine.SetProgress(70);
180 g_Map.log("Creating grass patches");
181 for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)])
183 new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5),
185 new LayeredPainter([tGrassC, tGrassA, tGrassB], [2, 1]),
186 new TileClassPainter(clDirt)
188 avoidClasses(clWater, 8, clForest, 0, clHill, 0, clPlayer, 12, clDirt, 16),
189 scaleByMapSize(20, 80));
191 for (let size of [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)])
193 new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5),
195 new TerrainPainter(tPlants),
196 new TileClassPainter(clDirt)
198 avoidClasses(clWater, 8, clForest, 0, clHill, 0, clPlayer, 12, clDirt, 16),
199 scaleByMapSize(20, 80));
201 g_Map.log("Creating stone mines");
202 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);
203 createObjectGroupsDeprecated(group, 0,
204 avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1),
205 scaleByMapSize(4,16), 100
208 g_Map.log("Creating small stone quarries");
209 group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock);
210 createObjectGroupsDeprecated(group, 0,
211 avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1),
212 scaleByMapSize(4,16), 100
215 g_Map.log("Creating metal mines");
216 group = new SimpleGroup([new SimpleObject(oMetalLarge, 1,1, 0,4)], true, clMetal);
217 createObjectGroupsDeprecated(group, 0,
218 avoidClasses(clWater, 3, clForest, 1, clPlayer, 20, clMetal, 10, clRock, 5, clHill, 1),
219 scaleByMapSize(4,16), 100
222 g_Map.log("Creating small decorative rocks");
223 group = new SimpleGroup(
224 [new SimpleObject(aRockMedium, 1,3, 0,1)],
227 createObjectGroupsDeprecated(
229 avoidClasses(clWater, 0, clForest, 0, clPlayer, 0, clHill, 0),
230 3*scaleByMapSize(16, 262), 50
233 g_Map.log("Creating large decorative rocks");
234 group = new SimpleGroup(
235 [new SimpleObject(aRockLarge, 1,2, 0,1), new SimpleObject(aRockMedium, 1,3, 0,2)],
238 createObjectGroupsDeprecated(
240 avoidClasses(clWater, 0, clForest, 0, clPlayer, 0, clHill, 0),
241 3*scaleByMapSize(8, 131), 50
244 g_Map.log("Creating small grass tufts");
245 group = new SimpleGroup(
246 [new SimpleObject(aBush1, 1,2, 0,1, -Math.PI / 8, Math.PI / 8)]
248 createObjectGroupsDeprecated(group, 0,
249 avoidClasses(clWater, 2, clHill, 2, clPlayer, 2, clDirt, 0),
250 8 * scaleByMapSize(13, 200)
253 Engine.SetProgress(90);
255 g_Map.log("Creating large grass tufts");
256 group = new SimpleGroup(
257 [new SimpleObject(aBush2, 2,4, 0,1.8, -Math.PI / 8, Math.PI / 8), new SimpleObject(aBush1, 3,6, 1.2,2.5, -Math.PI / 8, Math.PI / 8)]
259 createObjectGroupsDeprecated(group, 0,
260 avoidClasses(clWater, 3, clHill, 2, clPlayer, 2, clDirt, 1, clForest, 0),
261 8 * scaleByMapSize(13, 200)
264 Engine.SetProgress(95);
266 g_Map.log("Creating bushes");
267 group = new SimpleGroup(
268 [new SimpleObject(aBush3, 1,2, 0,2), new SimpleObject(aBush2, 2,4, 0,2)]
270 createObjectGroupsDeprecated(group, 0,
271 avoidClasses(clWater, 1, clHill, 1, clPlayer, 1, clDirt, 1),
272 8 * scaleByMapSize(13, 200), 50
275 Engine.SetProgress(96);
277 createStragglerTrees(
279 avoidClasses(clWater, 5, clForest, 1, clHill, 1, clPlayer, 12, clMetal, 6, clRock, 6),
283 g_Map.log("Creating deer");
284 group = new SimpleGroup(
285 [new SimpleObject(oDeer, 5,7, 0,4)],
288 createObjectGroupsDeprecated(group, 0,
289 avoidClasses(clWater, 3, clForest, 0, clPlayer, 10, clHill, 1, clFood, 20),
293 Engine.SetProgress(97);
295 g_Map.log("Creating berry bush");
296 group = new SimpleGroup(
297 [new SimpleObject(oBush, 5,7, 0,4)],
300 createObjectGroupsDeprecated(group, 0,
301 avoidClasses(clWater, 6, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10),
302 randIntInclusive(1, 4) * numPlayers + 2, 50
305 g_Map.log("Creating sheep");
306 group = new SimpleGroup(
307 [new SimpleObject(oSheep, 2,3, 0,2)],
310 createObjectGroupsDeprecated(group, 0,
311 avoidClasses(clWater, 3, clForest, 0, clPlayer, 22, clHill, 1, clFood, 20),
315 g_Map.log("Creating fish");
316 group = new SimpleGroup(
317 [new SimpleObject(oFish, 2,3, 0,2)],
320 createObjectGroupsDeprecated(group, 0,
321 [avoidClasses(clFood, 20), stayClasses(clWater, 6)],
325 placePlayersNomad(clPlayer, avoidClasses(clWater, 4, clHill, 2, clForest, 1, clMetal, 4, clRock, 4, clFood, 2));
327 setSunColor(0.6, 0.6, 0.6);
328 setSunElevation(Math.PI / 3);
330 setWaterColor(0.524,0.734,0.839);
331 setWaterTint(0.369,0.765,0.745);
332 setWaterWaviness(1.0);
333 setWaterType("ocean");
334 setWaterMurkiness(0.35);
337 setFogThickness(0.2);
341 setPPSaturation(0.65);