Melee attack

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 bullets, throwing fireballs or firing rockets.

A number of the Doom monsters can perform melee attacks in the form of scratching or biting. In fact, Demons, Spectres and Lost Souls have only melee attacks. Others have both melee and ranged attacks&mdash;these are the Imp, Cacodemon, Revenant, Hell Knight and Baron of Hell. Players perform melee attacks using the fists and the chainsaw.

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.

For monsters that have melee attacks, the function P_CheckMeleeRange is invoked, and it returns true if a melee attack is possible. First, P_AproxDistance is called. (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. Finally, P_CheckSight is called to ensure that nothing is in-between the attacker and the target.

All melee attacks are implemented as hitscan attacks.