Welcome to Smogon! Take a moment to read the Introduction to Smogon for a run-down on everything Smogon, and make sure you take some time to read the global rules.
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:
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.
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
Aura Break - 0xC00
Rivalry and gender is not the same - 0xC00
-ate Abilities - 0x1333
Iron Fist - 0x1333
Reckless - 0x1333
Rivalry and gender is the same - 0x1400
Battery - 0x14CD
Sheer Force - 0x14CD
Sand Force - 0x14CD
Analytic - 0x14CD
Tough Claws - 0x14CD
Fairy Aura / Dark Aura - 0x1548
Technician - 0x1800 (note that Technician will check if the previous modifiers would have pushed this above/below 60 BP)
Electric / Grassy / Psychic Terrain (offensive) - 0x1800
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
Slow Start (of note, don't forget that special Z-moves are affected by Slow Start) - 0x800
Defeatist - 0x800
Flower Gift - 0x1800
Guts - 0x1800
Overgrow / Blaze / Torrent / Swarm - 0x1800
Flash Fire - 0x1800
Solar Power - 0x1800
Plus / Minus - 0x1800
Steelworker - 0x1800
Huge Power / Pure Power - 0x2000
Water Bubble (offensive) - 0x2000
Stakeout - 0x2000
Thick Fat - 0x800
Water Bubble (defensive) - 0x800
Choice Band / Choice Specs - 0x1800
Thick Club - 0x2000
Deep Sea Tooth - 0x2000
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
Flower Gift - 0x1800
Marvel Scale - 0x1800
Grass Pelt - 0x1800
Fur Coat - 0x2000
Eviolite - 0x1800
Assault Vest - 0x1800
Deep Sea Scale - 0x2000
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.
Spread move - 0xC00
Parental Bond - 0x400
Weather - 0x1800 for boosting, 0x800 for weakening
Crit - 0x1800
Random factor
STAB (Adaptability) - 0x1800 (0x2000)
Type effectiveness - So long as we only support two types, 0.25x-4x
Burn - 0x800
Final damage modifiers
Z-moves into Protect - 0x400
1 damage modifier
16 bit constraint (maximum damage should never be higher than 65535)
Final damage modifiers
OZY research etc.
Screens - Singles = 0x800, Doubles = 0xAAC
Neuroforce - 0x1400
Sniper - 0x1800
Tinted Lens - 0x2000
Multiscale / Shadow Shield - 0x800
Fluffy (contact moves) - 0x800
Friend Guard - 0xC00
Solid Rock / Filter / Prism Armor - 0xC00
Fluffy (Fire-type moves) - 0x2000
Metronome (item) - you have this right
Expert Belt - 0x1333
Life Orb - 0x14CC
Resist Berries - 0x800
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.
Apply all Autotomizes (there is a weight minimum of 0.1kg).
Apply Heavy Metal (there is no weight maximum)
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).
Changing your HP/Atk/Def should have no affect on a Special Attack if I'm not mistaken, so I assume you mean "The calculator does not update the Hidden Power's type and base power based on changes to DVs?" (If you look, its still HP Ice 70). In the particular case of your screenshot, I believe 7/14/13/15/15/15 would still be base power 70, and Water has the same type effectiveness against Aerodactyl as Ice, so the end result should be the same in this case?
Please correct me if I'm misunderstanding - I've filed a bug to have changes to DVs/IVs reflected as changes to the Hidden Power type/BP, but for now you'll need to adjust the BP and type manually using the drop downs beside the move. :(
Thanks. This isn't a regression, we've never supported this AFAICT. I've filed a bug to make sure we have import/export parity with the teambuilder on the client, but this is going to take some time to implement :(. In the meantime you're stuck changing 'Gastrodon-East' to 'Gastrodon' before importing, sorry.
Moves that lower user's stats (i.e. Leaf Storm, Superpower, Draco Meteor) seems to not working when clicking Twice or even 5 times to show the total damage output.
i discovered an issue with the way stat boots and drops are measured in gsc. in gens 1 and 2 when you drop your speed stat by one stage it's dropped to 66/100 and not 67/100 like in gen 3 and above. the damage calc however implements 67/100 for gen 2
Is there a nodejs version? I'd really like to use this in my own project. I tried to convert it by hand, but it was taking forever, and once an update comes out, well, I'd be screwed.
I pasted an importable of a 1v1 team on the Import/Export text box, clicked the "Import" button, clicked on "Only show imported sets", and then tried to select a set from the newly imported Pokemon. It showed the Pokemon and the spread all right, but it doesn't seem to display the moves, but instead shows something like this
[21:11:22] Attid(UwU)de:In the damage calc
[21:11:40] Attid(UwU)de:When I import set(s), the set moves are not loading
[21:12:13] jetou :https://www.smogon.com/forums/threads/3593546
[21:16:58] Attid(UwU)de:https://imgur.com/loeG2kJ This shod be proof enough, right?
[21:17:37] jetou:Yes, they can reproduce it on their end, granted you explain the reproduction steps well enough.
Just wanted to make sure I did everything correctly......
This made me think about a potential new feature for the Damage Calculator with healing, stat raising moves, and Protect (although would probably be somewhat niche).
It's where you can calculate if a move would be a 2HKO, 3HKO, ect. when factoring in Protect, Leftovers, Wish, Recover, and Calm Mind/Curse.
This would be useful in those scenarios where you have use a move like Leaf Storm/Super Power against a wall with recover, or in those moments where 2 left over recoveries turn a 2HKO into a 3HKO.
It can also create the NKO (Never Knock Out) as a move may be too weak initially, the opponent can heal/boost off any potential damage, or when your stats are dropping.
This probably would be too much effort to code for such a niche idea, but it would be interesting.
It's well known that spread damage in Gen 3 is split between 100% damage for moves that target everyone (Earthquake, Explosion, etc.) and 50% damage for moves that only target both opponents (Razor Leaf, Surf, etc.). It's just not implemented yet, nor is the actual correct order for the Gen 3 damage formula in general.
Which brings up the question - if we fix the Gen 3 damage formula in the damage calc (which would require work beyond just this line, in the same way we still need to implement OZY's move order research in Gen 6/7), would we instead get people thinking its wrong compared to PS? (ie. is it better to be wrong and consistent with PS, where most people are going to be playing when using the calc, or correct but inconsistent and less useful when trying to determine how things will work on PS).
I think both the simulator and calc should be corrected (obviously), but the simulator is probably much higher value to fix first.
Which brings up the question - if we fix the Gen 3 damage formula in the damage calc (which would require work beyond just this line, in the same way we still need to implement OZY's move order research in Gen 6/7), would we instead get people thinking its wrong compared to PS?
I skimmed through the disassembly extremely quickly and compared to the damage calc code, and it appears that everything is already done in exactly the right order except for this specific line being wrong (move target "8" is both opponents, and only when two opponents exist) and physical attacks ensuring minimum 1 damage before the + 2 at the end, but no such check for special attacks.
It's well known that spread damage in Gen 3 is split between 100% damage for moves that target everyone (Earthquake, Explosion, etc.) and 50% damage for moves that only target both opponents (Razor Leaf, Surf, etc.). It's just not implemented yet, nor is the actual correct order for the Gen 3 damage formula in general.
What i think is a bug with the +1 All Stats button
from what i understand it is supposed to emulate the effects of z-celebrate/hold hands/happy hour
When clicking on the button and then checking Stored Power, it shows its BP as 140 (and calcs 140 BP) when in game it should be 120. likely a bug not certain but im psure thats a mistake