diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 070745df4..e0ebaea92 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1158,6 +1158,14 @@ AInventory *AActor::DropInventory (AInventory *item, int amt) drop->Vel += Vel; drop->flags &= ~MF_NOGRAVITY; // Don't float drop->ClearCounters(); // do not count for statistics again + { + // [MK] call OnDrop so item can change its drop behaviour + IFVIRTUALPTR(drop, AInventory, OnDrop) + { + VMValue params[] = { drop, this }; + VMCall(func, params, 2, nullptr, 0); + } + } return drop; } diff --git a/wadsrc/static/zscript/inventory/inventory.txt b/wadsrc/static/zscript/inventory/inventory.txt index 1bc3f42a6..d724c90d9 100644 --- a/wadsrc/static/zscript/inventory/inventory.txt +++ b/wadsrc/static/zscript/inventory/inventory.txt @@ -906,7 +906,17 @@ class Inventory : Actor native return item; } - + + //=========================================================================== + // + // AInventory :: OnDrop + // + // Called by AActor::DropInventory. Allows items to modify how they behave + // after being dropped. + // + //=========================================================================== + + virtual void OnDrop (Actor dropper) {} } //===========================================================================