Remove Math.sin, cos and PI proxy functions from rmgen. Fixes #4933.

This was SVN commit r20816.
This commit is contained in:
elexis
2018-01-11 03:16:31 +00:00
parent 921850cdef
commit 08f561c02d
43 changed files with 235 additions and 245 deletions
@@ -280,7 +280,7 @@ setFogColor(0.8, 0.7, 0.5);
setSkySet("sunny");
setSunRotation(randFloat(0, 2 * Math.PI));
setSunElevation(randFloat(PI/ 4, PI / 2));
setSunElevation(Math.PI * randFloat(1/4, 1/2));
setWaterColor(0.223, 0.247, 0.2); // dark majestic blue
setWaterTint(0.462, 0.756, 0.566); // light blue
@@ -293,7 +293,7 @@ createStragglerTrees(
setSkySet(pickRandom(["cirrus", "cumulus", "sunny"]));
setSunRotation(randFloat(0, 2 * Math.PI));
setSunElevation(randFloat(PI/ 5, PI / 3));
setSunElevation(Math.PI * randFloat(1/5, 1/3));
setWaterColor(0.0, 0.047, 0.286); // dark majestic blue
setWaterTint(0.471, 0.776, 0.863); // light blue
setWaterMurkiness(0.82);
@@ -506,7 +506,7 @@ log("Creating small grass tufts...");
var planetm = 1;
group = new SimpleGroup(
[new SimpleObject(aGrassShort, 1,2, 0,1, -PI/8,PI/8)]
[new SimpleObject(aGrassShort, 1,2, 0,1, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsDeprecated(group, 0,
avoidClasses(clHill, 2, clPlayer, 2, clDirt, 0),
@@ -516,7 +516,7 @@ Engine.SetProgress(90);
log("Creating large grass tufts...");
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, -Math.PI / 8, Math.PI / 8), new SimpleObject(aGrassShort, 3,6, 1.2,2.5, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsDeprecated(group, 0,
avoidClasses(clHill, 2, clPlayer, 2, clDirt, 1, clForest, 0),
@@ -535,7 +535,7 @@ createObjectGroupsDeprecated(group, 0,
setSkySet(pickRandom(["cirrus", "cumulus", "sunny"]));
setSunRotation(randFloat(0, 2 * Math.PI));
setSunElevation(randFloat(PI/ 5, PI / 3));
setSunElevation(Math.PI * randFloat(1/5, 1/3));
setWaterColor(0.0, 0.047, 0.286); // dark majestic blue
setWaterTint(0.471, 0.776, 0.863); // light blue
setWaterMurkiness(0.72);
@@ -213,7 +213,7 @@ createStragglerTrees(
log("Creating large grass tufts...");
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, -Math.PI / 8, Math.PI / 8), new SimpleObject(aGrassShort, 3,6, 1.2,2.5, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsDeprecated(group, 0,
avoidClasses(clHill, 2, clPlayer, 10, clDirt, 1, clForest, 0),
@@ -306,11 +306,11 @@ createStragglerTrees(
stragglerTrees);
setSkySet("sunset 1");
setSunRotation(randFloat(0, 2 * PI));
setSunRotation(randFloat(0, 2 * Math.PI));
setSunColor(0.8, 0.7, 0.6);
setTerrainAmbientColor(0.7, 0.6, 0.7);
setUnitsAmbientColor(0.6, 0.5, 0.6);
setSunElevation(randFloat(PI/12, PI/7));
setSunElevation(Math.PI * randFloat(1/12, 1/7));
setWaterColor(0, 0.047, 0.286);
setWaterTint(0.462, 0.756, 0.866);
setWaterMurkiness(0.92);
@@ -268,7 +268,7 @@ for (var ix = 0; ix < mapSize; ix++)
if (h > 35 && randBool(0.1) ||
h < 15 && 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));
placeObject(ix + randFloat(0, 1), iz + randFloat(0, 1), pickRandom(aTrees), 0, randFloat(0, 2 * Math.PI));
}
}
@@ -445,7 +445,7 @@ Engine.SetProgress(95);
log("Creating grass tufts...");
group = new SimpleGroup(
[new SimpleObject(aGrassLarge, 1,2, 0,1, -PI/8,PI/8)]
[new SimpleObject(aGrassLarge, 1,2, 0,1, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsByAreasDeprecated(group, 0,
avoidClasses(clHill, 2, clPlayer, 2),
@@ -285,97 +285,97 @@ for(var x = minTerrainDistToBorder; x < mapSize - minTerrainDistToBorder; x++)
if (i == 0) // ...deep water
{
if (randBool(propDensity / 100))
placeObject(x, y, "actor|props/flora/pond_lillies_large.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/pond_lillies_large.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 40))
placeObject(x, y, "actor|props/flora/water_lillies.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/water_lillies.xml", 0, randFloat(0, 2 * Math.PI));
}
if (i == 1) // ...medium water (with fish)
{
if (randBool(propDensity / 200))
placeObject(x, y, "actor|props/flora/pond_lillies_large.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/pond_lillies_large.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 100))
placeObject(x, y, "actor|props/flora/water_lillies.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/water_lillies.xml", 0, randFloat(0, 2 * Math.PI));
}
if (i == 2) // ...low water/mud
{
if (randBool(propDensity / 200))
placeObject(x, y, "actor|props/flora/water_log.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/water_log.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 100))
placeObject(x, y, "actor|props/flora/water_lillies.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/water_lillies.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 40))
placeObject(x, y, "actor|geology/highland_c.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|geology/highland_c.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 20))
placeObject(x, y, "actor|props/flora/reeds_pond_lush_b.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/reeds_pond_lush_b.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 10))
placeObject(x, y, "actor|props/flora/reeds_pond_lush_a.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/reeds_pond_lush_a.xml", 0, randFloat(0, 2 * Math.PI));
}
if (i == 3) // ...water suroundings/bog
{
if (randBool(propDensity / 200))
placeObject(x, y, "actor|props/flora/water_log.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/water_log.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 100))
placeObject(x, y, "actor|geology/highland_c.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|geology/highland_c.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 40))
placeObject(x, y, "actor|props/flora/reeds_pond_lush_a.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/reeds_pond_lush_a.xml", 0, randFloat(0, 2 * Math.PI));
}
if (i == 4) // ...low height grass
{
if (randBool(propDensity / 800))
placeObject(x, y, "actor|props/flora/grass_field_flowering_tall.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/grass_field_flowering_tall.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 400))
placeObject(x, y, "actor|geology/gray_rock1.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|geology/gray_rock1.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 200))
placeObject(x, y, "actor|props/flora/bush_tempe_sm_lush.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/bush_tempe_sm_lush.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 100))
placeObject(x, y, "actor|props/flora/bush_tempe_b.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/bush_tempe_b.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 40))
placeObject(x, y, "actor|props/flora/grass_soft_small_tall.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/grass_soft_small_tall.xml", 0, randFloat(0, 2 * Math.PI));
}
if (i == 5) // ...medium height grass
{
if (randBool(propDensity / 800))
placeObject(x, y, "actor|geology/decal_stone_medit_a.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|geology/decal_stone_medit_a.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 400))
placeObject(x, y, "actor|props/flora/decals_flowers_daisies.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/decals_flowers_daisies.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 200))
placeObject(x, y, "actor|props/flora/bush_tempe_underbrush.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/bush_tempe_underbrush.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 100))
placeObject(x, y, "actor|props/flora/grass_soft_small_tall.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/grass_soft_small_tall.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 40))
placeObject(x, y, "actor|props/flora/grass_temp_field.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/grass_temp_field.xml", 0, randFloat(0, 2 * Math.PI));
}
if (i == 6) // ...high height grass
{
if (randBool(propDensity / 400))
placeObject(x, y, "actor|geology/stone_granite_boulder.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|geology/stone_granite_boulder.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 200))
placeObject(x, y, "actor|props/flora/foliagebush.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/foliagebush.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 100))
placeObject(x, y, "actor|props/flora/bush_tempe_underbrush.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/bush_tempe_underbrush.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 40))
placeObject(x, y, "actor|props/flora/grass_soft_small_tall.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/grass_soft_small_tall.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 20))
placeObject(x, y, "actor|props/flora/ferns.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/ferns.xml", 0, randFloat(0, 2 * Math.PI));
}
if (i == 7) // ...forest border (with wood/food plants/deer/rabits)
{
if (randBool(propDensity / 400))
placeObject(x, y, "actor|geology/highland_c.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|geology/highland_c.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 200))
placeObject(x, y, "actor|props/flora/bush_tempe_a.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/bush_tempe_a.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 100))
placeObject(x, y, "actor|props/flora/ferns.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/ferns.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 40))
placeObject(x, y, "actor|props/flora/grass_soft_tuft_a.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/grass_soft_tuft_a.xml", 0, randFloat(0, 2 * Math.PI));
}
if (i == 8) // ...woods
{
if (randBool(propDensity / 200))
placeObject(x, y, "actor|geology/highland2_moss.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|geology/highland2_moss.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 100))
placeObject(x, y, "actor|props/flora/grass_soft_tuft_a.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/grass_soft_tuft_a.xml", 0, randFloat(0, 2 * Math.PI));
else if (randBool(propDensity / 40))
placeObject(x, y, "actor|props/flora/ferns.xml", 0, randFloat(0, 2*PI));
placeObject(x, y, "actor|props/flora/ferns.xml", 0, randFloat(0, 2 * Math.PI));
}
break;
}
@@ -404,7 +404,7 @@ for (var p = 0; p < numPlayers; p++)
var uSpace = 1;
for (var j = 1; j <= 4; ++j)
{
var uAngle = BUILDING_ORIENTATION - PI * (2-j) / 2;
var uAngle = BUILDING_ORIENTATION - Math.PI * (2-j) / 2;
var count = 4;
for (var numberofentities = 0; numberofentities < count; numberofentities++)
{
@@ -412,9 +412,9 @@ for (var p = 0; p < numPlayers; p++)
var uz = actualY + uDist * Math.sin(uAngle) + numberofentities * uSpace * Math.sin(uAngle + Math.PI/2) - (0.75 * uSpace * Math.floor(count / 2) * Math.sin(uAngle + Math.PI/2));
if (j % 2 == 0)
placeObject(ux, uz, "gaia/flora_bush_berry", 0, randFloat(0, 2*PI));
placeObject(ux, uz, "gaia/flora_bush_berry", 0, randFloat(0, 2 * Math.PI));
else
placeObject(ux, uz, "gaia/flora_tree_cypress", 0, randFloat(0, 2*PI));
placeObject(ux, uz, "gaia/flora_tree_cypress", 0, randFloat(0, 2 * Math.PI));
}
}
}
@@ -314,7 +314,7 @@ Engine.SetProgress(85);
log("Creating small grass tufts...");
createObjectGroupsDeprecated(
new SimpleGroup([new SimpleObject(aGrassShort, 1, 2, 0, 1, -PI/8, PI/8)]),
new SimpleGroup([new SimpleObject(aGrassShort, 1, 2, 0, 1, -Math.PI / 8, Math.PI / 8)]),
0,
avoidClasses(clWater, 2, clPlayer, 13, clDirt, 0),
scaleByMapSize(13, 200));
@@ -323,8 +323,8 @@ Engine.SetProgress(90);
log("Creating large grass tufts...");
createObjectGroupsDeprecated(
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, -Math.PI / 8, Math.PI / 8),
new SimpleObject(aGrassShort, 3, 6, 1.2, 2.5, -Math.PI / 8, Math.PI / 8)
]),
0,
avoidClasses(clWater, 3, clPlayer, 13, clDirt, 1, clForest, 0),
@@ -32,9 +32,9 @@ function placeRandomPathToHeight(
if (Math.euclidDistance2D(position.x, position.y, target.x, target.y) < distance / 2)
break;
let angleToTarget = getAngle(position.x, position.y, target.x, target.y);
let angleOff = randFloat(-PI/2, PI/2);
position.x += distance * cos(angleToTarget + angleOff);
position.y += distance * sin(angleToTarget + angleOff);
let angleOff = randFloat(-1, 1) * Math.PI / 2;
position.x += distance * Math.cos(angleToTarget + angleOff);
position.y += distance * Math.sin(angleToTarget + angleOff);
}
return pathPoints;
}
@@ -60,7 +60,7 @@ function placeMine(point, centerEntity)
{
let angle = dAngle * randFloat(i, i + 1);
let dist = randFloat(2, 5);
placeObject(point.x + dist * Math.cos(angle), point.y + dist * Math.sin(angle), pickRandom(decorations), 0, randFloat(0, 2 * PI));
placeObject(point.x + dist * Math.cos(angle), point.y + dist * Math.sin(angle), pickRandom(decorations), 0, randFloat(0, 2 * Math.PI));
}
}
@@ -122,7 +122,7 @@ let clGrove = createTileClass();
function placeGrove(point)
{
placeObject(point.x, point.y, pickRandom(["structures/gaul_outpost", "gaia/flora_tree_oak_new"]), 0, randFloat(0, 2 * PI));
placeObject(point.x, point.y, pickRandom(["structures/gaul_outpost", "gaia/flora_tree_oak_new"]), 0, randFloat(0, 2 * Math.PI));
let quantity = randIntInclusive(20, 30);
let dAngle = 2 * Math.PI / quantity;
for (let i = 0; i < quantity; ++i)
@@ -134,7 +134,7 @@ function placeGrove(point)
objectList = groveActors;
let x = point.x + dist * Math.cos(angle);
let y = point.y + dist * Math.sin(angle);
placeObject(x, y, pickRandom(objectList), 0, randFloat(0, 2 * PI));
placeObject(x, y, pickRandom(objectList), 0, randFloat(0, 2 * Math.PI));
createArea(new ClumpPlacer(5, 1, 1, 1, Math.floor(x), Math.floor(y)), [new TerrainPainter("temp_grass_plants"), paintClass(clGrove)]);
}
}
@@ -155,7 +155,7 @@ function placeCamp(point,
{
let angle = dAngle * randFloat(i, i + 1);
let dist = randFloat(1, 3);
placeObject(point.x + dist * Math.cos(angle), point.y + dist * Math.sin(angle), pickRandom(otherEntities), 0, randFloat(0, 2 * PI));
placeObject(point.x + dist * Math.cos(angle), point.y + dist * Math.sin(angle), pickRandom(otherEntities), 0, randFloat(0, 2 * Math.PI));
}
}
@@ -184,7 +184,7 @@ function placeStartLocationResources(point, foodEntities = ["gaia/flora_bush_ber
objectList = groveActors;
x = point.x + dist * Math.cos(angle);
y = point.y + dist * Math.sin(angle);
placeObject(x, y, pickRandom(objectList), 0, randFloat(0, 2 * PI));
placeObject(x, y, pickRandom(objectList), 0, randFloat(0, 2 * Math.PI));
createArea(new ClumpPlacer(5, 1, 1, 1, Math.floor(x), Math.floor(y)), [new TerrainPainter("temp_grass_plants"), paintClass(clGrove)]);
currentAngle += dAngle;
}
@@ -207,7 +207,7 @@ function placeStartLocationResources(point, foodEntities = ["gaia/flora_bush_ber
dist = randFloat(10, 15);
x = point.x + dist * Math.cos(angle);
y = point.y + dist * Math.sin(angle);
placeObject(x, y, pickRandom(foodEntities), 0, randFloat(0, 2 * PI));
placeObject(x, y, pickRandom(foodEntities), 0, randFloat(0, 2 * Math.PI));
currentAngle += dAngle;
}
}
@@ -443,7 +443,7 @@ for (let h = 0; h < heighLimits.length; ++h)
g_Map.texture[x][y] = g_Map.getTextureID(texture);
if (actor)
placeObject(randFloat(x, x + 1), randFloat(y, y + 1), actor, 0, randFloat(0, 2 * PI));
placeObject(randFloat(x, x + 1), randFloat(y, y + 1), actor, 0, randFloat(0, 2 * Math.PI));
}
}
@@ -468,7 +468,7 @@ for (let i = 0; i < resourceSpots.length; ++i)
if (choice == 1)
placeMine(resourceSpots[i], "gaia/geology_metal_temperate_slabs");
if (choice == 2)
placeCustomFortress(resourceSpots[i].x, resourceSpots[i].y, pickRandom(fences), "other", 0, randFloat(0, 2 * PI));
placeCustomFortress(resourceSpots[i].x, resourceSpots[i].y, pickRandom(fences), "other", 0, randFloat(0, 2 * Math.PI));
if (choice == 3)
placeGrove(resourceSpots[i]);
if (choice == 4)
@@ -210,11 +210,11 @@ if (gallicCC)
// Create the meeting place near the shoreline at the end of the path
createArea(
new ClumpPlacer(mRadius * mRadius * PI, 0.6, 0.3, 10, mX, mZ),
new ClumpPlacer(mRadius * mRadius * Math.PI, 0.6, 0.3, 10, mX, mZ),
[new LayeredPainter([tShore, tShore], [1]), paintClass(clPath), paintClass(clRitualPlace)],
null);
placeObject(mX, mZ, aCampfire, 0, randFloat(0, 2 * PI));
placeObject(mX, mZ, aCampfire, 0, randFloat(0, 2 * Math.PI));
let femaleCount = Math.round(mRadius * 2);
let maleCount = Math.round(mRadius * 3);
@@ -252,11 +252,11 @@ if (gallicCC)
placeCustomFortress(mX, mZ, new Fortress("celt ritual goat", new Array(goatCount).fill("goat")), "celt_ritual", 0, 0);
}
placeObject(gX, gZ, oCivicCenter, 0, BUILDING_ORIENTATION + PI * 3/2 * i);
placeObject(gX, gZ, oCivicCenter, 0, BUILDING_ORIENTATION + Math.PI * 3/2 * i);
// Create the city patch
createArea(
new ClumpPlacer(gaulCityRadius * gaulCityRadius * PI, 0.6, 0.3, 10, gX, gZ),
new ClumpPlacer(gaulCityRadius * gaulCityRadius * Math.PI, 0.6, 0.3, 10, gX, gZ),
[new LayeredPainter([tShore, tShore], [1]), paintClass(clGauls)],
null);
@@ -300,7 +300,7 @@ if (gallicCC)
"spike_single"
];
spikes = spikes.concat(spikes);
placeCustomFortress(gX, gZ, new Fortress("spikes", spikes), "palisade", 0, PI);
placeCustomFortress(gX, gZ, new Fortress("spikes", spikes), "palisade", 0, Math.PI);
// Place treasure, potentially inside buildings
for (let i = 0; i < gallicCCTreasureCount; ++i)
@@ -309,7 +309,7 @@ if (gallicCC)
gZ + randFloat(-0.8, 0.8) * gaulCityRadius,
pickRandom(oTreasures),
0,
randFloat(0, 2 * PI));
randFloat(0, 2 * Math.PI));
}
}
Engine.SetProgress(10);
@@ -648,10 +648,10 @@ createDecoration(
[
[new SimpleObject(aBucket, 1, 1, 0, 1)],
[new SimpleObject(aBarrel, 1, 1, 0, 1)],
[new SimpleObject(aTartan, 3, 3, 4, 4, PI/4, PI/2)],
[new SimpleObject(aTartan, 3, 3, 4, 4, Math.PI/4, Math.PI/2)],
[new SimpleObject(aWheel, 2, 4, 1, 2)],
[new SimpleObject(aWell, 1, 1, 0, 2)],
[new SimpleObject(aWoodcord, 1, 2, 2, 2, PI/2, PI/2)]
[new SimpleObject(aWoodcord, 1, 2, 2, 2, Math.PI/2, Math.PI/2)]
],
[
scaleByMapSize(2, 10),
@@ -46,8 +46,8 @@ var maxPlayerRadius = Math.min(mapRadius - baseRadius, 3/4 * mapRadius);
var playerStartLocX = [];
var playerStartLocZ = [];
var playerAngle = [];
var playerAngleStart = randFloat(0, 2*PI);
var playerAngleAddAvrg = 2*PI / numPlayers;
var playerAngleStart = randFloat(0, 2 * Math.PI);
var playerAngleAddAvrg = 2 * Math.PI / numPlayers;
var playerAngleMaxOff = playerAngleAddAvrg/4;
// Setup eyecandy
@@ -56,7 +56,7 @@ var radiusEC = Math.max(mapRadius/8, baseRadius/2);
// Setup paths
var pathSucsessRadius = baseRadius/2;
var pathAngleOff = PI/2;
var pathAngleOff = Math.PI / 2;
var pathWidth = 5; // This is not really the path's sickness in tiles but the number of tiles in the clumbs of the path
// Setup additional resources
@@ -73,7 +73,7 @@ var playerIDs = [];
for (var i=0; i < numPlayers; i++)
{
playerIDs[i] = i+1;
playerAngle[i] = (playerAngleStart + i*playerAngleAddAvrg + randFloat(0, playerAngleMaxOff))%(2*PI);
playerAngle[i] = (playerAngleStart + i * playerAngleAddAvrg + randFloat(0, playerAngleMaxOff)) % (2 * Math.PI);
playerStartLocX[i] = mapCenterX + Math.round(randFloat(minPlayerRadius, maxPlayerRadius) * Math.cos(playerAngle[i]));
playerStartLocZ[i] = mapCenterZ + Math.round(randFloat(minPlayerRadius, maxPlayerRadius) * Math.sin(playerAngle[i]));
}
@@ -155,8 +155,8 @@ for (var i = 0; i < maxI; i++)
// Prepare path placement
var angle = getAngle(x, z, targetX, targetZ);
x += Math.round(pathSucsessRadius*cos(angle));
z += Math.round(pathSucsessRadius*sin(angle));
x += Math.round(pathSucsessRadius * Math.cos(angle));
z += Math.round(pathSucsessRadius * Math.sin(angle));
var targetReached = false;
var tries = 0;
// Placing paths
@@ -170,13 +170,13 @@ for (var i = 0; i < maxI; i++)
angle = getAngle(x, z, targetX, targetZ);
if (doublePaths == true) // Bended paths
{
x += Math.round(cos(angle + randFloat(-pathAngleOff/2, 3*pathAngleOff/2)));
z += Math.round(sin(angle + randFloat(-pathAngleOff/2, 3*pathAngleOff/2)));
x += Math.round(Math.cos(angle + randFloat(-pathAngleOff/2, 3*pathAngleOff/2)));
z += Math.round(Math.sin(angle + randFloat(-pathAngleOff/2, 3*pathAngleOff/2)));
}
else // Straight paths
{
x += Math.round(cos(angle + randFloat(-pathAngleOff, pathAngleOff)));
z += Math.round(sin(angle + randFloat(-pathAngleOff, pathAngleOff)));
x += Math.round(Math.cos(angle + randFloat(-pathAngleOff, pathAngleOff)));
z += Math.round(Math.sin(angle + randFloat(-pathAngleOff, pathAngleOff)));
}
if (Math.euclidDistance2D(x, z, targetX, targetZ) < pathSucsessRadius)
targetReached = true;
@@ -194,12 +194,12 @@ for (var i=0; i < numPlayers; i++)
for (var rIndex = 0; rIndex < resourcePerPlayer.length; rIndex++)
{
if (numPlayers > 1)
var angleDist = (playerAngle[(i+1)%numPlayers] - playerAngle[i] + 2*PI)%(2*PI);
var angleDist = (playerAngle[(i+1)%numPlayers] - playerAngle[i] + 2 * Math.PI) % (2 * Math.PI);
else
var angleDist = 2*PI;
var placeX = Math.round(mapCenterX + resourceRadius*cos(playerAngle[i] + (rIndex+1)*angleDist/(resourcePerPlayer.length+1)));
var placeZ = Math.round(mapCenterX + resourceRadius*sin(playerAngle[i] + (rIndex+1)*angleDist/(resourcePerPlayer.length+1)));
placeObject(placeX, placeZ, resourcePerPlayer[rIndex], 0, randFloat(0, 2*PI));
var angleDist = 2 * Math.PI;
var placeX = Math.round(mapCenterX + resourceRadius * Math.cos(playerAngle[i] + (rIndex+1)*angleDist/(resourcePerPlayer.length+1)));
var placeZ = Math.round(mapCenterX + resourceRadius * Math.sin(playerAngle[i] + (rIndex+1)*angleDist/(resourcePerPlayer.length+1)));
placeObject(placeX, placeZ, resourcePerPlayer[rIndex], 0, randFloat(0, 2 * Math.PI));
var placer = new ClumpPlacer(40, 1/2, 1/8, 1, placeX, placeZ);
var painter = [new LayeredPainter([terrainHillBorder, terrainHill], [1]), new ElevationPainter(randFloat(1, 2)), paintClass(clHill)];
createArea(placer, painter);
@@ -209,7 +209,7 @@ for (var i=0; i < numPlayers; i++)
Engine.SetProgress(60);
// Place eyecandy
placeObject(mapCenterX, mapCenterZ, templateEC, 0, randFloat(0, 2*PI));
placeObject(mapCenterX, mapCenterZ, templateEC, 0, randFloat(0, 2 * Math.PI));
var placer = new ClumpPlacer(radiusEC*radiusEC, 1/2, 1/8, 1, mapCenterX, mapCenterZ);
var painter = [new LayeredPainter([terrainHillBorder, terrainHill], [radiusEC/4]), new ElevationPainter(randFloat(1, 2)), paintClass(clHill)];
createArea(placer, painter);
@@ -245,8 +245,8 @@ for (var x = 0; x < mapSize; x++)
}
// General hight map
var hVarMiddleHill = mapSize/64 * (1+cos(3*PI/2 * radius/mapRadius));
var hVarHills = 5*(1+sin(x/10)*sin(z/10));
var hVarMiddleHill = mapSize / 64 * (1 + Math.cos(3/2 * Math.PI * radius / mapRadius));
var hVarHills = 5 * (1 + Math.sin(x / 10) * Math.sin(z / 10));
setHeight(x, z, getHeight(x, z) + hVarMiddleHill + hVarHills + 1);
}
}
@@ -16,13 +16,13 @@ addBases("stronghold", 0.37, 0.04, startAngle);
Engine.SetProgress(20);
// Change the starting angle and add the players again
var rotation = PI;
var rotation = Math.PI;
if (teamsArray.length == 2)
rotation = PI / 2;
rotation = Math.PI / 2;
if (teamsArray.length == 4)
rotation = PI + PI / 4;
rotation = 5/4 * Math.PI;
addBases("stronghold", 0.15, 0.04, startAngle + rotation);
Engine.SetProgress(40);
@@ -76,35 +76,35 @@ for (var i=0; i < numPlayers; i++)
// Create treasure
var bbAngle = BUILDING_ORIENTATION;
var bbDist = 10;
var bbX = Math.round(playerX[i] + bbDist * cos(bbAngle));
var bbZ = Math.round(playerZ[i] + bbDist * sin(bbAngle));
var bbX = Math.round(playerX[i] + bbDist * Math.cos(bbAngle));
var bbZ = Math.round(playerZ[i] + bbDist * Math.sin(bbAngle));
var group = new SimpleGroup(
[new SimpleObject(oFoodTreasure, 5,5, 0,2)],
true, clBaseResource, bbX, bbZ
);
createObjectGroup(group, 0);
bbAngle += PI/2;
var bbX = Math.round(playerX[i] + bbDist * cos(bbAngle));
var bbZ = Math.round(playerZ[i] + bbDist * sin(bbAngle));
bbAngle += Math.PI / 2;
var bbX = Math.round(playerX[i] + bbDist * Math.cos(bbAngle));
var bbZ = Math.round(playerZ[i] + bbDist * Math.sin(bbAngle));
group = new SimpleGroup(
[new SimpleObject(oWoodTreasure, 5,5, 0,2)],
true, clBaseResource, bbX, bbZ
);
createObjectGroup(group, 0);
bbAngle += PI/2;
var bbX = Math.round(playerX[i] + bbDist * cos(bbAngle));
var bbZ = Math.round(playerZ[i] + bbDist * sin(bbAngle));
bbAngle += Math.PI / 2;
var bbX = Math.round(playerX[i] + bbDist * Math.cos(bbAngle));
var bbZ = Math.round(playerZ[i] + bbDist * Math.sin(bbAngle));
group = new SimpleGroup(
[new SimpleObject(oMetalTreasure, 3,3, 0,2)],
true, clBaseResource, bbX, bbZ
);
createObjectGroup(group, 0);
bbAngle += PI/2;
var bbX = Math.round(playerX[i] + bbDist * cos(bbAngle));
var bbZ = Math.round(playerZ[i] + bbDist * sin(bbAngle));
bbAngle += Math.PI / 2;
var bbX = Math.round(playerX[i] + bbDist * Math.cos(bbAngle));
var bbZ = Math.round(playerZ[i] + bbDist * Math.sin(bbAngle));
group = new SimpleGroup(
[new SimpleObject(oStoneTreasure, 2,2, 0,2)],
true, clBaseResource, bbX, bbZ
@@ -310,7 +310,7 @@ createStragglerTrees(
setSkySet("stormy");
setSunRotation(randFloat(0, 2 * Math.PI));
setSunElevation(randFloat(PI/ 6, PI / 4));
setSunElevation(Math.PI * randFloat(1/6, 1/4));
setWaterColor(0.035,0.098,0.314);
setWaterTint(0.28, 0.3, 0.59);
@@ -384,10 +384,10 @@ function addSpines()
createArea(
new PathPlacer(
fractionToTiles(0.5 + mStartCo * cos(tang)),
fractionToTiles(0.5 + mStartCo * sin(tang)),
fractionToTiles(0.5 + mStopCo * cos(tang)),
fractionToTiles(0.5 + mStopCo * sin(tang)),
fractionToTiles(0.5 + mStartCo * Math.cos(tang)),
fractionToTiles(0.5 + mStartCo * Math.sin(tang)),
fractionToTiles(0.5 + mStopCo * Math.cos(tang)),
fractionToTiles(0.5 + mStopCo * Math.sin(tang)),
scaleByMapSize(14, mSize),
mWaviness,
0.1,
@@ -144,7 +144,7 @@ function distributeEntitiesByHeight(heightRange, avoidPoints, minDistance, entit
let checkPoint = validPoints[checkPointIndex];
if (placements.every(p => Math.euclidDistance2D(p.x, p.y, checkPoint.x, checkPoint.y) > minDistance))
{
placeObject(checkPoint.x, checkPoint.y, pickRandom(entityList), playerID, randFloat(0, 2*PI));
placeObject(checkPoint.x, checkPoint.y, pickRandom(entityList), playerID, randFloat(0, 2 * Math.PI));
placements.push(checkPoint);
}
@@ -296,7 +296,7 @@ createStragglerTrees(
log("Creating small grass tufts...");
group = new SimpleGroup(
[new SimpleObject(aGrassShort, 1,2, 0,1, -PI/8,PI/8)]
[new SimpleObject(aGrassShort, 1,2, 0,1, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsDeprecated(group, 0,
avoidClasses(clWater, 2, clHill, 2, clPlayer, 2, clDirt, 0, clSea, 1),
@@ -305,7 +305,7 @@ createObjectGroupsDeprecated(group, 0,
log("Creating large grass tufts...");
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, -Math.PI / 8, Math.PI / 8), new SimpleObject(aGrassShort, 3,6, 1.2,2.5, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsDeprecated(group, 0,
avoidClasses(clWater, 3, clHill, 2, clPlayer, 2, clDirt, 1, clForest, 0, clSea, 1),
@@ -241,7 +241,7 @@ createObjectGroupsDeprecated(
log("Creating large grass tufts...");
createObjectGroupsDeprecated(
new SimpleGroup(
[new SimpleObject(aBush, 2, 4, 0, 1.8, -PI/8, PI/8)]
[new SimpleObject(aBush, 2, 4, 0, 1.8, -Math.PI/8, Math.PI/8)]
),
0,
avoidClasses(clWater, 3, clPlayer, 2, clForest, 0),
@@ -5,8 +5,8 @@ function getPlayerTileCoordinates(playerIdx, teamIdx, fractionX, fractionZ)
{
let playerAngle = startAngle + (playerIdx+1) * 2 * Math.PI / teams[teamIdx].length;
let fx = fractionToTiles(fractionX + 0.05 * cos(playerAngle));
let fz = fractionToTiles(fractionZ + 0.05 * sin(playerAngle));
let fx = fractionToTiles(fractionX + 0.05 * Math.cos(playerAngle));
let fz = fractionToTiles(fractionZ + 0.05 * Math.sin(playerAngle));
return [playerAngle, fx, fz, Math.round(fx), Math.round(fz)];
}
@@ -92,8 +92,8 @@ for (let i = 0; i < teams.length; ++i)
++teamNo;
let teamAngle = startAngle + teamNo * 2 * Math.PI / numTeams;
let fractionX = 0.5 + 0.3 * cos(teamAngle);
let fractionZ = 0.5 + 0.3 * sin(teamAngle);
let fractionX = 0.5 + 0.3 * Math.cos(teamAngle);
let fractionZ = 0.5 + 0.3 * Math.sin(teamAngle);
let teamX = fractionToTiles(fractionX);
let teamZ = fractionToTiles(fractionZ);
@@ -120,11 +120,11 @@ for (let i = 0; i < teams.length; ++i)
for (let p = 0; p < teams[i].length; ++p)
{
let [playerAngle, fx, fz, ix, iz] = getPlayerTileCoordinates(p, i, fractionX, fractionZ);
let mAngle = randFloat(playerAngle - PI / teams[i].length, playerAngle + PI / teams[i].length);
let mAngle = randFloat(playerAngle - Math.PI / teams[i].length, playerAngle + Math.PI / teams[i].length);
// Metal
let mX = Math.round(fx + g_InitialMineDistance * cos(mAngle));
let mZ = Math.round(fz + g_InitialMineDistance * sin(mAngle));
let mX = Math.round(fx + g_InitialMineDistance * Math.cos(mAngle));
let mZ = Math.round(fz + g_InitialMineDistance * Math.sin(mAngle));
let group = new SimpleGroup(
[new SimpleObject(oMetalLarge, g_InitialMines, g_InitialMines, 0, 4)],
true, clBaseResource, mX, mZ
@@ -132,8 +132,8 @@ for (let i = 0; i < teams.length; ++i)
createObjectGroup(group, 0, [avoidClasses(clBaseResource, 2, clPlayer, 4), stayClasses(clLand, 2)]);
// Stone
let sX = Math.round(fx + g_InitialMineDistance * cos(mAngle + PI/4));
let sZ = Math.round(fz + g_InitialMineDistance * sin(mAngle + PI/4));
let sX = Math.round(fx + g_InitialMineDistance * Math.cos(mAngle + Math.PI / 4));
let sZ = Math.round(fz + g_InitialMineDistance * Math.sin(mAngle + Math.PI / 4));
group = new SimpleGroup(
[new SimpleObject(oStoneLarge, g_InitialMines, g_InitialMines, 0, 4)],
true, clBaseResource, sX, sZ
@@ -155,10 +155,10 @@ for (let i = 0; i < teams.length; ++i)
});
// create initial berry bushes
let bbAngle = randFloat(PI, PI*1.5);
let bbAngle = Math.PI * randFloat(1, 1.5);
let bbDist = 10;
let bbX = Math.round(fx + bbDist * cos(bbAngle));
let bbZ = Math.round(fz + bbDist * sin(bbAngle));
let bbX = Math.round(fx + bbDist * Math.cos(bbAngle));
let bbZ = Math.round(fz + bbDist * Math.sin(bbAngle));
let group = new SimpleGroup(
[new SimpleObject(oFruitBush, 5, 5, 0, 3)],
true, clBaseResource, bbX, bbZ
@@ -171,8 +171,8 @@ for (let i = 0; i < teams.length; ++i)
for (let x = 0; x < tries; ++x)
{
let tAngle = playerAngle + randFloat(-1, 1) * 2 * Math.PI / teams[i].length;
let tX = Math.round(fx + tDist * cos(tAngle));
let tZ = Math.round(fz + tDist * sin(tAngle));
let tX = Math.round(fx + tDist * Math.cos(tAngle));
let tZ = Math.round(fz + tDist * Math.sin(tAngle));
group = new SimpleGroup(
[new SimpleObject(oTree2, g_InitialTrees, g_InitialTrees, 0, 7)],
@@ -459,7 +459,7 @@ createObjectGroupsDeprecated(group, 0,
log("Creating small grass tufts...");
let planetm = currentBiome() == "tropic" ? 8 : 1;
group = new SimpleGroup(
[new SimpleObject(aGrassShort, 1, 2, 0, 1, -PI / 8, PI / 8)]
[new SimpleObject(aGrassShort, 1, 2, 0, 1, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsDeprecated(group, 0,
[avoidClasses(clHill, 2, clPlayer, 2, clDirt, 0), stayClasses(clLand, 3)],
@@ -470,7 +470,7 @@ Engine.SetProgress(95);
log("Creating large grass tufts...");
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, -Math.PI / 8, Math.PI / 8), new SimpleObject(aGrassShort, 3, 6, 1.2,2.5, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsDeprecated(group, 0,
[avoidClasses(clHill, 2, clPlayer, 2, clDirt, 1, clForest, 0), stayClasses(clLand, 5)],
@@ -482,7 +482,7 @@ paintTerrainBasedOnHeight(getMapBaseHeight(), 1, 3, tWater);
setSkySet(pickRandom(["cloudless", "cumulus", "overcast"]));
setSunRotation(randFloat(0, 2 * Math.PI));
setSunElevation(randFloat(PI/5, PI/3));
setSunElevation(randFloat(1/5, 1/3) * Math.PI);
setWaterWaviness(2);
Engine.SetProgress(100);
@@ -381,7 +381,7 @@ if (currentBiome() == "tropic")
log("Creating small grass tufts...");
group = new SimpleGroup(
[new SimpleObject(aGrassShort, 1,2, 0,1, -PI/8,PI/8)]
[new SimpleObject(aGrassShort, 1,2, 0,1, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsDeprecated(group, 0,
[avoidClasses(clHill, 2, clPlayer, 2, clDirt, 0), stayClasses(clLand, 6)],
@@ -392,7 +392,7 @@ Engine.SetProgress(90);
log("Creating large grass tufts...");
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, -Math.PI / 8, Math.PI / 8), new SimpleObject(aGrassShort, 3,6, 1.2,2.5, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsDeprecated(group, 0,
[avoidClasses(clHill, 2, clPlayer, 2, clDirt, 1, clForest, 0), stayClasses(clLand, 5)],
@@ -412,7 +412,7 @@ createObjectGroupsDeprecated(group, 0,
setSkySet(pickRandom(["cirrus", "cumulus", "sunny"]));
setSunRotation(randFloat(0, 2 * Math.PI));
setSunElevation(randFloat(PI/ 5, PI / 3));
setSunElevation(randFloat(1/5, 1/3) * Math.PI);
setWaterWaviness(2);
ExportMap();
@@ -229,7 +229,7 @@ createObjectGroupsDeprecated(
log("Creating small grass tufts...");
group = new SimpleGroup(
[new SimpleObject(aBush1, 1,2, 0,1, -PI/8,PI/8)]
[new SimpleObject(aBush1, 1,2, 0,1, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsDeprecated(group, 0,
avoidClasses(clWater, 2, clHill, 2, clPlayer, 2, clDirt, 0),
@@ -240,7 +240,7 @@ Engine.SetProgress(90);
log("Creating large grass tufts...");
group = new SimpleGroup(
[new SimpleObject(aBush2, 2,4, 0,1.8, -PI/8,PI/8), new SimpleObject(aBush1, 3,6, 1.2,2.5, -PI/8,PI/8)]
[new SimpleObject(aBush2, 2,4, 0,1.8, -Math.PI / 8, Math.PI / 8), new SimpleObject(aBush1, 3,6, 1.2,2.5, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsDeprecated(group, 0,
avoidClasses(clWater, 3, clHill, 2, clPlayer, 2, clDirt, 1, clForest, 0),
@@ -309,7 +309,7 @@ createObjectGroupsDeprecated(group, 0,
);
setSunColor(0.6, 0.6, 0.6);
setSunElevation(PI/ 3);
setSunElevation(Math.PI / 3);
setWaterColor(0.524,0.734,0.839);
setWaterTint(0.369,0.765,0.745);
@@ -291,14 +291,14 @@ for (var ix = 0; ix < mapSize; ix++)
{
t = (diffH > 1.2) ? tGrassCliff : tGrassDry;
if (diffH < 0.5 && randBool(0.02))
placeObject(randFloat(ix, ix + 1), randFloat(iz, iz + 1), aGrassDry, 0, randFloat(0, 2 * PI));
placeObject(randFloat(ix, ix + 1), randFloat(iz, iz + 1), aGrassDry, 0, randFloat(0, 2 * Math.PI));
}
else if (grassNoise > 0.61)
{
t = (diffH > 1.2 ? tGrassRock : tGrassShrubs);
}
else if (diffH < 0.5 && randBool(0.02))
placeObject(randFloat(ix, ix + 1), randFloat(iz, iz + 1), aGrass, 0, randFloat(0, 2 * PI));
placeObject(randFloat(ix, ix + 1), randFloat(iz, iz + 1), aGrass, 0, randFloat(0, 2 * Math.PI));
}
placeTerrain(ix, iz, t);
@@ -264,7 +264,7 @@ createStragglerTrees(
log("Creating small grass tufts...");
group = new SimpleGroup(
[new SimpleObject(aGrassShort, 1,2, 0,1, -PI/8,PI/8)]
[new SimpleObject(aGrassShort, 1,2, 0,1, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsDeprecated(group, 0,
avoidClasses(clWater, 2, clHill, 2, clPlayer, 2, clDirt, 0),
@@ -273,7 +273,7 @@ createObjectGroupsDeprecated(group, 0,
log("Creating large grass tufts...");
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, -Math.PI / 8, Math.PI / 8), new SimpleObject(aGrassShort, 3,6, 1.2,2.5, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsDeprecated(group, 0,
avoidClasses(clWater, 3, clHill, 2, clPlayer, 2, clDirt, 1, clForest, 0),
@@ -329,7 +329,7 @@ var planetm = currentBiome() == "tropic" ? 8 : 1;
log("Creating small grass tufts...");
group = new SimpleGroup(
[new SimpleObject(aGrassShort, 1,2, 0,1, -PI/8,PI/8)]
[new SimpleObject(aGrassShort, 1,2, 0,1, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsDeprecated(group, 0,
[avoidClasses(clHill, 2, clPlayer, 2, clDirt, 0), stayClasses(clLand, 6)],
@@ -339,7 +339,7 @@ Engine.SetProgress(90);
log("Creating large grass tufts...");
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, -Math.PI / 8, Math.PI / 8), new SimpleObject(aGrassShort, 3,6, 1.2,2.5, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsDeprecated(group, 0,
[avoidClasses(clHill, 2, clPlayer, 2, clDirt, 1, clForest, 0), stayClasses(clLand, 6)],
@@ -359,7 +359,7 @@ Engine.SetProgress(98);
setSkySet(pickRandom(["cirrus", "cumulus", "sunny"]));
setSunRotation(randFloat(0, 2 * Math.PI));
setSunElevation(randFloat(PI/ 5, PI / 3));
setSunElevation(randFloat(1/5, 1/3) * Math.PI);
setWaterWaviness(2);
ExportMap();
@@ -133,7 +133,7 @@ createArea(
Engine.SetProgress(30);
log("Creating oasis wildlife...");
var num = Math.round(PI * oRadius / 8);
var num = Math.round(Math.PI * oRadius / 8);
var constraint = new AndConstraint([borderClasses(clForest, 0, 3), avoidClasses(clForest, 0)]);
var halfSize = mapSize/2;
for (var i = 0; i < num; ++i)
@@ -142,8 +142,8 @@ for (var i = 0; i < num; ++i)
var angle = 2 * Math.PI / num * i;
do {
// Work outward until constraint met
var gx = Math.round(halfSize + r * cos(angle));
var gz = Math.round(halfSize + r * sin(angle));
var gx = Math.round(halfSize + r * Math.cos(angle));
var gz = Math.round(halfSize + r * Math.sin(angle));
++r;
} while (!constraint.allows(gx,gz) && r < halfSize);
@@ -161,15 +161,15 @@ for (var i = 0; i < num; ++i)
}
constraint = new AndConstraint([borderClasses(clForest, 15, 0), avoidClasses(clFood, 5)]);
num = Math.round(PI * oRadius / 16);
num = Math.round(Math.PI * oRadius / 16);
for (var i = 0; i < num; ++i)
{
var r = 0;
var angle = 2 * Math.PI / num * i;
do {
// Work outward until constraint met
var gx = Math.round(halfSize + r * cos(angle));
var gz = Math.round(halfSize + r * sin(angle));
var gx = Math.round(halfSize + r * Math.cos(angle));
var gz = Math.round(halfSize + r * Math.sin(angle));
++r;
} while (!constraint.allows(gx,gz) && r < halfSize);
@@ -265,7 +265,7 @@ createObjectGroupsDeprecated(group, 0,
);
setSunColor(0.6, 0.6, 0.6);
setSunElevation(PI/ 6);
setSunElevation(Math.PI/ 6);
setWaterColor(0.02, 0.17, 0.52);
setWaterTint(0.494, 0.682, 0.808);
+11 -11
View File
@@ -79,9 +79,9 @@ for (let i = 0; i < numPlayers; ++i)
// Creating the water patch explaining the forest
do {
var watAngle = forestAngle + randFloat((PI/3), (5*PI/3));
var watX = Math.round(forestX + 6 * cos(watAngle));
var watY = Math.round(forestY + 6 * sin(watAngle));
var watAngle = forestAngle + randFloat(1/3, 5/3) * Math.PI;
var watX = Math.round(forestX + 6 * Math.cos(watAngle));
var watY = Math.round(forestY + 6 * Math.sin(watAngle));
createObjectGroup(
new SimpleGroup(
@@ -134,7 +134,7 @@ placePlayerBases({
{ "template": eStoneMine },
],
"distance": defaultPlayerBaseRadius(),
"maxAngle": PI / 2,
"maxAngle": Math.PI * / 2,
"groupElements": shuffleArray([aBushA, aBushB, ePalmShort, ePalmTall]).map(t => new SimpleObject(t, 1, 1, 3, 4))
}
// Starting trees were set above
@@ -183,10 +183,10 @@ if (mapSize > 150 && randBool())
{
log("Creating path though the oasis...");
var pAngle = randFloat(0, 2 * Math.PI);
var px = Math.round(fx) + Math.round(fractionToTiles(0.13 * cos(pAngle)));
var py = Math.round(fz) + Math.round(fractionToTiles(0.13 * sin(pAngle)));
var pex = Math.round(fx) + Math.round(fractionToTiles(0.13 * -cos(pAngle)));
var pey = Math.round(fz) + Math.round(fractionToTiles(0.13 * sin(pAngle + PI)));
var px = Math.round(fx) + Math.round(fractionToTiles(0.13 * Math.cos(pAngle)));
var py = Math.round(fz) + Math.round(fractionToTiles(0.13 * Math.sin(pAngle)));
var pex = Math.round(fx) + Math.round(fractionToTiles(0.13 * -Math.cos(pAngle)));
var pey = Math.round(fz) + Math.round(fractionToTiles(0.13 * Math.sin(pAngle + Math.PI)));
createArea(
new PathPlacer(px, py, pex, pey, scaleByMapSize(7, 18), 0.4, 1, 0.2, 0),
[
@@ -250,8 +250,8 @@ for (var p = 0; p < scaleByMapSize(5,30); p++)
{
var aAngle = randFloat(0, 2 * Math.PI);
var aDist = fractionToTiles(0.11);
var animX = Math.round(fx + aDist * cos(aAngle));
var animY = Math.round(fz + aDist * sin(aAngle));
var animX = Math.round(fx + aDist * Math.cos(aAngle));
var animY = Math.round(fz + aDist * Math.sin(aAngle));
group = new RandomGroup(
[new SimpleObject(eLion, 1,2, 0,4),new SimpleObject(eLioness, 1,2, 2,4),new SimpleObject(eGazelle, 4,6, 1,5),new SimpleObject(eCamel, 1,2, 1,5)], true, clFood, animX,animY);
createObjectGroup(group, 0);
@@ -308,7 +308,7 @@ for (var sandx = 0; sandx < mapSize; sandx += 4)
setSkySet("sunny");
setSunColor(0.914,0.827,0.639);
setSunRotation(PI/3);
setSunRotation(Math.PI/3);
setSunElevation(0.5);
setWaterColor(0, 0.227, 0.843);
setWaterTint(0, 0.545, 0.859);
@@ -310,7 +310,7 @@ createStragglerTrees(
stragglerTrees);
setSunColor(1.0, 0.796, 0.374);
setSunElevation(PI / 6);
setSunElevation(Math.PI / 6);
setSunRotation(-1.86532);
setFogFactor(0.2);
@@ -267,12 +267,12 @@ if (randBool(1/3))
setSunColor(0.8, 0.7, 0.6);
setTerrainAmbientColor(0.7, 0.6, 0.7);
setUnitsAmbientColor(0.6, 0.5, 0.6);
setSunElevation(randFloat(PI/24, PI/7));
setSunElevation(Math.PI * randFloat(1/24, 1/7));
}
else
{
setSkySet(pickRandom(["cumulus", "rain", "mountainous", "overcast", "rain", "stratus"]));
setSunElevation(randFloat(PI/9, PI/7));
setSunElevation(Math.PI * randFloat(1/9, 1/7));
}
setSunRotation(randFloat(0, 2 * Math.PI));
@@ -97,8 +97,9 @@ for (var ix = 0; ix < mapSize; ix++)
if (g_Map.inMapBounds(ix,iz))
{
placeTerrain(ix, iz, tGrass);
setHeight(ix,iz,baseHeight +randFloat(-1,1) + scaleByMapSize(1,3)*(cos(ix/scaleByMapSize(5,30))+sin(iz/scaleByMapSize(5,30))));
baseHeights[ix].push( baseHeight +randFloat(-1,1) + scaleByMapSize(1,3)*(cos(ix/scaleByMapSize(5,30))+sin(iz/scaleByMapSize(5,30))) );
let height = baseHeight + randFloat(-1, 1) + scaleByMapSize(1, 3) * (Math.cos(ix / scaleByMapSize(5, 30)) + Math.sin(iz / scaleByMapSize(5, 30)));
setHeight(ix, iz, height);
baseHeights[ix].push(height);
}
else
baseHeights[ix].push(-100);
@@ -164,10 +165,10 @@ for (var i = 0; i < NumOfIterations; i++)
for (var dist = 0; dist < width*3; dist++)
{
var okDist = dist/3;
var S1x = Math.round((mountainStart.x * (1-position) + mountainEnd.x*position) + randomNess*cos(position*3.14*4) + cos(MoutainAngle+PI/2)*okDist);
var S1z = Math.round((mountainStart.y * (1-position) + mountainEnd.y*position) + randomNess*sin(position*3.14*4) + sin(MoutainAngle+PI/2)*okDist);
var S2x = Math.round((mountainStart.x * (1-position) + mountainEnd.x*position) + randomNess*cos(position*3.14*4) + cos(MoutainAngle-PI/2)*okDist);
var S2z = Math.round((mountainStart.y * (1-position) + mountainEnd.y*position) + randomNess*sin(position*3.14*4) + sin(MoutainAngle-PI/2)*okDist);
var S1x = Math.round((mountainStart.x * (1 - position) + mountainEnd.x * position) + randomNess * Math.cos(position * Math.PI * 4) + Math.cos(MoutainAngle + Math.PI / 2) * okDist);
var S1z = Math.round((mountainStart.y * (1 - position) + mountainEnd.y * position) + randomNess * Math.sin(position * Math.PI * 4) + Math.sin(MoutainAngle + Math.PI / 2) * okDist);
var S2x = Math.round((mountainStart.x * (1 - position) + mountainEnd.x * position) + randomNess * Math.cos(position * Math.PI * 4) + Math.cos(MoutainAngle - Math.PI / 2) * okDist);
var S2z = Math.round((mountainStart.y * (1 - position) + mountainEnd.y * position) + randomNess * Math.sin(position * Math.PI * 4) + Math.sin(MoutainAngle - Math.PI / 2) * okDist);
// complicated sigmoid
// Ranges is 0-1, FormX is 0-1 too.
@@ -298,7 +299,7 @@ createAreas(
log("Creating forests...");
var types = [[tForestTransition, pForestLandVeryLight, pForestLandLight, pForestLand]];
var size = scaleByMapSize(40,115)*PI;
var size = scaleByMapSize(40, 115) * Math.PI;
var num = Math.floor(scaleByMapSize(8,40) / types.length);
for (let type of types)
createAreas(
@@ -397,12 +398,12 @@ Engine.SetProgress(70);
// making more in dirt areas so as to appear different
log("Creating small grass tufts...");
var group = new SimpleGroup( [new SimpleObject(aGrassShort, 1,2, 0,1, -PI/8,PI/8)] );
var group = new SimpleGroup( [new SimpleObject(aGrassShort, 1,2, 0,1, -Math.PI / 8, Math.PI / 8)] );
createObjectGroupsDeprecated(group, 0, avoidClasses(clWater, 2, clHill, 2, clPlayer, 5, clDirt, 0, clPyrenneans,2), scaleByMapSize(13, 200) );
createObjectGroupsDeprecated(group, 0, stayClasses(clDirt,1), scaleByMapSize(13, 200),10);
log("Creating large grass tufts...");
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)] );
group = new SimpleGroup( [new SimpleObject(aGrass, 2,4, 0,1.8, -Math.PI / 8, Math.PI / 8), new SimpleObject(aGrassShort, 3,6, 1.2,2.5, -Math.PI / 8, Math.PI / 8)] );
createObjectGroupsDeprecated(group, 0, avoidClasses(clWater, 3, clHill, 2, clPlayer, 5, clDirt, 1, clForest, 0, clPyrenneans,2), scaleByMapSize(13, 200) );
createObjectGroupsDeprecated(group, 0, stayClasses(clDirt,1), scaleByMapSize(13, 200),10);
Engine.SetProgress(75);
@@ -453,7 +454,7 @@ log("Creating fish...");
group = new SimpleGroup( [new SimpleObject(oFish, 2,3, 0,2)], true, clFood );
createObjectGroupsDeprecated(group, 0, [avoidClasses(clFood, 15), stayClasses(clWater, 6)], 20 * numPlayers, 60 );
setSunElevation(randFloat(PI/5, PI / 3));
setSunElevation(Math.PI * randFloat(1/5, 1/3));
setSunRotation(randFloat(0, 2 * Math.PI));
setSkySet("cumulus");
@@ -354,7 +354,7 @@ createObjectGroupsDeprecated(
log("Creating small grass tufts...");
createObjectGroupsDeprecated(
new SimpleGroup([new SimpleObject(aBush1, 1, 2, 0, 1, -PI/8, PI/8)]),
new SimpleGroup([new SimpleObject(aBush1, 1, 2, 0, 1, -Math.PI / 8, Math.PI / 8)]),
0,
avoidClasses(
clWater, 4,
@@ -369,8 +369,8 @@ Engine.SetProgress(70);
log("Creating large grass tufts...");
createObjectGroupsDeprecated(
new SimpleGroup([
new SimpleObject(aBush2, 2, 4, 0, 1.8, -PI/8, PI/8),
new SimpleObject(aBush1, 3, 6, 1.2, 2.5, -PI/8, PI/8)
new SimpleObject(aBush2, 2, 4, 0, 1.8, -Math.PI / 8, Math.PI / 8),
new SimpleObject(aBush1, 3, 6, 1.2, 2.5, -Math.PI / 8, Math.PI / 8)
]),
0,
avoidClasses(
@@ -464,7 +464,7 @@ createObjectGroupsDeprecated(
100);
setSunColor(0.6, 0.6, 0.6);
setSunElevation(PI/ 3);
setSunElevation(Math.PI/ 3);
setWaterColor(0.424, 0.534, 0.639);
setWaterTint(0.369, 0.765, 0.745);
@@ -23,7 +23,7 @@ function setBiome(biomeID)
setSkySet(pickRandom(["cirrus", "cumulus", "sunny"]));
setSunRotation(randFloat(0, 2 * Math.PI));
setSunElevation(randFloat(PI/ 6, PI / 3));
setSunElevation(Math.PI * randFloat(1/6, 1/3));
g_BiomeID = biomeID;
@@ -1,4 +1,3 @@
const PI = Math.PI;
const TERRAIN_SEPARATOR = "|";
const SEA_LEVEL = 20.0;
const HEIGHT_UNITS_PER_METRE = 92;
@@ -19,8 +18,11 @@ const MIN_HEIGHT = - SEA_LEVEL;
const TERRAIN_TILE_SIZE = Engine.GetTerrainTileSize();
const MAX_HEIGHT = MAX_HEIGHT_RANGE - SEA_LEVEL;
// Default angle for buildings
const BUILDING_ORIENTATION = - PI / 4;
/**
* Default angle for buildings.
*/
const BUILDING_ORIENTATION = -1/4 * Math.PI;
const g_CivData = deepfreeze(loadCivFiles(false));
@@ -49,19 +51,6 @@ function scaleByMapSize(min, max, minMapSize = 128, maxMapSize = 512)
return min + (max - min) * (g_Map.size - minMapSize) / (maxMapSize - minMapSize);
}
/**
* DEPRECATED Math proxies
*/
function cos(x)
{
return Math.cos(x);
}
function sin(x)
{
return Math.sin(x);
}
/**
* Retries the given function with those arguments as often as specified.
*/
@@ -32,7 +32,7 @@ function Noise2D(freq)
this.grads[i] = [];
for (var j=0; j < freq; ++j)
{
var a = randFloat(0, 2 * PI);
var a = randFloat(0, 2 * Math.PI);
this.grads[i][j] = new Vector2D(Math.cos(a), Math.sin(a));
}
}
@@ -37,13 +37,13 @@ ClumpPlacer.prototype.place = function(constraint)
var size = getMapSize();
var gotRet = new Array(size).fill(0).map(p => new Uint8Array(size)); // booleans
var radius = Math.sqrt(this.size / Math.PI);
var perim = 4 * radius * 2 * PI;
var perim = 4 * radius * 2 * Math.PI;
var intPerim = Math.ceil(perim);
var ctrlPts = 1 + Math.floor(1.0/Math.max(this.smoothness,1.0/intPerim));
if (ctrlPts > radius * 2 * PI)
ctrlPts = Math.floor(radius * 2 * PI) + 1;
if (ctrlPts > radius * 2 * Math.PI)
ctrlPts = Math.floor(radius * 2 * Math.PI) + 1;
var noise = new Float32Array(intPerim); //float32
var ctrlCoords = new Float32Array(ctrlPts+1); //float32
@@ -79,10 +79,10 @@ ClumpPlacer.prototype.place = function(constraint)
var failed = 0;
for (var p=0; p < intPerim; p++)
{
var th = 2 * PI * p / perim;
var th = 2 * Math.PI * p / perim;
var r = radius * (1 + (1-this.coherence)*noise[p]);
var s = sin(th);
var c = cos(th);
var s = Math.sin(th);
var c = Math.cos(th);
var xx = this.x;
var yy = this.z;
@@ -286,8 +286,8 @@ function placeLine(teamsArray, distance, groupedDistance, startAngle)
{
players[teamsArray[i][p]] = {
"id": teamsArray[i][p],
"x": 0.5 + (safeDist + p * groupedDistance) * cos(teamAngle),
"z": 0.5 + (safeDist + p * groupedDistance) * sin(teamAngle)
"x": 0.5 + (safeDist + p * groupedDistance) * Math.cos(teamAngle),
"z": 0.5 + (safeDist + p * groupedDistance) * Math.sin(teamAngle)
};
createBase(players[teamsArray[i][p]], false);
}
@@ -313,8 +313,8 @@ function placeRadial(playerIDs, distance, startAngle)
let angle = startAngle + i * 2 * Math.PI / numPlayers;
players[i] = {
"id": playerIDs[i],
"x": 0.5 + distance * cos(angle),
"z": 0.5 + distance * sin(angle)
"x": 0.5 + distance * Math.cos(angle),
"z": 0.5 + distance * Math.sin(angle)
};
createBase(players[i]);
}
@@ -338,8 +338,8 @@ function placeRandom(playerIDs)
// Distance from the center of the map in percent
// Mapsize being used as a diameter, so 0.5 is the edge of the map
var distance = randFloat(0, 0.42);
var x = 0.5 + distance * cos(playerAngle);
var z = 0.5 + distance * sin(playerAngle);
var x = 0.5 + distance * Math.cos(playerAngle);
var z = 0.5 + distance * Math.sin(playerAngle);
// Minimum distance between initial bases must be a quarter of the map diameter
if (locations.some(loc => Math.euclidDistance2D(x, z, loc.x, loc.z) < 0.25))
@@ -447,8 +447,8 @@ function placeStronghold(teamsArray, distance, groupedDistance, startAngle)
for (let i = 0; i < teamsArray.length; ++i)
{
var teamAngle = startAngle + (i + 1) * 2 * Math.PI / teamsArray.length;
var fractionX = 0.5 + distance * cos(teamAngle);
var fractionZ = 0.5 + distance * sin(teamAngle);
var fractionX = 0.5 + distance * Math.cos(teamAngle);
var fractionZ = 0.5 + distance * Math.sin(teamAngle);
var teamGroupDistance = groupedDistance;
// If we have a team of above average size, make sure they're spread out
@@ -467,8 +467,8 @@ function placeStronghold(teamsArray, distance, groupedDistance, startAngle)
var angle = startAngle + (p + 1) * 2 * Math.PI / teamsArray[i].length;
players[teamsArray[i][p]] = {
"id": teamsArray[i][p],
"x": fractionX + teamGroupDistance * cos(angle),
"z": fractionZ + teamGroupDistance * sin(angle)
"x": fractionX + teamGroupDistance * Math.cos(angle),
"z": fractionZ + teamGroupDistance * Math.sin(angle)
};
createBase(players[teamsArray[i][p]], false);
}
@@ -519,8 +519,8 @@ function randomPlayerPlacementAt(teamsArray, singleBases, strongholdBases, heigh
players[p] = {
"id": team[p].id,
"x": x + groupedDistance * cos(angle),
"z": z + groupedDistance * sin(angle)
"x": x + groupedDistance * Math.cos(angle),
"z": z + groupedDistance * Math.sin(angle)
};
createBase(players[p], false);
@@ -212,7 +212,7 @@ createStragglerTrees(
log("Creating large grass tufts...");
group = new SimpleGroup(
[new SimpleObject(aBush, 2,4, 0,1.8, -PI/8,PI/8)]
[new SimpleObject(aBush, 2,4, 0,1.8, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsDeprecated(group, 0,
avoidClasses(clWater, 3, clPlayer, 2, clForest, 0),
@@ -343,7 +343,7 @@ createStragglerTrees(
var planetm = 4;
log("Creating small grass tufts...");
group = new SimpleGroup(
[new SimpleObject(aGrassShort, 1,2, 0,1, -PI/8,PI/8)]
[new SimpleObject(aGrassShort, 1,2, 0,1, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsDeprecated(group, 0,
avoidClasses(clWater, 2, clHill, 2, clPlayer, 2),
@@ -354,7 +354,7 @@ Engine.SetProgress(90);
log("Creating large grass tufts...");
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, -Math.PI / 8, Math.PI / 8), new SimpleObject(aGrassShort, 3,6, 1.2,2.5, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsDeprecated(group, 0,
avoidClasses(clWater, 3, clHill, 2, clPlayer, 2, clForest, 0),
@@ -375,7 +375,7 @@ createObjectGroupsDeprecated(group, 0,
setSkySet("sunny");
setSunRotation(randFloat(0, 2 * Math.PI));
setSunElevation(randFloat(PI/ 5, PI / 4));
setSunElevation(Math.PI * randFloat(1/5, 1/4));
setWaterColor(0.478,0.42,0.384); // greyish
setWaterTint(0.58,0.22,0.067); // reddish
setWaterMurkiness(0.87);
@@ -92,12 +92,12 @@ var maxPlayerRadius = Math.min(mapRadius - baseRadius, 3/4 * mapRadius);
var playerStartLocX = [];
var playerStartLocZ = [];
var playerAngleStart = randFloat(0, 2*PI);
var playerAngleAddAvrg = 2*PI / numPlayers;
var playerAngleStart = randFloat(0, 2 * Math.PI);
var playerAngleAddAvrg = 2 * Math.PI / numPlayers;
var playerAngleMaxOff = playerAngleAddAvrg/4;
var pathSucsessRadius = baseRadius/2;
var pathAngleOff = PI/2;
var pathAngleOff = Math.PI/2;
var pathWidth = 10; // This is not really the path's thickness in tiles but the number of tiles in the clumbs of the path
var resourceRadius = 2/3 * mapRadius;
@@ -278,8 +278,8 @@ for (var i = 0; i < maxI; i++)
// Prepare path placement
var angle = getAngle(x, z, targetX, targetZ);
x += Math.round(pathSucsessRadius*cos(angle));
z += Math.round(pathSucsessRadius*sin(angle));
x += Math.round(pathSucsessRadius * Math.cos(angle));
z += Math.round(pathSucsessRadius * Math.sin(angle));
var targetReached = false;
var tries = 0;
@@ -296,13 +296,13 @@ for (var i = 0; i < maxI; i++)
angle = getAngle(x, z, targetX, targetZ);
if (doublePaths === true) // Bended paths
{
x += Math.round(cos(angle + randFloat(-pathAngleOff/2, 3*pathAngleOff/2)));
z += Math.round(sin(angle + randFloat(-pathAngleOff/2, 3*pathAngleOff/2)));
x += Math.round(Math.cos(angle + randFloat(-pathAngleOff/2, 3*pathAngleOff/2)));
z += Math.round(Math.sin(angle + randFloat(-pathAngleOff/2, 3*pathAngleOff/2)));
}
else // Straight paths
{
x += Math.round(cos(angle + randFloat(-pathAngleOff, pathAngleOff)));
z += Math.round(sin(angle + randFloat(-pathAngleOff, pathAngleOff)));
x += Math.round(Math.cos(angle + randFloat(-pathAngleOff, pathAngleOff)));
z += Math.round(Math.sin(angle + randFloat(-pathAngleOff, pathAngleOff)));
}
if (Math.euclidDistance2D(x, z, targetX, targetZ) < pathSucsessRadius)
@@ -399,7 +399,7 @@ if (currentBiome() == "tropic")
log("Creating small grass tufts...");
group = new SimpleGroup(
[new SimpleObject(aGrassShort, 1,2, 0,1, -PI/8,PI/8)]
[new SimpleObject(aGrassShort, 1,2, 0,1, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsDeprecated(group, 0,
[avoidClasses(clHill, 2, clPlayer, 2, clDirt, 0), stayClasses(clLand, 4)],
@@ -410,7 +410,7 @@ Engine.SetProgress(90);
log("Creating large grass tufts...");
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, -Math.PI / 8, Math.PI / 8), new SimpleObject(aGrassShort, 3,6, 1.2,2.5, -Math.PI / 8, Math.PI / 8)]
);
createObjectGroupsDeprecated(group, 0,
[avoidClasses(clHill, 2, clPlayer, 2, clDirt, 1, clForest, 0), stayClasses(clLand, 4)],
@@ -429,6 +429,6 @@ createObjectGroupsDeprecated(group, 0,
setSkySet(pickRandom(["cirrus", "cumulus", "sunny"]));
setSunRotation(randFloat(0, 2 * Math.PI));
setSunElevation(randFloat(PI/ 5, PI / 3));
setSunElevation(Math.PI * randFloat(1/5, 1/3));
ExportMap();
@@ -247,7 +247,7 @@ createStragglerTrees(
stragglerTrees);
setSkySet("sunny");
setSunElevation(PI / 8);
setSunElevation(Math.PI / 8);
setSunRotation(randFloat(0, 2 * Math.PI));
setSunColor(0.746, 0.718, 0.539);
setWaterColor(0.292, 0.347, 0.691);
@@ -84,11 +84,11 @@ for (var i = 0; i < numPlayers; ++i)
continue;
var count = civEntities[j].Count || 1;
var jx = ix + 2 * cos(angle);
var jz = iz + 2 * sin(angle);
var jx = ix + 2 * Math.cos(angle);
var jz = iz + 2 * Math.sin(angle);
var kAngle = randFloat(0, 2 * Math.PI);
for (var k = 0; k < count; ++k)
placeObject(jx + cos(kAngle + k*2 * Math.PI/count), jz + sin(kAngle + k*2 * Math.PI/count), civEntities[j].Template, id, randFloat(0, 2 * Math.PI));
placeObject(jx + Math.cos(kAngle + k*2 * Math.PI/count), jz + Math.sin(kAngle + k*2 * Math.PI/count), civEntities[j].Template, id, randFloat(0, 2 * Math.PI));
angle += 2 * Math.PI / 3;
}
@@ -100,18 +100,18 @@ for (var i = 0; i < numPlayers; ++i)
{
var angle = randFloat(0, 2 * Math.PI);
var rad = randFloat(3, 5);
var jx = ix + rad * cos(angle);
var jz = iz + rad * sin(angle);
var jx = ix + rad * Math.cos(angle);
var jz = iz + rad * Math.sin(angle);
placeObject(jx, jz, "gaia/special_treasure_wood", 0, randFloat(0, 2 * Math.PI));
var angle = randFloat(0, 2 * Math.PI);
var rad = randFloat(3, 5);
var jx = ix + rad * cos(angle);
var jz = iz + rad * sin(angle);
var jx = ix + rad * Math.cos(angle);
var jz = iz + rad * Math.sin(angle);
placeObject(jx, jz, "gaia/special_treasure_stone", 0, randFloat(0, 2 * Math.PI));
var angle = randFloat(0, 2 * Math.PI);
var rad = randFloat(3, 5);
var jx = ix + rad * cos(angle);
var jz = iz + rad * sin(angle);
var jx = ix + rad * Math.cos(angle);
var jz = iz + rad * Math.sin(angle);
placeObject(jx, jz, "gaia/special_treasure_metal", 0, randFloat(0, 2 * Math.PI));
}
}
@@ -221,7 +221,7 @@ function placeMine(point, centerEntity,
{
let angle = dAngle * randFloat(i, i + 1);
let dist = randFloat(2, 5);
placeObject(point.x + dist * Math.cos(angle), point.y + dist * Math.sin(angle), pickRandom(decorativeActors), 0, randFloat(0, 2 * PI));
placeObject(point.x + dist * Math.cos(angle), point.y + dist * Math.sin(angle), pickRandom(decorativeActors), 0, randFloat(0, 2 * Math.PI));
}
}
@@ -240,7 +240,7 @@ function placeGrove(point,
groveTerrainTexture = getArray(g_Terrains.forestFloor1)
)
{
placeObject(point.x, point.y, pickRandom(["structures/gaul_outpost", "gaia/flora_tree_oak_new"]), 0, randFloat(0, 2 * PI));
placeObject(point.x, point.y, pickRandom(["structures/gaul_outpost", "gaia/flora_tree_oak_new"]), 0, randFloat(0, 2 * Math.PI));
let quantity = randIntInclusive(20, 30);
let dAngle = 2 * Math.PI / quantity;
for (let i = 0; i < quantity; ++i)
@@ -252,7 +252,7 @@ function placeGrove(point,
objectList = groveActors;
let x = point.x + dist * Math.cos(angle);
let y = point.y + dist * Math.sin(angle);
placeObject(x, y, pickRandom(objectList), 0, randFloat(0, 2 * PI));
placeObject(x, y, pickRandom(objectList), 0, randFloat(0, 2 * Math.PI));
if (groveTileClass)
createArea(new ClumpPlacer(5, 1, 1, 1, Math.floor(x), Math.floor(y)), [new TerrainPainter(groveTerrainTexture), paintClass(groveTileClass)]);
else
@@ -333,7 +333,7 @@ function placeCamp(point,
{
let angle = dAngle * randFloat(i, i + 1);
let dist = randFloat(1, 3);
placeObject(point.x + dist * Math.cos(angle), point.y + dist * Math.sin(angle), pickRandom(otherEntities), 0, randFloat(0, 2 * PI));
placeObject(point.x + dist * Math.cos(angle), point.y + dist * Math.sin(angle), pickRandom(otherEntities), 0, randFloat(0, 2 * Math.PI));
}
}
@@ -376,7 +376,7 @@ function placeStartLocationResources(
objectList = groveActors;
let x = point.x + dist * Math.cos(angle);
let y = point.y + dist * Math.sin(angle);
placeObject(x, y, pickRandom(objectList), 0, randFloat(0, 2 * PI));
placeObject(x, y, pickRandom(objectList), 0, randFloat(0, 2 * Math.PI));
createArea(new ClumpPlacer(5, 1, 1, 1, Math.floor(x), Math.floor(y)), [new TerrainPainter(groveTerrainTexture), paintClass(clGrove)]);
currentAngle += dAngle;
}
@@ -394,7 +394,7 @@ function placeStartLocationResources(
{
angle = currentAngle + randFloat(0, dAngle);
let dist = getRandDist();
placeObject(point.x + dist * Math.cos(angle), point.y + dist * Math.sin(angle), pickRandom(foodEntities), 0, randFloat(0, 2 * PI));
placeObject(point.x + dist * Math.cos(angle), point.y + dist * Math.sin(angle), pickRandom(foodEntities), 0, randFloat(0, 2 * Math.PI));
currentAngle += dAngle;
}
}
@@ -586,7 +586,7 @@ for (let h = 0; h < heighLimits.length; ++h)
g_Map.texture[x][y] = g_Map.getTextureID(texture);
if (actor)
placeObject(randFloat(x, x + 1), randFloat(y, y + 1), actor, 0, randFloat(0, 2 * PI));
placeObject(randFloat(x, x + 1), randFloat(y, y + 1), actor, 0, randFloat(0, 2 * Math.PI));
}
}
@@ -640,7 +640,7 @@ for (let i = 0; i < resourceSpots.length; ++i)
}
else
{
placeCustomFortress(resourceSpots[i].x, resourceSpots[i].y, pickRandom(fences), "other", 0, randFloat(0, 2 * PI));
placeCustomFortress(resourceSpots[i].x, resourceSpots[i].y, pickRandom(fences), "other", 0, randFloat(0, 2 * Math.PI));
rectangularSmoothToHeight(resourceSpots[i], 10, 10, g_Map.height[resourceSpots[i].x][resourceSpots[i].y], 0.5);
}
}