A_CheckSight

From ZDoom Wiki
Jump to: navigation, search

state A_CheckSight (int offset)
state A_CheckSight (str "state")

Note: Jump functions perform differently inside of anonymous functions.

Jumps if there is no possible line of sight between the center of the calling actor and that of any player pawn.

This function does not account for whether or not a player is actually looking at the calling actor or not; as long as there is a possible line of sight (i.e. at least one player is in a position where they could see the calling actor if they faced the right direction), no jump will occur. And on the other hand, the jump might happen even though the actor is partially seen by a player.

Note that A_CheckSight also counts for actors being viewed through cameras and co-op spy. It does not check if the actor is being viewed through a camera texture.

Examples

The following actor fades out and disappears from the map once killed, but will not do so until out of sight of all players. Useful for open maps with a high body count, to reduce possible lag.

 actor FadingZombie : Zombieman
 {
   States
   {
   Death:
     POSS H 5
     POSS I 5 A_Scream
     POSS J 5 A_NoBlocking
     POSS K 5
     // intentional fallthrough
   DeathWait:
     POSS L 1 A_CheckSight("DeathFade")
     loop
   DeathFade:
     POSS L 1 A_FadeOut(0.02)
     loop
   XDeath:
     POSS M 5
     POSS N 5 A_XScream
     POSS O 5 A_NoBlocking
     POSS PQRST 5
     // intentional fallthrough
   XDeathWait:
     POSS U 1 A_CheckSight("XDeathFade")
     loop
   XDeathFade:
     POSS U 1 A_FadeOut(0.02)
     loop
   Raise:
     stop    // not fair to have the monster revivable just because it's in LOS
   }
 }

See also