Fixed mannequin pocket items being lost on pmc death

This commit is contained in:
Dev 2024-09-24 18:21:19 +01:00
parent 4c2f93f219
commit 9b7602baa8
3 changed files with 29 additions and 1 deletions

View File

@ -66,6 +66,8 @@ export class SptDialogueChatBot implements IDialogueChatBot {
"Hey! you got the right code!",
"A secret code, how exciting!",
"You found a gift code!",
"A gift code! incredible",
"A gift! what could it be!",
]),
);

View File

@ -194,7 +194,11 @@ export class InRaidHelper {
}
// Pocket items are lost on death
if (item.slotId.startsWith("pocket")) {
// Ensure we dont pick up pocket items from manniquins
if (
item.slotId.startsWith("pocket") &&
this.inventoryHelper.doesItemHaveRootId(pmcProfile, item, pmcProfile.Inventory.equipment)
) {
return true;
}

View File

@ -1148,6 +1148,28 @@ export class InventoryHelper {
}
}
}
/**
* Does the provided item have a root item with the provided id
* @param pmcData Profile with items
* @param item Item to check
* @param rootId Root item id to check for
* @returns True when item has rootId, false when not
*/
public doesItemHaveRootId(pmcData: IPmcData, item: IItem, rootId: string) {
let currentItem = item;
while (currentItem) {
// If we've found the equipment root ID, return true
if (currentItem._id === rootId) {
return true;
}
// Otherwise get the parent item
currentItem = pmcData.Inventory.items.find((item) => item._id === currentItem.parentId);
}
return false;
}
}
namespace InventoryHelper {