Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/maps/random/unknown_nomad.js
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | for (var ix = 0; ix < mapSize; ix++) | ||||
{ | { | ||||
var x = ix / (mapSize + 1.0); | var x = ix / (mapSize + 1.0); | ||||
var z = iz / (mapSize + 1.0); | var z = iz / (mapSize + 1.0); | ||||
placeTerrain(ix, iz, tWater); | placeTerrain(ix, iz, tWater); | ||||
} | } | ||||
} | } | ||||
var startAngle = randFloat(0, TWO_PI); | var startAngle = randFloat(0, TWO_PI); | ||||
var md = randInt(1,13); | var md = randIntInclusive(1,13); | ||||
var needsAdditionalWood = false; | var needsAdditionalWood = false; | ||||
//***************************************************************************************************************************** | //***************************************************************************************************************************** | ||||
if (md == 1) //archipelago and island | if (md == 1) //archipelago and island | ||||
{ | { | ||||
needsAdditionalWood = true; | needsAdditionalWood = true; | ||||
// randomize player order | // randomize player order | ||||
var playerIDs = []; | var playerIDs = []; | ||||
for (var i = 0; i < numPlayers; i++) | for (var i = 0; i < numPlayers; i++) | ||||
{ | { | ||||
playerIDs.push(i+1); | playerIDs.push(i+1); | ||||
} | } | ||||
playerIDs = sortPlayers(playerIDs); | playerIDs = sortPlayers(playerIDs); | ||||
var radius = scaleByMapSize(17, 29); | var radius = scaleByMapSize(17, 29); | ||||
var hillSize = PI * radius * radius; | var hillSize = PI * radius * radius; | ||||
var mdd1 = randInt(1,3); | var mdd1 = randIntInclusive(1,3); | ||||
if (mdd1 == 1) //archipelago | if (mdd1 == 1) //archipelago | ||||
{ | { | ||||
// create islands | // create islands | ||||
log("Creating islands..."); | log("Creating islands..."); | ||||
placer = new ClumpPlacer(floor(hillSize*randFloat(0.8,1.2)), 0.80, 0.1, 10); | placer = new ClumpPlacer(floor(hillSize*randFloat(0.8,1.2)), 0.80, 0.1, 10); | ||||
terrainPainter = new LayeredPainter( | terrainPainter = new LayeredPainter( | ||||
[tGrass, tGrass], // terrains | [tGrass, tGrass], // terrains | ||||
[2] // widths | [2] // widths | ||||
); | ); | ||||
elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 4); | elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 4); | ||||
createAreas( | createAreas( | ||||
placer, | placer, | ||||
[terrainPainter, elevationPainter, paintClass(clLand)], | [terrainPainter, elevationPainter, paintClass(clLand)], | ||||
null, | null, | ||||
scaleByMapSize(2, 5)*randInt(8,14) | scaleByMapSize(2, 5)*randIntInclusive(8,14) | ||||
); | ); | ||||
} | } | ||||
else if (mdd1 == 2) //islands | else if (mdd1 == 2) //islands | ||||
{ | { | ||||
// create islands | // create islands | ||||
log("Creating islands..."); | log("Creating islands..."); | ||||
placer = new ClumpPlacer(floor(hillSize*randFloat(0.6,1.4)), 0.80, 0.1, randFloat(0.0, 0.2)); | placer = new ClumpPlacer(floor(hillSize*randFloat(0.6,1.4)), 0.80, 0.1, randFloat(0.0, 0.2)); | ||||
terrainPainter = new LayeredPainter( | terrainPainter = new LayeredPainter( | ||||
[tGrass, tGrass], // terrains | [tGrass, tGrass], // terrains | ||||
[2] // widths | [2] // widths | ||||
); | ); | ||||
elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 4); | elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 4); | ||||
createAreas( | createAreas( | ||||
placer, | placer, | ||||
[terrainPainter, elevationPainter, paintClass(clLand)], | [terrainPainter, elevationPainter, paintClass(clLand)], | ||||
avoidClasses(clLand, 3, clPlayer, 3), | avoidClasses(clLand, 3, clPlayer, 3), | ||||
scaleByMapSize(6, 10)*randInt(8,14) | scaleByMapSize(6, 10)*randIntInclusive(8,14) | ||||
); | ); | ||||
} | } | ||||
else if (mdd1 == 3) // tight islands | else if (mdd1 == 3) // tight islands | ||||
{ | { | ||||
// create islands | // create islands | ||||
log("Creating islands..."); | log("Creating islands..."); | ||||
placer = new ClumpPlacer(floor(hillSize*randFloat(0.8,1.2)), 0.80, 0.1, 10); | placer = new ClumpPlacer(floor(hillSize*randFloat(0.8,1.2)), 0.80, 0.1, 10); | ||||
terrainPainter = new LayeredPainter( | terrainPainter = new LayeredPainter( | ||||
[tGrass, tGrass], // terrains | [tGrass, tGrass], // terrains | ||||
[2] // widths | [2] // widths | ||||
); | ); | ||||
elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 4); | elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 4); | ||||
createAreas( | createAreas( | ||||
placer, | placer, | ||||
[terrainPainter, elevationPainter, paintClass(clLand)], | [terrainPainter, elevationPainter, paintClass(clLand)], | ||||
avoidClasses(clLand, randInt(8, 16), clPlayer, 3), | avoidClasses(clLand, randIntInclusive(8, 16), clPlayer, 3), | ||||
scaleByMapSize(2, 5)*randInt(8,14) | scaleByMapSize(2, 5)*randIntInclusive(8,14) | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
//******************************************************************************************************** | //******************************************************************************************************** | ||||
else if (md == 2) //continent | else if (md == 2) //continent | ||||
{ | { | ||||
Show All 17 Lines | else if (md == 2) //continent | ||||
); | ); | ||||
var elevationPainter = new SmoothElevationPainter( | var elevationPainter = new SmoothElevationPainter( | ||||
ELEVATION_SET, // type | ELEVATION_SET, // type | ||||
3, // elevation | 3, // elevation | ||||
4 // blend radius | 4 // blend radius | ||||
); | ); | ||||
createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null); | createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null); | ||||
if (randInt(1,4)==1) // peninsula | if (randBool(1/4)) // peninsula | ||||
{ | { | ||||
var angle = randFloat(0, TWO_PI); | var angle = randFloat(0, TWO_PI); | ||||
var fx = fractionToTiles(0.5 + 0.25*cos(angle)); | var fx = fractionToTiles(0.5 + 0.25*cos(angle)); | ||||
var fz = fractionToTiles(0.5 + 0.25*sin(angle)); | var fz = fractionToTiles(0.5 + 0.25*sin(angle)); | ||||
ix = round(fx); | ix = round(fx); | ||||
iz = round(fz); | iz = round(fz); | ||||
var placer = new ClumpPlacer(mapArea * 0.45, 0.9, 0.09, 10, ix, iz); | var placer = new ClumpPlacer(mapArea * 0.45, 0.9, 0.09, 10, ix, iz); | ||||
var terrainPainter = new LayeredPainter( | var terrainPainter = new LayeredPainter( | ||||
[tWater, tShore, tGrass], // terrains | [tWater, tShore, tGrass], // terrains | ||||
[4, 2] // widths | [4, 2] // widths | ||||
); | ); | ||||
var elevationPainter = new SmoothElevationPainter( | var elevationPainter = new SmoothElevationPainter( | ||||
ELEVATION_SET, // type | ELEVATION_SET, // type | ||||
3, // elevation | 3, // elevation | ||||
4 // blend radius | 4 // blend radius | ||||
); | ); | ||||
createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null); | createArea(placer, [terrainPainter, elevationPainter, paintClass(clLand)], null); | ||||
} | } | ||||
var mdd1 = randInt(1,3); | var mdd1 = randIntInclusive(1,3); | ||||
if (mdd1 == 1) | if (mdd1 == 1) | ||||
{ | { | ||||
// create islands | // create islands | ||||
log("Creating islands..."); | log("Creating islands..."); | ||||
placer = new ClumpPlacer(randInt(scaleByMapSize(8,15),scaleByMapSize(15,23))*randInt(scaleByMapSize(8,15),scaleByMapSize(15,23)), 0.80, 0.1, randFloat(0.0, 0.2)); | placer = new ClumpPlacer(randIntInclusive(scaleByMapSize(8,15),scaleByMapSize(15,23))*randIntInclusive(scaleByMapSize(8,15),scaleByMapSize(15,23)), 0.80, 0.1, randFloat(0.0, 0.2)); | ||||
terrainPainter = new LayeredPainter( | terrainPainter = new LayeredPainter( | ||||
[tGrass, tGrass], // terrains | [tGrass, tGrass], // terrains | ||||
[2] // widths | [2] // widths | ||||
); | ); | ||||
elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 4); | elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 4); | ||||
createAreas( | createAreas( | ||||
placer, | placer, | ||||
[terrainPainter, elevationPainter, paintClass(clLand)], | [terrainPainter, elevationPainter, paintClass(clLand)], | ||||
avoidClasses(clLand, 3, clPlayer, 3), | avoidClasses(clLand, 3, clPlayer, 3), | ||||
scaleByMapSize(2, 5)*randInt(8,14) | scaleByMapSize(2, 5)*randIntInclusive(8,14) | ||||
); | ); | ||||
} | } | ||||
else if (mdd1 == 2) | else if (mdd1 == 2) | ||||
{ | { | ||||
// create extentions | // create extentions | ||||
log("Creating extentions..."); | log("Creating extentions..."); | ||||
placer = new ClumpPlacer(randInt(scaleByMapSize(13,24),scaleByMapSize(24,45))*randInt(scaleByMapSize(13,24),scaleByMapSize(24,45)), 0.80, 0.1, 10); | placer = new ClumpPlacer(randIntInclusive(scaleByMapSize(13,24),scaleByMapSize(24,45))*randIntInclusive(scaleByMapSize(13,24),scaleByMapSize(24,45)), 0.80, 0.1, 10); | ||||
terrainPainter = new LayeredPainter( | terrainPainter = new LayeredPainter( | ||||
[tGrass, tGrass], // terrains | [tGrass, tGrass], // terrains | ||||
[2] // widths | [2] // widths | ||||
); | ); | ||||
elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 4); | elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 4); | ||||
createAreas( | createAreas( | ||||
placer, | placer, | ||||
[terrainPainter, elevationPainter, paintClass(clLand)], | [terrainPainter, elevationPainter, paintClass(clLand)], | ||||
null, | null, | ||||
scaleByMapSize(2, 5)*randInt(8,14) | scaleByMapSize(2, 5)*randIntInclusive(8,14) | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
//******************************************************************************************************** | //******************************************************************************************************** | ||||
else if (md == 3) //central sea | else if (md == 3) //central sea | ||||
{ | { | ||||
// randomize player order | // randomize player order | ||||
var playerIDs = []; | var playerIDs = []; | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | for (var iz = 0; iz < mapSize; iz++) | ||||
{ | { | ||||
setHeight(ix, iz, 3.1); | setHeight(ix, iz, 3.1); | ||||
addToClass(ix, iz, clLand); | addToClass(ix, iz, clLand); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if (!randInt(3)) | if (randBool(1/3)) | ||||
{ | { | ||||
if (mdd1 == 1) //vertical | if (mdd1 == 1) //vertical | ||||
{ | { | ||||
var placer = new PathPlacer(1, fractionToTiles(0.5), fractionToTiles(0.99), fractionToTiles(0.5), scaleByMapSize(randInt(16,24),randInt(100,140)), 0.5, 3*(scaleByMapSize(1,4)), 0.1, 0.01); | var placer = new PathPlacer(1, fractionToTiles(0.5), fractionToTiles(0.99), fractionToTiles(0.5), scaleByMapSize(randIntInclusive(16,24),randIntInclusive(100,140)), 0.5, 3*(scaleByMapSize(1,4)), 0.1, 0.01); | ||||
} | } | ||||
else | 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( | var terrainPainter = new LayeredPainter( | ||||
[tGrass, tGrass, tGrass], // terrains | [tGrass, tGrass, tGrass], // terrains | ||||
[1, 3] // widths | [1, 3] // widths | ||||
); | ); | ||||
var elevationPainter = new SmoothElevationPainter( | var elevationPainter = new SmoothElevationPainter( | ||||
ELEVATION_SET, // type | ELEVATION_SET, // type | ||||
3.1, // elevation | 3.1, // elevation | ||||
4 // blend radius | 4 // blend radius | ||||
); | ); | ||||
createArea(placer, [terrainPainter, elevationPainter, unPaintClass(clWater)], null); | createArea(placer, [terrainPainter, elevationPainter, unPaintClass(clWater)], null); | ||||
} | } | ||||
var mdd2 = randInt(1,3); | var mdd2 = randIntInclusive(1,3); | ||||
if (mdd2 == 1) | if (mdd2 == 1) | ||||
{ | { | ||||
// create islands | // create islands | ||||
log("Creating islands..."); | log("Creating islands..."); | ||||
placer = new ClumpPlacer(randInt(scaleByMapSize(8,15),scaleByMapSize(15,23))*randInt(scaleByMapSize(8,15),scaleByMapSize(15,23)), 0.80, 0.1, randFloat(0.0, 0.2)); | placer = new ClumpPlacer(randIntInclusive(scaleByMapSize(8,15),scaleByMapSize(15,23))*randIntInclusive(scaleByMapSize(8,15),scaleByMapSize(15,23)), 0.80, 0.1, randFloat(0.0, 0.2)); | ||||
terrainPainter = new LayeredPainter( | terrainPainter = new LayeredPainter( | ||||
[tGrass, tGrass], // terrains | [tGrass, tGrass], // terrains | ||||
[2] // widths | [2] // widths | ||||
); | ); | ||||
elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3.1, 4); | elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3.1, 4); | ||||
createAreas( | createAreas( | ||||
placer, | placer, | ||||
[terrainPainter, elevationPainter, paintClass(clLand)], | [terrainPainter, elevationPainter, paintClass(clLand)], | ||||
avoidClasses(clLand, 3, clPlayer, 3), | avoidClasses(clLand, 3, clPlayer, 3), | ||||
scaleByMapSize(2, 5)*randInt(8,14) | scaleByMapSize(2, 5)*randIntInclusive(8,14) | ||||
); | ); | ||||
} | } | ||||
else if (mdd2 == 2) | else if (mdd2 == 2) | ||||
{ | { | ||||
// create extentions | // create extentions | ||||
log("Creating extentions..."); | log("Creating extentions..."); | ||||
placer = new ClumpPlacer(randInt(scaleByMapSize(13,24),scaleByMapSize(24,45))*randInt(scaleByMapSize(13,24),scaleByMapSize(24,45)), 0.80, 0.1, 10); | placer = new ClumpPlacer(randIntInclusive(scaleByMapSize(13,24),scaleByMapSize(24,45))*randIntInclusive(scaleByMapSize(13,24),scaleByMapSize(24,45)), 0.80, 0.1, 10); | ||||
terrainPainter = new LayeredPainter( | terrainPainter = new LayeredPainter( | ||||
[tGrass, tGrass], // terrains | [tGrass, tGrass], // terrains | ||||
[2] // widths | [2] // widths | ||||
); | ); | ||||
elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3.1, 4); | elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3.1, 4); | ||||
createAreas( | createAreas( | ||||
placer, | placer, | ||||
[terrainPainter, elevationPainter, paintClass(clLand)], | [terrainPainter, elevationPainter, paintClass(clLand)], | ||||
null, | null, | ||||
scaleByMapSize(2, 5)*randInt(8,14) | scaleByMapSize(2, 5)*randIntInclusive(8,14) | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
//******************************************************************************************************** | //******************************************************************************************************** | ||||
else if (md == 4) //central river | else if (md == 4) //central river | ||||
{ | { | ||||
for (var ix = 0; ix < mapSize; ix++) | for (var ix = 0; ix < mapSize; ix++) | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | if (mdd1 == 1) | ||||
placer = new ClumpPlacer(floor(PI*scaleByMapSize(10,20)*scaleByMapSize(10,20)/4), 0.95, 0.6, 10, fractionToTiles(0.99), fractionToTiles(0.5)); | placer = new ClumpPlacer(floor(PI*scaleByMapSize(10,20)*scaleByMapSize(10,20)/4), 0.95, 0.6, 10, fractionToTiles(0.99), fractionToTiles(0.5)); | ||||
else | else | ||||
placer = new ClumpPlacer(floor(PI*scaleByMapSize(10,20)*scaleByMapSize(10,20)/4), 0.95, 0.6, 10, fractionToTiles(0.5), fractionToTiles(0.99)); | placer = new ClumpPlacer(floor(PI*scaleByMapSize(10,20)*scaleByMapSize(10,20)/4), 0.95, 0.6, 10, fractionToTiles(0.5), fractionToTiles(0.99)); | ||||
var painter = new LayeredPainter([tWater, tWater], [1]); | var painter = new LayeredPainter([tWater, tWater], [1]); | ||||
var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -4, 2); | var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -4, 2); | ||||
createArea(placer, [painter, elevationPainter], avoidClasses(clPlayer, 8)); | createArea(placer, [painter, elevationPainter], avoidClasses(clPlayer, 8)); | ||||
var mdd2 = randInt(1,2); | var mdd2 = randIntInclusive(1,2); | ||||
if (mdd2 == 1) | if (mdd2 == 1) | ||||
{ | { | ||||
// create the shallows of the main river | // create the shallows of the main river | ||||
log("Creating the shallows of the main river"); | log("Creating the shallows of the main river"); | ||||
for (var i = 0; i <= randInt(1, scaleByMapSize(4,8)); i++) | for (var i = 0; i <= randIntInclusive(1, scaleByMapSize(4,8)); i++) | ||||
{ | { | ||||
var cLocation = randFloat(0.15,0.85); | var cLocation = randFloat(0.15,0.85); | ||||
if (mdd1 == 1) | if (mdd1 == 1) | ||||
passageMaker(fractionToTiles(cLocation), fractionToTiles(0.35), fractionToTiles(cLocation), fractionToTiles(0.65), scaleByMapSize(4,8), -2, -2, 2, clShallow, undefined, -4); | passageMaker(fractionToTiles(cLocation), fractionToTiles(0.35), fractionToTiles(cLocation), fractionToTiles(0.65), scaleByMapSize(4,8), -2, -2, 2, clShallow, undefined, -4); | ||||
else | else | ||||
passageMaker(fractionToTiles(0.35), fractionToTiles(cLocation), fractionToTiles(0.65), fractionToTiles(cLocation), scaleByMapSize(4,8), -2, -2, 2, clShallow, undefined, -4); | passageMaker(fractionToTiles(0.35), fractionToTiles(cLocation), fractionToTiles(0.65), fractionToTiles(cLocation), scaleByMapSize(4,8), -2, -2, 2, clShallow, undefined, -4); | ||||
} | } | ||||
} | } | ||||
if (randInt(1,2) == 1) | if (randBool()) | ||||
{ | { | ||||
// create tributaries | // create tributaries | ||||
log("Creating tributaries"); | log("Creating tributaries"); | ||||
for (var i = 0; i <= randInt(8, (scaleByMapSize(12,20))); i++) | for (var i = 0; i <= randIntInclusive(8, (scaleByMapSize(12,20))); i++) | ||||
{ | { | ||||
var cLocation = randFloat(0.05,0.95); | var cLocation = randFloat(0.05,0.95); | ||||
var tang = randFloat(PI*0.2, PI*0.8)*((randInt(2)-0.5)*2); | var tang = randFloat(PI*0.2, PI*0.8)*((randIntInclusive(0, 1)-0.5)*2); | ||||
if (tang > 0) | if (tang > 0) | ||||
{ | { | ||||
var cDistance = 0.05; | var cDistance = 0.05; | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
var cDistance = -0.05; | var cDistance = -0.05; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | for (var ix = 0; ix < mapSize; ix++) | ||||
for (var iz = 0; iz < mapSize; iz++) | for (var iz = 0; iz < mapSize; iz++) | ||||
{ | { | ||||
var x = ix / (mapSize + 1.0); | var x = ix / (mapSize + 1.0); | ||||
var z = iz / (mapSize + 1.0); | var z = iz / (mapSize + 1.0); | ||||
setHeight(ix, iz, 3); | setHeight(ix, iz, 3); | ||||
} | } | ||||
} | } | ||||
var mdd1 = randInt(1,3); | var mdd1 = randIntInclusive(1,3); | ||||
if (mdd1 < 3) //lake | if (mdd1 < 3) //lake | ||||
{ | { | ||||
var fx = fractionToTiles(0.5); | var fx = fractionToTiles(0.5); | ||||
var fz = fractionToTiles(0.5); | var fz = fractionToTiles(0.5); | ||||
ix = round(fx); | ix = round(fx); | ||||
iz = round(fz); | iz = round(fz); | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | if (mdd1 > 1) //rivers | ||||
var elevationPainter = new SmoothElevationPainter( | var elevationPainter = new SmoothElevationPainter( | ||||
ELEVATION_SET, // type | ELEVATION_SET, // type | ||||
-4, // elevation | -4, // elevation | ||||
4 // blend radius | 4 // blend radius | ||||
); | ); | ||||
createArea(placer, [terrainPainter, elevationPainter, paintClass(clWater)], null); | createArea(placer, [terrainPainter, elevationPainter, paintClass(clWater)], null); | ||||
} | } | ||||
if (randInt(1,3) == 1 && mdd1 < 3)//island | if (randBool(1/3) && mdd1 < 3)//island | ||||
{ | { | ||||
var placer = new ClumpPlacer(mapArea * 0.006 * lSize, 0.7, 0.1, 10, ix, iz); | var placer = new ClumpPlacer(mapArea * 0.006 * lSize, 0.7, 0.1, 10, ix, iz); | ||||
var terrainPainter = new LayeredPainter( | var terrainPainter = new LayeredPainter( | ||||
[tShore, tWater, tWater, tWater], // terrains | [tShore, tWater, tWater, tWater], // terrains | ||||
[1, 4, 2] // widths | [1, 4, 2] // widths | ||||
); | ); | ||||
var elevationPainter = new SmoothElevationPainter( | var elevationPainter = new SmoothElevationPainter( | ||||
ELEVATION_SET, // type | ELEVATION_SET, // type | ||||
Show All 12 Lines | for (var ix = 0; ix < mapSize; ix++) | ||||
for (var iz = 0; iz < mapSize; iz++) | for (var iz = 0; iz < mapSize; iz++) | ||||
{ | { | ||||
var x = ix / (mapSize + 1.0); | var x = ix / (mapSize + 1.0); | ||||
var z = iz / (mapSize + 1.0); | var z = iz / (mapSize + 1.0); | ||||
setHeight(ix, iz, 3); | setHeight(ix, iz, 3); | ||||
} | } | ||||
} | } | ||||
var mdd1 = randInt(1,2); | var mdd1 = randIntInclusive(1,2); | ||||
// randomize player order | // randomize player order | ||||
var playerIDs = []; | var playerIDs = []; | ||||
for (var i = 0; i < numPlayers; i++) | for (var i = 0; i < numPlayers; i++) | ||||
{ | { | ||||
playerIDs.push(i+1); | playerIDs.push(i+1); | ||||
} | } | ||||
playerIDs = sortPlayers(playerIDs); | playerIDs = sortPlayers(playerIDs); | ||||
var mdd2 = randInt(1,3); | var mdd2 = randIntInclusive(1,3); | ||||
var fadedistance = 7; | var fadedistance = 7; | ||||
if (mdd1 == 1) | if (mdd1 == 1) | ||||
{ | { | ||||
if ((mdd2 == 1)||(mdd2 == 3)) | if ((mdd2 == 1)||(mdd2 == 3)) | ||||
{ | { | ||||
var distance = randFloat(0., 0.1); | var distance = randFloat(0., 0.1); | ||||
for (var ix = 0; ix < mapSize; ix++) | for (var ix = 0; ix < mapSize; ix++) | ||||
▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | if ((mdd2 == 2)||(mdd2 == 3)) | ||||
placer, | placer, | ||||
[terrainPainter, elevationPainter, unPaintClass(clWater)], | [terrainPainter, elevationPainter, unPaintClass(clWater)], | ||||
null | null | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
var mdd3 = randInt(1,3); | var mdd3 = randIntInclusive(1,3); | ||||
if (mdd3 == 1) | if (mdd3 == 1) | ||||
{ | { | ||||
// create islands | // create islands | ||||
log("Creating islands..."); | log("Creating islands..."); | ||||
placer = new ClumpPlacer(randInt(scaleByMapSize(8,15),scaleByMapSize(15,23))*randInt(scaleByMapSize(8,15),scaleByMapSize(15,23)), 0.80, 0.1, randFloat(0.0, 0.2)); | placer = new ClumpPlacer(randIntInclusive(scaleByMapSize(8,15),scaleByMapSize(15,23))*randIntInclusive(scaleByMapSize(8,15),scaleByMapSize(15,23)), 0.80, 0.1, randFloat(0.0, 0.2)); | ||||
terrainPainter = new LayeredPainter( | terrainPainter = new LayeredPainter( | ||||
[tGrass, tGrass], // terrains | [tGrass, tGrass], // terrains | ||||
[2] // widths | [2] // widths | ||||
); | ); | ||||
elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3.1, 4); | elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3.1, 4); | ||||
createAreas( | createAreas( | ||||
placer, | placer, | ||||
[terrainPainter, elevationPainter, paintClass(clLand)], | [terrainPainter, elevationPainter, paintClass(clLand)], | ||||
avoidClasses(clLand, 3, clPlayer, 3), | avoidClasses(clLand, 3, clPlayer, 3), | ||||
scaleByMapSize(2, 5)*randInt(8,14) | scaleByMapSize(2, 5)*randIntInclusive(8,14) | ||||
); | ); | ||||
} | } | ||||
else if (mdd3 == 2) | else if (mdd3 == 2) | ||||
{ | { | ||||
// create extentions | // create extentions | ||||
log("Creating extentions..."); | log("Creating extentions..."); | ||||
placer = new ClumpPlacer(randInt(scaleByMapSize(13,24),scaleByMapSize(24,45))*randInt(scaleByMapSize(13,24),scaleByMapSize(24,45)), 0.80, 0.1, 10); | placer = new ClumpPlacer(randIntInclusive(scaleByMapSize(13,24),scaleByMapSize(24,45))*randIntInclusive(scaleByMapSize(13,24),scaleByMapSize(24,45)), 0.80, 0.1, 10); | ||||
terrainPainter = new LayeredPainter( | terrainPainter = new LayeredPainter( | ||||
[tGrass, tGrass], // terrains | [tGrass, tGrass], // terrains | ||||
[2] // widths | [2] // widths | ||||
); | ); | ||||
elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3.1, 4); | elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3.1, 4); | ||||
createAreas( | createAreas( | ||||
placer, | placer, | ||||
[terrainPainter, elevationPainter, paintClass(clLand)], | [terrainPainter, elevationPainter, paintClass(clLand)], | ||||
null, | null, | ||||
scaleByMapSize(2, 5)*randInt(8,14) | scaleByMapSize(2, 5)*randIntInclusive(8,14) | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
//******************************************************************************************************** | //******************************************************************************************************** | ||||
else if (md == 7) //gulf | else if (md == 7) //gulf | ||||
{ | { | ||||
for (var ix = 0; ix < mapSize; ix++) | for (var ix = 0; ix < mapSize; ix++) | ||||
{ | { | ||||
for (var iz = 0; iz < mapSize; iz++) | for (var iz = 0; iz < mapSize; iz++) | ||||
{ | { | ||||
var x = ix / (mapSize + 1.0); | var x = ix / (mapSize + 1.0); | ||||
var z = iz / (mapSize + 1.0); | var z = iz / (mapSize + 1.0); | ||||
setHeight(ix, iz, 3); | setHeight(ix, iz, 3); | ||||
} | } | ||||
} | } | ||||
var mdd1 = randInt(1,4); | var mdd1 = randIntInclusive(1,4); | ||||
// randomize player order | // randomize player order | ||||
var playerIDs = []; | var playerIDs = []; | ||||
for (var i = 0; i < numPlayers; i++) | for (var i = 0; i < numPlayers; i++) | ||||
{ | { | ||||
playerIDs.push(i+1); | playerIDs.push(i+1); | ||||
} | } | ||||
playerIDs = sortPlayers(playerIDs); | playerIDs = sortPlayers(playerIDs); | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | else if (md == 8) //lakes | ||||
// create lakes | // create lakes | ||||
log("Creating lakes..."); | log("Creating lakes..."); | ||||
placer = new ClumpPlacer(scaleByMapSize(160, 700), 0.2, 0.1, 1); | placer = new ClumpPlacer(scaleByMapSize(160, 700), 0.2, 0.1, 1); | ||||
terrainPainter = new LayeredPainter( | terrainPainter = new LayeredPainter( | ||||
[tShore, tWater, tWater], // terrains | [tShore, tWater, tWater], // terrains | ||||
[1, 3] // widths | [1, 3] // widths | ||||
); | ); | ||||
elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -5, 5); | elevationPainter = new SmoothElevationPainter(ELEVATION_SET, -5, 5); | ||||
if (randInt(1,2) == 1) | if (randBool()) | ||||
{ | { | ||||
createAreas( | createAreas( | ||||
placer, | placer, | ||||
[terrainPainter, elevationPainter, paintClass(clWater)], | [terrainPainter, elevationPainter, paintClass(clWater)], | ||||
avoidClasses(clPlayer, 12, clWater, 8), | avoidClasses(clPlayer, 12, clWater, 8), | ||||
scaleByMapSize(5, 16) | scaleByMapSize(5, 16) | ||||
); | ); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | for (var m = 0; m < numPlayers; m++) | ||||
var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 24, 0); | var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 24, 0); | ||||
createArea(placer, [painter, elevationPainter], avoidClasses(clPlayer, 5)); | createArea(placer, [painter, elevationPainter], avoidClasses(clPlayer, 5)); | ||||
var placer = new PathPlacer(fractionToTiles(0.5 + 0.3*cos(tang) - 0.1 * cos(tang+PI/2)), fractionToTiles(0.5 + 0.3*sin(tang) - 0.1 * sin(tang+PI/2)), fractionToTiles(0.5 + 0.3*cos(tang) + 0.1 * cos(tang+PI/2)), fractionToTiles(0.5 + 0.3*sin(tang) + 0.1 * sin(tang+PI/2)), scaleByMapSize(14,24), 0.4, 3*(scaleByMapSize(1,3)), 0.2, 0.05); | var placer = new PathPlacer(fractionToTiles(0.5 + 0.3*cos(tang) - 0.1 * cos(tang+PI/2)), fractionToTiles(0.5 + 0.3*sin(tang) - 0.1 * sin(tang+PI/2)), fractionToTiles(0.5 + 0.3*cos(tang) + 0.1 * cos(tang+PI/2)), fractionToTiles(0.5 + 0.3*sin(tang) + 0.1 * sin(tang+PI/2)), scaleByMapSize(14,24), 0.4, 3*(scaleByMapSize(1,3)), 0.2, 0.05); | ||||
var painter = new LayeredPainter([tCliff, tCliff], [1]); | var painter = new LayeredPainter([tCliff, tCliff], [1]); | ||||
var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 2); | var elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 2); | ||||
createArea(placer, [painter, elevationPainter], null); | createArea(placer, [painter, elevationPainter], null); | ||||
} | } | ||||
var mdd1 = randInt (1,3); | var mdd1 = randIntInclusive(1,3); | ||||
if (mdd1 <= 2) | if (mdd1 <= 2) | ||||
{ | { | ||||
var fx = fractionToTiles(0.5); | var fx = fractionToTiles(0.5); | ||||
var fz = fractionToTiles(0.5); | var fz = fractionToTiles(0.5); | ||||
ix = round(fx); | ix = round(fx); | ||||
iz = round(fz); | iz = round(fz); | ||||
var placer = new ClumpPlacer(mapArea * 0.005, 0.7, 0.1, 10, ix, iz); | var placer = new ClumpPlacer(mapArea * 0.005, 0.7, 0.1, 10, ix, iz); | ||||
▲ Show 20 Lines • Show All 309 Lines • ▼ Show 20 Lines | |||||
// create bumps | // create bumps | ||||
log("Creating bumps..."); | log("Creating bumps..."); | ||||
placer = new ClumpPlacer(scaleByMapSize(20, 50), 0.3, 0.06, 1); | placer = new ClumpPlacer(scaleByMapSize(20, 50), 0.3, 0.06, 1); | ||||
var painter = new SmoothElevationPainter(ELEVATION_MODIFY, 2, 2); | var painter = new SmoothElevationPainter(ELEVATION_MODIFY, 2, 2); | ||||
createAreas( | createAreas( | ||||
placer, | placer, | ||||
painter, | painter, | ||||
[avoidClasses(clWater, 2, clPlayer, 10), stayClasses(clLand, 3)], | [avoidClasses(clWater, 2, clPlayer, 10), stayClasses(clLand, 3)], | ||||
randInt(0,scaleByMapSize(200, 400)) | randIntInclusive(0,scaleByMapSize(200, 400)) | ||||
); | ); | ||||
// create hills | // create hills | ||||
log("Creating hills..."); | log("Creating hills..."); | ||||
placer = new ClumpPlacer(scaleByMapSize(20, 150), 0.2, 0.1, 1); | placer = new ClumpPlacer(scaleByMapSize(20, 150), 0.2, 0.1, 1); | ||||
terrainPainter = new LayeredPainter( | terrainPainter = new LayeredPainter( | ||||
[tCliff, tHill], // terrains | [tCliff, tHill], // terrains | ||||
[2] // widths | [2] // widths | ||||
); | ); | ||||
elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 18, 2); | elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 18, 2); | ||||
createAreas( | createAreas( | ||||
placer, | placer, | ||||
[terrainPainter, elevationPainter, paintClass(clHill)], | [terrainPainter, elevationPainter, paintClass(clHill)], | ||||
[avoidClasses(clPlayer, 15, clHill, randInt(6, 18)), stayClasses(clLand, 0)], | [avoidClasses(clPlayer, 15, clHill, randIntInclusive(6, 18)), stayClasses(clLand, 0)], | ||||
randInt(0, scaleByMapSize(4, 8))*randInt(1, scaleByMapSize(4, 9)) | randIntInclusive(0, scaleByMapSize(4, 8))*randIntInclusive(1, scaleByMapSize(4, 9)) | ||||
); | ); | ||||
var multiplier = sqrt(randFloat(0.5,1.2)*randFloat(0.5,1.2)); | var multiplier = sqrt(randFloat(0.5,1.2)*randFloat(0.5,1.2)); | ||||
// calculate desired number of trees for map (based on size) | // calculate desired number of trees for map (based on size) | ||||
if (rt == 6) | if (rt == 6) | ||||
{ | { | ||||
var MIN_TREES = floor(200*multiplier); | var MIN_TREES = floor(200*multiplier); | ||||
var MAX_TREES = floor(1250*multiplier); | var MAX_TREES = floor(1250*multiplier); | ||||
Show All 36 Lines | for (var i = 0; i < types.length; ++i) | ||||
placer = new ClumpPlacer(numForest / num, 0.1, 0.1, 1); | placer = new ClumpPlacer(numForest / num, 0.1, 0.1, 1); | ||||
painter = new LayeredPainter( | painter = new LayeredPainter( | ||||
types[i], // terrains | types[i], // terrains | ||||
[2] // widths | [2] // widths | ||||
); | ); | ||||
createAreas( | createAreas( | ||||
placer, | placer, | ||||
[painter, paintClass(clForest)], | [painter, paintClass(clForest)], | ||||
[avoidClasses(clPlayer, 17, clForest, randInt(5, 15), clHill, 0), stayClasses(clLand, 4)], | [avoidClasses(clPlayer, 17, clForest, randIntInclusive(5, 15), clHill, 0), stayClasses(clLand, 4)], | ||||
num | num | ||||
); | ); | ||||
} | } | ||||
RMS.SetProgress(50); | RMS.SetProgress(50); | ||||
// create dirt patches | // create dirt patches | ||||
log("Creating dirt patches..."); | log("Creating dirt patches..."); | ||||
var sizes = [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]; | var sizes = [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)]; | ||||
Show All 32 Lines | |||||
RMS.SetProgress(55); | RMS.SetProgress(55); | ||||
log("Creating stone mines..."); | log("Creating stone mines..."); | ||||
// create large stone quarries | // create large stone quarries | ||||
var group = new SimpleGroup([new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)], true, clRock); | var group = new SimpleGroup([new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)], true, clRock); | ||||
createObjectGroups(group, 0, | createObjectGroups(group, 0, | ||||
[avoidClasses(clForest, 1, clPlayer, 10, clRock, 10, clHill, 1), stayClasses(clLand, 3)], | [avoidClasses(clForest, 1, clPlayer, 10, clRock, 10, clHill, 1), stayClasses(clLand, 3)], | ||||
randInt(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 | randIntInclusive(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 | ||||
); | ); | ||||
// create small stone quarries | // create small stone quarries | ||||
group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock); | group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock); | ||||
createObjectGroups(group, 0, | createObjectGroups(group, 0, | ||||
[avoidClasses(clForest, 1, clPlayer, 10, clRock, 10, clHill, 1), stayClasses(clLand, 3)], | [avoidClasses(clForest, 1, clPlayer, 10, clRock, 10, clHill, 1), stayClasses(clLand, 3)], | ||||
randInt(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 | randIntInclusive(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 | ||||
); | ); | ||||
log("Creating metal mines..."); | log("Creating metal mines..."); | ||||
// create large metal quarries | // create large metal quarries | ||||
group = new SimpleGroup([new SimpleObject(oMetalLarge, 1,1, 0,4)], true, clMetal); | group = new SimpleGroup([new SimpleObject(oMetalLarge, 1,1, 0,4)], true, clMetal); | ||||
createObjectGroups(group, 0, | createObjectGroups(group, 0, | ||||
[avoidClasses(clForest, 1, clPlayer, 10, clMetal, 10, clRock, 5, clHill, 1), stayClasses(clLand, 3)], | [avoidClasses(clForest, 1, clPlayer, 10, clMetal, 10, clRock, 5, clHill, 1), stayClasses(clLand, 3)], | ||||
randInt(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 | randIntInclusive(scaleByMapSize(2,9),scaleByMapSize(9,40)), 100 | ||||
); | ); | ||||
RMS.SetProgress(65); | RMS.SetProgress(65); | ||||
// create small decorative rocks | // create small decorative rocks | ||||
log("Creating small decorative rocks..."); | log("Creating small decorative rocks..."); | ||||
group = new SimpleGroup( | group = new SimpleGroup( | ||||
[new SimpleObject(aRockMedium, 1,3, 0,1)], | [new SimpleObject(aRockMedium, 1,3, 0,1)], | ||||
Show All 23 Lines | |||||
// create deer | // create deer | ||||
log("Creating deer..."); | log("Creating deer..."); | ||||
group = new SimpleGroup( | group = new SimpleGroup( | ||||
[new SimpleObject(oDeer, 5,7, 0,4)], | [new SimpleObject(oDeer, 5,7, 0,4)], | ||||
true, clFood | true, clFood | ||||
); | ); | ||||
createObjectGroups(group, 0, | createObjectGroups(group, 0, | ||||
[avoidClasses(clWater, 0, clForest, 0, clPlayer, 8, clHill, 1, clFood, 20), stayClasses(clLand, 2)], | [avoidClasses(clWater, 0, clForest, 0, clPlayer, 8, clHill, 1, clFood, 20), stayClasses(clLand, 2)], | ||||
randInt(numPlayers+3, 5*numPlayers+4), 50 | randIntInclusive(numPlayers+3, 5*numPlayers+4), 50 | ||||
); | ); | ||||
// create berry bush | // create berry bush | ||||
log("Creating berry bush..."); | log("Creating berry bush..."); | ||||
group = new SimpleGroup( | group = new SimpleGroup( | ||||
[new SimpleObject(oBerryBush, 5,7, 0,4)], | [new SimpleObject(oBerryBush, 5,7, 0,4)], | ||||
true, clFood | true, clFood | ||||
); | ); | ||||
createObjectGroups(group, 0, | createObjectGroups(group, 0, | ||||
[avoidClasses(clWater, 0, clForest, 0, clPlayer, 8, clHill, 1, clFood, 20), stayClasses(clLand, 2)], | [avoidClasses(clWater, 0, clForest, 0, clPlayer, 8, clHill, 1, clFood, 20), stayClasses(clLand, 2)], | ||||
randInt(1, 4) * numPlayers + 2, 50 | randIntInclusive(1, 4) * numPlayers + 2, 50 | ||||
); | ); | ||||
RMS.SetProgress(75); | RMS.SetProgress(75); | ||||
// create sheep | // create sheep | ||||
log("Creating sheep..."); | log("Creating sheep..."); | ||||
group = new SimpleGroup( | group = new SimpleGroup( | ||||
[new SimpleObject(oSheep, 2,3, 0,2)], | [new SimpleObject(oSheep, 2,3, 0,2)], | ||||
true, clFood | true, clFood | ||||
); | ); | ||||
createObjectGroups(group, 0, | createObjectGroups(group, 0, | ||||
[avoidClasses(clWater, 0, clForest, 0, clPlayer, 8, clHill, 1, clFood, 20), stayClasses(clLand, 2)], | [avoidClasses(clWater, 0, clForest, 0, clPlayer, 8, clHill, 1, clFood, 20), stayClasses(clLand, 2)], | ||||
randInt(numPlayers+3, 5*numPlayers+4), 50 | randIntInclusive(numPlayers+3, 5*numPlayers+4), 50 | ||||
); | ); | ||||
// create fish | // create fish | ||||
log("Creating fish..."); | log("Creating fish..."); | ||||
group = new SimpleGroup( | group = new SimpleGroup( | ||||
[new SimpleObject(oFish, 2,3, 0,2)], | [new SimpleObject(oFish, 2,3, 0,2)], | ||||
true, clFood | true, clFood | ||||
); | ); | ||||
createObjectGroups(group, 0, | createObjectGroups(group, 0, | ||||
avoidClasses(clLand, 4, clForest, 0, clPlayer, 0, clHill, 0, clFood, 20), | avoidClasses(clLand, 4, clForest, 0, clPlayer, 0, clHill, 0, clFood, 20), | ||||
randInt(15, 40) * numPlayers, 60 | randIntInclusive(15, 40) * numPlayers, 60 | ||||
); | ); | ||||
RMS.SetProgress(85); | RMS.SetProgress(85); | ||||
// create straggler trees | // create straggler trees | ||||
log("Creating straggler trees..."); | log("Creating straggler trees..."); | ||||
var types = [oOak, oOakLarge, oPine, oApple]; // some variation | var types = [oOak, oOakLarge, oPine, oApple]; // some variation | ||||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator