Damage formula (enemy shooting)Edit
Hitscanning is unique among damage in Wolfenstein 3D in that not one but two calculations are performed, one to determine if a hit actually occurred, and another for damage dealt.
The following variables are used:
- Random integer between and including the numbers 0 and 255. Every time this variable is mentioned is a different call to the function, and a different random number, even within formulas.
- The distance between the player and the enemy. Multiplied by two-thirds if the enemy shooting is Hans Grösse or an SS ("ss are better shots").
- Output of the first formula, used to determine if a hit occurred.
- base damage
- Output of the second formula and input of TakeDamage, will be divided by four if the player is on lowest difficulty level.
Note the floor function around the division—due to the use of bit shift rather than true division, the output is rounded down. This allows the player's health to never stray from being a whole number. The maximum damage (255/4) is therefore 63 rather than 63.75. The minimum is zero, even with a successful hit.
As with all damage to the player, the actual damage received is one-fourth of the base damage if the player is playing at "Can I play, Daddy?" difficulty. Save for godmode, the two are otherwise equal.
Damage formula (player shooting)Edit
- ↑ WOLFSRC/WL_ACT2.C from the Wolfenstein 3D source code on github.com, line 3444
- ↑ WOLFSRC/ID_US_A.ASM from the Wolfenstein 3D source code on github.com
- ↑ WOLFSRC/WL_ACT2.C from the Wolfenstein 3D source code on github.com, line 3461
- ↑ 4.0 4.1 WOLFSRC/WL_AGENT.C from the Wolfenstein 3D source code on github.com, line 392
- ↑ WOLFSRC/WL_AGENT.C from the Wolfenstein 3D source code on github.com, line 1168