diff --git a/soh/soh/GameMenuBar.cpp b/soh/soh/GameMenuBar.cpp index 798abcde3..9f82bb250 100644 --- a/soh/soh/GameMenuBar.cpp +++ b/soh/soh/GameMenuBar.cpp @@ -1470,6 +1470,11 @@ namespace GameMenuBar { } } + if (ImGui::Button("Change Age")) { + CVar_SetS32("gSwitchAge", 1); + } + UIWidgets::Tooltip("Switches links age and reloads the area."); + ImGui::EndMenu(); } diff --git a/soh/src/code/game.c b/soh/src/code/game.c index 8482c7678..699f1b22d 100644 --- a/soh/src/code/game.c +++ b/soh/src/code/game.c @@ -9,6 +9,10 @@ VisMono sMonoColors; ViMode sViMode; FaultClient sGameFaultClient; u16 sLastButtonPressed; +int32_t warpTime = 0; +bool warped = false; +Vec3f playerPos; +int16_t playerYaw; // Forward declared, because this in a C++ header. int gfx_create_framebuffer(uint32_t width, uint32_t height); @@ -426,6 +430,33 @@ void GameState_Update(GameState* gameState) { } else { CVar_SetS32("gPrevTime", -1); } + + //Switches Link's age and respawns him at the last entrance he entered. + if (CVar_GetS32("gSwitchAge", 0) != 0) { + CVar_SetS32("gSwitchAge", 0); + if (gPlayState) { + playerPos = GET_PLAYER(gPlayState)->actor.world.pos; + playerYaw = GET_PLAYER(gPlayState)->actor.shape.rot.y; + gPlayState->nextEntranceIndex = gSaveContext.entranceIndex; + gPlayState->sceneLoadFlag = 0x14; + gPlayState->fadeTransition = 11; + gSaveContext.nextTransition = 11; + warped = true; + if (gPlayState->linkAgeOnLoad == 1) { + gPlayState->linkAgeOnLoad = 0; + } else { + gPlayState->linkAgeOnLoad = 1; + } + } + } + + if (gPlayState) { + if (warped && gPlayState->sceneLoadFlag != 0x0014 && gSaveContext.nextTransition == 255) { + GET_PLAYER(gPlayState)->actor.shape.rot.y = playerYaw; + GET_PLAYER(gPlayState)->actor.world.pos = playerPos; + warped = false; + } + } //since our CVar is same value and properly default to 0 there is not problems doing this in single line. gSaveContext.language = CVar_GetS32("gLanguages", 0);