From 262c862a76b8cee090fe40326de64583840ef2bc Mon Sep 17 00:00:00 2001 From: Llinos Evans <36418502+PlagueVonKarma@users.noreply.github.com> Date: Tue, 27 Jun 2023 21:09:38 +0100 Subject: [PATCH] Fighting Dojo script revamp This restructures the Fighting Dojo to match the new map, as well as add a few more features and safety mechanisms. - Koichi, the Karate Master, now plays the Gym Leader theme when fought. - Hitmontop is now an optional reward. - Post-Game Rematch is available in addition to the gym scaling to be consistent with other Gym Leaders. - A safety lock is on the Poke Balls prior to defeating the Karate Master, as the new structure now demands it. Indeed, this is why the reward area in vanilla is like that. - Architecturally, there is now only one EVENT_GOT_HITMON constant, which is all that was actually needed in the vanilla game. Extreme microoptimisation, as event constants appear to be 16-bit. --- README.md | 1 + constants/event_constants.asm | 5 +- constants/hide_show_constants.asm | 1 + data/maps/hide_show_data.asm | 1 + data/maps/objects/FightingDojo.asm | 17 ++-- data/tilesets/collision_tile_ids.asm | 2 +- scripts/FightingDojo.asm | 126 ++++++++++++++++++++++++--- text/FightingDojo.asm | 30 +++++++ 8 files changed, 161 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index c351ecd4..6d4ad891 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,7 @@ Improved Areas - Rock Tunnel has a more workable map, now being easier to go through and having new areas to explore. Includes a way to get renewable fossils, items, and other interesting bits and pieces. Overall, it makes Flash much more rewarding to bring, showing you where the items and content are instead of being an inconvenience. - Diglett's Cave has a more detailed map with Onix, Wiglett, and Wugtrio also appearing! It also has its beta music! - Route 25 has been given a facelift, adding Bill's Lighthouse in place of the Sea Cottage. +- The Fighting Dojo has been revamped, featuring a design reminiscent of the prototype versions; rough floors, the elder in the back, and more. Additionally, you can now get a Hitmontop as a third option. The Karate Master is also now treated somewhat more like a Gym Leader, having Gym Scaling and a Rematch system. - Cinnabar Island is a lot bigger, with the volcano being added to it. The mansion seems different too... - Cinnabar Lab's Trade Room now features the Trader, who will evolve trade-evolving Pokemon for you! - Pokemon Tower was shortened, being less intensive and adding room for more maps. diff --git a/constants/event_constants.asm b/constants/event_constants.asm index b05e95ee..6c98c148 100644 --- a/constants/event_constants.asm +++ b/constants/event_constants.asm @@ -257,9 +257,8 @@ const EVENT_BEAT_FIGHTING_DOJO_TRAINER_1 const EVENT_BEAT_FIGHTING_DOJO_TRAINER_2 const EVENT_BEAT_FIGHTING_DOJO_TRAINER_3 - const EVENT_GOT_HITMONLEE - const EVENT_GOT_HITMONCHAN - const_skip 8 + const EVENT_GOT_HITMON + const_skip 9 const EVENT_GOT_TM46 const EVENT_BEAT_SABRINA const EVENT_BEAT_SAFFRON_GYM_TRAINER_0 diff --git a/constants/hide_show_constants.asm b/constants/hide_show_constants.asm index 79763925..c7ac9f8c 100644 --- a/constants/hide_show_constants.asm +++ b/constants/hide_show_constants.asm @@ -88,6 +88,7 @@ DEF SHOW EQU $15 const HS_POKEMON_MANSION_1F_ITEM_2 ; 4E X const HS_FIGHTING_DOJO_GIFT_1 ; 4F const HS_FIGHTING_DOJO_GIFT_2 ; 50 + const HS_FIGHTING_DOJO_GIFT_3 const HS_SILPH_CO_1F_RECEPTIONIST ; 51 const HS_VOLTORB_1 ; 52 X const HS_VOLTORB_2 ; 53 X diff --git a/data/maps/hide_show_data.asm b/data/maps/hide_show_data.asm index ad4f9717..5fb3bb5f 100644 --- a/data/maps/hide_show_data.asm +++ b/data/maps/hide_show_data.asm @@ -384,6 +384,7 @@ PokemonMansion1FHS: FightingDojoHS: db FIGHTING_DOJO, $06, SHOW ; HS_FIGHTING_DOJO_GIFT_1 db FIGHTING_DOJO, $07, SHOW ; HS_FIGHTING_DOJO_GIFT_2 + db FIGHTING_DOJO, $08, SHOW ; HS_FIGHTING_DOJO_GIFT_3 SilphCo1FHS: db SILPH_CO_1F, $01, HIDE ; HS_SILPH_CO_1F_RECEPTIONIST PowerPlantHS: diff --git a/data/maps/objects/FightingDojo.asm b/data/maps/objects/FightingDojo.asm index b6f10f77..7d9bba96 100644 --- a/data/maps/objects/FightingDojo.asm +++ b/data/maps/objects/FightingDojo.asm @@ -1,5 +1,5 @@ FightingDojo_Object: - db $3 ; border block + db $0 ; border block def_warp_events warp_event 4, 11, LAST_MAP, 2 @@ -8,12 +8,13 @@ FightingDojo_Object: def_bg_events def_object_events - object_event 6, 3, SPRITE_HIKER, STAY, DOWN, 1, OPP_BLACKBELT, 1 ; koichi - object_event 3, 4, SPRITE_HIKER, STAY, RIGHT, 2, OPP_BLACKBELT, 9 - object_event 3, 6, SPRITE_HIKER, STAY, RIGHT, 3, OPP_BLACKBELT, 10 - object_event 6, 5, SPRITE_HIKER, STAY, LEFT, 4, OPP_BLACKBELT, 11 - object_event 6, 8, SPRITE_HIKER, STAY, LEFT, 5, OPP_BLACKBELT, 12 - object_event 5, 1, SPRITE_POKE_BALL, STAY, NONE, 6 ; person - object_event 7, 1, SPRITE_POKE_BALL, STAY, NONE, 7 ; person + object_event 4, 1, SPRITE_HIKER, STAY, DOWN, 1, OPP_BLACKBELT, 1 ; koichi + object_event 3, 3, SPRITE_HIKER, STAY, RIGHT, 2, OPP_BLACKBELT, 11 + object_event 3, 5, SPRITE_HIKER, STAY, RIGHT, 3, OPP_BLACKBELT, 12 + object_event 6, 4, SPRITE_HIKER, STAY, LEFT, 4, OPP_BLACKBELT, 13 + object_event 6, 6, SPRITE_HIKER, STAY, LEFT, 5, OPP_BLACKBELT, 14 + object_event 5, 1, SPRITE_POKE_BALL, STAY, NONE, 6 ; Hitmonlee + object_event 7, 1, SPRITE_POKE_BALL, STAY, NONE, 7 ; Hitmonchan + object_event 6, 1, SPRITE_POKE_BALL, STAY, NONE, 8 ; Hitmontop def_warps_to FIGHTING_DOJO diff --git a/data/tilesets/collision_tile_ids.asm b/data/tilesets/collision_tile_ids.asm index 5a194a19..55b9c066 100644 --- a/data/tilesets/collision_tile_ids.asm +++ b/data/tilesets/collision_tile_ids.asm @@ -68,7 +68,7 @@ Plateau_Coll:: coll_tiles $1b, $23, $2c, $2d, $3b, $45 PreGym_Coll:: - coll_tiles $0B, $0E, $1E, $1F + coll_tiles $0B, $0E, $1E, $1F, $11 Citrine_Coll:: coll_tiles $2C, $31, $3F, $55, $0E, $2F, $23, $20, $10, $03, $1C, $1B, $0B, $0C, $21, $39, $3C, $48, $49, $58, $59 diff --git a/scripts/FightingDojo.asm b/scripts/FightingDojo.asm index a32aeb05..51545778 100644 --- a/scripts/FightingDojo.asm +++ b/scripts/FightingDojo.asm @@ -21,6 +21,8 @@ FightingDojo_ScriptPointers: dw FightingDojoScript3 FightingDojoScript1: + CheckEvent EVENT_POST_GAME_ATTAINED ; Required in the case you have cleared the game, but not cleared the dojo. It's an optional deal. + ret nz CheckEvent EVENT_DEFEATED_FIGHTING_DOJO ret nz call CheckFightingMapTrainers @@ -33,18 +35,18 @@ FightingDojoScript1: ldh [hJoyHeld], a ld [wcf0d], a ld a, [wYCoord] - cp 3 + cp 2 ret nz ld a, [wXCoord] cp 4 ret nz ld a, $1 ld [wcf0d], a - ld a, PLAYER_DIR_RIGHT + ld a, PLAYER_DIR_UP ld [wPlayerMovingDirection], a ld a, $1 ldh [hSpriteIndex], a - ld a, SPRITE_FACING_LEFT + ld a, SPRITE_FACING_DOWN ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay ld a, $1 @@ -59,11 +61,11 @@ FightingDojoScript3: ld a, [wcf0d] and a jr z, .asm_5cde4 - ld a, PLAYER_DIR_RIGHT + ld a, PLAYER_DIR_UP ld [wPlayerMovingDirection], a ld a, $1 ldh [hSpriteIndex], a - ld a, SPRITE_FACING_LEFT + ld a, SPRITE_FACING_DOWN ldh [hSpriteFacingDirection], a call SetSpriteFacingDirectionAndDelay @@ -71,7 +73,7 @@ FightingDojoScript3: ld a, $f0 ld [wJoyIgnore], a SetEventRange EVENT_BEAT_KARATE_MASTER, EVENT_BEAT_FIGHTING_DOJO_TRAINER_3 - ld a, $8 + ld a, $9 ldh [hSpriteIndexOrTextID], a call DisplayTextID xor a @@ -88,6 +90,7 @@ FightingDojo_TextPointers: dw FightingDojoText5 dw FightingDojoText6 dw FightingDojoText7 + dw FightingDojoTextHitmontop dw FightingDojoText8 FightingDojoTrainerHeaders: @@ -104,10 +107,36 @@ FightingDojoTrainerHeader3: FightingDojoText1: ; gym scaling can be removed to make space text_asm + CheckEvent EVENT_POST_GAME_ATTAINED ; No need to view previous stuff, technically you can skip Bide this way but I think that's hilarious + jp z, .normalProcessing CheckEvent EVENT_DEFEATED_FIGHTING_DOJO jp nz, .continue1 CheckEventReuseA EVENT_BEAT_KARATE_MASTER jp nz, .continue2 +.rematchMode ; Rematch functionality. Just loads pre-battle text and his trainer. + ld hl, KoichiRematchPreBattleText + call PrintText + ld c, BANK(Music_MeetMaleTrainer) + ld a, MUSIC_MEET_MALE_TRAINER + call PlayMusic + set 6, [hl] + set 7, [hl] + ldh a, [hSpriteIndex] + ld [wSpriteIndex], a + ld hl, KoichiRematchDefeatedText + ld de, KoichiRematchDefeatedText + call SaveEndBattleTextPointers + call EngageMapTrainer + ld a, OPP_BLACKBELT + ld [wCurOpponent], a + ld a, 10 ; Silph Gauntlet lineup. + ld [wTrainerNo], a + ld a, 1 + ld [wIsTrainerBattle], a + ld a, $1 + ld [wGymLeaderNo], a + jr .asm_9dba4 +.normalProcessing ld hl, FightingDojoText_5ce8e call PrintText ld hl, wd72d @@ -134,12 +163,15 @@ FightingDojoText1: ; gym scaling can be removed to make space ld [wTrainerNo], a ld a, 1 ld [wIsTrainerBattle], a + ld a, $1 + ld [wGymLeaderNo], a ; play gym music ;ends here ld a, $3 ld [wFightingDojoCurScript], a ld [wCurMapScript], a + SetEvent EVENT_DEFEATED_FIGHTING_DOJO jr .asm_9dba4 .continue1 ld hl, FightingDojoText_5ce9d @@ -239,10 +271,18 @@ FightingDojoAfterBattleText4: text_far _FightingDojoAfterBattleText4 text_end +; So get this, the game had an EVENT_GOT_HITMONCHAN and EVENT_GOT_HITMONLEE here. +; However, in the way it was being used... +; You can just make it EVENT_GOT_HITMON and be outright better off. +; So when implementing the new stuff, I made this optimisation. +; Oh, and because of the new Dojo structure, I had to rework the EVENT_DEFEATED_FIGHTING_DOJO system, to ensure people don't grab their prizes early. + FightingDojoText6: ; Hitmonlee Poké Ball text_asm - CheckEitherEventSet EVENT_GOT_HITMONLEE, EVENT_GOT_HITMONCHAN + CheckEvent EVENT_DEFEATED_FIGHTING_DOJO + jr z, .Oi + CheckEvent EVENT_GOT_HITMON jr z, .GetMon ld hl, OtherHitmonText call PrintText @@ -266,7 +306,12 @@ FightingDojoText6: ld a, HS_FIGHTING_DOJO_GIFT_1 ld [wMissableObjectIndex], a predef HideObject - SetEvents EVENT_GOT_HITMONLEE, EVENT_DEFEATED_FIGHTING_DOJO + SetEvents EVENT_GOT_HITMON + jr .done +.Oi + ld hl, OiMateText + call PrintText + ;fallthrough .done jp TextScriptEnd @@ -277,7 +322,9 @@ WantHitmonleeText: FightingDojoText7: ; Hitmonchan Poké Ball text_asm - CheckEitherEventSet EVENT_GOT_HITMONLEE, EVENT_GOT_HITMONCHAN + CheckEvent EVENT_DEFEATED_FIGHTING_DOJO + jr z, .Oi + CheckEvent EVENT_GOT_HITMON jr z, .GetMon ld hl, OtherHitmonText call PrintText @@ -296,12 +343,55 @@ FightingDojoText7: ld c, 30 call GivePokemon jr nc, .done - SetEvents EVENT_GOT_HITMONCHAN, EVENT_DEFEATED_FIGHTING_DOJO + SetEvent EVENT_GOT_HITMON ; once Poké Ball is taken, hide sprite ld a, HS_FIGHTING_DOJO_GIFT_2 ld [wMissableObjectIndex], a predef HideObject + jr .done +.Oi + ld hl, OiMateText + call PrintText + ;fallthrough +.done + jp TextScriptEnd + +FightingDojoTextHitmontop: +; Hitmontop Poké Ball + text_asm + CheckEvent EVENT_DEFEATED_FIGHTING_DOJO + jr z, .Oi + CheckEvent EVENT_GOT_HITMON + jr z, .GetMon + ld hl, OtherHitmonText + call PrintText + jr .done +.GetMon + ld a, HITMONTOP + call DisplayPokedex + ld hl, WantHitmontopText + call PrintText + call YesNoChoice + ld a, [wCurrentMenuItem] + and a + jr nz, .done + ld a, [wcf91] + ld b, a + ld c, 30 + call GivePokemon + jr nc, .done + SetEvent EVENT_GOT_HITMON + + ; once Poké Ball is taken, hide sprite + ld a, HS_FIGHTING_DOJO_GIFT_3 + ld [wMissableObjectIndex], a + predef HideObject + jr .done +.Oi + ld hl, OiMateText + call PrintText + ;fallthrough .done jp TextScriptEnd @@ -309,6 +399,22 @@ WantHitmonchanText: text_far _WantHitmonchanText text_end +WantHitmontopText: + text_far _WantHitmontopText + text_end + OtherHitmonText: text_far _GreedyBastardText text_end + +OiMateText: + text_far _OiMateText + text_end + +KoichiRematchPreBattleText: + text_far _KoichiRematchPreBattleText + text_end + +KoichiRematchDefeatedText: + text_far _KoichiRematchDefeatedText + text_end diff --git a/text/FightingDojo.asm b/text/FightingDojo.asm index fbebcda1..dfe84354 100644 --- a/text/FightingDojo.asm +++ b/text/FightingDojo.asm @@ -123,3 +123,33 @@ _WantHitmonchanText:: line "piston punching" cont "HITMONCHAN?" done + +_WantHitmontopText:: + text "You want the" + line "capoeira fighter" + cont "HITMONTOP?" + done + +_OiMateText:: + text "What do you think" + line "you're doing?" + + para "Fight like a true" + line "warrior!" + done + +_KoichiRematchPreBattleText:: + text "Ho, !" + + para "Did you return" + line "to spar with us" + cont "again?" + + para "Aha! Then I" + line "won't hold back!" + done + +_KoichiRematchDefeatedText:: + text "I have" + line "been defeated" + cont "once more..."