Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/maps/random/islands.js
Show First 20 Lines • Show All 214 Lines • ▼ Show 20 Lines | for (var i = 0; i < numIslands; ++i) | ||||
// create big islands | // create big islands | ||||
placer = new ChainPlacer(floor(scaleByMapSize(4, 8)), floor(scaleByMapSize(8, 14)), floor(scaleByMapSize(25, 60)), 0.07, chosenPoint[0], chosenPoint[1], scaleByMapSize(30,70)); | placer = new ChainPlacer(floor(scaleByMapSize(4, 8)), floor(scaleByMapSize(8, 14)), floor(scaleByMapSize(25, 60)), 0.07, chosenPoint[0], chosenPoint[1], scaleByMapSize(30,70)); | ||||
//placer = new ClumpPlacer(floor(hillSize*randFloat(0.9,2.1)), 0.80, 0.1, 0.07, chosenPoint[0], chosenPoint[1]); | //placer = new ClumpPlacer(floor(hillSize*randFloat(0.9,2.1)), 0.80, 0.1, 0.07, chosenPoint[0], chosenPoint[1]); | ||||
terrainPainter = new LayeredPainter( | terrainPainter = new LayeredPainter( | ||||
[tMainTerrain, tMainTerrain], // terrains | [tMainTerrain, tMainTerrain], // terrains | ||||
[2] // widths | [2] // widths | ||||
); | ); | ||||
elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 6); | elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 6); | ||||
var newIsland = createAreas( | var newIsland = createAreasDeprecated( | ||||
placer, | placer, | ||||
[terrainPainter, elevationPainter, paintClass(clLand)], | [terrainPainter, elevationPainter, paintClass(clLand)], | ||||
avoidClasses(clLand, 3, clPlayer, 3), | avoidClasses(clLand, 3, clPlayer, 3), | ||||
1, 1 | 1, 1 | ||||
); | ); | ||||
if (newIsland && newIsland.length) | if (newIsland && newIsland.length) | ||||
{ | { | ||||
var n = 0; | var n = 0; | ||||
Show All 21 Lines | for (var i = 0; i < numIslands; ++i) | ||||
chosenPoint = pickRandom(landAreas); | chosenPoint = pickRandom(landAreas); | ||||
placer = new ChainPlacer(floor(scaleByMapSize(4, 7)), floor(scaleByMapSize(7, 10)), floor(scaleByMapSize(16, 40)), 0.07, chosenPoint[0], chosenPoint[1], scaleByMapSize(22,40)); | placer = new ChainPlacer(floor(scaleByMapSize(4, 7)), floor(scaleByMapSize(7, 10)), floor(scaleByMapSize(16, 40)), 0.07, chosenPoint[0], chosenPoint[1], scaleByMapSize(22,40)); | ||||
terrainPainter = new LayeredPainter( | terrainPainter = new LayeredPainter( | ||||
[tMainTerrain, tMainTerrain], // terrains | [tMainTerrain, tMainTerrain], // terrains | ||||
[2] // widths | [2] // widths | ||||
); | ); | ||||
elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 6); | elevationPainter = new SmoothElevationPainter(ELEVATION_SET, 3, 6); | ||||
createAreas( | createAreasDeprecated( | ||||
placer, | placer, | ||||
[terrainPainter, elevationPainter, paintClass(clLand)], | [terrainPainter, elevationPainter, paintClass(clLand)], | ||||
avoidClasses(clLand, 3, clPlayer, 3), | avoidClasses(clLand, 3, clPlayer, 3), | ||||
1, 1 | 1, 1 | ||||
); | ); | ||||
if (newIsland !== undefined) | if (newIsland !== undefined) | ||||
{ | { | ||||
var temp = []; | var temp = []; | ||||
Show All 21 Lines | for (var i = 0; i < numPlayers; i++) | ||||
var painter = new LayeredPainter([tRoadWild, tRoad], [1]); | var painter = new LayeredPainter([tRoadWild, tRoad], [1]); | ||||
createArea(placer, painter, null); | createArea(placer, painter, null); | ||||
} | } | ||||
// 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); | ||||
painter = new SmoothElevationPainter(ELEVATION_MODIFY, 2, 2); | painter = new SmoothElevationPainter(ELEVATION_MODIFY, 2, 2); | ||||
createAreas( | createAreasDeprecated( | ||||
placer, | placer, | ||||
painter, | painter, | ||||
[avoidClasses(clPlayer, 0), stayClasses(clLand, 3)], | [avoidClasses(clPlayer, 0), stayClasses(clLand, 3)], | ||||
scaleByMapSize(20, 100) | scaleByMapSize(20, 100) | ||||
); | ); | ||||
// create hills | // create hills | ||||
log("Creating hills..."); | log("Creating hills..."); | ||||
placer = new ChainPlacer(1, floor(scaleByMapSize(4, 6)), floor(scaleByMapSize(16, 40)), 0.5); | placer = new ChainPlacer(1, floor(scaleByMapSize(4, 6)), floor(scaleByMapSize(16, 40)), 0.5); | ||||
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( | createAreasDeprecated( | ||||
placer, | placer, | ||||
[terrainPainter, elevationPainter, paintClass(clHill)], | [terrainPainter, elevationPainter, paintClass(clHill)], | ||||
[avoidClasses(clPlayer, 2, clHill, 15), stayClasses(clLand, 0)], | [avoidClasses(clPlayer, 2, clHill, 15), stayClasses(clLand, 0)], | ||||
scaleByMapSize(4, 13) | scaleByMapSize(4, 13) | ||||
); | ); | ||||
// calculate desired number of trees for map (based on size) | // calculate desired number of trees for map (based on size) | ||||
Show All 32 Lines | if (random_terrain != g_BiomeSavanna) | ||||
var num = floor(size / types.length); | var num = floor(size / types.length); | ||||
for (var i = 0; i < types.length; ++i) | for (var i = 0; i < types.length; ++i) | ||||
{ | { | ||||
placer = new ChainPlacer(1, floor(scaleByMapSize(3, 5)), numForest / (num * floor(scaleByMapSize(2,5))), 0.5); | placer = new ChainPlacer(1, floor(scaleByMapSize(3, 5)), numForest / (num * floor(scaleByMapSize(2,5))), 0.5); | ||||
painter = new LayeredPainter( | painter = new LayeredPainter( | ||||
types[i], // terrains | types[i], // terrains | ||||
[2] // widths | [2] // widths | ||||
); | ); | ||||
createAreas( | createAreasDeprecated( | ||||
placer, | placer, | ||||
[painter, paintClass(clForest)], | [painter, paintClass(clForest)], | ||||
[avoidClasses(clPlayer, 0, clForest, 10, clHill, 0), stayClasses(clLand, 6)], | [avoidClasses(clPlayer, 0, clForest, 10, clHill, 0), stayClasses(clLand, 6)], | ||||
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, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]; | var sizes = [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)]; | ||||
var numb = 1; | var numb = 1; | ||||
if (random_terrain == g_BiomeSavanna) | if (random_terrain == g_BiomeSavanna) | ||||
numb = 3; | numb = 3; | ||||
for (var i = 0; i < sizes.length; i++) | for (var i = 0; i < sizes.length; i++) | ||||
{ | { | ||||
placer = new ChainPlacer(1, floor(scaleByMapSize(3, 5)), sizes[i], 0.5); | placer = new ChainPlacer(1, floor(scaleByMapSize(3, 5)), sizes[i], 0.5); | ||||
painter = new LayeredPainter( | painter = new LayeredPainter( | ||||
[[tMainTerrain,tTier1Terrain],[tTier1Terrain,tTier2Terrain], [tTier2Terrain,tTier3Terrain]], // terrains | [[tMainTerrain,tTier1Terrain],[tTier1Terrain,tTier2Terrain], [tTier2Terrain,tTier3Terrain]], // terrains | ||||
[1,1] // widths | [1,1] // widths | ||||
); | ); | ||||
createAreas( | createAreasDeprecated( | ||||
placer, | placer, | ||||
[painter, paintClass(clDirt)], | [painter, paintClass(clDirt)], | ||||
[avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 0), stayClasses(clLand, 6)], | [avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 0), stayClasses(clLand, 6)], | ||||
numb*scaleByMapSize(15, 45) | numb*scaleByMapSize(15, 45) | ||||
); | ); | ||||
} | } | ||||
// create grass patches | // create grass patches | ||||
log("Creating grass patches..."); | log("Creating grass patches..."); | ||||
var sizes = [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)]; | var sizes = [scaleByMapSize(2, 4), scaleByMapSize(3, 7), scaleByMapSize(5, 15)]; | ||||
for (var i = 0; i < sizes.length; i++) | for (var i = 0; i < sizes.length; i++) | ||||
{ | { | ||||
placer = new ChainPlacer(1, floor(scaleByMapSize(3, 5)), sizes[i], 0.5); | placer = new ChainPlacer(1, floor(scaleByMapSize(3, 5)), sizes[i], 0.5); | ||||
painter = new TerrainPainter(tTier4Terrain); | painter = new TerrainPainter(tTier4Terrain); | ||||
createAreas( | createAreasDeprecated( | ||||
placer, | placer, | ||||
painter, | painter, | ||||
[avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 0), stayClasses(clLand, 6)], | [avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 0), stayClasses(clLand, 6)], | ||||
numb*scaleByMapSize(15, 45) | numb*scaleByMapSize(15, 45) | ||||
); | ); | ||||
} | } | ||||
RMS.SetProgress(55); | RMS.SetProgress(55); | ||||
log("Creating stone mines..."); | log("Creating stone mines..."); | ||||
// create large stone quarries | // create large stone quarries | ||||
group = new SimpleGroup([new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)], true, clRock); | group = new SimpleGroup([new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)], true, clRock); | ||||
createObjectGroups(group, 0, | createObjectGroupsDeprecated(group, 0, | ||||
[avoidClasses(clForest, 1, clPlayer, 0, clRock, 10, clHill, 1), stayClasses(clLand, 5)], | [avoidClasses(clForest, 1, clPlayer, 0, clRock, 10, clHill, 1), stayClasses(clLand, 5)], | ||||
scaleByMapSize(4,16), 100 | scaleByMapSize(4,16), 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, | createObjectGroupsDeprecated(group, 0, | ||||
[avoidClasses(clForest, 1, clPlayer, 0, clRock, 10, clHill, 1), stayClasses(clLand, 5)], | [avoidClasses(clForest, 1, clPlayer, 0, clRock, 10, clHill, 1), stayClasses(clLand, 5)], | ||||
scaleByMapSize(4,16), 100 | scaleByMapSize(4,16), 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, | createObjectGroupsDeprecated(group, 0, | ||||
[avoidClasses(clForest, 1, clPlayer, 0, clMetal, 10, clRock, 5, clHill, 1), stayClasses(clLand, 5)], | [avoidClasses(clForest, 1, clPlayer, 0, clMetal, 10, clRock, 5, clHill, 1), stayClasses(clLand, 5)], | ||||
scaleByMapSize(4,16), 100 | scaleByMapSize(4,16), 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)], | ||||
true | true | ||||
); | ); | ||||
createObjectGroups( | createObjectGroupsDeprecated( | ||||
group, 0, | group, 0, | ||||
[avoidClasses(clForest, 0, clPlayer, 0, clHill, 0), stayClasses(clLand, 5)], | [avoidClasses(clForest, 0, clPlayer, 0, clHill, 0), stayClasses(clLand, 5)], | ||||
scaleByMapSize(16, 262), 50 | scaleByMapSize(16, 262), 50 | ||||
); | ); | ||||
// create large decorative rocks | // create large decorative rocks | ||||
log("Creating large decorative rocks..."); | log("Creating large decorative rocks..."); | ||||
group = new SimpleGroup( | group = new SimpleGroup( | ||||
[new SimpleObject(aRockLarge, 1,2, 0,1), new SimpleObject(aRockMedium, 1,3, 0,2)], | [new SimpleObject(aRockLarge, 1,2, 0,1), new SimpleObject(aRockMedium, 1,3, 0,2)], | ||||
true | true | ||||
); | ); | ||||
createObjectGroups( | createObjectGroupsDeprecated( | ||||
group, 0, | group, 0, | ||||
[avoidClasses(clForest, 0, clPlayer, 0, clHill, 0), stayClasses(clLand, 5)], | [avoidClasses(clForest, 0, clPlayer, 0, clHill, 0), stayClasses(clLand, 5)], | ||||
scaleByMapSize(8, 131), 50 | scaleByMapSize(8, 131), 50 | ||||
); | ); | ||||
RMS.SetProgress(70); | RMS.SetProgress(70); | ||||
// create deer | // create deer | ||||
log("Creating deer..."); | log("Creating deer..."); | ||||
group = new SimpleGroup( | group = new SimpleGroup( | ||||
[new SimpleObject(oMainHuntableAnimal, 5,7, 0,4)], | [new SimpleObject(oMainHuntableAnimal, 5,7, 0,4)], | ||||
true, clFood | true, clFood | ||||
); | ); | ||||
createObjectGroups(group, 0, | createObjectGroupsDeprecated(group, 0, | ||||
[avoidClasses(clForest, 0, clPlayer, 0, clHill, 1, clFood, 20), stayClasses(clLand, 5)], | [avoidClasses(clForest, 0, clPlayer, 0, clHill, 1, clFood, 20), stayClasses(clLand, 5)], | ||||
3 * numPlayers, 50 | 3 * numPlayers, 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(oSecondaryHuntableAnimal, 2,3, 0,2)], | [new SimpleObject(oSecondaryHuntableAnimal, 2,3, 0,2)], | ||||
true, clFood | true, clFood | ||||
); | ); | ||||
createObjectGroups(group, 0, | createObjectGroupsDeprecated(group, 0, | ||||
[avoidClasses(clForest, 0, clPlayer, 0, clHill, 1, clFood, 20), stayClasses(clLand, 5)], | [avoidClasses(clForest, 0, clPlayer, 0, clHill, 1, clFood, 20), stayClasses(clLand, 5)], | ||||
3 * numPlayers, 50 | 3 * numPlayers, 50 | ||||
); | ); | ||||
// create fruit bush | // create fruit bush | ||||
log("Creating fruit bush..."); | log("Creating fruit bush..."); | ||||
group = new SimpleGroup( | group = new SimpleGroup( | ||||
[new SimpleObject(oFruitBush, 5,7, 0,4)], | [new SimpleObject(oFruitBush, 5,7, 0,4)], | ||||
true, clFood | true, clFood | ||||
); | ); | ||||
createObjectGroups(group, 0, | createObjectGroupsDeprecated(group, 0, | ||||
[avoidClasses(clForest, 0, clPlayer, 8, clHill, 1, clFood, 20), stayClasses(clLand, 5)], | [avoidClasses(clForest, 0, clPlayer, 8, clHill, 1, clFood, 20), stayClasses(clLand, 5)], | ||||
randIntInclusive(1, 4) * numPlayers + 2, 50 | randIntInclusive(1, 4) * numPlayers + 2, 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, | createObjectGroupsDeprecated(group, 0, | ||||
avoidClasses(clLand, 4, clForest, 2, clPlayer, 2, clHill, 2, clFood, 20), | avoidClasses(clLand, 4, clForest, 2, clPlayer, 2, clHill, 2, clFood, 20), | ||||
25 * numPlayers, 60 | 25 * numPlayers, 60 | ||||
); | ); | ||||
RMS.SetProgress(85); | RMS.SetProgress(85); | ||||
// create straggler trees | // create straggler trees | ||||
log("Creating straggler trees..."); | log("Creating straggler trees..."); | ||||
var types = [oTree1, oTree2, oTree4, oTree3]; // some variation | var types = [oTree1, oTree2, oTree4, oTree3]; // some variation | ||||
var num = floor(numStragglers / types.length); | var num = floor(numStragglers / types.length); | ||||
for (var i = 0; i < types.length; ++i) | for (var i = 0; i < types.length; ++i) | ||||
{ | { | ||||
group = new SimpleGroup( | group = new SimpleGroup( | ||||
[new SimpleObject(types[i], 1,1, 0,3)], | [new SimpleObject(types[i], 1,1, 0,3)], | ||||
true, clForest | true, clForest | ||||
); | ); | ||||
createObjectGroups(group, 0, | createObjectGroupsDeprecated(group, 0, | ||||
[avoidClasses(clForest, 1, clHill, 1, clPlayer, 0, clMetal, 6, clRock, 6), stayClasses(clLand, 6)], | [avoidClasses(clForest, 1, clHill, 1, clPlayer, 0, clMetal, 6, clRock, 6), stayClasses(clLand, 6)], | ||||
num | num | ||||
); | ); | ||||
} | } | ||||
var planetm = 1; | var planetm = 1; | ||||
if (random_terrain == g_BiomeTropic) | if (random_terrain == g_BiomeTropic) | ||||
planetm = 8; | planetm = 8; | ||||
//create small grass tufts | //create small grass tufts | ||||
log("Creating small grass tufts..."); | log("Creating small grass tufts..."); | ||||
group = new SimpleGroup( | group = new SimpleGroup( | ||||
[new SimpleObject(aGrassShort, 1,2, 0,1, -PI/8,PI/8)] | [new SimpleObject(aGrassShort, 1,2, 0,1, -PI/8,PI/8)] | ||||
); | ); | ||||
createObjectGroups(group, 0, | createObjectGroupsDeprecated(group, 0, | ||||
[avoidClasses(clHill, 2, clPlayer, 2, clDirt, 0), stayClasses(clLand, 6)], | [avoidClasses(clHill, 2, clPlayer, 2, clDirt, 0), stayClasses(clLand, 6)], | ||||
planetm * scaleByMapSize(13, 200) | planetm * scaleByMapSize(13, 200) | ||||
); | ); | ||||
RMS.SetProgress(90); | RMS.SetProgress(90); | ||||
// create large grass tufts | // create large grass tufts | ||||
log("Creating large grass tufts..."); | log("Creating large grass tufts..."); | ||||
group = new SimpleGroup( | group = new SimpleGroup( | ||||
[new SimpleObject(aGrass, 2,4, 0,1.8, -PI/8,PI/8), new SimpleObject(aGrassShort, 3,6, 1.2,2.5, -PI/8,PI/8)] | [new SimpleObject(aGrass, 2,4, 0,1.8, -PI/8,PI/8), new SimpleObject(aGrassShort, 3,6, 1.2,2.5, -PI/8,PI/8)] | ||||
); | ); | ||||
createObjectGroups(group, 0, | createObjectGroupsDeprecated(group, 0, | ||||
[avoidClasses(clHill, 2, clPlayer, 2, clDirt, 1, clForest, 0), stayClasses(clLand, 5)], | [avoidClasses(clHill, 2, clPlayer, 2, clDirt, 1, clForest, 0), stayClasses(clLand, 5)], | ||||
planetm * scaleByMapSize(13, 200) | planetm * scaleByMapSize(13, 200) | ||||
); | ); | ||||
RMS.SetProgress(95); | RMS.SetProgress(95); | ||||
// create bushes | // create bushes | ||||
log("Creating bushes..."); | log("Creating bushes..."); | ||||
group = new SimpleGroup( | group = new SimpleGroup( | ||||
[new SimpleObject(aBushMedium, 1,2, 0,2), new SimpleObject(aBushSmall, 2,4, 0,2)] | [new SimpleObject(aBushMedium, 1,2, 0,2), new SimpleObject(aBushSmall, 2,4, 0,2)] | ||||
); | ); | ||||
createObjectGroups(group, 0, | createObjectGroupsDeprecated(group, 0, | ||||
[avoidClasses(clHill, 1, clPlayer, 1, clDirt, 1), stayClasses(clLand, 6)], | [avoidClasses(clHill, 1, clPlayer, 1, clDirt, 1), stayClasses(clLand, 6)], | ||||
planetm * scaleByMapSize(13, 200), 50 | planetm * scaleByMapSize(13, 200), 50 | ||||
); | ); | ||||
setSkySet(pickRandom(["cirrus", "cumulus", "sunny"])); | setSkySet(pickRandom(["cirrus", "cumulus", "sunny"])); | ||||
setSunRotation(randFloat(0, TWO_PI)); | setSunRotation(randFloat(0, TWO_PI)); | ||||
setSunElevation(randFloat(PI/ 5, PI / 3)); | setSunElevation(randFloat(PI/ 5, PI / 3)); | ||||
setWaterWaviness(2); | setWaterWaviness(2); | ||||
// Export map data | // Export map data | ||||
ExportMap(); | ExportMap(); |
Wildfire Games · Phabricator