From 3a4bd1164a58929f952ce08b7c2cb2c9065f97f8 Mon Sep 17 00:00:00 2001 From: Jordan Longstaff Date: Mon, 21 Oct 2024 22:18:34 -0400 Subject: [PATCH] Add freeze timer hook for Gold Skulltula collection (#4445) * Add freeze timer hook for Gold Skulltula collection * Remove unused player references * Replace magic number text IDs * Separate hook for freezing player on token collection * Revert one unintended change --- .../Enhancements/game-interactor/GameInteractor.h | 1 + soh/soh/Enhancements/timesaver_hook_handlers.cpp | 5 +++++ soh/src/overlays/actors/ovl_En_Si/z_en_si.c | 15 ++++++++++----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor.h b/soh/soh/Enhancements/game-interactor/GameInteractor.h index 6225cb1b5..892482e35 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor.h @@ -348,6 +348,7 @@ typedef enum { VB_GIVE_ITEM_FROM_ITEM_00, // Opt: *EnSi VB_GIVE_ITEM_SKULL_TOKEN, + VB_FREEZE_ON_SKULL_TOKEN, // Opt: *EnCow VB_GIVE_ITEM_FROM_COW, // Opt: *EnDns diff --git a/soh/soh/Enhancements/timesaver_hook_handlers.cpp b/soh/soh/Enhancements/timesaver_hook_handlers.cpp index f496bcdf4..f16f2d44f 100644 --- a/soh/soh/Enhancements/timesaver_hook_handlers.cpp +++ b/soh/soh/Enhancements/timesaver_hook_handlers.cpp @@ -529,6 +529,11 @@ void TimeSaverOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_li *should = false; } break; + case VB_FREEZE_ON_SKULL_TOKEN: + if (CVarGetInteger(CVAR_ENHANCEMENT("SkulltulaFreeze"), 0)) { + *should = false; + } + break; case VB_DAMPE_IN_GRAVEYARD_DESPAWN: if (CVarGetInteger(CVAR_ENHANCEMENT("DampeAllNight"), 0)) { *should = LINK_IS_ADULT || gPlayState->sceneNum != SCENE_GRAVEYARD; diff --git a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c index 170eed16e..832e3c45d 100644 --- a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -5,6 +5,7 @@ */ #include "z_en_si.h" +#include "soh/Enhancements/custom-message/CustomMessageTypes.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_HOOKSHOT_DRAGS) @@ -96,8 +97,10 @@ void func_80AFB768(EnSi* this, PlayState* play) { this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; if (GameInteractor_Should(VB_GIVE_ITEM_SKULL_TOKEN, true, this)) { Item_Give(play, ITEM_SKULL_TOKEN); - player->actor.freezeTimer = 10; - Message_StartTextbox(play, 0xB4, NULL); + if (GameInteractor_Should(VB_FREEZE_ON_SKULL_TOKEN, true, this)) { + player->actor.freezeTimer = 10; + } + Message_StartTextbox(play, TEXT_GS_NO_FREEZE, NULL); Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); } this->actionFunc = func_80AFB950; @@ -120,8 +123,10 @@ void func_80AFB89C(EnSi* this, PlayState* play) { if (!CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_HOOKSHOT_ATTACHED)) { if (GameInteractor_Should(VB_GIVE_ITEM_SKULL_TOKEN, true, this)) { Item_Give(play, ITEM_SKULL_TOKEN); - player->actor.freezeTimer = 10; - Message_StartTextbox(play, 0xB4, NULL); + if (GameInteractor_Should(VB_FREEZE_ON_SKULL_TOKEN, true, this)) { + player->actor.freezeTimer = 10; + } + Message_StartTextbox(play, TEXT_GS_NO_FREEZE, NULL); Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); } this->actionFunc = func_80AFB950; @@ -131,7 +136,7 @@ void func_80AFB89C(EnSi* this, PlayState* play) { void func_80AFB950(EnSi* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (Message_GetState(&play->msgCtx) != TEXT_STATE_CLOSING && GameInteractor_Should(VB_GIVE_ITEM_SKULL_TOKEN, true, this)) { + if (Message_GetState(&play->msgCtx) != TEXT_STATE_CLOSING && GameInteractor_Should(VB_FREEZE_ON_SKULL_TOKEN, true, this)) { player->actor.freezeTimer = 10; } else { SET_GS_FLAGS((this->actor.params & 0x1F00) >> 8, this->actor.params & 0xFF);