Search In
• More options...
Find results that contain...
Find results in...

# bfg9000 trace damage calculation problem

## Recommended Posts

according to various sources including doomwiki and bfg faq, a bfg shot has 40 traces. and for each trace, a pseudo random number between 1 and 8 is generated and repeated 16 times. This makes the total damage vary from 16 to 128, with an average of 72. due to the pseudo random number generator of Doom, the damage is limited to the range of 49 to 87.

however according to the sourcecode listed in the bfg faq, damage of each trace is calculated in this way:

damage = 0;
for (j=0;j<15;j++)
damage += (P_Random()&7) + 1;

isn't the last line executed for 15 times instead of 16? when the value of j is 0, 1, 2... 14, but not executed when j is 15.

It's 0, 1, 2... 15 because of j++.

noshutdown said:

isn't the last line executed for 15 times instead of 16?

True.

Never_Again said:

It's 0, 1, 2... 15 because of j++.

False. That doesn't even make sense.

Yes, that is 15 iterations. So the damage values and histograms on DoomWiki.org are incorrect?

Regarding the wiki histogram, the "source" is obfuscated, but I believe it uses 15 iterations (Mathematica has a very similar loop construct).  So it's only the text that says 16; interestingly, the Hit point article says 15 instead.

Those stats sections have needed sprucing up for years, so it wouldn't exactly be shocking if someone did find an error like that.

## Create an account

Register a new account