From dd9a8706f921fd1afce180f686f8bc167209fbeb Mon Sep 17 00:00:00 2001 From: elexis Date: Sat, 3 Jun 2017 00:28:34 +0000 Subject: [PATCH] Complete the move of random number helper functions from the random map library (0e0ed94926, refs #6) to globalscripts. Differential Revision: https://code.wildfiregames.com/D596 Patch By: bb 3c56638e8b introduced pickRandom and its petra chat application, 08fbf223f6 used the randFloat function more often, introduced randBool and randIntInclusive/Exclusive to replace randInt (whose behavior and argument meaning depended on the number of arguments) calls in the GUI and simulation, ddfc985586 changed randInt to pickRandom for random maps, da2b89583a introduced randBool with a probability and replaced deprecated randInt calls for random maps, 175cded64a replaced randInt calls with randIntInclusive/Exclusive for random maps except the Unknown, a227a7f45b removed optional arguments of randFloat, this commit replaces the remaining occurances in the Unknown maps, thus fixes #4326 (old patch from refs #3102). This was SVN commit r19721. --- .../mods/public/maps/random/rmgen/random.js | 28 ------ .../data/mods/public/maps/random/unknown.js | 92 +++++++++--------- .../mods/public/maps/random/unknown_land.js | 68 ++++++------- .../mods/public/maps/random/unknown_nomad.js | 96 +++++++++---------- .../data/mods/public/maps/random/wild_lake.js | 6 +- 5 files changed, 131 insertions(+), 159 deletions(-) delete mode 100644 binaries/data/mods/public/maps/random/rmgen/random.js diff --git a/binaries/data/mods/public/maps/random/rmgen/random.js b/binaries/data/mods/public/maps/random/rmgen/random.js deleted file mode 100644 index b22ddfacfc..0000000000 --- a/binaries/data/mods/public/maps/random/rmgen/random.js +++ /dev/null @@ -1,28 +0,0 @@ -// TODO: rename/change these functions, so the bounds are more clear - -/* - * Return a random integer using Math.random library - * - * If one parameter given, it's maxval, and the returned integer is in the interval [0, maxval) - * If two parameters are given, they are minval and maxval, and the returned integer is in the interval [minval, maxval] - */ -function randInt() -{ - if (arguments.length == 1) - { - var maxVal = arguments[0]; - return Math.floor(Math.random() * maxVal); - } - else if (arguments.length == 2) - { - var minVal = arguments[0]; - var maxVal = arguments[1]; - - return minVal + randInt(maxVal - minVal + 1); - } - else - { - error("randInt: invalid number of arguments: "+arguments.length); - return undefined; - } -} diff --git a/binaries/data/mods/public/maps/random/unknown.js b/binaries/data/mods/public/maps/random/unknown.js index f41160d581..02e45e891f 100644 --- a/binaries/data/mods/public/maps/random/unknown.js +++ b/binaries/data/mods/public/maps/random/unknown.js @@ -82,7 +82,7 @@ for (var ix = 0; ix < mapSize; ix++) } var iberianTowers = false; -var md = randInt(1,13); +var md = randIntInclusive(1,13); var needsAdditionalWood = false; //***************************************************************************************************************************** if (md == 1) //archipelago and island @@ -112,7 +112,7 @@ if (md == 1) //archipelago and island playerZ[i] = 0.5 + 0.35*sin(playerAngle[i]); } - var mdd1 = randInt(1,3); + var mdd1 = randIntInclusive(1,3); for (var i = 0; i < numPlayers; ++i) { @@ -153,7 +153,7 @@ if (md == 1) //archipelago and island placer, [terrainPainter, elevationPainter, paintClass(clLand)], null, - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); // create shore jaggedness @@ -185,7 +185,7 @@ if (md == 1) //archipelago and island placer, [terrainPainter, elevationPainter, paintClass(clLand)], avoidClasses(clLand, 3, clPlayer, 3), - scaleByMapSize(6, 10)*randInt(8,14) + scaleByMapSize(6, 10)*randIntInclusive(8,14) ); // create small islands @@ -200,7 +200,7 @@ if (md == 1) //archipelago and island placer, [terrainPainter, elevationPainter, paintClass(clLand)], avoidClasses(clLand, 3, clPlayer, 3), - scaleByMapSize(2, 6)*randInt(6,15), 25 + scaleByMapSize(2, 6)*randIntInclusive(6,15), 25 ); } else if (mdd1 == 3) // tight islands @@ -216,8 +216,8 @@ if (md == 1) //archipelago and island createAreas( placer, [terrainPainter, elevationPainter, paintClass(clLand)], - avoidClasses(clLand, randInt(8, 16), clPlayer, 3), - scaleByMapSize(2, 5)*randInt(8,14) + avoidClasses(clLand, randIntInclusive(8, 16), clPlayer, 3), + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } @@ -277,7 +277,7 @@ else if (md == 2) //continent var clPeninsulaSteam = createTileClass(); - if (randInt(1,3)==1) // peninsula + if (randBool(1/3)) // peninsula { var angle = randFloat(0, TWO_PI); @@ -356,7 +356,7 @@ playerIDs = primeSortPlayers(sortPlayers(playerIDs)); var playerPos = new Array(numPlayers); var iop = 0; - var mdd1 = randInt(1,2); + var mdd1 = randIntInclusive(1,2); if (mdd1 == 1) //vertical { for (var i = 0; i < numPlayers; i++) @@ -508,16 +508,16 @@ playerIDs = primeSortPlayers(sortPlayers(playerIDs)); } } - if (!randInt(3)) + if (randBool(1/3)) { // linked if (mdd1 == 1) //vertical { - var placer = new PathPlacer(1, fractionToTiles(0.5), fractionToTiles(0.99), fractionToTiles(0.5), scaleByMapSize(randInt(16,24),randInt(100,140)), 0.5, 3*(scaleByMapSize(1,4)), 0.1, 0.01); + var placer = new PathPlacer(1, fractionToTiles(0.5), fractionToTiles(0.99), fractionToTiles(0.5), scaleByMapSize(randIntInclusive(16,24),randIntInclusive(100,140)), 0.5, 3*(scaleByMapSize(1,4)), 0.1, 0.01); } else { - var placer = new PathPlacer(fractionToTiles(0.5), 1, fractionToTiles(0.5), fractionToTiles(0.99), scaleByMapSize(randInt(16,24),randInt(100,140)), 0.5, 3*(scaleByMapSize(1,4)), 0.1, 0.01); + var placer = new PathPlacer(fractionToTiles(0.5), 1, fractionToTiles(0.5), fractionToTiles(0.99), scaleByMapSize(randIntInclusive(16,24),randIntInclusive(100,140)), 0.5, 3*(scaleByMapSize(1,4)), 0.1, 0.01); } var terrainPainter = new LayeredPainter( [tMainTerrain, tMainTerrain, tMainTerrain], // terrains @@ -530,12 +530,12 @@ playerIDs = primeSortPlayers(sortPlayers(playerIDs)); ); createArea(placer, [terrainPainter, elevationPainter, unPaintClass(clWater)], null); } - var mdd2 = randInt(1,7); + var mdd2 = randIntInclusive(1,7); if (mdd2 == 1) { // create islands log("Creating islands..."); - placer = new ClumpPlacer(randInt(scaleByMapSize(8,15),scaleByMapSize(15,23))*randInt(scaleByMapSize(8,15),scaleByMapSize(15,23)), 0.80, 0.1, randFloat(0.0, 0.2)); + placer = new ClumpPlacer(randIntInclusive(scaleByMapSize(8,15),scaleByMapSize(15,23))*randIntInclusive(scaleByMapSize(8,15),scaleByMapSize(15,23)), 0.80, 0.1, randFloat(0.0, 0.2)); terrainPainter = new LayeredPainter( [tMainTerrain, tMainTerrain], // terrains [2] // widths @@ -545,14 +545,14 @@ playerIDs = primeSortPlayers(sortPlayers(playerIDs)); placer, [terrainPainter, elevationPainter, paintClass(clLand)], avoidClasses(clLand, 3, clPlayer, 3), - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } else if (mdd2 == 2) { // create extentions log("Creating extentions..."); - placer = new ClumpPlacer(randInt(scaleByMapSize(13,24),scaleByMapSize(24,45))*randInt(scaleByMapSize(13,24),scaleByMapSize(24,45)), 0.80, 0.1, 10); + placer = new ClumpPlacer(randIntInclusive(scaleByMapSize(13,24),scaleByMapSize(24,45))*randIntInclusive(scaleByMapSize(13,24),scaleByMapSize(24,45)), 0.80, 0.1, 10); terrainPainter = new LayeredPainter( [tMainTerrain, tMainTerrain], // terrains [2] // widths @@ -562,7 +562,7 @@ playerIDs = primeSortPlayers(sortPlayers(playerIDs)); placer, [terrainPainter, elevationPainter, paintClass(clLand)], null, - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } } @@ -595,7 +595,7 @@ else if (md == 4) //central river var playerAngle = new Array(numPlayers); var playerPos = new Array(numPlayers); var iop = 0; - var mdd1 = randInt(1,2); + var mdd1 = randIntInclusive(1,2); if (mdd1 == 1) //horizontal { for (var i = 0; i < numPlayers; i++) @@ -682,13 +682,13 @@ else if (md == 4) //central river var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -4, 2); createArea(placer, [painter, elevationPainter], avoidClasses(clPlayer, 8)); - var mdd2 = randInt(1,2); + var mdd2 = randIntInclusive(1,2); if (mdd2 == 1) { // create the shallows of the main river log("Creating the shallows of the main river"); - for (var i = 0; i <= randInt(1, scaleByMapSize(4,8)); i++) + for (var i = 0; i <= randIntInclusive(1, scaleByMapSize(4,8)); i++) { var cLocation = randFloat(0.15,0.85); if (mdd1 == 1) @@ -698,7 +698,7 @@ else if (md == 4) //central river } } - if (randInt(1,2) == 1) + if (randBool()) { for (var i = 0; i < numPlayers; i++) { @@ -715,10 +715,10 @@ else if (md == 4) //central river // create tributaries log("Creating tributaries"); - for (var i = 0; i <= randInt(8, (scaleByMapSize(12,20))); i++) + for (var i = 0; i <= randIntInclusive(8, (scaleByMapSize(12,20))); i++) { var cLocation = randFloat(0.05,0.95); - var tang = randFloat(PI*0.2, PI*0.8)*((randInt(2)-0.5)*2); + var tang = randFloat(PI*0.2, PI*0.8)*((randIntInclusive(0, 1)-0.5)*2); if (tang > 0) { var cDistance = 0.05; @@ -812,7 +812,7 @@ else if (md == 5) //rivers and lake setHeight(ix, iz, 3); } } - var mdd1 = randInt(1,2); + var mdd1 = randIntInclusive(1,2); if (mdd1 == 1) //lake { var fx = fractionToTiles(0.5); @@ -863,7 +863,7 @@ else if (md == 5) //rivers and lake ); } - if (randInt(1,2) == 1) //rivers + if (randBool()) // rivers { //create rivers log ("Creating rivers..."); @@ -906,7 +906,7 @@ else if (md == 5) //rivers and lake createArea(placer, [terrainPainter, elevationPainter, paintClass(clWater)], null); } - if ((randInt(1,3) == 1)&&(mdd1 == 1))//island + if (randBool(1/3) &&(mdd1 == 1))//island { var placer = new ClumpPlacer(mapArea * 0.006 * lSize, 0.7, 0.1, 10, ix, iz); var terrainPainter = new LayeredPainter( @@ -935,7 +935,7 @@ else if (md == 6) //edge seas } } - var mdd1 = randInt(1,2); + var mdd1 = randIntInclusive(1,2); // randomize player order var playerIDs = []; @@ -976,7 +976,7 @@ else if (md == 6) //edge seas addToClass(ix, iz-5, clPlayer); } - var mdd2 = randInt(1,3); + var mdd2 = randIntInclusive(1,3); var fadedistance = 7; if (mdd1 == 1) @@ -1141,12 +1141,12 @@ else if (md == 6) //edge seas scaleByMapSize(12, 130) * 2, 150 ); - var mdd3 = randInt(1,3); + var mdd3 = randIntInclusive(1,3); if (mdd3 == 1) { // create islands log("Creating islands..."); - placer = new ClumpPlacer(randInt(scaleByMapSize(8,15),scaleByMapSize(15,23))*randInt(scaleByMapSize(8,15),scaleByMapSize(15,23)), 0.80, 0.1, randFloat(0.0, 0.2)); + placer = new ClumpPlacer(randIntInclusive(scaleByMapSize(8,15),scaleByMapSize(15,23))*randIntInclusive(scaleByMapSize(8,15),scaleByMapSize(15,23)), 0.80, 0.1, randFloat(0.0, 0.2)); terrainPainter = new LayeredPainter( [tMainTerrain, tMainTerrain], // terrains [2] // widths @@ -1156,14 +1156,14 @@ else if (md == 6) //edge seas placer, [terrainPainter, elevationPainter, paintClass(clLand)], avoidClasses(clLand, 3, clPlayer, 3), - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } else if (mdd3 == 2) { // create extentions log("Creating extentions..."); - placer = new ClumpPlacer(randInt(scaleByMapSize(13,24),scaleByMapSize(24,45))*randInt(scaleByMapSize(13,24),scaleByMapSize(24,45)), 0.80, 0.1, 10); + placer = new ClumpPlacer(randIntInclusive(scaleByMapSize(13,24),scaleByMapSize(24,45))*randIntInclusive(scaleByMapSize(13,24),scaleByMapSize(24,45)), 0.80, 0.1, 10); terrainPainter = new LayeredPainter( [tMainTerrain, tMainTerrain], // terrains [2] // widths @@ -1173,7 +1173,7 @@ else if (md == 6) //edge seas placer, [terrainPainter, elevationPainter, paintClass(clLand)], null, - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } } @@ -1341,7 +1341,7 @@ else if (md == 8) //lakes [1, 3] // widths ); elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -5, 5); - if (randInt(1,2) == 1) + if (randBool()) { createAreas( placer, @@ -1422,7 +1422,7 @@ else if (md == 9) //passes var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 2); createArea(placer, [painter, elevationPainter], null); } - var mdd1 = randInt (1,3); + var mdd1 = randIntInclusive(1,3); if (mdd1 <= 2) { var fx = fractionToTiles(0.5); @@ -1745,7 +1745,7 @@ createAreas( placer, painter, [avoidClasses(clWater, 2, clPlayer, 10), stayClasses(clLand, 3)], - randInt(0,scaleByMapSize(200, 400)) + randIntInclusive(0,scaleByMapSize(200, 400)) ); // create hills @@ -1759,8 +1759,8 @@ elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 18, 2); createAreas( placer, [terrainPainter, elevationPainter, paintClass(clHill)], - [avoidClasses(clPlayer, 20, clHill, randInt(6, 18)), stayClasses(clLand, 0)], - randInt(0, scaleByMapSize(4, 8))*randInt(1, scaleByMapSize(4, 9)) + [avoidClasses(clPlayer, 20, clHill, randIntInclusive(6, 18)), stayClasses(clLand, 0)], + randIntInclusive(0, scaleByMapSize(4, 8))*randIntInclusive(1, scaleByMapSize(4, 9)) ); var multiplier = sqrt(randFloat(0.5,1.2)*randFloat(0.5,1.2)); @@ -1810,7 +1810,7 @@ for (var i = 0; i < types.length; ++i) createAreas( placer, [painter, paintClass(clForest)], - [avoidClasses(clPlayer, 20, clForest, randInt(5, 15), clHill, 0), stayClasses(clLand, 4)], + [avoidClasses(clPlayer, 20, clForest, randIntInclusive(5, 15), clHill, 0), stayClasses(clLand, 4)], num ); } @@ -1859,14 +1859,14 @@ log("Creating stone mines..."); group = new SimpleGroup([new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)], true, clRock); createObjectGroups(group, 0, [avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clHill, 1), stayClasses(clLand, 4)], - randInt(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 + randIntInclusive(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 ); // create small stone quarries group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock); createObjectGroups(group, 0, [avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clHill, 1), stayClasses(clLand, 4)], - randInt(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 + randIntInclusive(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 ); log("Creating metal mines..."); @@ -1874,7 +1874,7 @@ log("Creating metal mines..."); group = new SimpleGroup([new SimpleObject(oMetalLarge, 1,1, 0,4)], true, clMetal); createObjectGroups(group, 0, [avoidClasses(clForest, 1, clPlayer, 20, clMetal, 10, clRock, 5, clHill, 1), stayClasses(clLand, 4)], - randInt(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 + randIntInclusive(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 ); RMS.SetProgress(65); @@ -1914,7 +1914,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, [avoidClasses(clWater, 0, clForest, 0, clPlayer, 20, clHill, 1, clFood, 20), stayClasses(clLand, 4)], - randInt(numPlayers+3, 5*numPlayers+4), 50 + randIntInclusive(numPlayers+3, 5*numPlayers+4), 50 ); // create berry bush @@ -1925,7 +1925,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, [avoidClasses(clWater, 0, clForest, 0, clPlayer, 20, clHill, 1, clFood, 20), stayClasses(clLand, 4)], - randInt(1, 4) * numPlayers + 2, 50 + randIntInclusive(1, 4) * numPlayers + 2, 50 ); RMS.SetProgress(75); @@ -1938,7 +1938,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, [avoidClasses(clWater, 0, clForest, 0, clPlayer, 20, clHill, 1, clFood, 20), stayClasses(clLand, 4)], - randInt(numPlayers+3, 5*numPlayers+4), 50 + randIntInclusive(numPlayers+3, 5*numPlayers+4), 50 ); // create fish @@ -1949,7 +1949,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, avoidClasses(clLand, 5, clForest, 0, clPlayer, 0, clHill, 0, clFood, 20), - randInt(15, 40) * numPlayers, 60 + randIntInclusive(15, 40) * numPlayers, 60 ); RMS.SetProgress(85); diff --git a/binaries/data/mods/public/maps/random/unknown_land.js b/binaries/data/mods/public/maps/random/unknown_land.js index ddbfd07c1e..3a1bfb5620 100644 --- a/binaries/data/mods/public/maps/random/unknown_land.js +++ b/binaries/data/mods/public/maps/random/unknown_land.js @@ -81,7 +81,7 @@ for (var ix = 0; ix < mapSize; ix++) } } -var md = randInt(2,13); +var md = randIntInclusive(2,13); var needsAdditionalWood = false; //***************************************************************************************************************************** if (md == 2) //continent @@ -146,7 +146,7 @@ if (md == 2) //continent var clPeninsulaSteam = createTileClass(); - if (randInt(1,3)==1) // peninsula + if (randBool(1/3)) // peninsula { var angle = randFloat(0, TWO_PI); @@ -195,7 +195,7 @@ playerIDs = primeSortPlayers(sortPlayers(playerIDs)); var playerPos = new Array(numPlayers); var iop = 0; - var mdd1 = randInt(1,2); + var mdd1 = randIntInclusive(1,2); if (mdd1 == 1) //vertical { for (var i = 0; i < numPlayers; i++) @@ -351,11 +351,11 @@ playerIDs = primeSortPlayers(sortPlayers(playerIDs)); // linked if (mdd1 == 1) //vertical { - var placer = new PathPlacer(1, fractionToTiles(0.5), fractionToTiles(0.99), fractionToTiles(0.5), scaleByMapSize(randInt(16,24),randInt(100,140)), 0.5, 3*(scaleByMapSize(1,4)), 0.1, 0.01); + var placer = new PathPlacer(1, fractionToTiles(0.5), fractionToTiles(0.99), fractionToTiles(0.5), scaleByMapSize(randIntInclusive(16,24),randIntInclusive(100,140)), 0.5, 3*(scaleByMapSize(1,4)), 0.1, 0.01); } else { - var placer = new PathPlacer(fractionToTiles(0.5), 1, fractionToTiles(0.5), fractionToTiles(0.99), scaleByMapSize(randInt(16,24),randInt(100,140)), 0.5, 3*(scaleByMapSize(1,4)), 0.1, 0.01); + var placer = new PathPlacer(fractionToTiles(0.5), 1, fractionToTiles(0.5), fractionToTiles(0.99), scaleByMapSize(randIntInclusive(16,24),randIntInclusive(100,140)), 0.5, 3*(scaleByMapSize(1,4)), 0.1, 0.01); } var terrainPainter = new LayeredPainter( [tMainTerrain, tMainTerrain, tMainTerrain], // terrains @@ -368,7 +368,7 @@ playerIDs = primeSortPlayers(sortPlayers(playerIDs)); ); createArea(placer, [terrainPainter, elevationPainter, unPaintClass(clWater)], null); - var mdd2 = randInt(1,7); + var mdd2 = randIntInclusive(1,7); if (mdd2 == 1) { // create islands @@ -383,14 +383,14 @@ playerIDs = primeSortPlayers(sortPlayers(playerIDs)); placer, [terrainPainter, elevationPainter, paintClass(clLand)], avoidClasses(clLand, 3, clPlayer, 3), - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } else if (mdd2 == 2) { // create extentions log("Creating extentions..."); - placer = new ClumpPlacer(randInt(scaleByMapSize(13,24),scaleByMapSize(24,45))*randInt(scaleByMapSize(13,24),scaleByMapSize(24,45)), 0.80, 0.1, 10); + placer = new ClumpPlacer(randIntInclusive(scaleByMapSize(13,24),scaleByMapSize(24,45))*randIntInclusive(scaleByMapSize(13,24),scaleByMapSize(24,45)), 0.80, 0.1, 10); terrainPainter = new LayeredPainter( [tMainTerrain, tMainTerrain], // terrains [2] // widths @@ -400,7 +400,7 @@ playerIDs = primeSortPlayers(sortPlayers(playerIDs)); placer, [terrainPainter, elevationPainter, paintClass(clLand)], null, - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } } @@ -433,7 +433,7 @@ else if (md == 4) //central river var playerAngle = new Array(numPlayers); var playerPos = new Array(numPlayers); var iop = 0; - var mdd1 = randInt(1,2); + var mdd1 = randIntInclusive(1,2); if (mdd1 == 1) //horizontal { for (var i = 0; i < numPlayers; i++) @@ -523,7 +523,7 @@ else if (md == 4) //central river // create the shallows of the main river log("Creating the shallows of the main river"); - for (var i = 0; i <= randInt(1, scaleByMapSize(4,8)); i++) + for (var i = 0; i <= randIntInclusive(1, scaleByMapSize(4,8)); i++) { var cLocation = randFloat(0.15,0.85); if (mdd1 == 1) @@ -532,7 +532,7 @@ else if (md == 4) //central river passageMaker(floor(fractionToTiles(0.35)), floor(fractionToTiles(cLocation)), floor(fractionToTiles(0.65)), floor(fractionToTiles(cLocation)), scaleByMapSize(4,8), -2, -2, 2, clShallow, undefined, -4); } - if (randInt(1,2) == 1) + if (randBool()) { for (var i = 0; i < numPlayers; i++) { @@ -549,10 +549,10 @@ else if (md == 4) //central river // create tributaries log("Creating tributaries"); - for (var i = 0; i <= randInt(8, (scaleByMapSize(12,20))); i++) + for (var i = 0; i <= randIntInclusive(8, (scaleByMapSize(12,20))); i++) { var cLocation = randFloat(0.05,0.95); - var tang = randFloat(PI*0.2, PI*0.8)*((randInt(2)-0.5)*2); + var tang = randFloat(PI*0.2, PI*0.8)*((randIntInclusive(2)-0.5)*2); if (tang > 0) { var cDistance = 0.05; @@ -646,7 +646,7 @@ else if (md == 5) //rivers and lake setHeight(ix, iz, 3); } } - var mdd1 = randInt(1,2); + var mdd1 = randIntInclusive(1,2); if (mdd1 == 1) //lake { var fx = fractionToTiles(0.5); @@ -685,7 +685,7 @@ else if (md == 5) //rivers and lake ); } - if ((randInt(1,3) == 1)&&(mdd1 == 1))//island + if (randBool(1/3) &&(mdd1 == 1))//island { var placer = new ClumpPlacer(mapArea * 0.006 * lSize, 0.7, 0.1, 10, ix, iz); var terrainPainter = new LayeredPainter( @@ -714,7 +714,7 @@ else if (md == 6) //edge seas } } - var mdd1 = randInt(1,2); + var mdd1 = randIntInclusive(1,2); // randomize player order var playerIDs = []; @@ -755,7 +755,7 @@ else if (md == 6) //edge seas addToClass(ix, iz-5, clPlayer); } - var mdd2 = randInt(1,3); + var mdd2 = randIntInclusive(1,3); var fadedistance = 7; if (mdd1 == 1) @@ -890,7 +890,7 @@ else if (md == 6) //edge seas scaleByMapSize(12, 130) * 2, 150 ); - var mdd3 = randInt(1,5); + var mdd3 = randIntInclusive(1,5); if (mdd3 == 1) { // create islands @@ -905,7 +905,7 @@ else if (md == 6) //edge seas placer, [terrainPainter, elevationPainter, paintClass(clLand)], avoidClasses(clLand, 3, clPlayer, 3), - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } else if (mdd3 == 2) @@ -922,7 +922,7 @@ else if (md == 6) //edge seas placer, [terrainPainter, elevationPainter, paintClass(clLand)], null, - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } } @@ -1104,7 +1104,7 @@ else if (md == 8) //lakes if (!lakeAreaLen) break; - chosenPoint = lakeAreas[randInt(lakeAreaLen)]; + chosenPoint = pickRandom(lakeAreas); placer = new ChainPlacer(1, floor(scaleByMapSize(4, 8)), floor(scaleByMapSize(40, 180)), 0.7, chosenPoint[0], chosenPoint[1]); terrainPainter = new LayeredPainter( @@ -1194,7 +1194,7 @@ else if (md == 9) //passes var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 2); createArea(placer, [painter, elevationPainter], null); } - var mdd1 = randInt (1,3); + var mdd1 = randIntInclusive (1,3); if (mdd1 <= 2) { var fx = fractionToTiles(0.5); @@ -1514,7 +1514,7 @@ createAreas( placer, painter, [avoidClasses(clWater, 2, clPlayer, 10), stayClasses(clLand, 3)], - randInt(0,scaleByMapSize(200, 400)) + randIntInclusive(0,scaleByMapSize(200, 400)) ); // create hills @@ -1528,8 +1528,8 @@ elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 18, 2); createAreas( placer, [terrainPainter, elevationPainter, paintClass(clHill)], - [avoidClasses(clPlayer, 20, clHill, randInt(6, 18)), stayClasses(clLand, 0)], - randInt(0, scaleByMapSize(4, 8))*randInt(1, scaleByMapSize(4, 9)) + [avoidClasses(clPlayer, 20, clHill, randIntInclusive(6, 18)), stayClasses(clLand, 0)], + randIntInclusive(0, scaleByMapSize(4, 8))*randIntInclusive(1, scaleByMapSize(4, 9)) ); var multiplier = sqrt(randFloat(0.5,1.2)*randFloat(0.5,1.2)); @@ -1577,7 +1577,7 @@ if (random_terrain != g_BiomeSavanna) createAreas( placer, [painter, paintClass(clForest)], - [avoidClasses(clPlayer, 20, clForest, randInt(5, 15), clHill, 0), stayClasses(clLand, 4)], + [avoidClasses(clPlayer, 20, clForest, randIntInclusive(5, 15), clHill, 0), stayClasses(clLand, 4)], num ); } @@ -1627,14 +1627,14 @@ log("Creating stone mines..."); group = new SimpleGroup([new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)], true, clRock); createObjectGroups(group, 0, [avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clHill, 1), stayClasses(clLand, 4)], - randInt(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 + randIntInclusive(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 ); // create small stone quarries group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock); createObjectGroups(group, 0, [avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clHill, 1), stayClasses(clLand, 4)], - randInt(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 + randIntInclusive(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 ); log("Creating metal mines..."); @@ -1642,7 +1642,7 @@ log("Creating metal mines..."); group = new SimpleGroup([new SimpleObject(oMetalLarge, 1,1, 0,4)], true, clMetal); createObjectGroups(group, 0, [avoidClasses(clForest, 1, clPlayer, 20, clMetal, 10, clRock, 5, clHill, 1), stayClasses(clLand, 4)], - randInt(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 + randIntInclusive(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 ); RMS.SetProgress(65); @@ -1682,7 +1682,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, [avoidClasses(clWater, 0, clForest, 0, clPlayer, 20, clHill, 1, clFood, 20), stayClasses(clLand, 4)], - randInt(numPlayers+3, 5*numPlayers+4), 50 + randIntInclusive(numPlayers+3, 5*numPlayers+4), 50 ); // create berry bush @@ -1693,7 +1693,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, [avoidClasses(clWater, 0, clForest, 0, clPlayer, 20, clHill, 1, clFood, 20), stayClasses(clLand, 4)], - randInt(1, 4) * numPlayers + 2, 50 + randIntInclusive(1, 4) * numPlayers + 2, 50 ); RMS.SetProgress(75); @@ -1706,7 +1706,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, [avoidClasses(clWater, 0, clForest, 0, clPlayer, 20, clHill, 1, clFood, 20), stayClasses(clLand, 4)], - randInt(numPlayers+3, 5*numPlayers+4), 50 + randIntInclusive(numPlayers+3, 5*numPlayers+4), 50 ); // create fish @@ -1717,7 +1717,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, avoidClasses(clLand, 5, clForest, 0, clPlayer, 0, clHill, 0, clFood, 20), - randInt(15, 40) * numPlayers, 60 + randIntInclusive(15, 40) * numPlayers, 60 ); RMS.SetProgress(85); diff --git a/binaries/data/mods/public/maps/random/unknown_nomad.js b/binaries/data/mods/public/maps/random/unknown_nomad.js index 2adda76eaf..8a745827e1 100644 --- a/binaries/data/mods/public/maps/random/unknown_nomad.js +++ b/binaries/data/mods/public/maps/random/unknown_nomad.js @@ -82,7 +82,7 @@ for (var ix = 0; ix < mapSize; ix++) } var startAngle = randFloat(0, TWO_PI); -var md = randInt(1,13); +var md = randIntInclusive(1,13); var needsAdditionalWood = false; //***************************************************************************************************************************** if (md == 1) //archipelago and island @@ -100,7 +100,7 @@ if (md == 1) //archipelago and island var radius = scaleByMapSize(17, 29); var hillSize = PI * radius * radius; - var mdd1 = randInt(1,3); + var mdd1 = randIntInclusive(1,3); if (mdd1 == 1) //archipelago { @@ -116,7 +116,7 @@ if (md == 1) //archipelago and island placer, [terrainPainter, elevationPainter, paintClass(clLand)], null, - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } else if (mdd1 == 2) //islands @@ -133,7 +133,7 @@ if (md == 1) //archipelago and island placer, [terrainPainter, elevationPainter, paintClass(clLand)], avoidClasses(clLand, 3, clPlayer, 3), - scaleByMapSize(6, 10)*randInt(8,14) + scaleByMapSize(6, 10)*randIntInclusive(8,14) ); } else if (mdd1 == 3) // tight islands @@ -149,8 +149,8 @@ if (md == 1) //archipelago and island createAreas( placer, [terrainPainter, elevationPainter, paintClass(clLand)], - avoidClasses(clLand, randInt(8, 16), clPlayer, 3), - scaleByMapSize(2, 5)*randInt(8,14) + avoidClasses(clLand, randIntInclusive(8, 16), clPlayer, 3), + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } @@ -184,7 +184,7 @@ else if (md == 2) //continent ); createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null); - if (randInt(1,4)==1) // peninsula + if (randBool(1/4)) // peninsula { var angle = randFloat(0, TWO_PI); @@ -206,12 +206,12 @@ else if (md == 2) //continent createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null); } - var mdd1 = randInt(1,3); + var mdd1 = randIntInclusive(1,3); if (mdd1 == 1) { // create islands log("Creating islands..."); - placer = new ClumpPlacer(randInt(scaleByMapSize(8,15),scaleByMapSize(15,23))*randInt(scaleByMapSize(8,15),scaleByMapSize(15,23)), 0.80, 0.1, randFloat(0.0, 0.2)); + placer = new ClumpPlacer(randIntInclusive(scaleByMapSize(8,15),scaleByMapSize(15,23))*randIntInclusive(scaleByMapSize(8,15),scaleByMapSize(15,23)), 0.80, 0.1, randFloat(0.0, 0.2)); terrainPainter = new LayeredPainter( [tGrass, tGrass], // terrains [2] // widths @@ -221,14 +221,14 @@ else if (md == 2) //continent placer, [terrainPainter, elevationPainter, paintClass(clLand)], avoidClasses(clLand, 3, clPlayer, 3), - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } else if (mdd1 == 2) { // create extentions log("Creating extentions..."); - placer = new ClumpPlacer(randInt(scaleByMapSize(13,24),scaleByMapSize(24,45))*randInt(scaleByMapSize(13,24),scaleByMapSize(24,45)), 0.80, 0.1, 10); + placer = new ClumpPlacer(randIntInclusive(scaleByMapSize(13,24),scaleByMapSize(24,45))*randIntInclusive(scaleByMapSize(13,24),scaleByMapSize(24,45)), 0.80, 0.1, 10); terrainPainter = new LayeredPainter( [tGrass, tGrass], // terrains [2] // widths @@ -238,7 +238,7 @@ else if (md == 2) //continent placer, [terrainPainter, elevationPainter, paintClass(clLand)], null, - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } } @@ -356,15 +356,15 @@ else if (md == 3) //central sea } } - if (!randInt(3)) + if (randBool(1/3)) { if (mdd1 == 1) //vertical { - var placer = new PathPlacer(1, fractionToTiles(0.5), fractionToTiles(0.99), fractionToTiles(0.5), scaleByMapSize(randInt(16,24),randInt(100,140)), 0.5, 3*(scaleByMapSize(1,4)), 0.1, 0.01); + var placer = new PathPlacer(1, fractionToTiles(0.5), fractionToTiles(0.99), fractionToTiles(0.5), scaleByMapSize(randIntInclusive(16,24),randIntInclusive(100,140)), 0.5, 3*(scaleByMapSize(1,4)), 0.1, 0.01); } else { - var placer = new PathPlacer(fractionToTiles(0.5), 1, fractionToTiles(0.5), fractionToTiles(0.99), scaleByMapSize(randInt(16,24),randInt(100,140)), 0.5, 3*(scaleByMapSize(1,4)), 0.1, 0.01); + var placer = new PathPlacer(fractionToTiles(0.5), 1, fractionToTiles(0.5), fractionToTiles(0.99), scaleByMapSize(randIntInclusive(16,24),randIntInclusive(100,140)), 0.5, 3*(scaleByMapSize(1,4)), 0.1, 0.01); } var terrainPainter = new LayeredPainter( [tGrass, tGrass, tGrass], // terrains @@ -377,12 +377,12 @@ else if (md == 3) //central sea ); createArea(placer, [terrainPainter, elevationPainter, unPaintClass(clWater)], null); } - var mdd2 = randInt(1,3); + var mdd2 = randIntInclusive(1,3); if (mdd2 == 1) { // create islands log("Creating islands..."); - placer = new ClumpPlacer(randInt(scaleByMapSize(8,15),scaleByMapSize(15,23))*randInt(scaleByMapSize(8,15),scaleByMapSize(15,23)), 0.80, 0.1, randFloat(0.0, 0.2)); + placer = new ClumpPlacer(randIntInclusive(scaleByMapSize(8,15),scaleByMapSize(15,23))*randIntInclusive(scaleByMapSize(8,15),scaleByMapSize(15,23)), 0.80, 0.1, randFloat(0.0, 0.2)); terrainPainter = new LayeredPainter( [tGrass, tGrass], // terrains [2] // widths @@ -392,14 +392,14 @@ else if (md == 3) //central sea placer, [terrainPainter, elevationPainter, paintClass(clLand)], avoidClasses(clLand, 3, clPlayer, 3), - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } else if (mdd2 == 2) { // create extentions log("Creating extentions..."); - placer = new ClumpPlacer(randInt(scaleByMapSize(13,24),scaleByMapSize(24,45))*randInt(scaleByMapSize(13,24),scaleByMapSize(24,45)), 0.80, 0.1, 10); + placer = new ClumpPlacer(randIntInclusive(scaleByMapSize(13,24),scaleByMapSize(24,45))*randIntInclusive(scaleByMapSize(13,24),scaleByMapSize(24,45)), 0.80, 0.1, 10); terrainPainter = new LayeredPainter( [tGrass, tGrass], // terrains [2] // widths @@ -409,7 +409,7 @@ else if (md == 3) //central sea placer, [terrainPainter, elevationPainter, paintClass(clLand)], null, - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } } @@ -472,13 +472,13 @@ else if (md == 4) //central river var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -4, 2); createArea(placer, [painter, elevationPainter], avoidClasses(clPlayer, 8)); - var mdd2 = randInt(1,2); + var mdd2 = randIntInclusive(1,2); if (mdd2 == 1) { // create the shallows of the main river log("Creating the shallows of the main river"); - for (var i = 0; i <= randInt(1, scaleByMapSize(4,8)); i++) + for (var i = 0; i <= randIntInclusive(1, scaleByMapSize(4,8)); i++) { var cLocation = randFloat(0.15,0.85); if (mdd1 == 1) @@ -488,16 +488,16 @@ else if (md == 4) //central river } } - if (randInt(1,2) == 1) + if (randBool()) { // create tributaries log("Creating tributaries"); - for (var i = 0; i <= randInt(8, (scaleByMapSize(12,20))); i++) + for (var i = 0; i <= randIntInclusive(8, (scaleByMapSize(12,20))); i++) { var cLocation = randFloat(0.05,0.95); - var tang = randFloat(PI*0.2, PI*0.8)*((randInt(2)-0.5)*2); + var tang = randFloat(PI*0.2, PI*0.8)*((randIntInclusive(0, 1)-0.5)*2); if (tang > 0) { var cDistance = 0.05; @@ -566,7 +566,7 @@ else if (md == 5) //rivers and lake } } - var mdd1 = randInt(1,3); + var mdd1 = randIntInclusive(1,3); if (mdd1 < 3) //lake { @@ -633,7 +633,7 @@ else if (md == 5) //rivers and lake createArea(placer, [terrainPainter, elevationPainter, paintClass(clWater)], null); } - if (randInt(1,3) == 1 && mdd1 < 3)//island + if (randBool(1/3) && mdd1 < 3)//island { var placer = new ClumpPlacer(mapArea * 0.006 * lSize, 0.7, 0.1, 10, ix, iz); var terrainPainter = new LayeredPainter( @@ -662,7 +662,7 @@ else if (md == 6) //edge seas } } - var mdd1 = randInt(1,2); + var mdd1 = randIntInclusive(1,2); // randomize player order var playerIDs = []; @@ -672,7 +672,7 @@ else if (md == 6) //edge seas } playerIDs = sortPlayers(playerIDs); - var mdd2 = randInt(1,3); + var mdd2 = randIntInclusive(1,3); var fadedistance = 7; if (mdd1 == 1) @@ -839,12 +839,12 @@ else if (md == 6) //edge seas } } - var mdd3 = randInt(1,3); + var mdd3 = randIntInclusive(1,3); if (mdd3 == 1) { // create islands log("Creating islands..."); - placer = new ClumpPlacer(randInt(scaleByMapSize(8,15),scaleByMapSize(15,23))*randInt(scaleByMapSize(8,15),scaleByMapSize(15,23)), 0.80, 0.1, randFloat(0.0, 0.2)); + placer = new ClumpPlacer(randIntInclusive(scaleByMapSize(8,15),scaleByMapSize(15,23))*randIntInclusive(scaleByMapSize(8,15),scaleByMapSize(15,23)), 0.80, 0.1, randFloat(0.0, 0.2)); terrainPainter = new LayeredPainter( [tGrass, tGrass], // terrains [2] // widths @@ -854,14 +854,14 @@ else if (md == 6) //edge seas placer, [terrainPainter, elevationPainter, paintClass(clLand)], avoidClasses(clLand, 3, clPlayer, 3), - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } else if (mdd3 == 2) { // create extentions log("Creating extentions..."); - placer = new ClumpPlacer(randInt(scaleByMapSize(13,24),scaleByMapSize(24,45))*randInt(scaleByMapSize(13,24),scaleByMapSize(24,45)), 0.80, 0.1, 10); + placer = new ClumpPlacer(randIntInclusive(scaleByMapSize(13,24),scaleByMapSize(24,45))*randIntInclusive(scaleByMapSize(13,24),scaleByMapSize(24,45)), 0.80, 0.1, 10); terrainPainter = new LayeredPainter( [tGrass, tGrass], // terrains [2] // widths @@ -871,7 +871,7 @@ else if (md == 6) //edge seas placer, [terrainPainter, elevationPainter, paintClass(clLand)], null, - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } } @@ -889,7 +889,7 @@ else if (md == 7) //gulf } } - var mdd1 = randInt(1,4); + var mdd1 = randIntInclusive(1,4); // randomize player order var playerIDs = []; @@ -988,7 +988,7 @@ else if (md == 8) //lakes [1, 3] // widths ); elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -5, 5); - if (randInt(1,2) == 1) + if (randBool()) { createAreas( placer, @@ -1055,7 +1055,7 @@ else if (md == 9) //passes var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 2); createArea(placer, [painter, elevationPainter], null); } - var mdd1 = randInt (1,3); + var mdd1 = randIntInclusive(1,3); if (mdd1 <= 2) { var fx = fractionToTiles(0.5); @@ -1381,7 +1381,7 @@ createAreas( placer, painter, [avoidClasses(clWater, 2, clPlayer, 10), stayClasses(clLand, 3)], - randInt(0,scaleByMapSize(200, 400)) + randIntInclusive(0,scaleByMapSize(200, 400)) ); // create hills @@ -1395,8 +1395,8 @@ elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 18, 2); createAreas( placer, [terrainPainter, elevationPainter, paintClass(clHill)], - [avoidClasses(clPlayer, 15, clHill, randInt(6, 18)), stayClasses(clLand, 0)], - randInt(0, scaleByMapSize(4, 8))*randInt(1, scaleByMapSize(4, 9)) + [avoidClasses(clPlayer, 15, clHill, randIntInclusive(6, 18)), stayClasses(clLand, 0)], + randIntInclusive(0, scaleByMapSize(4, 8))*randIntInclusive(1, scaleByMapSize(4, 9)) ); var multiplier = sqrt(randFloat(0.5,1.2)*randFloat(0.5,1.2)); @@ -1449,7 +1449,7 @@ for (var i = 0; i < types.length; ++i) createAreas( placer, [painter, paintClass(clForest)], - [avoidClasses(clPlayer, 17, clForest, randInt(5, 15), clHill, 0), stayClasses(clLand, 4)], + [avoidClasses(clPlayer, 17, clForest, randIntInclusive(5, 15), clHill, 0), stayClasses(clLand, 4)], num ); } @@ -1498,14 +1498,14 @@ log("Creating stone mines..."); var group = new SimpleGroup([new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)], true, clRock); createObjectGroups(group, 0, [avoidClasses(clForest, 1, clPlayer, 10, clRock, 10, clHill, 1), stayClasses(clLand, 3)], - randInt(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 + randIntInclusive(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 ); // create small stone quarries group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock); createObjectGroups(group, 0, [avoidClasses(clForest, 1, clPlayer, 10, clRock, 10, clHill, 1), stayClasses(clLand, 3)], - randInt(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 + randIntInclusive(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 ); log("Creating metal mines..."); @@ -1513,7 +1513,7 @@ log("Creating metal mines..."); group = new SimpleGroup([new SimpleObject(oMetalLarge, 1,1, 0,4)], true, clMetal); createObjectGroups(group, 0, [avoidClasses(clForest, 1, clPlayer, 10, clMetal, 10, clRock, 5, clHill, 1), stayClasses(clLand, 3)], - randInt(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 + randIntInclusive(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 ); RMS.SetProgress(65); @@ -1553,7 +1553,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, [avoidClasses(clWater, 0, clForest, 0, clPlayer, 8, clHill, 1, clFood, 20), stayClasses(clLand, 2)], - randInt(numPlayers+3, 5*numPlayers+4), 50 + randIntInclusive(numPlayers+3, 5*numPlayers+4), 50 ); // create berry bush @@ -1564,7 +1564,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, [avoidClasses(clWater, 0, clForest, 0, clPlayer, 8, clHill, 1, clFood, 20), stayClasses(clLand, 2)], - randInt(1, 4) * numPlayers + 2, 50 + randIntInclusive(1, 4) * numPlayers + 2, 50 ); RMS.SetProgress(75); @@ -1577,7 +1577,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, [avoidClasses(clWater, 0, clForest, 0, clPlayer, 8, clHill, 1, clFood, 20), stayClasses(clLand, 2)], - randInt(numPlayers+3, 5*numPlayers+4), 50 + randIntInclusive(numPlayers+3, 5*numPlayers+4), 50 ); // create fish @@ -1588,7 +1588,7 @@ group = new SimpleGroup( ); createObjectGroups(group, 0, avoidClasses(clLand, 4, clForest, 0, clPlayer, 0, clHill, 0, clFood, 20), - randInt(15, 40) * numPlayers, 60 + randIntInclusive(15, 40) * numPlayers, 60 ); RMS.SetProgress(85); diff --git a/binaries/data/mods/public/maps/random/wild_lake.js b/binaries/data/mods/public/maps/random/wild_lake.js index affbd395e8..1ec10f9179 100644 --- a/binaries/data/mods/public/maps/random/wild_lake.js +++ b/binaries/data/mods/public/maps/random/wild_lake.js @@ -483,7 +483,7 @@ 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) { @@ -509,7 +509,7 @@ function placeGrove(point, ) { placeObject(point.x, point.y, pickRandom(["structures/gaul_outpost", "gaia/flora_tree_oak_new"]), 0, randFloat(0, 2 * PI)); - let quantity = randInt(20, 30); + let quantity = randIntInclusive(20, 30); let dAngle = TWO_PI / quantity; for (let i = 0; i < quantity; ++i) { @@ -581,7 +581,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) {