Difference between revisions of "Melee attack"

From DoomWiki.org

[unchecked revision][checked revision]
(+external link)
m (fix some stuff)
 
(18 intermediate revisions by 10 users not shown)
Line 1: Line 1:
'''Melee''' is a word borrowed from French (''mêlée'', pronounced ''MAY LAY'') meaning hand-to-hand, close-quarters combat. Melee attacks are in contrast to ''ranged attacks'', performed at a distance, such as shooting [[bullet]]s, throwing [[fireball]]s or firing [[rocket]]s.
+
'''Melee''' is a word borrowed from [[Wikipedia:French language|French]] (''mêlée'', [[Wikipedia:IPA chart for English|pronounced]] /mε'lε/) meaning hand-to-hand, close-quarters combat. Melee attacks are in contrast to ''ranged attacks'', performed at a distance, such as shooting [[bullet]]s, throwing [[fireball]]s or firing [[rocket]]s.
  
A number of the Doom [[monsters]] can perform melee attacks in the form of clawing, biting or (in one case) punching. In fact, [[Demon]]s, [[Spectre]]s and [[Lost Soul]]s have only melee attacks. 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]].
+
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 attackers only, but in fact the game treats them like living [[projectile]]s.
  
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.
+
== Technical ==
  
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 the [[Doom source code]], there is a constant {{c|MELEERANGE}} defined as {{c|64*FRACUNIT}}. 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 {{c|MELEERANGE}} 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.
  
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:
+
For monsters that have melee attacks, the function {{c|P_CheckMeleeRange}} is called, and it returns {{c|true}} if a melee attack will be successful. If so, damage is inflicted immediately; if not, a ranged attack (if any) is launched.
 +
 
 +
In {{c|P_CheckMeleeRange}}, {{c|P_AproxDistance}} 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)
 
     if (dist >= MELEERANGE-20*FRACUNIT+pl->info->radius)
 
     return false;
 
     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 target.
+
This returns {{c|false}} 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, {{c|P_CheckSight}} is called to ensure that nothing is in between the attacker and the target.
 +
 
 +
==See also==
 +
* [[Hitscan]]
 +
* [[Fireball]]
  
 
==External links==
 
==External links==

Latest revision as of 13:41, 8 July 2018

Melee is a word borrowed from French (mêlée, pronounced /mε'lε/) meaning hand-to-hand, close-quarters combat. Melee attacks are in contrast to ranged attacks, performed at a distance, such as shooting bullets, throwing fireballs or firing rockets.

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. Demons and spectres are melee attackers only, while others have both melee and ranged attacks—these are the imp, cacodemon, revenant, Hell knight and baron of Hell. Players can perform melee attacks using the fists or the chainsaw. Lost souls may be seen like melee attackers only, but in fact the game treats them like living projectiles.

Technical[edit]

In the Doom source code, there is a constant MELEERANGE defined as 64*FRACUNIT. 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 MELEERANGE 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 P_CheckMeleeRange is called, and it returns true if a melee attack will be successful. If so, damage is inflicted immediately; if not, a ranged attack (if any) is launched.

In P_CheckMeleeRange, P_AproxDistance 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 false 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, P_CheckSight is called to ensure that nothing is in between the attacker and the target.

See also[edit]

External links[edit]