Programming Pokémon Showdown Damage Calculator

Thx for fix. Now, i'd like to make some suggestions for the group damage result output display ( one vs all, all vs one)
1. Summary row : providing % and absolute number of pokemon koed in 1, 2 etc turns
2. Usage column : assuming your program has access to the smogon usage database, a column with usage % would be incredibly useful for filtering. If i wish to know how well will X pokemon sweep in Y tier , I can filter the results in descending usage order and focus on the highest ones
3. Group copy-pasting. Basically , allow for users to input multiple names per search (in the search fuction of the 1 vs all table). This way, if i want to check how multiple sweepers perform against the x top used mons or whatever, I can write the defending top mons in a notepad, input each sweeper in a calculator in a tab, and paste in the searcher the top mons i want to check as opponents quickly
 
Minor complaint: When I change the weather and then change something else (such as a Pokemon's move or ability), the weather automatically reverts to none. This makes doing calculations in a certain weather condition annoying. Can it please not happen anymore?
 

Felucia

Robot Empress
is a Battle Simulator Moderator
Minor accuracy thing: Moves cannot deal 0 damage (source: bulbapedia. Someone might need to factcheck this)

-6 0- Atk Happiny Tackle vs. +6 252 HP / 252+ Def Aggron through Reflect: 0-0 (0 - 0%) -- aim for the horn next time
 
That might not be a bug. I know someone tested in BW and found that they can, since Reflect and other final modifiers get applied after ensuring 1 damage. Someone should probably test if that's still the case in ORAS and SM though.
 
Minor accuracy thing: Moves cannot deal 0 damage (source: bulbapedia. Someone might need to factcheck this)

-6 0- Atk Happiny Tackle vs. +6 252 HP / 252+ Def Aggron through Reflect: 0-0 (0 - 0%) -- aim for the horn next time
I can't replicate this issue, at least for Gen 7. It always shows at least 1 damage being dealt.

-6 0- Atk Defeatist burned Happiny Return vs. +6 252 HP / 252+ Def Eviolite Fur Coat Lairon with an ally's Friend Guard with an ally's Aurora Veil: 1-1 (0.3 - 0.3%) -- possibly the worst move ever
 
That makes sense though. Pretty much everything there isn't a final modifier except for Friend Guard. So it applies everything except friend guard, gets zero damage, then forces it to be 1. And then it multiplies by 3072/4096 if we base it off of the BW base damage formula, which isn't enough to make it round down.

Test with something that reduces damage by 0.5x or more either on its own or in combination (like reflect).

For reference, this is what all the damage formulas for BW and later are assumed to be based on.
 
And then it multiplies by 3072/4096 if we base it off of the BW base damage formula, which isn't enough to make it round down.
Doesn't Pokemon always round down when calculating anything? If it didn't, then 255 EVs will give 1 more point than 252 EVs.
 
No, BW and onward it has different methods of rounding applied to certain scenarios. Applying and chaining modifiers rounds "half-to-zero", e.g.:
round(0.5)=0
round(0.6)=1
round(-0.5)=0

I believe there are other scenarios that just do integer division though, it really depends.

It might apply to HGSS too, but nobody ever looked at a disassembly like they did for BW. It might not apply to current gens, but again, nobody has looked at the disassembly for ORAS and SM as far as I know, so we just assume it's the same and say "good enough".

edit: tl;dr rby, gsc, adv (maybe), and bw are the only gens we actually know exactly how damage is calculated
 
yea its broken because someone refactored without unit tests a year ago. :(

the person that posted here must have a really old cached version, i remember it had issues with the cache before too.
 
bug concerning Metronome

Rather than doing damage at intervals of 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, it's doing 1.0, 1.1, 1.1*1.2 (1.32), 1.1*1.2*1.3 (1.716), 1.1*1.2*1.3*1.4 (2.4024).

For example, blank set Blaziken using Blaze Kick vs. blank set Mew, at 2/3/4/5 consecutive uses, with an unboosted hit for reference:

0 Atk Blaziken Blaze Kick vs. 0 HP / 0 Def Mew: 108-127 (31.6 - 37.2%) -- 83.8% chance to 3HKO


Capping at 5 consecutive hits also means we can't calc a 2.0 hit
 
I tried to import:
Nidoking @ Life Orb
Timid Nature
Ability: Sheer Force
EVs: 4 HP / 252 SpA / 252 Spe
- Ice Beam
- Flamethrower
- Sludge Wave
- Earth Power

But the Damage Calculator seems can't remember the ability
Every time I click its custom set
The ability is "other"
How can I force the Damage Calculator to remember the ability?
you can't force it to remember it, but it is probably just a small bug
 

Lego

Formally LegoFigure11
is a Top Social Media Contributor Alumnusis a Community Contributor Alumnus
I tried to import:
Nidoking @ Life Orb
Timid Nature
Ability: Sheer Force
EVs: 4 HP / 252 SpA / 252 Spe
- Ice Beam
- Flamethrower
- Sludge Wave
- Earth Power

But the Damage Calculator seems can't remember the ability
Every time I click its custom set
The ability is "other"
How can I force the Damage Calculator to remember the ability?
Code:
Nidoking @ Life Orb
Ability: Sheer Force
Timid Nature
EVs: 4 HP / 252 SpA / 252 Spe
- Ice Beam
- Flamethrower
- Sludge Wave
- Earth Power
Using the actual export format from PS with Ability listed second works fine. I'll see if I can make it find the ability regardless of where it is but for now doing this should fix your problem.
 
Using the actual export format from PS with Ability listed second works fine. I'll see if I can make it find the ability regardless of where it is but for now doing this should fix your problem.
unfortunately it don't work for me
I import again with your way and checked it right away, the ability Sheer Force was there
however after I pressed F5 to refresh the page, the ability was back to "other"
 
Last edited:
Feature request: add a column to the right of where you apply stat buffs/debuffs that displays the final calculated value of that stat (taking items and weather into account as well). Example: what is the final speed stat of a +2 Heracross with a choice scarf? What is the sp.def of Tyranitar in sand? (I know you can just calculate it manually, but it would be convenient)
 
Last edited:

Austin

Schismatic
is a Programmeris a Community Contributoris a Forum Moderator Alumnusis a Battle Simulator Moderator Alumnus
I tried to import:
Nidoking @ Life Orb
Timid Nature
Ability: Sheer Force
EVs: 4 HP / 252 SpA / 252 Spe
- Ice Beam
- Flamethrower
- Sludge Wave
- Earth Power

But the Damage Calculator seems can't remember the ability
Every time I click its custom set
The ability is "other"
How can I force the Damage Calculator to remember the ability?
It should be fixed now
 

Austin

Schismatic
is a Programmeris a Community Contributoris a Forum Moderator Alumnusis a Battle Simulator Moderator Alumnus
Okay, first of all, sry for double posting, but I'd rather be sure mY post is seen.

This time I've found an issue, still related to teravolt/mold breaker (and this time, I've tested sunsteel strike and photon geyser too). So the current situation is : against a pokemon having multiscale (I just tested with lugia but I assume it's coded the same way for dragonite), multiscale does get ignored on the sims by the move/abilities stated above, but not in the calc.

first the replay with the test : http://replay.pokemonshowdown.com/gen7anythinggoes-849776798 (I've been carefull to use the spread of the calc)

For LO KB (dealt 45% to full health Lugia and 49% with multiscale broke):
4 Atk Life Orb Teravolt Kyurem-Black Fusion Bolt vs. 252 HP / 160+ Def Multiscale Lugia: 95-113 (22.8 - 27.1%) -- Theorical damage against a full health lugia according to the calc
4 Atk Life Orb Teravolt Kyurem-Black Fusion Bolt vs. 252 HP / 160+ Def Lugia: 190-226 (45.6 - 54.3%) -- Theorical damage against a lugia that is either not at full else or if multiscale does get ignored

For excadrill scarf (dealt 30% to full lugia and 29%with multiscale broke):
252 Atk Mold Breaker Excadrill Rock Slide vs. 252 HP / 160+ Def Multiscale Lugia: 55-65 (13.2 - 15.6%) -- Theorical damage against a full health lugia according to the calc
252 Atk Mold Breaker Excadrill Rock Slide vs. 252 HP / 160+ Def Lugia: 110-130 (26.4 - 31.2%) -- Theorical damage against a lugia that is either not at full else or if multiscale does get ignored

For Necro-DM's Sunsteel Strike ( dealt 30% to full health Lugia and 30% with multiscale broke):
252 Atk Necrozma-Dusk-Mane Sunsteel Strike vs. 252 HP / 160+ Def Multiscale Lugia: 60-72 (14.4 - 17.3%) -- Theorical damage against a full health lugia according to the calc
252 Atk Necrozma-Dusk-Mane Sunsteel Strike vs. 252 HP / 160+ Def Lugia: 121-144 (29 - 34.6%) -- Theorical damage against a lugia that is either not at full else or if multiscale does get ignored

For Necro-DM's Photon Geyser (dealt 15% to full health Lugia and 16% with multiscale broke):
252 Atk Necrozma-Dusk-Mane Photon Geyser vs. 252 HP / 160+ Def Multiscale Lugia: 30-36 (7.2 - 8.6%) -- Theorical damage against a full health lugia according to the calc
252 Atk Necrozma-Dusk-Mane Photon Geyser vs. 252 HP / 160+ Def Lugia: 60-72 (14.4 - 17.3%) -- Theorical damage against a lugia that is either not at full else or if multiscale does get ignored

Once Again it might very well be the sims that does things wrong, but once again the sims doing what I expected I posted here.
(However if needed, I'm gonna try to test those things on cartridge asap)
This should have been fixed idk if the calc was updated yet
 

Austin

Schismatic
is a Programmeris a Community Contributoris a Forum Moderator Alumnusis a Battle Simulator Moderator Alumnus
It looks like the damage coding for Electro Ball doesn't match Bulbapedia (some in-game research may be needed.

Calc Code:
JavaScript:
    case "Electro Ball":
        var r = Math.floor(attacker.stats[SP] / defender.stats[SP]);
        basePower = r >= 4 ? 150 : r >= 3 ? 120 : r >= 2 ? 80 : 60;
        description.moveBP = basePower;
        break;
https://bulbapedia.bulbagarden.net/wiki/Electro_Ball_(move)
Mainly it says that the attack power bottoms out at 40, not 60. Also Electro Ball takes stat boosts into account and it seems that the calc code does not.

The damage from other speed based moves (Gyro Ball) may also need to be researched.
Fixed
 
Some fixes/features:
  • toggle option for partners with Battery ability
  • toggle for ally with plus/minus (right now the calc acts like plus/minus is always active)
  • toggles for the effects of Power Split, Power Trick, and Guard Split
 
Moves that lower one of the user's attack stats come with a dropdown that lets people calculate the total damage after using it multiple times, right? Clicking things in the dropdown doesn't seem to do anything in generations before BW.
164947
Edit: I was instructed to tell Austin.
165474
 
Last edited:

Austin

Schismatic
is a Programmeris a Community Contributoris a Forum Moderator Alumnusis a Battle Simulator Moderator Alumnus
it still don't work for me on both Chrome and Firefox :psycry:

importing when the ability on 3rd line:
ability shows "other" before F5
ability shows "other" after F5

importing when the ability on 2nd line:
ability shows "Sheer Force " before F5
ability shows "other" after F5
Was fixed
 

Austin

Schismatic
is a Programmeris a Community Contributoris a Forum Moderator Alumnusis a Battle Simulator Moderator Alumnus
A quick potential suggestion for the damage calculator: for DPP only (excluding RBY and GSC), when Tyranitar is clicked on, the "Sand" option is not automatically turned on to provide more realistic damage calculations vs Tyranitar. As someone who's used the calculator extensively, I think it would benefit all DPP players to have sand automatically selected when Tyranitar is selected. Thanks!
I made a PR for smogon to fix this, I’m not site staff so it may take a bit + honko will need to update the sets but this should be fixed soon. I have no idea why it was never listed in its analysis
E: actually I just fixed it rn
 

SparksBlade

is a Tournament Directoris a Community Leaderis a Community Contributoris a member of the Battle Simulator Staffis a Top Dedicated Tournament Host
Community Leader
I don't know if the same happens with other mons/sets but when I try to importy the following set:


Garchomp-Mega @ Garchompite
Ability: Rough Skin
EVs: 4 Atk / 252 SpA / 252 Spe
Mild Nature
- Earthquake
- Fire Blast
- Draco Meteor
- Stealth Rock

and then try to calc with the custom set, the set got no move.
I've asked friend to try and import that same set in the calculator to see and they obtain the same result.
it's because of the space at the end of first three moves, remove that and import
 

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

Top