From c146ca4aa5b3715ad0bfc3e4d01d50fb0677e425 Mon Sep 17 00:00:00 2001 From: inspectredc <78732756+inspectredc@users.noreply.github.com> Date: Fri, 21 Apr 2023 02:53:56 +0100 Subject: [PATCH] Fix: SoT Time Travel B-Button Behaviour (#2720) * time travel allows fishing rod + fixes vanilla ToT age change behaviour * oops removed too much --- soh/soh/Enhancements/mods.cpp | 22 ++-------------------- soh/src/code/z_parameter.c | 9 +++++---- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index 6e6c3c138..15232c1da 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -194,26 +194,6 @@ void RegisterSwitchAge() { /// Switches Link's age and respawns him at the last entrance he entered. void RegisterOcarinaTimeTravel() { - GameInteractor::Instance->RegisterGameHook([]() { - if (!gPlayState) return; - - // For the gTimeTravel: Don't give child Link a Kokiri Sword if we don't have one - if (LINK_AGE_IN_YEARS == 5 && CVarGetInteger("gTimeTravel", 0)) { - uint32_t kokiriSwordBitMask = 1 << 0; - if (!(gSaveContext.inventory.equipment & kokiriSwordBitMask)) { - Player* player = GET_PLAYER(gPlayState); - player->currentSwordItemId = ITEM_NONE; - gSaveContext.equips.buttonItems[0] = ITEM_NONE; - Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_NONE); - } - } - - // Switches Link's age and respawns him at the last entrance he entered. - if (CVarGetInteger("gTimeTravel", 0) && CVarGetInteger("gSwitchTimeline", 0)) { - CVarSetInteger("gSwitchTimeline", 0); - ReloadSceneTogglingLinkAge(); - } - }); GameInteractor::Instance->RegisterGameHook([]() { if (!gPlayState) { @@ -233,6 +213,7 @@ void RegisterOcarinaTimeTravel() { if (CVarGetInteger("gTimeTravel", 0) && hasOcarinaOfTime && hasMasterSword && gPlayState->msgCtx.lastPlayedSong == OCARINA_SONG_TIME && !nearbyTimeBlockEmpty && !nearbyTimeBlock && !nearbyOcarinaSpot && !nearbyFrogs) { + if (gSaveContext.n64ddFlag) { CVarSetInteger("gSwitchTimeline", 1); } else if (!gSaveContext.n64ddFlag && !nearbyDoorOfTime) { @@ -240,6 +221,7 @@ void RegisterOcarinaTimeTravel() { // Temple of Time scene where the only object present is the Door of Time CVarSetInteger("gSwitchTimeline", 1); } + ReloadSceneTogglingLinkAge(); } }); } diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index e69fd0126..ff22c0e12 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -1417,7 +1417,7 @@ void Inventory_SwapAgeEquipment(void) { if (i != 0) { gSaveContext.childEquips.buttonItems[i] = gSaveContext.equips.buttonItems[i]; } else { - if (CVarGetInteger("gSwitchAge", 0) && + if ((CVarGetInteger("gSwitchAge", 0) || CVarGetInteger("gSwitchTimeline", 0)) && (gSaveContext.infTable[29] & 1)) { gSaveContext.childEquips.buttonItems[i] = ITEM_NONE; } else { @@ -1501,7 +1501,8 @@ void Inventory_SwapAgeEquipment(void) { gSaveContext.adultEquips.equipment = gSaveContext.equips.equipment; if (gSaveContext.childEquips.buttonItems[0] != ITEM_NONE || - CVarGetInteger("gSwitchAge", 0)) { + CVarGetInteger("gSwitchAge", 0) || + CVarGetInteger("gSwitchTimeline", 0)) { for (i = 0; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { gSaveContext.equips.buttonItems[i] = gSaveContext.childEquips.buttonItems[i]; @@ -1542,7 +1543,7 @@ void Inventory_SwapAgeEquipment(void) { gSaveContext.equips.equipment = 0x1111; } - if (CVarGetInteger("gSwitchAge", 0) && + if ((CVarGetInteger("gSwitchAge", 0) || CVarGetInteger("gSwitchTimeline", 0)) && (gSaveContext.equips.buttonItems[0] == ITEM_NONE)) { gSaveContext.infTable[29] |= 1; if (gSaveContext.childEquips.equipment == 0) { @@ -1552,7 +1553,7 @@ void Inventory_SwapAgeEquipment(void) { } } } - + CVarSetInteger("gSwitchTimeline", 0); temp = gEquipMasks[EQUIP_SHIELD] & gSaveContext.equips.equipment; if (temp != 0) { temp >>= gEquipShifts[EQUIP_SHIELD];