2024-06-25 19:13:31 +00:00
|
|
|
#include "z64game_over.h"
|
|
|
|
|
2021-03-28 23:50:46 +00:00
|
|
|
#include "global.h"
|
2024-08-29 01:00:06 +00:00
|
|
|
#include "versions.h"
|
2021-03-28 23:50:46 +00:00
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
void GameOver_Init(PlayState* play) {
|
|
|
|
play->gameOverCtx.state = GAMEOVER_INACTIVE;
|
2021-03-28 23:50:46 +00:00
|
|
|
}
|
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
void GameOver_FadeInLights(PlayState* play) {
|
|
|
|
GameOverContext* gameOverCtx = &play->gameOverCtx;
|
2021-03-28 23:50:46 +00:00
|
|
|
|
|
|
|
if ((gameOverCtx->state >= GAMEOVER_DEATH_WAIT_GROUND && gameOverCtx->state < GAMEOVER_REVIVE_START) ||
|
|
|
|
(gameOverCtx->state >= GAMEOVER_REVIVE_RUMBLE && gameOverCtx->state < GAMEOVER_REVIVE_FADE_OUT)) {
|
2022-05-21 18:23:43 +00:00
|
|
|
Environment_FadeInGameOverLights(play);
|
2021-03-28 23:50:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-10 14:07:51 +00:00
|
|
|
s16 sGameOverTimer = 0;
|
2021-03-28 23:50:46 +00:00
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
void GameOver_Update(PlayState* play) {
|
|
|
|
GameOverContext* gameOverCtx = &play->gameOverCtx;
|
2021-03-28 23:50:46 +00:00
|
|
|
s16 i;
|
|
|
|
s16 j;
|
2022-09-27 16:40:26 +00:00
|
|
|
s32 rumbleStrength;
|
|
|
|
s32 rumbleDuration;
|
|
|
|
s32 rumbleDecreaseRate;
|
2021-03-28 23:50:46 +00:00
|
|
|
|
|
|
|
switch (gameOverCtx->state) {
|
|
|
|
case GAMEOVER_DEATH_START:
|
2022-05-21 18:23:43 +00:00
|
|
|
Message_CloseTextbox(play);
|
2021-03-28 23:50:46 +00:00
|
|
|
|
2022-11-16 18:41:27 +00:00
|
|
|
gSaveContext.timerState = TIMER_STATE_OFF;
|
|
|
|
gSaveContext.subTimerState = SUBTIMER_STATE_OFF;
|
|
|
|
CLEAR_EVENTINF(EVENTINF_MARATHON_ACTIVE);
|
2021-03-28 23:50:46 +00:00
|
|
|
|
|
|
|
// search inventory for spoiling items and revert if necessary
|
|
|
|
for (i = 0; i < ARRAY_COUNT(gSpoilingItems); i++) {
|
|
|
|
if (INV_CONTENT(ITEM_POCKET_EGG) == gSpoilingItems[i]) {
|
|
|
|
INV_CONTENT(gSpoilingItemReverts[i]) = gSpoilingItemReverts[i];
|
|
|
|
|
|
|
|
// search c buttons for the found spoiling item and revert if necessary
|
2023-08-13 19:24:26 +00:00
|
|
|
for (j = 1; j < ARRAY_COUNT(gSaveContext.save.info.equips.buttonItems); j++) {
|
|
|
|
if (gSaveContext.save.info.equips.buttonItems[j] == gSpoilingItems[i]) {
|
|
|
|
gSaveContext.save.info.equips.buttonItems[j] = gSpoilingItemReverts[i];
|
2022-05-21 18:23:43 +00:00
|
|
|
Interface_LoadItemIcon1(play, j);
|
2021-03-28 23:50:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// restore "temporary B" to the B Button if not a sword item
|
2023-08-13 19:24:26 +00:00
|
|
|
if (gSaveContext.save.info.equips.buttonItems[0] != ITEM_SWORD_KOKIRI &&
|
|
|
|
gSaveContext.save.info.equips.buttonItems[0] != ITEM_SWORD_MASTER &&
|
|
|
|
gSaveContext.save.info.equips.buttonItems[0] != ITEM_SWORD_BIGGORON &&
|
|
|
|
gSaveContext.save.info.equips.buttonItems[0] != ITEM_GIANTS_KNIFE) {
|
2021-03-28 23:50:46 +00:00
|
|
|
|
|
|
|
if (gSaveContext.buttonStatus[0] != BTN_ENABLED) {
|
2023-08-13 19:24:26 +00:00
|
|
|
gSaveContext.save.info.equips.buttonItems[0] = gSaveContext.buttonStatus[0];
|
2021-03-28 23:50:46 +00:00
|
|
|
} else {
|
2023-08-13 19:24:26 +00:00
|
|
|
gSaveContext.save.info.equips.buttonItems[0] = ITEM_NONE;
|
2021-03-28 23:50:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-29 01:00:06 +00:00
|
|
|
#if OOT_VERSION < PAL_1_1
|
|
|
|
gSaveContext.nayrusLoveTimer = 0;
|
|
|
|
#else
|
2021-03-28 23:50:46 +00:00
|
|
|
gSaveContext.nayrusLoveTimer = 2000;
|
2024-08-29 01:00:06 +00:00
|
|
|
#endif
|
|
|
|
|
2023-08-13 19:24:26 +00:00
|
|
|
gSaveContext.save.info.playerData.naviTimer = 0;
|
2021-12-03 14:49:32 +00:00
|
|
|
gSaveContext.seqId = (u8)NA_BGM_DISABLED;
|
2021-12-27 17:35:05 +00:00
|
|
|
gSaveContext.natureAmbienceId = NATURE_ID_DISABLED;
|
2021-03-28 23:50:46 +00:00
|
|
|
gSaveContext.eventInf[0] = 0;
|
|
|
|
gSaveContext.eventInf[1] = 0;
|
|
|
|
gSaveContext.eventInf[2] = 0;
|
|
|
|
gSaveContext.eventInf[3] = 0;
|
|
|
|
gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] =
|
|
|
|
gSaveContext.buttonStatus[3] = gSaveContext.buttonStatus[4] = BTN_ENABLED;
|
2022-11-22 03:01:44 +00:00
|
|
|
gSaveContext.forceRisingButtonAlphas = gSaveContext.nextHudVisibilityMode = gSaveContext.hudVisibilityMode =
|
|
|
|
gSaveContext.hudVisibilityModeTimer = 0; // false, HUD_VISIBILITY_NO_CHANGE
|
2021-03-28 23:50:46 +00:00
|
|
|
|
2022-05-21 18:23:43 +00:00
|
|
|
Environment_InitGameOverLights(play);
|
2024-06-10 14:07:51 +00:00
|
|
|
sGameOverTimer = 20;
|
2022-09-27 16:40:26 +00:00
|
|
|
|
2021-03-28 23:50:46 +00:00
|
|
|
if (1) {}
|
2022-09-27 16:40:26 +00:00
|
|
|
rumbleStrength = R_GAME_OVER_RUMBLE_STRENGTH;
|
|
|
|
rumbleDuration = R_GAME_OVER_RUMBLE_DURATION;
|
|
|
|
rumbleDecreaseRate = R_GAME_OVER_RUMBLE_DECREASE_RATE;
|
2021-03-28 23:50:46 +00:00
|
|
|
|
2022-09-27 16:40:26 +00:00
|
|
|
Rumble_Request(0.0f, ((rumbleStrength > 100) ? 255 : (rumbleStrength * 255) / 100),
|
|
|
|
(CLAMP_MAX(rumbleDuration * 3, 255)),
|
|
|
|
((rumbleDecreaseRate > 100) ? 255 : (rumbleDecreaseRate * 255) / 100));
|
2021-03-28 23:50:46 +00:00
|
|
|
|
|
|
|
gameOverCtx->state = GAMEOVER_DEATH_WAIT_GROUND;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GAMEOVER_DEATH_WAIT_GROUND:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GAMEOVER_DEATH_DELAY_MENU:
|
2024-06-10 14:07:51 +00:00
|
|
|
sGameOverTimer--;
|
2021-03-28 23:50:46 +00:00
|
|
|
|
2024-06-10 14:07:51 +00:00
|
|
|
if (sGameOverTimer == 0) {
|
2023-09-06 15:14:15 +00:00
|
|
|
play->pauseCtx.state = PAUSE_STATE_8;
|
2021-03-28 23:50:46 +00:00
|
|
|
gameOverCtx->state++;
|
2022-09-27 16:40:26 +00:00
|
|
|
Rumble_Reset();
|
2021-03-28 23:50:46 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GAMEOVER_REVIVE_START:
|
|
|
|
gameOverCtx->state++;
|
2024-06-10 14:07:51 +00:00
|
|
|
sGameOverTimer = 0;
|
2022-05-21 18:23:43 +00:00
|
|
|
Environment_InitGameOverLights(play);
|
2022-08-15 13:39:06 +00:00
|
|
|
Letterbox_SetSizeTarget(32);
|
2021-03-28 23:50:46 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case GAMEOVER_REVIVE_RUMBLE:
|
2024-06-10 14:07:51 +00:00
|
|
|
sGameOverTimer = 50;
|
2021-03-28 23:50:46 +00:00
|
|
|
gameOverCtx->state++;
|
|
|
|
|
2022-09-27 16:40:26 +00:00
|
|
|
if (1) {}
|
|
|
|
rumbleStrength = R_GAME_OVER_RUMBLE_STRENGTH;
|
|
|
|
rumbleDuration = R_GAME_OVER_RUMBLE_DURATION;
|
|
|
|
rumbleDecreaseRate = R_GAME_OVER_RUMBLE_DECREASE_RATE;
|
2021-03-28 23:50:46 +00:00
|
|
|
|
2022-09-27 16:40:26 +00:00
|
|
|
Rumble_Request(0.0f, ((rumbleStrength > 100) ? 255 : (rumbleStrength * 255) / 100),
|
|
|
|
(CLAMP_MAX(rumbleDuration * 3, 255)),
|
|
|
|
((rumbleDecreaseRate > 100) ? 255 : (rumbleDecreaseRate * 255) / 100));
|
2021-03-28 23:50:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GAMEOVER_REVIVE_WAIT_GROUND:
|
2024-06-10 14:07:51 +00:00
|
|
|
sGameOverTimer--;
|
2021-03-28 23:50:46 +00:00
|
|
|
|
2024-06-10 14:07:51 +00:00
|
|
|
if (sGameOverTimer == 0) {
|
|
|
|
sGameOverTimer = 64;
|
2021-03-28 23:50:46 +00:00
|
|
|
gameOverCtx->state++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GAMEOVER_REVIVE_WAIT_FAIRY:
|
2024-06-10 14:07:51 +00:00
|
|
|
sGameOverTimer--;
|
2021-03-28 23:50:46 +00:00
|
|
|
|
2024-06-10 14:07:51 +00:00
|
|
|
if (sGameOverTimer == 0) {
|
|
|
|
sGameOverTimer = 50;
|
2021-03-28 23:50:46 +00:00
|
|
|
gameOverCtx->state++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GAMEOVER_REVIVE_FADE_OUT:
|
2022-05-21 18:23:43 +00:00
|
|
|
Environment_FadeOutGameOverLights(play);
|
2024-06-10 14:07:51 +00:00
|
|
|
sGameOverTimer--;
|
2021-03-28 23:50:46 +00:00
|
|
|
|
2024-06-10 14:07:51 +00:00
|
|
|
if (sGameOverTimer == 0) {
|
2021-03-28 23:50:46 +00:00
|
|
|
gameOverCtx->state = GAMEOVER_INACTIVE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|