A_LookEx

From ZDoom Wiki
Jump to: navigation, search

A_LookEx (int flags, float minseedist, floatmaxseedist, float maxheardist, double fov, state label)

Usage

This is a customizable version of A_Look, allowing for enemies which can only see or hear a target under given conditions. Just like with A_Look, if you set this on a friendly monster, it will make the monster enter the specified state even if it does not have a target. The STANDSTILL actor flag can be used (and is pretty much required) with this function to prevent this behavior.

Note: In order for A_LookEx to function correctly, the actor calling it must have either the seestate, or a “See” state defined.

Parameters

  • flags: Controls miscellaneous aspects of the monster's behavior while looking for targets. Use | to use multiple flags at once.
    • LOF_NOSIGHTCHECK — do not process sight checks (makes monster blind).
    • LOF_NOSOUNDCHECK — do not process sound target checks (makes monster deaf).
      • Note: this is not the same as using AMBUSH: When the AMBUSH flag is specified for a monster, if the player makes a sound in the same room (and in range of the monster if maxheardist is set), the monster will react to the player if they walk within the monster's current line of sight, regardless of the direction it is facing (FOV is ignored). This flag will make the monster completely deaf, preventing it from reacting to the player at all, regardless of the sounds they make.
    • LOF_DONTCHASEGOAL — do not leave to chase after a goal from this state, even if the actor has one. This can be used to prevent a monster from breaking from its idle animations to walk over to a goal.
    • LOF_NOSEESOUND — do not play the actor's sight sound if it wakes up from this state.
    • LOF_FULLVOLSEESOUND — Play the see sound globally at full volume (like a boss).
    • LOF_NOJUMP — acquire a target, but do not jump to any other state, allows to check the target and jump manually into the See state based on conditions without interrupting the idle animation.
  • minseedist: the minimum sight distance of the monster in map units. If this is greater than 0, the monster will not see a player who is closer than this. If this is set, the monster also will not wake up if touched by the player (so it can be set smaller than the radius to prevent the monster from reacting if the player comes up from behind).
  • maxseedist: the maximum sight distance of the monster, in map units. It will not see any players farther away than this. 0 means unlimited (as in Doom). Note that friendly monsters have a hard cap of 1280 map units for performance reasons.
  • maxheardist: the maximum hearing range of the monster, it will not react to sounds from players farther away than this. 0 means unlimited (as in Doom).
  • fov: the field of view of the monster. A narrower FOV means the player has to be more centered in front of the monster for it to notice the player. Setting this to 0 uses the old default of 180 degrees, while smaller values make the FOV narrower and larger values wider. 360 means look in all directions and is the same as LOOKALLAROUND with an FOV of 0.
  • label: The state the monster will jump to if it acquires a target. Default is “See”.

Examples

The actor in the following example is totally deaf, and can not see targets more than 256 map units away. It jumps to the custom state “WakeUp” upon acquiring a valid target.

 actor ImpairedZombie : ZombieMan
 {
   states
   {
   Spawn:
     POSS A 1 A_LookEx(LOF_NOSOUNDCHECK, 0, 256, 0, 0, "WakeUp")
     loop
   WakeUp:
     POSS A 1 A_AlertMonsters
     goto See
   }
 }

The following actor, in addition to being totally deaf, has a limited field of vision (30 degrees) and will not detect targets closer than 32 map units to it. Its seesound is played at full volume upon waking up.

 actor SecuritySoul : LostSoul
 {
   SeeSound "misc/alarm"
   states
   {
   Spawn:
     SKUL A 1 A_LookEx(LOF_NOSOUNDCHECK | LOF_FULLVOLSEESOUND, 32, 0, 0, 30, "See")
     loop
   }
 }

Note that in both these cases, the actor will regain full hearing and vision upon waking up, like a regular Doom monster. To check FOV while currently chasing a target, see A_JumpIfTargetInLOS. To check for distance from a current target, see A_JumpIfCloser.