1 RMS.LoadLibrary("rmgen");
3 const tGrass = ["temp_grass", "temp_grass", "temp_grass_d"];
4 const tGrassPForest = "temp_plants_bog";
5 const tGrassDForest = "temp_plants_bog";
6 const tGrassA = "temp_grass_plants";
7 const tGrassB = "temp_plants_bog";
8 const tGrassC = "temp_mud_a";
9 const tDirt = ["temp_plants_bog", "temp_mud_a"];
10 const tHill = ["temp_highlands", "temp_grass_long_b"];
11 const tCliff = ["temp_cliff_a", "temp_cliff_b"];
12 const tRoad = "temp_road";
13 const tRoadWild = "temp_road_overgrown";
14 const tGrassPatchBlend = "temp_grass_long_b";
15 const tGrassPatch = ["temp_grass_d", "temp_grass_clovers"];
16 const tShoreBlend = "temp_grass_plants";
17 const tShore = "temp_dirt_gravel";
18 const tWater = "temp_dirt_gravel_b";
20 const oBeech = "gaia/flora_tree_euro_beech";
21 const oPoplar = "gaia/flora_tree_poplar";
22 const oApple = "gaia/flora_tree_apple";
23 const oOak = "gaia/flora_tree_oak";
24 const oBerryBush = "gaia/flora_bush_berry";
25 const oDeer = "gaia/fauna_deer";
26 const oFish = "gaia/fauna_fish";
27 const oGoat = "gaia/fauna_goat";
28 const oBoar = "gaia/fauna_boar";
29 const oStoneLarge = "gaia/geology_stonemine_temperate_quarry";
30 const oStoneSmall = "gaia/geology_stone_temperate";
31 const oMetalLarge = "gaia/geology_metal_temperate_slabs";
33 const aGrass = "actor|props/flora/grass_soft_large_tall.xml";
34 const aGrassShort = "actor|props/flora/grass_soft_large.xml";
35 const aRockLarge = "actor|geology/stone_granite_large.xml";
36 const aRockMedium = "actor|geology/stone_granite_med.xml";
37 const aBushMedium = "actor|props/flora/bush_medit_me_lush.xml";
38 const aBushSmall = "actor|props/flora/bush_medit_sm_lush.xml";
39 const aReeds = "actor|props/flora/reeds_pond_lush_a.xml";
40 const aLillies = "actor|props/flora/water_lillies.xml";
42 // terrain + entity (for painting)
43 const pForestD = [tGrassDForest + TERRAIN_SEPARATOR + oBeech, tGrassDForest];
44 const pForestP = [tGrassPForest + TERRAIN_SEPARATOR + oOak, tGrassPForest];
46 const WATER_WIDTH = 0.25;
50 const numPlayers = getNumPlayers();
51 const mapSize = getMapSize();
52 const mapArea = mapSize*mapSize;
54 var clPlayer = createTileClass();
55 var clHill = createTileClass();
56 var clForest = createTileClass();
57 var clWater = createTileClass();
58 var clDirt = createTileClass();
59 var clRock = createTileClass();
60 var clMetal = createTileClass();
61 var clFood = createTileClass();
62 var clBaseResource = createTileClass();
63 var clSettlement = createTileClass();
64 var clShallow = createTileClass();
66 var playerIDs = primeSortAllPlayers();
67 var playerPos = placePlayersRiver();
72 for (var i = 0; i < numPlayers; i++)
74 playerZ[i] = 0.2 + 0.6*(i%2);
75 playerX[i] = playerPos[i];
78 for (var i = 0; i < numPlayers; i++)
80 var id = playerIDs[i];
81 log("Creating base for player " + id + "...");
83 var radius = scaleByMapSize(15,25);
87 // get the x and z in tiles
88 var fx = fractionToTiles(playerX[i]);
89 var fz = fractionToTiles(playerZ[i]);
93 addToClass(ix, iz, clPlayer);
94 addToClass(ix+5, iz, clPlayer);
95 addToClass(ix, iz+5, clPlayer);
96 addToClass(ix-5, iz, clPlayer);
97 addToClass(ix, iz-5, clPlayer);
99 // create the city patch
100 var cityRadius = radius/3;
101 var placer = new ClumpPlacer(PI*cityRadius*cityRadius, 0.6, 0.3, 10, ix, iz);
102 var painter = new LayeredPainter([tRoadWild, tRoad], [1]);
103 createArea(placer, [painter, paintClass(clPlayer)], null);
105 placeCivDefaultEntities(fx, fz, id);
107 placeDefaultChicken(fx, fz, clBaseResource);
109 // create berry bushes
110 var bbAngle = randFloat(0, TWO_PI);
112 var bbX = round(fx + bbDist * cos(bbAngle));
113 var bbZ = round(fz + bbDist * sin(bbAngle));
114 var group = new SimpleGroup(
115 [new SimpleObject(oBerryBush, 5,5, 0,3)],
116 true, clBaseResource, bbX, bbZ
118 createObjectGroup(group, 0);
121 var mAngle = bbAngle;
122 while(abs(mAngle - bbAngle) < PI/3)
123 mAngle = randFloat(0, TWO_PI);
126 var mX = round(fx + mDist * cos(mAngle));
127 var mZ = round(fz + mDist * sin(mAngle));
128 group = new SimpleGroup(
129 [new SimpleObject(oMetalLarge, 1,1, 0,0)],
130 true, clBaseResource, mX, mZ
132 createObjectGroup(group, 0);
134 // create stone mines
135 mAngle += randFloat(PI/8, PI/4);
136 mX = round(fx + mDist * cos(mAngle));
137 mZ = round(fz + mDist * sin(mAngle));
138 group = new SimpleGroup(
139 [new SimpleObject(oStoneLarge, 1,1, 0,2)],
140 true, clBaseResource, mX, mZ
142 createObjectGroup(group, 0);
144 // create starting trees
146 var tAngle = randFloat(-PI/3, 4*PI/3);
147 var tDist = randFloat(11, 13);
148 var tX = round(fx + tDist * cos(tAngle));
149 var tZ = round(fz + tDist * sin(tAngle));
150 group = new SimpleGroup(
151 [new SimpleObject(oOak, num, num, 0,5)],
152 false, clBaseResource, tX, tZ
154 createObjectGroup(group, 0, avoidClasses(clBaseResource,2));
156 placeDefaultDecoratives(fx, fz, aGrassShort, clBaseResource, radius);
162 var theta = randFloat(0, 1);
163 var theta2 = randFloat(0, 1);
165 var seed = randFloat(2,3);
166 var seed2 = randFloat(2,3);
168 for (var ix = 0; ix < mapSize; ix++)
169 for (var iz = 0; iz < mapSize; iz++)
171 var x = ix / (mapSize + 1.0);
172 var z = iz / (mapSize + 1.0);
174 // add the rough shape of the water
175 var km = 20/scaleByMapSize(35, 160);
179 var cu = km*rndRiver(theta+x*0.5*(mapSize/64),seed);
180 var cu2 = km*rndRiver(theta2+x*0.5*(mapSize/64),seed2);
182 if (z > cu + 0.5 - WATER_WIDTH/2 &&
183 z < cu2 + 0.5 + WATER_WIDTH/2)
186 if (z < (cu + 0.5 + fadeDist - WATER_WIDTH/2))
187 h = 3 - 7 * (1 - ((cu + 0.5 + fadeDist - WATER_WIDTH/2) - z)/fadeDist);
188 else if (z > (cu2 + 0.5 - fadeDist + WATER_WIDTH/2))
189 h = 3 - 7 * (1 - (z - (cu2 + 0.5 - fadeDist + WATER_WIDTH/2))/fadeDist);
194 placeTerrain(ix, iz, tWater);
196 placeTerrain(ix, iz, tShore);
198 setHeight(ix, iz, h);
201 setHeight(ix, iz, 3.1);
205 log("Creating rivers");
206 for (let i = 0; i <= randIntInclusive(8, scaleByMapSize(12, 20)); ++i)
208 var cLocation = randFloat(0.05, 0.95);
210 var sign = randBool() ? 1 : -1;
211 var tang = sign * PI * randFloat(0.2, 0.8);
212 var cDistance = sign * 0.05;
214 var point = getTIPIADBON([fractionToTiles(cLocation), fractionToTiles(0.5 + cDistance)], [fractionToTiles(cLocation), fractionToTiles(0.5 - cDistance)], [-6, -1.5], 0.5, 4, 0.01);
215 if (point !== undefined)
217 var placer = new PathPlacer(floor(point[0]), floor(point[1]), floor(fractionToTiles(0.5 + 0.49*cos(tang))), floor(fractionToTiles(0.5 + 0.49*sin(tang))), scaleByMapSize(10,20), 0.4, 3*(scaleByMapSize(1,4)), 0.1, 0.05);
218 var terrainPainter = new LayeredPainter(
219 [tShore, tWater, tWater], // terrains
222 var elevationPainter = new SmoothElevationPainter(
223 ELEVATION_SET, // type
227 var success = createArea(placer, [terrainPainter, elevationPainter, paintClass(clWater)], avoidClasses(clPlayer, 8, clWater, 3, clShallow, 2));
228 if (success !== undefined)
230 placer = new ClumpPlacer(floor(PI*scaleByMapSize(10,20)*scaleByMapSize(10,20)/4), 0.95, 0.6, 10, fractionToTiles(0.5 + 0.49*cos(tang)), fractionToTiles(0.5 + 0.49*sin(tang)));
231 var painter = new LayeredPainter(
232 [tShore, tWater, tWater], // terrains
235 var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -3, 3);
236 createArea(placer, [painter, elevationPainter], avoidClasses(clPlayer, 23));
241 passageMaker(round(fractionToTiles(0.2)), round(fractionToTiles(0.25)), round(fractionToTiles(0.8)), round(fractionToTiles(0.25)), scaleByMapSize(4,8), -2, -2, 2, clShallow, undefined, -4);
242 passageMaker(round(fractionToTiles(0.2)), round(fractionToTiles(0.75)), round(fractionToTiles(0.8)), round(fractionToTiles(0.75)), scaleByMapSize(4,8), -2, -2, 2, clShallow, undefined, -4);
244 paintTerrainBasedOnHeight(-5, 1, 1, tWater);
245 paintTerrainBasedOnHeight(1, 3, 1, tShore);
246 paintTileClassBasedOnHeight(-6, 0.5, 1, clWater);
249 createBumps(avoidClasses(clWater, 5, clPlayer, 20));
252 createHills([tCliff, tCliff, tHill], avoidClasses(clPlayer, 20, clHill, 15, clWater, 5), clHill, scaleByMapSize(1, 4) * numPlayers);
256 [tGrass, tGrassDForest, tGrassDForest, pForestD, pForestD],
257 avoidClasses(clPlayer, 20, clForest, 17, clHill, 0, clWater, 6),
263 log("Creating dirt patches...");
264 createLayeredPatches(
265 [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
266 [[tGrass,tGrassA], tGrassB, [tGrassB,tGrassC]],
268 avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 6)
271 log("Creating grass patches...");
273 [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
274 [tGrassPatchBlend, tGrassPatch],
276 avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 6)
280 log("Creating stone mines...");
283 [new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],
284 [new SimpleObject(oStoneSmall, 2,5, 1,3)]
286 avoidClasses(clWater, 2, clForest, 1, clPlayer, 20, clRock, 10, clHill, 2)
289 log("Creating metal mines...");
292 [new SimpleObject(oMetalLarge, 1,1, 0,4)]
294 avoidClasses(clWater, 2, clForest, 1, clPlayer, 20, clMetal, 10, clRock, 5, clHill, 2),
301 [[new SimpleObject(aRockMedium, 1,3, 0,1)],
302 [new SimpleObject(aRockLarge, 1,2, 0,1), new SimpleObject(aRockMedium, 1,3, 0,2)],
303 [new SimpleObject(aGrassShort, 1,2, 0,1, -PI/8,PI/8)],
304 [new SimpleObject(aGrass, 2,4, 0,1.8, -PI/8,PI/8), new SimpleObject(aGrassShort, 3,6, 1.2,2.5, -PI/8,PI/8)],
305 [new SimpleObject(aBushMedium, 1,2, 0,2), new SimpleObject(aBushSmall, 2,4, 0,2)]
308 scaleByMapSize(16, 262),
309 scaleByMapSize(8, 131),
310 scaleByMapSize(13, 200),
311 scaleByMapSize(13, 200),
312 scaleByMapSize(13, 200)
314 avoidClasses(clWater, 1, clForest, 0, clPlayer, 0, clHill, 0)
317 // create water decoration in the shallow parts
320 [[new SimpleObject(aReeds, 1,3, 0,1)],
321 [new SimpleObject(aLillies, 1,2, 0,1)]
324 scaleByMapSize(800, 12800),
325 scaleByMapSize(800, 12800)
327 stayClasses(clShallow, 0)
333 [new SimpleObject(oDeer, 5,7, 0,4)],
334 [new SimpleObject(oGoat, 2,3, 0,2)],
335 [new SimpleObject(oBoar, 2,3, 0,2)]
342 avoidClasses(clWater, 1, clForest, 0, clPlayer, 20, clHill, 0, clFood, 15)
348 [new SimpleObject(oBerryBush, 5,7, 0,4)]
351 randIntInclusive(1, 4) * numPlayers + 2
353 avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10)
359 [new SimpleObject(oFish, 2,3, 0,2)]
361 [scaleByMapSize(3, 25) * numPlayers],
362 [avoidClasses(clFood, 6), stayClasses(clWater, 4)]
365 log("Creating straggler trees...");
366 var types = [oBeech, oPoplar, oApple]; // some variation
367 createStragglerTrees(types, avoidClasses(clWater, 1, clForest, 1, clHill, 1, clPlayer, 8, clMetal, 6, clRock, 6));
370 setWaterColor(0.114, 0.192, 0.463);
371 setWaterTint(0.255, 0.361, 0.651);
372 setWaterWaviness(3.0);
373 setWaterType("ocean");
374 setWaterMurkiness(0.83);
376 setFogThickness(0.35);
380 setPPSaturation(0.62);