Index: binaries/data/mods/public/globalscripts/random.js =================================================================== --- binaries/data/mods/public/globalscripts/random.js +++ binaries/data/mods/public/globalscripts/random.js @@ -57,9 +57,9 @@ } /** - * Returns true or false randomly. + * Returns a Bernoulli distributed boolean with p chance on true. */ -function randBool() +function randBool(p = 0.5) { - return Math.random() < 0.5; + return Math.random() < p; } Index: binaries/data/mods/public/maps/random/aegean_sea.js =================================================================== --- binaries/data/mods/public/maps/random/aegean_sea.js +++ binaries/data/mods/public/maps/random/aegean_sea.js @@ -252,7 +252,7 @@ RMS.SetProgress(50); // create hills -if (randInt(1,2) == 1) +if (randBool()) createHills([tGrass, tCliff, tHill], avoidClasses(clPlayer, 20, clForest, 1, clHill, 15, clWater, 3), clHill, scaleByMapSize(3, 15)); else createMountains(tCliff, avoidClasses(clPlayer, 20, clForest, 1, clHill, 15, clWater, 3), clHill, scaleByMapSize(3, 15)); Index: binaries/data/mods/public/maps/random/alpine_lakes.js =================================================================== --- binaries/data/mods/public/maps/random/alpine_lakes.js +++ binaries/data/mods/public/maps/random/alpine_lakes.js @@ -1,10 +1,7 @@ RMS.LoadLibrary("rmgen"); -//set up the random terrain -var random_var = randInt(1,2); - -//late spring -if (random_var == 1) +// late spring +if (randBool()) { setFogThickness(0.26); setFogFactor(0.4); Index: binaries/data/mods/public/maps/random/alpine_valley.js =================================================================== --- binaries/data/mods/public/maps/random/alpine_valley.js +++ binaries/data/mods/public/maps/random/alpine_valley.js @@ -2,11 +2,8 @@ TILE_CENTERED_HEIGHT_MAP = true; -//set up the random terrain -var random_terrain = randInt(1,2); - -//late spring -if (random_terrain == 1) +// late spring +if (randBool()) { var tPrimary = ["alpine_dirt_grass_50"]; var tForestFloor = "alpine_forrestfloor"; Index: binaries/data/mods/public/maps/random/archipelago.js =================================================================== --- binaries/data/mods/public/maps/random/archipelago.js +++ binaries/data/mods/public/maps/random/archipelago.js @@ -214,7 +214,7 @@ createBumps([avoidClasses(clPlayer, 10), stayClasses(clLand, 5)]); -if (randInt(1,2) == 1) +if (randBool()) createHills([tMainTerrain, tCliff, tHill], [avoidClasses(clPlayer, 2, clHill, 15), stayClasses(clLand, 0)], clHill, scaleByMapSize(1, 4) * numPlayers); else createMountains(tCliff, [avoidClasses(clPlayer, 2, clHill, 15), stayClasses(clLand, 0)], clHill, scaleByMapSize(1, 4) * numPlayers); Index: binaries/data/mods/public/maps/random/ardennes_forest.js =================================================================== --- binaries/data/mods/public/maps/random/ardennes_forest.js +++ binaries/data/mods/public/maps/random/ardennes_forest.js @@ -396,8 +396,8 @@ explorableArea.points.push(pt); } - if (h > 35 && g_Map.validT(ix, iz) && randFloat(0, 1) < 0.1 || - h < 15 && g_Map.validT(ix, iz) && randFloat(0, 1) < 0.05 && hillDecoClass.countMembersInRadius(ix, iz, 1) == 0) + if (h > 35 && g_Map.validT(ix, iz) && randBool(0.1) || + h < 15 && g_Map.validT(ix, iz) && randBool(0.05) && hillDecoClass.countMembersInRadius(ix, iz, 1) == 0) placeObject(ix + randFloat(0, 1), iz + randFloat(0, 1), pickRandom(aTrees), 0, randFloat(0, 2 * PI)); } } Index: binaries/data/mods/public/maps/random/belgian_uplands.js =================================================================== --- binaries/data/mods/public/maps/random/belgian_uplands.js +++ binaries/data/mods/public/maps/random/belgian_uplands.js @@ -301,97 +301,97 @@ // Add some props at... if (i == 0) // ...deep water { - if (randFloat() < 1/100 * propDensity) + if (randBool(propDensity / 100)) placeObject(x, y, "actor|props/flora/pond_lillies_large.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/40 * propDensity) + else if (randBool(propDensity / 40)) placeObject(x, y, "actor|props/flora/water_lillies.xml", 0, randFloat(0, 2*PI)); } if (i == 1) // ...medium water (with fish) { - if (randFloat() < 1/200 * propDensity) + if (randBool(propDensity / 200)) placeObject(x, y, "actor|props/flora/pond_lillies_large.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/100 * propDensity) + else if (randBool(propDensity / 100)) placeObject(x, y, "actor|props/flora/water_lillies.xml", 0, randFloat(0, 2*PI)); } if (i == 2) // ...low water/mud { - if (randFloat() < 1/200 * propDensity) + if (randBool(propDensity / 200)) placeObject(x, y, "actor|props/flora/water_log.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/100 * propDensity) + else if (randBool(propDensity / 100)) placeObject(x, y, "actor|props/flora/water_lillies.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/40 * propDensity) + else if (randBool(propDensity / 40)) placeObject(x, y, "actor|geology/highland_c.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/20 * propDensity) + else if (randBool(propDensity / 20)) placeObject(x, y, "actor|props/flora/reeds_pond_lush_b.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/10 * propDensity) + else if (randBool(propDensity / 10)) placeObject(x, y, "actor|props/flora/reeds_pond_lush_a.xml", 0, randFloat(0, 2*PI)); } if (i == 3) // ...water suroundings/bog { - if (randFloat() < 1/200 * propDensity) + if (randBool(propDensity / 200)) placeObject(x, y, "actor|props/flora/water_log.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/100 * propDensity) + else if (randBool(propDensity / 100)) placeObject(x, y, "actor|geology/highland_c.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/40 * propDensity) + else if (randBool(propDensity / 40)) placeObject(x, y, "actor|props/flora/reeds_pond_lush_a.xml", 0, randFloat(0, 2*PI)); } if (i == 4) // ...low height grass { - if (randFloat() < 1/800 * propDensity) + if (randBool(propDensity / 800)) placeObject(x, y, "actor|props/flora/grass_field_flowering_tall.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/400 * propDensity) + else if (randBool(propDensity / 400)) placeObject(x, y, "actor|geology/gray_rock1.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/200 * propDensity) + else if (randBool(propDensity / 200)) placeObject(x, y, "actor|props/flora/bush_tempe_sm_lush.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/100 * propDensity) + else if (randBool(propDensity / 100)) placeObject(x, y, "actor|props/flora/bush_tempe_b.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/40 * propDensity) + else if (randBool(propDensity / 40)) placeObject(x, y, "actor|props/flora/grass_soft_small_tall.xml", 0, randFloat(0, 2*PI)); } if (i == 5) // ...medium height grass { - if (randFloat() < 1/800 * propDensity) + if (randBool(propDensity / 800)) placeObject(x, y, "actor|geology/decal_stone_medit_a.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/400 * propDensity) + else if (randBool(propDensity / 400)) placeObject(x, y, "actor|props/flora/decals_flowers_daisies.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/200 * propDensity) + else if (randBool(propDensity / 200)) placeObject(x, y, "actor|props/flora/bush_tempe_underbrush.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/100 * propDensity) + else if (randBool(propDensity / 100)) placeObject(x, y, "actor|props/flora/grass_soft_small_tall.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/40 * propDensity) + else if (randBool(propDensity / 40)) placeObject(x, y, "actor|props/flora/grass_temp_field.xml", 0, randFloat(0, 2*PI)); } if (i == 6) // ...high height grass { - if (randFloat() < 1/400 * propDensity) + if (randBool(propDensity / 400)) placeObject(x, y, "actor|geology/stone_granite_boulder.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/200 * propDensity) + else if (randBool(propDensity / 200)) placeObject(x, y, "actor|props/flora/foliagebush.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/100 * propDensity) + else if (randBool(propDensity / 100)) placeObject(x, y, "actor|props/flora/bush_tempe_underbrush.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/40 * propDensity) + else if (randBool(propDensity / 40)) placeObject(x, y, "actor|props/flora/grass_soft_small_tall.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/20 * propDensity) + else if (randBool(propDensity / 20)) placeObject(x, y, "actor|props/flora/ferns.xml", 0, randFloat(0, 2*PI)); } if (i == 7) // ...forest border (with wood/food plants/deer/rabits) { - if (randFloat() < 1/400 * propDensity) + if (randBool(propDensity / 400)) placeObject(x, y, "actor|geology/highland_c.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/200 * propDensity) + else if (randBool(propDensity / 200)) placeObject(x, y, "actor|props/flora/bush_tempe_a.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/100 * propDensity) + else if (randBool(propDensity / 100)) placeObject(x, y, "actor|props/flora/ferns.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/40 * propDensity) + else if (randBool(propDensity / 40)) placeObject(x, y, "actor|props/flora/grass_soft_tuft_a.xml", 0, randFloat(0, 2*PI)); } if (i == 8) // ...woods { - if (randFloat() < 1/200 * propDensity) + if (randBool(propDensity / 200)) placeObject(x, y, "actor|geology/highland2_moss.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/100 * propDensity) + else if (randBool(propDensity / 100)) placeObject(x, y, "actor|props/flora/grass_soft_tuft_a.xml", 0, randFloat(0, 2*PI)); - else if (randFloat() < 1/40 * propDensity) + else if (randBool(propDensity / 40)) placeObject(x, y, "actor|props/flora/ferns.xml", 0, randFloat(0, 2*PI)); } break; Index: binaries/data/mods/public/maps/random/caledonian_meadows.js =================================================================== --- binaries/data/mods/public/maps/random/caledonian_meadows.js +++ binaries/data/mods/public/maps/random/caledonian_meadows.js @@ -711,13 +711,13 @@ let texture = pickRandom(myBiome[h].texture); if (slopeMap[x][y] < 0.4 * (minSlope[h] + maxSlope[h])) { - if (randFloat() < myBiome[h].actor[1]) + if (randBool(myBiome[h].actor[1])) actor = pickRandom(myBiome[h].actor[0]); } else { texture = pickRandom(myBiome[h].textureHS); - if (randFloat() < myBiome[h].actorHS[1]) + if (randBool(myBiome[h].actorHS[1])) actor = pickRandom(myBiome[h].actorHS[0]); } g_Map.setTexture(x, y, texture); Index: binaries/data/mods/public/maps/random/continent.js =================================================================== --- binaries/data/mods/public/maps/random/continent.js +++ binaries/data/mods/public/maps/random/continent.js @@ -226,8 +226,7 @@ // create bumps createBumps([avoidClasses(clPlayer, 10), stayClasses(clLand, 5)]); -// create hills -if (randInt(1,2) == 1) +if (randBool()) createHills([tMainTerrain, tCliff, tHill], [avoidClasses(clPlayer, 20, clHill, 15, clBaseResource, 3), stayClasses(clLand, 5)], clHill, scaleByMapSize(1, 4) * numPlayers); else createMountains(tCliff, [avoidClasses(clPlayer, 20, clHill, 15, clBaseResource, 3), stayClasses(clLand, 5)], clHill, scaleByMapSize(1, 4) * numPlayers); Index: binaries/data/mods/public/maps/random/corinthian_isthmus.js =================================================================== --- binaries/data/mods/public/maps/random/corinthian_isthmus.js +++ binaries/data/mods/public/maps/random/corinthian_isthmus.js @@ -249,7 +249,7 @@ RMS.SetProgress(50); // create hills -if (randInt(1,2) == 1) +if (randBool()) createHills([tGrass, tCliff, tHill], avoidClasses(clPlayer, 20, clForest, 1, clHill, 15, clWater, 3), clHill, scaleByMapSize(3, 15)); else createMountains(tCliff, avoidClasses(clPlayer, 20, clForest, 1, clHill, 15, clWater, 3), clHill, scaleByMapSize(3, 15)); Index: binaries/data/mods/public/maps/random/corsica.js =================================================================== --- binaries/data/mods/public/maps/random/corsica.js +++ binaries/data/mods/public/maps/random/corsica.js @@ -106,7 +106,7 @@ } // let's decide if we swap -var swap = Math.round(Math.random()); // should return about 50/50 a 0 or a 1 +var swap = randBool(); // let's create Corsica log("Creating Corsica"); var CorsicaX = fractionToTiles(0.99); @@ -189,11 +189,8 @@ fz = radius * sin(angle); fx = round(islandX[island] + fx); fz = round(islandZ[island] + fz); - var size = scaleByMapSize(75,100); - if (Math.random() > 0.5) - size = Math.random() * 40 + 10; - else - size += Math.random() * 20; + + var size = randBool() ? randFloat(10, 50) : scaleByMapSize(75,100) + randFloat(0, 20); var placer = new ClumpPlacer(size, 0.4, 0.01, 10, fx,fz); var terrainPainter = new TerrainPainter(tSteepCliffs); var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -5,0); // base height is -10 Index: binaries/data/mods/public/maps/random/deep_forest.js =================================================================== --- binaries/data/mods/public/maps/random/deep_forest.js +++ binaries/data/mods/public/maps/random/deep_forest.js @@ -226,7 +226,7 @@ var tDensFactRad = abs((resourceRadius - radius) / resourceRadius); var tDensFactEC = max(min((radius - radiusEC) / radiusEC, 1), 0); var tDensActual = maxTreeDensity * tDensFactSL * tDensFactRad * tDensFactEC; - if (randFloat() < tDensActual && radius < playableMapRadius) + if (randBool(tDensActual) && radius < playableMapRadius) { if (tDensActual < bushChance*randFloat()*maxTreeDensity) { Index: binaries/data/mods/public/maps/random/english_channel.js =================================================================== --- binaries/data/mods/public/maps/random/english_channel.js +++ binaries/data/mods/public/maps/random/english_channel.js @@ -225,9 +225,11 @@ log("Creating rivers"); for (var i = 0; i <= randInt(8, (scaleByMapSize(12,20))); i++) { - var cLocation = randFloat(0.05,0.95); - var tang = 2*PI * randFloat(0.2, 0.8) * (randInt(2) - 0.5); - var cDistance = 0.05 * (tang > 0 ? 1 : -1); + var cLocation = randFloat(0.05, 0.95); + + var sign = randBool() ? 1 : -1; + var tang = sign * PI * randFloat(0.2, 0.8); + var cDistance = sign * 0.05; var point = getTIPIADBON([fractionToTiles(cLocation), fractionToTiles(0.5 + cDistance)], [fractionToTiles(cLocation), fractionToTiles(0.5 - cDistance)], [-6, -1.5], 0.5, 4, 0.01); if (point !== undefined) Index: binaries/data/mods/public/maps/random/gear.js =================================================================== --- binaries/data/mods/public/maps/random/gear.js +++ binaries/data/mods/public/maps/random/gear.js @@ -354,7 +354,7 @@ createArea(placer, painter, null); } -if (randInt(1,2) == 1) +if (randBool()) createHills([tMainTerrain, tCliff, tHill], avoidClasses(clPlayer, 20, clHill, 15, clWater, 2), clHill, scaleByMapSize(1, 4) * numPlayers); else createMountains(tCliff, avoidClasses(clPlayer, 20, clHill, 15, clWater, 2), clHill, scaleByMapSize(1, 4) * numPlayers); Index: binaries/data/mods/public/maps/random/gulf_of_bothnia.js =================================================================== --- binaries/data/mods/public/maps/random/gulf_of_bothnia.js +++ binaries/data/mods/public/maps/random/gulf_of_bothnia.js @@ -350,7 +350,7 @@ createBumps(avoidClasses(clWater, 2, clPlayer, 10)); // create hills -if (randInt(1,2) == 1) +if (randBool()) createHills([tPrimary, tCliff, tPrimary], avoidClasses(clPlayer, 20, clHill, 15, clWater, 0), clHill, scaleByMapSize(1, 4) * numPlayers); else createMountains(tCliff, avoidClasses(clPlayer, 20, clHill, 15, clWater, 0), clHill, scaleByMapSize(1, 4) * numPlayers); Index: binaries/data/mods/public/maps/random/lake.js =================================================================== --- binaries/data/mods/public/maps/random/lake.js +++ binaries/data/mods/public/maps/random/lake.js @@ -239,7 +239,7 @@ createBumps(avoidClasses(clWater, 2, clPlayer, 20)); // create hills -if (randInt(1,2) == 1) +if (randBool()) createHills([tMainTerrain, tCliff, tHill], avoidClasses(clPlayer, 20, clHill, 15, clWater, 2), clHill, scaleByMapSize(1, 4) * numPlayers); else createMountains(tCliff, avoidClasses(clPlayer, 20, clHill, 15, clWater, 2), clHill, scaleByMapSize(1, 4) * numPlayers); Index: binaries/data/mods/public/maps/random/latium.js =================================================================== --- binaries/data/mods/public/maps/random/latium.js +++ binaries/data/mods/public/maps/random/latium.js @@ -299,7 +299,7 @@ var forestNoise = (noise6.get(x,z) + 0.5*noise7.get(x,z)) / 1.5 * pn - 0.59; // Thin out trees a bit - if (forestNoise > 0 && randFloat() < 0.5) + if (forestNoise > 0 && randBool()) { if (minH < 11 && minH >= 4) { @@ -333,14 +333,14 @@ else if (grassNoise < 0.34) { t = (diffH > 1.2) ? tGrassCliff : tGrassDry; - if (diffH < 0.5 && randFloat() < 0.02) + if (diffH < 0.5 && randBool(0.02)) placeObject(ix+randFloat(), iz+randFloat(), aGrassDry, 0, randFloat(0, TWO_PI)); } else if (grassNoise > 0.61) { t = (diffH > 1.2 ? tGrassRock : tGrassShrubs); } - else if (diffH < 0.5 && randFloat() < 0.02) + else if (diffH < 0.5 && randBool(0.02)) placeObject(ix+randFloat(), iz+randFloat(), aGrass, 0, randFloat(0, TWO_PI)); } Index: binaries/data/mods/public/maps/random/lorraine_plain.js =================================================================== --- binaries/data/mods/public/maps/random/lorraine_plain.js +++ binaries/data/mods/public/maps/random/lorraine_plain.js @@ -218,19 +218,14 @@ // create tributaries log("Creating tributaries"); - -for (var i = 0; i <= randInt(8, (scaleByMapSize(12,20))); i++) +for (let 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); - if (tang > 0) - { - var cDistance = 0.05; - } - else - { - var cDistance = -0.05; - } + var cLocation = randFloat(0.05, 0.95); + + let sign = randBool() ? 1 : -1; + let tang = sign * PI * randFloat(0.2, 0.8); + let cDistance = sign * 0.05; + var point = getTIPIADBON([fractionToTiles(cLocation), fractionToTiles(0.5 + cDistance)], [fractionToTiles(cLocation), fractionToTiles(0.5 - cDistance)], [-6, -1.5], 0.5, 5, 0.01); if (point !== undefined) { Index: binaries/data/mods/public/maps/random/mainland.js =================================================================== --- binaries/data/mods/public/maps/random/mainland.js +++ binaries/data/mods/public/maps/random/mainland.js @@ -187,7 +187,7 @@ createBumps(); // create hills -if (randInt(1,2) == 1) +if (randBool()) createHills([tCliff, tCliff, tHill], avoidClasses(clPlayer, 20, clHill, 15), clHill, scaleByMapSize(3, 15)); else createMountains(tCliff, avoidClasses(clPlayer, 20, clHill, 15), clHill, scaleByMapSize(3, 15)); Index: binaries/data/mods/public/maps/random/oasis.js =================================================================== --- binaries/data/mods/public/maps/random/oasis.js +++ binaries/data/mods/public/maps/random/oasis.js @@ -243,7 +243,8 @@ var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -3, 15 ); createArea(placer, [terrainPainter, elevationPainter, paintClass(clWater)], null); RMS.SetProgress(50); -if(mapSize > 150 && randInt(0,1)) { +if (mapSize > 150 && randBool()) +{ log ("creating path through"); var pAngle = randFloat(0, TWO_PI); var px = round(fx) + round(fractionToTiles(0.13 * cos(pAngle))); @@ -354,28 +355,28 @@ { if (getHeight(sandx,sandz) > 3.4) { - if (Math.random()* 1.4 < getHeight(sandx,sandz) - 3.4) + if (randBool((getHeight(sandx,sandz) - 3.4) / 1.4)) { group = new SimpleGroup( [new SimpleObject(aSand, 0,1, 0,2)], true, undefined, sandx,sandz ); createObjectGroup(group, 0); } } else if (getHeight(sandx,sandz) > -2.5 && getHeight(sandx,sandz) < -1.0) { - if (Math.random() < 0.4) + if (randBool(0.4)) { group = new SimpleGroup( [new SimpleObject(aWaterFlower, 1,4, 1,2)], true, undefined, sandx,sandz ); createObjectGroup(group, 0); - } else if (Math.random() > 0.3 && getHeight(sandx,sandz) < -1.9) + } else if (randBool(0.7) && getHeight(sandx,sandz) < -1.9) { group = new SimpleGroup( [new SimpleObject(aReedsA, 5,12, 0,2),new SimpleObject(aReedsB, 5,12, 0,2)], true, undefined, sandx,sandz ); createObjectGroup(group, 0); } if (getTileClass(clPassage).countInRadius(sandx,sandz,2,true) > 0) { - if (Math.random() < 0.4) + if (randBool(0.4)) { group = new SimpleGroup( [new SimpleObject(aWaterFlower, 1,4, 1,2)], true, undefined, sandx,sandz ); createObjectGroup(group, 0); - } else if (Math.random() > 0.3 && getHeight(sandx,sandz) < -1.9) + } else if (randBool(0.7) && getHeight(sandx,sandz) < -1.9) { group = new SimpleGroup( [new SimpleObject(aReedsA, 5,12, 0,2),new SimpleObject(aReedsB, 5,12, 0,2)], true, undefined, sandx,sandz ); createObjectGroup(group, 0); Index: binaries/data/mods/public/maps/random/persian_highlands.js =================================================================== --- binaries/data/mods/public/maps/random/persian_highlands.js +++ binaries/data/mods/public/maps/random/persian_highlands.js @@ -1,8 +1,8 @@ RMS.LoadLibrary("rmgen"); const tCity = "desert_city_tile_pers_dirt"; -var random_season = randInt(0,1); -if (random_season) //summer + +if (randBool()) // summer { var tDirtMain = ["desert_dirt_persia_1", "desert_dirt_persia_2", "grass_field_dry"]; var tLakebed1 = ["desert_lakebed_dry_b", "desert_lakebed_dry"]; @@ -27,6 +27,8 @@ var tRocks = "desert_plants_a"; var tGrass = "desert_dirt_persia_rocky"; var tHill = "desert_cliff_persia_base"; + + setTerrainAmbientColor(0.329412, 0.419608, 0.501961); } // gaia entities @@ -426,9 +428,6 @@ ); } -if (!random_season) - setTerrainAmbientColor(0.329412, 0.419608, 0.501961); - setSunColor(1.0, 0.796, 0.374); setSunElevation(PI / 6); setSunRotation(-1.86532); Index: binaries/data/mods/public/maps/random/polar_sea.js =================================================================== --- binaries/data/mods/public/maps/random/polar_sea.js +++ binaries/data/mods/public/maps/random/polar_sea.js @@ -321,7 +321,7 @@ ); RMS.SetProgress(95); -if (randInt(0, 2) == 0) +if (randBool(0.33)) { setSkySet("sunset 1"); setSunColor(0.8, 0.7, 0.6); Index: binaries/data/mods/public/maps/random/rivers.js =================================================================== --- binaries/data/mods/public/maps/random/rivers.js +++ binaries/data/mods/public/maps/random/rivers.js @@ -369,7 +369,7 @@ createBumps(avoidClasses(clWater, 2, clPlayer, 20)); // create hills -if (randInt(1,2) == 1) +if (randBool()) createHills([tMainTerrain, tCliff, tHill], avoidClasses(clPlayer, 20, clHill, 15, clWater, 2), clHill, scaleByMapSize(3, 15)); else createMountains(tCliff, avoidClasses(clPlayer, 20, clHill, 15, clWater, 2), clHill, scaleByMapSize(3, 15)); Index: binaries/data/mods/public/maps/random/rmgen/randombiome.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen/randombiome.js +++ binaries/data/mods/public/maps/random/rmgen/randombiome.js @@ -110,7 +110,7 @@ "water": "medit_sand_wet" }; - if (randInt(2)) + if (randBool()) { g_Terrains.mainTerrain = "alpine_grass"; g_Terrains.forestFloor1 = "temp_forestfloor_pine"; @@ -296,7 +296,8 @@ "stoneSmall": "gaia/geology_stone_desert_small", "metalLarge": "gaia/geology_metal_desert_slabs" }; - if (randInt(2)) + + if (randBool()) { g_Gaia.tree1 = "gaia/flora_tree_cretan_date_palm_short"; g_Gaia.tree2 = "gaia/flora_tree_cretan_date_palm_tall"; @@ -307,7 +308,8 @@ g_Gaia.tree2 = "gaia/flora_tree_date_palm"; } g_Gaia.tree3 = "gaia/flora_tree_fig"; - if (randInt(2)) + + if (randBool()) { g_Gaia.tree4 = "gaia/flora_tree_tamarix"; g_Gaia.tree5 = "gaia/flora_tree_tamarix"; @@ -454,12 +456,12 @@ g_Gaia.tree2 = "gaia/flora_tree_medit_fan_palm"; } - if (randInt(2)) + if (randBool()) g_Gaia.tree3 = "gaia/flora_tree_apple"; else g_Gaia.tree3 = "gaia/flora_tree_poplar_lombardy"; - if (randInt(2)) + if (randBool()) { g_Gaia.tree4 = "gaia/flora_tree_cypress"; g_Gaia.tree5 = "gaia/flora_tree_cypress"; @@ -470,7 +472,7 @@ g_Gaia.tree5 = "gaia/flora_tree_aleppo_pine"; } - if (randInt(2)) + if (randBool()) g_Gaia.fruitBush = "gaia/flora_bush_berry"; else g_Gaia.fruitBush = "gaia/flora_bush_grapes"; Index: binaries/data/mods/public/maps/random/rmgen2/setup.js =================================================================== --- binaries/data/mods/public/maps/random/rmgen2/setup.js +++ binaries/data/mods/public/maps/random/rmgen2/setup.js @@ -518,7 +518,7 @@ let strongholdBasesRandom = shuffleArray(strongholdBases); let singleBasesRandom = shuffleArray(singleBases); - if (randInt(2) == 1 && + if (randBool() && g_MapInfo.mapSize >= 256 && g_MapInfo.teams.length >= 2 && g_MapInfo.teams.length < g_MapInfo.numPlayers && Index: binaries/data/mods/public/maps/random/schwarzwald.js =================================================================== --- binaries/data/mods/public/maps/random/schwarzwald.js +++ binaries/data/mods/public/maps/random/schwarzwald.js @@ -432,7 +432,7 @@ var tDensFactRad = abs((resourceRadius - radius) / resourceRadius); var tDensActual = (maxTreeDensity * tDensFactSL * tDensFactRad)*0.75; - if (randFloat() < tDensActual && radius < playableMapRadius) + if (randBool(tDensActual) && radius < playableMapRadius) { if (tDensActual < bushChance*randFloat()*maxTreeDensity) { Index: binaries/data/mods/public/maps/random/survivalofthefittest.js =================================================================== --- binaries/data/mods/public/maps/random/survivalofthefittest.js +++ binaries/data/mods/public/maps/random/survivalofthefittest.js @@ -219,7 +219,7 @@ createBumps([avoidClasses(clWater, 2, clPlayer, 10), stayClasses(clLand, 5)]); // create hills -if (randInt(1,2) == 1) +if (randBool()) createHills([tMainTerrain, tCliff, tHill], [avoidClasses(clPlayer, 20, clHill, 5, clBaseResource, 3, clWomen, 5), stayClasses(clLand, 5)], clHill, scaleByMapSize(10, 60) * numPlayers); else createMountains(tCliff, [avoidClasses(clPlayer, 20, clHill, 5, clBaseResource, 3, clWomen, 5), stayClasses(clLand, 5)], clHill, scaleByMapSize(10, 60) * numPlayers); Index: binaries/data/mods/public/maps/random/unknown.js =================================================================== --- binaries/data/mods/public/maps/random/unknown.js +++ binaries/data/mods/public/maps/random/unknown.js @@ -277,7 +277,7 @@ var clPeninsulaSteam = createTileClass(); - if (randInt(1,3)==1) // peninsula + if (randBool(0.33)) // peninsula { var angle = randFloat(0, TWO_PI); @@ -356,8 +356,8 @@ var playerPos = new Array(numPlayers); var iop = 0; - var mdd1 = randInt(1,2); - if (mdd1 == 1) //vertical + var mdd1 = randBool(); + if (mdd1) // vertical { for (var i = 0; i < numPlayers; i++) { @@ -423,7 +423,7 @@ var fadeDist = 0.05; - if (mdd1 == 1) //vertical + if (mdd1) // vertical { var cu = km*rndRiver(theta+z*0.5*(mapSize/64),seed); var cu2 = km*rndRiver(theta2+z*0.5*(mapSize/64),seed2); @@ -508,13 +508,20 @@ } } - if (!randInt(3)) + if (randBool(0.33)) { // 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); - } + if (mdd1) // vertical + 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); @@ -595,8 +602,8 @@ var playerAngle = new Array(numPlayers); var playerPos = new Array(numPlayers); var iop = 0; - var mdd1 = randInt(1,2); - if (mdd1 == 1) //horizontal + var mdd1 = randBool(); + if (mdd1) // horizontal { for (var i = 0; i < numPlayers; i++) { @@ -648,10 +655,12 @@ // create the main river log("Creating the main river"); - if (mdd1 == 2) - var placer = new PathPlacer(fractionToTiles(0.5), 1, fractionToTiles(0.5) , fractionToTiles(0.99), scaleByMapSize(14,24), 0.5, 3*(scaleByMapSize(1,4)), 0.1, 0.01); - else + if (mdd1) var placer = new PathPlacer(1, fractionToTiles(0.5), fractionToTiles(0.99), fractionToTiles(0.5), scaleByMapSize(14,24), 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(14,24), 0.5, 3*(scaleByMapSize(1,4)), 0.1, 0.01); + + var terrainPainter = new LayeredPainter( [tShore, tWater, tWater], // terrains @@ -664,7 +673,7 @@ ); createArea(placer, [terrainPainter, elevationPainter], avoidClasses(clPlayer, 4)); - if (mdd1 == 1) + if (mdd1) placer = new ClumpPlacer(floor(PI*scaleByMapSize(10,20)*scaleByMapSize(10,20)/4), 0.95, 0.6, 10, 1, fractionToTiles(0.5)); else placer = new ClumpPlacer(floor(PI*scaleByMapSize(10,20)*scaleByMapSize(10,20)/4), 0.95, 0.6, 10, fractionToTiles(0.5), 1); @@ -673,7 +682,7 @@ var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -4, 2); createArea(placer, [painter, elevationPainter], avoidClasses(clPlayer, 8)); - if (mdd1 == 1) + if (mdd1) placer = new ClumpPlacer(floor(PI*scaleByMapSize(10,20)*scaleByMapSize(10,20)/4), 0.95, 0.6, 10, fractionToTiles(0.99), fractionToTiles(0.5)); else placer = new ClumpPlacer(floor(PI*scaleByMapSize(10,20)*scaleByMapSize(10,20)/4), 0.95, 0.6, 10, fractionToTiles(0.5), fractionToTiles(0.99)); @@ -682,23 +691,23 @@ var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -4, 2); createArea(placer, [painter, elevationPainter], avoidClasses(clPlayer, 8)); - var mdd2 = randInt(1,2); - if (mdd2 == 1) + var mdd2 = randBool(); + if (mdd2) { // 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++) { - var cLocation = randFloat(0.15,0.85); - if (mdd1 == 1) + var cLocation = randFloat(0.15, 0.85); + if (mdd1) passageMaker(floor(fractionToTiles(cLocation)), floor(fractionToTiles(0.35)), floor(fractionToTiles(cLocation)), floor(fractionToTiles(0.65)), scaleByMapSize(4,8), -2, -2, 2, clShallow, undefined, -4); else 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++) { @@ -715,26 +724,22 @@ // create tributaries log("Creating tributaries"); - for (var i = 0; i <= randInt(8, (scaleByMapSize(12,20))); i++) + for (let 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); - if (tang > 0) - { - var cDistance = 0.05; - } - else - { - var cDistance = -0.05; - } - if (mdd1 == 1) + var cLocation = randFloat(0.05, 0.95); + + var sign = randBool() ? 1 : -1; + var tang = sign * PI * randFloat(0.2, 0.8); + var cDistance = sign * 0.05; + + if (mdd1) var point = getTIPIADBON([fractionToTiles(cLocation), fractionToTiles(0.5 + cDistance)], [fractionToTiles(cLocation), fractionToTiles(0.5 - cDistance)], [-6, -1.5], 0.5, 5, 0.01); else var point = getTIPIADBON([fractionToTiles(0.5 + cDistance), fractionToTiles(cLocation)], [fractionToTiles(0.5 - cDistance), fractionToTiles(cLocation)], [-6, -1.5], 0.5, 5, 0.01); if (point !== undefined) { - if (mdd1 == 1) + if (mdd1) var placer = new PathPlacer(floor(point[0]), floor(point[1]), floor(fractionToTiles(0.5 + 0.49*cos(tang))), floor(fractionToTiles(0.5 + 0.49*sin(tang))), scaleByMapSize(10,20), 0.4, 3*(scaleByMapSize(1,4)), 0.1, 0.05); else var placer = new PathPlacer(floor(point[0]), floor(point[1]), floor(fractionToTiles(0.5 + 0.49*sin(tang))), floor(fractionToTiles(0.5 + 0.49*cos(tang))), scaleByMapSize(10,20), 0.4, 3*(scaleByMapSize(1,4)), 0.1, 0.05); @@ -752,7 +757,7 @@ var success = createArea(placer, [terrainPainter, elevationPainter, paintClass(clWater)], avoidClasses(clPlayer, 3, clWater, 3, clShallow, 2)); if (success !== undefined) { - if (mdd1 == 1) + if (mdd1) placer = new ClumpPlacer(floor(PI*scaleByMapSize(10,20)*scaleByMapSize(10,20)/4), 0.95, 0.6, 10, fractionToTiles(0.5 + 0.49*cos(tang)), fractionToTiles(0.5 + 0.49*sin(tang))); else placer = new ClumpPlacer(floor(PI*scaleByMapSize(10,20)*scaleByMapSize(10,20)/4), 0.95, 0.6, 10, fractionToTiles(0.5 + 0.49*sin(tang)), fractionToTiles(0.5 + 0.49*cos(tang))); @@ -812,8 +817,8 @@ setHeight(ix, iz, 3); } } - var mdd1 = randInt(1,2); - if (mdd1 == 1) //lake + var mdd1 = randBool(); + if (mdd1) // lake { var fx = fractionToTiles(0.5); var fz = fractionToTiles(0.5); @@ -863,7 +868,7 @@ ); } - if (randInt(1,2) == 1) //rivers + if (randBool()) // rivers { //create rivers log ("Creating rivers..."); @@ -906,7 +911,7 @@ createArea(placer, [terrainPainter, elevationPainter, paintClass(clWater)], null); } - if ((randInt(1,3) == 1)&&(mdd1 == 1))//island + if (randBool(0.33) && mdd1) // island { var placer = new ClumpPlacer(mapArea * 0.006 * lSize, 0.7, 0.1, 10, ix, iz); var terrainPainter = new LayeredPainter( @@ -935,8 +940,6 @@ } } - var mdd1 = randInt(1,2); - // randomize player order var playerIDs = []; for (var i = 0; i < numPlayers; i++) @@ -951,10 +954,11 @@ var playerZ = new Array(numPlayers); var playerPos = new Array(numPlayers); + var mdd1 = randBool(); for (var i = 0; i < numPlayers; i++) { playerPos[i] = (i + 1) / (numPlayers + 1); - if (mdd1 == 1) //horizontal + if (mdd1) // horizontal { playerX[i] = playerPos[i]; playerZ[i] = 0.4 + 0.2*(i%2); @@ -979,7 +983,7 @@ var mdd2 = randInt(1,3); var fadedistance = 7; - if (mdd1 == 1) + if (mdd1) { if ((mdd2 == 1)||(mdd2 == 3)) { @@ -1341,7 +1345,7 @@ [1, 3] // widths ); elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -5, 5); - if (randInt(1,2) == 1) + if (randBool()) { createAreas( placer, @@ -1422,8 +1426,8 @@ var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 2); createArea(placer, [painter, elevationPainter], null); } - var mdd1 = randInt (1,3); - if (mdd1 <= 2) + + if (randBool(0.66)) { var fx = fractionToTiles(0.5); var fz = fractionToTiles(0.5); Index: binaries/data/mods/public/maps/random/unknown_land.js =================================================================== --- binaries/data/mods/public/maps/random/unknown_land.js +++ binaries/data/mods/public/maps/random/unknown_land.js @@ -146,7 +146,7 @@ var clPeninsulaSteam = createTileClass(); - if (randInt(1,3)==1) // peninsula + if (randBool(0.33)) // peninsula { var angle = randFloat(0, TWO_PI); @@ -195,8 +195,8 @@ var playerPos = new Array(numPlayers); var iop = 0; - var mdd1 = randInt(1,2); - if (mdd1 == 1) //vertical + var mdd1 = randBool(); + if (mdd1) // vertical { for (var i = 0; i < numPlayers; i++) { @@ -262,7 +262,7 @@ var fadeDist = 0.05; - if (mdd1 == 1) //vertical + if (mdd1) // vertical { var cu = km*rndRiver(theta+z*0.5*(mapSize/64),seed); var cu2 = km*rndRiver(theta2+z*0.5*(mapSize/64),seed2); @@ -349,13 +349,29 @@ // 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); - } + if (mdd1) // vertical + 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 @@ -433,8 +449,8 @@ var playerAngle = new Array(numPlayers); var playerPos = new Array(numPlayers); var iop = 0; - var mdd1 = randInt(1,2); - if (mdd1 == 1) //horizontal + var mdd1 = randBool(); + if (mdd1) // horizontal { for (var i = 0; i < numPlayers; i++) { @@ -486,10 +502,12 @@ // create the main river log("Creating the main river"); - if (mdd1 == 2) - var placer = new PathPlacer(fractionToTiles(0.5), 1, fractionToTiles(0.5) , fractionToTiles(0.99), scaleByMapSize(14,24), 0.5, 3*(scaleByMapSize(1,4)), 0.1, 0.01); - else + if (mdd1) var placer = new PathPlacer(1, fractionToTiles(0.5), fractionToTiles(0.99), fractionToTiles(0.5), scaleByMapSize(14,24), 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(14,24), 0.5, 3*(scaleByMapSize(1,4)), 0.1, 0.01); + + var terrainPainter = new LayeredPainter( [tShore, tWater, tWater], // terrains @@ -502,7 +520,7 @@ ); createArea(placer, [terrainPainter, elevationPainter], avoidClasses(clPlayer, 4)); - if (mdd1 == 1) + if (mdd1) placer = new ClumpPlacer(floor(PI*scaleByMapSize(10,20)*scaleByMapSize(10,20)/4), 0.95, 0.6, 10, 1, fractionToTiles(0.5)); else placer = new ClumpPlacer(floor(PI*scaleByMapSize(10,20)*scaleByMapSize(10,20)/4), 0.95, 0.6, 10, fractionToTiles(0.5), 1); @@ -511,7 +529,7 @@ var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -4, 2); createArea(placer, [painter, elevationPainter], avoidClasses(clPlayer, 8)); - if (mdd1 == 1) + if (mdd1) placer = new ClumpPlacer(floor(PI*scaleByMapSize(10,20)*scaleByMapSize(10,20)/4), 0.95, 0.6, 10, fractionToTiles(0.99), fractionToTiles(0.5)); else placer = new ClumpPlacer(floor(PI*scaleByMapSize(10,20)*scaleByMapSize(10,20)/4), 0.95, 0.6, 10, fractionToTiles(0.5), fractionToTiles(0.99)); @@ -526,13 +544,13 @@ for (var i = 0; i <= randInt(1, scaleByMapSize(4,8)); i++) { var cLocation = randFloat(0.15,0.85); - if (mdd1 == 1) + if (mdd1) passageMaker(floor(fractionToTiles(cLocation)), floor(fractionToTiles(0.35)), floor(fractionToTiles(cLocation)), floor(fractionToTiles(0.65)), scaleByMapSize(4,8), -2, -2, 2, clShallow, undefined, -4); else 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,26 +567,22 @@ // create tributaries log("Creating tributaries"); - for (var i = 0; i <= randInt(8, (scaleByMapSize(12,20))); i++) + for (let 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); - if (tang > 0) - { - var cDistance = 0.05; - } - else - { - var cDistance = -0.05; - } - if (mdd1 == 1) + var cLocation = randFloat(0.05, 0.95); + + var sign = randBool() ? 1 : -1; + var tang = sign * PI * randFloat(0.2, 0.8); + var cDistance = sign * 0.05; + + if (mdd1) var point = getTIPIADBON([fractionToTiles(cLocation), fractionToTiles(0.5 + cDistance)], [fractionToTiles(cLocation), fractionToTiles(0.5 - cDistance)], [-6, -1.5], 0.5, 5, 0.01); else var point = getTIPIADBON([fractionToTiles(0.5 + cDistance), fractionToTiles(cLocation)], [fractionToTiles(0.5 - cDistance), fractionToTiles(cLocation)], [-6, -1.5], 0.5, 5, 0.01); if (point !== undefined) { - if (mdd1 == 1) + if (mdd1) var placer = new PathPlacer(floor(point[0]), floor(point[1]), floor(fractionToTiles(0.5 + 0.49*cos(tang))), floor(fractionToTiles(0.5 + 0.49*sin(tang))), scaleByMapSize(10,20), 0.4, 3*(scaleByMapSize(1,4)), 0.1, 0.05); else var placer = new PathPlacer(floor(point[0]), floor(point[1]), floor(fractionToTiles(0.5 + 0.49*sin(tang))), floor(fractionToTiles(0.5 + 0.49*cos(tang))), scaleByMapSize(10,20), 0.4, 3*(scaleByMapSize(1,4)), 0.1, 0.05); @@ -586,7 +600,7 @@ var success = createArea(placer, [terrainPainter, elevationPainter, paintClass(clWater)], avoidClasses(clPlayer, 3, clWater, 3, clShallow, 2)); if (success !== undefined) { - if (mdd1 == 1) + if (mdd1) placer = new ClumpPlacer(floor(PI*scaleByMapSize(10,20)*scaleByMapSize(10,20)/4), 0.95, 0.6, 10, fractionToTiles(0.5 + 0.49*cos(tang)), fractionToTiles(0.5 + 0.49*sin(tang))); else placer = new ClumpPlacer(floor(PI*scaleByMapSize(10,20)*scaleByMapSize(10,20)/4), 0.95, 0.6, 10, fractionToTiles(0.5 + 0.49*sin(tang)), fractionToTiles(0.5 + 0.49*cos(tang))); @@ -646,8 +660,8 @@ setHeight(ix, iz, 3); } } - var mdd1 = randInt(1,2); - if (mdd1 == 1) //lake + var mdd1 = randBool(); + if (mdd1) // lake { var fx = fractionToTiles(0.5); var fz = fractionToTiles(0.5); @@ -685,7 +699,7 @@ ); } - if ((randInt(1,3) == 1)&&(mdd1 == 1))//island + if (randBool(0.33) && mdd1) // island { var placer = new ClumpPlacer(mapArea * 0.006 * lSize, 0.7, 0.1, 10, ix, iz); var terrainPainter = new LayeredPainter( @@ -714,8 +728,6 @@ } } - var mdd1 = randInt(1,2); - // randomize player order var playerIDs = []; for (var i = 0; i < numPlayers; i++) @@ -730,10 +742,11 @@ var playerZ = new Array(numPlayers); var playerPos = new Array(numPlayers); + var mdd1 = randBool(); for (var i = 0; i < numPlayers; i++) { playerPos[i] = (i + 1) / (numPlayers + 1); - if (mdd1 == 1) //horizontal + if (mdd1) // horizontal { playerX[i] = playerPos[i]; playerZ[i] = 0.4 + 0.2*(i%2); @@ -758,7 +771,7 @@ var mdd2 = randInt(1,3); var fadedistance = 7; - if (mdd1 == 1) + if (mdd1) { if ((mdd2 == 1)||(mdd2 == 3)) { @@ -1104,7 +1117,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,8 +1207,8 @@ var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 2); createArea(placer, [painter, elevationPainter], null); } - var mdd1 = randInt (1,3); - if (mdd1 <= 2) + + if (randBool(0.66)) { var fx = fractionToTiles(0.5); var fz = fractionToTiles(0.5); Index: binaries/data/mods/public/maps/random/unknown_nomad.js =================================================================== --- binaries/data/mods/public/maps/random/unknown_nomad.js +++ binaries/data/mods/public/maps/random/unknown_nomad.js @@ -184,7 +184,7 @@ ); createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null); - if (randInt(1,4)==1) // peninsula + if (randBool(0.25)) // peninsula { var angle = randFloat(0, TWO_PI); @@ -356,7 +356,7 @@ } } - if (!randInt(3)) + if (randBool(0.33)) { if (mdd1 == 1) //vertical { @@ -472,8 +472,8 @@ var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -4, 2); createArea(placer, [painter, elevationPainter], avoidClasses(clPlayer, 8)); - var mdd2 = randInt(1,2); - if (mdd2 == 1) + let shallows = randBool(); + if (!shallows) { // create the shallows of the main river log("Creating the shallows of the main river"); @@ -488,7 +488,7 @@ } } - if (randInt(1,2) == 1) + if (randBool()) { // create tributaries @@ -496,16 +496,11 @@ for (var i = 0; i <= randInt(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); - if (tang > 0) - { - var cDistance = 0.05; - } - else - { - var cDistance = -0.05; - } + let cLocation = randFloat(0.05, 0.95); + let sign = randBool() ? 1 : -1; + let tang = sign * PI * randFloat(0.2, 0.8); + let cDistance = sign * 0.05; + if (mdd1 == 1) var point = getTIPIADBON([fractionToTiles(cLocation), fractionToTiles(0.5 + cDistance)], [fractionToTiles(cLocation), fractionToTiles(0.5 - cDistance)], [-6, -1.5], 0.5, 4, 0.01); else @@ -633,7 +628,7 @@ createArea(placer, [terrainPainter, elevationPainter, paintClass(clWater)], null); } - if (randInt(1,3) == 1 && mdd1 < 3)//island + if (randBool(0.33) && mdd1 < 3) // island { var placer = new ClumpPlacer(mapArea * 0.006 * lSize, 0.7, 0.1, 10, ix, iz); var terrainPainter = new LayeredPainter( @@ -662,8 +657,6 @@ } } - var mdd1 = randInt(1,2); - // randomize player order var playerIDs = []; for (var i = 0; i < numPlayers; i++) @@ -675,7 +668,7 @@ var mdd2 = randInt(1,3); var fadedistance = 7; - if (mdd1 == 1) + if (randBool()) { if ((mdd2 == 1)||(mdd2 == 3)) { @@ -988,24 +981,14 @@ [1, 3] // widths ); elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -5, 5); - if (randInt(1,2) == 1) - { - createAreas( - placer, - [terrainPainter, elevationPainter, paintClass(clWater)], + createAreas( + placer, + [terrainPainter, elevationPainter, paintClass(clWater)], + randBool() ? + avoidClasses(clPlayer, 12) : avoidClasses(clPlayer, 12, clWater, 8), - scaleByMapSize(5, 16) - ); - } - else - { - createAreas( - placer, - [terrainPainter, elevationPainter, paintClass(clWater)], - avoidClasses(clPlayer, 12), - scaleByMapSize(5, 16) - ); - } + scaleByMapSize(5, 16) + ); } //******************************************************************************************************** else if (md == 9) //passes Index: binaries/data/mods/public/simulation/ai/petra/diplomacyManager.js =================================================================== --- binaries/data/mods/public/simulation/ai/petra/diplomacyManager.js +++ binaries/data/mods/public/simulation/ai/petra/diplomacyManager.js @@ -277,7 +277,7 @@ let moreEnemiesThanAllies = gameState.getEnemies().length > gameState.getMutualAllies().length; // For any given diplomacy request be likely to permanently decline - if (!request && gameState.getPlayerCiv() !== gameState.getPlayerCiv(player) && randFloat(0, 1) > 0.4 || + if (!request && gameState.getPlayerCiv() !== gameState.getPlayerCiv(player) && randBool(0.6) || !moreEnemiesThanAllies || gameState.ai.HQ.attackManager.currentEnemyPlayer === player) { this.diplomacyRequests.set(player, { "requestType": requestType, "status": "declinedRequest" }); @@ -296,7 +296,7 @@ } } else if (requestType === "ally" && gameState.getEntities(player).length < gameState.getOwnEntities().length && - randFloat(0, 1) > 0.6 || requestType === "neutral" && moreEnemiesThanAllies && randFloat(0, 1) > 0.2) + randBool(0.4) || requestType === "neutral" && moreEnemiesThanAllies && randBool(0.8)) { response = "accept"; this.changePlayerDiplomacy(gameState, player, requestType);