From ZDoom Wiki
Jump to navigation Jump to search

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

Note: Jump functions perform differently inside of anonymous functions.

This can be used with monsters, weapons, projectiles and inventory items.

For weapons and inventory, jumps if the player has a suitable line target under their crosshair. With weapons and inventory, FOV is meaningless and can be omitted. "Suitable" is defined as:

  1. The targeted actor has the SOLID flag.
  2. The targeted actor has the SHOOTABLE flag.
  3. The targeted actor does not have the NOBLOCKMAP flag.

For monsters and seeking projectiles, the flags parameter is used to determine the actor that the calling actor looks for. In the rest of the description, "target" will refer to either:

  1. The calling actor's master, if the actor is a monster and the JLOSF_CHECKMASTER flag is set;
  2. The calling actor's tracer, if the actor is a missile with the SEEKERMISSILE flag and JLOSF_PROJECTILE is set. It will also refer to tracer if the JLOSF_CHECKTRACER is set, regardless if the actor is a missile or not;
  3. The calling actor's target, in all other cases. This corresponds to a monster's enemy or a projectile's shooter. (It is counter-intuitive, but a projectile's target field does not store the projectile's actual target.)


Jumps if the calling actor has a valid target (as explained above) and can currently see it. If FOV is given, it is an angle representing the size (in degrees) of the actor's sight cone. Actors outside of this cone (the center of which is the calling 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 caller and the target is unobstructed (the caller can see the target, 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 — Seeking projectile: If set, the actor checks sight with the target it is seeking (tracer field) instead of the normal target field (which, for projectiles, actually corresponds to the actor that fired it). If the actor is not a projectile or does not have the SEEKERMISSILE flag set, this flag is ignored.
    • JLOSF_NOSIGHT — No sight check: Disables the sight check.
    • JLOSF_CLOSENOFOV — No FOV check if close: Disable the FOV check if the target is within dist_close distance.
    • JLOSF_CLOSENOSIGHT — No sight check if close: Disable the sight check if the target is within dist_close distance.
    • JLOSF_CLOSENOJUMP — No jump if close: Does not perform a jump if the target is within dist_close distance.
    • JLOSF_DEADNOJUMP — No jump if dead: Does not perform a jump if the target is dead.
    • JLOSF_CHECKMASTER — Check master: Use the master field instead of the target or tracer field.
    • JLOSF_TARGETLOS — Check target's line of sight.
    • JLOSF_FLIPFOV — Check FOV for the actor that does not make a sight check.
    • JLOSF_ALLYNOJUMP — Jump only if the actors are not allied to each other. Unfriendly monsters have no allies.
    • JLOSF_COMBATANTONLY — Jump only if the target is a monster or a player. (Particularly useful when working with a player's target, as it could be any actor.)
    • JLOSF_NOAUTOAIM — Jump only if the target is under the crosshair, taking both horizontal and vertical aims into account. This is to cater for weapons that require manual aiming by nature such as railguns, or ones that have autoaim disabled in them with the use of the WEAPON.NOAUTOAIM flag.
    • JLOSF_CHECKTRACER — Check line of sight with the calling actor's tracer instead of target. Unlike JLOSF_PROJECTILE, this flag works on non-missile actors.
The combination of the flags JLOSF_TARGETLOS and JLOSF_FLIPFOV duplicates the behavior of A_JumpIfInTargetLOS (target line is checked, caller fov is checked).
  • 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 is a modified railgun that will not shoot unless it will hit something.

ACTOR ScannerRailgun : Railgun
  +WEAPON.NOAUTOFIRE // Disables Automatic fire.
    RLGG E 1 A_JumpIfTargetInLOS(1, 0, JLOSF_NOAUTOAIM) // Is there something that is being aimed at?
    Goto Ready // Cannot fire, go back to ready
    RLGG E 12 A_FireRailgun
    RLGG F 6 A_CheckForReload(4, "Reloaded")
    RLGG L 6 A_ResetReloadCounter

See also