diff --git a/mm/2s2h/BenGui/BenMenuBar.cpp b/mm/2s2h/BenGui/BenMenuBar.cpp index c52df59a1..c01729ab0 100644 --- a/mm/2s2h/BenGui/BenMenuBar.cpp +++ b/mm/2s2h/BenGui/BenMenuBar.cpp @@ -668,6 +668,8 @@ void DrawEnhancementsMenu() { UIWidgets::CVarCheckbox("Pause Owl Warp", "gEnhancements.Songs.PauseOwlWarp", { .tooltip = "Allows the player to use the pause menu map to owl warp instead of " "having to play the Song of Soaring." }); + UIWidgets::CVarSliderInt("Zora Eggs For Bossa Nova", "gEnhancements.Songs.ZoraEggCount", 1, 7, 7, + { .tooltip = "The number of eggs required to unlock new wave bossa nova." }); ImGui::EndMenu(); } diff --git a/mm/2s2h/Enhancements/Enhancements.cpp b/mm/2s2h/Enhancements/Enhancements.cpp index d0c3cd939..2acb6db07 100644 --- a/mm/2s2h/Enhancements/Enhancements.cpp +++ b/mm/2s2h/Enhancements/Enhancements.cpp @@ -52,6 +52,7 @@ void InitEnhancements() { // Songs RegisterEnableSunsSong(); RegisterPauseOwlWarp(); + RegisterZoraEggCount(); // Restorations RegisterPowerCrouchStab(); diff --git a/mm/2s2h/Enhancements/Enhancements.h b/mm/2s2h/Enhancements/Enhancements.h index c69692e49..20ef77abc 100644 --- a/mm/2s2h/Enhancements/Enhancements.h +++ b/mm/2s2h/Enhancements/Enhancements.h @@ -32,6 +32,7 @@ #include "Player/Player.h" #include "Songs/EnableSunsSong.h" #include "Songs/PauseOwlWarp.h" +#include "Songs/ZoraEggCount.h" #include "Saving/SavingEnhancements.h" #include "Graphics/DisableBlackBars.h" #include "Modes/TimeMovesWhenYouMove.h" diff --git a/mm/2s2h/Enhancements/Songs/ZoraEggCount.cpp b/mm/2s2h/Enhancements/Songs/ZoraEggCount.cpp new file mode 100644 index 000000000..af03c56fe --- /dev/null +++ b/mm/2s2h/Enhancements/Songs/ZoraEggCount.cpp @@ -0,0 +1,38 @@ +#include "ZoraEggCount.h" +#include +#include "Enhancements/GameInteractor/GameInteractor.h" + +extern "C" { +#include "src/overlays/actors/ovl_En_Mk/z_en_mk.h" +} + +const uint32_t MAX_EGGS = 7; + +void RegisterZoraEggCount() { + // marine researcher, his actor update call is more consistent than the eggs + GameInteractor::Instance->RegisterGameHookForID(ACTOR_EN_MK, [](Actor* outerActor) { + static uint32_t enMkUpdateHook = 0; + static uint32_t enMkKillHook = 0; + GameInteractor::Instance->UnregisterGameHookForPtr(enMkUpdateHook); + GameInteractor::Instance->UnregisterGameHook(enMkKillHook); + enMkUpdateHook = 0; + enMkKillHook = 0; + + enMkUpdateHook = GameInteractor::Instance->RegisterGameHookForPtr( + (uintptr_t)outerActor, [](Actor* actor) { + // complete quest if you have enough eggs + if (gSaveContext.save.saveInfo.permanentSceneFlags[SCENE_LABO].unk_14 != MAX_EGGS && + CVarGetInteger("gEnhancements.Songs.ZoraEggCount", MAX_EGGS) <= + gSaveContext.save.saveInfo.permanentSceneFlags[SCENE_LABO].unk_14) { + gSaveContext.save.saveInfo.permanentSceneFlags[SCENE_LABO].unk_14 = MAX_EGGS; + } + }); + enMkKillHook = + GameInteractor::Instance->RegisterGameHook([](s8 sceneId, s8 spawnNum) { + GameInteractor::Instance->UnregisterGameHook(enMkUpdateHook); + GameInteractor::Instance->UnregisterGameHook(enMkKillHook); + enMkUpdateHook = 0; + enMkKillHook = 0; + }); + }); +} \ No newline at end of file diff --git a/mm/2s2h/Enhancements/Songs/ZoraEggCount.h b/mm/2s2h/Enhancements/Songs/ZoraEggCount.h new file mode 100644 index 000000000..35ac5ed60 --- /dev/null +++ b/mm/2s2h/Enhancements/Songs/ZoraEggCount.h @@ -0,0 +1,6 @@ +#ifndef VARIABLE_ZORA_EGG_COUNT_H +#define VARIABLE_ZORA_EGG_COUNT_H + +void RegisterZoraEggCount(); + +#endif // VARIABLE_ZORA_EGG_COUNT_H \ No newline at end of file