diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index ac76ef53d..b78368b80 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -800,6 +800,21 @@ void RegisterBrokenGiantsKnifeFix() { }); } +void RegisterDekuNutUpgradeFix() { + GameInteractor::Instance->RegisterGameHook([]() { + if (!GameInteractor::IsSaveLoaded(true)) return; + if (CVarGetInteger(CVAR_ENHANCEMENT("DekuNutUpgradeFix"), 0)) { + s32 expectedNutUpgrades = (INV_CONTENT(ITEM_NUT) == ITEM_NUT ? 1 : 0) + + (Flags_GetInfTable(INFTABLE_193) ? 1 : 0) + + (Flags_GetItemGetInf(ITEMGETINF_OBTAINED_NUT_UPGRADE_FROM_STAGE) ? 1 : 0); + s32 actualNutUpgrades = CUR_UPG_VALUE(UPG_NUTS); + if (expectedNutUpgrades != actualNutUpgrades) { + Flags_UnsetItemGetInf(ITEMGETINF_OBTAINED_NUT_UPGRADE_FROM_STAGE); + } + } + }); +} + //this map is used for enemies that can be uniquely identified by their id //and that are always counted //enemies that can't be uniquely identified by their id @@ -1502,6 +1517,7 @@ void InitMods() { RegisterMirrorModeHandler(); RegisterResetNaviTimer(); RegisterBrokenGiantsKnifeFix(); + RegisterDekuNutUpgradeFix(); RegisterEnemyDefeatCounts(); RegisterBossDefeatTimestamps(); RegisterAltTrapTypes(); diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 5152c6213..a55007de9 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -1468,18 +1468,10 @@ void DrawEnhancementsMenu() { UIWidgets::PaddedEnhancementCheckbox("Fix the Gravedigging Tour Glitch", CVAR_ENHANCEMENT("GravediggingTourFix"), true, false, SaveManager::Instance->IsRandoFile(), "This setting is always enabled in randomizer files", UIWidgets::CheckboxGraphics::Checkmark); UIWidgets::Tooltip("Fixes a bug where the Gravedigging Tour Heart Piece disappears if the area reloads"); - if (UIWidgets::PaddedEnhancementCheckbox( - "Fix Deku Nut upgrade", CVAR_ENHANCEMENT("DekuNutUpgradeFix"), true, false, IS_RANDO, - "This setting is forcefully enabled when you are playing a randomizer.", - UIWidgets::CheckboxGraphics::Checkmark)) { - s32 expectedNutUpgrades = (INV_CONTENT(ITEM_NUT) == ITEM_NUT ? 1 : 0) + - (Flags_GetInfTable(INFTABLE_193) ? 1 : 0) + - (Flags_GetItemGetInf(ITEMGETINF_OBTAINED_NUT_UPGRADE_FROM_STAGE) ? 1 : 0); - s32 actualNutUpgrades = CUR_UPG_VALUE(UPG_NUTS); - if (expectedNutUpgrades != actualNutUpgrades) { - Flags_UnsetItemGetInf(ITEMGETINF_OBTAINED_NUT_UPGRADE_FROM_STAGE); - } - } + UIWidgets::PaddedEnhancementCheckbox( + "Fix Deku Nut upgrade", CVAR_ENHANCEMENT("DekuNutUpgradeFix"), true, false, IS_RANDO, + "This setting is forcefully enabled when you are playing a randomizer.", + UIWidgets::CheckboxGraphics::Checkmark); UIWidgets::Tooltip("Prevents the Forest Stage Deku Nut upgrade from becoming unobtainable after receiving the Poacher's Saw"); UIWidgets::PaddedEnhancementCheckbox("Fix Navi text HUD position", CVAR_ENHANCEMENT("NaviTextFix"), true, false); UIWidgets::Tooltip("Correctly centers the Navi text prompt on the HUD's C-Up button");