From a13932e901bb7e26f20eb4f9c2517b826cc039c1 Mon Sep 17 00:00:00 2001 From: TakaRikka Date: Sat, 15 Aug 2026 15:32:09 -0700 Subject: [PATCH] partial ms check fix --- mods/randomizer/src/hooks.cpp | 49 ++++++++++++++--------------------- 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/mods/randomizer/src/hooks.cpp b/mods/randomizer/src/hooks.cpp index 0c76793ee1..28c71adc20 100644 --- a/mods/randomizer/src/hooks.cpp +++ b/mods/randomizer/src/hooks.cpp @@ -133,7 +133,7 @@ DEFINE_HOOK(&daNpc_ykW_c::isDelete, daNpc_ykW_c__isDelete); DEFINE_HOOK_SYMBOL("daE_MD_Create", int(fopAc_ac_c*), daE_MD_c__create); -DEFINE_HOOK(&daObjMasterSword_c::executeWait, daObjMasterSword_c__executeWait); +DEFINE_HOOK(&fopAcM_orderMapToolEvent, orderMapToolEvent); DEFINE_HOOK_SYMBOL("daObjMasterSword_Execute", int(daObjMasterSword_c*), daObjMasterSword_c__execute); DEFINE_HOOK(&dScnName_c::changeGameScene, dScnName_c__changeGameScene); @@ -2152,47 +2152,36 @@ void hookPostEMdCreate(ModContext*, void* args, void*, void*) { hookEMdCreate_prevSkipInfo = 0; } -// functions are simple enough that replacing isn't too bad -// todo: item service needs to be properly hooked up to this check i think instead of -// using "randomizer_getItemAtLocation" -void hookReplaceMasterSwordExecuteWait(ModContext*, void* args, void*, void*) { - auto* i_this = mods::arg(args, 0); - - if (daPy_getPlayerActorClass()->checkPriActorOwn(i_this)) { - for (int i = 0; i < dComIfGp_getAttention()->GetActionCount(); i++) { - if (dComIfGp_getAttention()->ActionTarget(i) == i_this) { - if (dComIfGp_getAttention()->getActionBtnB() != NULL && - dComIfGp_getAttention()->getActionBtnB()->mType == fopAc_attn_CARRY_e) - { - dComIfGp_setDoStatusForce(8, 0); - } - } - } - } - - if (fopAcM_checkCarryNow(i_this)) { - u8 itemToGive = randomizer_getItemAtLocation("Sacred Grove Pedestal Master Sword"); - g_randomizerState.addItemToEventQueue(itemToGive); - - itemToGive = randomizer_getItemAtLocation("Sacred Grove Pedestal Shadow Crystal"); - g_randomizerState.addItemToEventQueue(itemToGive); +HookAction hookPreOrderMapToolEvent(ModContext*, void* args, void*, void*) { + auto eventId = mods::arg(args, 1); + // skip starting the master sword cutscene so we can handle the checks manually + if (daAlink_c::checkStageName("F_SP117") && eventId == 2) { + // Set the necessary flags to de-spawn the MS and set the save file event flag. dComIfGs_onTmpBit(0x820); dComIfGs_onEventBit(0x2120); + return HOOK_SKIP_ORIGINAL; } + + return HOOK_CONTINUE; } HookAction hookPreMasterSwordExecute(ModContext*, void* args, void* retval, void*) { auto* i_this = mods::arg(args, 0); + (i_this->*i_this->mActionFunc[1])(); + dComIfG_Ccsp()->Set(&i_this->mCyl); + + i_this->mBtk.play(); + i_this->mBrk.play(); + if (dComIfGs_isTmpBit(dSv_event_tmp_flag_c::tempBitLabels[73])) { // Don't automatically give the master sword in randomizer fopAcM_delete(i_this); - *static_cast(retval) = 1; - return HOOK_SKIP_ORIGINAL; } - return HOOK_CONTINUE; + *static_cast(retval) = 1; + return HOOK_SKIP_ORIGINAL; } void hookPost_dScnName_c__changeGameScene(ModContext* ctx, void* args, void* retval, void* userdata) { @@ -2628,7 +2617,7 @@ ModResult initialize() { ADD_HOOK_PRE(daE_MD_c__create, hookPreEMdCreate); ADD_HOOK_POST(daE_MD_c__create, hookPostEMdCreate); - ADD_HOOK_REPLACE(daObjMasterSword_c__executeWait, hookReplaceMasterSwordExecuteWait); + ADD_HOOK_PRE(orderMapToolEvent, hookPreOrderMapToolEvent); ADD_HOOK_PRE(daObjMasterSword_c__execute, hookPreMasterSwordExecute); ADD_HOOK_POST(dScnName_c__changeGameScene, hookPost_dScnName_c__changeGameScene); @@ -2746,7 +2735,7 @@ ModResult uninstall() { mods::hook::uninstall(svc_hook); - mods::hook::uninstall(svc_hook); + mods::hook::uninstall(svc_hook); mods::hook::uninstall(svc_hook); mods::hook::uninstall();