Count all Pokemon as seen and caught - pret/pokecrystal GitHub Wiki
First, go to data/events/special_pointers.asm:
SpecialsPointers::
add_special WarpToSpawnPoint
...
add_special InitialClearDSTFlag
+if DEF(_DEBUG)
+ add_special FillPokedex
+else
add_special UnusedDummySpecial ; unused
+endc
Then, in engine/events/specials.asm:
...
+if DEF(_DEBUG)
+FillPokedex:
+ ld a, 1
+ ld [wFirstUnownSeen], a
+ ld [wScriptVar], a
+.loop
+ ld a, [wScriptVar]
+ dec a
+ call SetSeenAndCaughtMon
+ ld a, [wScriptVar]
+ cp NUM_POKEMON
+ ret z
+ inc a
+ ld [wScriptVar], a
+ jr .loop
+else
UnusedDummySpecial:
ret
+endc
...
By making this into a special, we can now easily execute it from a map script, like this:
...
PlayersHouseRadioScript:
+if DEF(_DEBUG)
+ special FillPokedex
+else
checkevent EVENT_GOT_A_POKEMON_FROM_ELM
iftrue .NormalRadio
checkevent EVENT_LISTENED_TO_INITIAL_RADIO
iftrue .AbbreviatedRadio
playmusic MUSIC_POKEMON_TALK
opentext
writetext PlayersRadioText1
pause 45
writetext PlayersRadioText2
pause 45
writetext PlayersRadioText3
pause 45
musicfadeout MUSIC_NEW_BARK_TOWN, 16
writetext PlayersRadioText4
pause 45
closetext
setevent EVENT_LISTENED_TO_INITIAL_RADIO
end
.NormalRadio:
jumpstd Radio1Script
.AbbreviatedRadio:
opentext
writetext PlayersRadioText4
pause 45
closetext
+endc
end
...
Of course, you'll have to actually give the player the Pokédex in order for them to see that it's full.
PlayersHouseRadioScript:
if DEF(_DEBUG)
+ setflag ENGINE_POKEDEX
special FillPokedex
else
checkevent EVENT_GOT_A_POKEMON_FROM_ELM
iftrue .NormalRadio
checkevent EVENT_LISTENED_TO_INITIAL_RADIO
iftrue .AbbreviatedRadio
playmusic MUSIC_POKEMON_TALK
opentext
writetext PlayersRadioText1
pause 45
writetext PlayersRadioText2
pause 45
writetext PlayersRadioText3
pause 45
musicfadeout MUSIC_NEW_BARK_TOWN, 16
writetext PlayersRadioText4
pause 45
closetext
setevent EVENT_LISTENED_TO_INITIAL_RADIO
end
.NormalRadio:
jumpstd Radio1Script
.AbbreviatedRadio:
opentext
writetext PlayersRadioText4
pause 45
closetext
endc
end
Because the function uses a raw value of 1 instead of a constant like BULBASAUR (who is Pokémon #1 in dex order), it will work even if you've changed the order of Pokémon in your dex or replaced them all with new ones. Similarly, the same 1 is loaded into wFirstUnownSeen, which will come out as Unown A, but if you've changed Unown forms around, it will still work to default to whichever is the first one. If you've removed Unown forms entirely, then you don't have to worry about wFirstUnownSeen.
FillPokedex:
ld a, 1
- ld [wFirstUnownSeen], a
ld [wScriptVar], a
.loop
ld a, [wScriptVar]
dec a
call SetSeenAndCaughtMon
ld a, [wScriptVar]
cp NUM_POKEMON
ret z
inc a
ld [wScriptVar], a
jr .loop
This function becomes even more useful if you expand the features of your Pokedex.