Index: binaries/data/mods/public/maps/random/african_plains.js =================================================================== --- binaries/data/mods/public/maps/random/african_plains.js +++ binaries/data/mods/public/maps/random/african_plains.js @@ -200,7 +200,7 @@ // Roaming animals { - var placeRoaming = function(name, objs) + const placeRoaming = function(name, objs) { g_Map.log("Creating roaming " + name); const group = new SimpleGroup(objs, true, clFood); @@ -237,7 +237,7 @@ // Animals that hang around watering holes { // TODO: these have a high retry factor because our mapgen constraint logic is bad. - var placeWateringHoleAnimals = function(name, objs, numberOfGroups) + const placeWateringHoleAnimals = function(name, objs, numberOfGroups) { g_Map.log("Creating " + name + " around watering holes"); const group = new SimpleGroup(objs, true, clFood); Index: binaries/data/mods/public/maps/random/alpine_lakes.js =================================================================== --- binaries/data/mods/public/maps/random/alpine_lakes.js +++ binaries/data/mods/public/maps/random/alpine_lakes.js @@ -1,6 +1,9 @@ Engine.LoadLibrary("rmgen"); Engine.LoadLibrary("rmgen-common"); +const { tPrimary, tForestFloor, tCliff, tSecondary, tHalfSnow, tSnowLimited, tDirt, tRoad, tRoadWild, + tShore, tWater, oPine, oBerryBush, oDeer, oFish, oRabbit, oStoneLarge, oStoneSmall, oMetalLarge, + aGrass, aGrassShort, aRockLarge, aRockMedium, aBushMedium, aBushSmall } = (() => { if (randBool()) { RandomMapLogger.prototype.printDirectly("Setting late spring biome.\n"); @@ -13,33 +16,35 @@ setPPContrast(0.53); setPPBloom(0.12); - var tPrimary = ["alpine_dirt_grass_50"]; - var tForestFloor = "alpine_forrestfloor"; - var tCliff = ["alpine_cliff_a", "alpine_cliff_b", "alpine_cliff_c"]; - var tSecondary = "alpine_grass_rocky"; - var tHalfSnow = ["alpine_grass_snow_50", "alpine_dirt_snow"]; - var tSnowLimited = ["alpine_snow_rocky"]; - var tDirt = "alpine_dirt"; - var tRoad = "new_alpine_citytile"; - var tRoadWild = "new_alpine_citytile"; - var tShore = "alpine_shore_rocks_grass_50"; - var tWater = "alpine_shore_rocks"; - - var oPine = "gaia/tree/pine"; - var oBerryBush = "gaia/fruit/berry_01"; - var oDeer = "gaia/fauna_deer"; - var oFish = "gaia/fish/generic"; - var oRabbit = "gaia/fauna_rabbit"; - var oStoneLarge = "gaia/rock/alpine_large"; - var oStoneSmall = "gaia/rock/alpine_small"; - var oMetalLarge = "gaia/ore/alpine_large"; - - var aGrass = "actor|props/flora/grass_soft_small_tall.xml"; - var aGrassShort = "actor|props/flora/grass_soft_large.xml"; - var aRockLarge = "actor|geology/stone_granite_med.xml"; - var aRockMedium = "actor|geology/stone_granite_med.xml"; - var aBushMedium = "actor|props/flora/bush_medit_me.xml"; - var aBushSmall = "actor|props/flora/bush_medit_sm.xml"; + return { + "tPrimary": ["alpine_dirt_grass_50"], + "tForestFloor": "alpine_forrestfloor", + "tCliff": ["alpine_cliff_a", "alpine_cliff_b", "alpine_cliff_c"], + "tSecondary": "alpine_grass_rocky", + "tHalfSnow": ["alpine_grass_snow_50", "alpine_dirt_snow"], + "tSnowLimited": ["alpine_snow_rocky"], + "tDirt": "alpine_dirt", + "tRoad": "new_alpine_citytile", + "tRoadWild": "new_alpine_citytile", + "tShore": "alpine_shore_rocks_grass_50", + "tWater": "alpine_shore_rocks", + + "oPine": "gaia/tree/pine", + "oBerryBush": "gaia/fruit/berry_01", + "oDeer": "gaia/fauna_deer", + "oFish": "gaia/fish/generic", + "oRabbit": "gaia/fauna_rabbit", + "oStoneLarge": "gaia/rock/alpine_large", + "oStoneSmall": "gaia/rock/alpine_small", + "oMetalLarge": "gaia/ore/alpine_large", + + "aGrass": "actor|props/flora/grass_soft_small_tall.xml", + "aGrassShort": "actor|props/flora/grass_soft_large.xml", + "aRockLarge": "actor|geology/stone_granite_med.xml", + "aRockMedium": "actor|geology/stone_granite_med.xml", + "aBushMedium": "actor|props/flora/bush_medit_me.xml", + "aBushSmall": "actor|props/flora/bush_medit_sm.xml", + } } else { @@ -50,34 +55,37 @@ setPPSaturation(0.37); setPPEffect("hdr"); - var tPrimary = ["alpine_snow_a", "alpine_snow_b"]; - var tForestFloor = "alpine_forrestfloor_snow"; - var tCliff = ["alpine_cliff_snow"]; - var tSecondary = "alpine_grass_snow_50"; - var tHalfSnow = ["alpine_grass_snow_50", "alpine_dirt_snow"]; - var tSnowLimited = ["alpine_snow_a", "alpine_snow_b"]; - var tDirt = "alpine_dirt"; - var tRoad = "new_alpine_citytile"; - var tRoadWild = "new_alpine_citytile"; - var tShore = "alpine_shore_rocks_icy"; - var tWater = "alpine_shore_rocks"; - - var oPine = "gaia/tree/pine_w"; - var oBerryBush = "gaia/fruit/berry_01"; - var oDeer = "gaia/fauna_deer"; - var oFish = "gaia/fish/generic"; - var oRabbit = "gaia/fauna_rabbit"; - var oStoneLarge = "gaia/rock/alpine_large"; - var oStoneSmall = "gaia/rock/alpine_small"; - var oMetalLarge = "gaia/ore/alpine_large"; - - var aGrass = "actor|props/flora/grass_soft_dry_small_tall.xml"; - var aGrassShort = "actor|props/flora/grass_soft_dry_large.xml"; - var aRockLarge = "actor|geology/stone_granite_med.xml"; - var aRockMedium = "actor|geology/stone_granite_med.xml"; - var aBushMedium = "actor|props/flora/bush_medit_me_dry.xml"; - var aBushSmall = "actor|props/flora/bush_medit_sm_dry.xml"; + return { + "tPrimary": ["alpine_snow_a", "alpine_snow_b"], + "tForestFloor": "alpine_forrestfloor_snow", + "tCliff": ["alpine_cliff_snow"], + "tSecondary": "alpine_grass_snow_50", + "tHalfSnow": ["alpine_grass_snow_50", "alpine_dirt_snow"], + "tSnowLimited": ["alpine_snow_a", "alpine_snow_b"], + "tDirt": "alpine_dirt", + "tRoad": "new_alpine_citytile", + "tRoadWild": "new_alpine_citytile", + "tShore": "alpine_shore_rocks_icy", + "tWater": "alpine_shore_rocks", + + "oPine": "gaia/tree/pine_w", + "oBerryBush": "gaia/fruit/berry_01", + "oDeer": "gaia/fauna_deer", + "oFish": "gaia/fish/generic", + "oRabbit": "gaia/fauna_rabbit", + "oStoneLarge": "gaia/rock/alpine_large", + "oStoneSmall": "gaia/rock/alpine_small", + "oMetalLarge": "gaia/ore/alpine_large", + + "aGrass": "actor|props/flora/grass_soft_dry_small_tall.xml", + "aGrassShort": "actor|props/flora/grass_soft_dry_large.xml", + "aRockLarge": "actor|geology/stone_granite_med.xml", + "aRockMedium": "actor|geology/stone_granite_med.xml", + "aBushMedium": "actor|props/flora/bush_medit_me_dry.xml", + "aBushSmall": "actor|props/flora/bush_medit_sm_dry.xml" + } } +})(); const pForest = [tForestFloor + TERRAIN_SEPARATOR + oPine, tForestFloor]; Index: binaries/data/mods/public/maps/random/alpine_valley.js =================================================================== --- binaries/data/mods/public/maps/random/alpine_valley.js +++ binaries/data/mods/public/maps/random/alpine_valley.js @@ -226,67 +226,75 @@ } }; +const { tPrimary, tForestFloor, tCliff, tSecondary, tHalfSnow, tSnowLimited, tDirt, tRoad, tRoadWild, oPine, + oBerryBush, oDeer, oRabbit, oStoneLarge, oStoneSmall, oMetalLarge, aGrass, aGrassShort, aRockLarge, + aRockMedium, aBushMedium, aBushSmall} = (() => { if (randBool()) { RandomMapLogger.prototype.printDirectly("Setting late spring biome.\n"); - var tPrimary = ["alpine_dirt_grass_50"]; - var tForestFloor = "alpine_forrestfloor"; - var tCliff = ["alpine_cliff_a", "alpine_cliff_b", "alpine_cliff_c"]; - var tSecondary = "alpine_grass_rocky"; - var tHalfSnow = ["alpine_grass_snow_50", "alpine_dirt_snow"]; - var tSnowLimited = ["alpine_snow_rocky"]; - var tDirt = "alpine_dirt"; - var tRoad = "new_alpine_citytile"; - var tRoadWild = "new_alpine_citytile"; - - var oPine = "gaia/tree/pine"; - var oBerryBush = "gaia/fruit/berry_01"; - var oDeer = "gaia/fauna_deer"; - var oRabbit = "gaia/fauna_rabbit"; - var oStoneLarge = "gaia/rock/alpine_large"; - var oStoneSmall = "gaia/rock/alpine_small"; - var oMetalLarge = "gaia/ore/alpine_large"; - - var aGrass = "actor|props/flora/grass_soft_small_tall.xml"; - var aGrassShort = "actor|props/flora/grass_soft_large.xml"; - var aRockLarge = "actor|geology/stone_granite_med.xml"; - var aRockMedium = "actor|geology/stone_granite_med.xml"; - var aBushMedium = "actor|props/flora/bush_medit_me.xml"; - var aBushSmall = "actor|props/flora/bush_medit_sm.xml"; + return { + "tPrimary": ["alpine_dirt_grass_50"], + "tForestFloor": "alpine_forrestfloor", + "tCliff": ["alpine_cliff_a", "alpine_cliff_b", "alpine_cliff_c"], + "tSecondary": "alpine_grass_rocky", + "tHalfSnow": ["alpine_grass_snow_50", "alpine_dirt_snow"], + "tSnowLimited": ["alpine_snow_rocky"], + "tDirt": "alpine_dirt", + "tRoad": "new_alpine_citytile", + "tRoadWild": "new_alpine_citytile", + + "oPine": "gaia/tree/pine", + "oBerryBush": "gaia/fruit/berry_01", + "oDeer": "gaia/fauna_deer", + "oRabbit": "gaia/fauna_rabbit", + "oStoneLarge": "gaia/rock/alpine_large", + "oStoneSmall": "gaia/rock/alpine_small", + "oMetalLarge": "gaia/ore/alpine_large", + + "aGrass": "actor|props/flora/grass_soft_small_tall.xml", + "aGrassShort": "actor|props/flora/grass_soft_large.xml", + "aRockLarge": "actor|geology/stone_granite_med.xml", + "aRockMedium": "actor|geology/stone_granite_med.xml", + "aBushMedium": "actor|props/flora/bush_medit_me.xml", + "aBushSmall": "actor|props/flora/bush_medit_sm.xml" + } } else { RandomMapLogger.prototype.printDirectly("Setting winter biome.\n"); - var tPrimary = ["alpine_snow_a", "alpine_snow_b"]; - var tForestFloor = "alpine_forrestfloor_snow"; - var tCliff = ["alpine_cliff_snow"]; - var tSecondary = "alpine_grass_snow_50"; - var tHalfSnow = ["alpine_grass_snow_50", "alpine_dirt_snow"]; - var tSnowLimited = ["alpine_snow_a", "alpine_snow_b"]; - var tDirt = "alpine_dirt"; - var tRoad = "new_alpine_citytile"; - var tRoadWild = "new_alpine_citytile"; - - var oPine = "gaia/tree/pine_w"; - var oBerryBush = "gaia/fruit/berry_01"; - var oDeer = "gaia/fauna_deer"; - var oRabbit = "gaia/fauna_rabbit"; - var oStoneLarge = "gaia/rock/alpine_large"; - var oStoneSmall = "gaia/rock/alpine_small"; - var oMetalLarge = "gaia/ore/alpine_large"; - - var aGrass = "actor|props/flora/grass_soft_dry_small_tall.xml"; - var aGrassShort = "actor|props/flora/grass_soft_dry_large.xml"; - var aRockLarge = "actor|geology/stone_granite_med.xml"; - var aRockMedium = "actor|geology/stone_granite_med.xml"; - var aBushMedium = "actor|props/flora/bush_medit_me_dry.xml"; - var aBushSmall = "actor|props/flora/bush_medit_sm_dry.xml"; + return { + "tPrimary": ["alpine_snow_a", "alpine_snow_b"], + "tForestFloor": "alpine_forrestfloor_snow", + "tCliff": ["alpine_cliff_snow"], + "tSecondary": "alpine_grass_snow_50", + "tHalfSnow": ["alpine_grass_snow_50", "alpine_dirt_snow"], + "tSnowLimited": ["alpine_snow_a", "alpine_snow_b"], + "tDirt": "alpine_dirt", + "tRoad": "new_alpine_citytile", + "tRoadWild": "new_alpine_citytile", + + "oPine": "gaia/tree/pine_w", + "oBerryBush": "gaia/fruit/berry_01", + "oDeer": "gaia/fauna_deer", + "oRabbit": "gaia/fauna_rabbit", + "oStoneLarge": "gaia/rock/alpine_large", + "oStoneSmall": "gaia/rock/alpine_small", + "oMetalLarge": "gaia/ore/alpine_large", + + "aGrass": "actor|props/flora/grass_soft_dry_small_tall.xml", + "aGrassShort": "actor|props/flora/grass_soft_dry_large.xml", + "aRockLarge": "actor|geology/stone_granite_med.xml", + "aRockMedium": "actor|geology/stone_granite_med.xml", + "aBushMedium": "actor|props/flora/bush_medit_me_dry.xml", + "aBushSmall": "actor|props/flora/bush_medit_sm_dry.xml" + } } +})(); -var heightLand = 3; -var heightOffsetBump = 2; -var snowlineHeight = 29; -var heightMountain = 30; +const heightLand = 3; +const heightOffsetBump = 2; +const snowlineHeight = 29; +const heightMountain = 30; const pForest = [tForestFloor + TERRAIN_SEPARATOR + oPine, tForestFloor]; @@ -304,7 +312,7 @@ const clFood = g_Map.createTileClass(); const clBaseResource = g_Map.createTileClass(); -var [playerIDs, playerPosition, playerAngle, startAngle] = playerPlacementCircle(fractionToTiles(0.35)); +const [playerIDs, playerPosition, playerAngle, startAngle] = playerPlacementCircle(fractionToTiles(0.35)); placePlayerBases({ "PlayerPlacement": [playerIDs, playerPosition], @@ -387,7 +395,7 @@ [[tForestFloor, tPrimary, pForest], [tForestFloor, pForest]] ]; -var size = forestTrees / (scaleByMapSize(2,8) * numPlayers); +const size = forestTrees / (scaleByMapSize(2,8) * numPlayers); const num = Math.floor(size / types.length); for (const type of types) @@ -423,7 +431,7 @@ Engine.SetProgress(65); g_Map.log("Creating stone mines"); -var group = new SimpleGroup([new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1), new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)], true, clRock); +let group = new SimpleGroup([new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1), new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)], true, clRock); createObjectGroupsDeprecated(group, 0, avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clHill, 1), scaleByMapSize(4,16), 100 @@ -505,7 +513,7 @@ stragglerTrees); g_Map.log("Creating small grass tufts"); -var planetm = 1; +const planetm = 1; group = new SimpleGroup( [new SimpleObject(aGrassShort, 1,2, 0,1, -Math.PI / 8, Math.PI / 8)] Index: binaries/data/mods/public/maps/random/ardennes_forest.js =================================================================== --- binaries/data/mods/public/maps/random/ardennes_forest.js +++ binaries/data/mods/public/maps/random/ardennes_forest.js @@ -302,32 +302,32 @@ Engine.SetProgress(60); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(1300, 8000, 0.8); -var [forestTreesJoin, forestTrees] = getTreeCounts(forestTrees, forestTrees, 0.25); +const [protoPorestTrees, stragglerTrees] = getTreeCounts(1300, 8000, 0.8); +const [forestTreesJoin, forestTrees] = getTreeCounts(protoPorestTrees, protoPorestTrees, 0.25); -var num = forestTrees / scaleByMapSize(20, 70); +const treeNum = forestTrees / scaleByMapSize(20, 70); createAreasInAreas( - new ClumpPlacer(forestTrees / num, 0.1, 0.1, Infinity), + new ClumpPlacer(forestTrees / treeNum, 0.1, 0.1, Infinity), [ new TerrainPainter(pForest), new TileClassPainter(clForest) ], avoidClasses(clPlayer, 5, clBaseResource, 4, clForest, 5, clHill, 4), - num, + treeNum, 100, [explorableArea] ); -var num = forestTreesJoin / (scaleByMapSize(4, 6) * numPlayers); +const joinNum = forestTreesJoin / (scaleByMapSize(4, 6) * numPlayers); createAreasInAreas( - new ClumpPlacer(forestTreesJoin / num, 0.1, 0.1, Infinity), + new ClumpPlacer(forestTreesJoin / joinNum, 0.1, 0.1, Infinity), [ new TerrainPainter(pForest), new TileClassPainter(clForest), new TileClassPainter(clForestJoin) ], [avoidClasses(clPlayer, 5, clBaseResource, 4, clForestJoin, 5, clHill, 4), borderClasses(clForest, 1, 4)], - num, + joinNum, 100, [explorableArea] ); @@ -436,13 +436,13 @@ g_Map.log("Creating straggler trees"); const types = [oOak, oOakLarge, oPine, oAleppoPine]; -var num = Math.floor(stragglerTrees / types.length); +const stragglerNum = Math.floor(stragglerTrees / types.length); for (const type of types) createObjectGroupsByAreasDeprecated( new SimpleGroup([new SimpleObject(type, 1, 1, 0, 3)], true, clForest), 0, avoidClasses(clForest, 4, clHill, 5, clPlayer, 10, clBaseResource, 2, clMetal, 5, clRock, 5), - num, 20, + stragglerNum, 20, [explorableArea]); Engine.SetProgress(95); Index: binaries/data/mods/public/maps/random/belgian_uplands.js =================================================================== --- binaries/data/mods/public/maps/random/belgian_uplands.js +++ binaries/data/mods/public/maps/random/belgian_uplands.js @@ -27,7 +27,7 @@ textueByHeight.push({"upperHeightLimit": heightRange.min + 1/3 * (heightSeaGroundAdjusted - heightRange.min), "terrain": "temp_sea_rocks"}); // Medium deep water (with fish) -var terrains = ["temp_sea_weed"]; +let terrains = ["temp_sea_weed"]; terrains = terrains.concat(terrains, terrains, terrains, terrains); terrains = terrains.concat(terrains, terrains, terrains, terrains); terrains.push("temp_sea_weed|gaia/fish/generic"); @@ -37,7 +37,7 @@ textueByHeight.push({"upperHeightLimit": heightRange.min + 3/3 * (heightSeaGroundAdjusted - heightRange.min), "terrain": "temp_mud_a"}); // Water surroundings/bog (with stone/metal some rabits and bushes) -var terrains = ["temp_plants_bog", "temp_plants_bog_aut", "temp_dirt_gravel_plants", "temp_grass_d"]; +terrains = ["temp_plants_bog", "temp_plants_bog_aut", "temp_dirt_gravel_plants", "temp_grass_d"]; terrains = terrains.concat(terrains, terrains, terrains, terrains, terrains); terrains = ["temp_plants_bog|gaia/tree/bush_temperate"].concat(terrains, terrains); terrains = ["temp_dirt_gravel_plants|gaia/ore/temperate_small", "temp_dirt_gravel_plants|gaia/rock/temperate_small", "temp_plants_bog|gaia/fauna_rabbit"].concat(terrains, terrains); @@ -58,7 +58,7 @@ "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"]}); // Forest border (With wood/food plants/deer/rabits) -var terrains = ["temp_grass_plants|gaia/tree/euro_beech", "temp_grass_mossy|gaia/tree/poplar", "temp_grass_mossy|gaia/tree/poplar_lombardy", +terrains = ["temp_grass_plants|gaia/tree/euro_beech", "temp_grass_mossy|gaia/tree/poplar", "temp_grass_mossy|gaia/tree/poplar_lombardy", "temp_grass_long|gaia/tree/bush_temperate", "temp_mud_plants|gaia/tree/bush_temperate", "temp_mud_plants|gaia/tree/bush_badlands", "temp_grass_long|gaia/fruit/apple", "temp_grass_clovers|gaia/fruit/berry_01", "temp_grass_clovers_2|gaia/fruit/grapes", "temp_grass_plants|gaia/fauna_deer", "temp_grass_long_b|gaia/fauna_rabbit"]; Index: binaries/data/mods/public/maps/random/cycladic_archipelago.js =================================================================== --- binaries/data/mods/public/maps/random/cycladic_archipelago.js +++ binaries/data/mods/public/maps/random/cycladic_archipelago.js @@ -85,8 +85,8 @@ const areas = []; -var nPlayer = 0; -var playerPosition = []; +let nPlayer = 0; +const playerPosition = []; function createCycladicArchipelagoIsland(position, tileClass, radius, coralRadius) { @@ -186,7 +186,7 @@ paintTileClassBasedOnHeight(-Infinity, 0, Elevation_ExcludeMin_ExcludeMax, clWater); g_Map.log("Creating forests"); -var forestTypes = [ +const forestTypes = [ [[tForestFloor, tGrass, pPalmForest], [tForestFloor, pPalmForest]], [[tForestFloor, tGrass, pPineForest], [tForestFloor, pPineForest]], [[tForestFloor, tGrass, pPoplarForest], [tForestFloor, pPoplarForest]], Index: binaries/data/mods/public/maps/random/flood.js =================================================================== --- binaries/data/mods/public/maps/random/flood.js +++ binaries/data/mods/public/maps/random/flood.js @@ -196,19 +196,19 @@ 10 * numPlayers, 60); -var [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(0.7)); +const [forestTreesMainIsland, stragglerTreesMainIsland] = getTreeCounts(...rBiomeTreeCount(0.7)); createForests( [tMainTerrain, tForestFloor1, tForestFloor2, pForest1, pForest2], [avoidClasses(clPlayer, 25, clForest, 10, clBaseResource, 3, clMetal, 6, clRock, 6, clMountain, 2), stayClasses(clHill, 6)], clForest, - forestTrees); + forestTreesMainIsland); const types = [oTree1, oTree2, oTree4, oTree3]; createStragglerTrees( types, [avoidClasses(clBaseResource, 2, clMetal, 6, clRock, 6, clMountain, 2, clPlayer, 25), stayClasses(clHill, 6)], clForest, - stragglerTrees); + stragglerTreesMainIsland); Engine.SetProgress(65); g_Map.log("Creating dirt patches"); @@ -256,7 +256,7 @@ Engine.SetProgress(85); -var planetm = currentBiome() == "generic/india" ? 8 : 1; +const planetm = currentBiome() == "generic/india" ? 8 : 1; createDecoration( [ [new SimpleObject(aRockMedium, 1, 3, 0, 1)], @@ -274,12 +274,12 @@ ], avoidClasses(clForest, 2, clPlayer, 20, clMountain, 5, clFood, 1, clBaseResource, 2)); -var [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(0.1)); +const [forestTreesAround, stragglerTreesAround] = getTreeCounts(...rBiomeTreeCount(0.1)); createForests( [tMainTerrain, tForestFloor1, tForestFloor2, pForest1, pForest2], avoidClasses(clPlayer, 30, clHill, 10, clFood, 5), clForest, - forestTrees); + forestTreesAround); g_Map.log("Creating small grass tufts"); createObjectGroupsDeprecated( Index: binaries/data/mods/public/maps/random/latium.js =================================================================== --- binaries/data/mods/public/maps/random/latium.js +++ binaries/data/mods/public/maps/random/latium.js @@ -71,12 +71,11 @@ const clPlayer = g_Map.createTileClass(); const clBaseResource = g_Map.createTileClass(); -var WATER_WIDTH = 0.1; -var horizontal = randBool(); +const WATER_WIDTH = 0.1; g_Map.log("Creating players"); -var startAngle = randBool() ? 0 : Math.PI / 2; -var playerPosition = playerPlacementLine(startAngle + Math.PI / 2, mapCenter, fractionToTiles(randFloat(0.42, 0.46))); +const startAngle = randBool() ? 0 : Math.PI / 2; +const playerPosition = playerPlacementLine(startAngle + Math.PI / 2, mapCenter, fractionToTiles(randFloat(0.42, 0.46))); function distanceToPlayers(x, z) { @@ -122,32 +121,32 @@ Engine.SetProgress(10); g_Map.log("Painting elevation"); -var noise0 = new Noise2D(scaleByMapSize(4, 16)); -var noise1 = new Noise2D(scaleByMapSize(8, 32)); -var noise2 = new Noise2D(scaleByMapSize(15, 60)); +const noise0 = new Noise2D(scaleByMapSize(4, 16)); +const noise1 = new Noise2D(scaleByMapSize(8, 32)); +const noise2 = new Noise2D(scaleByMapSize(15, 60)); -var noise2a = new Noise2D(scaleByMapSize(20, 80)); -var noise2b = new Noise2D(scaleByMapSize(35, 140)); +const noise2a = new Noise2D(scaleByMapSize(20, 80)); +const noise2b = new Noise2D(scaleByMapSize(35, 140)); -var noise3 = new Noise2D(scaleByMapSize(4, 16)); -var noise4 = new Noise2D(scaleByMapSize(6, 24)); -var noise5 = new Noise2D(scaleByMapSize(11, 44)); +const noise3 = new Noise2D(scaleByMapSize(4, 16)); +const noise4 = new Noise2D(scaleByMapSize(6, 24)); +const noise5 = new Noise2D(scaleByMapSize(11, 44)); -for (var ix = 0; ix <= mapSize; ix++) - for (var iz = 0; iz <= mapSize; iz++) +for (let ix = 0; ix <= mapSize; ix++) + for (let iz = 0; iz <= mapSize; iz++) { const position = new Vector2D(ix, iz); - var x = ix / (mapSize + 1.0); - var z = iz / (mapSize + 1.0); - var pn = playerNearness(x, z); + const x = ix / (mapSize + 1.0); + const z = iz / (mapSize + 1.0); + const pn = playerNearness(x, z); const c = startAngle ? z : x; const distToWater = clWater.has(position) ? 0 : (0.5 - WATER_WIDTH - Math.abs(c - 0.5)); let h = distToWater ? heightHill * (1 - Math.abs(c - 0.5) / (0.5 - WATER_WIDTH)) : g_Map.getHeight(position); // add some base noise - var baseNoise = 16*noise0.get(x,z) + 8*noise1.get(x,z) + 4*noise2.get(x,z) - (16+8+4)/2; + let baseNoise = 16*noise0.get(x,z) + 8*noise1.get(x,z) + 4*noise2.get(x,z) - (16+8+4)/2; if ( baseNoise < 0 ) { baseNoise *= pn; @@ -186,19 +185,19 @@ Engine.SetProgress(20); g_Map.log("Painting terrain"); -var noise6 = new Noise2D(scaleByMapSize(10, 40)); -var noise7 = new Noise2D(scaleByMapSize(20, 80)); -var noise8 = new Noise2D(scaleByMapSize(13, 52)); -var noise9 = new Noise2D(scaleByMapSize(26, 104)); -var noise10 = new Noise2D(scaleByMapSize(50, 200)); - -for (var ix = 0; ix < mapSize; ix++) - for (var iz = 0; iz < mapSize; iz++) +const noise6 = new Noise2D(scaleByMapSize(10, 40)); +const noise7 = new Noise2D(scaleByMapSize(20, 80)); +const noise8 = new Noise2D(scaleByMapSize(13, 52)); +const noise9 = new Noise2D(scaleByMapSize(26, 104)); +const noise10 = new Noise2D(scaleByMapSize(50, 200)); + +for (let ix = 0; ix < mapSize; ix++) + for (let iz = 0; iz < mapSize; iz++) { const position = new Vector2D(ix, iz); - var x = ix / (mapSize + 1.0); - var z = iz / (mapSize + 1.0); - var pn = playerNearness(x, z); + const x = ix / (mapSize + 1.0); + const z = iz / (mapSize + 1.0); + const pn = playerNearness(x, z); // Compute height difference let minH = +Infinity; @@ -209,14 +208,14 @@ minH = Math.min(minH, height); maxH = Math.max(maxH, height); } - var diffH = maxH - minH; + const diffH = maxH - minH; // figure out if we're at the top of a cliff using min adjacent height - var minAdjHeight = minH; + let minAdjHeight = minH; if (maxH > 15) { - var maxNx = Math.min(ix + 2, mapSize); - var maxNz = Math.min(iz + 2, mapSize); + const maxNx = Math.min(ix + 2, mapSize); + const maxNz = Math.min(iz + 2, mapSize); for (let nx = Math.max(ix - 1, 0); nx <= maxNx; ++nx) for (let nz = Math.max(iz - 1, 0); nz <= maxNz; ++nz) minAdjHeight = Math.min(minAdjHeight, g_Map.getHeight(new Vector2D(nx, nz))); @@ -269,7 +268,7 @@ // forests if (g_Map.getHeight(position) < 11 && diffH < 2 && minH > 1) { - var forestNoise = (noise6.get(x,z) + 0.5*noise7.get(x,z)) / 1.5 * pn - 0.59; + const forestNoise = (noise6.get(x,z) + 0.5*noise7.get(x,z)) / 1.5 * pn - 0.59; // Thin out trees a bit if (forestNoise > 0 && randBool()) @@ -298,7 +297,7 @@ // grass variations if (t == tGrass) { - var grassNoise = (noise8.get(x,z) + 0.6*noise9.get(x,z)) / 1.6; + const grassNoise = (noise8.get(x,z) + 0.6*noise9.get(x,z)) / 1.6; if (grassNoise < 0.3) t = (diffH > 1.2) ? tDirtCliff : tDirt; else if (grassNoise < 0.34) @@ -357,7 +356,7 @@ Engine.SetProgress(40); g_Map.log("Creating bushes"); -var group = new SimpleGroup( +let group = new SimpleGroup( [new SimpleObject(aBushSmall, 0,2, 0,2), new SimpleObject(aBushSmallDry, 0,2, 0,2), new SimpleObject(aBushMed, 0,1, 0,2), new SimpleObject(aBushMedDry, 0,1, 0,2)] ); Index: binaries/data/mods/public/maps/random/snowflake_searocks.js =================================================================== --- binaries/data/mods/public/maps/random/snowflake_searocks.js +++ binaries/data/mods/public/maps/random/snowflake_searocks.js @@ -65,11 +65,11 @@ const islandBetweenPlayerAndCenterRadius = 0.81; const centralIslandRadius = 0.36; -var [playerIDs, playerPosition, playerAngle, startAngle] = playerPlacementCircle(fractionToTiles(0.35)); +const [playerIDs, playerPosition, playerAngle, startAngle] = playerPlacementCircle(fractionToTiles(0.35)); -var numIslands = 0; -var isConnected = []; -var islandPos = []; +let numIslands = 0; +const isConnected = []; +const islandPos = []; function initIsConnected() { Index: binaries/data/mods/public/maps/random/unknown.js =================================================================== --- binaries/data/mods/public/maps/random/unknown.js +++ binaries/data/mods/public/maps/random/unknown.js @@ -72,9 +72,9 @@ const clLand = g_Map.createTileClass(); const clShallow = g_Map.createTileClass(); -var landElevationPainter = new SmoothElevationPainter(ELEVATION_SET, heightLand, 4); +const landElevationPainter = new SmoothElevationPainter(ELEVATION_SET, heightLand, 4); -var unknownMapFunctions = { +const unknownMapFunctions = { "land": [ "Continent", "Isthmus", @@ -99,11 +99,11 @@ * because nomad maps randomize the locations after the terrain generation. * The locations should only determined by the landscape functions to avoid placing bodies of water and resources into civic centers and the starting resources. */ -var playerIDs = sortAllPlayers(); -var playerPosition = []; +let playerIDs = sortAllPlayers(); +let playerPosition = []; -var g_StartingTreasures = false; -var g_StartingWalls = true; +let g_StartingTreasures = false; +let g_StartingWalls = true; function createUnknownMap() {