A_ClearTarget

From ZDoom Wiki
Jump to: navigation, search

A_ClearTarget

(no parameters)

Usage

Makes the calling actor forget about its target, sound target, and last target. You can call this before jumping back to a monster's idle states to make a monster "give up" trying to chase after its target after a while (for ex. if it's too far away), after which it will resume searching for targets or doing whatever else is specified in its spawn state.

Examples

This is a working example of an imp after a while completely forgets what he was doing and goes back to dancing on the spot.

Actor ForgetfulImp : DoomImp
{
  States
  {
  See:
    TROO AABBCCDD 3 A_Chase
    TROO A 0 A_GiveInventory("Forgettimer", 1) // 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", 20) // Reset the timer.
     TROO EF 8 A_FaceTarget
     TROO G 6 A_TroopAttack
     Goto See
  Forget: 
     TROO A 0 A_TakeInventory("Forgettimer", 20)
     TROO A 3 A_ClearTarget
     Goto Spawn
  }
}