From ZDoom Wiki
Jump to navigation Jump to search

state A_JumpIfInTargetLOS (int offset[, float fov[, int flags[, float dist_max[, float dist_close]]]])
state A_JumpIfInTargetLOS (str "state"[, float fov[, int flags[, float dist_max[, float dist_close]]]])

Note: Jump functions perform differently inside of anonymous functions.


Jumps if the calling actor is in the field of view of its target. The flags parameter is used to determine the target of the calling actor's target. In the rest of the description, "target" will refer to either:

  • the target's master, if the JLOSF_CHECKMASTER flag is set;
  • the target's tracer, if the actor is a missile with the SEEKERMISSILE flag and JLOSF_PROJECTILE is set;
  • the target's target, in all other cases. This corresponds to a monster's current enemy or a projectile's shooter.

If the calling actor has a valid target (as explained above) and can currently be seen by it, then a jump is performed. If fov is given, it is an angle representing the size (in degrees) of the sight cone. Actors outside of this cone (the center of which is the actor's current facing direction) are not considered to be “visible”. If omitted, no sight cone is used and instead this function jumps if the view between the target and the caller is unobstructed (the target can see the caller, regardless of facing direction, given there are no walls between the two).


  • state is label of the state to which the jump must be made.
  • offset corresponds to the number of states that must be skipped to make the jump.
  • fov corresponds to the field of vision used by the calling actor. The default value of 0 gives an all-around field of vision.
  • flags: The following flags can be combined by using the | character between the constant names:
    • JLOSF_PROJECTILE — if set, the actor checks sight with the target it is seeking (the tracer field) instead of the normal target field (that, for projectiles, corresponds to the actor that fired it). If the actor is a projectile and does not have the SEEKERMISSILE flag set, the target will be considered NULL, otherwise, if it is not a missile, the flag is ignored.
    • JLOSF_NOSIGHT — disables the sight check.
    • JLOSF_CLOSENOFOV — disables the FOV check if the target is within dist_close distance.
    • JLOSF_CLOSENOSIGHT — disables the sight check if the target is within dist_close distance.
    • JLOSF_CLOSENOJUMP — does not perform a jump if the target is within dist_close distance.
    • JLOSF_DEADNOJUMP — does not perform a jump if the target is dead.
    • JLOSF_CHECKMASTER — use the master field; overrides all other flags that specify the target.
  • dist_max: the maximum distance between the calling actor and the target, no jumps are performed beyond it. The default value of 0 means there are no distance checks.
  • dist_close: the function of this parameter depends on the flags used; it has otherwise no effect. The default value is 0.


This revenant will dodge its target's attacks:

    TNT1 A 0 A_JumpIfInTargetLOS(1, 30, JLOSF_DEADNOJUMP, 500) // if close and we're under their crosshair, jump!
    Goto See+3 // skip the evasion code.
    TNT1 A 0 A_FaceTarget
    SKEL A 4 A_ChangeVelocity(6, 0, 0, CFV_RELATIVE)

See also