DropInventory (ZScript)

From ZDoom Wiki
Jump to navigation Jump to search

Inventory DropInventory (Inventory item [, int amt])


Drops an item to the ground by the calling actor.

To be dropped, the item needs to have an owner. This owner does not necessarily need to be the calling actor itself. Items which have the INVENTORY.UNDROPPABLE or INVENTORY.UNTOSSABLE flags set cannot be dropped, as well as items which lack the Spawn state. The number of samples the dropped item could contain cannot be more than what the owner has in their inventory of the item.

Note: what is explained above is the default behavior, a behavior which can be altered through the virtual function CreateTossable.

A dropped item will have its NOGRAVITY flag explicitly cleared, and will no longer count towards the map's statistics.


  • item: the item to drop. This is a pointer to the item.
  • amt: the number of samples the dropped item contains. Default is -1, which is considered as one sample.

Return value

The function returns a pointer to the item if it was dropped successfully, otherwise it returns null.


The killer of this archvile drops an energy cell that is worth 20 ammo from their inventory.

class ExArchvile : Archvile
    override void Die (Actor source, Actor inflictor, int dmgflags, Name MeansOfDeath)
        Super.Die(source, inflictor, dmgflags, MeansOfDeath);

        if (source)
            Inventory drop = source.FindInventory("Cell");

            if (drop)
                source.DropInventory(drop, 20);