A FaceTarget

A_FaceTarget is a code pointer used in the melee attack and attack animations for various monsters.

True to its name,  changes the angle of the monster it is called on to be facing in the direction of its target; if it has no target, it does nothing. This is important for attack animations so that the monster appears to observers be attacking the right thing, but for hitscanners it also sets the direction in which the monster shoots. This is not the case for projectile launchers where the aiming calculation is done separately.

If the target has invisibility (an example is due to the Partial invisibility, but also if the target is an invisible monster like the Spectre), a random offset is added to the angle so that the monster appears to be attacking the wrong location. This has different effects depending on the monster:


 * For melee attacks such as the Demon, it is entirely cosmetic. Although the monster may appear to be facing the wrong way there is no effect on the damage done to the target.
 * For hitscan attacks, the monster can end up facing and firing in the wrong direction (although the two will match)
 * For projectile launchers, the direction that the monster appears to be facing and the direction that the projectile is launched are independent. Both are independently fuzzed due to the invisibility effect.

Uses
The  code pointer appears in the following states in Doom's state table:

Example
The following is an example of how to set the  code pointer in a Dehacked file:

Pointer 21 (Frame 34) Codep Frame = 739

Or using BEX syntax:

[CODEPTR] Frame 1234 = FaceTarget