From 6cd387ddf334ba73c812916f64a0a5874b69208b Mon Sep 17 00:00:00 2001 From: Malkierian Date: Tue, 17 Sep 2024 08:40:38 -0700 Subject: [PATCH] Fix Deku Mouth for Entrance Rando and Mido Rando Functionality (#4342) * Restore Deku Tree open as adult with dungeon shuffle. * Add Mido spawn VB to allow for preventing Mido moving in rando when starting with Zelda's letter and closed deku or forest. * Use RAND_GET_OPTION instead of OTRGlobals rando context, get rid of IS_RANDO in deku mouth VB handler. --- .../Enhancements/game-interactor/GameInteractor.h | 2 ++ soh/soh/Enhancements/randomizer/hook_handlers.cpp | 14 ++++++++++++++ soh/src/overlays/actors/ovl_En_Md/z_en_md.c | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor.h b/soh/soh/Enhancements/game-interactor/GameInteractor.h index 3523fa405..108d2f33e 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor.h @@ -78,6 +78,8 @@ typedef enum { // Vanilla condition: INFTABLE_GREETED_BY_SARIA VB_NOT_BE_GREETED_BY_SARIA, // Opt: *EnMd + VB_MIDO_SPAWN, + // Opt: *EnMd // Vanilla condition: EnMd->interactInfo.talkState == NPC_TALK_STATE_ACTION VB_MOVE_MIDO_IN_KOKIRI_FOREST, // Opt: *EnMd diff --git a/soh/soh/Enhancements/randomizer/hook_handlers.cpp b/soh/soh/Enhancements/randomizer/hook_handlers.cpp index 4bd8da742..92a1b278c 100644 --- a/soh/soh/Enhancements/randomizer/hook_handlers.cpp +++ b/soh/soh/Enhancements/randomizer/hook_handlers.cpp @@ -12,6 +12,7 @@ extern "C" { #include "functions.h" #include "variables.h" #include "soh/Enhancements/randomizer/adult_trade_shuffle.h" +#include "src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth.h" #include "src/overlays/actors/ovl_En_Si/z_en_si.h" #include "src/overlays/actors/ovl_En_Cow/z_en_cow.h" #include "src/overlays/actors/ovl_En_Shopnuts/z_en_shopnuts.h" @@ -614,6 +615,11 @@ void RandomizerOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, void case VB_BE_ELIGIBLE_FOR_PRELUDE_OF_LIGHT: *should = !Flags_GetEventChkInf(EVENTCHKINF_LEARNED_PRELUDE_OF_LIGHT) && CHECK_QUEST_ITEM(QUEST_MEDALLION_FOREST); break; + case VB_MIDO_SPAWN: + if (RAND_GET_OPTION(RSK_FOREST) != RO_FOREST_OPEN && !Flags_GetEventChkInf(EVENTCHKINF_SHOWED_MIDO_SWORD_SHIELD)) { + *should = true; + } + break; case VB_MOVE_MIDO_IN_KOKIRI_FOREST: if (RAND_GET_OPTION(RSK_FOREST) == RO_FOREST_OPEN) { *should = true; @@ -1465,6 +1471,14 @@ void RandomizerOnActorInitHandler(void* actorRef) { } } + if (actor->id == ACTOR_BG_TREEMOUTH && LINK_IS_ADULT && + RAND_GET_OPTION(RSK_SHUFFLE_DUNGEON_ENTRANCES) != RO_DUNGEON_ENTRANCE_SHUFFLE_OFF && + (RAND_GET_OPTION(RSK_FOREST) == RO_FOREST_OPEN || + Flags_GetEventChkInf(EVENTCHKINF_SHOWED_MIDO_SWORD_SHIELD))) { + BgTreemouth* bgTreemouth = static_cast(actorRef); + bgTreemouth->unk_168 = 1.0f; + } + //consumable bags if ( actor->id == ACTOR_EN_ITEM00 && diff --git a/soh/src/overlays/actors/ovl_En_Md/z_en_md.c b/soh/src/overlays/actors/ovl_En_Md/z_en_md.c index f55123f5b..5567f3e29 100644 --- a/soh/src/overlays/actors/ovl_En_Md/z_en_md.c +++ b/soh/src/overlays/actors/ovl_En_Md/z_en_md.c @@ -646,7 +646,7 @@ void EnMd_Init(Actor* thisx, PlayState* play) { Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - if (!EnMd_ShouldSpawn(this, play)) { + if (!GameInteractor_Should(VB_MIDO_SPAWN, EnMd_ShouldSpawn(this, play), this)) { Actor_Kill(&this->actor); return; }