From a93fec263473b2b08ebb18590a8ef1a3fc25a775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= <159546+serprex@users.noreply.github.com> Date: Mon, 12 Oct 2026 20:47:51 +0000 Subject: [PATCH] Add setting to limit minimum heat/water timer (#7373) Useful with rando settings where player never gets more than 3 hearts --- .../Difficulty/HazardTimerMin.cpp | 21 +++++++++++++++++++ soh/soh/SohGui/SohMenuEnhancements.cpp | 8 +++++++ 2 files changed, 29 insertions(+) create mode 100644 soh/soh/Enhancements/Difficulty/HazardTimerMin.cpp diff --git a/soh/soh/Enhancements/Difficulty/HazardTimerMin.cpp b/soh/soh/Enhancements/Difficulty/HazardTimerMin.cpp new file mode 100644 index 0000000000..9613e7a958 --- /dev/null +++ b/soh/soh/Enhancements/Difficulty/HazardTimerMin.cpp @@ -0,0 +1,21 @@ +#include + +#include "soh/Enhancements/game-interactor/GameInteractor.h" +#include "soh/ShipInit.hpp" + +extern "C" { +#include "variables.h" +} + +#define CVAR_HAZARD_TIMER_MIN_NAME CVAR_ENHANCEMENT("HazardTimerMin") +#define CVAR_HAZARD_TIMER_MIN_VALUE CVarGetInteger(CVAR_HAZARD_TIMER_MIN_NAME, 0) + +static void RegisterHazardTimerMin() { + COND_HOOK(OnGameFrameUpdate, CVAR_HAZARD_TIMER_MIN_VALUE, []() { + if (GameInteractor::IsSaveLoaded() && gSaveContext.timerState == TIMER_STATE_ENV_HAZARD_PREVIEW) { + gSaveContext.timerSeconds = std::max(gSaveContext.timerSeconds, CVAR_HAZARD_TIMER_MIN_VALUE); + } + }); +} + +static RegisterShipInitFunc initFunc(RegisterHazardTimerMin, { CVAR_HAZARD_TIMER_MIN_NAME }); diff --git a/soh/soh/SohGui/SohMenuEnhancements.cpp b/soh/soh/SohGui/SohMenuEnhancements.cpp index 759e0605ab..acdfd6ebd5 100644 --- a/soh/soh/SohGui/SohMenuEnhancements.cpp +++ b/soh/soh/SohGui/SohMenuEnhancements.cpp @@ -1516,6 +1516,14 @@ void SohMenu::AddMenuEnhancements() { .Options(IntSliderOptions().Min(-5).Max(5).DefaultValue(0).Format("%+d").Tooltip( "-5 will be half as much time, +5 will be 6x as much time. Affects timed switches, torches, GTG statue " "eyes, & doors in race with Dampe.")); + AddWidget(path, "Minimum Heat/Water Timer: %d seconds", WIDGET_CVAR_SLIDER_INT) + .CVar(CVAR_ENHANCEMENT("HazardTimerMin")) + .Options(IntSliderOptions() + .Min(0) + .Max(150) + .DefaultValue(0) + .Format("%d seconds") + .Tooltip("Limits how low heat timer or underwater timer can start.")); AddWidget(path, "Always Win Goron Pot", WIDGET_CVAR_CHECKBOX) .CVar(CVAR_ENHANCEMENT("GoronPot")) .Options(CheckboxOptions().Tooltip("Always get the Heart Piece/Purple Rupee from the Spinning Goron Pot."));