Autoaim

From DoomWiki.org

Under construction icon-yellow.svgThis article or section is a stub. Please help the Doom Wiki by adding to it.

Vertical autoaim[edit]

In Doom and Doom II, the player is limited in their ability to look, as they can only look left or right, not up or down. The ability to look up or down is called free look, and is added by some source ports. But in vanilla Doom and source ports without free look, the player's inability to aim up or down is adjusted for by the game. This is very noticeable with the rocket launcher and cacodemons, because of the former's slow-moving, obvious projectile, and the latter being able to float high above the player's level.

Horizontal autoaim[edit]

The player's projectile weapons have a limited ability to adjust their direction if the nearest target is not exactly straight ahead. From P_SpawnPlayerMissile in p_mobj.c:

   // see which target is to be aimed at
   an = source->angle;
   slope = P_AimLineAttack (source, an, 16*64*FRACUNIT);
   
   if (!linetarget)
   {
       an += 1<<26;
       slope = P_AimLineAttack (source, an, 16*64*FRACUNIT);
   
       if (!linetarget)
       {
           an -= 2<<26;
           slope = P_AimLineAttack (source, an, 16*64*FRACUNIT);
       }
   
       if (!linetarget)
       {
           an = source->angle;
           slope = 0;
       }
   }

An angle in the Doom engine is 32 bits, so that 1<<26 = 360° × (226 ÷ 232) ≈ 5.6°.