Do not return insured items stored in secure/special slots on death
This commit is contained in:
parent
5cd4a207c7
commit
12a79488d8
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user