• Hey Trainers! Be sure to check out Corsola Beach, our newest section on the forums, in partnership with our friends at Corsola Cove! At the Beach, you can discuss the competitive side of the games, post your favorite Pokemon memes, and connect with other Pokemon creators!
  • Due to the recent changes with Twitter's API, it is no longer possible for Bulbagarden forum users to login via their Twitter account. If you signed up to Bulbagarden via Twitter and do not have another way to login, please contact us here with your Twitter username so that we can get you sorted.

Damage calculation

CptMath

New Member
Joined
Dec 17, 2007
Messages
1
Reaction score
0
Hello,

I noticed that while the wiki is quite excellent, it does lack a damage calculation formula. I know this will cause me to be burned, but serebii actually got this one right. The problem is theirs doesn't take into consideration critical hits and doesn't say very accurately how you're supposed to use it. I have independently verified that the damage calc is right by loading Pokemon Diamond into a debugger and checking the assembly code for it.

Here's the precise calculation that Pokemon performs, excluding the extra part for criticals and weather.

Round((Round(A*Attack/B) * Move Base Damage * ( Round(Level*2/5) + 2 ) * Round((Round((Round(D/E))/Defense))/50) + 2) * STAB) * Random Number / 100) * Weak/Strong against modifier

Or, to say it more clearly,

((A*Attack/B) * Move Base Damage * (Level*2/5 + 2) * D/(Defense * 50 * E) + 2) * STAB * Random Number / 100 * Weak/Strong

Just note that every time it performs a division, it performs truncation (I guess I shouldn't have used the term round). In other words, if level is 4, level*2/5 is 1 (8/5 truncates to 1). If it's 2, level*2/5 is 0. You get the idea.

Random Number is a random number between 85 and 100. In fact, it starts out as a number between 0 and 15 and is subtracted from 100 to get the final result. Another note is that if the random number would cause a very weak attack to truncate to 0, it instead is set to 1.

A is a power increasing modifier. It starts out as 10. Swords Dance increases A, for example.

B is a power decreasing modifier. It starts out as 10. Growl increases B. Note that increasing the denominator decreases the result.

D is a defense decreasing modifier. It starts out as 10. Leer increases D. By increasing D, you increase the result of the calculation, or in other words, more damage.

E is a defense increasing modifier. It starts out as 10. Harden increases E. Increasing E means that the damage done is smaller (denominator increased).

None of A, B, D, or E can go below 10. This is done to make the truncation cleaner. When you use leer, for example, D goes from 10 to 15.

I still haven't tested weather to see where it gets thrown in here. I have sort of figured out how criticals work but not enough to confidently write it down.

Enjoy.

Edit: Let me be a little clearer about what is truncated.

A * Attack / B is truncated.

Level * 2 / 5 is truncated.

E * Defense / D is truncated.

(dmg calc so far) / the truncated result of E * Defense / D is truncated. The so far meaning that the parts involving attack, level, and base damage are taken it at this point. Note that dividing by E * Defense / D is the same as multiplying by D / E * Defense normally, but with the extra truncation, the difference is important.

The result of the above truncation / 50 is truncated. It's important to keep track of each truncation that happens because each time you lose a little precision.

Random Number * Damage / 100 is truncated. Again, if you have RN = 85, Dmg = 1, then rather than getting 0, you get 1.
 
Last edited:
Please note: The thread is from 16 years ago.
Please take the age of this thread into consideration in writing your reply. Depending on what exactly you wanted to say, you may want to consider if it would be better to post a new thread instead.
Back
Top Bottom