From 57d4e62ed042ab773bf59b9e2fc2a87ac36eb24e Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Thu, 30 May 2024 23:21:18 -0500 Subject: [PATCH] Fix issue where skipping clock tower cutscene would not return you correctly (#618) --- .../StoryCutscenes/SkipClockTowerOpen.cpp | 28 +++++++++++++++---- .../GameInteractor/GameInteractor.h | 1 + .../overlays/actors/ovl_En_Test4/z_en_test4.c | 5 +++- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/mm/2s2h/Enhancements/Cutscenes/StoryCutscenes/SkipClockTowerOpen.cpp b/mm/2s2h/Enhancements/Cutscenes/StoryCutscenes/SkipClockTowerOpen.cpp index ca31cef09..37876cb4d 100644 --- a/mm/2s2h/Enhancements/Cutscenes/StoryCutscenes/SkipClockTowerOpen.cpp +++ b/mm/2s2h/Enhancements/Cutscenes/StoryCutscenes/SkipClockTowerOpen.cpp @@ -5,18 +5,34 @@ extern "C" { #include "z64.h" void Flags_SetWeekEventReg(s32 flag); extern SaveContext gSaveContext; +extern PlayState* gPlayState; } void RegisterSkipClockTowerOpen() { + // This will handle skipping if you are around the Clock Town area, but not directly in south clock town + REGISTER_VB_SHOULD(GI_VB_CLOCK_TOWER_OPENING_CONSIDER_THIS_FIRST_CYCLE, { + if (CVarGetInteger("gEnhancements.Cutscenes.SkipStoryCutscenes", 0)) { + *should = false; + } + }); + + // This will handle skipping if you are directly in South Clock Town REGISTER_VB_SHOULD(GI_VB_PLAY_TRANSITION_CS, { - // Cutscene where clock tower opens. Will only show if the player is in Clock Town - if (gSaveContext.save.entrance == ENTRANCE(SOUTH_CLOCK_TOWN, 0) && gSaveContext.save.cutsceneIndex == 0xFFF1 && + if ((gSaveContext.save.entrance == ENTRANCE(SOUTH_CLOCK_TOWN, 0) || + gSaveContext.save.entrance == ENTRANCE(TERMINA_FIELD, 0)) && + gSaveContext.save.cutsceneIndex == 0xFFF1 && CVarGetInteger("gEnhancements.Cutscenes.SkipStoryCutscenes", 0)) { - // Setting the respawn flag to 2 will respawn the player where they were before the cutscene, consistent - // with the normal behavior - gSaveContext.respawnFlag = 2; - gSaveContext.save.cutsceneIndex = 0; + // Copied from ObjTokeidai_TowerOpening_EndCutscene SET_WEEKEVENTREG(WEEKEVENTREG_CLOCK_TOWER_OPENED); + gSaveContext.save.cutsceneIndex = 0; + gSaveContext.respawnFlag = 2; + gSaveContext.save.entrance = gSaveContext.respawn[RESPAWN_MODE_RETURN].entrance; + if (gSaveContext.respawn[RESPAWN_MODE_RETURN].playerParams == + PLAYER_PARAMS(0xFF, PLAYER_INITMODE_TELESCOPE)) { + gSaveContext.nextTransitionType = TRANS_TYPE_CIRCLE; + } else { + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; + } } }); } diff --git a/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h b/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h index 27c61447f..7d03955d8 100644 --- a/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h +++ b/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h @@ -51,6 +51,7 @@ typedef enum { GI_VB_TATL_INTERUPT_MSG6, GI_VB_ITEM_BE_RESTRICTED, GI_VB_FLIP_HOP_VARIABLE, + GI_VB_CLOCK_TOWER_OPENING_CONSIDER_THIS_FIRST_CYCLE, } GIVanillaBehavior; typedef enum { diff --git a/mm/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/mm/src/overlays/actors/ovl_En_Test4/z_en_test4.c index 5900c4a9c..fb9a88f3b 100644 --- a/mm/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/mm/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -8,6 +8,7 @@ #include "z64horse.h" #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" #include "overlays/actors/ovl_En_Horse/z_en_horse.h" +#include "2s2h/Enhancements/GameInteractor/GameInteractor.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_100000) @@ -443,7 +444,9 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { if (CURRENT_DAY == 3) { if ((this->nextBellTime == CLOCK_TIME(0, 0)) && - ((gSaveContext.save.saveInfo.inventory.items[SLOT_OCARINA] == ITEM_NONE) || + (GameInteractor_Should(GI_VB_CLOCK_TOWER_OPENING_CONSIDER_THIS_FIRST_CYCLE, + gSaveContext.save.saveInfo.inventory.items[SLOT_OCARINA] == ITEM_NONE, + this) || (play->sceneId == SCENE_CLOCKTOWER))) { s32 playerParams; u32 entrance = gSaveContext.save.entrance;