Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/maps/random/sahel.js
Show All 23 Lines | |||||
const oZebra = "gaia/fauna_zebra"; | const oZebra = "gaia/fauna_zebra"; | ||||
const oStoneSmall = "gaia/geology_stone_savanna_small"; | const oStoneSmall = "gaia/geology_stone_savanna_small"; | ||||
const oMetalLarge = "gaia/geology_metal_savanna_slabs"; | const oMetalLarge = "gaia/geology_metal_savanna_slabs"; | ||||
// decorative props | // decorative props | ||||
const aBush = "actor|props/flora/bush_medit_sm_dry.xml"; | const aBush = "actor|props/flora/bush_medit_sm_dry.xml"; | ||||
const aRock = "actor|geology/stone_savanna_med.xml"; | const aRock = "actor|geology/stone_savanna_med.xml"; | ||||
const PI12 = PI / 6; | |||||
function placeStoneMineFormation(x, z) | |||||
{ | |||||
var placer = new ChainPlacer(1, 2, 2, 1, x, z, undefined, [5]); | |||||
var painter = new TerrainPainter(tDirt4); | |||||
createArea(placer, painter, null); | |||||
var bbAngle = randFloat(0, TWO_PI); | |||||
const bbDist = 2.5; | |||||
for (var i = 0; i < 8; ++i) | |||||
{ | |||||
var bbX = round(x + (bbDist + randFloat(0,1)) * cos(bbAngle)); | |||||
var bbZ = round(z + (bbDist + randFloat(0,1)) * sin(bbAngle)); | |||||
placeObject(bbX, bbZ, oStoneSmall, 0, randFloat(0, TWO_PI)); | |||||
bbAngle += PI12; | |||||
} | |||||
} | |||||
log("Initializing map..."); | log("Initializing map..."); | ||||
InitMap(); | InitMap(); | ||||
var numPlayers = getNumPlayers(); | var numPlayers = getNumPlayers(); | ||||
var mapSize = getMapSize(); | var mapSize = getMapSize(); | ||||
var mapArea = mapSize*mapSize; | var mapArea = mapSize*mapSize; | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | group = new SimpleGroup( | ||||
true, clBaseResource, mX, mZ | true, clBaseResource, mX, mZ | ||||
); | ); | ||||
createObjectGroup(group, 0); | createObjectGroup(group, 0); | ||||
// create stone mines | // create stone mines | ||||
mAngle += randFloat(PI/8, PI/4); | mAngle += randFloat(PI/8, PI/4); | ||||
mX = round(fx + mDist * cos(mAngle)); | mX = round(fx + mDist * cos(mAngle)); | ||||
mZ = round(fz + mDist * sin(mAngle)); | mZ = round(fz + mDist * sin(mAngle)); | ||||
placeStoneMineFormation(mX, mZ); | createStoneMineFormation(mX, mZ, tDirt4); | ||||
addToClass(mX, mZ, clPlayer); | addToClass(mX, mZ, clPlayer); | ||||
// create the city patch | // create the city patch | ||||
var cityRadius = radius/3; | var cityRadius = radius/3; | ||||
var placer = new ClumpPlacer(PI*cityRadius*cityRadius, 0.6, 0.3, 10, ix, iz); | var placer = new ClumpPlacer(PI*cityRadius*cityRadius, 0.6, 0.3, 10, ix, iz); | ||||
var painter = new TerrainPainter(tCityTiles); | var painter = new TerrainPainter(tCityTiles); | ||||
createArea(placer, painter, null); | createArea(placer, painter, null); | ||||
var hillSize = PI * radius * radius; | var hillSize = PI * radius * radius; | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
log("Creating stone mines..."); | log("Creating stone mines..."); | ||||
// create stone mines | // create stone mines | ||||
for (var i = 0; i < scaleByMapSize(12,30); ++i) | for (var i = 0; i < scaleByMapSize(12,30); ++i) | ||||
{ | { | ||||
var mX = randInt(mapSize); | var mX = randInt(mapSize); | ||||
var mZ = randInt(mapSize); | var mZ = randInt(mapSize); | ||||
if (playerConstraint.allows(mX, mZ) && minesConstraint.allows(mX, mZ) && waterConstraint.allows(mX, mZ)) | if (playerConstraint.allows(mX, mZ) && minesConstraint.allows(mX, mZ) && waterConstraint.allows(mX, mZ)) | ||||
{ | { | ||||
placeStoneMineFormation(mX, mZ); | createStoneMineFormation(mX, mZ, tDirt4); | ||||
addToClass(mX, mZ, clRock); | addToClass(mX, mZ, clRock); | ||||
} | } | ||||
} | } | ||||
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, | ||||
▲ Show 20 Lines • Show All 131 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator