diff --git a/binaries/data/mods/public/maps/random/african_plains.js b/binaries/data/mods/public/maps/random/african_plains.js index f6f5d1a752..cf728492e1 100644 --- a/binaries/data/mods/public/maps/random/african_plains.js +++ b/binaries/data/mods/public/maps/random/african_plains.js @@ -314,7 +314,7 @@ createFood( [new SimpleObject(oBerryBush, 5,7, 0,4)] ], [ - randInt(1, 4) * numPlayers + 2 + randIntInclusive(1, 4) * numPlayers + 2 ], avoidClasses(clWater, 3, clForest, 2, clPlayer, 20, clHill, 3, clFood, 10) ); diff --git a/binaries/data/mods/public/maps/random/alpine_lakes.js b/binaries/data/mods/public/maps/random/alpine_lakes.js index d5941dff27..c0ab5b33a6 100644 --- a/binaries/data/mods/public/maps/random/alpine_lakes.js +++ b/binaries/data/mods/public/maps/random/alpine_lakes.js @@ -375,7 +375,7 @@ createFood [new SimpleObject(oBerryBush, 5,7, 0,4)] ], [ - randInt(1, 4) * numPlayers + 2 + randIntInclusive(1, 4) * numPlayers + 2 ], avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10) ); diff --git a/binaries/data/mods/public/maps/random/alpine_valley.js b/binaries/data/mods/public/maps/random/alpine_valley.js index 0a47a24b80..8092a1c609 100644 --- a/binaries/data/mods/public/maps/random/alpine_valley.js +++ b/binaries/data/mods/public/maps/random/alpine_valley.js @@ -251,7 +251,7 @@ for (var i = 0; i < numPoints; ++i) //find and place the edges while (possibleEdges.length) { - var index = randInt(0, possibleEdges.length - 1); + var index = randIntExclusive(0, possibleEdges.length); //ensure that a point is connected to a maximum of 3 others if (edgesConncetedToPoints[possibleEdges[index][0]] > 2 || edgesConncetedToPoints[possibleEdges[index][1]] > 2) @@ -567,7 +567,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, avoidClasses(clForest, 0, clPlayer, 20, clHill, 1, clFood, 10), - randInt(1, 4) * numPlayers + 2, 50 + randIntInclusive(1, 4) * numPlayers + 2, 50 ); log("Creating rabbit..."); diff --git a/binaries/data/mods/public/maps/random/anatolian_plateau.js b/binaries/data/mods/public/maps/random/anatolian_plateau.js index ac6a0c24fc..240b872abe 100644 --- a/binaries/data/mods/public/maps/random/anatolian_plateau.js +++ b/binaries/data/mods/public/maps/random/anatolian_plateau.js @@ -313,7 +313,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, avoidClasses(clForest, 0, clPlayer, 20, clHill, 1, clFood, 20), - randInt(1, 4) * numPlayers + 2, 50 + randIntInclusive(1, 4) * numPlayers + 2, 50 ); RMS.SetProgress(75); diff --git a/binaries/data/mods/public/maps/random/archipelago.js b/binaries/data/mods/public/maps/random/archipelago.js index d69d7cc4c2..1afab8d05a 100644 --- a/binaries/data/mods/public/maps/random/archipelago.js +++ b/binaries/data/mods/public/maps/random/archipelago.js @@ -191,7 +191,7 @@ createAreas( placer, [terrainPainter, elevationPainter, paintClass(clLand)], null, - scaleByMapSize(1, 5)*randInt(5,10) + scaleByMapSize(1, 5) * randIntInclusive(5, 10) ); paintTerrainBasedOnHeight(2.4, 3.4, 3, tMainTerrain); diff --git a/binaries/data/mods/public/maps/random/ardennes_forest.js b/binaries/data/mods/public/maps/random/ardennes_forest.js index 7e88560e82..a4ef9b047c 100644 --- a/binaries/data/mods/public/maps/random/ardennes_forest.js +++ b/binaries/data/mods/public/maps/random/ardennes_forest.js @@ -566,7 +566,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 20), - randInt(3, 12) * numPlayers + 2, 50 + randIntInclusive(3, 12) * numPlayers + 2, 50 ); log("Creating decorative props..."); diff --git a/binaries/data/mods/public/maps/random/atlas_mountains.js b/binaries/data/mods/public/maps/random/atlas_mountains.js index ca27580e97..b5eedc8a94 100644 --- a/binaries/data/mods/public/maps/random/atlas_mountains.js +++ b/binaries/data/mods/public/maps/random/atlas_mountains.js @@ -273,7 +273,7 @@ createFood [new SimpleObject(oBerryBush, 5,7, 0,4)] ], [ - randInt(3, 12) * numPlayers + 2 + randIntInclusive(3, 12) * numPlayers + 2 ], avoidClasses(clForest, 0, clPlayer, 20, clHill, 1, clFood, 10) ); diff --git a/binaries/data/mods/public/maps/random/belgian_uplands.js b/binaries/data/mods/public/maps/random/belgian_uplands.js index 1c8fbf9c5b..40f62695e9 100644 --- a/binaries/data/mods/public/maps/random/belgian_uplands.js +++ b/binaries/data/mods/public/maps/random/belgian_uplands.js @@ -230,7 +230,7 @@ while (!goodStartPositionsFound) { var vector = []; for (var p = 0; p < numPlayers; p++) - vector.push(randInt(possibleStartPositions.length)); + vector.push(randIntExclusive(0, possibleStartPositions.length)); possibleDerivations.push(vector); } diff --git a/binaries/data/mods/public/maps/random/caledonian_meadows.js b/binaries/data/mods/public/maps/random/caledonian_meadows.js index 90bf72a191..f813d4b4b5 100644 --- a/binaries/data/mods/public/maps/random/caledonian_meadows.js +++ b/binaries/data/mods/public/maps/random/caledonian_meadows.js @@ -305,7 +305,7 @@ let decorations = [ function placeMine(point, centerEntity) { placeObject(point.x, point.y, centerEntity, 0, randFloat(0, TWO_PI)); - let quantity = randInt(11, 23); + let quantity = randIntInclusive(11, 23); let dAngle = TWO_PI / quantity; for (let i = 0; i < quantity; ++i) { @@ -378,7 +378,7 @@ function placeCamp(point, ) { placeObject(point.x, point.y, centerEntity, 0, randFloat(0, TWO_PI)); - let quantity = randInt(5, 11); + let quantity = randIntInclusive(5, 11); let dAngle = TWO_PI / quantity; for (let i = 0; i < quantity; ++i) { diff --git a/binaries/data/mods/public/maps/random/cantabrian_highlands.js b/binaries/data/mods/public/maps/random/cantabrian_highlands.js index 94ef800757..961fbec2d3 100644 --- a/binaries/data/mods/public/maps/random/cantabrian_highlands.js +++ b/binaries/data/mods/public/maps/random/cantabrian_highlands.js @@ -321,7 +321,7 @@ createFood [new SimpleObject(oBerryBush, 5,7, 0,4)] ], [ - randInt(1, 4) * numPlayers + 2 + randIntInclusive(1, 4) * numPlayers + 2 ], avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10) ); diff --git a/binaries/data/mods/public/maps/random/canyon.js b/binaries/data/mods/public/maps/random/canyon.js index f22d928f16..77906b474c 100644 --- a/binaries/data/mods/public/maps/random/canyon.js +++ b/binaries/data/mods/public/maps/random/canyon.js @@ -219,11 +219,17 @@ createArea(placer, [painter, paintClass(clHill)], null); for (var i = 0; i < scaleByMapSize(9,16); i++) { - var ix = randInt(1, mapSize - 1); - var iz = randInt(1, mapSize - 1); - var ix2 = randInt(1, mapSize - 1); - var iz2 = randInt(1, mapSize - 1); - var placer = new PathPlacer(ix, iz, ix2, iz2, scaleByMapSize(11,16), 0.4, 3*(scaleByMapSize(1,4)), 0.1, 0); + var placer = new PathPlacer( + randIntExclusive(1, mapSize), + randIntExclusive(1, mapSize), + randIntExclusive(1, mapSize), + randIntExclusive(1, mapSize), + scaleByMapSize(11,16), + 0.4, + 3 * scaleByMapSize(1,4), + 0.1, + 0); + var terrainPainter = new LayeredPainter( [tMainTerrain, tMainTerrain], // terrains [3] // widths @@ -238,8 +244,8 @@ for (var i = 0; i < scaleByMapSize(9,16); i++) for (var g = 0; g < scaleByMapSize(5,30); g++) { - var tx = randInt(1, mapSize - 1); - var tz = randInt(1, mapSize - 1); + var tx = randIntInclusive(1, mapSize - 1); + var tz = randIntInclusive(1, mapSize - 1); placer = new ClumpPlacer(mapArea * 0.01 * lSize, 0.7, 0.1, 10, tx, tz); terrainPainter = new LayeredPainter( @@ -497,11 +503,11 @@ createStragglerTrees(types, [avoidClasses(clForest, 1, clHill, 1, clPlayer, 9, c // create treasures var fx = fractionToTiles(0.5); var fz = fractionToTiles(0.5); -for (var i = 0; i < randInt(3,8); i++) - placeObject(fx+randFloat(-7,7), fz+randFloat(-7,7), oWood, 0, randFloat(0, TWO_PI)); +for (let i = 0; i < randIntInclusive(3, 8); ++i) + placeObject(fx + randFloat(-7, 7), fz + randFloat(-7, 7), oWood, 0, randFloat(0, 2 * PI)); -for (var i = 0; i < randInt(3,8); i++) - placeObject(fx+randFloat(-7,7), fz+randFloat(-7,7), oFood, 0, randFloat(0, TWO_PI)); +for (let i = 0; i < randIntInclusive(3, 8); ++i) + placeObject(fx + randFloat(-7, 7), fz + randFloat(-7, 7), oFood, 0, randFloat(0, 2 * PI)); // Export map data ExportMap(); diff --git a/binaries/data/mods/public/maps/random/cycladic_archipelago.js b/binaries/data/mods/public/maps/random/cycladic_archipelago.js index cf7355b83e..b9a82b05f6 100644 --- a/binaries/data/mods/public/maps/random/cycladic_archipelago.js +++ b/binaries/data/mods/public/maps/random/cycladic_archipelago.js @@ -339,7 +339,7 @@ var size = 5; //size var num = scaleByMapSize(10, 64); //number for (var i = 0; i < types.length; ++i) { - placer = new ClumpPlacer(6+randInt(12), 0.1, 0.1, 1); + placer = new ClumpPlacer(randIntInclusive(6, 17), 0.1, 0.1, 1); painter = new LayeredPainter( types[i], // terrains [2] // widths diff --git a/binaries/data/mods/public/maps/random/empire.js b/binaries/data/mods/public/maps/random/empire.js index 02904e500a..00882b1bc0 100644 --- a/binaries/data/mods/public/maps/random/empire.js +++ b/binaries/data/mods/public/maps/random/empire.js @@ -7,7 +7,7 @@ randomizeBiome(); initMapSettings(); initTileClasses(); -resetTerrain(g_Terrains.mainTerrain, g_TileClasses.land, randInt(5)); +resetTerrain(g_Terrains.mainTerrain, g_TileClasses.land, randIntInclusive(0, 4)); RMS.SetProgress(10); addBases("stronghold", 0.37, 0.04); diff --git a/binaries/data/mods/public/maps/random/english_channel.js b/binaries/data/mods/public/maps/random/english_channel.js index 246fc9f5ec..40f777020f 100644 --- a/binaries/data/mods/public/maps/random/english_channel.js +++ b/binaries/data/mods/public/maps/random/english_channel.js @@ -371,7 +371,7 @@ createFood [new SimpleObject(oBerryBush, 5,7, 0,4)] ], [ - randInt(1, 4) * numPlayers + 2 + randIntInclusive(1, 4) * numPlayers + 2 ], avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10) ); diff --git a/binaries/data/mods/public/maps/random/flood.js b/binaries/data/mods/public/maps/random/flood.js index 9775221d6a..ab2e369216 100644 --- a/binaries/data/mods/public/maps/random/flood.js +++ b/binaries/data/mods/public/maps/random/flood.js @@ -224,13 +224,19 @@ elevationPainter = new SmoothElevationPainter( ); createArea(placer, [terrainPainter, elevationPainter, paintClass(clHill)], avoidClasses(clPlayer, 40)); -let randMountains = 20 + randInt(15); -for (let m = 0; m < randMountains; ++m) +for (let m = 0; m < randIntInclusive(20, 34); ++m) { - let randX = randInt(mapSize); - let randY = randInt(mapSize); - let placer = new ChainPlacer(floor(scaleByMapSize(7, 7)), floor(scaleByMapSize(15, 15)), floor(scaleByMapSize(15, 20)), 1, randX, randY, 0, [floor(mapSize * 0.01)]); - let elevRand = 6 + randInt(15); + let placer = new ChainPlacer( + Math.floor(scaleByMapSize(7, 7)), + Math.floor(scaleByMapSize(15, 15)), + Math.floor(scaleByMapSize(15, 20)), + 1, + randIntExclusive(0, mapSize), + randIntExclusive(0, mapSize), + 0, + [Math.floor(mapSize * 0.01)]); + + let elevRand = randIntInclusive(6, 20); let terrainPainter = new LayeredPainter( [tDirt, tHill], // terrains [floor(elevRand / 3), 40] // widths @@ -243,13 +249,19 @@ for (let m = 0; m < randMountains; ++m) createArea(placer, [terrainPainter, elevationPainter, paintClass(clHill)], [avoidClasses(clBaseResource, 2, clPlayer, 40), stayClasses(clHill, 6)]); } -randMountains = 8 + randInt(10); -for (let m = 0; m < randMountains; ++m) +for (let m = 0; m < randIntInclusive(8, 17); ++m) { - let randX = randInt(mapSize); - let randY = randInt(mapSize); - let placer = new ChainPlacer(floor(scaleByMapSize(5, 5)), floor(scaleByMapSize(8, 8)), floor(scaleByMapSize(15, 20)), 1, randX, randY, 0, [floor(mapSize * 0.01)]); - let elevRand = 15 + randInt(15); + let placer = new ChainPlacer( + Math.floor(scaleByMapSize(5, 5)), + Math.floor(scaleByMapSize(8, 8)), + Math.floor(scaleByMapSize(15, 20)), + 1, + randIntExclusive(0, mapSize), + randIntExclusive(0, mapSize), + 0, + [Math.floor(mapSize * 0.01)]); + + let elevRand = randIntInclusive(15, 29); let terrainPainter = new LayeredPainter( [tCliff, tForestFloor2], // terrains [floor(elevRand / 3), 40] // widths diff --git a/binaries/data/mods/public/maps/random/fortress.js b/binaries/data/mods/public/maps/random/fortress.js index 1df556e61b..eac36e17d0 100644 --- a/binaries/data/mods/public/maps/random/fortress.js +++ b/binaries/data/mods/public/maps/random/fortress.js @@ -341,7 +341,7 @@ createFood [new SimpleObject(oBerryBush, 5,7, 0,4)] ], [ - randInt(1, 4) * numPlayers + 2 + randIntInclusive(1, 4) * numPlayers + 2 ], avoidClasses(clWater, 2, clForest, 0, clPlayer, 6, clHill, 1, clFood, 10) ); diff --git a/binaries/data/mods/public/maps/random/frontier.js b/binaries/data/mods/public/maps/random/frontier.js index e95c6df3d3..1786fc8032 100644 --- a/binaries/data/mods/public/maps/random/frontier.js +++ b/binaries/data/mods/public/maps/random/frontier.js @@ -10,9 +10,9 @@ initTileClasses(); RMS.SetProgress(10); // Pick a random elevation with a bias towards lower elevations -var randElevation = randInt(30); +var randElevation = randIntInclusive(0, 29); if (randElevation < 25) - randElevation = 1 + randInt(4); + randElevation = randIntInclusive(1, 4); resetTerrain(g_Terrains.mainTerrain, g_TileClasses.land, randElevation); RMS.SetProgress(20); diff --git a/binaries/data/mods/public/maps/random/guadalquivir_river.js b/binaries/data/mods/public/maps/random/guadalquivir_river.js index f7d2129b61..65cffa330b 100644 --- a/binaries/data/mods/public/maps/random/guadalquivir_river.js +++ b/binaries/data/mods/public/maps/random/guadalquivir_river.js @@ -380,7 +380,7 @@ createFood [new SimpleObject(oBerryBush, 5,7, 0,4)] ], [ - randInt(1, 4) * numPlayers + 2 + randIntInclusive(1, 4) * numPlayers + 2 ], [avoidClasses(clForest, 0, clPlayer, 20, clHill, 1, clFood, 10, clRiver, 1), stayClasses(clLand, 3)] ); diff --git a/binaries/data/mods/public/maps/random/gulf_of_bothnia.js b/binaries/data/mods/public/maps/random/gulf_of_bothnia.js index b91a76e77a..a6c889ff6b 100644 --- a/binaries/data/mods/public/maps/random/gulf_of_bothnia.js +++ b/binaries/data/mods/public/maps/random/gulf_of_bothnia.js @@ -1,7 +1,7 @@ RMS.LoadLibrary("rmgen"); TILE_CENTERED_HEIGHT_MAP = true; -var random_terrain = randInt(1,3); +var random_terrain = randIntInclusive(1, 3); if (random_terrain == 1) { setFogThickness(0.26); @@ -453,7 +453,7 @@ createFood [new SimpleObject(oBerryBush, 5,7, 0,4)] ], [ - randInt(1, 4) * numPlayers + 2 + randIntInclusive(1, 4) * numPlayers + 2 ], avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10) ); diff --git a/binaries/data/mods/public/maps/random/heightmap/heightmap.js b/binaries/data/mods/public/maps/random/heightmap/heightmap.js index d8ecc048e2..6269d39727 100644 --- a/binaries/data/mods/public/maps/random/heightmap/heightmap.js +++ b/binaries/data/mods/public/maps/random/heightmap/heightmap.js @@ -139,7 +139,7 @@ function distributeEntitiesByHeight(heightRange, avoidPoints, minDistance = 30, for (let tries = 0; tries < maxTries; ++tries) { - let checkPointIndex = randInt(validPoints.length); + let checkPointIndex = randIntExclusive(0, validPoints.length); let checkPoint = validPoints[checkPointIndex]; if (placements.every(p => getDistance(p.x, p.y, checkPoint.x, checkPoint.y) > minDistance)) { diff --git a/binaries/data/mods/public/maps/random/hyrcanian_shores.js b/binaries/data/mods/public/maps/random/hyrcanian_shores.js index 78207e7e72..0088d5a31b 100644 --- a/binaries/data/mods/public/maps/random/hyrcanian_shores.js +++ b/binaries/data/mods/public/maps/random/hyrcanian_shores.js @@ -453,7 +453,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, avoidClasses(clWater, 6, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10), - randInt(1, 4) * numPlayers + 2, 50 + randIntInclusive(1, 4) * numPlayers + 2, 50 ); // create boar diff --git a/binaries/data/mods/public/maps/random/islands.js b/binaries/data/mods/public/maps/random/islands.js index 1034e96b68..a1a92d4e10 100644 --- a/binaries/data/mods/public/maps/random/islands.js +++ b/binaries/data/mods/public/maps/random/islands.js @@ -492,7 +492,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, [avoidClasses(clForest, 0, clPlayer, 8, clHill, 1, clFood, 20), stayClasses(clLand, 5)], - randInt(1, 4) * numPlayers + 2, 50 + randIntInclusive(1, 4) * numPlayers + 2, 50 ); // create fish diff --git a/binaries/data/mods/public/maps/random/kerala.js b/binaries/data/mods/public/maps/random/kerala.js index 311acd1af7..33b782e8f9 100644 --- a/binaries/data/mods/public/maps/random/kerala.js +++ b/binaries/data/mods/public/maps/random/kerala.js @@ -198,7 +198,14 @@ for (var ix = 0; ix < mapSize; ix++) log("Creating shores..."); for (var i = 0; i < scaleByMapSize(20,120); i++) { - placer = new ChainPlacer(1, floor(scaleByMapSize(4, 6)), floor(scaleByMapSize(16, 30)), 1, floor(randFloat(0.28,0.34)*mapSize), floor(randFloat(0.1,0.9)*mapSize)); + placer = new ChainPlacer( + 1, + Math.floor(scaleByMapSize(4, 6)), + Math.floor(scaleByMapSize(16, 30)), + 1, + randIntExclusive(0.28 * mapSize, 0.34 * mapSize), + randIntExclusive(0.1 * mapSize, 0.9 * mapSize)); + var terrainPainter = new LayeredPainter( [tGrass, tGrass], // terrains [2] // widths @@ -426,7 +433,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, avoidClasses(clWater, 6, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10), - randInt(1, 4) * numPlayers + 2, 50 + randIntInclusive(1, 4) * numPlayers + 2, 50 ); // create sheep diff --git a/binaries/data/mods/public/maps/random/latium.js b/binaries/data/mods/public/maps/random/latium.js index 8ed5e4b3a7..e21e23c512 100644 --- a/binaries/data/mods/public/maps/random/latium.js +++ b/binaries/data/mods/public/maps/random/latium.js @@ -501,20 +501,26 @@ RMS.SetProgress(85); log("Creating fish..."); var num = scaleByMapSize(4, 16); var offsetX = mapSize * WATER_WIDTH/2; -for (var i = 0; i < num; ++i) -{ - var cX = round(offsetX + offsetX/2 * randFloat(-1, 1)); - var cY = round((i + 0.5) * mapSize/num); - group = new SimpleGroup([new SimpleObject(oFish, 1,1, 0,1)], true, clFood, cX, cY); - createObjectGroup(group, 0); -} -for (var i = 0; i < num; ++i) -{ - var cX = round(mapSize - offsetX + offsetX/2 * randFloat(-1, 1)); - var cY = round((i + 0.5) * mapSize/num); - group = new SimpleGroup([new SimpleObject(oFish, 1,1, 0,1)], true, clFood, cX, cY); - createObjectGroup(group, 0); -} +for (let i = 0; i < num; ++i) + createObjectGroup( + new SimpleGroup( + [new SimpleObject(oFish, 1, 1, 0, 1)], + true, + clFood, + randIntInclusive(offsetX / 2, offsetX * 3/2), + Math.round((i + 0.5) * mapSize / num)), + 0); + +for (let i = 0; i < num; ++i) + createObjectGroup( + new SimpleGroup( + [new SimpleObject(oFish, 1, 1, 0, 1)], + true, + clFood, + randIntInclusive(mapSize - offsetX * 3/2, mapSize - offsetX / 2), + Math.round((i + 0.5) * mapSize / num)), + 0); + RMS.SetProgress(90); log("Creating deer..."); diff --git a/binaries/data/mods/public/maps/random/lorraine_plain.js b/binaries/data/mods/public/maps/random/lorraine_plain.js index fca8fdf42e..b0464df8e1 100644 --- a/binaries/data/mods/public/maps/random/lorraine_plain.js +++ b/binaries/data/mods/public/maps/random/lorraine_plain.js @@ -210,7 +210,7 @@ createArea(placer, [painter, elevationPainter], avoidClasses(clPlayer, 8)); // create the shallows of the main river log("Creating the shallows of the main river"); -for (var i = 0; i <= randInt(3, scaleByMapSize(4,6)); i++) +for (let i = 0; i <= randIntInclusive(3, scaleByMapSize(4, 6)); ++i) { var cLocation = randFloat(0.15,0.85); passageMaker(floor(fractionToTiles(cLocation)), floor(fractionToTiles(0.35)), floor(fractionToTiles(cLocation)), floor(fractionToTiles(0.65)), scaleByMapSize(4,8), -2, -2, 2, clShallow, undefined, -4); @@ -427,7 +427,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, avoidClasses(clWater, 3, clForest, 0, clPlayer, 15, clHill, 1, clFood, 10), - randInt(1, 4) * numPlayers + 2, 50 + randIntInclusive(1, 4) * numPlayers + 2, 50 ); // create straggler trees diff --git a/binaries/data/mods/public/maps/random/migration.js b/binaries/data/mods/public/maps/random/migration.js index 1a23758ce9..a9d1fecd45 100644 --- a/binaries/data/mods/public/maps/random/migration.js +++ b/binaries/data/mods/public/maps/random/migration.js @@ -420,7 +420,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, [avoidClasses(clForest, 0, clPlayer, 8, clHill, 1, clFood, 20), stayClasses(clLand, 7)], - randInt(1, 4) * numPlayers + 2, 50 + randIntInclusive(1, 4) * numPlayers + 2, 50 ); RMS.SetProgress(78); diff --git a/binaries/data/mods/public/maps/random/northern_lights.js b/binaries/data/mods/public/maps/random/northern_lights.js index 9425fdb6ec..4d44db00fe 100644 --- a/binaries/data/mods/public/maps/random/northern_lights.js +++ b/binaries/data/mods/public/maps/random/northern_lights.js @@ -180,7 +180,14 @@ for (var ix = 0; ix < mapSize; ix++) log("Creating shores..."); for (var i = 0; i < scaleByMapSize(20,120); i++) { - placer = new ChainPlacer(1, floor(scaleByMapSize(4, 6)), floor(scaleByMapSize(16, 30)), 1, floor(randFloat(0.1,0.9)*mapSize), floor(randFloat(0.67,0.74)*mapSize)); + placer = new ChainPlacer( + 1, + Math.floor(scaleByMapSize(4, 6)), + Math.floor(scaleByMapSize(16, 30)), + 1, + randIntExclusive(0.1 * mapSize, 0.9 * mapSize), + randIntExclusive(0.67 * mapSize, 0.74 * mapSize)); + var terrainPainter = new LayeredPainter( [tSnowA, tSnowA], // terrains [2] // widths diff --git a/binaries/data/mods/public/maps/random/persian_highlands.js b/binaries/data/mods/public/maps/random/persian_highlands.js index 66bd7d04eb..09c5e37b56 100644 --- a/binaries/data/mods/public/maps/random/persian_highlands.js +++ b/binaries/data/mods/public/maps/random/persian_highlands.js @@ -243,8 +243,8 @@ for (var i = 0; i < numHills; ++i) floor(scaleByMapSize(6, 12)), floor(scaleByMapSize(4, 10)), avoidClasses(clPlayer, 7, clCP, 5, clHill, floor(scaleByMapSize(18, 25))), - randInt(mapSize), - randInt(mapSize), + randIntExclusive(0, mapSize), + randIntExclusive(0, mapSize), tCliff, clHill, 14 @@ -395,7 +395,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, avoidClasses(clForest, 0, clPlayer, 20, clHill, 1, clFood, 10, clCP, 2), - randInt(1, 4) * numPlayers + 2, 50 + randIntInclusive(1, 4) * numPlayers + 2, 50 ); // create camels diff --git a/binaries/data/mods/public/maps/random/phoenician_levant.js b/binaries/data/mods/public/maps/random/phoenician_levant.js index 788577d990..9b4d7d9294 100644 --- a/binaries/data/mods/public/maps/random/phoenician_levant.js +++ b/binaries/data/mods/public/maps/random/phoenician_levant.js @@ -443,7 +443,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, avoidClasses(clWater, 3, clForest, 0, clPlayer, 15, clHill, 1, clFood, 7), - randInt(1, 4) * numPlayers + 2, 50 + randIntInclusive(1, 4) * numPlayers + 2, 50 ); RMS.SetProgress(90); diff --git a/binaries/data/mods/public/maps/random/pyrenean_sierra.js b/binaries/data/mods/public/maps/random/pyrenean_sierra.js index 9e84068f30..2dc9bea0c8 100644 --- a/binaries/data/mods/public/maps/random/pyrenean_sierra.js +++ b/binaries/data/mods/public/maps/random/pyrenean_sierra.js @@ -745,7 +745,7 @@ createObjectGroups(group, 0, avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, log("Creating berry bush..."); group = new SimpleGroup( [new SimpleObject(oBerryBush, 5,7, 0,4)],true, clFood ); -createObjectGroups(group, 0, avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clPyrenneans, 1, clFood, 10), randInt(1, 4) * numPlayers + 2, 50 ); +createObjectGroups(group, 0, avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clPyrenneans, 1, clFood, 10), randIntInclusive(1, 4) * numPlayers + 2, 50); log("Creating fish..."); group = new SimpleGroup( [new SimpleObject(oFish, 2,3, 0,2)], true, clFood ); diff --git a/binaries/data/mods/public/maps/random/rhine_marshlands.js b/binaries/data/mods/public/maps/random/rhine_marshlands.js index a44194fb14..2c221b575c 100644 --- a/binaries/data/mods/public/maps/random/rhine_marshlands.js +++ b/binaries/data/mods/public/maps/random/rhine_marshlands.js @@ -381,7 +381,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10), - randInt(1, 4) * numPlayers + 2, 50 + randIntInclusive(1, 4) * numPlayers + 2, 50 ); RMS.SetProgress(80); diff --git a/binaries/data/mods/public/maps/random/rmgen/library.js b/binaries/data/mods/public/maps/random/rmgen/library.js index 3de375b200..73fa720936 100644 --- a/binaries/data/mods/public/maps/random/rmgen/library.js +++ b/binaries/data/mods/public/maps/random/rmgen/library.js @@ -134,8 +134,8 @@ function randomizePlacerCoordinates(placer, halfMapSize) else { // Rectangular coordinates - placer.x = randInt(g_Map.size); - placer.z = randInt(g_Map.size); + placer.x = randIntExclusive(0, g_Map.size); + placer.z = randIntExclusive(0, g_Map.size); } } diff --git a/binaries/data/mods/public/maps/random/rmgen/misc.js b/binaries/data/mods/public/maps/random/rmgen/misc.js index 0fc7f70e4a..16f215c220 100644 --- a/binaries/data/mods/public/maps/random/rmgen/misc.js +++ b/binaries/data/mods/public/maps/random/rmgen/misc.js @@ -637,9 +637,7 @@ function createMountain(maxHeight, minRadius, maxRadius, numCircles, constraint, var [cx, cz] = pickRandom(edges); if (queueEmpty) - { - var radius = randInt(minRadius, maxRadius); - } + var radius = randIntInclusive(minRadius, maxRadius); else { var radius = q.pop(); @@ -787,7 +785,7 @@ function createMountain(maxHeight, minRadius, maxRadius, numCircles, constraint, dz = iz - cz; distance2 = dx * dx + dz * dz; - var newHeight = round((Math.sin(PI*(2*((radius - sqrt(distance2))/radius)/3 - 1/6)) + 0.5) * 2 / 3 *clumpHeight) + randInt(0,2); + var newHeight = Math.round((Math.sin(PI * (2 * ((radius - Math.sqrt(distance2)) / radius) / 3 - 1/6)) + 0.5) * 2/3 * clumpHeight) + randIntInclusive(0, 2); if (dx * dx + dz * dz <= radius2) { diff --git a/binaries/data/mods/public/maps/random/rmgen/placer.js b/binaries/data/mods/public/maps/random/rmgen/placer.js index 9100670e1d..efd6727680 100644 --- a/binaries/data/mods/public/maps/random/rmgen/placer.js +++ b/binaries/data/mods/public/maps/random/rmgen/placer.js @@ -158,7 +158,7 @@ ChainPlacer.prototype.place = function(constraint) { var [cx, cz] = pickRandom(edges); if (queueEmpty) - var radius = randInt(this.minRadius, this.maxRadius); + var radius = randIntInclusive(this.minRadius, this.maxRadius); else { var radius = this.q.pop(); @@ -344,11 +344,9 @@ function SimpleObject(type, minCount, maxCount, minDistance, maxDistance, minAng SimpleObject.prototype.place = function(cx, cz, player, avoidSelf, constraint, maxFailCount = 20) { var failCount = 0; - var count = randInt(this.minCount, this.maxCount); var resultObjs = []; - for (var i=0; i < count; i++) - { + for (var i = 0; i < randIntInclusive(this.minCount, this.maxCount); ++i) while(true) { var distance = randFloat(this.minDistance, this.maxDistance); @@ -395,7 +393,6 @@ SimpleObject.prototype.place = function(cx, cz, player, avoidSelf, constraint, m return undefined; } } - } return resultObjs; }; @@ -435,11 +432,9 @@ function RandomObject(types, minCount, maxCount, minDistance, maxDistance, minAn RandomObject.prototype.place = function(cx, cz, player, avoidSelf, constraint, maxFailCount = 20) { var failCount = 0; - var count = randInt(this.minCount, this.maxCount); var resultObjs = []; - for (var i=0; i < count; i++) - { + for (var i = 0; i < randIntInclusive(this.minCount, this.maxCount); ++i) while(true) { var distance = randFloat(this.minDistance, this.maxDistance); @@ -486,7 +481,6 @@ RandomObject.prototype.place = function(cx, cz, player, avoidSelf, constraint, m return undefined; } } - } return resultObjs; }; diff --git a/binaries/data/mods/public/maps/random/rmgen/randombiome.js b/binaries/data/mods/public/maps/random/rmgen/randombiome.js index 9a2b364bd7..496135a933 100644 --- a/binaries/data/mods/public/maps/random/rmgen/randombiome.js +++ b/binaries/data/mods/public/maps/random/rmgen/randombiome.js @@ -62,7 +62,7 @@ function randomizeBiome(avoid = []) { let biomeIndex; do - biomeIndex = randInt(1, 8); + biomeIndex = randIntInclusive(1, 8); while (avoid.indexOf(biomeIndex) != -1); setBiome(biomeIndex); @@ -142,13 +142,13 @@ function setBiome(biomeIndex) "metalLarge": "gaia/geology_metal_temperate_slabs" }; - var random_trees = randInt(3); - if (random_trees == 0) + var random_trees = randIntInclusive(1, 3); + if (random_trees == 1) { g_Gaia.tree1 = "gaia/flora_tree_oak"; g_Gaia.tree2 = "gaia/flora_tree_oak_large"; } - else if (random_trees == 1) + else if (random_trees == 2) { g_Gaia.tree1 = "gaia/flora_tree_poplar"; g_Gaia.tree2 = "gaia/flora_tree_poplar"; @@ -159,13 +159,13 @@ function setBiome(biomeIndex) g_Gaia.tree2 = "gaia/flora_tree_euro_beech"; } g_Gaia.tree3 = "gaia/flora_tree_apple"; - random_trees = randInt(3); - if (random_trees == 0) + random_trees = randIntInclusive(1, 3); + if (random_trees == 1) { g_Gaia.tree4 = "gaia/flora_tree_pine"; g_Gaia.tree5 = "gaia/flora_tree_aleppo_pine"; } - else if (random_trees == 1) + else if (random_trees == 2) { g_Gaia.tree4 = "gaia/flora_tree_pine"; g_Gaia.tree5 = "gaia/flora_tree_pine"; @@ -439,13 +439,13 @@ function setBiome(biomeIndex) "metalLarge": "gaia/geology_metal_mediterranean_slabs" }; - var random_trees = randInt(3); - if (random_trees == 0) + var random_trees = randIntInclusive(1, 3); + if (random_trees == 1) { g_Gaia.tree1 = "gaia/flora_tree_cretan_date_palm_short"; g_Gaia.tree2 = "gaia/flora_tree_cretan_date_palm_tall"; } - else if (random_trees == 1) + else if (random_trees == 2) { g_Gaia.tree1 = "gaia/flora_tree_carob"; g_Gaia.tree2 = "gaia/flora_tree_carob"; diff --git a/binaries/data/mods/public/maps/random/rmgen/utilityfunctions.js b/binaries/data/mods/public/maps/random/rmgen/utilityfunctions.js index ffd145ce21..a1f3e019d4 100644 --- a/binaries/data/mods/public/maps/random/rmgen/utilityfunctions.js +++ b/binaries/data/mods/public/maps/random/rmgen/utilityfunctions.js @@ -69,8 +69,8 @@ function createMountains(terrain, constraint, tileclass, count, maxHeight, minRa maxRadius, numCircles, constraint, - randInt(mapSize), - randInt(mapSize), + randIntExclusive(0, mapSize), + randIntExclusive(0, mapSize), terrain, tileclass, 14 diff --git a/binaries/data/mods/public/maps/random/rmgen/wall_builder.js b/binaries/data/mods/public/maps/random/rmgen/wall_builder.js index 6870759edc..a8796aab95 100644 --- a/binaries/data/mods/public/maps/random/rmgen/wall_builder.js +++ b/binaries/data/mods/public/maps/random/rmgen/wall_builder.js @@ -861,7 +861,7 @@ function placeIrregularPolygonalWall(centerX, centerY, radius, cornerWallElement style = style || "palisades"; playerId = playerId || 0; orientation = orientation || 0; - numCorners = numCorners || randInt(5, 7); + numCorners = numCorners || randIntInclusive(5, 7); irregularity = irregularity || 0.5; skipFirstWall = skipFirstWall || false; diff --git a/binaries/data/mods/public/maps/random/rmgen2/gaia.js b/binaries/data/mods/public/maps/random/rmgen2/gaia.js index f67e5905e1..577fb289ab 100644 --- a/binaries/data/mods/public/maps/random/rmgen2/gaia.js +++ b/binaries/data/mods/public/maps/random/rmgen2/gaia.js @@ -63,7 +63,7 @@ function addBluffs(constraint, size, deviation, fill) var bb = createBoundingBox(points, corners); // Get a random starting position for the baseline and the endline - var angle = randInt(4); + var angle = randIntInclusive(0, 3); var opAngle = angle - 2; if (angle < 2) opAngle = angle + 2; @@ -390,7 +390,7 @@ function addElevation(constraint, el) for (var i = 0; i < count; ++i) { - var elevation = el.minElevation + randInt(el.maxElevation - el.minElevation); + var elevation = randIntExclusive(el.minElevation, el.maxElevation); var smooth = Math.floor(elevation / el.steepness); var offset = getRandomDeviation(size, el.deviation); @@ -592,7 +592,7 @@ function addPlateaus(constraint, size, deviation, fill) { var placer = new ChainPlacer(3, 15, 1, 0.5); var terrainPainter = new LayeredPainter([plateauTile, plateauTile], [3]); - var hillElevation = 4 + randInt(15); + var hillElevation = randIntInclusive(4, 18); var elevationPainter = new SmoothElevationPainter(ELEVATION_MODIFY, hillElevation, hillElevation - 2); createAreas( @@ -1263,7 +1263,7 @@ function nextToFeature(bb, x, z) function getRandomDeviation(base, deviation) { deviation = Math.min(base, deviation); - deviation = base + randInt(20 * deviation) / 10 - deviation; + deviation = base + randIntExclusive(0, 20 * deviation) / 10 - deviation; return deviation.toFixed(2); } diff --git a/binaries/data/mods/public/maps/random/sahel.js b/binaries/data/mods/public/maps/random/sahel.js index 940ef7299c..2c41a88676 100644 --- a/binaries/data/mods/public/maps/random/sahel.js +++ b/binaries/data/mods/public/maps/random/sahel.js @@ -213,8 +213,8 @@ log("Creating stone mines..."); // create stone mines for (var i = 0; i < scaleByMapSize(12,30); ++i) { - var mX = randInt(mapSize); - var mZ = randInt(mapSize); + var mX = randIntExclusive(0, mapSize); + var mZ = randIntExclusive(0, mapSize); if (playerConstraint.allows(mX, mZ) && minesConstraint.allows(mX, mZ) && waterConstraint.allows(mX, mZ)) { createStoneMineFormation(mX, mZ, tDirt4); @@ -309,7 +309,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, avoidClasses(clWater, 3, clPlayer, 20, clFood, 12, clRock, 7, clMetal, 6), - randInt(1, 4) * numPlayers + 2, 50 + randIntInclusive(1, 4) * numPlayers + 2, 50 ); RMS.SetProgress(85); diff --git a/binaries/data/mods/public/maps/random/sahel_watering_holes.js b/binaries/data/mods/public/maps/random/sahel_watering_holes.js index da893b5bf3..0991f7f1af 100644 --- a/binaries/data/mods/public/maps/random/sahel_watering_holes.js +++ b/binaries/data/mods/public/maps/random/sahel_watering_holes.js @@ -476,7 +476,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10), - randInt(1, 4) * numPlayers + 2, 50 + randIntInclusive(1, 4) * numPlayers + 2, 50 ); RMS.SetProgress(85);