Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/module/item/physical/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,13 @@ function handleHPChange(item: PhysicalItemPF2e, changed: DeepPartial<PhysicalIte
const itemIndex = actorSource?.items.findIndex((i) => i._id === item._id);
if (itemIndex === -1) return;
actorSource?.items.splice(itemIndex ?? 0, 1, changedSource);
const actorClone = actorSource ? new ActorProxyPF2e(actorSource) : null;
const actorClone = ((): ActorPF2e | null => {
// Catch invalid items in the actor clone preventing other items from updating
try {
return actorSource ? new ActorProxyPF2e(actorSource) : null;
} catch {}
return null;
})();
const itemClone = actorClone?.inventory.get(item.id, { strict: true }) ?? item.clone(changed, { keepId: true });

// Adjust current HP proportionally if max HP changed
Expand Down