diff --git a/soh/soh/Enhancements/Difficulty/DivingGameTimer.cpp b/soh/soh/Enhancements/Difficulty/DivingGameTimer.cpp new file mode 100644 index 000000000..ff5e717aa --- /dev/null +++ b/soh/soh/Enhancements/Difficulty/DivingGameTimer.cpp @@ -0,0 +1,21 @@ +#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" +#include "soh/ShipInit.hpp" + +extern "C" { +#include "functions.h" +extern GameInfo* gGameInfo; +} + +static constexpr int32_t CVAR_DIVING_GAME_TIME_DEFAULT = 50; +#define CVAR_DIVING_GAME_TIME_NAME CVAR_ENHANCEMENT("DivingGame.TimeLimit") +#define CVAR_DIVING_GAME_TIME_VALUE CVarGetInteger(CVAR_DIVING_GAME_TIME_NAME, CVAR_DIVING_GAME_TIME_DEFAULT) +#define CVAR_DIVING_GAME_TIME_SET (CVAR_DIVING_GAME_TIME_VALUE != CVAR_DIVING_GAME_TIME_DEFAULT) + +static void RegisterDIvingGameTimeLimit() { + COND_VB_SHOULD(VB_SET_DIVING_GAME_TIME_LIMIT, CVAR_DIVING_GAME_TIME_SET, { + Interface_SetTimer(BREG(2) + CVAR_DIVING_GAME_TIME_VALUE); + *should = false; + }); +} + +static RegisterShipInitFunc initFunc(RegisterDIvingGameTimeLimit, { CVAR_DIVING_GAME_TIME_NAME }); diff --git a/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h b/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h index aba9f1e68..06eff69cb 100644 --- a/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h +++ b/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h @@ -2052,6 +2052,14 @@ typedef enum { // - `*EnNiwLady` VB_SET_CUCCO_COUNT, + // #### `result` + // ```c + // true + // ``` + // #### `args` + // - None + VB_SET_DIVING_GAME_TIME_LIMIT, + // #### `result` // ```c // SurfaceType_GetSlope(&play->colCtx, poly, bgId) == 2 diff --git a/soh/soh/SohGui/SohMenuEnhancements.cpp b/soh/soh/SohGui/SohMenuEnhancements.cpp index c8e6c34d4..461d2ca23 100644 --- a/soh/soh/SohGui/SohMenuEnhancements.cpp +++ b/soh/soh/SohGui/SohMenuEnhancements.cpp @@ -1523,6 +1523,11 @@ void SohMenu::AddMenuEnhancements() { .Options(CheckboxOptions().Tooltip("Amy's block pushing puzzle instantly solved.")); path.column = SECTION_COLUMN_3; + AddWidget(path, "Rupee Diving Game", WIDGET_SEPARATOR_TEXT); + AddWidget(path, "Time Limit: %d seconds", WIDGET_CVAR_SLIDER_INT) + .CVar(CVAR_ENHANCEMENT("DivingGame.TimeLimit")) + .Options(IntSliderOptions().Min(30).Max(120).DefaultValue(50).Format("%d seconds")); + AddWidget(path, "Fishing", WIDGET_SEPARATOR_TEXT); AddWidget(path, "Customize Behavior##Fishing", WIDGET_CVAR_CHECKBOX) .CVar(CVAR_ENHANCEMENT("CustomizeFishing")) diff --git a/soh/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c b/soh/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c index 194e09fd3..cd1a14f1f 100644 --- a/soh/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c +++ b/soh/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c @@ -424,10 +424,12 @@ void func_809EE800(EnDivingGame* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (this->unk_292 == Message_GetState(&play->msgCtx) && Message_ShouldAdvance(play)) { Message_CloseTextbox(play); - if (!Flags_GetEventChkInf(EVENTCHKINF_OBTAINED_SILVER_SCALE)) { - Interface_SetTimer(BREG(2) + 50); - } else { - Interface_SetTimer(BREG(2) + 50); + if (GameInteractor_Should(VB_SET_DIVING_GAME_TIME_LIMIT, true)) { + if (!Flags_GetEventChkInf(EVENTCHKINF_OBTAINED_SILVER_SCALE)) { + Interface_SetTimer(BREG(2) + 50); + } else { + Interface_SetTimer(BREG(2) + 50); + } } func_800F5ACC(NA_BGM_TIMED_MINI_GAME); Player_SetCsActionWithHaltedActors(play, NULL, 7);