From ba82bfbba6d89e0d0f0626d50515e5f7dfae7a14 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Sat, 13 Jul 2024 16:51:54 -0400 Subject: [PATCH] Fix spawn shuffle when starting age is adult/random. (#4230) * Fix spawn shuffle when starting age is adult. * Handle adult start without spawn shuffle * Handle correct entrance for adult start + spawn shuffle and add comments. * Fix grotto spawn cutscene skips. * Fix an issue with randomized starting age. --- .../TimeSavers/SkipCutscene/SkipIntro.cpp | 35 +++++++++++++++---- soh/soh/Enhancements/randomizer/savefile.cpp | 2 +- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/soh/soh/Enhancements/TimeSavers/SkipCutscene/SkipIntro.cpp b/soh/soh/Enhancements/TimeSavers/SkipCutscene/SkipIntro.cpp index f9dc8c239..2402f841c 100644 --- a/soh/soh/Enhancements/TimeSavers/SkipCutscene/SkipIntro.cpp +++ b/soh/soh/Enhancements/TimeSavers/SkipCutscene/SkipIntro.cpp @@ -5,18 +5,41 @@ extern "C" { #include "z64save.h" #include "functions.h" + #include "soh/Enhancements/randomizer/randomizer_grotto.h" extern PlayState* gPlayState; extern SaveContext gSaveContext; } void SkipIntro_Register() { REGISTER_VB_SHOULD(VB_PLAY_TRANSITION_CS, { - if (CVarGetInteger(CVAR_ENHANCEMENT("TimeSavers.SkipCutscene.Intro"), IS_RANDO) || - IS_RANDO && OTRGlobals::Instance->gRandoContext->GetOption(RSK_SHUFFLE_OVERWORLD_SPAWNS).Is(true)) { - if (gSaveContext.entranceIndex == (IS_RANDO ? Entrance_GetOverride(ENTR_LINKS_HOUSE_0) : ENTR_LINKS_HOUSE_0) && gSaveContext.cutsceneIndex == 0xFFF1) { - gSaveContext.cutsceneIndex = 0; - *should = false; - } + // If we're playing rando and if starting age is adult and/or overworld spawns are shuffled we need to skip + // the cutscene regardless of the enhancement being on. + bool adultStart = gSaveContext.linkAge == LINK_AGE_ADULT; + bool shuffleOverworldSpawns = OTRGlobals::Instance->gRandoContext->GetOption(RSK_SHUFFLE_OVERWORLD_SPAWNS).Is(true); + if (CVarGetInteger(CVAR_ENHANCEMENT("TimeSavers.SkipCutscene.Intro"), IS_RANDO) || (IS_RANDO && (adultStart || shuffleOverworldSpawns))) { + // Calculate spawn location. Start with vanilla, Link's house. + int32_t spawnEntrance = ENTR_LINKS_HOUSE_0; + // If we're not in rando, we can skip all of the below. + if (IS_RANDO) { + // If starting age is shuffled, use vanilla adult spawn/prelude warp. + if (adultStart) { + spawnEntrance = ENTR_TEMPLE_OF_TIME_7; + } + // If we're shuffling overworld spawns we'll need to get the Entrance Override + if (shuffleOverworldSpawns) { + // If we're shuffling overworld spawns the adult spawn is ENTR_HYRULE_FIELD_10 instead of + // ENTR_TEMPLE_OF_TIME_7, so that spawn and Prelude don't share an entrance. + if (adultStart){ + spawnEntrance = ENTR_HYRULE_FIELD_10; + } + spawnEntrance = Grotto_OverrideSpecialEntrance(Entrance_GetOverride(spawnEntrance)); + } + } + // Skip the intro cutscene for whatever the spawnEntrance is calculated to be. + if (gSaveContext.entranceIndex == spawnEntrance) { + gSaveContext.cutsceneIndex = 0; + *should = false; + } } }); } diff --git a/soh/soh/Enhancements/randomizer/savefile.cpp b/soh/soh/Enhancements/randomizer/savefile.cpp index e8998b4a4..4900e4a70 100644 --- a/soh/soh/Enhancements/randomizer/savefile.cpp +++ b/soh/soh/Enhancements/randomizer/savefile.cpp @@ -331,7 +331,7 @@ extern "C" void Randomizer_InitSaveFile() { gSaveContext.adultTradeItems = 0; } - int startingAge = Randomizer_GetSettingValue(RSK_STARTING_AGE); + int startingAge = OTRGlobals::Instance->gRandoContext->GetSettings()->ResolvedStartingAge(); switch (startingAge) { case RO_AGE_ADULT: // Adult gSaveContext.linkAge = LINK_AGE_ADULT;