A_Chase
From ZDoom Wiki
A_Chase [(str "MeleeState"[, str "RangedState"[, int Flags]])]
This is the standard monster walking function which has to be used in the walking frames of a monster. Typically, it is used in an actor's “See” state or a custom equivalent.
- MeleeState: The state to jump to when the monster decides to perform a melee attack. Default is “Melee”. If this is 0, the empty string "", or omitted, the monster will not be able to enter the melee state while chasing.
- RangedState: The state to jump to when the monster decides to perform a ranged attack. Default is “Missile”. If this is 0, "", or omitted, the monster will not be able to enter the ranged state while chasing.
- Flags: Determines how the monster will behave when the function is called. Flags can be combined by using the | character between the constant names.
- CHF_FASTCHASE — Actor will randomly attempt to strafe left or right around the target, like the “player bosses” in Hexen. Note that the calling actor will ignore their maxdropoff property when strafing, and so may strafe off cliffs or into pits from which they can not escape. Setting the NODROPOFF flag will prevent this from happening.
- CHF_NOPLAYACTIVE — Actor will not play active sounds.
- CHF_NIGHTMAREFAST — Actor will move twice as fast in Nightmare.
- CHF_RESURRECT — Actor will enter the “Heal” state (if defined) upon encountering a revivable corpse, like the Arch-Vile in Doom II.
- CHF_DONTMOVE — Actor will not move.
Note that because A_Chase and its variant have the capacity to put the actor into an attack state, they should not be used during the first tic of one of those states, as it may result in infinite recursion, which will usually manifest itself in ZDoom as a crash.
Example
Here is an example of a new monster which uses the optional range attack as well as a melee attack if it is close to its target (like the Revenant from Doom).
actor Scurymonster
{
Monster
Height 20
Radius 16
Speed 10
Missiletype "Cowmissile"
Meleedamage 5
States
{
Spawn:
MONS A 1 A_Look
Loop
See:
MONS ABCD 4 A_Chase("Meleeattack", "Cowattack")
Loop
Cowattack:
MONS E 5 A_MissileAttack
Goto See
Meleeattack:
MONS F 5 A_MeleeAttack
Goto See
}
}