Hookify three Glitch Restoration options (#7200)

This commit is contained in:
Jordan Longstaff
2026-09-16 14:15:17 -04:00
committed by GitHub
parent aff03cd7b8
commit ae62048910
7 changed files with 75 additions and 21 deletions
@@ -0,0 +1,13 @@
#include <libultraship/bridge/consolevariablebridge.h>
#include "soh/cvar_prefixes.h"
#include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/ShipInit.hpp"
static constexpr const char* CVAR_EARLY_EYEBALL_FROG = CVAR_ENHANCEMENT("EarlyEyeballFrog");
static void RegisterEarlyEyeballFrog() {
COND_VB_SHOULD(VB_GIVE_EYEBALL_FROG_EARLY, CVarGetInteger(CVAR_EARLY_EYEBALL_FROG, 0), { *should = true; });
}
static RegisterShipInitFunc initFunc(RegisterEarlyEyeballFrog, { CVAR_EARLY_EYEBALL_FROG });
@@ -0,0 +1,13 @@
#include <libultraship/bridge/consolevariablebridge.h>
#include "soh/cvar_prefixes.h"
#include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/ShipInit.hpp"
static constexpr const char* CVAR_QUICK_BONGO_KILL = CVAR_ENHANCEMENT("QuickBongoKill");
static void RegisterQuickBongoKill() {
COND_VB_SHOULD(VB_ALLOW_QUICK_BONGO_KILL, CVarGetInteger(CVAR_QUICK_BONGO_KILL, 0), { *should = true; });
}
static RegisterShipInitFunc initFunc(RegisterQuickBongoKill, { CVAR_QUICK_BONGO_KILL });
@@ -0,0 +1,13 @@
#include <libultraship/bridge/consolevariablebridge.h>
#include "soh/cvar_prefixes.h"
#include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/ShipInit.hpp"
static constexpr const char* CVAR_QUICK_PUTAWAY = CVAR_ENHANCEMENT("QuickPutaway");
static void RegisterQuickPutaway() {
COND_VB_SHOULD(VB_ALLOW_QUICK_PUTAWAY, CVarGetInteger(CVAR_QUICK_PUTAWAY, 0), { *should = true; });
}
static RegisterShipInitFunc initFunc(RegisterQuickPutaway, { CVAR_QUICK_PUTAWAY });
@@ -17,6 +17,22 @@ typedef enum {
// - `int32_t` (entrance index) (promoted from `uint16_t` by va_arg)
VB_ALLOW_ENTRANCE_CS_FOR_EITHER_AGE,
// #### `result`
// ```c
// (this->actionFunc != BossSst_HeadLurk) && (this->actionFunc != BossSst_HeadIntro)
// ```
// #### `args`
// - None
VB_ALLOW_QUICK_BONGO_KILL,
// #### `result`
// ```c
// !(this->stateFlags1 & PLAYER_STATE1_START_CHANGING_HELD_ITEM)
// ```
// #### `args`
// - None
VB_ALLOW_QUICK_PUTAWAY,
// #### `result`
// ```c
// sPuzzleState == 0xF
@@ -1011,6 +1027,14 @@ typedef enum {
// - `*EnJs`
VB_GIVE_BOMBCHUS_FROM_CARPET_SALESMAN,
// #### `result`
// ```c
// false
// ```
// #### `args`
// - None
VB_GIVE_EYEBALL_FROG_EARLY,
// #### `result`
// ```c
// true
@@ -377,21 +377,12 @@ void BossSst_HeadSetupLurk(BossSst* this) {
}
void BossSst_HeadLurk(BossSst* this, PlayState* play) {
if (CVarGetInteger(CVAR_ENHANCEMENT("QuickBongoKill"), 0)) {
this->colliderCyl.base.acFlags |= AC_ON;
}
if (this->actor.yDistToPlayer < 1000.0f) {
BossSst_HeadSetupIntro(this, play);
}
}
void BossSst_HeadSetupIntro(BossSst* this, PlayState* play) {
// Make sure to restore original behavior if the quick kill didn't happen
if (CVarGetInteger(CVAR_ENHANCEMENT("QuickBongoKill"), 0)) {
this->colliderCyl.base.acFlags &= ~AC_ON;
}
Player* player = GET_PLAYER(play);
this->timer = 611;
@@ -2632,7 +2623,8 @@ void BossSst_UpdateHand(Actor* thisx, PlayState* play) {
CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliderJntSph.base);
}
if ((sHead->actionFunc != BossSst_HeadLurk) && (sHead->actionFunc != BossSst_HeadIntro) &&
if (GameInteractor_Should(VB_ALLOW_QUICK_BONGO_KILL,
(this->actionFunc != BossSst_HeadLurk) && (this->actionFunc != BossSst_HeadIntro)) &&
(this->colliderJntSph.base.acFlags & AC_ON)) {
CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderJntSph.base);
}
@@ -2688,8 +2680,8 @@ void BossSst_UpdateHead(Actor* thisx, PlayState* play) {
CollisionCheck_SetAT(play, &play->colChkCtx, &this->colliderJntSph.base);
}
if ((this->actionFunc != BossSst_HeadLurk || CVarGetInteger(CVAR_ENHANCEMENT("QuickBongoKill"), 0)) &&
(this->actionFunc != BossSst_HeadIntro)) {
if (GameInteractor_Should(VB_ALLOW_QUICK_BONGO_KILL,
(this->actionFunc != BossSst_HeadLurk) && (this->actionFunc != BossSst_HeadIntro))) {
if (this->colliderCyl.base.acFlags & AC_ON) {
CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderCyl.base);
}
+7 -7
View File
@@ -126,7 +126,7 @@ s16 EnKz_UpdateTalkState(PlayState* play, Actor* thisx) {
switch (Message_GetState(&play->msgCtx)) {
case TEXT_STATE_DONE:
if (CVarGetInteger(CVAR_ENHANCEMENT("EarlyEyeballFrog"), 0)) {
if (GameInteractor_Should(VB_GIVE_EYEBALL_FROG_EARLY, false)) {
if (Message_ShouldAdvance(play)) {
talkState = NPC_TALK_STATE_ITEM_GIVEN;
}
@@ -147,7 +147,7 @@ s16 EnKz_UpdateTalkState(PlayState* play, Actor* thisx) {
}
break;
case TEXT_STATE_CLOSING:
if (CVarGetInteger(CVAR_ENHANCEMENT("EarlyEyeballFrog"), 0)) {
if (GameInteractor_Should(VB_GIVE_EYEBALL_FROG_EARLY, false)) {
talkState = NPC_TALK_STATE_IDLE;
switch (this->actor.textId) {
case 0x4012:
@@ -181,7 +181,7 @@ s16 EnKz_UpdateTalkState(PlayState* play, Actor* thisx) {
}
if (this->actor.textId == 0x4014) {
if (play->msgCtx.choiceIndex == 0) {
if (!CVarGetInteger(CVAR_ENHANCEMENT("EarlyEyeballFrog"), 0)) {
if (!GameInteractor_Should(VB_GIVE_EYEBALL_FROG_EARLY, false)) {
EnKz_SetupGetItem(this, play);
}
talkState = NPC_TALK_STATE_ACTION;
@@ -287,12 +287,12 @@ void func_80A9CB18(EnKz* this, PlayState* play) {
this->actor.textId = 0x4014;
this->sfxPlayed = false;
player->actor.textId = this->actor.textId;
if (!CVarGetInteger(CVAR_ENHANCEMENT("EarlyEyeballFrog"), 0)) {
if (!GameInteractor_Should(VB_GIVE_EYEBALL_FROG_EARLY, false)) {
this->isTrading = true;
}
return;
}
if (!CVarGetInteger(CVAR_ENHANCEMENT("EarlyEyeballFrog"), 0)) {
if (!GameInteractor_Should(VB_GIVE_EYEBALL_FROG_EARLY, false)) {
this->isTrading = false;
}
if (Flags_GetInfTable(INFTABLE_139)) {
@@ -455,7 +455,7 @@ void EnKz_StopMweep(EnKz* this, PlayState* play) {
void EnKz_Wait(EnKz* this, PlayState* play) {
if (this->interactInfo.talkState == NPC_TALK_STATE_ACTION) {
if (CVarGetInteger(CVAR_ENHANCEMENT("EarlyEyeballFrog"), 0)) {
if (GameInteractor_Should(VB_GIVE_EYEBALL_FROG_EARLY, false)) {
this->interactInfo.talkState = NPC_TALK_STATE_IDLE;
}
this->actionFunc = EnKz_SetupGetItem;
@@ -476,7 +476,7 @@ void EnKz_SetupGetItem(EnKz* this, PlayState* play) {
this->interactInfo.talkState = NPC_TALK_STATE_TALKING;
this->actionFunc = EnKz_StartTimer;
} else {
if (CVarGetInteger(CVAR_ENHANCEMENT("EarlyEyeballFrog"), 0)) {
if (GameInteractor_Should(VB_GIVE_EYEBALL_FROG_EARLY, false)) {
getItemId = Actor_GetPlayerExchangeItemId(play) == EXCH_ITEM_PRESCRIPTION ? GI_FROG : GI_TUNIC_ZORA;
} else {
getItemId = this->isTrading ? GI_FROG : GI_TUNIC_ZORA;
@@ -2612,8 +2612,7 @@ void Player_StartChangingHeldItem(Player* this, PlayState* play) {
void Player_UpdateItems(Player* this, PlayState* play) {
if ((this->actor.category == ACTORCAT_PLAYER) &&
(CVarGetInteger(CVAR_ENHANCEMENT("QuickPutaway"), 0) ||
!(this->stateFlags1 & PLAYER_STATE1_START_CHANGING_HELD_ITEM)) &&
GameInteractor_Should(VB_ALLOW_QUICK_PUTAWAY, !(this->stateFlags1 & PLAYER_STATE1_START_CHANGING_HELD_ITEM)) &&
((this->heldItemAction == this->itemAction) || (this->stateFlags1 & PLAYER_STATE1_SHIELDING)) &&
(gSaveContext.health != 0) && (play->csCtx.state == CS_STATE_IDLE) && (this->csAction == 0) &&
(play->shootingGalleryStatus == 0) && (play->activeCamera == CAM_ID_MAIN) &&