A_LookEx

From ZDoom Wiki
Jump to navigation Jump to search


Actor

void A_LookEx(int flags = 0, double minseedist = 0, double maxseedist = 0, double maxheardist = 0, double fov = 0, statelabel label = null)

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

  • int flags
Controls miscellaneous aspects of the monster's behavior while looking for targets. Use | to use multiple flags at once. The following flags are available:
  • 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.
  • double 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).
  • double 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.
  • double 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).
  • double 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.
  • StateLabel label
The state the monster will jump to if it acquires a target. Default is null which is interpreted as "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.

class ImpairedZombie : ZombieMan
{
  States
  {
  Spawn:
    POSS A 1 A_LookEx(LOF_NOSOUNDCHECK, maxseedist: 256, label: "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 plus its radius to it. Its seesound is played at full volume upon waking up.

class SecuritySoul : LostSoul
{
  Default
  {
    SeeSound "misc/alarm";
  }
  States
  {
  Spawn:
    SKUL A 1 A_LookEx(LOF_NOSOUNDCHECK|LOF_FULLVOLSEESOUND, radius + 32, fov: 30, label: "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 Distance2D, Distance3D and A_JumpIfCloser.

See also