Programming Pokémon Showdown Damage Calculator

FriendOfMrGolem120

aka. FOMG
is a Forum Moderatoris a Community Contributoris a Contributor to Smogonis a Battle Simulator Moderatoris a Past SPL Champion
Moderator
The damage calculator says that in Gen 2, Hydro Pump from a level 50 Starmie is a guranteed OHKO against a full health level 50 Marowak, displaying the roll like this: Starmie Hydro Pump vs. Marowak: 158-186 (95.1 - 112%) -- guaranteed OHKO
Interestingly enough, if you take off Hidden Power from Marowak (which only adjusted the attack and physical defense DVs), it shows more accurate odds: Starmie Hydro Pump vs. Marowak: 158-186 (95.1 - 112%) -- 71.8% chance to OHKO
CalcError.png
 

cherryb0ng

formerly Makkususu
The damage calculator says that in Gen 2, Hydro Pump from a level 50 Starmie is a guranteed OHKO against a full health level 50 Marowak, displaying the roll like this: Starmie Hydro Pump vs. Marowak: 158-186 (95.1 - 112%) -- guaranteed OHKO
Interestingly enough, if you take off Hidden Power from Marowak (which only adjusted the attack and physical defense DVs), it shows more accurate odds: Starmie Hydro Pump vs. Marowak: 158-186 (95.1 - 112%) -- 71.8% chance to OHKO
I noticed this with other calcs as well, though I don't recall which ones. I may provide examples in the future of the percentage of KO threshold misrepresenting the amount of a pokemon's health a certain attack depletes
 

Martin

cute cute
is a Forum Moderatoris a Community Contributoris a Live Chat Contributoris a Contributor to Smogon
Moderator
You may have given a reason for why the calculator does this instead of calculating correctly in the past that I can't find, in which case I apologise, but the way multi-hit moves interact with Multiscale/Shadow Shield on the calculator is currently incorrect. This was reported twice in 2019, first by DaWoblefet in July as part of a big Parental Bond fix and then later by DrPumpkinz in November in relation to Icicle Spear in a report that appears to have been buried. I also checked the old thread in IS and there wasn't anything about it in there.

I was doing some calcs of Double Iron Bash vs Multiscale Dragonite and thought the numbers looked wrong, so I checked each hit independently using a modified Iron Head and it was doing what I thought: if the Pokémon's HP is at 100%, Multiscale/Shadow Shield will weaken both hits of the move instead of only weakening the first, resulting in an output which is 3/5 of the correct value:

Tested: Melmetal (OU Protect) vs Dragonite (OU Dragon Dance)
Calculator output: 144–172 (unfavourable chance to 2HKO)
Correct output: (80+160)–(95+190) = 240–285 (guaranteed 2HKO)

After checking this, I checked a few other multi-hit moves and got the following results:

Tail Slap: Incorrect
Tested: 252 Atk Cinccino Tail Slap (5 hits) vs. 0 HP / 0 Def Multiscale Dragonite: 85-105 (26.3 - 32.5%)
Calculator output: 85–105 (guaranteed 4HKO)
Correct output: (17+4(34))–(21+4(42)) = 153–189 (favorable chance to 2HKO)

Triple Axel: Incorrect
Tested: 252 Atk Cinccino Triple Axel (40 BP) (3 hits) vs. 0 HP / 0 Def Multiscale Dragonite: 222-264 (68.7 - 81.7%) -- approx. 2HKO
Calculator output: 222–264 (guaranteed 2HKO)*
Correct output: (38+148+224)–(46+176+264) = 410–486 (guaranteed OHKO)

*it also seems to calculate it as 40,40,40 instead of 20,40,60. This would cause problems even if Multiscale did work correctly, as the first hit would need to be half of a 20 BP hit: not half of a 40 BP hit.

Parental Bond: Correct
Tested: 252+ Atk Parental Bond Kangaskhan-Mega Double-Edge vs. 0 HP / 0 Def Multiscale Dragonite
Calculator output: 163–193
Correct output: (109+⌊0.25(219)⌋)–(129+⌊0.25(258)⌋) = 163–193

Surging Strikes: Incorrect
Tested: 252 Atk Choice Band Urshifu-Rapid-Strike Surging Strikes (3 hits) vs. 0 HP / 4 Def Shadow Shield Lunala on a critical hit:
Calculator output: 279–327
Correct output: (51+2(102))–(60+2(121)) = 255–302

As you can see, while this was corrected on Parental Bond following DaWob's bug report, no other multi-hit moves that I tested work correctly, resulting in large inaccuracies with the damage outputs. Especially considering that both Melmetal and Dragonite currently reside in the same tier, this issue needs fixing with regards to both the Multiscale interaction and how Triple Axel and Triple Kick have their damage calculated. I haven't tested any other generations, but I'm going to presume that the code was ported forward and that the bug, therefore, persists backwards.

Also, while I'm still thinking about it, it'd be nice if, after fixing Triple Axel/Triple Kick, you could to add the option to check how much damage they would do if they only hit once or twice, as each hit has that trolly independent accuracy check that cancels any subsequent attacks when it fails.
 
Last edited:
Maybe this is a problem only in old generations. I found the bug when I was using the gen 4 calculator.
yeah that's it, tried it myself and the damage didn't change at all, works in every other gen. Probably related to how it's a smaller damage modifier in gen 4 than every other gen. (I believe 10% boost per attack in gen 4 and 20% in the rest)
 
It's not a bug from Showdown! exactly, more like a bug I discovered onto the damage calculator, about the Utility Umbrella mechanics. It's supposed to ignore effects from rain/sun, especially damage boosts/nerfs, and that's where it's broken : the calculator don't count it. Playing Ubers, rain is especially important and an important calc is broken so :
calc broken.JPG
What actually should be calculated is : 252 SpA Choice Specs Kyogre Water Spout (150 BP) vs. 240 HP / 0 SpD Eternatus: 213-251 (44.2 - 52.1%) -- 17.2% chance to 2HKO
You can find a replay showing that Showdown! itself does the good damage calculation there, I used the 252 Spa / 252 Spe Specs Timid Kyogre against a 252 HP / 252 SpA Modest Eternatus in both teams. The only thing that I changed is the Utility Umbrella on Eledyyr's Eternatus, and we can
see the reduced damages taken.
 
Last edited:
The calculator behaves incorrectly for some pokemon with damage-boosting abilities (e.g. Iron Fist, Adaptability). It seems to be that if the pokemon has an ability like this in its first slot, the calculator will apply that ability if "(other)" is selected (including from selecting a blank set). See screenshots:
Screenshot 2021-02-24 175017.png
Screenshot 2021-02-24 175041.png
 

Ununhexium

sons of a battlecry
is a Social Media Contributoris a Forum Moderatoris a Contributor to Smogon
Moderator
any chance you could add a feature to add a turn of Protect as an option to accumulate extra Leftovers / Black Sludge / Poison Heal recovery? for example it may have a 10% chance to 2HKO but if you Protect in the middle it would drop to 0
 

SparksBlade

is a Forum Moderatoris a Community Contributoris a Battle Simulator Driver
Moderator
double post cos completely different purpose+don't want any devs to miss it due to an edit

A button in damage calc to deactivate all special conditions. Instead of unselecting rain+light screen+2 spikes etc, just a button to put all of those back to default. I suggest including dynamax, crits, z moves, and the number of hits for multi hit moves in this as well.
 

Martin

cute cute
is a Forum Moderatoris a Community Contributoris a Live Chat Contributoris a Contributor to Smogon
Moderator
Magic Guard isn't currently programmed to ignore Sticky Barb for some reason:

252 SpA Choice Specs Dragapult Shadow Ball vs. 252 HP / 0 SpD Clefable: 178-211 (45.1 - 53.5%) -- guaranteed 2HKO after Sticky Barb damage

There doesn't appear to be any info regarding the interaction with MG on the Showdown/Smogon dexes, but MG users seem to be immune in battles on Showdown and Bulbapedia says that it is ignored by Magic Guard, so I figure it's just an unintended omission.

=================

Also lmk if part of this is an actual mechanic that I don't know about, but the damage calc will ALWAYS give Zacian, Zamazenta, Zacian-C, and Zanazenta-C +1 regardless of whether they have Intreped Sword/Dauntless Shield or not and, regardless of whether this is supposed to happen, Dauntless currently does not work correctly.

To check whether this was just a bug that arises when removing the ability, I manually edited Cobalion's stats to match those of Zamazenta-C and had the two use Close Combat on each other and non-DS Zama-C had the same damage calc as Cobalion:

252+ Atk Zamazenta-Crowned Close Combat vs. +1 64 HP / 0 Def Cobalion: 312-368 (91.4 - 107.9%) -- 50% chance to OHKO
252+ Atk Cobalion Close Combat vs. +1 64 HP / 0 Def Zamazenta-Crowned: 312-368 (91.4 - 107.9%) -- 50% chance to OHKO

I then checked against a blank set Zama-C and it appears the +1 is still said "vs +1 Zamazenta-Crowned" even when Dauntless Shield wasn't on it in the first place:

0 Atk Zamazenta-Crowned Close Combat vs. +1 0 HP / 0 Def Cobalion: 236-278 (72.6 - 85.5%) -- guaranteed 2HKO
0 Atk Cobalion Close Combat vs. +1 0 HP / 0 Def Zamazenta-Crowned: 236-278 (72.6 - 85.5%) -- guaranteed 2HKO

I tried going to Aboma and then back to Zama in case it was just a bug going from one Zac set to another and it persisted.

I then removed Dauntless Shield from the Cobalion and checked the Zama CC calc again. The +1 vanished from the text but the damage stayed the same:

0 Atk Zamazenta-Crowned Close Combat vs. 0 HP / 0 Def Cobalion: 236-278 (72.6 - 85.5%) -- guaranteed 2HKO

I then manually applied +1 Def and the damage decreased as expected:

0 Atk Zamazenta-Crowned Close Combat vs. +1 0 HP / 0 Def Cobalion: 158-188 (48.6 - 57.8%) -- 95.7% chance to 2HKO

Finally, I checked regular Zamazenta and, like Zama-C, the +1 text without any real boost was automatically applied regardless of whether it had Dauntless Shield or not.

TL;DR:
  • Zamazenta and Zamazenta-C have been hard-coded to have the effect of Dauntless Shield applied to the calc text but the output is otherwise unaffected
  • Dauntless Shield automatically applies the +1 calc text but the boost isn't ever substituted into the output formula
I've not done a comparison with a fake Zacian/Zacian-C for Intreped Sword, but I assume it's been implemented in the same way considering the same text bug appears for both Zacs regardless of whether they have Intreped Sword or not. The damage seems to work correctly for these though.
 
Last edited:
Multiscale and Shadow Shield currently do not reduce damage if the "Stealth Rock" button is selected, even if Heavy Duty Boots are worn. The same is true for Spikes, provided the pokemon in question is not immune to them (i.e. not a Flying-type).
On a side note could these abilities get a checkbox like Intimidate has?
 
The calculator considers multi-hits moves (eg. Dual Wingbeat) entirely halved by attack-reducing berries (eg. Coba Berry) instead of halving only the first hit.

252+ Atk Ninjask Dual Wingbeat (2 hits) vs. 0 HP / 0 Def Coba Berry Ninjask: 210-248 (79.8 - 94.2%) -- approx. 2HKO
This should deal around 120% (40+80%) or more in reality.
Lost a Same Solo tournament because of it :c
Code:
Ninjask @ Coba Berry
Ability: Speed Boost
EVs: 252 Atk / 4 Def / 252 Spe
Jolly Nature
- Acrobatics
- Bug Bite
- Agility
 
Last edited:
The Calculator doesn't seem to take into account the effects of the Utility Umbrella, and how it both negates sun/rain boosted moves against the holder and makes Weather Ball a 50bp normal move against the holder.
 
Request, is it possible to add to the all vs one and one vs all calc a way to calculate only custom sets? to make it easier to calc for formats like BSS factory, 1v1, and OM?
 

Delta 2777

Machampion
is a Tiering Contributor Alumnusis a Contributor Alumnusis the Smogon Tour Season 10 Champion
Forgive me if I'm not using the exactly correct technical terms here:

For the random battles damage calculator, the calculator will not work over certain connections. This is because it appears some content is not served entirely via https, and certain connections/VPNs (including the one I use) block requests that don't use https. You can see a screenshot attached from the Chrome developer console demonstrating with the issue.

I'm aware there are ways to get around this issue on my end, but they are fairly inconvenient, and was hoping if this isn't too difficult of a fix that something could be done here. Thanks.
 

Attachments

Neuroforce:
220 Atk Neuroforce Necrozma-Ultra Photon Geyser vs. 0 HP / 0 SpD Toxapex: 288-338 (119.5 - 140.2%) -- guaranteed OHKO
220 Atk Necrozma-Ultra Photon Geyser vs. 0 HP / 0 SpD Toxapex: 288-338 (119.5 - 140.2%) -- guaranteed OHKO

1.25x on super effective hits doesn't register, please fix, thanks.
 
Can someone verify whether the halving nature of strong winds is calculated before or after wonder guard? I have the feeling that it is before, considering that this custom game (where corviknight had both a wacan berry and wonder guard) did not get affected by thunderbolt under strong winds, but the damage calc says otherwise. This is because the damage calc currently puts the strong winds check after the wonder guard check.
Screen Shot 2021-04-01 at 9.18.23 PM.png

Neuroforce:
220 Atk Neuroforce Necrozma-Ultra Photon Geyser vs. 0 HP / 0 SpD Toxapex: 288-338 (119.5 - 140.2%) -- guaranteed OHKO
220 Atk Necrozma-Ultra Photon Geyser vs. 0 HP / 0 SpD Toxapex: 288-338 (119.5 - 140.2%) -- guaranteed OHKO

1.25x on super effective hits doesn't register, please fix, thanks.
I patched this a few months ago, but it looks like the site hasn't updated its code in a while.
 
Normalize is making Struggle act like a Normal move when it probably shouldn't.

Normalize Mew Struggle vs. Arceus-Ghost: 0-0 (0 - 0%) -- possibly the worst move ever
252+ Atk Silk Scarf Normalize Mew Struggle vs. 252 HP / 252 Def Mew: 85-102 (21 - 25.2%) -- 0% chance to 4HKO
252+ Atk Mew Struggle vs. 252 HP / 252 Def Mew: 40-48 (9.9 - 11.8%) -- possible 9HKO
 

zaaya

RELINQMISHED
is a Tiering Contributor
While having a discussion in the BS room i decided to go check some Rivalry calcs and it looks they're bugged this gen? Whereas they look right in XY. (didn't check SM)
Screenshot_2021-04-07-15-06-32-1.png

Screenshot_2021-04-07-15-06-10-1.png

some raw calcs
252 Atk Life Orb Rivalry nerfed Haxorus Close Combat vs. 140 HP / 0 Def Abomasnow: 380-447 (106.7 - 125.5%) -- guaranteed OHKO

252 Atk Life Orb Rivalry buffed Haxorus Close Combat vs. 140 HP / 0 Def Abomasnow: 354-419 (99.4 - 117.6%) -- 93.8% chance to OHKO

252 Atk Life Orb Haxorus Close Combat vs. 140 HP / 0 Def Abomasnow: 471-556 (132.3 - 156.1%) -- guaranteed OHKO
 

Users Who Are Viewing This Thread (Users: 1, Guests: 0)

Top