Yujirou Event Scripting, half-finished

This code has a lot of problems with solutions that me and Frrf can't seem to figure out. We've taken a lot of references from Erika's Gym but we've got many bugs after Yujirou is defeated, such as one case where you end up instantly doing the rematch fight, which is insane because there's no way this can actually happen.

What's committed is a fight that can be re-fought when it shouldn't.
This commit is contained in:
May Evans 2023-03-30 21:01:18 +01:00
parent 71de0f07a5
commit 67132fefcb
10 changed files with 163 additions and 15 deletions

View file

@ -25,7 +25,8 @@
const_next $28
const EVENT_VIRIDIAN_GYM_OPEN
const EVENT_GOT_TM42
const_skip 14
const EVENT_BEAT_YUJIROU
const_skip 13
const EVENT_OAK_GOT_PARCEL
const EVENT_GOT_OAKS_PARCEL
const_skip 22

View file

@ -248,4 +248,6 @@ DEF SHOW EQU $15
const HS_MT_MOON_CRATER_GUARD ; EC
const HS_MANSION_GUARD ; ED
const HS_BILLS_NIDORINO ; EE
const HS_YUJIROU ; EF
const HS_YUJIROU_REMATCH ; uhhh F0?
DEF NUM_HS_OBJECTS EQU const_value

View file

@ -73,7 +73,7 @@ MapHSPointers:
dw NoHS
dw NoHS
dw NoHS
dw NoHS
dw ViridianPreGymHS
dw NoHS
dw NoHS
dw NoHS
@ -582,6 +582,10 @@ Route1HS:
db ROUTE_1, $03, HIDE ; PROF OAK fight. To test, change to SHOW. - PvK
MtMoonCraterHS:
db MT_MOON_CRATER, $10, SHOW ; Crater Guard
ViridianPreGymHS:
db VIRIDIAN_PRE_GYM, $01, SHOW ; Initial Yujirou
db VIRIDIAN_PRE_GYM, $02, HIDE ; Yujirou Rematch
db $FF, $01, SHOW ; end
assert_table_length NUM_HS_OBJECTS + 1

View file

@ -9,5 +9,6 @@ ViridianPreGym_Object:
def_object_events
object_event 5, 2, SPRITE_YOUNGSTER, STAY, NONE, 1 ; person, Yujirou
object_event 5, 2, SPRITE_YOUNGSTER, STAY, NONE, 2 ; person, Yujirou 2
def_warps_to VIRIDIAN_PRE_GYM

View file

@ -323,7 +323,7 @@ EngineerData:
db 18, MAGNEMITE, MAGNEMITE, MAGNETITE, 0
YujirouData: ; was unused juggler
db $FF, 7, KONYA, 7, EEVEE, 10, LICKITUNG, 0
db $FF, 7, KONYA, 7, RATTATA, 10, LICKITUNG, 0
; post-game rematch team (currently unused)
db $FF, 66, PERSIAN, 67, TAUROS, 67, MADAAMU, 66, BLISSEY, 67, SNORLAX, 70, LICKILICKY, 0
@ -679,8 +679,8 @@ BrunoData:
; gyms except giovanni begin here
BrockData:
db $FF, 10, GEODUDE, 10, RHYHORN, 11, DECILLA, 13, ONIX, 0 ; 0 badges
db $FF, 19, GEODUDE, 18, OMANYTE, 18, KABUTO, 19, DECILLA, 21, ONIX, 0 ; 1
db $FF, 10, GEODUDE, 11, DECILLA, 13, ONIX, 0 ; 0 badges
db $FF, 19, GEODUDE, 18, KABUTO, 19, DECILLA, 21, ONIX, 0 ; 1
db $FF, 22, GRAVELER, 22, OMANYTE, 22, KABUTO, 23, DECILLA, 25, ONIX, 0 ; 2
db $FF, 29, GRAVELER, 28, OMANYTE, 28, KABUTO, 29, DECILLA, 31, ONIX, 0 ; 3
db $FF, 39, GOLEM, 38, OMANYTE, 38, KABUTO, 39, NIDOREIGN, 41, GYAOON, 0 ; 4
@ -690,7 +690,7 @@ BrockData:
db $FF, 66, GOLEM, 67, OMASTAR, 67, KABUTOPS, 66, NIDOREIGN, 67, KLEAVOR, 70, GYAOON, 0 ; 8 (postgame)
MistyData:
db $FF, 10, HORSEA, 10, CHEEP, 11, GYOPIN, 13, WEIRDUCK, 0 ; 0 badges
db $FF, 10, HORSEA, 11, GYOPIN, 13, STARYU, 0 ; 0 badges
db $FF, 19, HORSEA, 18, CHEEP, 18, GOLDEEN, 19, WEIRDUCK, 21, STARMIE, 0 ; 1
db $FF, 22, HORSEA, 22, CHEEP, 22, GOLDEEN, 23, WEIRDUCK, 25, STARMIE, 0 ; 2
db $FF, 29, HORSEA, 28, JABETTA, 28, GOLDEEN, 29, WEIRDUCK, 31, STARMIE, 0 ; 3
@ -701,7 +701,7 @@ MistyData:
db $FF, 66, STARMIE, 67, VAPOREON, 67, GOLDUCK, 66, TOTARTLE, 67, JAGG, 70, GYARADOS, 0 ; 8 (postgame)
LtSurgeData:
db $FF, 10, VOLTORB, 10, KOTORA, 11, PIKACHU, 13, MAGNETITE, 0 ; 0 badges
db $FF, 10, VOLTORB, 10, KOTORA, 11, PIKACHU, 0 ; 0 badges
db $FF, 19, VOLTORB, 18, KOTORA, 18, PIKACHU, 19, MAGNETITE, 21, ELECTABUZZ, 0 ; 1
db $FF, 22, VOLTORB, 22, GAOTORA, 22, MAGNETITE, 23, ELECTABUZZ, 25, GOROCHU, 0 ; 2
db $FF, 28, ELECTRODE, 28, GAOTORA, 28, MAGNETITE, 29, ELECTABUZZ, 31, GOROCHU, 0 ; 3

View file

@ -6954,8 +6954,16 @@ _LoadTrainerPic:
ld d, a ; de contains pointer to trainer pic
ld a, [wLinkState]
and a
ld a, BANK("Pics 6") ; this is where all the trainer pics are (not counting Red's)
jr z, .loadSprite
;ld a, BANK("Pics 6") ; this is where all the trainer pics are (not counting Red's)
;jr z, .loadSprite
jr nz, .useRed ; New Trainer Pic code, credit to Rangi's Red*/Blue* hack
ld a, [wTrainerClass]
cp YUJIROU ; first trainer class in "Pics 10"
ld a, Bank("Pics 10")
jr nc, .loadSprite
ld a, Bank("Pics 6")
jr .loadSprite
.useRed
ld a, BANK(RedPicFront)
.loadSprite
call UncompressSpriteFromDE

View file

@ -544,4 +544,6 @@ ToedscruelPicFront:: INCBIN "gfx/pokemon/front/toedscruel.pic"
ToedscruelPicBack:: INCBIN "gfx/pokemon/back/toedscruelb.pic"
MissingNoPicFront:: INCBIN "gfx/pokemon/front/missingno.pic"
MissingNoPicBack:: INCBIN "gfx/pokemon/back/missingnob.pic"
SECTION "Pics 10", ROMX ; Extra Trainer Bank
YujirouPic:: INCBIN "gfx/trainers/yujirou.pic"

View file

@ -109,6 +109,12 @@ HallofFameRoomScript1:
ld a, HS_MANSION_GUARD
ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_YUJIROU
ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_YUJIROU_REMATCH
ld [wMissableObjectIndex], a
predef ShowObject
ld a, $2
ld [wHallOfFameCurScript], a
ret

View file

@ -1,17 +1,62 @@
; This code has a lot of problems with solutions that barely escape me. Many references from Erika's Gym have been taken to make a fight that cannot be done again, but with a rematch later. In other words, your average gym.
; SetEvent EVENT_BEAT_YUJIROU does not seem to be applying.
; It's very easy to cause an infinite loop where you somehow get catapulted into the rematch fight
; And much more.
; Commit on 30-3-23 has a somewhat stable version of the fight.
ViridianPreGym_Script:
call EnableAutoTextBoxDrawing
ld de, ViridianPreGym_ScriptPointers
ld a, [wViridianPreGymCurScript]
call ExecuteCurMapScriptInTable
ld [wViridianPreGymCurScript], a
ret
LoadNames:
ld hl, .CityName
ld de, .LeaderName
jp LoadGymLeaderAndCityName
.CityName:
db "VIRIDIAN PRE-GYM@"
.LeaderName:
db "YUJIROU@"
ViridianPreGymResetScripts:
xor a
ld [wJoyIgnore], a
ld [wViridianPreGymCurScript], a
ld [wCurMapScript], a
ret
ViridianPreGym_ScriptPointers:
dw EndTrainerBattle
dw ViridianGymYujirouPostBattle
ViridianPreGym_TextPointers:
dw YujirouText
dw YujirouRematch
ViridianGymYujirouPostBattle:
ld a, [wIsInBattle]
cp $ff
jp z, ViridianGymResetScripts
ld a, $f0
ld [wJoyIgnore], a
YujirouHasBeenBeaten:
;text_asm
;ld hl, YujirouAfterBattleText
;call PrintText
SetEvent EVENT_BEAT_YUJIROU
jp ViridianPreGymResetScripts
YujirouText:
text_asm
CheckEvent EVENT_BEAT_YUJIROU
jr z, .YujirouBeaten
ld hl, YujirouIntro
call PrintText
@ -27,18 +72,21 @@ YujirouText:
ld [wCurOpponent], a
ld a, 1
ld [wTrainerNo], a
ld [wIsTrainerBattle], a ; note to self - make him play gym music...somehow.
ld a, $2
ld [wViridianPreGymCurScript], a
ld [wIsTrainerBattle], a
ld hl, YujirouLoseText
ld de, YujirouWinText
call SaveEndBattleTextPointers
jp TextScriptEnd
ld a, $6
ld [wViridianPreGymCurScript], a
ld [wCurMapScript], a
jr .done
.done
.YujirouBeaten
ld hl, YujirouAfterBattleText
call PrintText
jr .done
.done
jp TextScriptEnd
; where the hell do i put SetEvent EVENT_BEAT_YUJIROU
YujirouIntro::
text_far _YujirouIntro
@ -56,4 +104,46 @@ YujirouAfterBattleText::
text_far _YujirouAfterBattleText
text_end
YujirouRematch:
text_asm
ld hl, YujirouIntro2
call PrintText
ld c, BANK(Music_MeetMaleTrainer)
ld a, MUSIC_MEET_MALE_TRAINER
call PlayMusic
ld hl, wd72d
set 6, [hl]
set 7, [hl]
call Delay3
ld a, OPP_YUJIROU
ld [wCurOpponent], a
ld a, 2
ld [wTrainerNo], a
ld [wIsTrainerBattle], a
ld a, $2
ld [wViridianPreGymCurScript], a
ld hl, YujirouLoseText2
ld de, YujirouWinText
call SaveEndBattleTextPointers
jp TextScriptEnd
jr .done
.done
ld hl, YujirouAfterBattleText2
call PrintText
jp TextScriptEnd
YujirouIntro2::
text_far _YujirouIntro2
text_end
YujirouLoseText2::
text_far _YujirouLoseText2
text_end
YujirouAfterBattleText2::
text_far _YujirouAfterBattleText2
text_end
text_end ; unused

View file

@ -37,3 +37,37 @@ _YujirouAfterBattleText::
line "beat you!"
done
_YujirouIntro2::
text "Hey! You're back!"
para "After GIOVANNI got"
line "exposed for who"
cont "he truly is, I'm"
cont "closer than ever"
cont "to my goal!"
para "<PLAYER>!"
para "This time, I"
line "will defeat you!"
done
_YujirouLoseText2::
text "Huh?!"
line "Not again!"
prompt
_YujirouAfterBattleText2::
text "I lost..."
para "..."
para "I had all the"
line "best NORMAL-"
cont "type #MON."
para "Maybe it's me?"
done