A_JumpIfTargetInLOS
A_JumpIfTargetInLOS (int offset[, float fov[, int flags[, float dist_max[, float dist_close]]]])
A_JumpIfTargetInLOS (str "state"[, float fov[, int flags[, float dist_max[, float dist_close]]]])
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.
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:
- The calling actor's master, if the actor is a monster and the JLOSF_CHECKMASTER flag is set;
- The calling actor's tracer, if the actor is a missile with the SEEKERMISSILE flag and JLOSF_PROJECTILE is set;
- 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: (New from 2.5.0)
- 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 (development version r3222+ only)
- JLOSF_FLIPFOV: Check FOV for the actor that does not make a sight check (development version r3222+ only)
- JLOSF_ALLYNOJUMP: Jump only if the actors are not allied to eachother. Unfriendly monsters have no allies. (development version r3222+ only)
- 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.) (development version r3222+ only)
JLOSF_TARGETLOS|JLOSF_FLIPFOV: Duplicates behavior of A_JumpIfInTargetLOS (target line is checked, caller fov is checked) (development version r3222+ only)
- 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. (New from 2.5.0)
- dist_close: The function of this parameter depends on the flags used; it has otherwise no effect. The default value is 0. (New from 2.5.0)
Examples
ACTOR ScannerRailgun : Railgun { +WEAPON.NOAUTOFIRE // to keep dumb things from happening when there's no target in sight and the fire button is held States { Fire: RLGG E 0 A_JumpIfTargetInLOS(1) // Is there something in sight? Goto Ready // Can't fire, go back to ready RLGG E 12 A_FireRailgun RLGG F 6 A_CheckForReload(4, "Reloaded") RLGG GHIJK 6 RLGG L 6 A_ResetReloadCounter } }
This is a modified Railgun that won't shoot unless it'll hit something.