This code is executed when the Poké Radar item is used and when finishing a battle that continues the chain.
- Each time the chain continues, there is a chance for the radar music to change into a more upbeat tune. The chance for this to occur is 2% normally and 4% if it is the player's birthday.
- When the upbeat music is playing, the shiny rate is maxed out at 1/100, which is the normal rate after a chain of 40+.
- The upbeat music cannot start with a chain of 0 or when the Poké Radar is used.
- If the upbeat music is already playing, each time the radar is used or an encounter to +1 the chain finishes, there is a 50% chance the upbeat music changes back to the regular music.
- Think of there being 4 levels of square rings around the player. Ring 1 is the innermost set of tiles, and ring 4 is the outermost set of tiles.
- The game generates a random grass patch starting from ring 1 to ring 4. It does this by randomly picking a side of the square, and then randomly picking a tile on that side.
- If the tile chosen has grass on it, then:
- The game decides the continue rate based on how the last encounter was completed.
- If the Pokémon was captured, the rates are 33%, 53%, 73%, and 93% for rings 1, 2, 3, and 4, respectively.
- Otherwise, if the chain was completed by KO, the rates are 23%, 43%, 63%, and 83% for rings 1, 2, 3, and 4, respectively.
- If the radar is being used to reset the location of the grass patches, it uses the rates based on how the last encounter was completed. In other words, if you catch the last Pokémon when continuing the chain, then all subsequent radar uses will use the higher rates until another Pokémon is encountered.
- The game rolls a random number to decide if the chain will continue for each ring. If this roll passes, then a violently-shaking grass patch will be generated. Otherwise, a regular grass patch is generated.
- A violently-shaking grass patch uses the chain shiny rate (see this section). If this shiny roll is passed, the patch will be forced shiny with the shiny icon on the map. If this shiny roll fails, it will be forced nonshiny.
- If the chain is 0, all violently-shaking grass patches will be forced antishiny.
- See this section below for how these grass patches can have different appearances than how they were generated.
- The game decides the continue rate based on how the last encounter was completed.
- If the tile does not have grass on it, then no grass patch is generated for this ring.
- After all 4 rings have been checked for new grass patches, the game randomly decides a location to put a weakly-shaking grass patch within rings 1, 2, or 3. If the location of this weakly-shaking grass patch overlaps with one of the previous violently-shaking or regular grass patches, it will not overwrite and no weakly-shaking grass patch will be generated. The weakly-shaking grass patch is the one that automatically ends your chain if you step on it.
- If no grass patches were generated, such as if you were on an edge and all random rolls ended up on tiles with no grass, the chain ends.
- The violently-shaking and regular grass patches have a chance of changing appearance visually. What this means is that a regular grass patch can appear to be a violently-shaking grass patch, but behave like a regular one that has a high chance to break your chain.
- A true violently-shaking grass patch contains the chained Pokémon species. A true regular grass patch has a random assortment, which can break your chain if you run into a non-chained species.
- A patch of grass that was initially violently-shaking has a 20% chance to appear like a regular grass patch, and an 80% chance to appear correctly like a violently-shaking grass patch.
- A patch of grass that was initially a regular patch has a 10% chance to appear like a violently-shaking grass patch, and a 90% chance to appear correctly like a regular grass patch.
- This implies that it is still best to go for the grass patches in the most distant rings since they are more likely to have initially generated as violently-shaking.
- The weakly-shaking grass patch does not change appearance. The shiny patch can change appearance beneath the shiny sparkles.
- True violently-shaking grass is either forced shiny or forced antishiny, so the only way to get a shiny Pokémon from a violently-shaking grass patch with no sparkle effect is if this was actually a regular patch that changed appearance to violently-shaking.
- The shiny rate of violently-shaking grass starts at 1/8100. However, note that on first use of the radar, with a chain of 0, all of the violently-shaking grass patches are forced antishiny.
- For each additional +1 to the chain, the denominator of the shiny rate decreases by 200, up to a maximum of 1/100 at a chain of 40.
- Capturing a shiny Pokémon with the upbeat music active does not reset the shiny rate.
- Capturing a shiny Pokémon without the upbeat music active resets the shiny rate to 1/8100 without resetting the chain length (which also controls IVs).
- KOing the shiny Pokémon or resetting over a shiny patch without the upbeat music present does not reset the shiny rate.
- All regular shaking grass patches use the standard shiny rates (e.g. with Shiny Charm).