Index: ps/trunk/binaries/data/mods/public/maps/random/rmgen/random.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/rmgen/random.js +++ ps/trunk/binaries/data/mods/public/maps/random/rmgen/random.js @@ -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; - } -} Index: ps/trunk/binaries/data/mods/public/maps/random/unknown.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/unknown.js +++ ps/trunk/binaries/data/mods/public/maps/random/unknown.js @@ -82,7 +82,7 @@ } 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ var clPeninsulaSteam = createTileClass(); - if (randInt(1,3)==1) // peninsula + if (randBool(1/3)) // peninsula { var angle = randFloat(0, TWO_PI); @@ -356,7 +356,7 @@ 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 @@ } } - 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 @@ ); 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 @@ 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 @@ placer, [terrainPainter, elevationPainter, paintClass(clLand)], null, - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } } @@ -595,7 +595,7 @@ 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 @@ 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 @@ } } - if (randInt(1,2) == 1) + if (randBool()) { for (var i = 0; i < numPlayers; i++) { @@ -715,10 +715,10 @@ // 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 @@ 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 @@ ); } - if (randInt(1,2) == 1) //rivers + if (randBool()) // rivers { //create rivers log ("Creating rivers..."); @@ -906,7 +906,7 @@ 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 @@ } } - var mdd1 = randInt(1,2); + var mdd1 = randIntInclusive(1,2); // randomize player order var playerIDs = []; @@ -976,7 +976,7 @@ 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 @@ 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 @@ 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 @@ placer, [terrainPainter, elevationPainter, paintClass(clLand)], null, - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } } @@ -1341,7 +1341,7 @@ [1, 3] // widths ); elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -5, 5); - if (randInt(1,2) == 1) + if (randBool()) { createAreas( placer, @@ -1422,7 +1422,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ ); 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 @@ ); 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 @@ ); 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 @@ ); 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); Index: ps/trunk/binaries/data/mods/public/maps/random/unknown_land.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/unknown_land.js +++ ps/trunk/binaries/data/mods/public/maps/random/unknown_land.js @@ -81,7 +81,7 @@ } } -var md = randInt(2,13); +var md = randIntInclusive(2,13); var needsAdditionalWood = false; //***************************************************************************************************************************** if (md == 2) //continent @@ -146,7 +146,7 @@ var clPeninsulaSteam = createTileClass(); - if (randInt(1,3)==1) // peninsula + if (randBool(1/3)) // peninsula { var angle = randFloat(0, TWO_PI); @@ -195,7 +195,7 @@ 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 @@ // 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 @@ ); 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 @@ 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 @@ placer, [terrainPainter, elevationPainter, paintClass(clLand)], null, - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } } @@ -433,7 +433,7 @@ 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 @@ // 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 @@ 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 @@ // 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 @@ 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 @@ ); } - 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 @@ } } - var mdd1 = randInt(1,2); + var mdd1 = randIntInclusive(1,2); // randomize player order var playerIDs = []; @@ -755,7 +755,7 @@ 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 @@ scaleByMapSize(12, 130) * 2, 150 ); - var mdd3 = randInt(1,5); + var mdd3 = randIntInclusive(1,5); if (mdd3 == 1) { // create islands @@ -905,7 +905,7 @@ 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 @@ placer, [terrainPainter, elevationPainter, paintClass(clLand)], null, - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } } @@ -1104,7 +1104,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ ); 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 @@ ); 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 @@ ); 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 @@ ); 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); Index: ps/trunk/binaries/data/mods/public/maps/random/unknown_nomad.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/unknown_nomad.js +++ ps/trunk/binaries/data/mods/public/maps/random/unknown_nomad.js @@ -82,7 +82,7 @@ } 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ ); 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 @@ 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 @@ 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 @@ placer, [terrainPainter, elevationPainter, paintClass(clLand)], null, - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } } @@ -356,15 +356,15 @@ } } - 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 @@ ); 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 @@ 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 @@ placer, [terrainPainter, elevationPainter, paintClass(clLand)], null, - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } } @@ -472,13 +472,13 @@ 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 @@ } } - 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 @@ } } - var mdd1 = randInt(1,3); + var mdd1 = randIntInclusive(1,3); if (mdd1 < 3) //lake { @@ -633,7 +633,7 @@ 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 @@ } } - var mdd1 = randInt(1,2); + var mdd1 = randIntInclusive(1,2); // randomize player order var playerIDs = []; @@ -672,7 +672,7 @@ } playerIDs = sortPlayers(playerIDs); - var mdd2 = randInt(1,3); + var mdd2 = randIntInclusive(1,3); var fadedistance = 7; if (mdd1 == 1) @@ -839,12 +839,12 @@ } } - 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 @@ 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 @@ placer, [terrainPainter, elevationPainter, paintClass(clLand)], null, - scaleByMapSize(2, 5)*randInt(8,14) + scaleByMapSize(2, 5)*randIntInclusive(8,14) ); } } @@ -889,7 +889,7 @@ } } - var mdd1 = randInt(1,4); + var mdd1 = randIntInclusive(1,4); // randomize player order var playerIDs = []; @@ -988,7 +988,7 @@ [1, 3] // widths ); elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -5, 5); - if (randInt(1,2) == 1) + if (randBool()) { createAreas( placer, @@ -1055,7 +1055,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ ); 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 @@ ); 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 @@ ); 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 @@ ); 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); Index: ps/trunk/binaries/data/mods/public/maps/random/wild_lake.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/wild_lake.js +++ ps/trunk/binaries/data/mods/public/maps/random/wild_lake.js @@ -483,7 +483,7 @@ ) { 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 @@ ) { 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 @@ ) { 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) {