Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/maps/random/heightmap/heightmap.js
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | function getStartLocationsByHeightmap(heightRange, maxTries = 1000, minDistToBorder = 20, numberOfPlayers = g_MapSettings.PlayerData.length - 1, heightmap = g_Map.height, isCircular = g_MapSettings.CircularMap) | ||||
let maxMinDist = 0; | let maxMinDist = 0; | ||||
let finalStartLoc; | let finalStartLoc; | ||||
for (let tries = 0; tries < maxTries; ++tries) | for (let tries = 0; tries < maxTries; ++tries) | ||||
{ | { | ||||
let startLoc = []; | let startLoc = []; | ||||
let minDist = Infinity; | let minDist = Infinity; | ||||
for (let p = 0; p < numberOfPlayers; ++p) | for (let p = 0; p < numberOfPlayers; ++p) | ||||
startLoc.push(validStartLoc[randInt(validStartLoc.length)]); | startLoc.push(pickRandom(validStartLoc)); | ||||
elexis: ✓ | |||||
for (let p1 = 0; p1 < numberOfPlayers - 1; ++p1) | for (let p1 = 0; p1 < numberOfPlayers - 1; ++p1) | ||||
{ | { | ||||
for (let p2 = p1 + 1; p2 < numberOfPlayers; ++p2) | for (let p2 = p1 + 1; p2 < numberOfPlayers; ++p2) | ||||
{ | { | ||||
let dist = getDistance(startLoc[p1].x, startLoc[p1].y, startLoc[p2].x, startLoc[p2].y); | let dist = getDistance(startLoc[p1].x, startLoc[p1].y, startLoc[p2].x, startLoc[p2].y); | ||||
if (dist < minDist) | if (dist < minDist) | ||||
minDist = dist; | minDist = dist; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 250 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
✓