mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 09:10:43 -05:00
Fixed dynamic loot code choosing blacklisted items - credit to Drakia for solution
This commit is contained in:
parent
ef5d72f06b
commit
7497f0d40f
@ -649,6 +649,7 @@ export class LocationLootGenerator
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 100%, add it to guaranteed
|
||||||
if (spawnpoint.probability === 1)
|
if (spawnpoint.probability === 1)
|
||||||
{
|
{
|
||||||
guaranteedLoosePoints.push(spawnpoint);
|
guaranteedLoosePoints.push(spawnpoint);
|
||||||
@ -663,7 +664,7 @@ export class LocationLootGenerator
|
|||||||
let chosenSpawnpoints: Spawnpoint[] = [...guaranteedLoosePoints];
|
let chosenSpawnpoints: Spawnpoint[] = [...guaranteedLoosePoints];
|
||||||
|
|
||||||
const randomSpawnpointCount = desiredSpawnpointCount - chosenSpawnpoints.length;
|
const randomSpawnpointCount = desiredSpawnpointCount - chosenSpawnpoints.length;
|
||||||
// only draw random spawn points if needed
|
// Only draw random spawn points if needed
|
||||||
if (randomSpawnpointCount > 0 && spawnpointArray.length > 0)
|
if (randomSpawnpointCount > 0 && spawnpointArray.length > 0)
|
||||||
{
|
{
|
||||||
// Add randomly chosen spawn points
|
// Add randomly chosen spawn points
|
||||||
@ -696,6 +697,7 @@ export class LocationLootGenerator
|
|||||||
const seasonalItemTplBlacklist = this.seasonalEventService.getInactiveSeasonalEventItems();
|
const seasonalItemTplBlacklist = this.seasonalEventService.getInactiveSeasonalEventItems();
|
||||||
for (const spawnPoint of chosenSpawnpoints)
|
for (const spawnPoint of chosenSpawnpoints)
|
||||||
{
|
{
|
||||||
|
// Spawnpoint is invalid, skip it
|
||||||
if (!spawnPoint.template)
|
if (!spawnPoint.template)
|
||||||
{
|
{
|
||||||
this.logger.warning(
|
this.logger.warning(
|
||||||
@ -709,14 +711,14 @@ export class LocationLootGenerator
|
|||||||
spawnPoint.template.Items = spawnPoint.template.Items
|
spawnPoint.template.Items = spawnPoint.template.Items
|
||||||
.filter((item) => !this.itemFilterService.isLootableItemBlacklisted(item._tpl));
|
.filter((item) => !this.itemFilterService.isLootableItemBlacklisted(item._tpl));
|
||||||
|
|
||||||
// Ensure no seasonal items are in pool
|
// Ensure no seasonal items are in pool if not in-season
|
||||||
if (!seasonalEventActive)
|
if (!seasonalEventActive)
|
||||||
{
|
{
|
||||||
spawnPoint.template.Items = spawnPoint.template.Items
|
spawnPoint.template.Items = spawnPoint.template.Items
|
||||||
.filter((item) => !seasonalItemTplBlacklist.includes(item._tpl));
|
.filter((item) => !seasonalItemTplBlacklist.includes(item._tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Has no items, useless
|
// Spawn point has no items after filtering, skip
|
||||||
if (!spawnPoint.template.Items || spawnPoint.template.Items.length === 0)
|
if (!spawnPoint.template.Items || spawnPoint.template.Items.length === 0)
|
||||||
{
|
{
|
||||||
this.logger.warning(
|
this.logger.warning(
|
||||||
@ -726,10 +728,18 @@ export class LocationLootGenerator
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get an array of allowed IDs after above filtering has occured
|
||||||
|
const validItemIds = spawnPoint.template.Items.map((item) => item._id);
|
||||||
|
|
||||||
// Construct container to hold above filtered items, letting us pick an item for the spot
|
// Construct container to hold above filtered items, letting us pick an item for the spot
|
||||||
const itemArray = new ProbabilityObjectArray<string>(this.mathUtil, this.cloner);
|
const itemArray = new ProbabilityObjectArray<string>(this.mathUtil, this.cloner);
|
||||||
for (const itemDist of spawnPoint.itemDistribution)
|
for (const itemDist of spawnPoint.itemDistribution)
|
||||||
{
|
{
|
||||||
|
if (!validItemIds.includes(itemDist.composedKey.key))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
itemArray.push(new ProbabilityObject(itemDist.composedKey.key, itemDist.relativeProbability));
|
itemArray.push(new ProbabilityObject(itemDist.composedKey.key, itemDist.relativeProbability));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user