Cheat: Switch Age and Reload Link (#1963)

* Added button to switch age

* Added logic to switch link's age

Reloads link from last entrance he went through once his age is switched.

* Link now respawns where he last was

* Update game.c

* move setting to GameMenuBar.cpp, fix build issues

Co-authored-by: Jake Edvenson <77412657+JakeEdvenson@users.noreply.github.com>
Co-authored-by: briaguya <briaguya@alice>
This commit is contained in:
briaguya 2022-11-14 19:29:16 -05:00 committed by GitHub
parent 6361a4c776
commit 8571545bf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 0 deletions

View File

@ -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();
}

View File

@ -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);