Damage

Damage is anything that causes B.J. Blazkowicz or an enemy to lose health. Damage may arise from being shot by an enemy, or bitten by Dogs, through attacks with projectiles, or by contact with Ghosts. Too much damage and they will die. This article explains the mechanics behind various enemy attacks on the player in Wolfenstein 3D and Spear of Destiny, as well as player attacks on the enemy.
==Factors that affect damage==
Various kinds of attacks calculate how much damage is dealt differently. The following factors affect the damage dealt:
===Random numbers===
The primary decisive factor is that of two random numbers, each of which is between, and including, 0 and 255.
===Difficulty===
Playing on “Can I play, Daddy?” difficulty divides all damage you take by four.
===Enemy Type===
SS guards and Bosses are considered better shots in the game, so for any calculations the distance used for calculating hit or damage is reduced by one third.
===Distance===
The further away you are, the lesser chance of the enemy hitting you, and the less damage you will take. This only applies to hitscans.
===Speed===
If the player is running, the enemy’s chance of hitting you is reduced. This only applies to hitscans.
===Looking===
If you can see the enemy shooting at you, you have half as much chance of being hit as if they are shooting you from out of the player’s view. This is because the game assumes B.J. would be more likely to ‘see’ the enemy shooting at him and would try to dodge the shot. This only applies to hitscans.
==Hit Formulae==
The following variables will be referred to:
;[DIST]
:Distance between enemy and player (in number of squares).
;[SPEED]
:160 (if player is running) or 256 (if player isn't).
;[LOOK]
:16 (if player can see the shooter) or 8 (if the player can’t).
;[RAND1]
:A random number between 0 and 255 (inclusive). Used for hit calculation.
;[RAND2]
:A second random number between 0 and 255 (inclusive). Used for damage calculation.
===Hitscans===
:Main article:Hitscan
Hitscans are the game's method of calculating bullets. There are two calculations for hitscans: one to determine if the player is hit, followed by one to determine how much damage is dealt.
The Formula to calculate a hit is:
 If shooter is SS or Boss then: [DIST] = [DIST] x (2 / 3)
 
 Player is considered hit if: [RAND1] < ( [SPEED] - ( [DIST] x [LOOK] ) )
If the player is hit then the second calculation is performed to determine how much damage the player will take. The Formula to calculate damage is:
 If shooter is SS or Boss then: [DIST] = [DIST] x (2 / 3)
 
 
 If ( [DIST] less than 2 ) then damage is: [RAND2] / 4
 
 If ( [DIST] between 2 and 4 ) then damage is: [RAND2] / 8
 
 If ( [DIST] is 4 or more ) then damage is: [RAND2] / 16
 
 
 If “Can I play daddy” then [DAMAGE] = [DAMAGE] / 4
====Example====
The player is shot at by a normal guard from 2 squares away. The player can see the shooter, but was only walking at the time. The first random number is 69.
 [RAND1] < ( [SPEED] - ( [DIST] x [LOOK] ) )
 
 69 < (256 - (2 x 16))
 
 69 < (256 - 32)
 
 69 < 224
The statement is true so the player received a hit! Now to calculate damage. The second random number is 140. The distance was 2, so the formula is:
 [RAND2] / 8
 
 140 / 8
 
 17.5
Due to the use of bit shift the result is rounded down to 17. Therefore the player would lose 17 health as a result from the guard shooting the player in this example.
===Bites===
Dogs can only attack when the player is in the adjacent square using the following formula:
 Player is bitten if [RAND1] < 180 
 
 Damage taken = [RAND2] / 16
===Projectiles===
Many characters shoot projectiles, including Fake Hitlers, Dr Schabbs, General Fettgesicht and Otto Giftmacher .
The player can dodge these projectiles so no calculation is done to determine hit chance, only damage:
 Needle damage = ( [RAND2] / 8 ) + 20
 
 Rocket damage = ( [RAND2] / 8 ) + 30
 
 Fireball damage = ( [RAND2] / 8 )
===Ghosts===
Ghosts and Spectres only do damage upon contact with the player:
 Damage = 10
==Player shooting==
The formula used to determine the damage given to an enemy by the player is as follows:
===Knife===
 [DAMAGE] = [RAND2] / 16
===Gun===
 If ( [DIST] is 4 or more ) then only hit if ( ( [RAND1] / 12 ) < [DIST] ).
 
 
 If ( [DIST] is less than 2 ) then [DAMAGE] = [RAND2] / 4
 
 If ( [DIST] is 2 or more ) then [DAMAGE] = [RAND2] / 6
==References==
nl:Player damage mechanics
Category:Wolfenstein 3D engine