A_TakeInventory
From ZDoom Wiki
A_TakeInventory (string type, int count[, int flags])
A_TakeInventory (string type, int count[, int flags[, pointer takefrom]]) (development version r3167+ only)
Removes count items of type type from the calling actor's inventory. The minimum amount of item of a type in an inventory is zero, removing a greater amount than what the actor actually possesses will not result in a negative amount.
There is at the moment only one flag:
- TIF_NOTAKEINFINITE: If this flag is set, nothing is taken if the type is an Ammo and the player benefits from infinite ammo (either from a powerup or a cheat). (New from 2.5.0)
The takefrom pointer can be any of the following:
- AAPTR_DEFAULT: The calling actor itself (default value)
- AAPTR_NULL: No actor at all
- AAPTR_TARGET: The calling actor's target, if any (equivalent to using A_TakeFromTarget)
- AAPTR_MASTER: The calling actor's master, if any
- AAPTR_TRACER: The calling actor's tracer, if any
Remember that the nature of these pointers depend on the actor type and is not always intuitive.
Examples
This is a working example of an forgetful imp that uses inventory for timed checks. A_TakeInventory is used to reset the inventory based timer.
actor ForgetfulImp : DoomImp
{
states
{
See:
TROO AABBCCDD 3 A_Chase
TROO A 0 A_GiveInventory("Forgettimer",0) // A dummy inventory for tracking how long the imp has been searching.
TROO A 0 A_JumpIfInventory("Forgettimer", 20, "Forget") // Jump to the Forget state when the timer reaches 20
loop
Melee:
Missile:
TROO E 0 A_TakeInventory("Forgettimer", 255) // Reset the timer.
TROO EF 8 A_FaceTarget
TROO G 6 A_TroopAttack
goto See
Forget:
TROO A 0 A_TakeInventory("Forgettimer", 255)
TROO A 3 A_ClearTarget
Goto Spawn
}
}