forked from mirrors/0ad
Replace deprecated randInt calls (besides those in the Unknown maps).
Differential Revision: https://code.wildfiregames.com/D278 Patch By: bb Refs #4326 This was SVN commit r19443.
This commit is contained in:
@@ -314,7 +314,7 @@ createFood(
|
||||
[new SimpleObject(oBerryBush, 5,7, 0,4)]
|
||||
],
|
||||
[
|
||||
randInt(1, 4) * numPlayers + 2
|
||||
randIntInclusive(1, 4) * numPlayers + 2
|
||||
],
|
||||
avoidClasses(clWater, 3, clForest, 2, clPlayer, 20, clHill, 3, clFood, 10)
|
||||
);
|
||||
|
||||
@@ -375,7 +375,7 @@ createFood
|
||||
[new SimpleObject(oBerryBush, 5,7, 0,4)]
|
||||
],
|
||||
[
|
||||
randInt(1, 4) * numPlayers + 2
|
||||
randIntInclusive(1, 4) * numPlayers + 2
|
||||
],
|
||||
avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10)
|
||||
);
|
||||
|
||||
@@ -251,7 +251,7 @@ for (var i = 0; i < numPoints; ++i)
|
||||
//find and place the edges
|
||||
while (possibleEdges.length)
|
||||
{
|
||||
var index = randInt(0, possibleEdges.length - 1);
|
||||
var index = randIntExclusive(0, possibleEdges.length);
|
||||
|
||||
//ensure that a point is connected to a maximum of 3 others
|
||||
if (edgesConncetedToPoints[possibleEdges[index][0]] > 2 || edgesConncetedToPoints[possibleEdges[index][1]] > 2)
|
||||
@@ -567,7 +567,7 @@ group = new SimpleGroup(
|
||||
);
|
||||
createObjectGroups(group, 0,
|
||||
avoidClasses(clForest, 0, clPlayer, 20, clHill, 1, clFood, 10),
|
||||
randInt(1, 4) * numPlayers + 2, 50
|
||||
randIntInclusive(1, 4) * numPlayers + 2, 50
|
||||
);
|
||||
|
||||
log("Creating rabbit...");
|
||||
|
||||
@@ -313,7 +313,7 @@ group = new SimpleGroup(
|
||||
);
|
||||
createObjectGroups(group, 0,
|
||||
avoidClasses(clForest, 0, clPlayer, 20, clHill, 1, clFood, 20),
|
||||
randInt(1, 4) * numPlayers + 2, 50
|
||||
randIntInclusive(1, 4) * numPlayers + 2, 50
|
||||
);
|
||||
|
||||
RMS.SetProgress(75);
|
||||
|
||||
@@ -191,7 +191,7 @@ createAreas(
|
||||
placer,
|
||||
[terrainPainter, elevationPainter, paintClass(clLand)],
|
||||
null,
|
||||
scaleByMapSize(1, 5)*randInt(5,10)
|
||||
scaleByMapSize(1, 5) * randIntInclusive(5, 10)
|
||||
);
|
||||
|
||||
paintTerrainBasedOnHeight(2.4, 3.4, 3, tMainTerrain);
|
||||
|
||||
@@ -566,7 +566,7 @@ group = new SimpleGroup(
|
||||
);
|
||||
createObjectGroups(group, 0,
|
||||
avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 20),
|
||||
randInt(3, 12) * numPlayers + 2, 50
|
||||
randIntInclusive(3, 12) * numPlayers + 2, 50
|
||||
);
|
||||
|
||||
log("Creating decorative props...");
|
||||
|
||||
@@ -273,7 +273,7 @@ createFood
|
||||
[new SimpleObject(oBerryBush, 5,7, 0,4)]
|
||||
],
|
||||
[
|
||||
randInt(3, 12) * numPlayers + 2
|
||||
randIntInclusive(3, 12) * numPlayers + 2
|
||||
],
|
||||
avoidClasses(clForest, 0, clPlayer, 20, clHill, 1, clFood, 10)
|
||||
);
|
||||
|
||||
@@ -230,7 +230,7 @@ while (!goodStartPositionsFound)
|
||||
{
|
||||
var vector = [];
|
||||
for (var p = 0; p < numPlayers; p++)
|
||||
vector.push(randInt(possibleStartPositions.length));
|
||||
vector.push(randIntExclusive(0, possibleStartPositions.length));
|
||||
possibleDerivations.push(vector);
|
||||
}
|
||||
|
||||
|
||||
@@ -305,7 +305,7 @@ let decorations = [
|
||||
function placeMine(point, centerEntity)
|
||||
{
|
||||
placeObject(point.x, point.y, centerEntity, 0, randFloat(0, TWO_PI));
|
||||
let quantity = randInt(11, 23);
|
||||
let quantity = randIntInclusive(11, 23);
|
||||
let dAngle = TWO_PI / quantity;
|
||||
for (let i = 0; i < quantity; ++i)
|
||||
{
|
||||
@@ -378,7 +378,7 @@ function placeCamp(point,
|
||||
)
|
||||
{
|
||||
placeObject(point.x, point.y, centerEntity, 0, randFloat(0, TWO_PI));
|
||||
let quantity = randInt(5, 11);
|
||||
let quantity = randIntInclusive(5, 11);
|
||||
let dAngle = TWO_PI / quantity;
|
||||
for (let i = 0; i < quantity; ++i)
|
||||
{
|
||||
|
||||
@@ -321,7 +321,7 @@ createFood
|
||||
[new SimpleObject(oBerryBush, 5,7, 0,4)]
|
||||
],
|
||||
[
|
||||
randInt(1, 4) * numPlayers + 2
|
||||
randIntInclusive(1, 4) * numPlayers + 2
|
||||
],
|
||||
avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10)
|
||||
);
|
||||
|
||||
@@ -219,11 +219,17 @@ createArea(placer, [painter, paintClass(clHill)], null);
|
||||
|
||||
for (var i = 0; i < scaleByMapSize(9,16); i++)
|
||||
{
|
||||
var ix = randInt(1, mapSize - 1);
|
||||
var iz = randInt(1, mapSize - 1);
|
||||
var ix2 = randInt(1, mapSize - 1);
|
||||
var iz2 = randInt(1, mapSize - 1);
|
||||
var placer = new PathPlacer(ix, iz, ix2, iz2, scaleByMapSize(11,16), 0.4, 3*(scaleByMapSize(1,4)), 0.1, 0);
|
||||
var placer = new PathPlacer(
|
||||
randIntExclusive(1, mapSize),
|
||||
randIntExclusive(1, mapSize),
|
||||
randIntExclusive(1, mapSize),
|
||||
randIntExclusive(1, mapSize),
|
||||
scaleByMapSize(11,16),
|
||||
0.4,
|
||||
3 * scaleByMapSize(1,4),
|
||||
0.1,
|
||||
0);
|
||||
|
||||
var terrainPainter = new LayeredPainter(
|
||||
[tMainTerrain, tMainTerrain], // terrains
|
||||
[3] // widths
|
||||
@@ -238,8 +244,8 @@ for (var i = 0; i < scaleByMapSize(9,16); i++)
|
||||
|
||||
for (var g = 0; g < scaleByMapSize(5,30); g++)
|
||||
{
|
||||
var tx = randInt(1, mapSize - 1);
|
||||
var tz = randInt(1, mapSize - 1);
|
||||
var tx = randIntInclusive(1, mapSize - 1);
|
||||
var tz = randIntInclusive(1, mapSize - 1);
|
||||
|
||||
placer = new ClumpPlacer(mapArea * 0.01 * lSize, 0.7, 0.1, 10, tx, tz);
|
||||
terrainPainter = new LayeredPainter(
|
||||
@@ -497,11 +503,11 @@ createStragglerTrees(types, [avoidClasses(clForest, 1, clHill, 1, clPlayer, 9, c
|
||||
// create treasures
|
||||
var fx = fractionToTiles(0.5);
|
||||
var fz = fractionToTiles(0.5);
|
||||
for (var i = 0; i < randInt(3,8); i++)
|
||||
placeObject(fx+randFloat(-7,7), fz+randFloat(-7,7), oWood, 0, randFloat(0, TWO_PI));
|
||||
for (let i = 0; i < randIntInclusive(3, 8); ++i)
|
||||
placeObject(fx + randFloat(-7, 7), fz + randFloat(-7, 7), oWood, 0, randFloat(0, 2 * PI));
|
||||
|
||||
for (var i = 0; i < randInt(3,8); i++)
|
||||
placeObject(fx+randFloat(-7,7), fz+randFloat(-7,7), oFood, 0, randFloat(0, TWO_PI));
|
||||
for (let i = 0; i < randIntInclusive(3, 8); ++i)
|
||||
placeObject(fx + randFloat(-7, 7), fz + randFloat(-7, 7), oFood, 0, randFloat(0, 2 * PI));
|
||||
|
||||
// Export map data
|
||||
ExportMap();
|
||||
|
||||
@@ -339,7 +339,7 @@ var size = 5; //size
|
||||
var num = scaleByMapSize(10, 64); //number
|
||||
for (var i = 0; i < types.length; ++i)
|
||||
{
|
||||
placer = new ClumpPlacer(6+randInt(12), 0.1, 0.1, 1);
|
||||
placer = new ClumpPlacer(randIntInclusive(6, 17), 0.1, 0.1, 1);
|
||||
painter = new LayeredPainter(
|
||||
types[i], // terrains
|
||||
[2] // widths
|
||||
|
||||
@@ -7,7 +7,7 @@ randomizeBiome();
|
||||
initMapSettings();
|
||||
initTileClasses();
|
||||
|
||||
resetTerrain(g_Terrains.mainTerrain, g_TileClasses.land, randInt(5));
|
||||
resetTerrain(g_Terrains.mainTerrain, g_TileClasses.land, randIntInclusive(0, 4));
|
||||
RMS.SetProgress(10);
|
||||
|
||||
addBases("stronghold", 0.37, 0.04);
|
||||
|
||||
@@ -371,7 +371,7 @@ createFood
|
||||
[new SimpleObject(oBerryBush, 5,7, 0,4)]
|
||||
],
|
||||
[
|
||||
randInt(1, 4) * numPlayers + 2
|
||||
randIntInclusive(1, 4) * numPlayers + 2
|
||||
],
|
||||
avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10)
|
||||
);
|
||||
|
||||
@@ -224,13 +224,19 @@ elevationPainter = new SmoothElevationPainter(
|
||||
);
|
||||
createArea(placer, [terrainPainter, elevationPainter, paintClass(clHill)], avoidClasses(clPlayer, 40));
|
||||
|
||||
let randMountains = 20 + randInt(15);
|
||||
for (let m = 0; m < randMountains; ++m)
|
||||
for (let m = 0; m < randIntInclusive(20, 34); ++m)
|
||||
{
|
||||
let randX = randInt(mapSize);
|
||||
let randY = randInt(mapSize);
|
||||
let placer = new ChainPlacer(floor(scaleByMapSize(7, 7)), floor(scaleByMapSize(15, 15)), floor(scaleByMapSize(15, 20)), 1, randX, randY, 0, [floor(mapSize * 0.01)]);
|
||||
let elevRand = 6 + randInt(15);
|
||||
let placer = new ChainPlacer(
|
||||
Math.floor(scaleByMapSize(7, 7)),
|
||||
Math.floor(scaleByMapSize(15, 15)),
|
||||
Math.floor(scaleByMapSize(15, 20)),
|
||||
1,
|
||||
randIntExclusive(0, mapSize),
|
||||
randIntExclusive(0, mapSize),
|
||||
0,
|
||||
[Math.floor(mapSize * 0.01)]);
|
||||
|
||||
let elevRand = randIntInclusive(6, 20);
|
||||
let terrainPainter = new LayeredPainter(
|
||||
[tDirt, tHill], // terrains
|
||||
[floor(elevRand / 3), 40] // widths
|
||||
@@ -243,13 +249,19 @@ for (let m = 0; m < randMountains; ++m)
|
||||
createArea(placer, [terrainPainter, elevationPainter, paintClass(clHill)], [avoidClasses(clBaseResource, 2, clPlayer, 40), stayClasses(clHill, 6)]);
|
||||
}
|
||||
|
||||
randMountains = 8 + randInt(10);
|
||||
for (let m = 0; m < randMountains; ++m)
|
||||
for (let m = 0; m < randIntInclusive(8, 17); ++m)
|
||||
{
|
||||
let randX = randInt(mapSize);
|
||||
let randY = randInt(mapSize);
|
||||
let placer = new ChainPlacer(floor(scaleByMapSize(5, 5)), floor(scaleByMapSize(8, 8)), floor(scaleByMapSize(15, 20)), 1, randX, randY, 0, [floor(mapSize * 0.01)]);
|
||||
let elevRand = 15 + randInt(15);
|
||||
let placer = new ChainPlacer(
|
||||
Math.floor(scaleByMapSize(5, 5)),
|
||||
Math.floor(scaleByMapSize(8, 8)),
|
||||
Math.floor(scaleByMapSize(15, 20)),
|
||||
1,
|
||||
randIntExclusive(0, mapSize),
|
||||
randIntExclusive(0, mapSize),
|
||||
0,
|
||||
[Math.floor(mapSize * 0.01)]);
|
||||
|
||||
let elevRand = randIntInclusive(15, 29);
|
||||
let terrainPainter = new LayeredPainter(
|
||||
[tCliff, tForestFloor2], // terrains
|
||||
[floor(elevRand / 3), 40] // widths
|
||||
|
||||
@@ -341,7 +341,7 @@ createFood
|
||||
[new SimpleObject(oBerryBush, 5,7, 0,4)]
|
||||
],
|
||||
[
|
||||
randInt(1, 4) * numPlayers + 2
|
||||
randIntInclusive(1, 4) * numPlayers + 2
|
||||
],
|
||||
avoidClasses(clWater, 2, clForest, 0, clPlayer, 6, clHill, 1, clFood, 10)
|
||||
);
|
||||
|
||||
@@ -10,9 +10,9 @@ initTileClasses();
|
||||
RMS.SetProgress(10);
|
||||
|
||||
// Pick a random elevation with a bias towards lower elevations
|
||||
var randElevation = randInt(30);
|
||||
var randElevation = randIntInclusive(0, 29);
|
||||
if (randElevation < 25)
|
||||
randElevation = 1 + randInt(4);
|
||||
randElevation = randIntInclusive(1, 4);
|
||||
|
||||
resetTerrain(g_Terrains.mainTerrain, g_TileClasses.land, randElevation);
|
||||
RMS.SetProgress(20);
|
||||
|
||||
@@ -380,7 +380,7 @@ createFood
|
||||
[new SimpleObject(oBerryBush, 5,7, 0,4)]
|
||||
],
|
||||
[
|
||||
randInt(1, 4) * numPlayers + 2
|
||||
randIntInclusive(1, 4) * numPlayers + 2
|
||||
],
|
||||
[avoidClasses(clForest, 0, clPlayer, 20, clHill, 1, clFood, 10, clRiver, 1), stayClasses(clLand, 3)]
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
RMS.LoadLibrary("rmgen");
|
||||
|
||||
TILE_CENTERED_HEIGHT_MAP = true;
|
||||
var random_terrain = randInt(1,3);
|
||||
var random_terrain = randIntInclusive(1, 3);
|
||||
if (random_terrain == 1)
|
||||
{
|
||||
setFogThickness(0.26);
|
||||
@@ -453,7 +453,7 @@ createFood
|
||||
[new SimpleObject(oBerryBush, 5,7, 0,4)]
|
||||
],
|
||||
[
|
||||
randInt(1, 4) * numPlayers + 2
|
||||
randIntInclusive(1, 4) * numPlayers + 2
|
||||
],
|
||||
avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10)
|
||||
);
|
||||
|
||||
@@ -139,7 +139,7 @@ function distributeEntitiesByHeight(heightRange, avoidPoints, minDistance = 30,
|
||||
|
||||
for (let tries = 0; tries < maxTries; ++tries)
|
||||
{
|
||||
let checkPointIndex = randInt(validPoints.length);
|
||||
let checkPointIndex = randIntExclusive(0, validPoints.length);
|
||||
let checkPoint = validPoints[checkPointIndex];
|
||||
if (placements.every(p => getDistance(p.x, p.y, checkPoint.x, checkPoint.y) > minDistance))
|
||||
{
|
||||
|
||||
@@ -453,7 +453,7 @@ group = new SimpleGroup(
|
||||
);
|
||||
createObjectGroups(group, 0,
|
||||
avoidClasses(clWater, 6, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10),
|
||||
randInt(1, 4) * numPlayers + 2, 50
|
||||
randIntInclusive(1, 4) * numPlayers + 2, 50
|
||||
);
|
||||
|
||||
// create boar
|
||||
|
||||
@@ -492,7 +492,7 @@ group = new SimpleGroup(
|
||||
);
|
||||
createObjectGroups(group, 0,
|
||||
[avoidClasses(clForest, 0, clPlayer, 8, clHill, 1, clFood, 20), stayClasses(clLand, 5)],
|
||||
randInt(1, 4) * numPlayers + 2, 50
|
||||
randIntInclusive(1, 4) * numPlayers + 2, 50
|
||||
);
|
||||
|
||||
// create fish
|
||||
|
||||
@@ -198,7 +198,14 @@ for (var ix = 0; ix < mapSize; ix++)
|
||||
log("Creating shores...");
|
||||
for (var i = 0; i < scaleByMapSize(20,120); i++)
|
||||
{
|
||||
placer = new ChainPlacer(1, floor(scaleByMapSize(4, 6)), floor(scaleByMapSize(16, 30)), 1, floor(randFloat(0.28,0.34)*mapSize), floor(randFloat(0.1,0.9)*mapSize));
|
||||
placer = new ChainPlacer(
|
||||
1,
|
||||
Math.floor(scaleByMapSize(4, 6)),
|
||||
Math.floor(scaleByMapSize(16, 30)),
|
||||
1,
|
||||
randIntExclusive(0.28 * mapSize, 0.34 * mapSize),
|
||||
randIntExclusive(0.1 * mapSize, 0.9 * mapSize));
|
||||
|
||||
var terrainPainter = new LayeredPainter(
|
||||
[tGrass, tGrass], // terrains
|
||||
[2] // widths
|
||||
@@ -426,7 +433,7 @@ group = new SimpleGroup(
|
||||
);
|
||||
createObjectGroups(group, 0,
|
||||
avoidClasses(clWater, 6, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10),
|
||||
randInt(1, 4) * numPlayers + 2, 50
|
||||
randIntInclusive(1, 4) * numPlayers + 2, 50
|
||||
);
|
||||
|
||||
// create sheep
|
||||
|
||||
@@ -501,20 +501,26 @@ RMS.SetProgress(85);
|
||||
log("Creating fish...");
|
||||
var num = scaleByMapSize(4, 16);
|
||||
var offsetX = mapSize * WATER_WIDTH/2;
|
||||
for (var i = 0; i < num; ++i)
|
||||
{
|
||||
var cX = round(offsetX + offsetX/2 * randFloat(-1, 1));
|
||||
var cY = round((i + 0.5) * mapSize/num);
|
||||
group = new SimpleGroup([new SimpleObject(oFish, 1,1, 0,1)], true, clFood, cX, cY);
|
||||
createObjectGroup(group, 0);
|
||||
}
|
||||
for (var i = 0; i < num; ++i)
|
||||
{
|
||||
var cX = round(mapSize - offsetX + offsetX/2 * randFloat(-1, 1));
|
||||
var cY = round((i + 0.5) * mapSize/num);
|
||||
group = new SimpleGroup([new SimpleObject(oFish, 1,1, 0,1)], true, clFood, cX, cY);
|
||||
createObjectGroup(group, 0);
|
||||
}
|
||||
for (let i = 0; i < num; ++i)
|
||||
createObjectGroup(
|
||||
new SimpleGroup(
|
||||
[new SimpleObject(oFish, 1, 1, 0, 1)],
|
||||
true,
|
||||
clFood,
|
||||
randIntInclusive(offsetX / 2, offsetX * 3/2),
|
||||
Math.round((i + 0.5) * mapSize / num)),
|
||||
0);
|
||||
|
||||
for (let i = 0; i < num; ++i)
|
||||
createObjectGroup(
|
||||
new SimpleGroup(
|
||||
[new SimpleObject(oFish, 1, 1, 0, 1)],
|
||||
true,
|
||||
clFood,
|
||||
randIntInclusive(mapSize - offsetX * 3/2, mapSize - offsetX / 2),
|
||||
Math.round((i + 0.5) * mapSize / num)),
|
||||
0);
|
||||
|
||||
RMS.SetProgress(90);
|
||||
|
||||
log("Creating deer...");
|
||||
|
||||
@@ -210,7 +210,7 @@ createArea(placer, [painter, elevationPainter], avoidClasses(clPlayer, 8));
|
||||
// create the shallows of the main river
|
||||
log("Creating the shallows of the main river");
|
||||
|
||||
for (var i = 0; i <= randInt(3, scaleByMapSize(4,6)); i++)
|
||||
for (let i = 0; i <= randIntInclusive(3, scaleByMapSize(4, 6)); ++i)
|
||||
{
|
||||
var cLocation = randFloat(0.15,0.85);
|
||||
passageMaker(floor(fractionToTiles(cLocation)), floor(fractionToTiles(0.35)), floor(fractionToTiles(cLocation)), floor(fractionToTiles(0.65)), scaleByMapSize(4,8), -2, -2, 2, clShallow, undefined, -4);
|
||||
@@ -427,7 +427,7 @@ group = new SimpleGroup(
|
||||
);
|
||||
createObjectGroups(group, 0,
|
||||
avoidClasses(clWater, 3, clForest, 0, clPlayer, 15, clHill, 1, clFood, 10),
|
||||
randInt(1, 4) * numPlayers + 2, 50
|
||||
randIntInclusive(1, 4) * numPlayers + 2, 50
|
||||
);
|
||||
|
||||
// create straggler trees
|
||||
|
||||
@@ -420,7 +420,7 @@ group = new SimpleGroup(
|
||||
);
|
||||
createObjectGroups(group, 0,
|
||||
[avoidClasses(clForest, 0, clPlayer, 8, clHill, 1, clFood, 20), stayClasses(clLand, 7)],
|
||||
randInt(1, 4) * numPlayers + 2, 50
|
||||
randIntInclusive(1, 4) * numPlayers + 2, 50
|
||||
);
|
||||
RMS.SetProgress(78);
|
||||
|
||||
|
||||
@@ -180,7 +180,14 @@ for (var ix = 0; ix < mapSize; ix++)
|
||||
log("Creating shores...");
|
||||
for (var i = 0; i < scaleByMapSize(20,120); i++)
|
||||
{
|
||||
placer = new ChainPlacer(1, floor(scaleByMapSize(4, 6)), floor(scaleByMapSize(16, 30)), 1, floor(randFloat(0.1,0.9)*mapSize), floor(randFloat(0.67,0.74)*mapSize));
|
||||
placer = new ChainPlacer(
|
||||
1,
|
||||
Math.floor(scaleByMapSize(4, 6)),
|
||||
Math.floor(scaleByMapSize(16, 30)),
|
||||
1,
|
||||
randIntExclusive(0.1 * mapSize, 0.9 * mapSize),
|
||||
randIntExclusive(0.67 * mapSize, 0.74 * mapSize));
|
||||
|
||||
var terrainPainter = new LayeredPainter(
|
||||
[tSnowA, tSnowA], // terrains
|
||||
[2] // widths
|
||||
|
||||
@@ -243,8 +243,8 @@ for (var i = 0; i < numHills; ++i)
|
||||
floor(scaleByMapSize(6, 12)),
|
||||
floor(scaleByMapSize(4, 10)),
|
||||
avoidClasses(clPlayer, 7, clCP, 5, clHill, floor(scaleByMapSize(18, 25))),
|
||||
randInt(mapSize),
|
||||
randInt(mapSize),
|
||||
randIntExclusive(0, mapSize),
|
||||
randIntExclusive(0, mapSize),
|
||||
tCliff,
|
||||
clHill,
|
||||
14
|
||||
@@ -395,7 +395,7 @@ group = new SimpleGroup(
|
||||
);
|
||||
createObjectGroups(group, 0,
|
||||
avoidClasses(clForest, 0, clPlayer, 20, clHill, 1, clFood, 10, clCP, 2),
|
||||
randInt(1, 4) * numPlayers + 2, 50
|
||||
randIntInclusive(1, 4) * numPlayers + 2, 50
|
||||
);
|
||||
|
||||
// create camels
|
||||
|
||||
@@ -443,7 +443,7 @@ group = new SimpleGroup(
|
||||
);
|
||||
createObjectGroups(group, 0,
|
||||
avoidClasses(clWater, 3, clForest, 0, clPlayer, 15, clHill, 1, clFood, 7),
|
||||
randInt(1, 4) * numPlayers + 2, 50
|
||||
randIntInclusive(1, 4) * numPlayers + 2, 50
|
||||
);
|
||||
|
||||
RMS.SetProgress(90);
|
||||
|
||||
@@ -745,7 +745,7 @@ createObjectGroups(group, 0, avoidClasses(clWater, 3, clForest, 0, clPlayer, 20,
|
||||
|
||||
log("Creating berry bush...");
|
||||
group = new SimpleGroup( [new SimpleObject(oBerryBush, 5,7, 0,4)],true, clFood );
|
||||
createObjectGroups(group, 0, avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clPyrenneans, 1, clFood, 10), randInt(1, 4) * numPlayers + 2, 50 );
|
||||
createObjectGroups(group, 0, avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clPyrenneans, 1, clFood, 10), randIntInclusive(1, 4) * numPlayers + 2, 50);
|
||||
|
||||
log("Creating fish...");
|
||||
group = new SimpleGroup( [new SimpleObject(oFish, 2,3, 0,2)], true, clFood );
|
||||
|
||||
@@ -381,7 +381,7 @@ group = new SimpleGroup(
|
||||
);
|
||||
createObjectGroups(group, 0,
|
||||
avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10),
|
||||
randInt(1, 4) * numPlayers + 2, 50
|
||||
randIntInclusive(1, 4) * numPlayers + 2, 50
|
||||
);
|
||||
|
||||
RMS.SetProgress(80);
|
||||
|
||||
@@ -134,8 +134,8 @@ function randomizePlacerCoordinates(placer, halfMapSize)
|
||||
else
|
||||
{
|
||||
// Rectangular coordinates
|
||||
placer.x = randInt(g_Map.size);
|
||||
placer.z = randInt(g_Map.size);
|
||||
placer.x = randIntExclusive(0, g_Map.size);
|
||||
placer.z = randIntExclusive(0, g_Map.size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -637,9 +637,7 @@ function createMountain(maxHeight, minRadius, maxRadius, numCircles, constraint,
|
||||
var [cx, cz] = pickRandom(edges);
|
||||
|
||||
if (queueEmpty)
|
||||
{
|
||||
var radius = randInt(minRadius, maxRadius);
|
||||
}
|
||||
var radius = randIntInclusive(minRadius, maxRadius);
|
||||
else
|
||||
{
|
||||
var radius = q.pop();
|
||||
@@ -787,7 +785,7 @@ function createMountain(maxHeight, minRadius, maxRadius, numCircles, constraint,
|
||||
dz = iz - cz;
|
||||
distance2 = dx * dx + dz * dz;
|
||||
|
||||
var newHeight = round((Math.sin(PI*(2*((radius - sqrt(distance2))/radius)/3 - 1/6)) + 0.5) * 2 / 3 *clumpHeight) + randInt(0,2);
|
||||
var newHeight = Math.round((Math.sin(PI * (2 * ((radius - Math.sqrt(distance2)) / radius) / 3 - 1/6)) + 0.5) * 2/3 * clumpHeight) + randIntInclusive(0, 2);
|
||||
|
||||
if (dx * dx + dz * dz <= radius2)
|
||||
{
|
||||
|
||||
@@ -158,7 +158,7 @@ ChainPlacer.prototype.place = function(constraint)
|
||||
{
|
||||
var [cx, cz] = pickRandom(edges);
|
||||
if (queueEmpty)
|
||||
var radius = randInt(this.minRadius, this.maxRadius);
|
||||
var radius = randIntInclusive(this.minRadius, this.maxRadius);
|
||||
else
|
||||
{
|
||||
var radius = this.q.pop();
|
||||
@@ -344,11 +344,9 @@ function SimpleObject(type, minCount, maxCount, minDistance, maxDistance, minAng
|
||||
SimpleObject.prototype.place = function(cx, cz, player, avoidSelf, constraint, maxFailCount = 20)
|
||||
{
|
||||
var failCount = 0;
|
||||
var count = randInt(this.minCount, this.maxCount);
|
||||
var resultObjs = [];
|
||||
|
||||
for (var i=0; i < count; i++)
|
||||
{
|
||||
for (var i = 0; i < randIntInclusive(this.minCount, this.maxCount); ++i)
|
||||
while(true)
|
||||
{
|
||||
var distance = randFloat(this.minDistance, this.maxDistance);
|
||||
@@ -395,7 +393,6 @@ SimpleObject.prototype.place = function(cx, cz, player, avoidSelf, constraint, m
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resultObjs;
|
||||
};
|
||||
@@ -435,11 +432,9 @@ function RandomObject(types, minCount, maxCount, minDistance, maxDistance, minAn
|
||||
RandomObject.prototype.place = function(cx, cz, player, avoidSelf, constraint, maxFailCount = 20)
|
||||
{
|
||||
var failCount = 0;
|
||||
var count = randInt(this.minCount, this.maxCount);
|
||||
var resultObjs = [];
|
||||
|
||||
for (var i=0; i < count; i++)
|
||||
{
|
||||
for (var i = 0; i < randIntInclusive(this.minCount, this.maxCount); ++i)
|
||||
while(true)
|
||||
{
|
||||
var distance = randFloat(this.minDistance, this.maxDistance);
|
||||
@@ -486,7 +481,6 @@ RandomObject.prototype.place = function(cx, cz, player, avoidSelf, constraint, m
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resultObjs;
|
||||
};
|
||||
|
||||
@@ -62,7 +62,7 @@ function randomizeBiome(avoid = [])
|
||||
{
|
||||
let biomeIndex;
|
||||
do
|
||||
biomeIndex = randInt(1, 8);
|
||||
biomeIndex = randIntInclusive(1, 8);
|
||||
while (avoid.indexOf(biomeIndex) != -1);
|
||||
|
||||
setBiome(biomeIndex);
|
||||
@@ -142,13 +142,13 @@ function setBiome(biomeIndex)
|
||||
"metalLarge": "gaia/geology_metal_temperate_slabs"
|
||||
};
|
||||
|
||||
var random_trees = randInt(3);
|
||||
if (random_trees == 0)
|
||||
var random_trees = randIntInclusive(1, 3);
|
||||
if (random_trees == 1)
|
||||
{
|
||||
g_Gaia.tree1 = "gaia/flora_tree_oak";
|
||||
g_Gaia.tree2 = "gaia/flora_tree_oak_large";
|
||||
}
|
||||
else if (random_trees == 1)
|
||||
else if (random_trees == 2)
|
||||
{
|
||||
g_Gaia.tree1 = "gaia/flora_tree_poplar";
|
||||
g_Gaia.tree2 = "gaia/flora_tree_poplar";
|
||||
@@ -159,13 +159,13 @@ function setBiome(biomeIndex)
|
||||
g_Gaia.tree2 = "gaia/flora_tree_euro_beech";
|
||||
}
|
||||
g_Gaia.tree3 = "gaia/flora_tree_apple";
|
||||
random_trees = randInt(3);
|
||||
if (random_trees == 0)
|
||||
random_trees = randIntInclusive(1, 3);
|
||||
if (random_trees == 1)
|
||||
{
|
||||
g_Gaia.tree4 = "gaia/flora_tree_pine";
|
||||
g_Gaia.tree5 = "gaia/flora_tree_aleppo_pine";
|
||||
}
|
||||
else if (random_trees == 1)
|
||||
else if (random_trees == 2)
|
||||
{
|
||||
g_Gaia.tree4 = "gaia/flora_tree_pine";
|
||||
g_Gaia.tree5 = "gaia/flora_tree_pine";
|
||||
@@ -439,13 +439,13 @@ function setBiome(biomeIndex)
|
||||
"metalLarge": "gaia/geology_metal_mediterranean_slabs"
|
||||
};
|
||||
|
||||
var random_trees = randInt(3);
|
||||
if (random_trees == 0)
|
||||
var random_trees = randIntInclusive(1, 3);
|
||||
if (random_trees == 1)
|
||||
{
|
||||
g_Gaia.tree1 = "gaia/flora_tree_cretan_date_palm_short";
|
||||
g_Gaia.tree2 = "gaia/flora_tree_cretan_date_palm_tall";
|
||||
}
|
||||
else if (random_trees == 1)
|
||||
else if (random_trees == 2)
|
||||
{
|
||||
g_Gaia.tree1 = "gaia/flora_tree_carob";
|
||||
g_Gaia.tree2 = "gaia/flora_tree_carob";
|
||||
|
||||
@@ -69,8 +69,8 @@ function createMountains(terrain, constraint, tileclass, count, maxHeight, minRa
|
||||
maxRadius,
|
||||
numCircles,
|
||||
constraint,
|
||||
randInt(mapSize),
|
||||
randInt(mapSize),
|
||||
randIntExclusive(0, mapSize),
|
||||
randIntExclusive(0, mapSize),
|
||||
terrain,
|
||||
tileclass,
|
||||
14
|
||||
|
||||
@@ -861,7 +861,7 @@ function placeIrregularPolygonalWall(centerX, centerY, radius, cornerWallElement
|
||||
style = style || "palisades";
|
||||
playerId = playerId || 0;
|
||||
orientation = orientation || 0;
|
||||
numCorners = numCorners || randInt(5, 7);
|
||||
numCorners = numCorners || randIntInclusive(5, 7);
|
||||
irregularity = irregularity || 0.5;
|
||||
skipFirstWall = skipFirstWall || false;
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ function addBluffs(constraint, size, deviation, fill)
|
||||
var bb = createBoundingBox(points, corners);
|
||||
|
||||
// Get a random starting position for the baseline and the endline
|
||||
var angle = randInt(4);
|
||||
var angle = randIntInclusive(0, 3);
|
||||
var opAngle = angle - 2;
|
||||
if (angle < 2)
|
||||
opAngle = angle + 2;
|
||||
@@ -390,7 +390,7 @@ function addElevation(constraint, el)
|
||||
|
||||
for (var i = 0; i < count; ++i)
|
||||
{
|
||||
var elevation = el.minElevation + randInt(el.maxElevation - el.minElevation);
|
||||
var elevation = randIntExclusive(el.minElevation, el.maxElevation);
|
||||
var smooth = Math.floor(elevation / el.steepness);
|
||||
|
||||
var offset = getRandomDeviation(size, el.deviation);
|
||||
@@ -592,7 +592,7 @@ function addPlateaus(constraint, size, deviation, fill)
|
||||
{
|
||||
var placer = new ChainPlacer(3, 15, 1, 0.5);
|
||||
var terrainPainter = new LayeredPainter([plateauTile, plateauTile], [3]);
|
||||
var hillElevation = 4 + randInt(15);
|
||||
var hillElevation = randIntInclusive(4, 18);
|
||||
var elevationPainter = new SmoothElevationPainter(ELEVATION_MODIFY, hillElevation, hillElevation - 2);
|
||||
|
||||
createAreas(
|
||||
@@ -1263,7 +1263,7 @@ function nextToFeature(bb, x, z)
|
||||
function getRandomDeviation(base, deviation)
|
||||
{
|
||||
deviation = Math.min(base, deviation);
|
||||
deviation = base + randInt(20 * deviation) / 10 - deviation;
|
||||
deviation = base + randIntExclusive(0, 20 * deviation) / 10 - deviation;
|
||||
return deviation.toFixed(2);
|
||||
}
|
||||
|
||||
|
||||
@@ -213,8 +213,8 @@ log("Creating stone mines...");
|
||||
// create stone mines
|
||||
for (var i = 0; i < scaleByMapSize(12,30); ++i)
|
||||
{
|
||||
var mX = randInt(mapSize);
|
||||
var mZ = randInt(mapSize);
|
||||
var mX = randIntExclusive(0, mapSize);
|
||||
var mZ = randIntExclusive(0, mapSize);
|
||||
if (playerConstraint.allows(mX, mZ) && minesConstraint.allows(mX, mZ) && waterConstraint.allows(mX, mZ))
|
||||
{
|
||||
createStoneMineFormation(mX, mZ, tDirt4);
|
||||
@@ -309,7 +309,7 @@ group = new SimpleGroup(
|
||||
);
|
||||
createObjectGroups(group, 0,
|
||||
avoidClasses(clWater, 3, clPlayer, 20, clFood, 12, clRock, 7, clMetal, 6),
|
||||
randInt(1, 4) * numPlayers + 2, 50
|
||||
randIntInclusive(1, 4) * numPlayers + 2, 50
|
||||
);
|
||||
|
||||
RMS.SetProgress(85);
|
||||
|
||||
@@ -476,7 +476,7 @@ group = new SimpleGroup(
|
||||
);
|
||||
createObjectGroups(group, 0,
|
||||
avoidClasses(clWater, 3, clForest, 0, clPlayer, 20, clHill, 1, clFood, 10),
|
||||
randInt(1, 4) * numPlayers + 2, 50
|
||||
randIntInclusive(1, 4) * numPlayers + 2, 50
|
||||
);
|
||||
|
||||
RMS.SetProgress(85);
|
||||
|
||||
Reference in New Issue
Block a user