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 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:
Example of accurate output
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.
Example of accurate output
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.
- 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)
- Flare Boost - 0x1800
- Toxic Boost - 0x1800
- Strong Jaw - 0x1800
- Mega Launcher - 0x1800
- Heatproof - 0x800
- Dry Skin - 0x1400
- Muscle Band - 0x1199
- Wise Glasses - 0x1199
- Type-boosting items - 0x1333
- Orbs - 0x1333
- Gems - 0x14CD
- Solar Beam / Solar Blade - 0x800
- Me First - 0x1800
- Knock Off - 0x1800
- Helping Hand - 0x1800
- Charge - 0x2000
- Facade - 0x2000
- Brine - 0x2000
- Venoshock - 0x2000
- Retaliate - 0x2000
- Fusion Bolt / Fusion Flare - 0x2000
- Grassy Terrain / Misty Terrain (defensive) - 0x800
- 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.
+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.
+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.
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)
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.
See
SadisticMystic's research.
- 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).
See
DaWoblefet's research.
- Apply boosts/drops (+6/-6) and floor.
- Apply all other Speed modifiers except paralysis and pokeRound.
- Apply paralysis and floor.