Invincible women on survival of the fittest to prevent women fights and cheap tower...
[0ad.git] / binaries / data / mods / public / maps / random / snowflake_searocks.js
blobaa718676d832f0a473ed64ab91c1a7a9a1df8c1f
1 RMS.LoadLibrary("rmgen");
3 //random terrain textures
4 var random_terrain = randomizeBiome();
6 const tMainTerrain = rBiomeT1();
7 const tForestFloor1 = rBiomeT2();
8 const tForestFloor2 = rBiomeT3();
9 const tCliff = rBiomeT4();
10 const tTier1Terrain = rBiomeT5();
11 const tTier2Terrain = rBiomeT6();
12 const tTier3Terrain = rBiomeT7();
13 const tHill = rBiomeT1();
14 const tDirt = rBiomeT9();
15 const tRoad = rBiomeT10();
16 const tRoadWild = rBiomeT11();
17 const tTier4Terrain = rBiomeT12();
18 const tShoreBlend = rBiomeT13();
19 const tShore = rBiomeT14();
20 const tWater = rBiomeT15();
22 // gaia entities
23 const oTree1 = rBiomeE1();
24 const oTree2 = rBiomeE2();
25 const oTree3 = rBiomeE3();
26 const oTree4 = rBiomeE4();
27 const oTree5 = rBiomeE5();
28 const oFruitBush = rBiomeE6();
29 const oMainHuntableAnimal = rBiomeE8();
30 const oFish = rBiomeE9();
31 const oSecondaryHuntableAnimal = rBiomeE10();
32 const oStoneLarge = rBiomeE11();
33 const oStoneSmall = rBiomeE12();
34 const oMetalLarge = rBiomeE13();
36 // decorative props
37 const aGrass = rBiomeA1();
38 const aGrassShort = rBiomeA2();
39 const aReeds = rBiomeA3();
40 const aLillies = rBiomeA4();
41 const aRockLarge = rBiomeA5();
42 const aRockMedium = rBiomeA6();
43 const aBushMedium = rBiomeA7();
44 const aBushSmall = rBiomeA8();
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...");
51 InitMap();
53 const numPlayers = getNumPlayers();
54 const mapSize = getMapSize();
55 const mapArea = mapSize*mapSize;
57 log(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();
72 //Paint the whole map
74 for (var ix = 0; ix < mapSize; ix++)
76         for (var iz = 0; iz < mapSize; iz++)
77         {
78                 var x = ix / (mapSize + 1.0);
79                 var z = iz / (mapSize + 1.0);
80                         placeTerrain(ix, iz, tWater);
81         }
84 const radius = scaleByMapSize(15,30);
85 const cliffRadius = 2;
86 const elevation = 20;
87 // randomize player order
89 var playerIDs = [];
90 for (var i = 0; i < numPlayers; i++)
92         playerIDs.push(i+1);
94 playerIDs = sortPlayers(playerIDs);
96 // place players
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
111 var numIslands = 0;
112 //****************************
113 //----------------------------
114 //Tiny and Small Size
115 //----------------------------
116 //****************************
117 if ((mapSize == 128)||(mapSize == 192)){
118                 //2 PLAYERS
119                 //-----------------
120                 //-----------------
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++)
127                 {
128                         isConnected[q]=new Array(numIslands);
129                 }
130                 for (var m = 0; m < numIslands; m++){
131                         for (var n = 0; n < numIslands; n++){
132                                 isConnected[m][n] = 0;
133                         }
134                 }
135                 //connections
136                 var sX = 0;
137                 var sZ = 0;
138                 for (var l = 0; l < numPlayers; l++)
139                 {
140                         isConnected[4*numPlayers][l+2*numPlayers] = 1;
141                         sX = sX + playerX[l];
142                         sZ = sZ + playerZ[l];
143                 }
145                 var fx = fractionToTiles(sX/numPlayers);
146                 var fz = fractionToTiles(sZ/numPlayers);
147                 var ix = round(fx);
148                 var iz = round(fz);
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);
154                 // create the hill
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
159                 );
160                 var elevationPainter = new SmoothElevationPainter(
161                         ELEVATION_SET,                  // type
162                         elevation,                              // elevation
163                         cliffRadius                             // blend radius
164                 );
165                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
166                 //centeral island id numPlayers
168                 for (var e = 0; e <numPlayers; e++)
169                 {
170                 isConnected[e+2*numPlayers][e] = 1;
171                 if (e+2*numPlayers+1<numIslands-numPlayers-1)
172                 {
173                         isConnected[e+2*numPlayers][e+2*numPlayers+1] = 1;
174                 }
175                 else
176                 {
177                         isConnected[2*numPlayers][e+2*numPlayers] = 1;
178                 }
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));
182                 var ix = round(fx);
183                 var iz = round(fz);
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);
189                 // create the hill
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
194                 );
195                 var elevationPainter = new SmoothElevationPainter(
196                         ELEVATION_SET,                  // type
197                         elevation,                              // elevation
198                         cliffRadius                             // blend radius
199                 );
200                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
202                 //Small Isles
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)));
206                 var ix = round(fx);
207                 var iz = round(fz);
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);
213                 // create the hill
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
218                 );
219                 var elevationPainter = new SmoothElevationPainter(
220                         ELEVATION_SET,                  // type
221                         elevation,                              // elevation
222                         cliffRadius                             // blend radius
223                 );
224                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
225                 }
227                 for (var e = 0; e <numPlayers; e++)
228                 {
229                         isConnected[e][e+numPlayers] = 1;
230                         if (e+1<numPlayers)
231                         {
232                                 isConnected[e + 1][e+numPlayers] = 1;
233                         }
234                         else
235                         {
236                                 isConnected[0][e+numPlayers] = 1;
237                         }
239                         //second island id 4
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)));
242                         var ix = round(fx);
243                         var iz = round(fz);
244                         IslandX[e+numPlayers]=ix;
245                         IslandZ[e+numPlayers]=iz;
246                         // calculate size based on the radius
247                         var hillSize = PI * radius * radius;
249                         // create the hill
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
254                         );
255                         var elevationPainter = new SmoothElevationPainter(
256                                 ELEVATION_SET,                  // type
257                                 elevation,                              // elevation
258                                 cliffRadius                             // blend radius
259                         );
260                         createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
261                 }
262         }
263                 //3 PLAYERS
264                 //-----------------
265                 //-----------------
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++)
272                 {
273                         isConnected[q]=new Array(numIslands);
274                 }
275                 for (var m = 0; m < numIslands; m++){
276                         for (var n = 0; n < numIslands; n++){
277                                 isConnected[m][n] = 0;
278                         }
279                 }
280                 //connections
281                 var sX = 0;
282                 var sZ = 0;
283                 for (var l = 0; l < numPlayers; l++)
284                 {
285                         isConnected[4*numPlayers][l+2*numPlayers] = 1;
286                         sX = sX + playerX[l];
287                         sZ = sZ + playerZ[l];
288                 }
290                 var fx = fractionToTiles(sX/numPlayers);
291                 var fz = fractionToTiles(sZ/numPlayers);
292                 var ix = round(fx);
293                 var iz = round(fz);
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);
299                 // create the hill
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
304                 );
305                 var elevationPainter = new SmoothElevationPainter(
306                         ELEVATION_SET,                  // type
307                         elevation,                              // elevation
308                         cliffRadius                             // blend radius
309                 );
310                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
311                 //centeral island id numPlayers
313                 for (var e = 0; e <numPlayers; e++)
314                 {
315                 isConnected[e+2*numPlayers][e] = 1;
316                 if (e+2*numPlayers+1<numIslands-numPlayers-1)
317                 {
318                         isConnected[e+2*numPlayers][e+2*numPlayers+1] = 1;
319                 }
320                 else
321                 {
322                         isConnected[2*numPlayers][e+2*numPlayers] = 1;
323                 }
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));
327                 var ix = round(fx);
328                 var iz = round(fz);
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);
334                 // create the hill
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
339                 );
340                 var elevationPainter = new SmoothElevationPainter(
341                         ELEVATION_SET,                  // type
342                         elevation,                              // elevation
343                         cliffRadius                             // blend radius
344                 );
345                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
347                 //Small Isles
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)));
351                 var ix = round(fx);
352                 var iz = round(fz);
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);
358                 // create the hill
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
363                 );
364                 var elevationPainter = new SmoothElevationPainter(
365                         ELEVATION_SET,                  // type
366                         elevation,                              // elevation
367                         cliffRadius                             // blend radius
368                 );
369                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
370                 }
372                 for (var e = 0; e <numPlayers; e++)
373                 {
374                         isConnected[e][e+numPlayers] = 1;
375                         if (e+1<numPlayers)
376                         {
377                                 isConnected[e + 1][e+numPlayers] = 1;
378                         }
379                         else
380                         {
381                                 isConnected[0][e+numPlayers] = 1;
382                         }
384                         //second island id 4
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)));
387                         var ix = round(fx);
388                         var iz = round(fz);
389                         IslandX[e+numPlayers]=ix;
390                         IslandZ[e+numPlayers]=iz;
391                         // calculate size based on the radius
392                         var hillSize = PI * radius * radius;
394                         // create the hill
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
399                         );
400                         var elevationPainter = new SmoothElevationPainter(
401                                 ELEVATION_SET,                  // type
402                                 elevation,                              // elevation
403                                 cliffRadius                             // blend radius
404                         );
405                         createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
406                 }
407         }
409                 //4 PLAYERS
410                 //-----------------
411                 //-----------------
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++)
418                 {
419                         isConnected[q]=new Array(numIslands);
420                 }
421                 for (var m = 0; m < numIslands; m++){
422                         for (var n = 0; n < numIslands; n++){
423                                 isConnected[m][n] = 0;
424                         }
425                 }
426                 //connections
427                 var sX = 0;
428                 var sZ = 0;
429                 for (var l = 0; l < numPlayers; l++)
430                 {
431                         isConnected[4*numPlayers][l+2*numPlayers] = 1;
432                         sX = sX + playerX[l];
433                         sZ = sZ + playerZ[l];
434                 }
436                 var fx = fractionToTiles(sX/numPlayers);
437                 var fz = fractionToTiles(sZ/numPlayers);
438                 var ix = round(fx);
439                 var iz = round(fz);
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);
445                 // create the hill
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
450                 );
451                 var elevationPainter = new SmoothElevationPainter(
452                         ELEVATION_SET,                  // type
453                         elevation,                              // elevation
454                         cliffRadius                             // blend radius
455                 );
456                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
457                 //centeral island id numPlayers
459                 for (var e = 0; e <numPlayers; e++)
460                 {
461                 isConnected[e+2*numPlayers][e] = 1;
462                 if (e+2*numPlayers+1<numIslands-numPlayers-1)
463                 {
464                         isConnected[e+2*numPlayers][e+2*numPlayers+1] = 1;
465                 }
466                 else
467                 {
468                         isConnected[2*numPlayers][e+2*numPlayers] = 1;
469                 }
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));
473                 var ix = round(fx);
474                 var iz = round(fz);
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);
480                 // create the hill
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
485                 );
486                 var elevationPainter = new SmoothElevationPainter(
487                         ELEVATION_SET,                  // type
488                         elevation,                              // elevation
489                         cliffRadius                             // blend radius
490                 );
491                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
493                 //Small Isles
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)));
497                 var ix = round(fx);
498                 var iz = round(fz);
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);
504                 // create the hill
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
509                 );
510                 var elevationPainter = new SmoothElevationPainter(
511                         ELEVATION_SET,                  // type
512                         elevation,                              // elevation
513                         cliffRadius                             // blend radius
514                 );
515                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
516                 }
518                 for (var e = 0; e <numPlayers; e++)
519                 {
520                         isConnected[e][e+numPlayers] = 1;
521                         if (e+1<numPlayers)
522                         {
523                                 isConnected[e + 1][e+numPlayers] = 1;
524                         }
525                         else
526                         {
527                                 isConnected[0][e+numPlayers] = 1;
528                         }
530                         //second island id 4
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)));
533                         var ix = round(fx);
534                         var iz = round(fz);
535                         IslandX[e+numPlayers]=ix;
536                         IslandZ[e+numPlayers]=iz;
537                         // calculate size based on the radius
538                         var hillSize = PI * radius * radius;
540                         // create the hill
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
545                         );
546                         var elevationPainter = new SmoothElevationPainter(
547                                 ELEVATION_SET,                  // type
548                                 elevation,                              // elevation
549                                 cliffRadius                             // blend radius
550                         );
551                         createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
552                 }
553         }
555                         //More than 4 PLAYERS
556                 //-----------------
557                 //-----------------
558                 if (numPlayers > 4){
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++)
564                 {
565                         isConnected[q]=new Array(numIslands);
566                 }
567                 for (var m = 0; m < numIslands; m++){
568                         for (var n = 0; n < numIslands; n++){
569                                 isConnected[m][n] = 0;
570                         }
571                 }
572                 //connections
573                 var sX = 0;
574                 var sZ = 0;
575                 for (var l = 0; l < numPlayers; l++)
576                 {
577                         isConnected[l][numPlayers] = 1;
578                         sX = sX + playerX[l];
579                         sZ = sZ + playerZ[l];
580                 }
582                 //centeral island id numPlayers
584                 var fx = fractionToTiles((sX)/numPlayers);
585                 var fz = fractionToTiles((sZ)/numPlayers);
586                 var ix = round(fx);
587                 var iz = round(fz);
588                 IslandX[numPlayers]=ix;
589                 IslandZ[numPlayers]=iz;
590                 // calculate size based on the radius
591                 var hillSize = PI * radius * radius;
593                 // create the hill
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
598                 );
599                 var elevationPainter = new SmoothElevationPainter(
600                         ELEVATION_SET,                  // type
601                         elevation,                              // elevation
602                         cliffRadius                             // blend radius
603                 );
604                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
607         }
610 //****************************
611 //----------------------------
612 //Medium Size
613 //----------------------------
614 //****************************
615 if (mapSize == 256){
616                 //2,3,4 PLAYERS
617                 //-----------------
618                 //-----------------
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++)
625                 {
626                         isConnected[q]=new Array(numIslands);
627                 }
628                 for (var m = 0; m < numIslands; m++){
629                         for (var n = 0; n < numIslands; n++){
630                                 isConnected[m][n] = 0;
631                         }
632                 }
633                 //connections
634                 var sX = 0;
635                 var sZ = 0;
636                 for (var l = 0; l < numPlayers; l++)
637                 {
638                         isConnected[4*numPlayers][l+2*numPlayers] = 1;
639                         sX = sX + playerX[l];
640                         sZ = sZ + playerZ[l];
641                 }
643                 var fx = fractionToTiles(sX/numPlayers);
644                 var fz = fractionToTiles(sZ/numPlayers);
645                 var ix = round(fx);
646                 var iz = round(fz);
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);
652                 // create the hill
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
657                 );
658                 var elevationPainter = new SmoothElevationPainter(
659                         ELEVATION_SET,                  // type
660                         elevation,                              // elevation
661                         cliffRadius                             // blend radius
662                 );
663                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
664                 //centeral island id numPlayers
666                 for (var e = 0; e <numPlayers; e++)
667                 {
668                 isConnected[e+2*numPlayers][e] = 1;
669                 if (e+2*numPlayers+1<numIslands-numPlayers-1)
670                 {
671                         isConnected[e+2*numPlayers][e+2*numPlayers+1] = 1;
672                 }
673                 else
674                 {
675                         isConnected[2*numPlayers][e+2*numPlayers] = 1;
676                 }
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));
680                 var ix = round(fx);
681                 var iz = round(fz);
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);
687                 // create the hill
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
692                 );
693                 var elevationPainter = new SmoothElevationPainter(
694                         ELEVATION_SET,                  // type
695                         elevation,                              // elevation
696                         cliffRadius                             // blend radius
697                 );
698                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
700                 //Small Isles
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)));
704                 var ix = round(fx);
705                 var iz = round(fz);
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);
711                 // create the hill
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
716                 );
717                 var elevationPainter = new SmoothElevationPainter(
718                         ELEVATION_SET,                  // type
719                         elevation,                              // elevation
720                         cliffRadius                             // blend radius
721                 );
722                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
723                 }
725                 for (var e = 0; e <numPlayers; e++)
726                 {
727                         isConnected[e][e+numPlayers] = 1;
728                         if (e+1<numPlayers)
729                         {
730                                 isConnected[e + 1][e+numPlayers] = 1;
731                         }
732                         else
733                         {
734                                 isConnected[0][e+numPlayers] = 1;
735                         }
737                         //second island id 4
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)));
740                         var ix = round(fx);
741                         var iz = round(fz);
742                         IslandX[e+numPlayers]=ix;
743                         IslandZ[e+numPlayers]=iz;
744                         // calculate size based on the radius
745                         var hillSize = PI * radius * radius;
747                         // create the hill
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
752                         );
753                         var elevationPainter = new SmoothElevationPainter(
754                                 ELEVATION_SET,                  // type
755                                 elevation,                              // elevation
756                                 cliffRadius                             // blend radius
757                         );
758                         createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
759                 }
760         }
762                         //More than 4 PLAYERS
763                 //-----------------
764                 //-----------------
765                 if (numPlayers > 4){
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++)
771                 {
772                         isConnected[q]=new Array(numIslands);
773                 }
774                 for (var m = 0; m < numIslands; m++){
775                         for (var n = 0; n < numIslands; n++){
776                                 isConnected[m][n] = 0;
777                         }
778                 }
779                 //connections
780                 var sX = 0;
781                 var sZ = 0;
785                 //centeral island id numPlayers
787                 for (var e = 0; e <numPlayers; e++)
788                 {
789                 if (e+1<numPlayers)
790                 {
791                         isConnected[e][e+1] = 1;
792                 }
793                 else
794                 {
795                         isConnected[0][e] = 1;
796                 }
797                 isConnected[e+numPlayers][e] = 1;
798                 if (e+numPlayers+1<numIslands)
799                 {
800                         isConnected[e+numPlayers][e+numPlayers+1] = 1;
801                 }
802                 else
803                 {
804                         isConnected[e+numPlayers][numPlayers] = 1;
805                 }
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));
808                 var ix = round(fx);
809                 var iz = round(fz);
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);
815                 // create the hill
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
820                 );
821                 var elevationPainter = new SmoothElevationPainter(
822                         ELEVATION_SET,                  // type
823                         elevation,                              // elevation
824                         cliffRadius                             // blend radius
825                 );
826                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
827                 }
829         }
832 //****************************
833 //----------------------------
834 //Normal Size
835 //----------------------------
836 //****************************
837 if (mapSize == 320){
838                 //2,3,4,5 PLAYERS
839                 //-----------------
840                 //-----------------
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++)
847                 {
848                         isConnected[q]=new Array(numIslands);
849                 }
850                 for (var m = 0; m < numIslands; m++){
851                         for (var n = 0; n < numIslands; n++){
852                                 isConnected[m][n] = 0;
853                         }
854                 }
855                 //connections
856                 var sX = 0;
857                 var sZ = 0;
858                 for (var l = 0; l < numPlayers; l++)
859                 {
860                         isConnected[4*numPlayers][l+2*numPlayers] = 1;
861                         sX = sX + playerX[l];
862                         sZ = sZ + playerZ[l];
863                 }
865                 var fx = fractionToTiles(sX/numPlayers);
866                 var fz = fractionToTiles(sZ/numPlayers);
867                 var ix = round(fx);
868                 var iz = round(fz);
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);
874                 // create the hill
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
879                 );
880                 var elevationPainter = new SmoothElevationPainter(
881                         ELEVATION_SET,                  // type
882                         elevation,                              // elevation
883                         cliffRadius                             // blend radius
884                 );
885                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
886                 //centeral island id numPlayers
888                 for (var e = 0; e <numPlayers; e++)
889                 {
890                 isConnected[e+2*numPlayers][e] = 1;
891                 if (e+2*numPlayers+1<numIslands-numPlayers-1)
892                 {
893                         isConnected[e+2*numPlayers][e+2*numPlayers+1] = 1;
894                 }
895                 else
896                 {
897                         isConnected[2*numPlayers][e+2*numPlayers] = 1;
898                 }
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));
902                 var ix = round(fx);
903                 var iz = round(fz);
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);
909                 // create the hill
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
914                 );
915                 var elevationPainter = new SmoothElevationPainter(
916                         ELEVATION_SET,                  // type
917                         elevation,                              // elevation
918                         cliffRadius                             // blend radius
919                 );
920                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
922                 //Small Isles
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)));
926                 var ix = round(fx);
927                 var iz = round(fz);
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);
933                 // create the hill
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
938                 );
939                 var elevationPainter = new SmoothElevationPainter(
940                         ELEVATION_SET,                  // type
941                         elevation,                              // elevation
942                         cliffRadius                             // blend radius
943                 );
944                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
945                 }
947                 for (var e = 0; e <numPlayers; e++)
948                 {
949                         isConnected[e][e+numPlayers] = 1;
950                         if (e+1<numPlayers)
951                         {
952                                 isConnected[e + 1][e+numPlayers] = 1;
953                         }
954                         else
955                         {
956                                 isConnected[0][e+numPlayers] = 1;
957                         }
959                         //second island id 4
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)));
962                         var ix = round(fx);
963                         var iz = round(fz);
964                         IslandX[e+numPlayers]=ix;
965                         IslandZ[e+numPlayers]=iz;
966                         // calculate size based on the radius
967                         var hillSize = PI * radius * radius;
969                         // create the hill
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
974                         );
975                         var elevationPainter = new SmoothElevationPainter(
976                                 ELEVATION_SET,                  // type
977                                 elevation,                              // elevation
978                                 cliffRadius                             // blend radius
979                         );
980                         createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
981                 }
982         }
984                 //6,7 PLAYERS
985                 //-----------------
986                 //-----------------
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++)
993                 {
994                         isConnected[q]=new Array(numIslands);
995                 }
996                 for (var m = 0; m < numIslands; m++){
997                         for (var n = 0; n < numIslands; n++){
998                                 isConnected[m][n] = 0;
999                         }
1000                 }
1001                 //connections
1002                 var sX = 0;
1003                 var sZ = 0;
1004                 for (var l = 0; l < numPlayers; l++)
1005                 {
1006                         isConnected[4*numPlayers][l+2*numPlayers] = 1;
1007                         sX = sX + playerX[l];
1008                         sZ = sZ + playerZ[l];
1009                 }
1011                 var fx = fractionToTiles(sX/numPlayers);
1012                 var fz = fractionToTiles(sZ/numPlayers);
1013                 var ix = round(fx);
1014                 var iz = round(fz);
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);
1020                 // create the hill
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
1025                 );
1026                 var elevationPainter = new SmoothElevationPainter(
1027                         ELEVATION_SET,                  // type
1028                         elevation,                              // elevation
1029                         cliffRadius                             // blend radius
1030                 );
1031                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1032                 //centeral island id numPlayers
1034                 for (var e = 0; e <numPlayers; e++)
1035                 {
1036                 isConnected[e+2*numPlayers][e] = 1;
1037                 if (e+2*numPlayers+1<numIslands-numPlayers-1)
1038                 {
1039                         isConnected[e+2*numPlayers][e+2*numPlayers+1] = 1;
1040                 }
1041                 else
1042                 {
1043                         isConnected[2*numPlayers][e+2*numPlayers] = 1;
1044                 }
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));
1048                 var ix = round(fx);
1049                 var iz = round(fz);
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);
1055                 // create the hill
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
1060                 );
1061                 var elevationPainter = new SmoothElevationPainter(
1062                         ELEVATION_SET,                  // type
1063                         elevation,                              // elevation
1064                         cliffRadius                             // blend radius
1065                 );
1066                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1068                 //Small Isles
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)));
1072                 var ix = round(fx);
1073                 var iz = round(fz);
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);
1079                 // create the hill
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
1084                 );
1085                 var elevationPainter = new SmoothElevationPainter(
1086                         ELEVATION_SET,                  // type
1087                         elevation,                              // elevation
1088                         cliffRadius                             // blend radius
1089                 );
1090                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1091                 }
1093                 for (var e = 0; e <numPlayers; e++)
1094                 {
1095                         isConnected[e][e+numPlayers] = 1;
1096                         if (e+1<numPlayers)
1097                         {
1098                                 isConnected[e + 1][e+numPlayers] = 1;
1099                         }
1100                         else
1101                         {
1102                                 isConnected[0][e+numPlayers] = 1;
1103                         }
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)));
1108                         var ix = round(fx);
1109                         var iz = round(fz);
1110                         IslandX[e+numPlayers]=ix;
1111                         IslandZ[e+numPlayers]=iz;
1112                         // calculate size based on the radius
1113                         var hillSize = PI * radius * radius;
1115                         // create the hill
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
1120                         );
1121                         var elevationPainter = new SmoothElevationPainter(
1122                                 ELEVATION_SET,                  // type
1123                                 elevation,                              // elevation
1124                                 cliffRadius                             // blend radius
1125                         );
1126                         createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1127                 }
1128         }
1129                 //8 PLAYERS
1130                 //-----------------
1131                 //-----------------
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++)
1138                 {
1139                         isConnected[q]=new Array(numIslands);
1140                 }
1141                 for (var m = 0; m < numIslands; m++){
1142                         for (var n = 0; n < numIslands; n++){
1143                                 isConnected[m][n] = 0;
1144                         }
1145                 }
1146                 //connections
1147                 var sX = 0;
1148                 var sZ = 0;
1152                 //centeral island id numPlayers
1154                 for (var e = 0; e <numPlayers; e++)
1155                 {
1156                 if (e+1<numPlayers)
1157                 {
1158                         isConnected[e][e+1] = 1;
1159                 }
1160                 else
1161                 {
1162                         isConnected[0][e] = 1;
1163                 }
1164                 isConnected[e+numPlayers][e] = 1;
1165                 if (e+numPlayers+1<numIslands)
1166                 {
1167                         isConnected[e+numPlayers][e+numPlayers+1] = 1;
1168                 }
1169                 else
1170                 {
1171                         isConnected[e+numPlayers][numPlayers] = 1;
1172                 }
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));
1175                 var ix = round(fx);
1176                 var iz = round(fz);
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);
1182                 // create the hill
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
1187                 );
1188                 var elevationPainter = new SmoothElevationPainter(
1189                         ELEVATION_SET,                  // type
1190                         elevation,                              // elevation
1191                         cliffRadius                             // blend radius
1192                 );
1193                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1194                 }
1196         }
1199 //****************************
1200 //----------------------------
1201 //Large and larger Sizes
1202 //----------------------------
1203 //****************************
1204 if (mapSize > 383){
1205                 //2,3,4,5 PLAYERS
1206                 //-----------------
1207                 //-----------------
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++)
1214                 {
1215                         isConnected[q]=new Array(numIslands);
1216                 }
1217                 for (var m = 0; m < numIslands; m++){
1218                         for (var n = 0; n < numIslands; n++){
1219                                 isConnected[m][n] = 0;
1220                         }
1221                 }
1222                 //connections
1223                 var sX = 0;
1224                 var sZ = 0;
1225                 for (var l = 0; l < numPlayers; l++)
1226                 {
1227                         isConnected[4*numPlayers][l+2*numPlayers] = 1;
1228                         sX = sX + playerX[l];
1229                         sZ = sZ + playerZ[l];
1230                 }
1232                 var fx = fractionToTiles(sX/numPlayers);
1233                 var fz = fractionToTiles(sZ/numPlayers);
1234                 var ix = round(fx);
1235                 var iz = round(fz);
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);
1241                 // create the hill
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
1246                 );
1247                 var elevationPainter = new SmoothElevationPainter(
1248                         ELEVATION_SET,                  // type
1249                         elevation,                              // elevation
1250                         cliffRadius                             // blend radius
1251                 );
1252                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1253                 //centeral island id numPlayers
1255                 for (var e = 0; e <numPlayers; e++)
1256                 {
1257                 isConnected[e+2*numPlayers][e] = 1;
1258                 if (e+2*numPlayers+1<numIslands-numPlayers-1)
1259                 {
1260                         isConnected[e+2*numPlayers][e+2*numPlayers+1] = 1;
1261                 }
1262                 else
1263                 {
1264                         isConnected[2*numPlayers][e+2*numPlayers] = 1;
1265                 }
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));
1269                 var ix = round(fx);
1270                 var iz = round(fz);
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);
1276                 // create the hill
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
1281                 );
1282                 var elevationPainter = new SmoothElevationPainter(
1283                         ELEVATION_SET,                  // type
1284                         elevation,                              // elevation
1285                         cliffRadius                             // blend radius
1286                 );
1287                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1289                 //Small Isles
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)));
1293                 var ix = round(fx);
1294                 var iz = round(fz);
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);
1300                 // create the hill
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
1305                 );
1306                 var elevationPainter = new SmoothElevationPainter(
1307                         ELEVATION_SET,                  // type
1308                         elevation,                              // elevation
1309                         cliffRadius                             // blend radius
1310                 );
1311                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1312                 }
1314                 for (var e = 0; e <numPlayers; e++)
1315                 {
1316                         isConnected[e][e+numPlayers] = 1;
1317                         if (e+1<numPlayers)
1318                         {
1319                                 isConnected[e + 1][e+numPlayers] = 1;
1320                         }
1321                         else
1322                         {
1323                                 isConnected[0][e+numPlayers] = 1;
1324                         }
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)));
1329                         var ix = round(fx);
1330                         var iz = round(fz);
1331                         IslandX[e+numPlayers]=ix;
1332                         IslandZ[e+numPlayers]=iz;
1333                         // calculate size based on the radius
1334                         var hillSize = PI * radius * radius;
1336                         // create the hill
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
1341                         );
1342                         var elevationPainter = new SmoothElevationPainter(
1343                                 ELEVATION_SET,                  // type
1344                                 elevation,                              // elevation
1345                                 cliffRadius                             // blend radius
1346                         );
1347                         createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1348                 }
1350         }
1352                 //6,7,8 PLAYERS
1353                 //-----------------
1354                 //-----------------
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++)
1361                 {
1362                         isConnected[q]=new Array(numIslands);
1363                 }
1364                 for (var m = 0; m < numIslands; m++){
1365                         for (var n = 0; n < numIslands; n++){
1366                                 isConnected[m][n] = 0;
1367                         }
1368                 }
1369                 //connections
1370                 var sX = 0;
1371                 var sZ = 0;
1372                 for (var l = 0; l < numPlayers; l++)
1373                 {
1374                         isConnected[4*numPlayers][l+2*numPlayers] = 1;
1375                         sX = sX + playerX[l];
1376                         sZ = sZ + playerZ[l];
1377                 }
1379                 var fx = fractionToTiles(sX/numPlayers);
1380                 var fz = fractionToTiles(sZ/numPlayers);
1381                 var ix = round(fx);
1382                 var iz = round(fz);
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);
1388                 // create the hill
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
1393                 );
1394                 var elevationPainter = new SmoothElevationPainter(
1395                         ELEVATION_SET,                  // type
1396                         elevation,                              // elevation
1397                         cliffRadius                             // blend radius
1398                 );
1399                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1403                 //centeral island id numPlayers
1405                 for (var e = 0; e <numPlayers; e++)
1406                 {
1407                 isConnected[e+2*numPlayers][e] = 1;
1408                 if (e+2*numPlayers+1<numIslands-numPlayers-1)
1409                 {
1410                         isConnected[e+2*numPlayers][e+2*numPlayers+1] = 1;
1411                 }
1412                 else
1413                 {
1414                         isConnected[2*numPlayers][e+2*numPlayers] = 1;
1415                 }
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));
1419                 var ix = round(fx);
1420                 var iz = round(fz);
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);
1426                 // create the hill
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
1431                 );
1432                 var elevationPainter = new SmoothElevationPainter(
1433                         ELEVATION_SET,                  // type
1434                         elevation,                              // elevation
1435                         cliffRadius                             // blend radius
1436                 );
1437                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1439                 //Small Isles
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)));
1443                 var ix = round(fx);
1444                 var iz = round(fz);
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);
1450                 // create the hill
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
1455                 );
1456                 var elevationPainter = new SmoothElevationPainter(
1457                         ELEVATION_SET,                  // type
1458                         elevation,                              // elevation
1459                         cliffRadius                             // blend radius
1460                 );
1461                 createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1462                 }
1464                 for (var e = 0; e <numPlayers; e++)
1465                 {
1466                         isConnected[e][e+numPlayers] = 1;
1467                         if (e+1<numPlayers)
1468                         {
1469                                 isConnected[e + 1][e+numPlayers] = 1;
1470                         }
1471                         else
1472                         {
1473                                 isConnected[0][e+numPlayers] = 1;
1474                         }
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)));
1479                         var ix = round(fx);
1480                         var iz = round(fz);
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;
1486                         // create the hill
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
1491                         );
1492                         var elevationPainter = new SmoothElevationPainter(
1493                                 ELEVATION_SET,                  // type
1494                                 elevation,                              // elevation
1495                                 cliffRadius                             // blend radius
1496                         );
1497                         createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null);
1498                 }
1500         }
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;
1507                 }
1508         }
1513 for (var i = 0; i < numPlayers; i++)
1515         var id = playerIDs[i];
1516         log("Creating base for player " + id + "...");
1518         // some constants
1521         // get the x and z in tiles
1522         var fx = fractionToTiles(playerX[i]);
1523         var fz = fractionToTiles(playerZ[i]);
1524         var ix = round(fx);
1525         var iz = round(fz);
1526                 IslandX[i]=ix;
1527                 IslandZ[i]=iz;
1528         // calculate size based on the radius
1529         var hillSize = PI * radius * radius;
1531         // create the hill
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
1536         );
1537         var elevationPainter = new SmoothElevationPainter(
1538                 ELEVATION_SET,                  // type
1539                 elevation,                              // elevation
1540                 cliffRadius                             // blend radius
1541         );
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);
1558         var bbDist = 10;
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
1564         );
1565         createObjectGroup(group, 0);
1567         // create metal mine
1568         var mAngle = bbAngle;
1569         while(abs(mAngle - bbAngle) < PI/3)
1570         {
1571                 mAngle = randFloat(0, TWO_PI);
1572         }
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
1579         );
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
1589         );
1590         createObjectGroup(group, 0);
1592         // create starting trees
1593         var num = floor(hillSize / 60);
1594         var tAngle = randFloat(-PI/3, 4*PI/3);
1595         var tDist = 11;
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
1601         );
1602         createObjectGroup(group, 0, [avoidClasses(clBaseResource,2), stayClasses(clPlayer, 3)]);
1604         // create grass tufts
1605         var num = hillSize / 250;
1606         for (var j = 0; j < num; j++)
1607         {
1608                 var gAngle = randFloat(0, TWO_PI);
1609                 var gDist = radius - (5 + randInt(7));
1610                 var gX = round(fx + gDist * cos(gAngle));
1611                 var gZ = round(fz + gDist * sin(gAngle));
1612                 group = new SimpleGroup(
1613                         [new SimpleObject(aGrassShort, 2,5, 0,1, -PI/8,PI/8)],
1614                         false, clBaseResource, gX, gZ
1615                 );
1616                 createObjectGroup(group, 0);
1617         }
1620 RMS.SetProgress(30);
1622 //Create connectors
1623 for (var ix = 0; ix < mapSize; ix++)
1625         for (var iz = 0; iz < mapSize; iz++)
1626         {
1627                 for (var m = 0; m < numIslands; m++)
1628                 {
1629                         for (var n = 0; n < numIslands; n++)
1630                         {
1631                                 if(isConnected[m][n] == 1)
1632                                 {
1633                                         var a = IslandZ[m]-IslandZ[n];
1634                                         var b = IslandX[n]-IslandX[m];
1635                                         var c = (IslandZ[m]*(IslandX[m]-IslandX[n]))-(IslandX[m]*(IslandZ[m]-IslandZ[n]));
1636                                         var dis = abs(a*ix + b*iz + c)/sqrt(a*a + b*b);
1637                                         var k = (a*ix + b*iz + c)/(a*a + b*b);
1638                                         var y = iz-(b*k);
1639                                         if((dis < 5)&&(y <= Math.max(IslandZ[m],IslandZ[n]))&&(y >= Math.min(IslandZ[m],IslandZ[n])))
1640                                         {
1641                                                 if (dis < 3){
1642                                                         var h = 20;
1643                                                         if (dis < 2)
1644                                                         {
1645                                                                 var t = tHill;
1646                                                         }
1647                                                         else
1648                                                         {
1649                                                                 var t = tCliff;
1650                                                         }
1651                                                         addToClass(ix, iz, clLand);
1652                                                 }
1653                                                 else
1654                                                 {
1655                                                         var h = 50 - 10 * dis;
1656                                                         var t = tCliff;
1657                                                         addToClass(ix, iz, clLand);
1658                                                 }
1659                                                 if (getHeight(ix, iz)<h)
1660                                                 {
1661                                                         placeTerrain(ix, iz, t);
1662                                                         setHeight(ix, iz, h);
1663                                                 }
1664                                         }
1665                                 }
1666                         }
1667                 }
1668         }
1671 // calculate desired number of trees for map (based on size)
1672 if (random_terrain == g_BiomeSavanna)
1674         var MIN_TREES = 200;
1675         var MAX_TREES = 1250;
1676         var P_FOREST = 0.02;
1678 else if (random_terrain == g_BiomeTropic)
1680         var MIN_TREES = 1000;
1681         var MAX_TREES = 6000;
1682         var P_FOREST = 0.6;
1684 else
1686         var MIN_TREES = 500;
1687         var MAX_TREES = 3000;
1688         var P_FOREST = 0.7;
1690 var totalTrees = scaleByMapSize(MIN_TREES, MAX_TREES);
1691 var numForest = totalTrees * P_FOREST;
1692 var numStragglers = totalTrees * (1.0 - P_FOREST);
1694 // create forests
1695 log("Creating forests...");
1696 var types = [
1697         [[tForestFloor2, tMainTerrain, pForest1], [tForestFloor2, pForest1]],
1698         [[tForestFloor1, tMainTerrain, pForest2], [tForestFloor1, pForest2]]
1699 ];      // some variation
1701 if (random_terrain == g_BiomeSavanna)
1702         var size = numForest / (0.5 * scaleByMapSize(2,8) * numPlayers);
1703 else
1704         var size = numForest / (scaleByMapSize(2,8) * numPlayers);
1706 var num = floor(size / types.length);
1707 for (var i = 0; i < types.length; ++i)
1709         placer = new ClumpPlacer(numForest / num, 0.1, 0.1, 1);
1710         painter = new LayeredPainter(
1711                 types[i],               // terrains
1712                 [2]                                                                                     // widths
1713                 );
1714         createAreas(
1715                 placer,
1716                 [painter, paintClass(clForest)],
1717                 [avoidClasses(clPlayer, 6, clForest, 10, clHill, 0), stayClasses(clLand, 4)],
1718                 num
1719         );
1722 RMS.SetProgress(55);
1725 log("Creating stone mines...");
1726 // create large stone quarries
1727 group = new SimpleGroup([new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)], true, clRock);
1728 createObjectGroups(group, 0,
1729         [avoidClasses(clForest, 1, clPlayer, 10, clRock, 10, clHill, 1), stayClasses(clLand, 5)],
1730         5*scaleByMapSize(4,16), 100
1733 // create small stone quarries
1734 group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock);
1735 createObjectGroups(group, 0,
1736         [avoidClasses(clForest, 1, clPlayer, 10, clRock, 10, clHill, 1), stayClasses(clLand, 5)],
1737         5*scaleByMapSize(4,16), 100
1740 log("Creating metal mines...");
1741 // create large metal quarries
1742 group = new SimpleGroup([new SimpleObject(oMetalLarge, 1,1, 0,4)], true, clMetal);
1743 createObjectGroups(group, 0,
1744         [avoidClasses(clForest, 1, clPlayer, 10, clMetal, 10, clRock, 5, clHill, 1), stayClasses(clLand, 5)],
1745         5*scaleByMapSize(4,16), 100
1748 RMS.SetProgress(65);
1749 // create dirt patches
1750 log("Creating dirt patches...");
1751 var sizes = [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)];
1752 for (var i = 0; i < sizes.length; i++)
1754         placer = new ClumpPlacer(sizes[i], 0.3, 0.06, 0.5);
1755         painter = new LayeredPainter(
1756                 [[tMainTerrain,tTier1Terrain],[tTier1Terrain,tTier2Terrain], [tTier2Terrain,tTier3Terrain]],            // terrains
1757                 [1,1]                                                                                                                   // widths
1758         );
1759         createAreas(
1760                 placer,
1761                 [painter, paintClass(clDirt)],
1762                 [avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12), stayClasses(clLand, 5)],
1763                 scaleByMapSize(15, 45)
1764         );
1767 // create grass patches
1768 log("Creating grass patches...");
1769 var sizes = [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)];
1770 for (var i = 0; i < sizes.length; i++)
1772         placer = new ClumpPlacer(sizes[i], 0.3, 0.06, 0.5);
1773         painter = new TerrainPainter(tTier4Terrain);
1774         createAreas(
1775                 placer,
1776                 painter,
1777                 [avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12), stayClasses(clLand, 5)],
1778                 scaleByMapSize(15, 45)
1779         );
1782 // create small decorative rocks
1783 log("Creating small decorative rocks...");
1784 group = new SimpleGroup(
1785         [new SimpleObject(aRockMedium, 1,3, 0,1)],
1786         true
1788 createObjectGroups(
1789         group, 0,
1790         [avoidClasses(clForest, 0, clPlayer, 0, clHill, 0), stayClasses(clLand, 4)],
1791         scaleByMapSize(16, 262), 50
1795 // create large decorative rocks
1796 log("Creating large decorative rocks...");
1797 group = new SimpleGroup(
1798         [new SimpleObject(aRockLarge, 1,2, 0,1), new SimpleObject(aRockMedium, 1,3, 0,2)],
1799         true
1801 createObjectGroups(
1802         group, 0,
1803         [avoidClasses(clForest, 0, clPlayer, 0, clHill, 0), stayClasses(clLand, 4)],
1804         scaleByMapSize(8, 131), 50
1807 RMS.SetProgress(70);
1809 // create deer
1810 log("Creating deer...");
1811 group = new SimpleGroup(
1812         [new SimpleObject(oMainHuntableAnimal, 5,7, 0,4)],
1813         true, clFood
1815 createObjectGroups(group, 0,
1816         [avoidClasses(clForest, 0, clPlayer, 10, clHill, 1, clFood, 20), stayClasses(clLand, 4)],
1817         3 * numPlayers, 50
1820 RMS.SetProgress(75);
1822 // create sheep
1823 log("Creating sheep...");
1824 group = new SimpleGroup(
1825         [new SimpleObject(oSecondaryHuntableAnimal, 2,3, 0,2)],
1826         true, clFood
1828 createObjectGroups(group, 0,
1829         [avoidClasses(clForest, 0, clPlayer, 10, clHill, 1, clFood, 20), stayClasses(clLand, 4)],
1830         3 * numPlayers, 50
1833 // create fruits
1834 log("Creating fruits...");
1835 group = new SimpleGroup(
1836         [new SimpleObject(oFruitBush, 5,7, 0,4)],
1837         true, clFood
1839 createObjectGroups(group, 0,
1840         [avoidClasses(clForest, 0, clPlayer, 10, clHill, 1, clFood, 20), stayClasses(clLand, 4)],
1841         3 * numPlayers, 50
1844 RMS.SetProgress(85);
1847 // create straggler trees
1848 log("Creating straggler trees...");
1849 var types = [oTree1, oTree2, oTree4, oTree3];   // some variation
1850 var num = floor(numStragglers / types.length);
1851 for (var i = 0; i < types.length; ++i)
1853         group = new SimpleGroup(
1854                 [new SimpleObject(types[i], 1,1, 0,3)],
1855                 true, clForest
1856         );
1857         createObjectGroups(group, 0,
1858                 [avoidClasses(clForest, 1, clHill, 1, clPlayer, 9, clMetal, 1, clRock, 1), stayClasses(clLand, 4)],
1859                 num
1860         );
1863 var planetm = 1;
1864 if (random_terrain == g_BiomeTropic)
1865         planetm = 8;
1867 //create small grass tufts
1868 log("Creating small grass tufts...");
1869 group = new SimpleGroup(
1870         [new SimpleObject(aGrassShort, 1,2, 0,1, -PI/8,PI/8)]
1872 createObjectGroups(group, 0,
1873         [avoidClasses(clHill, 2, clPlayer, 2, clDirt, 0), stayClasses(clLand, 4)],
1874         planetm * scaleByMapSize(13, 200)
1877 RMS.SetProgress(90);
1879 // create large grass tufts
1880 log("Creating large grass tufts...");
1881 group = new SimpleGroup(
1882         [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)]
1884 createObjectGroups(group, 0,
1885         [avoidClasses(clHill, 2, clPlayer, 2, clDirt, 1, clForest, 0), stayClasses(clLand, 4)],
1886         planetm * scaleByMapSize(13, 200)
1889 RMS.SetProgress(95);
1891 // create bushes
1892 log("Creating bushes...");
1893 group = new SimpleGroup(
1894         [new SimpleObject(aBushMedium, 1,2, 0,2), new SimpleObject(aBushSmall, 2,4, 0,2)]
1896 createObjectGroups(group, 0,
1897         [avoidClasses(clHill, 1, clPlayer, 1, clDirt, 1), stayClasses(clLand, 4)],
1898         planetm * scaleByMapSize(13, 200), 50
1901 random_terrain = randInt(1,3);
1902 if (random_terrain == 1)
1903         setSkySet("cirrus");
1904 else if (random_terrain == 2)
1905         setSkySet("cumulus");
1906 else if (random_terrain == 3)
1907         setSkySet("sunny");
1909 setSunRotation(randFloat(0, TWO_PI));
1910 setSunElevation(randFloat(PI/ 5, PI / 3));
1912 // Export map data
1913 ExportMap();