1 RMS.LoadLibrary("rmgen");
4 const tGrass = ["temp_grass_aut", "temp_grass_aut", "temp_grass_d_aut"];
5 const tForestFloor = "temp_grass_aut";
6 const tGrassA = "temp_grass_plants_aut";
7 const tGrassB = "temp_grass_b_aut";
8 const tGrassC = "temp_grass_c_aut";
9 const tDirt = ["temp_plants_bog_aut", "temp_mud_a"];
10 const tHill = ["temp_highlands_aut", "temp_grass_long_b_aut"];
11 const tCliff = ["temp_cliff_a", "temp_cliff_b"];
12 const tRoad = "temp_road_aut";
13 const tRoadWild = "temp_road_overgrown_aut";
14 const tGrassPatch = "temp_grass_plants_aut";
15 const tShoreBlend = "temp_grass_plants_aut";
16 const tShore = "temp_plants_bog_aut";
17 const tWater = "temp_mud_a";
20 const oBeech = "gaia/flora_tree_euro_beech_aut";
21 const oOak = "gaia/flora_tree_oak_aut";
22 const oPine = "gaia/flora_tree_pine";
23 const oDeer = "gaia/fauna_deer";
24 const oFish = "gaia/fauna_fish";
25 const oSheep = "gaia/fauna_rabbit";
26 const oBerryBush = "gaia/flora_bush_berry";
27 const oStoneLarge = "gaia/geology_stonemine_temperate_quarry";
28 const oStoneSmall = "gaia/geology_stone_temperate";
29 const oMetalLarge = "gaia/geology_metal_temperate_slabs";
30 const oWood = "gaia/special_treasure_wood";
31 const oFood = "gaia/special_treasure_food_bin";
32 const oMetal = "gaia/special_treasure_metal";
33 const oStone = "gaia/special_treasure_stone";
36 const aGrass = "actor|props/flora/grass_soft_dry_small_tall.xml";
37 const aGrassShort = "actor|props/flora/grass_soft_dry_large.xml";
38 const aRockLarge = "actor|geology/stone_granite_med.xml";
39 const aRockMedium = "actor|geology/stone_granite_med.xml";
40 const aReeds = "actor|props/flora/reeds_pond_dry.xml";
41 const aLillies = "actor|props/flora/water_lillies.xml";
42 const aBushMedium = "actor|props/flora/bush_medit_me_dry.xml";
43 const aBushSmall = "actor|props/flora/bush_medit_sm_dry.xml";
45 const pForestD = [tForestFloor + TERRAIN_SEPARATOR + oBeech, tForestFloor];
46 const pForestO = [tForestFloor + TERRAIN_SEPARATOR + oOak, tForestFloor];
47 const pForestP = [tForestFloor + TERRAIN_SEPARATOR + oPine, tForestFloor];
49 log("Initializing map...");
52 const numPlayers = getNumPlayers();
53 const mapSize = getMapSize();
54 const mapArea = mapSize*mapSize;
56 var clPlayer = createTileClass();
57 var clHill = createTileClass();
58 var clForest = createTileClass();
59 var clWater = createTileClass();
60 var clDirt = createTileClass();
61 var clRock = createTileClass();
62 var clMetal = createTileClass();
63 var clFood = createTileClass();
64 var clBaseResource = createTileClass();
65 var clSettlement = createTileClass();
67 // randomize player order
69 for (var i = 0; i < numPlayers; i++)
72 playerIDs = sortPlayers(playerIDs);
75 var playerX = new Array(numPlayers);
76 var playerZ = new Array(numPlayers);
77 var playerAngle = new Array(numPlayers);
80 var startAngle = randFloat(0, TWO_PI);
81 for (var i = 0; i < numPlayers; i++)
83 playerAngle[i] = startAngle + i*TWO_PI/numPlayers;
84 playerX[i] = mapSize*(0.5 + 0.35*cos(playerAngle[i]));
85 playerZ[i] = mapSize*(0.5 + 0.35*sin(playerAngle[i]));
88 for (var i=0; i < numPlayers; i++)
90 var startEntities = getStartingEntities(i);
91 // Place starting entities
92 createStartingPlayerEntities(playerX[i], playerZ[i], i+1, startEntities);
95 for (var j = 1; j < startEntities.length - 1; ++j)
97 var uAngle = BUILDING_ORIENTATION - PI * (2-j) / 2;
98 var count = (startEntities[j].Count !== undefined ? startEntities[j].Count : 1);
99 for (var numberofentities = 0; numberofentities < count; numberofentities++)
101 var ux = playerX[i] + uDist * cos(uAngle) + numberofentities * uSpace * cos(uAngle + PI/2) - (0.75 * uSpace * floor(count / 2) * cos(uAngle + PI/2));
102 var uz = playerZ[i] + uDist * sin(uAngle) + numberofentities * uSpace * sin(uAngle + PI/2) - (0.75 * uSpace * floor(count / 2) * sin(uAngle + PI/2));
103 placeObject(ux, uz, startEntities[j].Template, i+1, uAngle);
108 var bbAngle = BUILDING_ORIENTATION;
110 var bbX = round(playerX[i] + bbDist * cos(bbAngle));
111 var bbZ = round(playerZ[i] + bbDist * sin(bbAngle));
112 var group = new SimpleGroup(
113 [new SimpleObject(oFood, 5,5, 0,2)],
114 true, clBaseResource, bbX, bbZ
116 createObjectGroup(group, 0);
119 var bbX = round(playerX[i] + bbDist * cos(bbAngle));
120 var bbZ = round(playerZ[i] + bbDist * sin(bbAngle));
121 group = new SimpleGroup(
122 [new SimpleObject(oWood, 5,5, 0,2)],
123 true, clBaseResource, bbX, bbZ
125 createObjectGroup(group, 0);
128 var bbX = round(playerX[i] + bbDist * cos(bbAngle));
129 var bbZ = round(playerZ[i] + bbDist * sin(bbAngle));
130 group = new SimpleGroup(
131 [new SimpleObject(oMetal, 3,3, 0,2)],
132 true, clBaseResource, bbX, bbZ
134 createObjectGroup(group, 0);
137 var bbX = round(playerX[i] + bbDist * cos(bbAngle));
138 var bbZ = round(playerZ[i] + bbDist * sin(bbAngle));
139 group = new SimpleGroup(
140 [new SimpleObject(oStone, 2,2, 0,2)],
141 true, clBaseResource, bbX, bbZ
143 createObjectGroup(group, 0);
146 var civ = getCivCode(i);
147 var tilesSize = civ == "cart" ? 27 : 22;
149 const minBoundX = (playerX[i] > tilesSize ? playerX[i] - tilesSize : 0);
150 const minBoundY = (playerZ[i] > tilesSize ? playerZ[i] - tilesSize : 0);
151 const maxBoundX = (playerX[i] < mapSize - tilesSize ? playerX[i] + tilesSize : mapSize);
152 const maxBoundY = (playerZ[i] < mapSize - tilesSize ? playerZ[i] + tilesSize : mapSize);
154 for (var tx = minBoundX; tx < maxBoundX; ++tx)
155 for (var ty = minBoundY; ty < maxBoundY; ++ty)
157 var unboundSumOfXY = tx + ty - minBoundX - minBoundY;
158 if ((unboundSumOfXY > tilesSize) && (unboundSumOfXY < 3 * tilesSize) && (tx - ty + minBoundY - minBoundX < tilesSize) && (ty - tx - minBoundY + minBoundX < tilesSize))
160 placeTerrain(floor(tx), floor(ty), tRoad);
161 addToClass(floor(tx), floor(ty), clPlayer);
165 // Place custom fortress
166 if (civ == "brit" || civ == "gaul" || civ == "iber")
168 var wall = ["gate", "tower", "wallLong",
169 "cornerIn", "wallLong", "barracks", "tower", "wallLong", "tower", "house", "wallLong",
170 "cornerIn", "wallLong", "house", "tower", "gate", "tower", "house", "wallLong",
171 "cornerIn", "wallLong", "house", "tower", "wallLong", "tower", "house", "wallLong",
172 "cornerIn", "wallLong", "house", "tower"];
176 var wall = ["gate", "tower", "wallLong",
177 "cornerIn", "wallLong", "barracks", "tower", "wallLong", "tower", "wallLong",
178 "cornerIn", "wallLong", "house", "tower", "gate", "tower", "wallLong",
179 "cornerIn", "wallLong", "house", "tower", "wallLong", "tower", "wallLong",
180 "cornerIn", "wallLong", "house", "tower"];
182 placeCustomFortress(playerX[i], playerZ[i], new Fortress("Spahbod", wall), civ, i+1);
185 log("Creating lakes...");
186 var numLakes = round(scaleByMapSize(1,4) * numPlayers);
187 var placer = new ClumpPlacer(scaleByMapSize(100,250), 0.8, 0.1, 10);
188 var terrainPainter = new LayeredPainter(
189 [tShore, tWater, tWater], // terrains
192 var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -4, 3);
193 var waterAreas = createAreas(
195 [terrainPainter, elevationPainter, paintClass(clWater)],
196 avoidClasses(clPlayer, 7, clWater, 20),
201 log("Creating reeds...");
202 group = new SimpleGroup(
203 [new SimpleObject(aReeds, 5,10, 0,4), new SimpleObject(aLillies, 0,1, 0,4)], true
205 createObjectGroupsByAreas(group, 0,
206 [borderClasses(clWater, 3, 0), stayClasses(clWater, 1)],
212 log("Creating fish...");
213 createObjectGroupsByAreas(
215 [new SimpleObject(oFish, 1,1, 0,1)],
219 [stayClasses(clWater, 4), avoidClasses(clFood, 8)],
226 createBumps(avoidClasses(clWater, 2, clPlayer, 5));
229 log("Creating hills...");
230 createHills([tCliff, tCliff, tHill], avoidClasses(clPlayer, 5, clWater, 5, clHill, 15), clHill, scaleByMapSize(1, 4) * numPlayers);
233 // calculate desired number of trees for map (based on size)
234 const MIN_TREES = 500;
235 const MAX_TREES = 2500;
236 const P_FOREST = 0.7;
238 var totalTrees = scaleByMapSize(MIN_TREES, MAX_TREES);
239 var numForest = totalTrees * P_FOREST;
240 g_numStragglerTrees = totalTrees * (1.0 - P_FOREST);
242 log("Creating forests...");
244 [[tForestFloor, tGrass, pForestD], [tForestFloor, pForestD]],
245 [[tForestFloor, tGrass, pForestO], [tForestFloor, pForestO]],
246 [[tForestFloor, tGrass, pForestP], [tForestFloor, pForestP]]
248 var size = numForest / (scaleByMapSize(3,6) * numPlayers);
249 var num = floor(size / types.length);
250 for (var i = 0; i < types.length; ++i)
252 placer = new ChainPlacer(1, floor(scaleByMapSize(3, 5)), numForest / num, 0.5);
253 var painter = new LayeredPainter(
254 types[i], // terrains
259 [painter, paintClass(clForest)],
260 avoidClasses(clPlayer, 5, clWater, 3, clForest, 15, clHill, 1),
266 log("Creating dirt patches...");
267 createLayeredPatches(
268 [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)],
269 [[tGrass,tGrassA],[tGrassA,tGrassB], [tGrassB,tGrassC]],
271 avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 1)
275 log("Creating grass patches...");
277 [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)],
279 avoidClasses(clWater, 1, clForest, 0, clHill, 0, clDirt, 5, clPlayer, 1)
283 log("Creating stone mines...");
286 [new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],
287 [new SimpleObject(oStoneSmall, 2,5, 1,3)]
289 avoidClasses(clWater, 0, clForest, 1, clPlayer, 5, clRock, 10, clHill, 1)
293 log("Creating metal mines...");
296 [new SimpleObject(oMetalLarge, 1,1, 0,4)]
298 avoidClasses(clWater, 0, clForest, 1, clPlayer, 5, clMetal, 10, clRock, 5, clHill, 1),
305 [[new SimpleObject(aRockMedium, 1,3, 0,1)],
306 [new SimpleObject(aRockLarge, 1,2, 0,1), new SimpleObject(aRockMedium, 1,3, 0,2)],
307 [new SimpleObject(aGrassShort, 1,2, 0,1, -PI/8,PI/8)],
308 [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)],
309 [new SimpleObject(aBushMedium, 1,2, 0,2), new SimpleObject(aBushSmall, 2,4, 0,2)]
312 scaleByMapSize(16, 262),
313 scaleByMapSize(8, 131),
314 scaleByMapSize(13, 200),
315 scaleByMapSize(13, 200),
316 scaleByMapSize(13, 200)
318 avoidClasses(clWater, 0, clForest, 0, clPlayer, 1, clHill, 0)
326 [new SimpleObject(oSheep, 2,3, 0,2)],
327 [new SimpleObject(oDeer, 5,7, 0,4)]
333 avoidClasses(clWater, 0, clForest, 0, clPlayer, 6, clHill, 1, clFood, 20)
341 [new SimpleObject(oBerryBush, 5,7, 0,4)]
344 randInt(1, 4) * numPlayers + 2
346 avoidClasses(clWater, 2, clForest, 0, clPlayer, 6, clHill, 1, clFood, 10)
351 log("Creating straggler trees...");
352 var types = [oOak, oBeech, oPine]; // some variation
353 createStragglerTrees(types, avoidClasses(clWater, 1, clForest, 1, clHill, 1, clPlayer, 1, clMetal, 1, clRock, 1));
357 setWaterColor(0.157, 0.149, 0.443);
358 setWaterTint(0.443,0.42,0.824);
359 setWaterWaviness(2.0);
360 setWaterType("lake");
361 setWaterMurkiness(0.83);
364 setFogThickness(0.22);
365 setFogColor(0.82,0.82, 0.73);
366 setPPSaturation(0.56);