Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/maps/random/rmgen2/setup.js
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | for (let element of elements) | ||||
); | ); | ||||
} | } | ||||
/** | /** | ||||
* Converts "amount" terms to numbers. | * Converts "amount" terms to numbers. | ||||
*/ | */ | ||||
function pickAmount(amounts) | function pickAmount(amounts) | ||||
{ | { | ||||
var amount = amounts[randInt(amounts.length)]; | let amount = pickRandom(amounts); | ||||
if (amount in g_Amounts) | if (amount in g_Amounts) | ||||
return g_Amounts[amount]; | return g_Amounts[amount]; | ||||
return g_Amounts.normal; | return g_Amounts.normal; | ||||
} | } | ||||
/** | /** | ||||
* Converts "mix" terms to numbers. | * Converts "mix" terms to numbers. | ||||
*/ | */ | ||||
function pickMix(mixes) | function pickMix(mixes) | ||||
{ | { | ||||
var mix = mixes[randInt(mixes.length)]; | let mix = pickRandom(mixes); | ||||
if (mix in g_Mixes) | if (mix in g_Mixes) | ||||
return g_Mixes[mix]; | return g_Mixes[mix]; | ||||
return g_Mixes.normal; | return g_Mixes.normal; | ||||
} | } | ||||
/** | /** | ||||
* Converts "size" terms to numbers. | * Converts "size" terms to numbers. | ||||
*/ | */ | ||||
function pickSize(sizes) | function pickSize(sizes) | ||||
{ | { | ||||
var size = sizes[randInt(sizes.length)]; | let size = pickRandom(sizes); | ||||
if (size in g_Sizes) | if (size in g_Sizes) | ||||
return g_Sizes[size]; | return g_Sizes[size]; | ||||
return g_Sizes.normal; | return g_Sizes.normal; | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 189 Lines • ▼ Show 20 Lines | function randomStartingPositionPattern() | ||||
if (g_MapInfo.mapSize >= 256 && (g_MapInfo.teams.length >= 3 || g_MapInfo.numPlayers > 4)) | if (g_MapInfo.mapSize >= 256 && (g_MapInfo.teams.length >= 3 || g_MapInfo.numPlayers > 4)) | ||||
formats.push("random"); | formats.push("random"); | ||||
// Enable line if we have enough teams and players on a big enough map | // Enable line if we have enough teams and players on a big enough map | ||||
if (g_MapInfo.teams.length >= 2 && g_MapInfo.numPlayers >= 4 && g_MapInfo.mapSize >= 384) | if (g_MapInfo.teams.length >= 2 && g_MapInfo.numPlayers >= 4 && g_MapInfo.mapSize >= 384) | ||||
formats.push("line"); | formats.push("line"); | ||||
return { | return { | ||||
"setup": formats[randInt(formats.length)], | "setup": pickRandom(formats), | ||||
"distance": randFloat(0.2, 0.35), | "distance": randFloat(0.2, 0.35), | ||||
"separation": randFloat(0.05, 0.1) | "separation": randFloat(0.05, 0.1) | ||||
}; | }; | ||||
} | } | ||||
/** | /** | ||||
* Mix player indices but sort by team. | * Mix player indices but sort by team. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 305 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator