From 410131fb19a39f34b1dd964090a523b33bba6b86 Mon Sep 17 00:00:00 2001 From: JordanLongstaff Date: Fri, 15 Nov 2024 14:03:45 -0500 Subject: [PATCH] Force Sleeping Waterfall enhancement in rando mode --- .../location_access/locacc_zoras_domain.cpp | 7 +- .../randomizer/option_descriptions.cpp | 3 +- .../Enhancements/timesaver_hook_handlers.cpp | 67 +++++++++---------- soh/soh/SohMenuBar.cpp | 8 ++- 4 files changed, 48 insertions(+), 37 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_zoras_domain.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_zoras_domain.cpp index ea5e04d72..ee83edb10 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_zoras_domain.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_zoras_domain.cpp @@ -43,7 +43,12 @@ void RegionTable_Init_ZorasDomain() { Entrance(RR_ZR_FAIRY_GROTTO, {[]{return Here(RR_ZORAS_RIVER, []{return logic->BlastOrSmash();});}}), Entrance(RR_THE_LOST_WOODS, {[]{return logic->HasItem(RG_SILVER_SCALE) || logic->CanUse(RG_IRON_BOOTS);}}), Entrance(RR_ZR_STORMS_GROTTO, {[]{return logic->CanOpenStormsGrotto();}}), - Entrance(RR_ZR_BEHIND_WATERFALL, {[]{return ctx->GetOption(RSK_SLEEPING_WATERFALL).Is(RO_WATERFALL_OPEN) || logic->CanUse(RG_ZELDAS_LULLABY) || (logic->IsChild && ctx->GetTrickOption(RT_ZR_CUCCO)) || (logic->IsAdult && logic->CanUse(RG_HOVER_BOOTS) && ctx->GetTrickOption(RT_ZR_HOVERS));}}), + Entrance(RR_ZR_BEHIND_WATERFALL, {[]{ + return Here(RR_ZORAS_RIVER, []{return ctx->GetOption(RSK_SLEEPING_WATERFALL).Is(RO_WATERFALL_OPEN);}) || + logic->CanUse(RG_ZELDAS_LULLABY) || + (logic->IsChild && ctx->GetTrickOption(RT_ZR_CUCCO)) || + (logic->IsAdult && logic->CanUse(RG_HOVER_BOOTS) && ctx->GetTrickOption(RT_ZR_HOVERS)); + }}), }); areaTable[RR_ZR_BEHIND_WATERFALL] = Region("ZR Behind Waterfall", "Zora River", {RA_ZORAS_RIVER}, DAY_NIGHT_CYCLE, {}, {}, { diff --git a/soh/soh/Enhancements/randomizer/option_descriptions.cpp b/soh/soh/Enhancements/randomizer/option_descriptions.cpp index 5f8090534..d119c5e80 100644 --- a/soh/soh/Enhancements/randomizer/option_descriptions.cpp +++ b/soh/soh/Enhancements/randomizer/option_descriptions.cpp @@ -34,7 +34,8 @@ void Settings::CreateOptionDescriptions() { "Open - King Zora has already mweeped out of the way in both " "time periods. Ruto's Letter is removed from the item pool."; mOptionDescriptions[RSK_SLEEPING_WATERFALL] = "Closed - Sleeping Waterfall obstructs the entrance to Zora's " - "Domain. Zelda's Lullaby must be played in order to open it.\n" + "Domain. Zelda's Lullaby must be played in order to open it " + "(but only once; then it stays open in both time periods).\n" "\n" "Open - Sleeping Waterfall is always open. " "Link may always enter Zora's Domain."; diff --git a/soh/soh/Enhancements/timesaver_hook_handlers.cpp b/soh/soh/Enhancements/timesaver_hook_handlers.cpp index d77357b86..5f351326c 100644 --- a/soh/soh/Enhancements/timesaver_hook_handlers.cpp +++ b/soh/soh/Enhancements/timesaver_hook_handlers.cpp @@ -790,45 +790,44 @@ void TimeSaverOnActorInitHandler(void* actorRef) { if (actor->id == ACTOR_BG_SPOT03_TAKI) { bgSpot03UpdateHook = GameInteractor::Instance->RegisterGameHook([](void* innerActorRef) mutable { Actor* innerActor = static_cast(innerActorRef); - bool shouldKeepOpen; if (innerActor->id != ACTOR_BG_SPOT03_TAKI) { - shouldKeepOpen = false; - } else if (IS_RANDO) { - shouldKeepOpen = RAND_GET_OPTION(RSK_SLEEPING_WATERFALL) == RO_WATERFALL_OPEN; - } else { - switch (CVarGetInteger(CVAR_ENHANCEMENT("TimeSavers.SleepingWaterfall"), 0)) { - case 1: - shouldKeepOpen = Flags_GetEventChkInf(EVENTCHKINF_OPENED_ZORAS_DOMAIN); - break; - case 2: - shouldKeepOpen = CHECK_QUEST_ITEM(QUEST_SONG_LULLABY) && - (INV_CONTENT(ITEM_OCARINA_TIME) == ITEM_OCARINA_TIME || - INV_CONTENT(ITEM_OCARINA_FAIRY) == ITEM_OCARINA_FAIRY); - break; - default: - shouldKeepOpen = false; - break; - } - + return; } - if (shouldKeepOpen) { - BgSpot03Taki* bgSpot03 = static_cast(innerActorRef); - if (bgSpot03->actionFunc == func_808ADEF0) { - bgSpot03->actionFunc = BgSpot03Taki_KeepOpen; - bgSpot03->state = WATERFALL_OPENED; - bgSpot03->openingAlpha = 0.0f; - Flags_SetSwitch(gPlayState, bgSpot03->switchFlag); - func_8003EBF8(gPlayState, &gPlayState->colCtx.dyna, bgSpot03->dyna.bgId); - BgSpot03Taki_ApplyOpeningAlpha(bgSpot03, 0); - BgSpot03Taki_ApplyOpeningAlpha(bgSpot03, 1); + bool shouldKeepOpen; + switch (CVarGetInteger(CVAR_ENHANCEMENT("TimeSavers.SleepingWaterfall"), 0)) { + case 1: + shouldKeepOpen = Flags_GetEventChkInf(EVENTCHKINF_OPENED_ZORAS_DOMAIN); + break; + case 2: + shouldKeepOpen = CHECK_QUEST_ITEM(QUEST_SONG_LULLABY) && + (INV_CONTENT(ITEM_OCARINA_TIME) == ITEM_OCARINA_TIME || + INV_CONTENT(ITEM_OCARINA_FAIRY) == ITEM_OCARINA_FAIRY); + break; + default: + shouldKeepOpen = false; + break; + } - GameInteractor::Instance->UnregisterGameHook(bgSpot03UpdateHook); - GameInteractor::Instance->UnregisterGameHook(bgSpot03KillHook); - bgSpot03UpdateHook = 0; - bgSpot03KillHook = 0; - } + if (!shouldKeepOpen) { + return; + } + + BgSpot03Taki* bgSpot03 = static_cast(innerActorRef); + if (bgSpot03->actionFunc == func_808ADEF0) { + bgSpot03->actionFunc = BgSpot03Taki_KeepOpen; + bgSpot03->state = WATERFALL_OPENED; + bgSpot03->openingAlpha = 0.0f; + Flags_SetSwitch(gPlayState, bgSpot03->switchFlag); + func_8003EBF8(gPlayState, &gPlayState->colCtx.dyna, bgSpot03->dyna.bgId); + BgSpot03Taki_ApplyOpeningAlpha(bgSpot03, 0); + BgSpot03Taki_ApplyOpeningAlpha(bgSpot03, 1); + + GameInteractor::Instance->UnregisterGameHook(bgSpot03UpdateHook); + GameInteractor::Instance->UnregisterGameHook(bgSpot03KillHook); + bgSpot03UpdateHook = 0; + bgSpot03KillHook = 0; } }); bgSpot03KillHook = GameInteractor::Instance->RegisterGameHook([](int16_t sceneNum) mutable { diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 052f45877..a37801b9f 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -795,8 +795,14 @@ void DrawEnhancementsMenu() { "- Not within range of Ocarina playing spots"); UIWidgets::PaddedEnhancementCheckbox("Pause Warp", CVAR_ENHANCEMENT("PauseWarp"), true, false); UIWidgets::Tooltip("Selection of warp song in pause menu initiates warp. Disables song playback."); + + uint8_t forceSleepingWaterfallValue = + OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_SLEEPING_WATERFALL) + 1; + static const char* forceSleepingWaterfallText = + "This setting is forcefully enabled because you are playing a randomizer."; UIWidgets::PaddedText("Play Zelda's Lullaby to open Sleeping Waterfall", true, false); - UIWidgets::EnhancementCombobox(CVAR_ENHANCEMENT("TimeSavers.SleepingWaterfall"), sleepingWaterfallOptions, 0); + UIWidgets::EnhancementCombobox(CVAR_ENHANCEMENT("TimeSavers.SleepingWaterfall"), + sleepingWaterfallOptions, 0, IS_RANDO, forceSleepingWaterfallText, forceSleepingWaterfallValue); UIWidgets::Tooltip( "Always: Link must always play Zelda's Lullaby to open " "the waterfall entrance to Zora's Domain.\n"