Groundwork

The script currently doesn't work how I want it to, and I don't know why.
This commit is contained in:
Llinos Evans 2023-07-06 16:02:58 +01:00
parent ab72fa0e51
commit f9f5a7f1b0
3 changed files with 128 additions and 6 deletions

View file

@ -4,7 +4,8 @@ IndigoPlateauLobby_Object:
def_warp_events
warp_event 7, 11, LAST_MAP, 1
warp_event 8, 11, LAST_MAP, 2
warp_event 8, 0, LORELEIS_ROOM, 1
warp_event 8, 0, HALL_OF_FAME, 1 ; test post-game setup
;warp_event 8, 0, LORELEIS_ROOM, 1
def_bg_events

View file

@ -4,12 +4,13 @@ RedsHouse2F_Object:
def_warp_events
warp_event 7, 1, REDS_HOUSE_1F, 3
;warp_event 5, 1, SILPH_GAUNTLET_7F, 1 ; - Test Chief
;warp_event 5, 1, SILPH_CO_11F, 1 ; - Test Omega & Giovanni
;warp_event 5, 1, SILPH_CO_11F, 1 ; - Test J&J, Omega, & Giovanni
;warp_event 5, 1, ROCKET_HIDEOUT_B4F, 2 ; - Test Giovanni 1
;warp_event 5, 1, MT_MOON_SQUARE, 1 ; - Test Shop, NPCs, and Crater
;warp_event 5, 1, CELESTE_HILL, 2 ; - Test GMolt
;warp_event 5, 1, CELESTE_HILL, 1 ; - Test GMolt
;warp_event 5, 1, INDIGO_PLATEAU_LOBBY, 1 ; easy league access
warp_event 5, 1, GARNET_CAVERN_B1F, 1 ; Test GCuno
;warp_event 5, 1, FARAWAY_ISLAND_INSIDE, 1 ; Test Mew
def_bg_events

View file

@ -96,6 +96,7 @@ HallofFameRoomScript1:
ld [wJoyIgnore], a
call PostGameSetup
call ResetLegendaryPokemon
ld a, $2
ld [wHallOfFameCurScript], a
@ -113,9 +114,8 @@ HallofFameRoomText1:
; It replaces the Cerulean Cave Guard bit, adapting him into the whole ordeal.
PostGameSetup:
SetEvent EVENT_POST_GAME_ATTAINED
ld hl, ObjectsToHide
.loop1
.loop1 ; Hides
ld a, [hli]
cp $ff
jr z, .skip
@ -126,7 +126,7 @@ PostGameSetup:
jr .loop1
.skip
ld hl, ObjectsToShow
.loop2
.loop2 ; Shows
ld a, [hli]
cp -1
ret z
@ -136,6 +136,105 @@ PostGameSetup:
pop hl
jr .loop2
; Begin conditional shows for Legendary Pokemon.
; Here, we check if a Pokemon is owned, and if it is, we reset their events.
; It's really suboptimal and I think there is a way to make it better.
ResetLegendaryPokemon:
ld a, DEX_ARTICUNO ; Load dex number
ld [wd11e], a ; Store in wd11e (input for IsPokemonBitSet)
ld hl, wPokedexOwned ; Grab the owned thing while you're at it
call HoFIsPokemonBitSet ; Is it owned?
jr nz, .skipArticuno ; If owned, skip
ResetEvent EVENT_BEAT_ARTICUNO ; If not, reset the event...
ld a, HS_ARTICUNO
ld [wMissableObjectIndex], a
predef ShowObject ; And restore the hide/show.
.skipArticuno ; Rinse and repeat.
ld a, DEX_ZAPDOS
ld [wd11e], a
call HoFIsPokemonBitSet
jr z, .skipZapdos
ResetEvent EVENT_BEAT_ZAPDOS
ld a, HS_ZAPDOS
ld [wMissableObjectIndex], a
predef ShowObject
.skipZapdos
ld a, DEX_MOLTRES
ld [wd11e], a
call HoFIsPokemonBitSet
jr z, .skipMoltres
ResetEvent EVENT_BEAT_MOLTRES
ld a, HS_MOLTRES
ld [wMissableObjectIndex], a
predef ShowObject
.skipMoltres
; Omega is special.
; If Omega wasn't obtained, it'll be available somewhere else on Silph Co. 11F.
; Commented out until we actually do this.
; ld a, DEX_OMEGA
; ld [wd11e], a
; call HoFIsPokemonBitSet
; jr nz, .skipOmega
; ResetEvent EVENT_BEAT_OMEGA_2
; ld a, HS_OMEGA_2
; ld [wMissableObjectIndex], a
; predef ShowObject
;.skipOmega
; Mew's hints aren't until the post-game, but is available regardless.
; So, we put this here.
ld a, DEX_MEW
ld [wd11e], a
call HoFIsPokemonBitSet
jr z, .skipMew
ResetEvent EVENT_BEAT_MEW
ld a, HS_MEW
ld [wMissableObjectIndex], a
predef ShowObject
.skipMew
; If you haven't cleared the game yet, you've not met the Galarian Birds.
; So we may as well skip processing all this.
CheckEvent EVENT_POST_GAME_ATTAINED
jp z, .skipGalarianBirdsAndMewtwo
ld a, DEX_ARTICUNO_G
ld [wd11e], a
call HoFIsPokemonBitSet
jr z, .skipArticunoG
ResetEvent EVENT_BEAT_ARTICUNO_G
ld a, HS_GARNET_ARTICUNO_G
ld [wMissableObjectIndex], a
predef ShowObject
.skipArticunoG
ld a, DEX_ZAPDOS_G
ld [wd11e], a
call HoFIsPokemonBitSet
jr z, .skipZapdosG
ResetEvent EVENT_BEAT_ZAPDOSG
ld a, HS_BRUNSWICK_ZAPDOS_G_2
ld [wMissableObjectIndex], a
predef ShowObject
.skipZapdosG
ld a, DEX_MOLTRES_G
ld [wd11e], a
call HoFIsPokemonBitSet
jr z, .skipMoltresG
ResetEvent EVENT_BEAT_GALARIAN_MOLTRES
ld a, HS_MOLTRES_G
ld [wMissableObjectIndex], a
predef ShowObject
.skipMoltresG
ld a, DEX_MEWTWO
ld [wd11e], a
call HoFIsPokemonBitSet
jr z, .skipGalarianBirdsAndMewtwo
ResetEvent EVENT_BEAT_MEWTWO
ld a, HS_MEWTWO
ld [wMissableObjectIndex], a
predef ShowObject
.skipGalarianBirdsAndMewtwo
; We set this last to save on processing earlier in the script.
SetEvent EVENT_POST_GAME_ATTAINED
ret
ObjectsToShow:
db HS_ROUTE_1_OAK ; Oak post-game fight
db -1 ; end
@ -146,3 +245,24 @@ ObjectsToHide:
db HS_MT_MOON_CRATER_GUARD ; Mt. Moon Crater access
db HS_CERULEAN_CAVE_GUY ; Cerulean Cave access
db -1 ; end
; Farcalling this caused weird issues so I'm just using a clone
; This is a function used in engine/menus/pokedex.asm to check if a Pokemon is in the dex.
; We use this to reset Legendary Pokemon after the Elite Four.
; tests if a pokemon's bit is set in the seen or owned pokemon bit fields
; INPUT:
; [wd11e] = pokedex number
; hl = address of bit field
; OUTPUT:
; 0 = Not Owned
; 1 = Owned
HoFIsPokemonBitSet:
ld hl, wPokedexOwned
ld a, [wd11e]
dec a
ld c, a
ld b, FLAG_TEST
predef FlagActionPredef
ld a, c
and a
ret