From cb5faa1ac83d94682815020affa792529aff9e2b Mon Sep 17 00:00:00 2001 From: Adam Bird Date: Mon, 23 Jan 2023 14:08:16 -0500 Subject: [PATCH] fix mido spawn for dungeon entrance rando (#2384) --- soh/include/z64save.h | 6 ++-- soh/src/code/z_sram.c | 8 +++--- .../actors/ovl_Bg_Treemouth/z_bg_treemouth.c | 4 +-- soh/src/overlays/actors/ovl_En_Md/z_en_md.c | 28 ++++++++++++------- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/soh/include/z64save.h b/soh/include/z64save.h index 72303c580..bab7813dd 100644 --- a/soh/include/z64save.h +++ b/soh/include/z64save.h @@ -345,9 +345,9 @@ typedef enum { #define EVENTCHKINF_02 0x02 #define EVENTCHKINF_03 0x03 -#define EVENTCHKINF_04 0x04 +#define EVENTCHKINF_SHOWED_MIDO_SWORD_SHIELD 0x04 #define EVENTCHKINF_05 0x05 -#define EVENTCHKINF_07 0x07 +#define EVENTCHKINF_OBTAINED_KOKIRI_EMERALD_DEKU_TREE_DEAD 0x07 #define EVENTCHKINF_09 0x09 #define EVENTCHKINF_0A 0x0A #define EVENTCHKINF_0B 0x0B @@ -392,7 +392,7 @@ typedef enum { #define EVENTCHKINF_40_MASK (1 << EVENTCHKINF_40_SHIFT) #define EVENTCHKINF_40 ((EVENTCHKINF_40_INDEX << 4) | EVENTCHKINF_40_SHIFT) -#define EVENTCHKINF_41 0x41 +#define EVENTCHKINF_OBTAINED_ZELDAS_LETTER 0x41 #define EVENTCHKINF_42 0x42 #define EVENTCHKINF_43 0x43 #define EVENTCHKINF_45 0x45 diff --git a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c index 40dcca14c..edf3191c9 100644 --- a/soh/src/code/z_sram.c +++ b/soh/src/code/z_sram.c @@ -366,11 +366,11 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx) { case RO_FOREST_CLOSED: break; case RO_FOREST_CLOSED_DEKU: - Flags_SetEventChkInf(7); + Flags_SetEventChkInf(EVENTCHKINF_OBTAINED_KOKIRI_EMERALD_DEKU_TREE_DEAD); break; case RO_FOREST_OPEN: - Flags_SetEventChkInf(7); - gSaveContext.eventChkInf[0] |= 0x10; + Flags_SetEventChkInf(EVENTCHKINF_OBTAINED_KOKIRI_EMERALD_DEKU_TREE_DEAD); + Flags_SetEventChkInf(EVENTCHKINF_SHOWED_MIDO_SWORD_SHIELD); break; } @@ -469,7 +469,7 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx) { gSaveContext.eventChkInf[1] |= (1 << 4); // Set "Got Zelda's Letter" flag. Also ensures Saria is back at SFM. TODO: Is this flag used for anything else? - gSaveContext.eventChkInf[4] |= 1; + Flags_SetEventChkInf(EVENTCHKINF_OBTAINED_ZELDAS_LETTER); // Got item from impa gSaveContext.eventChkInf[5] |= 0x200; diff --git a/soh/src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth.c b/soh/src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth.c index 5f7ed2f54..b825ee65c 100644 --- a/soh/src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth.c +++ b/soh/src/overlays/actors/ovl_Bg_Treemouth/z_bg_treemouth.c @@ -74,10 +74,10 @@ void BgTreemouth_Init(Actor* thisx, PlayState* play) { if ((gSaveContext.sceneSetupIndex < 4) && !LINK_IS_ADULT) { BgTreemouth_SetupAction(this, func_808BC8B8); // If dungeon entrance randomizer is on, keep the tree mouth open - // when Link is adult and sword & shield have been shown to mido + // when Link is adult and sword & shield have been shown to Mido } else if ((LINK_IS_ADULT && (!gSaveContext.n64ddFlag || Randomizer_GetSettingValue(RSK_SHUFFLE_DUNGEON_ENTRANCES) == RO_DUNGEON_ENTRANCE_SHUFFLE_OFF) || - !Flags_GetEventChkInf(0x4)) || (gSaveContext.sceneSetupIndex == 7)) { + !Flags_GetEventChkInf(EVENTCHKINF_SHOWED_MIDO_SWORD_SHIELD)) || (gSaveContext.sceneSetupIndex == 7)) { this->unk_168 = 0.0f; BgTreemouth_SetupAction(this, BgTreemouth_DoNothing); } else { 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 496cab769..21bd913e7 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 @@ -372,8 +372,8 @@ u16 EnMd_GetTextKokiriForest(PlayState* play, EnMd* this) { this->unk_208 = 0; this->unk_209 = TEXT_STATE_NONE; - if ((!gSaveContext.n64ddFlag && CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD)) || - (gSaveContext.n64ddFlag && Flags_GetRandomizerInf(RAND_INF_DUNGEONS_DONE_DEKU_TREE))) { + // In rando, skip talking about the tree being dead so we can have the prompt sword and shield instead + if (!gSaveContext.n64ddFlag && CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD)) { return 0x1045; } @@ -482,17 +482,25 @@ s16 func_80AAAF04(PlayState* play, Actor* thisx) { } u8 EnMd_ShouldSpawn(EnMd* this, PlayState* play) { - if (play->sceneNum == SCENE_SPOT04) { - if (gSaveContext.n64ddFlag) { - // if we have beaten deku tree or have open forest turned on - // or have already shown mido we have an equipped sword/shield - if (Flags_GetRandomizerInf(RAND_INF_DUNGEONS_DONE_DEKU_TREE) || - gSaveContext.eventChkInf[0] & 0x10) { - return 0; - } + // In rando, Mido's spawn logic is adjusted to support closed deku/forest options + // He will spawn in the forest if you haven't showed the sword and shield, and will remain + // in the forest until you've obtained Zelda's letter or Deku Tree dies + // This is to ensure Deku Tree can still be opened in dungeon entrance rando even if Ghoma is defeated + if (gSaveContext.n64ddFlag) { + if (play->sceneNum == SCENE_SPOT10) { return 1; } + if (Flags_GetEventChkInf(EVENTCHKINF_SHOWED_MIDO_SWORD_SHIELD) && + (Flags_GetEventChkInf(EVENTCHKINF_OBTAINED_ZELDAS_LETTER) || + Flags_GetEventChkInf(EVENTCHKINF_OBTAINED_KOKIRI_EMERALD_DEKU_TREE_DEAD))) { + return play->sceneNum == SCENE_KOKIRI_HOME4 && !LINK_IS_ADULT; + } + + return play->sceneNum == SCENE_SPOT04; + } + + if (play->sceneNum == SCENE_SPOT04) { if (!(gSaveContext.eventChkInf[1] & 0x1000) && !(gSaveContext.eventChkInf[4] & 1)) { return 1; }