In Pokecheck's VS. Player, we calculate the final modifier in pieces based on if situation->then chain each modifier with current modifier step by step.
I'd just gather up all the modifiers that you have to chain and then loop through them. You can't do it all in one calculation as the bitshifting drops an (albeit small) fraction of the number each time.
Modifier chaining is rounded @ 0.5, and every other calc is rounded down. You're doing it right for the first half when modifiers are involved, but when you calculate final damage after altering with the random factor you're supposed to drop any decimal.
"D' = (D * (100-R)) ÷ 100"
remember, "In this article, ÷ always denotes the in-game unsigned divmod function, i.e. the unrounded/truncated integer division."
Honko has programmed his damage calculator to use the BW damage formula, you can see how all the damage chaining works here.
Hi, I'm having some troubles with the damage formula for BW. So, if you could clarify a few areas, that would be great ^^;
a) For chaining modifiers, it says that when multiple triggers apply, you have to chain the modifier for the parameter, starting from 0x1000. The example given is: M' = ((M * M') + 0x800) >> 12 - Can this be generalized to find the results of chaining any amount of modifiers? Or is it recursive i.e. to find M'''' we would need to know M''' and M'' ?
b) Also, can we go through an example to make sure I've understood it correctly?
Gen IV uses the same RNG as gen III, which has been researched thoroughly by FractalFusion and the Tool Assisted Speedrun community. They even share the same Method of Wild Pokemon generation, except the way the screen refresh was programmed in GBA games requires a consumption of the RNG, which skews the method.
Sure the random number output may output reasonable distributions, but that's not how Gen III-V games do their calculations.
Back in the early days of DP, people didn't have access to emulators or debuggers to see how the game actually calculated things. Now that we do, we can be exact with our formulas as we know what numbers are fed to the RNG.
When I did my tests I did the same exact formula, it did line up mostly, but I tested the discrepancies and the *16/%16 calc was correct (not the gen2)
Kaphotics, X-Act might not have been wrong about the damage formula in DPP – If, according to him, R = (Rand*100)/255 where Rand is between 217 and 255, then the list of all possible values can only be: