Index: binaries/data/mods/public/maps/random/aegean_sea.js =================================================================== --- binaries/data/mods/public/maps/random/aegean_sea.js +++ binaries/data/mods/public/maps/random/aegean_sea.js @@ -53,25 +53,25 @@ const heightLand = 2; const heightIsland = 6; -var g_Map = new RandomMap(heightShore, tHill); +const g_Map = new RandomMap(heightShore, tHill); const numPlayers = getNumPlayers(); const mapCenter = g_Map.getCenter(); const mapBounds = g_Map.getBounds(); -var clPlayer = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clGrass = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clIsland = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clGrass = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clIsland = g_Map.createTileClass(); -var startAngle = randomAngle(); +const startAngle = randomAngle(); placePlayerBases({ "PlayerPlacement": playerPlacementRiver(startAngle , fractionToTiles(0.6)), @@ -123,7 +123,7 @@ createBumps(avoidClasses(clWater, 2, clPlayer, 20)); -var [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7); +const [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7); createForests( [tForestFloor, tForestFloor, tForestFloor, pForest, pForest], avoidClasses(clPlayer, 20, clForest, 17, clWater, 2, clBaseResource, 3), @@ -276,7 +276,7 @@ Engine.SetProgress(90); -var types = [oDatePalm, oSDatePalm, oCarob, oFanPalm, oPoplar, oCypress]; +const types = [oDatePalm, oSDatePalm, oCarob, oFanPalm, oPoplar, oCypress]; createStragglerTrees( types, avoidClasses(clForest, 1, clWater, 2, clPlayer, 12, clMetal, 6, clHill, 1), 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 @@ -9,64 +9,64 @@ // Pick some biome defaults and overload a few settings. -var tPrimary = g_Terrains.mainTerrain; -var tForestFloor = g_Terrains.tier3Terrain; -var tCliff = ["savanna_cliff_a", "savanna_cliff_a_red", "savanna_cliff_b", "savanna_cliff_b_red"]; -var tSecondary = g_Terrains.tier1Terrain; -var tGrassShrubs = g_Terrains.tier2Terrain; -var tDirt = g_Terrains.tier3Terrain; -var tDirt2 = g_Terrains.tier4Terrain; -var tDirt3 = g_Terrains.dirt; -var tDirt4 = g_Terrains.dirt; -var tCitytiles = "savanna_tile_a"; -var tShore = g_Terrains.shore; -var tWater = g_Terrains.water; +const tPrimary = g_Terrains.mainTerrain; +const tForestFloor = g_Terrains.tier3Terrain; +const tCliff = ["savanna_cliff_a", "savanna_cliff_a_red", "savanna_cliff_b", "savanna_cliff_b_red"]; +const tSecondary = g_Terrains.tier1Terrain; +const tGrassShrubs = g_Terrains.tier2Terrain; +const tDirt = g_Terrains.tier3Terrain; +const tDirt2 = g_Terrains.tier4Terrain; +const tDirt3 = g_Terrains.dirt; +const tDirt4 = g_Terrains.dirt; +const tCitytiles = "savanna_tile_a"; +const tShore = g_Terrains.shore; +const tWater = g_Terrains.water; -var oBaobab = pickRandom(["gaia/tree/baobab", "gaia/tree/baobab_3_mature", "gaia/tree/acacia"]); -var oPalm = "gaia/tree/bush_tropic"; -var oPalm2 = "gaia/tree/cretan_date_palm_short"; -var oBerryBush = "gaia/fruit/berry_01"; -var oWildebeest = "gaia/fauna_wildebeest"; -var oZebra = "gaia/fauna_zebra"; -var oRhino = "gaia/fauna_rhinoceros_white"; -var oLion = "gaia/fauna_lion"; -var oLioness = "gaia/fauna_lioness"; -var oHawk = "birds/buzzard"; -var oGiraffe = "gaia/fauna_giraffe"; -var oGiraffe2 = "gaia/fauna_giraffe_infant"; -var oGazelle = "gaia/fauna_gazelle"; -var oElephant = "gaia/fauna_elephant_african_bush"; -var oElephant2 = "gaia/fauna_elephant_african_infant"; -var oCrocodile = "gaia/fauna_crocodile_nile"; -var oFish = g_Gaia.fish; -var oStoneLarge = g_Gaia.stoneLarge; -var oStoneSmall = g_Gaia.stoneSmall; -var oMetalLarge = g_Gaia.metalLarge; -var oMetalSmall = g_Gaia.metalSmall; +const oBaobab = pickRandom(["gaia/tree/baobab", "gaia/tree/baobab_3_mature", "gaia/tree/acacia"]); +const oPalm = "gaia/tree/bush_tropic"; +const oPalm2 = "gaia/tree/cretan_date_palm_short"; +const oBerryBush = "gaia/fruit/berry_01"; +const oWildebeest = "gaia/fauna_wildebeest"; +const oZebra = "gaia/fauna_zebra"; +const oRhino = "gaia/fauna_rhinoceros_white"; +const oLion = "gaia/fauna_lion"; +const oLioness = "gaia/fauna_lioness"; +const oHawk = "birds/buzzard"; +const oGiraffe = "gaia/fauna_giraffe"; +const oGiraffe2 = "gaia/fauna_giraffe_infant"; +const oGazelle = "gaia/fauna_gazelle"; +const oElephant = "gaia/fauna_elephant_african_bush"; +const oElephant2 = "gaia/fauna_elephant_african_infant"; +const oCrocodile = "gaia/fauna_crocodile_nile"; +const oFish = g_Gaia.fish; +const oStoneLarge = g_Gaia.stoneLarge; +const oStoneSmall = g_Gaia.stoneSmall; +const oMetalLarge = g_Gaia.metalLarge; +const oMetalSmall = g_Gaia.metalSmall; -var aBush = g_Decoratives.bushMedium; -var aRock = g_Decoratives.rockMedium; +const aBush = g_Decoratives.bushMedium; +const aRock = g_Decoratives.rockMedium; const pForest = [tForestFloor + TERRAIN_SEPARATOR + oPalm, tForestFloor + TERRAIN_SEPARATOR + oPalm2, tForestFloor]; -var heightSeaGround = -5; -var heightLand = 2; -var heightCliff = 3; +const heightSeaGround = -5; +const heightLand = 2; +const heightCliff = 3; -var g_Map = new RandomMap(heightLand, tPrimary); +const g_Map = new RandomMap(heightLand, tPrimary); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); placePlayerBases({ "PlayerPlacement": playerPlacementCircle(fractionToTiles(0.35)), 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 @@ -81,23 +81,23 @@ const pForest = [tForestFloor + TERRAIN_SEPARATOR + oPine, tForestFloor]; -var heightSeaGround = -5; -var heightLand = 3; +const heightSeaGround = -5; +const heightLand = 3; -var g_Map = new RandomMap(heightLand, tPrimary); +const g_Map = new RandomMap(heightLand, tPrimary); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); placePlayerBases({ "PlayerPlacement": playerPlacementCircle(fractionToTiles(0.35)), @@ -149,7 +149,7 @@ createBumps(avoidClasses(clWater, 2, clPlayer, 20)); -var [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7); +const [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7); createForests( [tPrimary, tForestFloor, tForestFloor, pForest, pForest], avoidClasses(clPlayer, 20, clForest, 17, clHill, 0, clWater, 2), 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 @@ -113,14 +113,14 @@ { this.UpdateCurrentEdge(); - let comparedEdge = this.possibleEdges[i]; - let comparedEdgeStart = this.vertices[comparedEdge[0]]; - let comparedEdgeEnd = this.vertices[comparedEdge[1]]; + const comparedEdge = this.possibleEdges[i]; + const comparedEdgeStart = this.vertices[comparedEdge[0]]; + const comparedEdgeEnd = this.vertices[comparedEdge[1]]; - let edge0Equal = this.currentEdgeStart == comparedEdgeStart; - let edge1Equal = this.currentEdgeStart == comparedEdgeEnd; - let edge2Equal = this.currentEdgeEnd == comparedEdgeEnd; - let edge3Equal = this.currentEdgeEnd == comparedEdgeStart; + const edge0Equal = this.currentEdgeStart == comparedEdgeStart; + const edge1Equal = this.currentEdgeStart == comparedEdgeEnd; + const edge2Equal = this.currentEdgeEnd == comparedEdgeEnd; + const edge3Equal = this.currentEdgeEnd == comparedEdgeStart; if (!edge0Equal && !edge2Equal && !edge1Equal && !edge3Equal && testLineIntersection(this.currentEdgeStart, this.currentEdgeEnd, comparedEdgeStart, comparedEdgeEnd, this.minDistance) || ( edge0Equal && !edge2Equal || !edge1Equal && edge3Equal) && distanceOfPointFromLine(this.currentEdgeStart, this.currentEdgeEnd, comparedEdgeEnd) < this.minDistance || @@ -140,13 +140,13 @@ */ MountainRangeBuilder.prototype.HasCycles = function() { - let tree = []; - let backtree = []; - let pointQueue = [this.currentEdge[0]]; + const tree = []; + const backtree = []; + const pointQueue = [this.currentEdge[0]]; while (pointQueue.length) { - let selectedPoint = pointQueue.shift(); + const selectedPoint = pointQueue.shift(); if (tree.indexOf(selectedPoint) == -1) { @@ -184,7 +184,7 @@ return false; // Creating circular mountains at both ends of that mountainrange - for (let point of [this.currentEdgeStart, this.currentEdgeEnd]) + for (const point of [this.currentEdgeStart, this.currentEdgeEnd]) createArea( new ClumpPlacer(diskArea(this.mountainWidth / 2), 0.95, 0.6, Infinity, point), this.painters, @@ -200,7 +200,7 @@ { g_Map.log("Creating mountainrange with " + this.possibleEdges.length + " possible edges"); - let max = this.possibleEdges.length; + const max = this.possibleEdges.length; while (this.possibleEdges.length) { @@ -290,19 +290,19 @@ const pForest = [tForestFloor + TERRAIN_SEPARATOR + oPine, tForestFloor]; -var g_Map = new RandomMap(heightLand, tPrimary); +const g_Map = new RandomMap(heightLand, tPrimary); const numPlayers = getNumPlayers(); const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); var [playerIDs, playerPosition, playerAngle, startAngle] = playerPlacementCircle(fractionToTiles(0.35)); @@ -382,15 +382,15 @@ Engine.SetProgress(50); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7); -var types = [ +const [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7); +const types = [ [[tForestFloor, tPrimary, pForest], [tForestFloor, pForest]] ]; var size = forestTrees / (scaleByMapSize(2,8) * numPlayers); -var num = Math.floor(size / types.length); -for (let type of types) +const num = Math.floor(size / types.length); +for (const type of types) createAreas( new ClumpPlacer(forestTrees / num, 0.1, 0.1, Infinity), [ @@ -402,7 +402,7 @@ Engine.SetProgress(60); g_Map.log("Creating dirt patches"); -for (let size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) +for (const size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), [ @@ -413,7 +413,7 @@ scaleByMapSize(15, 45)); g_Map.log("Creating grass patches"); -for (let size of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)]) +for (const size of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), new TerrainPainter(tSecondary), Index: binaries/data/mods/public/maps/random/ambush.js =================================================================== --- binaries/data/mods/public/maps/random/ambush.js +++ binaries/data/mods/public/maps/random/ambush.js @@ -5,11 +5,11 @@ setSelectedBiome(); -var heightLand = 2; +const heightLand = 2; -var g_Map = new RandomMap(heightLand, g_Terrains.mainTerrain); -var mapCenter = g_Map.getCenter(); -var mapSize = g_Map.getSize(); +const g_Map = new RandomMap(heightLand, g_Terrains.mainTerrain); +const mapCenter = g_Map.getCenter(); +const mapSize = g_Map.getSize(); initTileClasses(["bluffsPassage", "nomadArea"]); createArea( @@ -20,7 +20,7 @@ if (!isNomad()) { - let pattern = g_MapSettings.TeamPlacement || pickRandom(["line", "radial", "randomGroup", "stronghold"]); + const pattern = g_MapSettings.TeamPlacement || pickRandom(["line", "radial", "randomGroup", "stronghold"]); var [playerIDs, playerPosition] = createBases( ...playerPlacementByPattern( Index: binaries/data/mods/public/maps/random/anatolian_plateau.js =================================================================== --- binaries/data/mods/public/maps/random/anatolian_plateau.js +++ binaries/data/mods/public/maps/random/anatolian_plateau.js @@ -31,21 +31,21 @@ const pForest = [tForestFloor + TERRAIN_SEPARATOR + oPoplar, tForestFloor]; -var heightLand = 1; -var heightOffsetBump = 2; +const heightLand = 1; +const heightOffsetBump = 2; -var g_Map = new RandomMap(heightLand, tPrimary); +const g_Map = new RandomMap(heightLand, tPrimary); -var numPlayers = getNumPlayers(); +const numPlayers = getNumPlayers(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); placePlayerBases({ "PlayerPlacement": playerPlacementCircle(fractionToTiles(0.35)), @@ -85,11 +85,11 @@ scaleByMapSize(300, 800)); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(220, 1000, 0.65); -var types = [[[tForestFloor, tGrass, pForest], [tForestFloor, pForest]]]; -var size = forestTrees / (scaleByMapSize(2,8) * numPlayers); -var num = 4 * Math.floor(size / types.length); -for (let type of types) +const [forestTrees, stragglerTrees] = getTreeCounts(220, 1000, 0.65); +const types = [[[tForestFloor, tGrass, pForest], [tForestFloor, pForest]]]; +const size = forestTrees / (scaleByMapSize(2,8) * numPlayers); +const num = 4 * Math.floor(size / types.length); +for (const type of types) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(2, 3)), 4, Infinity), [ @@ -132,7 +132,7 @@ Engine.SetProgress(60); 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(1,4), 100 Index: binaries/data/mods/public/maps/random/archipelago.js =================================================================== --- binaries/data/mods/public/maps/random/archipelago.js +++ binaries/data/mods/public/maps/random/archipelago.js @@ -46,27 +46,27 @@ const pForest1 = [tForestFloor2 + TERRAIN_SEPARATOR + oTree1, tForestFloor2 + TERRAIN_SEPARATOR + oTree2, tForestFloor2]; const pForest2 = [tForestFloor1 + TERRAIN_SEPARATOR + oTree4, tForestFloor1 + TERRAIN_SEPARATOR + oTree5, tForestFloor1]; -var heightSeaGround = -5; -var heightLand = 3; -var heightShore = 1; +const heightSeaGround = -5; +const heightLand = 3; +const heightShore = 1; -var g_Map = new RandomMap(heightSeaGround, tWater); +const g_Map = new RandomMap(heightSeaGround, tWater); const numPlayers = getNumPlayers(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clLand = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clLand = g_Map.createTileClass(); -var islandRadius = scaleByMapSize(22, 31); +const islandRadius = scaleByMapSize(22, 31); -var [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.35)); +const [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.35)); g_Map.log("Creating player islands"); for (let i = 0; i < numPlayers; ++i) @@ -155,7 +155,7 @@ // adjust biomes (especially wood) const biomeSpecifics = biomeTweaks[currentBiome()] || biomeTweaks.baseline; -var [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(biomeSpecifics.treeAmount)); +const [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(biomeSpecifics.treeAmount)); createForests( [tMainTerrain, tForestFloor1, tForestFloor2, pForest1, pForest2], [avoidClasses(clPlayer, biomeSpecifics.forestPlayerSpacing, clForest, biomeSpecifics.forestForestSpacing, clHill, 0), stayClasses(clLand, 3)], @@ -202,7 +202,7 @@ ); Engine.SetProgress(65); -var planetm = currentBiome() == "generic/india" ? 8 : 1; +const planetm = currentBiome() == "generic/india" ? 8 : 1; createDecoration( [ [new SimpleObject(aRockMedium, 1, 3, 0, 1)], Index: binaries/data/mods/public/maps/random/arctic_summer.js =================================================================== --- binaries/data/mods/public/maps/random/arctic_summer.js +++ binaries/data/mods/public/maps/random/arctic_summer.js @@ -9,53 +9,53 @@ setPPContrast(0.53); setPPBloom(0.12); -var tPrimary = ["alpine_grass_rocky"]; -var tForestFloor = "alpine_grass"; -var tCliff = ["polar_cliff_a", "polar_cliff_b", "polar_cliff_snow"]; -var tSecondary = "alpine_grass"; -var tHalfSnow = ["polar_grass_snow", "ice_dirt"]; -var tSnowLimited = ["polar_snow_rocks", "polar_ice"]; -var tDirt = "ice_dirt"; -var tShore = "alpine_shore_rocks"; -var tWater = "polar_ice_b"; -var tHill = "polar_ice_cracked"; +const tPrimary = ["alpine_grass_rocky"]; +const tForestFloor = "alpine_grass"; +const tCliff = ["polar_cliff_a", "polar_cliff_b", "polar_cliff_snow"]; +const tSecondary = "alpine_grass"; +const tHalfSnow = ["polar_grass_snow", "ice_dirt"]; +const tSnowLimited = ["polar_snow_rocks", "polar_ice"]; +const tDirt = "ice_dirt"; +const tShore = "alpine_shore_rocks"; +const tWater = "polar_ice_b"; +const tHill = "polar_ice_cracked"; -var oBush = "gaia/tree/bush_badlands"; -var oBush2 = "gaia/tree/bush_temperate"; -var oBerryBush = "gaia/fruit/berry_01"; -var oRabbit = "gaia/fauna_rabbit"; -var oMuskox = "gaia/fauna_muskox"; -var oDeer = "gaia/fauna_deer"; -var oWolf = "gaia/fauna_wolf"; -var oWhaleFin = "gaia/fauna_whale_fin"; -var oWhaleHumpback = "gaia/fauna_whale_humpback"; -var oFish = "gaia/fish/generic"; -var oStoneLarge = "gaia/rock/alpine_large"; -var oStoneSmall = "gaia/rock/alpine_small"; -var oMetalLarge = "gaia/ore/alpine_large"; -var oWoodTreasure = "gaia/treasure/wood"; +const oBush = "gaia/tree/bush_badlands"; +const oBush2 = "gaia/tree/bush_temperate"; +const oBerryBush = "gaia/fruit/berry_01"; +const oRabbit = "gaia/fauna_rabbit"; +const oMuskox = "gaia/fauna_muskox"; +const oDeer = "gaia/fauna_deer"; +const oWolf = "gaia/fauna_wolf"; +const oWhaleFin = "gaia/fauna_whale_fin"; +const oWhaleHumpback = "gaia/fauna_whale_humpback"; +const oFish = "gaia/fish/generic"; +const oStoneLarge = "gaia/rock/alpine_large"; +const oStoneSmall = "gaia/rock/alpine_small"; +const oMetalLarge = "gaia/ore/alpine_large"; +const oWoodTreasure = "gaia/treasure/wood"; -var aRockLarge = "actor|geology/stone_granite_med.xml"; -var aRockMedium = "actor|geology/stone_granite_med.xml"; +const aRockLarge = "actor|geology/stone_granite_med.xml"; +const aRockMedium = "actor|geology/stone_granite_med.xml"; const pForest = [tForestFloor + TERRAIN_SEPARATOR + oBush, tForestFloor + TERRAIN_SEPARATOR + oBush2, tForestFloor]; -var heightSeaGround = -5; -var heightLand = 2; +const heightSeaGround = -5; +const heightLand = 2; -var g_Map = new RandomMap(heightLand, tPrimary); +const g_Map = new RandomMap(heightLand, tPrimary); const numPlayers = getNumPlayers(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); placePlayerBases({ "PlayerPlacement": playerPlacementCircle(fractionToTiles(0.35)), @@ -128,7 +128,7 @@ paintTerrainBasedOnHeight(4, 15, 0, tCliff); paintTerrainBasedOnHeight(15, 100, 3, tSnowLimited); -var [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7); +const [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7); createForests( [tSecondary, tForestFloor, tForestFloor, pForest, pForest], avoidClasses( 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 @@ -44,7 +44,7 @@ const aCeltHouse = "actor|structures/celts/house.xml"; const aCeltLongHouse = "actor|structures/celts/longhouse.xml"; -var pForest = [ +const pForest = [ tPineForestFloor+TERRAIN_SEPARATOR+oOak, tForestFloor, tPineForestFloor+TERRAIN_SEPARATOR+oPine, tForestFloor, tPineForestFloor+TERRAIN_SEPARATOR+oAleppoPine, tForestFloor, @@ -57,22 +57,22 @@ const heightHill = 50; const heightOffsetRavine = 10; -var g_Map = new RandomMap(heightHill, tPrimary); +const g_Map = new RandomMap(heightHill, tPrimary); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clForestJoin = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clHillDeco = g_Map.createTileClass(); -var clExplorable = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clForestJoin = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clHillDeco = g_Map.createTileClass(); +const clExplorable = g_Map.createTileClass(); g_Map.log("Creating the central dip"); createArea( @@ -84,33 +84,33 @@ Engine.SetProgress(5); g_Map.log("Finding hills"); -var noise0 = new Noise2D(20); -for (var ix = 0; ix < mapSize; ix++) - for (var iz = 0; iz < mapSize; iz++) +const noise0 = new Noise2D(20); +for (let ix = 0; ix < mapSize; ix++) + for (let iz = 0; iz < mapSize; iz++) { - let position = new Vector2D(ix, iz); - let h = g_Map.getHeight(position); + const position = new Vector2D(ix, iz); + const h = g_Map.getHeight(position); if (h > heightRavineHill) { clHill.add(position); // Add hill noise - var x = ix / (mapSize + 1.0); - var z = iz / (mapSize + 1.0); - var n = (noise0.get(x, z) - 0.5) * heightRavineHill; + const x = ix / (mapSize + 1.0); + const z = iz / (mapSize + 1.0); + const n = (noise0.get(x, z) - 0.5) * heightRavineHill; g_Map.setHeight(position, h + n); } } -var [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.3)); +const [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.3)); function distanceToPlayers(x, z) { - var r = 10000; - for (var i = 0; i < numPlayers; i++) + let r = 10000; + for (let i = 0; i < numPlayers; i++) { - var dx = x - tilesToFraction(playerPosition[i].x); - var dz = z - tilesToFraction(playerPosition[i].y); + let dx = x - tilesToFraction(playerPosition[i].x); + let dz = z - tilesToFraction(playerPosition[i].y); r = Math.min(r, Math.square(dx) + Math.square(dz)); } return Math.sqrt(r); @@ -118,7 +118,7 @@ function playerNearness(x, z) { - var d = fractionToTiles(distanceToPlayers(x,z)); + let d = fractionToTiles(distanceToPlayers(x,z)); if (d < 13) return 0; @@ -172,9 +172,9 @@ Engine.SetProgress(30); g_Map.log("Creating hills"); -for (let size of [scaleByMapSize(50, 800), scaleByMapSize(50, 400), scaleByMapSize(10, 30), scaleByMapSize(10, 30)]) +for (const size of [scaleByMapSize(50, 800), scaleByMapSize(50, 400), scaleByMapSize(10, 30), scaleByMapSize(10, 30)]) { - let mountains = createAreas( + const mountains = createAreas( new ClumpPlacer(size, 0.1, 0.2, 0.1), [ new LayeredPainter([tCliff, [tForestFloor, tForestFloor, tCliff]], [2]), @@ -196,7 +196,7 @@ 20, mountains); - let ravine = createAreas( + const ravine = createAreas( new ClumpPlacer(size, 0.1, 0.2, 0.1), [ new LayeredPainter([tCliff, tForestFloor], [2]), @@ -257,11 +257,11 @@ Engine.SetProgress(50); -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++) { - let position = new Vector2D(ix, iz); - let h = g_Map.getHeight(position); + const position = new Vector2D(ix, iz); + const h = g_Map.getHeight(position); if (h > 35 && randBool(0.1) || h < 15 && randBool(0.05) && clHillDeco.countMembersInRadius(position, 1) == 0) @@ -272,7 +272,7 @@ randomAngle()); } -var explorableArea = createArea( +const explorableArea = createArea( new MapBoundsPlacer(), undefined, [ @@ -285,16 +285,16 @@ Engine.SetProgress(55); // Add some general noise - after placing height dependant trees -for (var ix = 0; ix < mapSize; ix++) +for (let ix = 0; ix < mapSize; ix++) { - var x = ix / (mapSize + 1.0); - for (var iz = 0; iz < mapSize; iz++) + const x = ix / (mapSize + 1.0); + for (let iz = 0; iz < mapSize; iz++) { - let position = new Vector2D(ix, iz); - var z = iz / (mapSize + 1.0); - var h = g_Map.getHeight(position); - var pn = playerNearness(x,z); - var n = (noise0.get(x,z) - 0.5) * 10; + const position = new Vector2D(ix, iz); + const z = iz / (mapSize + 1.0); + const h = g_Map.getHeight(position); + const pn = playerNearness(x,z); + const n = (noise0.get(x,z) - 0.5) * 10; g_Map.setHeight(position, h + (n * pn)); } } @@ -335,7 +335,7 @@ Engine.SetProgress(70); g_Map.log("Creating grass patches"); -for (let size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) +for (const size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), new TerrainPainter([tGrass, tGrassPatch]), @@ -343,7 +343,7 @@ scaleByMapSize(15, 45)); g_Map.log("Creating chopped forest patches"); -for (let size of [scaleByMapSize(20, 120)]) +for (const size of [scaleByMapSize(20, 120)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), new TerrainPainter(tForestFloor), @@ -435,9 +435,9 @@ Engine.SetProgress(90); g_Map.log("Creating straggler trees"); -var types = [oOak, oOakLarge, oPine, oAleppoPine]; +const types = [oOak, oOakLarge, oPine, oAleppoPine]; var num = Math.floor(stragglerTrees / types.length); -for (let type of types) +for (const type of types) createObjectGroupsByAreasDeprecated( new SimpleGroup([new SimpleObject(type, 1, 1, 0, 3)], true, clForest), 0, Index: binaries/data/mods/public/maps/random/atlas_mountains.js =================================================================== --- binaries/data/mods/public/maps/random/atlas_mountains.js +++ binaries/data/mods/public/maps/random/atlas_mountains.js @@ -38,19 +38,19 @@ const heightLand = 3; -var g_Map = new RandomMap(heightLand, tPrimary); +const g_Map = new RandomMap(heightLand, tPrimary); const numPlayers = getNumPlayers(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clTreasure = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clTreasure = g_Map.createTileClass(); placePlayerBases({ "PlayerPlacement": playerPlacementCircle(fractionToTiles(0.35)), @@ -87,7 +87,7 @@ Engine.SetProgress(25); -var [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7); +const [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7); createForests( [tGrass, tForestFloor, tForestFloor, pForest1, pForest2], avoidClasses(clPlayer, 20, clForest, 14, clHill, 1), @@ -178,7 +178,7 @@ clFood); g_Map.log("Creating food treasures"); -var group = new SimpleGroup( +let group = new SimpleGroup( [new SimpleObject(oFoodTreasure, 2,3, 0,2)], true, clTreasure ); Index: binaries/data/mods/public/maps/random/bahrain.js =================================================================== --- binaries/data/mods/public/maps/random/bahrain.js +++ binaries/data/mods/public/maps/random/bahrain.js @@ -75,10 +75,10 @@ const heightWaterLevel = heightScale(0); const heightShoreline = heightScale(0.5); -var g_Map = new RandomMap(0, g_Terrains.mainTerrain); -var mapBounds = g_Map.getBounds(); -var mapCenter = g_Map.getCenter(); -var numPlayers = getNumPlayers(); +const g_Map = new RandomMap(0, g_Terrains.mainTerrain); +const mapBounds = g_Map.getBounds(); +const mapCenter = g_Map.getCenter(); +const numPlayers = getNumPlayers(); g_Map.LoadHeightmapImage("bahrain.png", 0, 15); Engine.SetProgress(15); @@ -113,7 +113,7 @@ Engine.SetProgress(35); g_Map.log("Marking island"); -var areaIsland = createArea( +const areaIsland = createArea( new RectPlacer(new Vector2D(fractionToTiles(0.4), mapBounds.top), new Vector2D(fractionToTiles(0.6), mapCenter.y), Infinity), new TileClassPainter(g_TileClasses.island), avoidClasses(g_TileClasses.water, 0)); @@ -145,7 +145,7 @@ if (!isNomad()) { g_Map.log("Placing players"); - let [playerIDs, playerPosition] = createBases( + const [playerIDs, playerPosition] = createBases( ...playerPlacementRandom( sortAllPlayers(), [ @@ -155,7 +155,7 @@ "towers"); g_Map.log("Flatten the initial CC area"); - for (let position of playerPosition) + for (const position of playerPosition) createArea( new ClumpPlacer(diskArea(defaultPlayerBaseRadius() * 0.8), 0.95, 0.6, Infinity, position), new SmoothElevationPainter(ELEVATION_SET, g_Map.getHeight(position), 6)); @@ -417,7 +417,7 @@ Engine.SetProgress(85); g_Map.log("Creating treasures"); -for (let treasure of [g_Gaia.woodTreasure, g_Gaia.foodTreasure]) +for (const treasure of [g_Gaia.woodTreasure, g_Gaia.foodTreasure]) createObjectGroups( new SimpleGroup([new SimpleObject(treasure, 1, 1, 0, 2)], true), 0, 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 @@ -6,22 +6,22 @@ "temp_grass_long_b", "temp_grass_clovers_2", "temp_grass_mossy", "temp_grass_plants"]; const heightLand = 0; -var g_Map = new RandomMap(heightLand, tPrimary); -var numPlayers = getNumPlayers(); -var mapSize = g_Map.getSize(); -var mapCenter = g_Map.getCenter(); +const g_Map = new RandomMap(heightLand, tPrimary); +const numPlayers = getNumPlayers(); +const mapSize = g_Map.getSize(); +const mapCenter = g_Map.getCenter(); // Set target min and max height depending on map size to make average stepness the same on all map sizes -var heightRange = {"min": MIN_HEIGHT * mapSize / 8192, "max": MAX_HEIGHT * mapSize / 8192}; +const heightRange = {"min": MIN_HEIGHT * mapSize / 8192, "max": MAX_HEIGHT * mapSize / 8192}; // Since erosion is not predictable, actual water coverage can differ much with the same value -var averageWaterCoverage = scaleByMapSize(1/5, 1/3); +const averageWaterCoverage = scaleByMapSize(1/5, 1/3); -var heightSeaGround = -MIN_HEIGHT + heightRange.min + averageWaterCoverage * (heightRange.max - heightRange.min); -var heightSeaGroundAdjusted = heightSeaGround + MIN_HEIGHT; +const heightSeaGround = -MIN_HEIGHT + heightRange.min + averageWaterCoverage * (heightRange.max - heightRange.min); +const heightSeaGroundAdjusted = heightSeaGround + MIN_HEIGHT; setWaterHeight(heightSeaGround); -var textueByHeight = []; +const textueByHeight = []; // Deep water textueByHeight.push({"upperHeightLimit": heightRange.min + 1/3 * (heightSeaGroundAdjusted - heightRange.min), "terrain": "temp_sea_rocks"}); @@ -49,7 +49,7 @@ "terrain": ["temp_grass", "temp_grass_d", "temp_grass_long_b", "temp_grass_plants"]}); // Medium level grass -// var testActor = "actor|geology/decal_stone_medit_a.xml"; +// const testActor = "actor|geology/decal_stone_medit_a.xml"; textueByHeight.push({"upperHeightLimit": heightSeaGroundAdjusted + 3/6 * (heightRange.max - heightSeaGroundAdjusted), "terrain": ["temp_grass", "temp_grass_b", "temp_grass_c", "temp_grass_mossy"]}); @@ -63,8 +63,8 @@ "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"]; -var numTerrains = terrains.length; -for (var i = 0; i < numTerrains; i++) +const numTerrains = terrains.length; +for (let i = 0; i < numTerrains; i++) terrains.push("temp_grass_plants"); textueByHeight.push({"upperHeightLimit": heightSeaGroundAdjusted + 5/6 * (heightRange.max - heightSeaGroundAdjusted), "terrain": terrains}); @@ -77,11 +77,11 @@ Engine.SetProgress(5); -var lowerHeightLimit = textueByHeight[3].upperHeightLimit; -var upperHeightLimit = textueByHeight[6].upperHeightLimit; +const lowerHeightLimit = textueByHeight[3].upperHeightLimit; +const upperHeightLimit = textueByHeight[6].upperHeightLimit; -var playerPosition; -var playerIDs; +let playerPosition; +let playerIDs; while (true) { @@ -100,13 +100,13 @@ rescaleHeightmap(heightRange.min, heightRange.max, g_Map.height); g_Map.log("Mark valid heightrange for player starting positions"); - let tHeightRange = g_Map.createTileClass(); - let area = createArea( + const tHeightRange = g_Map.createTileClass(); + const area = createArea( new DiskPlacer(fractionToTiles(0.5) - MAP_BORDER_WIDTH, mapCenter), new TileClassPainter(tHeightRange), new HeightConstraint(lowerHeightLimit, upperHeightLimit)); - let players = area && playerPlacementRandom(sortAllPlayers(), stayClasses(tHeightRange, 15), true); + const players = area && playerPlacementRandom(sortAllPlayers(), stayClasses(tHeightRange, 15), true); if (players) { [playerIDs, playerPosition] = players; @@ -118,7 +118,7 @@ Engine.SetProgress(60); g_Map.log("Painting terrain by height and add props"); -var propDensity = 1; // 1 means as determined in the loop, less for large maps as set below +let propDensity = 1; // 1 means as determined in the loop, less for large maps as set below if (mapSize > 500) propDensity = 1/4; else if (mapSize > 400) @@ -127,12 +127,12 @@ for (let x = 0; x < mapSize; ++x) for (let y = 0; y < mapSize; ++y) { - let position = new Vector2D(x, y); + const position = new Vector2D(x, y); if (!g_Map.validHeight(position)) continue; - var textureMinHeight = heightRange.min; - for (var i = 0; i < textueByHeight.length; i++) + let textureMinHeight = heightRange.min; + for (let i = 0; i < textueByHeight.length; i++) { if (g_Map.getHeight(position) >= textureMinHeight && g_Map.getHeight(position) <= textueByHeight[i].upperHeightLimit) { @@ -254,9 +254,9 @@ { g_Map.log("Placing players and starting resources"); - let resourceDistance = 8; - let resourceSpacing = 1; - let resourceCount = 4; + const resourceDistance = 8; + const resourceSpacing = 1; + const resourceCount = 4; for (let i = 0; i < numPlayers; ++i) { @@ -264,10 +264,10 @@ for (let j = 1; j <= 4; ++j) { - let uAngle = BUILDING_ORIENTATION - Math.PI * (2-j) / 2; + const uAngle = BUILDING_ORIENTATION - Math.PI * (2-j) / 2; for (let k = 0; k < resourceCount; ++k) { - let pos = Vector2D.sum([ + const pos = Vector2D.sum([ playerPosition[i], new Vector2D(resourceDistance, 0).rotate(-uAngle), new Vector2D(k * resourceSpacing, 0).rotate(-uAngle - Math.PI/2), Index: binaries/data/mods/public/maps/random/botswanan_haven.js =================================================================== --- binaries/data/mods/public/maps/random/botswanan_haven.js +++ binaries/data/mods/public/maps/random/botswanan_haven.js @@ -50,19 +50,19 @@ const heightOffsetBump1 = 2; const heightOffsetBump2 = 1; -var g_Map = new RandomMap(heightLand, tShoreBlend); +const g_Map = new RandomMap(heightLand, tShoreBlend); const numPlayers = getNumPlayers(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); placePlayerBases({ "PlayerPlacement": playerPlacementCircle(fractionToTiles(0.35)), @@ -145,7 +145,7 @@ scaleByMapSize(50, 100)); g_Map.log("Creating mud patches"); -for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) +for (const size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) createAreas( new ChainPlacer(2, Math.floor(scaleByMapSize(3, 6)), size, Infinity), [ Index: binaries/data/mods/public/maps/random/caledonian_meadows.js =================================================================== --- binaries/data/mods/public/maps/random/caledonian_meadows.js +++ binaries/data/mods/public/maps/random/caledonian_meadows.js @@ -3,18 +3,18 @@ Engine.LoadLibrary("rmbiome"); Engine.LoadLibrary("heightmap"); -var tGrove = "temp_grass_plants"; -var tPath = "road_rome_a"; +const tGrove = "temp_grass_plants"; +const tPath = "road_rome_a"; -var oGroveEntities = ["structures/gaul/outpost", "gaia/tree/oak_new"]; +const oGroveEntities = ["structures/gaul/outpost", "gaia/tree/oak_new"]; -var g_Map = new RandomMap(0, "whiteness"); +const g_Map = new RandomMap(0, "whiteness"); /** * Design resource spots */ // Mines -let decorations = [ +const decorations = [ "actor|geology/gray1.xml", "actor|geology/gray_rock1.xml", "actor|geology/highland1.xml", "actor|geology/highland2.xml", "actor|geology/highland3.xml", "actor|geology/highland_c.xml", "actor|geology/highland_d.xml", "actor|geology/highland_e.xml", @@ -25,8 +25,8 @@ function placeMine(point, centerEntity) { g_Map.placeEntityPassable(centerEntity, 0, point, randomAngle()); - let quantity = randIntInclusive(11, 23); - let dAngle = 2 * Math.PI / quantity; + const quantity = randIntInclusive(11, 23); + const dAngle = 2 * Math.PI / quantity; for (let i = 0; i < quantity; ++i) g_Map.placeEntityPassable( @@ -47,7 +47,7 @@ "farmstead": { "angle": Math.PI, "length": 0, "indent": -3, "bend": 0, "templateName": "structures/brit/farmstead" } }; -let fences = [ +const fences = [ new Fortress("fence", [ "foodBin", "farmstead", "bench", "turn_0.25", "sheep", "turn_0.25", "fence", @@ -79,13 +79,13 @@ "turn_0.25", "sheep", "turn_0.25", "fence_short", "sheep", "fence" ]) ]; -let num = fences.length; +const num = fences.length; for (let i = 0; i < num; ++i) fences.push(new Fortress("fence", clone(fences[i].wall).reverse())); // Groves, only wood -let groveEntities = ["gaia/tree/bush_temperate", "gaia/tree/euro_beech"]; -let groveActors = [ +const groveEntities = ["gaia/tree/bush_temperate", "gaia/tree/euro_beech"]; +const groveActors = [ "actor|geology/highland1_moss.xml", "actor|geology/highland2_moss.xml", "actor|props/flora/bush.xml", "actor|props/flora/bush_dry_a.xml", "actor|props/flora/bush_highlands.xml", "actor|props/flora/bush_tempe_a.xml", "actor|props/flora/bush_tempe_b.xml", "actor|props/flora/ferns.xml" @@ -94,16 +94,16 @@ function placeGrove(point) { g_Map.placeEntityPassable(pickRandom(oGroveEntities), 0, point, randomAngle()); - let quantity = randIntInclusive(20, 30); - let dAngle = 2 * Math.PI / quantity; + const quantity = randIntInclusive(20, 30); + const dAngle = 2 * Math.PI / quantity; for (let i = 0; i < quantity; ++i) { - let angle = dAngle * randFloat(i, i + 1); - let dist = randFloat(2, 5); + const angle = dAngle * randFloat(i, i + 1); + const dist = randFloat(2, 5); let objectList = groveEntities; if (i % 3 == 0) objectList = groveActors; - let position = Vector2D.add(point, new Vector2D(dist, 0).rotate(-angle)); + const position = Vector2D.add(point, new Vector2D(dist, 0).rotate(-angle)); g_Map.placeEntityPassable(pickRandom(objectList), 0, position, randomAngle()); createArea( new ClumpPlacer(5, 1, 1, Infinity, position), @@ -121,12 +121,12 @@ ) { g_Map.placeEntityPassable(centerEntity, 0, point, randomAngle()); - let quantity = randIntInclusive(5, 11); - let dAngle = 2 * Math.PI / quantity; + const quantity = randIntInclusive(5, 11); + const dAngle = 2 * Math.PI / quantity; for (let i = 0; i < quantity; ++i) { - let angle = dAngle * randFloat(i, i + 1); - let dist = randFloat(1, 3); + const angle = dAngle * randFloat(i, i + 1); + const dist = randFloat(1, 3); g_Map.placeEntityPassable(pickRandom(otherEntities), 0, Vector2D.add(point, new Vector2D(dist, 0).rotate(-angle)), randomAngle()); } } @@ -137,7 +137,7 @@ // Stone and chicken let dAngle = 4/9 * Math.PI; let angle = currentAngle + randFloat(1, 3) * dAngle / 4; - let stonePosition = Vector2D.add(point, new Vector2D(12, 0).rotate(-angle)); + const stonePosition = Vector2D.add(point, new Vector2D(12, 0).rotate(-angle)); placeMine(stonePosition, "gaia/rock/temperate_large"); currentAngle += dAngle; @@ -150,7 +150,7 @@ let objectList = groveEntities; if (i % 2 == 0) objectList = groveActors; - let woodPosition = Vector2D.add(point, new Vector2D(randFloat(10, 15), 0).rotate(-angle)); + const woodPosition = Vector2D.add(point, new Vector2D(randFloat(10, 15), 0).rotate(-angle)); g_Map.placeEntityPassable(pickRandom(objectList), 0, woodPosition, randomAngle()); createArea( new ClumpPlacer(5, 1, 1, Infinity, woodPosition), @@ -161,7 +161,7 @@ // Metal and chicken dAngle = 2 * Math.PI * 2 / 9; angle = currentAngle + dAngle * randFloat(1, 3) / 4; - let metalPosition = Vector2D.add(point, new Vector2D(13, 0).rotate(-angle)); + const metalPosition = Vector2D.add(point, new Vector2D(13, 0).rotate(-angle)); placeMine(metalPosition, "gaia/ore/temperate_large"); currentAngle += dAngle; @@ -171,7 +171,7 @@ for (let i = 0; i < quantity; ++i) { angle = currentAngle + randFloat(0, dAngle); - let berriesPosition = Vector2D.add(point, new Vector2D(randFloat(10, 15), 0).rotate(-angle)); + const berriesPosition = Vector2D.add(point, new Vector2D(randFloat(10, 15), 0).rotate(-angle)); g_Map.placeEntityPassable(pickRandom(foodEntities), 0, berriesPosition, randomAngle()); currentAngle += dAngle; } @@ -188,18 +188,18 @@ /** * Base terrain shape generation and settings */ -let heightScale = (g_Map.size + 256) / 768 / 4; -let heightRange = { "min": MIN_HEIGHT * heightScale, "max": MAX_HEIGHT * heightScale }; +const heightScale = (g_Map.size + 256) / 768 / 4; +const heightRange = { "min": MIN_HEIGHT * heightScale, "max": MAX_HEIGHT * heightScale }; // Water coverage -let averageWaterCoverage = 1/5; // NOTE: Since terrain generation is quite unpredictable actual water coverage might vary much with the same value -let heightSeaGround = -MIN_HEIGHT + heightRange.min + averageWaterCoverage * (heightRange.max - heightRange.min); // Water height in environment and the engine -let heightSeaGroundAdjusted = heightSeaGround + MIN_HEIGHT; // Water height in RMGEN +const averageWaterCoverage = 1/5; // NOTE: Since terrain generation is quite unpredictable actual water coverage might vary much with the same value +const heightSeaGround = -MIN_HEIGHT + heightRange.min + averageWaterCoverage * (heightRange.max - heightRange.min); // Water height in environment and the engine +const heightSeaGroundAdjusted = heightSeaGround + MIN_HEIGHT; // Water height in RMGEN setWaterHeight(heightSeaGround); g_Map.log("Generating terrain using diamon-square"); -let medH = (heightRange.min + heightRange.max) / 2; -let initialHeightmap = [[medH, medH], [medH, medH]]; +const medH = (heightRange.min + heightRange.max) / 2; +const initialHeightmap = [[medH, medH], [medH, medH]]; setBaseTerrainDiamondSquare(heightRange.min, heightRange.max, initialHeightmap, 0.8); g_Map.log("Apply erosion"); @@ -210,7 +210,7 @@ Engine.SetProgress(25); -let heighLimits = [ +const heighLimits = [ heightRange.min + 1/3 * (heightSeaGroundAdjusted - heightRange.min), // 0 Deep water heightRange.min + 2/3 * (heightSeaGroundAdjusted - heightRange.min), // 1 Medium Water heightRange.min + (heightSeaGroundAdjusted - heightRange.min), // 2 Shallow water @@ -223,11 +223,11 @@ heightSeaGroundAdjusted + 7/8 * (heightRange.max - heightSeaGroundAdjusted), // 9 Upper forest border heightSeaGroundAdjusted + (heightRange.max - heightSeaGroundAdjusted)]; // 10 Hilltop -let playerHeight = (heighLimits[4] + heighLimits[5]) / 2; // Average player height +const playerHeight = (heighLimits[4] + heighLimits[5]) / 2; // Average player height g_Map.log("Determining height-dependent biome"); // Texture and actor presets -let myBiome = []; +const myBiome = []; myBiome.push({ // 0 Deep water "texture": ["shoreline_stoney_a"], "entity": [["gaia/fish/generic", "actor|geology/stone_granite_boulder.xml"], 0.02], @@ -284,17 +284,17 @@ "textureHS": ["alpine_cliff_c"], "entityHS": [["actor|geology/highland1.xml"], 0.0] }); -let [playerIDs, playerPosition] = groupPlayersCycle(getStartLocationsByHeightmap({ "min": heighLimits[4], "max": heighLimits[5] }, 1000, 30)); +const [playerIDs, playerPosition] = groupPlayersCycle(getStartLocationsByHeightmap({ "min": heighLimits[4], "max": heighLimits[5] }, 1000, 30)); Engine.SetProgress(30); g_Map.log("Smoothing player locations"); -for (let position of playerPosition) +for (const position of playerPosition) createArea( new DiskPlacer(35, position), new SmoothElevationPainter(ELEVATION_SET, g_Map.getHeight(position), 35)); g_Map.log("Creating paths between players"); -let clPath = g_Map.createTileClass(); +const clPath = g_Map.createTileClass(); for (let i = 0; i < playerPosition.length; ++i) createArea( new RandomPathPlacer(playerPosition[i], playerPosition[(i + 1) % playerPosition.length], 4, 2, false), @@ -313,21 +313,21 @@ Engine.SetProgress(45); g_Map.log("Determining resource locations"); -let avoidPoints = playerPosition.map(pos => pos.clone()); +const avoidPoints = playerPosition.map(pos => pos.clone()); for (let i = 0; i < avoidPoints.length; ++i) avoidPoints[i].dist = 30; -let resourceSpots = getPointsByHeight({ "min": (heighLimits[3] + heighLimits[4]) / 2, "max": (heighLimits[5] + heighLimits[6]) / 2 }, avoidPoints, clPath); +const resourceSpots = getPointsByHeight({ "min": (heighLimits[3] + heighLimits[4]) / 2, "max": (heighLimits[5] + heighLimits[6]) / 2 }, avoidPoints, clPath); Engine.SetProgress(55); /** * Divide tiles in areas by height and avoid paths */ -let tchm = getTileCenteredHeightmap(); -let areas = heighLimits.map(heightLimit => []); +const tchm = getTileCenteredHeightmap(); +const areas = heighLimits.map(heightLimit => []); for (let x = 0; x < tchm.length; ++x) for (let y = 0; y < tchm[0].length; ++y) { - let position = new Vector2D(x, y); + const position = new Vector2D(x, y); if (!avoidClasses(clPath, 0).allows(position)) continue; @@ -347,16 +347,16 @@ /** * Get max slope of each area */ -let slopeMap = getSlopeMap(); -let minSlope = []; -let maxSlope = []; +const slopeMap = getSlopeMap(); +const minSlope = []; +const maxSlope = []; for (let h = 0; h < heighLimits.length; ++h) { minSlope[h] = Infinity; maxSlope[h] = 0; - for (let point of areas[h]) + for (const point of areas[h]) { - let slope = slopeMap[point.x][point.y]; + const slope = slopeMap[point.x][point.y]; if (slope > maxSlope[h]) maxSlope[h] = slope; @@ -368,7 +368,7 @@ g_Map.log("Painting areas by height and slope"); for (let h = 0; h < heighLimits.length; ++h) - for (let point of areas[h]) + for (const point of areas[h]) { let entity; let texture = pickRandom(myBiome[h].texture); @@ -405,8 +405,8 @@ g_Map.log("Placing resources, farmsteads, groves and camps"); for (let i = 0; i < resourceSpots.length; ++i) { - let pos = new Vector2D(resourceSpots[i].x, resourceSpots[i].y); - let choice = i % (isNomad() ? 4 : 5); + const pos = new Vector2D(resourceSpots[i].x, resourceSpots[i].y); + const choice = i % (isNomad() ? 4 : 5); if (choice == 0) placeMine(pos, "gaia/rock/temperate_large_02"); if (choice == 1) Index: binaries/data/mods/public/maps/random/cantabrian_highlands.js =================================================================== --- binaries/data/mods/public/maps/random/cantabrian_highlands.js +++ binaries/data/mods/public/maps/random/cantabrian_highlands.js @@ -51,24 +51,24 @@ const heightLand = 3; const heightHill = 20; -var g_Map = new RandomMap(heightLand, tPrimary); +const g_Map = new RandomMap(heightLand, tPrimary); -var numPlayers = getNumPlayers(); -var mapSize = g_Map.getSize(); +const numPlayers = getNumPlayers(); +const mapSize = g_Map.getSize(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); -var playerHillRadius = defaultPlayerBaseRadius() / (isNomad() ? 1.5 : 1); +const playerHillRadius = defaultPlayerBaseRadius() / (isNomad() ? 1.5 : 1); -var [playerIDs, playerPosition, playerAngle] = playerPlacementCircle(fractionToTiles(0.35)); +const [playerIDs, playerPosition, playerAngle] = playerPlacementCircle(fractionToTiles(0.35)); g_Map.log("Creating player hills and ramps"); for (let i = 0; i < numPlayers; ++i) @@ -81,7 +81,7 @@ new TileClassPainter(clPlayer) ]); - let angle = playerAngle[i] + Math.PI * (1 + randFloat(-1, 1) / 8); + const angle = playerAngle[i] + Math.PI * (1 + randFloat(-1, 1) / 8); createPassage({ "start": Vector2D.add(playerPosition[i], new Vector2D(playerHillRadius + 15, 0).rotate(-angle)), "end": Vector2D.add(playerPosition[i], new Vector2D(playerHillRadius - 3, 0).rotate(-angle)), @@ -125,8 +125,8 @@ Engine.SetProgress(10); g_Map.log("Creating lakes"); -var numLakes = Math.round(scaleByMapSize(1,4) * numPlayers); -var waterAreas = createAreas( +const numLakes = Math.round(scaleByMapSize(1,4) * numPlayers); +const waterAreas = createAreas( new ClumpPlacer(scaleByMapSize(100, 250), 0.8, 0.1, Infinity), [ new LayeredPainter([tShoreBlend, tShore, tWater], [1, 1]), @@ -139,7 +139,7 @@ Engine.SetProgress(15); g_Map.log("Creating reeds"); -var group = new SimpleGroup( +const group = new SimpleGroup( [new SimpleObject(aReeds, 5,10, 0,4), new SimpleObject(aLillies, 0,1, 0,4)], true ); createObjectGroupsByAreas(group, 0, @@ -169,7 +169,7 @@ createHills([tCliff, tCliff, tHill], avoidClasses(clPlayer, 2, clWater, 5, clHill, 15), clHill, scaleByMapSize(1, 4) * numPlayers); Engine.SetProgress(35); -var [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); +const [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); createDefaultForests( [tGrass, tGrassDForest, tGrassPForest, pForestP, pForestD], avoidClasses(clPlayer, 1, clWater, 3, clForest, 17, clHill, 1), Index: binaries/data/mods/public/maps/random/canyon.js =================================================================== --- binaries/data/mods/public/maps/random/canyon.js +++ binaries/data/mods/public/maps/random/canyon.js @@ -44,26 +44,26 @@ const heightLand = 3; const heightHill = 30; -var g_Map = new RandomMap(heightHill, tMainTerrain); +const g_Map = new RandomMap(heightHill, tMainTerrain); -var numPlayers = getNumPlayers(); -var mapSize = g_Map.getSize(); -var mapCenter = g_Map.getCenter(); +const numPlayers = getNumPlayers(); +const mapSize = g_Map.getSize(); +const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clHill2 = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clLand = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clHill2 = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clLand = g_Map.createTileClass(); -var playerCanyonRadius = scaleByMapSize(18, 32); +const playerCanyonRadius = scaleByMapSize(18, 32); -var [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.35)); +const [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.35)); g_Map.log("Reserving space for the players, their initial forests and some less space therein without trees"); for (let i = 0; i < numPlayers; ++i) @@ -108,9 +108,9 @@ for (let g = 0; g < scaleByMapSize(5, 30); ++g) { - let position = new Vector2D(randIntInclusive(1, mapSize - 1), randIntInclusive(1, mapSize - 1)); + const position = new Vector2D(randIntInclusive(1, mapSize - 1), randIntInclusive(1, mapSize - 1)); - let newarea = createArea( + const newarea = createArea( new ClumpPlacer(diskArea(fractionToTiles(0.06)), 0.7, 0.1, Infinity, position), [ new TerrainPainter(tMainTerrain), @@ -121,11 +121,11 @@ if (newarea !== null) { - var distances = []; - var d1 = 9999; - var d2 = 9999; - var p1 = -1; - var p2 = 0; + let distances = []; + let d1 = 9999; + let d2 = 9999; + let p1 = -1; + let p2 = 0; for (let i = 0; i < numPlayers; ++i) distances.push(position.distanceTo(playerPosition[i])); @@ -146,7 +146,7 @@ } } - for (let playerID of [p1, p2]) + for (const playerID of [p1, p2]) if (playerPosition[playerID]) createArea( new PathPlacer(position, playerPosition[playerID], scaleByMapSize(11, 17), 0.4, scaleByMapSize(3, 12), 0.1, 0.1), @@ -161,8 +161,8 @@ g_Map.log("Creating paths from players to neighbor and center"); for (let i = 0; i < numPlayers; ++i) { - let neighbor = i + 1 < numPlayers ? i + 1 : 0; - for (let position of [playerPosition[neighbor], mapCenter]) + const neighbor = i + 1 < numPlayers ? i + 1 : 0; + for (const position of [playerPosition[neighbor], mapCenter]) createArea( new PathPlacer( playerPosition[i], @@ -225,7 +225,7 @@ // create hills outside the canyon createHills([tCliff, tCliff, tMainTerrain], avoidClasses(clLand, 1, clHill, 1), clHill, scaleByMapSize(20, 150), undefined, undefined, undefined, undefined, 40); -var [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); +const [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); createForests( [tMainTerrain, tForestFloor1, tForestFloor2, pForest1, pForest2], [avoidClasses(clPlayer, 1, clForest, 15, clHill, 1, clHill2, 0), stayClasses(clLand, 4)], @@ -271,7 +271,7 @@ Engine.SetProgress(65); -var planetm = 1; +let planetm = 1; if (currentBiome() == "generic/india") planetm = 8; @@ -294,7 +294,7 @@ avoidClasses(clForest, 0, clPlayer, 0, clHill, 0)); g_Map.log("Creating actor trees"); -var group = new SimpleGroup( +const group = new SimpleGroup( [new SimpleObject(aTree, 1,1, 0,1)], true ); @@ -338,7 +338,7 @@ g_Map.log("Creating treasures"); for (let i = 0; i < randIntInclusive(3, 8); ++i) - for (let template of [oFoodTreasure, oWoodTreasure]) + for (const template of [oFoodTreasure, oWoodTreasure]) g_Map.placeEntityPassable( template, 0, Index: binaries/data/mods/public/maps/random/continent.js =================================================================== --- binaries/data/mods/public/maps/random/continent.js +++ binaries/data/mods/public/maps/random/continent.js @@ -45,21 +45,21 @@ const heightSeaGround = -5; const heightLand = 3; -var g_Map = new RandomMap(heightSeaGround, tWater); +const g_Map = new RandomMap(heightSeaGround, tWater); -var numPlayers = getNumPlayers(); -var mapSize = g_Map.getSize(); -var mapCenter = g_Map.getCenter(); +const numPlayers = getNumPlayers(); +const mapSize = g_Map.getSize(); +const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clLand = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clLand = g_Map.createTileClass(); g_Map.log("Creating continent"); createArea( @@ -76,7 +76,7 @@ new TileClassPainter(clLand) ]); -var [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.25)); +const [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.25)); g_Map.log("Ensuring initial player land"); for (let i = 0; i < numPlayers; ++i) @@ -136,7 +136,7 @@ else createMountains(tCliff, [avoidClasses(clPlayer, 20, clHill, 15, clBaseResource, 3), stayClasses(clLand, 5)], clHill, scaleByMapSize(1, 4) * numPlayers); -var [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); +const [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); createDefaultForests( [tMainTerrain, tForestFloor1, tForestFloor2, pForest1, pForest2], [avoidClasses(clPlayer, 20, clForest, 17, clHill, 0, clBaseResource,2), stayClasses(clLand, 4)], @@ -182,7 +182,7 @@ Engine.SetProgress(65); // create decoration -var planetm = 1; +let planetm = 1; if (currentBiome() == "generic/india") planetm = 8; Index: binaries/data/mods/public/maps/random/corinthian_isthmus.js =================================================================== --- binaries/data/mods/public/maps/random/corinthian_isthmus.js +++ binaries/data/mods/public/maps/random/corinthian_isthmus.js @@ -54,34 +54,34 @@ tForestFloor ]; -var heightSeaGround = -7; -var heightShallow = -0.8; -var heightLand = 3; +const heightSeaGround = -7; +const heightShallow = -0.8; +const heightLand = 3; -var g_Map = new RandomMap(heightLand, tHill); +const g_Map = new RandomMap(heightLand, tHill); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clGrass = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clPassageway = g_Map.createTileClass(); -var clShallow = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +let clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clGrass = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clPassageway = g_Map.createTileClass(); +const clShallow = g_Map.createTileClass(); g_Map.log("Creating the main river"); -var riverAngle = randomAngle(); -var riverWidth = scaleByMapSize(20, 90); -var riverStart = new Vector2D(mapCenter.x, 0).rotateAround(riverAngle, mapCenter); -var riverEnd = new Vector2D(mapCenter.x, mapSize).rotateAround(riverAngle, mapCenter); +const riverAngle = randomAngle(); +const riverWidth = scaleByMapSize(20, 90); +const riverStart = new Vector2D(mapCenter.x, 0).rotateAround(riverAngle, mapCenter); +const riverEnd = new Vector2D(mapCenter.x, mapSize).rotateAround(riverAngle, mapCenter); createArea( new PathPlacer(riverStart, riverEnd, riverWidth, 0.2, scaleByMapSize(0.3, 1), 0.04, 0.01), Index: binaries/data/mods/public/maps/random/corsica.js =================================================================== --- binaries/data/mods/public/maps/random/corsica.js +++ binaries/data/mods/public/maps/random/corsica.js @@ -1,90 +1,90 @@ Engine.LoadLibrary("rmgen"); Engine.LoadLibrary("rmgen-common"); -var tGrass = ["medit_grass_field", "medit_grass_field_b", "temp_grass_c"]; -var tLushGrass = ["medit_grass_field","medit_grass_field_a"]; +const tGrass = ["medit_grass_field", "medit_grass_field_b", "temp_grass_c"]; +const tLushGrass = ["medit_grass_field","medit_grass_field_a"]; -var tSteepCliffs = ["temp_cliff_b", "temp_cliff_a"]; -var tCliffs = ["temp_cliff_b", "medit_cliff_italia", "medit_cliff_italia_grass"]; -var tHill = ["medit_cliff_italia_grass","medit_cliff_italia_grass", "medit_grass_field", "medit_grass_field", "temp_grass"]; -var tMountain = ["medit_cliff_italia_grass","medit_cliff_italia"]; +const tSteepCliffs = ["temp_cliff_b", "temp_cliff_a"]; +const tCliffs = ["temp_cliff_b", "medit_cliff_italia", "medit_cliff_italia_grass"]; +const tHill = ["medit_cliff_italia_grass","medit_cliff_italia_grass", "medit_grass_field", "medit_grass_field", "temp_grass"]; +const tMountain = ["medit_cliff_italia_grass","medit_cliff_italia"]; -var tRoad = ["medit_city_tile","medit_rocks_grass","medit_grass_field_b"]; -var tRoadWild = ["medit_rocks_grass","medit_grass_field_b"]; +const tRoad = ["medit_city_tile","medit_rocks_grass","medit_grass_field_b"]; +const tRoadWild = ["medit_rocks_grass","medit_grass_field_b"]; -var tShoreBlend = ["medit_sand_wet","medit_rocks_wet"]; -var tShore = ["medit_rocks","medit_sand","medit_sand"]; -var tSandTransition = ["medit_sand","medit_rocks_grass","medit_rocks_grass","medit_rocks_grass"]; -var tVeryDeepWater = ["medit_sea_depths","medit_sea_coral_deep"]; -var tDeepWater = ["medit_sea_coral_deep","tropic_ocean_coral"]; -var tCreekWater = "medit_sea_coral_plants"; +const tShoreBlend = ["medit_sand_wet","medit_rocks_wet"]; +const tShore = ["medit_rocks","medit_sand","medit_sand"]; +const tSandTransition = ["medit_sand","medit_rocks_grass","medit_rocks_grass","medit_rocks_grass"]; +const tVeryDeepWater = ["medit_sea_depths","medit_sea_coral_deep"]; +const tDeepWater = ["medit_sea_coral_deep","tropic_ocean_coral"]; +const tCreekWater = "medit_sea_coral_plants"; -var ePine = "gaia/tree/aleppo_pine"; -var ePalmTall = "gaia/tree/cretan_date_palm_tall"; -var eFanPalm = "gaia/tree/medit_fan_palm"; -var eApple = "gaia/fruit/apple"; -var eBush = "gaia/fruit/berry_01"; -var eFish = "gaia/fish/generic"; -var ePig = "gaia/fauna_pig"; -var eStoneMine = "gaia/rock/mediterranean_large"; -var eMetalMine = "gaia/ore/mediterranean_large"; +const ePine = "gaia/tree/aleppo_pine"; +const ePalmTall = "gaia/tree/cretan_date_palm_tall"; +const eFanPalm = "gaia/tree/medit_fan_palm"; +const eApple = "gaia/fruit/apple"; +const eBush = "gaia/fruit/berry_01"; +const eFish = "gaia/fish/generic"; +const ePig = "gaia/fauna_pig"; +const eStoneMine = "gaia/rock/mediterranean_large"; +const eMetalMine = "gaia/ore/mediterranean_large"; -var aRock = "actor|geology/stone_granite_med.xml"; -var aLargeRock = "actor|geology/stone_granite_large.xml"; -var aBushA = "actor|props/flora/bush_medit_sm_lush.xml"; -var aBushB = "actor|props/flora/bush_medit_me_lush.xml"; -var aPlantA = "actor|props/flora/plant_medit_artichoke.xml"; -var aPlantB = "actor|props/flora/grass_tufts_a.xml"; -var aPlantC = "actor|props/flora/grass_soft_tuft_a.xml"; +const aRock = "actor|geology/stone_granite_med.xml"; +const aLargeRock = "actor|geology/stone_granite_large.xml"; +const aBushA = "actor|props/flora/bush_medit_sm_lush.xml"; +const aBushB = "actor|props/flora/bush_medit_me_lush.xml"; +const aPlantA = "actor|props/flora/plant_medit_artichoke.xml"; +const aPlantB = "actor|props/flora/grass_tufts_a.xml"; +const aPlantC = "actor|props/flora/grass_soft_tuft_a.xml"; -var aStandingStone = "actor|props/special/eyecandy/standing_stones.xml"; +const aStandingStone = "actor|props/special/eyecandy/standing_stones.xml"; -var heightSeaGround = -8; -var heightCreeks = -5; -var heightBeaches = -1; -var heightMain = 5; +const heightSeaGround = -8; +const heightCreeks = -5; +const heightBeaches = -1; +const heightMain = 5; -var heightOffsetMainRelief = 30; -var heightOffsetLevel1 = 9; -var heightOffsetLevel2 = 8; -var heightOffsetBumps = 2; -var heightOffsetAntiBumps = -5; +const heightOffsetMainRelief = 30; +const heightOffsetLevel1 = 9; +const heightOffsetLevel2 = 8; +const heightOffsetBumps = 2; +const heightOffsetAntiBumps = -5; -var g_Map = new RandomMap(heightSeaGround, tVeryDeepWater); +const g_Map = new RandomMap(heightSeaGround, tVeryDeepWater); -var numPlayers = getNumPlayers(); -var mapSize = g_Map.getSize(); -var mapCenter = g_Map.getCenter(); +const numPlayers = getNumPlayers(); +const mapSize = g_Map.getSize(); +const mapCenter = g_Map.getCenter(); -var clIsland = g_Map.createTileClass(); -var clCreek = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clCliffs = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clShore = g_Map.createTileClass(); -var clPlayer = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clPassage = g_Map.createTileClass(); -var clSettlement = g_Map.createTileClass(); +const clIsland = g_Map.createTileClass(); +const clCreek = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clCliffs = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clShore = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clPassage = g_Map.createTileClass(); +const clSettlement = g_Map.createTileClass(); -var radiusBeach = fractionToTiles(0.57); -var radiusCreeks = fractionToTiles(0.52); -var radiusIsland = fractionToTiles(0.4); -var radiusLevel1 = fractionToTiles(0.35); -var radiusPlayer = fractionToTiles(0.25); -var radiusLevel2 = fractionToTiles(0.2); +const radiusBeach = fractionToTiles(0.57); +const radiusCreeks = fractionToTiles(0.52); +const radiusIsland = fractionToTiles(0.4); +const radiusLevel1 = fractionToTiles(0.35); +const radiusPlayer = fractionToTiles(0.25); +const radiusLevel2 = fractionToTiles(0.2); -var creeksArea = () => randBool() ? randFloat(10, 50) : scaleByMapSize(75, 100) + randFloat(0, 20); +const creeksArea = () => randBool() ? randFloat(10, 50) : scaleByMapSize(75, 100) + randFloat(0, 20); -var nbCreeks = scaleByMapSize(6, 15); -var nbSubIsland = 5; -var nbBeaches = scaleByMapSize(2, 5); -var nbPassagesLevel1 = scaleByMapSize(4, 8); -var nbPassagesLevel2 = scaleByMapSize(2, 4); +const nbCreeks = scaleByMapSize(6, 15); +const nbSubIsland = 5; +const nbBeaches = scaleByMapSize(2, 5); +const nbPassagesLevel1 = scaleByMapSize(4, 8); +const nbPassagesLevel2 = scaleByMapSize(2, 4); g_Map.log("Creating Corsica and Sardinia"); -var swapAngle = randBool() ? Math.PI / 2 : 0; -var islandLocations = [new Vector2D(0.05, 0.05), new Vector2D(0.95, 0.95)].map(v => v.mult(mapSize).rotateAround(-swapAngle, mapCenter)); +const swapAngle = randBool() ? Math.PI / 2 : 0; +const islandLocations = [new Vector2D(0.05, 0.05), new Vector2D(0.95, 0.95)].map(v => v.mult(mapSize).rotateAround(-swapAngle, mapCenter)); for (let island = 0; island < 2; ++island) { @@ -100,8 +100,8 @@ g_Map.log("Creating subislands"); for (let i = 0; i < nbSubIsland + 1; ++i) { - let angle = Math.PI * (island + i / (nbSubIsland * 2)) + swapAngle; - let location = Vector2D.add(islandLocations[island], new Vector2D(radiusIsland, 0).rotate(-angle)); + const angle = Math.PI * (island + i / (nbSubIsland * 2)) + swapAngle; + const location = Vector2D.add(islandLocations[island], new Vector2D(radiusIsland, 0).rotate(-angle)); createArea( new ClumpPlacer(diskArea(fractionToTiles(0.09)), 0.6, 0.03, Infinity, location), [ @@ -114,8 +114,8 @@ g_Map.log("Creating creeks"); for (let i = 0; i < nbCreeks + 1; ++i) { - let angle = Math.PI * (island + i * (1 / (nbCreeks * 2))) + swapAngle; - let location = Vector2D.add(islandLocations[island], new Vector2D(radiusCreeks, 0).rotate(-angle)); + const angle = Math.PI * (island + i * (1 / (nbCreeks * 2))) + swapAngle; + const location = Vector2D.add(islandLocations[island], new Vector2D(radiusCreeks, 0).rotate(-angle)); createArea( new ClumpPlacer(creeksArea(), 0.4, 0.01, Infinity, location), [ @@ -128,9 +128,9 @@ g_Map.log("Creating beaches"); for (let i = 0; i < nbBeaches + 1; ++i) { - let angle = Math.PI * (island + (i / (nbBeaches * 2.5)) + 1 / (nbBeaches * 6) + randFloat(-1, 1) / (nbBeaches * 7)) + swapAngle; - let start = Vector2D.add(islandLocations[island], new Vector2D(radiusIsland, 0).rotate(-angle)); - let end = Vector2D.add(islandLocations[island], new Vector2D(radiusBeach, 0).rotate(-angle)); + const angle = Math.PI * (island + (i / (nbBeaches * 2.5)) + 1 / (nbBeaches * 6) + randFloat(-1, 1) / (nbBeaches * 7)) + swapAngle; + const start = Vector2D.add(islandLocations[island], new Vector2D(radiusIsland, 0).rotate(-angle)); + const end = Vector2D.add(islandLocations[island], new Vector2D(radiusBeach, 0).rotate(-angle)); createArea( new ClumpPlacer(130, 0.7, 0.8, Infinity, Vector2D.add(start, Vector2D.mult(end, 3)).div(4)), @@ -159,7 +159,7 @@ g_Map.log("Creating first level passages"); for (let i = 0; i <= nbPassagesLevel1; ++i) { - let angle = Math.PI * (i / 7 + 1 / 9 + island) + swapAngle; + const angle = Math.PI * (i / 7 + 1 / 9 + island) + swapAngle; createPassage({ "start": Vector2D.add(islandLocations[island], new Vector2D(radiusLevel1 + 10, 0).rotate(-angle)), "end": Vector2D.add(islandLocations[island], new Vector2D(radiusLevel1 - 4, 0).rotate(-angle)), @@ -183,7 +183,7 @@ g_Map.log("Creating second level passages"); for (let i = 0; i < nbPassagesLevel2; ++i) { - let angle = Math.PI * (i / (2 * nbPassagesLevel2) + 1 / (4 * nbPassagesLevel2) + island) + swapAngle; + const angle = Math.PI * (i / (2 * nbPassagesLevel2) + 1 / (4 * nbPassagesLevel2) + island) + swapAngle; createPassage({ "start": Vector2D.add(islandLocations[island], new Vector2D(radiusLevel2 + 3, 0).rotate(-angle)), "end": Vector2D.add(islandLocations[island], new Vector2D(radiusLevel2 - 6, 0).rotate(-angle)), @@ -198,13 +198,13 @@ Engine.SetProgress(30); g_Map.log("Determining player locations"); -var playerIDs = sortAllPlayers(); -var playerPosition = []; -var playerAngle = []; -var p = 0; +const playerIDs = sortAllPlayers(); +let playerPosition = []; +let playerAngle = []; +let p = 0; for (let island = 0; island < 2; ++island) { - let playersPerIsland = island == 0 ? Math.ceil(numPlayers / 2) : Math.floor(numPlayers / 2); + const playersPerIsland = island == 0 ? Math.ceil(numPlayers / 2) : Math.floor(numPlayers / 2); for (let i = 0; i < playersPerIsland; ++i) { @@ -270,8 +270,8 @@ for (let mapX = 0; mapX < mapSize; ++mapX) for (let mapZ = 0; mapZ < mapSize; ++mapZ) { - let position = new Vector2D(mapX, mapZ); - let terrain = getCosricaSardiniaTerrain(position); + const position = new Vector2D(mapX, mapZ); + const terrain = getCosricaSardiniaTerrain(position); if (!terrain) continue; @@ -283,16 +283,16 @@ function getCosricaSardiniaTerrain(position) { - let isWater = clWater.countMembersInRadius(position, 3); - let isShore = clShore.countMembersInRadius(position, 2); - let isPassage = clPassage.countMembersInRadius(position, 2); - let isSettlement = clSettlement.countMembersInRadius(position, 2); + const isWater = clWater.countMembersInRadius(position, 3); + const isShore = clShore.countMembersInRadius(position, 2); + const isPassage = clPassage.countMembersInRadius(position, 2); + const isSettlement = clSettlement.countMembersInRadius(position, 2); if (isSettlement) return undefined; - let height = g_Map.getHeight(position); - let slope = g_Map.getSlope(position); + const height = g_Map.getHeight(position); + const slope = g_Map.getSlope(position); if (height >= 0.5 && height < 1.5 && isShore) return tSandTransition; @@ -339,7 +339,7 @@ Engine.SetProgress(65); g_Map.log("Creating mines"); -for (let mine of [eMetalMine, eStoneMine]) +for (const mine of [eMetalMine, eStoneMine]) createObjectGroupsDeprecated( new SimpleGroup( [ @@ -422,7 +422,7 @@ 50); g_Map.log("Creating large decorative rocks"); -var rocksGroup = new SimpleGroup( +const rocksGroup = new SimpleGroup( [ new SimpleObject(aLargeRock, 1, 2, 0, 1), new SimpleObject(aRock, 1, 3, 0, 2) @@ -449,7 +449,7 @@ 500); g_Map.log("Creating decorative plants"); -var plantGroups = [ +const plantGroups = [ new SimpleGroup( [ new SimpleObject(aPlantA, 3, 7, 0, 3), @@ -464,7 +464,7 @@ ], true) ]; -for (let group of plantGroups) +for (const group of plantGroups) createObjectGroupsDeprecated( group, 0, 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 @@ -49,41 +49,41 @@ const heightHill = 12; const heightOffsetBump = 2; -var g_Map = new RandomMap(heightSeaGround, tWater); +const g_Map = new RandomMap(heightSeaGround, tWater); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); -var clCoral = g_Map.createTileClass(); -var clPlayer = g_Map.createTileClass(); -var clIsland = g_Map.createTileClass(); -var clCity = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clCoral = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clIsland = g_Map.createTileClass(); +const clCity = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); //array holding starting islands based on number of players -var startingPlaces=[[0],[0,3],[0,2,4],[0,1,3,4],[0,1,2,3,4],[0,1,2,3,4,5]]; +const startingPlaces=[[0],[0,3],[0,2,4],[0,1,3,4],[0,1,2,3,4],[0,1,2,3,4,5]]; -var startAngle = randomAngle(); +const startAngle = randomAngle(); -var islandRadius = scaleByMapSize(15, 40); -var islandCount = Math.max(6, numPlayers); -var islandPosition = distributePointsOnCircle(islandCount, startAngle, fractionToTiles(0.39), mapCenter)[0].map(position => position.round()); +const islandRadius = scaleByMapSize(15, 40); +const islandCount = Math.max(6, numPlayers); +const islandPosition = distributePointsOnCircle(islandCount, startAngle, fractionToTiles(0.39), mapCenter)[0].map(position => position.round()); -var centralIslandRadius = scaleByMapSize(15, 30); -var centralIslandCount = Math.floor(scaleByMapSize(1, 4)); -var centralIslandPosition = new Array(numPlayers).fill(0).map((v, i) => +const centralIslandRadius = scaleByMapSize(15, 30); +const centralIslandCount = Math.floor(scaleByMapSize(1, 4)); +const centralIslandPosition = new Array(numPlayers).fill(0).map((v, i) => Vector2D.add(mapCenter, new Vector2D(fractionToTiles(randFloat(0.1, 0.16)), 0).rotate( -startAngle - Math.PI * (i * 2 / centralIslandCount + randFloat(-1, 1) / 8)).round())); -var areas = []; +const areas = []; var nPlayer = 0; var playerPosition = []; @@ -114,7 +114,7 @@ g_Map.log("Creating player islands"); for (let i = 0; i < islandCount; ++i) { - let isPlayerIsland = numPlayers >= 6 || i == startingPlaces[numPlayers - 1][nPlayer]; + const isPlayerIsland = numPlayers >= 6 || i == startingPlaces[numPlayers - 1][nPlayer]; if (isPlayerIsland) { playerPosition[nPlayer] = islandPosition[i]; @@ -124,7 +124,7 @@ } g_Map.log("Creating central islands"); -for (let position of centralIslandPosition) +for (const position of centralIslandPosition) createCycladicArchipelagoIsland(position, clIsland, centralIslandRadius, 2); placePlayerBases({ @@ -193,7 +193,7 @@ [[tForestFloor, tGrass, pMainForest], [tForestFloor, pMainForest]] ]; -for (let type of forestTypes) +for (const type of forestTypes) createAreasInAreas( new ClumpPlacer(randIntInclusive(6, 17), 0.1, 0.1, Infinity), [ @@ -207,7 +207,7 @@ Engine.SetProgress(42); 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); createObjectGroupsByAreasDeprecated(group, 0, [avoidClasses(clWater, 1, clForest, 1, clHill, 1, clPlayer, 5, clRock, 6)], scaleByMapSize(4,16), 200, areas @@ -215,7 +215,7 @@ Engine.SetProgress(46); g_Map.log("Creating small stone mines"); -var group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock); +group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock); createObjectGroupsByAreasDeprecated(group, 0, [avoidClasses(clWater, 1, clForest, 1, clHill, 1, clPlayer, 5, clRock, 6)], scaleByMapSize(4,16), 200, areas @@ -231,7 +231,7 @@ Engine.SetProgress(54); g_Map.log("Creating shrub patches"); -for (let size of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)]) +for (const size of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)]) createAreasInAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), [ @@ -245,7 +245,7 @@ Engine.SetProgress(58); g_Map.log("Creating grass patches"); -for (let size of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)]) +for (const size of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)]) createAreasInAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), [ @@ -259,7 +259,7 @@ Engine.SetProgress(62); g_Map.log("Creating straggler trees"); -for (let tree of [oCarob, oBeech, oLombardyPoplar, oLombardyPoplar, oPine]) +for (const tree of [oCarob, oBeech, oLombardyPoplar, oLombardyPoplar, oPine]) createObjectGroupsByAreasDeprecated( new SimpleGroup([new SimpleObject(tree, 1,1, 0,1)], true, clForest), 0, Index: binaries/data/mods/public/maps/random/danubius.js =================================================================== --- binaries/data/mods/public/maps/random/danubius.js +++ binaries/data/mods/public/maps/random/danubius.js @@ -137,48 +137,48 @@ const heightPath = 1.5; const heightIsland = 6; -var g_Map = new RandomMap(heightLand, tPrimary); +const g_Map = new RandomMap(heightLand, tPrimary); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); const mapBounds = g_Map.getBounds(); -var clPlayer = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clLand = [g_Map.createTileClass(), g_Map.createTileClass()]; -var clPatrolPointSiegeEngine = [g_Map.createTileClass(), g_Map.createTileClass()]; -var clPatrolPointSoldier = [g_Map.createTileClass(), g_Map.createTileClass()]; -var clShore = [g_Map.createTileClass(), g_Map.createTileClass()]; -var clShoreUngarrisonPoint = [g_Map.createTileClass(), g_Map.createTileClass()]; -var clShip = g_Map.createTileClass(); -var clShipPatrol = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clIsland = g_Map.createTileClass(); -var clTreasure = g_Map.createTileClass(); -var clWaterLog = g_Map.createTileClass(); -var clGauls = g_Map.createTileClass(); -var clTower = g_Map.createTileClass(); -var clOutpost = g_Map.createTileClass(); -var clPath = g_Map.createTileClass(); -var clRitualPlace = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clLand = [g_Map.createTileClass(), g_Map.createTileClass()]; +const clPatrolPointSiegeEngine = [g_Map.createTileClass(), g_Map.createTileClass()]; +const clPatrolPointSoldier = [g_Map.createTileClass(), g_Map.createTileClass()]; +const clShore = [g_Map.createTileClass(), g_Map.createTileClass()]; +const clShoreUngarrisonPoint = [g_Map.createTileClass(), g_Map.createTileClass()]; +const clShip = g_Map.createTileClass(); +const clShipPatrol = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clIsland = g_Map.createTileClass(); +const clTreasure = g_Map.createTileClass(); +const clWaterLog = g_Map.createTileClass(); +const clGauls = g_Map.createTileClass(); +const clTower = g_Map.createTileClass(); +const clOutpost = g_Map.createTileClass(); +const clPath = g_Map.createTileClass(); +const clRitualPlace = g_Map.createTileClass(); -var startAngle = randomAngle(); -var waterWidth = fractionToTiles(0.3); +const startAngle = randomAngle(); +const waterWidth = fractionToTiles(0.3); // How many treasures will be placed near the gallic civic centers -var gallicCCTreasureCount = randIntInclusive(8, 12); +const gallicCCTreasureCount = randIntInclusive(8, 12); // How many treasures will be placed randomly on the map at most -var randomTreasureCount = randIntInclusive(0, scaleByMapSize(0, 2)); +const randomTreasureCount = randIntInclusive(0, scaleByMapSize(0, 2)); -var ritualParticipants = [ +const ritualParticipants = [ { "radius": 0.6, "templates": [oFemale], @@ -233,7 +233,7 @@ "overlap": 0 }; -var fortressDanubiusVillage = new Fortress( +const fortressDanubiusVillage = new Fortress( "Geto-Dacian Tribal Confederation", new Array(2).fill([ "gate", "pillar", "hut", "long", "long", @@ -242,47 +242,47 @@ "cornerIn", "defense_tower", "long", "tavern", "long", "pillar" ]).reduce((result, items) => result.concat(items), [])); -var palisadeCorner = ["turn_0.25", "spike_single", "turn_0.25"]; -var palisadeGate = ["spike_single", "gap_3.6", "spike_single"]; -var palisadeWallShort = new Array(3).fill("spikes_tall"); -var palisadeWallLong = new Array(5).fill("spikes_tall"); -var palisadeSideShort = [...palisadeGate, ...palisadeWallShort, ...palisadeCorner, ...palisadeWallShort]; -var palisadeSideLong = [...palisadeGate, ...palisadeWallShort, ...palisadeCorner, ...palisadeWallLong]; -var fortressDanubiusSpikes = new Fortress( +const palisadeCorner = ["turn_0.25", "spike_single", "turn_0.25"]; +const palisadeGate = ["spike_single", "gap_3.6", "spike_single"]; +const palisadeWallShort = new Array(3).fill("spikes_tall"); +const palisadeWallLong = new Array(5).fill("spikes_tall"); +const palisadeSideShort = [...palisadeGate, ...palisadeWallShort, ...palisadeCorner, ...palisadeWallShort]; +const palisadeSideLong = [...palisadeGate, ...palisadeWallShort, ...palisadeCorner, ...palisadeWallLong]; +const fortressDanubiusSpikes = new Fortress( "Spikes Of The Geto-Dacian Tribal Confederation", [...palisadeSideLong, ...palisadeSideShort, ...palisadeSideLong, ...palisadeSideShort]); // Place a gallic village on small maps and larger -var gallicCC = mapSize >= smallMapSize; +const gallicCC = mapSize >= smallMapSize; if (gallicCC) { g_Map.log("Creating gallic villages"); - let gaulCityRadius = 12; - let gaulCityBorderDistance = mapSize < mediumMapSize ? 10 : 18; + const gaulCityRadius = 12; + const gaulCityBorderDistance = mapSize < mediumMapSize ? 10 : 18; // Whether to add a celtic ritual and a path from the gallic city leading to it - let addCelticRitual = randBool(0.9); + const addCelticRitual = randBool(0.9); // One village left and right of the river for (let i = 0; i < 2; ++i) { - let civicCenterPosition = new Vector2D( + const civicCenterPosition = new Vector2D( i == 0 ? mapBounds.left + gaulCityBorderDistance : mapBounds.right - gaulCityBorderDistance, mapCenter.y).rotateAround(startAngle, mapCenter); if (addCelticRitual) { // Don't position the meeting place at the center of the map - let meetingPlacePosition = new Vector2D( + const meetingPlacePosition = new Vector2D( i == 0 ? mapBounds.left + waterWidth : mapBounds.right - waterWidth, mapCenter.y + fractionToTiles(randFloat(0.1, 0.4)) * (randBool() ? 1 : -1)).rotateAround(startAngle, mapCenter); // Radius of the meeting place - let mRadius = scaleByMapSize(4, 6); + const mRadius = scaleByMapSize(4, 6); // Create a path connecting the gallic city with a meeting place at the shoreline. // To avoid the path going through the palisade wall, start it at the gate, not at the city center. - let pathStart = Vector2D.add(civicCenterPosition, new Vector2D(gaulCityRadius * (i == 0 ? 1 : -1), 0).rotate(startAngle)); + const pathStart = Vector2D.add(civicCenterPosition, new Vector2D(gaulCityRadius * (i == 0 ? 1 : -1), 0).rotate(startAngle)); createArea( new PathPlacer(pathStart, meetingPlacePosition, 4, 0.4, 4, 0.2, 0.05), [ @@ -302,9 +302,9 @@ g_Map.placeEntityAnywhere(aCampfire, 0, meetingPlacePosition, randomAngle()); - for (let participants of ritualParticipants) + for (const participants of ritualParticipants) { - let [positions, angles] = distributePointsOnCircle(participants.count, startAngle, participants.radius * mRadius, meetingPlacePosition); + const [positions, angles] = distributePointsOnCircle(participants.count, startAngle, participants.radius * mRadius, meetingPlacePosition); for (let j = 0; j < positions.length; ++j) g_Map.placeEntityPassable(pickRandom(participants.templates), 0, positions[j], angles[j] + participants.angle); } @@ -380,7 +380,7 @@ "meanderShort": 30, "meanderLong": 0, "waterFunc": (position, height, riverFraction) => { - let origPos = position.clone().rotateAround(-startAngle, mapCenter); + const origPos = position.clone().rotateAround(-startAngle, mapCenter); // Distinguish left and right shoreline if (0 < height && height < 1 && origPos.y > ShorelineDistance && origPos.y < mapSize - ShorelineDistance) @@ -399,13 +399,13 @@ paintTileClassBasedOnHeight(-Infinity, 0.7, Elevation_ExcludeMin_ExcludeMax, clWater); -var areasLand = [0, 1].map(i => +const areasLand = [0, 1].map(i => createArea( new MapBoundsPlacer(), undefined, stayClasses(clLand[i], 0))); -var areasWater = +const areasWater = [createArea( new MapBoundsPlacer(), undefined, @@ -434,7 +434,7 @@ Engine.SetProgress(45); -var [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7); +const [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7); createForests( [tForestFloor, tForestFloor, tForestFloor, pForest1, pForest2], avoidClasses(clPlayer, 16, clForest, 17, clWater, 5, clHill, 2, clGauls, 5, clPath, 1), @@ -455,7 +455,7 @@ Engine.SetProgress(55); g_Map.log("Creating islands"); -var areaIslands = createAreas( +const areaIslands = createAreas( new ChainPlacer(Math.floor(scaleByMapSize(3, 4)), Math.floor(scaleByMapSize(4, 8)), Math.floor(scaleByMapSize(50, 80)), 0.5), [ new LayeredPainter([tWater, tShore, tIsland], [2, 1]), @@ -720,7 +720,7 @@ g_Map.log("Creating ungarrison points for ships"); for (let i = 0; i < 2; ++i) { - let areaShore = [createArea( + const areaShore = [createArea( new MapBoundsPlacer(), undefined, stayClasses(clShore[i], 0))]; Index: binaries/data/mods/public/maps/random/deep_forest.js =================================================================== --- binaries/data/mods/public/maps/random/deep_forest.js +++ binaries/data/mods/public/maps/random/deep_forest.js @@ -1,66 +1,66 @@ Engine.LoadLibrary("rmgen"); Engine.LoadLibrary("rmgen-common"); -var templateStone = "gaia/rock/temperate_small"; -var templateStoneMine = "gaia/rock/temperate_large"; -var templateMetalMine = "gaia/ore/temperate_large"; -var templateTemple = "gaia/ruins/unfinished_greek_temple"; +const templateStone = "gaia/rock/temperate_small"; +const templateStoneMine = "gaia/rock/temperate_large"; +const templateMetalMine = "gaia/ore/temperate_large"; +const templateTemple = "gaia/ruins/unfinished_greek_temple"; -var terrainPrimary = ["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"]; -var terrainWood = ['temp_grass_mossy|gaia/tree/oak', 'temp_forestfloor_pine|gaia/tree/pine', 'temp_mud_plants|gaia/tree/dead', +const terrainPrimary = ["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"]; +const terrainWood = ['temp_grass_mossy|gaia/tree/oak', 'temp_forestfloor_pine|gaia/tree/pine', 'temp_mud_plants|gaia/tree/dead', 'temp_plants_bog|gaia/tree/oak_large', "temp_dirt_gravel_plants|gaia/tree/aleppo_pine", 'temp_forestfloor_autumn|gaia/tree/carob']; -var terrainWoodBorder = ['temp_grass_plants|gaia/tree/euro_beech', 'temp_grass_mossy|gaia/tree/poplar', 'temp_grass_mossy|gaia/tree/poplar_lombardy', +const terrainWoodBorder = ['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", "temp_grass_plants"]; -var terrainBase = ["temp_dirt_gravel", "temp_grass_b"]; -var terrainBaseBorder = ["temp_grass_b", "temp_grass_b", "temp_grass", "temp_grass_c", "temp_grass_mossy"]; -var terrainBaseCenter = ['temp_dirt_gravel', 'temp_dirt_gravel', 'temp_grass_b']; -var terrainPath = ['temp_road', "temp_road_overgrown", 'temp_grass_b']; -var terrainHill = ["temp_highlands", "temp_highlands", "temp_highlands", "temp_dirt_gravel_b", "temp_cliff_a"]; -var terrainHillBorder = ["temp_highlands", "temp_highlands", "temp_highlands", "temp_dirt_gravel_b", "temp_dirt_gravel_plants", +const terrainBase = ["temp_dirt_gravel", "temp_grass_b"]; +const terrainBaseBorder = ["temp_grass_b", "temp_grass_b", "temp_grass", "temp_grass_c", "temp_grass_mossy"]; +const terrainBaseCenter = ['temp_dirt_gravel', 'temp_dirt_gravel', 'temp_grass_b']; +const terrainPath = ['temp_road', "temp_road_overgrown", 'temp_grass_b']; +const terrainHill = ["temp_highlands", "temp_highlands", "temp_highlands", "temp_dirt_gravel_b", "temp_cliff_a"]; +const terrainHillBorder = ["temp_highlands", "temp_highlands", "temp_highlands", "temp_dirt_gravel_b", "temp_dirt_gravel_plants", "temp_highlands", "temp_highlands", "temp_highlands", "temp_dirt_gravel_b", "temp_dirt_gravel_plants", "temp_highlands", "temp_highlands", "temp_highlands", "temp_cliff_b", "temp_dirt_gravel_plants", "temp_highlands", "temp_highlands", "temp_highlands", "temp_cliff_b", "temp_dirt_gravel_plants", "temp_highlands|gaia/fauna_goat"]; -var heightPath = -2; -var heightLand = 0; -var heightOffsetRandomPath = 1; +const heightPath = -2; +const heightLand = 0; +const heightOffsetRandomPath = 1; -var g_Map = new RandomMap(heightLand, terrainPrimary); +const g_Map = new RandomMap(heightLand, terrainPrimary); -var mapSize = g_Map.getSize(); -var mapRadius = mapSize/2; -var mapCenter = g_Map.getCenter(); +const mapSize = g_Map.getSize(); +const mapRadius = mapSize/2; +const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clPath = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clPath = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); -var numPlayers = getNumPlayers(); -var baseRadius = 20; -var minPlayerRadius = Math.min(mapRadius - 1.5 * baseRadius, 5/8 * mapRadius); -var maxPlayerRadius = Math.min(mapRadius - baseRadius, 3/4 * mapRadius); -var playerPosition = []; -var playerAngle = []; -var playerAngleStart = randomAngle(); -var playerAngleAddAvrg = 2 * Math.PI / numPlayers; -var playerAngleMaxOff = playerAngleAddAvrg/4; +const numPlayers = getNumPlayers(); +const baseRadius = 20; +const minPlayerRadius = Math.min(mapRadius - 1.5 * baseRadius, 5/8 * mapRadius); +const maxPlayerRadius = Math.min(mapRadius - baseRadius, 3/4 * mapRadius); +let playerPosition = []; +let playerAngle = []; +const playerAngleStart = randomAngle(); +const playerAngleAddAvrg = 2 * Math.PI / numPlayers; +const playerAngleMaxOff = playerAngleAddAvrg/4; -var radiusEC = Math.max(mapRadius/8, baseRadius/2); -var resourceRadius = fractionToTiles(1/3); -var resourcePerPlayer = [templateStone, templateMetalMine]; +const radiusEC = Math.max(mapRadius/8, baseRadius/2); +const resourceRadius = fractionToTiles(1/3); +const resourcePerPlayer = [templateStone, templateMetalMine]; // For large maps there are memory errors with too many trees. A density of 256x192/mapArea works with 0 players. // Around each player there is an area without trees so with more players the max density can increase a bit. -var maxTreeDensity = Math.min(256 * (192 + 8 * numPlayers) / Math.square(mapSize), 1); // Has to be tweeked but works ok -var bushChance = 1/3; // 1 means 50% chance in deepest wood, 0.5 means 25% chance in deepest wood +const maxTreeDensity = Math.min(256 * (192 + 8 * numPlayers) / Math.square(mapSize), 1); // Has to be tweeked but works ok +const bushChance = 1/3; // 1 means 50% chance in deepest wood, 0.5 means 25% chance in deepest wood -var playerIDs = sortAllPlayers(); -for (var i=0; i < numPlayers; i++) +const playerIDs = sortAllPlayers(); +for (let i=0; i < numPlayers; i++) { playerAngle[i] = (playerAngleStart + i * playerAngleAddAvrg + randFloat(0, playerAngleMaxOff)) % (2 * Math.PI); playerPosition[i] = Vector2D.add(mapCenter, new Vector2D(randFloat(minPlayerRadius, maxPlayerRadius), 0).rotate(-playerAngle[i]).round()); @@ -105,12 +105,12 @@ Engine.SetProgress(30); g_Map.log("Painting paths"); -var pathBlending = numPlayers <= 4; +const pathBlending = numPlayers <= 4; for (let i = 0; i < numPlayers + (pathBlending ? 1 : 0); ++i) for (let j = pathBlending ? 0 : i + 1; j < numPlayers + 1; ++j) { - let pathStart = i < numPlayers ? playerPosition[i] : mapCenter; - let pathEnd = j < numPlayers ? playerPosition[j] : mapCenter; + const pathStart = i < numPlayers ? playerPosition[i] : mapCenter; + const pathEnd = j < numPlayers ? playerPosition[j] : mapCenter; createArea( new RandomPathPlacer(pathStart, pathEnd, 1.25, baseRadius / 2, pathBlending), @@ -127,13 +127,13 @@ for (let i = 0; i < numPlayers; ++i) for (let rIndex = 0; rIndex < resourcePerPlayer.length; ++rIndex) { - let angleDist = numPlayers > 1 ? + const angleDist = numPlayers > 1 ? (playerAngle[(i + 1) % numPlayers] - playerAngle[i] + 2 * Math.PI) % (2 * Math.PI) : 2 * Math.PI; // they are supposed to be in between players on the same radius - let angle = playerAngle[i] + angleDist * (rIndex + 1) / (resourcePerPlayer.length + 1); - let position = Vector2D.add(mapCenter, new Vector2D(resourceRadius, 0).rotate(-angle)).round(); + const angle = playerAngle[i] + angleDist * (rIndex + 1) / (resourcePerPlayer.length + 1); + const position = Vector2D.add(mapCenter, new Vector2D(resourceRadius, 0).rotate(-angle)).round(); g_Map.placeEntityPassable(resourcePerPlayer[rIndex], 0, position, randomAngle()); @@ -161,26 +161,26 @@ ]); // Woods and general height map -for (var x = 0; x < mapSize; x++) - for (var z = 0; z < mapSize; z++) +for (let x = 0; x < mapSize; x++) + for (let z = 0; z < mapSize; z++) { - let position = new Vector2D(x, z); + const position = new Vector2D(x, z); // The 0.5 is a correction for the entities placed on the center of tiles - var radius = mapCenter.distanceTo(Vector2D.add(position, new Vector2D(0.5, 0.5))); - var minDistToSL = mapSize; - for (var i=0; i < numPlayers; i++) + const radius = mapCenter.distanceTo(Vector2D.add(position, new Vector2D(0.5, 0.5))); + let minDistToSL = mapSize; + for (let i=0; i < numPlayers; i++) minDistToSL = Math.min(minDistToSL, position.distanceTo(playerPosition[i])); // Woods tile based - var tDensFactSL = Math.max(Math.min((minDistToSL - baseRadius) / baseRadius, 1), 0); - var tDensFactRad = Math.abs((resourceRadius - radius) / resourceRadius); - var tDensFactEC = Math.max(Math.min((radius - radiusEC) / radiusEC, 1), 0); - var tDensActual = maxTreeDensity * tDensFactSL * tDensFactRad * tDensFactEC; + const tDensFactSL = Math.max(Math.min((minDistToSL - baseRadius) / baseRadius, 1), 0); + const tDensFactRad = Math.abs((resourceRadius - radius) / resourceRadius); + const tDensFactEC = Math.max(Math.min((radius - radiusEC) / radiusEC, 1), 0); + const tDensActual = maxTreeDensity * tDensFactSL * tDensFactRad * tDensFactEC; if (randBool(tDensActual) && g_Map.validTile(position)) { - let border = tDensActual < randFloat(0, bushChance * maxTreeDensity); + const border = tDensActual < randFloat(0, bushChance * maxTreeDensity); if (avoidClasses(clPath, 1, clHill, border ? 0 : 1).allows(position)) { createTerrain(border ? terrainWoodBorder : terrainWood).place(position); @@ -190,8 +190,8 @@ } // General height map - let hVarMiddleHill = fractionToTiles(1 / 64) * (1 + Math.cos(3/2 * Math.PI * radius / mapRadius)); - var hVarHills = 5 * (1 + Math.sin(x / 10) * Math.sin(z / 10)); + const hVarMiddleHill = fractionToTiles(1 / 64) * (1 + Math.cos(3/2 * Math.PI * radius / mapRadius)); + const hVarHills = 5 * (1 + Math.sin(x / 10) * Math.sin(z / 10)); g_Map.setHeight(position, g_Map.getHeight(position) + hVarMiddleHill + hVarHills + 1); } Engine.SetProgress(95); Index: binaries/data/mods/public/maps/random/dodecanese.js =================================================================== --- binaries/data/mods/public/maps/random/dodecanese.js +++ binaries/data/mods/public/maps/random/dodecanese.js @@ -74,33 +74,33 @@ const heightHill = 8; const heightVolano = 25; -var g_Map = new RandomMap(heightSeaGround, tWater); -var numPlayers = getNumPlayers(); +const g_Map = new RandomMap(heightSeaGround, tWater); +const numPlayers = getNumPlayers(); -var clIsland = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clPlayer = g_Map.createTileClass(); -var clPlayerIsland = g_Map.createTileClass(); -var clShore = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clGrass = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clVolcano = g_Map.createTileClass(); -var clBridge = g_Map.createTileClass(); +const clIsland = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clPlayerIsland = g_Map.createTileClass(); +const clShore = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clGrass = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clVolcano = g_Map.createTileClass(); +const clBridge = g_Map.createTileClass(); const playerIslandRadius = scaleByMapSize(20, 29); const bridgeLength = 16; const maxBridges = scaleByMapSize(2, 12); -var [playerIDs, playerPosition] = playerPlacementRandom(sortAllPlayers()); +const [playerIDs, playerPosition] = playerPlacementRandom(sortAllPlayers()); g_Map.log("Creating player islands"); -for (let position of playerPosition) +for (const position of playerPosition) createArea( new ChainPlacer(2, 6, scaleByMapSize(15, 50), Infinity, position, 0, [playerIslandRadius]), [ @@ -139,7 +139,7 @@ Engine.SetProgress(35); g_Map.log("Creating volcano"); -var areasVolcano = createAreas( +const areasVolcano = createAreas( new ClumpPlacer(diskArea(scaleByMapSize(4, 8)), 0.5, 0.5, 0.1), [ new LayeredPainter([tLavaOuter, tLavaInner], [4]), @@ -182,7 +182,7 @@ paintTerrainBasedOnHeight(heightCoralsUpper, heightShoreLower, Elevation_IncludeMin_ExcludeMax, tCoralsUpper); g_Map.log("Painting shoreline"); -var areaShoreline = createArea( +const areaShoreline = createArea( new HeightPlacer(Elevation_IncludeMin_ExcludeMax, heightShoreLower, heightShoreUpper), [ new TerrainPainter(tShoreLower), @@ -258,7 +258,7 @@ placePlayersNomad(clPlayer, avoidClasses(clWater, 12, clVolcano, 4, clMetal, 4, clRock, 4, clHill, 4)); -var [forestTrees, stragglerTrees] = getTreeCounts(800, 4000, 0.7); +const [forestTrees, stragglerTrees] = getTreeCounts(800, 4000, 0.7); createForests( [tForestFloor, tForestFloor, tForestFloor, pForest1, pForest2], avoidClasses(clWater, 2, clPlayer, 4, clVolcano, 2, clForest, 1, clBaseResource, 4, clMetal, 4, clRock, 4), @@ -330,32 +330,32 @@ avoidClasses(clWater, 4, clPlayer, 5, clVolcano, 4, clForest, 1, clBaseResource, 4, clRock, 4, clMetal, 4, clHill, 1)); g_Map.log("Creating bridges"); -var bridges = 0; -for (let bridgeStart of shuffleArray(areaShoreline.getPoints())) +let bridges = 0; +for (const bridgeStart of shuffleArray(areaShoreline.getPoints())) { if (new NearTileClassConstraint(clBridge, bridgeLength * 8).allows(bridgeStart)) continue; for (let direction = 0; direction < 4; ++direction) { - let bridgeAngle = direction * Math.PI / 2; - let bridgeDirection = new Vector2D(1, 0).rotate(bridgeAngle); + const bridgeAngle = direction * Math.PI / 2; + const bridgeDirection = new Vector2D(1, 0).rotate(bridgeAngle); - let areaOffset = new Vector2D(1, 1); + const areaOffset = new Vector2D(1, 1); - let bridgeOffset = new Vector2D(direction % 2 ? 2 : 0, direction % 2 ? 0 : 2); - let bridgeCenter1 = Vector2D.add(bridgeStart, Vector2D.mult(bridgeDirection, bridgeLength / 2)); - let bridgeCenter2 = Vector2D.add(bridgeCenter1, bridgeOffset); + const bridgeOffset = new Vector2D(direction % 2 ? 2 : 0, direction % 2 ? 0 : 2); + const bridgeCenter1 = Vector2D.add(bridgeStart, Vector2D.mult(bridgeDirection, bridgeLength / 2)); + const bridgeCenter2 = Vector2D.add(bridgeCenter1, bridgeOffset); if (avoidClasses(clWater, 0).allows(bridgeCenter1) && avoidClasses(clWater, 0).allows(bridgeCenter2)) continue; - let bridgeEnd1 = Vector2D.add(bridgeStart, Vector2D.mult(bridgeDirection, bridgeLength)); - let bridgeEnd2 = Vector2D.add(bridgeEnd1, bridgeOffset); + const bridgeEnd1 = Vector2D.add(bridgeStart, Vector2D.mult(bridgeDirection, bridgeLength)); + const bridgeEnd2 = Vector2D.add(bridgeEnd1, bridgeOffset); if (avoidClasses(clShore, 0).allows(bridgeEnd1) && avoidClasses(clShore, 0).allows(bridgeEnd2)) continue; - let bridgePerpendicular = bridgeDirection.perpendicular(); - let bridgeP = Vector2D.mult(bridgePerpendicular, bridgeLength / 2).round(); + const bridgePerpendicular = bridgeDirection.perpendicular(); + const bridgeP = Vector2D.mult(bridgePerpendicular, bridgeLength / 2).round(); if (avoidClasses(clWater, 0).allows(Vector2D.add(bridgeCenter1, bridgeP)) || avoidClasses(clWater, 0).allows(Vector2D.sub(bridgeCenter2, bridgeP))) continue; @@ -364,7 +364,7 @@ // This bridge model is not centered on the horizontal plane, so the angle is messy // TILE_CENTERED_HEIGHT_MAP also influences the outcome of the placement. - let bridgeOrientation = direction % 2 ? 0 : Math.PI / 2; + const bridgeOrientation = direction % 2 ? 0 : Math.PI / 2; bridgeCenter1[direction % 2 ? "y" : "x"] += 0.25; bridgeCenter2[direction % 2 ? "y" : "x"] -= 0.25; @@ -378,7 +378,7 @@ new TileClassPainter(clBridge) ]); - for (let center of [bridgeStart, bridgeEnd2]) + for (const center of [bridgeStart, bridgeEnd2]) createArea( new DiskPlacer(2, center), new SmoothingPainter(1, 1, 1)); Index: binaries/data/mods/public/maps/random/elephantine.js =================================================================== --- binaries/data/mods/public/maps/random/elephantine.js +++ binaries/data/mods/public/maps/random/elephantine.js @@ -187,7 +187,7 @@ Engine.SetProgress(10); g_Map.log("Marking islands"); -var areaIsland = createArea( +const areaIsland = createArea( new ConvexPolygonPlacer( [ new Vector2D(mapCenter.x - riverWidthBorder / 2, mapBounds.top), @@ -248,7 +248,7 @@ Engine.SetProgress(22); g_Map.log("Creating temple"); -var groupTemple = createObjectGroupsByAreas( +const groupTemple = createObjectGroupsByAreas( new SimpleGroup([new RandomObject(g_Map.getSize() >= 320 ? [oWonder] : oTemples, 1, 1, 0, 1, riverAngle, riverAngle)], true, clTemple), 0, stayClasses(clIsland, scaleByMapSize(10, 20)), @@ -258,7 +258,7 @@ Engine.SetProgress(34); g_Map.log("Creating pyramid"); -var groupPyramid = createObjectGroupsByAreas( +const groupPyramid = createObjectGroupsByAreas( new SimpleGroup([new SimpleObject(oPyramid, 1, 1, 0, 1, riverAngle, riverAngle)], true, clTemple), 0, [stayClasses(clIsland, scaleByMapSize(10, 20)), avoidClasses(clTemple, scaleByMapSize(20, 50)), avoidCollisions], @@ -268,11 +268,11 @@ Engine.SetProgress(37); g_Map.log("Painting city patches"); -var cityCenters = [ +const cityCenters = [ groupTemple[0] && groupTemple[0][0] && { "pos": Vector2D.from3D(groupTemple[0][0].position), "radius": 10 }, groupPyramid[0] && groupPyramid[0][0] && { "pos": Vector2D.from3D(groupPyramid[0][0].position), "radius": 6 },].filter(pos => !!pos); -var areaCityPatch = cityCenters.map(cityCenter => +const areaCityPatch = cityCenters.map(cityCenter => createArea( new DiskPlacer(cityCenter.radius, cityCenter.pos), new LayeredPainter([tRoadWildIsland, tRoadIsland], [2]), @@ -339,7 +339,7 @@ 200); Engine.SetProgress(49); -var [forestTrees, stragglerTrees] = getTreeCounts(400, 3000, 0.7); +const [forestTrees, stragglerTrees] = getTreeCounts(400, 3000, 0.7); createForests( [tForestFloorLand, tForestFloorLand, tForestFloorLand, pForestPalmsLand, pForest2Land], [avoidCollisions, avoidClasses(clIsland, 0, clPlayer, 20, clForest, 18, clWater, 2)], Index: binaries/data/mods/public/maps/random/empire.js =================================================================== --- binaries/data/mods/public/maps/random/empire.js +++ binaries/data/mods/public/maps/random/empire.js @@ -5,7 +5,7 @@ setSelectedBiome(); -var g_Map = new RandomMap(2, g_Terrains.mainTerrain); +const g_Map = new RandomMap(2, g_Terrains.mainTerrain); initTileClasses(); @@ -28,7 +28,7 @@ Engine.SetProgress(20); // Change the starting angle and add the players again -var rotation = Math.PI; +let rotation = Math.PI; if (teamsArray.length == 2) rotation = Math.PI / 2; Index: binaries/data/mods/public/maps/random/english_channel.js =================================================================== --- binaries/data/mods/public/maps/random/english_channel.js +++ binaries/data/mods/public/maps/random/english_channel.js @@ -40,28 +40,28 @@ const pForestD = [tGrassDForest + TERRAIN_SEPARATOR + oBeech, tGrassDForest]; -var heightSeaGround = -4; -var heightShore = 1; -var heightLand = 3; +const heightSeaGround = -4; +const heightShore = 1; +const heightLand = 3; -var g_Map = new RandomMap(heightShore, tPrimary); +const g_Map = new RandomMap(heightShore, tPrimary); const numPlayers = getNumPlayers(); const mapCenter = g_Map.getCenter(); const mapBounds = g_Map.getBounds(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clShallow = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clShallow = g_Map.createTileClass(); -var startAngle = randomAngle(); +const startAngle = randomAngle(); placePlayerBases({ "PlayerPlacement": playerPlacementRiver(startAngle + Math.PI / 2, fractionToTiles(0.6)), @@ -135,7 +135,7 @@ createHills([tCliff, tCliff, tHill], avoidClasses(clPlayer, 20, clHill, 15, clWater, 5), clHill, scaleByMapSize(1, 4) * numPlayers); Engine.SetProgress(50); -var [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7); +const [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7); createForests( [tGrass, tGrassDForest, tGrassDForest, pForestD, pForestD], avoidClasses(clPlayer, 20, clForest, 17, clHill, 0, clWater, 6), Index: binaries/data/mods/public/maps/random/extinct_volcano.js =================================================================== --- binaries/data/mods/public/maps/random/extinct_volcano.js +++ binaries/data/mods/public/maps/random/extinct_volcano.js @@ -51,33 +51,33 @@ tForestFloor1 ]; -var heightSeaGround = -4; -var heightLand = 1; -var heightHill = 18; -var heightPlayerHill = 25; +const heightSeaGround = -4; +const heightLand = 1; +const heightHill = 18; +const heightPlayerHill = 25; -var g_Map = new RandomMap(heightLand, tHillMedium1); +const g_Map = new RandomMap(heightLand, tHillMedium1); -var numPlayers = getNumPlayers(); -var mapCenter = g_Map.getCenter(); +const numPlayers = getNumPlayers(); +const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clGrass = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clBumps = g_Map.createTileClass(); -var clTower = g_Map.createTileClass(); -var clRain = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clGrass = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clBumps = g_Map.createTileClass(); +const clTower = g_Map.createTileClass(); +const clRain = g_Map.createTileClass(); -var playerMountainSize = defaultPlayerBaseRadius(); +const playerMountainSize = defaultPlayerBaseRadius(); -var [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.35)); +const [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.35)); g_Map.log("Creating CC mountains"); if (!isNomad()) @@ -167,14 +167,14 @@ Engine.SetProgress(35); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(1200, 3000, 0.7); -var types = [ +const [forestTrees, stragglerTrees] = getTreeCounts(1200, 3000, 0.7); +const types = [ [[tGrassB, tGrassA, pForestD], [tGrassB, pForestD]], [[tGrassB, tGrassA, pForestP], [tGrassB, pForestP]] ]; -var size = forestTrees / (scaleByMapSize(4, 12) * numPlayers); -var num = Math.floor(size / types.length); -for (let type of types) +const size = forestTrees / (scaleByMapSize(4, 12) * numPlayers); +const num = Math.floor(size / types.length); +for (const type of types) createAreas( new ClumpPlacer(forestTrees / num, 0.1, 0.1, Infinity), [ @@ -190,8 +190,8 @@ Engine.SetProgress(40); g_Map.log("Creating hill patches"); -for (let size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) - for (let type of [[tHillMedium1, tHillDark], [tHillDark, tHillMedium2], [tHillMedium1, tHillMedium2]]) +for (const size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) + for (const type of [[tHillMedium1, tHillDark], [tHillDark, tHillMedium2], [tHillMedium1, tHillMedium2]]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), [ Index: binaries/data/mods/public/maps/random/fields_of_meroe.js =================================================================== --- binaries/data/mods/public/maps/random/fields_of_meroe.js +++ binaries/data/mods/public/maps/random/fields_of_meroe.js @@ -68,20 +68,20 @@ const mapCenter = g_Map.getCenter(); const mapBounds = g_Map.getBounds(); -var clPlayer = g_Map.createTileClass(); -var clKushiteVillages = g_Map.createTileClass(); -var clRiver = g_Map.createTileClass(); -var clShore = g_Map.createTileClass(); -var clDunes = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clRain = g_Map.createTileClass(); -var clCataract = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clKushiteVillages = g_Map.createTileClass(); +const clRiver = g_Map.createTileClass(); +const clShore = g_Map.createTileClass(); +const clDunes = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clRain = g_Map.createTileClass(); +const clCataract = g_Map.createTileClass(); -var kushVillageBuildings = { +const kushVillageBuildings = { "houseA": { "template": oHouse, "offset": new Vector2D(5, 5) }, "houseB": { "template": oHouse, "offset": new Vector2D(5, 0) }, "houseC": { "template": oHouse, "offset": new Vector2D(5, -5) }, @@ -124,7 +124,7 @@ createTerrain(tRiverBank).place(position); }, "landFunc": (position, shoreDist1, shoreDist2) => { - for (let riv of riverTextures) + for (const riv of riverTextures) if (riv.left < +shoreDist1 && +shoreDist1 < riv.right || riv.left < -shoreDist2 && -shoreDist2 < riv.right) { riv.tileClass.add(position); @@ -136,11 +136,11 @@ Engine.SetProgress(10); g_Map.log("Creating cataracts"); -for (let x of [fractionToTiles(randFloat(0.15, 0.25)), fractionToTiles(randFloat(0.75, 0.85))]) +for (const x of [fractionToTiles(randFloat(0.15, 0.25)), fractionToTiles(randFloat(0.75, 0.85))]) { - let anglePassage = riverAngle + Math.PI / 2 * randFloat(0.8, 1.2); + const anglePassage = riverAngle + Math.PI / 2 * randFloat(0.8, 1.2); - let areaPassage = createArea( + const areaPassage = createArea( new PathPlacer( new Vector2D(x, mapBounds.bottom).rotateAround(anglePassage, mapCenter), new Vector2D(x, mapBounds.top).rotateAround(anglePassage, mapCenter), @@ -173,7 +173,7 @@ [areaPassage]); } -var [playerIDs, playerPosition] = playerPlacementRandom(sortAllPlayers(), avoidClasses(clRiver, 15, clPlayer, 30)); +const [playerIDs, playerPosition] = playerPlacementRandom(sortAllPlayers(), avoidClasses(clRiver, 15, clPlayer, 30)); placePlayerBases({ "PlayerPlacement": [playerIDs, playerPosition], "BaseResourceClass": clBaseResource, @@ -208,10 +208,10 @@ Engine.SetProgress(15); g_Map.log("Getting random coordinates for Kushite settlements"); -var kushiteTownPositions = []; +let kushiteTownPositions = []; for (let retryCount = 0; retryCount < scaleByMapSize(3, 10); ++retryCount) { - let coordinate = g_Map.randomCoordinate(true); + const coordinate = g_Map.randomCoordinate(true); if (new AndConstraint(avoidClasses(clPlayer, 40, clForest, 5, clKushiteVillages, 50, clRiver, 15)).allows(coordinate)) { kushiteTownPositions.push(coordinate); @@ -225,9 +225,9 @@ } g_Map.log("Placing the Kushite buildings"); -for (let coordinate of kushiteTownPositions) +for (const coordinate of kushiteTownPositions) { - for (let building in kushVillageBuildings) + for (const building in kushVillageBuildings) g_Map.placeEntityPassable(kushVillageBuildings[building].template, 0, Vector2D.add(coordinate, kushVillageBuildings[building].offset), Math.PI); createObjectGroup(new SimpleGroup([new SimpleObject(oKushUnits, 5, 7, 1, 2)], true, clKushiteVillages, coordinate), 0); @@ -261,7 +261,7 @@ Engine.SetProgress(25); -var [forestTrees, stragglerTrees] = getTreeCounts(400, 2000, 0.7); +const [forestTrees, stragglerTrees] = getTreeCounts(400, 2000, 0.7); createForests( [tMainDirt[0], tForestFloor, tForestFloor, pForestP, pForestP], avoidClasses(clPlayer, 20, clForest, 20, clDunes, 2, clRiver, 20, clKushiteVillages, 10), @@ -270,7 +270,7 @@ Engine.SetProgress(40); g_Map.log("Creating dirt patches"); -for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) +for (const size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5), new LayeredPainter([tSecondaryDirt, tDirt], [1]), @@ -278,7 +278,7 @@ scaleByMapSize(50, 90)); g_Map.log("Creating patches of farmland"); -for (let size of [scaleByMapSize(30, 40), scaleByMapSize(35, 50)]) +for (const size of [scaleByMapSize(30, 40), scaleByMapSize(35, 50)]) createAreas( new ClumpPlacer(size, 0.4, 0.6), new TerrainPainter(tFarmland), 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 @@ -17,8 +17,8 @@ const tShore = g_Terrains.shore; const tWater = g_Terrains.water; -var tHill = g_Terrains.hill; -var tDirt = g_Terrains.dirt; +let tHill = g_Terrains.hill; +let tDirt = g_Terrains.dirt; if (currentBiome() == "generic/temperate") { tDirt = ["medit_shrubs_a", "grass_field"]; @@ -52,7 +52,7 @@ const heightStartingIslands = 2; const shoreRadius = 6; -var g_Map = new RandomMap(heightSeaGround, tWater); +const g_Map = new RandomMap(heightSeaGround, tWater); const clPlayer = g_Map.createTileClass(); const clHill = g_Map.createTileClass(); @@ -69,7 +69,7 @@ const mapCenter = g_Map.getCenter(); g_Map.log("Creating player islands..."); -var [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.38)); +const [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.38)); for (let i = 0; i < numPlayers; ++i) createArea( @@ -131,7 +131,7 @@ for (let m = 0; m < randIntInclusive(20, 34); ++m) { - let elevRand = randIntInclusive(6, 20); + const elevRand = randIntInclusive(6, 20); createArea( new ChainPlacer( 7, @@ -151,7 +151,7 @@ for (let m = 0; m < randIntInclusive(8, 17); ++m) { - let elevRand = randIntInclusive(15, 29); + const elevRand = randIntInclusive(15, 29); createArea( new ChainPlacer( 5, @@ -203,7 +203,7 @@ clForest, forestTrees); -let types = [oTree1, oTree2, oTree4, oTree3]; +const types = [oTree1, oTree2, oTree4, oTree3]; createStragglerTrees( types, [avoidClasses(clBaseResource, 2, clMetal, 6, clRock, 6, clMountain, 2, clPlayer, 25), stayClasses(clHill, 6)], @@ -212,8 +212,8 @@ Engine.SetProgress(65); g_Map.log("Creating dirt patches"); -var numb = currentBiome() == "generic/savanna" ? 3 : 1; -for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) +const numb = currentBiome() == "generic/savanna" ? 3 : 1; +for (const size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5), [ @@ -228,7 +228,7 @@ paintTerrainBasedOnHeight(heightSeaGround, 1, 3, tTier1Terrain); g_Map.log("Creating grass patches"); -for (let size of [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)]) +for (const size of [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5), new TerrainPainter(tTier4Terrain), Index: binaries/data/mods/public/maps/random/fortress.js =================================================================== --- binaries/data/mods/public/maps/random/fortress.js +++ binaries/data/mods/public/maps/random/fortress.js @@ -42,41 +42,41 @@ const pForestO = [tForestFloor + TERRAIN_SEPARATOR + oOak, tForestFloor]; const pForestP = [tForestFloor + TERRAIN_SEPARATOR + oPine, tForestFloor]; -var heightSeaGround = -4; -var heightLand = 3; +const heightSeaGround = -4; +const heightLand = 3; -var g_Map = new RandomMap(heightLand, tGrass); +const g_Map = new RandomMap(heightLand, tGrass); const numPlayers = getNumPlayers(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); -var treasures = [ +const treasures = [ { "template": oFoodTreasure, "count": 5 }, { "template": oWoodTreasure, "count": 5 }, { "template": oMetalTreasure, "count": 4 }, { "template": oStoneTreasure, "count": 2 } ]; -var [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.35)); +const [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.35)); g_Map.log("Creating playerbases"); -var playerAngle = BUILDING_ORIENTATION; +const playerAngle = BUILDING_ORIENTATION; for (let i = 0; i < numPlayers; ++i) { if (isNomad()) break; // CC and units - for (let dist of [6, 8]) + for (const dist of [6, 8]) { let ents = getStartingEntities(playerIDs[i]); @@ -97,8 +97,8 @@ 0); // Ground texture - var civ = getCivCode(playerIDs[i]); - var tilesSize = civ == "cart" ? 23 : 21; + const civ = getCivCode(playerIDs[i]); + const tilesSize = civ == "cart" ? 23 : 21; createArea( new ConvexPolygonPlacer( new Array(4).fill(0).map((zero, j) => new Vector2D(tilesSize, 0).rotate(j * Math.PI / 2 - playerAngle - Math.PI/4).add(playerPosition[i])), @@ -109,7 +109,7 @@ ]); // Fortress - var wall = ["gate", "tower", "long", + const wall = ["gate", "tower", "long", "cornerIn", "long", "barracks", "tower", "long", "tower", "long", "cornerIn", "long", "stable", "tower", "gate", "tower", "long", "cornerIn", "long", "temple", "tower", "long", "tower", "long", @@ -119,8 +119,8 @@ } g_Map.log("Creating lakes"); -var numLakes = Math.round(scaleByMapSize(1,4) * numPlayers); -var waterAreas = createAreas( +const numLakes = Math.round(scaleByMapSize(1,4) * numPlayers); +const waterAreas = createAreas( new ClumpPlacer(scaleByMapSize(100,250), 0.8, 0.1, Infinity), [ new LayeredPainter([tShore, tWater], [1]), @@ -162,15 +162,15 @@ Engine.SetProgress(40); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(500, 2500, 0.7); -var types = [ +const [forestTrees, stragglerTrees] = getTreeCounts(500, 2500, 0.7); +const types = [ [[tForestFloor, tGrass, pForestD], [tForestFloor, pForestD]], [[tForestFloor, tGrass, pForestO], [tForestFloor, pForestO]], [[tForestFloor, tGrass, pForestP], [tForestFloor, pForestP]] ]; -var size = forestTrees / (scaleByMapSize(3,6) * numPlayers); -var num = Math.floor(size / types.length); -for (let type of types) +const size = forestTrees / (scaleByMapSize(3,6) * numPlayers); +const num = Math.floor(size / types.length); +for (const type of types) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), forestTrees / num, 0.5), [ Index: binaries/data/mods/public/maps/random/frontier.js =================================================================== --- binaries/data/mods/public/maps/random/frontier.js +++ binaries/data/mods/public/maps/random/frontier.js @@ -6,11 +6,11 @@ setSelectedBiome(); // Random elevation with a bias towards lower elevations -var randElevation = randIntInclusive(0, 29); +let randElevation = randIntInclusive(0, 29); if (randElevation < 25) randElevation = randIntInclusive(1, 4); -var g_Map = new RandomMap(randElevation, g_Terrains.mainTerrain); +const g_Map = new RandomMap(randElevation, g_Terrains.mainTerrain); initTileClasses(); createArea( @@ -22,7 +22,7 @@ if (!isNomad()) { // Note: `|| pickRandom(...)` is needed for atlas. - let pattern = g_MapSettings.TeamPlacement || pickRandom(["line", "radial", "randomGroup", "stronghold"]); + const pattern = g_MapSettings.TeamPlacement || pickRandom(["line", "radial", "randomGroup", "stronghold"]); createBases( ...playerPlacementByPattern( pattern, @@ -34,7 +34,7 @@ } Engine.SetProgress(40); -var features = [ +let features = [ { "func": addBluffs, "baseHeight": randElevation, Index: binaries/data/mods/public/maps/random/gear.js =================================================================== --- binaries/data/mods/public/maps/random/gear.js +++ binaries/data/mods/public/maps/random/gear.js @@ -43,39 +43,39 @@ const pForest1 = [tForestFloor2 + TERRAIN_SEPARATOR + oTree1, tForestFloor2 + TERRAIN_SEPARATOR + oTree2, tForestFloor2]; const pForest2 = [tForestFloor1 + TERRAIN_SEPARATOR + oTree4, tForestFloor1 + TERRAIN_SEPARATOR + oTree5, tForestFloor1]; -var heightSeaGround = -4; -var heightShallow = -2; -var heightLand = 3; -var heightRing = 4; -var heightHill = 20; +const heightSeaGround = -4; +const heightShallow = -2; +const heightLand = 3; +const heightRing = 4; +const heightHill = 20; -var g_Map = new RandomMap(heightLand, tMainTerrain); +const g_Map = new RandomMap(heightLand, tMainTerrain); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); -var radiusPlayers = fractionToTiles(0.35); -var radiusCentralLake = fractionToTiles(0.27); -var radiusCentralRingLand = fractionToTiles(0.21); -var radiusCentralWaterRing = fractionToTiles(0.17); -var radiusCentralIsland = fractionToTiles(0.14); -var radiusCentralHill = fractionToTiles(0.12); +const radiusPlayers = fractionToTiles(0.35); +const radiusCentralLake = fractionToTiles(0.27); +const radiusCentralRingLand = fractionToTiles(0.21); +const radiusCentralWaterRing = fractionToTiles(0.17); +const radiusCentralIsland = fractionToTiles(0.14); +const radiusCentralHill = fractionToTiles(0.12); -var [playerIDs, playerPosition, playerAngle, startAngle] = playerPlacementCircle(radiusPlayers); +const [playerIDs, playerPosition, playerAngle, startAngle] = playerPlacementCircle(radiusPlayers); g_Map.log("Determining number of rivers between players"); -var split = 1; +let split = 1; if (mapSize == 128 && numPlayers <= 2) split = 2; else if (mapSize == 192 && numPlayers <= 3) @@ -123,9 +123,9 @@ g_Map.log("Creating rivers between players"); for (let m = 0; m < numPlayers * split; ++m) { - let angle = startAngle + (m + 0.5) * 2 * Math.PI / (numPlayers * split); - let position1 = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.15), 0).rotate(-angle)); - let position2 = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.6), 0).rotate(-angle)); + const angle = startAngle + (m + 0.5) * 2 * Math.PI / (numPlayers * split); + const position1 = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.15), 0).rotate(-angle)); + const position2 = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.6), 0).rotate(-angle)); createArea( new PathPlacer(position1, position2, scaleByMapSize(14, 40), 0, scaleByMapSize(3, 9), 0.2, 0.05), new SmoothElevationPainter(ELEVATION_SET, heightSeaGround, 4), @@ -135,9 +135,9 @@ g_Map.log("Create path from the island to the center"); for (let m = 0; m < numPlayers * split; ++m) { - let angle = startAngle + m * 2 * Math.PI / (numPlayers * split); - let position1 = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.05), 0).rotate(-angle)); - let position2 = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.49), 0).rotate(-angle)); + const angle = startAngle + m * 2 * Math.PI / (numPlayers * split); + const position1 = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.05), 0).rotate(-angle)); + const position2 = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.49), 0).rotate(-angle)); createArea( new PathPlacer(position1, position2, scaleByMapSize(10, 40), 0, scaleByMapSize(3, 9), 0.2, 0.05), new SmoothElevationPainter(ELEVATION_SET, heightLand, 4)); @@ -204,7 +204,7 @@ else createMountains(tCliff, avoidClasses(clPlayer, 20, clHill, 15, clWater, 2), clHill, scaleByMapSize(1, 4) * numPlayers); -var [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); +const [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); createForests( [tMainTerrain, tForestFloor1, tForestFloor2, pForest1, pForest2], avoidClasses(clPlayer, 20, clForest, 17, clHill, 0, clWater, 2), @@ -259,7 +259,7 @@ Engine.SetProgress(65); -var planetm = 1; +let planetm = 1; if (currentBiome() == "generic/india") planetm = 8; Index: binaries/data/mods/public/maps/random/guadalquivir_river.js =================================================================== --- binaries/data/mods/public/maps/random/guadalquivir_river.js +++ binaries/data/mods/public/maps/random/guadalquivir_river.js @@ -36,32 +36,32 @@ const pForestP = [tForestFloorP + TERRAIN_SEPARATOR + oPoplar, tForestFloorP]; const pForestC = [tForestFloorC + TERRAIN_SEPARATOR + oCarob, tForestFloorC]; -var heightSeaGround = -3; -var heightShallow = -1.5; -var heightShore = 2; -var heightLand = 3; +const heightSeaGround = -3; +const heightShallow = -1.5; +const heightShore = 2; +const heightLand = 3; -var g_Map = new RandomMap(heightSeaGround, tWater); +const g_Map = new RandomMap(heightSeaGround, tWater); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); const mapBounds = g_Map.getBounds(); -var clPlayer = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clLand = g_Map.createTileClass(); -var clRiver = g_Map.createTileClass(); -var clShallow = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clLand = g_Map.createTileClass(); +const clRiver = g_Map.createTileClass(); +const clShallow = g_Map.createTileClass(); g_Map.log("Create the continent body"); -var startAngle = randomAngle(); -var continentCenter = new Vector2D(fractionToTiles(0.5), fractionToTiles(0.7)).rotateAround(startAngle, mapCenter).round(); +const startAngle = randomAngle(); +const continentCenter = new Vector2D(fractionToTiles(0.5), fractionToTiles(0.7)).rotateAround(startAngle, mapCenter).round(); createArea( new ChainPlacer( @@ -78,8 +78,8 @@ new TileClassPainter(clLand) ]); -var playerIDs = sortAllPlayers(); -var playerPosition = playerPlacementArcs( +const playerIDs = sortAllPlayers(); +const playerPosition = playerPlacementArcs( playerIDs, continentCenter, fractionToTiles(0.35), @@ -149,7 +149,7 @@ createBumps([avoidClasses(clPlayer, 20, clRiver, 1), stayClasses(clLand, 3)]); -var [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7); +const [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7); createForests( [tGrass, tForestFloorP, tForestFloorC, pForestC, pForestP], [avoidClasses(clPlayer, 20, clForest, 17, clRiver, 1), stayClasses(clLand, 7)], Index: binaries/data/mods/public/maps/random/gulf_of_bothnia.js =================================================================== --- binaries/data/mods/public/maps/random/gulf_of_bothnia.js +++ binaries/data/mods/public/maps/random/gulf_of_bothnia.js @@ -62,24 +62,24 @@ tForestFloor + TERRAIN_SEPARATOR + oTree4, tForestFloor + TERRAIN_SEPARATOR + oTree5, tForestFloor]; -var g_Map = new RandomMap(heightLand, tPrimary); +const g_Map = new RandomMap(heightLand, tPrimary); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clLake = g_Map.createTileClass(); -var clWater = isLakeFrozen ? g_Map.createTileClass() : clLake; -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clLake = g_Map.createTileClass(); +const clWater = isLakeFrozen ? g_Map.createTileClass() : clLake; +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); -var startAngle = randomAngle(); +const startAngle = randomAngle(); placePlayerBases({ "PlayerPlacement": [sortAllPlayers(), ...playerPlacementCustomAngle( @@ -114,15 +114,15 @@ Engine.SetProgress(20); g_Map.log("Creating the gulf"); -var gulfLakePositions = [ +const gulfLakePositions = [ { "numCircles": 200, "x": fractionToTiles(0), "radius": fractionToTiles(0.175) }, { "numCircles": 120, "x": fractionToTiles(0.3), "radius": fractionToTiles(0.2) }, { "numCircles": 100, "x": fractionToTiles(0.5), "radius": fractionToTiles(0.225) } ]; -for (let gulfLake of gulfLakePositions) +for (const gulfLake of gulfLakePositions) { - let position = Vector2D.add(mapCenter, new Vector2D(gulfLake.x, 0).rotate(-startAngle)).round(); + const position = Vector2D.add(mapCenter, new Vector2D(gulfLake.x, 0).rotate(-startAngle)).round(); createArea( new ChainPlacer( @@ -185,7 +185,7 @@ else createMountains(tCliff, avoidClasses(clPlayer, 20, clHill, 15, clLake, 0), clHill, scaleByMapSize(1, 4) * numPlayers, Math.floor(scaleByMapSize(20, 40))); -var [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7); +const [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7); createDefaultForests( [tForestFloor, tForestFloor, tForestFloor, pForest1, pForest2], avoidClasses(clPlayer, 20, clForest, 16, clHill, 0, clLake, 2), Index: binaries/data/mods/public/maps/random/harbor.js =================================================================== --- binaries/data/mods/public/maps/random/harbor.js +++ binaries/data/mods/public/maps/random/harbor.js @@ -5,11 +5,11 @@ setSelectedBiome(); -var heightSeaGround = -18; -var heightLand = 2; -var heightOffsetHarbor = -11; +const heightSeaGround = -18; +const heightLand = 2; +const heightOffsetHarbor = -11; -var g_Map = new RandomMap(heightLand, g_Terrains.mainTerrain); +const g_Map = new RandomMap(heightLand, g_Terrains.mainTerrain); initTileClasses(); @@ -325,9 +325,9 @@ function addHarbors() { - for (let position of playerPosition) + for (const position of playerPosition) { - let harborPosition = Vector2D.add(position, Vector2D.sub(mapCenter, position).div(2.5).round()); + const harborPosition = Vector2D.add(position, Vector2D.sub(mapCenter, position).div(2.5).round()); createArea( new ClumpPlacer(1200, 0.5, 0.5, Infinity, harborPosition), [ @@ -345,12 +345,12 @@ function addSpines() { - let smallSpines = mapSize <= 192; - let spineSize = smallSpines ? 0.02 : 0.5; - let spineTapering = smallSpines ?-0.1 : -1.4; - let heightOffsetSpine = smallSpines ? 20 : 35; + const smallSpines = mapSize <= 192; + const spineSize = smallSpines ? 0.02 : 0.5; + const spineTapering = smallSpines ?-0.1 : -1.4; + const heightOffsetSpine = smallSpines ? 20 : 35; - let numPlayers = getNumPlayers(); + const numPlayers = getNumPlayers(); let spineTile = g_Terrains.dirt; if (currentBiome() == "generic/arctic") @@ -368,9 +368,9 @@ for (let i = 0; i < numPlayers * split; ++i) { - let tang = startAngle + (i + 0.5) * 2 * Math.PI / (numPlayers * split); - let start = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.12), 0).rotate(-tang)); - let end = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.4), 0).rotate(-tang)); + const tang = startAngle + (i + 0.5) * 2 * Math.PI / (numPlayers * split); + const start = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.12), 0).rotate(-tang)); + const end = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.4), 0).rotate(-tang)); createArea( new PathPlacer(start, end, scaleByMapSize(14, spineSize), 0.6, 0.1, 0.4, spineTapering), Index: binaries/data/mods/public/maps/random/heightmap/heightmap.js =================================================================== --- binaries/data/mods/public/maps/random/heightmap/heightmap.js +++ binaries/data/mods/public/maps/random/heightmap/heightmap.js @@ -18,7 +18,7 @@ */ function getMinAndMaxHeight(heightmap = g_Map.height) { - let height = { + const height = { "min": Infinity, "max": -Infinity }; @@ -42,7 +42,7 @@ */ function rescaleHeightmap(minHeight = MIN_HEIGHT, maxHeight = MAX_HEIGHT, heightmap = g_Map.height) { - let oldHeightRange = getMinAndMaxHeight(heightmap); + const oldHeightRange = getMinAndMaxHeight(heightmap); for (let x = 0; x < heightmap.length; ++x) for (let y = 0; y < heightmap[x].length; ++y) heightmap[x][y] = minHeight + (heightmap[x][y] - oldHeightRange.min) / (oldHeightRange.max - oldHeightRange.min) * (maxHeight - minHeight); @@ -62,7 +62,7 @@ defaultHeight = getMinAndMaxHeight(heightmap).min; offset.round(); - let sourceHeightmap = clone(heightmap); + const sourceHeightmap = clone(heightmap); for (let x = 0; x < heightmap.length; ++x) for (let y = 0; y < heightmap[x].length; ++y) heightmap[x][y] = @@ -86,16 +86,16 @@ */ function getStartLocationsByHeightmap(heightRange, maxTries = 1000, minDistToBorder = 20, numberOfPlayers = g_MapSettings.PlayerData.length - 1, heightmap = g_Map.height, isCircular = g_MapSettings.CircularMap) { - let validStartLoc = []; - let mapCenter = g_Map.getCenter(); - let mapSize = g_Map.getSize(); + const validStartLoc = []; + const mapCenter = g_Map.getCenter(); + const mapSize = g_Map.getSize(); - let heightConstraint = new HeightConstraint(heightRange.min, heightRange.max); + const heightConstraint = new HeightConstraint(heightRange.min, heightRange.max); for (let x = minDistToBorder; x < mapSize - minDistToBorder; ++x) for (let y = minDistToBorder; y < mapSize - minDistToBorder; ++y) { - let position = new Vector2D(x, y); + const position = new Vector2D(x, y); if (heightConstraint.allows(position) && (!isCircular || position.distanceTo(mapCenter)) < mapSize / 2 - minDistToBorder) validStartLoc.push(position); } @@ -105,7 +105,7 @@ for (let tries = 0; tries < maxTries; ++tries) { - let startLoc = []; + const startLoc = []; let minDist = Infinity; for (let p = 0; p < numberOfPlayers; ++p) @@ -114,7 +114,7 @@ for (let p1 = 0; p1 < numberOfPlayers - 1; ++p1) for (let p2 = p1 + 1; p2 < numberOfPlayers; ++p2) { - let dist = startLoc[p1].distanceTo(startLoc[p2]); + const dist = startLoc[p1].distanceTo(startLoc[p2]); if (dist < minDist) minDist = dist; } @@ -146,7 +146,7 @@ g_Map.log("Generating map using the diamond-square algorithm"); initialHeightmap = (initialHeightmap || [[randFloat(minHeight / 2, maxHeight / 2), randFloat(minHeight / 2, maxHeight / 2)], [randFloat(minHeight / 2, maxHeight / 2), randFloat(minHeight / 2, maxHeight / 2)]]); - let heightRange = maxHeight - minHeight; + const heightRange = maxHeight - minHeight; if (heightRange <= 0) warn("setBaseTerrainDiamondSquare: heightRange <= 0"); @@ -157,7 +157,7 @@ while (initialHeightmap.length < heightmap.length) { newHeightmap = []; - let oldWidth = initialHeightmap.length; + const oldWidth = initialHeightmap.length; // Square for (let x = 0; x < 2 * oldWidth - 1; ++x) { @@ -215,7 +215,7 @@ } // Cut initialHeightmap to fit target width - let shift = [Math.floor((newHeightmap.length - heightmap.length) / 2), Math.floor((newHeightmap[0].length - heightmap[0].length) / 2)]; + const shift = [Math.floor((newHeightmap.length - heightmap.length) / 2), Math.floor((newHeightmap[0].length - heightmap[0].length) / 2)]; for (let x = 0; x < heightmap.length; ++x) for (let y = 0; y < heightmap[0].length; ++y) heightmap[x][y] = newHeightmap[x + shift[0]][y + shift[1]]; @@ -277,9 +277,9 @@ */ function getTileCenteredHeightmap(heightmap = g_Map.height) { - let max_x = heightmap.length - 1; - let max_y = heightmap[0].length - 1; - let tchm = []; + const max_x = heightmap.length - 1; + const max_y = heightmap[0].length - 1; + const tchm = []; for (let x = 0; x < max_x; ++x) { tchm[x] = new Float32Array(max_y); @@ -297,11 +297,11 @@ */ function getSlopeMap(inclineMap = getInclineMap(g_Map.height)) { - let max_x = inclineMap.length; - let slopeMap = []; + const max_x = inclineMap.length; + const slopeMap = []; for (let x = 0; x < max_x; ++x) { - let max_y = inclineMap[x].length; + const max_y = inclineMap[x].length; slopeMap[x] = new Float32Array(max_y); for (let y = 0; y < max_y; ++y) slopeMap[x][y] = Math.euclidDistance2D(0, 0, inclineMap[x][y].x, inclineMap[x][y].y); @@ -319,18 +319,18 @@ function getInclineMap(heightmap) { heightmap = (heightmap || g_Map.height); - let max_x = heightmap.length - 1; - let max_y = heightmap[0].length - 1; - let inclineMap = []; + const max_x = heightmap.length - 1; + const max_y = heightmap[0].length - 1; + const inclineMap = []; for (let x = 0; x < max_x; ++x) { inclineMap[x] = []; for (let y = 0; y < max_y; ++y) { - let dx = heightmap[x + 1][y] - heightmap[x][y]; - let dy = heightmap[x][y + 1] - heightmap[x][y]; - let next_dx = heightmap[x + 1][y + 1] - heightmap[x][y + 1]; - let next_dy = heightmap[x + 1][y + 1] - heightmap[x + 1][y]; + const dx = heightmap[x + 1][y] - heightmap[x][y]; + const dy = heightmap[x][y + 1] - heightmap[x][y]; + const next_dx = heightmap[x + 1][y + 1] - heightmap[x][y + 1]; + const next_dy = heightmap[x + 1][y + 1] - heightmap[x + 1][y]; inclineMap[x][y] = { "x": 0.5 * (dx + next_dx), "y": 0.5 * (dy + next_dy) }; } } @@ -339,7 +339,7 @@ function getGrad(wrapped = true, scalarField = g_Map.height) { - let vectorField = []; + const vectorField = []; let max_x = scalarField.length; let max_y = scalarField[0].length; if (!wrapped) @@ -365,28 +365,28 @@ function splashErodeMap(strength = 1, heightmap = g_Map.height) { - let max_x = heightmap.length; - let max_y = heightmap[0].length; + const max_x = heightmap.length; + const max_y = heightmap[0].length; - let dHeight = getGrad(heightmap); + const dHeight = getGrad(heightmap); for (let x = 0; x < max_x; ++x) { - let next_x = (x + 1) % max_x; - let prev_x = (x + max_x - 1) % max_x; + const next_x = (x + 1) % max_x; + const prev_x = (x + max_x - 1) % max_x; for (let y = 0; y < max_y; ++y) { - let next_y = (y + 1) % max_y; - let prev_y = (y + max_y - 1) % max_y; + const next_y = (y + 1) % max_y; + const prev_y = (y + max_y - 1) % max_y; - let slopes = [-dHeight[x][y].x, -dHeight[x][y].y, dHeight[prev_x][y].x, dHeight[x][prev_y].y]; + const slopes = [-dHeight[x][y].x, -dHeight[x][y].y, dHeight[prev_x][y].x, dHeight[x][prev_y].y]; let sumSlopes = 0; for (let i = 0; i < slopes.length; ++i) if (slopes[i] > 0) sumSlopes += slopes[i]; - let drain = []; + const drain = []; for (let i = 0; i < slopes.length; ++i) { drain.push(0); Index: binaries/data/mods/public/maps/random/hellas.js =================================================================== --- binaries/data/mods/public/maps/random/hellas.js +++ binaries/data/mods/public/maps/random/hellas.js @@ -20,7 +20,7 @@ TILE_CENTERED_HEIGHT_MAP = true; -var mapStyles = [ +const mapStyles = [ // mainland { "minMapSize": 0, @@ -56,47 +56,47 @@ const heightmapMin = 0; const heightmapMax = 100; -var g_Map = new RandomMap(0, biomes.lowlands.terrains.main); -var mapSize = g_Map.getSize(); -var mapCenter = g_Map.getCenter(); -var numPlayers = getNumPlayers(); +const g_Map = new RandomMap(0, biomes.lowlands.terrains.main); +const mapSize = g_Map.getSize(); +const mapCenter = g_Map.getCenter(); +const numPlayers = getNumPlayers(); -var clWater; -var clCliffs; -var clPlayer = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clDock = g_Map.createTileClass(); +let clWater = g_Map.createTileClass(); +let clCliffs = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clDock = g_Map.createTileClass(); -var constraintLowlands = new HeightConstraint(heightShoreline, heightLowlands); -var constraintHighlands = new HeightConstraint(heightLowlands, heightHighlands); -var constraintMountains = new HeightConstraint(heightHighlands, Infinity); +const constraintLowlands = new HeightConstraint(heightShoreline, heightLowlands); +const constraintHighlands = new HeightConstraint(heightLowlands, heightHighlands); +const constraintMountains = new HeightConstraint(heightHighlands, Infinity); -var [minLandRatio, maxLandRatio] = mapStyles.filter(mapStyle => mapSize >= mapStyle.minMapSize).sort((a, b) => a.enabled - b.enabled).pop().landRatio; -var [minCliffRatio, maxCliffRatio] = [maxLandRatio < 0.75 ? 0 : 0.08, 0.18]; +const [minLandRatio, maxLandRatio] = mapStyles.filter(mapStyle => mapSize >= mapStyle.minMapSize).sort((a, b) => a.enabled - b.enabled).pop().landRatio; +const [minCliffRatio, maxCliffRatio] = [maxLandRatio < 0.75 ? 0 : 0.08, 0.18]; -var playerIDs = sortAllPlayers(); -var playerPosition; +let playerIDs = sortAllPlayers(); +let playerPosition; // Pick a random subset of the heightmap that meets the mapStyle and has space for all players -var subAreaSize; -var subAreaTopLeft; +let subAreaSize; +let subAreaTopLeft; while (true) { subAreaSize = Math.floor(randFloat(0.01, 0.2) * heightmapHellas.length); subAreaTopLeft = new Vector2D(randFloat(0, 1), randFloat(0, 1)).mult(heightmapHellas.length - subAreaSize).floor(); - let heightmap = extractHeightmap(heightmapHellas, subAreaTopLeft, subAreaSize); - let heightmapPainter = new HeightmapPainter(heightmap, heightmapMin, heightmapMax); + const heightmap = extractHeightmap(heightmapHellas, subAreaTopLeft, subAreaSize); + const heightmapPainter = new HeightmapPainter(heightmap, heightmapMin, heightmapMax); // Quick area test - let points = new DiskPlacer(heightmap.length / 2 - MAP_BORDER_WIDTH, new Vector2D(1, 1).mult(heightmap.length / 2)).place(new NullConstraint()); + const points = new DiskPlacer(heightmap.length / 2 - MAP_BORDER_WIDTH, new Vector2D(1, 1).mult(heightmap.length / 2)).place(new NullConstraint()); let landArea = 0; - for (let point of points) + for (const point of points) if (heightmapPainter.scaleHeight(heightmap[point.x][point.y]) > heightShoreline) ++landArea; @@ -111,7 +111,7 @@ heightmapPainter); g_Map.log("Measuring land area"); - let passableLandArea = createArea( + const passableLandArea = createArea( new DiskPlacer(fractionToTiles(0.5), mapCenter), undefined, new HeightConstraint(heightShoreline, Infinity)); @@ -145,7 +145,7 @@ clCliffs = g_Map.createTileClass(); // Marking cliffs - let cliffsArea = createArea( + const cliffsArea = createArea( new MapBoundsPlacer(), new TileClassPainter(clCliffs), [ @@ -169,7 +169,7 @@ break; g_Map.log("Finding player locations"); - let players = playerPlacementRandom( + const players = playerPlacementRandom( playerIDs, avoidClasses( clCliffs, scaleByMapSize(6, 15), @@ -188,8 +188,8 @@ if (!isNomad()) { g_Map.log("Flattening initial CC area"); - let playerRadius = defaultPlayerBaseRadius() * 0.8; - for (let position of playerPosition) + const playerRadius = defaultPlayerBaseRadius() * 0.8; + for (const position of playerPosition) createArea( new ClumpPlacer(diskArea(playerRadius), 0.95, 0.6, Infinity, position), new SmoothElevationPainter(ELEVATION_SET, g_Map.getHeight(position), playerRadius / 2)); @@ -242,7 +242,7 @@ if (isNomad()) break; - let localBiome = constraintHighlands.allows(playerPosition[i]) ? biomes.highlands : biomes.lowlands; + const localBiome = constraintHighlands.allows(playerPosition[i]) ? biomes.highlands : biomes.lowlands; placePlayerBase({ "playerID": playerIDs[i], "playerPosition": playerPosition[i], @@ -296,9 +296,9 @@ 50); Engine.SetProgress(65); -let [forestTrees, stragglerTrees] = getTreeCounts(600, 4000, 0.7); -let biomeTreeRatioHighlands = 0.4; -for (let biome of ["lowlands", "highlands"]) +const [forestTrees, stragglerTrees] = getTreeCounts(600, 4000, 0.7); +const biomeTreeRatioHighlands = 0.4; +for (const biome of ["lowlands", "highlands"]) createForests( [ biomes[biome].terrains.main, @@ -316,11 +316,11 @@ Engine.SetProgress(70); g_Map.log("Creating stone mines"); -var minesStone = [ +const minesStone = [ [new SimpleObject(biomes.common.gaia.mines.stoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)], [new SimpleObject(biomes.common.gaia.mines.stoneSmall, 2, 3, 1, 3, 0, 2 * Math.PI, 1)] ]; -for (let mine of minesStone) +for (const mine of minesStone) createObjectGroups( new SimpleGroup(mine, true, clRock), 0, @@ -330,11 +330,11 @@ Engine.SetProgress(75); g_Map.log("Creating metal mines"); -var minesMetal = [ +const minesMetal = [ [new SimpleObject(biomes.common.gaia.mines.metalLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)], [new SimpleObject(biomes.common.gaia.mines.metalSmall, 2, 3, 1, 3, 0, 2 * Math.PI, 1)] ]; -for (let mine of minesMetal) +for (const mine of minesMetal) createObjectGroups( new SimpleGroup(mine, true, clMetal), 0, @@ -343,7 +343,7 @@ 50); Engine.SetProgress(80); -for (let biome of ["lowlands", "highlands"]) +for (const biome of ["lowlands", "highlands"]) createStragglerTrees( biomes[biome].gaia.flora.trees, [ @@ -417,8 +417,8 @@ Engine.SetProgress(95); g_Map.log("Creating grass patches"); -for (let biome of ["lowlands", "highlands"]) - for (let patch of biomes[biome].terrains.patches) +for (const biome of ["lowlands", "highlands"]) + for (const patch of biomes[biome].terrains.patches) createPatches( [scaleByMapSize(3, 7), scaleByMapSize(5, 15)], patch, @@ -430,7 +430,7 @@ clDirt); Engine.SetProgress(96); -for (let biome of ["lowlands", "highlands"]) +for (const biome of ["lowlands", "highlands"]) { createDecoration( [ Index: binaries/data/mods/public/maps/random/hells_pass.js =================================================================== --- binaries/data/mods/public/maps/random/hells_pass.js +++ binaries/data/mods/public/maps/random/hells_pass.js @@ -8,7 +8,7 @@ const heightLand = 1; const heightBarrier = 30; -var g_Map = new RandomMap(heightLand, g_Terrains.mainTerrain); +const g_Map = new RandomMap(heightLand, g_Terrains.mainTerrain); initTileClasses(); @@ -256,7 +256,7 @@ function placeBarriers() { - var spineTerrain = g_Terrains.dirt; + let spineTerrain = g_Terrains.dirt; if (currentBiome() == "generic/arctic") spineTerrain = g_Terrains.tier1Terrain; @@ -267,14 +267,14 @@ if (currentBiome() == "generic/autumn") spineTerrain = g_Terrains.tier4Terrain; - let spineCount = isNomad() ? randIntInclusive(1, 4) : teamsArray.length; + const spineCount = isNomad() ? randIntInclusive(1, 4) : teamsArray.length; for (let i = 0; i < spineCount; ++i) { - var mSize = 8; - var mWaviness = 0.6; - var mOffset = 0.5; - var mTaper = -1.5; + let mSize = 8; + let mWaviness = 0.6; + let mOffset = 0.5; + let mTaper = -1.5; if (spineCount > 3 || g_Map.getSize() <= 192) { @@ -291,9 +291,9 @@ mTaper = -0.7; } - let angle = startAngle + (i + 0.5) * 2 * Math.PI / spineCount; - let start = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.075), 0).rotate(-angle)); - let end = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.42), 0).rotate(-angle)); + const angle = startAngle + (i + 0.5) * 2 * Math.PI / spineCount; + const start = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.075), 0).rotate(-angle)); + const end = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.42), 0).rotate(-angle)); createArea( new PathPlacer(start, end, scaleByMapSize(14, mSize), mWaviness, 0.1, mOffset, mTaper), [ Index: binaries/data/mods/public/maps/random/hyrcanian_shores.js =================================================================== --- binaries/data/mods/public/maps/random/hyrcanian_shores.js +++ binaries/data/mods/public/maps/random/hyrcanian_shores.js @@ -49,27 +49,27 @@ const heightOffsetBump = 4; const heightHill = 15; -var g_Map = new RandomMap(heightLand, tPrimary); +const g_Map = new RandomMap(heightLand, tPrimary); const mapCenter = g_Map.getCenter(); const mapBounds = g_Map.getBounds(); const numPlayers = getNumPlayers(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clHighlands = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clHighlands = g_Map.createTileClass(); -var waterPosition = fractionToTiles(0.25); -var highlandsPosition = fractionToTiles(0.75); +const waterPosition = fractionToTiles(0.25); +const highlandsPosition = fractionToTiles(0.75); -var startAngle = randomAngle(); +const startAngle = randomAngle(); placePlayerBases({ "PlayerPlacement": [sortAllPlayers(), playerPlacementLine(startAngle, mapCenter, fractionToTiles(0.2))], @@ -169,7 +169,7 @@ const [forestTrees, stragglerTrees] = getTreeCounts(1000, 3500, 0.85); const highlandShare = 0.4; { - var types = [ + const types = [ [[tGrassDForest, tGrass, pForestD], [tGrassDForest, pForestD]] ]; const numberOfForests = scaleByMapSize(20, 100) / types[0].length; @@ -187,7 +187,7 @@ g_Map.log("Creating highland forests"); { - var types = [ + const types = [ [[tGrassDForest, tGrass, pForestP], [tGrassDForest, pForestP]] ]; const numberOfForests = scaleByMapSize(8, 50) / types[0].length; @@ -209,7 +209,7 @@ Engine.SetProgress(70); g_Map.log("Creating dirt patches"); -for (let size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) +for (const size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), [ @@ -221,7 +221,7 @@ Engine.SetProgress(75); g_Map.log("Creating grass patches"); -for (let size of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)]) +for (const size of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), new LayeredPainter([tGrassC, tGrassPatch], [2]), @@ -231,7 +231,7 @@ Engine.SetProgress(80); 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(clWater, 0, clForest, 1, clPlayer, 20, clRock, 10, clHill, 2)], scaleByMapSize(4,16), 100 Index: binaries/data/mods/public/maps/random/india.js =================================================================== --- binaries/data/mods/public/maps/random/india.js +++ binaries/data/mods/public/maps/random/india.js @@ -28,19 +28,19 @@ const heightShore = 3; const heightOffsetBump = 2; -var g_Map = new RandomMap(heightLand, tGrass1); +const g_Map = new RandomMap(heightLand, tGrass1); -var numPlayers = getNumPlayers(); -var mapSize = g_Map.getSize(); -var mapCenter = g_Map.getCenter(); +const numPlayers = getNumPlayers(); +const mapSize = g_Map.getSize(); +const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); placePlayerBases({ "PlayerPlacement": playerPlacementCircle(fractionToTiles(0.35)), @@ -120,7 +120,7 @@ g_Map.log("Creating stone mines"); for (let i = 0; i < scaleByMapSize(12, 30); ++i) { - let position = new Vector2D(randIntInclusive(1, mapSize - 1), randIntInclusive(1, mapSize - 1)); + const position = new Vector2D(randIntInclusive(1, mapSize - 1), randIntInclusive(1, mapSize - 1)); if (avoidClasses(clPlayer, 30, clRock, 25, clWater, 10).allows(position)) { createStoneMineFormation(position, oStoneSmall, tDirt4); Index: binaries/data/mods/public/maps/random/island_stronghold.js =================================================================== --- binaries/data/mods/public/maps/random/island_stronghold.js +++ binaries/data/mods/public/maps/random/island_stronghold.js @@ -49,7 +49,7 @@ const heightLand = 3; const heightHill = 18; -var g_Map = new RandomMap(heightSeaGround, tWater); +const g_Map = new RandomMap(heightSeaGround, tWater); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); @@ -65,14 +65,14 @@ const clBaseResource = g_Map.createTileClass(); const clLand = g_Map.createTileClass(); -var startAngle = randomAngle(); +const startAngle = randomAngle(); -var teams = getTeamsArray(); -var numTeams = teams.filter(team => team).length; -var teamPosition = distributePointsOnCircle(numTeams, startAngle, fractionToTiles(0.3), mapCenter)[0]; -var teamRadius = fractionToTiles(0.05); +const teams = getTeamsArray(); +const numTeams = teams.filter(team => team).length; +const teamPosition = distributePointsOnCircle(numTeams, startAngle, fractionToTiles(0.3), mapCenter)[0]; +const teamRadius = fractionToTiles(0.05); -var teamNo = 0; +let teamNo = 0; g_Map.log("Creating player islands and bases"); @@ -83,7 +83,7 @@ ++teamNo; - let [playerPosition, playerAngle] = distributePointsOnCircle(teams[i].length, startAngle + 2 * Math.PI / teams[i].length, teamRadius, teamPosition[i]); + const [playerPosition, playerAngle] = distributePointsOnCircle(teams[i].length, startAngle + 2 * Math.PI / teams[i].length, teamRadius, teamPosition[i]); playerPosition.forEach(position => position.round()); for (let p = 0; p < teams[i].length; ++p) @@ -101,17 +101,17 @@ placeCivDefaultStartingEntities(playerPosition[p], teams[i][p], false); } - let mineAngle = randFloat(-1, 1) * Math.PI / teams[i].length; - let mines = [ + const mineAngle = randFloat(-1, 1) * Math.PI / teams[i].length; + const mines = [ { "template": oMetalLarge, "angle": mineAngle }, { "template": oStoneLarge, "angle": mineAngle + Math.PI / 4 } ]; // Mines for (let p = 0; p < teams[i].length; ++p) - for (let mine of mines) + for (const mine of mines) { - let position = Vector2D.add(playerPosition[p], new Vector2D(g_InitialMineDistance, 0).rotate(-playerAngle[p] - mine.angle)); + const position = Vector2D.add(playerPosition[p], new Vector2D(g_InitialMineDistance, 0).rotate(-playerAngle[p] - mine.angle)); createObjectGroup( new SimpleGroup([new SimpleObject(mine.template, 1, 1, 0, 4)], true, clBaseResource, position), 0, @@ -121,11 +121,11 @@ // Trees for (let p = 0; p < teams[i].length; ++p) { - let tries = 10; + const tries = 10; for (let x = 0; x < tries; ++x) { - let tAngle = playerAngle[p] + randFloat(-1, 1) * 2 * Math.PI / teams[i].length; - let treePosition = Vector2D.add(playerPosition[p], new Vector2D(16, 0).rotate(-tAngle)).round(); + const tAngle = playerAngle[p] + randFloat(-1, 1) * 2 * Math.PI / teams[i].length; + const treePosition = Vector2D.add(playerPosition[p], new Vector2D(16, 0).rotate(-tAngle)).round(); if (createObjectGroup( new SimpleGroup([new SimpleObject(oTree2, g_InitialTrees, g_InitialTrees, 0, 7)], true, clBaseResource, treePosition), 0, @@ -229,7 +229,7 @@ [avoidClasses(clForest, 1, clPlayer, 40, clMetal, 20), stayClasses(clLand, 4)], clRock); -var [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); +const [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); createForests( [tMainTerrain, tForestFloor1, tForestFloor2, pForest1, pForest2], [avoidClasses(clPlayer, 10, clForest, 20, clBaseResource, 5, clRock, 6, clMetal, 6), stayClasses(clLand, 3)], @@ -282,7 +282,7 @@ if (currentBiome() == "generic/sahara") { g_Map.log("Creating obelisks"); - let group = new SimpleGroup( + const group = new SimpleGroup( [new SimpleObject(oObelisk, 1, 1, 0, 1)], true ); @@ -294,8 +294,8 @@ } g_Map.log("Creating dirt patches"); -let numb = currentBiome() == "generic/savanna" ? 3 : 1; -for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) +const numb = currentBiome() == "generic/savanna" ? 3 : 1; +for (const size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5), [ @@ -306,7 +306,7 @@ numb*scaleByMapSize(15, 45)); g_Map.log("Creating grass patches"); -for (let size of [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)]) +for (const size of [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5), new TerrainPainter(tTier4Terrain), @@ -376,7 +376,7 @@ ); g_Map.log("Creating small grass tufts"); -let planetm = currentBiome() == "generic/india" ? 8 : 1; +const planetm = currentBiome() == "generic/india" ? 8 : 1; group = new SimpleGroup( [new SimpleObject(aGrassShort, 1, 2, 0, 1, -Math.PI / 8, Math.PI / 8)] ); Index: binaries/data/mods/public/maps/random/islands.js =================================================================== --- binaries/data/mods/public/maps/random/islands.js +++ binaries/data/mods/public/maps/random/islands.js @@ -50,25 +50,25 @@ const heightOffsetBump = 2; const heightHill = 18; -var g_Map = new RandomMap(heightSeaGround, tWater); +const g_Map = new RandomMap(heightSeaGround, tWater); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clLand = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clLand = g_Map.createTileClass(); -var playerIslandRadius = scaleByMapSize(20, 29); +const playerIslandRadius = scaleByMapSize(20, 29); -var [playerIDs, playerPosition, playerAngle] = playerPlacementCircle(fractionToTiles(0.35)); +const [playerIDs, playerPosition, playerAngle] = playerPlacementCircle(fractionToTiles(0.35)); if (!isNomad()) { @@ -84,7 +84,7 @@ new TileClassPainter(clPlayer) ]); - let dockLocation = findLocationInDirectionBasedOnHeight(playerPosition[i], mapCenter, -3 , heightLand - 0.5, heightLand); + const dockLocation = findLocationInDirectionBasedOnHeight(playerPosition[i], mapCenter, -3 , heightLand - 0.5, heightLand); g_Map.placeEntityPassable(oDock, playerIDs[i], dockLocation, playerAngle[i] + Math.PI); } } @@ -179,17 +179,17 @@ scaleByMapSize(4, 13)); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); -var types = [ +const [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); +const types = [ [[tForestFloor2, tMainTerrain, pForest1], [tForestFloor2, pForest1]], [[tForestFloor1, tMainTerrain, pForest2], [tForestFloor1, pForest2]] ]; if (currentBiome() != "generic/savanna") { - var size = forestTrees / (scaleByMapSize(3,6) * numPlayers); - var num = Math.floor(size / types.length); - for (let type of types) + const size = forestTrees / (scaleByMapSize(3,6) * numPlayers); + const num = Math.floor(size / types.length); + for (const type of types) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), forestTrees / (num * Math.floor(scaleByMapSize(2, 5))), 0.5), [ @@ -202,8 +202,8 @@ Engine.SetProgress(50); g_Map.log("Creating dirt patches"); -var numberOfPatches = scaleByMapSize(15, 45) * (currentBiome() == "generic/savanna" ? 3 : 1); -for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) +const numberOfPatches = scaleByMapSize(15, 45) * (currentBiome() == "generic/savanna" ? 3 : 1); +for (const size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5), [ @@ -214,7 +214,7 @@ numberOfPatches); g_Map.log("Creating grass patches"); -for (let size of [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)]) +for (const size of [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5), new TerrainPainter(tTier4Terrain), @@ -224,7 +224,7 @@ Engine.SetProgress(55); 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, 0, clRock, 10, clHill, 1), stayClasses(clLand, 5)], scaleByMapSize(4,16), 100 @@ -320,7 +320,7 @@ clForest, stragglerTrees); -var planetm = 1; +let planetm = 1; if (currentBiome() == "generic/india") planetm = 8; Index: binaries/data/mods/public/maps/random/jebel_barkal.js =================================================================== --- binaries/data/mods/public/maps/random/jebel_barkal.js +++ binaries/data/mods/public/maps/random/jebel_barkal.js @@ -217,7 +217,7 @@ } ]; -var layoutKushTemples = [ +const layoutKushTemples = [ ...new Array(2).fill(0).map((v, i) => ({ "template": oTempleApedemak, @@ -370,7 +370,7 @@ new HeightConstraint(-Infinity, heightDesert)); // Fertile land -var widthFertileLand = fractionToTiles(0.33); +const widthFertileLand = fractionToTiles(0.33); paintRiver({ "parallel": true, "start": new Vector2D(mapBounds.left, mapBounds.bottom).rotateAround(-riverAngle, mapCenter), @@ -388,7 +388,7 @@ }, "landFunc": (position, shoreDist1, shoreDist2) => { - for (let riv of layoutFertileLandTextures) + for (const riv of layoutFertileLandTextures) if (riv.left < +shoreDist1 && +shoreDist1 < riv.right || riv.left < -shoreDist2 && -shoreDist2 < riv.right) { @@ -426,7 +426,7 @@ if (!isNomad()) { g_Map.log("Marking player positions"); - for (let position of playerPosition) + for (const position of playerPosition) addCivicCenterAreaToClass(position, clPlayer); } @@ -454,10 +454,10 @@ const stayFertileLand = new StaticConstraint(stayClasses(clFertileLand, 0)); g_Map.log("Finding possible irrigation canal locations"); -var irrigationCanalAreas = []; +let irrigationCanalAreas = []; for (let i = 0; i < 30; ++i) { - let x = fractionToTiles(randFloat(0, 1)); + const x = fractionToTiles(randFloat(0, 1)); irrigationCanalAreas.push( createArea( new PathPlacer( @@ -474,8 +474,8 @@ } g_Map.log("Creating irrigation canals"); -var irrigationCanalLocations = []; -for (let area of irrigationCanalAreas) +let irrigationCanalLocations = []; +for (const area of irrigationCanalAreas) { if (!area.getPoints().length || area.getPoints().some(point => !avoidClasses(clPlayer, scaleByMapSize(8, 13), clIrrigationCanal, scaleByMapSize(15, 25)).allows(point))) @@ -492,16 +492,16 @@ } g_Map.log("Creating passages"); -var previousPassageY = randIntInclusive(0, widthFertileLand); -var areasPassages = []; +let previousPassageY = randIntInclusive(0, widthFertileLand); +let areasPassages = []; irrigationCanalLocations.sort((a, b) => a - b); for (let i = 0; i < irrigationCanalLocations.length; ++i) { - let previous = i == 0 ? mapBounds.left : irrigationCanalLocations[i - 1]; - let next = i == irrigationCanalLocations.length - 1 ? mapBounds.right : irrigationCanalLocations[i + 1]; + const previous = i == 0 ? mapBounds.left : irrigationCanalLocations[i - 1]; + const next = i == irrigationCanalLocations.length - 1 ? mapBounds.right : irrigationCanalLocations[i + 1]; - let x1 = (irrigationCanalLocations[i] + previous) / 2; - let x2 = (irrigationCanalLocations[i] + next) / 2; + const x1 = (irrigationCanalLocations[i] + previous) / 2; + const x2 = (irrigationCanalLocations[i] + next) / 2; let y; // The passages should be at different locations, so that enemies can't attack each other easily @@ -509,7 +509,7 @@ { y = (previousPassageY + randIntInclusive(0.2 * widthFertileLand, 0.8 * widthFertileLand)) % widthFertileLand; - let pos = new Vector2D((x1 + x2) / 2, y).rotateAround(-riverAngle, mapCenter).round(); + const pos = new Vector2D((x1 + x2) / 2, y).rotateAround(-riverAngle, mapCenter).round(); if (g_Map.validTilePassable(new Vector2D(pos.x, pos.y)) && avoidClasses(clDesert, 12).allows(pos) && @@ -517,7 +517,7 @@ break; } - let area = + const area = createArea( new PathPlacer( new Vector2D(x1, y).rotateAround(-riverAngle, mapCenter), @@ -582,7 +582,7 @@ for (let i = 0; i < numPlayers; ++i) { - let isDesert = clDesert.has(playerPosition[i]); + const isDesert = clDesert.has(playerPosition[i]); placePlayerBase({ "playerID": playerIDs[i], "playerPosition": playerPosition[i], @@ -664,26 +664,26 @@ // The city is a circle segment of this maximum size g_Map.log("Computing city grid"); -var gridCenter = new Vector2D(0, fractionToTiles(0.3)).rotate(-riverAngle).add(mapCenter).round(); -var gridMaxAngle = Math.min(scaleByMapSize(1/3, 1), 2/3) * Math.PI; -var gridStartAngle = -Math.PI / 2 -gridMaxAngle / 2 + riverAngle; -var gridRadius = y => hillRadius + 18 * y; +const gridCenter = new Vector2D(0, fractionToTiles(0.3)).rotate(-riverAngle).add(mapCenter).round(); +const gridMaxAngle = Math.min(scaleByMapSize(1/3, 1), 2/3) * Math.PI; +const gridStartAngle = -Math.PI / 2 -gridMaxAngle / 2 + riverAngle; +const gridRadius = y => hillRadius + 18 * y; -var gridPointsX = layoutKushTemples.length; -var gridPointsY = Math.floor(scaleByMapSize(2, 5)); -var gridPointXCenter = Math.floor(gridPointsX / 2); -var gridPointYCenter = Math.floor(gridPointsY / 2); +const gridPointsX = layoutKushTemples.length; +const gridPointsY = Math.floor(scaleByMapSize(2, 5)); +const gridPointXCenter = Math.floor(gridPointsX / 2); +const gridPointYCenter = Math.floor(gridPointsY / 2); // Maps from grid position to map position -var cityGridPosition = []; -var cityGridAngle = []; +let cityGridPosition = []; +let cityGridAngle = []; for (let y = 0; y < gridPointsY; ++y) [cityGridPosition[y], cityGridAngle[y]] = distributePointsOnCircularSegment( gridPointsX, gridMaxAngle, gridStartAngle, gridRadius(y), gridCenter); g_Map.log("Marking city path crossings"); -for (let y in cityGridPosition) - for (let x in cityGridPosition[y]) +for (const y in cityGridPosition) + for (const x in cityGridPosition[y]) { cityGridPosition[y][x].round(); createArea( @@ -695,11 +695,11 @@ } g_Map.log("Marking horizontal city paths"); -var areasCityPaths = []; +const areasCityPaths = []; for (let y = 0; y < gridPointsY; ++y) for (let x = 1; x < gridPointsX; ++x) { - let width = y == gridPointYCenter ? pathWidthSecondary : pathWidth; + const width = y == gridPointYCenter ? pathWidthSecondary : pathWidth; areasCityPaths.push( createArea( new PathPlacer(cityGridPosition[y][x - 1], cityGridPosition[y][x], width, 0, 8, 0, 0, Infinity), @@ -710,7 +710,7 @@ for (let y = 1; y < gridPointsY; ++y) for (let x = 0; x < gridPointsX; ++x) { - let width = + const width = Math.abs(x - gridPointXCenter) == 0 ? pathWidthCenter : Math.abs(x - gridPointXCenter) == 1 ? @@ -725,11 +725,11 @@ Engine.SetProgress(70); g_Map.log("Placing kushite temples"); -var entitiesTemples = []; -var templePosition = []; +let entitiesTemples = []; +const templePosition = []; for (let i = 0; i < layoutKushTemples.length; ++i) { - let x = i + (gridPointsX - layoutKushTemples.length) / 2; + const x = i + (gridPointsX - layoutKushTemples.length) / 2; templePosition[i] = Vector2D.add(cityGridPosition[0][x], layoutKushTemples[i].pathOffset.rotate(-Math.PI / 2 - cityGridAngle[0][x])); entitiesTemples[i] = g_Map.placeEntityPassable(layoutKushTemples[i].template, 0, templePosition[i], cityGridAngle[0][x]); } @@ -767,15 +767,15 @@ ]); g_Map.log("Placing lion statues in the central path"); -var statueCount = scaleByMapSize(10, 40); -var centralPathStart = cityGridPosition[0][gridPointXCenter]; -var centralPathLength = centralPathStart.distanceTo(cityGridPosition[gridPointsY - 1][gridPointXCenter]); -var centralPathAngle = cityGridAngle[0][gridPointXCenter]; +const statueCount = scaleByMapSize(10, 40); +const centralPathStart = cityGridPosition[0][gridPointXCenter]; +const centralPathLength = centralPathStart.distanceTo(cityGridPosition[gridPointsY - 1][gridPointXCenter]); +const centralPathAngle = cityGridAngle[0][gridPointXCenter]; for (let i = 0; i < 2; ++i) for (let stat = 0; stat < statueCount; ++stat) { - let start = new Vector2D(0, pathWidthCenter * 3/4 * (i - 0.5)).rotate(centralPathAngle).add(centralPathStart); - let position = new Vector2D(centralPathLength, 0).mult(stat / statueCount).rotate(-centralPathAngle).add(start).add(new Vector2D(0.5, 0.5)); + const start = new Vector2D(0, pathWidthCenter * 3/4 * (i - 0.5)).rotate(centralPathAngle).add(centralPathStart); + const position = new Vector2D(centralPathLength, 0).mult(stat / statueCount).rotate(-centralPathAngle).add(start).add(new Vector2D(0.5, 0.5)); if (!avoidClasses(clPathCrossing, 2).allows(position)) continue; @@ -785,12 +785,12 @@ } g_Map.log("Placing guardian infantry in the central path"); -var centralChampionsCount = scaleByMapSize(2, 40); +const centralChampionsCount = scaleByMapSize(2, 40); for (let i = 0; i < 2; ++i) for (let champ = 0; champ < centralChampionsCount; ++champ) { - let start = new Vector2D(0, pathWidthCenter * 1/2 * (i - 0.5)).rotate(-centralPathAngle).add(centralPathStart); - let position = new Vector2D(centralPathLength, 0).mult(champ / centralChampionsCount).rotate(-centralPathAngle).add(start).add(new Vector2D(0.5, 0.5)); + const start = new Vector2D(0, pathWidthCenter * 1/2 * (i - 0.5)).rotate(-centralPathAngle).add(centralPathStart); + const position = new Vector2D(centralPathLength, 0).mult(champ / centralChampionsCount).rotate(-centralPathAngle).add(start).add(new Vector2D(0.5, 0.5)); if (!avoidClasses(clPathCrossing, 2).allows(position)) continue; @@ -800,21 +800,21 @@ } g_Map.log("Placing kushite statues in the secondary paths"); -for (let x of [gridPointXCenter - 1, gridPointXCenter + 1]) +for (const x of [gridPointXCenter - 1, gridPointXCenter + 1]) { g_Map.placeEntityAnywhere(aStatueKush, 0, cityGridPosition[gridPointYCenter][x], cityGridAngle[gridPointYCenter][x]); clPathStatues.add(cityGridPosition[gridPointYCenter][x]); } g_Map.log("Creating ritual place near the wonder"); -var ritualPosition = Vector2D.average([ +const ritualPosition = Vector2D.average([ templePosition[Math.floor(templePosition.length / 2) - 1], templePosition[Math.ceil(templePosition.length / 2) - 1], cityGridPosition[0][gridPointXCenter], cityGridPosition[0][gridPointXCenter - 1] ]).round(); -var ritualAngle = (cityGridAngle[0][gridPointXCenter] + cityGridAngle[0][gridPointXCenter - 1]) / 2 + Math.PI / 2; +const ritualAngle = (cityGridAngle[0][gridPointXCenter] + cityGridAngle[0][gridPointXCenter - 1]) / 2 + Math.PI / 2; g_Map.placeEntityPassable(aStatueKush, 0, ritualPosition, ritualAngle - Math.PI / 2); @@ -832,26 +832,26 @@ new ElevationPainter(heightDesert + heightOffsetStatue)); g_Map.log("Placing healers at the ritual place"); -var [healerPosition, healerAngle] = distributePointsOnCircularSegment( +const [healerPosition, healerAngle] = distributePointsOnCircularSegment( scaleByMapSize(2, 10), Math.PI, ritualAngle, scaleByMapSize(2, 3), ritualPosition); for (let i = 0; i < healerPosition.length; ++i) g_Map.placeEntityPassable(oKushHealer, 0, healerPosition[i], healerAngle[i] + Math.PI); g_Map.log("Placing statues at the ritual place"); -var [statuePosition, statueAngle] = distributePointsOnCircularSegment( +const [statuePosition, statueAngle] = distributePointsOnCircularSegment( scaleByMapSize(4, 8), Math.PI, ritualAngle, scaleByMapSize(3, 4), ritualPosition); for (let i = 0; i < statuePosition.length; ++i) g_Map.placeEntityPassable(pickRandom(aStatues), 0, statuePosition[i], statueAngle[i] + Math.PI); g_Map.log("Placing palms at the ritual place"); -var palmPosition = distributePointsOnCircularSegment( +const palmPosition = distributePointsOnCircularSegment( scaleByMapSize(6, 16), Math.PI, ritualAngle, scaleByMapSize(4, 5), ritualPosition)[0]; for (let i = 0; i < palmPosition.length; ++i) if (avoidClasses(clTemple, 1).allows(palmPosition[i])) g_Map.placeEntityPassable(oPalmPath, 0, palmPosition[i], randomAngle()); g_Map.log("Painting city paths"); -var areaPaths = createArea( +const areaPaths = createArea( new MapBoundsPlacer(), [ new LayeredPainter([tPathWild, tPath], [1]), @@ -880,14 +880,14 @@ ], new StaticConstraint(avoidClasses(clPath, 0))); -var entitiesGates; +let entitiesGates; if (placeNapataWall) { g_Map.log("Placing front walls"); - let wallGridMaxAngleSummand = scaleByMapSize(0.04, 0.03) * Math.PI; - let wallGridStartAngle = gridStartAngle - wallGridMaxAngleSummand / 2; - let wallGridRadiusFront = gridRadius(gridPointsY - 1) + pathWidth - 1; - let wallGridMaxAngleFront = gridMaxAngle + wallGridMaxAngleSummand; + const wallGridMaxAngleSummand = scaleByMapSize(0.04, 0.03) * Math.PI; + const wallGridStartAngle = gridStartAngle - wallGridMaxAngleSummand / 2; + const wallGridRadiusFront = gridRadius(gridPointsY - 1) + pathWidth - 1; + const wallGridMaxAngleFront = gridMaxAngle + wallGridMaxAngleSummand; let entitiesWalls = placeCircularWall( gridCenter, wallGridRadiusFront, @@ -901,11 +901,11 @@ 0); g_Map.log("Placing side and back walls"); - let wallGridRadiusBack = hillRadius - scaleByMapSize(15, 25); - let wallGridMaxAngleBack = gridMaxAngle + wallGridMaxAngleSummand; - let wallGridPositionFront = distributePointsOnCircularSegment(gridPointsX, wallGridMaxAngleBack, wallGridStartAngle, wallGridRadiusFront, gridCenter)[0]; - let wallGridPositionBack = distributePointsOnCircularSegment(gridPointsX, wallGridMaxAngleBack, wallGridStartAngle, wallGridRadiusBack, gridCenter)[0]; - let wallGridPosition = [wallGridPositionFront[0], ...wallGridPositionBack, wallGridPositionFront[wallGridPositionFront.length - 1]]; + const wallGridRadiusBack = hillRadius - scaleByMapSize(15, 25); + const wallGridMaxAngleBack = gridMaxAngle + wallGridMaxAngleSummand; + const wallGridPositionFront = distributePointsOnCircularSegment(gridPointsX, wallGridMaxAngleBack, wallGridStartAngle, wallGridRadiusFront, gridCenter)[0]; + const wallGridPositionBack = distributePointsOnCircularSegment(gridPointsX, wallGridMaxAngleBack, wallGridStartAngle, wallGridRadiusBack, gridCenter)[0]; + const wallGridPosition = [wallGridPositionFront[0], ...wallGridPositionBack, wallGridPositionFront[wallGridPositionFront.length - 1]]; for (let x = 1; x < wallGridPosition.length; ++x) entitiesWalls = entitiesWalls.concat( placeLinearWall( @@ -941,7 +941,7 @@ ]); g_Map.log("Painting gate terrain"); - for (let entity of entitiesGates) + for (const entity of entitiesGates) createArea( new DiskPlacer(pathWidth, entity.GetPosition2D()), [ @@ -956,7 +956,7 @@ Engine.SetProgress(70); g_Map.log("Finding road starting points"); -var roadStartLocations = shuffleArray( +const roadStartLocations = shuffleArray( entitiesGates ? entitiesGates.map(entity => entity.GetPosition2D()) : [ @@ -966,24 +966,24 @@ ]); g_Map.log("Finding possible roads"); -var roadConstraint = new StaticConstraint( +let roadConstraint = new StaticConstraint( [ stayDesert, avoidClasses(clHill, 0, clCity, 0, clPyramid, 6, clPlayer, 16) ]); -var areaCityPaths = new Area(areasCityPaths.reduce((points, area) => points.concat(area.getPoints()), [])); -var areaRoads = []; -for (let roadStart of roadStartLocations) +const areaCityPaths = new Area(areasCityPaths.reduce((points, area) => points.concat(area.getPoints()), [])); +const areaRoads = []; +for (const roadStart of roadStartLocations) { if (areaRoads.length >= scaleByMapSize(2, 5)) break; - let closestPoint = areaCityPaths.getClosestPointTo(roadStart); + const closestPoint = areaCityPaths.getClosestPointTo(roadStart); roadConstraint = new StaticConstraint([roadConstraint, avoidClasses(clRoad, 20)]); for (let tries = 0; tries < 30; ++tries) { - let area = createArea( + const area = createArea( new PathPlacer( Vector2D.add(closestPoint, new Vector2D(0, 3/4 * mapSize).rotate(closestPoint.angleTo(roadStart))), roadStart, @@ -1014,7 +1014,7 @@ [stayClasses(clRoad, 0), avoidClasses(clPath, 0)]); g_Map.log("Marking road palm area"); -var areaRoadPalms = createArea( +const areaRoadPalms = createArea( new MapBoundsPlacer(), undefined, [ @@ -1045,7 +1045,7 @@ Engine.SetProgress(75); g_Map.log("Marking city bush area"); -var areaCityBushes = +const areaCityBushes = createArea( new MapBoundsPlacer(), undefined, @@ -1072,7 +1072,7 @@ ]); g_Map.log("Marking city palm area"); -var areaCityPalms = +const areaCityPalms = createArea( new MapBoundsPlacer(), undefined, @@ -1102,7 +1102,7 @@ if (placeNapataWall) { g_Map.log("Marking wall palm area"); - var areaWallPalms = createArea( + const areaWallPalms = createArea( new MapBoundsPlacer(), undefined, new StaticConstraint([ @@ -1132,7 +1132,7 @@ g_Map.log("Setting up common constraints and areas"); const nearWater = new NearTileClassConstraint(clWater, 3); -var avoidCollisionsNomad = new AndConstraint( +const avoidCollisionsNomad = new AndConstraint( [ new StaticConstraint(avoidClasses( clCliff, 0, clHill, 0, clPlayer, 15, clWater, 1, clPath, 2, clRitualPlace, 10, @@ -1140,7 +1140,7 @@ avoidClasses(clForest, 1, clRock, 4, clMetal, 4, clFood, 2, clSoldier, 1, clTreasure, 1) ]); -var avoidCollisions = new AndConstraint( +let avoidCollisions = new AndConstraint( [ avoidCollisionsNomad, new StaticConstraint(avoidClasses(clRoad, 6, clFood, 6)) @@ -1188,8 +1188,8 @@ for (let i = 0; i < scaleByMapSize(6, 22); ++i) { - let mineObjectsBiome = pickRandom(mineObjectsPerBiome); - for (let i in mineObjectsBiome.desert) + const mineObjectsBiome = pickRandom(mineObjectsPerBiome); + for (const i in mineObjectsBiome.desert) createObjectGroupsByAreas( new SimpleGroup(mineObjectsBiome.desert[i], true, mineObjectsBiome.tileClass), 0, @@ -1201,7 +1201,7 @@ for (let i = 0; i < (isNomad() ? scaleByMapSize(6, 16) : scaleByMapSize(0, 8)); ++i) { - let mineObjectsBiome = pickRandom(mineObjectsPerBiome); + const mineObjectsBiome = pickRandom(mineObjectsPerBiome); createObjectGroupsByAreas( new SimpleGroup(mineObjectsBiome.fertileLand.small, true, mineObjectsBiome.tileClass), 0, @@ -1297,7 +1297,7 @@ Engine.SetProgress(85); g_Map.log("Marking irrigation canal tree area"); -var areaIrrigationCanalTrees = createArea( +const areaIrrigationCanalTrees = createArea( new MapBoundsPlacer(), undefined, [ @@ -1392,7 +1392,7 @@ [areaHilltop]); g_Map.log("Placing treasures in the city"); -var pathBorderConstraint = new AndConstraint([ +const pathBorderConstraint = new AndConstraint([ new StaticConstraint([new NearTileClassConstraint(clCity, 1)]), avoidClasses(clTreasure, 2, clStatue, 10, clPathStatues, 4, clWall, 2, clForest, 1) ]); @@ -1464,7 +1464,7 @@ [areaWater]); g_Map.log("Creating reeds at the irrigation canals"); -for (let area of areasPassages) +for (const area of areasPassages) createObjectGroupsByAreas( new SimpleGroup([new RandomObject(aWaterDecoratives, 2, 4, 1, 2)], true), 0, Index: binaries/data/mods/public/maps/random/kerala.js =================================================================== --- binaries/data/mods/public/maps/random/kerala.js +++ binaries/data/mods/public/maps/random/kerala.js @@ -37,27 +37,27 @@ const heightLand = 3; const heightHill = 25; -var g_Map = new RandomMap(heightLand, tGrass); +const g_Map = new RandomMap(heightLand, tGrass); const numPlayers = getNumPlayers(); const mapCenter = g_Map.getCenter(); const mapBounds = g_Map.getBounds(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); -var waterPosition = fractionToTiles(0.31); -var playerPosition = fractionToTiles(0.55); -var mountainPosition = fractionToTiles(0.69); +const waterPosition = fractionToTiles(0.31); +const playerPosition = fractionToTiles(0.55); +const mountainPosition = fractionToTiles(0.69); -var startAngle = randomAngle(); +const startAngle = randomAngle(); placePlayerBases({ "PlayerPlacement": [ @@ -110,7 +110,7 @@ }); g_Map.log("Marking mountain area"); -var areaMountains = createArea( +const areaMountains = createArea( new ConvexPolygonPlacer( [ new Vector2D(mountainPosition, mapBounds.top), @@ -123,7 +123,7 @@ g_Map.log("Creating shores"); for (let i = 0; i < scaleByMapSize(20, 120); ++i) { - let position = new Vector2D(fractionToTiles(randFloat(0.28, 0.34)), fractionToTiles(randFloat(0.1, 0.9))).rotateAround(startAngle - Math.PI / 2, mapCenter).round(); + const position = new Vector2D(fractionToTiles(randFloat(0.28, 0.34)), fractionToTiles(randFloat(0.1, 0.9))).rotateAround(startAngle - Math.PI / 2, mapCenter).round(); createArea( new ChainPlacer(1, Math.floor(scaleByMapSize(4, 6)), Math.floor(scaleByMapSize(16, 30)), Infinity, position), [ @@ -154,14 +154,14 @@ [areaMountains]); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(1000, 6000, 0.7); -var types = [ +const [forestTrees, stragglerTrees] = getTreeCounts(1000, 6000, 0.7); +const types = [ [[tGrass, tGrass, tGrass, tGrass, pForestD], [tGrass, tGrass, tGrass, pForestD]], [[tGrass, tGrass, tGrass, tGrass, pForestP], [tGrass, tGrass, tGrass, pForestP]] ]; -var size = forestTrees / (scaleByMapSize(3,6) * numPlayers); -var num = Math.floor(size / types.length); -for (let type of types) +const forestSize = forestTrees / (scaleByMapSize(3,6) * numPlayers); +const num = Math.floor(forestSize / types.length); +for (const type of types) createAreas( new ChainPlacer( 1, @@ -178,7 +178,7 @@ Engine.SetProgress(70); g_Map.log("Creating grass patches"); -for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) +for (const size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5), [ @@ -188,7 +188,7 @@ avoidClasses(clWater, 8, clForest, 0, clHill, 0, clPlayer, 12, clDirt, 16), scaleByMapSize(20, 80)); -for (let size of [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)]) +for (const size of [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5), [ @@ -199,7 +199,7 @@ scaleByMapSize(20, 80)); 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(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1), scaleByMapSize(4,16), 100 Index: binaries/data/mods/public/maps/random/lake.js =================================================================== --- binaries/data/mods/public/maps/random/lake.js +++ binaries/data/mods/public/maps/random/lake.js @@ -45,23 +45,23 @@ const heightSeaGround = -3; const heightLand = 3; -var g_Map = new RandomMap(heightLand, tMainTerrain); +const g_Map = new RandomMap(heightLand, tMainTerrain); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); -var [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.35)); +const [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.35)); g_Map.log("Preventing water in player territory"); for (let i = 0; i < numPlayers; ++i) @@ -180,7 +180,7 @@ Engine.SetProgress(65); -var planetm = 1; +let planetm = 1; if (currentBiome() == "generic/india") planetm = 8; 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 @@ -55,21 +55,21 @@ const heightPlayer = 5; const heightHill = 12; -var g_Map = new RandomMap(heightLand, tGrass); +const g_Map = new RandomMap(heightLand, tGrass); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); const mapBounds = g_Map.getBounds(); -var clWater = g_Map.createTileClass(); -var clCliff = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clPlayer = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clCliff = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); var WATER_WIDTH = 0.1; var horizontal = randBool(); @@ -83,8 +83,8 @@ let r = Infinity; for (let i = 0; i < numPlayers; ++i) { - var dx = x - tilesToFraction(playerPosition[i].x); - var dz = z - tilesToFraction(playerPosition[i].y); + let dx = x - tilesToFraction(playerPosition[i].x); + let dz = z - tilesToFraction(playerPosition[i].y); r = Math.min(r, Math.square(dx) + Math.square(dz)); } return Math.sqrt(r); @@ -92,7 +92,7 @@ function playerNearness(x, z) { - var d = fractionToTiles(distanceToPlayers(x,z)); + let d = fractionToTiles(distanceToPlayers(x,z)); if (d < 13) return 0; @@ -103,7 +103,7 @@ return 1; } -for (let x of [mapBounds.left, mapBounds.right]) +for (const x of [mapBounds.left, mapBounds.right]) paintRiver({ "parallel": true, "start": new Vector2D(x, mapBounds.top).rotateAround(startAngle, mapCenter), @@ -136,14 +136,14 @@ for (var ix = 0; ix <= mapSize; ix++) for (var iz = 0; iz <= mapSize; iz++) { - let position = new Vector2D(ix, iz); + const position = new Vector2D(ix, iz); var x = ix / (mapSize + 1.0); var z = iz / (mapSize + 1.0); var pn = playerNearness(x, z); - let c = startAngle ? z : x; - let distToWater = clWater.has(position) ? 0 : (0.5 - WATER_WIDTH - Math.abs(c - 0.5)); + 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 @@ -153,7 +153,7 @@ baseNoise *= pn; baseNoise *= Math.max(0.1, distToWater / (0.5 - WATER_WIDTH)); } - var oldH = h; + const oldH = h; h += baseNoise; // add some higher-frequency noise on land @@ -163,7 +163,7 @@ // create cliff noise if ( h > -10 ) { - var cliffNoise = (noise3.get(x,z) + 0.5*noise4.get(x,z)) / 1.5; + let cliffNoise = (noise3.get(x,z) + 0.5*noise4.get(x,z)) / 1.5; if (h < 1) { var u = 1 - 0.3*((h-1)/-10); @@ -195,7 +195,7 @@ for (var ix = 0; ix < mapSize; ix++) for (var iz = 0; iz < mapSize; iz++) { - let position = new Vector2D(ix, iz); + const position = new Vector2D(ix, iz); var x = ix / (mapSize + 1.0); var z = iz / (mapSize + 1.0); var pn = playerNearness(x, z); @@ -203,9 +203,9 @@ // Compute height difference let minH = +Infinity; let maxH = -Infinity; - for (let vertex of g_TileVertices) + for (const vertex of g_TileVertices) { - let height = g_Map.getHeight(Vector2D.add(position, vertex)); + const height = g_Map.getHeight(Vector2D.add(position, vertex)); minH = Math.min(minH, height); maxH = Math.max(maxH, height); } @@ -223,7 +223,7 @@ } // choose a terrain based on elevation - var t = tGrass; + let t = tGrass; // water if (maxH < -12) @@ -276,7 +276,7 @@ { if (minH < 11 && minH >= 4) { - var typeNoise = noise10.get(x,z); + const typeNoise = noise10.get(x,z); if (typeNoise < 0.43 && forestNoise < 0.05) t = pPoplarForest; Index: binaries/data/mods/public/maps/random/lions_den.js =================================================================== --- binaries/data/mods/public/maps/random/lions_den.js +++ binaries/data/mods/public/maps/random/lions_den.js @@ -12,7 +12,7 @@ const heightDen = 15; const heightHill = 50; -var g_Map = new RandomMap(heightHill, topTerrain); +const g_Map = new RandomMap(heightHill, topTerrain); const mapCenter = g_Map.getCenter(); const numPlayers = getNumPlayers(); @@ -434,10 +434,10 @@ function createSunkenTerrain() { - var base = g_Terrains.mainTerrain; - var middle = g_Terrains.dirt; - var lower = g_Terrains.tier2Terrain; - var road = g_Terrains.road; + let base = g_Terrains.mainTerrain; + let middle = g_Terrains.dirt; + let lower = g_Terrains.tier2Terrain; + let road = g_Terrains.road; if (currentBiome() == "generic/arctic") { @@ -469,9 +469,9 @@ if (currentBiome() == "generic/autumn") middle = g_Terrains.shore; - var expSize = diskArea(fractionToTiles(0.14)) / numPlayers; - var expDist = 0.1 + numPlayers / 200; - var expAngle = 0.75; + let expSize = diskArea(fractionToTiles(0.14)) / numPlayers; + let expDist = 0.1 + numPlayers / 200; + let expAngle = 0.75; if (numPlayers <= 2) { @@ -479,8 +479,8 @@ expAngle = 0.72; } - var nRoad = 0.44; - var nExp = 0.425; + let nRoad = 0.44; + let nExp = 0.425; if (numPlayers < 4) { @@ -506,17 +506,17 @@ new TileClassPainter(g_TileClasses.mountain) ]); - let getCoords = (distance, playerID, playerIDOffset) => { - let angle = startAngle + (playerID + playerIDOffset) * 2 * Math.PI / numPlayers; + const getCoords = (distance, playerID, playerIDOffset) => { + const angle = startAngle + (playerID + playerIDOffset) * 2 * Math.PI / numPlayers; return Vector2D.add(mapCenter, new Vector2D(fractionToTiles(distance), 0).rotate(-angle)).round(); }; for (let i = 0; i < numPlayers; ++i) { - let playerPosition = getCoords(0.4, i, 0); + const playerPosition = getCoords(0.4, i, 0); // Path from player to expansion - let expansionPosition = getCoords(expDist, i, expAngle); + const expansionPosition = getCoords(expDist, i, expAngle); createArea( new PathPlacer(playerPosition, expansionPosition, 12, 0.7, 0.5, 0.1, -1), [ @@ -526,10 +526,10 @@ ]); // Path from player to neighbor - for (let neighborOffset of [-0.5, 0.5]) + for (const neighborOffset of [-0.5, 0.5]) { - let neighborPosition = getCoords(nRoad, i, neighborOffset); - let pathPosition = getCoords(0.47, i, 0); + const neighborPosition = getCoords(nRoad, i, neighborOffset); + const pathPosition = getCoords(0.47, i, 0); createArea( new PathPlacer(pathPosition, neighborPosition, 19, 0.4, 0.5, 0.1, -0.6), [ @@ -562,7 +562,7 @@ g_Map.log("Creating the expansions between players"); for (let i = 0; i < numPlayers; ++i) { - let position = getCoords(nExp, i, 0.5); + const position = getCoords(nExp, i, 0.5); createArea( new ClumpPlacer(expSize, 0.9, 0.3, Infinity, position), [ Index: binaries/data/mods/public/maps/random/lorraine_plain.js =================================================================== --- binaries/data/mods/public/maps/random/lorraine_plain.js +++ binaries/data/mods/public/maps/random/lorraine_plain.js @@ -42,27 +42,27 @@ const heightLand = 3; const heightOffsetBump = 2; -var g_Map = new RandomMap(heightLand, tPrimary); +const g_Map = new RandomMap(heightLand, tPrimary); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); const mapBounds = g_Map.getBounds(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clShallow = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clShallow = g_Map.createTileClass(); -var shallowWidth = scaleByMapSize(8, 12); +const shallowWidth = scaleByMapSize(8, 12); -var startAngle = randomAngle(); +const startAngle = randomAngle(); placePlayerBases({ "PlayerPlacement": playerPlacementRiver(startAngle + Math.PI / 2, fractionToTiles(0.5)), @@ -97,7 +97,7 @@ }); Engine.SetProgress(20); -var riverPositions = [ +const riverPositions = [ new Vector2D(mapBounds.left + 1, mapCenter.y), new Vector2D(mapBounds.right - 1, mapCenter.y) ].map(v => v.rotateAround(startAngle, mapCenter)); @@ -110,7 +110,7 @@ Engine.SetProgress(25); g_Map.log("Creating small puddles at the map border to ensure players being separated"); -for (let riverPosition of riverPositions) +for (const riverPosition of riverPositions) createArea( new ClumpPlacer(diskArea(scaleByMapSize(5, 10)), 0.95, 0.6, Infinity, riverPosition), new SmoothElevationPainter(ELEVATION_SET, heightSeaGround, 2), @@ -120,7 +120,7 @@ g_Map.log("Creating the shallows of the main river"); for (let i = 0; i <= randIntInclusive(3, scaleByMapSize(4, 6)); ++i) { - let location = fractionToTiles(randFloat(0.15, 0.85)); + const location = fractionToTiles(randFloat(0.15, 0.85)); createPassage({ "start": new Vector2D(location, mapBounds.top).rotateAround(startAngle, mapCenter), "end": new Vector2D(location, mapBounds.bottom).rotateAround(startAngle, mapCenter), @@ -163,7 +163,7 @@ ); Engine.SetProgress(55); -var [forestTrees, stragglerTrees] = getTreeCounts(500, 2500, 0.7); +const [forestTrees, stragglerTrees] = getTreeCounts(500, 2500, 0.7); createForests( [tGrass, tGrassDForest, tGrassPForest, pForestB, pForestO], avoidClasses(clPlayer, 15, clWater, 3, clForest, 16, clHill, 1), @@ -172,7 +172,7 @@ Engine.SetProgress(70); g_Map.log("Creating dirt patches"); -for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) +for (const size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5), [ @@ -184,7 +184,7 @@ ); g_Map.log("Creating grass patches"); -for (let size of [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)]) +for (const size of [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5), new LayeredPainter([tGrassPatchBlend, tGrassPatch], [1]), @@ -194,7 +194,7 @@ Engine.SetProgress(80); 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(clWater, 0, clForest, 1, clPlayer, 15, clRock, 10, clHill, 1)], scaleByMapSize(4,16), 100 Index: binaries/data/mods/public/maps/random/lower_nubia.js =================================================================== --- binaries/data/mods/public/maps/random/lower_nubia.js +++ binaries/data/mods/public/maps/random/lower_nubia.js @@ -109,7 +109,7 @@ Engine.SetProgress(3); g_Map.log("Composing heightmap"); -var heightmapCombined = []; +let heightmapCombined = []; for (let x = 0; x < heightmapLand.length; ++x) { heightmapCombined[x] = new Float32Array(heightmapLand.length); @@ -140,7 +140,7 @@ const riverAngle = Math.PI * 3 / 4; for (let i = 0; i < scaleByMapSize(8, 15); ++i) { - let x = fractionToTiles(randFloat(0, 1)); + const x = fractionToTiles(randFloat(0, 1)); createArea( new PathPlacer( new Vector2D(x, mapBounds.bottom).rotateAround(riverAngle, mapCenter), @@ -197,15 +197,15 @@ new HeightConstraint(heightPlateau2, Infinity)); Engine.SetProgress(38); -var playerIDs = []; -var playerPosition = []; +let playerIDs = []; +let playerPosition = []; if (!isNomad()) { g_Map.log("Finding player locations"); [playerIDs, playerPosition] = playerPlacementRandom(sortAllPlayers(), avoidClasses(clWater, scaleByMapSize(8, 12), clCliff, scaleByMapSize(8, 12))); g_Map.log("Flatten the initial CC area"); - for (let position of playerPosition) + for (const position of playerPosition) createArea( new ClumpPlacer(diskArea(defaultPlayerBaseRadius() * 0.8), 0.95, 0.6, Infinity, position), new SmoothElevationPainter(ELEVATION_SET, g_Map.getHeight(position), 6)); @@ -327,11 +327,11 @@ const avoidCollisions = avoidClasses(clPlayer, 12, clBaseResource, 5, clWater, 1, clForest, 1, clRock, 4, clMetal, 4, clFood, 6, clCliff, 0, clPyramid, 6); g_Map.log("Creating straggler trees and bushes"); -var stragglerTreeObjects = [ +const stragglerTreeObjects = [ [new SimpleObject(oAcacia, 1, 1, 0, 0), new SimpleObject(oBushBadlands, 0, 1, 2, 2)], [new SimpleObject(oTreeDead, 1, 1, 0, 0), new SimpleObject(oBushBadlands, 0, 1, 2, 2)] ]; -for (let objects of stragglerTreeObjects) +for (const objects of stragglerTreeObjects) createObjectGroups( new SimpleGroup(objects, true, clForest), 0, Index: binaries/data/mods/public/maps/random/mainland.js =================================================================== --- binaries/data/mods/public/maps/random/mainland.js +++ binaries/data/mods/public/maps/random/mainland.js @@ -41,18 +41,18 @@ const heightLand = 3; -var g_Map = new RandomMap(heightLand, tMainTerrain); +const g_Map = new RandomMap(heightLand, tMainTerrain); const numPlayers = getNumPlayers(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); placePlayerBases({ "PlayerPlacement": playerPlacementCircle(fractionToTiles(0.35)), @@ -88,7 +88,7 @@ else createMountains(tCliff, avoidClasses(clPlayer, 20, clHill, 15), clHill, scaleByMapSize(3, 15)); -var [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); +const [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); createDefaultForests( [tMainTerrain, tForestFloor1, tForestFloor2, pForest1, pForest2], avoidClasses(clPlayer, 20, clForest, 18, clHill, 0), @@ -133,7 +133,7 @@ Engine.SetProgress(65); -var planetm = 1; +let planetm = 1; if (currentBiome() == "generic/india") planetm = 8; Index: binaries/data/mods/public/maps/random/marmara.js =================================================================== --- binaries/data/mods/public/maps/random/marmara.js +++ binaries/data/mods/public/maps/random/marmara.js @@ -59,8 +59,8 @@ const heightWaterLevel = heightScale(0); const heightShoreline = heightScale(0); -var g_Map = new RandomMap(0, g_Terrains.mainTerrain); -var mapCenter = g_Map.getCenter(); +const g_Map = new RandomMap(0, g_Terrains.mainTerrain); +const mapCenter = g_Map.getCenter(); initTileClasses(["shoreline"]); @@ -121,7 +121,7 @@ if (!isNomad()) { g_Map.log("Placing players"); - let [playerIDs, playerPosition] = createBases( + const [playerIDs, playerPosition] = createBases( ...playerPlacementRandom( sortAllPlayers(), [ @@ -131,7 +131,7 @@ true); g_Map.log("Flatten the initial CC area"); - for (let position of playerPosition) + for (const position of playerPosition) createArea( new ClumpPlacer(diskArea(defaultPlayerBaseRadius() * 0.8), 0.95, 0.6, Infinity, position), new SmoothElevationPainter(ELEVATION_SET, g_Map.getHeight(position), 6)); Index: binaries/data/mods/public/maps/random/mediterranean.js =================================================================== --- binaries/data/mods/public/maps/random/mediterranean.js +++ binaries/data/mods/public/maps/random/mediterranean.js @@ -34,21 +34,21 @@ const heightShoreline = heightScale(0.5); const heightSnow = heightScale(10); -var g_Map = new RandomMap(heightWaterLevel, g_Terrains.mainTerrain); -var mapSize = g_Map.getSize(); -var mapCenter = g_Map.getCenter(); -var mapBounds = g_Map.getBounds(); +const g_Map = new RandomMap(heightWaterLevel, g_Terrains.mainTerrain); +const mapSize = g_Map.getSize(); +const mapCenter = g_Map.getCenter(); +const mapBounds = g_Map.getBounds(); g_Map.LoadHeightmapImage("mediterranean.png", 0, 40); Engine.SetProgress(15); initTileClasses(["autumn", "desert", "medit", "polar", "steppe", "temp", "shoreline", "africa", "northern_europe", "southern_europe", "western_europe", "eastern_europe"]); -var northernTopLeft = new Vector2D(fractionToTiles(0.3), fractionToTiles(0.7)); -var westernTopLeft = new Vector2D(fractionToTiles(0.7), fractionToTiles(0.47)); -var africaTop = fractionToTiles(0.33); +const northernTopLeft = new Vector2D(fractionToTiles(0.3), fractionToTiles(0.7)); +const westernTopLeft = new Vector2D(fractionToTiles(0.7), fractionToTiles(0.47)); +const africaTop = fractionToTiles(0.33); -var climateZones = [ +const climateZones = [ { "tileClass": g_TileClasses.northern_europe, "position1": new Vector2D(northernTopLeft.x, mapBounds.top), @@ -114,7 +114,7 @@ Engine.SetProgress(35); g_Map.log("Marking climate zones"); -for (let zone of climateZones) +for (const zone of climateZones) { setBiome(zone.biome); createArea( @@ -133,7 +133,7 @@ Engine.SetProgress(40); g_Map.log("Fuzzing biome borders"); -for (let zone of climateZones) +for (const zone of climateZones) { setBiome(zone.biome); @@ -163,7 +163,7 @@ { g_Map.log("Finding player positions"); - let [playerIDs, playerPosition] = playerPlacementRandom( + const [playerIDs, playerPosition] = playerPlacementRandom( sortAllPlayers(), [ avoidClasses(g_TileClasses.mountain, 5), @@ -185,7 +185,7 @@ } Engine.SetProgress(50); -for (let zone of climateZones) +for (const zone of climateZones) { setBiome(zone.biome); Index: binaries/data/mods/public/maps/random/migration.js =================================================================== --- binaries/data/mods/public/maps/random/migration.js +++ binaries/data/mods/public/maps/random/migration.js @@ -48,26 +48,26 @@ const heightHill = 18; const heightOffsetBump = 2; -var g_Map = new RandomMap(heightSeaGround, tWater); +const g_Map = new RandomMap(heightSeaGround, tWater); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clLand = g_Map.createTileClass(); -var clIsland = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clLand = g_Map.createTileClass(); +const clIsland = g_Map.createTileClass(); -var startAngle = randomAngle(); -var playerIDs = sortAllPlayers(); -var [playerPosition, playerAngle] = playerPlacementCustomAngle( +const startAngle = randomAngle(); +const playerIDs = sortAllPlayers(); +const [playerPosition, playerAngle] = playerPlacementCustomAngle( fractionToTiles(0.35), mapCenter, i => startAngle - Math.PI * (i + 1) / (numPlayers + 1)); @@ -87,7 +87,7 @@ if (isNomad()) continue; - let dockLocation = findLocationInDirectionBasedOnHeight(playerPosition[i], mapCenter, -3 , 2.6, 3); + const dockLocation = findLocationInDirectionBasedOnHeight(playerPosition[i], mapCenter, -3 , 2.6, 3); g_Map.placeEntityPassable(oDock, playerIDs[i], dockLocation, playerAngle[i] + Math.PI); } Engine.SetProgress(10); @@ -128,7 +128,7 @@ Engine.SetProgress(15); g_Map.log("Create the continent body"); -var continentPosition = Vector2D.add(mapCenter, new Vector2D(0, fractionToTiles(0.38)).rotate(-startAngle)).round(); +const continentPosition = Vector2D.add(mapCenter, new Vector2D(0, fractionToTiles(0.38)).rotate(-startAngle)).round(); createArea( new ClumpPlacer(diskArea(fractionToTiles(0.4)), 0.8, 0.08, Infinity, continentPosition), [ @@ -181,17 +181,17 @@ Engine.SetProgress(34); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); -var types = [ +const [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); +const types = [ [[tForestFloor2, tMainTerrain, pForest1], [tForestFloor2, pForest1]], [[tForestFloor1, tMainTerrain, pForest2], [tForestFloor1, pForest2]] ]; -var size = forestTrees / (scaleByMapSize(2,8) * numPlayers) * +const forestSize = forestTrees / (scaleByMapSize(2,8) * numPlayers) * (currentBiome() == "generic/savanna" ? 2 : 1); -var num = Math.floor(size / types.length); -for (let type of types) +const num = Math.floor(forestSize / types.length); +for (const type of types) createAreas( new ClumpPlacer(forestTrees / num, 0.1, 0.1, Infinity), [ @@ -203,7 +203,7 @@ Engine.SetProgress(38); g_Map.log("Creating dirt patches"); -for (let size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) +for (const size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), [ @@ -225,7 +225,7 @@ Engine.SetProgress(42); g_Map.log("Creating grass patches"); -for (let size of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)]) +for (const size of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), new TerrainPainter(tTier4Terrain), @@ -234,7 +234,7 @@ Engine.SetProgress(46); 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, 10, clRock, 10, clHill, 1), stayClasses(clLand, 7)], scaleByMapSize(4,16), 100 @@ -331,7 +331,7 @@ Engine.SetProgress(86); -var planetm = currentBiome() == "generic/india" ? 8 : 1; +const planetm = currentBiome() == "generic/india" ? 8 : 1; g_Map.log("Creating small grass tufts"); group = new SimpleGroup( Index: binaries/data/mods/public/maps/random/neareastern_badlands.js =================================================================== --- binaries/data/mods/public/maps/random/neareastern_badlands.js +++ binaries/data/mods/public/maps/random/neareastern_badlands.js @@ -55,25 +55,25 @@ const heightOffsetHill3 = 16; const heightOffsetBump = 2; -var g_Map = new RandomMap(heightLand, tPrimary); +const g_Map = new RandomMap(heightLand, tPrimary); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clHill1 = g_Map.createTileClass(); -var clOasis = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clPatch = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill1 = g_Map.createTileClass(); +const clOasis = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clPatch = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); -var oasisRadius = scaleByMapSize(14, 40); +const oasisRadius = scaleByMapSize(14, 40); -var [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.35)); +const [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.35)); if (!isNomad()) for (let i = 0; i < numPlayers; ++i) @@ -154,13 +154,13 @@ Engine.SetProgress(30); g_Map.log("Creating oasis wildlife"); -var num = Math.round(Math.PI * oasisRadius / 8); -var constraint = new AndConstraint([borderClasses(clOasis, 0, 3), avoidClasses(clOasis, 0)]); -for (var i = 0; i < num; ++i) +let num = Math.round(Math.PI * oasisRadius / 8); +let constraint = new AndConstraint([borderClasses(clOasis, 0, 3), avoidClasses(clOasis, 0)]); +for (let i = 0; i < num; ++i) { let animalPosition; let r = 0; - let angle = 2 * Math.PI / num * i; + const angle = 2 * Math.PI / num * i; do { // Work outward until constraint met animalPosition = Vector2D.add(mapCenter, new Vector2D(r, 0).rotate(-angle)).round(); @@ -183,11 +183,11 @@ g_Map.log("Creating oasis fish"); constraint = new AndConstraint([borderClasses(clOasis, 15, 0), avoidClasses(clFood, 5)]); num = Math.round(Math.PI * oasisRadius / 16); -for (var i = 0; i < num; ++i) +for (let i = 0; i < num; ++i) { let fishPosition; - var r = 0; - var angle = 2 * Math.PI / num * i; + let r = 0; + const angle = 2 * Math.PI / num * i; do { // Work outward until constraint met fishPosition = Vector2D.add(mapCenter, new Vector2D(r, 0).rotate(-angle)); @@ -199,7 +199,7 @@ Engine.SetProgress(35); g_Map.log("Creating level 1 hills"); -var hillAreas = createAreas( +let hillAreas = createAreas( new ClumpPlacer(scaleByMapSize(50,300), 0.25, 0.1, 0.5), [ new LayeredPainter([tCliff, tSand], [1]), @@ -276,8 +276,8 @@ Engine.SetProgress(65); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(500, 2500, 0.5); -var num = g_DefaultNumberOfForests; +const [forestTrees, stragglerTrees] = getTreeCounts(500, 2500, 0.5); +num = g_DefaultNumberOfForests; createAreas( new ClumpPlacer(forestTrees / num, 0.15, 0.1, 0.5), [ Index: binaries/data/mods/public/maps/random/new_rms_test.js =================================================================== --- binaries/data/mods/public/maps/random/new_rms_test.js +++ binaries/data/mods/public/maps/random/new_rms_test.js @@ -1,7 +1,7 @@ Engine.LoadLibrary("rmgen"); Engine.LoadLibrary("rmgen-common"); -var g_Map = new RandomMap(0, "grass1_spring"); +const g_Map = new RandomMap(0, "grass1_spring"); placePlayerBases({ "PlayerPlacement": playerPlacementCircle(fractionToTiles(0.39)) Index: binaries/data/mods/public/maps/random/ngorongoro.js =================================================================== --- binaries/data/mods/public/maps/random/ngorongoro.js +++ binaries/data/mods/public/maps/random/ngorongoro.js @@ -85,8 +85,8 @@ g_Gaia.secondaryHuntableAnimal = "gaia/fauna_elephant_african_bush"; } -var g_Map = new RandomMap(0, g_Terrains.mainTerrain); -var mapCenter = g_Map.getCenter(); +const g_Map = new RandomMap(0, g_Terrains.mainTerrain); +const mapCenter = g_Map.getCenter(); initTileClasses(["eden", "highlands"]); @@ -135,7 +135,7 @@ if (!isNomad()) { g_Map.log("Placing players"); - let [playerIDs, playerPosition] = createBases( + const [playerIDs, playerPosition] = createBases( ...playerPlacementRandom( sortAllPlayers(), [ @@ -148,7 +148,7 @@ true); g_Map.log("Flatten the initial CC area"); - for (let position of playerPosition) + for (const position of playerPosition) createArea( new ClumpPlacer(diskArea(defaultPlayerBaseRadius() * 0.8), 0.95, 0.6, Infinity, position), new SmoothElevationPainter(ELEVATION_SET, g_Map.getHeight(position), 6)); Index: binaries/data/mods/public/maps/random/northern_lights.js =================================================================== --- binaries/data/mods/public/maps/random/northern_lights.js +++ binaries/data/mods/public/maps/random/northern_lights.js @@ -32,25 +32,25 @@ const heightLand = 3; const heightHill = 25; -var g_Map = new RandomMap(heightLand, tSnowA); +const g_Map = new RandomMap(heightLand, tSnowA); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); const mapBounds = g_Map.getBounds(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clIsland = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clIsland = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); -var startAngle = randomAngle(); +const startAngle = randomAngle(); placePlayerBases({ "PlayerPlacement": [ @@ -97,7 +97,7 @@ g_Map.log("Creating shores"); for (let i = 0; i < scaleByMapSize(20, 120); ++i) { - let position = new Vector2D(fractionToTiles(randFloat(0.1, 0.9)), fractionToTiles(randFloat(0.67, 0.74))).rotateAround(startAngle, mapCenter).round(); + const position = new Vector2D(fractionToTiles(randFloat(0.1, 0.9)), fractionToTiles(randFloat(0.67, 0.74))).rotateAround(startAngle, mapCenter).round(); createArea( new ChainPlacer(1, Math.floor(scaleByMapSize(4, 6)), Math.floor(scaleByMapSize(16, 30)), Infinity, position), [ @@ -150,16 +150,16 @@ ); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(100, 625, 0.7); -var types = [ +const [forestTrees, stragglerTrees] = getTreeCounts(100, 625, 0.7); +const types = [ [[tSnowA, tSnowA, tSnowA, tSnowA, pForestD], [tSnowA, tSnowA, tSnowA, pForestD]], [[tSnowA, tSnowA, tSnowA, tSnowA, pForestS], [tSnowA, tSnowA, tSnowA, pForestS]] ]; -var size = forestTrees / (scaleByMapSize(3,6) * numPlayers); +const forestSize = forestTrees / (scaleByMapSize(3,6) * numPlayers); -var num = Math.floor(size / types.length); -for (let type of types) +const num = Math.floor(forestSize / types.length); +for (const type of types) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), forestTrees / (num * Math.floor(scaleByMapSize(2, 4))), Infinity), [ @@ -179,7 +179,7 @@ Engine.SetProgress(70); g_Map.log("Creating dirt patches"); -for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) +for (const size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5), [ @@ -194,7 +194,7 @@ clDirt, 16), scaleByMapSize(20, 80)); -for (let size of [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)]) +for (const size of [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5), [ @@ -210,7 +210,7 @@ scaleByMapSize(20, 80)); 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(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1), scaleByMapSize(8,32), 100 Index: binaries/data/mods/public/maps/random/oasis.js =================================================================== --- binaries/data/mods/public/maps/random/oasis.js +++ binaries/data/mods/public/maps/random/oasis.js @@ -43,30 +43,30 @@ const heightOffsetBump = 4; const heightOffsetDune = 18; -var g_Map = new RandomMap(heightLand, tSand); +const g_Map = new RandomMap(heightLand, tSand); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clOasis = g_Map.createTileClass(); -var clPassage = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clOasis = g_Map.createTileClass(); +const clPassage = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); -var waterRadius = scaleByMapSize(7, 50); -var shoreDistance = scaleByMapSize(4, 10); -var forestDistance = scaleByMapSize(6, 20); +const waterRadius = scaleByMapSize(7, 50); +const shoreDistance = scaleByMapSize(4, 10); +const forestDistance = scaleByMapSize(6, 20); -var [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.35)); +const [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.35)); g_Map.log("Creating small oasis near the players..."); -var forestDist = 1.2 * defaultPlayerBaseRadius(); +const forestDist = 1.2 * defaultPlayerBaseRadius(); for (let i = 0; i < numPlayers; ++i) { let forestPosition; @@ -87,7 +87,7 @@ let flowerPosition; let reedsPosition; do { - let waterAngle = forestAngle + randFloat(1, 5) / 3 * Math.PI; + const waterAngle = forestAngle + randFloat(1, 5) / 3 * Math.PI; waterPosition = Vector2D.add(forestPosition, new Vector2D(6, 0).rotate(-waterAngle)).round(); flowerPosition = Vector2D.add(forestPosition, new Vector2D(3, 0).rotate(-waterAngle)).round(); reedsPosition = Vector2D.add(forestPosition, new Vector2D(5, 0).rotate(-waterAngle)).round(); @@ -175,8 +175,8 @@ if (mapSize > 150 && randBool()) { g_Map.log("Creating path though the oasis"); - let pathWidth = scaleByMapSize(7, 18); - let points = distributePointsOnCircle(2, randomAngle(), waterRadius + shoreDistance + forestDistance + pathWidth, mapCenter)[0]; + const pathWidth = scaleByMapSize(7, 18); + const points = distributePointsOnCircle(2, randomAngle(), waterRadius + shoreDistance + forestDistance + pathWidth, mapCenter)[0]; createArea( new PathPlacer(points[0], points[1], pathWidth, 0.4, 1, 0.2, 0), [ @@ -186,7 +186,7 @@ ]); } g_Map.log("Creating some straggler trees around the passage"); -var group = new SimpleGroup([new SimpleObject(ePalmTall, 1,1, 0,0),new SimpleObject(ePalmShort, 1, 2, 1, 2), new SimpleObject(aBushA, 0,2, 1,3)], true, clForest); +let group = new SimpleGroup([new SimpleObject(ePalmTall, 1,1, 0,0),new SimpleObject(ePalmShort, 1, 2, 1, 2), new SimpleObject(aBushA, 0,2, 1,3)], true, clForest); createObjectGroupsDeprecated(group, 0, stayClasses(clPassage, 3), scaleByMapSize(60, 250), 100); g_Map.log("Creating stone mines"); @@ -237,7 +237,7 @@ g_Map.log("Creating oasis animals"); for (let i = 0; i < scaleByMapSize(5, 30); ++i) { - let animalPos = Vector2D.add(mapCenter, new Vector2D(forestDistance + shoreDistance + waterRadius, 0).rotate(randomAngle())); + const animalPos = Vector2D.add(mapCenter, new Vector2D(forestDistance + shoreDistance + waterRadius, 0).rotate(randomAngle())); createObjectGroup( new RandomGroup( @@ -255,7 +255,7 @@ Engine.SetProgress(90); g_Map.log("Creating bushes"); -var group = new SimpleGroup( +group = new SimpleGroup( [new SimpleObject(aBushB, 1,2, 0,2), new SimpleObject(aBushA, 2,4, 0,2)] ); createObjectGroupsDeprecated(group, 0, @@ -263,17 +263,17 @@ scaleByMapSize(10, 40), 20 ); -var objectsWaterFlora = [ +const objectsWaterFlora = [ new SimpleObject(aReedsA, 5, 12, 0, 2), new SimpleObject(aReedsB, 5, 12, 0, 2) ]; g_Map.log("Creating sand blows and beautifications"); -for (var sandx = 0; sandx < mapSize; sandx += 4) - for (var sandz = 0; sandz < mapSize; sandz += 4) +for (let sandx = 0; sandx < mapSize; sandx += 4) + for (let sandz = 0; sandz < mapSize; sandz += 4) { - let position = new Vector2D(sandx, sandz); - let height = g_Map.getHeight(position); + const position = new Vector2D(sandx, sandz); + const height = g_Map.getHeight(position); if (height > heightSand) { Index: binaries/data/mods/public/maps/random/persian_highlands.js =================================================================== --- binaries/data/mods/public/maps/random/persian_highlands.js +++ binaries/data/mods/public/maps/random/persian_highlands.js @@ -39,21 +39,21 @@ const heightLand = 10; const heightOffsetValley = -10; -var g_Map = new RandomMap(heightLand, tDirtMain); +const g_Map = new RandomMap(heightLand, tDirtMain); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clPatch = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clCP = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clPatch = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clCP = g_Map.createTileClass(); placePlayerBases({ "PlayerPlacement": playerPlacementCircle(fractionToTiles(0.35)), @@ -156,19 +156,19 @@ Engine.SetProgress(35); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(500, 2500, 0.7); -var types = [ +const [forestTrees, stragglerTrees] = getTreeCounts(500, 2500, 0.7); +const types = [ [[tDirtMain, tForestFloor, pForestO], [tForestFloor, pForestO]], [[tDirtMain, tForestFloor, pForestO], [tForestFloor, pForestO]] ]; -var size = forestTrees / (scaleByMapSize(3,6) * numPlayers); -var num = Math.floor(size / types.length); -for (let type of types) +const forestSize = forestTrees / (scaleByMapSize(3,6) * numPlayers); +const num = Math.floor(forestSize / types.length); +for (const type of types) createAreas( new ChainPlacer( Math.floor(scaleByMapSize(1, 2)), Math.floor(scaleByMapSize(2, 5)), - Math.floor(size / Math.floor(scaleByMapSize(8, 3))), + Math.floor(forestSize / Math.floor(scaleByMapSize(8, 3))), Infinity), [ new LayeredPainter(type, [2]), @@ -229,7 +229,7 @@ 50); g_Map.log("Creating small stone quarries"); -var group = new SimpleGroup([new SimpleObject(oStoneSmall, 2, 5, 1, 3), new RandomObject(aBushes, 2, 4, 0, 2)], true, clRock); +let group = new SimpleGroup([new SimpleObject(oStoneSmall, 2, 5, 1, 3), new RandomObject(aBushes, 2, 4, 0, 2)], true, clRock); createObjectGroupsDeprecated(group, 0, stayClasses(clCP, 6), 5*scaleByMapSize(5,30), 50 Index: binaries/data/mods/public/maps/random/phoenician_levant.js =================================================================== --- binaries/data/mods/public/maps/random/phoenician_levant.js +++ binaries/data/mods/public/maps/random/phoenician_levant.js @@ -47,26 +47,26 @@ const heightHill = 15; const heightOffsetBump = 2; -var g_Map = new RandomMap(heightLand, tHill); +const g_Map = new RandomMap(heightLand, tHill); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); const mapBounds = g_Map.getBounds(); -var clPlayer = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clGrass = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clIsland = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clGrass = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clIsland = g_Map.createTileClass(); -var startAngle = randIntInclusive(0, 3) * Math.PI / 2; +const startAngle = randIntInclusive(0, 3) * Math.PI / 2; placePlayerBases({ "PlayerPlacement": [ @@ -138,8 +138,8 @@ scaleByMapSize(1, 4) * numPlayers * 3); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(500, 2500, 0.5); -var num = scaleByMapSize(10,42); +const [forestTrees, stragglerTrees] = getTreeCounts(500, 2500, 0.5); +const num = scaleByMapSize(10,42); createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), forestTrees / (num * Math.floor(scaleByMapSize(2, 5))), 0.5), [ @@ -152,7 +152,7 @@ Engine.SetProgress(50); g_Map.log("Creating grass patches"); -for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) +for (const size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5), [ @@ -166,7 +166,7 @@ Engine.SetProgress(55); g_Map.log("Creating dirt patches"); -for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) +for (const size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5), [ @@ -193,12 +193,12 @@ 100); g_Map.log("Creating cyprus mines"); -var mines = [ +const mines = [ 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), new SimpleGroup([new SimpleObject(oMetalLarge, 1, 1, 0, 4)], true, clMetal), new SimpleGroup([new SimpleObject(oStoneSmall, 2, 5, 1, 3)], true, clRock) ]; -for (let mine of mines) +for (const mine of mines) createObjectGroups( mine, 0, @@ -209,7 +209,7 @@ scaleByMapSize(4, 16)); 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, clWater, 3, clHill, 1), scaleByMapSize(4,16), 100 @@ -293,12 +293,12 @@ ); Engine.SetProgress(90); -var stragglerTreeConfig = [ +const stragglerTreeConfig = [ [1, avoidClasses(clForest, 0, clWater, 4, clPlayer, 8, clMetal, 6, clHill, 1)], [3, [stayClasses(clIsland, 9), avoidClasses(clRock, 4, clMetal, 4)]] ]; -for (let [amount, constraint] of stragglerTreeConfig) +for (const [amount, constraint] of stragglerTreeConfig) createStragglerTrees( [oDatePalm, oSDatePalm, oCarob, oFanPalm, oPoplar, oCypress], constraint, Index: binaries/data/mods/public/maps/random/polar_sea.js =================================================================== --- binaries/data/mods/public/maps/random/polar_sea.js +++ binaries/data/mods/public/maps/random/polar_sea.js @@ -1,51 +1,51 @@ Engine.LoadLibrary("rmgen"); Engine.LoadLibrary("rmgen-common"); -var tPrimary = ["alpine_snow_01"]; -var tSecondary = "alpine_snow_02"; -var tShore = "alpine_ice_01"; -var tWater = "alpine_ice_01"; +const tPrimary = ["alpine_snow_01"]; +const tSecondary = "alpine_snow_02"; +const tShore = "alpine_ice_01"; +const tWater = "alpine_ice_01"; -var oArcticFox = "gaia/fauna_fox_arctic"; -var oArcticWolf = "gaia/fauna_wolf_arctic_violent"; -var oMuskox = "gaia/fauna_muskox"; -var oWalrus = "gaia/fauna_walrus"; -var oWhaleFin = "gaia/fauna_whale_fin"; -var oWhaleHumpback = "gaia/fauna_whale_humpback"; -var oFish = "gaia/fish/generic"; -var oStoneLarge = "gaia/rock/polar_01"; -var oStoneSmall = "gaia/rock/alpine_small"; -var oMetalLarge = "gaia/ore/polar_01"; -var oWoodTreasure = "gaia/treasure/wood"; -var oMarket = "skirmish/structures/default_market"; +const oArcticFox = "gaia/fauna_fox_arctic"; +const oArcticWolf = "gaia/fauna_wolf_arctic_violent"; +const oMuskox = "gaia/fauna_muskox"; +const oWalrus = "gaia/fauna_walrus"; +const oWhaleFin = "gaia/fauna_whale_fin"; +const oWhaleHumpback = "gaia/fauna_whale_humpback"; +const oFish = "gaia/fish/generic"; +const oStoneLarge = "gaia/rock/polar_01"; +const oStoneSmall = "gaia/rock/alpine_small"; +const oMetalLarge = "gaia/ore/polar_01"; +const oWoodTreasure = "gaia/treasure/wood"; +const oMarket = "skirmish/structures/default_market"; -var aRockLarge = "actor|geology/stone_granite_med.xml"; -var aRockMedium = "actor|geology/stone_granite_med.xml"; -var aIceberg = "actor|props/special/eyecandy/iceberg.xml"; +const aRockLarge = "actor|geology/stone_granite_med.xml"; +const aRockMedium = "actor|geology/stone_granite_med.xml"; +const aIceberg = "actor|props/special/eyecandy/iceberg.xml"; -var heightSeaGround = -10; -var heightLand = 2; -var heightCliff = 3; +const heightSeaGround = -10; +const heightLand = 2; +const heightCliff = 3; -var g_Map = new RandomMap(heightLand, tPrimary); +const g_Map = new RandomMap(heightLand, tPrimary); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clArcticWolf = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clArcticWolf = g_Map.createTileClass(); -var [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.35)); +const [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.35)); -var treasures = [{ +const treasures = [{ "template": oWoodTreasure, "count": isNomad() ? 16 : 14 }]; @@ -54,7 +54,7 @@ if (!isNomad()) for (let i = 0; i < numPlayers; ++i) { - let marketPos = Vector2D.add(playerPosition[i], new Vector2D(12, 0).rotate(randomAngle())).round(); + const marketPos = Vector2D.add(playerPosition[i], new Vector2D(12, 0).rotate(randomAngle())).round(); g_Map.placeEntityPassable(oMarket, playerIDs[i], marketPos, BUILDING_ORIENTATION); addCivicCenterAreaToClass(marketPos, clBaseResource); } @@ -242,7 +242,7 @@ if (isNomad()) { - let constraint = avoidClasses(clWater, 4, clMetal, 4, clRock, 4, clHill, 4, clFood, 2); + const constraint = avoidClasses(clWater, 4, clMetal, 4, clRock, 4, clHill, 4, clFood, 2); [playerIDs, playerPosition] = placePlayersNomad(clPlayer, constraint); for (let i = 0; i < numPlayers; ++i) Index: binaries/data/mods/public/maps/random/pompeii.js =================================================================== --- binaries/data/mods/public/maps/random/pompeii.js +++ binaries/data/mods/public/maps/random/pompeii.js @@ -88,8 +88,8 @@ const heightLavaVesuv = heightScale(38); const heightMountains = 140; -var g_Map = new RandomMap(0, g_Terrains.mainTerrain); -var mapCenter = g_Map.getCenter(); +const g_Map = new RandomMap(0, g_Terrains.mainTerrain); +const mapCenter = g_Map.getCenter(); initTileClasses(["decorative", "lava", "dock"]); @@ -137,7 +137,7 @@ Engine.SetProgress(45); g_Map.log("Painting lava"); -var areaVesuv = createArea( +const areaVesuv = createArea( new RectPlacer(new Vector2D(mapCenter.x, fractionToTiles(0.3)), new Vector2D(fractionToTiles(0.7), fractionToTiles(0.15))), [ new LayeredPainter([g_Terrains.lavaOuter,g_Terrains.lavaInner, g_Terrains.lavaCenter], [scaleByMapSize(1, 3), 2]), @@ -164,7 +164,7 @@ if (!isNomad()) { g_Map.log("Placing players"); - let [playerIDs, playerPosition] = createBases( + const [playerIDs, playerPosition] = createBases( ...playerPlacementRandom( sortAllPlayers(), [ @@ -174,7 +174,7 @@ false); g_Map.log("Flatten the initial CC area"); - for (let position of playerPosition) + for (const position of playerPosition) createArea( new ClumpPlacer(diskArea(defaultPlayerBaseRadius() * 0.8), 0.95, 0.6, Infinity, position), new SmoothElevationPainter(ELEVATION_SET, g_Map.getHeight(position), 6)); @@ -182,11 +182,11 @@ Engine.SetProgress(50); g_Map.log("Placing docks"); -var dockTypes = [ +const dockTypes = [ { "template": g_Gaia.dock, "count": scaleByMapSize(1, 2) }, { "template": g_Gaia.dockRubble, "count": scaleByMapSize(2, 3) } ]; -for (let dockType of dockTypes) +for (const dockType of dockTypes) placeDocks( dockType.template, 0, Index: binaries/data/mods/public/maps/random/pyrenean_sierra.js =================================================================== --- binaries/data/mods/public/maps/random/pyrenean_sierra.js +++ binaries/data/mods/public/maps/random/pyrenean_sierra.js @@ -73,36 +73,36 @@ const heightOffsetHill = 7; const heightOffsetHillRandom = 2; -var g_Map = new RandomMap(heightInit, tGrass); +const g_Map = new RandomMap(heightInit, tGrass); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clPass = g_Map.createTileClass(); -var clPyrenneans = g_Map.createTileClass(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clPass = g_Map.createTileClass(); +const clPyrenneans = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); -var startAngle = randomAngle(); -var oceanAngle = startAngle + randFloat(-1, 1) * Math.PI / 12; +const startAngle = randomAngle(); +const oceanAngle = startAngle + randFloat(-1, 1) * Math.PI / 12; -var mountainLength = fractionToTiles(0.68); -var mountainWidth = scaleByMapSize(15, 55); +const mountainLength = fractionToTiles(0.68); +const mountainWidth = scaleByMapSize(15, 55); -var mountainPeaks = 100 * scaleByMapSize(1, 10); -var mountainOffset = randFloat(-1, 1) * scaleByMapSize(1, 12); +const mountainPeaks = 100 * scaleByMapSize(1, 10); +const mountainOffset = randFloat(-1, 1) * scaleByMapSize(1, 12); -var passageLength = scaleByMapSize(8, 50); +const passageLength = scaleByMapSize(8, 50); -var terrainPerHeight = [ +const terrainPerHeight = [ { "maxHeight": heightGrass, "steepness": 5, @@ -142,16 +142,16 @@ ]; g_Map.log("Creating initial sinusoidal noise"); -var baseHeights = []; -for (var ix = 0; ix < mapSize; ix++) +let baseHeights = []; +for (let ix = 0; ix < mapSize; ix++) { baseHeights.push([]); - for (var iz = 0; iz < mapSize; iz++) + for (let iz = 0; iz < mapSize; iz++) { - let position = new Vector2D(ix, iz); + const position = new Vector2D(ix, iz); if (g_Map.inMapBounds(position)) { - let height = heightBase + randFloat(-1, 1) + scaleByMapSize(1, 3) * (Math.cos(ix / scaleByMapSize(5, 30)) + Math.sin(iz / scaleByMapSize(5, 30))); + const height = heightBase + randFloat(-1, 1) + scaleByMapSize(1, 3) * (Math.cos(ix / scaleByMapSize(5, 30)) + Math.sin(iz / scaleByMapSize(5, 30))); g_Map.setHeight(position, height); baseHeights[ix].push(height); } @@ -160,8 +160,8 @@ } } -var playerIDs = sortAllPlayers(); -var playerPosition = playerPlacementArcs( +const playerIDs = sortAllPlayers(); +const playerPosition = playerPlacementArcs( playerIDs, mapCenter, fractionToTiles(0.35), @@ -198,9 +198,9 @@ Engine.SetProgress(30); g_Map.log("Creating the pyreneans"); -var mountainVec = new Vector2D(mountainLength, 0).rotate(-startAngle); -var mountainStart = Vector2D.sub(mapCenter, Vector2D.div(mountainVec, 2)); -var mountainDirection = mountainVec.clone().normalize(); +const mountainVec = new Vector2D(mountainLength, 0).rotate(-startAngle); +const mountainStart = Vector2D.sub(mapCenter, Vector2D.div(mountainVec, 2)); +const mountainDirection = mountainVec.clone().normalize(); createPyreneans(); paintTileClassBasedOnHeight(heightPyreneans, Infinity, Elevation_ExcludeMin_ExcludeMax, clPyrenneans); Engine.SetProgress(40); @@ -222,23 +222,23 @@ { for (let peak = 0; peak < mountainPeaks; ++peak) { - let peakPosition = peak / mountainPeaks; - let peakHeight = randFloat(0, 10); + const peakPosition = peak / mountainPeaks; + const peakHeight = randFloat(0, 10); for (let distance = 0; distance < mountainWidth; distance += 1/3) { - let rest = 2 * (1 - distance / mountainWidth); + const rest = 2 * (1 - distance / mountainWidth); - let sigmoidX = + const sigmoidX = - 1 * (rest - 1.9) + - 4 * (rest - randFloat(0.9, 1.1)) * (rest - randFloat(0.9, 1.1)) * (rest - randFloat(0.9, 1.1)); - for (let direction of [-1, 1]) + for (const direction of [-1, 1]) { - let pos = Vector2D.sum([ + const pos = Vector2D.sum([ Vector2D.add(mountainStart, Vector2D.mult(mountainDirection, peakPosition * mountainLength)), new Vector2D(mountainOffset, 0).rotate(-peakPosition * Math.PI * 4), new Vector2D(distance, 0).rotate(-startAngle - direction * Math.PI / 2) @@ -251,14 +251,14 @@ } g_Map.log("Creating passages"); -var passageLocation = 0.35; -var passageVec = mountainDirection.perpendicular().mult(passageLength); +const passageLocation = 0.35; +const passageVec = mountainDirection.perpendicular().mult(passageLength); -for (let passLoc of [passageLocation, 1 - passageLocation]) - for (let direction of [1, -1]) +for (const passLoc of [passageLocation, 1 - passageLocation]) + for (const direction of [1, -1]) { - let passageStart = Vector2D.add(mountainStart, Vector2D.mult(mountainVec, passLoc)); - let passageEnd = Vector2D.add(passageStart, Vector2D.mult(passageVec, direction)); + const passageStart = Vector2D.add(mountainStart, Vector2D.mult(mountainVec, passLoc)); + const passageEnd = Vector2D.add(passageStart, Vector2D.mult(passageVec, direction)); createPassage({ "start": passageStart, @@ -279,7 +279,7 @@ new NearTileClassConstraint(clPyrenneans, 1)); g_Map.log("Creating oceans"); -for (let ocean of distributePointsOnCircle(2, oceanAngle, fractionToTiles(0.48), mapCenter)[0]) +for (const ocean of distributePointsOnCircle(2, oceanAngle, fractionToTiles(0.48), mapCenter)[0]) createArea( new ClumpPlacer(diskArea(fractionToTiles(0.18)), 0.9, 0.05, Infinity, ocean), [ @@ -305,12 +305,12 @@ avoidClasses(clWater, 5, clPlayer, 20, clBaseResource, 6, clPyrenneans, 2), scaleByMapSize(5, 35)); g_Map.log("Creating forests"); -var types = [[tForestTransition, pForestLandVeryLight, pForestLandLight, pForestLand]]; -var size = scaleByMapSize(40, 115) * Math.PI; -var num = Math.floor(scaleByMapSize(8,40) / types.length); -for (let type of types) +const types = [[tForestTransition, pForestLandVeryLight, pForestLandLight, pForestLand]]; +const forestSize = scaleByMapSize(40, 115) * Math.PI; +let num = Math.floor(scaleByMapSize(8,40) / types.length); +for (const type of types) createAreas( - new ClumpPlacer(size, 0.2, 0.1, Infinity), + new ClumpPlacer(forestSize, 0.2, 0.1, Infinity), [ new LayeredPainter(type, [scaleByMapSize(1, 2), scaleByMapSize(3, 6), scaleByMapSize(3, 6)]), new TileClassPainter(clForest) @@ -320,14 +320,14 @@ Engine.SetProgress(60); g_Map.log("Creating lone trees"); -var num = scaleByMapSize(80,400); +num = scaleByMapSize(80,400); -var group = new SimpleGroup([new SimpleObject(oPine, 1,2, 1,3),new SimpleObject(oBeech, 1,2, 1,3)], true, clForest); +let group = new SimpleGroup([new SimpleObject(oPine, 1,2, 1,3),new SimpleObject(oBeech, 1,2, 1,3)], true, clForest); createObjectGroupsDeprecated(group, 0, avoidClasses(clWater, 3, clForest, 1, clPlayer, 8,clPyrenneans, 1), num, 20 ); g_Map.log("Painting terrain by height and slope"); for (let i = 0; i < terrainPerHeight.length; ++i) - for (let steep of [false, true]) + for (const steep of [false, true]) createArea( new MapBoundsPlacer(), new TerrainPainter(steep ? terrainPerHeight[i].terrainSteep : terrainPerHeight[i].terrainGround), @@ -342,11 +342,11 @@ for (let x = 0; x < mapSize; ++x) for (let z = 0; z < mapSize; ++z) { - let position = new Vector2D(x, z); - let height = g_Map.getHeight(position); - let heightDiff = g_Map.getSlope(position); + const position = new Vector2D(x, z); + const height = g_Map.getHeight(position); + const heightDiff = g_Map.getSlope(position); - let terrainShore = getShoreTerrain(position, height, heightDiff); + const terrainShore = getShoreTerrain(position, height, heightDiff); if (terrainShore) createTerrain(terrainShore).place(position); } @@ -367,7 +367,7 @@ } g_Map.log("Creating dirt patches"); -for (let size of [scaleByMapSize(3, 20), scaleByMapSize(5, 40), scaleByMapSize(8, 60)]) +for (const size of [scaleByMapSize(3, 20), scaleByMapSize(5, 40), scaleByMapSize(8, 60)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), [ @@ -378,7 +378,7 @@ scaleByMapSize(15, 45)); g_Map.log("Creating grass patches"); -for (let size of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)]) +for (const size of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), new TerrainPainter(tLushGrass), @@ -389,7 +389,7 @@ // making more in dirt areas so as to appear different g_Map.log("Creating small grass tufts"); -var group = new SimpleGroup( [new SimpleObject(aGrassShort, 1,2, 0,1, -Math.PI / 8, Math.PI / 8)] ); +group = new SimpleGroup( [new SimpleObject(aGrassShort, 1,2, 0,1, -Math.PI / 8, Math.PI / 8)] ); createObjectGroupsDeprecated(group, 0, avoidClasses(clWater, 2, clHill, 2, clPlayer, 5, clDirt, 0, clPyrenneans,2), scaleByMapSize(13, 200) ); createObjectGroupsDeprecated(group, 0, stayClasses(clDirt,1), scaleByMapSize(13, 200),10); Index: binaries/data/mods/public/maps/random/ratumacos.js =================================================================== --- binaries/data/mods/public/maps/random/ratumacos.js +++ binaries/data/mods/public/maps/random/ratumacos.js @@ -77,7 +77,7 @@ g_Map.log("Creating shallows"); for (let i = 0; i < scaleByMapSize(5, 12); ++i) { - let x = fractionToTiles(randFloat(0, 1)); + const x = fractionToTiles(randFloat(0, 1)); createPassage({ "start": new Vector2D(x, mapBounds.bottom).rotateAround(riverAngle + Math.PI / 2 * randFloat(0.8, 1.2), mapCenter), "end": new Vector2D(x, mapBounds.top).rotateAround(riverAngle + Math.PI / 2 * randFloat(0.8, 1.2), mapCenter), Index: binaries/data/mods/public/maps/random/red_sea.js =================================================================== --- binaries/data/mods/public/maps/random/red_sea.js +++ binaries/data/mods/public/maps/random/red_sea.js @@ -59,8 +59,8 @@ const heightShoreline = heightScale(0.5); const heightHills = heightScale(16); -var g_Map = new RandomMap(0, g_Terrains.mainTerrain); -var mapCenter = g_Map.getCenter(); +const g_Map = new RandomMap(0, g_Terrains.mainTerrain); +const mapCenter = g_Map.getCenter(); initTileClasses(["shoreline"]); @@ -120,7 +120,7 @@ if (!isNomad()) { g_Map.log("Placing players"); - let [playerIDs, playerPosition] = createBases( + const [playerIDs, playerPosition] = createBases( ...playerPlacementRandom( sortAllPlayers(), [ @@ -130,7 +130,7 @@ true); g_Map.log("Flatten the initial CC area"); - for (let position of playerPosition) + for (const position of playerPosition) createArea( new ClumpPlacer(diskArea(defaultPlayerBaseRadius() * 0.8), 0.95, 0.6, Infinity, position), new SmoothElevationPainter(ELEVATION_SET, g_Map.getHeight(position), 6)); @@ -294,7 +294,7 @@ Engine.SetProgress(80); g_Map.log("Painting dirt patches"); -var dirtPatches = [ +const dirtPatches = [ { "sizes": [2, 4], "count": scaleByMapSize(2, 5), @@ -306,7 +306,7 @@ "terrain": g_Terrains.additionalDirt2 } ]; -for (let dirtPatch of dirtPatches) +for (const dirtPatch of dirtPatches) createPatches( dirtPatch.sizes, dirtPatch.terrain, Index: binaries/data/mods/public/maps/random/rhine_marshlands.js =================================================================== --- binaries/data/mods/public/maps/random/rhine_marshlands.js +++ binaries/data/mods/public/maps/random/rhine_marshlands.js @@ -40,18 +40,18 @@ const heightOffsetBumpWater = 1; const heightOffsetBumpLand = 2; -var g_Map = new RandomMap(heightLand, tGrass); +const g_Map = new RandomMap(heightLand, tGrass); const numPlayers = getNumPlayers(); -var clPlayer = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); placePlayerBases({ "PlayerPlacement": playerPlacementCircle(fractionToTiles(0.35)), @@ -116,14 +116,14 @@ scaleByMapSize(50, 100)); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(500, 2500, 0.7); -var types = [ +const [forestTrees, stragglerTrees] = getTreeCounts(500, 2500, 0.7); +const types = [ [[tForestFloor, tGrass, pForestD], [tForestFloor, pForestD]], [[tForestFloor, tGrass, pForestP], [tForestFloor, pForestP]] ]; -var size = forestTrees / (scaleByMapSize(3,6) * numPlayers); -var num = Math.floor(size / types.length); -for (let type of types) +const forestSize = forestTrees / (scaleByMapSize(3,6) * numPlayers); +const num = Math.floor(forestSize / types.length); +for (const type of types) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), forestTrees / (num * Math.floor(scaleByMapSize(2, 4))), Infinity), [ @@ -135,7 +135,7 @@ Engine.SetProgress(50); g_Map.log("Creating mud patches"); -for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) +for (const size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, Infinity), [ @@ -146,7 +146,7 @@ scaleByMapSize(15, 45)); 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(clWater, 0, clForest, 1, clPlayer, 20, clRock, 10)], scaleByMapSize(4,16), 100 Index: binaries/data/mods/public/maps/random/river_archipelago.js =================================================================== --- binaries/data/mods/public/maps/random/river_archipelago.js +++ binaries/data/mods/public/maps/random/river_archipelago.js @@ -47,49 +47,49 @@ const heightLand = 3; const heightHill = 25; -var g_Map = new RandomMap(heightSeaGround, tGrass); +const g_Map = new RandomMap(heightSeaGround, tGrass); const numPlayers = getNumPlayers(); const mapCenter = g_Map.getCenter(); const mapBounds = g_Map.getBounds(); -var clPlayer = g_Map.createTileClass(); -var clPlayerTerritory = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clGaia = g_Map.createTileClass(); -var clStrip = []; +const clPlayer = g_Map.createTileClass(); +const clPlayerTerritory = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clGaia = g_Map.createTileClass(); +const clStrip = []; -var startAngle = randomAngle(); -var connectPlayers = randBool(); +const startAngle = randomAngle(); +const connectPlayers = randBool(); // Map layout -var stripWidthsLeft = connectPlayers ? +const stripWidthsLeft = connectPlayers ? [[0.03, 0.09], [0.14, 0.25], [0.36, 0.46]] : [[0, 0.06], [0.12, 0.23], [0.33, 0.43]]; // Mirror -var stripWidthsRight = clone(stripWidthsLeft); +let stripWidthsRight = clone(stripWidthsLeft); stripWidthsRight.reverse(); stripWidthsRight = stripWidthsRight.map(strip => [1 - strip[1], 1 - strip[0]]); -var stripWidths = stripWidthsLeft.concat(stripWidthsRight); +const stripWidths = stripWidthsLeft.concat(stripWidthsRight); g_Map.log("Creating strips"); for (let i = 0; i < stripWidths.length; ++i) { clStrip[i] = g_Map.createTileClass(); - let isPlayerStrip = i == 2 || i == 3; + const isPlayerStrip = i == 2 || i == 3; for (let j = 0; j < scaleByMapSize(20, 100); ++j) { - let position = new Vector2D( + const position = new Vector2D( randFloat(mapBounds.bottom, mapBounds.top), fractionToTiles(randFloat(...stripWidths[i]))).rotateAround(startAngle, mapCenter).round(); @@ -109,13 +109,13 @@ } Engine.SetProgress(20); -var playerPosition = playerPlacementLine(startAngle, mapCenter, fractionToTiles(1 - stripWidthsLeft[2][0] - stripWidthsLeft[2][1])); +const playerPosition = playerPlacementLine(startAngle, mapCenter, fractionToTiles(1 - stripWidthsLeft[2][0] - stripWidthsLeft[2][1])); // Either left vs right or top vs bottom -var playerIDs = randBool() ? sortAllPlayers() : primeSortAllPlayers(); +const playerIDs = randBool() ? sortAllPlayers() : primeSortAllPlayers(); g_Map.log("Ensuring player territory"); -var playerRadius = scaleByMapSize(12, 20); +const playerRadius = scaleByMapSize(12, 20); for (let i = 0; i < numPlayers; ++i) createArea( new ChainPlacer(1, 6, 40, 1, playerPosition[i], 0, [Math.floor(playerRadius)]), @@ -156,7 +156,7 @@ }); Engine.SetProgress(35); -var areaWater = createArea( +const areaWater = createArea( new HeightPlacer(Elevation_IncludeMin_ExcludeMax, -Infinity, heightWaterLevel), [ new TerrainPainter(tWater), @@ -222,15 +222,15 @@ Engine.SetProgress(50); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(1000, 4000, 0.7); -var types = [ +const [forestTrees, stragglerTrees] = getTreeCounts(1000, 4000, 0.7); +const types = [ [[tGrass, tGrass, tGrass, tGrass, pForestD], [tGrass, tGrass, tGrass, pForestD]], [[tGrass, tGrass, tGrass, tGrass, pForestP1], [tGrass, tGrass, tGrass, pForestP1]], [[tGrass, tGrass, tGrass, tGrass, pForestP2], [tGrass, tGrass, tGrass, pForestP2]] ]; -var size = forestTrees / (scaleByMapSize(3, 6) * numPlayers); -var num = Math.floor(size / types.length); -for (let type of types) +const forestSize = forestTrees / (scaleByMapSize(3, 6) * numPlayers); +const num = Math.floor(forestSize / types.length); +for (const type of types) createAreas( new ChainPlacer( 1, @@ -266,7 +266,7 @@ Engine.SetProgress(60); g_Map.log("Creating grass patches"); -for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) +for (const size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5), [ @@ -283,7 +283,7 @@ scaleByMapSize(20, 80)); g_Map.log("Creating dirt patches"); -for (let size of [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)]) +for (const size of [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5), [ Index: binaries/data/mods/public/maps/random/rivers.js =================================================================== --- binaries/data/mods/public/maps/random/rivers.js +++ binaries/data/mods/public/maps/random/rivers.js @@ -15,8 +15,8 @@ const tRoad = g_Terrains.road; const tRoadWild = g_Terrains.roadWild; const tTier4Terrain = g_Terrains.tier4Terrain; -var tShore = g_Terrains.shore; -var tWater = g_Terrains.water; +let tShore = g_Terrains.shore; +let tWater = g_Terrains.water; if (currentBiome() == "generic/india") { tShore = "tropic_dirt_b_plants"; @@ -52,24 +52,24 @@ const heightShallows = -1; const heightLand = 1; -var g_Map = new RandomMap(heightLand, tMainTerrain); +const g_Map = new RandomMap(heightLand, tMainTerrain); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clShallow = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clShallow = 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], @@ -109,15 +109,15 @@ ]); g_Map.log("Creating rivers between opponents"); -let numRivers = isNomad() ? randIntInclusive(4, 8) : numPlayers; -let rivers = distributePointsOnCircle(numRivers, startAngle + Math.PI / numRivers, fractionToTiles(0.5), mapCenter)[0]; +const numRivers = isNomad() ? randIntInclusive(4, 8) : numPlayers; +const rivers = distributePointsOnCircle(numRivers, startAngle + Math.PI / numRivers, fractionToTiles(0.5), mapCenter)[0]; for (let i = 0; i < numRivers; ++i) { if (isNomad() ? randBool() : areAllies(playerIDs[i], playerIDs[(i + 1) % numPlayers])) continue; - let shallowLocation = randFloat(0.2, 0.7); - let shallowWidth = randFloat(0.12, 0.21); + const shallowLocation = randFloat(0.2, 0.7); + const shallowWidth = randFloat(0.12, 0.21); paintRiver({ "parallel": true, @@ -135,11 +135,11 @@ clWater.add(position); - let isShallow = height < heightShallows && + const isShallow = height < heightShallows && riverFraction > shallowLocation && riverFraction < shallowLocation + shallowWidth; - let newHeight = isShallow ? heightShallows : Math.max(height, heightSeaGround); + const newHeight = isShallow ? heightShallows : Math.max(height, heightSeaGround); if (g_Map.getHeight(position) < newHeight) return; @@ -161,7 +161,7 @@ else createMountains(tCliff, avoidClasses(clPlayer, 20, clHill, 15, clWater, 2), clHill, scaleByMapSize(3, 15)); -var [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); +const [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); createDefaultForests( [tMainTerrain, tForestFloor1, tForestFloor2, pForest1, pForest2], avoidClasses(clPlayer, 20, clForest, 17, clHill, 0, clWater, 2), @@ -206,7 +206,7 @@ Engine.SetProgress(65); -var planetm = 1; +let planetm = 1; if (currentBiome() == "generic/india") planetm = 8; Index: binaries/data/mods/public/maps/random/rmbiome/randombiome.js =================================================================== --- binaries/data/mods/public/maps/random/rmbiome/randombiome.js +++ binaries/data/mods/public/maps/random/rmbiome/randombiome.js @@ -32,7 +32,7 @@ loadBiomeFile(biomeID); Engine.LoadLibrary("rmbiome/" + dirname(biomeID)); - let setupBiomeFunc = global["setupBiome_" + basename(biomeID)]; + const setupBiomeFunc = global["setupBiome_" + basename(biomeID)]; if (setupBiomeFunc) setupBiomeFunc(); } @@ -42,7 +42,7 @@ */ function loadBiomeFile(file) { - let path = "maps/random/rmbiome/" + file + ".json"; + const path = "maps/random/rmbiome/" + file + ".json"; if (!Engine.FileExists(path)) { @@ -50,10 +50,10 @@ return; } - let biome = Engine.ReadJSONFile(path); + const biome = Engine.ReadJSONFile(path); - let copyProperties = (from, to) => { - for (let prop in from) + const copyProperties = (from, to) => { + for (const prop in from) { if (from[prop] !== null && typeof from[prop] == "object" && !Array.isArray(from[prop])) { @@ -67,7 +67,7 @@ } }; - for (let rmsGlobal in biome) + for (const rmsGlobal in biome) { if (rmsGlobal == "Description") continue; Index: binaries/data/mods/public/maps/random/rmgen-common/gaia_entities.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen-common/gaia_entities.js +++ binaries/data/mods/public/maps/random/rmgen-common/gaia_entities.js @@ -95,7 +95,7 @@ function createStragglerTrees(templateNames, constraint, tileClass, treeCount, retryFactor) { g_Map.log("Creating straggler trees"); - for (let templateName of templateNames) + for (const templateName of templateNames) createObjectGroupsDeprecated( new SimpleGroup([new SimpleObject(templateName, 1, 1, 0, 3)], true, tileClass), 0, @@ -110,7 +110,7 @@ */ function createMines(objects, constraint, tileClass, count) { - for (let object of objects) + for (const object of objects) createObjectGroupsDeprecated( new SimpleGroup(object, true, tileClass), 0, @@ -226,7 +226,7 @@ for (let i = 0; i < count; ++i) { - let pos = Vector2D.add(position, new Vector2D(radius + randFloat(0, maxOffset), 0).rotate(-angle)).round(); + const pos = Vector2D.add(position, new Vector2D(radius + randFloat(0, maxOffset), 0).rotate(-angle)).round(); g_Map.placeEntityPassable(templateName, 0, pos, randomAngle()); angle += 3/2 * Math.PI / count; } @@ -280,28 +280,28 @@ */ function placeDocks(template, playerID, count, tileClassWater, tileClassDock, heightMin, heightMax, constraints, offset, retryFactor) { - let mapCenter = g_Map.getCenter(); + const mapCenter = g_Map.getCenter(); g_Map.log("Marking dock search start area"); - let areaSearchStart = createArea( + const areaSearchStart = createArea( new DiskPlacer(fractionToTiles(0.5) - 10, mapCenter), undefined, avoidClasses(tileClassWater, 6)); g_Map.log("Marking dock search end area"); - let areaSearchEnd = createArea( + const areaSearchEnd = createArea( new DiskPlacer(fractionToTiles(0.5) - 10, mapCenter), undefined, stayClasses(tileClassWater, 20)); g_Map.log("Marking land area"); - let areaLand = createArea( + const areaLand = createArea( new MapBoundsPlacer(), undefined, avoidClasses(tileClassWater, 0)); g_Map.log("Marking water area"); - let areaWater = createArea( + const areaWater = createArea( new MapBoundsPlacer(), undefined, stayClasses(tileClassWater, 0)); @@ -310,14 +310,14 @@ return; // TODO: computing the exact intersection with the waterplane would both not require us to pass reasonable heights and be more precise - let constraint = new AndConstraint(constraints); + const constraint = new AndConstraint(constraints); g_Map.log("Placing docks"); for (let i = 0; i < count; ++i) for (let tries = 0; tries < retryFactor; ++tries) { - let positionLand = pickRandom(areaSearchStart.getPoints()); - let positionWaterLarge = areaSearchEnd.getClosestPointTo(positionLand); - let positionDock = findLocationInDirectionBasedOnHeight(positionWaterLarge, positionLand, heightMin, heightMax, offset); + const positionLand = pickRandom(areaSearchStart.getPoints()); + const positionWaterLarge = areaSearchEnd.getClosestPointTo(positionLand); + const positionDock = findLocationInDirectionBasedOnHeight(positionWaterLarge, positionLand, heightMin, heightMax, offset); if (!positionDock) continue; @@ -326,7 +326,7 @@ if (!g_Map.inMapBounds(positionDock) || !constraint.allows(positionDock)) continue; - let angle = positionDock.angleTo(Vector2D.average(new DiskPlacer(8, positionDock).place(stayClasses(tileClassWater, 0)))); + const angle = positionDock.angleTo(Vector2D.average(new DiskPlacer(8, positionDock).place(stayClasses(tileClassWater, 0)))); g_Map.placeEntityPassable(template, playerID, positionDock, -angle + Math.PI / 2); tileClassDock.add(positionDock); Index: binaries/data/mods/public/maps/random/rmgen-common/gaia_terrain.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen-common/gaia_terrain.js +++ binaries/data/mods/public/maps/random/rmgen-common/gaia_terrain.js @@ -46,7 +46,7 @@ function createMountains(terrain, constraints, tileClass, count, maxHeight, minRadius, maxRadius, numCircles) { g_Map.log("Creating mountains"); - let mapSize = g_Map.getSize(); + const mapSize = g_Map.getSize(); for (let i = 0; i < (count || scaleByMapSize(1, 4) * getNumPlayers()); ++i) createMountain( @@ -67,8 +67,8 @@ */ function createMountain(maxHeight, minRadius, maxRadius, numCircles, constraints, x, z, terrain, tileClass, fcc = 0, q = []) { - let position = new Vector2D(x, z); - let constraint = new AndConstraint(constraints); + const position = new Vector2D(x, z); + const constraint = new AndConstraint(constraints); if (!g_Map.inMapBounds(position) || !constraint.allows(position)) return; @@ -76,7 +76,7 @@ let mapSize = g_Map.getSize(); let queueEmpty = !q.length; - let gotRet = []; + const gotRet = []; for (let i = 0; i < mapSize; ++i) { gotRet[i] = []; @@ -88,13 +88,13 @@ minRadius = Math.max(1, Math.min(minRadius, maxRadius)); - let edges = [[x, z]]; - let circles = []; + const edges = [[x, z]]; + const circles = []; for (let i = 0; i < numCircles; ++i) { let badPoint = false; - let [cx, cz] = pickRandom(edges); + const [cx, cz] = pickRandom(edges); let radius; if (queueEmpty) @@ -105,18 +105,18 @@ queueEmpty = !q.length; } - let sx = Math.max(0, cx - radius); - let sz = Math.max(0, cz - radius); - let lx = Math.min(cx + radius, mapSize); - let lz = Math.min(cz + radius, mapSize); + const sx = Math.max(0, cx - radius); + const sz = Math.max(0, cz - radius); + const lx = Math.min(cx + radius, mapSize); + const lz = Math.min(cz + radius, mapSize); - let radius2 = Math.square(radius); + const radius2 = Math.square(radius); for (let ix = sx; ix <= lx; ++ix) { for (let iz = sz; iz <= lz; ++iz) { - let pos = new Vector2D(ix, iz); + const pos = new Vector2D(ix, iz); if (Math.euclidDistance2D(ix, iz, cx, cz) > radius2 || !g_Map.inMapBounds(pos)) continue; @@ -127,7 +127,7 @@ break; } - let state = gotRet[ix][iz]; + const state = gotRet[ix][iz]; if (state == -1) { gotRet[ix][iz] = -2; @@ -167,23 +167,23 @@ } } - for (let [cx, cz, radius] of circles) + for (const [cx, cz, radius] of circles) { - let circlePosition = new Vector2D(cx, cz); - let sx = Math.max(0, cx - radius); - let sz = Math.max(0, cz - radius); - let lx = Math.min(cx + radius, mapSize); - let lz = Math.min(cz + radius, mapSize); + const circlePosition = new Vector2D(cx, cz); + const sx = Math.max(0, cx - radius); + const sz = Math.max(0, cz - radius); + const lx = Math.min(cx + radius, mapSize); + const lz = Math.min(cz + radius, mapSize); - let clumpHeight = radius / maxRadius * maxHeight * randFloat(0.8, 1.2); + const clumpHeight = radius / maxRadius * maxHeight * randFloat(0.8, 1.2); for (let ix = sx; ix <= lx; ++ix) for (let iz = sz; iz <= lz; ++iz) { - let position = new Vector2D(ix, iz); - let distance = position.distanceTo(circlePosition); + const position = new Vector2D(ix, iz); + const distance = position.distanceTo(circlePosition); - let newHeight = + const newHeight = randIntInclusive(0, 2) + Math.round(2/3 * clumpHeight * (Math.sin(Math.PI * 2/3 * (3/4 - distance / radius)) + 0.5)); @@ -218,8 +218,8 @@ { g_Map.log("Creating volcano"); - let clLava = g_Map.createTileClass(); - let layers = [ + const clLava = g_Map.createTileClass(); + const layers = [ { "clumps": diskArea(scaleByMapSize(18, 25)), "elevation": 15, @@ -265,7 +265,7 @@ if (smoke) { - let num = Math.floor(diskArea(scaleByMapSize(3, 5))); + const num = Math.floor(diskArea(scaleByMapSize(3, 5))); createObjectGroup( new SimpleGroup( [new SimpleObject("actor|particle/smoke.xml", num, num, 0, 7)], @@ -282,7 +282,7 @@ */ function createPatches(sizes, terrain, constraints, count, tileClass, failFraction = 0.5) { - for (let size of sizes) + for (const size of sizes) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, failFraction), [ @@ -298,7 +298,7 @@ */ function createLayeredPatches(sizes, terrains, terrainWidths, constraints, count, tileClass, failFraction = 0.5) { - for (let size of sizes) + for (const size of sizes) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, failFraction), [ @@ -335,45 +335,45 @@ g_Map.log("Creating river"); // Model the river meandering as the sum of two sine curves. - let meanderShort = fractionToTiles(args.meanderShort / scaleByMapSize(35, 160)); - let meanderLong = fractionToTiles(args.meanderLong / scaleByMapSize(35, 100)); + const meanderShort = fractionToTiles(args.meanderShort / scaleByMapSize(35, 160)); + const meanderLong = fractionToTiles(args.meanderLong / scaleByMapSize(35, 100)); // Unless the river is parallel, each riverside will receive an own random seed and starting angle. - let seed1 = randFloat(2, 3); - let seed2 = randFloat(2, 3); + const seed1 = randFloat(2, 3); + const seed2 = randFloat(2, 3); - let startingAngle1 = randFloat(0, 1); - let startingAngle2 = randFloat(0, 1); + const startingAngle1 = randFloat(0, 1); + const startingAngle2 = randFloat(0, 1); // Computes the deflection of the river at a given point. - let riverCurve = (riverFraction, startAngle, seed) => + const riverCurve = (riverFraction, startAngle, seed) => meanderShort * rndRiver(startAngle + fractionToTiles(riverFraction) / 128, seed) + meanderLong * rndRiver(startAngle + fractionToTiles(riverFraction) / 256, seed); // Describe river location in vectors. - let riverLength = args.start.distanceTo(args.end); - let unitVecRiver = Vector2D.sub(args.start, args.end).normalize(); + const riverLength = args.start.distanceTo(args.end); + const unitVecRiver = Vector2D.sub(args.start, args.end).normalize(); // Describe river boundaries. - let riverMinX = Math.min(args.start.x, args.end.x); - let riverMinZ = Math.min(args.start.y, args.end.y); - let riverMaxX = Math.max(args.start.x, args.end.x); - let riverMaxZ = Math.max(args.start.y, args.end.y); + const riverMinX = Math.min(args.start.x, args.end.x); + const riverMinZ = Math.min(args.start.y, args.end.y); + const riverMaxX = Math.max(args.start.x, args.end.x); + const riverMaxZ = Math.max(args.start.y, args.end.y); - let mapSize = g_Map.getSize(); + const mapSize = g_Map.getSize(); for (let ix = 0; ix < mapSize; ++ix) for (let iz = 0; iz < mapSize; ++iz) { - let vecPoint = new Vector2D(ix, iz); + const vecPoint = new Vector2D(ix, iz); if (args.constraint && !args.constraint.allows(vecPoint)) continue; // Compute the shortest distance to the river. - let distanceToRiver = distanceOfPointFromLine(args.start, args.end, vecPoint); + const distanceToRiver = distanceOfPointFromLine(args.start, args.end, vecPoint); // Closest point on the river (i.e the foot of the perpendicular). - let river = Vector2D.sub(vecPoint, unitVecRiver.perpendicular().mult(distanceToRiver)); + const river = Vector2D.sub(vecPoint, unitVecRiver.perpendicular().mult(distanceToRiver)); // Only process points that actually are perpendicular with the river. if (river.x < riverMinX || river.x > riverMaxX || @@ -381,18 +381,18 @@ continue; // Coordinate between 0 and 1 on the axis parallel to the river. - let riverFraction = river.distanceTo(args.start) / riverLength; + const riverFraction = river.distanceTo(args.start) / riverLength; // Amplitude of the river at this location. - let riverCurve1 = riverCurve(riverFraction, startingAngle1, seed1); - let riverCurve2 = args.parallel ? riverCurve1 : riverCurve(riverFraction, startingAngle2, seed2); + const riverCurve1 = riverCurve(riverFraction, startingAngle1, seed1); + const riverCurve2 = args.parallel ? riverCurve1 : riverCurve(riverFraction, startingAngle2, seed2); // Add noise. - let deviation = args.deviation * randFloat(-1, 1); + const deviation = args.deviation * randFloat(-1, 1); // Compute the distance to the shoreline. - let shoreDist1 = riverCurve1 + distanceToRiver - deviation - args.width / 2; - let shoreDist2 = riverCurve2 + distanceToRiver - deviation + args.width / 2; + const shoreDist1 = riverCurve1 + distanceToRiver - deviation - args.width / 2; + const shoreDist2 = riverCurve2 + distanceToRiver - deviation + args.width / 2; // Create the elevation for the water and the slopy shoreline and call the user functions. if (shoreDist1 < 0 && shoreDist2 > 0) @@ -426,10 +426,10 @@ for (let i = 0; i <= f; ++i) rndRw = 10 * (rndRw % 1); - let rndRr = f % 1; + const rndRr = f % 1; let retVal = (Math.floor(f) % 2 ? -1 : 1) * rndRr * (rndRr - 1); - let rndRe = Math.floor(rndRw) % 5; + const rndRe = Math.floor(rndRw) % 5; if (rndRe == 0) retVal *= 2.3 * (rndRr - 0.5) * (rndRr - 0.5); else if (rndRe == 1) @@ -450,15 +450,15 @@ function createTributaryRivers(riverAngle, riverCount, riverWidth, heightRiverbed, heightRange, maxAngle, tributaryRiverTileClass, shallowTileClass, constraint) { g_Map.log("Creating tributary rivers"); - let waviness = 0.4; - let smoothness = scaleByMapSize(3, 12); - let offset = 0.1; - let tapering = 0.05; - let heightShallow = -2; + const waviness = 0.4; + const smoothness = scaleByMapSize(3, 12); + const offset = 0.1; + const tapering = 0.05; + const heightShallow = -2; - let mapSize = g_Map.getSize(); - let mapCenter = g_Map.getCenter(); - let mapBounds = g_Map.getBounds(); + const mapSize = g_Map.getSize(); + const mapCenter = g_Map.getCenter(); + const mapBounds = g_Map.getBounds(); let riverConstraint = avoidClasses(tributaryRiverTileClass, 3); if (shallowTileClass) @@ -467,19 +467,19 @@ for (let i = 0; i < riverCount; ++i) { // Determining tributary river location - let searchCenter = new Vector2D(fractionToTiles(randFloat(tapering, 1 - tapering)), mapCenter.y); - let sign = randBool() ? 1 : -1; - let distanceVec = new Vector2D(0, sign * tapering); + const searchCenter = new Vector2D(fractionToTiles(randFloat(tapering, 1 - tapering)), mapCenter.y); + const sign = randBool() ? 1 : -1; + const distanceVec = new Vector2D(0, sign * tapering); - let searchStart = Vector2D.add(searchCenter, distanceVec).rotateAround(riverAngle, mapCenter); - let searchEnd = Vector2D.sub(searchCenter, distanceVec).rotateAround(riverAngle, mapCenter); + const searchStart = Vector2D.add(searchCenter, distanceVec).rotateAround(riverAngle, mapCenter); + const searchEnd = Vector2D.sub(searchCenter, distanceVec).rotateAround(riverAngle, mapCenter); - let start = findLocationInDirectionBasedOnHeight(searchStart, searchEnd, heightRange[0], heightRange[1], 4); + const start = findLocationInDirectionBasedOnHeight(searchStart, searchEnd, heightRange[0], heightRange[1], 4); if (!start) continue; start.round(); - let end = Vector2D.add(mapCenter, new Vector2D(mapSize, 0).rotate(riverAngle - sign * randFloat(maxAngle, 2 * Math.PI - maxAngle))).round(); + const end = Vector2D.add(mapCenter, new Vector2D(mapSize, 0).rotate(riverAngle - sign * randFloat(maxAngle, 2 * Math.PI - maxAngle))).round(); // Create river if (!createArea( @@ -502,7 +502,7 @@ if (shallowTileClass) { g_Map.log("Creating shallows in the tributary rivers"); - for (let z of [0.25, 0.75]) + for (const z of [0.25, 0.75]) createPassage({ "start": new Vector2D(mapBounds.left, fractionToTiles(z)).rotateAround(riverAngle, mapCenter), "end": new Vector2D(mapBounds.right, fractionToTiles(z)).rotateAround(riverAngle, mapCenter), @@ -536,27 +536,27 @@ */ function createPassage(args) { - let bound = x => Math.max(0, Math.min(Math.round(x), g_Map.height.length - 1)); + const bound = x => Math.max(0, Math.min(Math.round(x), g_Map.height.length - 1)); - let startHeight = args.startHeight !== undefined ? args.startHeight : g_Map.getHeight(new Vector2D(bound(args.start.x), bound(args.start.y))); - let endHeight = args.endHeight !== undefined ? args.endHeight : g_Map.getHeight(new Vector2D(bound(args.end.x), bound(args.end.y))); + const startHeight = args.startHeight !== undefined ? args.startHeight : g_Map.getHeight(new Vector2D(bound(args.start.x), bound(args.start.y))); + const endHeight = args.endHeight !== undefined ? args.endHeight : g_Map.getHeight(new Vector2D(bound(args.end.x), bound(args.end.y))); - let passageVec = Vector2D.sub(args.end, args.start); - let widthDirection = passageVec.perpendicular().normalize(); - let lengthStep = 1 / (2 * passageVec.length()); - let points = []; + const passageVec = Vector2D.sub(args.end, args.start); + const widthDirection = passageVec.perpendicular().normalize(); + const lengthStep = 1 / (2 * passageVec.length()); + const points = []; - let constraint = args.constraints && new StaticConstraint(args.constraints); + const constraint = args.constraints && new StaticConstraint(args.constraints); for (let lengthFraction = 0; lengthFraction <= 1; lengthFraction += lengthStep) { - let locationLength = Vector2D.add(args.start, Vector2D.mult(passageVec, lengthFraction)); - let halfPassageWidth = (args.startWidth + (args.endWidth - args.startWidth) * lengthFraction) / 2; - let passageHeight = startHeight + (endHeight - startHeight) * lengthFraction; + const locationLength = Vector2D.add(args.start, Vector2D.mult(passageVec, lengthFraction)); + const halfPassageWidth = (args.startWidth + (args.endWidth - args.startWidth) * lengthFraction) / 2; + const passageHeight = startHeight + (endHeight - startHeight) * lengthFraction; for (let stepWidth = -halfPassageWidth; stepWidth <= halfPassageWidth; stepWidth += 0.5) { - let location = Vector2D.add(locationLength, Vector2D.mult(widthDirection, stepWidth)).round(); + const location = Vector2D.add(locationLength, Vector2D.mult(widthDirection, stepWidth)).round(); if (!g_Map.inMapBounds(location) || constraint && !constraint.allows(location)) @@ -564,7 +564,7 @@ points.push(location); - let smoothDistance = args.smoothWidth + Math.abs(stepWidth) - halfPassageWidth; + const smoothDistance = args.smoothWidth + Math.abs(stepWidth) - halfPassageWidth; g_Map.setHeight( location, @@ -590,14 +590,14 @@ */ function findLocationInDirectionBasedOnHeight(startPoint, endPoint, minHeight, maxHeight, offset = 0) { - let stepVec = Vector2D.sub(endPoint, startPoint); - let distance = Math.ceil(stepVec.length()); + const stepVec = Vector2D.sub(endPoint, startPoint); + const distance = Math.ceil(stepVec.length()); stepVec.normalize(); for (let i = 0; i < distance; ++i) { - let pos = Vector2D.add(startPoint, Vector2D.mult(stepVec, i)); - let ipos = pos.clone().round(); + const pos = Vector2D.add(startPoint, Vector2D.mult(stepVec, i)); + const ipos = pos.clone().round(); if (g_Map.validHeight(ipos) && g_Map.getHeight(ipos) >= minHeight && Index: binaries/data/mods/public/maps/random/rmgen-common/player.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen-common/player.js +++ binaries/data/mods/public/maps/random/rmgen-common/player.js @@ -76,7 +76,7 @@ { // Place the central structure let i = 0; - let firstTemplate = civEntities[i].Template; + const firstTemplate = civEntities[i].Template; if (firstTemplate.startsWith("structures/")) { g_Map.placeEntityPassable(firstTemplate, playerID, location, orientation); @@ -84,15 +84,15 @@ } // Place entities surrounding it - let space = 2; + const space = 2; for (let j = i; j < civEntities.length; ++j) { - let angle = orientation - Math.PI * (1 - j / 2); - let count = civEntities[j].Count || 1; + const angle = orientation - Math.PI * (1 - j / 2); + const count = civEntities[j].Count || 1; for (let num = 0; num < count; ++num) { - let position = Vector2D.sum([ + const position = Vector2D.sum([ location, new Vector2D(dist, 0).rotate(-angle), new Vector2D(space * (-num + (count - 1) / 2), 0).rotate(angle) @@ -118,7 +118,7 @@ */ function placeStartingWalls(position, playerID, wallType, orientation = BUILDING_ORIENTATION) { - let civ = getCivCode(playerID); + const civ = getCivCode(playerID); if (civ != "iber" || g_Map.getSize() <= 128) return; @@ -138,7 +138,7 @@ { g_Map.log("Creating playerbases"); - let [playerIDs, playerPosition] = playerBaseArgs.PlayerPlacement; + const [playerIDs, playerPosition] = playerBaseArgs.PlayerPlacement; for (let i = 0; i < getNumPlayers(); ++i) { @@ -166,20 +166,20 @@ if (playerBaseArgs.PlayerTileClass) addCivicCenterAreaToClass(playerBaseArgs.playerPosition, playerBaseArgs.PlayerTileClass); - for (let functionID of g_PlayerBaseFunctions) + for (const functionID of g_PlayerBaseFunctions) { - let funcName = "placePlayerBase" + functionID; - let func = global[funcName]; + const funcName = "placePlayerBase" + functionID; + const func = global[funcName]; if (!func) throw new Error("Could not find " + funcName); if (!playerBaseArgs[functionID]) continue; - let args = playerBaseArgs[functionID]; + const args = playerBaseArgs[functionID]; // Copy some global arguments to the arguments for each function - for (let prop of ["playerID", "playerPosition", "BaseResourceClass", "baseResourceConstraint"]) + for (const prop of ["playerID", "playerPosition", "BaseResourceClass", "baseResourceConstraint"]) args[prop] = playerBaseArgs[prop]; func(args); @@ -221,7 +221,7 @@ function placePlayerBaseCityPatch(args) { - let [get, basePosition, baseResourceConstraint] = getPlayerBaseArgs(args); + const [get, basePosition, baseResourceConstraint] = getPlayerBaseArgs(args); let painters = []; @@ -243,18 +243,18 @@ function placePlayerBaseStartingAnimal(args) { - let [get, basePosition, baseResourceConstraint] = getPlayerBaseArgs(args); + const [get, basePosition, baseResourceConstraint] = getPlayerBaseArgs(args); const template = get("template", "gaia/fauna_chicken"); const count = template === "gaia/fauna_chicken" ? 5 : - Math.round(5 * (Engine.GetTemplate("gaia/fauna_chicken").ResourceSupply.Max / Engine.GetTemplate(get("template")).ResourceSupply.Max)) + Math.round(5 * (Engine.GetTemplate("gaia/fauna_chicken").ResourceSupply.Max / Engine.GetTemplate(get("template")).ResourceSupply.Max)); for (let i = 0; i < get("groupCount", 2); ++i) { let success = false; for (let tries = 0; tries < get("maxTries", 30); ++tries) { - let position = new Vector2D(0, get("distance", 9)).rotate(randomAngle()).add(basePosition); + const position = new Vector2D(0, get("distance", 9)).rotate(randomAngle()).add(basePosition); if (createObjectGroup( new SimpleGroup( [ @@ -286,10 +286,10 @@ function placePlayerBaseBerries(args) { - let [get, basePosition, baseResourceConstraint] = getPlayerBaseArgs(args); + const [get, basePosition, baseResourceConstraint] = getPlayerBaseArgs(args); for (let tries = 0; tries < get("maxTries", 30); ++tries) { - let position = new Vector2D(0, get("distance", 12)).rotate(randomAngle()).add(basePosition); + const position = new Vector2D(0, get("distance", 12)).rotate(randomAngle()).add(basePosition); if (createObjectGroup( new SimpleGroup( [new SimpleObject(args.template, get("minCount", 5), get("maxCount", 5), get("maxDist", 1), get("maxDist", 3))], @@ -306,10 +306,10 @@ function placePlayerBaseMines(args) { - let [get, basePosition, baseResourceConstraint] = getPlayerBaseArgs(args); + const [get, basePosition, baseResourceConstraint] = getPlayerBaseArgs(args); - let angleBetweenMines = randFloat(get("minAngle", Math.PI / 6), get("maxAngle", Math.PI / 3)); - let mineCount = args.types.length; + const angleBetweenMines = randFloat(get("minAngle", Math.PI / 6), get("maxAngle", Math.PI / 3)); + const mineCount = args.types.length; let groupElements = []; if (args.groupElements) @@ -319,10 +319,10 @@ { // First find a place where all mines can be placed let pos = []; - let startAngle = randomAngle(); + const startAngle = randomAngle(); for (let i = 0; i < mineCount; ++i) { - let angle = startAngle + angleBetweenMines * (i + (mineCount - 1) / 2); + const angle = startAngle + angleBetweenMines * (i + (mineCount - 1) / 2); pos[i] = new Vector2D(0, get("distance", 12)).rotate(angle).add(basePosition).round(); if (!g_Map.validTilePassable(pos[i]) || !baseResourceConstraint.allows(pos[i])) { @@ -360,13 +360,13 @@ function placePlayerBaseTrees(args) { - let [get, basePosition, baseResourceConstraint] = getPlayerBaseArgs(args); + const [get, basePosition, baseResourceConstraint] = getPlayerBaseArgs(args); - let num = Math.floor(get("count", scaleByMapSize(7, 20))); + const num = Math.floor(get("count", scaleByMapSize(7, 20))); for (let x = 0; x < get("maxTries", 30); ++x) { - let position = new Vector2D(0, randFloat(get("minDist", 11), get("maxDist", 13))).rotate(randomAngle()).add(basePosition).round(); + const position = new Vector2D(0, randFloat(get("minDist", 11), get("maxDist", 13))).rotate(randomAngle()).add(basePosition).round(); if (createObjectGroup( new SimpleGroup( @@ -386,7 +386,7 @@ { let [get, basePosition, baseResourceConstraint] = getPlayerBaseArgs(args); - for (let resourceTypeArgs of args.types) + for (const resourceTypeArgs of args.types) { get = (property, defaultVal) => resourceTypeArgs[property] === undefined ? defaultVal : resourceTypeArgs[property]; @@ -394,7 +394,7 @@ for (let tries = 0; tries < get("maxTries", 30); ++tries) { - let position = new Vector2D(0, randFloat(get("minDist", 11), get("maxDist", 13))).rotate(randomAngle()).add(basePosition).round(); + const position = new Vector2D(0, randFloat(get("minDist", 11), get("maxDist", 13))).rotate(randomAngle()).add(basePosition).round(); if (createObjectGroup( new SimpleGroup( @@ -422,14 +422,14 @@ */ function placePlayerBaseDecoratives(args) { - let [get, basePosition, baseResourceConstraint] = getPlayerBaseArgs(args); + const [get, basePosition, baseResourceConstraint] = getPlayerBaseArgs(args); for (let i = 0; i < get("count", scaleByMapSize(2, 5)); ++i) { let success = false; for (let x = 0; x < get("maxTries", 30); ++x) { - let position = new Vector2D(0, randIntInclusive(get("minDist", 8), get("maxDist", 11))).rotate(randomAngle()).add(basePosition).round(); + const position = new Vector2D(0, randIntInclusive(get("minDist", 8), get("maxDist", 11))).rotate(randomAngle()).add(basePosition).round(); if (createObjectGroup( new SimpleGroup( @@ -457,25 +457,25 @@ g_Map.log("Placing nomad starting units"); - let distance = scaleByMapSize(60, 240); - let constraint = new StaticConstraint(constraints); + const distance = scaleByMapSize(60, 240); + const constraint = new StaticConstraint(constraints); - let numPlayers = getNumPlayers(); - let playerIDs = shuffleArray(sortAllPlayers()); - let playerPosition = []; + const numPlayers = getNumPlayers(); + const playerIDs = shuffleArray(sortAllPlayers()); + const playerPosition = []; for (let i = 0; i < numPlayers; ++i) { - let objects = getStartingEntities(playerIDs[i]).filter(ents => ents.Template.startsWith("units/")).map( + const objects = getStartingEntities(playerIDs[i]).filter(ents => ents.Template.startsWith("units/")).map( ents => new SimpleObject(ents.Template, ents.Count || 1, ents.Count || 1, 1, 3)); // Add treasure if too few resources for a civic center - let ccCost = Engine.GetTemplate("structures/" + getCivCode(playerIDs[i]) + "/civil_centre").Cost.Resources; - for (let resourceType in ccCost) + const ccCost = Engine.GetTemplate("structures/" + getCivCode(playerIDs[i]) + "/civil_centre").Cost.Resources; + for (const resourceType in ccCost) { - let treasureTemplate = g_NomadTreasureTemplates[resourceType]; + const treasureTemplate = g_NomadTreasureTemplates[resourceType]; - let count = Math.max(0, Math.ceil( + const count = Math.max(0, Math.ceil( (ccCost[resourceType] - (g_MapSettings.StartingResources || 0)) / Engine.GetTemplate(treasureTemplate).Treasure.Resources[resourceType])); @@ -483,9 +483,9 @@ } // Try place these entities at a random location - let group = new SimpleGroup(objects, true, playerClass); + const group = new SimpleGroup(objects, true, playerClass); let success = false; - for (let distanceFactor of [1, 1/2, 1/4, 0]) + for (const distanceFactor of [1, 1/2, 1/4, 0]) if (createObjectGroups(group, playerIDs[i], new AndConstraint([constraint, avoidClasses(playerClass, distance * distanceFactor)]), 1, 200, false).length) { success = true; @@ -516,7 +516,7 @@ */ function sortAllPlayers() { - let playerIDs = []; + const playerIDs = []; for (let i = 0; i < getNumPlayers(); ++i) playerIDs.push(i+1); @@ -528,7 +528,7 @@ */ function primeSortPlayers(playerIDs) { - let prime = []; + const prime = []; for (let i = 0; i < Math.floor(playerIDs.length / 2); ++i) { prime.push(playerIDs[i]); @@ -552,14 +552,14 @@ */ function partitionPlayers(playerIDs) { - let teamIDs = Array.from(new Set(playerIDs.map(getPlayerTeam))); + const teamIDs = Array.from(new Set(playerIDs.map(getPlayerTeam))); let teams = teamIDs.map(teamID => playerIDs.filter(playerID => getPlayerTeam(playerID) == teamID)); if (teamIDs.indexOf(-1) != -1) teams = teams.concat(teams.splice(teamIDs.indexOf(-1), 1)[0].map(playerID => [playerID])); if (teams.length == 1) { - let idx = Math.floor(teams[0].length / 2); + const idx = Math.floor(teams[0].length / 2); teams = [teams[0].slice(idx), teams[0].slice(0, idx)]; } @@ -578,14 +578,14 @@ */ function getTeamsArray() { - var playerIDs = sortAllPlayers(); - var numPlayers = getNumPlayers(); + let playerIDs = sortAllPlayers(); + let numPlayers = getNumPlayers(); // Group players by team - var teams = []; + let teams = []; for (let i = 0; i < numPlayers; ++i) { - let team = getPlayerTeam(playerIDs[i]); + const team = getPlayerTeam(playerIDs[i]); if (team == -1) continue; @@ -634,8 +634,8 @@ */ function playerPlacementCircle(radius, startingAngle = undefined, center = undefined) { - let startAngle = startingAngle !== undefined ? startingAngle : randomAngle(); - let [playerPosition, playerAngle] = distributePointsOnCircle(getNumPlayers(), startAngle, radius, center || g_Map.getCenter()); + const startAngle = startingAngle !== undefined ? startingAngle : randomAngle(); + const [playerPosition, playerAngle] = distributePointsOnCircle(getNumPlayers(), startAngle, radius, center || g_Map.getCenter()); return [sortAllPlayers(), playerPosition.map(p => p.round()), playerAngle, startAngle]; } @@ -645,10 +645,10 @@ */ function playerPlacementCustomAngle(radius, center, playerAngleFunc) { - let playerPosition = []; - let playerAngle = []; + const playerPosition = []; + const playerAngle = []; - let numPlayers = getNumPlayers(); + const numPlayers = getNumPlayers(); for (let i = 0; i < numPlayers; ++i) { @@ -678,9 +678,9 @@ */ function playerPlacementArcs(playerIDs, center, radius, mapAngle, startAngle, endAngle) { - let [east, west] = partitionPlayers(playerIDs); - let eastPosition = playerPlacementArc(east, center, radius, mapAngle + startAngle, mapAngle + endAngle); - let westPosition = playerPlacementArc(west, center, radius, mapAngle - startAngle, mapAngle - endAngle); + const [east, west] = partitionPlayers(playerIDs); + const eastPosition = playerPlacementArc(east, center, radius, mapAngle + startAngle, mapAngle + endAngle); + const westPosition = playerPlacementArc(west, center, radius, mapAngle - startAngle, mapAngle - endAngle); return playerIDs.map(playerID => east.indexOf(playerID) != -1 ? eastPosition[east.indexOf(playerID)] : westPosition[west.indexOf(playerID)]); @@ -693,18 +693,18 @@ */ function playerPlacementRiver(angle, width, center = undefined) { - let numPlayers = getNumPlayers(); - let numPlayersEven = numPlayers % 2 == 0; - let mapSize = g_Map.getSize(); - let centerPosition = center || g_Map.getCenter(); - let playerPosition = []; + const numPlayers = getNumPlayers(); + const numPlayersEven = numPlayers % 2 == 0; + const mapSize = g_Map.getSize(); + const centerPosition = center || g_Map.getCenter(); + const playerPosition = []; for (let i = 0; i < numPlayers; ++i) { - let currentPlayerEven = i % 2 == 0; + const currentPlayerEven = i % 2 == 0; - let offsetDivident = numPlayersEven || currentPlayerEven ? (i + 1) % 2 : 0; - let offsetDivisor = numPlayersEven ? 0 : currentPlayerEven ? +1 : -1; + const offsetDivident = numPlayersEven || currentPlayerEven ? (i + 1) % 2 : 0; + const offsetDivisor = numPlayersEven ? 0 : currentPlayerEven ? +1 : -1; playerPosition[i] = new Vector2D( width * (i % 2) + (mapSize - width) / 2, @@ -721,8 +721,8 @@ */ function playerPlacementLine(angle, center, width) { - let playerPosition = []; - let numPlayers = getNumPlayers(); + const playerPosition = []; + const numPlayers = getNumPlayers(); for (let i = 0; i < numPlayers; ++i) playerPosition[i] = Vector2D.add( @@ -748,19 +748,19 @@ */ function placeLine(teamsArray, distance, groupedDistance, startAngle) { - let playerIDs = []; - let playerPosition = []; + const playerIDs = []; + const playerPosition = []; - let mapCenter = g_Map.getCenter(); - let dist = fractionToTiles(0.45); + const mapCenter = g_Map.getCenter(); + const dist = fractionToTiles(0.45); for (let i = 0; i < teamsArray.length; ++i) { - var safeDist = distance; + let safeDist = distance; if (distance + teamsArray[i].length * groupedDistance > dist) safeDist = dist - teamsArray[i].length * groupedDistance; - var teamAngle = startAngle + (i + 1) * 2 * Math.PI / teamsArray.length; + let teamAngle = startAngle + (i + 1) * 2 * Math.PI / teamsArray.length; for (let p = 0; p < teamsArray[i].length; ++p) { @@ -782,16 +782,16 @@ */ function placeStronghold(teamsArray, distance, groupedDistance, startAngle) { - var mapCenter = g_Map.getCenter(); + let mapCenter = g_Map.getCenter(); - let playerIDs = []; - let playerPosition = []; + const playerIDs = []; + const playerPosition = []; for (let i = 0; i < teamsArray.length; ++i) { - var teamAngle = startAngle + (i + 1) * 2 * Math.PI / teamsArray.length; - var teamPosition = Vector2D.add(mapCenter, new Vector2D(distance, 0).rotate(-teamAngle)); - var teamGroupDistance = groupedDistance; + let teamAngle = startAngle + (i + 1) * 2 * Math.PI / teamsArray.length; + let teamPosition = Vector2D.add(mapCenter, new Vector2D(distance, 0).rotate(-teamAngle)); + let teamGroupDistance = groupedDistance; // If we have a team of above average size, make sure they're spread out if (teamsArray[i].length > 4) @@ -804,9 +804,9 @@ // TODO: Ensure players are not placed outside of the map area, similar to placeLine // Create player base - for (var p = 0; p < teamsArray[i].length; ++p) + for (let p = 0; p < teamsArray[i].length; ++p) { - var angle = startAngle + (p + 1) * 2 * Math.PI / teamsArray[i].length; + let angle = startAngle + (p + 1) * 2 * Math.PI / teamsArray[i].length; playerIDs.push(teamsArray[i][p]); playerPosition.push(Vector2D.add(teamPosition, new Vector2D(teamGroupDistance, 0).rotate(-angle)).round()); } @@ -825,11 +825,11 @@ let attempts = 0; let resets = 0; - let mapCenter = g_Map.getCenter(); + const mapCenter = g_Map.getCenter(); let playerMinDistSquared = Math.square(fractionToTiles(0.25)); - let borderDistance = fractionToTiles(0.08); + const borderDistance = fractionToTiles(0.08); - let area = createArea(new MapBoundsPlacer(), undefined, new AndConstraint(constraints)); + const area = createArea(new MapBoundsPlacer(), undefined, new AndConstraint(constraints)); for (let i = 0; i < getNumPlayers(); ++i) { @@ -887,8 +887,8 @@ for (let i = 1; i < playerIDs.length; ++i) { - let team1 = getPlayerTeam(playerIDs[i - 1]); - let team2 = getPlayerTeam(playerIDs[i]); + const team1 = getPlayerTeam(playerIDs[i - 1]); + const team2 = getPlayerTeam(playerIDs[i]); ++teamSize; if (team1 != -1 && team1 == team2) teamDist += permutation[i - 1].distanceTo(permutation[i]); @@ -918,9 +918,9 @@ */ function groupPlayersCycle(startLocations) { - let startLocationOrder = sortPointsShortestCycle(startLocations); + const startLocationOrder = sortPointsShortestCycle(startLocations); - let newStartLocations = []; + const newStartLocations = []; for (let i = 0; i < startLocations.length; ++i) newStartLocations.push(startLocations[startLocationOrder[i]]); @@ -928,11 +928,11 @@ // Sort players by team let playerIDs = []; - let teams = []; + const teams = []; for (let i = 0; i < g_MapSettings.PlayerData.length - 1; ++i) { playerIDs.push(i+1); - let t = g_MapSettings.PlayerData[i + 1].Team; + const t = g_MapSettings.PlayerData[i + 1].Team; if (teams.indexOf(t) == -1 && t !== undefined) teams.push(t); } @@ -950,7 +950,7 @@ let maxTeamDist = 0; for (let pi = 0; pi < playerIDs.length - 1; ++pi) { - let t1 = getPlayerTeam(playerIDs[(pi + s) % playerIDs.length]); + const t1 = getPlayerTeam(playerIDs[(pi + s) % playerIDs.length]); if (teams.indexOf(t1) === -1) continue; @@ -979,7 +979,7 @@ if (bestShift) { - let newPlayerIDs = []; + const newPlayerIDs = []; for (let i = 0; i < playerIDs.length; ++i) newPlayerIDs.push(playerIDs[(i + bestShift) % playerIDs.length]); playerIDs = newPlayerIDs; Index: binaries/data/mods/public/maps/random/rmgen-common/wall_builder.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen-common/wall_builder.js +++ binaries/data/mods/public/maps/random/rmgen-common/wall_builder.js @@ -22,14 +22,14 @@ */ function loadWallsetsFromCivData() { - let wallsets = {}; - for (let civ in g_CivData) + const wallsets = {}; + for (const civ in g_CivData) { - let civInfo = g_CivData[civ]; + const civInfo = g_CivData[civ]; if (!civInfo.WallSets) continue; - for (let path of civInfo.WallSets) + for (const path of civInfo.WallSets) { // File naming conventions: // - structures/wallset_{style} @@ -47,12 +47,12 @@ function loadWallset(wallsetPath, civ) { - let newWallset = { "curves": [] }; + const newWallset = { "curves": [] }; const wallsetData = GetTemplateDataHelper(wallsetPath, null, null, g_Resources).wallSet; - for (let element in wallsetData.templates) + for (const element in wallsetData.templates) if (element == "curves") - for (let filename of wallsetData.templates.curves) + for (const filename of wallsetData.templates.curves) newWallset.curves.push(readyWallElement(filename, civ)); else newWallset[element] = readyWallElement(wallsetData.templates[element], civ); @@ -86,12 +86,12 @@ function createDefaultFortressTypes() { - let defaultFortresses = {}; + const defaultFortresses = {}; /** * Define some basic default fortress types. */ - let addFortress = (type, walls) => defaultFortresses[type] = { "wall": walls.concat(walls, walls, walls) }; + const addFortress = (type, walls) => defaultFortresses[type] = { "wall": walls.concat(walls, walls, walls) }; addFortress("tiny", ["gate", "tower", "short", "cornerIn", "short", "tower"]); addFortress("small", ["gate", "tower", "medium", "cornerIn", "medium", "tower"]); addFortress("medium", ["gate", "tower", "long", "cornerIn", "long", "tower"]); @@ -104,7 +104,7 @@ * Define some fortresses based on those above, but designed for use * with the "palisades" wallset. */ - for (let fortressType in defaultFortresses) + for (const fortressType in defaultFortresses) { const fillTowersBetween = ["short", "medium", "long", "start", "end", "cornerIn", "cornerOut"]; const newKey = fortressType + "Palisades"; @@ -156,7 +156,7 @@ // Attempt to derive any unknown elements. // Defaults to a wall tower piece const quarterBend = Math.PI / 2; - let wallset = g_WallStyles[style]; + const wallset = g_WallStyles[style]; let civ = style.split("/")[0]; let ret = wallset.tower ? clone(wallset.tower) : { "angle": 0, "bend": 0, "length": 0, "indent": 0 }; @@ -164,7 +164,7 @@ { case "cornerIn": if (wallset.curves) - for (let curve of wallset.curves) + for (const curve of wallset.curves) if (curve.bend == quarterBend) ret = curve; @@ -179,7 +179,7 @@ case "cornerOut": if (wallset.curves) - for (let curve of wallset.curves) + for (const curve of wallset.curves) if (curve.bend == quarterBend) { ret = clone(curve); @@ -245,7 +245,7 @@ if (!g_CivData[civ]) civ = Object.keys(g_CivData)[0]; - let templateName = "structures/" + civ + "/" + element; + const templateName = "structures/" + civ + "/" + element; if (Engine.TemplateExists(templateName)) { ret.indent = ret.length * (element == "outpost" || element.endsWith("_tower") ? -3 : 3.5); @@ -272,7 +272,7 @@ { path = path.replace(/\{civ\}/g, civCode); const template = GetTemplateDataHelper(Engine.GetTemplate(path), null, null, g_Resources); - let length = template.wallPiece ? template.wallPiece.length : template.obstruction.shape.width; + const length = template.wallPiece ? template.wallPiece.length : template.obstruction.shape.width; return deepfreeze({ "templateName": path, @@ -297,12 +297,12 @@ function getWallAlignment(position, wall = [], style = "athen_stone", orientation = 0) { style = validateStyle(style); - let alignment = []; - let wallPosition = position.clone(); + const alignment = []; + const wallPosition = position.clone(); for (let i = 0; i < wall.length; ++i) { - let element = getWallElement(wall[i], style); + const element = getWallElement(wall[i], style); if (!element && i == 0) { warn("Not a valid wall element: style = " + style + ", wall[" + i + "] = " + wall[i] + "; " + uneval(element)); @@ -320,7 +320,7 @@ if (i + 1 < wall.length) { orientation += element.bend; - let nextElement = getWallElement(wall[i + 1], style); + const nextElement = getWallElement(wall[i + 1], style); if (!nextElement) { warn("Not a valid wall element: style = " + style + ", wall[" + (i + 1) + "] = " + wall[i + 1] + "; " + uneval(nextElement)); @@ -330,8 +330,8 @@ let distance = (element.length + nextElement.length) / 2 - g_WallStyles[style].overlap; // Corrections for elements with indent AND bending - let indent = element.indent; - let bend = element.bend; + const indent = element.indent; + const bend = element.bend; if (bend != 0 && indent != 0) { // Indent correction to adjust distance @@ -373,8 +373,8 @@ style = validateStyle(style); let length = 0; - let overlap = g_WallStyles[style].overlap; - for (let element of wall) + const overlap = g_WallStyles[style].overlap; + for (const element of wall) length += getWallElement(element, style).length - overlap; return length; @@ -420,10 +420,10 @@ { style = validateStyle(style, playerId); - let entities = []; - let constraint = new StaticConstraint(constraints); + const entities = []; + const constraint = new StaticConstraint(constraints); - for (let align of getWallAlignment(position, wall, style, orientation)) + for (const align of getWallAlignment(position, wall, style, orientation)) if (align.templateName && g_Map.inMapBounds(align.position) && constraint.allows(align.position.clone().floor())) entities.push(g_Map.placeEntityPassable(align.templateName, playerId, align.position, align.angle)); @@ -454,7 +454,7 @@ centerToFirstElement = getCenterToFirstElement(getWallAlignment(new Vector2D(0, 0), fortress.wall, style)); // Placing the fortress wall - let position = Vector2D.sum([ + const position = Vector2D.sum([ centerPosition, new Vector2D(centerToFirstElement.x, 0).rotate(-orientation), new Vector2D(centerToFirstElement.y, 0).perpendicular().rotate(-orientation) @@ -493,13 +493,13 @@ style = validateStyle(style, playerId); // Check arguments - for (let element of wallPart) + for (const element of wallPart) if (getWallElement(element, style).bend != 0) warn("placeLinearWall : Bending is not supported by this function, but the following bending wall element was used: " + element); // Setup number of wall parts - let totalLength = startPosition.distanceTo(targetPosition); - let wallPartLength = getWallLength(style, wallPart); + const totalLength = startPosition.distanceTo(targetPosition); + const wallPartLength = getWallLength(style, wallPart); let numParts = Math.ceil(totalLength / wallPartLength); if (endWithFirst) numParts = Math.ceil((totalLength - getWallElement(wallPart[0], style).length) / wallPartLength); @@ -510,27 +510,27 @@ scaleFactor = totalLength / (numParts * wallPartLength + getWallElement(wallPart[0], style).length); // Setup angle - let wallAngle = getAngle(startPosition.x, startPosition.y, targetPosition.x, targetPosition.y); - let placeAngle = wallAngle - Math.PI / 2; + const wallAngle = getAngle(startPosition.x, startPosition.y, targetPosition.x, targetPosition.y); + const placeAngle = wallAngle - Math.PI / 2; // Place wall entities - let entities = []; - let position = startPosition.clone(); - let overlap = g_WallStyles[style].overlap; - let constraint = new StaticConstraint(constraints); + const entities = []; + const position = startPosition.clone(); + const overlap = g_WallStyles[style].overlap; + const constraint = new StaticConstraint(constraints); for (let partIndex = 0; partIndex < numParts; ++partIndex) for (let elementIndex = 0; elementIndex < wallPart.length; ++elementIndex) { - let wallEle = getWallElement(wallPart[elementIndex], style); + const wallEle = getWallElement(wallPart[elementIndex], style); - let wallLength = (wallEle.length - overlap) / 2; - let dist = new Vector2D(scaleFactor * wallLength, 0).rotate(-wallAngle); + const wallLength = (wallEle.length - overlap) / 2; + const dist = new Vector2D(scaleFactor * wallLength, 0).rotate(-wallAngle); // Length correction position.add(dist); // Indent correction - let place = Vector2D.add(position, new Vector2D(0, wallEle.indent).rotate(-wallAngle)); + const place = Vector2D.add(position, new Vector2D(0, wallEle.indent).rotate(-wallAngle)); if (wallEle.templateName && g_Map.inMapBounds(place) && constraint.allows(place.clone().floor())) entities.push(g_Map.placeEntityPassable(wallEle.templateName, playerId, place, placeAngle + wallEle.angle)); @@ -540,8 +540,8 @@ if (endWithFirst) { - let wallEle = getWallElement(wallPart[0], style); - let wallLength = (wallEle.length - overlap) / 2; + const wallEle = getWallElement(wallPart[0], style); + const wallLength = (wallEle.length - overlap) / 2; position.add(new Vector2D(scaleFactor * wallLength, 0).rotate(-wallAngle)); if (wallEle.templateName && g_Map.inMapBounds(position) && constraint.allows(position.clone().floor())) entities.push(g_Map.placeEntityPassable(wallEle.templateName, playerId, position, placeAngle + wallEle.angle)); @@ -583,13 +583,13 @@ if (maxBendOff > Math.PI / 2 || maxBendOff < 0) warn("placeCircularWall : maxBendOff should satisfy 0 < maxBendOff < PI/2 (~1.5rad) but it is: " + maxBendOff); - for (let element of wallPart) + for (const element of wallPart) if (getWallElement(element, style).bend != 0) warn("placeCircularWall : Bending is not supported by this function, but the following bending wall element was used: " + element); // Setup number of wall parts - let totalLength = maxAngle * radius; - let wallPartLength = getWallLength(style, wallPart); + const totalLength = maxAngle * radius; + const wallPartLength = getWallLength(style, wallPart); let numParts = Math.ceil(totalLength / wallPartLength); if (endWithFirst) numParts = Math.ceil((totalLength - getWallElement(wallPart[0], style).length) / wallPartLength); @@ -600,21 +600,21 @@ scaleFactor = totalLength / (numParts * wallPartLength + getWallElement(wallPart[0], style).length); // Place wall entities - let entities = []; - let constraint = new StaticConstraint(constraints); + const entities = []; + const constraint = new StaticConstraint(constraints); let actualAngle = orientation; let position = Vector2D.add(center, new Vector2D(radius, 0).rotate(-actualAngle)); - let overlap = g_WallStyles[style].overlap; + const overlap = g_WallStyles[style].overlap; for (let partIndex = 0; partIndex < numParts; ++partIndex) for (let wallEle of wallPart) { wallEle = getWallElement(wallEle, style); // Width correction - let addAngle = scaleFactor * (wallEle.length - overlap) / radius; - let target = Vector2D.add(center, new Vector2D(radius, 0).rotate(-actualAngle - addAngle)); - let place = Vector2D.average([position, target]); - let placeAngle = actualAngle + addAngle / 2; + const addAngle = scaleFactor * (wallEle.length - overlap) / radius; + const target = Vector2D.add(center, new Vector2D(radius, 0).rotate(-actualAngle - addAngle)); + const place = Vector2D.average([position, target]); + const placeAngle = actualAngle + addAngle / 2; // Indent correction place.sub(new Vector2D(wallEle.indent, 0).rotate(-placeAngle)); @@ -622,7 +622,7 @@ // Placement if (wallEle.templateName && g_Map.inMapBounds(place) && constraint.allows(place.clone().floor())) { - let entity = g_Map.placeEntityPassable(wallEle.templateName, playerId, place, placeAngle + wallEle.angle); + const entity = g_Map.placeEntityPassable(wallEle.templateName, playerId, place, placeAngle + wallEle.angle); if (entity) entities.push(entity); } @@ -634,11 +634,11 @@ if (endWithFirst) { - let wallEle = getWallElement(wallPart[0], style); - let addAngle = scaleFactor * wallEle.length / radius; - let target = Vector2D.add(center, new Vector2D(radius, 0).rotate(-actualAngle - addAngle)); - let place = Vector2D.average([position, target]); - let placeAngle = actualAngle + addAngle / 2; + const wallEle = getWallElement(wallPart[0], style); + const addAngle = scaleFactor * wallEle.length / radius; + const target = Vector2D.add(center, new Vector2D(radius, 0).rotate(-actualAngle - addAngle)); + const place = Vector2D.average([position, target]); + const placeAngle = actualAngle + addAngle / 2; if (g_Map.inMapBounds(place) && constraint.allows(place.clone().floor())) entities.push(g_Map.placeEntityPassable(wallEle.templateName, playerId, place, placeAngle + wallEle.angle)); } @@ -668,28 +668,28 @@ style = validateStyle(style, playerId); let entities = []; - let constraint = new StaticConstraint(constraints); - let angleAdd = Math.PI * 2 / numCorners; - let angleStart = orientation - angleAdd / 2; - let corners = new Array(numCorners).fill(0).map((zero, i) => + const constraint = new StaticConstraint(constraints); + const angleAdd = Math.PI * 2 / numCorners; + const angleStart = orientation - angleAdd / 2; + const corners = new Array(numCorners).fill(0).map((zero, i) => Vector2D.add(centerPosition, new Vector2D(radius, 0).rotate(-angleStart - i * angleAdd))); for (let i = 0; i < numCorners; ++i) { - let angleToCorner = getAngle(corners[i].x, corners[i].y, centerPosition.x, centerPosition.y); + const angleToCorner = getAngle(corners[i].x, corners[i].y, centerPosition.x, centerPosition.y); if (g_Map.inMapBounds(corners[i]) && constraint.allows(corners[i].clone().floor())) { - let entity = g_Map.placeEntityPassable(getWallElement(cornerWallElement, style).templateName, playerId, corners[i], angleToCorner); + const entity = g_Map.placeEntityPassable(getWallElement(cornerWallElement, style).templateName, playerId, corners[i], angleToCorner); if (entity) entities.push(entity); } if (!skipFirstWall || i != 0) { - let cornerLength = getWallElement(cornerWallElement, style).length / 2; - let cornerAngle = angleToCorner + angleAdd / 2; - let targetCorner = (i + 1) % numCorners; - let cornerPosition = new Vector2D(cornerLength, 0).rotate(-cornerAngle).perpendicular(); + const cornerLength = getWallElement(cornerWallElement, style).length / 2; + const cornerAngle = angleToCorner + angleAdd / 2; + const targetCorner = (i + 1) % numCorners; + const cornerPosition = new Vector2D(cornerLength, 0).rotate(-cornerAngle).perpendicular(); entities = entities.concat( placeLinearWall( @@ -734,11 +734,11 @@ // Generating a generic wall part assortment with each wall part including 1 gate lengthened by walls and towers // NOTE: It might be a good idea to write an own function for that... - let defaultWallPartsAssortment = [["short"], ["medium"], ["long"], ["gate", "tower", "short"]]; - let centeredWallPart = ["gate"]; - let extendingWallPartAssortment = [["tower", "long"], ["tower", "medium"]]; + const defaultWallPartsAssortment = [["short"], ["medium"], ["long"], ["gate", "tower", "short"]]; + const centeredWallPart = ["gate"]; + const extendingWallPartAssortment = [["tower", "long"], ["tower", "medium"]]; defaultWallPartsAssortment.push(centeredWallPart); - for (let assortment of extendingWallPartAssortment) + for (const assortment of extendingWallPartAssortment) { let wallPart = centeredWallPart; for (let j = 0; j < radius; ++j) @@ -760,7 +760,7 @@ // Setup angles let angleToCover = Math.PI * 2; - let angleAddList = []; + const angleAddList = []; for (let i = 0; i < numCorners; ++i) { // Randomize covered angles. Variety scales down with raising angle though... @@ -769,7 +769,7 @@ } // Setup corners - let corners = []; + const corners = []; let angleActual = orientation - angleAddList[0] / 2; for (let i = 0; i < numCorners; ++i) { @@ -780,28 +780,28 @@ } // Setup best wall parts for the different walls (a bit confusing naming...) - let wallPartLengths = []; + const wallPartLengths = []; let maxWallPartLength = 0; - for (let wallPart of wallPartsAssortment) + for (const wallPart of wallPartsAssortment) { - let length = getWallLength(style, wallPart); + const length = getWallLength(style, wallPart); wallPartLengths.push(length); if (length > maxWallPartLength) maxWallPartLength = length; } - let wallPartList = []; // This is the list of the wall parts to use for the walls between the corners, not to confuse with wallPartsAssortment! + const wallPartList = []; // This is the list of the wall parts to use for the walls between the corners, not to confuse with wallPartsAssortment! for (let i = 0; i < numCorners; ++i) { let bestWallPart = []; // This is a simple wall part not a wallPartsAssortment! let bestWallLength = Infinity; - let targetCorner = (i + 1) % numCorners; + const targetCorner = (i + 1) % numCorners; // NOTE: This is not quite the length the wall will be in the end. Has to be tweaked... - let wallLength = corners[i].distanceTo(corners[targetCorner]); - let numWallParts = Math.ceil(wallLength / maxWallPartLength); + const wallLength = corners[i].distanceTo(corners[targetCorner]); + const numWallParts = Math.ceil(wallLength / maxWallPartLength); for (let partIndex = 0; partIndex < wallPartsAssortment.length; ++partIndex) { - let linearWallLength = numWallParts * wallPartLengths[partIndex]; + const linearWallLength = numWallParts * wallPartLengths[partIndex]; if (linearWallLength < bestWallLength && linearWallLength > wallLength) { bestWallPart = wallPartsAssortment[partIndex]; @@ -813,20 +813,20 @@ // Place Corners and walls let entities = []; - let constraint = new StaticConstraint(constraints); + const constraint = new StaticConstraint(constraints); for (let i = 0; i < numCorners; ++i) { - let angleToCorner = getAngle(corners[i].x, corners[i].y, centerPosition.x, centerPosition.y); + const angleToCorner = getAngle(corners[i].x, corners[i].y, centerPosition.x, centerPosition.y); if (g_Map.inMapBounds(corners[i]) && constraint.allows(corners[i].clone().floor())) entities.push( g_Map.placeEntityPassable(getWallElement(cornerWallElement, style).templateName, playerId, corners[i], angleToCorner)); if (!skipFirstWall || i != 0) { - let cornerLength = getWallElement(cornerWallElement, style).length / 2; - let targetCorner = (i + 1) % numCorners; - let startAngle = angleToCorner + angleAddList[i] / 2; - let targetAngle = angleToCorner + angleAddList[targetCorner] / 2; + const cornerLength = getWallElement(cornerWallElement, style).length / 2; + const targetCorner = (i + 1) % numCorners; + const startAngle = angleToCorner + angleAddList[i] / 2; + const targetAngle = angleToCorner + angleAddList[targetCorner] / 2; entities = entities.concat( placeLinearWall( @@ -867,10 +867,10 @@ style = validateStyle(style, playerId); // Setup some vars - let startAngle = randomAngle(); - let actualOff = new Vector2D(radius, 0).rotate(-startAngle); + const startAngle = randomAngle(); + const actualOff = new Vector2D(radius, 0).rotate(-startAngle); let actualAngle = startAngle; - let pointDistance = getWallLength(style, ["long", "tower"]); + const pointDistance = getWallLength(style, ["long", "tower"]); // Searching for a well fitting point derivation let tries = 0; @@ -879,20 +879,20 @@ let overlap; while (tries < maxTries && minOverlap > g_WallStyles[style].overlap) { - let pointDerivation = []; + const pointDerivation = []; let distanceToTarget = 1000; while (true) { - let indent = randFloat(-irregularity * pointDistance, irregularity * pointDistance); - let tmp = new Vector2D(radius + indent, 0).rotate(-actualAngle - pointDistance / radius); - let tmpAngle = getAngle(actualOff.x, actualOff.y, tmp.x, tmp.y); + const indent = randFloat(-irregularity * pointDistance, irregularity * pointDistance); + const tmp = new Vector2D(radius + indent, 0).rotate(-actualAngle - pointDistance / radius); + const tmpAngle = getAngle(actualOff.x, actualOff.y, tmp.x, tmp.y); actualOff.add(new Vector2D(pointDistance, 0).rotate(-tmpAngle)); actualAngle = getAngle(0, 0, actualOff.x, actualOff.y); pointDerivation.push(actualOff.clone()); distanceToTarget = pointDerivation[0].distanceTo(actualOff); - let numPoints = pointDerivation.length; + const numPoints = pointDerivation.length; if (numPoints > 3 && distanceToTarget < pointDistance) // Could be done better... { overlap = pointDistance - pointDerivation[numPoints - 1].distanceTo(pointDerivation[0]); @@ -910,12 +910,12 @@ log("placeGenericFortress: Reduced overlap to " + minOverlap + " after " + tries + " tries"); // Place wall - let entities = []; - let constraint = new StaticConstraint(constraints); + const entities = []; + const constraint = new StaticConstraint(constraints); for (let pointIndex = 0; pointIndex < bestPointDerivation.length; ++pointIndex) { let start = Vector2D.add(center, bestPointDerivation[pointIndex]); - let target = Vector2D.add(center, bestPointDerivation[(pointIndex + 1) % bestPointDerivation.length]); + const target = Vector2D.add(center, bestPointDerivation[(pointIndex + 1) % bestPointDerivation.length]); let angle = getAngle(start.x, start.y, target.x, target.y); let element = (pointIndex + 1) % gateOccurence == 0 ? "gate" : "long"; @@ -923,7 +923,7 @@ if (element.templateName) { - let pos = Vector2D.add(start, new Vector2D(start.distanceTo(target) / 2, 0).rotate(-angle)); + const pos = Vector2D.add(start, new Vector2D(start.distanceTo(target) / 2, 0).rotate(-angle)); if (g_Map.inMapBounds(pos) && constraint.allows(pos.clone().floor())) entities.push(g_Map.placeEntityPassable(element.templateName, playerId, pos, angle - Math.PI / 2 + element.angle)); } @@ -932,8 +932,8 @@ start = Vector2D.add(center, bestPointDerivation[(pointIndex + bestPointDerivation.length - 1) % bestPointDerivation.length]); angle = getAngle(start.x, start.y, target.x, target.y); - let tower = getWallElement("tower", style); - let pos = Vector2D.add(center, bestPointDerivation[pointIndex]); + const tower = getWallElement("tower", style); + const pos = Vector2D.add(center, bestPointDerivation[pointIndex]); if (g_Map.inMapBounds(pos) && constraint.allows(pos.clone().floor())) entities.push( g_Map.placeEntityPassable(tower.templateName, playerId, pos, angle - Math.PI / 2 + tower.angle)); Index: binaries/data/mods/public/maps/random/rmgen/Area.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/Area.js +++ binaries/data/mods/public/maps/random/rmgen/Area.js @@ -6,10 +6,10 @@ { this.points = deepfreeze(points); - let mapSize = g_Map.getSize(); + const mapSize = g_Map.getSize(); this.cache = new Array(mapSize).fill(0).map(() => new Uint8Array(mapSize)); - for (let point of points) + for (const point of points) this.cache[point.x][point.y] = 1; } @@ -31,9 +31,9 @@ let closestPoint = this.points[0]; let shortestDistance = Infinity; - for (let point of this.points) + for (const point of this.points) { - let currentDistance = point.distanceToSquared(position); + const currentDistance = point.distanceToSquared(position); if (currentDistance < shortestDistance) { shortestDistance = currentDistance; Index: binaries/data/mods/public/maps/random/rmgen/Constraint.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/Constraint.js +++ binaries/data/mods/public/maps/random/rmgen/Constraint.js @@ -214,7 +214,7 @@ */ function StaticConstraint(constraints) { - let mapSize = g_Map.getSize(); + const mapSize = g_Map.getSize(); this.constraint = new AndConstraint(constraints); this.cache = new Array(mapSize).fill(0).map(() => new Uint8Array(mapSize)); Index: binaries/data/mods/public/maps/random/rmgen/Group.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/Group.js +++ binaries/data/mods/public/maps/random/rmgen/Group.js @@ -41,9 +41,9 @@ // Test if the Objects can be placed at the given location // Place none of them if one can't be placed. - for (let object of this.objects) + for (const object of this.objects) { - let entitySpecs = object.place(this.centerPosition, playerID, avoidPositions, constraint, 30); + const entitySpecs = object.place(this.centerPosition, playerID, avoidPositions, constraint, 30); if (!entitySpecs) return undefined; @@ -58,8 +58,8 @@ } // Create and place entities as specified - let entities = []; - for (let entitySpecs of entitySpecsResult) + const entities = []; + for (const entitySpecs of entitySpecsResult) { // The Object must ensure that non-actor entities are not placed at the impassable map-border entities.push( Index: binaries/data/mods/public/maps/random/rmgen/Noise.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/Noise.js +++ binaries/data/mods/public/maps/random/rmgen/Noise.js @@ -7,7 +7,7 @@ // Find mod of number but only positive values function modPos(num, m) { - var p = num % m; + let p = num % m; if (p < 0) p += m; @@ -27,12 +27,12 @@ this.freq = freq; this.grads = []; - for (var i=0; i < freq; ++i) + for (let i=0; i < freq; ++i) { this.grads[i] = []; - for (var j=0; j < freq; ++j) + for (let j=0; j < freq; ++j) { - var a = randomAngle(); + let a = randomAngle(); this.grads[i][j] = new Vector2D(Math.cos(a), Math.sin(a)); } } @@ -43,24 +43,24 @@ x *= this.freq; y *= this.freq; - var ix = modPos(Math.floor(x), this.freq); - var iy = modPos(Math.floor(y), this.freq); + let ix = modPos(Math.floor(x), this.freq); + let iy = modPos(Math.floor(y), this.freq); - var fx = x - ix; - var fy = y - iy; + let fx = x - ix; + let fy = y - iy; - var ix1 = (ix+1) % this.freq; - var iy1 = (iy+1) % this.freq; + let ix1 = (ix+1) % this.freq; + let iy1 = (iy+1) % this.freq; - var s = this.grads[ix][iy].dot(new Vector2D(fx, fy)); - var t = this.grads[ix1][iy].dot(new Vector2D(fx-1, fy)); - var u = this.grads[ix][iy1].dot(new Vector2D(fx, fy-1)); - var v = this.grads[ix1][iy1].dot(new Vector2D(fx-1, fy-1)); + let s = this.grads[ix][iy].dot(new Vector2D(fx, fy)); + let t = this.grads[ix1][iy].dot(new Vector2D(fx-1, fy)); + let u = this.grads[ix][iy1].dot(new Vector2D(fx, fy-1)); + let v = this.grads[ix1][iy1].dot(new Vector2D(fx-1, fy-1)); - var ex = easeCurve(fx); - var ey = easeCurve(fy); - var a = s + ex*(t-s); - var b = u + ex*(v-u); + let ex = easeCurve(fx); + let ey = easeCurve(fy); + let a = s + ex*(t-s); + let b = u + ex*(v-u); return (a + ey*(b-a)) * 0.5 + 0.5; }; @@ -79,15 +79,15 @@ this.vfreq = vfreq; this.grads = []; - for (var i=0; i < freq; ++i) + for (let i=0; i < freq; ++i) { this.grads[i] = []; - for (var j=0; j < freq; ++j) + for (let j=0; j < freq; ++j) { this.grads[i][j] = []; - for(var k=0; k < vfreq; ++k) + for(let k=0; k < vfreq; ++k) { - var v = new Vector3D(); + let v = new Vector3D(); do { v.set(randFloat(-1, 1), randFloat(-1, 1), randFloat(-1, 1)); @@ -108,39 +108,39 @@ y *= this.freq; z *= this.vfreq; - var ix =modPos(Math.floor(x), this.freq); - var iy = modPos(Math.floor(y), this.freq); - var iz = modPos(Math.floor(z), this.vfreq); + let ix =modPos(Math.floor(x), this.freq); + let iy = modPos(Math.floor(y), this.freq); + let iz = modPos(Math.floor(z), this.vfreq); - var fx = x - ix; - var fy = y - iy; - var fz = z - iz; + let fx = x - ix; + let fy = y - iy; + let fz = z - iz; - var ix1 = (ix+1) % this.freq; - var iy1 = (iy+1) % this.freq; - var iz1 = (iz+1) % this.vfreq; + let ix1 = (ix+1) % this.freq; + let iy1 = (iy+1) % this.freq; + let iz1 = (iz+1) % this.vfreq; - var s0 = this.grads[ix][iy][iz].dot(new Vector3D(fx, fy, fz)); - var t0 = this.grads[ix1][iy][iz].dot(new Vector3D(fx-1, fy, fz)); - var u0 = this.grads[ix][iy1][iz].dot(new Vector3D(fx, fy-1, fz)); - var v0 = this.grads[ix1][iy1][iz].dot(new Vector3D(fx-1, fy-1, fz)); + let s0 = this.grads[ix][iy][iz].dot(new Vector3D(fx, fy, fz)); + let t0 = this.grads[ix1][iy][iz].dot(new Vector3D(fx-1, fy, fz)); + let u0 = this.grads[ix][iy1][iz].dot(new Vector3D(fx, fy-1, fz)); + let v0 = this.grads[ix1][iy1][iz].dot(new Vector3D(fx-1, fy-1, fz)); - var s1 = this.grads[ix][iy][iz1].dot(new Vector3D(fx, fy, fz-1)); - var t1 = this.grads[ix1][iy][iz1].dot(new Vector3D(fx-1, fy, fz-1)); - var u1 = this.grads[ix][iy1][iz1].dot(new Vector3D(fx, fy-1, fz-1)); - var v1 = this.grads[ix1][iy1][iz1].dot(new Vector3D(fx-1, fy-1, fz-1)); + let s1 = this.grads[ix][iy][iz1].dot(new Vector3D(fx, fy, fz-1)); + let t1 = this.grads[ix1][iy][iz1].dot(new Vector3D(fx-1, fy, fz-1)); + let u1 = this.grads[ix][iy1][iz1].dot(new Vector3D(fx, fy-1, fz-1)); + let v1 = this.grads[ix1][iy1][iz1].dot(new Vector3D(fx-1, fy-1, fz-1)); - var ex = easeCurve(fx); - var ey = easeCurve(fy); - var ez = easeCurve(fz); + let ex = easeCurve(fx); + let ey = easeCurve(fy); + let ez = easeCurve(fz); - var a0 = s0 + ex*(t0-s0); - var b0 = u0 + ex*(v0-u0); - var c0 = a0 + ey*(b0-a0); + let a0 = s0 + ex*(t0-s0); + let b0 = u0 + ex*(v0-u0); + let c0 = a0 + ey*(b0-a0); - var a1 = s1 + ex*(t1-s1); - var b1 = u1 + ex*(v1-u1); - var c1 = a1 + ey*(b1-a1); + let a1 = s1 + ex*(t1-s1); + let b1 = u1 + ex*(v1-u1); + let c1 = a1 + ey*(b1-a1); return (c0 + ez*(c1-c0)) * 0.5 + 0.5; }; Index: binaries/data/mods/public/maps/random/rmgen/Object.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/Object.js +++ binaries/data/mods/public/maps/random/rmgen/Object.js @@ -28,17 +28,17 @@ SimpleObject.prototype.place = function(centerPosition, playerID, avoidPositions, constraint, maxRetries) { - let entitySpecs = []; + const entitySpecs = []; let numRetries = 0; - let validTile = pos => this.templateName.startsWith(g_ActorPrefix) ? g_Map.validTile(pos) : g_Map.validTilePassable(pos); + const validTile = pos => this.templateName.startsWith(g_ActorPrefix) ? g_Map.validTile(pos) : g_Map.validTilePassable(pos); for (let i = 0; i < randIntInclusive(this.minCount, this.maxCount); ++i) while (true) { - let distance = randFloat(this.minDistance, this.maxDistance); - let angle = randomAngle(); + const distance = randFloat(this.minDistance, this.maxDistance); + const angle = randomAngle(); - let position = Vector2D.sum([centerPosition, new Vector2D(0.5, 0.5), new Vector2D(distance, 0).rotate(-angle)]); + const position = Vector2D.sum([centerPosition, new Vector2D(0.5, 0.5), new Vector2D(distance, 0).rotate(-angle)]); if (validTile(position) && (!avoidPositions || Index: binaries/data/mods/public/maps/random/rmgen/RandomMap.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/RandomMap.js +++ binaries/data/mods/public/maps/random/rmgen/RandomMap.js @@ -71,9 +71,9 @@ RandomMap.prototype.LoadMapTerrain = function(filename) { g_Map.log("Loading terrain file " + filename); - let mapTerrain = Engine.LoadMapTerrain("maps/random/" + filename + ".pmp"); + const mapTerrain = Engine.LoadMapTerrain("maps/random/" + filename + ".pmp"); - let heightmapPainter = new HeightmapPainter(convertHeightmap1Dto2D(mapTerrain.height)); + const heightmapPainter = new HeightmapPainter(convertHeightmap1Dto2D(mapTerrain.height)); createArea( new MapBoundsPlacer(), @@ -94,7 +94,7 @@ { g_Map.log("Loading heightmap " + filename); - let heightmapPainter = new HeightmapPainter( + const heightmapPainter = new HeightmapPainter( convertHeightmap1Dto2D(Engine.LoadHeightmapImage("maps/random/" + filename)), normalMinHeight, normalMaxHeight); createArea( @@ -113,7 +113,7 @@ if (texture in this.nameToID) return this.nameToID[texture]; - let id = this.IDToName.length; + const id = this.IDToName.length; this.nameToID[texture] = id; this.IDToName[id] = texture; @@ -217,7 +217,7 @@ */ RandomMap.prototype.randomCoordinate = function(passableOnly) { - let border = passableOnly ? MAP_BORDER_WIDTH : 0; + const border = passableOnly ? MAP_BORDER_WIDTH : 0; if (this.isCircularMap()) // Polar coordinates @@ -278,7 +278,7 @@ */ RandomMap.prototype.placeEntityAnywhere = function(templateName, playerID, position, orientation) { - let entity = new Entity(this.getEntityID(), templateName, playerID, position, orientation); + const entity = new Entity(this.getEntityID(), templateName, playerID, position, orientation); this.entities.push(entity); return entity; }; @@ -310,7 +310,7 @@ */ RandomMap.prototype.setTerrainEntity = function(templateName, playerID, position, orientation) { - let tilePosition = position.clone().floor(); + const tilePosition = position.clone().floor(); if (!this.validTilePassable(tilePosition)) throw new Error("setTerrainEntity: invalid tile position " + uneval(position)); @@ -320,7 +320,7 @@ RandomMap.prototype.deleteTerrainEntity = function(position) { - let tilePosition = position.clone().floor(); + const tilePosition = position.clone().floor(); if (!this.validTilePassable(tilePosition)) throw new Error("setTerrainEntity: invalid tile position " + uneval(position)); @@ -337,15 +337,15 @@ */ RandomMap.prototype.getExactHeight = function(position) { - let xi = Math.min(Math.floor(position.x), this.size); - let zi = Math.min(Math.floor(position.y), this.size); - let xf = position.x - xi; - let zf = position.y - zi; + const xi = Math.min(Math.floor(position.x), this.size); + const zi = Math.min(Math.floor(position.y), this.size); + const xf = position.x - xi; + const zf = position.y - zi; - let h00 = this.height[xi][zi]; - let h01 = this.height[xi][zi + 1]; - let h10 = this.height[xi + 1][zi]; - let h11 = this.height[xi + 1][zi + 1]; + const h00 = this.height[xi][zi]; + const h01 = this.height[xi][zi + 1]; + const h10 = this.height[xi + 1][zi]; + const h11 = this.height[xi + 1][zi + 1]; return (1 - zf) * ((1 - xf) * h00 + xf * h10) + zf * ((1 - xf) * h01 + xf * h11); }; @@ -356,9 +356,9 @@ let count = 0; let sumHeight = 0; - for (let vertex of g_TileVertices) + for (const vertex of g_TileVertices) { - let pos = Vector2D.sub(position, vertex); + const pos = Vector2D.sub(position, vertex); if (this.validHeight(pos)) { ++count; @@ -374,11 +374,11 @@ RandomMap.prototype.getAdjacentPoints = function(position) { - let adjacentPositions = []; + const adjacentPositions = []; - for (let adjacentCoordinate of g_AdjacentCoordinates) + for (const adjacentCoordinate of g_AdjacentCoordinates) { - let adjacentPos = Vector2D.add(position, adjacentCoordinate).round(); + const adjacentPos = Vector2D.add(position, adjacentCoordinate).round(); if (this.inMapBounds(adjacentPos)) adjacentPositions.push(adjacentPos); } @@ -391,7 +391,7 @@ */ RandomMap.prototype.getAverageHeight = function(position) { - let adjacentPositions = this.getAdjacentPoints(position); + const adjacentPositions = this.getAdjacentPoints(position); if (!adjacentPositions.length) return 0; @@ -403,7 +403,7 @@ */ RandomMap.prototype.getSlope = function(position) { - let adjacentPositions = this.getAdjacentPoints(position); + const adjacentPositions = this.getAdjacentPoints(position); if (!adjacentPositions.length) return 0; @@ -416,10 +416,10 @@ */ RandomMap.prototype.exportEntityList = function() { - let nonTerrainCount = this.entities.length; + const nonTerrainCount = this.entities.length; // Change rotation from simple 2d to 3d befor giving to engine - for (let entity of this.entities) + for (const entity of this.entities) entity.rotation.y = Math.PI / 2 - entity.rotation.y; // Terrain objects e.g. trees @@ -441,14 +441,14 @@ */ RandomMap.prototype.exportHeightData = function() { - let heightmapSize = this.size + 1; - let heightmap = new Uint16Array(Math.square(heightmapSize)); + const heightmapSize = this.size + 1; + const heightmap = new Uint16Array(Math.square(heightmapSize)); for (let x = 0; x < heightmapSize; ++x) for (let z = 0; z < heightmapSize; ++z) { - let position = new Vector2D(x, z); - let currentHeight = TILE_CENTERED_HEIGHT_MAP ? this.cornerHeight(position) : this.getHeight(position); + const position = new Vector2D(x, z); + const currentHeight = TILE_CENTERED_HEIGHT_MAP ? this.cornerHeight(position) : this.getHeight(position); // Correct height by SEA_LEVEL and prevent under/overflow in terrain data heightmap[z * heightmapSize + x] = Math.max(0, Math.min(0xFFFF, Math.floor((currentHeight + SEA_LEVEL) * HEIGHT_UNITS_PER_METRE))); @@ -462,8 +462,8 @@ */ RandomMap.prototype.exportTerrainTextures = function() { - let tileIndex = new Uint16Array(Math.square(this.size)); - let tilePriority = new Uint16Array(Math.square(this.size)); + const tileIndex = new Uint16Array(Math.square(this.size)); + const tilePriority = new Uint16Array(Math.square(this.size)); for (let x = 0; x < this.size; ++x) for (let z = 0; z < this.size; ++z) Index: binaries/data/mods/public/maps/random/rmgen/library.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/library.js +++ binaries/data/mods/public/maps/random/rmgen/library.js @@ -50,9 +50,9 @@ function getObstructionSize(templateName, margin = 0) { - let obstruction = Engine.GetTemplate(templateName).Obstruction; + const obstruction = Engine.GetTemplate(templateName).Obstruction; - let obstructionSize = + const obstructionSize = obstruction.Static ? new Vector2D(obstruction.Static["@depth"], obstruction.Static["@width"]) : // Used for gates, should consider the position too @@ -110,14 +110,14 @@ */ function retryPlacing(placeFunc, retryFactor, amount, behaveDeprecated = false) { - let maxFail = amount * retryFactor; + const maxFail = amount * retryFactor; - let results = []; + const results = []; let bad = 0; while (results.length < amount && bad <= maxFail) { - let result = placeFunc(); + const result = placeFunc(); if (result !== undefined || behaveDeprecated) results.push(result); @@ -146,7 +146,7 @@ */ function createAreas(centeredPlacer, painter, constraints, amount, retryFactor = 10) { - let placeFunc = function() { + const placeFunc = function() { centeredPlacer.setCenterPosition(g_Map.randomCoordinate(false)); return createArea(centeredPlacer, painter, constraints); }; @@ -162,11 +162,11 @@ { areas = areas.filter(area => area.getPoints().length); if (!areas.length) { - log("createAreasInAreas: 'areas' was either empty or only contained empty areas thus returning an empty array.\n" + new Error().stack) + log("createAreasInAreas: 'areas' was either empty or only contained empty areas thus returning an empty array.\n" + new Error().stack); return []; } - let placeFunc = function() { + const placeFunc = function() { centeredPlacer.setCenterPosition(pickRandom(pickRandom(areas).getPoints())); return createArea(centeredPlacer, painter, constraints); }; @@ -180,7 +180,7 @@ */ function createObjectGroups(group, player, constraints, amount, retryFactor = 10, behaveDeprecated = false) { - let placeFunc = function() { + const placeFunc = function() { group.setCenterPosition(g_Map.randomCoordinate(true)); return createObjectGroup(group, player, constraints); }; @@ -196,11 +196,11 @@ { areas = areas.filter(area => area.getPoints().length); if (!areas.length) { - log("createObjectGroupsByAreas: 'areas' was either empty or only contained empty areas.\n" + new Error().stack) + log("createObjectGroupsByAreas: 'areas' was either empty or only contained empty areas.\n" + new Error().stack); return []; } - let placeFunc = function() { + const placeFunc = function() { group.setCenterPosition(pickRandom(pickRandom(areas).getPoints())); return createObjectGroup(group, player, constraints); }; @@ -221,11 +221,11 @@ */ function createArea(placer, painters, constraints) { - let points = placer.place(new AndConstraint(constraints)); + const points = placer.place(new AndConstraint(constraints)); if (!points) return undefined; - let area = new Area(points); + const area = new Area(points); new MultiPainter(painters).paint(area); @@ -270,7 +270,7 @@ */ function avoidClasses(/*class1, dist1, class2, dist2, etc*/) { - let ar = []; + const ar = []; for (let i = 0; i < arguments.length/2; ++i) ar.push(new AvoidTileClassConstraint(arguments[2*i], arguments[2*i+1])); @@ -286,7 +286,7 @@ */ function stayClasses(/*class1, dist1, class2, dist2, etc*/) { - let ar = []; + const ar = []; for (let i = 0; i < arguments.length/2; ++i) ar.push(new StayInTileClassConstraint(arguments[2*i], arguments[2*i+1])); @@ -302,7 +302,7 @@ */ function borderClasses(/*class1, idist1, odist1, class2, idist2, odist2, etc*/) { - let ar = []; + const ar = []; for (let i = 0; i < arguments.length/3; ++i) ar.push(new BorderTileClassConstraint(arguments[3*i], arguments[3*i+1], arguments[3*i+2])); @@ -318,7 +318,7 @@ */ function extractHeightmap(heightmap, topLeft, size) { - let result = []; + const result = []; for (let x = 0; x < size; ++x) { result[x] = new Float32Array(size); @@ -330,8 +330,8 @@ function convertHeightmap1Dto2D(heightmap) { - let result = []; - let hmSize = Math.sqrt(heightmap.length); + const result = []; + const hmSize = Math.sqrt(heightmap.length); for (let x = 0; x < hmSize; ++x) { result[x] = new Float32Array(hmSize); @@ -351,6 +351,6 @@ */ function getDifficulty() { - let level = g_MapSettings.TriggerDifficulty || 3; + const level = g_MapSettings.TriggerDifficulty || 3; return getDifficulties().find(difficulty => difficulty.Difficulty == level).Difficulty; } Index: binaries/data/mods/public/maps/random/rmgen/math.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/math.js +++ binaries/data/mods/public/maps/random/rmgen/math.js @@ -44,8 +44,8 @@ */ function distributePointsOnCircularSegment(pointCount, maxAngle, startAngle, radius, center) { - let points = []; - let angle = []; + const points = []; + const angle = []; pointCount = Math.round(pointCount); for (let i = 0; i < pointCount; ++i) @@ -75,9 +75,9 @@ */ function testLineIntersection(start1, end1, start2, end2, width) { - let start1end1 = Vector2D.sub(start1, end1); - let start2end2 = Vector2D.sub(start2, end2); - let start1start2 = Vector2D.sub(start1, start2); + const start1end1 = Vector2D.sub(start1, end1); + const start2end2 = Vector2D.sub(start2, end2); + const start1start2 = Vector2D.sub(start1, start2); return ( Math.abs(distanceOfPointFromLine(start1, end1, start2)) < width || @@ -93,10 +93,10 @@ */ function getBoundingBox(points) { - let min = points[0].clone(); - let max = points[0].clone(); + const min = points[0].clone(); + const max = points[0].clone(); - for (let point of points) + for (const point of points) { min.set(Math.min(min.x, point.x), Math.min(min.y, point.y)); max.set(Math.max(max.x, point.x), Math.max(max.y, point.y)); @@ -110,7 +110,7 @@ function getPointsInBoundingBox(boundingBox) { - let points = []; + const points = []; for (let x = boundingBox.min.x; x <= boundingBox.max.x; ++x) for (let y = boundingBox.min.y; y <= boundingBox.max.y; ++y) points.push(new Vector2D(x, y)); @@ -124,8 +124,8 @@ */ function sortPointsShortestCycle(points) { - let order = []; - let distances = []; + const order = []; + const distances = []; if (points.length <= 3) { for (let i = 0; i < points.length; ++i) @@ -135,7 +135,7 @@ } // Just add the first 3 points - let pointsToAdd = points.map(p => p.clone()); + const pointsToAdd = points.map(p => p.clone()); for (let i = 0; i < 3; ++i) { order.push(i); @@ -147,7 +147,7 @@ distances.push(points[order[0]].distanceTo(points[order[order.length - 1]])); // Add remaining points so the path lengthens the least - let numPointsToAdd = pointsToAdd.length; + const numPointsToAdd = pointsToAdd.length; for (let i = 0; i < numPointsToAdd; ++i) { let indexToAddTo; @@ -156,10 +156,10 @@ let minDist2 = 0; for (let k = 0; k < order.length; ++k) { - let dist1 = pointsToAdd[0].distanceTo(points[order[k]]); - let dist2 = pointsToAdd[0].distanceTo(points[order[(k + 1) % order.length]]); + const dist1 = pointsToAdd[0].distanceTo(points[order[k]]); + const dist2 = pointsToAdd[0].distanceTo(points[order[(k + 1) % order.length]]); - let enlengthen = dist1 + dist2 - distances[k]; + const enlengthen = dist1 + dist2 - distances[k]; if (enlengthen < minEnlengthen) { indexToAddTo = k; Index: binaries/data/mods/public/maps/random/rmgen/painter/CityPainter.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/painter/CityPainter.js +++ binaries/data/mods/public/maps/random/rmgen/painter/CityPainter.js @@ -7,7 +7,7 @@ this.playerID = playerID; this.templates = templates.map(template => { - let obstructionSize = getObstructionSize(template.templateName, template.margin || 0); + const obstructionSize = getObstructionSize(template.templateName, template.margin || 0); return { "templateName": template.templateName, "maxCount": template.maxCount !== undefined ? template.maxCount : Infinity, @@ -27,42 +27,42 @@ { let templates = this.templates; - let templateCounts = {}; - for (let template of this.templates) + const templateCounts = {}; + for (const template of this.templates) templateCounts[template.templateName] = 0; - let mapCenter = g_Map.getCenter(); - let mapSize = g_Map.getSize(); + const mapCenter = g_Map.getCenter(); + const mapSize = g_Map.getSize(); // TODO: Due to the rounding, this is wasting a lot of space. // The city would be much denser if it would test for actual shape intersection or // if it would use a custom, more fine-grained obstruction grid - let tileClass = g_Map.createTileClass(); + const tileClass = g_Map.createTileClass(); - let processed = new Array(mapSize).fill(0).map(() => new Uint8Array(mapSize)); + const processed = new Array(mapSize).fill(0).map(() => new Uint8Array(mapSize)); for (let x = 0; x < mapSize; x += 0.5) for (let y = 0; y < mapSize; y += 0.5) { - let point = new Vector2D(x, y).rotateAround(this.angle, mapCenter).round(); + const point = new Vector2D(x, y).rotateAround(this.angle, mapCenter).round(); if (!area.contains(point) || processed[point.x][point.y] || !g_Map.validTilePassable(point)) continue; processed[point.x][point.y] = 1; - for (let template of shuffleArray(templates)) + for (const template of shuffleArray(templates)) { if (template.constraint && !template.constraint.allows(point)) continue; // Randomize building angle while keeping it aligned - let buildingAngle = this.angle + randIntInclusive(0, 3) * Math.PI / 2; + const buildingAngle = this.angle + randIntInclusive(0, 3) * Math.PI / 2; // Place the entity if all points are within the boundaries and don't collide with the other entities - let obstructionCorners = template.obstructionCorners.map(obstructionCorner => + const obstructionCorners = template.obstructionCorners.map(obstructionCorner => Vector2D.add(point, obstructionCorner.clone().rotate(buildingAngle))); - let obstructionPoints = new ConvexPolygonPlacer(obstructionCorners, 0).place( + const obstructionPoints = new ConvexPolygonPlacer(obstructionCorners, 0).place( new AndConstraint([new StayAreasConstraint([area]), avoidClasses(tileClass, 0), new PassableMapAreaConstraint()])); if (!obstructionPoints) @@ -73,7 +73,7 @@ if (template.painter) template.painter.paint(new Area(obstructionPoints)); - for (let obstructionPoint of obstructionPoints) + for (const obstructionPoint of obstructionPoints) tileClass.add(obstructionPoint); ++templateCounts[template.templateName]; Index: binaries/data/mods/public/maps/random/rmgen/painter/ElevationBlendingPainter.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/painter/ElevationBlendingPainter.js +++ binaries/data/mods/public/maps/random/rmgen/painter/ElevationBlendingPainter.js @@ -9,6 +9,6 @@ ElevationBlendingPainter.prototype.paint = function(area) { - for (let point of area.getPoints()) + for (const point of area.getPoints()) g_Map.setHeight(point, this.strength * this.targetHeight + (1 - this.strength) * g_Map.getHeight(point)); }; Index: binaries/data/mods/public/maps/random/rmgen/painter/ElevationPainter.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/painter/ElevationPainter.js +++ binaries/data/mods/public/maps/random/rmgen/painter/ElevationPainter.js @@ -8,10 +8,10 @@ ElevationPainter.prototype.paint = function(area) { - for (let point of area.getPoints()) - for (let vertex of g_TileVertices) + for (const point of area.getPoints()) + for (const vertex of g_TileVertices) { - let position = Vector2D.add(point, vertex); + const position = Vector2D.add(point, vertex); if (g_Map.validHeight(position)) g_Map.setHeight(position, this.elevation); } Index: binaries/data/mods/public/maps/random/rmgen/painter/HeightmapPainter.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/painter/HeightmapPainter.js +++ binaries/data/mods/public/maps/random/rmgen/painter/HeightmapPainter.js @@ -26,37 +26,37 @@ if (this.normalMinHeight === undefined || this.normalMaxHeight === undefined) return height / this.getScale() / HEIGHT_UNITS_PER_METRE; - let minHeight = this.normalMinHeight * (g_Map.getSize() + 1) / 321; - let maxHeight = this.normalMaxHeight * (g_Map.getSize() + 1) / 321; + const minHeight = this.normalMinHeight * (g_Map.getSize() + 1) / 321; + const maxHeight = this.normalMaxHeight * (g_Map.getSize() + 1) / 321; return minHeight + (maxHeight - minHeight) * height / 0xFFFF; }; HeightmapPainter.prototype.paint = function(area) { - let scale = this.getScale(); - let leftBottom = new Vector2D(0, 0); - let rightTop = new Vector2D(this.verticesPerSide, this.verticesPerSide); - let brushSize = new Vector2D(3, 3); - let brushCenter = new Vector2D(1, 1); + const scale = this.getScale(); + const leftBottom = new Vector2D(0, 0); + const rightTop = new Vector2D(this.verticesPerSide, this.verticesPerSide); + const brushSize = new Vector2D(3, 3); + const brushCenter = new Vector2D(1, 1); // Additional complexity to process all 4 vertices of each tile, i.e the last row too - let seen = new Array(g_Map.height.length).fill(0).map(zero => new Uint8Array(g_Map.height.length).fill(0)); + const seen = new Array(g_Map.height.length).fill(0).map(zero => new Uint8Array(g_Map.height.length).fill(0)); - for (let point of area.getPoints()) - for (let vertex of g_TileVertices) + for (const point of area.getPoints()) + for (const vertex of g_TileVertices) { - let vertexPos = Vector2D.add(point, vertex); + const vertexPos = Vector2D.add(point, vertex); if (!g_Map.validHeight(vertexPos) || seen[vertexPos.x][vertexPos.y]) continue; seen[vertexPos.x][vertexPos.y] = 1; - let sourcePos = Vector2D.mult(vertexPos, scale); - let sourceTilePos = sourcePos.clone().floor(); + const sourcePos = Vector2D.mult(vertexPos, scale); + const sourceTilePos = sourcePos.clone().floor(); - let brushPosition = Vector2D.max( + const brushPosition = Vector2D.max( leftBottom, Vector2D.min( Vector2D.sub(sourceTilePos, brushCenter), Index: binaries/data/mods/public/maps/random/rmgen/painter/MultiPainter.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/painter/MultiPainter.js +++ binaries/data/mods/public/maps/random/rmgen/painter/MultiPainter.js @@ -13,6 +13,6 @@ MultiPainter.prototype.paint = function(area) { - for (let painter of this.painters) + for (const painter of this.painters) painter.paint(area); }; Index: binaries/data/mods/public/maps/random/rmgen/painter/RandomElevationPainter.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/painter/RandomElevationPainter.js +++ binaries/data/mods/public/maps/random/rmgen/painter/RandomElevationPainter.js @@ -9,10 +9,10 @@ RandomElevationPainter.prototype.paint = function(area) { - for (let point of area.getPoints()) - for (let vertex of g_TileVertices) + for (const point of area.getPoints()) + for (const vertex of g_TileVertices) { - let position = Vector2D.add(point, vertex); + const position = Vector2D.add(point, vertex); if (g_Map.validHeight(position)) g_Map.setHeight(position, randFloat(this.minHeight, this.maxHeight)); } Index: binaries/data/mods/public/maps/random/rmgen/painter/SmoothElevationPainter.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/painter/SmoothElevationPainter.js +++ binaries/data/mods/public/maps/random/rmgen/painter/SmoothElevationPainter.js @@ -31,11 +31,11 @@ SmoothElevationPainter.prototype.paint = function(area) { // The heightmap grid has one more vertex per side than the tile grid - let heightmapSize = g_Map.height.length; + const heightmapSize = g_Map.height.length; // Remember height inside the area before changing it - let gotHeightPt = []; - let newHeight = []; + const gotHeightPt = []; + const newHeight = []; for (let i = 0; i < heightmapSize; ++i) { gotHeightPt[i] = new Uint8Array(heightmapSize); @@ -43,16 +43,16 @@ } // Get heightmap grid vertices within or adjacent to the area - let brushSize = 2; - let heightPoints = []; - for (let point of area.getPoints()) + const brushSize = 2; + const heightPoints = []; + for (const point of area.getPoints()) for (let dx = -1; dx < 1 + brushSize; ++dx) { - let nx = point.x + dx; + const nx = point.x + dx; for (let dz = -1; dz < 1 + brushSize; ++dz) { - let nz = point.y + dz; - let position = new Vector2D(nx, nz); + const nz = point.y + dz; + const position = new Vector2D(nx, nz); if (g_Map.validHeight(position) && !gotHeightPt[nx][nz]) { @@ -63,7 +63,7 @@ } } - let withinArea = (area, position) => g_TileVertices.some(vertexPos => area.contains(Vector2D.sub(position, vertexPos))); + const withinArea = (area, position) => g_TileVertices.some(vertexPos => area.contains(Vector2D.sub(position, vertexPos))); // Change height inside the area depending on the distance to the border breadthFirstSearchPaint({ @@ -84,7 +84,7 @@ }); // Smooth everything out - for (let point of heightPoints) + for (const point of heightPoints) { if (!withinArea(area, point)) continue; @@ -94,11 +94,11 @@ for (let dx = -1; dx <= 1; ++dx) { - let nx = point.x + dx; + const nx = point.x + dx; for (let dz = -1; dz <= 1; ++dz) { - let nz = point.y + dz; + const nz = point.y + dz; if (g_Map.validHeight(new Vector2D(nx, nz))) { @@ -126,27 +126,27 @@ function breadthFirstSearchPaint(args) { // These variables save which points were visited already and the shortest distance to the area - let saw = []; - let dist = []; + const saw = []; + const dist = []; for (let i = 0; i < args.gridSize; ++i) { saw[i] = new Uint8Array(args.gridSize); dist[i] = new Uint16Array(args.gridSize); } - let withinGrid = (x, z) => Math.min(x, z) >= 0 && Math.max(x, z) < args.gridSize; + const withinGrid = (x, z) => Math.min(x, z) >= 0 && Math.max(x, z) < args.gridSize; // Find all points outside of the area, mark them as seen and set zero distance - let pointQueue = []; - for (let point of args.area.getPoints()) + const pointQueue = []; + for (const point of args.area.getPoints()) // The brushSize is added because the entire brushSize is by definition part of the area for (let dx = -1; dx < 1 + args.brushSize; ++dx) { - let nx = point.x + dx; + const nx = point.x + dx; for (let dz = -1; dz < 1 + args.brushSize; ++dz) { - let nz = point.y + dz; - let position = new Vector2D(nx, nz); + const nz = point.y + dz; + const position = new Vector2D(nx, nz); if (!withinGrid(nx, nz) || args.withinArea(args.area, position) || saw[nx][nz]) continue; @@ -161,8 +161,8 @@ // Call the paintTile method for each point within the area, with distance == 1 for the border. while (pointQueue.length) { - let point = pointQueue.shift(); - let distance = dist[point.x][point.y]; + const point = pointQueue.shift(); + const distance = dist[point.x][point.y]; if (args.withinArea(args.area, point)) args.paintTile(point, distance); @@ -170,11 +170,11 @@ // Enqueue neighboring points for (let dx = -1; dx <= 1; ++dx) { - let nx = point.x + dx; + const nx = point.x + dx; for (let dz = -1; dz <= 1; ++dz) { - let nz = point.y + dz; - let position = new Vector2D(nx, nz); + const nz = point.y + dz; + const position = new Vector2D(nx, nz); if (!withinGrid(nx, nz) || !args.withinArea(args.area, position) || saw[nx][nz]) continue; Index: binaries/data/mods/public/maps/random/rmgen/painter/SmoothingPainter.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/painter/SmoothingPainter.js +++ binaries/data/mods/public/maps/random/rmgen/painter/SmoothingPainter.js @@ -23,20 +23,20 @@ SmoothingPainter.prototype.paint = function(area) { - let brushPoints = getPointsInBoundingBox(getBoundingBox( + const brushPoints = getPointsInBoundingBox(getBoundingBox( new Array(2).fill(0).map((zero, i) => new Vector2D(1, 1).mult(this.size).mult(i ? 1 : -1)))); for (let i = 0; i < this.iterations; ++i) { - let heightmap = clone(g_Map.height); + const heightmap = clone(g_Map.height); // Additional complexity to process all 4 vertices of each tile, i.e the last row too - let seen = new Array(heightmap.length).fill(0).map(zero => new Uint8Array(heightmap.length).fill(0)); + const seen = new Array(heightmap.length).fill(0).map(zero => new Uint8Array(heightmap.length).fill(0)); - for (let point of area.getPoints()) - for (let tileVertex of g_TileVertices) + for (const point of area.getPoints()) + for (const tileVertex of g_TileVertices) { - let vertex = Vector2D.add(point, tileVertex); + const vertex = Vector2D.add(point, tileVertex); if (!g_Map.validHeight(vertex) || seen[vertex.x][vertex.y]) continue; @@ -45,10 +45,10 @@ let sumWeightedHeights = 0; let sumWeights = 0; - for (let brushPoint of brushPoints) + for (const brushPoint of brushPoints) { - let position = Vector2D.add(vertex, brushPoint); - let distance = Math.abs(brushPoint.x) + Math.abs(brushPoint.y); + const position = Vector2D.add(vertex, brushPoint); + const distance = Math.abs(brushPoint.x) + Math.abs(brushPoint.y); if (!distance || !g_Map.validHeight(position)) continue; Index: binaries/data/mods/public/maps/random/rmgen/painter/TerrainPainter.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/painter/TerrainPainter.js +++ binaries/data/mods/public/maps/random/rmgen/painter/TerrainPainter.js @@ -9,6 +9,6 @@ TerrainPainter.prototype.paint = function(area) { - for (let point of area.getPoints()) + for (const point of area.getPoints()) this.terrain.place(point); }; Index: binaries/data/mods/public/maps/random/rmgen/painter/TerrainTextureArrayPainter.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/painter/TerrainTextureArrayPainter.js +++ binaries/data/mods/public/maps/random/rmgen/painter/TerrainTextureArrayPainter.js @@ -13,12 +13,12 @@ TerrainTextureArrayPainter.prototype.paint = function(area) { - let sourceSize = Math.sqrt(this.textureIDs.length); - let scale = sourceSize / g_Map.getSize(); + const sourceSize = Math.sqrt(this.textureIDs.length); + const scale = sourceSize / g_Map.getSize(); - for (let point of area.getPoints()) + for (const point of area.getPoints()) { - let sourcePos = Vector2D.mult(point, scale).floor(); + const sourcePos = Vector2D.mult(point, scale).floor(); g_Map.setTexture(point, this.textureNames[this.textureIDs[sourcePos.x * sourceSize + sourcePos.y]]); } }; Index: binaries/data/mods/public/maps/random/rmgen/painter/TileClassPainter.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/painter/TileClassPainter.js +++ binaries/data/mods/public/maps/random/rmgen/painter/TileClassPainter.js @@ -8,6 +8,6 @@ TileClassPainter.prototype.paint = function(area) { - for (let point of area.getPoints()) + for (const point of area.getPoints()) this.tileClass.add(point); }; Index: binaries/data/mods/public/maps/random/rmgen/painter/TileClassUnPainter.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/painter/TileClassUnPainter.js +++ binaries/data/mods/public/maps/random/rmgen/painter/TileClassUnPainter.js @@ -8,6 +8,6 @@ TileClassUnPainter.prototype.paint = function(area) { - for (let point of area.getPoints()) + for (const point of area.getPoints()) this.tileClass.remove(point); }; Index: binaries/data/mods/public/maps/random/rmgen/placer/centered/ChainPlacer.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/placer/centered/ChainPlacer.js +++ binaries/data/mods/public/maps/random/rmgen/placer/centered/ChainPlacer.js @@ -34,30 +34,30 @@ if (!g_Map.inMapBounds(this.centerPosition) || !constraint.allows(this.centerPosition)) return undefined; - let points = []; + const points = []; let size = g_Map.getSize(); let failed = 0; let count = 0; - let gotRet = new Array(size).fill(0).map(p => new Array(size).fill(-1)); + const gotRet = new Array(size).fill(0).map(p => new Array(size).fill(-1)); --size; this.minRadius = Math.min(this.maxRadius, Math.max(this.minRadius, 1)); - let edges = [this.centerPosition]; + const edges = [this.centerPosition]; for (let i = 0; i < this.numCircles; ++i) { - let chainPos = pickRandom(edges); - let radius = this.queue.length ? this.queue.pop() : randIntInclusive(this.minRadius, this.maxRadius); - let radius2 = Math.square(radius); + const chainPos = pickRandom(edges); + const radius = this.queue.length ? this.queue.pop() : randIntInclusive(this.minRadius, this.maxRadius); + const radius2 = Math.square(radius); - let bbox = getPointsInBoundingBox(getBoundingBox([ + const bbox = getPointsInBoundingBox(getBoundingBox([ new Vector2D(Math.max(0, chainPos.x - radius), Math.max(0, chainPos.y - radius)), new Vector2D(Math.min(chainPos.x + radius, size), Math.min(chainPos.y + radius, size)) ])); - for (let position of bbox) + for (const position of bbox) { if (position.distanceToSquared(chainPos) >= radius2) continue; @@ -70,7 +70,7 @@ continue; } - let state = gotRet[position.x][position.y]; + const state = gotRet[position.x][position.y]; if (state == -1) { points.push(position); @@ -86,7 +86,7 @@ } } - for (let pos of bbox) + for (const pos of bbox) { if (this.maxDistance && (Math.abs(this.centerPosition.x - pos.x) > this.maxDistance || Index: binaries/data/mods/public/maps/random/rmgen/placer/centered/ClumpPlacer.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/placer/centered/ClumpPlacer.js +++ binaries/data/mods/public/maps/random/rmgen/placer/centered/ClumpPlacer.js @@ -30,25 +30,25 @@ if (!g_Map.inMapBounds(this.centerPosition) || !constraint.allows(this.centerPosition)) return undefined; - var points = []; + let points = []; - var size = g_Map.getSize(); - var gotRet = new Array(size).fill(0).map(p => new Uint8Array(size)); // booleans - var radius = Math.sqrt(this.size / Math.PI); - var perim = 4 * radius * 2 * Math.PI; - var intPerim = Math.ceil(perim); + let size = g_Map.getSize(); + let gotRet = new Array(size).fill(0).map(p => new Uint8Array(size)); // booleans + let radius = Math.sqrt(this.size / Math.PI); + let perim = 4 * radius * 2 * Math.PI; + let intPerim = Math.ceil(perim); - var ctrlPts = 1 + Math.floor(1.0/Math.max(this.smoothness,1.0/intPerim)); + let ctrlPts = 1 + Math.floor(1.0/Math.max(this.smoothness,1.0/intPerim)); if (ctrlPts > radius * 2 * Math.PI) ctrlPts = Math.floor(radius * 2 * Math.PI) + 1; - var noise = new Float32Array(intPerim); //float32 - var ctrlCoords = new Float32Array(ctrlPts+1); //float32 - var ctrlVals = new Float32Array(ctrlPts+1); //float32 + let noise = new Float32Array(intPerim); //float32 + let ctrlCoords = new Float32Array(ctrlPts+1); //float32 + let ctrlVals = new Float32Array(ctrlPts+1); //float32 // Generate some interpolated noise - for (var i=0; i < ctrlPts; i++) + for (let i=0; i < ctrlPts; i++) { ctrlCoords[i] = i * perim / ctrlPts; ctrlVals[i] = randFloat(0, 2); @@ -78,14 +78,14 @@ let count = 0; for (let stepAngle = 0; stepAngle < intPerim; ++stepAngle) { - let position = this.centerPosition.clone(); - let radiusUnitVector = new Vector2D(0, 1).rotate(-2 * Math.PI * stepAngle / perim); - let maxRadiusSteps = Math.ceil(radius * (1 + (1 - this.coherence) * noise[stepAngle])); + const position = this.centerPosition.clone(); + const radiusUnitVector = new Vector2D(0, 1).rotate(-2 * Math.PI * stepAngle / perim); + const maxRadiusSteps = Math.ceil(radius * (1 + (1 - this.coherence) * noise[stepAngle])); count += maxRadiusSteps; for (let stepRadius = 0; stepRadius < maxRadiusSteps; ++stepRadius) { - let tilePos = position.clone().floor(); + const tilePos = position.clone().floor(); if (g_Map.inMapBounds(tilePos) && constraint.allows(tilePos)) { Index: binaries/data/mods/public/maps/random/rmgen/placer/centered/DiskPlacer.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/placer/centered/DiskPlacer.js +++ binaries/data/mods/public/maps/random/rmgen/placer/centered/DiskPlacer.js @@ -18,14 +18,14 @@ DiskPlacer.prototype.place = function(constraint) { - let points = []; + const points = []; const xMin = Math.floor(Math.max(0, this.centerPosition.x - this.radius)); const yMin = Math.floor(Math.max(0, this.centerPosition.y - this.radius)); const xMax = Math.ceil(Math.min(g_Map.getSize() - 1, this.centerPosition.x + this.radius)); const yMax = Math.ceil(Math.min(g_Map.getSize() - 1, this.centerPosition.y + this.radius)); - let it = new Vector2D(); + const it = new Vector2D(); for (it.x = xMin; it.x <= xMax; ++it.x) for (it.y = yMin; it.y <= yMax; ++it.y) { Index: binaries/data/mods/public/maps/random/rmgen/placer/noncentered/ConvexPolygonPlacer.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/placer/noncentered/ConvexPolygonPlacer.js +++ binaries/data/mods/public/maps/random/rmgen/placer/noncentered/ConvexPolygonPlacer.js @@ -9,11 +9,11 @@ ConvexPolygonPlacer.prototype.place = function(constraint) { - let points = []; + const points = []; let count = 0; let failed = 0; - for (let point of getPointsInBoundingBox(getBoundingBox(this.polygonVertices))) + for (const point of getPointsInBoundingBox(getBoundingBox(this.polygonVertices))) { if (this.polygonVertices.some((vertex, i) => distanceOfPointFromLine(this.polygonVertices[i], this.polygonVertices[(i + 1) % this.polygonVertices.length], point) > 0)) @@ -36,13 +36,13 @@ */ ConvexPolygonPlacer.prototype.getConvexHull = function(points) { - let uniquePoints = []; - for (let point of points) + const uniquePoints = []; + for (const point of points) if (uniquePoints.every(p => p.x != point.x || p.y != point.y)) uniquePoints.push(point); // Start with the leftmost point - let result = [uniquePoints.reduce((leftMost, point) => point.x < leftMost.x ? point : leftMost, uniquePoints[0])]; + const result = [uniquePoints.reduce((leftMost, point) => point.x < leftMost.x ? point : leftMost, uniquePoints[0])]; // Add the vector most left of the most recently added point until a cycle is reached while (result.length < uniquePoints.length) @@ -50,7 +50,7 @@ let nextLeftmostPoint; // Of all points, find the one that is leftmost - for (let point of uniquePoints) + for (const point of uniquePoints) { if (point == result[result.length - 1]) continue; Index: binaries/data/mods/public/maps/random/rmgen/placer/noncentered/EntitiesObstructionPlacer.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/placer/noncentered/EntitiesObstructionPlacer.js +++ binaries/data/mods/public/maps/random/rmgen/placer/noncentered/EntitiesObstructionPlacer.js @@ -13,11 +13,11 @@ { let points = []; - for (let entity of this.entities) + for (const entity of this.entities) { - let halfObstructionSize = getObstructionSize(entity.templateName, this.margin).div(2); + const halfObstructionSize = getObstructionSize(entity.templateName, this.margin).div(2); - let obstructionCorners = [ + const obstructionCorners = [ new Vector2D(-halfObstructionSize.x, -halfObstructionSize.y), new Vector2D(-halfObstructionSize.x, +halfObstructionSize.y), new Vector2D(+halfObstructionSize.x, -halfObstructionSize.y), Index: binaries/data/mods/public/maps/random/rmgen/placer/noncentered/HeightPlacer.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/placer/noncentered/HeightPlacer.js +++ binaries/data/mods/public/maps/random/rmgen/placer/noncentered/HeightPlacer.js @@ -25,7 +25,7 @@ HeightPlacer.prototype.place = function(constraint) { - let mapSize = g_Map.getSize(); + const mapSize = g_Map.getSize(); return getPointsInBoundingBox(getBoundingBox([new Vector2D(0, 0), new Vector2D(mapSize - 1, mapSize - 1)])).filter( point => this.withinHeightRange(point) && constraint.allows(point)); Index: binaries/data/mods/public/maps/random/rmgen/placer/noncentered/MapBoundsPlacer.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/placer/noncentered/MapBoundsPlacer.js +++ binaries/data/mods/public/maps/random/rmgen/placer/noncentered/MapBoundsPlacer.js @@ -3,7 +3,7 @@ */ function MapBoundsPlacer(failFraction = Infinity) { - let mapBounds = g_Map.getBounds(); + const mapBounds = g_Map.getBounds(); this.rectPlacer = new RectPlacer(new Vector2D(mapBounds.left, mapBounds.top), new Vector2D(mapBounds.right, mapBounds.bottom), failFraction); } Index: binaries/data/mods/public/maps/random/rmgen/placer/noncentered/PathPlacer.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/placer/noncentered/PathPlacer.js +++ binaries/data/mods/public/maps/random/rmgen/placer/noncentered/PathPlacer.js @@ -25,20 +25,20 @@ PathPlacer.prototype.place = function(constraint) { - let pathLength = this.start.distanceTo(this.end); + const pathLength = this.start.distanceTo(this.end); - let numStepsWaviness = 1 + Math.floor(pathLength / 4 * this.waviness); - let numStepsLength = 1 + Math.floor(pathLength / 4 * this.smoothness); - let offset = 1 + Math.floor(pathLength / 4 * this.offset); + const numStepsWaviness = 1 + Math.floor(pathLength / 4 * this.waviness); + const numStepsLength = 1 + Math.floor(pathLength / 4 * this.smoothness); + const offset = 1 + Math.floor(pathLength / 4 * this.offset); // Generate random offsets - let ctrlVals = new Float32Array(numStepsWaviness); + const ctrlVals = new Float32Array(numStepsWaviness); for (let j = 1; j < numStepsWaviness - 1; ++j) ctrlVals[j] = randFloat(-offset, offset); // Interpolate for smoothed 1D noise - let totalSteps = numStepsWaviness * numStepsLength; - let noise = new Float32Array(totalSteps + 1); + const totalSteps = numStepsWaviness * numStepsLength; + const noise = new Float32Array(totalSteps + 1); for (let j = 0; j < numStepsWaviness; ++j) for (let k = 0; k < numStepsLength; ++k) noise[j * numStepsLength + k] = cubicInterpolation( @@ -50,42 +50,42 @@ ctrlVals[(j + 2) % numStepsWaviness]); // Add smoothed noise to straight path - let pathPerpendicular = Vector2D.sub(this.end, this.start).normalize().perpendicular(); - let segments1 = []; - let segments2 = []; + const pathPerpendicular = Vector2D.sub(this.end, this.start).normalize().perpendicular(); + const segments1 = []; + const segments2 = []; for (let j = 0; j < totalSteps; ++j) { // Interpolated points along straight path - let step1 = j / totalSteps; - let step2 = (j + 1) / totalSteps; - let stepStart = Vector2D.add(Vector2D.mult(this.start, 1 - step1), Vector2D.mult(this.end, step1)); - let stepEnd = Vector2D.add(Vector2D.mult(this.start, 1 - step2), Vector2D.mult(this.end, step2)); + const step1 = j / totalSteps; + const step2 = (j + 1) / totalSteps; + const stepStart = Vector2D.add(Vector2D.mult(this.start, 1 - step1), Vector2D.mult(this.end, step1)); + const stepEnd = Vector2D.add(Vector2D.mult(this.start, 1 - step2), Vector2D.mult(this.end, step2)); // Find noise offset points - let noiseStart = Vector2D.add(stepStart, Vector2D.mult(pathPerpendicular, noise[j])); - let noiseEnd = Vector2D.add(stepEnd, Vector2D.mult(pathPerpendicular, noise[j + 1])); - let noisePerpendicular = Vector2D.sub(noiseEnd, noiseStart).normalize().perpendicular(); + const noiseStart = Vector2D.add(stepStart, Vector2D.mult(pathPerpendicular, noise[j])); + const noiseEnd = Vector2D.add(stepEnd, Vector2D.mult(pathPerpendicular, noise[j + 1])); + const noisePerpendicular = Vector2D.sub(noiseEnd, noiseStart).normalize().perpendicular(); - let taperedWidth = (1 - step1 * this.tapering) * this.width / 2; + const taperedWidth = (1 - step1 * this.tapering) * this.width / 2; segments1.push(Vector2D.sub(noiseStart, Vector2D.mult(noisePerpendicular, taperedWidth)).round()); segments2.push(Vector2D.add(noiseEnd, Vector2D.mult(noisePerpendicular, taperedWidth)).round()); } // Draw path segments - let size = g_Map.getSize(); - let gotRet = new Array(size).fill(0).map(i => new Uint8Array(size)); - let retVec = []; + const size = g_Map.getSize(); + const gotRet = new Array(size).fill(0).map(i => new Uint8Array(size)); + const retVec = []; let failed = 0; for (let j = 0; j < segments1.length - 1; ++j) { - let points = new ConvexPolygonPlacer([segments1[j], segments1[j + 1], segments2[j], segments2[j + 1]], Infinity).place(new NullConstraint()); + const points = new ConvexPolygonPlacer([segments1[j], segments1[j + 1], segments2[j], segments2[j + 1]], Infinity).place(new NullConstraint()); if (!points) continue; - for (let point of points) + for (const point of points) { if (!constraint.allows(point)) { Index: binaries/data/mods/public/maps/random/rmgen/placer/noncentered/RandomPathPlacer.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/placer/noncentered/RandomPathPlacer.js +++ binaries/data/mods/public/maps/random/rmgen/placer/noncentered/RandomPathPlacer.js @@ -16,8 +16,8 @@ RandomPathPlacer.prototype.place = function(constraint) { let pathLength = 0; - let points = []; - let position = this.pathStart; + const points = []; + const position = this.pathStart; while (position.distanceToSquared(this.pathEnd) >= this.offsetSquared && pathLength++ < this.maxPathLength) { @@ -28,7 +28,7 @@ this.diskPlacer.setCenterPosition(position); - for (let point of this.diskPlacer.place(constraint)) + for (const point of this.diskPlacer.place(constraint)) if (points.every(p => !Vector2D.isEqualTo(p, point))) points.push(point); } Index: binaries/data/mods/public/maps/random/rmgen/placer/noncentered/RectPlacer.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/placer/noncentered/RectPlacer.js +++ binaries/data/mods/public/maps/random/rmgen/placer/noncentered/RectPlacer.js @@ -11,7 +11,7 @@ RectPlacer.prototype.place = function(constraint) { - let bboxPoints = getPointsInBoundingBox(this.bounds); - let points = bboxPoints.filter(point => g_Map.inMapBounds(point) && constraint.allows(point)); + const bboxPoints = getPointsInBoundingBox(this.bounds); + const points = bboxPoints.filter(point => g_Map.inMapBounds(point) && constraint.allows(point)); return (bboxPoints.length - points.length) / bboxPoints.length <= this.failFraction ? points : undefined; }; Index: binaries/data/mods/public/maps/random/rmgen2/gaia.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen2/gaia.js +++ binaries/data/mods/public/maps/random/rmgen2/gaia.js @@ -11,7 +11,7 @@ */ function markPlayerAvoidanceArea(playerPosition, radius) { - for (let position of playerPosition) + for (const position of playerPosition) createArea( new ChainPlacer(3, 6, scaleByMapSize(25, 60), Infinity, position, radius), new TileClassPainter(g_TileClasses.bluffIgnore), @@ -31,14 +31,14 @@ function createBluffsPassages(playerPosition) { g_Map.log("Creating passages towards the center"); - for (let position of playerPosition) + for (const position of playerPosition) { - let successful = true; + const successful = true; for (let tryCount = 0; tryCount < 80; ++tryCount) { - let angle = position.angleTo(g_Map.getCenter()) + randFloat(-1, 1) * Math.PI / 2; - let start = Vector2D.add(position, new Vector2D(defaultPlayerBaseRadius() * 0.7, 0).rotate(angle).perpendicular()).round(); - let end = Vector2D.add(position, new Vector2D(defaultPlayerBaseRadius() * randFloat(1.7, 2), 0).rotate(angle).perpendicular()).round(); + const angle = position.angleTo(g_Map.getCenter()) + randFloat(-1, 1) * Math.PI / 2; + const start = Vector2D.add(position, new Vector2D(defaultPlayerBaseRadius() * 0.7, 0).rotate(angle).perpendicular()).round(); + const end = Vector2D.add(position, new Vector2D(defaultPlayerBaseRadius() * randFloat(1.7, 2), 0).rotate(angle).perpendicular()).round(); if (g_TileClasses.forest.has(end) || !stayClasses(g_TileClasses.bluff, 12).allows(end)) continue; @@ -46,7 +46,7 @@ if ((g_Map.getHeight(end.clone().floor()) - g_Map.getHeight(start.clone().floor())) / start.distanceTo(end) > 1.5) continue; - let area = createPassage({ + const area = createPassage({ "start": start, "end": end, "startWidth": scaleByMapSize(10, 20), @@ -56,7 +56,7 @@ "tileClass": g_TileClasses.bluffsPassage }); - for (let point of area.getPoints()) + for (const point of area.getPoints()) g_Map.deleteTerrainEntity(point); createArea( @@ -86,10 +86,10 @@ { g_Map.log("Creating bluffs"); - let elevation = 30; + const elevation = 30; // Percent of the length of the bluff determining the entrance area - let margin = 0.08; + const margin = 0.08; let constrastTerrain = g_Terrains.tier2Terrain; @@ -101,10 +101,10 @@ for (let i = 0; i < fill * 15; ++i) { - let bluffDeviation = getRandomDeviation(size, deviation); + const bluffDeviation = getRandomDeviation(size, deviation); // Pick a random bluff location and shape - let areasBluff = createAreas( + const areasBluff = createAreas( new ChainPlacer(5 * bluffDeviation, 7 * bluffDeviation, 100 * bluffDeviation, 0.5), undefined, constraint, @@ -147,12 +147,12 @@ ], new StayAreasConstraint(areasBluff)); - let slopeLength = (1 - margin) * Vector2D.average([baseLine.start, baseLine.end]).distanceTo(Vector2D.average([endLine.start, endLine.end])); + const slopeLength = (1 - margin) * Vector2D.average([baseLine.start, baseLine.end]).distanceTo(Vector2D.average([endLine.start, endLine.end])); // Adjust the height of each point in the bluff - for (let point of areasBluff[0].getPoints()) + for (const point of areasBluff[0].getPoints()) { - let dist = Math.abs(distanceOfPointFromLine(baseLine.start, baseLine.end, point)); + const dist = Math.abs(distanceOfPointFromLine(baseLine.start, baseLine.end, point)); g_Map.setHeight(point, Math.max(g_Map.getHeight(point) * (1 - dist / slopeLength) - 2, baseHeight)); } @@ -299,7 +299,7 @@ } ])); - let savanna = currentBiome() == "generic/savanna"; + const savanna = currentBiome() == "generic/savanna"; addElements(shuffleArray([ { "func": addStragglerTrees, @@ -359,8 +359,8 @@ { g_Map.log("Creating decoration"); - var offset = getRandomDeviation(size, deviation); - var decorations = [ + let offset = getRandomDeviation(size, deviation); + let decorations = [ [ new SimpleObject(g_Decoratives.rockMedium, offset, 3 * offset, 0, offset) ], @@ -381,11 +381,11 @@ ] ]; - var baseCount = 1; + let baseCount = 1; if (currentBiome() == "generic/india") baseCount = 8; - var counts = [ + let counts = [ scaleByMapSize(16, 262), scaleByMapSize(8, 131), baseCount * scaleByMapSize(13, 200), @@ -393,10 +393,10 @@ baseCount * scaleByMapSize(13, 200) ]; - for (var i = 0; i < decorations.length; ++i) + for (let i = 0; i < decorations.length; ++i) { - var decorCount = Math.floor(counts[i] * fill); - var group = new SimpleGroup(decorations[i], true); + let decorCount = Math.floor(counts[i] * fill); + let group = new SimpleGroup(decorations[i], true); createObjectGroupsDeprecated(group, 0, constraint, decorCount, 5); } } @@ -423,32 +423,32 @@ function addElevation(constraint, el) { - var count = el.fill * el.count; - var minSize = el.minSize; - var maxSize = el.maxSize; - var spread = el.spread; + let count = el.fill * el.count; + let minSize = el.minSize; + let maxSize = el.maxSize; + let spread = el.spread; - var elType = ELEVATION_MODIFY; + let elType = ELEVATION_MODIFY; if (el.class == g_TileClasses.water) elType = ELEVATION_SET; - var widths = []; + let widths = []; // Allow for shore and cliff rendering - for (var s = el.painter.length; s > 2; --s) + for (let s = el.painter.length; s > 2; --s) widths.push(1); - for (var i = 0; i < count; ++i) + for (let i = 0; i < count; ++i) { - var elevation = randIntExclusive(el.minElevation, el.maxElevation); - var smooth = Math.floor(elevation / el.steepness); + let elevation = randIntExclusive(el.minElevation, el.maxElevation); + let smooth = Math.floor(elevation / el.steepness); - var offset = getRandomDeviation(el.size, el.deviation); - var pMinSize = Math.floor(minSize * offset); - var pMaxSize = Math.floor(maxSize * offset); - var pSpread = Math.floor(spread * offset); - var pSmooth = Math.abs(Math.floor(smooth * offset)); - var pElevation = Math.floor(elevation * offset); + let offset = getRandomDeviation(el.size, el.deviation); + let pMinSize = Math.floor(minSize * offset); + let pMaxSize = Math.floor(maxSize * offset); + let pSpread = Math.floor(spread * offset); + let pSmooth = Math.abs(Math.floor(smooth * offset)); + let pElevation = Math.floor(elevation * offset); pElevation = Math.max(el.minElevation, Math.min(pElevation, el.maxElevation)); pMinSize = Math.min(pMinSize, pMaxSize); @@ -503,7 +503,7 @@ { g_Map.log("Creating lakes"); - var lakeTile = g_Terrains.water; + let lakeTile = g_Terrains.water; if (currentBiome() == "generic/temperate" || currentBiome() == "generic/india") lakeTile = g_Terrains.dirt; @@ -545,7 +545,7 @@ } ]); - var group = new SimpleGroup([new SimpleObject(g_Decoratives.rockMedium, 1, 3, 1, 3)], true, g_TileClasses.dirt); + let group = new SimpleGroup([new SimpleObject(g_Decoratives.rockMedium, 1, 3, 1, 3)], true, g_TileClasses.dirt); createObjectGroupsDeprecated(group, 0, [stayClasses(g_TileClasses.water, 1), borderClasses(g_TileClasses.water, 4, 3)], 1000, 100); group = new SimpleGroup([new SimpleObject(g_Decoratives.reeds, 10, 15, 1, 3), new SimpleObject(g_Decoratives.rockMedium, 1, 3, 1, 3)], true, g_TileClasses.dirt); @@ -559,21 +559,21 @@ { g_Map.log("Creating layered patches"); - var minRadius = 1; - var maxRadius = Math.floor(scaleByMapSize(3, 5)); - var count = fill * scaleByMapSize(15, 45); + let minRadius = 1; + let maxRadius = Math.floor(scaleByMapSize(3, 5)); + let count = fill * scaleByMapSize(15, 45); - var patchSizes = [ + let patchSizes = [ scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21) ]; - for (let patchSize of patchSizes) + for (const patchSize of patchSizes) { - var offset = getRandomDeviation(size, deviation); - var patchMinRadius = Math.floor(minRadius * offset); - var patchMaxRadius = Math.floor(maxRadius * offset); + let offset = getRandomDeviation(size, deviation); + let patchMinRadius = Math.floor(minRadius * offset); + let patchMaxRadius = Math.floor(maxRadius * offset); createAreas( new ChainPlacer(Math.min(patchMinRadius, patchMaxRadius), patchMaxRadius, Math.floor(patchSize * offset), 0.5), @@ -623,7 +623,7 @@ { g_Map.log("Creating plateaus"); - var plateauTile = g_Terrains.dirt; + let plateauTile = g_Terrains.dirt; if (currentBiome() == "generic/arctic") plateauTile = g_Terrains.tier1Terrain; @@ -649,9 +649,9 @@ "steepness": 8 }); - for (var i = 0; i < 40; ++i) + for (let i = 0; i < 40; ++i) { - var hillElevation = randIntInclusive(4, 18); + let hillElevation = randIntInclusive(4, 18); createAreas( new ChainPlacer(3, 15, 1, 0.5), [ @@ -703,9 +703,9 @@ { g_Map.log("Creating rare actors"); - var offset = getRandomDeviation(size, deviation); + let offset = getRandomDeviation(size, deviation); - var props = [ + let props = [ [ new SimpleObject(g_Props.skeleton, offset, 5 * offset, 0, 3 * offset + 2), ], @@ -717,9 +717,9 @@ ] ]; - var baseCount = 1; + let baseCount = 1; - var counts = [ + let counts = [ scaleByMapSize(16, 262), scaleByMapSize(8, 131), baseCount * scaleByMapSize(13, 200), @@ -728,15 +728,15 @@ ]; // Add small props - for (var i = 0; i < props.length; ++i) + for (let i = 0; i < props.length; ++i) { - var propCount = Math.floor(counts[i] * fill); - var group = new SimpleGroup(props[i], true); + let propCount = Math.floor(counts[i] * fill); + let group = new SimpleGroup(props[i], true); createObjectGroupsDeprecated(group, 0, constraint, propCount, 5); } // Add decorative trees - var trees = new SimpleObject(g_Decoratives.tree, 5 * offset, 30 * offset, 2, 3 * offset + 10); + let trees = new SimpleObject(g_Decoratives.tree, 5 * offset, 30 * offset, 2, 3 * offset + 10); createObjectGroupsDeprecated(new SimpleGroup([trees], true), 0, constraint, counts[0] * 5 * fill, 5); } @@ -747,10 +747,10 @@ g_Map.log("Creating valleys"); - let minElevation = Math.max(-baseHeight, 1 - baseHeight / (size * (deviation + 1))); + const minElevation = Math.max(-baseHeight, 1 - baseHeight / (size * (deviation + 1))); - var valleySlope = g_Terrains.tier1Terrain; - var valleyFloor = g_Terrains.tier4Terrain; + let valleySlope = g_Terrains.tier1Terrain; + let valleyFloor = g_Terrains.tier4Terrain; if (currentBiome() == "generic/sahara") { @@ -796,14 +796,14 @@ { g_Map.log("Creating animals"); - var groupOffset = getRandomDeviation(size, deviation); + let groupOffset = getRandomDeviation(size, deviation); - var animals = [ + let animals = [ [new SimpleObject(g_Gaia.mainHuntableAnimal, 5 * groupOffset, 7 * groupOffset, 0, 4 * groupOffset)], [new SimpleObject(g_Gaia.secondaryHuntableAnimal, 2 * groupOffset, 3 * groupOffset, 0, 2 * groupOffset)] ]; - for (let animal of animals) + for (const animal of animals) createObjectGroupsDeprecated( new SimpleGroup(animal, true, g_TileClasses.animals), 0, @@ -816,7 +816,7 @@ { g_Map.log("Creating berries"); - let groupOffset = getRandomDeviation(size, deviation); + const groupOffset = getRandomDeviation(size, deviation); createObjectGroupsDeprecated( new SimpleGroup([new SimpleObject(g_Gaia.fruitBush, 5 * groupOffset, 5 * groupOffset, 0, 3 * groupOffset)], true, g_TileClasses.berries), @@ -830,14 +830,14 @@ { g_Map.log("Creating fish"); - var groupOffset = getRandomDeviation(size, deviation); + let groupOffset = getRandomDeviation(size, deviation); - var fishes = [ + let fishes = [ [new SimpleObject(g_Gaia.fish, groupOffset, 2 * groupOffset, 0, 2 * groupOffset)], [new SimpleObject(g_Gaia.fish, 2 * groupOffset, 4 * groupOffset, 10 * groupOffset, 20 * groupOffset)] ]; - for (let fish of fishes) + for (const fish of fishes) createObjectGroupsDeprecated( new SimpleGroup(fish, true, g_TileClasses.fish), 0, @@ -853,7 +853,7 @@ g_Map.log("Creating forests"); - let treeTypes = [ + const treeTypes = [ [ g_Terrains.forestFloor2 + TERRAIN_SEPARATOR + g_Gaia.tree1, g_Terrains.forestFloor2 + TERRAIN_SEPARATOR + g_Gaia.tree2, @@ -866,7 +866,7 @@ ] ]; - let forestTypes = [ + const forestTypes = [ [ [g_Terrains.forestFloor2, g_Terrains.mainTerrain, treeTypes[0]], [g_Terrains.forestFloor2, treeTypes[0]] @@ -883,9 +883,9 @@ ] ]; - for (let forestType of forestTypes) + for (const forestType of forestTypes) { - let offset = getRandomDeviation(size, deviation); + const offset = getRandomDeviation(size, deviation); createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5) * offset), Math.floor(50 * offset), 0.5), [ @@ -901,7 +901,7 @@ { g_Map.log("Creating metal mines"); - var offset = getRandomDeviation(size, deviation); + let offset = getRandomDeviation(size, deviation); createObjectGroupsDeprecated( new SimpleGroup([new SimpleObject(g_Gaia.metalLarge, offset, offset, 0, 4 * offset)], true, g_TileClasses.metal), 0, @@ -914,7 +914,7 @@ { g_Map.log("Creating small metal mines"); - let deviation = getRandomDeviation(size, mixes); + const deviation = getRandomDeviation(size, mixes); createObjectGroupsDeprecated( new SimpleGroup([new SimpleObject(g_Gaia.metalSmall, 2 * deviation, 5 * deviation, deviation, 3 * deviation)], true, g_TileClasses.metal), 0, @@ -930,9 +930,9 @@ { g_Map.log("Creating stone mines"); - var offset = getRandomDeviation(size, deviation); + let offset = getRandomDeviation(size, deviation); - var mines = [ + let mines = [ [ new SimpleObject(g_Gaia.stoneSmall, 0, 2 * offset, 0, 4 * offset), new SimpleObject(g_Gaia.stoneLarge, offset, offset, 0, 4 * offset) @@ -942,7 +942,7 @@ ] ]; - for (let mine of mines) + for (const mine of mines) createObjectGroupsDeprecated( new SimpleGroup(mine, true, g_TileClasses.rock), 0, @@ -965,20 +965,20 @@ size = Math.max(size, 1); } - var trees = [g_Gaia.tree1, g_Gaia.tree2, g_Gaia.tree3, g_Gaia.tree4]; + let trees = [g_Gaia.tree1, g_Gaia.tree2, g_Gaia.tree3, g_Gaia.tree4]; - var treesPerPlayer = 40; - var playerBonus = Math.max(1, (getNumPlayers() - 3) / 2); + let treesPerPlayer = 40; + let playerBonus = Math.max(1, (getNumPlayers() - 3) / 2); - var offset = getRandomDeviation(size, deviation); - var treeCount = treesPerPlayer * playerBonus * fill; - var totalTrees = scaleByMapSize(treeCount, treeCount); + let offset = getRandomDeviation(size, deviation); + let treeCount = treesPerPlayer * playerBonus * fill; + let totalTrees = scaleByMapSize(treeCount, treeCount); - var count = Math.floor(totalTrees / trees.length) * fill; - var min = offset; - var max = 4 * offset; - var minDist = offset; - var maxDist = 5 * offset; + let count = Math.floor(totalTrees / trees.length) * fill; + let min = offset; + let max = 4 * offset; + let minDist = offset; + let maxDist = 5 * offset; // More trees for the african biome if (currentBiome() == "generic/savanna") @@ -989,9 +989,9 @@ maxDist = 3 * offset + 2; } - for (var i = 0; i < trees.length; ++i) + for (let i = 0; i < trees.length; ++i) { - var treesMax = max; + let treesMax = max; // Don't clump fruit trees if (i == 2 && (currentBiome() == "generic/sahara" || currentBiome() == "generic/aegean")) @@ -999,7 +999,7 @@ min = Math.min(min, treesMax); - var group = new SimpleGroup([new SimpleObject(trees[i], min, treesMax, minDist, maxDist)], true, g_TileClasses.forest); + let group = new SimpleGroup([new SimpleObject(trees[i], min, treesMax, minDist, maxDist)], true, g_TileClasses.forest); createObjectGroupsDeprecated(group, 0, constraint, count); } } @@ -1015,22 +1015,22 @@ !g_Map.validTilePassable(endLine.end)) return false; - let minTilesInGroup = 2; + const minTilesInGroup = 2; let insideBluff = false; let outsideBluff = false; // If there aren't enough points in each row - let corners = getBoundingBox(bluffArea.getPoints()); + const corners = getBoundingBox(bluffArea.getPoints()); for (let x = corners.min.x; x <= corners.max.x; ++x) { let count = 0; for (let y = corners.min.y; y <= corners.max.y; ++y) { - let pos = new Vector2D(x, y); + const pos = new Vector2D(x, y); if (!bluffArea.contains(pos)) continue; - let valid = g_Map.validTilePassable(pos); + const valid = g_Map.validTilePassable(pos); if (valid) ++count; @@ -1055,11 +1055,11 @@ let count = 0; for (let x = corners.min.x; x <= corners.max.x; ++x) { - let pos = new Vector2D(x, y); + const pos = new Vector2D(x, y); if (!bluffArea.contains(pos)) continue; - let valid = g_Map.validTilePassable(pos.add(corners.min)); + const valid = g_Map.validTilePassable(pos.add(corners.min)); if (valid) ++count; @@ -1083,7 +1083,7 @@ */ function findClearLine(bluffArea, angle) { - let corners = getBoundingBox(bluffArea.getPoints()); + const corners = getBoundingBox(bluffArea.getPoints()); // Angle - 0: northwest; 1: northeast; 2: southeast; 3: southwest let offset; @@ -1113,10 +1113,10 @@ let clearLine; for (let x = corners.min.x; x <= corners.max.x; ++x) { - let start = new Vector2D(x, y); + const start = new Vector2D(x, y); let intersectsBluff = false; - let end = start.clone(); + const end = start.clone(); while (end.x >= corners.min.x && end.x <= corners.max.x && end.y >= corners.min.y && end.y <= corners.max.y) { Index: binaries/data/mods/public/maps/random/rmgen2/setup.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen2/setup.js +++ binaries/data/mods/public/maps/random/rmgen2/setup.js @@ -86,7 +86,7 @@ */ function addElements(elements) { - for (let element of elements) + for (const element of elements) element.func( [ avoidClasses.apply(null, element.avoid), @@ -103,7 +103,7 @@ */ function pickAmount(amounts) { - let amount = pickRandom(amounts); + const amount = pickRandom(amounts); if (amount in g_Amounts) return g_Amounts[amount]; @@ -116,7 +116,7 @@ */ function pickMix(mixes) { - let mix = pickRandom(mixes); + const mix = pickRandom(mixes); if (mix in g_Mixes) return g_Mixes[mix]; @@ -129,7 +129,7 @@ */ function pickSize(sizes) { - let size = pickRandom(sizes); + const size = pickRandom(sizes); if (size in g_Sizes) return g_Sizes[size]; @@ -221,12 +221,12 @@ */ function initTileClasses(newClasses) { - var classNames = g_DefaultTileClasses; + let classNames = g_DefaultTileClasses; if (newClasses) classNames = classNames.concat(newClasses); g_TileClasses = {}; - for (var className of classNames) + for (let className of classNames) g_TileClasses[className] = g_Map.createTileClass(); } Index: binaries/data/mods/public/maps/random/saharan_oases.js =================================================================== --- binaries/data/mods/public/maps/random/saharan_oases.js +++ binaries/data/mods/public/maps/random/saharan_oases.js @@ -37,23 +37,23 @@ const heightLand = 1; const heightOffsetOasis = -3; -var g_Map = new RandomMap(heightLand, tPrimary); +const g_Map = new RandomMap(heightLand, tPrimary); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clTreasure = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clTreasure = g_Map.createTileClass(); -var [playerIDs, playerPosition, playerAngle] = playerPlacementCircle(fractionToTiles(0.35)); +const [playerIDs, playerPosition, playerAngle] = playerPlacementCircle(fractionToTiles(0.35)); placePlayerBases({ "PlayerPlacement": [playerIDs, playerPosition], @@ -84,10 +84,10 @@ Engine.SetProgress(30); g_Map.log("Creating oases"); -var oasisRadius = fractionToTiles(scaleByMapSize(0.19, 0.22)); +const oasisRadius = fractionToTiles(scaleByMapSize(0.19, 0.22)); for (let i = 0; i < numPlayers; ++i) { - let position = Vector2D.add(mapCenter, new Vector2D(oasisRadius, 0).rotate(-playerAngle[i])); + const position = Vector2D.add(mapCenter, new Vector2D(oasisRadius, 0).rotate(-playerAngle[i])); createArea( new ClumpPlacer(diskArea(scaleByMapSize(16, 60)) * 0.185, 0.6, 0.15, 0, position), [ @@ -101,7 +101,7 @@ Engine.SetProgress(50); g_Map.log("Creating grass patches"); -for (let size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) +for (const size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), [ @@ -116,7 +116,7 @@ Engine.SetProgress(55); g_Map.log("Creating dirt patches"); -for (let size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) +for (const size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), [ @@ -131,7 +131,7 @@ Engine.SetProgress(60); 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, 26, clRock, 10, clWater, 1), 2*scaleByMapSize(4,16), 100 Index: binaries/data/mods/public/maps/random/sahel.js =================================================================== --- binaries/data/mods/public/maps/random/sahel.js +++ binaries/data/mods/public/maps/random/sahel.js @@ -31,18 +31,18 @@ const heightSeaGround = -5; const heightLand = 1; -var g_Map = new RandomMap(heightLand, tPrimary); +const g_Map = new RandomMap(heightLand, tPrimary); -var numPlayers = getNumPlayers(); -var mapSize = g_Map.getSize(); +const numPlayers = getNumPlayers(); +const mapSize = g_Map.getSize(); -var clPlayer = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); placePlayerBases({ "PlayerPlacement": playerPlacementCircle(fractionToTiles(0.35)), @@ -80,8 +80,8 @@ Engine.SetProgress(20); g_Map.log("Creating big patches"); -var patches = [tGrass2, tGrass3]; -for (var i = 0; i < patches.length; i++) +const patches = [tGrass2, tGrass3]; +for (let i = 0; i < patches.length; i++) createAreas( new ChainPlacer(Math.floor(scaleByMapSize(3, 6)), Math.floor(scaleByMapSize(10, 20)), Math.floor(scaleByMapSize(15, 60)), Infinity), new TerrainPainter(patches[i]), @@ -89,8 +89,8 @@ scaleByMapSize(5, 20)); g_Map.log("Creating small patches"); -for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) - for (let patch of [tDirt1, tDirt2, tDirt3]) +for (const size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) + for (const patch of [tDirt1, tDirt2, tDirt3]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, Infinity), new TerrainPainter(patch), @@ -110,9 +110,9 @@ Engine.SetProgress(55); g_Map.log("Creating stone mines"); -for (var i = 0; i < scaleByMapSize(12,30); ++i) +for (let i = 0; i < scaleByMapSize(12,30); ++i) { - let position = new Vector2D(randIntExclusive(0, mapSize), randIntExclusive(0, mapSize)); + const position = new Vector2D(randIntExclusive(0, mapSize), randIntExclusive(0, mapSize)); if (avoidClasses(clPlayer, 30, clRock, 25, clWater, 10).allows(position)) { createStoneMineFormation(position, oStoneSmall, tDirt4); @@ -121,7 +121,7 @@ } g_Map.log("Creating metal mines"); -var group = new SimpleGroup([new SimpleObject(oMetalLarge, 1, 1, 0, 4)], true, clMetal); +let group = new SimpleGroup([new SimpleObject(oMetalLarge, 1, 1, 0, 4)], true, clMetal); createObjectGroupsDeprecated(group, 0, avoidClasses(clPlayer, 20, clMetal, 10, clRock, 8, clWater, 4), scaleByMapSize(2,8), 100 Index: binaries/data/mods/public/maps/random/sahel_watering_holes.js =================================================================== --- binaries/data/mods/public/maps/random/sahel_watering_holes.js +++ binaries/data/mods/public/maps/random/sahel_watering_holes.js @@ -42,24 +42,24 @@ const heightHill = 35; const heightOffsetBump = 2; -var g_Map = new RandomMap(heightLand, tGrass); +const g_Map = new RandomMap(heightLand, tGrass); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clShallows = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clShallows = 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], @@ -91,12 +91,12 @@ Engine.SetProgress(20); g_Map.log("Creating rivers"); -var riverStart = distributePointsOnCircle(numPlayers, startAngle + Math.PI / numPlayers, fractionToTiles(0.15), mapCenter)[0]; -var riverEnd = distributePointsOnCircle(numPlayers, startAngle + Math.PI / numPlayers, fractionToTiles(0.49), mapCenter)[0]; +const riverStart = distributePointsOnCircle(numPlayers, startAngle + Math.PI / numPlayers, fractionToTiles(0.15), mapCenter)[0]; +const riverEnd = distributePointsOnCircle(numPlayers, startAngle + Math.PI / numPlayers, fractionToTiles(0.49), mapCenter)[0]; for (let i = 0; i < numPlayers; ++i) { - let neighborID = (i + 1) % numPlayers; + const neighborID = (i + 1) % numPlayers; // Lake near the center createArea( @@ -140,13 +140,13 @@ }); // Animals in shallows - let shallowPosition = Vector2D.average([playerPosition[i], playerPosition[neighborID]]).round(); - let objects = [ + const shallowPosition = Vector2D.average([playerPosition[i], playerPosition[neighborID]]).round(); + const objects = [ new SimpleObject(oWildebeest, 5, 6, 0, 4), new SimpleObject(oElephant, 2, 3, 0, 4) ]; - for (let object of objects) + for (const object of objects) createObjectGroup(new SimpleGroup([object], true, clFood, shallowPosition), 0); } @@ -171,14 +171,14 @@ scaleByMapSize(1, 4) * numPlayers); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(160, 900, 0.02); -var types = [ +const [forestTrees, stragglerTrees] = getTreeCounts(160, 900, 0.02); +const types = [ [[tForestFloor, tGrass, pForest], [tForestFloor, pForest]] ]; -var size = forestTrees / (0.5 * scaleByMapSize(2,8) * numPlayers); -var num = Math.floor(size / types.length); -for (let type of types) +const forestSize = forestTrees / (0.5 * scaleByMapSize(2,8) * numPlayers); +const num = Math.floor(forestSize / types.length); +for (const type of types) createAreas( new ClumpPlacer(forestTrees / num, 0.1, 0.1, Infinity), [ @@ -191,7 +191,7 @@ Engine.SetProgress(50); g_Map.log("Creating dirt patches"); -for (let size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) +for (const size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), [ @@ -204,7 +204,7 @@ scaleByMapSize(15, 45)); g_Map.log("Creating grass patches"); -for (let size of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)]) +for (const size of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), new TerrainPainter(tGrassPatch), @@ -213,7 +213,7 @@ Engine.SetProgress(55); 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(clWater, 3, clForest, 1, clPlayer, 20, clRock, 10, clHill, 1), scaleByMapSize(4,16), 100 @@ -339,7 +339,7 @@ clForest, stragglerTrees); -var planetm = 4; +let planetm = 4; g_Map.log("Creating small grass tufts"); group = new SimpleGroup( [new SimpleObject(aGrassShort, 1,2, 0,1, -Math.PI / 8, Math.PI / 8)] Index: binaries/data/mods/public/maps/random/schwarzwald.js =================================================================== --- binaries/data/mods/public/maps/random/schwarzwald.js +++ binaries/data/mods/public/maps/random/schwarzwald.js @@ -18,24 +18,24 @@ setPPEffect("hdr"); setPPBloom(0.4); -var oStoneLarge = 'gaia/rock/alpine_large'; -var oMetalLarge = 'gaia/ore/alpine_large'; -var oFish = "gaia/fish/generic"; +const oStoneLarge = 'gaia/rock/alpine_large'; +const oMetalLarge = 'gaia/ore/alpine_large'; +const oFish = "gaia/fish/generic"; -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'; -var aReeds = 'actor|props/flora/reeds_pond_lush_b.xml'; +const aGrass = 'actor|props/flora/grass_soft_small_tall.xml'; +const aGrassShort = 'actor|props/flora/grass_soft_large.xml'; +const aRockLarge = 'actor|geology/stone_granite_med.xml'; +const aRockMedium = 'actor|geology/stone_granite_med.xml'; +const aBushMedium = 'actor|props/flora/bush_medit_me.xml'; +const aBushSmall = 'actor|props/flora/bush_medit_sm.xml'; +const aReeds = 'actor|props/flora/reeds_pond_lush_b.xml'; -var terrainPrimary = ["temp_grass_plants", "temp_plants_bog"]; -var terrainWood = ['alpine_forrestfloor|gaia/tree/oak', 'alpine_forrestfloor|gaia/tree/pine']; -var terrainWoodBorder = ['new_alpine_grass_mossy|gaia/tree/oak', 'alpine_forrestfloor|gaia/tree/pine', +const terrainPrimary = ["temp_grass_plants", "temp_plants_bog"]; +const terrainWood = ['alpine_forrestfloor|gaia/tree/oak', 'alpine_forrestfloor|gaia/tree/pine']; +const terrainWoodBorder = ['new_alpine_grass_mossy|gaia/tree/oak', 'alpine_forrestfloor|gaia/tree/pine', 'temp_grass_long|gaia/tree/bush_temperate', 'temp_grass_clovers|gaia/fruit/berry_01', 'temp_grass_clovers_2|gaia/fruit/grapes', 'temp_grass_plants|gaia/fauna_deer', 'temp_grass_plants|gaia/fauna_rabbit', 'new_alpine_grass_dirt_a']; -var terrainBase = ['temp_plants_bog', 'temp_grass_plants', 'temp_grass_d', 'temp_grass_plants', +const terrainBase = ['temp_plants_bog', 'temp_grass_plants', 'temp_grass_d', 'temp_grass_plants', 'temp_plants_bog', 'temp_grass_plants', 'temp_grass_plants', 'temp_plants_bog', 'temp_grass_plants', 'temp_grass_plants', 'temp_plants_bog', 'temp_grass_plants', 'temp_grass_plants', @@ -47,7 +47,7 @@ 'temp_plants_bog', 'temp_grass_plants', 'temp_grass_d', 'temp_grass_plants', 'temp_plants_bog', 'temp_grass_plants', 'temp_grass_d', 'temp_grass_plants', 'temp_plants_bog', 'temp_grass_plants', 'temp_grass_plants', 'temp_grass_plants|gaia/fauna_sheep']; -var terrainBaseBorder = ['temp_plants_bog', 'temp_grass_plants', 'temp_grass_d', 'temp_grass_plants', +const terrainBaseBorder = ['temp_plants_bog', 'temp_grass_plants', 'temp_grass_d', 'temp_grass_plants', 'temp_plants_bog', 'temp_grass_plants', 'temp_grass_plants', 'temp_plants_bog', 'temp_grass_plants', 'temp_grass_plants', 'temp_plants_bog', 'temp_grass_plants', 'temp_grass_plants', @@ -59,61 +59,61 @@ 'temp_plants_bog', 'temp_grass_plants', 'temp_grass_d', 'temp_grass_plants', 'temp_plants_bog', 'temp_grass_plants', 'temp_grass_d', 'temp_grass_plants', 'temp_plants_bog', 'temp_grass_plants', 'temp_grass_plants']; -var baseTex = ['temp_road', 'temp_road_overgrown']; -var terrainPath = ['temp_road', 'temp_road_overgrown']; -var tWater = ['dirt_brown_d']; -var tWaterBorder = ['dirt_brown_d']; +const baseTex = ['temp_road', 'temp_road_overgrown']; +const terrainPath = ['temp_road', 'temp_road_overgrown']; +const tWater = ['dirt_brown_d']; +const tWaterBorder = ['dirt_brown_d']; const heightLand = 1; const heightOffsetPath = -0.1; -var g_Map = new RandomMap(heightLand, terrainPrimary); +const g_Map = new RandomMap(heightLand, terrainPrimary); -var clPlayer = g_Map.createTileClass(); -var clPath = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clOpen = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clPath = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clOpen = g_Map.createTileClass(); -var mapSize = g_Map.getSize(); -var mapCenter = g_Map.getCenter(); -var mapRadius = mapSize/2; +const mapSize = g_Map.getSize(); +const mapCenter = g_Map.getCenter(); +const mapRadius = mapSize/2; -var numPlayers = getNumPlayers(); -var baseRadius = 15; -var minPlayerRadius = Math.min(mapRadius - 1.5 * baseRadius, 5/8 * mapRadius); -var maxPlayerRadius = Math.min(mapRadius - baseRadius, 3/4 * mapRadius); +const numPlayers = getNumPlayers(); +const baseRadius = 15; +const minPlayerRadius = Math.min(mapRadius - 1.5 * baseRadius, 5/8 * mapRadius); +const maxPlayerRadius = Math.min(mapRadius - baseRadius, 3/4 * mapRadius); -var playerPosition = []; -var playerAngleStart = randomAngle(); -var playerAngleAddAvrg = 2 * Math.PI / numPlayers; -var playerAngleMaxOff = playerAngleAddAvrg/4; +let playerPosition = []; +const playerAngleStart = randomAngle(); +const playerAngleAddAvrg = 2 * Math.PI / numPlayers; +const playerAngleMaxOff = playerAngleAddAvrg/4; -var resourceRadius = fractionToTiles(1/3); +const resourceRadius = fractionToTiles(1/3); // Set up woods. // For large maps there are memory errors with too many trees. A density of 256x192/mapArea works with 0 players. // Around each player there is an area without trees so with more players the max density can increase a bit. -var maxTreeDensity = Math.min(256 * (192 + 8 * numPlayers) / Math.square(mapSize), 1); // Has to be tweeked but works ok. -var bushChance = 1/3; // 1 means 50% chance in deepest wood, 0.5 means 25% chance in deepest wood. +const maxTreeDensity = Math.min(256 * (192 + 8 * numPlayers) / Math.square(mapSize), 1); // Has to be tweeked but works ok. +const bushChance = 1/3; // 1 means 50% chance in deepest wood, 0.5 means 25% chance in deepest wood. // Set height limits and water level by map size. // Set target min and max height depending on map size to make average steepness about the same on all map sizes. -var heightRange = { 'min': MIN_HEIGHT * (g_Map.size + 512) / 8192, 'max': MAX_HEIGHT * (g_Map.size + 512) / 8192, 'avg': (MIN_HEIGHT * (g_Map.size + 512) + MAX_HEIGHT * (g_Map.size + 512)) / 16384 }; +const heightRange = { 'min': MIN_HEIGHT * (g_Map.size + 512) / 8192, 'max': MAX_HEIGHT * (g_Map.size + 512) / 8192, 'avg': (MIN_HEIGHT * (g_Map.size + 512) + MAX_HEIGHT * (g_Map.size + 512)) / 16384 }; // Set average water coverage. -var averageWaterCoverage = 1/5; // NOTE: Since erosion is not predictable actual water coverage might vary much with the same values. -var heightSeaGround = -MIN_HEIGHT + heightRange.min + averageWaterCoverage * (heightRange.max - heightRange.min); -var heightSeaGroundAdjusted = heightSeaGround + MIN_HEIGHT; +const averageWaterCoverage = 1/5; // NOTE: Since erosion is not predictable actual water coverage might vary much with the same values. +const heightSeaGround = -MIN_HEIGHT + heightRange.min + averageWaterCoverage * (heightRange.max - heightRange.min); +const heightSeaGroundAdjusted = heightSeaGround + MIN_HEIGHT; setWaterHeight(heightSeaGround); // Setting a 3x3 grid as initial heightmap. -var initialReliefmap = [[heightRange.max, heightRange.max, heightRange.max], [heightRange.max, heightRange.min, heightRange.max], [heightRange.max, heightRange.max, heightRange.max]]; +const initialReliefmap = [[heightRange.max, heightRange.max, heightRange.max], [heightRange.max, heightRange.min, heightRange.max], [heightRange.max, heightRange.max, heightRange.max]]; setBaseTerrainDiamondSquare(heightRange.min, heightRange.max, initialReliefmap); @@ -124,7 +124,7 @@ rescaleHeightmap(heightRange.min, heightRange.max); -var heighLimits = [ +const heighLimits = [ heightRange.min + 1/3 * (heightSeaGroundAdjusted - heightRange.min), // 0 Deep water heightRange.min + 2/3 * (heightSeaGroundAdjusted - heightRange.min), // 1 Medium Water heightRange.min + (heightSeaGroundAdjusted - heightRange.min), // 2 Shallow water @@ -185,8 +185,8 @@ }); g_Map.log("Creating mines"); -for (let [minHeight, maxHeight] of [[heighLimits[3], (heighLimits[4] + heighLimits[3]) / 2], [(heighLimits[5] + heighLimits[6]) / 2, heighLimits[7]]]) - for (let [template, tileClass] of [[oStoneLarge, clRock], [oMetalLarge, clMetal]]) +for (const [minHeight, maxHeight] of [[heighLimits[3], (heighLimits[4] + heighLimits[3]) / 2], [(heighLimits[5] + heighLimits[6]) / 2, heighLimits[7]]]) + for (const [template, tileClass] of [[oStoneLarge, clRock], [oMetalLarge, clMetal]]) createObjectGroups( new SimpleGroup([new SimpleObject(template, 1, 1, 0, 4)], true, tileClass), 0, @@ -201,7 +201,7 @@ Engine.SetProgress(50); g_Map.log("Painting textures"); -var betweenShallowAndShore = (heighLimits[3] + heighLimits[2]) / 2; +const betweenShallowAndShore = (heighLimits[3] + heighLimits[2]) / 2; createArea( new HeightPlacer(Elevation_IncludeMin_IncludeMax, heighLimits[2], betweenShallowAndShore), new LayeredPainter([terrainBase, terrainBaseBorder], [5])); @@ -216,12 +216,12 @@ Engine.SetProgress(60); g_Map.log("Painting paths"); -var pathBlending = numPlayers <= 4; +const pathBlending = numPlayers <= 4; for (let i = 0; i < numPlayers + (pathBlending ? 1 : 0); ++i) for (let j = pathBlending ? 0 : i + 1; j < numPlayers + 1; ++j) { - let pathStart = i < numPlayers ? playerPosition[i] : mapCenter; - let pathEnd = j < numPlayers ? playerPosition[j] : mapCenter; + const pathStart = i < numPlayers ? playerPosition[i] : mapCenter; + const pathEnd = j < numPlayers ? playerPosition[j] : mapCenter; createArea( new RandomPathPlacer(pathStart, pathEnd, 1.75, baseRadius / 2, pathBlending), @@ -268,8 +268,8 @@ Engine.SetProgress(85); g_Map.log("Planting reeds"); -var types = [aReeds]; -for (let type of types) +const types = [aReeds]; +for (const type of types) createObjectGroupsDeprecated( new SimpleGroup([new SimpleObject(type, 1, 1, 0, 0)], true), 0, @@ -280,31 +280,31 @@ Engine.SetProgress(90); g_Map.log("Planting trees"); -for (var x = 0; x < mapSize; x++) - for (var z = 0; z < mapSize; z++) +for (let x = 0; x < mapSize; x++) + for (let z = 0; z < mapSize; z++) { - let position = new Vector2D(x, z); + const position = new Vector2D(x, z); if (!g_Map.validTile(position)) continue; // The 0.5 is a correction for the entities placed on the center of tiles - let radius = Vector2D.add(position, new Vector2D(0.5, 0.5)).distanceTo(mapCenter); - var minDistToSL = mapSize; + const radius = Vector2D.add(position, new Vector2D(0.5, 0.5)).distanceTo(mapCenter); + let minDistToSL = mapSize; for (let i = 0; i < numPlayers; ++i) minDistToSL = Math.min(minDistToSL, position.distanceTo(playerPosition[i])); // Woods tile based - var tDensFactSL = Math.max(Math.min((minDistToSL - baseRadius) / baseRadius, 1), 0); - var tDensFactRad = Math.abs((resourceRadius - radius) / resourceRadius); - var tDensActual = (maxTreeDensity * tDensFactSL * tDensFactRad)*0.75; + const tDensFactSL = Math.max(Math.min((minDistToSL - baseRadius) / baseRadius, 1), 0); + const tDensFactRad = Math.abs((resourceRadius - radius) / resourceRadius); + const tDensActual = (maxTreeDensity * tDensFactSL * tDensFactRad)*0.75; if (!randBool(tDensActual)) continue; - let border = tDensActual < randFloat(0, bushChance * maxTreeDensity); + const border = tDensActual < randFloat(0, bushChance * maxTreeDensity); - let constraint = border ? + const constraint = border ? avoidClasses(clPath, 1, clOpen, 2, clWater, 3, clMetal, 4, clRock, 4) : avoidClasses(clPath, 2, clOpen, 3, clWater, 4, clMetal, 4, clRock, 4); Index: binaries/data/mods/public/maps/random/scythian_rivulet.js =================================================================== --- binaries/data/mods/public/maps/random/scythian_rivulet.js +++ binaries/data/mods/public/maps/random/scythian_rivulet.js @@ -40,39 +40,39 @@ const pForest1 = [tForestFloor2 + TERRAIN_SEPARATOR + oTreeDead, tForestFloor2 + TERRAIN_SEPARATOR + oOak, tForestFloor2]; const pForest2 = [tForestFloor1 + TERRAIN_SEPARATOR + oTreeDead, tForestFloor1]; -var heightSeaGround = -2; -var heightShoreLower = 0.7; -var heightShoreUpper = 1; -var heightLand = 2; -var heightSnowline = 12; -var heightOffsetLargeBumps = 4; +const heightSeaGround = -2; +const heightShoreLower = 0.7; +const heightShoreUpper = 1; +const heightLand = 2; +const heightSnowline = 12; +const heightOffsetLargeBumps = 4; -var g_Map = new RandomMap(heightShoreUpper, tMainTerrain); +const g_Map = new RandomMap(heightShoreUpper, tMainTerrain); const numPlayers = getNumPlayers(); const mapCenter = g_Map.getCenter(); const mapBounds = g_Map.getBounds(); -var clPlayer = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRiver = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clShallowsFlora = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRiver = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clShallowsFlora = g_Map.createTileClass(); -var riverWidth = fractionToTiles(0.1); +const riverWidth = fractionToTiles(0.1); -var startAngle = randomAngle(); +const startAngle = randomAngle(); -var [playerIDs, playerPosition] = playerPlacementRiver(startAngle, fractionToTiles(0.6)); +const [playerIDs, playerPosition] = playerPlacementRiver(startAngle, fractionToTiles(0.6)); if (!isNomad()) - for (let position of playerPosition) + for (const position of playerPosition) addCivicCenterAreaToClass(position, clPlayer); paintRiver({ @@ -186,7 +186,7 @@ scaleByMapSize(25, 55), clDirt); -var [forestTrees, stragglerTrees] = getTreeCounts(200, 1200, 0.7); +const [forestTrees, stragglerTrees] = getTreeCounts(200, 1200, 0.7); createForests( [tForestFloor1, tForestFloor2, tForestFloor1, pForest1, pForest2], avoidClasses(clPlayer, 20, clWater, 2, clHill, 2, clForest, 12), 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 @@ -44,20 +44,20 @@ const heightIsland = 20; const heightSeaGround = -5; -var g_Map = new RandomMap(heightSeaGround, tWater); +const g_Map = new RandomMap(heightSeaGround, tWater); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clLand = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clLand = g_Map.createTileClass(); const playerIslandRadius = scaleByMapSize(15, 30); @@ -94,16 +94,16 @@ function createIslandAtRadialLocation(playerID, islandID, playerIDOffset, distFromCenter, islandRadius) { - let angle = startAngle + (playerID * 2 + playerIDOffset) * Math.PI / numPlayers; + const angle = startAngle + (playerID * 2 + playerIDOffset) * Math.PI / numPlayers; islandPos[islandID] = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(distFromCenter), 0).rotate(-angle)).round(); createIsland(islandID, islandRadius, clLand); } function createSnowflakeSearockWithCenter(sizeID) { - let [tertiaryIslandDist, tertiaryIslandRadius, islandBetweenPlayersDist, islandBetweenPlayersRadius] = islandSizes[sizeID]; + const [tertiaryIslandDist, tertiaryIslandRadius, islandBetweenPlayersDist, islandBetweenPlayersRadius] = islandSizes[sizeID]; - let islandID_center = 4 * numPlayers; + const islandID_center = 4 * numPlayers; numIslands = islandID_center + 1; initIsConnected(); @@ -113,14 +113,14 @@ for (let playerID = 0; playerID < numPlayers; ++playerID) { - let playerID_neighbor = playerID + 1 < numPlayers ? playerID + 1 : 0; + const playerID_neighbor = playerID + 1 < numPlayers ? playerID + 1 : 0; - let islandID_player = playerID; - let islandID_playerNeighbor = playerID_neighbor; - let islandID_betweenPlayers = playerID + numPlayers; - let islandID_betweenPlayerAndCenter = playerID + 2 * numPlayers; - let islandID_betweenPlayerAndCenterNeighbor = playerID_neighbor + 2 * numPlayers; - let islandID_tertiary = playerID + 3 * numPlayers; + const islandID_player = playerID; + const islandID_playerNeighbor = playerID_neighbor; + const islandID_betweenPlayers = playerID + numPlayers; + const islandID_betweenPlayerAndCenter = playerID + 2 * numPlayers; + const islandID_betweenPlayerAndCenterNeighbor = playerID_neighbor + 2 * numPlayers; + const islandID_tertiary = playerID + 3 * numPlayers; g_Map.log("Creating island between the player and their neighbor"); isConnected[islandID_betweenPlayers][islandID_player] = 1; @@ -149,12 +149,12 @@ for (let playerID = 0; playerID < numPlayers; ++playerID) { - let playerID_neighbor = playerID + 1 < numPlayers ? playerID + 1 : 0; + const playerID_neighbor = playerID + 1 < numPlayers ? playerID + 1 : 0; - let islandID_player = playerID; - let islandID_playerNeighbor = playerID_neighbor; - let islandID_inFrontOfPlayer = playerID + numPlayers; - let islandID_inFrontOfPlayerNeighbor = playerID_neighbor + numPlayers; + const islandID_player = playerID; + const islandID_playerNeighbor = playerID_neighbor; + const islandID_inFrontOfPlayer = playerID + numPlayers; + const islandID_inFrontOfPlayerNeighbor = playerID_neighbor + numPlayers; isConnected[islandID_player][islandID_playerNeighbor] = 1; isConnected[islandID_player][islandID_inFrontOfPlayer] = 1; @@ -169,7 +169,7 @@ numIslands = numPlayers + 1; initIsConnected(); - let islandID_center = numPlayers; + const islandID_center = numPlayers; g_Map.log("Creating central island"); islandPos[islandID_center] = mapCenter; @@ -177,7 +177,7 @@ for (let playerID = 0; playerID < numPlayers; ++playerID) { - let islandID_player = playerID; + const islandID_player = playerID; isConnected[islandID_player][islandID_center] = 1; } } @@ -275,15 +275,15 @@ Engine.SetProgress(40); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); -var types = [ +const [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); +const types = [ [[tForestFloor2, tMainTerrain, pForest1], [tForestFloor2, pForest1]], [[tForestFloor1, tMainTerrain, pForest2], [tForestFloor1, pForest2]] ]; -var size = forestTrees / (scaleByMapSize(2, 8) * numPlayers) * (currentBiome() == "generic/savanna" ? 2 : 1); -var num = Math.floor(size / types.length); -for (let type of types) +const forestSize = forestTrees / (scaleByMapSize(2, 8) * numPlayers) * (currentBiome() == "generic/savanna" ? 2 : 1); +const num = Math.floor(forestSize / types.length); +for (const type of types) createAreas( new ClumpPlacer(forestTrees / num, 0.1, 0.1, Infinity), [ @@ -295,7 +295,7 @@ Engine.SetProgress(55); 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, 10, clRock, 10), stayClasses(clLand, 5)], 5*scaleByMapSize(4,16), 100 @@ -317,7 +317,7 @@ Engine.SetProgress(65); g_Map.log("Creating dirt patches"); -for (let size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) +for (const size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), [ @@ -328,7 +328,7 @@ scaleByMapSize(15, 45)); g_Map.log("Creating grass patches"); -for (let size of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)]) +for (const size of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), new TerrainPainter(tTier4Terrain), @@ -398,7 +398,7 @@ clForest, stragglerTrees); -var planetm = 1; +let planetm = 1; if (currentBiome() == "generic/india") planetm = 8; Index: binaries/data/mods/public/maps/random/stronghold.js =================================================================== --- binaries/data/mods/public/maps/random/stronghold.js +++ binaries/data/mods/public/maps/random/stronghold.js @@ -7,7 +7,7 @@ const heightLand = 30; -var g_Map = new RandomMap(heightLand, g_Terrains.mainTerrain); +const g_Map = new RandomMap(heightLand, g_Terrains.mainTerrain); initTileClasses(); Index: binaries/data/mods/public/maps/random/survivalofthefittest.js =================================================================== --- binaries/data/mods/public/maps/random/survivalofthefittest.js +++ binaries/data/mods/public/maps/random/survivalofthefittest.js @@ -43,19 +43,19 @@ const heightLand = 3; const heightHill = 30; -var g_Map = new RandomMap(heightHill, tMainTerrain); +const g_Map = new RandomMap(heightHill, tMainTerrain); -var numPlayers = getNumPlayers(); -var mapSize = g_Map.getSize(); -var mapCenter = g_Map.getCenter(); +const numPlayers = getNumPlayers(); +const mapSize = g_Map.getSize(); +const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clLand = g_Map.createTileClass(); -var clWomen = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clLand = g_Map.createTileClass(); +const clWomen = g_Map.createTileClass(); g_Map.log("Creating central area"); createArea( @@ -67,10 +67,10 @@ ]); Engine.SetProgress(10); -var [playerIDs, playerPosition, playerAngle, startAngle] = playerPlacementCircle(fractionToTiles(0.3)); -var halfway = distributePointsOnCircle(numPlayers, startAngle, fractionToTiles(0.375), mapCenter)[0].map(v => v.round()); -var attacker = distributePointsOnCircle(numPlayers, startAngle, fractionToTiles(0.45), mapCenter)[0].map(v => v.round()); -var passage = distributePointsOnCircle(numPlayers, startAngle + Math.PI / numPlayers, fractionToTiles(0.5), mapCenter)[0]; +const [playerIDs, playerPosition, playerAngle, startAngle] = playerPlacementCircle(fractionToTiles(0.3)); +const halfway = distributePointsOnCircle(numPlayers, startAngle, fractionToTiles(0.375), mapCenter)[0].map(v => v.round()); +const attacker = distributePointsOnCircle(numPlayers, startAngle, fractionToTiles(0.45), mapCenter)[0].map(v => v.round()); +const passage = distributePointsOnCircle(numPlayers, startAngle + Math.PI / numPlayers, fractionToTiles(0.5), mapCenter)[0]; g_Map.log("Creating player bases, passages, treasure seeker woman and attacker points"); for (let i = 0; i < numPlayers; ++i) @@ -93,7 +93,7 @@ ]); // Treasure seeker woman - let femaleLocation = findLocationInDirectionBasedOnHeight(playerPosition[i], mapCenter, -3 , 3.5, 3).round(); + const femaleLocation = findLocationInDirectionBasedOnHeight(playerPosition[i], mapCenter, -3 , 3.5, 3).round(); clWomen.add(femaleLocation); g_Map.placeEntityPassable(oTreasureSeeker, playerIDs[i], femaleLocation, playerAngle[i] + Math.PI); @@ -112,9 +112,9 @@ paintTileClassBasedOnHeight(heightLand + 0.12, heightHill - 1, Elevation_IncludeMin_ExcludeMax, clHill); Engine.SetProgress(30); -var landConstraint = new StaticConstraint(stayClasses(clLand, 5)); +const landConstraint = new StaticConstraint(stayClasses(clLand, 5)); -for (let triggerPointTreasure of triggerPointTreasures) +for (const triggerPointTreasure of triggerPointTreasures) createObjectGroupsDeprecated( new SimpleGroup([new SimpleObject(triggerPointTreasure, 1, 1, 0, 0)], true, clWomen), 0, @@ -126,7 +126,7 @@ createBumps(landConstraint); Engine.SetProgress(40); -var hillConstraint = new AndConstraint([avoidClasses(clHill, 5), new StaticConstraint(avoidClasses(clPlayer, 20, clBaseResource, 3, clWomen, 5))]); +const hillConstraint = new AndConstraint([avoidClasses(clHill, 5), new StaticConstraint(avoidClasses(clPlayer, 20, clBaseResource, 3, clWomen, 5))]); if (randBool()) createHills([tMainTerrain, tCliff, tHill], [hillConstraint, landConstraint], clHill, scaleByMapSize(10, 60) * numPlayers); else @@ -145,7 +145,7 @@ 55); Engine.SetProgress(50); -var [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); +const [forestTrees, stragglerTrees] = getTreeCounts(...rBiomeTreeCount(1)); createForests( [tMainTerrain, tForestFloor1, tForestFloor2, pForest1, pForest2], [avoidClasses(clForest, 5), new StaticConstraint([avoidClasses(clPlayer, 20, clHill, 0, clBaseResource, 2, clWomen, 5), stayClasses(clLand, 4)])], @@ -173,7 +173,7 @@ clDirt); Engine.SetProgress(80); -var planetm = 1; +let planetm = 1; if (currentBiome() == "generic/india") planetm = 8; Index: binaries/data/mods/public/maps/random/syria.js =================================================================== --- binaries/data/mods/public/maps/random/syria.js +++ binaries/data/mods/public/maps/random/syria.js @@ -36,21 +36,21 @@ const heightHill = 22; const heightOffsetBump = 2; -var g_Map = new RandomMap(heightLand, tMainDirt); +const g_Map = new RandomMap(heightLand, tMainDirt); const mapCenter = g_Map.getCenter(); const numPlayers = getNumPlayers(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clGrass = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clGrass = g_Map.createTileClass(); -var [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.35)); +const [playerIDs, playerPosition] = playerPlacementCircle(fractionToTiles(0.35)); g_Map.log("Creating big grass patches around the playerbases"); for (let i = 0; i < numPlayers; ++i) @@ -127,14 +127,14 @@ Engine.SetProgress(25); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(400, 2000, 0.7); -var types = [ +const [forestTrees, stragglerTrees] = getTreeCounts(400, 2000, 0.7); +const types = [ [[tMainDirt, tForestFloor2, pForestP], [tForestFloor2, pForestP]], [[tMainDirt, tForestFloor1, pForestT], [tForestFloor1, pForestT]] ]; -var size = forestTrees / (scaleByMapSize(3,6) * numPlayers); -var num = Math.floor(size / types.length); -for (let type of types) +const forestSize = forestTrees / (scaleByMapSize(3,6) * numPlayers); +const num = Math.floor(forestSize / types.length); +for (const type of types) createAreas( new ChainPlacer( 1, @@ -151,7 +151,7 @@ Engine.SetProgress(40); g_Map.log("Creating dirt patches"); -for (let size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) +for (const size of [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5), new LayeredPainter([tSecondaryDirt, tDirt], [1]), @@ -160,7 +160,7 @@ Engine.SetProgress(60); g_Map.log("Creating big patches"); -for (let size of [scaleByMapSize(6, 30), scaleByMapSize(10, 50), scaleByMapSize(16, 70)]) +for (const size of [scaleByMapSize(6, 30), scaleByMapSize(10, 50), scaleByMapSize(16, 70)]) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(3, 5)), size, 0.5), new LayeredPainter([tSecondaryDirt, tDirt], [1]), @@ -184,7 +184,7 @@ 100); g_Map.log("Creating small stone quarries"); -var group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3), new RandomObject(aBushes, 2,4, 0,2)], true, clRock); +let group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3), new RandomObject(aBushes, 2,4, 0,2)], true, clRock); createObjectGroupsDeprecated(group, 0, [avoidClasses(clForest, 1, clPlayer, 10, clRock, 10, clHill, 1, clGrass, 1)], scaleByMapSize(2,8), 100 Index: binaries/data/mods/public/maps/random/the_nile.js =================================================================== --- binaries/data/mods/public/maps/random/the_nile.js +++ binaries/data/mods/public/maps/random/the_nile.js @@ -1,44 +1,44 @@ Engine.LoadLibrary("rmgen"); Engine.LoadLibrary("rmgen-common"); -var tPrimary = "desert_sand_dunes_100"; -var tCity = "desert_city_tile"; -var tCityPlaza = "desert_city_tile_plaza"; -var tFineSand = "desert_sand_smooth"; -var tForestFloor = "desert_forestfloor_palms"; -var tGrass = "desert_dirt_rough_2"; -var tGrassSand50 = "desert_sand_dunes_50"; -var tGrassSand25 = "desert_dirt_rough"; -var tDirt = "desert_dirt_rough"; -var tDirtCracks = "desert_dirt_cracks"; -var tShore = "desert_sand_wet"; -var tLush = "desert_grass_a"; -var tSLush = "desert_grass_a_sand"; -var tSDry = "desert_plants_b"; +const tPrimary = "desert_sand_dunes_100"; +const tCity = "desert_city_tile"; +const tCityPlaza = "desert_city_tile_plaza"; +const tFineSand = "desert_sand_smooth"; +const tForestFloor = "desert_forestfloor_palms"; +const tGrass = "desert_dirt_rough_2"; +const tGrassSand50 = "desert_sand_dunes_50"; +const tGrassSand25 = "desert_dirt_rough"; +const tDirt = "desert_dirt_rough"; +const tDirtCracks = "desert_dirt_cracks"; +const tShore = "desert_sand_wet"; +const tLush = "desert_grass_a"; +const tSLush = "desert_grass_a_sand"; +const tSDry = "desert_plants_b"; -var oBerryBush = "gaia/fruit/berry_01"; -var oCamel = "gaia/fauna_camel"; -var oGazelle = "gaia/fauna_gazelle"; -var oGoat = "gaia/fauna_goat"; -var oStoneLarge = "gaia/rock/badlands_large"; -var oStoneSmall = "gaia/rock/desert_small"; -var oMetalLarge = "gaia/ore/desert_large"; -var oDatePalm = "gaia/tree/date_palm"; -var oSDatePalm = "gaia/tree/cretan_date_palm_short"; -var eObelisk = "structures/obelisk"; -var ePyramid = "gaia/ruins/pyramid_minor"; -var oWoodTreasure = "gaia/treasure/wood"; -var oFoodTreasure = "gaia/treasure/food_bin"; +const oBerryBush = "gaia/fruit/berry_01"; +const oCamel = "gaia/fauna_camel"; +const oGazelle = "gaia/fauna_gazelle"; +const oGoat = "gaia/fauna_goat"; +const oStoneLarge = "gaia/rock/badlands_large"; +const oStoneSmall = "gaia/rock/desert_small"; +const oMetalLarge = "gaia/ore/desert_large"; +const oDatePalm = "gaia/tree/date_palm"; +const oSDatePalm = "gaia/tree/cretan_date_palm_short"; +const eObelisk = "structures/obelisk"; +const ePyramid = "gaia/ruins/pyramid_minor"; +const oWoodTreasure = "gaia/treasure/wood"; +const oFoodTreasure = "gaia/treasure/food_bin"; -var aBush1 = "actor|props/flora/bush_desert_a.xml"; -var aBush2 = "actor|props/flora/bush_desert_dry_a.xml"; -var aBush3 = "actor|props/flora/bush_medit_sm_dry.xml"; -var aBush4 = "actor|props/flora/plant_desert_a.xml"; -var aDecorativeRock = "actor|geology/stone_desert_med.xml"; -var aReeds = "actor|props/flora/reeds_pond_lush_a.xml"; -var aLillies = "actor|props/flora/water_lillies.xml"; +const aBush1 = "actor|props/flora/bush_desert_a.xml"; +const aBush2 = "actor|props/flora/bush_desert_dry_a.xml"; +const aBush3 = "actor|props/flora/bush_medit_sm_dry.xml"; +const aBush4 = "actor|props/flora/plant_desert_a.xml"; +const aDecorativeRock = "actor|geology/stone_desert_med.xml"; +const aReeds = "actor|props/flora/reeds_pond_lush_a.xml"; +const aLillies = "actor|props/flora/water_lillies.xml"; -var pForest = [tForestFloor + TERRAIN_SEPARATOR + oDatePalm, tForestFloor + TERRAIN_SEPARATOR + oSDatePalm, tForestFloor]; +const pForest = [tForestFloor + TERRAIN_SEPARATOR + oDatePalm, tForestFloor + TERRAIN_SEPARATOR + oSDatePalm, tForestFloor]; const heightLand = 1; const heightShore = 2; @@ -46,34 +46,34 @@ const heightSeaGround = -3; const heightOffsetBump = 2; -var g_Map = new RandomMap(heightLand, tPrimary); +const g_Map = new RandomMap(heightLand, tPrimary); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); const mapBounds = g_Map.getBounds(); -var aPlants = mapSize < 256 ? +const aPlants = mapSize < 256 ? "actor|props/flora/grass_tropical.xml" : "actor|props/flora/grass_tropic_field_tall.xml"; -var numPlayers = getNumPlayers(); +const numPlayers = getNumPlayers(); -var clPlayer = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clGrass = g_Map.createTileClass(); -var clDesert = g_Map.createTileClass(); -var clPond = g_Map.createTileClass(); -var clShore = g_Map.createTileClass(); -var clTreasure = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clGrass = g_Map.createTileClass(); +const clDesert = g_Map.createTileClass(); +const clPond = g_Map.createTileClass(); +const clShore = g_Map.createTileClass(); +const clTreasure = g_Map.createTileClass(); -var desertWidth = fractionToTiles(0.25); -var startAngle = randomAngle(); +const desertWidth = fractionToTiles(0.25); +const startAngle = randomAngle(); placePlayerBases({ "PlayerPlacement": playerPlacementRiver(startAngle, fractionToTiles(0.4)), @@ -131,7 +131,7 @@ ]; const plantFrequency = 2; -var plantID = 0; +let plantID = 0; paintRiver({ "parallel": true, @@ -162,7 +162,7 @@ }, "landFunc": (position, shoreDist1, shoreDist2) => { - for (let riv of riverTextures) + for (const riv of riverTextures) if (riv.left < +shoreDist1 && +shoreDist1 < riv.right || riv.left < -shoreDist2 && -shoreDist2 < riv.right) { @@ -183,8 +183,8 @@ scaleByMapSize(100, 200)); g_Map.log("Creating ponds"); -var numLakes = Math.round(scaleByMapSize(1, 4) * numPlayers / 2); -var waterAreas = createAreas( +const numLakes = Math.round(scaleByMapSize(1, 4) * numPlayers / 2); +const waterAreas = createAreas( new ClumpPlacer(scaleByMapSize(2, 5) * 50, 0.8, 0.1, Infinity), [ new TerrainPainter(tShore), @@ -213,8 +213,8 @@ waterAreas); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(700, 3500, 0.5); -var num = scaleByMapSize(10,30); +const [forestTrees, stragglerTrees] = getTreeCounts(700, 3500, 0.5); +const num = scaleByMapSize(10,30); createAreas( new ClumpPlacer(forestTrees / num, 0.15, 0.1, 0.5), [ @@ -228,7 +228,7 @@ Engine.SetProgress(50); g_Map.log("Creating grass patches"); -for (let size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) +for (const size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), [ @@ -242,7 +242,7 @@ Engine.SetProgress(55); g_Map.log("Creating dirt patches"); -for (let size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) +for (const size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), [ @@ -257,7 +257,7 @@ Engine.SetProgress(60); 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, clWater, 1, clPond, 1), scaleByMapSize(4,16), 100 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 @@ -51,26 +51,26 @@ const heightHill = 18; const heightOffsetBump = 2; -var g_Map = new RandomMap(heightSeaGround, tWater); +const g_Map = new RandomMap(heightSeaGround, tWater); const numPlayers = getNumPlayers(); const mapSize = g_Map.getSize(); const mapCenter = g_Map.getCenter(); const mapBounds = g_Map.getBounds(); -var clPlayer = g_Map.createTileClass(); -var clPlayerTerritory = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clWater = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clFood = g_Map.createTileClass(); -var clPeninsulaSteam = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); -var clLand = g_Map.createTileClass(); -var clShallow = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clPlayerTerritory = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clWater = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clFood = g_Map.createTileClass(); +const clPeninsulaSteam = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); +const clLand = g_Map.createTileClass(); +const clShallow = g_Map.createTileClass(); var landElevationPainter = new SmoothElevationPainter(ELEVATION_SET, heightLand, 4); @@ -127,7 +127,7 @@ g_StartingWalls = "towers"; g_StartingTreasures = true; - let [pIDs, islandPosition] = playerPlacementCircle(fractionToTiles(0.35)); + const [pIDs, islandPosition] = playerPlacementCircle(fractionToTiles(0.35)); if (!isNomad()) { [playerIDs, playerPosition] = [pIDs, islandPosition]; @@ -135,13 +135,13 @@ } g_Map.log("Creating islands"); - let islandSize = diskArea(scaleByMapSize(17, 29)); + const islandSize = diskArea(scaleByMapSize(17, 29)); for (let i = 0; i < numPlayers; ++i) createArea( new ClumpPlacer(islandSize, 0.8, 0.1, Infinity, islandPosition[i]), landElevationPainter); - let type = isNomad() ? randIntInclusive(1, 2) : randIntInclusive(1, 3); + const type = isNomad() ? randIntInclusive(1, 2) : randIntInclusive(1, 3); if (type == 1) { g_Map.log("Creating archipelago"); @@ -207,7 +207,7 @@ */ function unknownContinent() { - let waterHeight = -5; + const waterHeight = -5; if (!isNomad()) { @@ -242,8 +242,8 @@ if (randBool(1/3)) { g_Map.log("Creating peninsula (i.e. half the map not being surrounded by water)"); - let angle = randomAngle(); - let peninsulaPosition1 = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.25), 0).rotate(-angle)); + const angle = randomAngle(); + const peninsulaPosition1 = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.25), 0).rotate(-angle)); createArea( new ClumpPlacer(diskArea(fractionToTiles(0.38)), 0.9, 0.09, Infinity, peninsulaPosition1), [ @@ -252,7 +252,7 @@ ]); g_Map.log("Remembering to not paint shorelines into the peninsula"); - let peninsulaPosition2 = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.35), 0).rotate(-angle)); + const peninsulaPosition2 = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(0.35), 0).rotate(-angle)); createArea( new ClumpPlacer(diskArea(fractionToTiles(0.33)), 0.9, 0.01, Infinity, peninsulaPosition2), new TileClassPainter(clPeninsulaSteam)); @@ -276,11 +276,11 @@ */ function unknownCentralSeaOrIsthmus(isthmus) { - let waterHeight = -3; + const waterHeight = -3; - let startAngle = randomAngle(); + const startAngle = randomAngle(); - let [riverStart, riverEnd] = centralRiverCoordinates(startAngle); + const [riverStart, riverEnd] = centralRiverCoordinates(startAngle); paintRiver({ "parallel": false, @@ -312,7 +312,7 @@ if (isthmus) { g_Map.log("Creating isthmus (i.e. connecting the two riversides with a big land passage)"); - let [isthmusStart, isthmusEnd] = centralRiverCoordinates(startAngle + Math.PI / 2); + const [isthmusStart, isthmusEnd] = centralRiverCoordinates(startAngle + Math.PI / 2); createArea( new PathPlacer( isthmusStart, @@ -348,14 +348,14 @@ */ function unknownCentralRiver(shallows) { - let waterHeight = -4; - let heightShallow = -2; + const waterHeight = -4; + const heightShallow = -2; createArea( new MapBoundsPlacer(), new ElevationPainter(heightLand)); - let startAngle = randomAngle(); + const startAngle = randomAngle(); if (!isNomad()) { @@ -364,14 +364,14 @@ } g_Map.log("Creating the main river"); - let [coord1, coord2] = centralRiverCoordinates(startAngle); + const [coord1, coord2] = centralRiverCoordinates(startAngle); createArea( new PathPlacer(coord1, coord2, scaleByMapSize(14, 24), 0.5, scaleByMapSize(3, 12), 0.1, 0.01), new SmoothElevationPainter(ELEVATION_SET, waterHeight, 4), avoidClasses(clPlayerTerritory, 4)); g_Map.log("Creating small water spots at the map border to ensure separation of players"); - for (let coord of [coord1, coord2]) + for (const coord of [coord1, coord2]) createArea( new ClumpPlacer(diskArea(scaleByMapSize(5, 10)), 0.95, 0.6, Infinity, coord), new SmoothElevationPainter(ELEVATION_SET, waterHeight, 2), @@ -382,7 +382,7 @@ g_Map.log("Creating the shallows of the main river"); for (let i = 0; i <= randIntInclusive(1, scaleByMapSize(4, 8)); ++i) { - let location = fractionToTiles(randFloat(0.15, 0.85)); + const location = fractionToTiles(randFloat(0.15, 0.85)); createPassage({ "start": new Vector2D(location, mapBounds.top).rotateAround(startAngle, mapCenter), "end": new Vector2D(location, mapBounds.bottom).rotateAround(startAngle, mapCenter), @@ -415,7 +415,7 @@ */ function unknownRiversAndLake() { - let waterHeight = -4; + const waterHeight = -4; createArea( new MapBoundsPlacer(), new ElevationPainter(heightLand)); @@ -428,7 +428,7 @@ markPlayerArea("small"); } - let lake = randBool(3/4); + const lake = randBool(3/4); if (lake) { g_Map.log("Creating lake"); @@ -446,7 +446,7 @@ { g_Map.log("Creating small rivers separating players"); - for (let river of distributePointsOnCircle(numPlayers, startAngle + Math.PI / numPlayers, fractionToTiles(0.5), mapCenter)[0]) + for (const river of distributePointsOnCircle(numPlayers, startAngle + Math.PI / numPlayers, fractionToTiles(0.5), mapCenter)[0]) { createArea( new PathPlacer(mapCenter, river, scaleByMapSize(14, 24), 0.4, 3 * scaleByMapSize(1, 3), 0.2, 0.05), @@ -491,13 +491,13 @@ */ function unknownEdgeSeas() { - let waterHeight = -4; + const waterHeight = -4; createArea( new MapBoundsPlacer(), new ElevationPainter(heightLand)); - let startAngle = randomAngle(); + const startAngle = randomAngle(); if (!isNomad()) { playerIDs = sortAllPlayers(); @@ -506,7 +506,7 @@ markPlayerArea("small"); } - for (let side of pickRandom([[0], [Math.PI], [0, Math.PI]])) + for (const side of pickRandom([[0], [Math.PI], [0, Math.PI]])) paintRiver({ "parallel": true, "start": new Vector2D(mapBounds.left, mapBounds.top).rotateAround(side + startAngle, mapCenter), @@ -530,13 +530,13 @@ */ function unknownGulf() { - let waterHeight = -3; + const waterHeight = -3; createArea( new MapBoundsPlacer(), new ElevationPainter(heightLand)); - let startAngle = randomAngle(); + const startAngle = randomAngle(); if (!isNomad()) { g_Map.log("Determining player locations"); @@ -549,15 +549,15 @@ markPlayerArea("large"); } - let gulfParts = [ + const gulfParts = [ { "radius": fractionToTiles(0.16), "distance": fractionToTiles(0) }, { "radius": fractionToTiles(0.2), "distance": fractionToTiles(0.2) }, { "radius": fractionToTiles(0.22), "distance": fractionToTiles(0.49) } ]; - for (let gulfPart of gulfParts) + for (const gulfPart of gulfParts) { - let position = Vector2D.sub(mapCenter, new Vector2D(gulfPart.distance, 0).rotate(-startAngle)).round(); + const position = Vector2D.sub(mapCenter, new Vector2D(gulfPart.distance, 0).rotate(-startAngle)).round(); createArea( new ClumpPlacer(diskArea(gulfPart.radius), 0.7, 0.05, Infinity, position), [ @@ -573,7 +573,7 @@ */ function unknownLakes() { - let waterHeight = -5; + const waterHeight = -5; createArea( new MapBoundsPlacer(), @@ -601,8 +601,8 @@ */ function unknownPasses() { - let heightMountain = 24; - let waterHeight = -4; + const heightMountain = 24; + const waterHeight = -4; createArea( new MapBoundsPlacer(), @@ -619,7 +619,7 @@ startAngle = randomAngle(); g_Map.log("Creating a mountain range between neighboring players"); - for (let mountain of distributePointsOnCircle(numPlayers, startAngle + Math.PI / numPlayers, fractionToTiles(0.5), mapCenter)[0]) + for (const mountain of distributePointsOnCircle(numPlayers, startAngle + Math.PI / numPlayers, fractionToTiles(0.5), mapCenter)[0]) { createArea( new PathPlacer(mapCenter, mountain, scaleByMapSize(14, 24), 0.4, 3 * scaleByMapSize(1, 3), 0.2, 0.05), @@ -681,7 +681,7 @@ */ function unknownLowlands() { - let heightMountain = 30; + const heightMountain = 30; g_Map.log("Creating mountain that is going to separate players"); createArea( @@ -708,7 +708,7 @@ valleys *= 2; g_Map.log("Creating player valley"); - for (let valley of distributePointsOnCircle(valleys, startAngle, fractionToTiles(0.35), mapCenter)[0]) + for (const valley of distributePointsOnCircle(valleys, startAngle, fractionToTiles(0.35), mapCenter)[0]) { createArea( new ClumpPlacer(diskArea(scaleByMapSize(18, 32)), 0.65, 0.1, Infinity, valley), @@ -780,7 +780,7 @@ function createExtensionsOrIslands() { - let rnd = randIntInclusive(1, 3); + const rnd = randIntInclusive(1, 3); if (rnd == 1) { @@ -865,15 +865,15 @@ Engine.SetProgress(30); g_Map.log("Creating forests"); - let [numForest, numStragglers] = getTreeCounts(...rBiomeTreeCount(1)); + const [numForest, numStragglers] = getTreeCounts(...rBiomeTreeCount(1)); let types = [ [[tForestFloor2, tMainTerrain, pForest1], [tForestFloor2, pForest1]], [[tForestFloor1, tMainTerrain, pForest2], [tForestFloor1, pForest2]] ]; - let size = numForest / (scaleByMapSize(2, 8) * numPlayers); + const size = numForest / (scaleByMapSize(2, 8) * numPlayers); let num = Math.floor(size / types.length); - for (let type of types) + for (const type of types) createAreas( new ClumpPlacer(numForest / num, 0.1, 0.1, Infinity), [ @@ -885,8 +885,8 @@ Engine.SetProgress(50); g_Map.log("Creating dirt patches"); - let patchCount = (currentBiome() == "generic/savanna" ? 3 : 1) * scaleByMapSize(15, 45); - for (let patchSize of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) + const patchCount = (currentBiome() == "generic/savanna" ? 3 : 1) * scaleByMapSize(15, 45); + for (const patchSize of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) createAreas( new ClumpPlacer(patchSize, 0.3, 0.06, 0.5), [ @@ -897,7 +897,7 @@ patchCount); g_Map.log("Creating grass patches"); - for (let size of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)]) + for (const size of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), new TerrainPainter(tTier4Terrain), @@ -986,14 +986,14 @@ types = [g_Gaia.tree1, g_Gaia.tree2, g_Gaia.tree3, g_Gaia.tree4]; num = Math.floor(numStragglers / types.length); - for (let type of types) + for (const type of types) createObjectGroupsDeprecated( new SimpleGroup([new SimpleObject(type, 1, 1, 0, 3)], true, clForest), 0, [avoidClasses(clWater, 1, clForest, 1, clHill, 2, clPlayer, 0, clMetal, 6, clRock, 6, clBaseResource, 6), stayClasses(clLand, 4)], num); - let planetm = currentBiome() == "generic/india" ? 8 : 1; + const planetm = currentBiome() == "generic/india" ? 8 : 1; g_Map.log("Creating small grass tufts"); createObjectGroupsDeprecated( Index: binaries/data/mods/public/maps/random/volcanic_lands.js =================================================================== --- binaries/data/mods/public/maps/random/volcanic_lands.js +++ binaries/data/mods/public/maps/random/volcanic_lands.js @@ -1,43 +1,43 @@ Engine.LoadLibrary("rmgen"); Engine.LoadLibrary("rmgen-common"); -var tGrass = ["cliff volcanic light", "ocean_rock_a", "ocean_rock_b"]; -var tGrassA = "cliff volcanic light"; -var tGrassB = "ocean_rock_a"; -var tGrassC = "ocean_rock_b"; -var tCliff = ["cliff volcanic coarse", "cave_walls"]; -var tRoad = "road1"; -var tRoadWild = "road1"; -var tLava1 = "LavaTest05"; -var tLava2 = "LavaTest04"; -var tLava3 = "LavaTest03"; +const tGrass = ["cliff volcanic light", "ocean_rock_a", "ocean_rock_b"]; +const tGrassA = "cliff volcanic light"; +const tGrassB = "ocean_rock_a"; +const tGrassC = "ocean_rock_b"; +const tCliff = ["cliff volcanic coarse", "cave_walls"]; +const tRoad = "road1"; +const tRoadWild = "road1"; +const tLava1 = "LavaTest05"; +const tLava2 = "LavaTest04"; +const tLava3 = "LavaTest03"; -var oTree = "gaia/tree/dead"; -var oStoneLarge = "gaia/rock/alpine_large"; -var oStoneSmall = "gaia/rock/alpine_small"; -var oMetalLarge = "gaia/ore/alpine_large"; +const oTree = "gaia/tree/dead"; +const oStoneLarge = "gaia/rock/alpine_large"; +const oStoneSmall = "gaia/rock/alpine_small"; +const oMetalLarge = "gaia/ore/alpine_large"; -var aRockLarge = "actor|geology/stone_granite_med.xml"; -var aRockMedium = "actor|geology/stone_granite_med.xml"; +const aRockLarge = "actor|geology/stone_granite_med.xml"; +const aRockMedium = "actor|geology/stone_granite_med.xml"; -var pForestD = [tGrassC + TERRAIN_SEPARATOR + oTree, tGrassC]; -var pForestP = [tGrassB + TERRAIN_SEPARATOR + oTree, tGrassB]; +const pForestD = [tGrassC + TERRAIN_SEPARATOR + oTree, tGrassC]; +const pForestP = [tGrassB + TERRAIN_SEPARATOR + oTree, tGrassB]; const heightLand = 1; const heightHill = 18; -var g_Map = new RandomMap(heightLand, tGrassB); +const g_Map = new RandomMap(heightLand, tGrassB); -var numPlayers = getNumPlayers(); -var mapCenter = g_Map.getCenter(); +const numPlayers = getNumPlayers(); +const mapCenter = g_Map.getCenter(); -var clPlayer = g_Map.createTileClass(); -var clHill = g_Map.createTileClass(); -var clForest = g_Map.createTileClass(); -var clDirt = g_Map.createTileClass(); -var clRock = g_Map.createTileClass(); -var clMetal = g_Map.createTileClass(); -var clBaseResource = g_Map.createTileClass(); +const clPlayer = g_Map.createTileClass(); +const clHill = g_Map.createTileClass(); +const clForest = g_Map.createTileClass(); +const clDirt = g_Map.createTileClass(); +const clRock = g_Map.createTileClass(); +const clMetal = g_Map.createTileClass(); +const clBaseResource = g_Map.createTileClass(); placePlayerBases({ "PlayerPlacement": playerPlacementCircle(fractionToTiles(0.35)), @@ -77,14 +77,14 @@ ); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(200, 1250, 0.7); -var types = [ +const [forestTrees, stragglerTrees] = getTreeCounts(200, 1250, 0.7); +const types = [ [[tGrassB, tGrassA, pForestD], [tGrassB, pForestD]], [[tGrassB, tGrassA, pForestP], [tGrassB, pForestP]] ]; -var size = forestTrees / (scaleByMapSize(2,8) * numPlayers); -var num = Math.floor(size / types.length); -for (let type of types) +const forestSize = forestTrees / (scaleByMapSize(2,8) * numPlayers); +const num = Math.floor(forestSize / types.length); +for (const type of types) createAreas( new ClumpPlacer(forestTrees / num, 0.1, 0.1, Infinity), [ @@ -97,7 +97,7 @@ Engine.SetProgress(70); g_Map.log("Creating dirt patches"); -for (let size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) +for (const size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), [ @@ -107,7 +107,7 @@ avoidClasses(clForest, 0, clHill, 0, clPlayer, 12), scaleByMapSize(20, 80)); -for (let size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) +for (const size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), [ @@ -117,7 +117,7 @@ avoidClasses(clForest, 0, clHill, 0, clPlayer, 12), scaleByMapSize(20, 80)); -for (let size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) +for (const size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]) createAreas( new ClumpPlacer(size, 0.3, 0.06, 0.5), [ @@ -129,7 +129,7 @@ ); 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, 10, clRock, 10, clHill, 1), scaleByMapSize(4,16), 100 Index: binaries/data/mods/public/maps/random/wall_demo.js =================================================================== --- binaries/data/mods/public/maps/random/wall_demo.js +++ binaries/data/mods/public/maps/random/wall_demo.js @@ -1,7 +1,7 @@ Engine.LoadLibrary("rmgen"); Engine.LoadLibrary("rmgen-common"); -var g_Map = new RandomMap(0, "grass1"); +const g_Map = new RandomMap(0, "grass1"); /** * Demonstration code for wall placement. @@ -43,17 +43,17 @@ * And have fun! */ -var mapSize = g_Map.getSize(); +const mapSize = g_Map.getSize(); /** * General wall placement setup */ const distToMapBorder = 5; const distToOtherWalls = 10; -var buildableMapSize = mapSize - 2 * distToMapBorder; +const buildableMapSize = mapSize - 2 * distToMapBorder; -var position = new Vector2D(distToMapBorder, distToMapBorder); -var playerID = 0; +const position = new Vector2D(distToMapBorder, distToMapBorder); +const playerID = 0; const wallStyleList = Object.keys(g_WallStyles); /** @@ -68,12 +68,12 @@ * * This function permits bending wall elements. */ -for (let styleIndex in wallStyleList) +for (const styleIndex in wallStyleList) { - let pos = Vector2D.add(position, new Vector2D(styleIndex * buildableMapSize / wallStyleList.length)); - let wall = ['start', 'long', 'tower', 'tower', 'tower', 'medium', 'outpost', 'medium', 'cornerOut', 'medium', 'cornerIn', 'medium', 'house', 'end', 'entryTower', 'start', 'short', 'barracks', 'gate', 'tower', 'medium', 'fort', 'medium', 'end']; - let style = wallStyleList[styleIndex]; - let orientation = Math.PI / 16 * Math.sin(styleIndex * Math.PI / 4); + const pos = Vector2D.add(position, new Vector2D(styleIndex * buildableMapSize / wallStyleList.length)); + const wall = ['start', 'long', 'tower', 'tower', 'tower', 'medium', 'outpost', 'medium', 'cornerOut', 'medium', 'cornerIn', 'medium', 'house', 'end', 'entryTower', 'start', 'short', 'barracks', 'gate', 'tower', 'medium', 'fort', 'medium', 'end']; + const style = wallStyleList[styleIndex]; + const orientation = Math.PI / 16 * Math.sin(styleIndex * Math.PI / 4); placeWall(pos, wall, style, playerID, orientation); } @@ -93,15 +93,15 @@ * For this function, orientation is the direction in which the main gate * is facing. */ -var fortressRadius = 15; // The space the fortresses take in average. Just for design of this map. Not passed to the function. +const fortressRadius = 15; // The space the fortresses take in average. Just for design of this map. Not passed to the function. -for (let styleIndex in wallStyleList) +for (const styleIndex in wallStyleList) { - let type = "tiny"; - let style = wallStyleList[styleIndex]; - let orientation = styleIndex * Math.PI / 32; + const type = "tiny"; + const style = wallStyleList[styleIndex]; + const orientation = styleIndex * Math.PI / 32; - let pos = Vector2D.sum([ + const pos = Vector2D.sum([ position, new Vector2D(1, 1).mult(fortressRadius), new Vector2D(styleIndex * buildableMapSize / wallStyleList.length, 0) @@ -124,12 +124,12 @@ * * We also supply a radius value to dictate how wide the circuit of walls should be. */ -var radius = Math.min((mapSize - position.y - distToOtherWalls) / 3, (buildableMapSize / wallStyleList.length - distToOtherWalls) / 2); -for (let styleIndex in wallStyleList) +let radius = Math.min((mapSize - position.y - distToOtherWalls) / 3, (buildableMapSize / wallStyleList.length - distToOtherWalls) / 2); +for (const styleIndex in wallStyleList) { - let style = wallStyleList[styleIndex]; + const style = wallStyleList[styleIndex]; - let pos = Vector2D.sum([ + const pos = Vector2D.sum([ position, new Vector2D(radius, radius), new Vector2D(styleIndex * buildableMapSize / wallStyleList.length, 0) @@ -164,17 +164,17 @@ * the orientation of the first wall piece. */ radius = Math.min((mapSize - position.y - distToOtherWalls) / 3, (buildableMapSize / wallStyleList.length - distToOtherWalls) / 2); -for (let styleIndex in wallStyleList) +for (const styleIndex in wallStyleList) { - let center = Vector2D.sum([position, new Vector2D(1, 1).mult(radius), new Vector2D(styleIndex * buildableMapSize / wallStyleList.length, 0)]); - let wallPart = ['tower', 'medium', 'house']; - let style = wallStyleList[styleIndex]; - let orientation = styleIndex * Math.PI / 16; + const center = Vector2D.sum([position, new Vector2D(1, 1).mult(radius), new Vector2D(styleIndex * buildableMapSize / wallStyleList.length, 0)]); + const wallPart = ['tower', 'medium', 'house']; + const style = wallStyleList[styleIndex]; + const orientation = styleIndex * Math.PI / 16; // maxAngle is how far the wall should circumscribe the center. // If equal to Pi * 2, then the wall will be a full circle. // If less than Pi * 2, then the wall will be an arc. - let maxAngle = Math.PI / 2 * (styleIndex % 3 + 2); + const maxAngle = Math.PI / 2 * (styleIndex % 3 + 2); g_Map.placeEntityPassable("structures/obelisk", playerID, center, orientation); placeCircularWall(center, radius, wallPart, style, playerID, orientation, maxAngle); @@ -208,22 +208,22 @@ */ radius = Math.min((mapSize - position.y - distToOtherWalls) / 2, (buildableMapSize / wallStyleList.length - distToOtherWalls) / 2); -for (let styleIndex in wallStyleList) +for (const styleIndex in wallStyleList) { - let centerPosition = Vector2D.sum([position, new Vector2D(1, 1).mult(radius), new Vector2D(styleIndex * buildableMapSize / wallStyleList.length, 0)]); - let wallParts = ['medium', 'tower']; // Function default: ['long', 'tower'] + const centerPosition = Vector2D.sum([position, new Vector2D(1, 1).mult(radius), new Vector2D(styleIndex * buildableMapSize / wallStyleList.length, 0)]); + const wallParts = ['medium', 'tower']; // Function default: ['long', 'tower'] // Which wall element to use for the corners of the polygon - let cornerWallElement = 'tower'; + const cornerWallElement = 'tower'; - let style = wallStyleList[styleIndex]; - let orientation = styleIndex * Math.PI / 16; + const style = wallStyleList[styleIndex]; + const orientation = styleIndex * Math.PI / 16; // How many corners the polygon should have: - let numCorners = styleIndex % 6 + 3; + const numCorners = styleIndex % 6 + 3; // If true, the first side will not be drawn, leaving the wall open. - let skipFirstWall = true; + const skipFirstWall = true; g_Map.placeEntityPassable("structures/obelisk", playerID, centerPosition, orientation); placePolygonalWall(centerPosition, radius, wallParts, cornerWallElement, style, playerID, orientation, numCorners, skipFirstWall); @@ -260,28 +260,28 @@ * as it is not easy to comprehend. */ radius = Math.min((mapSize - position.y - distToOtherWalls) / 2, (buildableMapSize / wallStyleList.length - distToOtherWalls) / 2); // The radius of wall polygons -for (let styleIndex in wallStyleList) +for (const styleIndex in wallStyleList) { - let centerPosition = Vector2D.sum([ + const centerPosition = Vector2D.sum([ position, new Vector2D(1, 1).mult(radius), new Vector2D(styleIndex * buildableMapSize / wallStyleList.length, 0) ]); // Which wall element type will be used for the corners of the polygon. - let cornerWallElement = 'tower'; + const cornerWallElement = 'tower'; - let style = wallStyleList[styleIndex]; - let orientation = styleIndex * Math.PI / 16; + const style = wallStyleList[styleIndex]; + const orientation = styleIndex * Math.PI / 16; // How many corners the polygon will have - let numCorners = styleIndex % 6 + 3; + const numCorners = styleIndex % 6 + 3; // Irregularity of the polygon. - let irregularity = 0.5; + const irregularity = 0.5; // If true, the first side will not be drawn, leaving the wall open. - let skipFirstWall = true; + const skipFirstWall = true; g_Map.placeEntityPassable("structures/obelisk", playerID, centerPosition, orientation); placeIrregularPolygonalWall(centerPosition, radius, cornerWallElement, style, playerID, orientation, numCorners, irregularity, skipFirstWall); @@ -303,18 +303,18 @@ * of the walls is facing the top of the screen. */ // Two vars, just for this map; firstly how long the longest wall will be. -var maxWallLength = (mapSize - position.y - distToMapBorder - distToOtherWalls); +const maxWallLength = (mapSize - position.y - distToMapBorder - distToOtherWalls); // And secondly, how many walls of the same style will be placed. -var numWallsPerStyle = Math.floor(buildableMapSize / distToOtherWalls / wallStyleList.length); +const numWallsPerStyle = Math.floor(buildableMapSize / distToOtherWalls / wallStyleList.length); -for (let styleIndex in wallStyleList) +for (const styleIndex in wallStyleList) for (let wallIndex = 0; wallIndex < numWallsPerStyle; ++wallIndex) { - let offsetX = (styleIndex * numWallsPerStyle + wallIndex) * buildableMapSize / wallStyleList.length / numWallsPerStyle; - let start = Vector2D.add(position, new Vector2D(offsetX, 0)); + const offsetX = (styleIndex * numWallsPerStyle + wallIndex) * buildableMapSize / wallStyleList.length / numWallsPerStyle; + const start = Vector2D.add(position, new Vector2D(offsetX, 0)); - let offsetY = (wallIndex + 1) * maxWallLength / numWallsPerStyle; - let end = Vector2D.add(position, new Vector2D(offsetX, offsetY)); + const offsetY = (wallIndex + 1) * maxWallLength / numWallsPerStyle; + const end = Vector2D.add(position, new Vector2D(offsetX, offsetY)); placeLinearWall(start, end, ['tower', 'medium'], wallStyleList[styleIndex], playerID); } Index: binaries/data/mods/public/maps/random/wild_lake.js =================================================================== --- binaries/data/mods/public/maps/random/wild_lake.js +++ binaries/data/mods/public/maps/random/wild_lake.js @@ -3,7 +3,7 @@ Engine.LoadLibrary("rmbiome"); Engine.LoadLibrary("heightmap"); -var g_Map = new RandomMap(0, "whiteness"); +const g_Map = new RandomMap(0, "whiteness"); /** * getArray - To ensure a terrain texture is contained within an array @@ -18,7 +18,7 @@ setSelectedBiome(); // Terrain, entities and actors -let wildLakeBiome = [ +const wildLakeBiome = [ // 0 Deep water { "texture": getArray(g_Terrains.water), @@ -169,8 +169,8 @@ { g_Map.placeEntityPassable(centerEntity, 0, position, randomAngle()); - let quantity = randIntInclusive(11, 23); - let dAngle = 2 * Math.PI / quantity; + const quantity = randIntInclusive(11, 23); + const dAngle = 2 * Math.PI / quantity; for (let i = 0; i < quantity; ++i) g_Map.placeEntityPassable( pickRandom(decorativeActors), @@ -180,8 +180,8 @@ } // Groves, only wood -let groveActors = [g_Decoratives.grass, g_Decoratives.rockMedium, g_Decoratives.bushMedium]; -let clGaiaCamp = g_Map.createTileClass(); +const groveActors = [g_Decoratives.grass, g_Decoratives.rockMedium, g_Decoratives.bushMedium]; +const clGaiaCamp = g_Map.createTileClass(); function placeGrove(point, groveEntities = [ @@ -194,23 +194,23 @@ groveTerrainTexture = getArray(g_Terrains.forestFloor1) ) { - let position = new Vector2D(point.x, point.y); + const position = new Vector2D(point.x, point.y); g_Map.placeEntityPassable(pickRandom(["structures/gaul/outpost", g_Gaia.tree1]), 0, position, randomAngle()); - let quantity = randIntInclusive(20, 30); - let dAngle = 2 * Math.PI / quantity; + const quantity = randIntInclusive(20, 30); + const dAngle = 2 * Math.PI / quantity; for (let i = 0; i < quantity; ++i) { - let angle = dAngle * randFloat(i, i + 1); - let dist = randFloat(2, 5); + const angle = dAngle * randFloat(i, i + 1); + const dist = randFloat(2, 5); let objectList = groveEntities; if (i % 3 == 0) objectList = groveActors; - let pos = Vector2D.add(position, new Vector2D(dist, 0).rotate(-angle)); + const pos = Vector2D.add(position, new Vector2D(dist, 0).rotate(-angle)); g_Map.placeEntityPassable(pickRandom(objectList), 0, pos, randomAngle()); - let painters = [new TerrainPainter(groveTerrainTexture)]; + const painters = [new TerrainPainter(groveTerrainTexture)]; if (groveTileClass) painters.push(new TileClassPainter(groveTileClass)); @@ -232,7 +232,7 @@ "farmstead": { "angle": Math.PI, "length": 0, "indent": -3, "bend": 0, "templateName": farmEntities.building } }; -let fences = [ +const fences = [ new Fortress("fence", [ "foodBin", "farmstead", "bench", "turn_0.25", "animal", "turn_0.25", "fence", @@ -264,7 +264,7 @@ "turn_0.25", "animal", "turn_0.25", "fence_short", "animal", "fence" ]) ]; -let num = fences.length; +const num = fences.length; for (let i = 0; i < num; ++i) fences.push(new Fortress("fence", clone(fences[i].wall).reverse())); @@ -275,12 +275,12 @@ { g_Map.placeEntityPassable(centerEntity, 0, position, randomAngle()); - let quantity = randIntInclusive(5, 11); - let dAngle = 2 * Math.PI / quantity; + const quantity = randIntInclusive(5, 11); + const dAngle = 2 * Math.PI / quantity; for (let i = 0; i < quantity; ++i) { - let angle = dAngle * randFloat(i, i + 1); - let dist = randFloat(1, 3); + const angle = dAngle * randFloat(i, i + 1); + const dist = randFloat(1, 3); g_Map.placeEntityPassable(pickRandom(campEntities), 0, Vector2D.add(position, new Vector2D(dist, 0).rotate(-angle)), randomAngle()); } @@ -320,12 +320,12 @@ for (let i = 0; i < quantity; ++i) { angle = currentAngle + randFloat(0, dAngle); - let dist = getRandDist(); + const dist = getRandDist(); let objectList = groveEntities; if (i % 2 == 0) objectList = groveActors; - let position = Vector2D.add(point, new Vector2D(dist, 0).rotate(-angle)); + const position = Vector2D.add(point, new Vector2D(dist, 0).rotate(-angle)); g_Map.placeEntityPassable(pickRandom(objectList), 0, position, randomAngle()); createArea( @@ -346,7 +346,7 @@ for (let i = 0; i < quantity; ++i) { angle = currentAngle + randFloat(0, dAngle); - let dist = getRandDist(); + const dist = getRandDist(); g_Map.placeEntityPassable(pickRandom(foodEntities), 0, Vector2D.add(point, new Vector2D(dist, 0).rotate(-angle)), randomAngle()); currentAngle += dAngle; } @@ -357,18 +357,18 @@ */ // Height range by map size -let heightScale = (g_Map.size + 512) / 1024 / 5; -let heightRange = { "min": MIN_HEIGHT * heightScale, "max": MAX_HEIGHT * heightScale }; +const heightScale = (g_Map.size + 512) / 1024 / 5; +const heightRange = { "min": MIN_HEIGHT * heightScale, "max": MAX_HEIGHT * heightScale }; // Water coverage -let averageWaterCoverage = 1 / 5; // NOTE: Since terrain generation is quite unpredictable actual water coverage might vary much with the same value -let heightSeaGround = -MIN_HEIGHT + heightRange.min + averageWaterCoverage * (heightRange.max - heightRange.min); // Water height in environment and the engine -let heightSeaGroundAdjusted = heightSeaGround + MIN_HEIGHT; // Water height as terrain height +const averageWaterCoverage = 1 / 5; // NOTE: Since terrain generation is quite unpredictable actual water coverage might vary much with the same value +const heightSeaGround = -MIN_HEIGHT + heightRange.min + averageWaterCoverage * (heightRange.max - heightRange.min); // Water height in environment and the engine +const heightSeaGroundAdjusted = heightSeaGround + MIN_HEIGHT; // Water height as terrain height setWaterHeight(heightSeaGround); // Generate base terrain shape -let lowH = heightRange.min; -let medH = (heightRange.min + heightRange.max) / 2; +const lowH = heightRange.min; +const medH = (heightRange.min + heightRange.max) / 2; // Lake let initialHeightmap = [ @@ -422,7 +422,7 @@ /** * Prepare terrain texture placement */ -let heighLimits = [ +const heighLimits = [ heightRange.min + 3/4 * (heightSeaGroundAdjusted - heightRange.min), // 0 Deep water heightSeaGroundAdjusted, // 1 Shallow water heightSeaGroundAdjusted + 2/8 * (heightRange.max - heightSeaGroundAdjusted), // 2 Shore @@ -432,15 +432,15 @@ heightSeaGroundAdjusted + 7/8 * (heightRange.max - heightSeaGroundAdjusted), // 6 Lower forest border heightRange.max // 7 Forest ]; -let playerHeightRange = { "min": heighLimits[3], "max": heighLimits[4] }; -let resourceSpotHeightRange = { "min": (heighLimits[2] + heighLimits[3]) / 2, "max": (heighLimits[4] + heighLimits[5]) / 2 }; -let playerHeight = (playerHeightRange.min + playerHeightRange.max) / 2; // Average player height +const playerHeightRange = { "min": heighLimits[3], "max": heighLimits[4] }; +const resourceSpotHeightRange = { "min": (heighLimits[2] + heighLimits[3]) / 2, "max": (heighLimits[4] + heighLimits[5]) / 2 }; +const playerHeight = (playerHeightRange.min + playerHeightRange.max) / 2; // Average player height g_Map.log("Chosing starting locations"); -let [playerIDs, playerPosition] = groupPlayersCycle(getStartLocationsByHeightmap(playerHeightRange, 1000, 30)); +const [playerIDs, playerPosition] = groupPlayersCycle(getStartLocationsByHeightmap(playerHeightRange, 1000, 30)); g_Map.log("Smoothing starting locations before height calculation"); -for (let position of playerPosition) +for (const position of playerPosition) createArea( new ClumpPlacer(diskArea(20), 0.8, 0.8, Infinity, position), new SmoothElevationPainter(ELEVATION_SET, g_Map.getHeight(position), 20)); @@ -451,10 +451,10 @@ * Calculate tile centered height map after start position smoothing but before placing paths * This has nothing to to with TILE_CENTERED_HEIGHT_MAP which should be false! */ -let tchm = getTileCenteredHeightmap(); +const tchm = getTileCenteredHeightmap(); g_Map.log("Get points per height"); -let areas = heighLimits.map(heightLimit => []); +const areas = heighLimits.map(heightLimit => []); for (let x = 0; x < tchm.length; ++x) for (let y = 0; y < tchm[0].length; ++y) { @@ -472,16 +472,16 @@ } g_Map.log("Get slope limits per heightrange"); -let slopeMap = getSlopeMap(); -let minSlope = []; -let maxSlope = []; +const slopeMap = getSlopeMap(); +const minSlope = []; +const maxSlope = []; for (let h = 0; h < heighLimits.length; ++h) { minSlope[h] = Infinity; maxSlope[h] = 0; - for (let point of areas[h]) + for (const point of areas[h]) { - let slope = slopeMap[point.x][point.y]; + const slope = slopeMap[point.x][point.y]; if (slope > maxSlope[h]) maxSlope[h] = slope; @@ -493,7 +493,7 @@ g_Map.log("Paint areas by height and slope"); for (let h = 0; h < heighLimits.length; ++h) - for (let point of areas[h]) + for (const point of areas[h]) { let entity; let texture = pickRandom(wildLakeBiome[h].texture); @@ -518,10 +518,10 @@ Engine.SetProgress(40); g_Map.log("Placing resources"); -let avoidPoints = playerPosition.map(pos => pos.clone()); +const avoidPoints = playerPosition.map(pos => pos.clone()); for (let i = 0; i < avoidPoints.length; ++i) avoidPoints[i].dist = 30; -let resourceSpots = getPointsByHeight(resourceSpotHeightRange, avoidPoints).map(point => new Vector2D(point.x, point.y)); +const resourceSpots = getPointsByHeight(resourceSpotHeightRange, avoidPoints).map(point => new Vector2D(point.x, point.y)); Engine.SetProgress(55); @@ -545,7 +545,7 @@ for (let i = 0; i < resourceSpots.length; ++i) { let radius; - let choice = i % (isNomad() ? 4 : 5); + const choice = i % (isNomad() ? 4 : 5); if (choice == 0) placeMine(resourceSpots[i], g_Gaia.stoneLarge); if (choice == 1)