Ticket #1688: belgian_uplands2012-10-5b.diff

File belgian_uplands2012-10-5b.diff, 24.9 KB (added by FeXoR, 12 years ago)

The SVN .diff

  • binaries/data/mods/public/art/textures/ui/session/icons/mappreview/belgian_uplands.png

    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
  • binaries/data/mods/public/maps/random/belgian_uplands.js

    Property changes on: binaries/data/mods/public/art/textures/ui/session/icons/mappreview/belgian_uplands.png
    ___________________________________________________________________
    Added: svn:mime-type
    ## -0,0 +1 ##
    +application/octet-stream
    \ No newline at end of property
     
     1// Prepare progress calculation
     2var timeArray = [];
     3timeArray.push(new Date().getTime());
     4
     5// Importing rmgen libraries
     6RMS.LoadLibrary("rmgen");
     7
     8const BUILDING_ANGlE = -PI/4;
     9
     10// initialize map
     11
     12log("Initializing map...");
     13
     14InitMap();
     15
     16var numPlayers = getNumPlayers();
     17var mapSize = getMapSize();
     18
     19
     20//////////
     21// Heightmap functionality
     22//////////
     23
     24// Some general heightmap settings
     25const MIN_HEIGHT = - SEA_LEVEL; // 20, should be set in the libs!
     26const MAX_HEIGHT = 0xFFFF/HEIGHT_UNITS_PER_METRE - SEA_LEVEL; // A bit smaler than 90, should be set in the libs!
     27
     28// Add random heightmap generation functionality
     29function getRandomReliefmap(minHeight, maxHeight)
     30{
     31    minHeight = (minHeight || MIN_HEIGHT);
     32    maxHeight = (maxHeight || MAX_HEIGHT);
     33    if (minHeight < MIN_HEIGHT)
     34        warn("getRandomReliefmap: Argument minHeight is smaler then the supported minimum height of " + MIN_HEIGHT + " (const MIN_HEIGHT): " + minHeight)
     35    if (maxHeight > MAX_HEIGHT)
     36        warn("getRandomReliefmap: Argument maxHeight is smaler then the supported maximum height of " + MAX_HEIGHT + " (const MAX_HEIGHT): " + maxHeight)
     37    var reliefmap = [];
     38    for (var x = 0; x <= mapSize; x++)
     39    {
     40        reliefmap.push([]);
     41        for (var y = 0; y <= mapSize; y++)
     42        {
     43            reliefmap[x].push(randFloat(minHeight, maxHeight));
     44        }
     45    }
     46    return reliefmap;
     47}
     48
     49// Apply a heightmap
     50function setReliefmap(reliefmap)
     51{
     52    // g_Map.height = reliefmap;
     53    for (var x = 0; x <= mapSize; x++)
     54    {
     55        for (var y = 0; y <= mapSize; y++)
     56        {
     57            setHeight(x, y, reliefmap[x][y]);
     58        }
     59    }
     60}
     61
     62// Get minimum and maxumum height used in a heightmap
     63function getMinAndMaxHeight(reliefmap)
     64{
     65    var height = {};
     66    height.min = Infinity;
     67    height.max = -Infinity;
     68    for (var x = 0; x <= mapSize; x++)
     69    {
     70        for (var y = 0; y <= mapSize; y++)
     71        {
     72            if (reliefmap[x][y] < height.min)
     73                height.min = reliefmap[x][y];
     74            else if (reliefmap[x][y] > height.max)
     75                height.max = reliefmap[x][y];
     76        }
     77    }
     78    return height;
     79}
     80
     81// Rescale a heightmap (Waterlevel is not taken into consideration!)
     82function getRescaledReliefmap(reliefmap, minHeight, maxHeight)
     83{
     84    var newReliefmap = deepcopy(reliefmap);
     85    minHeight = (minHeight || MIN_HEIGHT);
     86    maxHeight = (maxHeight || MAX_HEIGHT);
     87    if (minHeight < MIN_HEIGHT)
     88        warn("getRescaledReliefmap: Argument minHeight is smaler then the supported minimum height of " + MIN_HEIGHT + " (const MIN_HEIGHT): " + minHeight)
     89    if (maxHeight > MAX_HEIGHT)
     90        warn("getRescaledReliefmap: Argument maxHeight is smaler then the supported maximum height of " + MAX_HEIGHT + " (const MAX_HEIGHT): " + maxHeight)
     91    var oldHeightRange = getMinAndMaxHeight(reliefmap);
     92    for (var x = 0; x <= mapSize; x++)
     93    {
     94        for (var y = 0; y <= mapSize; y++)
     95        {
     96            newReliefmap[x][y] = minHeight + (reliefmap[x][y] - oldHeightRange.min) / (oldHeightRange.max - oldHeightRange.min) * (maxHeight - minHeight);
     97        }
     98    }
     99    return newReliefmap
     100}
     101
     102// Applying decay errosion (terrain independent)
     103function getHeightErrosionedReliefmap(reliefmap, strength)
     104{
     105    var newReliefmap = deepcopy(reliefmap);
     106    strength = (strength || 1.0); // Values much higher then 1 (1.32+ for an 8 tile map, 1.45+ for a 12 tile map, 1.62+ @ 20 tile map, 0.99 @ 4 tiles) will result in a resonance disaster/self interference
     107    var map = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]; // Default
     108    for (var x = 0; x <= mapSize; x++)
     109    {
     110        for (var y = 0; y <= mapSize; y++)
     111        {
     112            var div = 0;
     113            for (var i = 0; i < map.length; i++)
     114                newReliefmap[x][y] += strength / map.length * (reliefmap[(x + map[i][0] + mapSize + 1) % (mapSize + 1)][(y + map[i][1] + mapSize + 1) % (mapSize + 1)] - reliefmap[x][y]); // Not entirely sure if scaling with map.length is perfect but tested values seam to indicate it is
     115        }
     116    }
     117    return newReliefmap;
     118}
     119
     120
     121//////////
     122// Prepare for hightmap munipulation
     123//////////
     124
     125// Set target min and max height depending on map size to make average stepness the same on all map sizes
     126var heightRange = {"min": MIN_HEIGHT * mapSize / 512, "max": MAX_HEIGHT * mapSize / 512};
     127
     128// Set average water coverage
     129var averageWaterCoverage = 1/3; // NOTE: Since errosion is not predictable actual water coverage might differ much with the same value
     130if (mapSize < 200) // Sink the waterlevel on tiny maps to ensure enough space
     131    averageWaterCoverage = 2/3 * averageWaterCoverage;
     132var waterHeight = -MIN_HEIGHT + heightRange.min + averageWaterCoverage * (heightRange.max - heightRange.min);
     133var waterHeightAdjusted = waterHeight + MIN_HEIGHT;
     134setWaterHeight(waterHeight);
     135
     136
     137//////////
     138// Prepare terrain texture by height placement
     139//////////
     140
     141var textueByHeight = [];
     142
     143// Deep water
     144textueByHeight.push({"upperHeightLimit": heightRange.min + 1/3 * (waterHeightAdjusted - heightRange.min), "terrain": "temp_sea_rocks"});
     145// Medium deep water (with fish)
     146var terreins = ["temp_sea_weed"];
     147terreins = terreins.concat(terreins, terreins, terreins, terreins);
     148terreins = terreins.concat(terreins, terreins, terreins, terreins);
     149terreins.push("temp_sea_weed|gaia/fauna_fish");
     150textueByHeight.push({"upperHeightLimit": heightRange.min + 2/3 * (waterHeightAdjusted - heightRange.min), "terrain": terreins});
     151// Flat Water
     152textueByHeight.push({"upperHeightLimit": heightRange.min + 3/3 * (waterHeightAdjusted - heightRange.min), "terrain": "temp_mud_a"});
     153// Water surroundings/bog (with stone/metal some rabits and bushes)
     154var terreins = ["temp_plants_bog", "temp_plants_bog_aut", "temp_dirt_gravel_plants", "temp_grass_d"];
     155terreins = terreins.concat(terreins, terreins, terreins, terreins, terreins);
     156terreins = ["temp_plants_bog|gaia/flora_bush_temperate"].concat(terreins, terreins);
     157terreins = ["temp_dirt_gravel_plants|gaia/geology_metal_temperate", "temp_dirt_gravel_plants|gaia/geology_stone_temperate", "temp_plants_bog|gaia/fauna_rabbit"].concat(terreins, terreins);
     158terreins = ["temp_plants_bog_aut|gaia/flora_tree_dead"].concat(terreins, terreins);
     159textueByHeight.push({"upperHeightLimit": waterHeightAdjusted + 1/6 * (heightRange.max - waterHeightAdjusted), "terrain": terreins});
     160// Juicy grass near bog
     161textueByHeight.push({"upperHeightLimit": waterHeightAdjusted + 2/6 * (heightRange.max - waterHeightAdjusted),
     162    "terrain": ["temp_grass", "temp_grass_d", "temp_grass_long_b", "temp_grass_plants"]});
     163// Medium level grass
     164// var testActor = "actor|geology/decal_stone_medit_a.xml";
     165textueByHeight.push({"upperHeightLimit": waterHeightAdjusted + 3/6 * (heightRange.max - waterHeightAdjusted),
     166    "terrain": ["temp_grass", "temp_grass_b", "temp_grass_c", "temp_grass_mossy"]});
     167// Long grass near forest border
     168textueByHeight.push({"upperHeightLimit": waterHeightAdjusted + 4/6 * (heightRange.max - waterHeightAdjusted),
     169    "terrain": ["temp_grass", "temp_grass_b", "temp_grass_c", "temp_grass_d", "temp_grass_long_b", "temp_grass_clovers_2", "temp_grass_mossy", "temp_grass_plants"]});
     170// Forest border (With wood/food plants/deer/rabits)
     171var terreins = ["temp_grass_plants|gaia/flora_tree_euro_beech", "temp_grass_mossy|gaia/flora_tree_poplar", "temp_grass_mossy|gaia/flora_tree_poplar_lombardy",
     172    "temp_grass_long|gaia/flora_bush_temperate", "temp_mud_plants|gaia/flora_bush_temperate", "temp_mud_plants|gaia/flora_bush_badlands",
     173    "temp_grass_long|gaia/flora_tree_apple", "temp_grass_clovers|gaia/flora_bush_berry", "temp_grass_clovers_2|gaia/flora_bush_grapes",
     174    "temp_grass_plants|gaia/fauna_deer", "temp_grass_long_b|gaia/fauna_rabbit"];
     175var numTerreins = terreins.length;
     176for (var i = 0; i < numTerreins; i++)
     177    terreins.push("temp_grass_plants");
     178textueByHeight.push({"upperHeightLimit": waterHeightAdjusted + 5/6 * (heightRange.max - waterHeightAdjusted), "terrain": terreins});
     179// Unpassable woods
     180textueByHeight.push({"upperHeightLimit": waterHeightAdjusted + 6/6 * (heightRange.max - waterHeightAdjusted),
     181    "terrain": ["temp_grass_mossy|gaia/flora_tree_oak", "temp_forestfloor_pine|gaia/flora_tree_pine",
     182    "temp_grass_mossy|gaia/flora_tree_oak", "temp_forestfloor_pine|gaia/flora_tree_pine",
     183    "temp_mud_plants|gaia/flora_tree_dead", "temp_plants_bog|gaia/flora_tree_oak_large",
     184    "temp_dirt_gravel_plants|gaia/flora_tree_aleppo_pine", "temp_forestfloor_autumn|gaia/flora_tree_carob"]});
     185var minTerrainDistToBorder = 3;
     186
     187// Time check 1
     188timeArray.push(new Date().getTime());
     189RMS.SetProgress(5);
     190
     191
     192// START THE GIANT WHILE LOOP:
     193// - Generate Heightmap
     194// - Search valid start position tiles
     195// - Choose a good start position derivation (largest distance between closest players)
     196// - Restart the loop if start positions are invalid or two players are to close to each other
     197var goodStartPositionsFound = false;
     198var minDistBetweenPlayers = 16 + mapSize / 16; // Don't set this higher than 25 for tiny maps! It will take forever with 8 players!
     199var tries = 0;
     200var enoughTiles = false;
     201while (!goodStartPositionsFound)
     202{
     203    tries++;
     204    log("Starting giant while loop try " + tries);
     205    // Generate reliefmap
     206    var myReliefmap = getRandomReliefmap(heightRange.min, heightRange.max);
     207    for (var i = 0; i < 50 + mapSize/4; i++) // Cycles depend on mapsize (more cycles -> bigger structures)
     208        myReliefmap = getHeightErrosionedReliefmap(myReliefmap, 1);
     209    myReliefmap = getRescaledReliefmap(myReliefmap, heightRange.min, heightRange.max);
     210    setReliefmap(myReliefmap);
     211   
     212    // Find good start position tiles
     213    var startPositions = [];
     214    var possibleStartPositions = [];
     215    var neededDistance = 7;
     216    var distToBorder = 2 * neededDistance; // Has to be greater than neededDistance! Otherwise the check if low/high ground is near will fail...
     217    var lowerHeightLimit = textueByHeight[3].upperHeightLimit;
     218    var upperHeightLimit = textueByHeight[6].upperHeightLimit;
     219    // Check for valid points by height
     220    for (var x = distToBorder + minTerrainDistToBorder; x < mapSize - distToBorder - minTerrainDistToBorder; x++)
     221    {
     222        for (var y = distToBorder + minTerrainDistToBorder; y < mapSize - distToBorder - minTerrainDistToBorder; y++)
     223        {
     224            var actualHeight = getHeight(x, y);
     225            if (actualHeight > lowerHeightLimit && actualHeight < upperHeightLimit)
     226            {
     227                // Check for points within a valid area by height (rectangular since faster)
     228                var isPossible = true;
     229                for (var offX = - neededDistance; offX <= neededDistance; offX++)
     230                {
     231                    for (var offY = - neededDistance; offY <= neededDistance; offY++)
     232                    {
     233                        var testHeight = getHeight(x + offX, y + offY);
     234                        if (testHeight <= lowerHeightLimit || testHeight >= upperHeightLimit)
     235                        {
     236                            isPossible = false;
     237                            break;
     238                        }
     239                    }
     240                }
     241                if (isPossible)
     242                {
     243                    possibleStartPositions.push([x, y]);
     244                    // placeTerrain(x, y, "blue"); // For debug reasons. Plz don't remove. // Only works properly for 1 loop
     245                }
     246            }
     247        }
     248    }
     249   
     250    // Trying to reduce the number of possible start locations...
     251   
     252    // Reduce to tiles in a circle of mapSize / 2 distance to the center (to avoid players placed in corners)
     253    var possibleStartPositionsTemp = [];
     254    var maxDistToCenter = mapSize / 2;
     255    for (var i = 0; i < possibleStartPositions.length; i++)
     256    {
     257        var deltaX = possibleStartPositions[i][0] - mapSize / 2;
     258        var deltaY = possibleStartPositions[i][1] - mapSize / 2;
     259        var distToCenter = Math.pow(Math.pow(deltaX, 2) + Math.pow(deltaY, 2), 1/2);
     260        if (distToCenter < maxDistToCenter)
     261        {
     262            possibleStartPositionsTemp.push(possibleStartPositions[i]);
     263            // placeTerrain(possibleStartPositions[i][0], possibleStartPositions[i][1], "purple"); // Only works properly for 1 loop
     264        }
     265    }
     266    possibleStartPositions = deepcopy(possibleStartPositionsTemp);
     267   
     268    // Reduce to tiles near low and high ground (Rectangular check since faster) to make sure each player has access to all resource types.
     269    var possibleStartPositionsTemp = [];
     270    var maxDistToResources = distToBorder; // Has to be <= distToBorder!
     271    var minNumLowTiles = 10;
     272    var minNumHighTiles = 10;
     273    for (var i = 0; i < possibleStartPositions.length; i++)
     274    {
     275        var numLowTiles = 0;
     276        var numHighTiles = 0;
     277        for (var dx = - maxDistToResources; dx < maxDistToResources; dx++)
     278        {
     279            for (var dy = - maxDistToResources; dy < maxDistToResources; dy++)
     280            {
     281                var testHeight = getHeight(possibleStartPositions[i][0] + dx, possibleStartPositions[i][1] + dy);
     282                if (testHeight < lowerHeightLimit)
     283                    numLowTiles++;
     284                if (testHeight > upperHeightLimit)
     285                    numHighTiles++;
     286                if (numLowTiles > minNumLowTiles && numHighTiles > minNumHighTiles)
     287                    break;
     288            }
     289            if (numLowTiles > minNumLowTiles && numHighTiles > minNumHighTiles)
     290                break;
     291        }
     292        if (numLowTiles > minNumLowTiles && numHighTiles > minNumHighTiles)
     293        {
     294            possibleStartPositionsTemp.push(possibleStartPositions[i]);
     295            // placeTerrain(possibleStartPositions[i][0], possibleStartPositions[i][1], "red"); // Only works properly for 1 loop
     296        }
     297    }
     298    possibleStartPositions = deepcopy(possibleStartPositionsTemp);
     299   
     300    if(possibleStartPositions.length > numPlayers)
     301        enoughTiles = true;
     302    else
     303    {
     304        enoughTiles = false;
     305        log("possibleStartPositions.length < numPlayers, possibleStartPositions.length = " + possibleStartPositions.length + ", numPlayers = " + numPlayers);
     306    }
     307   
     308    // Find a good start position derivation
     309    if (enoughTiles)
     310    {
     311        // Get some random start location derivations. NOTE: Itterating over all possible derivations is just to much (valid points ** numPlayers)
     312        var maxTries = 100000; // floor(800000 / (Math.pow(numPlayers, 2) / 2));
     313        var possibleDerivations = [];
     314        for (var i = 0; i < maxTries; i++)
     315        {
     316            var vector = [];
     317            for (var p = 0; p < numPlayers; p++)
     318                vector.push(randInt(possibleStartPositions.length));
     319            possibleDerivations.push(vector);
     320        }
     321       
     322        // Choose the start location derivation with the greatest minimum distance between players
     323        var maxMinDist = 0;
     324        for (var d = 0; d < possibleDerivations.length; d++)
     325        {
     326            var minDist = 2 * mapSize;
     327            for (var p1 = 0; p1 < numPlayers - 1; p1++)
     328            {
     329                for (var p2 = p1 + 1; p2 < numPlayers; p2++)
     330                {
     331                    if (p1 != p2)
     332                    {
     333                        var StartPositionP1 = possibleStartPositions[possibleDerivations[d][p1]];
     334                        var StartPositionP2 = possibleStartPositions[possibleDerivations[d][p2]];
     335                        var actualDist = Math.pow(Math.pow(StartPositionP1[0] - StartPositionP2[0], 2) + Math.pow(StartPositionP1[1] - StartPositionP2[1], 2), 1/2);
     336                        if (actualDist < minDist)
     337                            minDist = actualDist;
     338                        if (minDist < maxMinDist)
     339                            break;
     340                    }
     341                }
     342                if (minDist < maxMinDist)
     343                    break;
     344            }
     345            if (minDist > maxMinDist)
     346            {
     347                maxMinDist = minDist;
     348                var bestDerivation = possibleDerivations[d];
     349            }
     350        }
     351        if (maxMinDist > minDistBetweenPlayers)
     352        {
     353            goodStartPositionsFound = true;
     354            log("Exiting giant while loop after " +  tries + " tries with a minimum player distance of " + maxMinDist);
     355        }
     356        else
     357            log("maxMinDist <= " + minDistBetweenPlayers + ", maxMinDist = " + maxMinDist);
     358    } // End of derivation check
     359} // END THE GIANT WHILE LOOP
     360
     361// Time check 2
     362timeArray.push(new Date().getTime());
     363RMS.SetProgress(60);
     364
     365
     366////////
     367// Paint terrain by height and add props
     368////////
     369
     370var propDensity = 1; // 1 means as determined in the loop, less for large maps as set below
     371if (mapSize > 500)
     372    propDensity = 1/4;
     373else if (mapSize > 400)
     374    propDensity = 3/4;
     375for(var x = minTerrainDistToBorder; x < mapSize - minTerrainDistToBorder; x++)
     376{
     377    for (var y = minTerrainDistToBorder; y < mapSize - minTerrainDistToBorder; y++)
     378    {
     379        var textureMinHeight = heightRange.min;
     380        for (var i = 0; i < textueByHeight.length; i++)
     381        {
     382            if (getHeight(x, y) >= textureMinHeight && getHeight(x, y) <= textueByHeight[i].upperHeightLimit)
     383            {
     384                placeTerrain(x, y, textueByHeight[i].terrain);
     385                // Add some props at...
     386                if (i == 0) // ...deep water
     387                {
     388                    if (randFloat() < 1/50 * propDensity)
     389                        placeObject(x, y, "actor|props/flora/pond_lillies_large.xml", 0, randFloat(0, 2*PI));
     390                    else if (randFloat() < 1/20 * propDensity)
     391                        placeObject(x, y, "actor|props/flora/water_lillies.xml", 0, randFloat(0, 2*PI));
     392                }
     393                if (i == 1) // ...medium water (with fish)
     394                {
     395                    if (randFloat() < 1/100 * propDensity)
     396                        placeObject(x, y, "actor|props/flora/pond_lillies_large.xml", 0, randFloat(0, 2*PI));
     397                    else if (randFloat() < 1/50 * propDensity)
     398                        placeObject(x, y, "actor|props/flora/water_lillies.xml", 0, randFloat(0, 2*PI));
     399                }
     400                if (i == 2) // ...low water/mud
     401                {
     402                    if (randFloat() < 1/100 * propDensity)
     403                        placeObject(x, y, "actor|props/flora/water_log.xml", 0, randFloat(0, 2*PI));
     404                    else if (randFloat() < 1/50 * propDensity)
     405                        placeObject(x, y, "actor|props/flora/water_lillies.xml", 0, randFloat(0, 2*PI));
     406                    else if (randFloat() < 1/20 * propDensity)
     407                        placeObject(x, y, "actor|geology/highland_c.xml", 0, randFloat(0, 2*PI));
     408                    else if (randFloat() < 1/10 * propDensity)
     409                        placeObject(x, y, "actor|props/flora/reeds_pond_lush_b.xml", 0, randFloat(0, 2*PI));
     410                    else if (randFloat() < 1/5 * propDensity)
     411                        placeObject(x, y, "actor|props/flora/reeds_pond_lush_a.xml", 0, randFloat(0, 2*PI));
     412                }
     413                if (i == 3) // ...water suroundings/bog
     414                {
     415                    if (randFloat() < 1/100 * propDensity)
     416                        placeObject(x, y, "actor|props/flora/water_log.xml", 0, randFloat(0, 2*PI));
     417                    else if (randFloat() < 1/50 * propDensity)
     418                        placeObject(x, y, "actor|geology/highland_c.xml", 0, randFloat(0, 2*PI));
     419                    else if (randFloat() < 1/20 * propDensity)
     420                        placeObject(x, y, "actor|props/flora/reeds_pond_lush_a.xml", 0, randFloat(0, 2*PI));
     421                }
     422                if (i == 4) // ...low height grass
     423                {
     424                    if (randFloat() < 1/400 * propDensity)
     425                        placeObject(x, y, "actor|props/flora/grass_field_flowering_tall.xml", 0, randFloat(0, 2*PI));
     426                    else if (randFloat() < 1/200 * propDensity)
     427                        placeObject(x, y, "actor|geology/gray_rock1.xml", 0, randFloat(0, 2*PI));
     428                    else if (randFloat() < 1/100 * propDensity)
     429                        placeObject(x, y, "actor|props/flora/bush_tempe_sm_lush.xml", 0, randFloat(0, 2*PI));
     430                    else if (randFloat() < 1/50 * propDensity)
     431                        placeObject(x, y, "actor|props/flora/bush_tempe_b.xml", 0, randFloat(0, 2*PI));
     432                    else if (randFloat() < 1/20 * propDensity)
     433                        placeObject(x, y, "actor|props/flora/grass_soft_small_tall.xml", 0, randFloat(0, 2*PI));
     434                }
     435                if (i == 5) // ...medium height grass
     436                {
     437                    if (randFloat() < 1/400 * propDensity)
     438                        placeObject(x, y, "actor|geology/decal_stone_medit_a.xml", 0, randFloat(0, 2*PI));
     439                    else if (randFloat() < 1/200 * propDensity)
     440                        placeObject(x, y, "actor|props/flora/decals_flowers_daisies.xml", 0, randFloat(0, 2*PI));
     441                    else if (randFloat() < 1/100 * propDensity)
     442                        placeObject(x, y, "actor|props/flora/bush_tempe_underbrush.xml", 0, randFloat(0, 2*PI));
     443                    else if (randFloat() < 1/50 * propDensity)
     444                        placeObject(x, y, "actor|props/flora/grass_soft_small_tall.xml", 0, randFloat(0, 2*PI));
     445                    else if (randFloat() < 1/20 * propDensity)
     446                        placeObject(x, y, "actor|props/flora/grass_temp_field.xml", 0, randFloat(0, 2*PI));
     447                }
     448                if (i == 6) // ...high height grass
     449                {
     450                    if (randFloat() < 1/200 * propDensity)
     451                        placeObject(x, y, "actor|geology/stone_granite_boulder.xml", 0, randFloat(0, 2*PI));
     452                    else if (randFloat() < 1/100 * propDensity)
     453                        placeObject(x, y, "actor|props/flora/foliagebush.xml", 0, randFloat(0, 2*PI));
     454                    else if (randFloat() < 1/50 * propDensity)
     455                        placeObject(x, y, "actor|props/flora/bush_tempe_underbrush.xml", 0, randFloat(0, 2*PI));
     456                    else if (randFloat() < 1/20 * propDensity)
     457                        placeObject(x, y, "actor|props/flora/grass_soft_small_tall.xml", 0, randFloat(0, 2*PI));
     458                    else if (randFloat() < 1/10 * propDensity)
     459                        placeObject(x, y, "actor|props/flora/ferns.xml", 0, randFloat(0, 2*PI));
     460                }
     461                if (i == 7) // ...forest border (with wood/food plants/deer/rabits)
     462                {
     463                    if (randFloat() < 1/200 * propDensity)
     464                        placeObject(x, y, "actor|geology/highland_c.xml", 0, randFloat(0, 2*PI));
     465                    else if (randFloat() < 1/100 * propDensity)
     466                        placeObject(x, y, "actor|props/flora/bush_tempe_a.xml", 0, randFloat(0, 2*PI));
     467                    else if (randFloat() < 1/50 * propDensity)
     468                        placeObject(x, y, "actor|props/flora/ferns.xml", 0, randFloat(0, 2*PI));
     469                    else if (randFloat() < 1/20 * propDensity)
     470                        placeObject(x, y, "actor|props/flora/grass_soft_tuft_a.xml", 0, randFloat(0, 2*PI));
     471                }
     472                if (i == 8) // ...woods
     473                {
     474                    if (randFloat() < 1/100 * propDensity)
     475                        placeObject(x, y, "actor|geology/highland2_moss.xml", 0, randFloat(0, 2*PI));
     476                    else if (randFloat() < 1/50 * propDensity)
     477                        placeObject(x, y, "actor|props/flora/grass_soft_tuft_a.xml", 0, randFloat(0, 2*PI));
     478                    else if (randFloat() < 1/20 * propDensity)
     479                        placeObject(x, y, "actor|props/flora/ferns.xml", 0, randFloat(0, 2*PI));
     480                }
     481                break;
     482            }
     483            else
     484            {
     485                textureMinHeight = textueByHeight[i].upperHeightLimit;
     486            }
     487        }
     488    }
     489}
     490
     491// Time check 3
     492timeArray.push(new Date().getTime());
     493RMS.SetProgress(90);
     494
     495
     496////////
     497// Place players and start resources
     498////////
     499
     500for (var p = 0; p < numPlayers; p++)
     501{
     502    var actualX = possibleStartPositions[bestDerivation[p]][0];
     503    var actualY = possibleStartPositions[bestDerivation[p]][1];
     504    placeCivDefaultEntities(actualX, actualY, p + 1, BUILDING_ANGlE, {"iberWall" : false});
     505    // Place some start resources
     506    var uDist = 8;
     507    var uSpace = 1;
     508    for (var j = 1; j <= 4; ++j)
     509    {
     510        var uAngle = BUILDING_ANGlE - PI * (2-j) / 2;
     511        var count = 4;
     512        for (var numberofentities = 0; numberofentities < count; numberofentities++)
     513        {
     514            var ux = actualX + uDist * cos(uAngle) + numberofentities * uSpace * cos(uAngle + PI/2) - (0.75 * uSpace * floor(count / 2) * cos(uAngle + PI/2));
     515            var uz = actualY + uDist * sin(uAngle) + numberofentities * uSpace * sin(uAngle + PI/2) - (0.75 * uSpace * floor(count / 2) * sin(uAngle + PI/2));
     516            if (j % 2 == 0)
     517                placeObject(ux, uz, "gaia/flora_bush_berry", 0, randFloat(0, 2*PI));
     518            else
     519                placeObject(ux, uz, "gaia/flora_tree_cypress", 0, randFloat(0, 2*PI));
     520        }
     521    }
     522}
     523
     524
     525// Export map data
     526ExportMap();
     527
     528// Time check 7
     529timeArray.push(new Date().getTime());
     530
     531// Calculate progress percentage with the time checks
     532var generationTime = timeArray[timeArray.length - 1] - timeArray[0];
     533log("Total generation time (ms): " + generationTime);
     534for (var i = 0; i < timeArray.length; i++)
     535{
     536    var timeSinceStart = timeArray[i] - timeArray[0];
     537    var progressPercentage = 100 * timeSinceStart / generationTime;
     538    log("Time check " + i + ": Progress (%): " + progressPercentage);
     539}
  • binaries/data/mods/public/maps/random/belgian_uplands.json

     
     1{
     2    "settings" : {
     3        "Name" : "Belgian Uplands",
     4        "Script" : "belgian_uplands.js",
     5        "Description" : "An experimental map with its hightmap generated by erosion to look more natural. Not all seeds will be fair though! Tiny maps with 8 players may take a while to generate.",
     6        "CircularMap" : false,
     7        "BaseTerrain" : ["temp_grass", "temp_grass_b", "temp_grass_c", "temp_grass_d", "temp_grass_long_b", "temp_grass_clovers_2", "temp_grass_mossy", "temp_grass_plants"],
     8        "BaseHeight" : 0,
     9        "Preview" : "belgian_uplands.png",
     10        "XXXXXX" : "Optionally define other things here, like we would for a scenario"
     11    }
     12}