diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 8b63881f59..52f153bd73 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -510,7 +510,15 @@ class Actor : Thinker native return true; } - // Called in TryMove if the mover ran into another Actor. This isn't called on players + // [AA] Called by inventory items in CallTryPickup to see if this actor needs + // to process them in some way before they're received. Gets called before + // the item's TryPickup, allowing fully customized handling of all items. + virtual bool CanReceive(Inventory item) + { + return true; + } + + // Called in TryMove if the mover ran into another Actor. This isn't called on players // if they're currently predicting. Guarantees collisions unlike CanCollideWith. virtual void CollidedWith(Actor other, bool passive) {} diff --git a/wadsrc/static/zscript/actors/inventory/inventory.zs b/wadsrc/static/zscript/actors/inventory/inventory.zs index 35c1a3d958..7d45cc0676 100644 --- a/wadsrc/static/zscript/actors/inventory/inventory.zs +++ b/wadsrc/static/zscript/actors/inventory/inventory.zs @@ -597,8 +597,16 @@ class Inventory : Actor // unmorphed versions of a currently morphed actor cannot pick up anything. if (bUnmorphed) return false, null; - bool res; - if (CanPickup(toucher)) + //[AA] starting with true, so that CanReceive can unset it, + // if necessary: + bool res = true; + // [AA] CanReceive lets the actor receiving the item process it first. + if (!toucher.CanReceive(self)) + { + res = false; + } + // CanPickup processes restrictions by player class. + else if (CanPickup(toucher)) { res = TryPickup(toucher); }