Posting my efforts publicly has really enlightened me, as I got an outpouring of support from several different folks generating combinations (thanks pyuk and urkerab!) as well as some HUGE assistance from pre in helping me understand what's properly going on with not only accuracy and evasion, but also modifier application in general.
tl;dr when applying multiple modifiers from Abilities or items,
Speed is used to determine which modifier applies first. Among other things, that means that damage calculations can
change depending on the Speed interactions of the Pokemon involved. Note that this doesn't affect Singles at all (or at least very trivially if it does).
Within a given event in Pokemon, modifiers are applied in the following order:
- Z-move effects
- Move effects
- Effects relative to a particular slot of the field (Wish, Lunar Dance, Future Sight, etc.)
- Effects relative to a particular side of the field (Tailwind, Safeguard, Pledge combo effects, Wide Guard, etc.)
- Field effects (weather conditions, Terrains, Imprison, Ion Deluge, Magic Room, Gravity, etc.)
- Poison Touch
- All other abilities
- Items
- Stall (the ability)
Within those particular orders, further "subpriority" is given.
- For moves, it seems to be based on the move's priority (e.g. Helping Hand is +5 priority), then on the user's Speed, similar to how regular turn order works.
- For Abilities and items, it compares the Pokemon's raw Speed with a non-RNG based Speed tie. It was previously known that this was how things like, say, LightningRod redirection or which Eject Button activates worked. Here's a decent definition:
- Compare the raw Speed stats of Pokemon as they are in the summary screen, without modifiers (no Speed Swap, no Tailwind, no +6 / -6, etc.). Apply the effect to whichever Pokemon is fastest. If there is a tie, apply the effect to the Pokemon that has had the ability the longest amount of time. If both players lead with Speed tying Pokemon, the Pokemon on the side of the player who is the host of the battle (the player with their trainer card on the left of the pre-battle challenge screen) will be considered to have the ability longer. If the host leads two Pokemon that Speed tie, the Pokemon on the left is considered to have had the ability the longest.
- Z-moves also use raw Speed with a non-RNG based Speed tie. Not sure if this ever comes up though, since you couldn't have multiple Z-moves in the same interaction.
- The other effects don't use Speed-based subpriority. I'm not entirely sure if it ever comes up to matter (they would have to share events, like say, be base power modifiers or something).
Let me give an example with base power calculation, since that's
pretty well understood (well, I think the order of many events in the article are now mistaken but hang with me).
Suppose you have a Pokemon using Eruption with 345/367 HP (141 BP Eruption) that has an active Flare Boost, an ally with Battery, and the target has Heatproof. Because Flare Boost (6144/4096), Battery (5325/4096), and Heatproof (2048/4096) are all on different Pokemon,
the Speed of those Pokemon matter when chaining modifiers. Here's the combinations listed below:
137 - [6144, 2048, 5325]
138 - [2048, 5325, 6144]
137 - [6144, 5325, 2048]
137 - [5325, 6144, 2048]
137 - [2048, 6144, 5325]
137 - [6144, 2048, 5325]
So as you can see, if the speed order is Heatproof > Battery > Flare Boost, then Eruption will have 138 BP in the end; if the Speeds are any other way, it will have 137 BP.
To test this, I used the following setup:
- user: Mew at level 100, 200 Sp. Atk at -2, Flare Boost active while burned and 345/367 HP for a 141 BP Eruption
- user ally: Battery
- target: Mew with 168 Sp. Def at -6 with Heatproof
- setting: doubles, spread move
If the BP is 137:
base damage = floor(floor(42 * 137 * 100 / 42) / 50)) +2
base damage = floor(13700 / 50) +2
base damage = 274 +2
base damage = 276
Apply spread move modifier: pokeRound(276 * 3072/4096) = 207
207's damage rolls:
175, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 207
If the BP is 138:
base damage = floor(floor(42 * 138 * 100 / 42) / 50)) +2
base damage = floor(13800 / 50) +2
base damage = 276 +2
base damage = 278
Apply spread move modifier: pokeRound(278 * 3072/4096) = 208
208's damage rolls:
176, 178, 180, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, 208
When the order of Speeds was Flare Boost > Battery > Heatproof, I got a damage roll of 200, indicating 137 BP.
When the order of Speeds was Heatproof > Battery > Flare Blitz, I got a damage roll of 176, indicating 138 BP.
The applicability of this new discovery is far-reaching and this will deserve a LOT of attention from researchers. For accuracy / evasion in particular, it ends up being fairly straightforward:
- Gravity - 6840/4096
- Abilities; order is determined by raw Speed with a non-RNG Speed tie.
- Tangled Feet - 2048/4096
- Hustle - 3277/4096
- Sand Veil- 3277/4096
- Snow Cloak - 3277/4096
- Compound Eyes - 5325/4096
- Victory Star - 4506/4096 for each Victory Star
- Items; order is determined by raw Speed with a non-RNG Speed tie.
- Bright Powder - 3686/4096
- Lax Incense - 3686/4096
- Wide Lens - 4505/4096
- Zoom Lens - 4915/4096