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,23 +53,23 @@ 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(); @@ -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,43 +9,43 @@ // 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]; @@ -53,20 +53,20 @@ var heightLand = 2; var 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 @@ -84,20 +84,20 @@ var heightSeaGround = -5; var 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 @@ -7,9 +7,9 @@ var 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 @@ -34,18 +34,18 @@ var heightLand = 1; var 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]]]; +const [forestTrees, stragglerTrees] = getTreeCounts(220, 1000, 0.65); +const 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 num = 4 * Math.floor(size / types.length); +for (const type of types) createAreas( new ChainPlacer(1, Math.floor(scaleByMapSize(2, 3)), 4, Infinity), [ 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 @@ -50,19 +50,19 @@ var heightLand = 3; var 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); @@ -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)], 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; -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 @@ -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( @@ -88,8 +88,8 @@ for (var ix = 0; ix < mapSize; ix++) for (var 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); @@ -106,11 +106,11 @@ 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]), @@ -260,8 +260,8 @@ for (var ix = 0; ix < mapSize; ix++) for (var 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) @@ -290,7 +290,7 @@ var x = ix / (mapSize + 1.0); for (var iz = 0; iz < mapSize; iz++) { - let position = new Vector2D(ix, iz); + const position = new Vector2D(ix, iz); var z = iz / (mapSize + 1.0); var h = g_Map.getHeight(position); var pn = playerNearness(x,z); @@ -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), 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); +const g_Map = new RandomMap(0, g_Terrains.mainTerrain); var mapBounds = g_Map.getBounds(); -var mapCenter = g_Map.getCenter(); -var numPlayers = getNumPlayers(); +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}; // 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; 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,7 +63,7 @@ "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; +const numTerrains = terrains.length; for (var i = 0; i < numTerrains; i++) terrains.push("temp_grass_plants"); textueByHeight.push({"upperHeightLimit": heightSeaGroundAdjusted + 5/6 * (heightRange.max - heightSeaGroundAdjusted), "terrain": terrains}); @@ -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; @@ -127,11 +127,11 @@ 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; + let textureMinHeight = heightRange.min; for (var 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,20 +51,20 @@ 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); @@ -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,7 +125,7 @@ Engine.SetProgress(10); g_Map.log("Creating lakes"); -var numLakes = Math.round(scaleByMapSize(1,4) * numPlayers); +const numLakes = Math.round(scaleByMapSize(1,4) * numPlayers); var waterAreas = createAreas( new ClumpPlacer(scaleByMapSize(100, 250), 0.8, 0.1, Infinity), [ @@ -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,22 +44,22 @@ 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); @@ -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), @@ -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)], @@ -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( @@ -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)], 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 @@ -58,24 +58,24 @@ var heightShallow = -0.8; var 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(); 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,43 +1,43 @@ 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; @@ -50,22 +50,22 @@ var heightOffsetBumps = 2; var 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); @@ -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)), @@ -204,7 +204,7 @@ var 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( [ @@ -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,24 +49,24 @@ 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]]; @@ -83,7 +83,7 @@ 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), [ @@ -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,37 +137,37 @@ 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); @@ -257,32 +257,32 @@ 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/danubius_triggers.js =================================================================== --- binaries/data/mods/public/maps/random/danubius_triggers.js +++ binaries/data/mods/public/maps/random/danubius_triggers.js @@ -99,7 +99,7 @@ /** * Total count of gaia attackers per shipload. */ -var attackersPerShip = t => Math.min(30, Math.round(t * 2)); +const attackersPerShip = t => Math.min(30, Math.round(t * 2)); /** * Likelihood of adding a non-existing hero at t minutes. @@ -175,15 +175,15 @@ "healer": ["attack_capture", "promotion", "heal"] }; -var triggerPointShipSpawn = "A"; -var triggerPointShipPatrol = "B"; -var triggerPointUngarrisonLeft = "C"; -var triggerPointUngarrisonRight = "D"; -var triggerPointLandPatrolLeft = "E"; -var triggerPointLandPatrolRight = "F"; -var triggerPointCCAttackerPatrolLeft = "G"; -var triggerPointCCAttackerPatrolRight = "H"; -var triggerPointRiverDirection = "I"; +const triggerPointShipSpawn = "A"; +const triggerPointShipPatrol = "B"; +const triggerPointUngarrisonLeft = "C"; +const triggerPointUngarrisonRight = "D"; +const triggerPointLandPatrolLeft = "E"; +const triggerPointLandPatrolRight = "F"; +const triggerPointCCAttackerPatrolLeft = "G"; +const triggerPointCCAttackerPatrolRight = "H"; +const triggerPointRiverDirection = "I"; /** * Which playerID to use for the opposing gallic reinforcements. @@ -200,10 +200,10 @@ { this.debugLog("Garrisoning all gallic buildings"); - for (let buildingGarrison of gallicBuildingGarrison) - for (let buildingClass of buildingGarrison.buildingClasses) + for (const buildingGarrison of gallicBuildingGarrison) + for (const buildingClass of buildingGarrison.buildingClasses) { - let unitCounts = TriggerHelper.SpawnAndGarrisonAtClasses(gaulPlayer, buildingClass, buildingGarrison.unitTemplates, 1); + const unitCounts = TriggerHelper.SpawnAndGarrisonAtClasses(gaulPlayer, buildingClass, buildingGarrison.unitTemplates, 1); this.debugLog("Garrisoning at " + buildingClass + ": " + uneval(unitCounts)); } }; @@ -212,10 +212,10 @@ { this.debugLog("Turreting all gallic buildings"); - for (let buildingTurret of gallicBuildingTurret) - for (let buildingClass of buildingTurret.buildingClasses) + for (const buildingTurret of gallicBuildingTurret) + for (const buildingClass of buildingTurret.buildingClasses) { - let unitCounts = TriggerHelper.SpawnAndTurretAtClasses(gaulPlayer, buildingClass, buildingTurret.unitTemplates, 1); + const unitCounts = TriggerHelper.SpawnAndTurretAtClasses(gaulPlayer, buildingClass, buildingTurret.unitTemplates, 1); this.debugLog("Turreting at " + buildingClass + ": " + uneval(unitCounts)); } }; @@ -227,35 +227,35 @@ { this.debugLog("To defend CCs, spawning " + uneval(ccDefenders)); - for (let ent of this.civicCenters) - for (let ccDefender of ccDefenders) - for (let spawnedEnt of TriggerHelper.SpawnUnits(ent, pickRandom(ccDefender.templates), ccDefender.count, gaulPlayer)) + for (const ent of this.civicCenters) + for (const ccDefender of ccDefenders) + for (const spawnedEnt of TriggerHelper.SpawnUnits(ent, pickRandom(ccDefender.templates), ccDefender.count, gaulPlayer)) TriggerHelper.SetUnitStance(spawnedEnt, "defensive"); }; Trigger.prototype.SpawnCCAttackers = function() { - let time = TriggerHelper.GetMinutes(); + const time = TriggerHelper.GetMinutes(); - let [spawnLeft, spawnRight] = this.GetActiveRiversides(); + const [spawnLeft, spawnRight] = this.GetActiveRiversides(); - for (let gaiaCC of this.civicCenters) + for (const gaiaCC of this.civicCenters) { if (!TriggerHelper.IsInWorld(gaiaCC)) continue; - let isLeft = this.IsLeftRiverside(gaiaCC); + const isLeft = this.IsLeftRiverside(gaiaCC); if (isLeft && !spawnLeft || !isLeft && !spawnRight) continue; - let templateCounts = TriggerHelper.BalancedTemplateComposition(this.GetAttackerComposition(time, false), ccAttackerCount(time)); + const templateCounts = TriggerHelper.BalancedTemplateComposition(this.GetAttackerComposition(time, false), ccAttackerCount(time)); this.debugLog("Spawning civic center attackers at " + gaiaCC + ": " + uneval(templateCounts)); let ccAttackers = []; - for (let templateName in templateCounts) + for (const templateName in templateCounts) { - let ents = TriggerHelper.SpawnUnits(gaiaCC, templateName, templateCounts[templateName], gaulPlayer); + const ents = TriggerHelper.SpawnUnits(gaiaCC, templateName, templateCounts[templateName], gaulPlayer); if (danubiusAttackerTemplates.heroes.indexOf(templateName) != -1 && ents[0]) this.heroes.add(ents[0]); @@ -263,7 +263,7 @@ ccAttackers = ccAttackers.concat(ents); } - let patrolPointRef = isLeft ? + const patrolPointRef = isLeft ? triggerPointCCAttackerPatrolLeft : triggerPointCCAttackerPatrolRight; @@ -280,7 +280,7 @@ */ Trigger.prototype.StartCelticRitual = function() { - for (let ent of TriggerHelper.GetPlayerEntitiesByClass(gaulPlayer, "Human")) + for (const ent of TriggerHelper.GetPlayerEntitiesByClass(gaulPlayer, "Human")) { if (randBool(ritualProbability)) this.ritualEnts.add(ent); @@ -296,21 +296,21 @@ */ Trigger.prototype.UpdateCelticRitual = function() { - for (let ent of this.ritualEnts) + for (const ent of this.ritualEnts) { - let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); + const cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); if (!cmpUnitAI || cmpUnitAI.GetCurrentState() != "INDIVIDUAL.IDLE") continue; - let cmpIdentity = Engine.QueryInterface(ent, IID_Identity); + const cmpIdentity = Engine.QueryInterface(ent, IID_Identity); if (!cmpIdentity) continue; - let animations = ritualAnimations[ + const animations = ritualAnimations[ cmpIdentity.HasClass("Healer") ? "healer" : cmpIdentity.HasClass("Female") ? "female" : "male"]; - let cmpVisual = Engine.QueryInterface(ent, IID_Visual); + const cmpVisual = Engine.QueryInterface(ent, IID_Visual); if (!cmpVisual) continue; @@ -325,9 +325,9 @@ */ Trigger.prototype.SpawnShips = function() { - let time = TriggerHelper.GetMinutes(); - let numPlayers = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetActivePlayers().length; - let shipSpawnCount = shipCount(time, numPlayers) - this.ships.size; + const time = TriggerHelper.GetMinutes(); + const numPlayers = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetActivePlayers().length; + const shipSpawnCount = shipCount(time, numPlayers) - this.ships.size; this.debugLog("Spawning " + shipSpawnCount + " ships"); @@ -339,12 +339,12 @@ 1, gaulPlayer)[0]); - for (let ship of this.ships) + for (const ship of this.ships) this.AttackAndPatrol([ship], shipTargetClass, triggerPointShipPatrol, "Ship", true); this.DoAfterDelay(shipRespawnTime(time) * 60 * 1000, "SpawnShips", {}); - let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); + const cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); cmpTimer.CancelTimer(this.fillShipsTimer); this.FillShips(); @@ -352,7 +352,7 @@ Trigger.prototype.GetAttackerComposition = function(time, siegeEngines) { - let champRatio = championRatio(time); + const champRatio = championRatio(time); return [ { "templates": danubiusAttackerTemplates.heroes, @@ -380,22 +380,22 @@ Trigger.prototype.FillShips = function() { - let time = TriggerHelper.GetMinutes(); - for (let ship of this.ships) + const time = TriggerHelper.GetMinutes(); + for (const ship of this.ships) { - let cmpGarrisonHolder = Engine.QueryInterface(ship, IID_GarrisonHolder); + const cmpGarrisonHolder = Engine.QueryInterface(ship, IID_GarrisonHolder); if (!cmpGarrisonHolder) continue; - let templateCounts = TriggerHelper.BalancedTemplateComposition( + const templateCounts = TriggerHelper.BalancedTemplateComposition( this.GetAttackerComposition(time, true), Math.max(0, attackersPerShip(time) - cmpGarrisonHolder.GetEntities().length)); this.debugLog("Filling ship " + ship + " with " + uneval(templateCounts)); - for (let templateName in templateCounts) + for (const templateName in templateCounts) { - let ents = TriggerHelper.SpawnGarrisonedUnits(ship, templateName, templateCounts[templateName], gaulPlayer); + const ents = TriggerHelper.SpawnGarrisonedUnits(ship, templateName, templateCounts[templateName], gaulPlayer); if (danubiusAttackerTemplates.heroes.indexOf(templateName) != -1 && ents[0]) this.heroes.add(ents[0]); } @@ -412,7 +412,7 @@ if (!entities.length) return; - let healers = TriggerHelper.MatchEntitiesByClass(entities, "Healer").filter(TriggerHelper.IsInWorld); + const healers = TriggerHelper.MatchEntitiesByClass(entities, "Healer").filter(TriggerHelper.IsInWorld); if (healers.length) { let healerTargets = TriggerHelper.MatchEntitiesByClass(entities, "Hero Champion"); @@ -427,21 +427,21 @@ }); } - let attackers = TriggerHelper.MatchEntitiesByClass(entities, "!Healer").filter(TriggerHelper.IsInWorld); + const attackers = TriggerHelper.MatchEntitiesByClass(entities, "!Healer").filter(TriggerHelper.IsInWorld); if (!attackers.length) return; - let isLeft = this.IsLeftRiverside(attackers[0]); - let targets = TriggerHelper.MatchEntitiesByClass(TriggerHelper.GetAllPlayersEntities(), targetClass); + const isLeft = this.IsLeftRiverside(attackers[0]); + const targets = TriggerHelper.MatchEntitiesByClass(TriggerHelper.GetAllPlayersEntities(), targetClass); let closestTarget; let minDistance = Infinity; - for (let target of targets) + for (const target of targets) { if (!TriggerHelper.IsInWorld(target) || this.IsLeftRiverside(target) != isLeft) continue; - let targetDistance = PositionHelper.DistanceBetweenEntities(attackers[0], target); + const targetDistance = PositionHelper.DistanceBetweenEntities(attackers[0], target); if (targetDistance < minDistance) { closestTarget = target; @@ -460,12 +460,12 @@ "allowCapture": false }); - let patrolTargets = shuffleArray(this.GetTriggerPoints(triggerPointRef)).slice(0, patrolCount); + const patrolTargets = shuffleArray(this.GetTriggerPoints(triggerPointRef)).slice(0, patrolCount); this.debugLog(debugName + " " + uneval(attackers) + " patrol to " + uneval(patrolTargets)); - for (let patrolTarget of patrolTargets) + for (const patrolTarget of patrolTargets) { - let targetPos = TriggerHelper.GetEntityPosition2D(patrolTarget); + const targetPos = TriggerHelper.GetEntityPosition2D(patrolTarget); ProcessCommand(gaulPlayer, { "type": "patrol", "entities": attackers, @@ -490,7 +490,7 @@ let left = false; let right = false; - for (let ent of TriggerHelper.GetAllPlayersEntitiesByClass(siegeTargetClass)) + for (const ent of TriggerHelper.GetAllPlayersEntitiesByClass(siegeTargetClass)) { if (this.IsLeftRiverside(ent)) left = true; @@ -514,12 +514,12 @@ */ Trigger.prototype.UngarrisonShipsOrder = function() { - let [ungarrisonLeft, ungarrisonRight] = this.GetActiveRiversides(); + const [ungarrisonLeft, ungarrisonRight] = this.GetActiveRiversides(); if (!ungarrisonLeft && !ungarrisonRight) return; // Determine which ships should ungarrison on which side of the river - let ships = Array.from(this.ships); + const ships = Array.from(this.ships); let shipsLeft = []; let shipsRight = []; @@ -534,7 +534,7 @@ shipsRight = ships; // Determine which ships should ungarrison and patrol at which trigger point names - let sides = []; + const sides = []; if (shipsLeft.length) sides.push({ "ships": shipsLeft, @@ -552,11 +552,11 @@ // Order those ships to move to a randomly chosen trigger point on the determined // side of the river. Remember that chosen ungarrison point and the name of the // trigger points where the ungarrisoned units should patrol afterwards. - for (let side of sides) - for (let ship of side.ships) + for (const side of sides) + for (const ship of side.ships) { - let ungarrisonPoint = pickRandom(this.GetTriggerPoints(side.ungarrisonPointRef)); - let ungarrisonPos = TriggerHelper.GetEntityPosition2D(ungarrisonPoint); + const ungarrisonPoint = pickRandom(this.GetTriggerPoints(side.ungarrisonPointRef)); + const ungarrisonPos = TriggerHelper.GetEntityPosition2D(ungarrisonPoint); this.debugLog("Ship " + ship + " will ungarrison at " + side.ungarrisonPointRef + " (" + ungarrisonPos.x + "," + ungarrisonPos.y + ")"); @@ -573,17 +573,17 @@ */ Trigger.prototype.CheckShipRange = function() { - for (let ship of this.ships) + for (const ship of this.ships) { if (!this.shipTarget[ship] || PositionHelper.DistanceBetweenEntities(ship, this.shipTarget[ship].ungarrisonPoint) > shipUngarrisonDistance) continue; - let cmpGarrisonHolder = Engine.QueryInterface(ship, IID_GarrisonHolder); + const cmpGarrisonHolder = Engine.QueryInterface(ship, IID_GarrisonHolder); if (!cmpGarrisonHolder) continue; - let humans = TriggerHelper.MatchEntitiesByClass(cmpGarrisonHolder.GetEntities(), "Human"); - let siegeEngines = TriggerHelper.MatchEntitiesByClass(cmpGarrisonHolder.GetEntities(), "Siege"); + const humans = TriggerHelper.MatchEntitiesByClass(cmpGarrisonHolder.GetEntities(), "Human"); + const siegeEngines = TriggerHelper.MatchEntitiesByClass(cmpGarrisonHolder.GetEntities(), "Siege"); this.debugLog("Ungarrisoning ship " + ship + " at " + uneval(this.shipTarget[ship])); cmpGarrisonHolder.UnloadAll(); @@ -638,7 +638,7 @@ this.fillShipsTimer = undefined; // Be able to distinguish between the left and right riverside - let mapSize = TriggerHelper.GetMapSizeTerrain(); + const mapSize = TriggerHelper.GetMapSizeTerrain(); this.mapCenter = new Vector2D(mapSize / 2, mapSize / 2); this.riverDirection = Vector2D.sub( 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,24 +1,24 @@ 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", @@ -28,19 +28,19 @@ var heightLand = 0; var heightOffsetRandomPath = 1; -var g_Map = new RandomMap(heightLand, terrainPrimary); +const g_Map = new RandomMap(heightLand, terrainPrimary); -var mapSize = g_Map.getSize(); +const mapSize = g_Map.getSize(); var mapRadius = mapSize/2; -var mapCenter = g_Map.getCenter(); +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(); +const 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); @@ -109,8 +109,8 @@ 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()); @@ -164,7 +164,7 @@ for (var x = 0; x < mapSize; x++) for (var 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))); @@ -173,14 +173,14 @@ 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,7 +190,7 @@ } // General height map - let hVarMiddleHill = fractionToTiles(1 / 64) * (1 + Math.cos(3/2 * Math.PI * radius / mapRadius)); + const 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)); g_Map.setHeight(position, g_Map.getHeight(position) + hVarMiddleHill + hVarHills + 1); } 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,24 +74,24 @@ 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; @@ -100,7 +100,7 @@ var [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), @@ -331,31 +331,31 @@ g_Map.log("Creating bridges"); var bridges = 0; -for (let bridgeStart of shuffleArray(areaShoreline.getPoints())) +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), @@ -272,7 +272,7 @@ 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/elephantine_triggers.js =================================================================== --- binaries/data/mods/public/maps/random/elephantine_triggers.js +++ binaries/data/mods/public/maps/random/elephantine_triggers.js @@ -8,14 +8,14 @@ Trigger.prototype.InitElephantine_DefenderStance = function() { - for (let ent of TriggerHelper.GetPlayerEntitiesByClass(elephantinePlayerID, "Soldier")) + for (const ent of TriggerHelper.GetPlayerEntitiesByClass(elephantinePlayerID, "Soldier")) TriggerHelper.SetUnitStance(ent, "defensive"); }; Trigger.prototype.InitElephantine_GarrisonBuildings = function() { - let kushInfantryUnits = TriggerHelper.GetTemplateNamesByClasses("CitizenSoldier+Infantry", "kush", undefined, "Elite", true); - let kushSupportUnits = TriggerHelper.GetTemplateNamesByClasses("FemaleCitizen Healer", "kush", undefined, "Elite", true); + const kushInfantryUnits = TriggerHelper.GetTemplateNamesByClasses("CitizenSoldier+Infantry", "kush", undefined, "Elite", true); + const kushSupportUnits = TriggerHelper.GetTemplateNamesByClasses("FemaleCitizen Healer", "kush", undefined, "Elite", true); TriggerHelper.SpawnAndGarrisonAtClasses(elephantinePlayerID, "Tower", kushInfantryUnits, 1); TriggerHelper.SpawnAndGarrisonAtClasses(elephantinePlayerID, "Wonder Temple Pyramid", kushInfantryUnits.concat(kushSupportUnits), 1); 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(); 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 @@ -44,22 +44,22 @@ var heightShore = 1; var 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(); @@ -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 @@ -56,24 +56,24 @@ var heightHill = 18; var 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(); @@ -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 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/extinct_volcano_triggers.js =================================================================== --- binaries/data/mods/public/maps/random/extinct_volcano_triggers.js +++ binaries/data/mods/public/maps/random/extinct_volcano_triggers.js @@ -85,13 +85,13 @@ Trigger.prototype.GarrisonWoodenTowers = function() { - for (let gaiaEnt of Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager).GetEntitiesByPlayer(0)) + for (const gaiaEnt of Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager).GetEntitiesByPlayer(0)) { - let cmpIdentity = Engine.QueryInterface(gaiaEnt, IID_Identity); + const cmpIdentity = Engine.QueryInterface(gaiaEnt, IID_Identity); if (!cmpIdentity || !cmpIdentity.HasClass("Tower")) continue; - let cmpGarrisonHolder = Engine.QueryInterface(gaiaEnt, IID_GarrisonHolder); + const cmpGarrisonHolder = Engine.QueryInterface(gaiaEnt, IID_GarrisonHolder); if (!cmpGarrisonHolder) continue; @@ -101,10 +101,10 @@ Trigger.prototype.RaiseWaterLevelStep = function() { - let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); - let time = cmpTimer.GetTime(); - let cmpWaterManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_WaterManager); - let newLevel = cmpWaterManager.GetWaterLevel() + waterLevelIncreaseHeight; + const cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); + const time = cmpTimer.GetTime(); + const cmpWaterManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_WaterManager); + const newLevel = cmpWaterManager.GetWaterLevel() + waterLevelIncreaseHeight; cmpWaterManager.SetWaterLevel(newLevel); this.DebugLog("Raising water level to " + Math.round(newLevel) + " took " + (cmpTimer.GetTime() - time)); @@ -113,30 +113,30 @@ else this.DebugLog("Water reached final level"); - let actorTemplates = {}; - let killedTemplates = {}; + const actorTemplates = {}; + const killedTemplates = {}; - let cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); - let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); + const cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); + const cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); - for (let ent of cmpRangeManager.GetGaiaAndNonGaiaEntities()) + for (const ent of cmpRangeManager.GetGaiaAndNonGaiaEntities()) { - let cmpPosition = Engine.QueryInterface(ent, IID_Position); + const cmpPosition = Engine.QueryInterface(ent, IID_Position); if (!cmpPosition || !cmpPosition.IsInWorld()) continue; - let pos = cmpPosition.GetPosition(); + const pos = cmpPosition.GetPosition(); if (pos.y + drownHeight >= newLevel) continue; - let cmpIdentity = Engine.QueryInterface(ent, IID_Identity); + const cmpIdentity = Engine.QueryInterface(ent, IID_Identity); if (!cmpIdentity) continue; - let templateName = cmpTemplateManager.GetCurrentTemplateName(ent); + const templateName = cmpTemplateManager.GetCurrentTemplateName(ent); // Animals and units drown - let cmpHealth = Engine.QueryInterface(ent, IID_Health); + const cmpHealth = Engine.QueryInterface(ent, IID_Health); if (cmpHealth && cmpIdentity.HasClass(drownClass)) { cmpHealth.Kill(); @@ -151,21 +151,21 @@ // Do not use ChangeEntityTemplate for performance and // because we don't need nor want the effects of MT_EntityRenamed - let cmpVisualActor = Engine.QueryInterface(ent, IID_Visual); + const cmpVisualActor = Engine.QueryInterface(ent, IID_Visual); if (!cmpVisualActor) continue; - let height = cmpPosition.GetHeightOffset(); - let rot = cmpPosition.GetRotation(); + const height = cmpPosition.GetHeightOffset(); + const rot = cmpPosition.GetRotation(); - let actorTemplate = cmpTemplateManager.GetTemplate(templateName).VisualActor.Actor; - let seed = cmpVisualActor.GetActorSeed(); + const actorTemplate = cmpTemplateManager.GetTemplate(templateName).VisualActor.Actor; + const seed = cmpVisualActor.GetActorSeed(); Engine.DestroyEntity(ent); - let newEnt = Engine.AddEntity("actor|" + actorTemplate); + const newEnt = Engine.AddEntity("actor|" + actorTemplate); Engine.QueryInterface(newEnt, IID_Visual).SetActorSeed(seed); - let cmpNewPos = Engine.QueryInterface(newEnt, IID_Position); + const cmpNewPos = Engine.QueryInterface(newEnt, IID_Position); cmpNewPos.JumpTo(pos.x, pos.z); cmpNewPos.SetHeightOffset(height); cmpNewPos.SetXZRotation(rot.x, rot.z); @@ -181,8 +181,8 @@ }; { - let waterRiseTime = debugWaterRise ? 0 : (InitAttributes.settings.SeaLevelRiseTime || 0); - let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); + const waterRiseTime = debugWaterRise ? 0 : (InitAttributes.settings.SeaLevelRiseTime || 0); + const cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); cmpTrigger.GarrisonWoodenTowers(); cmpTrigger.DoAfterDelay((waterRiseTime - waterRiseNotificationDuration) * 60 * 1000, "RaisingWaterNotification", {}); cmpTrigger.DoAfterDelay(waterRiseTime * 60 * 1000, "RaiseWaterLevelStep", {}); 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,18 +68,18 @@ 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 = { "houseA": { "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), @@ -211,7 +211,7 @@ var 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"]; @@ -51,7 +51,7 @@ const heightLand = 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(); @@ -130,7 +130,7 @@ for (let m = 0; m < randIntInclusive(20, 34); ++m) { - let elevRand = randIntInclusive(6, 20); + const elevRand = randIntInclusive(6, 20); createArea( new ChainPlacer( 7, @@ -150,7 +150,7 @@ for (let m = 0; m < randIntInclusive(8, 17); ++m) { - let elevRand = randIntInclusive(15, 29); + const elevRand = randIntInclusive(15, 29); createArea( new ChainPlacer( 5, @@ -202,7 +202,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)], @@ -211,8 +211,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), [ @@ -227,7 +227,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 @@ -45,21 +45,21 @@ var heightSeaGround = -4; var 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 }, @@ -76,7 +76,7 @@ break; // CC and units - for (let dist of [6, 8]) + for (const dist of [6, 8]) { let ents = getStartingEntities(playerIDs[i]); @@ -98,7 +98,7 @@ // Ground texture var civ = getCivCode(playerIDs[i]); - var tilesSize = civ == "cart" ? 23 : 21; + 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])), @@ -119,7 +119,7 @@ } g_Map.log("Creating lakes"); -var numLakes = Math.round(scaleByMapSize(1,4) * numPlayers); +const numLakes = Math.round(scaleByMapSize(1,4) * numPlayers); var waterAreas = createAreas( new ClumpPlacer(scaleByMapSize(100,250), 0.8, 0.1, Infinity), [ @@ -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 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 @@ -10,7 +10,7 @@ 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, 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 @@ -49,21 +49,21 @@ var heightRing = 4; var 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); @@ -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), 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 @@ -41,23 +41,23 @@ var heightShore = 2; var 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(); @@ -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,22 +62,22 @@ 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(); @@ -120,9 +120,9 @@ { "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 @@ -9,7 +9,7 @@ var heightLand = 2; var 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 @@ -56,21 +56,21 @@ 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); @@ -90,13 +90,13 @@ 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, @@ -320,7 +320,7 @@ [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, @@ -334,7 +334,7 @@ [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,22 +49,22 @@ 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); @@ -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]), 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(); @@ -67,12 +67,12 @@ var 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,21 +50,21 @@ 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); @@ -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,8 +179,8 @@ 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]] ]; @@ -188,8 +188,8 @@ if (currentBiome() != "generic/savanna") { var size = forestTrees / (scaleByMapSize(3,6) * 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 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), 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 @@ -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); } @@ -457,7 +457,7 @@ var 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( @@ -475,7 +475,7 @@ g_Map.log("Creating irrigation canals"); var irrigationCanalLocations = []; -for (let area of irrigationCanalAreas) +for (const area of irrigationCanalAreas) { if (!area.getPoints().length || area.getPoints().some(point => !avoidClasses(clPlayer, scaleByMapSize(8, 13), clIrrigationCanal, scaleByMapSize(15, 25)).allows(point))) @@ -493,15 +493,15 @@ g_Map.log("Creating passages"); var previousPassageY = randIntInclusive(0, widthFertileLand); -var areasPassages = []; +const 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], @@ -682,8 +682,8 @@ 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 ? @@ -726,10 +726,10 @@ g_Map.log("Placing kushite temples"); var entitiesTemples = []; -var templePosition = []; +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]); } @@ -774,8 +774,8 @@ 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; @@ -789,8 +789,8 @@ 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,7 +800,7 @@ } 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]); @@ -851,7 +851,7 @@ 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]), @@ -884,10 +884,10 @@ 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()), [ @@ -972,18 +972,18 @@ 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, @@ -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, [ @@ -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/jebel_barkal_triggers.js =================================================================== --- binaries/data/mods/public/maps/random/jebel_barkal_triggers.js +++ binaries/data/mods/public/maps/random/jebel_barkal_triggers.js @@ -367,7 +367,7 @@ Trigger.prototype.JebelBarkal_Init = function() { - let isNomad = !TriggerHelper.GetAllPlayersEntitiesByClass("CivCentre").length; + const isNomad = !TriggerHelper.GetAllPlayersEntitiesByClass("CivCentre").length; this.JebelBarkal_TrackUnits(); this.RegisterTrigger("OnOwnershipChanged", "JebelBarkal_OwnershipChange", { "enabled": true }); @@ -411,7 +411,7 @@ Trigger.prototype.JebelBarkal_SetDefenderStance = function() { - for (let ent of TriggerHelper.GetPlayerEntitiesByClass(jebelBarkal_playerID, "Human")) + for (const ent of TriggerHelper.GetPlayerEntitiesByClass(jebelBarkal_playerID, "Human")) TriggerHelper.SetUnitStance(ent, "defensive"); }; @@ -422,13 +422,13 @@ Trigger.prototype.JebelBarkal_UpdateRitualAnimations = function() { - for (let ent of this.jebelBarkal_ritualHealers) + for (const ent of this.jebelBarkal_ritualHealers) { - let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); + const cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); if (!cmpUnitAI || cmpUnitAI.GetCurrentState() != "INDIVIDUAL.IDLE") continue; - let cmpVisual = Engine.QueryInterface(ent, IID_Visual); + const cmpVisual = Engine.QueryInterface(ent, IID_Visual); if (cmpVisual && jebelBarkal_ritualAnimations.indexOf(cmpVisual.GetAnimationName()) == -1) cmpVisual.SelectAnimation(pickRandom(jebelBarkal_ritualAnimations), false, 1, ""); } @@ -436,13 +436,13 @@ Trigger.prototype.JebelBarkal_GarrisonBuildings = function() { - for (let buildingGarrison of jebelBarkal_buildingGarrison(this.GetDifficulty())) + for (const buildingGarrison of jebelBarkal_buildingGarrison(this.GetDifficulty())) TriggerHelper.SpawnAndGarrisonAtClasses(jebelBarkal_playerID, buildingGarrison.buildingClasses, buildingGarrison.unitTemplates, buildingGarrison.capacityRatio); }; Trigger.prototype.JebelBarkal_TurretBuildings = function() { - for (let buildingTurret of jebelBarkal_buildingTurret(this.GetDifficulty())) + for (const buildingTurret of jebelBarkal_buildingTurret(this.GetDifficulty())) TriggerHelper.SpawnAndTurretAtClasses(jebelBarkal_playerID, buildingTurret.buildingClasses, buildingTurret.unitTemplates, buildingTurret.capacityRatio); }; @@ -454,33 +454,33 @@ if (!this.jebelBarkal_patrolGroupSpawnPoints.length) return; - let time = TriggerHelper.GetMinutes(); - let groupCount = Math.floor(Math.max(0, jebelBarkal_cityPatrolGroup_count(time)) - this.jebelBarkal_patrolingUnits.length); + const time = TriggerHelper.GetMinutes(); + const groupCount = Math.floor(Math.max(0, jebelBarkal_cityPatrolGroup_count(time)) - this.jebelBarkal_patrolingUnits.length); this.debugLog("Spawning " + groupCount + " city patrol groups, " + this.jebelBarkal_patrolingUnits.length + " exist"); for (let i = 0; i < groupCount; ++i) { - let spawnEnt = pickRandom(this.jebelBarkal_patrolGroupSpawnPoints); + const spawnEnt = pickRandom(this.jebelBarkal_patrolGroupSpawnPoints); - let templateCounts = TriggerHelper.BalancedTemplateComposition( + const templateCounts = TriggerHelper.BalancedTemplateComposition( jebelBarkal_cityPatrolGroup_balancing.unitComposition(time, this.jebelBarkal_heroes), jebelBarkal_cityPatrolGroup_balancing.unitCount(time)); this.debugLog(uneval(templateCounts)); - let groupEntities = this.JebelBarkal_SpawnTemplates(spawnEnt, templateCounts); + const groupEntities = this.JebelBarkal_SpawnTemplates(spawnEnt, templateCounts); this.jebelBarkal_patrolingUnits.push(groupEntities); - for (let ent of groupEntities) + for (const ent of groupEntities) TriggerHelper.SetUnitStance(ent, "defensive"); TriggerHelper.SetUnitFormation(jebelBarkal_playerID, groupEntities, pickRandom(jebelBarkal_formations)); - for (let patrolTarget of shuffleArray(this.GetTriggerPoints(jebelBarkal_cityPatrolGroup_triggerPointPath))) + for (const patrolTarget of shuffleArray(this.GetTriggerPoints(jebelBarkal_cityPatrolGroup_triggerPointPath))) { - let pos = TriggerHelper.GetEntityPosition2D(patrolTarget); + const pos = TriggerHelper.GetEntityPosition2D(patrolTarget); ProcessCommand(jebelBarkal_playerID, { "type": "patrol", "entities": groupEntities, @@ -502,9 +502,9 @@ { let groupEntities = []; - for (let templateName in templateCounts) + for (const templateName in templateCounts) { - let ents = TriggerHelper.SpawnUnits(spawnEnt, templateName, templateCounts[templateName], jebelBarkal_playerID); + const ents = TriggerHelper.SpawnUnits(spawnEnt, templateName, templateCounts[templateName], jebelBarkal_playerID); groupEntities = groupEntities.concat(ents); @@ -523,32 +523,32 @@ if (!this.jebelBarkal_attackerGroupSpawnPoints) return; - let time = TriggerHelper.GetMinutes(); + const time = TriggerHelper.GetMinutes(); this.JebelBarkal_StartAttackTimer(jebelBarkal_attackInterval(time, this.GetDifficulty())); this.debugLog("Attacker wave (at most " + (jebelBarkal_maxPopulation - this.jebelBarkal_attackerUnits.length) + " attackers)"); - let activePlayers = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetActivePlayers(); - let playerEntities = activePlayers.map(playerID => + const activePlayers = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetActivePlayers(); + const playerEntities = activePlayers.map(playerID => TriggerHelper.GetEntitiesByPlayer(playerID).filter(TriggerHelper.IsInWorld)); - let patrolPoints = this.GetTriggerPoints(jebelBarkal_attackerGroup_triggerPointPatrol); + const patrolPoints = this.GetTriggerPoints(jebelBarkal_attackerGroup_triggerPointPatrol); - let groupSizeFactor = jebelBarkal_attackerGroup_sizeFactor( + const groupSizeFactor = jebelBarkal_attackerGroup_sizeFactor( activePlayers.length, this.numInitialSpawnPoints, this.GetDifficulty()); let totalSpawnCount = 0; - for (let spawnPointBalancing of jebelBarkal_attackerGroup_balancing) + for (const spawnPointBalancing of jebelBarkal_attackerGroup_balancing) { - let targets = playerEntities.reduce((allTargets, playerEnts) => + const targets = playerEntities.reduce((allTargets, playerEnts) => allTargets.concat(shuffleArray(TriggerHelper.MatchEntitiesByClass(playerEnts, spawnPointBalancing.targetClasses())).slice(0, 10)), []); if (!targets.length) continue; - for (let spawnEnt of TriggerHelper.MatchEntitiesByClass(this.jebelBarkal_attackerGroupSpawnPoints, spawnPointBalancing.buildingClasses)) + for (const spawnEnt of TriggerHelper.MatchEntitiesByClass(this.jebelBarkal_attackerGroupSpawnPoints, spawnPointBalancing.buildingClasses)) { let unitCount = Math.min( jebelBarkal_maxPopulation - this.jebelBarkal_attackerUnits.length, @@ -560,7 +560,7 @@ if (unitCount <= 0) continue; - let templateCounts = TriggerHelper.BalancedTemplateComposition(spawnPointBalancing.unitComposition(time, this.jebelBarkal_heroes), unitCount); + const templateCounts = TriggerHelper.BalancedTemplateComposition(spawnPointBalancing.unitComposition(time, this.jebelBarkal_heroes), unitCount); totalSpawnCount += unitCount; @@ -570,19 +570,19 @@ if (dryRun) continue; - let spawnedEntities = this.JebelBarkal_SpawnTemplates(spawnEnt, templateCounts); + const spawnedEntities = this.JebelBarkal_SpawnTemplates(spawnEnt, templateCounts); this.jebelBarkal_attackerUnits = this.jebelBarkal_attackerUnits.concat(spawnedEntities); - let formation = pickRandom(spawnPointBalancing.formations); + const formation = pickRandom(spawnPointBalancing.formations); if (formation) TriggerHelper.SetUnitFormation(jebelBarkal_playerID, spawnedEntities, formation); - let entityGroups = formation ? [spawnedEntities] : spawnedEntities.reduce((entityGroup, ent) => entityGroup.concat([[ent]]), []); + const entityGroups = formation ? [spawnedEntities] : spawnedEntities.reduce((entityGroup, ent) => entityGroup.concat([[ent]]), []); for (let i = 0; i < jebelBarkal_patrolPointCount; ++i) - for (let entities of entityGroups) + for (const entities of entityGroups) { - let pos = TriggerHelper.GetEntityPosition2D(pickRandom(i == 0 ? targets : patrolPoints)); + const pos = TriggerHelper.GetEntityPosition2D(pickRandom(i == 0 ? targets : patrolPoints)); ProcessCommand(jebelBarkal_playerID, { "type": "patrol", "entities": entities, @@ -609,7 +609,7 @@ Trigger.prototype.JebelBarkal_StartAttackTimer = function(delay) { - let nextAttack = delay * 60 * 1000; + const nextAttack = delay * 60 * 1000; Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface).AddTimeNotification({ "message": markForTranslation("Napata will attack in %(time)s!"), @@ -629,7 +629,7 @@ if (data.from != 0) return; - let trackedEntityArrays = [ + const trackedEntityArrays = [ this.jebelBarkal_heroes, this.jebelBarkal_ritualHealers, this.jebelBarkal_patrolGroupSpawnPoints, @@ -638,9 +638,9 @@ ...this.jebelBarkal_patrolingUnits, ]; - for (let array of trackedEntityArrays) + for (const array of trackedEntityArrays) { - let idx = array.indexOf(data.entity); + const idx = array.indexOf(data.entity); if (idx != -1) array.splice(idx, 1); } 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,21 +37,21 @@ 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); @@ -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 num = Math.floor(size / 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), [ 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,21 +45,21 @@ 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)); 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,23 +42,23 @@ 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); @@ -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]), 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 @@ -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), @@ -205,7 +205,7 @@ [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)); @@ -331,7 +331,7 @@ [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), 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,9 +34,9 @@ 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(); +const g_Map = new RandomMap(heightWaterLevel, g_Terrains.mainTerrain); +const mapSize = g_Map.getSize(); +const mapCenter = g_Map.getCenter(); var mapBounds = g_Map.getBounds(); g_Map.LoadHeightmapImage("mediterranean.png", 0, 40); @@ -46,9 +46,9 @@ 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 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,22 +48,22 @@ 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(); @@ -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); @@ -181,8 +181,8 @@ 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]] ]; @@ -190,8 +190,8 @@ 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 num = Math.floor(size / 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), 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,23 +55,23 @@ 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)); @@ -160,7 +160,7 @@ { 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(); @@ -187,7 +187,7 @@ { let fishPosition; var r = 0; - var angle = 2 * Math.PI / num * i; + const angle = 2 * Math.PI / num * i; do { // Work outward until constraint met fishPosition = Vector2D.add(mapCenter, new Vector2D(r, 0).rotate(-angle)); @@ -276,7 +276,7 @@ Engine.SetProgress(65); g_Map.log("Creating forests"); -var [forestTrees, stragglerTrees] = getTreeCounts(500, 2500, 0.5); +const [forestTrees, stragglerTrees] = getTreeCounts(500, 2500, 0.5); var 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,23 +32,23 @@ 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(); @@ -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); -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 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), [ 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,21 +43,21 @@ 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); @@ -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), [ @@ -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( @@ -263,7 +263,7 @@ scaleByMapSize(10, 40), 20 ); -var objectsWaterFlora = [ +const objectsWaterFlora = [ new SimpleObject(aReedsA, 5, 12, 0, 2), new SimpleObject(aReedsB, 5, 12, 0, 2) ]; @@ -272,8 +272,8 @@ for (var sandx = 0; sandx < mapSize; sandx += 4) for (var 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,14 +156,14 @@ 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 num = Math.floor(size / types.length); +for (const type of types) createAreas( new ChainPlacer( Math.floor(scaleByMapSize(1, 2)), 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,24 +47,24 @@ 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; @@ -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), [ @@ -198,7 +198,7 @@ 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, @@ -298,7 +298,7 @@ [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; -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)); -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/polar_sea_triggers.js =================================================================== --- binaries/data/mods/public/maps/random/polar_sea_triggers.js +++ binaries/data/mods/public/maps/random/polar_sea_triggers.js @@ -1,6 +1,6 @@ const debugLog = false; -var attackerTemplate = "gaia/fauna_wolf_arctic_violent"; +const attackerTemplate = "gaia/fauna_wolf_arctic_violent"; var minWaveSize = 1; var maxWaveSize = 3; @@ -12,8 +12,8 @@ /** * Attackers will focus the targetCount closest units that have the targetClasses type. */ -var targetClasses = "Organic+!Domestic"; -var targetCount = 3; +const targetClasses = "Organic+!Domestic"; +const targetCount = 3; Trigger.prototype.DisableTechnologies = function() { @@ -28,31 +28,31 @@ Trigger.prototype.SpawnWolvesAndAttack = function() { - let waveSize = Math.round(Math.random() * (maxWaveSize - minWaveSize) + minWaveSize); - let attackers = TriggerHelper.SpawnUnitsFromTriggerPoints("A", attackerTemplate, waveSize, 0); + const waveSize = Math.round(Math.random() * (maxWaveSize - minWaveSize) + minWaveSize); + const attackers = TriggerHelper.SpawnUnitsFromTriggerPoints("A", attackerTemplate, waveSize, 0); if (debugLog) print("Spawned " + waveSize + " " + attackerTemplate + " at " + Object.keys(attackers).length + " points\n"); let allTargets; - let players = new Array(TriggerHelper.GetNumberOfPlayers()).fill(0).map((v, i) => i + 1); + const players = new Array(TriggerHelper.GetNumberOfPlayers()).fill(0).map((v, i) => i + 1); - for (let spawnPoint in attackers) + for (const spawnPoint in attackers) { // TriggerHelper.SpawnUnits is guaranteed to spawn - let firstAttacker = attackers[spawnPoint][0]; + const firstAttacker = attackers[spawnPoint][0]; if (!firstAttacker) continue; - let attackerPos = TriggerHelper.GetEntityPosition2D(firstAttacker); + const attackerPos = TriggerHelper.GetEntityPosition2D(firstAttacker); if (!attackerPos) continue; // The returned entities are sorted by RangeManager already // Only consider units implementing Health since wolves deal damage. - let targets = PositionHelper.EntitiesNearPoint(attackerPos, 200, players, IID_Health).filter(ent => { - let cmpIdentity = Engine.QueryInterface(ent, IID_Identity); + const targets = PositionHelper.EntitiesNearPoint(attackerPos, 200, players, IID_Health).filter(ent => { + const cmpIdentity = Engine.QueryInterface(ent, IID_Identity); return cmpIdentity && MatchesClassList(cmpIdentity.GetClassesList(), targetClasses); }); @@ -63,20 +63,20 @@ { if (!allTargets) allTargets = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager).GetNonGaiaEntities().filter(ent => { - let cmpIdentity = Engine.QueryInterface(ent, IID_Identity); + const cmpIdentity = Engine.QueryInterface(ent, IID_Identity); return cmpIdentity && MatchesClassList(cmpIdentity.GetClassesList(), targetClasses); }); - let getDistance = target => { - let targetPos = TriggerHelper.GetEntityPosition2D(target); + const getDistance = target => { + const targetPos = TriggerHelper.GetEntityPosition2D(target); return targetPos ? attackerPos.distanceToSquared(targetPos) : Infinity; }; goodTargets = []; - let goodDists = []; - for (let target of allTargets) + const goodDists = []; + for (const target of allTargets) { - let dist = getDistance(target); + const dist = getDistance(target); let i = goodDists.findIndex(element => dist < element); if (i != -1 || goodTargets.length < targetCount) { @@ -93,7 +93,7 @@ } } - for (let target of goodTargets) + for (const target of goodTargets) ProcessCommand(0, { "type": "attack", "entities": attackers[spawnPoint], @@ -106,7 +106,7 @@ }; { - let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); + const cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); cmpTrigger.RegisterTrigger("OnInitGame", "DisableTechnologies", { "enabled": true }); cmpTrigger.DoAfterDelay(firstWaveTime * 60 * 1000, "SpawnWolvesAndAttack", {}); } 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)); @@ -186,7 +186,7 @@ { "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,23 +73,23 @@ 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; @@ -102,7 +102,7 @@ var passageLength = scaleByMapSize(8, 50); -var terrainPerHeight = [ +const terrainPerHeight = [ { "maxHeight": heightGrass, "steepness": 5, @@ -148,10 +148,10 @@ baseHeights.push([]); for (var 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); } @@ -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) @@ -254,11 +254,11 @@ var passageLocation = 0.35; var 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,10 +305,10 @@ avoidClasses(clWater, 5, clPlayer, 20, clBaseResource, 6, clPyrenneans, 2), scaleByMapSize(5, 35)); g_Map.log("Creating forests"); -var types = [[tForestTransition, pForestLandVeryLight, pForestLandLight, pForestLand]]; +const 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) +for (const type of types) createAreas( new ClumpPlacer(size, 0.2, 0.1, Infinity), [ @@ -327,7 +327,7 @@ 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), 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)); @@ -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 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, 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), [ 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,24 +47,24 @@ 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(); @@ -86,10 +86,10 @@ { 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(); @@ -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 num = Math.floor(size / 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,22 +52,22 @@ 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)); @@ -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), 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,21 +37,21 @@ 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)); @@ -87,7 +87,7 @@ var 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), [ 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)), @@ -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), @@ -112,7 +112,7 @@ g_Map.log("Creating stone mines"); for (var 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); 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,22 +42,22 @@ 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)); @@ -96,7 +96,7 @@ 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 num = Math.floor(size / 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), 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', @@ -60,30 +60,30 @@ '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 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(); +const mapSize = g_Map.getSize(); +const mapCenter = g_Map.getCenter(); var mapRadius = mapSize/2; -var numPlayers = getNumPlayers(); +const 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); @@ -107,7 +107,7 @@ 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 }; // Set average water coverage. -var averageWaterCoverage = 1/5; // NOTE: Since erosion is not predictable actual water coverage might vary much with the same values. +const 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; setWaterHeight(heightSeaGround); @@ -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, @@ -220,8 +220,8 @@ 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, @@ -283,28 +283,28 @@ for (var x = 0; x < mapSize; x++) for (var 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); + const radius = Vector2D.add(position, new Vector2D(0.5, 0.5)).distanceTo(mapCenter); var 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 @@ -47,23 +47,23 @@ var heightSnowline = 12; var 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); @@ -72,7 +72,7 @@ var [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 num = Math.floor(size / types.length); +for (const type of types) createAreas( new ClumpPlacer(forestTrees / num, 0.1, 0.1, Infinity), [ @@ -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), 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( @@ -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); @@ -114,7 +114,7 @@ var 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, @@ -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)])], Index: binaries/data/mods/public/maps/random/survivalofthefittest_triggers.js =================================================================== --- binaries/data/mods/public/maps/random/survivalofthefittest_triggers.js +++ binaries/data/mods/public/maps/random/survivalofthefittest_triggers.js @@ -11,7 +11,7 @@ /** * Get the number of minutes to pass between spawning new treasures. */ -var treasureTime = () => randFloat(3, 5); +const treasureTime = () => randFloat(3, 5); /** * Get the time in minutes when the first wave of attackers will be spawned. @@ -41,7 +41,7 @@ /** * Greatest amount of attackers that can be spawned. */ -var totalAttackerLimit = 200; +const totalAttackerLimit = 200; /** * Least and greatest amount of siege engines per wave. @@ -84,7 +84,7 @@ /** * Spawn these treasures in regular intervals. */ -var treasures = [ +const treasures = [ "gaia/treasure/food_barrel", "gaia/treasure/food_bin", "gaia/treasure/food_crate", @@ -123,7 +123,7 @@ Trigger.prototype.LoadAttackerTemplates = function() { - for (let civ of ["gaia", ...Object.keys(loadCivFiles(false))]) + for (const civ of ["gaia", ...Object.keys(loadCivFiles(false))]) attackerUnitTemplates[civ] = { "heroes": TriggerHelper.GetTemplateNamesByClasses("Hero", civ, undefined, true), "champions": TriggerHelper.GetTemplateNamesByClasses("Champion+!Elephant", civ, undefined, true), @@ -155,7 +155,7 @@ Trigger.prototype.InitializeEnemyWaves = function() { - let time = firstWaveTime() * 60 * 1000; + const time = firstWaveTime() * 60 * 1000; Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface).AddTimeNotification({ "message": markForTranslation("The first wave will start in %(time)s!"), "translateMessage": true @@ -165,20 +165,20 @@ Trigger.prototype.StartAnEnemyWave = function() { - let currentMin = TriggerHelper.GetMinutes(); - let nextWaveTime = waveTime(); - let civ = pickRandom(Object.keys(attackerUnitTemplates)); + const currentMin = TriggerHelper.GetMinutes(); + const nextWaveTime = waveTime(); + const civ = pickRandom(Object.keys(attackerUnitTemplates)); // Determine total attacker count of the current wave. // Exponential increase with time, capped to the limit and fluctuating proportionally with the current wavetime. - let totalAttackers = Math.ceil(Math.min(totalAttackerLimit, + const totalAttackers = Math.ceil(Math.min(totalAttackerLimit, initialAttackers * Math.pow(percentPerMinute, currentMin) * nextWaveTime / maxWaveTime)); - let siegeRatio = siegeFraction(); + const siegeRatio = siegeFraction(); this.debugLog("Spawning " + totalAttackers + " attackers, siege ratio " + siegeRatio.toFixed(2)); - let attackerCount = TriggerHelper.BalancedTemplateComposition( + const attackerCount = TriggerHelper.BalancedTemplateComposition( [ { "templates": attackerUnitTemplates[civ].heroes, @@ -199,7 +199,7 @@ // Spawn the templates let spawned = false; - for (let point of this.GetTriggerPoints("A")) + for (const point of this.GetTriggerPoints("A")) { if (dryRun) { @@ -208,28 +208,28 @@ } // Don't spawn attackers for defeated players and players that lost their cc after win - let cmpPlayer = QueryOwnerInterface(point, IID_Player); + const cmpPlayer = QueryOwnerInterface(point, IID_Player); if (!cmpPlayer) continue; - let playerID = cmpPlayer.GetPlayerID(); - let civicCentre = this.playerCivicCenter[playerID]; + const playerID = cmpPlayer.GetPlayerID(); + const civicCentre = this.playerCivicCenter[playerID]; if (!civicCentre) continue; // Check if the cc is garrisoned in another building - let targetPos = TriggerHelper.GetEntityPosition2D(civicCentre); + const targetPos = TriggerHelper.GetEntityPosition2D(civicCentre); if (!targetPos) continue; - for (let templateName in attackerCount) + for (const templateName in attackerCount) { - let isHero = attackerUnitTemplates[civ].heroes.indexOf(templateName) != -1; + const isHero = attackerUnitTemplates[civ].heroes.indexOf(templateName) != -1; // Don't spawn gaia hero if the previous one is still alive if (this.gaiaHeroes[playerID] && isHero) { - let cmpHealth = Engine.QueryInterface(this.gaiaHeroes[playerID], IID_Health); + const cmpHealth = Engine.QueryInterface(this.gaiaHeroes[playerID], IID_Health); if (cmpHealth && cmpHealth.GetHitpoints() != 0) { this.debugLog("Not spawning hero for player " + playerID + " as the previous one is still alive"); @@ -240,7 +240,7 @@ if (dryRun) continue; - let entities = TriggerHelper.SpawnUnits(point, templateName, attackerCount[templateName], 0); + const entities = TriggerHelper.SpawnUnits(point, templateName, attackerCount[templateName], 0); ProcessCommand(0, { "type": "attack-walk", @@ -271,8 +271,8 @@ Trigger.prototype.PlaceTreasures = function() { - let triggerPoints = this.GetTriggerPoints(pickRandom(["B", "C", "D"])); - for (let point of triggerPoints) + const triggerPoints = this.GetTriggerPoints(pickRandom(["B", "C", "D"])); + for (const point of triggerPoints) TriggerHelper.SpawnUnits(point, pickRandom(treasures), 1, 0); this.DoAfterDelay(treasureTime() * 60 * 1000, "PlaceTreasures", {}); @@ -297,7 +297,7 @@ { - let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); + const cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); cmpTrigger.treasureFemale = []; cmpTrigger.playerCivicCenter = []; 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,19 +36,19 @@ 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)); @@ -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 num = Math.floor(size / 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]), Index: binaries/data/mods/public/maps/random/tests/test_TileClass.js =================================================================== --- binaries/data/mods/public/maps/random/tests/test_TileClass.js +++ binaries/data/mods/public/maps/random/tests/test_TileClass.js @@ -11,7 +11,7 @@ Engine.LoadLibrary("rmgen"); var g_MapSettings = { "Size": 512 }; -var g_Map = new RandomMap(0, "blackness"); +const g_Map = new RandomMap(0, "blackness"); // Test that that it checks by value, not by reference { 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,42 +1,42 @@ 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]; @@ -46,31 +46,31 @@ 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(); @@ -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,7 +183,7 @@ scaleByMapSize(100, 200)); g_Map.log("Creating ponds"); -var numLakes = Math.round(scaleByMapSize(1, 4) * numPlayers / 2); +const numLakes = Math.round(scaleByMapSize(1, 4) * numPlayers / 2); var waterAreas = createAreas( new ClumpPlacer(scaleByMapSize(2, 5) * 50, 0.8, 0.1, Infinity), [ @@ -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), [ 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,24 +1,24 @@ 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]; @@ -26,18 +26,18 @@ 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 num = Math.floor(size / 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), [ 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,7 +43,7 @@ * And have fun! */ -var mapSize = g_Map.getSize(); +const mapSize = g_Map.getSize(); /** * General wall placement setup @@ -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); } @@ -95,13 +95,13 @@ */ var 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) @@ -125,11 +125,11 @@ * 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) +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); @@ -305,16 +305,16 @@ // Two vars, just for this map; firstly how long the longest wall will be. var 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)