1
0
forked from mirrors/0ad

Random-map-script cleanup.

Use constants when checking for the biome type.
Remove unused code for nonexistent biomeID 0 from gaia.js.

This was SVN commit r17937.
This commit is contained in:
elexis
2016-03-23 03:05:39 +00:00
parent cfb8a6e30e
commit e7deb587bb
20 changed files with 88 additions and 105 deletions
@@ -316,7 +316,7 @@ RMS.SetProgress(65);
// create decoration
var planetm = 1;
if (random_terrain==7)
if (random_terrain == g_BiomeTropic)
planetm = 8;
createDecoration
@@ -454,7 +454,7 @@ RMS.SetProgress(65);
// create decoration
var planetm = 1;
if (random_terrain==7)
if (random_terrain == g_BiomeTropic)
planetm = 8;
createDecoration
@@ -317,7 +317,7 @@ RMS.SetProgress(65);
// create decoration
var planetm = 1;
if (random_terrain==7)
if (random_terrain == g_BiomeTropic)
planetm = 8;
createDecoration
@@ -1,7 +1,6 @@
RMS.LoadLibrary("rmgen");
//Random terrain textures, exclude african biome
let random_terrain = randomizeBiome([6]);
let random_terrain = randomizeBiome([g_BiomeSavanna]);
const tMainTerrain = rBiomeT1();
const tForestFloor1 = rBiomeT2();
@@ -18,7 +17,7 @@ const tWater = rBiomeT15();
let tHill = rBiomeT8();
let tDirt = rBiomeT9();
if (random_terrain == 1)
if (random_terrain == g_BiomeTemperate)
{
tDirt = ["medit_shrubs_a", "grass_field"];
tHill = ["grass_field", "peat_temp"];
@@ -333,7 +332,7 @@ RMS.SetProgress(65);
log("Creating dirt patches...");
let sizes = [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)];
let numb = random_terrain == 6 ? 3 : 1;
let numb = random_terrain == g_BiomeSavanna ? 3 : 1;
for (let i = 0; i < sizes.length; ++i)
{
@@ -394,7 +393,7 @@ log("Creating more straggeler trees...");
createStragglerTrees(types, avoidClasses(clWater, 5, clForest, 7, clMountain, 1, clPlayer, 30, clMetal, 3, clRock, 3));
log("Creating decoration...");
let planetm = random_terrain == 7 ? 8 : 1;
let planetm = random_terrain == g_BiomeTropic ? 8 : 1;
createDecoration
(
[
@@ -474,7 +474,7 @@ RMS.SetProgress(65);
// create decoration
var planetm = 1;
if (random_terrain==7)
if (random_terrain == g_BiomeTropic)
planetm = 8;
createDecoration
@@ -220,13 +220,13 @@ function placeBarriers()
{
var spineTerrain = g_Terrains.dirt;
if (g_MapInfo.biome == 2)
if (g_MapInfo.biome == g_BiomeSnowy)
spineTerrain = g_Terrains.tier1Terrain;
if (g_MapInfo.biome == 4 || g_MapInfo.biome == 6)
if (g_MapInfo.biome == g_BiomeAlpine || g_MapInfo.biome == g_BiomeSavanna)
spineTerrain = g_Terrains.tier2Terrain;
if (g_MapInfo.biome == 8)
if (g_MapInfo.biome == g_BiomeAutumn)
spineTerrain = g_Terrains.tier4Terrain;
// create mountain ranges
@@ -33,8 +33,7 @@ const g_InitialMines = 1;
const g_InitialMineDistance = 14;
const g_InitialTrees = 50;
// Random terrain textures, exclude african biome
let random_terrain = randomizeBiome([6]);
let random_terrain = randomizeBiome([g_BiomeSavanna]);
const tMainTerrain = rBiomeT1();
const tForestFloor1 = rBiomeT2();
@@ -446,7 +445,7 @@ createFood(
[avoidClasses(clForest, 0, clPlayer, 15, clHill, 1, clFood, 4, clRock, 4, clMetal, 4), stayClasses(clLand, 2)]
);
if (random_terrain == 3)
if (random_terrain == g_BiomeDesert)
{
log("Creating obelisks");
let group = new SimpleGroup(
@@ -462,7 +461,7 @@ if (random_terrain == 3)
log("Creating dirt patches...");
let sizes = [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)];
let numb = random_terrain == 6 ? 3 : 1;
let numb = random_terrain == g_BiomeSavanna ? 3 : 1;
for (let i = 0; i < sizes.length; ++i)
{
@@ -350,13 +350,13 @@ createAreas(
// calculate desired number of trees for map (based on size)
if (random_terrain == 6)
if (random_terrain == g_BiomeSavanna)
{
var MIN_TREES = 200;
var MAX_TREES = 1250;
var P_FOREST = 0;
}
else if (random_terrain == 7)
else if (random_terrain == g_BiomeTropic)
{
var MIN_TREES = 1000;
var MAX_TREES = 6000;
@@ -379,7 +379,7 @@ var types = [
[[tForestFloor1, tMainTerrain, pForest2], [tForestFloor1, pForest2]]
]; // some variation
if (random_terrain != 6)
if (random_terrain != g_BiomeSavanna)
{
var size = numForest / (scaleByMapSize(3,6) * numPlayers);
var num = floor(size / types.length);
@@ -404,7 +404,7 @@ RMS.SetProgress(50);
log("Creating dirt patches...");
var sizes = [scaleByMapSize(3, 6), scaleByMapSize(5, 10), scaleByMapSize(8, 21)];
var numb = 1;
if (random_terrain == 6)
if (random_terrain == g_BiomeSavanna)
numb = 3
for (var i = 0; i < sizes.length; i++)
{
@@ -556,10 +556,9 @@ for (var i = 0; i < types.length; ++i)
}
var planetm = 1;
if (random_terrain==7)
{
if (random_terrain == g_BiomeTropic)
planetm = 8;
}
//create small grass tufts
log("Creating small grass tufts...");
group = new SimpleGroup(
@@ -328,7 +328,7 @@ RMS.SetProgress(65);
// create decoration
var planetm = 1;
if (random_terrain==7)
if (random_terrain == g_BiomeTropic)
planetm = 8;
createDecoration
@@ -380,34 +380,34 @@ function createSunkenTerrain(players)
var lower = g_Terrains.tier2Terrain;
var road = g_Terrains.road;
if (g_MapInfo.biome == 2)
if (g_MapInfo.biome == g_BiomeSnowy)
{
middle = g_Terrains.tier2Terrain;
lower = g_Terrains.tier1Terrain;
}
if (g_MapInfo.biome == 4)
if (g_MapInfo.biome == g_BiomeAlpine)
{
middle = g_Terrains.shore;
lower = g_Terrains.tier4Terrain;
}
if (g_MapInfo.biome == 5)
if (g_MapInfo.biome == g_BiomeMediterranean)
{
middle = g_Terrains.tier1Terrain;
lower = g_Terrains.forestFloor1;
}
if (g_MapInfo.biome == 6)
if (g_MapInfo.biome == g_BiomeSavanna)
{
middle = g_Terrains.tier2Terrain;
lower = g_Terrains.tier4Terrain;
}
if (g_MapInfo.biome == 7 || g_MapInfo.biome == 8)
if (g_MapInfo.biome == g_BiomeTropic || g_MapInfo.biome == g_BiomeAutumn)
road = g_Terrains.roadWild;
if (g_MapInfo.biome == 8)
if (g_MapInfo.biome == g_BiomeAutumn)
middle = g_Terrains.shore;
var expSize = g_MapInfo.mapArea * 0.015 / (g_MapInfo.numPlayers / 4);
@@ -275,7 +275,7 @@ RMS.SetProgress(65);
// create decoration
var planetm = 1;
if (random_terrain==7)
if (random_terrain == g_BiomeTropic)
planetm = 8;
createDecoration
@@ -295,13 +295,13 @@ createAreas(
);
// calculate desired number of trees for map (based on size)
if (random_terrain == 6)
if (random_terrain == g_BiomeSavanna)
{
var MIN_TREES = 200;
var MAX_TREES = 1250;
var P_FOREST = 0.02;
}
else if (random_terrain == 7)
else if (random_terrain == g_BiomeTropic)
{
var MIN_TREES = 1000;
var MAX_TREES = 6000;
@@ -18,7 +18,7 @@ const tTier4Terrain = rBiomeT12();
const tShoreBlend = rBiomeT13();
var tShore = rBiomeT14();
var tWater = rBiomeT15();
if (random_terrain == 7)
if (random_terrain == g_BiomeTropic)
{
tShore = "tropic_dirt_b_plants";
tWater = "tropic_dirt_b";
@@ -458,7 +458,7 @@ RMS.SetProgress(65);
// create decoration
var planetm = 1;
if (random_terrain==7)
if (random_terrain == g_BiomeTropic)
planetm = 8;
createDecoration
@@ -320,7 +320,7 @@ function addDecoration(constraint, size, deviation, fill)
];
var baseCount = 1;
if (g_MapInfo.biome == 7)
if (g_MapInfo.biome == g_BiomeTropic)
baseCount = 8;
var counts = [
@@ -437,13 +437,13 @@ function addLakes(constraint, size, deviation, fill)
{
var lakeTile = g_Terrains.water;
if (g_MapInfo.biome == 0 || g_MapInfo.biome == 1 || g_MapInfo.biome == 7)
if (g_MapInfo.biome == g_BiomeTemperate || g_MapInfo.biome == g_BiomeTropic)
lakeTile = g_Terrains.dirt;
if (g_MapInfo.biome == 5)
if (g_MapInfo.biome == g_BiomeMediterranean)
lakeTile = g_Terrains.tier2Terrain;
if (g_MapInfo.biome == 8)
if (g_MapInfo.biome == g_BiomeAutumn)
lakeTile = g_Terrains.shore;
addElevation(constraint, {
@@ -556,13 +556,13 @@ function addPlateaus(constraint, size, deviation, fill)
{
var plateauTile = g_Terrains.dirt;
if (g_MapInfo.biome == 2)
if (g_MapInfo.biome == g_BiomeSnowy)
plateauTile = g_Terrains.tier1Terrain;
if (g_MapInfo.biome == 4 || g_MapInfo.biome == 6)
if (g_MapInfo.biome == g_BiomeAlpine || g_MapInfo.biome == g_BiomeSavanna)
plateauTile = g_Terrains.tier2Terrain;
if (g_MapInfo.biome == 8)
if (g_MapInfo.biome == g_BiomeAutumn)
plateauTile = g_Terrains.tier4Terrain;
addElevation(constraint, {
@@ -732,31 +732,25 @@ function addValleys(constraint, size, deviation, fill)
var valleySlope = g_Terrains.tier1Terrain;
var valleyFloor = g_Terrains.tier4Terrain;
if (g_MapInfo.biome == 0)
{
valleySlope = g_Terrains.dirt;
valleyFloor = g_Terrains.tier2Terrain;
}
if (g_MapInfo.biome == 3)
if (g_MapInfo.biome == g_BiomeDesert)
{
valleySlope = g_Terrains.tier3Terrain;
valleyFloor = g_Terrains.dirt;
}
if (g_MapInfo.biome == 5)
if (g_MapInfo.biome == g_BiomeMediterranean)
{
valleySlope = g_Terrains.tier2Terrain;
valleyFloor = g_Terrains.dirt;
}
if (g_MapInfo.biome == 4 || g_MapInfo.biome == 6)
if (g_MapInfo.biome == g_BiomeAlpine || g_MapInfo.biome == g_BiomeSavanna)
valleyFloor = g_Terrains.tier2Terrain;
if (g_MapInfo.biome == 7)
if (g_MapInfo.biome == g_BiomeTropic)
valleySlope = g_Terrains.dirt;
if (g_MapInfo.biome == 8)
if (g_MapInfo.biome == g_BiomeAutumn)
valleyFloor = g_Terrains.tier3Terrain;
addElevation(constraint, {
@@ -856,7 +850,7 @@ function addForests(constraint, size, deviation, fill)
fill = fill || 1;
// No forests for the african biome
if (g_MapInfo.biome == 6)
if (g_MapInfo.biome == g_BiomeSavanna)
return;
var types = [
@@ -947,7 +941,7 @@ function addStragglerTrees(constraint, size, deviation, fill)
fill = fill || 1;
// Ensure minimum distribution on african biome
if (g_MapInfo.biome == 6)
if (g_MapInfo.biome == g_BiomeSavanna)
{
fill = Math.max(fill, 2);
size = Math.max(size, 1);
@@ -969,7 +963,7 @@ function addStragglerTrees(constraint, size, deviation, fill)
var maxDist = 5 * offset;
// More trees for the african biome
if (g_MapInfo.biome == 6)
if (g_MapInfo.biome == g_BiomeSavanna)
{
min = 3 * offset;
max = 5 * offset;
@@ -982,7 +976,7 @@ function addStragglerTrees(constraint, size, deviation, fill)
var treesMax = max;
// Don't clump fruit trees
if (i == 2 && (g_MapInfo.biome == 3 || g_MapInfo.biome == 5))
if (i == 2 && (g_MapInfo.biome == g_BiomeDesert || g_MapInfo.biome == g_BiomeMediterranean))
treesMax = 1;
min = Math.min(min, treesMax);
@@ -1,3 +1,12 @@
const g_BiomeTemperate = 1;
const g_BiomeSnowy = 2;
const g_BiomeDesert = 3;
const g_BiomeAlpine = 4;
const g_BiomeMediterranean = 5;
const g_BiomeSavanna = 6;
const g_BiomeTropic = 7;
const g_BiomeAutumn = 8;
var biomeID = 1;
var rbt1 = ["temp_grass_long_b"];
var rbt2 = "temp_forestfloor_pine";
@@ -74,8 +83,7 @@ function setBiome(biomeIndex)
biomeID = biomeIndex;
//temperate
if (biomeID == 1)
if (biomeID == g_BiomeTemperate)
{
// temperate ocean blue, a bit too deep and saturated perhaps but it looks nicer.
// this assumes ocean settings, maps that aren't oceans should reset.
@@ -179,8 +187,7 @@ function setBiome(biomeIndex)
rba8 = "actor|props/flora/bush_medit_sm.xml";
rba9 = "actor|flora/trees/oak.xml";
}
//snowy
else if (biomeID == 2)
else if (biomeID == g_BiomeSnowy)
{
setSunColor(0.550, 0.601, 0.644); // a little darker
// Water is a semi-deep blue, fairly wavy, fairly murky for an ocean.
@@ -237,8 +244,7 @@ function setBiome(biomeIndex)
setPPSaturation(0.37);
setPPEffect("hdr");
}
//desert
else if (biomeID == 3)
else if (biomeID == g_BiomeDesert)
{
setSunColor(0.733, 0.746, 0.574);
@@ -315,8 +321,7 @@ function setBiome(biomeIndex)
rba8 = "actor|props/flora/bush_desert_dry_a.xml";
rba9 = "actor|flora/trees/palm_date.xml";
}
//alpine
else if (biomeID == 4)
else if (biomeID == g_BiomeAlpine)
{
// simulates an alpine lake, fairly deep.
// this is not intended for a clear running river, or even an ocean.
@@ -375,8 +380,7 @@ function setBiome(biomeIndex)
rba8 = "actor|props/flora/bush_desert_a.xml";
rba9 = "actor|flora/trees/pine.xml";
}
//medit
else if (biomeID == 5)
else if (biomeID == g_BiomeMediterranean)
{
// Guess what, this is based on the colors of the mediterranean sea.
setWaterColor(0.024,0.212,0.024);
@@ -470,8 +474,7 @@ function setBiome(biomeIndex)
rba8 = "actor|props/flora/bush_medit_sm.xml";
rba9 = "actor|flora/trees/palm_cretan_date.xml";
}
//savanah
else if (biomeID == 6)
else if (biomeID == g_BiomeSavanna)
{
// Using the Malawi as a reference, in parts where it's not too murky from a river nearby.
setWaterColor(0.055,0.176,0.431);
@@ -539,8 +542,7 @@ function setBiome(biomeIndex)
rba8 = "actor|props/flora/bush_dry_a.xml";
rba9 = "actor|flora/trees/baobab.xml";
}
//tropic
else if (biomeID == 7)
else if (biomeID == g_BiomeTropic)
{
// Bora-Bora ish. Quite transparent, not wavy.
@@ -600,8 +602,7 @@ function setBiome(biomeIndex)
rba8 = "actor|props/flora/plant_tropic_large.xml";
rba9 = "actor|flora/trees/tree_tropic.xml";
}
//autumn
else if (biomeID == 8)
else if (biomeID == g_BiomeAutumn)
{
// basically temperate with a reddish twist in the reflection and the tint. Also less wavy.
// this assumes ocean settings, maps that aren't oceans should reset.
@@ -95,13 +95,13 @@ function createForests(terrainset, constraint, tileclass, numMultiplier, biomeID
var tF1 = terrainset[3]
var tF2 = terrainset[4]
if (biomeID == 6)
if (biomeID == g_BiomeSavanna)
{
var MIN_TREES = 200 * numMultiplier;
var MAX_TREES = 1250 * numMultiplier;
var P_FOREST = 0;
}
else if (biomeID == 7)
else if (biomeID == g_BiomeTropic)
{
var MIN_TREES = 1000 * numMultiplier;
var MAX_TREES = 6000 * numMultiplier;
@@ -124,7 +124,7 @@ function createForests(terrainset, constraint, tileclass, numMultiplier, biomeID
[[tFF1, tM, tF2], [tFF1, tF2]]
]; // some variation
if (biomeID != 6)
if (biomeID != g_BiomeSavanna)
{
var size = numForest / (scaleByMapSize(3,6) * numPlayers);
var num = floor(size / types.length);
@@ -1687,13 +1687,13 @@ for (var ix = 0; ix < mapSize; ix++)
}
// calculate desired number of trees for map (based on size)
if (random_terrain == 6)
if (random_terrain == g_BiomeSavanna)
{
var MIN_TREES = 200;
var MAX_TREES = 1250;
var P_FOREST = 0.02;
}
else if (random_terrain == 7)
else if (random_terrain == g_BiomeTropic)
{
var MIN_TREES = 1000;
var MAX_TREES = 6000;
@@ -1716,14 +1716,11 @@ var types = [
[[tForestFloor1, tMainTerrain, pForest2], [tForestFloor1, pForest2]]
]; // some variation
if (random_terrain == 6)
{
if (random_terrain == g_BiomeSavanna)
var size = numForest / (0.5 * scaleByMapSize(2,8) * numPlayers);
}
else
{
else
var size = numForest / (scaleByMapSize(2,8) * numPlayers);
}
var num = floor(size / types.length);
for (var i = 0; i < types.length; ++i)
{
@@ -1882,10 +1879,9 @@ for (var i = 0; i < types.length; ++i)
}
var planetm = 1;
if (random_terrain==7)
{
if (random_terrain == g_BiomeTropic)
planetm = 8;
}
//create small grass tufts
log("Creating small grass tufts...");
group = new SimpleGroup(
@@ -262,7 +262,7 @@ createPatches(
// create decoration
var planetm = 1;
if (random_terrain==7)
if (random_terrain == g_BiomeTropic)
planetm = 8;
createDecoration
@@ -1804,13 +1804,13 @@ createAreas(
var multiplier = sqrt(randFloat(0.5,1.2)*randFloat(0.5,1.2));
// calculate desired number of trees for map (based on size)
if (random_terrain == 6)
if (random_terrain == g_BiomeSavanna)
{
var MIN_TREES = floor(200*multiplier);
var MAX_TREES = floor(1250*multiplier);
var P_FOREST = randFloat(0.02, 0.05);
}
else if (random_terrain == 7)
else if (random_terrain == g_BiomeTropic)
{
var MIN_TREES = floor(1000*multiplier);
var MAX_TREES = floor(6000*multiplier);
@@ -1833,14 +1833,11 @@ var types = [
[[tForestFloor1, tMainTerrain, pForest2], [tForestFloor1, pForest2]]
]; // some variation
if (random_terrain == 6)
{
if (random_terrain == g_BiomeSavanna)
var size = numForest / (0.5 * scaleByMapSize(2,8) * numPlayers);
}
else
{
var size = numForest / (scaleByMapSize(2,8) * numPlayers);
}
var num = floor(size / types.length);
for (var i = 0; i < types.length; ++i)
{
@@ -1862,7 +1859,7 @@ RMS.SetProgress(50);
log("Creating dirt patches...");
var sizes = [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)];
var numb = 1;
if (random_terrain == 6)
if (random_terrain == g_BiomeSavanna)
numb = 3
for (var i = 0; i < sizes.length; i++)
{
@@ -2014,10 +2011,9 @@ for (var i = 0; i < types.length; ++i)
}
var planetm = 1;
if (random_terrain==7)
{
if (random_terrain == g_BiomeTropic)
planetm = 8;
}
//create small grass tufts
log("Creating small grass tufts...");
group = new SimpleGroup(
@@ -1574,13 +1574,13 @@ createAreas(
var multiplier = sqrt(randFloat(0.5,1.2)*randFloat(0.5,1.2));
// calculate desired number of trees for map (based on size)
if (random_terrain == 6)
if (random_terrain == g_BiomeSavanna)
{
var MIN_TREES = floor(200*multiplier);
var MAX_TREES = floor(1250*multiplier);
var P_FOREST = 0;
}
else if (random_terrain == 7)
else if (random_terrain == g_BiomeTropic)
{
var MIN_TREES = floor(1000*multiplier);
var MAX_TREES = floor(6000*multiplier);
@@ -1603,7 +1603,7 @@ var types = [
[[tForestFloor1, tMainTerrain, pForest2], [tForestFloor1, pForest2]]
]; // some variation
if (random_terrain != 6)
if (random_terrain != g_BiomeSavanna)
{
var size = numForest / (scaleByMapSize(3,6) * numPlayers);
var num = floor(size / types.length);
@@ -1780,10 +1780,9 @@ for (var i = 0; i < types.length; ++i)
}
var planetm = 1;
if (random_terrain==7)
{
if (random_terrain == g_BiomeTropic)
planetm = 8;
}
//create small grass tufts
log("Creating small grass tufts...");
group = new SimpleGroup(