A_ClearTarget
From ZDoom Wiki
A_ClearTarget (no parameters)
Usage
Makes the calling actor forget about it's 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 it's 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",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
}
}

