diff --git a/binaries/data/mods/public/gui/gamesetup/gamesetup.js b/binaries/data/mods/public/gui/gamesetup/gamesetup.js index b98f92901f..0630a6e23c 100644 --- a/binaries/data/mods/public/gui/gamesetup/gamesetup.js +++ b/binaries/data/mods/public/gui/gamesetup/gamesetup.js @@ -483,6 +483,7 @@ var g_Dropdowns = { g_GameAttributes.settings.Biome = g_BiomeList && g_BiomeList.Id[idx]; }, "hidden": () => !g_BiomeList, + "autocomplete": 0, "initOrder": 1000 }, "numPlayers": { diff --git a/binaries/data/mods/public/maps/random/amazon.js b/binaries/data/mods/public/maps/random/amazon.js index a757c69524..d7e77dbb3b 100644 --- a/binaries/data/mods/public/maps/random/amazon.js +++ b/binaries/data/mods/public/maps/random/amazon.js @@ -3,6 +3,7 @@ RMS.LoadLibrary("rmgen"); RMS.LoadLibrary("rmgen2"); +RMS.LoadLibrary("rmbiome"); InitMap(); diff --git a/binaries/data/mods/public/maps/random/ambush.js b/binaries/data/mods/public/maps/random/ambush.js index 0bb20cf273..fbb82719f6 100644 --- a/binaries/data/mods/public/maps/random/ambush.js +++ b/binaries/data/mods/public/maps/random/ambush.js @@ -1,5 +1,6 @@ RMS.LoadLibrary("rmgen"); RMS.LoadLibrary("rmgen2"); +RMS.LoadLibrary("rmbiome"); InitMap(); diff --git a/binaries/data/mods/public/maps/random/archipelago.js b/binaries/data/mods/public/maps/random/archipelago.js index e151f6ba7c..bcb144adc2 100644 --- a/binaries/data/mods/public/maps/random/archipelago.js +++ b/binaries/data/mods/public/maps/random/archipelago.js @@ -1,4 +1,5 @@ RMS.LoadLibrary("rmgen"); +RMS.LoadLibrary("rmbiome"); TILE_CENTERED_HEIGHT_MAP = true; @@ -223,9 +224,8 @@ createForests( [tMainTerrain, tForestFloor1, tForestFloor2, pForest1, pForest2], [avoidClasses(clPlayer, 20, clForest, 17, clHill, 0), stayClasses(clLand, 4)], clForest, - 1.0, - currentBiome() -); + 1, + ...rBiomeTreeCount(1)); RMS.SetProgress(50); log("Creating dirt patches..."); diff --git a/binaries/data/mods/public/maps/random/atlas_mountains.js b/binaries/data/mods/public/maps/random/atlas_mountains.js index 77360023a1..2873a27916 100644 --- a/binaries/data/mods/public/maps/random/atlas_mountains.js +++ b/binaries/data/mods/public/maps/random/atlas_mountains.js @@ -179,14 +179,11 @@ createMountains(tCliff, avoidClasses(clPlayer, 20, clHill, 8), clHill, scaleByMa RMS.SetProgress(25); -// create forests createForests( [tGrass, tForestFloor, tForestFloor, pForest1, pForest2], avoidClasses(clPlayer, 20, clForest, 14, clHill, 1), clForest, - 0.6, - 0 -); + 0.6); RMS.SetProgress(40); diff --git a/binaries/data/mods/public/maps/random/bahrain.js b/binaries/data/mods/public/maps/random/bahrain.js index 30fc741859..b3dfcd7542 100644 --- a/binaries/data/mods/public/maps/random/bahrain.js +++ b/binaries/data/mods/public/maps/random/bahrain.js @@ -3,6 +3,7 @@ RMS.LoadLibrary("rmgen"); RMS.LoadLibrary("rmgen2"); +RMS.LoadLibrary("rmbiome"); InitMap(); diff --git a/binaries/data/mods/public/maps/random/caledonian_meadows.js b/binaries/data/mods/public/maps/random/caledonian_meadows.js index e0872ae0aa..3fe162a458 100644 --- a/binaries/data/mods/public/maps/random/caledonian_meadows.js +++ b/binaries/data/mods/public/maps/random/caledonian_meadows.js @@ -1,4 +1,5 @@ RMS.LoadLibrary("rmgen"); +RMS.LoadLibrary("rmbiome"); RMS.LoadLibrary("heightmap"); InitMap(); diff --git a/binaries/data/mods/public/maps/random/canyon.js b/binaries/data/mods/public/maps/random/canyon.js index 158a8251dd..e102780785 100644 --- a/binaries/data/mods/public/maps/random/canyon.js +++ b/binaries/data/mods/public/maps/random/canyon.js @@ -1,4 +1,5 @@ RMS.LoadLibrary("rmgen"); +RMS.LoadLibrary("rmbiome"); setSelectedBiome(); @@ -376,13 +377,12 @@ createHills([tCliff, tCliff, tHill], [avoidClasses(clPlayer, 2, clHill, 8, clHil // create hills outside the canyon createHills([tCliff, tCliff, tMainTerrain], avoidClasses(clLand, 1, clHill, 1), clHill, scaleByMapSize(20, 150), undefined, undefined, undefined, undefined, 40); -// create forests createForests( [tMainTerrain, tForestFloor1, tForestFloor2, pForest1, pForest2], [avoidClasses(clPlayer, 1, clForest, 15, clHill, 1, clHill2, 0), stayClasses(clLand, 4)], clForest, - 1.0, - currentBiome() + 1, + ...rBiomeTreeCount(1) ); RMS.SetProgress(50); diff --git a/binaries/data/mods/public/maps/random/continent.js b/binaries/data/mods/public/maps/random/continent.js index 12dc7f1ad4..de37082d30 100644 --- a/binaries/data/mods/public/maps/random/continent.js +++ b/binaries/data/mods/public/maps/random/continent.js @@ -1,4 +1,5 @@ RMS.LoadLibrary("rmgen"); +RMS.LoadLibrary("rmbiome"); setSelectedBiome(); @@ -230,14 +231,12 @@ if (randBool()) else createMountains(tCliff, [avoidClasses(clPlayer, 20, clHill, 15, clBaseResource, 3), stayClasses(clLand, 5)], clHill, scaleByMapSize(1, 4) * numPlayers); -// create forests createForests( [tMainTerrain, tForestFloor1, tForestFloor2, pForest1, pForest2], [avoidClasses(clPlayer, 20, clForest, 17, clHill, 0, clBaseResource,2), stayClasses(clLand, 4)], clForest, 1.0, - currentBiome() -); + ...rBiomeTreeCount(1)); RMS.SetProgress(50); diff --git a/binaries/data/mods/public/maps/random/empire.js b/binaries/data/mods/public/maps/random/empire.js index dab694514b..75fca1387e 100644 --- a/binaries/data/mods/public/maps/random/empire.js +++ b/binaries/data/mods/public/maps/random/empire.js @@ -1,5 +1,6 @@ RMS.LoadLibrary("rmgen"); RMS.LoadLibrary("rmgen2"); +RMS.LoadLibrary("rmbiome"); InitMap(); diff --git a/binaries/data/mods/public/maps/random/english_channel.js b/binaries/data/mods/public/maps/random/english_channel.js index 40f777020f..1b8263b4e5 100644 --- a/binaries/data/mods/public/maps/random/english_channel.js +++ b/binaries/data/mods/public/maps/random/english_channel.js @@ -277,7 +277,6 @@ createForests( avoidClasses(clPlayer, 20, clForest, 17, clHill, 0, clWater, 6), clForest, 1.0, - 0 ); RMS.SetProgress(70); diff --git a/binaries/data/mods/public/maps/random/flood.js b/binaries/data/mods/public/maps/random/flood.js index f72a24adb1..29ab10a879 100644 --- a/binaries/data/mods/public/maps/random/flood.js +++ b/binaries/data/mods/public/maps/random/flood.js @@ -1,4 +1,5 @@ RMS.LoadLibrary("rmgen"); +RMS.LoadLibrary("rmbiome"); setSelectedBiome(); @@ -306,8 +307,7 @@ createForests( [avoidClasses(clPlayer, 25, clForest, 10, clBaseResource, 3, clMetal, 6, clRock, 3, clMountain, 2), stayClasses(clHill, 6)], clForest, 0.7, - currentBiome() -); + ...rBiomeTreeCount(0.7)); log("Creating straggeler trees..."); let types = [oTree1, oTree2, oTree4, oTree3]; @@ -404,8 +404,7 @@ createForests( avoidClasses(clPlayer, 30, clHill, 10, clFood, 5), clForest, 0.1, - currentBiome() -); + ...rBiomeTreeCount(0.1)); log("Creating small grass tufts..."); group = new SimpleGroup( diff --git a/binaries/data/mods/public/maps/random/frontier.js b/binaries/data/mods/public/maps/random/frontier.js index 54ba01282d..40f66172ec 100644 --- a/binaries/data/mods/public/maps/random/frontier.js +++ b/binaries/data/mods/public/maps/random/frontier.js @@ -1,5 +1,6 @@ RMS.LoadLibrary("rmgen"); RMS.LoadLibrary("rmgen2"); +RMS.LoadLibrary("rmbiome"); InitMap(); diff --git a/binaries/data/mods/public/maps/random/gear.js b/binaries/data/mods/public/maps/random/gear.js index 76a62012a0..625d03279d 100644 --- a/binaries/data/mods/public/maps/random/gear.js +++ b/binaries/data/mods/public/maps/random/gear.js @@ -1,4 +1,5 @@ RMS.LoadLibrary("rmgen"); +RMS.LoadLibrary("rmbiome"); TILE_CENTERED_HEIGHT_MAP = true; @@ -362,9 +363,8 @@ createForests( [tMainTerrain, tForestFloor1, tForestFloor2, pForest1, pForest2], avoidClasses(clPlayer, 20, clForest, 17, clHill, 0, clWater, 2), clForest, - 1.0, - currentBiome() -); + 1, + ...rBiomeTreeCount(1)); RMS.SetProgress(50); diff --git a/binaries/data/mods/public/maps/random/guadalquivir_river.js b/binaries/data/mods/public/maps/random/guadalquivir_river.js index 65cffa330b..45ea479cc0 100644 --- a/binaries/data/mods/public/maps/random/guadalquivir_river.js +++ b/binaries/data/mods/public/maps/random/guadalquivir_river.js @@ -273,14 +273,11 @@ paintTerrainBasedOnHeight(-8, 1, 2, tWater); // create bumps createBumps([avoidClasses(clPlayer, 20, clRiver, 1), stayClasses(clLand, 3)]); -// create forests createForests( [tGrass, tForestFloorP, tForestFloorC, pForestC, pForestP], [avoidClasses(clPlayer, 20, clForest, 17, clHill, 0, clRiver, 1), stayClasses(clLand, 7)], clForest, - 1.0, - 0 -); + 1.0); RMS.SetProgress(50); diff --git a/binaries/data/mods/public/maps/random/gulf_of_bothnia.js b/binaries/data/mods/public/maps/random/gulf_of_bothnia.js index a6c889ff6b..8b612869b9 100644 --- a/binaries/data/mods/public/maps/random/gulf_of_bothnia.js +++ b/binaries/data/mods/public/maps/random/gulf_of_bothnia.js @@ -355,14 +355,11 @@ if (randBool()) else createMountains(tCliff, avoidClasses(clPlayer, 20, clHill, 15, clWater, 0), clHill, scaleByMapSize(1, 4) * numPlayers); -// create forests createForests( [tPrimary, tForestFloor, tForestFloor, pForest, pForest], avoidClasses(clPlayer, 20, clForest, 16, clHill, 0, clWater, 2), clForest, - 1.0, - random_terrain -); + 1.0); RMS.SetProgress(60); diff --git a/binaries/data/mods/public/maps/random/harbor.js b/binaries/data/mods/public/maps/random/harbor.js index 9f89d8edc8..baf7bb7fef 100644 --- a/binaries/data/mods/public/maps/random/harbor.js +++ b/binaries/data/mods/public/maps/random/harbor.js @@ -1,5 +1,6 @@ RMS.LoadLibrary("rmgen"); RMS.LoadLibrary("rmgen2"); +RMS.LoadLibrary("rmbiome"); InitMap(); diff --git a/binaries/data/mods/public/maps/random/hells_pass.js b/binaries/data/mods/public/maps/random/hells_pass.js index d7b4c021b6..1fcb873343 100644 --- a/binaries/data/mods/public/maps/random/hells_pass.js +++ b/binaries/data/mods/public/maps/random/hells_pass.js @@ -1,5 +1,6 @@ RMS.LoadLibrary("rmgen"); RMS.LoadLibrary("rmgen2"); +RMS.LoadLibrary("rmbiome"); InitMap(); diff --git a/binaries/data/mods/public/maps/random/howe_sound.js b/binaries/data/mods/public/maps/random/howe_sound.js index a178617e35..4e5d595df7 100644 --- a/binaries/data/mods/public/maps/random/howe_sound.js +++ b/binaries/data/mods/public/maps/random/howe_sound.js @@ -3,6 +3,7 @@ RMS.LoadLibrary("rmgen"); RMS.LoadLibrary("rmgen2"); +RMS.LoadLibrary("rmbiome"); InitMap(); diff --git a/binaries/data/mods/public/maps/random/island_stronghold.js b/binaries/data/mods/public/maps/random/island_stronghold.js index 70ebd45109..6aa13eefdd 100644 --- a/binaries/data/mods/public/maps/random/island_stronghold.js +++ b/binaries/data/mods/public/maps/random/island_stronghold.js @@ -12,6 +12,7 @@ function getPlayerTileCoordinates(playerIdx, teamIdx, fractionX, fractionZ) } RMS.LoadLibrary("rmgen"); +RMS.LoadLibrary("rmbiome"); RMS.LoadLibrary("heightmap"); const g_InitialMines = 1; @@ -373,9 +374,8 @@ createForests( [tMainTerrain, tForestFloor1, tForestFloor2, pForest1, pForest2], [avoidClasses(clPlayer, 10, clForest, 20, clHill, 10, clBaseResource, 5, clRock, 6, clMetal, 6), stayClasses(clLand, 3)], clForest, - 1.0, - currentBiome() -); + 1, + ...rBiomeTreeCount(1)); log("Creating hills..."); let placer = new ChainPlacer(1, floor(scaleByMapSize(4, 6)), floor(scaleByMapSize(16, 40)), 0.5); diff --git a/binaries/data/mods/public/maps/random/islands.js b/binaries/data/mods/public/maps/random/islands.js index 5cd2818b5a..26ff254d6b 100644 --- a/binaries/data/mods/public/maps/random/islands.js +++ b/binaries/data/mods/public/maps/random/islands.js @@ -1,4 +1,5 @@ RMS.LoadLibrary("rmgen"); +RMS.LoadLibrary("rmbiome"); TILE_CENTERED_HEIGHT_MAP = true; diff --git a/binaries/data/mods/public/maps/random/lake.js b/binaries/data/mods/public/maps/random/lake.js index aa3018dc46..01a29ae179 100644 --- a/binaries/data/mods/public/maps/random/lake.js +++ b/binaries/data/mods/public/maps/random/lake.js @@ -1,4 +1,5 @@ RMS.LoadLibrary("rmgen"); +RMS.LoadLibrary("rmbiome"); setSelectedBiome(); @@ -243,14 +244,12 @@ if (randBool()) else createMountains(tCliff, avoidClasses(clPlayer, 20, clHill, 15, clWater, 2), clHill, scaleByMapSize(1, 4) * numPlayers); -// create forests createForests( [tMainTerrain, tForestFloor1, tForestFloor2, pForest1, pForest2], avoidClasses(clPlayer, 20, clForest, 17, clHill, 0, clWater, 2), clForest, - 1.0, - currentBiome() -); + 1, + ...rBiomeTreeCount(1)); RMS.SetProgress(50); diff --git a/binaries/data/mods/public/maps/random/lions_den.js b/binaries/data/mods/public/maps/random/lions_den.js index da97cf8923..a93fb47f63 100644 --- a/binaries/data/mods/public/maps/random/lions_den.js +++ b/binaries/data/mods/public/maps/random/lions_den.js @@ -1,5 +1,6 @@ RMS.LoadLibrary("rmgen"); RMS.LoadLibrary("rmgen2"); +RMS.LoadLibrary("rmbiome"); InitMap(); diff --git a/binaries/data/mods/public/maps/random/mainland.js b/binaries/data/mods/public/maps/random/mainland.js index 1e1c4a1cf2..99f940c3d4 100644 --- a/binaries/data/mods/public/maps/random/mainland.js +++ b/binaries/data/mods/public/maps/random/mainland.js @@ -1,6 +1,6 @@ RMS.LoadLibrary("rmgen"); +RMS.LoadLibrary("rmbiome"); -//random terrain textures setSelectedBiome(); const tMainTerrain = rBiomeT1(); @@ -192,14 +192,12 @@ if (randBool()) else createMountains(tCliff, avoidClasses(clPlayer, 20, clHill, 15), clHill, scaleByMapSize(3, 15)); -// create forests createForests( [tMainTerrain, tForestFloor1, tForestFloor2, pForest1, pForest2], avoidClasses(clPlayer, 20, clForest, 18, clHill, 0), clForest, - 1.0, - currentBiome() -); + 1, + ...rBiomeTreeCount(1)); RMS.SetProgress(50); diff --git a/binaries/data/mods/public/maps/random/marmara.js b/binaries/data/mods/public/maps/random/marmara.js index 34b3465578..e98d272879 100644 --- a/binaries/data/mods/public/maps/random/marmara.js +++ b/binaries/data/mods/public/maps/random/marmara.js @@ -3,6 +3,7 @@ RMS.LoadLibrary("rmgen"); RMS.LoadLibrary("rmgen2"); +RMS.LoadLibrary("rmbiome"); InitMap(); diff --git a/binaries/data/mods/public/maps/random/mediterranean.js b/binaries/data/mods/public/maps/random/mediterranean.js index d0f6b9ec53..297c8508ea 100644 --- a/binaries/data/mods/public/maps/random/mediterranean.js +++ b/binaries/data/mods/public/maps/random/mediterranean.js @@ -3,6 +3,7 @@ RMS.LoadLibrary("rmgen"); RMS.LoadLibrary("rmgen2"); +RMS.LoadLibrary("rmbiome"); InitMap(); diff --git a/binaries/data/mods/public/maps/random/migration.js b/binaries/data/mods/public/maps/random/migration.js index 4d4ca4c51f..d8c52ba4ae 100644 --- a/binaries/data/mods/public/maps/random/migration.js +++ b/binaries/data/mods/public/maps/random/migration.js @@ -1,4 +1,5 @@ RMS.LoadLibrary("rmgen"); +RMS.LoadLibrary("rmbiome"); setSelectedBiome(); diff --git a/binaries/data/mods/public/maps/random/ngorongoro.js b/binaries/data/mods/public/maps/random/ngorongoro.js index 7a59b1bfe7..0b70984fa8 100644 --- a/binaries/data/mods/public/maps/random/ngorongoro.js +++ b/binaries/data/mods/public/maps/random/ngorongoro.js @@ -3,6 +3,7 @@ RMS.LoadLibrary("rmgen"); RMS.LoadLibrary("rmgen2"); +RMS.LoadLibrary("rmbiome"); InitMap(); diff --git a/binaries/data/mods/public/maps/random/pompeii.js b/binaries/data/mods/public/maps/random/pompeii.js index 3558f1f454..a814d271e3 100644 --- a/binaries/data/mods/public/maps/random/pompeii.js +++ b/binaries/data/mods/public/maps/random/pompeii.js @@ -3,6 +3,7 @@ RMS.LoadLibrary("rmgen"); RMS.LoadLibrary("rmgen2"); +RMS.LoadLibrary("rmbiome"); InitMap(); diff --git a/binaries/data/mods/public/maps/random/ratumacos.js b/binaries/data/mods/public/maps/random/ratumacos.js index abe4eecc73..16a1fdfbbd 100644 --- a/binaries/data/mods/public/maps/random/ratumacos.js +++ b/binaries/data/mods/public/maps/random/ratumacos.js @@ -3,6 +3,7 @@ RMS.LoadLibrary("rmgen"); RMS.LoadLibrary("rmgen2"); +RMS.LoadLibrary("rmbiome"); InitMap(); diff --git a/binaries/data/mods/public/maps/random/red_sea.js b/binaries/data/mods/public/maps/random/red_sea.js index 6067a133d6..db66750bd2 100644 --- a/binaries/data/mods/public/maps/random/red_sea.js +++ b/binaries/data/mods/public/maps/random/red_sea.js @@ -3,6 +3,7 @@ RMS.LoadLibrary("rmgen"); RMS.LoadLibrary("rmgen2"); +RMS.LoadLibrary("rmbiome"); InitMap(); diff --git a/binaries/data/mods/public/maps/random/rivers.js b/binaries/data/mods/public/maps/random/rivers.js index 7f7a705936..e1f691d8e2 100644 --- a/binaries/data/mods/public/maps/random/rivers.js +++ b/binaries/data/mods/public/maps/random/rivers.js @@ -1,4 +1,5 @@ RMS.LoadLibrary("rmgen"); +RMS.LoadLibrary("rmbiome"); setSelectedBiome(); @@ -373,14 +374,12 @@ if (randBool()) else createMountains(tCliff, avoidClasses(clPlayer, 20, clHill, 15, clWater, 2), clHill, scaleByMapSize(3, 15)); -// create forests createForests( [tMainTerrain, tForestFloor1, tForestFloor2, pForest1, pForest2], avoidClasses(clPlayer, 20, clForest, 17, clHill, 0, clWater, 2), clForest, - 1.0, - currentBiome() -); + 1, + ...rBiomeTreeCount(1)); RMS.SetProgress(50); diff --git a/binaries/data/mods/public/maps/random/rmgen/randombiome.js b/binaries/data/mods/public/maps/random/rmbiome/randombiome.js similarity index 98% rename from binaries/data/mods/public/maps/random/rmgen/randombiome.js rename to binaries/data/mods/public/maps/random/rmbiome/randombiome.js index aff1696fd3..6ad5fed3d9 100644 --- a/binaries/data/mods/public/maps/random/rmgen/randombiome.js +++ b/binaries/data/mods/public/maps/random/rmbiome/randombiome.js @@ -69,6 +69,12 @@ var g_Decoratives = { "tree": "actor|flora/trees/oak.xml" }; +var g_TreeCount = { + "minTrees": 500, + "maxTrees": 3000, + "forestProbability": 0.7 +}; + function currentBiome() { return g_BiomeID; @@ -85,12 +91,6 @@ function setSelectedBiome() setBiome(g_MapSettings.Biome); } -function randomizeBiome() -{ - setBiome(pickRandom(g_Biomes)); - return g_BiomeID; -} - function setBiome(biomeID) { if (g_Biomes.indexOf(biomeID) == -1) @@ -579,10 +579,15 @@ function setBiome(biomeID) "bushSmall": "actor|props/flora/bush_dry_a.xml", "tree": "actor|flora/trees/baobab.xml" }; + + g_TreeCount = { + "minTrees": 200, + "maxTrees": 1250, + "forestProbability": 0 + }; } else if (g_BiomeID == g_BiomeTropic) { - // Bora-Bora ish. Quite transparent, not wavy. // Mostly for shallow maps. Maps where the water level goes deeper should use a much darker Water Color to simulate deep water holes. setWaterColor(0.584,0.824,0.929); @@ -643,6 +648,12 @@ function setBiome(biomeID) "bushSmall": "actor|props/flora/plant_tropic_large.xml", "tree": "actor|flora/trees/tree_tropic.xml" }; + + g_TreeCount = { + "minTrees": 1000, + "maxTrees": 6000, + "forestProbabilityp": 0.52 + }; } else if (g_BiomeID == g_BiomeAutumn) { @@ -709,6 +720,15 @@ function setBiome(biomeID) } } +function rBiomeTreeCount(multiplier = 1) +{ + return [ + g_TreeCount.minTrees * multiplier, + g_TreeCount.maxTrees * multiplier, + g_TreeCount.forestProbability + ]; +} + function rBiomeT1() { return g_Terrains.mainTerrain; diff --git a/binaries/data/mods/public/maps/random/rmgen/utilityfunctions.js b/binaries/data/mods/public/maps/random/rmgen/utilityfunctions.js index d058cc165d..0945288a5a 100644 --- a/binaries/data/mods/public/maps/random/rmgen/utilityfunctions.js +++ b/binaries/data/mods/public/maps/random/rmgen/utilityfunctions.js @@ -77,64 +77,39 @@ function createMountains(terrain, constraint, tileclass, count, maxHeight, minRa ); } -function createForests(terrainset, constraint, tileclass, numMultiplier, biomeID) +function createForests(terrainset, constraint, tileclass, numMultiplier = 1, minTrees = 500, maxTrees = 3000, forestProbability = 0.7) { log("Creating forests..."); - tileclass = (tileclass !== undefined ? tileclass : clForest); - constraint = (constraint !== undefined ? constraint : avoidClasses(clPlayer, 20, clForest, 17, clHill, 0)); - numMultiplier = (numMultiplier !== undefined ? numMultiplier : 1.0); - biomeID = (biomeID !== undefined ? biomeID : 0); + tileclass = tileclass || clForest; + constraint = constraint || avoidClasses(clPlayer, 20, clForest, 17, clHill, 0); var [tM, tFF1, tFF2, tF1, tF2] = terrainset; + var totalTrees = scaleByMapSize(minTrees, maxTrees); + var numForest = totalTrees * forestProbability; + g_numStragglerTrees = totalTrees * (1.0 - forestProbability); - if (biomeID == g_BiomeSavanna) - { - var MIN_TREES = 200 * numMultiplier; - var MAX_TREES = 1250 * numMultiplier; - var P_FOREST = 0; - } - else if (biomeID == g_BiomeTropic) - { - var MIN_TREES = 1000 * numMultiplier; - var MAX_TREES = 6000 * numMultiplier; - var P_FOREST = 0.52; - } - else - { - var MIN_TREES = 500 * numMultiplier; - var MAX_TREES = 3000 * numMultiplier; - var P_FOREST = 0.7; - } - var totalTrees = scaleByMapSize(MIN_TREES, MAX_TREES); - var numForest = totalTrees * P_FOREST; - g_numStragglerTrees = totalTrees * (1.0 - P_FOREST); + if (!forestProbability) + return; log("Creating forests..."); - var types = [ + + let types = [ [[tFF2, tM, tF1], [tFF2, tF1]], [[tFF1, tM, tF2], [tFF1, tF2]] - ]; // some variation + ]; - if (biomeID != g_BiomeSavanna) - { - var size = numForest / (scaleByMapSize(3,6) * numPlayers); - var num = floor(size / types.length); - for (var i = 0; i < types.length; ++i) - { - var placer = new ChainPlacer(1, floor(scaleByMapSize(3, 5)), numForest / num, 0.5); - var painter = new LayeredPainter( - types[i], // terrains - [2] // widths - ); - createAreas( - placer, - [painter, paintClass(tileclass)], - constraint, - num - ); - } - } + let num = Math.floor(numForest / (scaleByMapSize(3,6) * numPlayers) / types.length); + for (let type of types) + createAreas( + new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), numForest / num, 0.5), + [ + new LayeredPainter(type, [2]), + paintClass(tileclass) + ], + constraint, + num + ); } function createLayeredPatches(sizes, terrainset, twidthset, constraint, count, tileclass, failfraction) diff --git a/binaries/data/mods/public/maps/random/snowflake_searocks.js b/binaries/data/mods/public/maps/random/snowflake_searocks.js index c9dd55f065..001e9e7c16 100644 --- a/binaries/data/mods/public/maps/random/snowflake_searocks.js +++ b/binaries/data/mods/public/maps/random/snowflake_searocks.js @@ -1,4 +1,5 @@ RMS.LoadLibrary("rmgen"); +RMS.LoadLibrary("rmbiome"); setSelectedBiome(); diff --git a/binaries/data/mods/public/maps/random/stronghold.js b/binaries/data/mods/public/maps/random/stronghold.js index b87fc887f7..5444d277a6 100644 --- a/binaries/data/mods/public/maps/random/stronghold.js +++ b/binaries/data/mods/public/maps/random/stronghold.js @@ -1,5 +1,6 @@ RMS.LoadLibrary("rmgen"); RMS.LoadLibrary("rmgen2"); +RMS.LoadLibrary("rmbiome"); InitMap(); diff --git a/binaries/data/mods/public/maps/random/survivalofthefittest.js b/binaries/data/mods/public/maps/random/survivalofthefittest.js index 328c7f88f1..ec1a5d48f1 100644 --- a/binaries/data/mods/public/maps/random/survivalofthefittest.js +++ b/binaries/data/mods/public/maps/random/survivalofthefittest.js @@ -1,4 +1,5 @@ RMS.LoadLibrary("rmgen"); +RMS.LoadLibrary("rmbiome"); setSelectedBiome(); @@ -185,8 +186,7 @@ createForests( [avoidClasses(clPlayer, 20, clForest, 5, clHill, 0, clBaseResource,2, clWomen, 5), stayClasses(clLand, 4)], clForest, 1, - currentBiome() -); + ...rBiomeTreeCount(1)); if (randBool()) createHills( diff --git a/binaries/data/mods/public/maps/random/unknown.js b/binaries/data/mods/public/maps/random/unknown.js index 86e2dc946d..30858c7c74 100644 --- a/binaries/data/mods/public/maps/random/unknown.js +++ b/binaries/data/mods/public/maps/random/unknown.js @@ -1,4 +1,5 @@ RMS.LoadLibrary("rmgen"); +RMS.LoadLibrary("rmbiome"); TILE_CENTERED_HEIGHT_MAP = true; diff --git a/binaries/data/mods/public/maps/random/unknown_land.js b/binaries/data/mods/public/maps/random/unknown_land.js index c000fff04f..3cae380076 100644 --- a/binaries/data/mods/public/maps/random/unknown_land.js +++ b/binaries/data/mods/public/maps/random/unknown_land.js @@ -1,4 +1,5 @@ RMS.LoadLibrary("rmgen"); +RMS.LoadLibrary("rmbiome"); TILE_CENTERED_HEIGHT_MAP = true; diff --git a/binaries/data/mods/public/maps/random/unknown_nomad.js b/binaries/data/mods/public/maps/random/unknown_nomad.js index 007d6e362d..d7e6701776 100644 --- a/binaries/data/mods/public/maps/random/unknown_nomad.js +++ b/binaries/data/mods/public/maps/random/unknown_nomad.js @@ -1,4 +1,5 @@ RMS.LoadLibrary("rmgen"); +RMS.LoadLibrary("rmbiome"); TILE_CENTERED_HEIGHT_MAP = true; diff --git a/binaries/data/mods/public/maps/random/wild_lake.js b/binaries/data/mods/public/maps/random/wild_lake.js index 0b9c44ff13..fd96c899ab 100644 --- a/binaries/data/mods/public/maps/random/wild_lake.js +++ b/binaries/data/mods/public/maps/random/wild_lake.js @@ -1,4 +1,5 @@ RMS.LoadLibrary("rmgen"); +RMS.LoadLibrary("rmbiome"); RMS.LoadLibrary("heightmap"); InitMap();