HasReceived

From ZDoom Wiki
Jump to navigation Jump to search

Actor

virtual void HasReceived(Inventory item) (New from 4.12.1)

Usage

An Actor virtual function that is called after an Inventory item has been received. It gets called automatically at the end of the item's CallTryPickup chain. In the base Actor class this function is empty and does nothing, but it can be overridden to add custom behavior.

Error.gif
Warning: Be wary of the following:

1. The item can be null by the time this function is called, so it's important to null-check the pointer.

2.This function is intended for the purposes of obtaining data only. The item should not be destroyed or detached from the recipient because it can cause a VM abort. If you want to manually deteremine whether the actor should be allowed to receive the item, see CanReceive instead.


Parameters

  • Inventory item
A pointer to the item that has been received by the calling actor.

Examples

This custom DoomPlayer will print the text "Received a Doom weapon!" folllowed by the name of the weapon in parentheses whenever they receive an item based on the DoomWeapon class:

class CustomDoomPlayer : DoomPlayer
{
  override void HasReceived(Inventory item)
  {
    if (item && item is 'DoomWeapon')
    {
      Console.Printf("Received a Doom weapon! (%s)", item.GetTag();
    }
  }
}

See also