1
0
forked from 0ad/0ad

Three new random map scripts by _kali showing actual geographical regions: Amazon, Mediterranean and Red Sea.

Includes a water and skyset fix by niektb. Partially reviewed by FeXoR.
Like last time, commits can be found at
https://github.com/0ADMods/maps_random_by_kali

This was SVN commit r18523.
This commit is contained in:
elexis 2016-07-15 19:39:42 +00:00
parent a83f2a376b
commit 33e3e6c2ab
11 changed files with 1243 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,11 @@
{
"settings" : {
"Name" : "Amazon",
"Script" : "amazon.js",
"Description" : "The Amazon River in South America is the largest river by discharge of water in the world, and the longest in length. The Amazon basin is the largest drainage basin in the world, with an area of approximately 7,050,000 square kilometers, and accounts for roughly one-fifth of the world's total river flow.",
"BaseTerrain" : ["medit_sea_depths"],
"BaseHeight" : 1,
"Preview" : "amazon.png",
"CircularMap" : false
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,11 @@
{
"settings" : {
"Name" : "Mediterranean",
"Script" : "mediterranean.js",
"Description" : "The Mediterranean Sea is a sea connected to the Atlantic Ocean surrounded by the Mediterranean Basin and almost completely enclosed by land: on the north by Southern Europe and Anatolia, on the south by North Africa, and on the east by the Levant. The name Mediterranean is derived from the Latin mediterraneus, meaning 'inland' or 'in the middle of land'.",
"BaseTerrain" : ["medit_sea_depths"],
"BaseHeight" : 1,
"Preview" : "mediterranean.png",
"CircularMap" : false
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,11 @@
{
"settings" : {
"Name" : "Red Sea",
"Script" : "red_sea.js",
"Description" : "The Red Sea is a seawater inlet of the Indian Ocean, lying between Africa and Asia and the world's northernmost tropical sea.",
"BaseTerrain" : ["medit_sea_depths"],
"BaseHeight" : 1,
"Preview" : "red_sea.png",
"CircularMap" : false
}
}

View File

@ -872,6 +872,19 @@ function addMetal(constraint, size, deviation, fill)
}
}
function addSmallMetal(constraint, size, mixes, amounts)
{
let deviation = getRandomDeviation(size || 1, mixes || g_DefaultDeviation);
let count = 1 + scaleByMapSize(20, 20) * (amounts || 1);
let mines = [[new SimpleObject(g_Gaia.metalSmall, 2 * deviation, 5 * deviation, 1 * deviation, 3 * deviation)]];
for (let i = 0; i < mines.length; ++i)
{
let group = new SimpleGroup(mines[i], true, g_TileClasses.metal);
createObjectGroups(group, 0, constraint, count, 100);
}
}
/**
* Create stone mines.
*/
@ -1253,3 +1266,52 @@ function getRandomDeviation(base, deviation)
deviation = base + randInt(20 * deviation) / 10 - deviation;
return deviation.toFixed(2);
}
/**
* Import a given digital elevation model.
* Scale it to the mapsize and paint the textures specified by coordinate on it.
*
* @param heightmap - An array with a square number of heights
* @param tilemap - The IDs of the palletmap to be painted for each heightmap tile
* @param pallet - The tile texture names used by the tilemap.
* @returns the ratio of heightmap tiles per map size tiles
*/
function paintHeightmap(heightmap, tilemap, pallet, func = undefined)
{
let lastI = -1;
let mapSize = getMapSize();
let hmSize = Math.sqrt(heightmap.length);
let scale = hmSize / mapSize;
for (let y = 0; y < mapSize; ++y)
for (let x = 0; x < mapSize; ++x)
{
let i = Math.floor(x * scale) * hmSize + Math.floor(y * scale);
let height = heightmap[i];
let tile = pallet[tilemap[i]];
if (i == lastI)
{
let nearby = [i];
if (i + hmSize < heightmap.length)
nearby.push(i + hmSize);
tile = pallet[tilemap[nearby[randInt(0, nearby.length - 1)]]];
// Average
height = nearby.reduce((sum, value) => sum + value) / nearby.length;
}
setHeight(x, y, height);
placeTerrain(x, y, tile);
if (func)
func(tile, x, y);
lastI = i;
}
return Math.sqrt(heightmap.length) / g_MapInfo.mapSize;
}

View File

@ -524,6 +524,63 @@ function placeStronghold(playerIDs, distance, groupedDistance)
return players;
}
/**
* Places players either randomly or in a stronghold-pattern at a set of given heightmap coordinates.
*
* @param singleBases - pair of coordinates of the heightmap to place isolated bases.
* @param singleBases - pair of coordinates of the heightmap to place team bases.
* @param groupedDistance - distance between neighboring players.
* @param singleBaseFunction - A function called for every singlebase placed.
*/
function randomPlayerPlacementAt(singleBases, strongholdBases, heightmapScale, groupedDistance, singleBaseFunction)
{
let strongholdBasesRandom = shuffleArray(strongholdBases);
let singleBasesRandom = shuffleArray(singleBases);
if (randInt(2) == 1 &&
g_MapInfo.mapSize >= 256 &&
g_MapInfo.teams.length >= 2 &&
g_MapInfo.teams.length < g_MapInfo.numPlayers &&
g_MapInfo.teams.length <= strongholdBasesRandom.length)
{
for (let t = 0; t < g_MapInfo.teams.length; ++t)
{
let team = g_MapInfo.teams[t].map(playerID => ({ "id": playerID }));
let x = Math.floor(strongholdBasesRandom[t][0] / heightmapScale) / g_MapInfo.mapSize;
let z = Math.floor(strongholdBasesRandom[t][1] / heightmapScale) / g_MapInfo.mapSize;
let players = [];
for (let p = 0; p < team.length; ++p)
{
let angle = g_MapInfo.startAngle + (p + 1) * TWO_PI / team.length;
players[p] = {
"id": team[p].id,
"angle": angle,
"x": x + groupedDistance * cos(angle),
"z": z + groupedDistance * sin(angle)
};
createBase(players[p], false);
}
}
}
else
{
let players = randomizePlayers();
for (let p = 0; p < players.length; ++p)
{
if (singleBaseFunction)
singleBaseFunction(singleBasesRandom[p]);
createBase({
"id": players[p],
"x": Math.floor(singleBasesRandom[p][0] / heightmapScale) / g_MapInfo.mapSize,
"z": Math.floor(singleBasesRandom[p][1] / heightmapScale) / g_MapInfo.mapSize
});
}
}
}
/**
* Creates tileClass for the default classes and every class given.
*