# [on site] The Complete Damage Formula for Diamond & Pearl

#### X-Act

##### np: Biffy Clyro - Shock Shock
I would post an HTML version next Thursday, if nobody else would have done it before that day. That's unless I don't end up fixing stuff at my under-construction home.

EDIT: I actually took the time to edit the article a bit with the latest news.

#### chaos

Owner
I think Obi was going to do something with it - drop him a line maybe if you want some help with the conversion

#### X-Act

##### np: Biffy Clyro - Shock Shock
Hopefully the modifications I just made did not mess his conversion too much. I can't start working on this until next Thursday I'm afraid, and that's if I don't end up fixing a good number of door handles at my new home.

#### chaos

Owner
X-Act what would you think about removing superfluous parens?

Damage Formula = (((((((Level × 2 ÷ 5) + 2) × BasePower × [Sp]Atk ÷ 50) ÷ [Sp]Def) × Mod1) + 2) × CH × Mod2 × R ÷ 100) × STAB × Type1 × Type2 × Mod3

Damage Formula = ((Level × 2 ÷ 5 + 2) × BasePower × [Sp]Atk ÷ 50 ÷ [Sp]Def × Mod1 + 2) × CH × Mod2 × R ÷ 100 × STAB × Type1 × Type2 × Mod3

I don't really think they add anything except a lot of arbitrary nesting. Feel free to disagree.

#### X-Act

##### np: Biffy Clyro - Shock Shock
As is also written in the guide, I could actually remove all the brackets altogether and proceed from left to right, working out each operand one by one and rounding down after each step (since that is, I believe, how it works in the game actually), but that wouldn't obey 'BODMAS' rules.

The reason why I added all those brackets is because the answer should be rounded down after performing any division, so I decided to add a pair of brackets for every division that is performed to emphasize this fact(although, admittedly, the bracket following Mod1 is redundant). I could have maybe said in the guide that every division operator performs integer division and not normal division and would have ended up with what you wrote, but I thought that not too many Smogoners are familiar with the concept of 'integer division', so I wrote it that way. (For example, I'm sure that STAB is actually performed by multiplying by 3 and then integer dividing by 2... but that would confuse a few people so I stuck with x1.5 and then rounding down.)

Bottom line - I think the following way has not too many brackets while still explaining what I said above:

Damage Formula = ((((Level × 2 ÷ 5 + 2) × BasePower × [Sp]Atk ÷ 50) ÷ [Sp]Def × Mod1 + 2) × CH × Mod2 × R ÷ 100) × STAB × Type1 × Type2 × Mod3

This way, I'd have a bracket around each division sign.

#### david stone

##### Fast-moving, smart, sexy and alarming.
If the attacker has an Expert Belt and the defender has a resistance berry, which goes first?

#### X-Act

##### np: Biffy Clyro - Shock Shock
It can be proved that the order does not matter. Doing x1.2 and then x0.5 or doing it vice-versa would be indistinguishable.

#### david stone

##### Fast-moving, smart, sexy and alarming.
This is the damage formula as I use it. Are there any errors in this implementation?

Damage=((((((((((((((((level * 2 / 5 + 2) * power * atk / 50) / def) / BRN) / RL) * TVT) * weather) * FF + 2) * CH * ITM) * TL * MF) * (R * 100 / 255) / 100) * STAB) * Type1) * Type2) * AEM) * IEM)

level = Attacker's level
power = Power of the move
atk = Attacking stat
def = Defending stat
BRN = Whether the attacker is Burned
RL = Reflect / Light Screen
TVT = 2v2 modifier
weather = Sunny Day / Rain Dance
FF = Flash Fire
CH = Critical Hit
ITM = Life Orb or Metronome
TL = Tinted Lens
MF = Me First
R = Random integer between 217 and 255 inclusive
STAB = STAB (heh)
Type1 = Effectiveness of first type
Type2 = Effectiveness of second type
AEM = Ability Effectiveness Modifier (Solid Rock and Filter, but excluding Tinted Lens)
IEM = Item Effectiveness Modifier (for instance, Expert Belt or Chople Berry)

Round down after each set of parentheses

What is the order of the defense modifiers? For instance, if you Skill Swap Marvel Scale a Ditto and get it statused, which comes first? Same for Camouflaging / Color Changing / whatever Lati@s into a Rock type during a Sandstorm and similar situations.

/edit: I left out the 2v2 modifier

#### X-Act

##### np: Biffy Clyro - Shock Shock
Apart from the fact that you're using BRN and RL as division modifiers instead of multiplication, that is correct. In Reflect/Light Screen's case, it must be remembered that it is a x2/3 modifier in 2vs2, so in 2vs2 I'd prefer it to be a multiplier. But in 1vs1 it's okay.

About the other question, the only reason this would matter is for Deepseascale Clamperl, since all the other defense modifiers are x1.5, and hence the order of the multiplication doesn't make a difference. Quoting from the guide, if there are two simultaneous boosts in Mod, first apply the ability boost, and then the item boost. Sandstorm's multiplier position is thus the only one we are not sure of.

#### david stone

##### Fast-moving, smart, sexy and alarming.
Which comes first: my own Pure Power / Huge Power or my ally's Flower Gift?

I had Reflect / Light Screen as a division modifier because I set it to divide by 2 in 1v1, or 1.5 in 2v2.

#### X-Act

##### np: Biffy Clyro - Shock Shock
That, I don't know. There are a lot of things which we did not test.

Frankly, after around 1 and a half months testing relentlessly, me and Peterko got bored of it. When we asked for help at around last August, we didn't get any. We were extremely disappointed because of that. I don't really know why nobody offered to do anything to help. Maybe they saw it as boring? (It sure as hell is.) Maybe they saw it as useless? (It sure as hell ISN'T.) Seeing all this lethargy, we decided to stop giving a fuck and just release the damage formula with what we knew, which proved to be extremely accurate anyway, but not 100%.

To give you an idea, it took us around three hours to confirm where the Me First multiplier is. During that time, all that Peterko did is attack every Pokemon he could with Me First. At one point, Peterko told me "this is the very last Pokemon I'm going to hit with Me First". Lo and behold, the damage he did there proved to be the one we needed to find the whereabouts of the Me First multiplier.

I don't know why Peterko wanted to research the damage formula perfectly, but, speaking for myself, I did it so that Competitor would be perfect in its damage calculation. When you calculate damage roughly, you can go wrong by 1% and it wouldn't matter, but for Competitor it's a completely different story. I really don't want to be OHKOed when really I should have survived, and vice-versa. To be even more perfect, I even suggested once that we implement the Pokemon games' RNG for accuracy checking and the damage generation, but the suggestion wasn't upheld.

You might have noticed that I never tested anything else from my DS from last August till now. I just thought "if they want to find out about their ability/move/damage/whatever, just let them find it themselves if they REALLY want the answer to it." I was so disappointed, and still am.

Anyway, I didn't vent this frustration at anyone in particular. I just wanted to spit this out of my mouth so that everyone knows what happened.

#### X-Act

##### np: Biffy Clyro - Shock Shock
I don't know if those are the _only_ things that remain to be tested, but those need to be tested for sure.

EDIT: Oh, there's another one: moves that sometimes do 75% of the damage in 2vs2 and sometimes they don't. We don't know the circumstances that change the damage done.

#### MetalKid

Was Forecast left out on purpose? It will change the Type of Castform (or whoever has it) to the Type of weather in play. This will have an affect on the damage in the end.

#### AJC

forecast only works on castform...it has no effect if another pokemon gains it via trace role play or skill swap

#### MetalKid

True, but if you are trying to calculate damage vs. a Castform, then you will need to know that small bit of information. It isn't mentioned anywhere what his Type changes to in the various weathers.

#### Aldaron

I am helping a friend make a damage calculator right now, and I have to say this was an extraordinarily useful contribution.

Many thanks to X-Act and Peterko for relentlessly pursuing as accurate a formula as they could; it has helped me a lot :)

I wish I had a DS so I could help you test, but I don't, so all I can do is make this a shout out to how useful your efforts have been.

Thanks again.

EDIT: OK, so I actually have a question regarding Dual Types and the Type 1 and Type 2. Let's take Bronzong for example. I calculate that the range for an attack on Bronzong is 87-103, and then I get to the Type 1 part. The attack is a Ghost type; is Type 1 Steel or Psychic? If it is Steel, my range goes from 87-103 to 86-102, because 87 * .5 = 43.5 or 43, and 43*2 = 86. However, if Type 1 is Psychic then it is still 87-103. I can't find this in the post, I apologize if you have it in there >_<

#### david stone

##### Fast-moving, smart, sexy and alarming.
[19:49] <Obi> Each Pokemon has that set
[19:49] <Obi> Type1 is the type listed first
[19:49] <Obi> Type2 is the type listed second

In other words, look it up in a Pokedex.

#### chaos

Owner
bumpers for my own purposes (writing the smogon official damage calculator)

has this been htmlized yet? i dont think so. it's one of our best guides

#### david stone

##### Fast-moving, smart, sexy and alarming.
I would rewrite the formula to remove Mod1, Mod2, and Mod3 and replace them with the variables they contain, because as it's written now, the guide gives technically incorrect information. This is because you are supposed to round down, but as written, Mod2 will never be influenced by Life Orb (1.3, round down to 1...), for example. For this reason (and because I hate having to reference another spot to see what is in each mod), I use the damage formula as follows:

Damage = (((((((((((((((((level * 2 / 5 + 2) * power * atk / 50) / def) / BRN) / RL) * weather) * FF + 2) * CH * item) * TL * MF) * (R * 100 / 255)) / 100) * STAB) * Type1) * Type2) * AEM) * EB) / RB)

Where
power = move's power
atk = attacking stat
def = defending stat
BRN = burn modifier
RL = Reflect / Light Screen
weather = weather modifier
FF = Flash Fire
CH = Critical Hit
item = Life Orb or Metronome
TL = Tinted Lens
MF = Me First
R = random number between 217 and 255, inclusive
STAB = Same-Type Attack Bonus (STAB)
Type1 = effectiveness on the defender's first type
Type2 = effectiveness on the defender's second type
AEM = Ability Effectiveness Multiplier (Solid Rock, Filter)
EB = Expert Belt
RB = Resistance Berries (including Chilan Berry, the "Normal resist" Berry)

All parenthesis are optional if you just follow as the guide says and round down after each step, except those surrounding the random number portion. You need to round the random portion to get a number between 85 and 100, then multiply that by the previous number and divide by 100 (and round down). Other than that, it's rounded in the order it's written.

#### chaos

Owner
Or, instead of using parens, use actual floor symbols &lfloor; and &rfloor; (U-230A, U-230B)

I'll admit, the Mod stuff was kind of inconvenient when studying the algorithm. There seems to be a lot of information to cover though...

#### X-Act

##### np: Biffy Clyro - Shock Shock
You can also, as I say in the guide, omit all parentheses altogether and just proceed from left to right, remembering to floor every result in so doing.

I was going to HTMLise this but Obi said he would, so I didn't. I wouldn't mind if ryubahamut did the HTMLising though.

You can also do it as Obi says, but I preferred using Mod1, Mod2 and Mod3 to simplify the equation slightly.