0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 09:50:43 -05:00

Improvements to setFoundInRaid and RewardHelper

This commit is contained in:
Chomp 2025-02-04 21:20:32 +00:00
parent fc1072c91e
commit 9f1c0be4df
2 changed files with 13 additions and 7 deletions

View File

@ -927,21 +927,26 @@ export class ItemHelper {
* Mark the passed in array of items as found in raid. * Mark the passed in array of items as found in raid.
* Modifies passed in items * Modifies passed in items
* @param items The list of items to mark as FiR * @param items The list of items to mark as FiR
* @param excludeCurrency Should currency be excluded from becoming FiR (default true)
*/ */
public setFoundInRaid(items: IItem[]): void { public setFoundInRaid(items: IItem[], excludeCurrency = true): void {
for (const item of items) { for (const item of items) {
if (!item.upd) { if (!item.upd) {
item.upd = {}; item.upd = {};
} }
if (excludeCurrency && this.isOfBaseclass(item._tpl, BaseClasses.MONEY)) {
continue;
}
item.upd.SpawnedInSession = true; item.upd.SpawnedInSession = true;
} }
} }
/** /**
* WARNING, SLOW. Recursively loop down through an items hierarchy to see if any of the ids match the supplied list, return true if any do * WARNING, SLOW. Recursively loop down through an items hierarchy to see if any of the ids match the supplied list, return true if any do
* @param {string} tpl Items tpl to check parents of * @param tpl Items tpl to check parents of
* @param {Array} tplsToCheck Tpl values to check if parents of item match * @param tplsToCheck Tpl values to check if parents of item match
* @returns boolean Match found * @returns boolean Match found
*/ */
public doesItemOrParentsIdMatch(tpl: string, tplsToCheck: string[]): boolean { public doesItemOrParentsIdMatch(tpl: string, tplsToCheck: string[]): boolean {
@ -949,12 +954,12 @@ export class ItemHelper {
const itemExists = itemDetails[0]; const itemExists = itemDetails[0];
const item = itemDetails[1]; const item = itemDetails[1];
// not an item, drop out // Not an item, drop out
if (!itemExists) { if (!itemExists) {
return false; return false;
} }
// no parent to check // No parent to check
if (!item._parent) { if (!item._parent) {
return false; return false;
} }

View File

@ -9,6 +9,7 @@ import { IReward } from "@spt/models/eft/common/tables/IReward";
import { IHideoutProduction } from "@spt/models/eft/hideout/IHideoutProduction"; import { IHideoutProduction } from "@spt/models/eft/hideout/IHideoutProduction";
import { IItemEventRouterResponse } from "@spt/models/eft/itemEvent/IItemEventRouterResponse"; import { IItemEventRouterResponse } from "@spt/models/eft/itemEvent/IItemEventRouterResponse";
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile"; import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
import { BaseClasses } from "@spt/models/enums/BaseClasses";
import { RewardType } from "@spt/models/enums/RewardType"; import { RewardType } from "@spt/models/enums/RewardType";
import { SkillTypes } from "@spt/models/enums/SkillTypes"; import { SkillTypes } from "@spt/models/enums/SkillTypes";
import type { ILogger } from "@spt/models/spt/utils/ILogger"; import type { ILogger } from "@spt/models/spt/utils/ILogger";
@ -253,8 +254,8 @@ export class RewardHelper {
for (const rewardItem of reward.items) { for (const rewardItem of reward.items) {
this.itemHelper.addUpdObjectToItem(rewardItem); this.itemHelper.addUpdObjectToItem(rewardItem);
// Reward items are granted Found in Raid status // Reward items are granted Found in Raid status (except currency)
rewardItem.upd.SpawnedInSession = true; this.itemHelper.setFoundInRaid(reward.items);
// Is root item, fix stacks // Is root item, fix stacks
if (rewardItem._id === reward.target) { if (rewardItem._id === reward.target) {