Where is the shiny rate?
Closed this issue · 4 comments
I couldn't find a place to comment or message, so this may not be the appropriate spot.
What file affects the shiny rate of wild pokemon encountered?
There is no one particular thing that determines the shiny "rate" in generation 2 (and by extension generation 1). In the GB/C games, shininess is determined by a pokemon's randomly generated DVs. A pokemon can only be shiny if its DV bytes in binary are xx1x1010 10101010 with the 'x' meaning the bit can be a 1 or a 0. This pattern is checked in the ShinyDVsChecker function. Since there are 13 bits that must have a specific value, the chance of a shiny pokemon is 1 in 2^13 or 1/8192.
The actual functions for generating random numbers are kept in /engine/random.asm
It is possible to artificially control when a shiny wild pokemon occurs by setting bit 7 of wFontLoaded. An example of this is seen here:
So if I drop the level 100 and Chansey requirements, and adjust the random check, would this do it?
Original:
ShinyAttractFunction:
;make a 1 in 255 chance to force shiny DVs on a wild pokemon
call Random
ret nz
ld a, [wFontLoaded]
set 7, a
ld [wFontLoaded], a
ret
Proposed
ShinyAttractFunction:
; Generate a random number and check if it's less than 26 for a 1 in 10 chance
call Random
cp 26 ; 256 / 10 = 25.6, approximate to 26 for a 1 in 10 chance
ret nc
; Set flag
ld a, [wFontLoaded]
set 7, a
ld [wFontLoaded], a
ret
What would be the benefit of adjusting the random function itself? Does the ShinyAttractFunction only affect wild pokemon encounters, so starter pokemon and enemy trainer pokemon would be unaffected unless the random function is adjusted?
What would be the benefit of adjusting the random function itself?
More direct control over the random numbers that are generated.
Does the ShinyAttractFunction only affect wild pokemon encounters, so starter pokemon and enemy trainer pokemon would be unaffected unless the random function is adjusted?
Pretty much.