[Enhancement] Custom Zora Egg Count (#624)

* initial commit of relevant files

* attempt to appease clang formatting

* fix edge case of marine researcher dialogue being wrong with low egg counts

* refactored to better use hooks and no longer touch main mm code directly

* undo GameInteractor.h changes

* removed useless egg checks, only need the researcher

* trigger remote build

* removing useless includes leftover from the old approach.

* move UIWidgets for egg into existing section
This commit is contained in:
Mothstery 2024-08-24 09:22:30 -07:00 committed by GitHub
parent 0c2a51c9f4
commit 136a928883
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 48 additions and 0 deletions

View File

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

View File

@ -52,6 +52,7 @@ void InitEnhancements() {
// Songs
RegisterEnableSunsSong();
RegisterPauseOwlWarp();
RegisterZoraEggCount();
// Restorations
RegisterPowerCrouchStab();

View File

@ -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"

View File

@ -0,0 +1,38 @@
#include "ZoraEggCount.h"
#include <libultraship/bridge.h>
#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<GameInteractor::OnActorInit>(ACTOR_EN_MK, [](Actor* outerActor) {
static uint32_t enMkUpdateHook = 0;
static uint32_t enMkKillHook = 0;
GameInteractor::Instance->UnregisterGameHookForPtr<GameInteractor::OnActorUpdate>(enMkUpdateHook);
GameInteractor::Instance->UnregisterGameHook<GameInteractor::OnSceneInit>(enMkKillHook);
enMkUpdateHook = 0;
enMkKillHook = 0;
enMkUpdateHook = GameInteractor::Instance->RegisterGameHookForPtr<GameInteractor::OnActorUpdate>(
(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<GameInteractor::OnSceneInit>([](s8 sceneId, s8 spawnNum) {
GameInteractor::Instance->UnregisterGameHook<GameInteractor::OnActorUpdate>(enMkUpdateHook);
GameInteractor::Instance->UnregisterGameHook<GameInteractor::OnSceneInit>(enMkKillHook);
enMkUpdateHook = 0;
enMkKillHook = 0;
});
});
}

View File

@ -0,0 +1,6 @@
#ifndef VARIABLE_ZORA_EGG_COUNT_H
#define VARIABLE_ZORA_EGG_COUNT_H
void RegisterZoraEggCount();
#endif // VARIABLE_ZORA_EGG_COUNT_H