TakeInventory
From ZDoom Wiki
void TakeInventory(str inventory_item, int amount);
Usage
This function will take the number of items specified from the activator. In the case of ammo, health and armor it will take the total number (so TakeInventory("Shells", 5) and TakeInventory("ShellBox", 5) will both take five shells from the player).
Unlike ClearInventory, TakeInventory can remove items that are flagged as undroppable.
See the Inventory page for a list of items in ZDoom.
Examples
This script randomly removes objects from the player. Sometimes it does not remove any object, though. It is due to how lucky the player is.
str weapons[8] = {"Pistol", "Shotgun", "SuperShotgun",
"Chaingun", "RocketLauncher", "PlasmaRifle", "BFG9000",
"Chainsaw"};
script 10 (void)
{
int targ = random(0, 7);
if (CheckInventory(weapons[targ]))
{
TakeInventory(weapons[targ], 1);
Print(s:"You have dropped a weapon!\ncareless player...");
}
}
Note that no inventory can be a negative amount.