From 0ec1d17d555d219d5876b3a286c9230571ceb0e1 Mon Sep 17 00:00:00 2001 From: aMannus Date: Thu, 28 Jul 2022 11:38:47 +0200 Subject: [PATCH 1/6] Fixed zelda sequence oddities --- soh/soh/Enhancements/randomizer/randomizer.cpp | 5 ++++- soh/src/code/z_play.c | 6 +++++- soh/src/code/z_sram.c | 3 +++ .../overlays/actors/ovl_En_Heishi1/z_en_heishi1.c | 15 +++++++++++++-- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 09704e8671b..0fd56c5f93d 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -3251,7 +3251,10 @@ void GenerateRandomizerImgui() { cvarSettings[RSK_CUCCO_COUNT] = CVar_GetS32("gRandomizeCuccosToReturn", 7); cvarSettings[RSK_BIG_POE_COUNT] = CVar_GetS32("gRandomizeBigPoeTargetCount", 10); - cvarSettings[RSK_SKIP_CHILD_STEALTH] = CVar_GetS32("gRandomizeSkipChildStealth", 0); + // If we skip child zelda, skip child stealth is pointless, so this needs to be reflected in the spoiler log + cvarSettings[RSK_SKIP_CHILD_STEALTH] = + ((CVar_GetS32("gRandomizeSkipChildZelda", 0) == 0) && CVar_GetS32("gRandomizeSkipChildStealth", 0)); + cvarSettings[RSK_SKIP_EPONA_RACE] = CVar_GetS32("gRandomizeSkipEponaRace", 0); cvarSettings[RSK_SKIP_TOWER_ESCAPE] = CVar_GetS32("gRandomizeSkipTowerEscape", 0); diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index a42fb2f78c4..512ede8fabd 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -273,7 +273,11 @@ void Gameplay_Init(GameState* thisx) { u8 tempSetupIndex; s32 pad[2]; - if (gSaveContext.n64ddFlag && Randomizer_GetSettingValue(RSK_SKIP_CHILD_STEALTH)) { + // Skip Child Stealth when option is enabled, Zelda's Letter isn't obtained and Impa's reward hasn't been received + // eventChkInf[4] & 0x01 = Got Zelda's Letter + // eventChkInf[5] & 0x200 = Got Impa's reward + if (gSaveContext.n64ddFlag && Randomizer_GetSettingValue(RSK_SKIP_CHILD_STEALTH) && + !(gSaveContext.eventChkInf[4] & 0x01) && !(gSaveContext.eventChkInf[5] & 0x200)) { if (gSaveContext.entranceIndex == 0x7A) { gSaveContext.entranceIndex = 0x400; } else if (gSaveContext.entranceIndex == 0x296) { diff --git a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c index 7670762c598..214a5d0d056 100644 --- a/soh/src/code/z_sram.c +++ b/soh/src/code/z_sram.c @@ -790,6 +790,9 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx) { gSaveContext.eventChkInf[1] |= (1 << 3); gSaveContext.eventChkInf[1] |= (1 << 4); + // Got Zelda's Letter + gSaveContext.eventChkInf[4] |= 1; + // Got item from impa gSaveContext.eventChkInf[5] |= 0x200; diff --git a/soh/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c b/soh/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c index d2d9fac4bce..cb41e3e4840 100644 --- a/soh/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c +++ b/soh/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c @@ -112,14 +112,25 @@ void EnHeishi1_Init(Actor* thisx, GlobalContext* globalCtx) { } } + // eventChkInf[4] & 1 = Got Zelda's Letter + // eventChkInf[5] & 0x200 = Got item from impa + // eventChkInf[8] & 1 = Ocarina thrown in moat + + // Rando'd but not met Zelda yet + bool randoNotMetZelda = + (gSaveContext.n64ddFlag) && !(gSaveContext.eventChkInf[5] & 0x200) && !(gSaveContext.eventChkInf[4] & 1); + // Rando'd and already met Zelda + bool randoMetZelda = (gSaveContext.n64ddFlag) && (gSaveContext.eventChkInf[5] & 0x200) && (gSaveContext.eventChkInf[4] & 1); + if (this->type != 5) { - if (((gSaveContext.dayTime < 0xB888) || IS_DAY) && (gSaveContext.n64ddFlag || !(gSaveContext.eventChkInf[8] & 1))) { + if ((gSaveContext.dayTime < 0xB888 || IS_DAY) && ((!(gSaveContext.eventChkInf[8] & 1) && !gSaveContext.n64ddFlag) || randoNotMetZelda)) { this->actionFunc = EnHeishi1_SetupWalk; } else { Actor_Kill(&this->actor); } } else { - if ((gSaveContext.dayTime >= 0xB889) || !IS_DAY || (!gSaveContext.n64ddFlag && (gSaveContext.eventChkInf[8] & 1))) { + if ((gSaveContext.dayTime >= 0xB889) || !IS_DAY || + (gSaveContext.eventChkInf[8] & 1 && !gSaveContext.n64ddFlag) || randoMetZelda) { this->actionFunc = EnHeishi1_SetupWaitNight; } else { Actor_Kill(&this->actor); From 4bdae45788c844209e5c0d4299e93b68a69de484 Mon Sep 17 00:00:00 2001 From: aMannus Date: Thu, 28 Jul 2022 11:41:23 +0200 Subject: [PATCH 2/6] Fixed code inconsistency --- soh/src/code/z_play.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index 512ede8fabd..dbe62a770bc 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -274,10 +274,10 @@ void Gameplay_Init(GameState* thisx) { s32 pad[2]; // Skip Child Stealth when option is enabled, Zelda's Letter isn't obtained and Impa's reward hasn't been received - // eventChkInf[4] & 0x01 = Got Zelda's Letter + // eventChkInf[4] & 1 = Got Zelda's Letter // eventChkInf[5] & 0x200 = Got Impa's reward if (gSaveContext.n64ddFlag && Randomizer_GetSettingValue(RSK_SKIP_CHILD_STEALTH) && - !(gSaveContext.eventChkInf[4] & 0x01) && !(gSaveContext.eventChkInf[5] & 0x200)) { + !(gSaveContext.eventChkInf[4] & 1) && !(gSaveContext.eventChkInf[5] & 0x200)) { if (gSaveContext.entranceIndex == 0x7A) { gSaveContext.entranceIndex = 0x400; } else if (gSaveContext.entranceIndex == 0x296) { From 38fcbdb2679f8ef0162f28f3b91acd0aec1fe1ed Mon Sep 17 00:00:00 2001 From: aMannus Date: Mon, 1 Aug 2022 09:06:19 +0200 Subject: [PATCH 3/6] Adressed review comments --- soh/src/code/z_sram.c | 5 +---- .../overlays/actors/ovl_En_Heishi1/z_en_heishi1.c | 13 ++++--------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c index 214a5d0d056..caf250a4aad 100644 --- a/soh/src/code/z_sram.c +++ b/soh/src/code/z_sram.c @@ -790,15 +790,12 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx) { gSaveContext.eventChkInf[1] |= (1 << 3); gSaveContext.eventChkInf[1] |= (1 << 4); - // Got Zelda's Letter + // 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; // Got item from impa gSaveContext.eventChkInf[5] |= 0x200; - // make sure saria is at SFM - gSaveContext.eventChkInf[4] |= (1 << 0); - // set this at the end to ensure we always start with the letter // this is for the off chance we got the weird egg from impa (which should never happen) INV_CONTENT(ITEM_LETTER_ZELDA) = ITEM_LETTER_ZELDA; diff --git a/soh/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c b/soh/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c index cb41e3e4840..91f4e49bf4f 100644 --- a/soh/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c +++ b/soh/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c @@ -115,22 +115,17 @@ void EnHeishi1_Init(Actor* thisx, GlobalContext* globalCtx) { // eventChkInf[4] & 1 = Got Zelda's Letter // eventChkInf[5] & 0x200 = Got item from impa // eventChkInf[8] & 1 = Ocarina thrown in moat - - // Rando'd but not met Zelda yet - bool randoNotMetZelda = - (gSaveContext.n64ddFlag) && !(gSaveContext.eventChkInf[5] & 0x200) && !(gSaveContext.eventChkInf[4] & 1); - // Rando'd and already met Zelda - bool randoMetZelda = (gSaveContext.n64ddFlag) && (gSaveContext.eventChkInf[5] & 0x200) && (gSaveContext.eventChkInf[4] & 1); + bool rando = gSaveContext.n64ddFlag; + bool metZelda = (gSaveContext.eventChkInf[4] & 1) && (gSaveContext.eventChkInf[5] & 0x200); if (this->type != 5) { - if ((gSaveContext.dayTime < 0xB888 || IS_DAY) && ((!(gSaveContext.eventChkInf[8] & 1) && !gSaveContext.n64ddFlag) || randoNotMetZelda)) { + if ((gSaveContext.dayTime < 0xB888 || IS_DAY) && ((!rando && !(gSaveContext.eventChkInf[8] & 1)) || (rando && !metZelda))) { this->actionFunc = EnHeishi1_SetupWalk; } else { Actor_Kill(&this->actor); } } else { - if ((gSaveContext.dayTime >= 0xB889) || !IS_DAY || - (gSaveContext.eventChkInf[8] & 1 && !gSaveContext.n64ddFlag) || randoMetZelda) { + if ((gSaveContext.dayTime >= 0xB889) || !IS_DAY || (!rando && gSaveContext.eventChkInf[8] & 1) || (rando && metZelda)) { this->actionFunc = EnHeishi1_SetupWaitNight; } else { Actor_Kill(&this->actor); From 144538b243bf882b05eb5d4fec42a39417b9f5af Mon Sep 17 00:00:00 2001 From: aMannus Date: Mon, 8 Aug 2022 10:58:03 +0200 Subject: [PATCH 4/6] Adressed review comments, removed unneccesary entrance skip --- soh/src/code/z_play.c | 4 ++-- soh/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index dbe62a770bc..fbfb4c76653 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -276,12 +276,12 @@ void Gameplay_Init(GameState* thisx) { // Skip Child Stealth when option is enabled, Zelda's Letter isn't obtained and Impa's reward hasn't been received // eventChkInf[4] & 1 = Got Zelda's Letter // eventChkInf[5] & 0x200 = Got Impa's reward + // entranceIndex 0x7A, Castle Courtyard - Day + // entranceIndex 0x400, Zelda's Courtyard if (gSaveContext.n64ddFlag && Randomizer_GetSettingValue(RSK_SKIP_CHILD_STEALTH) && !(gSaveContext.eventChkInf[4] & 1) && !(gSaveContext.eventChkInf[5] & 0x200)) { if (gSaveContext.entranceIndex == 0x7A) { gSaveContext.entranceIndex = 0x400; - } else if (gSaveContext.entranceIndex == 0x296) { - gSaveContext.entranceIndex = 0x23D; } } diff --git a/soh/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c b/soh/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c index 91f4e49bf4f..5a313a07f55 100644 --- a/soh/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c +++ b/soh/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c @@ -115,17 +115,20 @@ void EnHeishi1_Init(Actor* thisx, GlobalContext* globalCtx) { // eventChkInf[4] & 1 = Got Zelda's Letter // eventChkInf[5] & 0x200 = Got item from impa // eventChkInf[8] & 1 = Ocarina thrown in moat - bool rando = gSaveContext.n64ddFlag; bool metZelda = (gSaveContext.eventChkInf[4] & 1) && (gSaveContext.eventChkInf[5] & 0x200); if (this->type != 5) { - if ((gSaveContext.dayTime < 0xB888 || IS_DAY) && ((!rando && !(gSaveContext.eventChkInf[8] & 1)) || (rando && !metZelda))) { + if ((gSaveContext.dayTime < 0xB888 || IS_DAY) && + ((!gSaveContext.n64ddFlag && !(gSaveContext.eventChkInf[8] & 1)) || + (gSaveContext.n64ddFlag && !metZelda))) { this->actionFunc = EnHeishi1_SetupWalk; } else { Actor_Kill(&this->actor); } } else { - if ((gSaveContext.dayTime >= 0xB889) || !IS_DAY || (!rando && gSaveContext.eventChkInf[8] & 1) || (rando && metZelda)) { + if ((gSaveContext.dayTime >= 0xB889) || !IS_DAY || + (!gSaveContext.n64ddFlag && gSaveContext.eventChkInf[8] & 1) || + (gSaveContext.n64ddFlag && metZelda)) { this->actionFunc = EnHeishi1_SetupWaitNight; } else { Actor_Kill(&this->actor); From b83df9d90f0b9a4d668c9e79f166adf4ab5fbe2f Mon Sep 17 00:00:00 2001 From: aMannus Date: Mon, 8 Aug 2022 11:53:11 +0200 Subject: [PATCH 5/6] Addressed some more review comments --- soh/soh/Enhancements/randomizer/randomizer.cpp | 2 +- soh/src/code/z_play.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 0fd56c5f93d..05c041708b5 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -3253,7 +3253,7 @@ void GenerateRandomizerImgui() { // If we skip child zelda, skip child stealth is pointless, so this needs to be reflected in the spoiler log cvarSettings[RSK_SKIP_CHILD_STEALTH] = - ((CVar_GetS32("gRandomizeSkipChildZelda", 0) == 0) && CVar_GetS32("gRandomizeSkipChildStealth", 0)); + !(CVar_GetS32("gRandomizeSkipChildZelda", 0)) && CVar_GetS32("gRandomizeSkipChildStealth", 0); cvarSettings[RSK_SKIP_EPONA_RACE] = CVar_GetS32("gRandomizeSkipEponaRace", 0); cvarSettings[RSK_SKIP_TOWER_ESCAPE] = CVar_GetS32("gRandomizeSkipTowerEscape", 0); diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index fbfb4c76653..ae8791bd4fe 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -276,7 +276,7 @@ void Gameplay_Init(GameState* thisx) { // Skip Child Stealth when option is enabled, Zelda's Letter isn't obtained and Impa's reward hasn't been received // eventChkInf[4] & 1 = Got Zelda's Letter // eventChkInf[5] & 0x200 = Got Impa's reward - // entranceIndex 0x7A, Castle Courtyard - Day + // entranceIndex 0x7A, Castle Courtyard - Day from crawlspace // entranceIndex 0x400, Zelda's Courtyard if (gSaveContext.n64ddFlag && Randomizer_GetSettingValue(RSK_SKIP_CHILD_STEALTH) && !(gSaveContext.eventChkInf[4] & 1) && !(gSaveContext.eventChkInf[5] & 0x200)) { From 4b610a118a52d9d95c3dd69d4695ce4f8815e8b3 Mon Sep 17 00:00:00 2001 From: aMannus Date: Mon, 8 Aug 2022 11:58:37 +0200 Subject: [PATCH 6/6] tiny cleanup --- soh/soh/Enhancements/randomizer/randomizer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 05c041708b5..ed3c6182ed6 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -3253,7 +3253,7 @@ void GenerateRandomizerImgui() { // If we skip child zelda, skip child stealth is pointless, so this needs to be reflected in the spoiler log cvarSettings[RSK_SKIP_CHILD_STEALTH] = - !(CVar_GetS32("gRandomizeSkipChildZelda", 0)) && CVar_GetS32("gRandomizeSkipChildStealth", 0); + !CVar_GetS32("gRandomizeSkipChildZelda", 0) && CVar_GetS32("gRandomizeSkipChildStealth", 0); cvarSettings[RSK_SKIP_EPONA_RACE] = CVar_GetS32("gRandomizeSkipEponaRace", 0); cvarSettings[RSK_SKIP_TOWER_ESCAPE] = CVar_GetS32("gRandomizeSkipTowerEscape", 0);