DetachFromOwner

From ZDoom Wiki
Jump to navigation Jump to search

Inventory

virtual void DetachFromOwner()

Usage

A virtual function called by Inventory items when they're being removed from their owner's inventory. Normally, this happens when the items amount reaches 0, but items with the INVENTORY.KEEPDEPLETED flag don't do that, so they don't call this function.

In the base Inventory class this function is empty, i.e. no special behavior is executed.

Note: This function is not responsible for actually removing the item; that usually happens in GoAwayAndDie. Trying to call DetachFromOwner on an item directly does not remove it from their owner's inventory.

Examples

This item will kill its owner if it's removed from their inventory:

class DontDropMe : Inventory
{
  overide void DetachFromOwner()
  {
    if (owner)
    {
      owner.DamageMobj(self, self, owner.health, 'Normal');
    }
  }
}

See also