Move fix to hook

This commit is contained in:
JordanLongstaff 2025-01-12 15:03:07 -05:00
parent f05e9c99b9
commit 802a25971e
2 changed files with 20 additions and 12 deletions

View File

@ -800,6 +800,21 @@ void RegisterBrokenGiantsKnifeFix() {
});
}
void RegisterDekuNutUpgradeFix() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
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();

View File

@ -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(
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::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");