From c9e0e3238693fb2c417bbb3b7ca92f1448fb76e4 Mon Sep 17 00:00:00 2001 From: JordanLongstaff Date: Fri, 1 Nov 2024 14:28:06 -0400 Subject: [PATCH] Add Randomizer setting for keeping Sleeping Waterfall open --- soh/soh/Enhancements/presets.h | 8 +++- .../location_access/locacc_zoras_domain.cpp | 2 +- .../Enhancements/randomizer/hook_handlers.cpp | 43 +++++++++++++++++++ .../randomizer/option_descriptions.cpp | 9 ++++ .../Enhancements/randomizer/randomizerTypes.h | 8 ++++ soh/soh/Enhancements/randomizer/settings.cpp | 13 ++++++ .../Enhancements/timesaver_hook_handlers.cpp | 3 -- .../ovl_Bg_Spot03_Taki/z_bg_spot03_taki.h | 3 ++ 8 files changed, 83 insertions(+), 6 deletions(-) diff --git a/soh/soh/Enhancements/presets.h b/soh/soh/Enhancements/presets.h index 6f7da6ff66f..232ed83a96a 100644 --- a/soh/soh/Enhancements/presets.h +++ b/soh/soh/Enhancements/presets.h @@ -551,6 +551,7 @@ const std::vector randomizerCvars = { CVAR_RANDOMIZER_SETTING("SkipChildZelda"), CVAR_RANDOMIZER_SETTING("SkipEponaRace"), CVAR_RANDOMIZER_SETTING("SkipScarecrowsSong"), + CVAR_RANDOMIZER_SETTING("SleepingWaterfall"), CVAR_RANDOMIZER_SETTING("StartingAge"), CVAR_RANDOMIZER_SETTING("StartingBoleroOfFire"), CVAR_RANDOMIZER_SETTING("StartingConsumables"), @@ -1177,12 +1178,13 @@ const std::vector s6PresetEntries = { PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("SkipChildZelda"), 1), PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("SkipEponaRace"), 1), PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("SkipTowerEscape"), 1), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("SleepingWaterfall"), RO_WATERFALL_CLOSED), PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingAge"), RO_AGE_RANDOM), PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingConsumables"), 1), PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingDekuShield"), 1), PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingMapsCompasses"), RO_DUNGEON_ITEM_LOC_STARTWITH), PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingOcarina"), 1), - PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ZorasFountain"), 0), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ZorasFountain"), RO_ZF_CLOSED), }; const std::vector hellModePresetEntries = { @@ -1237,16 +1239,18 @@ const std::vector hellModePresetEntries = { PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("SkipEponaRace"), 1), PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("SkipScarecrowsSong"), 1), PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("SkipTowerEscape"), 1), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("SleepingWaterfall"), RO_WATERFALL_OPEN), PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingAge"), RO_AGE_RANDOM), PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingMapsCompasses"), RO_DUNGEON_ITEM_LOC_ANYWHERE), PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("SunlightArrows"), 1), - PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ZorasFountain"), 2), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ZorasFountain"), RO_ZF_OPEN), }; const std::vector BenchmarkPresetEntries = { PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("Forest"), RO_FOREST_CLOSED_DEKU), PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("KakarikoGate"), RO_KAK_GATE_OPEN), PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("DoorOfTime"), RO_DOOROFTIME_SONGONLY), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("SleepingWaterfall"), RO_WATERFALL_CLOSED), PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ZorasFountain"), RO_ZF_CLOSED), PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("GerudoFortress"), RO_GF_NORMAL), PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("RainbowBridge"), RO_BRIDGE_DUNGEON_REWARDS), 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 6ad5ec75835..4413dd56c9c 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,7 @@ 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 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 ctx->GetOption(RSK_SLEEPING_WATERFALL).Is(RO_WATERFALL_OPEN) || logic->CanUse(RG_ZELDAS_LULLABY) || (logic->IsChild && ctx->GetTrickOption(RT_ZR_CUCCO)) || (logic->IsAdult && (ctx->GetOption(RSK_SLEEPING_WATERFALL).Is(RO_WATERFALL_CLOSED_CHILD) || (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/hook_handlers.cpp b/soh/soh/Enhancements/randomizer/hook_handlers.cpp index 6b474cde1b9..3afd3effe2d 100644 --- a/soh/soh/Enhancements/randomizer/hook_handlers.cpp +++ b/soh/soh/Enhancements/randomizer/hook_handlers.cpp @@ -18,6 +18,7 @@ extern "C" { #include "soh/Enhancements/randomizer/adult_trade_shuffle.h" #include "soh/Enhancements/randomizer/randomizer_entrance.h" #include "soh/Enhancements/randomizer/randomizer_grotto.h" +#include "src/overlays/actors/ovl_Bg_Spot03_Taki/z_bg_spot03_taki.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" @@ -1612,6 +1613,8 @@ void ObjComb_RandomizerWait(ObjComb* objComb, PlayState* play) { } } +void BgSpot03Taki_KeepOpen(BgSpot03Taki* bgSpot03Taki, PlayState* play) { } + void RandomizerOnActorInitHandler(void* actorRef) { Actor* actor = static_cast(actorRef); @@ -1757,6 +1760,46 @@ void RandomizerOnActorInitHandler(void* actorRef) { bgTreemouth->unk_168 = 1.0f; } + if (actor->id == ACTOR_BG_SPOT03_TAKI) { + Rando::Option& waterfallOption = Rando::Context::GetInstance()->GetOption(RSK_SLEEPING_WATERFALL); + if (waterfallOption.Is(RO_WATERFALL_OPEN) || (waterfallOption.Is(RO_WATERFALL_CLOSED_CHILD) && LINK_IS_ADULT)) { + static uint32_t bgSpot03UpdateHook = 0; + static uint32_t bgSpot03KillHook = 0; + + bgSpot03UpdateHook = GameInteractor::Instance->RegisterGameHook( + [](void* innerActorRef) mutable { + Actor* innerActor = static_cast(innerActorRef); + Rando::Option& waterfallOption = Rando::Context::GetInstance()->GetOption(RSK_SLEEPING_WATERFALL); + if (innerActor->id == ACTOR_BG_SPOT03_TAKI && waterfallOption.IsNot(RO_WATERFALL_CLOSED) && (waterfallOption.Is(RO_WATERFALL_OPEN) || LINK_IS_ADULT)) { + 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 { + GameInteractor::Instance->UnregisterGameHook(bgSpot03UpdateHook); + GameInteractor::Instance->UnregisterGameHook(bgSpot03KillHook); + bgSpot03UpdateHook = 0; + bgSpot03KillHook = 0; + } + ); + } + } + //consumable bags if ( actor->id == ACTOR_EN_ITEM00 && diff --git a/soh/soh/Enhancements/randomizer/option_descriptions.cpp b/soh/soh/Enhancements/randomizer/option_descriptions.cpp index 7de98b3d098..9e2f1292564 100644 --- a/soh/soh/Enhancements/randomizer/option_descriptions.cpp +++ b/soh/soh/Enhancements/randomizer/option_descriptions.cpp @@ -33,6 +33,15 @@ void Settings::CreateOptionDescriptions() { "\n" "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 in " + "both time periods.\n" + "\n" + "Closed as child - Zelda's Lullaby is only required to open " + "Sleeping Waterfall as child Link. It starts open as adult.\n" + "\n" + "Open - Sleeping Waterfall is always open in both time periods. " + "Link may always enter Zora's Domain."; mOptionDescriptions[RSK_STARTING_AGE] = "Choose which age Link will start as.\n\n" "Starting as adult means you start with the Master Sword in your inventory.\n" diff --git a/soh/soh/Enhancements/randomizer/randomizerTypes.h b/soh/soh/Enhancements/randomizer/randomizerTypes.h index d49cc7bae73..b7607f8ae1e 100644 --- a/soh/soh/Enhancements/randomizer/randomizerTypes.h +++ b/soh/soh/Enhancements/randomizer/randomizerTypes.h @@ -3849,6 +3849,7 @@ typedef enum { RSK_KAK_GATE, RSK_DOOR_OF_TIME, RSK_ZORAS_FOUNTAIN, + RSK_SLEEPING_WATERFALL, RSK_STARTING_AGE, RSK_GERUDO_FORTRESS, RSK_RAINBOW_BRIDGE, @@ -4086,6 +4087,13 @@ typedef enum { RO_ZF_OPEN, } RandoOptionZorasFountain; +//Sleeping Waterfall settings (closed, closed as child, open) +typedef enum { + RO_WATERFALL_CLOSED, + RO_WATERFALL_CLOSED_CHILD, + RO_WATERFALL_OPEN, +} RandoOptionSleepingWaterfall; + //Starting Age settings (child, adult, random) typedef enum { RO_AGE_CHILD, diff --git a/soh/soh/Enhancements/randomizer/settings.cpp b/soh/soh/Enhancements/randomizer/settings.cpp index df263241f92..f3f1e43e18a 100644 --- a/soh/soh/Enhancements/randomizer/settings.cpp +++ b/soh/soh/Enhancements/randomizer/settings.cpp @@ -109,6 +109,7 @@ void Settings::CreateOptions() { mOptions[RSK_KAK_GATE] = Option::U8("Kakariko Gate", {"Closed", "Open"}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("KakarikoGate"), mOptionDescriptions[RSK_KAK_GATE]); mOptions[RSK_DOOR_OF_TIME] = Option::U8("Door of Time", {"Closed", "Song only", "Open"}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("DoorOfTime"), mOptionDescriptions[RSK_DOOR_OF_TIME], WidgetType::Combobox); mOptions[RSK_ZORAS_FOUNTAIN] = Option::U8("Zora's Fountain", {"Closed", "Closed as child", "Open"}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("ZorasFountain"), mOptionDescriptions[RSK_ZORAS_FOUNTAIN]); + mOptions[RSK_SLEEPING_WATERFALL] = Option::U8("Sleeping Waterfall", {"Closed", "Closed as child", "Open"}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("SleepingWaterfall"), mOptionDescriptions[RSK_SLEEPING_WATERFALL]); mOptions[RSK_GERUDO_FORTRESS] = Option::U8("Gerudo Fortress", {"Normal", "Fast", "Open"}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("GerudoFortress"), mOptionDescriptions[RSK_GERUDO_FORTRESS]); mOptions[RSK_RAINBOW_BRIDGE] = Option::U8("Rainbow Bridge", {"Vanilla", "Always open", "Stones", "Medallions", "Dungeon rewards", "Dungeons", "Tokens", "Greg"}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("RainbowBridge"), mOptionDescriptions[RSK_RAINBOW_BRIDGE], WidgetType::Combobox, RO_BRIDGE_VANILLA, false, IMFLAG_NONE); mOptions[RSK_RAINBOW_BRIDGE_STONE_COUNT] = Option::U8("Stone Count", {NumOpts(0, 4)}, OptionCategory::Setting, CVAR_RANDOMIZER_SETTING("StoneCount"), "", WidgetType::Slider, 3, true); @@ -695,6 +696,7 @@ void Settings::CreateOptions() { &mOptions[RSK_KAK_GATE], &mOptions[RSK_DOOR_OF_TIME], &mOptions[RSK_ZORAS_FOUNTAIN], + &mOptions[RSK_SLEEPING_WATERFALL], }, false, WidgetContainerType::COLUMN); mOptionGroups[RSG_WORLD_IMGUI] = OptionGroup::SubGroup("World Settings", { &mOptions[RSK_STARTING_AGE], @@ -944,6 +946,7 @@ void Settings::CreateOptions() { &mOptions[RSK_KAK_GATE], &mOptions[RSK_DOOR_OF_TIME], &mOptions[RSK_ZORAS_FOUNTAIN], + &mOptions[RSK_SLEEPING_WATERFALL], &mOptions[RSK_GERUDO_FORTRESS], &mOptions[RSK_RAINBOW_BRIDGE], &mOptions[RSK_RAINBOW_BRIDGE_STONE_COUNT], @@ -1261,6 +1264,7 @@ void Settings::CreateOptions() { { "Open Settings:Kakariko Gate", RSK_KAK_GATE }, { "Open Settings:Door of Time", RSK_DOOR_OF_TIME }, { "Open Settings:Zora's Fountain", RSK_ZORAS_FOUNTAIN }, + { "Open Settings:Sleeping Waterfall", RSK_SLEEPING_WATERFALL }, { "World Settings:Starting Age", RSK_STARTING_AGE }, { "Open Settings:Gerudo Fortress", RSK_GERUDO_FORTRESS }, { "Open Settings:Rainbow Bridge", RSK_RAINBOW_BRIDGE }, @@ -2576,6 +2580,15 @@ void Settings::ParseJson(nlohmann::json spoilerFileJson) { mOptions[index].SetSelectedIndex(RO_ZF_OPEN); } break; + case RSK_SLEEPING_WATERFALL: + if (it.value() == "Closed") { + mOptions[index].SetSelectedIndex(RO_WATERFALL_CLOSED); + } else if (it.value() == "Closed as child") { + mOptions[index].SetSelectedIndex(RO_WATERFALL_CLOSED_CHILD); + } else if (it.value() == "Open") { + mOptions[index].SetSelectedIndex(RO_WATERFALL_OPEN); + } + break; case RSK_STARTING_AGE: if (it.value() == "Child") { mOptions[index].SetSelectedIndex(RO_AGE_CHILD); diff --git a/soh/soh/Enhancements/timesaver_hook_handlers.cpp b/soh/soh/Enhancements/timesaver_hook_handlers.cpp index ec29ec456be..66b8b1aba22 100644 --- a/soh/soh/Enhancements/timesaver_hook_handlers.cpp +++ b/soh/soh/Enhancements/timesaver_hook_handlers.cpp @@ -93,9 +93,6 @@ void EnDntDemo_JudgeSkipToReward(EnDntDemo* enDntDemo, PlayState* play) { } } -void BgSpot03Taki_KeepOpen(BgSpot03Taki* bgSpot03Taki, PlayState* play) { -} - static int successChimeCooldown = 0; void RateLimitedSuccessChime() { if (successChimeCooldown == 0) { diff --git a/soh/src/overlays/actors/ovl_Bg_Spot03_Taki/z_bg_spot03_taki.h b/soh/src/overlays/actors/ovl_Bg_Spot03_Taki/z_bg_spot03_taki.h index 6eba416e727..4a94dad2ca2 100644 --- a/soh/src/overlays/actors/ovl_Bg_Spot03_Taki/z_bg_spot03_taki.h +++ b/soh/src/overlays/actors/ovl_Bg_Spot03_Taki/z_bg_spot03_taki.h @@ -30,4 +30,7 @@ void func_808ADEF0(BgSpot03Taki* bgSpot03Taki, PlayState* play); void BgSpot03Taki_ApplyOpeningAlpha(BgSpot03Taki* bgSpot03Taki, s32 bufferIndex); +// USED IN HOOK HANDLERS ONLY -- DO NOT REFERENCE FROM z_bg_spot03_taki.c +void BgSpot03Taki_KeepOpen(BgSpot03Taki* bgSpot03Taki, PlayState* play); + #endif