Fixed mannequin pocket items being lost on pmc death
This commit is contained in:
parent
4c2f93f219
commit
9b7602baa8
@ -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!",
|
||||
]),
|
||||
);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user