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.
This commit is contained in:
Christopher Leggett 2024-07-13 16:51:54 -04:00 committed by GitHub
parent a0fda39a75
commit ba82bfbba6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 7 deletions

View File

@ -5,18 +5,41 @@
extern "C" { extern "C" {
#include "z64save.h" #include "z64save.h"
#include "functions.h" #include "functions.h"
#include "soh/Enhancements/randomizer/randomizer_grotto.h"
extern PlayState* gPlayState; extern PlayState* gPlayState;
extern SaveContext gSaveContext; extern SaveContext gSaveContext;
} }
void SkipIntro_Register() { void SkipIntro_Register() {
REGISTER_VB_SHOULD(VB_PLAY_TRANSITION_CS, { REGISTER_VB_SHOULD(VB_PLAY_TRANSITION_CS, {
if (CVarGetInteger(CVAR_ENHANCEMENT("TimeSavers.SkipCutscene.Intro"), IS_RANDO) || // If we're playing rando and if starting age is adult and/or overworld spawns are shuffled we need to skip
IS_RANDO && OTRGlobals::Instance->gRandoContext->GetOption(RSK_SHUFFLE_OVERWORLD_SPAWNS).Is(true)) { // the cutscene regardless of the enhancement being on.
if (gSaveContext.entranceIndex == (IS_RANDO ? Entrance_GetOverride(ENTR_LINKS_HOUSE_0) : ENTR_LINKS_HOUSE_0) && gSaveContext.cutsceneIndex == 0xFFF1) { bool adultStart = gSaveContext.linkAge == LINK_AGE_ADULT;
gSaveContext.cutsceneIndex = 0; bool shuffleOverworldSpawns = OTRGlobals::Instance->gRandoContext->GetOption(RSK_SHUFFLE_OVERWORLD_SPAWNS).Is(true);
*should = false; 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;
}
} }
}); });
} }

View File

@ -331,7 +331,7 @@ extern "C" void Randomizer_InitSaveFile() {
gSaveContext.adultTradeItems = 0; gSaveContext.adultTradeItems = 0;
} }
int startingAge = Randomizer_GetSettingValue(RSK_STARTING_AGE); int startingAge = OTRGlobals::Instance->gRandoContext->GetSettings()->ResolvedStartingAge();
switch (startingAge) { switch (startingAge) {
case RO_AGE_ADULT: // Adult case RO_AGE_ADULT: // Adult
gSaveContext.linkAge = LINK_AGE_ADULT; gSaveContext.linkAge = LINK_AGE_ADULT;