m (→Horizontal autoaim: clean up) |
mNo edit summary Tag: Visual edit |
||
(One intermediate revision by the same user not shown) | |||
Line 19: | Line 19: | ||
if (!linetarget) |
if (!linetarget) |
||
{ |
{ |
||
− | + | an -= 2<<26; |
|
− | + | slope = P_AimLineAttack (source, an, 16*64*FRACUNIT); |
|
} |
} |
||
if (!linetarget) |
if (!linetarget) |
||
{ |
{ |
||
− | + | an = source->angle; |
|
− | + | slope = 0; |
|
} |
} |
||
} |
} |
||
Line 33: | Line 33: | ||
[[Category:Doom engine]] |
[[Category:Doom engine]] |
||
− | [[Category:Weapons]] |
Latest revision as of 20:05, 24 August 2019
This article is a stub. Please help the Doom Wiki by expanding it.
Vertical autoaim
Since you can't look up or down in Doom or Doom II, the system compensates for you. Accuracy is not affected by the differences in the Z-axis co-ordinates of the player and target. However, vertical autoaim will only work against targets that are within a certain distance from the player; if the target is too far away, vertical autoaim will not take effect.
Horizontal autoaim
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°.