A_JumpIfInTargetInventory

From ZDoom Wiki
Jump to: navigation, search

state A_JumpIfInTargetInventory (str "item", int count, int offset[, pointer forward])
state A_JumpIfInTargetInventory (str "item", int count, str "state"[, pointer forward])

Note: Jump functions perform differently inside of anonymous functions.

Usage

Jumps if the target has the specified actor type item and amount count in its inventory.

If an actor pointer is given, the test will be forwarded to the actor in the target's corresponding pointer.

Examples

This Imp runs away if the player has a BFG9000 or a Plasma Rifle.

actor WiseImp : DoomImp
{
  states
  {
  Spawn:
    TROO A 0 A_ChangeFlag("FRIGHTENED",0) // Clear the FRIGHTENED flag if the Imp loses its target.
    TROO AB 10 A_Look
    Goto Spawn+1
  See:
    TROO AABBCCDD 3 A_Chase
    TROO A 0 A_JumpIfInTargetInventory("PlasmaRifle", 1, "Ohcrap")
    TROO A 0 A_JumpIfInTargetInventory("BFG9000", 1, "Ohcrap")
    loop
  Ohcrap: 
    TROO A 0 A_Pain // Imp roars in fear
    TROO A 3 A_ChangeFlag("FRIGHTENED",1)
    TROO AABBCCDD 2 A_Chase
    Goto Ohcrap+2
  }
}