From ZDoom Wiki
Jump to: navigation, search

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 “Seestate or a custom equivalent. When called, actor's usually change their directions to a strict 45 degree angle to give the effect of pursuit. This angle changes based on which direction the target is, no matter if the calling actor can see it or not.

NOTE: This function is not subject to the same rules as other jump functions are in Anonymous Functions, and cannot be used inside of if/else statements. A_Chase WILL perform its jump, no matter what circumstances apply.

  • 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 “Healstate (if defined) upon encountering a revivable corpse, like the Arch-Vile in Doom II.
    • CHF_DONTMOVE - Actor will not move.
    • CHF_NORANDOMTURN - Actor will not change its chasing angle to its target if its beyond a certain degree until something blocks the way (obstacle or wall).
    • CHF_NODIRECTIONTURN - Actor will not turn its angle to face the direction of travel.
    • CHF_NOPOSTATTACKTURN - Actor will not turn itself to its target after attacking.
    • CHF_STOPIFBLOCKED - Actor cannot turn away from obstacles blocking it. It will simply not move, but can still angle itself.

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.


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 
    Height 20 // Default variables.
    Radius 16 // Default variables.
    Speed 10 
    Missiletype "Cowmissile" //NOT included in-game.
    Meleedamage 5 
              MONS A 1 A_Look
              MONS ABCD 4 A_Chase("Meleeattack", "Cowattack")
              MONS E 5 A_MissileAttack
              Goto See 
              MONS F 5 A_MeleeAttack
              Goto See