Register FAQ Social Groups Calendar Search Today's Posts Mark Forums Read

Showing Visitor Messages 1 to 6 of 6
1. Nov 18th, 2012 3:24:58 AM
Thank you, I really appreciate it :>
2. Nov 17th, 2012 7:15:13 PM
Kaphotics
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.

also here's the source for Pokecheck's battle video parser (VS. Player)
3. Nov 17th, 2012 12:37:06 PM
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?

Here's the example:

CB Terrakion Stone Edge vs. Nasty Plot Celebi

BaseDamage = ((((2 * Level) / 5 + 2) * BasePower * [Sp]Atk) / [Sp]Def) / 50 + 2

= ((((2 * 100) / 5 + 2) * 100 * Atk / 236) / 50 + 2

= (42 * 100 * Atk / 236) / 50 + 2

[Atk = 357 * 0x1800 / 0x1000 = 357 * 6144 / 4096 = 535.5 => 536]

= (42 * 100 * 536 / 236) / 50 + 2

= 192

4. Alter with a random factor
5. Apply STAB modifier

Min = (192 * (100 - 15)) / 100 = 163.2 => 163
Max = (192 * (100 - 0)) / 100 = 192

163 * 0x1800 / 0x1000 = 244.5 => 245 (Smogon's Damage Calc would have given 244 as the minimum)
192 * 0x1800 / 0x1000 = 288

4. Aug 27th, 2011 6:33:53 PM
Kaphotics
That's the gen 2 damage formula ;)

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)
5. Aug 27th, 2011 5:28:54 PM
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:

85.09804, 85.4902, 85.88235, 86.27451, 86.66667, 87.05882, 87.45098, 87.84314, 88.23529, 88.62745, 89.01961, 89.41176, 89.80392, 90.19608, 90.58824, 90.98039, 91.37255, 91.76471, 92.15686, 92.54902, 92.94118, 93.33333, 93.72549, 94.11765, 94.5098, 94.90196, 95.29412, 95.68627, 96.07843, 96.47059, 96.86275, 97.2549, 97.64706, 98.03922, 98.43137, 98.82353, 99.21569, 99.60784, 100
6. Aug 27th, 2011 5:28:24 PM