Ticket #1688: belgian_uplands2012-10-5.diff

File belgian_uplands2012-10-5.diff, 24.7 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
     193var goodStartPositionsFound = false;
     194var minDistBetweenPlayers = 25; // Don't set this to 30 or higher! It will take forever on tiny maps with 8 players!
     195var tries = 0;
     196var enoughTiles = false;
     197while (!goodStartPositionsFound)
     198{
     199    tries++;
     200    log("Starting giant while loop try " + tries);
     201    // Generate reliefmap
     202    var myReliefmap = getRandomReliefmap(heightRange.min, heightRange.max);
     203    for (var i = 0; i < 50 + mapSize/4; i++) // Cycles depend on mapsize (more cycles -> bigger structures)
     204        myReliefmap = getHeightErrosionedReliefmap(myReliefmap, 1);
     205    myReliefmap = getRescaledReliefmap(myReliefmap, heightRange.min, heightRange.max);
     206    setReliefmap(myReliefmap);
     207   
     208    // Find good start position tiles
     209    var startPositions = [];
     210    var possibleStartPositions = [];
     211    var neededDistance = 7;
     212    var distToBorder = 2 * neededDistance; // Has to be greater than neededDistance! Otherwise the check if low/high ground is near will fail...
     213    var lowerHeightLimit = textueByHeight[3].upperHeightLimit;
     214    var upperHeightLimit = textueByHeight[6].upperHeightLimit;
     215    // Check for valid points by height
     216    for (var x = distToBorder + minTerrainDistToBorder; x < mapSize - distToBorder - minTerrainDistToBorder; x++)
     217    {
     218        for (var y = distToBorder + minTerrainDistToBorder; y < mapSize - distToBorder - minTerrainDistToBorder; y++)
     219        {
     220            var actualHeight = getHeight(x, y);
     221            if (actualHeight > lowerHeightLimit && actualHeight < upperHeightLimit)
     222            {
     223                // Check for points within a valid area by height (rectangular since faster)
     224                var isPossible = true;
     225                for (var offX = - neededDistance; offX <= neededDistance; offX++)
     226                {
     227                    for (var offY = - neededDistance; offY <= neededDistance; offY++)
     228                    {
     229                        var testHeight = getHeight(x + offX, y + offY);
     230                        if (testHeight <= lowerHeightLimit || testHeight >= upperHeightLimit)
     231                        {
     232                            isPossible = false;
     233                            break;
     234                        }
     235                    }
     236                }
     237                if (isPossible)
     238                {
     239                    possibleStartPositions.push([x, y]);
     240                    // placeTerrain(x, y, "blue"); // For debug reasons. Plz don't remove.
     241                }
     242            }
     243        }
     244    }
     245   
     246    // Trying to reduce the number of possible start locations...
     247   
     248    // Reduce to tiles in a circle of mapSize / 2 distance to the center (to avoid players placed in corners)
     249    var possibleStartPositionsTemp = [];
     250    var maxDistToCenter = mapSize / 2;
     251    for (var i = 0; i < possibleStartPositions.length; i++)
     252    {
     253        var deltaX = possibleStartPositions[i][0] - mapSize / 2;
     254        var deltaY = possibleStartPositions[i][1] - mapSize / 2;
     255        var distToCenter = Math.pow(Math.pow(deltaX, 2) + Math.pow(deltaY, 2), 1/2);
     256        if (distToCenter < maxDistToCenter)
     257        {
     258            possibleStartPositionsTemp.push(possibleStartPositions[i]);
     259            // placeTerrain(possibleStartPositions[i][0], possibleStartPositions[i][1], "purple"); // For debug reasons. Plz don't remove.
     260        }
     261    }
     262    possibleStartPositions = deepcopy(possibleStartPositionsTemp);
     263   
     264    // Reduce to tiles near low and high ground (Rectangular check since faster) to make sure each player has access to all resource types.
     265    var possibleStartPositionsTemp = [];
     266    var maxDistToResources = distToBorder; // Has to be <= distToBorder!
     267    var minNumLowTiles = 10;
     268    var minNumHighTiles = 10;
     269    for (var i = 0; i < possibleStartPositions.length; i++)
     270    {
     271        var numLowTiles = 0;
     272        var numHighTiles = 0;
     273        for (var dx = - maxDistToResources; dx < maxDistToResources; dx++)
     274        {
     275            for (var dy = - maxDistToResources; dy < maxDistToResources; dy++)
     276            {
     277                var testHeight = getHeight(possibleStartPositions[i][0] + dx, possibleStartPositions[i][1] + dy);
     278                if (testHeight < lowerHeightLimit)
     279                    numLowTiles++;
     280                if (testHeight > upperHeightLimit)
     281                    numHighTiles++;
     282                if (numLowTiles > minNumLowTiles && numHighTiles > minNumHighTiles)
     283                    break;
     284            }
     285            if (numLowTiles > minNumLowTiles && numHighTiles > minNumHighTiles)
     286                break;
     287        }
     288        if (numLowTiles > minNumLowTiles && numHighTiles > minNumHighTiles)
     289        {
     290            possibleStartPositionsTemp.push(possibleStartPositions[i]);
     291            // placeTerrain(possibleStartPositions[i][0], possibleStartPositions[i][1], "red"); // For debug reasons. Plz don't remove.
     292        }
     293    }
     294    possibleStartPositions = deepcopy(possibleStartPositionsTemp);
     295   
     296    if(possibleStartPositions.length > numPlayers)
     297        enoughTiles = true;
     298    else
     299    {
     300        enoughTiles = false;
     301        log("possibleStartPositions.length < numPlayers, possibleStartPositions.length = " + possibleStartPositions.length + ", numPlayers = " + numPlayers);
     302    }
     303   
     304    // Find a good start position derivation
     305    if (enoughTiles)
     306    {
     307        // Get some random start location derivations. NOTE: Itterating over all possible derivations is just to much (valid points ** numPlayers)
     308        var maxTries = 100000; // floor(800000 / (Math.pow(numPlayers, 2) / 2));
     309        var possibleDerivations = [];
     310        for (var i = 0; i < maxTries; i++)
     311        {
     312            var vector = [];
     313            for (var p = 0; p < numPlayers; p++)
     314                vector.push(randInt(possibleStartPositions.length));
     315            possibleDerivations.push(vector);
     316        }
     317       
     318        // Choose the start location derivation with the greatest minimum distance between players
     319        var maxMinDist = 0;
     320        for (var d = 0; d < possibleDerivations.length; d++)
     321        {
     322            var minDist = 2 * mapSize;
     323            for (var p1 = 0; p1 < numPlayers - 1; p1++)
     324            {
     325                for (var p2 = p1 + 1; p2 < numPlayers; p2++)
     326                {
     327                    if (p1 != p2)
     328                    {
     329                        var StartPositionP1 = possibleStartPositions[possibleDerivations[d][p1]];
     330                        var StartPositionP2 = possibleStartPositions[possibleDerivations[d][p2]];
     331                        var actualDist = Math.pow(Math.pow(StartPositionP1[0] - StartPositionP2[0], 2) + Math.pow(StartPositionP1[1] - StartPositionP2[1], 2), 1/2);
     332                        if (actualDist < minDist)
     333                            minDist = actualDist;
     334                        if (minDist < maxMinDist)
     335                            break;
     336                    }
     337                }
     338                if (minDist < maxMinDist)
     339                    break;
     340            }
     341            if (minDist > maxMinDist)
     342            {
     343                maxMinDist = minDist;
     344                var bestDerivation = possibleDerivations[d];
     345            }
     346        }
     347        if (maxMinDist > minDistBetweenPlayers)
     348        {
     349            goodStartPositionsFound = true;
     350            log("Exiting giant while loop after " +  tries + " tries with a minimum player distance of " + maxMinDist);
     351        }
     352        else
     353            log("maxMinDist <= " + minDistBetweenPlayers + ", maxMinDist = " + maxMinDist);
     354    } // End of derivation check
     355} // END THE GIANT WHILE LOOP
     356
     357// Time check 2
     358timeArray.push(new Date().getTime());
     359RMS.SetProgress(60);
     360
     361
     362////////
     363// Paint terrain by height and add props
     364////////
     365
     366var propDensity = 1; // 1 means as determined in the loop, less for large maps as set below
     367if (mapSize > 500)
     368    propDensity = 1/4;
     369else if (mapSize > 400)
     370    propDensity = 3/4;
     371for(var x = minTerrainDistToBorder; x < mapSize - minTerrainDistToBorder; x++)
     372{
     373    for (var y = minTerrainDistToBorder; y < mapSize - minTerrainDistToBorder; y++)
     374    {
     375        var textureMinHeight = heightRange.min;
     376        for (var i = 0; i < textueByHeight.length; i++)
     377        {
     378            if (getHeight(x, y) >= textureMinHeight && getHeight(x, y) <= textueByHeight[i].upperHeightLimit)
     379            {
     380                placeTerrain(x, y, textueByHeight[i].terrain);
     381                // Add some props at...
     382                if (i == 0) // ...deep water
     383                {
     384                    if (randFloat() < 1/50 * propDensity)
     385                        placeObject(x, y, "actor|props/flora/pond_lillies_large.xml", 0, randFloat(0, 2*PI));
     386                    else if (randFloat() < 1/20 * propDensity)
     387                        placeObject(x, y, "actor|props/flora/water_lillies.xml", 0, randFloat(0, 2*PI));
     388                }
     389                if (i == 1) // ...medium water (with fish)
     390                {
     391                    if (randFloat() < 1/100 * propDensity)
     392                        placeObject(x, y, "actor|props/flora/pond_lillies_large.xml", 0, randFloat(0, 2*PI));
     393                    else if (randFloat() < 1/50 * propDensity)
     394                        placeObject(x, y, "actor|props/flora/water_lillies.xml", 0, randFloat(0, 2*PI));
     395                }
     396                if (i == 2) // ...low water/mud
     397                {
     398                    if (randFloat() < 1/100 * propDensity)
     399                        placeObject(x, y, "actor|props/flora/water_log.xml", 0, randFloat(0, 2*PI));
     400                    else if (randFloat() < 1/50 * propDensity)
     401                        placeObject(x, y, "actor|props/flora/water_lillies.xml", 0, randFloat(0, 2*PI));
     402                    else if (randFloat() < 1/20 * propDensity)
     403                        placeObject(x, y, "actor|geology/highland_c.xml", 0, randFloat(0, 2*PI));
     404                    else if (randFloat() < 1/10 * propDensity)
     405                        placeObject(x, y, "actor|props/flora/reeds_pond_lush_b.xml", 0, randFloat(0, 2*PI));
     406                    else if (randFloat() < 1/5 * propDensity)
     407                        placeObject(x, y, "actor|props/flora/reeds_pond_lush_a.xml", 0, randFloat(0, 2*PI));
     408                }
     409                if (i == 3) // ...water suroundings/bog
     410                {
     411                    if (randFloat() < 1/100 * propDensity)
     412                        placeObject(x, y, "actor|props/flora/water_log.xml", 0, randFloat(0, 2*PI));
     413                    else if (randFloat() < 1/50 * propDensity)
     414                        placeObject(x, y, "actor|geology/highland_c.xml", 0, randFloat(0, 2*PI));
     415                    else if (randFloat() < 1/20 * propDensity)
     416                        placeObject(x, y, "actor|props/flora/reeds_pond_lush_a.xml", 0, randFloat(0, 2*PI));
     417                }
     418                if (i == 4) // ...low height grass
     419                {
     420                    if (randFloat() < 1/400 * propDensity)
     421                        placeObject(x, y, "actor|props/flora/grass_field_flowering_tall.xml", 0, randFloat(0, 2*PI));
     422                    else if (randFloat() < 1/200 * propDensity)
     423                        placeObject(x, y, "actor|geology/gray_rock1.xml", 0, randFloat(0, 2*PI));
     424                    else if (randFloat() < 1/100 * propDensity)
     425                        placeObject(x, y, "actor|props/flora/bush_tempe_sm_lush.xml", 0, randFloat(0, 2*PI));
     426                    else if (randFloat() < 1/50 * propDensity)
     427                        placeObject(x, y, "actor|props/flora/bush_tempe_b.xml", 0, randFloat(0, 2*PI));
     428                    else if (randFloat() < 1/20 * propDensity)
     429                        placeObject(x, y, "actor|props/flora/grass_soft_small_tall.xml", 0, randFloat(0, 2*PI));
     430                }
     431                if (i == 5) // ...medium height grass
     432                {
     433                    if (randFloat() < 1/400 * propDensity)
     434                        placeObject(x, y, "actor|geology/decal_stone_medit_a.xml", 0, randFloat(0, 2*PI));
     435                    else if (randFloat() < 1/200 * propDensity)
     436                        placeObject(x, y, "actor|props/flora/decals_flowers_daisies.xml", 0, randFloat(0, 2*PI));
     437                    else if (randFloat() < 1/100 * propDensity)
     438                        placeObject(x, y, "actor|props/flora/bush_tempe_underbrush.xml", 0, randFloat(0, 2*PI));
     439                    else if (randFloat() < 1/50 * propDensity)
     440                        placeObject(x, y, "actor|props/flora/grass_soft_small_tall.xml", 0, randFloat(0, 2*PI));
     441                    else if (randFloat() < 1/20 * propDensity)
     442                        placeObject(x, y, "actor|props/flora/grass_temp_field.xml", 0, randFloat(0, 2*PI));
     443                }
     444                if (i == 6) // ...high height grass
     445                {
     446                    if (randFloat() < 1/200 * propDensity)
     447                        placeObject(x, y, "actor|geology/stone_granite_boulder.xml", 0, randFloat(0, 2*PI));
     448                    else if (randFloat() < 1/100 * propDensity)
     449                        placeObject(x, y, "actor|props/flora/foliagebush.xml", 0, randFloat(0, 2*PI));
     450                    else if (randFloat() < 1/50 * propDensity)
     451                        placeObject(x, y, "actor|props/flora/bush_tempe_underbrush.xml", 0, randFloat(0, 2*PI));
     452                    else if (randFloat() < 1/20 * propDensity)
     453                        placeObject(x, y, "actor|props/flora/grass_soft_small_tall.xml", 0, randFloat(0, 2*PI));
     454                    else if (randFloat() < 1/10 * propDensity)
     455                        placeObject(x, y, "actor|props/flora/ferns.xml", 0, randFloat(0, 2*PI));
     456                }
     457                if (i == 7) // ...forest border (with wood/food plants/deer/rabits)
     458                {
     459                    if (randFloat() < 1/200 * propDensity)
     460                        placeObject(x, y, "actor|geology/highland_c.xml", 0, randFloat(0, 2*PI));
     461                    else if (randFloat() < 1/100 * propDensity)
     462                        placeObject(x, y, "actor|props/flora/bush_tempe_a.xml", 0, randFloat(0, 2*PI));
     463                    else if (randFloat() < 1/50 * propDensity)
     464                        placeObject(x, y, "actor|props/flora/ferns.xml", 0, randFloat(0, 2*PI));
     465                    else if (randFloat() < 1/20 * propDensity)
     466                        placeObject(x, y, "actor|props/flora/grass_soft_tuft_a.xml", 0, randFloat(0, 2*PI));
     467                }
     468                if (i == 8) // ...woods
     469                {
     470                    if (randFloat() < 1/100 * propDensity)
     471                        placeObject(x, y, "actor|geology/highland2_moss.xml", 0, randFloat(0, 2*PI));
     472                    else if (randFloat() < 1/50 * propDensity)
     473                        placeObject(x, y, "actor|props/flora/grass_soft_tuft_a.xml", 0, randFloat(0, 2*PI));
     474                    else if (randFloat() < 1/20 * propDensity)
     475                        placeObject(x, y, "actor|props/flora/ferns.xml", 0, randFloat(0, 2*PI));
     476                }
     477                break;
     478            }
     479            else
     480            {
     481                textureMinHeight = textueByHeight[i].upperHeightLimit;
     482            }
     483        }
     484    }
     485}
     486
     487// Time check 3
     488timeArray.push(new Date().getTime());
     489RMS.SetProgress(90);
     490
     491
     492////////
     493// Place players and start resources
     494////////
     495
     496for (var p = 0; p < numPlayers; p++)
     497{
     498    var actualX = possibleStartPositions[bestDerivation[p]][0];
     499    var actualY = possibleStartPositions[bestDerivation[p]][1];
     500    placeCivDefaultEntities(actualX, actualY, p + 1, BUILDING_ANGlE, {"iberWall" : false});
     501    // Place some start resources
     502    var uDist = 8;
     503    var uSpace = 1;
     504    for (var j = 1; j <= 4; ++j)
     505    {
     506        var uAngle = BUILDING_ANGlE - PI * (2-j) / 2;
     507        var count = 4;
     508        for (var numberofentities = 0; numberofentities < count; numberofentities++)
     509        {
     510            var ux = actualX + uDist * cos(uAngle) + numberofentities * uSpace * cos(uAngle + PI/2) - (0.75 * uSpace * floor(count / 2) * cos(uAngle + PI/2));
     511            var uz = actualY + uDist * sin(uAngle) + numberofentities * uSpace * sin(uAngle + PI/2) - (0.75 * uSpace * floor(count / 2) * sin(uAngle + PI/2));
     512            if (j % 2 == 0)
     513                placeObject(ux, uz, "gaia/flora_bush_berry", 0, randFloat(0, 2*PI));
     514            else
     515                placeObject(ux, uz, "gaia/flora_tree_cypress", 0, randFloat(0, 2*PI));
     516        }
     517    }
     518}
     519
     520
     521// Export map data
     522ExportMap();
     523
     524// Time check 7
     525timeArray.push(new Date().getTime());
     526
     527// Calculate progress percentage with the time checks
     528var generationTime = timeArray[timeArray.length - 1] - timeArray[0];
     529log("Total generation time (ms): " + generationTime);
     530for (var i = 0; i < timeArray.length; i++)
     531{
     532    var timeSinceStart = timeArray[i] - timeArray[0];
     533    var progressPercentage = 100 * timeSinceStart / generationTime;
     534    log("Time check " + i + ": Progress (%): " + progressPercentage);
     535}
  • 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}