Index: ps/trunk/binaries/data/mods/public/maps/random/african_plains.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/african_plains.js +++ ps/trunk/binaries/data/mods/public/maps/random/african_plains.js @@ -314,7 +314,7 @@ [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) ); Index: ps/trunk/binaries/data/mods/public/maps/random/alpine_lakes.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/alpine_lakes.js +++ ps/trunk/binaries/data/mods/public/maps/random/alpine_lakes.js @@ -375,7 +375,7 @@ [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) ); Index: ps/trunk/binaries/data/mods/public/maps/random/alpine_valley.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/alpine_valley.js +++ ps/trunk/binaries/data/mods/public/maps/random/alpine_valley.js @@ -251,7 +251,7 @@ //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 @@ ); 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..."); Index: ps/trunk/binaries/data/mods/public/maps/random/anatolian_plateau.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/anatolian_plateau.js +++ ps/trunk/binaries/data/mods/public/maps/random/anatolian_plateau.js @@ -313,7 +313,7 @@ ); 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); Index: ps/trunk/binaries/data/mods/public/maps/random/archipelago.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/archipelago.js +++ ps/trunk/binaries/data/mods/public/maps/random/archipelago.js @@ -191,7 +191,7 @@ 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); Index: ps/trunk/binaries/data/mods/public/maps/random/ardennes_forest.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/ardennes_forest.js +++ ps/trunk/binaries/data/mods/public/maps/random/ardennes_forest.js @@ -566,7 +566,7 @@ ); 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..."); Index: ps/trunk/binaries/data/mods/public/maps/random/atlas_mountains.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/atlas_mountains.js +++ ps/trunk/binaries/data/mods/public/maps/random/atlas_mountains.js @@ -273,7 +273,7 @@ [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) ); Index: ps/trunk/binaries/data/mods/public/maps/random/belgian_uplands.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/belgian_uplands.js +++ ps/trunk/binaries/data/mods/public/maps/random/belgian_uplands.js @@ -230,7 +230,7 @@ { var vector = []; for (var p = 0; p < numPlayers; p++) - vector.push(randInt(possibleStartPositions.length)); + vector.push(randIntExclusive(0, possibleStartPositions.length)); possibleDerivations.push(vector); } Index: ps/trunk/binaries/data/mods/public/maps/random/caledonian_meadows.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/caledonian_meadows.js +++ ps/trunk/binaries/data/mods/public/maps/random/caledonian_meadows.js @@ -305,7 +305,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) { @@ -378,7 +378,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) { Index: ps/trunk/binaries/data/mods/public/maps/random/cantabrian_highlands.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/cantabrian_highlands.js +++ ps/trunk/binaries/data/mods/public/maps/random/cantabrian_highlands.js @@ -321,7 +321,7 @@ [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) ); Index: ps/trunk/binaries/data/mods/public/maps/random/canyon.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/canyon.js +++ ps/trunk/binaries/data/mods/public/maps/random/canyon.js @@ -219,11 +219,17 @@ 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 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 @@ // 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(); Index: ps/trunk/binaries/data/mods/public/maps/random/cycladic_archipelago.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/cycladic_archipelago.js +++ ps/trunk/binaries/data/mods/public/maps/random/cycladic_archipelago.js @@ -339,7 +339,7 @@ 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 Index: ps/trunk/binaries/data/mods/public/maps/random/empire.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/empire.js +++ ps/trunk/binaries/data/mods/public/maps/random/empire.js @@ -7,7 +7,7 @@ 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); Index: ps/trunk/binaries/data/mods/public/maps/random/english_channel.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/english_channel.js +++ ps/trunk/binaries/data/mods/public/maps/random/english_channel.js @@ -371,7 +371,7 @@ [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) ); Index: ps/trunk/binaries/data/mods/public/maps/random/flood.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/flood.js +++ ps/trunk/binaries/data/mods/public/maps/random/flood.js @@ -224,13 +224,19 @@ ); 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 @@ 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 Index: ps/trunk/binaries/data/mods/public/maps/random/fortress.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/fortress.js +++ ps/trunk/binaries/data/mods/public/maps/random/fortress.js @@ -341,7 +341,7 @@ [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) ); Index: ps/trunk/binaries/data/mods/public/maps/random/frontier.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/frontier.js +++ ps/trunk/binaries/data/mods/public/maps/random/frontier.js @@ -10,9 +10,9 @@ 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); Index: ps/trunk/binaries/data/mods/public/maps/random/guadalquivir_river.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/guadalquivir_river.js +++ ps/trunk/binaries/data/mods/public/maps/random/guadalquivir_river.js @@ -380,7 +380,7 @@ [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)] ); Index: ps/trunk/binaries/data/mods/public/maps/random/gulf_of_bothnia.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/gulf_of_bothnia.js +++ ps/trunk/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 @@ [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) ); Index: ps/trunk/binaries/data/mods/public/maps/random/heightmap/heightmap.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/heightmap/heightmap.js +++ ps/trunk/binaries/data/mods/public/maps/random/heightmap/heightmap.js @@ -139,7 +139,7 @@ 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)) { Index: ps/trunk/binaries/data/mods/public/maps/random/hyrcanian_shores.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/hyrcanian_shores.js +++ ps/trunk/binaries/data/mods/public/maps/random/hyrcanian_shores.js @@ -453,7 +453,7 @@ ); 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 Index: ps/trunk/binaries/data/mods/public/maps/random/islands.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/islands.js +++ ps/trunk/binaries/data/mods/public/maps/random/islands.js @@ -492,7 +492,7 @@ ); 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 Index: ps/trunk/binaries/data/mods/public/maps/random/kerala.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/kerala.js +++ ps/trunk/binaries/data/mods/public/maps/random/kerala.js @@ -198,7 +198,14 @@ 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 @@ ); 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 Index: ps/trunk/binaries/data/mods/public/maps/random/latium.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/latium.js +++ ps/trunk/binaries/data/mods/public/maps/random/latium.js @@ -501,20 +501,26 @@ 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..."); Index: ps/trunk/binaries/data/mods/public/maps/random/lorraine_plain.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/lorraine_plain.js +++ ps/trunk/binaries/data/mods/public/maps/random/lorraine_plain.js @@ -210,7 +210,7 @@ // 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 @@ ); 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 Index: ps/trunk/binaries/data/mods/public/maps/random/migration.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/migration.js +++ ps/trunk/binaries/data/mods/public/maps/random/migration.js @@ -420,7 +420,7 @@ ); 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); Index: ps/trunk/binaries/data/mods/public/maps/random/northern_lights.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/northern_lights.js +++ ps/trunk/binaries/data/mods/public/maps/random/northern_lights.js @@ -180,7 +180,14 @@ 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 Index: ps/trunk/binaries/data/mods/public/maps/random/persian_highlands.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/persian_highlands.js +++ ps/trunk/binaries/data/mods/public/maps/random/persian_highlands.js @@ -243,8 +243,8 @@ 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 @@ ); 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 Index: ps/trunk/binaries/data/mods/public/maps/random/phoenician_levant.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/phoenician_levant.js +++ ps/trunk/binaries/data/mods/public/maps/random/phoenician_levant.js @@ -443,7 +443,7 @@ ); 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); Index: ps/trunk/binaries/data/mods/public/maps/random/pyrenean_sierra.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/pyrenean_sierra.js +++ ps/trunk/binaries/data/mods/public/maps/random/pyrenean_sierra.js @@ -745,7 +745,7 @@ 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 ); Index: ps/trunk/binaries/data/mods/public/maps/random/rhine_marshlands.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/rhine_marshlands.js +++ ps/trunk/binaries/data/mods/public/maps/random/rhine_marshlands.js @@ -381,7 +381,7 @@ ); 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); Index: ps/trunk/binaries/data/mods/public/maps/random/rmgen/library.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/rmgen/library.js +++ ps/trunk/binaries/data/mods/public/maps/random/rmgen/library.js @@ -134,8 +134,8 @@ 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); } } Index: ps/trunk/binaries/data/mods/public/maps/random/rmgen/misc.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/rmgen/misc.js +++ ps/trunk/binaries/data/mods/public/maps/random/rmgen/misc.js @@ -637,9 +637,7 @@ 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 @@ 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) { Index: ps/trunk/binaries/data/mods/public/maps/random/rmgen/placer.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/rmgen/placer.js +++ ps/trunk/binaries/data/mods/public/maps/random/rmgen/placer.js @@ -158,7 +158,7 @@ { 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 @@ 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 @@ return undefined; } } - } return resultObjs; }; @@ -435,11 +432,9 @@ 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 @@ return undefined; } } - } return resultObjs; }; Index: ps/trunk/binaries/data/mods/public/maps/random/rmgen/randombiome.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/rmgen/randombiome.js +++ ps/trunk/binaries/data/mods/public/maps/random/rmgen/randombiome.js @@ -62,7 +62,7 @@ { let biomeIndex; do - biomeIndex = randInt(1, 8); + biomeIndex = randIntInclusive(1, 8); while (avoid.indexOf(biomeIndex) != -1); setBiome(biomeIndex); @@ -142,13 +142,13 @@ "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 @@ 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 @@ "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"; Index: ps/trunk/binaries/data/mods/public/maps/random/rmgen/utilityfunctions.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/rmgen/utilityfunctions.js +++ ps/trunk/binaries/data/mods/public/maps/random/rmgen/utilityfunctions.js @@ -69,8 +69,8 @@ maxRadius, numCircles, constraint, - randInt(mapSize), - randInt(mapSize), + randIntExclusive(0, mapSize), + randIntExclusive(0, mapSize), terrain, tileclass, 14 Index: ps/trunk/binaries/data/mods/public/maps/random/rmgen/wall_builder.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/rmgen/wall_builder.js +++ ps/trunk/binaries/data/mods/public/maps/random/rmgen/wall_builder.js @@ -861,7 +861,7 @@ 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; Index: ps/trunk/binaries/data/mods/public/maps/random/rmgen2/gaia.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/rmgen2/gaia.js +++ ps/trunk/binaries/data/mods/public/maps/random/rmgen2/gaia.js @@ -63,7 +63,7 @@ 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 @@ 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 @@ { 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 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); } Index: ps/trunk/binaries/data/mods/public/maps/random/sahel.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/sahel.js +++ ps/trunk/binaries/data/mods/public/maps/random/sahel.js @@ -213,8 +213,8 @@ // 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 @@ ); 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); Index: ps/trunk/binaries/data/mods/public/maps/random/sahel_watering_holes.js =================================================================== --- ps/trunk/binaries/data/mods/public/maps/random/sahel_watering_holes.js +++ ps/trunk/binaries/data/mods/public/maps/random/sahel_watering_holes.js @@ -476,7 +476,7 @@ ); 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);