ref: 139a28ff9906d728a6820fe678a2a616eb309421
dir: /scripts/CeladonGym.asm/
CeladonGym_Script: ld hl, wCurrentMapScriptFlags bit 6, [hl] res 6, [hl] call nz, CeladonGymScript_48927 call EnableAutoTextBoxDrawing ld hl, CeladonGymTrainerHeader0 ld de, CeladonGym_ScriptPointers ld a, [wCeladonGymCurScript] call ExecuteCurMapScriptInTable ld [wCeladonGymCurScript], a ret CeladonGymScript_48927: ld hl, Gym4CityName ld de, Gym4LeaderName jp LoadGymLeaderAndCityName Gym4CityName: db "CELADON CITY@" Gym4LeaderName: db "ERIKA@" CeladonGymText_48943: xor a ld [wJoyIgnore], a ld [wCeladonGymCurScript], a ld [wCurMapScript], a ret CeladonGym_ScriptPointers: dw CheckFightingMapTrainers dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw CeladonGymScript3 CeladonGymScript3: ld a, [wIsInBattle] cp $ff jp z, CeladonGymText_48943 ld a, $f0 ld [wJoyIgnore], a CeladonGymText_48963: ld a, $9 ld [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_BEAT_ERIKA lb bc, TM_21, 1 call GiveItem jr nc, .BagFull ld a, $a ld [hSpriteIndexOrTextID], a call DisplayTextID SetEvent EVENT_GOT_TM21 jr .gymVictory .BagFull ld a, $b ld [hSpriteIndexOrTextID], a call DisplayTextID .gymVictory ld hl, wObtainedBadges set 3, [hl] ld hl, wBeatGymFlags set 3, [hl] ; deactivate gym trainers SetEventRange EVENT_BEAT_CELADON_GYM_TRAINER_0, EVENT_BEAT_CELADON_GYM_TRAINER_6 jp CeladonGymText_48943 CeladonGym_TextPointers: dw CeladonGymText1 dw CeladonGymText2 dw CeladonGymText3 dw CeladonGymText4 dw CeladonGymText5 dw CeladonGymText6 dw CeladonGymText7 dw CeladonGymText8 dw CeladonGymText9 dw TM21Text dw TM21NoRoomText CeladonGymTrainerHeader0: dbEventFlagBit EVENT_BEAT_CELADON_GYM_TRAINER_0 db ($2 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_CELADON_GYM_TRAINER_0 dw CeladonGymBattleText2 ; TextBeforeBattle dw CeladonGymAfterBattleText2 ; TextAfterBattle dw CeladonGymEndBattleText2 ; TextEndBattle dw CeladonGymEndBattleText2 ; TextEndBattle CeladonGymTrainerHeader1: dbEventFlagBit EVENT_BEAT_CELADON_GYM_TRAINER_1 db ($2 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_CELADON_GYM_TRAINER_1 dw CeladonGymBattleText3 ; TextBeforeBattle dw CeladonGymAfterBattleText3 ; TextAfterBattle dw CeladonGymEndBattleText3 ; TextEndBattle dw CeladonGymEndBattleText3 ; TextEndBattle CeladonGymTrainerHeader2: dbEventFlagBit EVENT_BEAT_CELADON_GYM_TRAINER_2 db ($4 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_CELADON_GYM_TRAINER_2 dw CeladonGymBattleText4 ; TextBeforeBattle dw CeladonGymAfterBattleText4 ; TextAfterBattle dw CeladonGymEndBattleText4 ; TextEndBattle dw CeladonGymEndBattleText4 ; TextEndBattle CeladonGymTrainerHeader3: dbEventFlagBit EVENT_BEAT_CELADON_GYM_TRAINER_3 db ($4 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_CELADON_GYM_TRAINER_3 dw CeladonGymBattleText5 ; TextBeforeBattle dw CeladonGymAfterBattleText5 ; TextAfterBattle dw CeladonGymEndBattleText5 ; TextEndBattle dw CeladonGymEndBattleText5 ; TextEndBattle CeladonGymTrainerHeader4: dbEventFlagBit EVENT_BEAT_CELADON_GYM_TRAINER_4 db ($2 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_CELADON_GYM_TRAINER_4 dw CeladonGymBattleText6 ; TextBeforeBattle dw CeladonGymAfterBattleText6 ; TextAfterBattle dw CeladonGymEndBattleText6 ; TextEndBattle dw CeladonGymEndBattleText6 ; TextEndBattle CeladonGymTrainerHeader5: dbEventFlagBit EVENT_BEAT_CELADON_GYM_TRAINER_5 db ($2 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_CELADON_GYM_TRAINER_5 dw CeladonGymBattleText7 ; TextBeforeBattle dw CeladonGymAfterBattleText7 ; TextAfterBattle dw CeladonGymEndBattleText7 ; TextEndBattle dw CeladonGymEndBattleText7 ; TextEndBattle CeladonGymTrainerHeader6: dbEventFlagBit EVENT_BEAT_CELADON_GYM_TRAINER_6, 1 db ($3 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_CELADON_GYM_TRAINER_6, 1 dw CeladonGymBattleText8 ; TextBeforeBattle dw CeladonGymAfterBattleText8 ; TextAfterBattle dw CeladonGymEndBattleText8 ; TextEndBattle dw CeladonGymEndBattleText8 ; TextEndBattle db $ff CeladonGymText1: text_asm CheckEvent EVENT_BEAT_ERIKA jr z, .beginBattle CheckEventReuseA EVENT_GOT_TM21 jr nz, .afterVictory call z, CeladonGymText_48963 call DisableWaitingAfterTextDisplay jr .done .afterVictory ld hl, CeladonGymText_48a68 call PrintText jr .done .beginBattle ld hl, CeladonGymText_48a5e call PrintText ld hl, wd72d set 6, [hl] set 7, [hl] ld hl, CeladonGymText_48a63 ld de, CeladonGymText_48a63 call SaveEndBattleTextPointers ld a, [hSpriteIndex] ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $4 ld [wGymLeaderNo], a ld a, $3 ld [wCeladonGymCurScript], a ld [wCurMapScript], a .done jp TextScriptEnd CeladonGymText_48a5e: text_far _CeladonGymText_48a5e text_end CeladonGymText_48a63: text_far _CeladonGymText_48a63 text_end CeladonGymText_48a68: text_far _CeladonGymText_48a68 text_end CeladonGymText9: text_far _CeladonGymText9 text_end TM21Text: text_far _ReceivedTM21Text sound_get_item_1 text_far _TM21ExplanationText text_end TM21NoRoomText: text_far _TM21NoRoomText text_end CeladonGymText2: text_asm ld hl, CeladonGymTrainerHeader0 call TalkToTrainer jp TextScriptEnd CeladonGymBattleText2: text_far _CeladonGymBattleText2 text_end CeladonGymEndBattleText2: text_far _CeladonGymEndBattleText2 text_end CeladonGymAfterBattleText2: text_far _CeladonGymAfterBattleText2 text_end CeladonGymText3: text_asm ld hl, CeladonGymTrainerHeader1 call TalkToTrainer jp TextScriptEnd CeladonGymBattleText3: text_far _CeladonGymBattleText3 text_end CeladonGymEndBattleText3: text_far _CeladonGymEndBattleText3 text_end CeladonGymAfterBattleText3: text_far _CeladonGymAfterBattleText3 text_end CeladonGymText4: text_asm ld hl, CeladonGymTrainerHeader2 call TalkToTrainer jp TextScriptEnd CeladonGymBattleText4: text_far _CeladonGymBattleText4 text_end CeladonGymEndBattleText4: text_far _CeladonGymEndBattleText4 text_end CeladonGymAfterBattleText4: text_far _CeladonGymAfterBattleText4 text_end CeladonGymText5: text_asm ld hl, CeladonGymTrainerHeader3 call TalkToTrainer jp TextScriptEnd CeladonGymBattleText5: text_far _CeladonGymBattleText5 text_end CeladonGymEndBattleText5: text_far _CeladonGymEndBattleText5 text_end CeladonGymAfterBattleText5: text_far _CeladonGymAfterBattleText5 text_end CeladonGymText6: text_asm ld hl, CeladonGymTrainerHeader4 call TalkToTrainer jp TextScriptEnd CeladonGymBattleText6: text_far _CeladonGymBattleText6 text_end CeladonGymEndBattleText6: text_far _CeladonGymEndBattleText6 text_end CeladonGymAfterBattleText6: text_far _CeladonGymAfterBattleText6 text_end CeladonGymText7: text_asm ld hl, CeladonGymTrainerHeader5 call TalkToTrainer jp TextScriptEnd CeladonGymBattleText7: text_far _CeladonGymBattleText7 text_end CeladonGymEndBattleText7: text_far _CeladonGymEndBattleText7 text_end CeladonGymAfterBattleText7: text_far _CeladonGymAfterBattleText7 text_end CeladonGymText8: text_asm ld hl, CeladonGymTrainerHeader6 call TalkToTrainer jp TextScriptEnd CeladonGymBattleText8: text_far _CeladonGymBattleText8 text_end CeladonGymEndBattleText8: text_far _CeladonGymEndBattleText8 text_end CeladonGymAfterBattleText8: text_far _CeladonGymAfterBattleText8 text_end