Data Pokemon Sun/Moon Battle Mechanics Research

Marty

Always more to find
is a member of the Site Staffis a Battle Server Administratoris a Programmeris a Super Moderatoris a Pokemon Researcher
Super Moderator
What triggers first... Soul-Heart or Power of Alchemy/Receiver?
Say, If a Passimian and a Magearna are on your side, and Magearna faints, will Passimian will receive its Soul-Heart and then immediately get a Soul-Heart boost? (This would/should happen if Receiver procs first)
If Soul-Heart procs first, nothing special would happen I guess.
Receiver takes over the Ability before the faint process finishes. I actually added it to the Gen 7 to-do list a week or two after the games came out.
 
Can anyone confirm some Stakeout mechanics? It looks like in the OP that everything isn't totally clear. In a situation where a Pokémon faints and a replacement is sent in, Stakeout does not activate, correct? It only activates when the target is switching? And it is currently unknown if U-turn, Volt Switch, etc. activate Stakeout?

Thank you to whomever can answer!
 
Can anyone confirm some Stakeout mechanics? It looks like in the OP that everything isn't totally clear. In a situation where a Pokémon faints and a replacement is sent in, Stakeout does not activate, correct? It only activates when the target is switching? And it is currently unknown if U-turn, Volt Switch, etc. activate Stakeout?

Thank you to whomever can answer!
IIRC, pivoting moves also activate Stakeout, because they're switching out afterwards
 

E4 Flint

-inactive in BH due corrupt leader-
is a member of the Site Staffis a Community Leaderis a Battle Server Moderator
Community Leader
re: (hacked) arceus queries. Most of these are relevant to the BH meta and I just wanted to confirm since it will affect that it
  • I wanted to confirm whether Arceus shows that it is Normal type in-game when it has the form of any of its types. It's pretty difficult to find a source on the internet (i was only able to find this, and there the normal type is not visible). From this same link and other feedback, the in-battle display shows only the true type effectiveness on the Arceus regardless of the visible type. This is a pretty significant difference than just displaying its Normal type openly
  • Assuming the current mechanics are correct, earlier in this thread, it said that the Imposter takes on the type of an Arceus' visible form and not the true type it has with Multitype and a Plate. I wanted to confirm if this is the correct behavior for a hacked arceus as well i.e. a (normal type) Arceus with a different ability than Multitype and a different item displaying that it is Grass type means its Imposter is grass type (as seen in this replay, Turn 37)
Thanks!
 
Last edited:
Actual in-game footage of the "Arceus bluff":


Cosmetically, this is Arceus-Dark, and I even left the Dread Plate on so as not to mess with too many variables for this test. However, Protean is not Multitype, so on the summary screen from clicking its minisprite you can see that it doesn't get credit for Dark typing. (If you have an Arceus or Silvally with Protean, the ability does not even pop up an announcement when you use moves, no matter what type those moves are.)


Eventually a Ditto transforms into the bluffed Arceus, either by regular old Transform or by Imposter--it doesn't matter which. You can't see your opponent's ability or item from clicking their minisprite, but you can see their type, and despite Ditto copying the Arceus-Dark appearance, it's still a regular old normal type.


The move selection screen doesn't buy the fake either. Karate Chop would be SE against both Normal and Dark, but if it really thought the opponent was Dark, Fell Stinger would show up as super effective too. It doesn't.
 
Here are three facts that I think I know. Can you guys confirm them?

When dancer calls a move that targets another Pokemon, it targets a random opponent and never targets an ally.
When a Pokemon uses a move that calls another move, the last move used is set to the "caller move" and not the "callee move". For example, if a Pokemon is encored after using tri attack though using nature power, then it gets locked into nature power and not tri attack. (I know this isn't the case with the metronome item; it seems to vary depending on which move/ability/item is used to check the last move used)
A galvanized normal-type status move will activate a target's lightning rod.
 

E4 Flint

-inactive in BH due corrupt leader-
is a member of the Site Staffis a Community Leaderis a Battle Server Moderator
Community Leader
Thanks for verifying.
Eventually a Ditto transforms into the bluffed Arceus, either by regular old Transform or by Imposter--it doesn't matter which. You can't see your opponent's ability or item from clicking their minisprite, but you can see their type, and despite Ditto copying the Arceus-Dark appearance, it's still a regular old normal type.


The move selection screen doesn't buy the fake either. Karate Chop would be SE against both Normal and Dark, but if it really thought the opponent was Dark, Fell Stinger would show up as super effective too. It doesn't.
Just to confirm, does this make the behavior in the above replay not the correct one (tldr Spectral Thief was able to affect Chansey impostered as Arceus-Grass as it is Grass-type)
 

Kalalokki

the time for spooks
is a Smogon Social Media Contributoris a Battle Server Moderator
does Pursuit becomes base 120 damage when is used by a Pokemon with Technician since the moves mechanics double the damage upon switch a base 40 base power move power by Technician becomes based 60 then does the move doubles when the target is leaving the field becoming base 120?
No. This sort of thing doesn't belong in this thread as well.
 
Last edited:
I managed to get some readings on Gyro Ball at both ends of the speed spectrum, and in both cases there are implementation details the sim doesn't get right for now.

In the first battle, we attempt to get some very fast Pokemon. I have it saved as a battle video at my end, but each save file has a limit of 10 battle videos uploaded to the public at once; I don't want to take any of the existing ones down so it doesn't have a code yet. However, DaWoblefet was also in on the test and captured an actual video, which is what's at the link.

There's a long-standing anecdote about the phenomenon "If a Pokemon has at least 1809 speed, it can continue to outspeed slower things even when Trick Room is up." But what's really going on with speed and turn order that gives rise to that behavior is a more fundamental series of steps:
1. Start with the original speed stat
2. Apply all stat modifiers and other effects (such as Swift Swim or Tailwind)
3. If the speed is greater than 10000, set it to 10000
4. If Trick Room is in effect, replace speed with (10000 - speed)
5. If the speed is 8192 or higher, subtract 8192 (a truncation to 13 bits of precision)

After turn 4, Swoobat (which is max-speed Jolly) has 213 attack, and a starting speed of 359 at +5 with Tailwind up, for a total of 2512. Ditto, meanwhile, came in under a Tailwind of its own with +6 Speed (as well as +1 Defense) on a Baton Pass, and was immediately given a 504 as the "step 1 speed" from Speed Swap, Surge Surfer as its ability from Skill Swap, and a Quick Powder from Trick, so it has 198 defense, and a speed stat of 16128--the highest "speed" it's possible for any Pokemon to reach under current rules. Of course, that's so fast that it hits the cap of 10000, which then gets truncated to 1808 for the purpose of effective turn order, so on turn 5 Swoobat will actually be able to act before Ditto can transform, and that action is a Gyro Ball.

The question here was "at what point in that series of speed steps does Gyro Ball draw the speed it plugs into the formula?" If Gyro Ball used the full step-2 speed of 16128, then Swoobat's Gyro Ball would hit for the maximum of 150 power; if it drew from the step-3 speed (after it's been capped out at 10000), then Gyro Ball would be 99 power; or if it drew from the final effective turn-order speed (1808 in this case) then Gyro Ball would be 17 power. Luckily, these figures are far enough apart that they have no overlap between them:
252 Atk Swoobat Gyro Ball (150 BP) vs. +1 252 HP / 0 Def Ditto: 116-137 (38.6 - 45.6%) -- guaranteed 3HKO
252 Atk Swoobat Gyro Ball (99 BP) vs. +1 252 HP / 0 Def Ditto: 77-91 (25.6 - 30.3%) -- guaranteed 4HKO
252 Atk Swoobat Gyro Ball (17 BP) vs. +1 252 HP / 0 Def Ditto: 14-17 (4.6 - 5.6%) -- possibly the worst move ever

As it turns out, the move from the actual battle dealt 85 damage, which confirms case 2: Gyro Ball does not consider a Pokemon's speed until after it has been subject to the hard cap of 10000. Simulator behavior in this case shows that it's considering the entire 16128, which is now known to be incorrect.

By contrast, the second battle is about getting a very slow Pokemon. Level 39 is as high as Shuckle can go while allowing its speed on a 0- nature to stay as low as 7, and 7 is as high as it can start out in order to round down to 1 at -6. Then on top of that, Shuckle holds an Iron Ball to cut its speed even further, and it has nowhere left to round down but 0. Trivially, if you have 0 speed then your opponent is obviously "at least 6 times as fast as you are", which is colloquially what it takes to get max power out of Gyro Ball, but the game expresses that condition in a particular way, and the game also really doesn't like dividing by 0, which is what that formula would task it with doing.

The first few Gyro Balls in the video hit for just 1/2/4 damage depending on the type matchup. But then a level 1 Chimchar, who resists the attack, switches in and takes more damage than I originally expected, and it turns out the explanation is pretty simple after all: If a Pokemon uses Gyro Ball when its own speed rounds down to 0, the move is automatically set to 1 base power, no matter what the opponent's speed is--even if that's also 0.The rest of the battle is all about testing various permutations of critical hit and Life Orb with the type matchups, but it's all consistent with "the move is always 1 power", with the blatant except that when Stantler comes in for the second time, Ditto has lost its Iron Ball and hasn't been paralyzed yet, so on that turn it has 1 speed and the Gyro Ball is 150 power, in a damage range to be expected for that. The final hit, where the L100 Ditto comes in and transforms into Shuckle for its own "0 speed vs. 0 speed" test, dealt 16 damage, more than the first Shuckle vs. Ditto hit did because of level superiority and how that plays into the damage formula.

The simulator test for this case reveals that Gyro Ball seems to default to 1 power in the 0 speed vs. 0 speed case, but 0 speed vs. anything greater than 0 is taken as a 150 power move.

I don't have video footage for it, but one more observation is easy enough to set up in-game using a wild Ditto: If you use Electro Ball against a target with 0 speed, no matter what your own speed is, the move hits at the lowest possible power level of 40, rather than the highest level of 150. One more case where it seems to be saying "I hate trying to divide by 0, so I'll just default to the low end of the power range instead."
 

Marty

Always more to find
is a member of the Site Staffis a Battle Server Administratoris a Programmeris a Super Moderatoris a Pokemon Researcher
Super Moderator
So DragonWhale mentioned to me a little while ago that Shell Trap fails when the physical hit was Sheer Force boosted, and while I was thinking of how to implement this on PS I wondered if it completely canceled the effect or merely delayed it.

As I was testing it I saw that yes, a Sheer Force boosted move just didn't count as a hit, and getting hit after during the same turn still triggered Shell Trap. However, I accidentally "discovered" something Doubles players might know already. Shell Trap triggers immediately after being hit by an opposing physical attack, even if there are other Pokemon still left to move, and then your turn is over and you won't move again at -3 priority later. This is Pursuit-tier abnormal behaviour! Up to you whether you consider this good or bad for Shell Trap as a whole.
 

Marty

Always more to find
is a member of the Site Staffis a Battle Server Administratoris a Programmeris a Super Moderatoris a Pokemon Researcher
Super Moderator
In my ongoing effort to write accurate descriptions of everything in every gen, I've done some more testing on Electro Ball and Gyro Ball in other gens to supplement SadisticMystic and DaWoblefet's Gen 7 tests above.

Turns out the power calculation for both changed in Gen 6, because before that their solution to dividing by 0 was to divide by 1 instead.

Here are my notes:
Gen 4:
user 0 speed vs target 0 speed -> 1 power
user 1 speed vs target 0 speed -> 1 power
user 0 speed vs target 438 speed -> 150 power

Gen 5:
user 0 speed vs target 0 speed -> 1 power
user 1 speed vs target 0 speed -> 1 power
user 0 speed vs target 438 speed -> 150 power
user 0 speed vs target 1 speed -> 26 power

Gen 6:
user 0 speed vs target 0 speed -> 1 power
user 1 speed vs target 0 speed -> 1 power
user 0 speed vs target 438 speed -> 1 power
user 0 speed vs target 1 speed -> 1 power
user 1 speed vs target 1 speed -> 26 power
Gen 5:
user 0 speed vs target 0 speed -> 40 power
user 1 speed vs target 0 speed -> 60 power
user 7 speed vs target 0 speed -> 150 power
user 0 speed vs target 438 speed -> 40 power
user 0 speed vs target 1 speed -> 40 power

Gen 6:
user 0 speed vs target 0 speed -> 40 power
user 1 speed vs target 0 speed -> 40 power
user 7 speed vs target 0 speed -> 40 power
user 0 speed vs target 438 speed -> 40 power
user 0 speed vs target 1 speed -> 40 power

Gen 6-7 descriptions
Power is equal to (25 * target's current Speed / user's current Speed) + 1, rounded down, but not more than 150. If the user's current Speed is 0, this move's power is 1.
The power of this move depends on (user's current Speed / target's current Speed), rounded down. Power is equal to 150 if the result is 4 or more, 120 if 3, 80 if 2, 60 if 1, 40 if less than 1. If the target's current Speed is 0, this move's power is 40.

Gen 4-5 descriptions
Power is equal to (25 * target's current Speed / user's current Speed) + 1, rounded down, but not more than 150. If the user's current Speed is 0, it is treated as 1 instead.
The power of this move depends on (user's current Speed / target's current Speed), rounded down. Power is equal to 150 if the result is 4 or more, 120 if 3, 80 if 2, 60 if 1, 40 if less than 1. If the target's current Speed is 0, it is treated as 1 instead.
 
The damage cap is 721,898,992 20,660,732,484 2,009,741,660 343,597,200 1,048,575 a mere 65,535. Furthermore, dealing 0 damage is still possible in current generations, not even considering the trivial cases of False Swipe vs. a Pokemon that already has just 1 HP left, or breaking Mimikyu's disguise or Shedinja's Focus Sash.

As part of my ongoing investigation into overflowing registers during damage calculation, the first result I ever came across to "confirm" that mechanic was a 74-damage hit that was naively supposed to calculate as about 10 million. It certainly proved something fishy was going on, but not in the way that my model expected: I had the post-rollover damage range pegged as 170-201, so this figure was too low even by that standard. A closer examination of the unusual attack combination involved in that test revealed that it didn't actually work the way I was expecting, but in that case the damage range shouldn't be 170-201...it should have been around 800-900 thousand, and the mystery of 74 was now only further away. In looking over the numbers to try to explain what could possibly cause that hit, I found a possible cause which both 1) indicated that that first test was only confirmed due to an extreme stroke of luck (getting a 1/16 damage roll where any of the other 15 rolls would have been a clean KO, and I never would have suspected a thing about this particular corollary) and 2) moved the damage cap lower and easier to reach than ever.

Here's the battle video demonstration on USUM: UJ8W-WWWW-WWWS-9YPA (you can skip ahead to turn 14 if you want). The idea was to set it up so that Lucario could take potshots at a Sturdy Aron for up to 32 consecutive turns, starting with turn 2. Obviously since it's Sturdy, these hits are supposed to go for about 55,000-65,000 damage, but leave Aron with 1 HP instead, and it recovers back to full in time for next turn. However, if (and only if) Lucario rolls the max roll, the damage is slated to be exactly 65,536. On the turn where that roll finally comes, Aron takes the hit, super effectively...but nothing happens. Aura Sphere is suddenly the new Splash!

What's actually going on here is an undisclosed final step, taking place after everything in the site's own reckoning of the damage formula. In-game HP values never take more than 2 bytes to store (in fact, 10 bits, but they might as well split on whole-byte boundaries so rounding up to 16 bits just makes sense), and 2 bytes are all that's allocated to them. So as not to create a type mismatch when it comes to trying to subtract numbers, and also not writing willy-nilly into a region of memory that controls something other than HP, the game's solution is to truncate the damage figure all the way down to 16 bits at the very end, just before it can be applied.

Back in BW, as the aforementioned damage account draws from, the "make sure minimum damage is always at least 1" check still had a few multipliers that could kick in after it, including Reflect and Multiscale. Those have since been "fixed" in current games so that damage will always be at least 1 even in spite of their presence, but there's still one vector left. With this 16-bit truncation mechanic, a 64,880-damage hit (as would be the case from the 99% roll) remains 64,880, but the top roll of 65,536 truncates to exactly 0 damage. And based on the fact that in this battle, that hit is allowed to remain at 0, we can prove that the truncation happens after the minimum-of-1 step.

"Aura Sphere is the new Splash"...really has a nice ring to it, come to think of it. A ring that looks suspiciously like the number 0, I might add.
 
Last edited:
The damage cap is 721,898,992 20,660,732,484 2,009,741,660 343,597,200 1,048,575 a mere 65,535. Furthermore, dealing 0 damage is still possible in current generations, not even considering the trivial cases of False Swipe vs. a Pokemon that already has just 1 HP left, or breaking Mimikyu's disguise or Shedinja's Focus Sash.

As part of my ongoing investigation into overflowing registers during damage calculation, the first result I ever came across to "confirm" that mechanic was a 74-damage hit that was naively supposed to calculate as about 10 million. It certainly proved something fishy was going on, but not in the way that my model expected: I had the post-rollover damage range pegged as 170-201, so this figure was too low even by that standard. A closer examination of the unusual attack combination involved in that test revealed that it didn't actually work the way I was expecting, but in that case the damage range shouldn't be 170-201...it should have been around 800-900 thousand, and the mystery of 74 was now only further away. In looking over the numbers to try to explain what could possibly cause that hit, I found a possible cause which both 1) indicated that that first test was only confirmed due to an extreme stroke of luck (getting a 1/16 damage roll where any of the other 15 rolls would have been a clean KO, and I never would have suspected a thing about this particular corollary) and 2) moved the damage cap lower and easier to reach than ever.

Here's the battle video demonstration on USUM: UJ8W-WWWW-WWWS-9YPA (you can skip ahead to turn 14 if you want). The idea was to set it up so that Lucario could take potshots at a Sturdy Aron for up to 32 consecutive turns, starting with turn 2. Obviously since it's Sturdy, these hits are supposed to go for about 55,000-65,000 damage, but leave Aron with 1 HP instead, and it recovers back to full in time for next turn. However, if (and only if) Lucario rolls the max roll, the damage is slated to be exactly 65,536. On the turn where that roll finally comes, Aron takes the hit, super effectively...but nothing happens. Aura Sphere is suddenly the new Splash!

What's actually going on here is an undisclosed final step, taking place after everything in the site's own reckoning of the damage formula. In-game HP values never take more than 2 bytes to store (in fact, 10 bits, but they might as well split on whole-byte boundaries so rounding up to 16 bits just makes sense), and 2 bytes are all that's allocated to them. So as not to create a type mismatch when it comes to trying to subtract numbers, and also not writing willy-nilly into a region of memory that controls something other than HP, the game's solution is to truncate the damage figure all the way down to 16 bits at the very end, just before it can be applied.

Back in BW, as the aforementioned damage account draws from, the "make sure minimum damage is always at least 1" check still had a few multipliers that could kick in after it, including Reflect and Multiscale. Those have since been "fixed" in current games so that damage will always be at least 1 even in spite of their presence, but there's still one vector left. With this 16-bit truncation mechanic, a 64,880-damage hit (as would be the case from the 99% roll) remains 64,880, but the top roll of 65,536 truncates to exactly 0 damage. And based on the fact that in this battle, that hit is allowed to remain at 0, we can prove that the truncation happens after the minimum-of-1 step.

"Aura Sphere is the new Splash"...really has a nice ring to it, come to think of it. A ring that looks suspiciously like the number 0, I might add.
It's kinda funny to end up realizing it was actually much simpler with a mod 65536 operation to the damage amount.

But then again, it makes sense. Why would they bother using more bits for damage when not even Blissey reaches at least 1000 HP? After all, it took a glitch to notice the modulo operator.
 
It's a mod-65536 in addition to all the 4-byte chokepoints that have been documented. Otherwise in the Growlithe test, there would still have been a roll for 10 damage, but no roll that could deal exactly 9.

There's one other chokepoint that I could conceivably prove the existence of, but in light of this 65536 rollover, doing so would require a setup in which one of the damage rolls was set to be exactly 1,048,576. Constructing such a thing could require factoring up to 800 different numbers in search of the nicest one.
 
SadisticMystic Something I just thought of and don't remember being discussed; does metronome (item) get effected by this glitch too? Namely if Metronome already have its 2X boost, you use the glitch, then Rollout again, does the multiplier stay or reset?
 
Setting up Rollout storage just to use Rollout again immediately doesn't really exhibit much in the way of abnormal behavior, it just corrects the dangling multiplier by counting as the "real" last turn of Rollout, complete with a Metronome-6 boost, then it stops and you're free to pick any move next turn without being locked in.

If you switch to another move that isn't Rollout, then that only counts as turn 1 from Metronome's perspective and you get no boost from that item.
 
"Sheer Force does not prevent Emergency Exit from actuating." What precisely is implied by this? If I'm not mistaken, Sheer Force just helped moves with reactions. I suspected that Emergency Exit was initiated by means of all moves making the client go to half HP. Furthermore,
Manga zuki regarding the matter of that capacity, if Golisopod/Wimpod were to get hit by Spikes/Stealth Rock, and that makes it achieve half HP after exchanging in, will the capacity actuate? Is Wimpod/Golisopod essentially futile by then where its capacity enacted?
 
"Sheer Force does not prevent Emergency Exit from actuating." What precisely is implied by this? If I'm not mistaken, Sheer Force just helped moves with reactions. I suspected that Emergency Exit was initiated by means of all moves making the client go to half HP.
Emergency exit doesn't always work. For example, attacks that have been powered up by sheer force cannot activate emergency exit. Such attacks also do a bunch of other interesting things, like prevent life orb recoil.
https://bulbapedia.bulbagarden.net/wiki/Emergency_Exit_(Ability)
https://bulbapedia.bulbagarden.net/wiki/Sheer_Force_(Ability)
I don't know the answer to your second question, though.
 
If Golisopod has more than 50% health when it switches in, but something like Stealth Rock immediately takes away enough health to cross the 50% boundary, it will pop up Emergency Exit and force another switch (unless it's the last mon, of course). If it already has less than 50% when it comes in, Emergency Exit can't pop up, no matter if it takes hazard damage on top of that, unless it goes back up over 50% health first (using something like Leech Life, probably) and then crosses that level again in the downward direction.
 

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

Top