diff --git a/project/src/helpers/ItemHelper.ts b/project/src/helpers/ItemHelper.ts index ca6a6610..84324ae8 100644 --- a/project/src/helpers/ItemHelper.ts +++ b/project/src/helpers/ItemHelper.ts @@ -1229,7 +1229,7 @@ export class ItemHelper { */ public itemIsInsideContainer(itemToCheck: Item, desiredContainerSlotId: string, items: Item[]): boolean { // Get items parent - const parent = items.find((x) => x._id === itemToCheck.parentId); + const parent = items.find((item) => item._id === itemToCheck.parentId); if (!parent) { // No parent, end of line, not inside container return false; diff --git a/project/src/services/InsuranceService.ts b/project/src/services/InsuranceService.ts index aaa714e5..3f74649e 100644 --- a/project/src/services/InsuranceService.ts +++ b/project/src/services/InsuranceService.ts @@ -228,6 +228,10 @@ export class InsuranceService { continue; } + if (this.itemCannotBeLostOnDeath(lostItem, pmcProfile.Inventory.items)) { + continue; + } + // Add insured item + details to return array result.push({ sessionID: sessionId, @@ -240,6 +244,25 @@ export class InsuranceService { return result; } + /** + * Some items should never be returned in insurance but BSG send them in the request + * @param lostItem Item being returned in insurance + * @param inventoryItems Player inventory + * @returns True if item + */ + protected itemCannotBeLostOnDeath(lostItem: Item, inventoryItems: Item[]): boolean { + if (lostItem.slotId?.toLowerCase().startsWith("specialslot")) { + return true; + } + + // We check secure container items even tho they are omitted from lostInsuredItems, just in case + if (this.itemHelper.itemIsInsideContainer(lostItem, "SecuredContainer", inventoryItems)) { + return true; + } + + return false; + } + /** * Add gear item to InsuredItems array in player profile * @param sessionID Session id diff --git a/project/src/services/LocationLifecycleService.ts b/project/src/services/LocationLifecycleService.ts index 8b4bc611..5128c497 100644 --- a/project/src/services/LocationLifecycleService.ts +++ b/project/src/services/LocationLifecycleService.ts @@ -622,7 +622,7 @@ export class LocationLifecycleService { preRaidPmcProfile: IPmcData, request: IEndLocalRaidRequestData, locationName: string, - ) { + ): void { if (request.lostInsuredItems?.length > 0) { const mappedItems = this.insuranceService.mapInsuredItemsToTrader( sessionId, @@ -630,6 +630,11 @@ export class LocationLifecycleService { request.results.profile, ); + // Is possible to have items in lostInsuredItems but removed before reaching mappedItems + if (mappedItems.length === 0) { + return; + } + this.insuranceService.storeGearLostInRaidToSendLater(sessionId, mappedItems); this.insuranceService.sendInsuredItems(preRaidPmcProfile, sessionId, locationName);