Fix dynamic loot generation not respecting spawn point's IsAlwaysSpawn field (!226)

A similar field can also be seen in static container generation which the value is respected

Also Limited the amount of random draws to avoid going over the `desiredSpawnpointCount`
- Consider a potential mod that changes every spawn point's `IsAlwaysSpawn` to true, then there is absolute no point for the generator to draw them again and only to have them removed during dedupe

Co-authored-by: qe201020335 <qe201020335@sina.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/226
Co-authored-by: qe201020335 <qe201020335@noreply.dev.sp-tarkov.com>
Co-committed-by: qe201020335 <qe201020335@noreply.dev.sp-tarkov.com>
This commit is contained in:
qe201020335 2024-02-15 09:09:35 +00:00 committed by chomp
parent d77c930396
commit a1d82af41f

View File

@ -623,7 +623,7 @@ export class LocationGenerator
continue;
}
if (spawnpoint.probability === 1)
if (spawnpoint.probability === 1 || spawnpoint.template.IsAlwaysSpawn)
{
guaranteedLoosePoints.push(spawnpoint);
continue;
@ -636,11 +636,16 @@ export class LocationGenerator
// Add ALL loose loot with 100% chance to pool
let chosenSpawnpoints: Spawnpoint[] = [...guaranteedLoosePoints];
const randomSpawnpointCount = desiredSpawnpointCount - chosenSpawnpoints.length
// only draw random spawn points if needed
if (randomSpawnpointCount > 0)
{
// Add randomly chosen spawn points
for (const si of spawnpointArray.draw(desiredSpawnpointCount, false))
for (const si of spawnpointArray.draw(randomSpawnpointCount, false))
{
chosenSpawnpoints.push(spawnpointArray.data(si));
}
}
// Filter out duplicate locationIds
chosenSpawnpoints = [...new Map(chosenSpawnpoints.map((x) => [x.locationId, x])).values()];