diff --git a/wadsrc/static/zscript/actors/inventory/inventory.zs b/wadsrc/static/zscript/actors/inventory/inventory.zs index 4108650a4a..c9890c699f 100644 --- a/wadsrc/static/zscript/actors/inventory/inventory.zs +++ b/wadsrc/static/zscript/actors/inventory/inventory.zs @@ -12,6 +12,7 @@ class Inventory : Actor private bool bSharingItem; // Currently being shared (avoid infinite recursions). private bool pickedUp[MAXPLAYERS]; // If items are set to local, track who already picked it up. + private bool bCreatingCopy; // Tells GoAway that it needs to return true so a new copy of the item is spawned. deprecated("3.7") private int ItemFlags; Actor Owner; // Who owns this item? NULL if it's still a pickup. @@ -835,9 +836,11 @@ class Inventory : Actor Inventory give = self; if (localPickUp) { - give = Inventory(Spawn(GetClass())); + give = CreateLocalCopy(toucher); if (!give) return; + + localPickUp = give != self; } bool res; @@ -1043,6 +1046,9 @@ class Inventory : Actor protected bool GoAway () { + if (bCreatingCopy) + return true; + // Dropped items never stick around if (bDropped) { @@ -1113,6 +1119,17 @@ class Inventory : Actor pickedUp[pNum] = true; DisableLocalRendering(pNum, true); } + + // Force spawn a new version of the item. This needs to use CreateCopy so that + // any transferrable properties on the item get correctly set. + Inventory CreateLocalCopy(Actor client) + { + bCreatingCopy = true; + let item = CreateCopy(client); + bCreatingCopy = false; + + return item; + } //=========================================================================== //