• The moderators of this forum are Austin and pre.
  • Welcome to Smogon! Take a moment to read the Introduction to Smogon for a run-down on everything Smogon.

Programming Pokémon Showdown Damage Calculator

pre

shaving yaks and herding cats
is a Battle Simulator Administratoris a Programmeris a Super Moderator
Builder
Reposting because I'm pretty sure it got glanced over, Power Spot is an ability which multiplies damage. Still hasn't been added.
This is a known issue, there is a bug filed on GitHub, anyone can do it, its a trivial change. There are many other effects like Mud/Water Sport, Ion Deluge, Charge, etc we do not currently support either. This is not even remotely worth my time to implement in Honko's UI, so please fine someone to open a pull request if you feel this is important.

gen 8 lacks garbodor, hatterene and alcremie
I mean, it doesn't, so it would be helpful if next time you specify (I assume) that you mean in Randoms Mode.
 

pre

shaving yaks and herding cats
is a Battle Simulator Administratoris a Programmeris a Super Moderator
Builder
OK sorry for the delay SoulWind, Earthworm, ABR. Wading into this Hidden Power mess, there are a couple of things to balance:
  • The set that was imported by the user
  • What the user manually overrides for the IVs in the UI
  • Attempting to maintain legality
One thing right off the bat is that the UI's moveset import does not currently properly implement the correct PS import mechanics which will autofill in DVs/IVs for Hidden Power if theyre not explicitly specified. This is fairly straightforward to implement in the calc, and will make it so that the preloaded sets and sets you import via the Import / Export box will actually have the correct IVs/DVs for Hidden Power (including just assuming 31 across the board for Gen 7+). This is straightforward and unambiguously The Right Thing To Do.

The more nuanced bit is the interaction between the set selector vs. the move selector vs. the IV fields. The way I plan to implement it is 'last write wins', where if you import a set or futz around with the IV fields and come up with with specific IVs and then all of a sudden give it Hidden Power with the IV fields will all be reset to the 'default PS IVs' for that Hidden Power (in Gen 2-6 at least, in Gen 7+ I don't need to ever trample the IVs one changing Hidden Power). I think we should also probably update the Hidden Power type and BP based on what is going on in the IV fields to reflect the cartridge mechanics.

I'm going to correct the moveset import logic first, please let me know if the second bit wouldn't solve your problem (and if not, please help me understand the interaction between these fields that would be most desirable)
 

pre

shaving yaks and herding cats
is a Battle Simulator Administratoris a Programmeris a Super Moderator
Builder
One thing right off the bat is that the UI's moveset import does not currently properly implement the correct PS import mechanics which will autofill in DVs/IVs for Hidden Power if theyre not explicitly specified. This is fairly straightforward to implement in the calc, and will make it so that the preloaded sets and sets you import via the Import / Export box will actually have the correct IVs/DVs for Hidden Power (including just assuming 31 across the board for Gen 7+). This is straightforward and unambiguously The Right Thing To Do.
This should be done.

The more nuanced bit is the interaction between the set selector vs. the move selector vs. the IV fields. The way I plan to implement it is 'last write wins', where if you import a set or futz around with the IV fields and come up with with specific IVs and then all of a sudden give it Hidden Power with the IV fields will all be reset to the 'default PS IVs' for that Hidden Power (in Gen 2-6 at least, in Gen 7+ I don't need to ever trample the IVs one changing Hidden Power).
The move selector and set selector should work pretty much as described.

I think we should also probably update the Hidden Power type and BP based on what is going on in the IV fields to reflect the cartridge mechanics.
I've punted on this - felt it more important to ship the first two things. The calc will not update the Hidden Power moves type and base power as you adjust IVs, nor will it try to figure out some set of IVs to match your entered Hidden Power type and power. Realistically the first one (IVs -> Hidden Power) isn't *too* hard in general (its just hard given the way the current UI is written), the other direction is kind of oof (unless we precompute the 'most desirable' IVs for each hidden power type and power from 30->70 instead of just 70 like we do today).

This involved a lot of code so I would be surprised if there was not a couple of bugs introduced - this code is deployed now, please let me know if you encounter any issues. Sorry for the long delay on addressing this after Earthworm's initial post, we probably should have acknowledged it was seen earlier (Austin and I typically react to the post to let you know if we've seen it, but perhaps some more explanation into why it is difficult and would take a while would have been appreciated)

One further potential gotcha: I've coded it so that if you change a move selection which was previously Hidden Power to a move which is not Hidden Power in Gen 2-6, all of the IVs/DVs are set to max. This isn't safe to do naively, and would require some sort of complicated field provenance tracking to do safely (was a IV field set by the user or automatically due to adding Hidden Power?) and even then would be kind of obtuse. However, this change still seems like it would be desirable more often than not when futzing with Hidden Power on sets that it seemed worth doing, but this isn't perfect (eg. very easy to 'fool' if you have two hidden power moves selected in the dropdowns, but like... don't do that).
 

pre

shaving yaks and herding cats
is a Battle Simulator Administratoris a Programmeris a Super Moderator
Builder
gen 8 lacks garbodor, hatterene and alcremie
yessir gen 8 /rcalc lacks those 3 monsters (hatterene alcremie and garbodor
This is fixed.

It also lacks Lapras. All of those mons always use their Gmax form in rands, which seems to be the reason they aren't in the rands calc.
Thank you for identifying that the fact that they were Gmax was the problem, this was very helpful and saved a lot of time.
 

pre

shaving yaks and herding cats
is a Battle Simulator Administratoris a Programmeris a Super Moderator
Builder
I'm guessing this issue is related to the Hidden Power update from yesterday(?): every single Hidden Power has been coming up as HP Fighting, regardless of how little sense that makes. Behold:


A quick search shows that this seems to be happening for Gens 2-6.
Yeah, but its STAB on Hitmonchan! (fixed, thanks)
 
I was making a team around Chandelure when I was doing some experimenting with calcs I noticed this weird bug with Aegislash-Blade output damage.
252+ Atk Choice Band Aegislash-Blade Shadow Sneak vs. 80 HP / 0 Def Chandelure: 252-296 (89.6 - 105.3%) -- 0% chance to OHKO after Leftovers recovery
It says 0% chance to OHKO when the percentage for the max roll is 105%.
To add on, using the manual calculation the answer should be around 6/16 chance to OHKO from using the possible damage amounts.
Possible damage amounts: (252, 254, 258, 260, 264, 266, 270, 272, 276, 278, 282, 284, 288, 290, 294, 296)
The numbers I have in bold are the damage rolls for the OHKO.

https://imgur.com/a/ohUzd2u Here is a screenshot as proof I haven't fiddled with anything.
Thank you.
 

Austin

Schismatic
is a Programmeris a Forum Moderatoris a Community Contributoris a Battle Simulator Moderator Alumnus
Moderator
Bug Report:
252+ Atk Choice Band Strong Jaw Dracovish Fishious Rend (170 BP) vs. 252 HP / 252+ Def Weezing-Galar: 339-399 (101.4 - 119.4%) -- guaranteed OHKO

It does not factor in that Neutralizing Gas cancels out Strong Jaws.
Thus, BandoVish only does 70% ish damage agains Galar Weezing.

This is also propably true for other neutralizing abilites aswell. I'd appreciate a bugfix for that. Thanks for your work. ;)
fixed

Max Moves still deal some damage through Protect, but this isn't reflected by the calculator
Yveltal Max Darkness vs. protected Ho-Oh: 0-0 (0 - 0%) -- possibly the worst move ever
This was fixed a while ago
 
Last edited:

Austin

Schismatic
is a Programmeris a Forum Moderatoris a Community Contributoris a Battle Simulator Moderator Alumnus
Moderator
Would it be possible to have Random Battle sets in here, or otherwise make it easy to calc things that have 84/84/84/84/84/84 investment with a neutral nature? It gets a bit tedious to have to redo that every time I want to make a calc in randbats.
lol didn't get back to you, but yes this was done a while ago :)
 
  • Haha
Reactions: pre

Austin

Schismatic
is a Programmeris a Forum Moderatoris a Community Contributoris a Battle Simulator Moderator Alumnus
Moderator
Posted this the other day but it still seems to be broken.

I think the "doubles" button is bugged for max moves. All other things equal, if you toggle the singles/doubles button and look at the damage for a max move (which of course is single target), the damage changes. I don't understand how this is possible.
Will look Into. You should not be waiting long fwiw
 

Austin

Schismatic
is a Programmeris a Forum Moderatoris a Community Contributoris a Battle Simulator Moderator Alumnus
Moderator
Posted this the other day but it still seems to be broken.

I think the "doubles" button is bugged for max moves. All other things equal, if you toggle the singles/doubles button and look at the damage for a max move (which of course is single target), the damage changes. I don't understand how this is possible.
fixed
 
Something might be wrong with Dauntless Shield, doesn't seem to be applying Defense buff in Damage Calc

+3 252 Atk Zacian-Crowned Close Combat vs. +1 252 HP / 180+ Def Zamazenta-Crowned: 464-546 (119.5 - 140.7%) -- guaranteed OHKO
Possible damage amounts: (464, 468, 474, 480, 484, 490, 496, 502, 506, 512, 518, 524, 528, 534, 540, 546)

This is with Dauntless Shield

+3 252 Atk Zacian-Crowned Close Combat vs. +1 252 HP / 180+ Def Zamazenta-Crowned: 308-364 (79.3 - 93.8%) -- guaranteed 2HKO

This is without Dauntless Shield, but +1 Defense
 
I noticed there was a "switching out" button, presumably just for Pursuit. However, there are a few things that change damage when the target is switching in, like Fishious Rend, Bolt Beak, Stakeout, and Gen 4 Payback. I think there should either also be a "switching in" button, or just have a single "switching" button that automatically applies switching out or in based on context.
 

Austin

Schismatic
is a Programmeris a Forum Moderatoris a Community Contributoris a Battle Simulator Moderator Alumnus
Moderator
Is there any chance Silvally can take itemless damage from Knock Off without having to manually remove the item? This interaction is possible to come up in NU battles currently and the damage it takes in the calc is as if it has an item equipped when the item is not knockable, so damage is as if it is itemless.
Do you just mean Silvally with a memory item?
 

Austin

Schismatic
is a Programmeris a Forum Moderatoris a Community Contributoris a Battle Simulator Moderator Alumnus
Moderator
Yes, for example:


252 Atk Mold Breaker Sawk Knock Off (97.5 BP) vs. 0 HP / 0 Def Silvally-Dark: 53-63 (16 - 19%) -- possible 6HKO

This says 16-19%, but that is the damage it would take with 97.5 BP (as the calc indicates). A player could notice this and simply adjust the calc accordingly, but if the default where to be itemless damage, that would save that step and avoid possible confusion
When I test silvally with a memory item it is getting the same damage result as silvally with no item? Which is what it should be doing when looking at the code
 

Finchinator

Treat People With Kindness
is a Top Smogon Social Media Contributoris a Forum Moderatoris a Community Contributoris a Tiering Contributoris a Contributor to Smogonis a Smogon Media Contributoris a Battle Simulator Moderatoris a Super Moderator Alumnusis a Past WCoP Championis a former Tournament Circuit Champion
BW Circuit Champion
When I test silvally with a memory item it is getting the same damage result as silvally with no item? Which is what it should be doing when looking at the code
https://replay.pokemonshowdown.com/smogtours-gen8nu-503196

Maybe it's impossible to fix in the calculator then? What I am trying to say is that Silvally forms with the memory equipped are always taking itemless damage as it is impossible to knock them, but the calc defaults to normal, item equipped damage. This replay shows it taking 12%, but this is impossible for item equipped damage and the item cannot be removed from Silvally.

They're both my teams being used, so I know for a fact the 12% damage is only accurate if itemless damage is being done:

252 Atk Mold Breaker Sawk Knock Off (97.5 BP) vs. 0 HP / 0 Def Silvally-Dark: 53-63 (16 - 19%) -- possible 6HKO
252 Atk Mold Breaker Sawk Knock Off vs. 0 HP / 0 Def Silvally-Dark: 36-43 (10.8 - 12.9%) -- possible 8HKO
 

pre

shaving yaks and herding cats
is a Battle Simulator Administratoris a Programmeris a Super Moderator
Builder
Can we review the levels of Pokémon as they appear in rands and in calc? I just lost a battle because I selected a move based on this:

+3 Lvl 84 84 Atk Lycanroc Close Combat vs. Lvl 80 84 HP / 84 Def Noctowl: 342-403 (117.5 - 138.4%) -- guaranteed OHKO

But in rands Noctowl is level 88 not level 80, it lived on 1% defeated me (my last Pokémon was itself sitting on 1%). EDIT: Just to be clear: this was rands singles. I know for dubs the levels are not configured and I always remember to change them manually.
I just deployed an update which should have the current levels, however:

Random Battle formats change implementations very often and the calc will never be a source of truth. If we're lucky we get notified when a change goes in and is hotpatched and we can get updated within a few hours, but at its core this is never going to be exact. You should not blindly trust the levels (or moves etc) in the calc, they were only correct at one point and may have been changed. The description helpfully includes the levels in the output so you can verify that the levels are what they say they are, it is merely a convenience, you should still expect to have to change the levels if the Random Battles implementation changes.

Random Doubles levels are a whole other can of worms and pretty much fundamentally will not work with the calc.
 
If a Pokemon's type is manually changed from what it usually is, could the calc make a note of it?

0 SpA Choice Specs Sheer Force Mewtwo Flamethrower vs. 0 HP / 0 SpD Assault Vest Dry Skin Mew: 153-180 (44.8 - 52.7%) -- 25.8% chance to 2HKO

0 SpA Choice Specs Sheer Force Psychic Fire Mewtwo Flamethrower vs. 0 HP / 0 SpD Assault Vest Dry Skin Dragon Mew: 114-135 (33.4 - 39.5%) -- guaranteed 3HKO

This is mostly relevant for defensive Protean/Libero calcs, as well as generic strength comparisons where the usual target is a typeless Mew or something, though Soak (and Magic Powder lol) is also a situation where it could be useful.

On the topic of types, could there also be toggles for Forest's Curse and Trick-or-Treat? They're almost exclusively useful for stacking weaknesses to get crazy calcs, but hey.
 

pre

shaving yaks and herding cats
is a Battle Simulator Administratoris a Programmeris a Super Moderator
Builder
Idk if this has been suggested, but would love to see calcs for random battles added in. Just each mon with its rand bats level and 84 evs in every slot, no items or moves.

This would be more of a convenience thing than anytting for those people who tryhard in rand bats
This already exists. Look for the selector in the top right.
 
I was playing with the calc a bit and I found that multi-hit move KO chances are calculated incorrectly.

1591783486692.png

^The original intention was seeing the chances that one of dragapult's subs can take 4 shuriken hits from specs greninja. However, 22.7-27.7% doesn't seem to match 87.5% chance given by the calc. I did some math and found that the chance is actually ~63.65% (assuming equal probability of each outcome).

1591783876328.png

^Ironically, a simplified calculation of 62.5% is closer to the actual answer than 87.5%

1591782948889.png

1591782994048.png
^That doesn't make much sense considering the mean damage of 4 shuriken hits is 80.25, with 81 and 82 both being above the mean.

1591783231298.png
^I made dragapult fire/ghost in the above case.

1591784166567.png

^I tweaked a lot of inputs to get the damage to be the same but rock blast behaves the same way. It seems that most if not all multi-hit moves, such as dragon darts and twineedle (which only cap at two) have the same issue. However, it appears that the parental bond ability calculates KO chances correctly.

1591783664729.png

^it's easy to see that the actual chance is 1/(16^4), which is a lot far off from 6.3% chance.

1591782603738.png


1591784289763.png


1591784331594.png

1591784388694.png

1591784442947.png

1591784921617.png

1591784796969.png
^Multi-hit moves seem to be using parts of the KO formula for gens 3-8 (with 16 unique damage amounts) instead of gens 1-2 (39 unique damage amounts).
 

Attachments

According the showdown damage calculator a lvl 50 Rash G-Darmanitan w/ 92 SpA EVs should OHKO a lvl 50 Dracovish with EV's invested in Atk/Spe apart from 4 EVs. It didn't. Can confirm that it only dealt about ~2/3...3/4. The Dracovish was not holding an Assault Vest (I tested this on two Dracovish. I don't know the nature of the first one, but I'm assuming a competitive nature, and the second was Gentle). Does anyone know why? Looks like it could be a bug in the damage calculator?
I am very confused as to how you came across this (why were you using a mixed Darmanitan?!) but I found out what's wrong, and it is a calculator problem (hence why I'm replying here and not the mechanics research thread). Gorilla Tactics is boosting special attacks on the calculator when it shouldn't.


92+ SpA Gorilla Tactics Darmanitan-Galar Freeze-Dry vs. 0 HP / 0 SpD Dracovish: 168-196 (101.8 - 118.7%) -- guaranteed OHKO

92+ SpA Darmanitan-Galar Freeze-Dry vs. 0 HP / 0 SpD Dracovish: 108-132 (65.4 - 80%) -- guaranteed 2HKO
 

Austin

Schismatic
is a Programmeris a Forum Moderatoris a Community Contributoris a Battle Simulator Moderator Alumnus
Moderator
I am very confused as to how you came across this (why were you using a mixed Darmanitan?!) but I found out what's wrong, and it is a calculator problem (hence why I'm replying here and not the mechanics research thread). Gorilla Tactics is boosting special attacks on the calculator when it shouldn't.


92+ SpA Gorilla Tactics Darmanitan-Galar Freeze-Dry vs. 0 HP / 0 SpD Dracovish: 168-196 (101.8 - 118.7%) -- guaranteed OHKO

92+ SpA Darmanitan-Galar Freeze-Dry vs. 0 HP / 0 SpD Dracovish: 108-132 (65.4 - 80%) -- guaranteed 2HKO
According the showdown damage calculator a lvl 50 Rash G-Darmanitan w/ 92 SpA EVs should OHKO a lvl 50 Dracovish with EV's invested in Atk/Spe apart from 4 EVs. It didn't. Can confirm that it only dealt about ~2/3...3/4. The Dracovish was not holding an Assault Vest (I tested this on two Dracovish. I don't know the nature of the first one, but I'm assuming a competitive nature, and the second was Gentle). Does anyone know why? Looks like it could be a bug in the damage calculator?

Aah, great, thanks! (He had great surprise value against the opponent, and he only would have two jobs in the team basically, which he could've still performed after some SpA investment. I know his SpA is useless. Now I need to rethink a bit obviously.)
Great timing on the reply, I was just about to move the post to here, too.
So currently, if I set SpA to -1 stage, I should get the correct result?
Or change the ability to something else when calcing for Freeze Dry. I used Gooey in the calc I posted just because it's right above Gorilla Tactics in the list. I don't know enough about Pokemon's order of operations to know if -1 will provide exactly the same results.
Fixed thank you :)
 

pre

shaving yaks and herding cats
is a Battle Simulator Administratoris a Programmeris a Super Moderator
Builder
I added a speed column to my local copy turskain's fork for the in game challenges.
Please talk to 'turskain'. The repo you link appears to be using code for about 3 years ago, the supported way to integrate the official damage calculator code into your application is with the @smogon/calc NPM package.
 
Last edited:

pre

shaving yaks and herding cats
is a Battle Simulator Administratoris a Programmeris a Super Moderator
Builder
Keldeo doesn't appear in the rands calc. This is probably because it's Keldeo-Resolute, not Keldeo, which has sets in random battles. Also, Darmanitan-Galar should have two sets, one for its zen form and one for the normal form (this matters because if it gets Zen Mode it's level 80, not level 72).
Keldeo resolute isnt in randbats calc, ty in advance
Sirfetch'd is not in the randbats calc lol
Done. These are all annoying edge cases :)

Can we add eiscue-noice to calc, or things like minior forms
** or in randbats calc sorry
Eiscue-Noice has always been selectable in Random Battle mode, please use the Forme selector

Screen Shot 2020-06-14 at 20.52.03.png


AFAICT, Minior is not supported in S/S random battles, though you can change Minior's forme to Minior-Meteor in S/M in exactly the same way.
 

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

Top