mirror of
https://github.com/HarbourMasters/2ship2harkinian.git
synced 2024-11-27 00:00:32 +00:00
[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:
parent
0c2a51c9f4
commit
136a928883
@ -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();
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ void InitEnhancements() {
|
||||
// Songs
|
||||
RegisterEnableSunsSong();
|
||||
RegisterPauseOwlWarp();
|
||||
RegisterZoraEggCount();
|
||||
|
||||
// Restorations
|
||||
RegisterPowerCrouchStab();
|
||||
|
@ -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"
|
||||
|
38
mm/2s2h/Enhancements/Songs/ZoraEggCount.cpp
Normal file
38
mm/2s2h/Enhancements/Songs/ZoraEggCount.cpp
Normal 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;
|
||||
});
|
||||
});
|
||||
}
|
6
mm/2s2h/Enhancements/Songs/ZoraEggCount.h
Normal file
6
mm/2s2h/Enhancements/Songs/ZoraEggCount.h
Normal 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
|
Loading…
Reference in New Issue
Block a user