# Can PokéTransporter make a Pokémon shiny

pokemon-bankpokemon-sixth-generation

Warning! This is going to get technical!

The method of determining whether a Pokémon is shiny in Generation III-V was the following:

1. Use the bitwise XOR operation on the 16-bit Trainer ID and 16-bit Secret ID, this results in a combined 16-bit OT-ID.
2. Use the bitwise XOR opeartion on the High Bytepart and Low part of the 32-bit Pokémon ID, this results in a combined 16-bit P-ID.
3. Use the bitwise XOR operation on the OT-ID and the P-ID, this results in a 16-bit Shiny Value.
4. If the Shiny Value is lower than 8, the Pokémon is shiny. In other words, if the 13 most significant bits are all 0, the Pokémon is shiny.

This results in a chance of 1:8192 (2^13) of a Pokémon being shiny, assuming TID, SID and PID were uniformly random.

Since Generation VI, this process has been massively simplified:

1. Use the bitwise XOR operation on the OT's 12-bit TSV (Trainer Shiny value) and the Pokémon's 12-bit ESV (Egg Shiny Value).
2. If the result is 0 (TSV and ESV are the same), the Pokémon is shiny.

This results in a chance of 1:4096 (2^12) of a Pokémon being shiny, assuming TSV and ESV were uniformly random.

Recent research has shown that the TSV is calculated as `TID XOR SID >> 4`, that is, the 12 most significant bits of the bitwise XOR operation applied to the OT's TID and SID. The ESV is calculated in a similar fashion based on the Pokèmon's PID. Using this information, the above Gen VI shiny check algorithm can be reformulated as such:

1. Use the bitwise XOR operation on the 16-bit Trainer ID and 16-bit Secret ID, this results in a combined 16-bit OT-ID.
2. Use the bitwise XOR opeartion on the High Byte and Low Byte of the 32-bit Pokémon ID, this results in a combined 16-bit P-ID.
3. Use the bitwise XOR operation on the OT-ID and the P-ID, this results in a 16-bit Shiny Value.
4. If the Shiny Value is lower than 16, the Pokémon is shiny. In other words, if the 12 most significant bits are all 0, the Pokémon is shiny.

By now, you probably guessed where this is going.

Let's say I have a Pokémon on a Gen V game whose Shiny Value in step 3 is between 8 and 15. This means that the first 12 bits are all 0 and the 13th bit is 1, resulting in a non-shiny Pokémon. If I use PokéTransporter to transfer this Pokémon to Pokémon Bank and thus Gen VI, the shiny check will notice that the first 12 bits of the Shiny Value are 0 (or rather, it will calculate TSV and ESV and notice they're the same) and conclude that the Pokémon is shiny! Unless of course PokéTransporter checks for this case and changes the PID in case it occurs.

Can anyone confirm or disprove this behaviour?

The implications are very interesting, by the way. Depending on when and how exactly this check happens in relation to the legality check, this loophole could possibly be used to circumvent the "no shiny" rule on Reshiram and Zekrom in Gen V as well as on event Pokémon, who are usually unavailable as shinies.

Alright, I managed to find an answer after all. Here's what happened:

I used light math and a well-known tool that helps with RNG abuse to craft myself 2 Pokémon on Gen V games with the following characteristics:

1. PID `7914C235` Shiny Value 6 -> shiny
2. PID `1B096AC5` Shiny Value 13 -> non-shiny in Gen V, theoretically shiny in Gen VI

I then transferred both Pokémon via PokéTransporter and checked their PID again. The result:

1. PID `7914C235` Shiny Value 6 -> shiny
2. PID `9B096AC5` Shiny Value 32781 (=13+2^15) -> non-shiny

This leads to the conclusion that PokéTransporter checks for this case. If and only if it occurs, it changes the Pokémon's PID, probably by inverting the most significant bit (adding or subtracting 2^31 depending on whether or not the PID is above or below that value originally). I could test and confirm how it's changed by RNG'ing a Pokémon with a PID of `80000000` or more with a Shiny Value between 8 and 15, but this would bring little new and relevant information.

So, the gist of it is this: PokéTransporter checks the PID and compares it against the TID/SID. If the resulting Shiny Value is between 8 and 15 and would thus make a non-shiny Pokémon become shiny, it inverts the PID's MSB to force the Pokémon to be non-shiny.

Since the PID is no longer used for the various purposes it served up until Generation V, this change doesn't affect anything but shininess. It also affects legality in that a Pokemon that was not created in Generation VI+ may not have a PID/TID/SID combination that would result in a Shiny Value between 8 and 15. If it does, it was hacked into Gen VI+ without setting the Pentagon flag (or similar flags usedin later games) to make it look like a Gen V Pokemon by someone who didn't know this and messed up the PID.