Changes

From DoomWiki.org

Melee attack

1,488 bytes removed, 19:13, 11 March 2009
Technical
Melee attacks are featured in [[Doom]], [[Heretic]], [[Hexen]] and [[Strife]]. A number of the Doom [[monsters]] can perform melee attacks in the form of clawing, biting or punching. [[Demon]]s and [[Spectre]]s are melee attackers only, while others have both melee and ranged attacks—these are the [[Imp]], [[Cacodemon]], [[Revenant]], [[Hell Knight]] and [[Baron of Hell]]. [[Player]]s can perform melee attacks using the [[fists]] or the [[chainsaw]]. [[Lost Soul]]s may be seen like melee atackers only, but infact the program treats them like living [[projectile]]s.
== Technical == In the [[Doom source code]], there is a constant <tt>MELEERANGE</tt> defined as <tt>64*FRACUNIT</tt>. For a player, this means that a melee attack will be successful only if the target is no farther than 64 map units away. Using the [[angle]] the player is facing, the map point <tt>MELEERANGE</tt> units away is determined trigonometrically. Then the [[hitscan]] function is invoked, which will damage the first vulnerable thing (if any) along the line to that point. For monsters that have melee attacks, the function <tt>P_CheckMeleeRange</tt> is called, and it returns <tt>true</tt> if a melee attack will be successful. If so, damage is inflicted immediately; if not, a ranged attack (if any) is launched. In <tt>P_CheckMeleeRange</tt>, <tt>P_AproxDistance</tt> is called first. (Approximate distance is used, presumably, to avoid a time-consuming square root evaluation that calculating distance more precisely would require.) Then, the following code is executed:  if (dist >= MELEERANGE-20*FRACUNIT+pl->info->radius) return false; This returns <tt>false</tt> if the calculated distance from the center of the attacker to the closest edge of the target is greater than or equal to 44 map units. Except for [[monster infighting]], the target will be a player (with radius 16) and melee attacks can occur only when the calculated distance is less than 60 map units. Finally, <tt>P_CheckSight</tt> is called to ensure that nothing is in between the attacker and the targetSight sucks.
==See also==
Anonymous user