From 45992125463a648997159b77517c8a2f4d1fd246 Mon Sep 17 00:00:00 2001 From: Patrick12115 <115201185+Patrick12115@users.noreply.github.com> Date: Thu, 15 Feb 2024 23:02:58 -0500 Subject: [PATCH] [Fixes] Fix Raised Floor Switches (#3851) * Lower by 1 * gEnhancements. * Update z_obj_switch.c Co-authored-by: Archez * Moved to Hook * Properly this time * Added to presets * Added a Return; * Use Hex Co-authored-by: inspectredc <78732756+inspectredc@users.noreply.github.com> --------- Co-authored-by: Archez Co-authored-by: inspectredc <78732756+inspectredc@users.noreply.github.com> Co-authored-by: Garrett Cox --- soh/soh/Enhancements/mods.cpp | 19 +++++++++++++++++++ soh/soh/Enhancements/presets.h | 7 +++++++ soh/soh/SohMenuBar.cpp | 3 +++ 3 files changed, 29 insertions(+) diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index 4788fb4f5..d1147f5fc 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -23,6 +23,7 @@ #include "src/overlays/actors/ovl_En_Tp/z_en_tp.h" #include "src/overlays/actors/ovl_En_Firefly/z_en_firefly.h" #include "src/overlays/actors/ovl_En_Xc/z_en_xc.h" +#include "src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h" #include "objects/object_link_boy/object_link_boy.h" #include "objects/object_link_child/object_link_child.h" @@ -1359,6 +1360,23 @@ void RegisterToTMedallions() { }); } + +void RegisterFloorSwitchesHook() { + GameInteractor::Instance->RegisterGameHook([](void* refActor) { + Actor* actor = static_cast(refActor); + if (actor->id != ACTOR_OBJ_SWITCH || !CVarGetInteger("gEnhancements.FixFloorSwitches", 0)) { + return; + } + + ObjSwitch* switchActor = reinterpret_cast(actor); + s32 type = (switchActor->dyna.actor.params & 7); + + if (switchActor->dyna.actor.params == 0x1200 || switchActor->dyna.actor.params == 0x3A00) { + switchActor->dyna.actor.world.pos.y -= 1; + } + }); +} + void RegisterPauseMenuHooks() { static bool pauseWarpHooksRegistered = false; GameInteractor::Instance->RegisterGameHook([&]() { @@ -1411,6 +1429,7 @@ void InitMods() { RegisterOpenAllHours(); RegisterToTMedallions(); NameTag_RegisterHooks(); + RegisterFloorSwitchesHook(); RegisterPatchHandHandler(); RegisterHurtContainerModeHandler(); RegisterPauseMenuHooks(); diff --git a/soh/soh/Enhancements/presets.h b/soh/soh/Enhancements/presets.h index d25d92780..025581b0d 100644 --- a/soh/soh/Enhancements/presets.h +++ b/soh/soh/Enhancements/presets.h @@ -270,6 +270,7 @@ const std::vector enhancementsCvars = { "gEnhancements.ResetNaviTimer", "gEnhancements.ScaleAdultEquimentAsChild", "gEnhancements.SwordToggle", + "gEnhancements.FixFloorSwitches", "gFixZoraHintDialogue", "gHurtContainer", "gPauseWarp", @@ -543,6 +544,8 @@ const std::vector vanillaPlusPresetEntries = { PRESET_ENTRY_S32("gNaviTextFix", 1), // Extend Silver Rupee Jingle PRESET_ENTRY_S32("gSilverRupeeJingleExtend", 1), + // Fix some Floor Switches + PRESET_ENTRY_S32("gEnhancements.FixFloorSwitches", 1), // Red Ganon blood PRESET_ENTRY_S32("gRedGanonBlood", 1), @@ -614,6 +617,8 @@ const std::vector enhancedPresetEntries = { PRESET_ENTRY_S32("gSilverRupeeJingleExtend", 1), // Fix enemies not spawning on ground over water PRESET_ENTRY_S32("gEnemySpawnsOverWaterboxes", 1), + // Fix some Floor Switches + PRESET_ENTRY_S32("gEnhancements.FixFloorSwitches", 1), // Red Ganon blood PRESET_ENTRY_S32("gRedGanonBlood", 1), @@ -736,6 +741,8 @@ const std::vector randomizerPresetEntries = { PRESET_ENTRY_S32("gNaviTextFix", 1), // Extend Silver Rupee Jingle PRESET_ENTRY_S32("gSilverRupeeJingleExtend", 1), + // Fix some Floor Switches + PRESET_ENTRY_S32("gEnhancements.FixFloorSwitches", 1), // Red Ganon blood PRESET_ENTRY_S32("gRedGanonBlood", 1), diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 96d99fbb1..a3f91b145 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -1252,6 +1252,9 @@ void DrawEnhancementsMenu() { UIWidgets::PaddedEnhancementCheckbox("Fix Darunia dancing too fast", "gEnhancements.FixDaruniaDanceSpeed", true, false, false, "", UIWidgets::CheckboxGraphics::Cross, true); UIWidgets::Tooltip("Fixes Darunia's dancing speed so he dances to the beat of Saria's Song, like in vanilla."); + UIWidgets::PaddedEnhancementCheckbox("Fix raised Floor Switches", "gEnhancements.FixFloorSwitches", true, false); + UIWidgets::Tooltip("Fixes the two raised floor switches, the one in Forest Temple Basement and the one at the top of Fire Temple. \n" + "This will lower them, making activating them easier"); UIWidgets::PaddedEnhancementCheckbox("Fix Zora hint dialogue", "gFixZoraHintDialogue", true, false); UIWidgets::Tooltip("Fixes one Zora's dialogue giving a hint about bringing Ruto's Letter to King Zora to properly occur before moving King Zora rather than after");