Programming Pokémon Showdown Damage Calculator

drampa's grandpa

googly eyed irl
is a Pre-Contributor
Galvanize should not effect Judgment, but in the calc they do. This also goes for Aerilate, Pixilate, and Refrigerate, and for Multi-Attack. This is relevant for OMs (I discovered it while messing around with the BH Zekrom set).
 
Is it possible for the Plus/Minus ability buff to be added to the damage calculator? I know that it's pretty rare that someone would use it, but the calculator is technically incomplete without it.
 
Last edited:
Is it possible for the Plus/Minus ability buff to be added to the damage calculator? I know that it's pretty rare that someone would use it, but the calculator is technically incomplete without it.
It is in the calc. The checkbox next to the ability toggle will activate/deactivate the ability.
 
I found an error with the showdown damage calculator. I originally posted this to Twitter, but after a few days I thought I'd try to reach out here.

Original tweet with pictures:
Basically, the damage calculator has Lycanroc-Dusk listed incorrectly. Lycanroc-Dusk has 117 Attack and 110 Speed, but the damage calculator says it has 115 Attack and 112 Speed, as if it was a Lycanroc-Day instead. This problem isn't present in the team builder, just the damage calculator.
 
Got a problem with the damage calculator as well, as you can see in the screenshots when Psycho Boost is selected to hit twice, the amount of damage goes through the roof. It is not the system not taking the -2 from the first attack into account, but it is also getting extra damage on top.
184744
184746
 
when i set the weather to rain, then change one of the 2 mons, the weather is reset to none, so if i have to calculate damage under rain vs a few mons, i have to set the weather each time. could the weather stay whatever it is unless one of the new mons has a weather ability
 
Weather doesn't change the 3HKO chance when I'm pretty sure it's supposed to.
185375
185376

when i set the weather to rain, then change one of the 2 mons, the weather is reset to none, so if i have to calculate damage under rain vs a few mons, i have to set the weather each time. could the weather stay whatever it is unless one of the new mons has a weather ability
This would be very helpful for those 2 generations when sand is everywhere.
 

drampa's grandpa

googly eyed irl
is a Pre-Contributor
Sand damage is not effecting damage calcs. Note that this is specifically the DAMAGE from sand, not the SpD boost.

252+ Atk Choice Band Tyranitar Pursuit vs. 252 HP / 144+ Def Latias-Mega: 152-182 (41.7 - 50%) -- 0.4% chance to 2HKO (without sand)
252+ Atk Choice Band Tyranitar Pursuit vs. 252 HP / 144+ Def Latias-Mega: 152-182 (41.7 - 50%) -- 0.4% chance to 2HKO (with sand)

I decided to test this with other forms of passive damage....
252+ Atk Choice Band Tyranitar Pursuit vs. 252 HP / 144+ Def Latias-Mega: 152-182 (41.7 - 50%) -- 89.8% chance to 2HKO after Stealth Rock (check)
252+ Atk Choice Band Tyranitar Pursuit vs. 252 HP / 144+ Def Latias-Mega: 152-182 (41.7 - 50%) -- 89.8% chance to 2HKO after Leech Seed damage (check)
252+ Atk Choice Band Tyranitar Pursuit vs. 252 HP / 144+ Def Latias-Mega: 152-182 (41.7 - 50%) -- guaranteed 2HKO after 3 layers of Spikes (check, ability was modified)
252+ Atk Choice Band Tyranitar Pursuit vs. 252 HP / 144+ Def Latias-Mega: 152-182 (41.7 - 50%) -- 89.8% chance to 2HKO after poison damage (check)
252+ Atk Choice Band Tyranitar Pursuit vs. 252 HP / 144+ Def Latias-Mega: 152-182 (41.7 - 50%) -- 30.1% chance to 2HKO after toxic damage (check)
252+ Atk Choice Band Tyranitar Pursuit vs. 252 HP / 144+ Def Latias-Mega: 152-182 (41.7 - 50%) -- 30.1% chance to 2HKO after burn damage (check)
252+ Atk Choice Band Tyranitar Pursuit vs. 252 HP / 144+ Def Latias-Mega: 152-182 (41.7 - 50%) -- 89.8% chance to 2HKO after Dry Skin damage (check)
252+ Atk Choice Band Tyranitar Pursuit vs. 252 HP / 144+ Def Latias-Mega: 152-182 (41.7 - 50%) -- 89.8% chance to 2HKO after Sticky Barb damage (check)

Only thing that was messed up was fellow weather Hail, although I don't guarantee I checked every possible type of passive damage ( I did get some odd ones though)
252+ Atk Choice Band Tyranitar Pursuit vs. 252 HP / 144+ Def Latias-Mega: 152-182 (41.7 - 50%) -- 0.4% chance to 2HKO (Hail, fail)

Proof of SpD boost is here:
0 SpA Latias-Mega Ice Beam vs. 40 HP / 48 SpD Tyranitar: 83-98 (23.6 - 27.9%) -- 88.9% chance to 4HKO
0 SpA Latias-Mega Ice Beam vs. 40 HP / 48 SpD Tyranitar in Sand: 56-66 (15.9 - 18.8%) -- possible 6HKO

One other thing... when I put in Download as an ability it automatically went to +6. This seems odd.
187193
 

pre

shaving yaks and herding cats
is a Battle Simulator Administratoris a Programmeris a Super Moderator
Builder
Thanks for reporting, pretty likely that was me. I'll look into it.

EDIT: Its because of mutation. :(
 
Last edited:

pre

shaving yaks and herding cats
is a Battle Simulator Administratoris a Programmeris a Super Moderator
Builder
Download is giving me odd numbers, sometimes it's fine and sometimes it's +3 or +6
EDIT: Its because of mutation. :(
I've fixed this (but not deployed the fix yet) and deployed the fix, I'm looking at the Sandstorm stuff now, the Sandstorm/Hail bug is an existing issue, not a new regression. LMK if you find any more bugs, I've been doing a lot of architectural changes under the hood and would be surprised if this was all that was broken
 
Last edited:
Intimidate seems buggy where it is seemingly doubled its effect when i clicked the box beside it.
187493

Sorry for the big screenshot :(
 
One bug I discovered recently, the damage didn't changed if i edited the stats of the pokemon like they still keep the original stat:
188005

188008

I was trying to edited the stats for some Other Metagames like 350 Cup.
 

DaWoblefet

Demonstrably so
is a Smogon Social Media Contributoris a Top Researcheris a Tiering Contributoris a Battle Simulator Moderator
A wide number of issues with the current damage calculator exist which largely arise at a result of not being up-to-date with Generation 7 modifier order. I'll go through the non-Gen 7 issues first, then I'll address the Gen 7-specific bugs. Assume in these damage calculations both targets are at level 100.
  • Parental Bond
Parental Bond should run two independent strikes to calculate damage, not do a trivial damage = damage * modifier. Parental Bond causes the move to run an entirely new damage calculation and applies the baby hit modifier in between the spread move modifier and the weather modifier. As a result, there should be two independent sets of damage rolls displayed, as well as percent to KO being based on 256 combinations of damage rolls, not 16. Displaying it as a combination would require displaying potentially 256 damage rolls, so most damage calculators that implement Parental Bond accurately do something like this:
Accurate output:
152 Atk Parental Bond Kangaskhan-Mega Frustration vs. 252 HP / 152+ Def Amoonguss: 190-225 (43.98 - 52.08%) -- 6.65% chance to 2HKO (1089/16384)
(1st Hit: 153, 154, 156, 157, 159, 162, 163, 165, 166, 168, 171, 172, 174, 175, 177, 180; 2nd Hit: 37, 37, 39, 39, 39, 40, 40, 40, 40, 42, 42, 42, 43, 43, 43, 45)

PS damage calc:
152 Atk Parental Bond Kangaskhan-Mega Frustration vs. 252 HP / 152+ Def Amoonguss: 191-225 (44.2 - 52%) -- 12.5% chance to 2HKO
Possible damage amounts: (191, 192, 195, 196, 198, 202, 203, 206, 207, 210, 213, 215, 217, 218, 221, 225)
In addition, certain secondary effects that apply if a target has taken damage / target is not at full HP should be factored into the baby hit's calculation. These notably include: Shadow Shield / Multiscale, Assurance, Power-Up Punch.
Accurate output:
252 Atk Parental Bond Kangaskhan-Mega Crunch vs. 0 HP / 0 Def Shadow Shield Lunala: 280-334 (67.47 - 80.48%) -- guaranteed 2HKO
(1st Hit: 188, 190, 192, 194, 196, 198, 202, 204, 206, 208, 210, 212, 214, 216, 218, 222; 2nd Hit: 92, 96, 96, 96, 96, 100, 100, 100, 104, 104, 104, 104, 108, 108, 108, 112)

PS damage calc:
252 Atk Parental Bond Kangaskhan-Mega Crunch vs. 0 HP / 0 Def Shadow Shield Lunala: 235-277 (56.6 - 66.7%) -- guaranteed 2HKO
Possible damage amounts: (235, 237, 240, 242, 245, 247, 252, 255, 257, 260, 262, 265, 267, 270, 272, 277)
  • Unnecessary 0x1000 modifiers: these would affect cases of damage overflow (and generally speaking won't affect the calculation in any normal cases anyway, so are unnecessary)
- Soul Dew when not a Lati twin
- STAB when user doesn't have STAB

Generation 7 modifier order

From a cursory glance, the conditions for checking if a modifier should be applied is correct; it's moreso the order. The listed modifiers (BP, Attack, Defense, final modifiers, general damage modifiers), are taken from OZY's research, which is considered to be the authoritative research for Gen 7 and is what the simulator itself is using (or minimally should be using). I have listed these in the order they should be applied. If you have any questions about what I mean, or need test cases, let me know. Modifiers that are incorrect in the PS damage calculator are bolded.
  • Gen 7 BP modifiers
  1. Aura Break - 0xC00
  2. Rivalry and gender is not the same - 0xC00
  3. -ate Abilities - 0x1333
  4. Iron Fist - 0x1333
  5. Reckless - 0x1333
  6. Rivalry and gender is the same - 0x1400
  7. Battery - 0x14CD
  8. Sheer Force - 0x14CD
  9. Sand Force - 0x14CD
  10. Analytic - 0x14CD
  11. Tough Claws - 0x14CD
  12. Fairy Aura / Dark Aura - 0x1548
  13. Technician - 0x1800 (note that Technician will check if the previous modifiers would have pushed this above/below 60 BP)
  14. Flare Boost - 0x1800
  15. Toxic Boost - 0x1800
  16. Strong Jaw - 0x1800
  17. Mega Launcher - 0x1800
  18. Heatproof - 0x800
  19. Dry Skin - 0x1400
  20. Muscle Band - 0x1199
  21. Wise Glasses - 0x1199
  22. Type-boosting items - 0x1333
  23. Orbs - 0x1333
  24. Gems - 0x14CD
  25. Solar Beam / Solar Blade - 0x800
  26. Me First - 0x1800
  27. Knock Off - 0x1800
  28. Helping Hand - 0x1800
  29. Charge - 0x2000
  30. Facade - 0x2000
  31. Brine - 0x2000
  32. Venoshock - 0x2000
  33. Retaliate - 0x2000
  34. Fusion Bolt / Fusion Flare - 0x2000
  35. Grassy Terrain / Misty Terrain (defensive) - 0x800
  36. Electric / Grassy / Psychic Terrain (offensive) - 0x1800
  37. Mud Sport / Water Sport - 0x548
If base power exceeds 16 bits after the 1 BP check (i.e. greater than 65535), mod by 65536. Source.
  • Gen 7 Attack modifiers
+6/-6 boosts/drops
Hustle
  1. Slow Start (of note, don't forget that special Z-moves are affected by Slow Start) - 0x800
  2. Defeatist - 0x800
  3. Flower Gift - 0x1800
  4. Guts - 0x1800
  5. Overgrow / Blaze / Torrent / Swarm - 0x1800
  6. Flash Fire - 0x1800
  7. Solar Power - 0x1800
  8. Plus / Minus - 0x1800
  9. Steelworker - 0x1800
  10. Huge Power / Pure Power - 0x2000
  11. Water Bubble (offensive) - 0x2000
  12. Stakeout - 0x2000
  13. Thick Fat - 0x800
  14. Water Bubble (defensive) - 0x800
  15. Choice Band / Choice Specs - 0x1800
  16. Thick Club - 0x2000
  17. Deep Sea Tooth - 0x2000
  18. Light Ball - 0x2000
If the attack exceeds 16 bits after the 1 attack check (i.e. greater than 65535), mod by 65536. Source.
  • Gen 7 Defense modifiers
+6/-6 boosts/drops
Sandstorm & Rock-types
  1. Flower Gift - 0x1800
  2. Marvel Scale - 0x1800
  3. Grass Pelt - 0x1800
  4. Fur Coat - 0x2000
  5. Eviolite - 0x1800
  6. Assault Vest - 0x1800
  7. Deep Sea Scale - 0x2000
  8. Metal Powder - 0x2000
If the attack exceeds 16 bits after the 1 defense check (i.e. greater than 65535), mod by 65536. Source.
  • General damage modifiers
After calculating the base damage, apply these modifiers in order, according to OZY research.
  1. Spread move - 0xC00
  2. Parental Bond - 0x400
  3. Weather - 0x1800 for boosting, 0x800 for weakening
  4. Crit - 0x1800
  5. Random factor
  6. STAB (Adaptability) - 0x1800 (0x2000)
  7. Type effectiveness - So long as we only support two types, 0.25x-4x
  8. Burn - 0x800
  9. Final damage modifiers
  10. Z-moves into Protect - 0x400
  11. 1 damage modifier
  12. 16 bit constraint (maximum damage should never be higher than 65535)
  • Final damage modifiers
OZY research etc.
  1. Screens - Singles = 0x800, Doubles = 0xAAC
  2. Neuroforce - 0x1400
  3. Sniper - 0x1800
  4. Tinted Lens - 0x2000
  5. Multiscale / Shadow Shield - 0x800
  6. Fluffy (contact moves) - 0x800
  7. Friend Guard - 0xC00
  8. Solid Rock / Filter / Prism Armor - 0xC00
  9. Fluffy (Fire-type moves) - 0x2000
  10. Metronome (item) - you have this right
  11. Expert Belt - 0x1333
  12. Life Orb - 0x14CC
  13. Resist Berries - 0x800
  14. Doubled-power moves - 0x2000
  • 32-bit multiplication overflow
If a calculation ever exceeds 2^32 - 1, mod by 2^32. This has been proven to be possible during the base damage calculation, when applying any modifier after the base damage, during the random factor, and even during trivial modifiers (e.g. if there are no final modifiers, an implicit 4096/4096 is applied). This is in addition to the 16 bit constraints listed for BP, Attack, Defense, and damage at the very end.
  • Weight calculations
See SadisticMystic's research.
  1. Apply all Autotomizes (there is a weight minimum of 0.1kg).
  2. Apply Heavy Metal (there is no weight maximum)
  3. Apply Light Metal and Float Stone. There is still a weight minimum of 0.1kg. If the calculation results in a weight that extends to two decimal places, "floor" to one decimal place (e.g. 10.25 = 10.2, 10.24 = 10.2, and 10.26 = 10.2).
  • Speed calculations
See DaWoblefet's research.
  1. Apply boosts/drops (+6/-6) and floor.
  2. Apply all other Speed modifiers except paralysis and pokeRound.
  3. Apply paralysis and floor.
 

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

Top