1 RMS.LoadLibrary("rmgen");
2 RMS.LoadLibrary("rmbiome");
6 const tMainTerrain = g_Terrains.mainTerrain;
7 const tForestFloor1 = g_Terrains.forestFloor1;
8 const tForestFloor2 = g_Terrains.forestFloor2;
9 const tCliff = g_Terrains.cliff;
10 const tTier1Terrain = g_Terrains.tier1Terrain;
11 const tTier2Terrain = g_Terrains.tier2Terrain;
12 const tTier3Terrain = g_Terrains.tier3Terrain;
13 const tHill = g_Terrains.mainTerrain;
14 const tDirt = g_Terrains.dirt;
15 const tRoad = g_Terrains.road;
16 const tRoadWild = g_Terrains.roadWild;
17 const tTier4Terrain = g_Terrains.tier4Terrain;
18 const tShoreBlend = g_Terrains.shoreBlend;
19 const tShore = g_Terrains.shore;
20 const tWater = g_Terrains.water;
23 const oTree1 = g_Gaia.tree1;
24 const oTree2 = g_Gaia.tree2;
25 const oTree3 = g_Gaia.tree3;
26 const oTree4 = g_Gaia.tree4;
27 const oTree5 = g_Gaia.tree5;
28 const oFruitBush = g_Gaia.fruitBush;
29 const oMainHuntableAnimal = g_Gaia.mainHuntableAnimal;
30 const oFish = g_Gaia.fish;
31 const oSecondaryHuntableAnimal = g_Gaia.secondaryHuntableAnimal;
32 const oStoneLarge = g_Gaia.stoneLarge;
33 const oStoneSmall = g_Gaia.stoneSmall;
34 const oMetalLarge = g_Gaia.metalLarge;
37 const aGrass = g_Decoratives.grass;
38 const aGrassShort = g_Decoratives.grassShort;
39 const aReeds = g_Decoratives.reeds;
40 const aLillies = g_Decoratives.lillies;
41 const aRockLarge = g_Decoratives.rockLarge;
42 const aRockMedium = g_Decoratives.rockMedium;
43 const aBushMedium = g_Decoratives.bushMedium;
44 const aBushSmall = g_Decoratives.bushSmall;
46 const pForest1 = [tForestFloor2 + TERRAIN_SEPARATOR + oTree1, tForestFloor2 + TERRAIN_SEPARATOR + oTree2, tForestFloor2];
47 const pForest2 = [tForestFloor1 + TERRAIN_SEPARATOR + oTree4, tForestFloor1 + TERRAIN_SEPARATOR + oTree5, tForestFloor1];
49 log("Initializing map...");
53 const numPlayers = getNumPlayers();
54 const mapSize = getMapSize();
55 const mapArea = mapSize*mapSize;
59 // create tile classes
61 var clPlayer = createTileClass();
62 var clHill = createTileClass();
63 var clForest = createTileClass();
64 var clDirt = createTileClass();
65 var clRock = createTileClass();
66 var clMetal = createTileClass();
67 var clFood = createTileClass();
68 var clBaseResource = createTileClass();
69 var clSettlement = createTileClass();
70 var clLand = createTileClass();
74 for (var ix = 0; ix < mapSize; ix++)
76 for (var iz = 0; iz < mapSize; iz++)
78 var x = ix / (mapSize + 1.0);
79 var z = iz / (mapSize + 1.0);
80 placeTerrain(ix, iz, tWater);
84 const radius = scaleByMapSize(15,30);
85 const cliffRadius = 2;
87 // randomize player order
90 for (var i = 0; i < numPlayers; i++)
94 playerIDs = sortPlayers(playerIDs);
98 var playerX = new Array(numPlayers);
99 var playerZ = new Array(numPlayers);
100 var playerAngle = new Array(numPlayers);
102 var startAngle = randFloat(0, TWO_PI);
103 for (var i = 0; i < numPlayers; i++)
105 playerAngle[i] = startAngle + i*TWO_PI/numPlayers;
106 playerX[i] = 0.5 + 0.35*cos(playerAngle[i]);
107 playerZ[i] = 0.5 + 0.35*sin(playerAngle[i]);
110 // Creating other islands
112 //****************************
113 //----------------------------
114 //Tiny and Small Size
115 //----------------------------
116 //****************************
117 if ((mapSize == 128)||(mapSize == 192)){
121 if (numPlayers == 2){
122 numIslands = 4*numPlayers+1;
123 var IslandX = new Array(numIslands);
124 var IslandZ = new Array(numIslands);
125 var isConnected = new Array(numIslands);
126 for (var q=0; q <numIslands; q++)
128 isConnected[q]=new Array(numIslands);
130 for (var m = 0; m < numIslands; m++){
131 for (var n = 0; n < numIslands; n++){
132 isConnected[m][n] = 0;
138 for (var l = 0; l < numPlayers; l++)
140 isConnected[4*numPlayers][l+2*numPlayers] = 1;
141 sX = sX + playerX[l];
142 sZ = sZ + playerZ[l];
145 var fx = fractionToTiles(sX/numPlayers);
146 var fz = fractionToTiles(sZ/numPlayers);
149 IslandX[4*numPlayers]=ix;
150 IslandZ[4*numPlayers]=iz;
151 // calculate size based on the radius
152 var hillSize = floor(PI * radius * radius * 0.36);
155 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
156 var terrainPainter = new LayeredPainter(
157 [tCliff, tHill], // terrains
158 [cliffRadius] // widths
160 var elevationPainter = new SmoothElevationPainter(
161 ELEVATION_SET, // type
162 elevation, // elevation
163 cliffRadius // blend radius
165 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
166 //centeral island id numPlayers
168 for (var e = 0; e <numPlayers; e++)
170 isConnected[e+2*numPlayers][e] = 1;
171 if (e+2*numPlayers+1<numIslands-numPlayers-1)
173 isConnected[e+2*numPlayers][e+2*numPlayers+1] = 1;
177 isConnected[2*numPlayers][e+2*numPlayers] = 1;
180 var fx = fractionToTiles(0.5 + 0.16*cos(startAngle + e*TWO_PI/numPlayers));
181 var fz = fractionToTiles(0.5 + 0.16*sin(startAngle + e*TWO_PI/numPlayers));
184 IslandX[e+2*numPlayers]=ix;
185 IslandZ[e+2*numPlayers]=iz;
186 // calculate size based on the radius
187 var hillSize = floor(PI * radius * radius * 0.81);
190 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
191 var terrainPainter = new LayeredPainter(
192 [tCliff, tHill], // terrains
193 [cliffRadius] // widths
195 var elevationPainter = new SmoothElevationPainter(
196 ELEVATION_SET, // type
197 elevation, // elevation
198 cliffRadius // blend radius
200 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
203 isConnected[e+3*numPlayers][e+numPlayers] = 1;
204 var fx = fractionToTiles(0.5 + 0.27*cos(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
205 var fz = fractionToTiles(0.5 + 0.27*sin(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
208 IslandX[e+3*numPlayers]=ix;
209 IslandZ[e+3*numPlayers]=iz;
210 // calculate size based on the radius
211 var hillSize = floor(PI * radius * radius * 0.49);
214 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
215 var terrainPainter = new LayeredPainter(
216 [tCliff, tHill], // terrains
217 [cliffRadius] // widths
219 var elevationPainter = new SmoothElevationPainter(
220 ELEVATION_SET, // type
221 elevation, // elevation
222 cliffRadius // blend radius
224 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
227 for (var e = 0; e <numPlayers; e++)
229 isConnected[e][e+numPlayers] = 1;
232 isConnected[e + 1][e+numPlayers] = 1;
236 isConnected[0][e+numPlayers] = 1;
240 var fx = fractionToTiles(0.5 + 0.41*cos(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
241 var fz = fractionToTiles(0.5 + 0.41*sin(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
244 IslandX[e+numPlayers]=ix;
245 IslandZ[e+numPlayers]=iz;
246 // calculate size based on the radius
247 var hillSize = PI * radius * radius;
250 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
251 var terrainPainter = new LayeredPainter(
252 [tCliff, tHill], // terrains
253 [cliffRadius] // widths
255 var elevationPainter = new SmoothElevationPainter(
256 ELEVATION_SET, // type
257 elevation, // elevation
258 cliffRadius // blend radius
260 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
266 if (numPlayers == 3){
267 numIslands = 4*numPlayers+1;
268 var IslandX = new Array(numIslands);
269 var IslandZ = new Array(numIslands);
270 var isConnected = new Array(numIslands);
271 for (var q=0; q <numIslands; q++)
273 isConnected[q]=new Array(numIslands);
275 for (var m = 0; m < numIslands; m++){
276 for (var n = 0; n < numIslands; n++){
277 isConnected[m][n] = 0;
283 for (var l = 0; l < numPlayers; l++)
285 isConnected[4*numPlayers][l+2*numPlayers] = 1;
286 sX = sX + playerX[l];
287 sZ = sZ + playerZ[l];
290 var fx = fractionToTiles(sX/numPlayers);
291 var fz = fractionToTiles(sZ/numPlayers);
294 IslandX[4*numPlayers]=ix;
295 IslandZ[4*numPlayers]=iz;
296 // calculate size based on the radius
297 var hillSize = floor(PI * radius * radius * 0.36);
300 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
301 var terrainPainter = new LayeredPainter(
302 [tCliff, tHill], // terrains
303 [cliffRadius] // widths
305 var elevationPainter = new SmoothElevationPainter(
306 ELEVATION_SET, // type
307 elevation, // elevation
308 cliffRadius // blend radius
310 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
311 //centeral island id numPlayers
313 for (var e = 0; e <numPlayers; e++)
315 isConnected[e+2*numPlayers][e] = 1;
316 if (e+2*numPlayers+1<numIslands-numPlayers-1)
318 isConnected[e+2*numPlayers][e+2*numPlayers+1] = 1;
322 isConnected[2*numPlayers][e+2*numPlayers] = 1;
325 var fx = fractionToTiles(0.5 + 0.16*cos(startAngle + e*TWO_PI/numPlayers));
326 var fz = fractionToTiles(0.5 + 0.16*sin(startAngle + e*TWO_PI/numPlayers));
329 IslandX[e+2*numPlayers]=ix;
330 IslandZ[e+2*numPlayers]=iz;
331 // calculate size based on the radius
332 var hillSize = floor(PI * radius * radius * 0.81);
335 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
336 var terrainPainter = new LayeredPainter(
337 [tCliff, tHill], // terrains
338 [cliffRadius] // widths
340 var elevationPainter = new SmoothElevationPainter(
341 ELEVATION_SET, // type
342 elevation, // elevation
343 cliffRadius // blend radius
345 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
348 isConnected[e+3*numPlayers][e+numPlayers] = 1;
349 var fx = fractionToTiles(0.5 + 0.27*cos(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
350 var fz = fractionToTiles(0.5 + 0.27*sin(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
353 IslandX[e+3*numPlayers]=ix;
354 IslandZ[e+3*numPlayers]=iz;
355 // calculate size based on the radius
356 var hillSize = floor(PI * radius * radius * 0.49);
359 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
360 var terrainPainter = new LayeredPainter(
361 [tCliff, tHill], // terrains
362 [cliffRadius] // widths
364 var elevationPainter = new SmoothElevationPainter(
365 ELEVATION_SET, // type
366 elevation, // elevation
367 cliffRadius // blend radius
369 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
372 for (var e = 0; e <numPlayers; e++)
374 isConnected[e][e+numPlayers] = 1;
377 isConnected[e + 1][e+numPlayers] = 1;
381 isConnected[0][e+numPlayers] = 1;
385 var fx = fractionToTiles(0.5 + 0.41*cos(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
386 var fz = fractionToTiles(0.5 + 0.41*sin(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
389 IslandX[e+numPlayers]=ix;
390 IslandZ[e+numPlayers]=iz;
391 // calculate size based on the radius
392 var hillSize = PI * radius * radius;
395 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
396 var terrainPainter = new LayeredPainter(
397 [tCliff, tHill], // terrains
398 [cliffRadius] // widths
400 var elevationPainter = new SmoothElevationPainter(
401 ELEVATION_SET, // type
402 elevation, // elevation
403 cliffRadius // blend radius
405 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
412 if (numPlayers == 4){
413 numIslands = 4*numPlayers+1;
414 var IslandX = new Array(numIslands);
415 var IslandZ = new Array(numIslands);
416 var isConnected = new Array(numIslands);
417 for (var q=0; q <numIslands; q++)
419 isConnected[q]=new Array(numIslands);
421 for (var m = 0; m < numIslands; m++){
422 for (var n = 0; n < numIslands; n++){
423 isConnected[m][n] = 0;
429 for (var l = 0; l < numPlayers; l++)
431 isConnected[4*numPlayers][l+2*numPlayers] = 1;
432 sX = sX + playerX[l];
433 sZ = sZ + playerZ[l];
436 var fx = fractionToTiles(sX/numPlayers);
437 var fz = fractionToTiles(sZ/numPlayers);
440 IslandX[4*numPlayers]=ix;
441 IslandZ[4*numPlayers]=iz;
442 // calculate size based on the radius
443 var hillSize = floor(PI * radius * radius * 0.36);
446 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
447 var terrainPainter = new LayeredPainter(
448 [tCliff, tHill], // terrains
449 [cliffRadius] // widths
451 var elevationPainter = new SmoothElevationPainter(
452 ELEVATION_SET, // type
453 elevation, // elevation
454 cliffRadius // blend radius
456 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
457 //centeral island id numPlayers
459 for (var e = 0; e <numPlayers; e++)
461 isConnected[e+2*numPlayers][e] = 1;
462 if (e+2*numPlayers+1<numIslands-numPlayers-1)
464 isConnected[e+2*numPlayers][e+2*numPlayers+1] = 1;
468 isConnected[2*numPlayers][e+2*numPlayers] = 1;
471 var fx = fractionToTiles(0.5 + 0.16*cos(startAngle + e*TWO_PI/numPlayers));
472 var fz = fractionToTiles(0.5 + 0.16*sin(startAngle + e*TWO_PI/numPlayers));
475 IslandX[e+2*numPlayers]=ix;
476 IslandZ[e+2*numPlayers]=iz;
477 // calculate size based on the radius
478 var hillSize = floor(PI * radius * radius * 0.81);
481 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
482 var terrainPainter = new LayeredPainter(
483 [tCliff, tHill], // terrains
484 [cliffRadius] // widths
486 var elevationPainter = new SmoothElevationPainter(
487 ELEVATION_SET, // type
488 elevation, // elevation
489 cliffRadius // blend radius
491 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
494 isConnected[e+3*numPlayers][e+numPlayers] = 1;
495 var fx = fractionToTiles(0.5 + 0.41*cos(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
496 var fz = fractionToTiles(0.5 + 0.41*sin(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
499 IslandX[e+3*numPlayers]=ix;
500 IslandZ[e+3*numPlayers]=iz;
501 // calculate size based on the radius
502 var hillSize = floor(PI * radius * radius * 0.49);
505 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
506 var terrainPainter = new LayeredPainter(
507 [tCliff, tHill], // terrains
508 [cliffRadius] // widths
510 var elevationPainter = new SmoothElevationPainter(
511 ELEVATION_SET, // type
512 elevation, // elevation
513 cliffRadius // blend radius
515 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
518 for (var e = 0; e <numPlayers; e++)
520 isConnected[e][e+numPlayers] = 1;
523 isConnected[e + 1][e+numPlayers] = 1;
527 isConnected[0][e+numPlayers] = 1;
531 var fx = fractionToTiles(0.5 + 0.27*cos(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
532 var fz = fractionToTiles(0.5 + 0.27*sin(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
535 IslandX[e+numPlayers]=ix;
536 IslandZ[e+numPlayers]=iz;
537 // calculate size based on the radius
538 var hillSize = PI * radius * radius;
541 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
542 var terrainPainter = new LayeredPainter(
543 [tCliff, tHill], // terrains
544 [cliffRadius] // widths
546 var elevationPainter = new SmoothElevationPainter(
547 ELEVATION_SET, // type
548 elevation, // elevation
549 cliffRadius // blend radius
551 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
555 //More than 4 PLAYERS
559 numIslands = numPlayers + 1;
560 var IslandX = new Array(numIslands);
561 var IslandZ = new Array(numIslands);
562 var isConnected = new Array(numIslands);
563 for (var q=0; q <numIslands; q++)
565 isConnected[q]=new Array(numIslands);
567 for (var m = 0; m < numIslands; m++){
568 for (var n = 0; n < numIslands; n++){
569 isConnected[m][n] = 0;
575 for (var l = 0; l < numPlayers; l++)
577 isConnected[l][numPlayers] = 1;
578 sX = sX + playerX[l];
579 sZ = sZ + playerZ[l];
582 //centeral island id numPlayers
584 var fx = fractionToTiles((sX)/numPlayers);
585 var fz = fractionToTiles((sZ)/numPlayers);
588 IslandX[numPlayers]=ix;
589 IslandZ[numPlayers]=iz;
590 // calculate size based on the radius
591 var hillSize = PI * radius * radius;
594 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
595 var terrainPainter = new LayeredPainter(
596 [tCliff, tHill], // terrains
597 [cliffRadius] // widths
599 var elevationPainter = new SmoothElevationPainter(
600 ELEVATION_SET, // type
601 elevation, // elevation
602 cliffRadius // blend radius
604 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
610 //****************************
611 //----------------------------
613 //----------------------------
614 //****************************
619 if ((numPlayers == 2)||(numPlayers == 3)||(numPlayers == 4)){
620 numIslands = 4*numPlayers+1;
621 var IslandX = new Array(numIslands);
622 var IslandZ = new Array(numIslands);
623 var isConnected = new Array(numIslands);
624 for (var q=0; q <numIslands; q++)
626 isConnected[q]=new Array(numIslands);
628 for (var m = 0; m < numIslands; m++){
629 for (var n = 0; n < numIslands; n++){
630 isConnected[m][n] = 0;
636 for (var l = 0; l < numPlayers; l++)
638 isConnected[4*numPlayers][l+2*numPlayers] = 1;
639 sX = sX + playerX[l];
640 sZ = sZ + playerZ[l];
643 var fx = fractionToTiles(sX/numPlayers);
644 var fz = fractionToTiles(sZ/numPlayers);
647 IslandX[4*numPlayers]=ix;
648 IslandZ[4*numPlayers]=iz;
649 // calculate size based on the radius
650 var hillSize = floor(PI * radius * radius * 0.36);
653 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
654 var terrainPainter = new LayeredPainter(
655 [tCliff, tHill], // terrains
656 [cliffRadius] // widths
658 var elevationPainter = new SmoothElevationPainter(
659 ELEVATION_SET, // type
660 elevation, // elevation
661 cliffRadius // blend radius
663 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
664 //centeral island id numPlayers
666 for (var e = 0; e <numPlayers; e++)
668 isConnected[e+2*numPlayers][e] = 1;
669 if (e+2*numPlayers+1<numIslands-numPlayers-1)
671 isConnected[e+2*numPlayers][e+2*numPlayers+1] = 1;
675 isConnected[2*numPlayers][e+2*numPlayers] = 1;
678 var fx = fractionToTiles(0.5 + 0.16*cos(startAngle + e*TWO_PI/numPlayers));
679 var fz = fractionToTiles(0.5 + 0.16*sin(startAngle + e*TWO_PI/numPlayers));
682 IslandX[e+2*numPlayers]=ix;
683 IslandZ[e+2*numPlayers]=iz;
684 // calculate size based on the radius
685 var hillSize = floor(PI * radius * radius * 0.81);
688 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
689 var terrainPainter = new LayeredPainter(
690 [tCliff, tHill], // terrains
691 [cliffRadius] // widths
693 var elevationPainter = new SmoothElevationPainter(
694 ELEVATION_SET, // type
695 elevation, // elevation
696 cliffRadius // blend radius
698 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
701 isConnected[e+3*numPlayers][e+numPlayers] = 1;
702 var fx = fractionToTiles(0.5 + 0.41*cos(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
703 var fz = fractionToTiles(0.5 + 0.41*sin(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
706 IslandX[e+3*numPlayers]=ix;
707 IslandZ[e+3*numPlayers]=iz;
708 // calculate size based on the radius
709 var hillSize = floor(PI * radius * radius * 0.49);
712 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
713 var terrainPainter = new LayeredPainter(
714 [tCliff, tHill], // terrains
715 [cliffRadius] // widths
717 var elevationPainter = new SmoothElevationPainter(
718 ELEVATION_SET, // type
719 elevation, // elevation
720 cliffRadius // blend radius
722 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
725 for (var e = 0; e <numPlayers; e++)
727 isConnected[e][e+numPlayers] = 1;
730 isConnected[e + 1][e+numPlayers] = 1;
734 isConnected[0][e+numPlayers] = 1;
738 var fx = fractionToTiles(0.5 + 0.26*cos(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
739 var fz = fractionToTiles(0.5 + 0.26*sin(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
742 IslandX[e+numPlayers]=ix;
743 IslandZ[e+numPlayers]=iz;
744 // calculate size based on the radius
745 var hillSize = PI * radius * radius;
748 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
749 var terrainPainter = new LayeredPainter(
750 [tCliff, tHill], // terrains
751 [cliffRadius] // widths
753 var elevationPainter = new SmoothElevationPainter(
754 ELEVATION_SET, // type
755 elevation, // elevation
756 cliffRadius // blend radius
758 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
762 //More than 4 PLAYERS
766 numIslands = 2*numPlayers;
767 var IslandX = new Array(numIslands);
768 var IslandZ = new Array(numIslands);
769 var isConnected = new Array(numIslands);
770 for (var q=0; q <numIslands; q++)
772 isConnected[q]=new Array(numIslands);
774 for (var m = 0; m < numIslands; m++){
775 for (var n = 0; n < numIslands; n++){
776 isConnected[m][n] = 0;
785 //centeral island id numPlayers
787 for (var e = 0; e <numPlayers; e++)
791 isConnected[e][e+1] = 1;
795 isConnected[0][e] = 1;
797 isConnected[e+numPlayers][e] = 1;
798 if (e+numPlayers+1<numIslands)
800 isConnected[e+numPlayers][e+numPlayers+1] = 1;
804 isConnected[e+numPlayers][numPlayers] = 1;
806 var fx = fractionToTiles(0.5 + 0.16*cos(startAngle + e*TWO_PI/numPlayers));
807 var fz = fractionToTiles(0.5 + 0.16*sin(startAngle + e*TWO_PI/numPlayers));
810 IslandX[e+numPlayers]=ix;
811 IslandZ[e+numPlayers]=iz;
812 // calculate size based on the radius
813 var hillSize = floor(PI * radius * radius * 0.81);
816 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
817 var terrainPainter = new LayeredPainter(
818 [tCliff, tHill], // terrains
819 [cliffRadius] // widths
821 var elevationPainter = new SmoothElevationPainter(
822 ELEVATION_SET, // type
823 elevation, // elevation
824 cliffRadius // blend radius
826 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
832 //****************************
833 //----------------------------
835 //----------------------------
836 //****************************
841 if ((numPlayers == 2)||(numPlayers == 3)||(numPlayers == 4)||(numPlayers == 5)){
842 numIslands = 4*numPlayers+1;
843 var IslandX = new Array(numIslands);
844 var IslandZ = new Array(numIslands);
845 var isConnected = new Array(numIslands);
846 for (var q=0; q <numIslands; q++)
848 isConnected[q]=new Array(numIslands);
850 for (var m = 0; m < numIslands; m++){
851 for (var n = 0; n < numIslands; n++){
852 isConnected[m][n] = 0;
858 for (var l = 0; l < numPlayers; l++)
860 isConnected[4*numPlayers][l+2*numPlayers] = 1;
861 sX = sX + playerX[l];
862 sZ = sZ + playerZ[l];
865 var fx = fractionToTiles(sX/numPlayers);
866 var fz = fractionToTiles(sZ/numPlayers);
869 IslandX[4*numPlayers]=ix;
870 IslandZ[4*numPlayers]=iz;
871 // calculate size based on the radius
872 var hillSize = floor(PI * radius * radius * 0.36);
875 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
876 var terrainPainter = new LayeredPainter(
877 [tCliff, tHill], // terrains
878 [cliffRadius] // widths
880 var elevationPainter = new SmoothElevationPainter(
881 ELEVATION_SET, // type
882 elevation, // elevation
883 cliffRadius // blend radius
885 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
886 //centeral island id numPlayers
888 for (var e = 0; e <numPlayers; e++)
890 isConnected[e+2*numPlayers][e] = 1;
891 if (e+2*numPlayers+1<numIslands-numPlayers-1)
893 isConnected[e+2*numPlayers][e+2*numPlayers+1] = 1;
897 isConnected[2*numPlayers][e+2*numPlayers] = 1;
900 var fx = fractionToTiles(0.5 + 0.16*cos(startAngle + e*TWO_PI/numPlayers));
901 var fz = fractionToTiles(0.5 + 0.16*sin(startAngle + e*TWO_PI/numPlayers));
904 IslandX[e+2*numPlayers]=ix;
905 IslandZ[e+2*numPlayers]=iz;
906 // calculate size based on the radius
907 var hillSize = floor(PI * radius * radius * 0.81);
910 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
911 var terrainPainter = new LayeredPainter(
912 [tCliff, tHill], // terrains
913 [cliffRadius] // widths
915 var elevationPainter = new SmoothElevationPainter(
916 ELEVATION_SET, // type
917 elevation, // elevation
918 cliffRadius // blend radius
920 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
923 isConnected[e+3*numPlayers][e+numPlayers] = 1;
924 var fx = fractionToTiles(0.5 + 0.41*cos(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
925 var fz = fractionToTiles(0.5 + 0.41*sin(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
928 IslandX[e+3*numPlayers]=ix;
929 IslandZ[e+3*numPlayers]=iz;
930 // calculate size based on the radius
931 var hillSize = floor(PI * radius * radius * 0.49);
934 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
935 var terrainPainter = new LayeredPainter(
936 [tCliff, tHill], // terrains
937 [cliffRadius] // widths
939 var elevationPainter = new SmoothElevationPainter(
940 ELEVATION_SET, // type
941 elevation, // elevation
942 cliffRadius // blend radius
944 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
947 for (var e = 0; e <numPlayers; e++)
949 isConnected[e][e+numPlayers] = 1;
952 isConnected[e + 1][e+numPlayers] = 1;
956 isConnected[0][e+numPlayers] = 1;
960 var fx = fractionToTiles(0.5 + 0.26*cos(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
961 var fz = fractionToTiles(0.5 + 0.26*sin(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
964 IslandX[e+numPlayers]=ix;
965 IslandZ[e+numPlayers]=iz;
966 // calculate size based on the radius
967 var hillSize = PI * radius * radius;
970 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
971 var terrainPainter = new LayeredPainter(
972 [tCliff, tHill], // terrains
973 [cliffRadius] // widths
975 var elevationPainter = new SmoothElevationPainter(
976 ELEVATION_SET, // type
977 elevation, // elevation
978 cliffRadius // blend radius
980 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
987 if ((numPlayers == 6)||(numPlayers == 7)){
988 numIslands = 4*numPlayers+1;
989 var IslandX = new Array(numIslands);
990 var IslandZ = new Array(numIslands);
991 var isConnected = new Array(numIslands);
992 for (var q=0; q <numIslands; q++)
994 isConnected[q]=new Array(numIslands);
996 for (var m = 0; m < numIslands; m++){
997 for (var n = 0; n < numIslands; n++){
998 isConnected[m][n] = 0;
1004 for (var l = 0; l < numPlayers; l++)
1006 isConnected[4*numPlayers][l+2*numPlayers] = 1;
1007 sX = sX + playerX[l];
1008 sZ = sZ + playerZ[l];
1011 var fx = fractionToTiles(sX/numPlayers);
1012 var fz = fractionToTiles(sZ/numPlayers);
1015 IslandX[4*numPlayers]=ix;
1016 IslandZ[4*numPlayers]=iz;
1017 // calculate size based on the radius
1018 var hillSize = floor(PI * radius * radius * 0.36);
1021 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
1022 var terrainPainter = new LayeredPainter(
1023 [tCliff, tHill], // terrains
1024 [cliffRadius] // widths
1026 var elevationPainter = new SmoothElevationPainter(
1027 ELEVATION_SET, // type
1028 elevation, // elevation
1029 cliffRadius // blend radius
1031 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1032 //centeral island id numPlayers
1034 for (var e = 0; e <numPlayers; e++)
1036 isConnected[e+2*numPlayers][e] = 1;
1037 if (e+2*numPlayers+1<numIslands-numPlayers-1)
1039 isConnected[e+2*numPlayers][e+2*numPlayers+1] = 1;
1043 isConnected[2*numPlayers][e+2*numPlayers] = 1;
1046 var fx = fractionToTiles(0.5 + 0.16*cos(startAngle + e*TWO_PI/numPlayers));
1047 var fz = fractionToTiles(0.5 + 0.16*sin(startAngle + e*TWO_PI/numPlayers));
1050 IslandX[e+2*numPlayers]=ix;
1051 IslandZ[e+2*numPlayers]=iz;
1052 // calculate size based on the radius
1053 var hillSize = floor(PI * radius * radius * 0.81);
1056 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
1057 var terrainPainter = new LayeredPainter(
1058 [tCliff, tHill], // terrains
1059 [cliffRadius] // widths
1061 var elevationPainter = new SmoothElevationPainter(
1062 ELEVATION_SET, // type
1063 elevation, // elevation
1064 cliffRadius // blend radius
1066 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1069 isConnected[e+3*numPlayers][e+numPlayers] = 1;
1070 var fx = fractionToTiles(0.5 + 0.41*cos(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
1071 var fz = fractionToTiles(0.5 + 0.41*sin(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
1074 IslandX[e+3*numPlayers]=ix;
1075 IslandZ[e+3*numPlayers]=iz;
1076 // calculate size based on the radius
1077 var hillSize = floor(PI * radius * radius * 0.49);
1080 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
1081 var terrainPainter = new LayeredPainter(
1082 [tCliff, tHill], // terrains
1083 [cliffRadius] // widths
1085 var elevationPainter = new SmoothElevationPainter(
1086 ELEVATION_SET, // type
1087 elevation, // elevation
1088 cliffRadius // blend radius
1090 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1093 for (var e = 0; e <numPlayers; e++)
1095 isConnected[e][e+numPlayers] = 1;
1098 isConnected[e + 1][e+numPlayers] = 1;
1102 isConnected[0][e+numPlayers] = 1;
1105 //second island id 4
1106 var fx = fractionToTiles(0.5 + 0.26*cos(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
1107 var fz = fractionToTiles(0.5 + 0.26*sin(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
1110 IslandX[e+numPlayers]=ix;
1111 IslandZ[e+numPlayers]=iz;
1112 // calculate size based on the radius
1113 var hillSize = PI * radius * radius;
1116 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
1117 var terrainPainter = new LayeredPainter(
1118 [tCliff, tHill], // terrains
1119 [cliffRadius] // widths
1121 var elevationPainter = new SmoothElevationPainter(
1122 ELEVATION_SET, // type
1123 elevation, // elevation
1124 cliffRadius // blend radius
1126 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1132 if (numPlayers == 8){
1133 numIslands = 2*numPlayers;
1134 var IslandX = new Array(numIslands);
1135 var IslandZ = new Array(numIslands);
1136 var isConnected = new Array(numIslands);
1137 for (var q=0; q <numIslands; q++)
1139 isConnected[q]=new Array(numIslands);
1141 for (var m = 0; m < numIslands; m++){
1142 for (var n = 0; n < numIslands; n++){
1143 isConnected[m][n] = 0;
1152 //centeral island id numPlayers
1154 for (var e = 0; e <numPlayers; e++)
1158 isConnected[e][e+1] = 1;
1162 isConnected[0][e] = 1;
1164 isConnected[e+numPlayers][e] = 1;
1165 if (e+numPlayers+1<numIslands)
1167 isConnected[e+numPlayers][e+numPlayers+1] = 1;
1171 isConnected[e+numPlayers][numPlayers] = 1;
1173 var fx = fractionToTiles(0.5 + 0.16*cos(startAngle + e*TWO_PI/numPlayers));
1174 var fz = fractionToTiles(0.5 + 0.16*sin(startAngle + e*TWO_PI/numPlayers));
1177 IslandX[e+numPlayers]=ix;
1178 IslandZ[e+numPlayers]=iz;
1179 // calculate size based on the radius
1180 var hillSize = floor(PI * radius * radius * 0.81);
1183 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
1184 var terrainPainter = new LayeredPainter(
1185 [tCliff, tHill], // terrains
1186 [cliffRadius] // widths
1188 var elevationPainter = new SmoothElevationPainter(
1189 ELEVATION_SET, // type
1190 elevation, // elevation
1191 cliffRadius // blend radius
1193 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1199 //****************************
1200 //----------------------------
1201 //Large and larger Sizes
1202 //----------------------------
1203 //****************************
1208 if ((numPlayers == 2)||(numPlayers == 3)||(numPlayers == 4)||(numPlayers == 5)){
1209 numIslands = 4*numPlayers+1;
1210 var IslandX = new Array(numIslands);
1211 var IslandZ = new Array(numIslands);
1212 var isConnected = new Array(numIslands);
1213 for (var q=0; q <numIslands; q++)
1215 isConnected[q]=new Array(numIslands);
1217 for (var m = 0; m < numIslands; m++){
1218 for (var n = 0; n < numIslands; n++){
1219 isConnected[m][n] = 0;
1225 for (var l = 0; l < numPlayers; l++)
1227 isConnected[4*numPlayers][l+2*numPlayers] = 1;
1228 sX = sX + playerX[l];
1229 sZ = sZ + playerZ[l];
1232 var fx = fractionToTiles(sX/numPlayers);
1233 var fz = fractionToTiles(sZ/numPlayers);
1236 IslandX[4*numPlayers]=ix;
1237 IslandZ[4*numPlayers]=iz;
1238 // calculate size based on the radius
1239 var hillSize = floor(PI * radius * radius * 0.36);
1242 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
1243 var terrainPainter = new LayeredPainter(
1244 [tCliff, tHill], // terrains
1245 [cliffRadius] // widths
1247 var elevationPainter = new SmoothElevationPainter(
1248 ELEVATION_SET, // type
1249 elevation, // elevation
1250 cliffRadius // blend radius
1252 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1253 //centeral island id numPlayers
1255 for (var e = 0; e <numPlayers; e++)
1257 isConnected[e+2*numPlayers][e] = 1;
1258 if (e+2*numPlayers+1<numIslands-numPlayers-1)
1260 isConnected[e+2*numPlayers][e+2*numPlayers+1] = 1;
1264 isConnected[2*numPlayers][e+2*numPlayers] = 1;
1267 var fx = fractionToTiles(0.5 + 0.16*cos(startAngle + e*TWO_PI/numPlayers));
1268 var fz = fractionToTiles(0.5 + 0.16*sin(startAngle + e*TWO_PI/numPlayers));
1271 IslandX[e+2*numPlayers]=ix;
1272 IslandZ[e+2*numPlayers]=iz;
1273 // calculate size based on the radius
1274 var hillSize = floor(PI * radius * radius * 0.81);
1277 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
1278 var terrainPainter = new LayeredPainter(
1279 [tCliff, tHill], // terrains
1280 [cliffRadius] // widths
1282 var elevationPainter = new SmoothElevationPainter(
1283 ELEVATION_SET, // type
1284 elevation, // elevation
1285 cliffRadius // blend radius
1287 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1290 isConnected[e+3*numPlayers][e+numPlayers] = 1;
1291 var fx = fractionToTiles(0.5 + 0.41*cos(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
1292 var fz = fractionToTiles(0.5 + 0.41*sin(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
1295 IslandX[e+3*numPlayers]=ix;
1296 IslandZ[e+3*numPlayers]=iz;
1297 // calculate size based on the radius
1298 var hillSize = floor(PI * radius * radius * 0.49);
1301 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
1302 var terrainPainter = new LayeredPainter(
1303 [tCliff, tHill], // terrains
1304 [cliffRadius] // widths
1306 var elevationPainter = new SmoothElevationPainter(
1307 ELEVATION_SET, // type
1308 elevation, // elevation
1309 cliffRadius // blend radius
1311 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1314 for (var e = 0; e <numPlayers; e++)
1316 isConnected[e][e+numPlayers] = 1;
1319 isConnected[e + 1][e+numPlayers] = 1;
1323 isConnected[0][e+numPlayers] = 1;
1326 //second island id 4
1327 var fx = fractionToTiles(0.5 + 0.24*cos(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
1328 var fz = fractionToTiles(0.5 + 0.24*sin(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
1331 IslandX[e+numPlayers]=ix;
1332 IslandZ[e+numPlayers]=iz;
1333 // calculate size based on the radius
1334 var hillSize = PI * radius * radius;
1337 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
1338 var terrainPainter = new LayeredPainter(
1339 [tCliff, tHill], // terrains
1340 [cliffRadius] // widths
1342 var elevationPainter = new SmoothElevationPainter(
1343 ELEVATION_SET, // type
1344 elevation, // elevation
1345 cliffRadius // blend radius
1347 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1355 if ((numPlayers == 6)||(numPlayers == 7)||(numPlayers == 8)){
1356 numIslands = 4*numPlayers+1;
1357 var IslandX = new Array(numIslands);
1358 var IslandZ = new Array(numIslands);
1359 var isConnected = new Array(numIslands);
1360 for (var q=0; q <numIslands; q++)
1362 isConnected[q]=new Array(numIslands);
1364 for (var m = 0; m < numIslands; m++){
1365 for (var n = 0; n < numIslands; n++){
1366 isConnected[m][n] = 0;
1372 for (var l = 0; l < numPlayers; l++)
1374 isConnected[4*numPlayers][l+2*numPlayers] = 1;
1375 sX = sX + playerX[l];
1376 sZ = sZ + playerZ[l];
1379 var fx = fractionToTiles(sX/numPlayers);
1380 var fz = fractionToTiles(sZ/numPlayers);
1383 IslandX[4*numPlayers]=ix;
1384 IslandZ[4*numPlayers]=iz;
1385 // calculate size based on the radius
1386 var hillSize = floor(PI * radius * radius * 0.36);
1389 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
1390 var terrainPainter = new LayeredPainter(
1391 [tCliff, tHill], // terrains
1392 [cliffRadius] // widths
1394 var elevationPainter = new SmoothElevationPainter(
1395 ELEVATION_SET, // type
1396 elevation, // elevation
1397 cliffRadius // blend radius
1399 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1403 //centeral island id numPlayers
1405 for (var e = 0; e <numPlayers; e++)
1407 isConnected[e+2*numPlayers][e] = 1;
1408 if (e+2*numPlayers+1<numIslands-numPlayers-1)
1410 isConnected[e+2*numPlayers][e+2*numPlayers+1] = 1;
1414 isConnected[2*numPlayers][e+2*numPlayers] = 1;
1417 var fx = fractionToTiles(0.5 + 0.16*cos(startAngle + e*TWO_PI/numPlayers));
1418 var fz = fractionToTiles(0.5 + 0.16*sin(startAngle + e*TWO_PI/numPlayers));
1421 IslandX[e+2*numPlayers]=ix;
1422 IslandZ[e+2*numPlayers]=iz;
1423 // calculate size based on the radius
1424 var hillSize = floor(PI * radius * radius * 0.81);
1427 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
1428 var terrainPainter = new LayeredPainter(
1429 [tCliff, tHill], // terrains
1430 [cliffRadius] // widths
1432 var elevationPainter = new SmoothElevationPainter(
1433 ELEVATION_SET, // type
1434 elevation, // elevation
1435 cliffRadius // blend radius
1437 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1440 isConnected[e+3*numPlayers][e+numPlayers] = 1;
1441 var fx = fractionToTiles(0.5 + 0.41*cos(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
1442 var fz = fractionToTiles(0.5 + 0.41*sin(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
1445 IslandX[e+3*numPlayers]=ix;
1446 IslandZ[e+3*numPlayers]=iz;
1447 // calculate size based on the radius
1448 var hillSize = floor(PI * radius * radius * 0.36);
1451 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
1452 var terrainPainter = new LayeredPainter(
1453 [tCliff, tHill], // terrains
1454 [cliffRadius] // widths
1456 var elevationPainter = new SmoothElevationPainter(
1457 ELEVATION_SET, // type
1458 elevation, // elevation
1459 cliffRadius // blend radius
1461 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1464 for (var e = 0; e <numPlayers; e++)
1466 isConnected[e][e+numPlayers] = 1;
1469 isConnected[e + 1][e+numPlayers] = 1;
1473 isConnected[0][e+numPlayers] = 1;
1476 //second island id 4
1477 var fx = fractionToTiles(0.5 + 0.28*cos(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
1478 var fz = fractionToTiles(0.5 + 0.28*sin(startAngle + e*TWO_PI/numPlayers + TWO_PI/(2*numPlayers)));
1481 IslandX[e+numPlayers]=ix;
1482 IslandZ[e+numPlayers]=iz;
1483 // calculate size based on the radius
1484 var hillSize = PI * radius * radius * 0.81;
1487 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
1488 var terrainPainter = new LayeredPainter(
1489 [tCliff, tHill], // terrains
1490 [cliffRadius] // widths
1492 var elevationPainter = new SmoothElevationPainter(
1493 ELEVATION_SET, // type
1494 elevation, // elevation
1495 cliffRadius // blend radius
1497 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1503 for (var m = 0; m < numIslands; m++){
1504 for (var n = 0; n < numIslands; n++){
1505 if(isConnected[m][n] == 1){
1506 isConnected[n][m] = 1;
1513 for (var i = 0; i < numPlayers; i++)
1515 var id = playerIDs[i];
1516 log("Creating base for player " + id + "...");
1521 // get the x and z in tiles
1522 var fx = fractionToTiles(playerX[i]);
1523 var fz = fractionToTiles(playerZ[i]);
1528 // calculate size based on the radius
1529 var hillSize = PI * radius * radius;
1532 var placer = new ClumpPlacer(hillSize, 0.95, 0.6, 10, ix, iz);
1533 var terrainPainter = new LayeredPainter(
1534 [tCliff, tHill], // terrains
1535 [cliffRadius] // widths
1537 var elevationPainter = new SmoothElevationPainter(
1538 ELEVATION_SET, // type
1539 elevation, // elevation
1540 cliffRadius // blend radius
1542 createArea(placer, [terrainPainter, elevationPainter, paintClass(clPlayer)], null);
1545 // create the city patch
1546 var cityRadius = radius/3;
1547 placer = new ClumpPlacer(PI*cityRadius*cityRadius, 0.6, 0.3, 10, ix, iz);
1548 var painter = new LayeredPainter([tRoadWild, tRoad], [1]);
1549 createArea(placer, painter, null);
1551 // create starting units
1552 placeCivDefaultEntities(fx, fz, id, { 'iberWall': 'towers' });
1554 placeDefaultChicken(fx, fz, clBaseResource);
1556 // create berry bushes
1557 var bbAngle = randFloat(0, TWO_PI);
1559 var bbX = round(fx + bbDist * cos(bbAngle));
1560 var bbZ = round(fz + bbDist * sin(bbAngle));
1561 var group = new SimpleGroup(
1562 [new SimpleObject(oFruitBush, 5,5, 0,3)],
1563 true, clBaseResource, bbX, bbZ
1565 createObjectGroup(group, 0);
1567 // create metal mine
1568 var mAngle = bbAngle;
1569 while(abs(mAngle - bbAngle) < PI/3)
1571 mAngle = randFloat(0, TWO_PI);
1573 var mDist = radius - 4;
1574 var mX = round(fx + mDist * cos(mAngle));
1575 var mZ = round(fz + mDist * sin(mAngle));
1576 group = new SimpleGroup(
1577 [new SimpleObject(oMetalLarge, 1,1, 0,0)],
1578 true, clBaseResource, mX, mZ
1580 createObjectGroup(group, 0);
1582 // create stone mines
1583 mAngle += randFloat(PI/8, PI/4);
1584 mX = round(fx + mDist * cos(mAngle));
1585 mZ = round(fz + mDist * sin(mAngle));
1586 group = new SimpleGroup(
1587 [new SimpleObject(oStoneLarge, 1,1, 0,2)],
1588 true, clBaseResource, mX, mZ
1590 createObjectGroup(group, 0);
1592 // create starting trees
1593 var num = floor(hillSize / 60);
1594 var tAngle = randFloat(-PI/3, 4*PI/3);
1596 var tX = round(fx + tDist * cos(tAngle));
1597 var tZ = round(fz + tDist * sin(tAngle));
1598 group = new SimpleGroup(
1599 [new SimpleObject(oTree1, num, num, 0,4)],
1600 false, clBaseResource, tX, tZ
1602 createObjectGroup(group, 0, [avoidClasses(clBaseResource,2), stayClasses(clPlayer, 3)]);
1604 placeDefaultDecoratives(fx, fz, aGrassShort, clBaseResource, radius);
1607 RMS.SetProgress(30);
1610 for (var ix = 0; ix < mapSize; ix++)
1612 for (var iz = 0; iz < mapSize; iz++)
1614 for (var m = 0; m < numIslands; m++)
1616 for (var n = 0; n < numIslands; n++)
1618 if(isConnected[m][n] == 1)
1620 var a = IslandZ[m]-IslandZ[n];
1621 var b = IslandX[n]-IslandX[m];
1622 var c = (IslandZ[m]*(IslandX[m]-IslandX[n]))-(IslandX[m]*(IslandZ[m]-IslandZ[n]));
1623 var dis = abs(a*ix + b*iz + c)/sqrt(a*a + b*b);
1624 var k = (a*ix + b*iz + c)/(a*a + b*b);
1626 if((dis < 5)&&(y <= Math.max(IslandZ[m],IslandZ[n]))&&(y >= Math.min(IslandZ[m],IslandZ[n])))
1638 addToClass(ix, iz, clLand);
1642 var h = 50 - 10 * dis;
1644 addToClass(ix, iz, clLand);
1646 if (getHeight(ix, iz)<h)
1648 placeTerrain(ix, iz, t);
1649 setHeight(ix, iz, h);
1658 // calculate desired number of trees for map (based on size)
1659 if (currentBiome() == "savanna")
1661 var MIN_TREES = 200;
1662 var MAX_TREES = 1250;
1663 var P_FOREST = 0.02;
1665 else if (currentBiome() == "tropic")
1667 var MIN_TREES = 1000;
1668 var MAX_TREES = 6000;
1673 var MIN_TREES = 500;
1674 var MAX_TREES = 3000;
1677 var totalTrees = scaleByMapSize(MIN_TREES, MAX_TREES);
1678 var numForest = totalTrees * P_FOREST;
1679 var numStragglers = totalTrees * (1.0 - P_FOREST);
1682 log("Creating forests...");
1684 [[tForestFloor2, tMainTerrain, pForest1], [tForestFloor2, pForest1]],
1685 [[tForestFloor1, tMainTerrain, pForest2], [tForestFloor1, pForest2]]
1686 ]; // some variation
1688 if (currentBiome() == "savanna")
1689 var size = numForest / (0.5 * scaleByMapSize(2,8) * numPlayers);
1691 var size = numForest / (scaleByMapSize(2,8) * numPlayers);
1693 var num = floor(size / types.length);
1694 for (var i = 0; i < types.length; ++i)
1696 placer = new ClumpPlacer(numForest / num, 0.1, 0.1, 1);
1697 painter = new LayeredPainter(
1698 types[i], // terrains
1703 [painter, paintClass(clForest)],
1704 [avoidClasses(clPlayer, 6, clForest, 10, clHill, 0), stayClasses(clLand, 4)],
1709 RMS.SetProgress(55);
1712 log("Creating stone mines...");
1713 // create large stone quarries
1714 group = new SimpleGroup([new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)], true, clRock);
1715 createObjectGroupsDeprecated(group, 0,
1716 [avoidClasses(clForest, 1, clPlayer, 10, clRock, 10, clHill, 1), stayClasses(clLand, 5)],
1717 5*scaleByMapSize(4,16), 100
1720 // create small stone quarries
1721 group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock);
1722 createObjectGroupsDeprecated(group, 0,
1723 [avoidClasses(clForest, 1, clPlayer, 10, clRock, 10, clHill, 1), stayClasses(clLand, 5)],
1724 5*scaleByMapSize(4,16), 100
1727 log("Creating metal mines...");
1728 // create large metal quarries
1729 group = new SimpleGroup([new SimpleObject(oMetalLarge, 1,1, 0,4)], true, clMetal);
1730 createObjectGroupsDeprecated(group, 0,
1731 [avoidClasses(clForest, 1, clPlayer, 10, clMetal, 10, clRock, 5, clHill, 1), stayClasses(clLand, 5)],
1732 5*scaleByMapSize(4,16), 100
1735 RMS.SetProgress(65);
1736 // create dirt patches
1737 log("Creating dirt patches...");
1738 var sizes = [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)];
1739 for (var i = 0; i < sizes.length; i++)
1741 placer = new ClumpPlacer(sizes[i], 0.3, 0.06, 0.5);
1742 painter = new LayeredPainter(
1743 [[tMainTerrain,tTier1Terrain],[tTier1Terrain,tTier2Terrain], [tTier2Terrain,tTier3Terrain]], // terrains
1748 [painter, paintClass(clDirt)],
1749 [avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12), stayClasses(clLand, 5)],
1750 scaleByMapSize(15, 45)
1754 // create grass patches
1755 log("Creating grass patches...");
1756 var sizes = [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)];
1757 for (var i = 0; i < sizes.length; i++)
1759 placer = new ClumpPlacer(sizes[i], 0.3, 0.06, 0.5);
1760 painter = new TerrainPainter(tTier4Terrain);
1764 [avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12), stayClasses(clLand, 5)],
1765 scaleByMapSize(15, 45)
1769 // create small decorative rocks
1770 log("Creating small decorative rocks...");
1771 group = new SimpleGroup(
1772 [new SimpleObject(aRockMedium, 1,3, 0,1)],
1775 createObjectGroupsDeprecated(
1777 [avoidClasses(clForest, 0, clPlayer, 0, clHill, 0), stayClasses(clLand, 4)],
1778 scaleByMapSize(16, 262), 50
1782 // create large decorative rocks
1783 log("Creating large decorative rocks...");
1784 group = new SimpleGroup(
1785 [new SimpleObject(aRockLarge, 1,2, 0,1), new SimpleObject(aRockMedium, 1,3, 0,2)],
1788 createObjectGroupsDeprecated(
1790 [avoidClasses(clForest, 0, clPlayer, 0, clHill, 0), stayClasses(clLand, 4)],
1791 scaleByMapSize(8, 131), 50
1794 RMS.SetProgress(70);
1797 log("Creating deer...");
1798 group = new SimpleGroup(
1799 [new SimpleObject(oMainHuntableAnimal, 5,7, 0,4)],
1802 createObjectGroupsDeprecated(group, 0,
1803 [avoidClasses(clForest, 0, clPlayer, 10, clHill, 1, clFood, 20), stayClasses(clLand, 4)],
1807 RMS.SetProgress(75);
1810 log("Creating sheep...");
1811 group = new SimpleGroup(
1812 [new SimpleObject(oSecondaryHuntableAnimal, 2,3, 0,2)],
1815 createObjectGroupsDeprecated(group, 0,
1816 [avoidClasses(clForest, 0, clPlayer, 10, clHill, 1, clFood, 20), stayClasses(clLand, 4)],
1821 log("Creating fruits...");
1822 group = new SimpleGroup(
1823 [new SimpleObject(oFruitBush, 5,7, 0,4)],
1826 createObjectGroupsDeprecated(group, 0,
1827 [avoidClasses(clForest, 0, clPlayer, 10, clHill, 1, clFood, 20), stayClasses(clLand, 4)],
1831 RMS.SetProgress(85);
1834 // create straggler trees
1835 log("Creating straggler trees...");
1836 var types = [oTree1, oTree2, oTree4, oTree3]; // some variation
1837 var num = floor(numStragglers / types.length);
1838 for (var i = 0; i < types.length; ++i)
1840 group = new SimpleGroup(
1841 [new SimpleObject(types[i], 1,1, 0,3)],
1844 createObjectGroupsDeprecated(group, 0,
1845 [avoidClasses(clForest, 1, clHill, 1, clPlayer, 9, clMetal, 6, clRock, 6), stayClasses(clLand, 4)],
1851 if (currentBiome() == "tropic")
1854 //create small grass tufts
1855 log("Creating small grass tufts...");
1856 group = new SimpleGroup(
1857 [new SimpleObject(aGrassShort, 1,2, 0,1, -PI/8,PI/8)]
1859 createObjectGroupsDeprecated(group, 0,
1860 [avoidClasses(clHill, 2, clPlayer, 2, clDirt, 0), stayClasses(clLand, 4)],
1861 planetm * scaleByMapSize(13, 200)
1864 RMS.SetProgress(90);
1866 // create large grass tufts
1867 log("Creating large grass tufts...");
1868 group = new SimpleGroup(
1869 [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)]
1871 createObjectGroupsDeprecated(group, 0,
1872 [avoidClasses(clHill, 2, clPlayer, 2, clDirt, 1, clForest, 0), stayClasses(clLand, 4)],
1873 planetm * scaleByMapSize(13, 200)
1876 RMS.SetProgress(95);
1879 log("Creating bushes...");
1880 group = new SimpleGroup(
1881 [new SimpleObject(aBushMedium, 1,2, 0,2), new SimpleObject(aBushSmall, 2,4, 0,2)]
1883 createObjectGroupsDeprecated(group, 0,
1884 [avoidClasses(clHill, 1, clPlayer, 1, clDirt, 1), stayClasses(clLand, 4)],
1885 planetm * scaleByMapSize(13, 200), 50
1888 setSkySet(pickRandom(["cirrus", "cumulus", "sunny"]));
1889 setSunRotation(randFloat(0, TWO_PI));
1890 setSunElevation(randFloat(PI/ 5, PI / 3));