A_Chase

From ZDoom Wiki

Jump to: navigation, search

A_Chase [(str MeleeState, [str RangedState, [int Flags]])]


Warning: Using state labels as arguments without quotation marks has been deprecated and will no longer work. Make sure to enclose all your string arguments with quotation marks to ensure full compatibility with future ZDoom versions. Refer to the available example(s) for proper usage


This is the standard monster walking function which has to be used in the walking frames of a monster (usually in the See state or a custom equivalent).

  • MeleeState: The state to jump to when the monster decides to perform a melee attack. Default is "Attack". If this is 0, "", 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 given as an integer (by adding the numbers together), or by using their keyword constants (separated by the | character).
    • 1 (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.
    • 2 (CHF_NOPLAYACTIVE): Actor does not play active sounds.
    • 4 (CHF_NIGHTMAREFAST): Actor moves twice as fast in Nightmare.
    • 8 (CHF_RESURRECT): Actor will enter the Heal state (if defined) upon encountering a revivable corpse (like the Arch-Vile in Doom II).
    • 16 (CHF_DONTMOVE): Actor does not move.

Note that because A_Chase and its variant have the capacity to put the actor into an attack state, they shouldn't be used on the first frame 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's close to it's 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 A_Chase("Meleeattack", "Cowattack")
              Loop 
         Cowattack: 
              MONS E 5 A_MissileAttack
              Goto See 
         Meleeattack: 
              MONS F 5 A_MeleeAttack
              Goto See
    }  
}
Personal tools