From a2cd701203198bfb79d3f8a532f1c8d8be82ca64 Mon Sep 17 00:00:00 2001 From: TakaRikka Date: Thu, 13 Aug 2026 23:32:21 -0700 Subject: [PATCH] ykm/ykw/fairy hooks --- include/d/actor/d_a_npc_fairy.h | 2 +- include/d/actor/d_a_npc_ykm.h | 2 +- mods/randomizer/src/hooks.cpp | 45 +++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/include/d/actor/d_a_npc_fairy.h b/include/d/actor/d_a_npc_fairy.h index efa9d760c1..da9977ed37 100644 --- a/include/d/actor/d_a_npc_fairy.h +++ b/include/d/actor/d_a_npc_fairy.h @@ -296,7 +296,7 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[18]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[18]; -private: +// private: /* 0x0E40 */ NPC_FAIRY_HIO_CLASS* mHIO; /* 0x0E44 */ dCcD_Cyl mCyl; /* 0x0F80 */ u8 mType; diff --git a/include/d/actor/d_a_npc_ykm.h b/include/d/actor/d_a_npc_ykm.h index d486d6fe6a..5ad9e7210b 100644 --- a/include/d/actor/d_a_npc_ykm.h +++ b/include/d/actor/d_a_npc_ykm.h @@ -287,7 +287,7 @@ public: static DUSK_GAME_DATA char DUSK_CONST* DUSK_CONST mCutNameList[10]; static DUSK_GAME_DATA cutFunc DUSK_CONST mCutList[10]; -private: +// private: /* 0x0E40 */ mDoExt_McaMorfSO* mFishModelMorf; /* 0x0E44 */ mDoExt_McaMorfSO* mLeafModelMorf; /* 0x0E48 */ NPC_YKM_HIO_CLASS* mpHIO; diff --git a/mods/randomizer/src/hooks.cpp b/mods/randomizer/src/hooks.cpp index f6a27bf363..5437aaa9ef 100644 --- a/mods/randomizer/src/hooks.cpp +++ b/mods/randomizer/src/hooks.cpp @@ -19,6 +19,9 @@ #include "d/actor/d_a_npc4.h" #include "d/actor/d_a_npc_bans.h" #include "d/actor/d_a_tag_kmsg.h" +#include "d/actor/d_a_npc_fairy.h" +#include "d/actor/d_a_npc_ykm.h" +#include "d/actor/d_a_npc_ykw.h" #include "d/d_door_param2.h" #include "d/d_file_sel_info.h" #include "d/d_file_select.h" @@ -91,6 +94,11 @@ DEFINE_HOOK(&daNpcF_c::orderEvent, daNpcF_c__orderEvent); DEFINE_HOOK(&daNpc_Bans_c::isDelete, daNpc_Bans_c__isDelete); +DEFINE_HOOK(&daNpc_Fairy_c::AppearDemoCall, daNpc_Fairy_c__AppearDemoCall); + +DEFINE_HOOK(&daNpc_ykM_c::isDelete, daNpc_ykM_c__isDelete); +DEFINE_HOOK(&daNpc_ykW_c::isDelete, daNpc_ykW_c__isDelete); + namespace randomizer::ui { dialogSelectModeState g_dialogSelectModeState = SelectReady; } @@ -1486,6 +1494,33 @@ HookAction hookPreNpcFOrderEvent(ModContext*, void* args, void* retval, void*) { return HOOK_CONTINUE; } +void hookPostFairyAppearDemoCall(ModContext*, void* args, void* retval, void*) { + daNpc_Fairy_c* i_this = mods::arg(args, 0); + + // randomizer overrides EVT_APPEAR_50F_04 set to always be EVT_APPEAR_50F_01 + if (i_this->field_0xff4 == 12) { + i_this->field_0xff4 = 9; + } +} + +void hookPostYkMIsDelete(ModContext*, void* args, void* retval, void*) { + daNpc_ykM_c* i_this = mods::arg(args, 0); + + if (i_this->mType == daNpc_ykM_c::TYPE_COOK) { + // We don't want cooking Yeto to leave the dungeon, even if the BK is obtained. + *static_cast(retval) = FALSE; + } +} + +void hookPostYkWIsDelete(ModContext*, void* args, void* retval, void*) { + daNpc_ykW_c* i_this = mods::arg(args, 0); + + if (i_this->field_0xf80 == 1) { + // We don't want Yeta to leave the dungeon, even if the BK is obtained. + *static_cast(retval) = FALSE; + } +} + } ModResult initialize() { @@ -1562,6 +1597,11 @@ ModResult initialize() { ADD_HOOK_PRE(daNpc_Bans_c__isDelete, hookPreNpcBansIsDelete); + ADD_HOOK_POST(daNpc_Fairy_c__AppearDemoCall, hookPostFairyAppearDemoCall); + + ADD_HOOK_POST(daNpc_ykM_c__isDelete, hookPostYkMIsDelete); + ADD_HOOK_POST(daNpc_ykW_c__isDelete, hookPostYkWIsDelete); + return MOD_OK; } @@ -1627,6 +1667,11 @@ ModResult uninstall() { mods::hook::uninstall(svc_hook); + mods::hook::uninstall(svc_hook); + + mods::hook::uninstall(svc_hook); + mods::hook::uninstall(svc_hook); + return MOD_OK; } } \ No newline at end of file