Hookify DropsDontDie, NoFishDespawn, NoBugsDespawn (#6513)

This commit is contained in:
Philip Dubé 2026-04-17 03:50:17 +00:00 committed by GitHub
parent 27d35e5a92
commit aedae12e63
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 72 additions and 21 deletions

View file

@ -0,0 +1,12 @@
#include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/ShipInit.hpp"
static void RegisterDropsDontDie() {
COND_VB_SHOULD(VB_ITEM00_TIMER_TICK, CVarGetInteger(CVAR_CHEAT("DropsDontDie"), 0), {
EnItem00* item00 = va_arg(args, EnItem00*);
if (item00->unk_154 <= 0)
*should = false;
});
}
static RegisterShipInitFunc initFunc(RegisterDropsDontDie, { CVAR_CHEAT("DropsDontDie") });

View file

@ -0,0 +1,25 @@
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#include "soh/ShipInit.hpp"
extern "C" {
#include "macros.h"
#include "src/overlays/actors/ovl_En_Insect/z_en_insect.h"
extern s16 D_80A7DEB8;
}
static void OnActorInitNoBugsDespawn(void* refActor) {
EnInsect* insect = reinterpret_cast<EnInsect*>(refActor);
if ((insect->actor.params & 2) && insect->soilActor == NULL) {
insect->insectFlags &= ~4;
D_80A7DEB8--;
}
}
static void RegisterNoBugsDespawn() {
COND_ID_HOOK(OnActorInit, ACTOR_EN_INSECT, CVarGetInteger(CVAR_CHEAT("NoBugsDespawn"), 0),
OnActorInitNoBugsDespawn);
}
static RegisterShipInitFunc initFunc(RegisterNoBugsDespawn, { CVAR_CHEAT("NoBugsDespawn") });

View file

@ -0,0 +1,8 @@
#include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/ShipInit.hpp"
static void RegisterNoFishDespawn() {
COND_VB_SHOULD(VB_FISH_TIMER_TICK, CVarGetInteger(CVAR_CHEAT("NoFishDespawn"), 0), { *should = false; });
}
static RegisterShipInitFunc initFunc(RegisterNoFishDespawn, { CVAR_CHEAT("NoFishDespawn") });

View file

@ -1315,6 +1315,14 @@ typedef enum {
// - `*EnItem00` // - `*EnItem00`
VB_ITEM00_DESPAWN, VB_ITEM00_DESPAWN,
// #### `result`
// ```c
// this->unk_15A > 0
// ```
// #### `args`
// - `*EnItem00`
VB_ITEM00_TIMER_TICK,
// #### `result` // #### `result`
// ```c // ```c
// true // true
@ -2672,14 +2680,6 @@ typedef enum {
// - `*BgHidanDalm` // - `*BgHidanDalm`
VB_HAMMER_TOTEM_BREAK, VB_HAMMER_TOTEM_BREAK,
// #### `result`
// ```c
// Actor_GetCollidedExplosive(play, &this->collider.base) != NULL
// ```
// #### `args`
// - `*BgHidanKowarerukabe`
VB_FIRE_TEMPLE_BOMBABLE_WALL_BREAK,
// #### `result` // #### `result`
// ```c // ```c
// true // true
@ -2714,6 +2714,22 @@ typedef enum {
// - `*FileChooseContext` // - `*FileChooseContext`
VB_FILE_SELECT_DRAW_FILE_INFO_BOX, VB_FILE_SELECT_DRAW_FILE_INFO_BOX,
// #### `result`
// ```c
// Actor_GetCollidedExplosive(play, &this->collider.base) != NULL
// ```
// #### `args`
// - `*BgHidanKowarerukabe`
VB_FIRE_TEMPLE_BOMBABLE_WALL_BREAK,
// #### `result`
// ```c
// this->timer > 0
// ```
// #### `args`
// - None
VB_FISH_TIMER_TICK,
// #### `result` // #### `result`
// ```c // ```c
// true // true

View file

@ -3,7 +3,6 @@
#include "objects/gameplay_keep/gameplay_keep.h" #include "objects/gameplay_keep/gameplay_keep.h"
#include "overlays/effects/ovl_Effect_Ss_Dead_Sound/z_eff_ss_dead_sound.h" #include "overlays/effects/ovl_Effect_Ss_Dead_Sound/z_eff_ss_dead_sound.h"
#include "textures/icon_item_static/icon_item_static.h" #include "textures/icon_item_static/icon_item_static.h"
#include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
@ -781,11 +780,8 @@ void EnItem00_Update(Actor* thisx, PlayState* play) {
} }
} }
if (this->unk_15A > 0) { if (GameInteractor_Should(VB_ITEM00_TIMER_TICK, this->unk_15A > 0, this)) {
this->unk_15A--; this->unk_15A--;
if (CVarGetInteger(CVAR_CHEAT("DropsDontDie"), 0) && (this->unk_154 <= 0)) {
this->unk_15A++;
}
} }
if ((this->unk_15A > 0) && (this->unk_15A < 41) && (this->unk_154 <= 0)) { if ((this->unk_15A > 0) && (this->unk_15A < 41) && (this->unk_154 <= 0)) {

View file

@ -8,6 +8,7 @@
#include "objects/gameplay_keep/gameplay_keep.h" #include "objects/gameplay_keep/gameplay_keep.h"
#include "vt.h" #include "vt.h"
#include "soh/ResourceManagerHelpers.h" #include "soh/ResourceManagerHelpers.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#define FLAGS 0 #define FLAGS 0
@ -679,7 +680,7 @@ void EnFish_UpdateCutscene(EnFish* this, PlayState* play) {
// Update functions and Draw // Update functions and Draw
void EnFish_OrdinaryUpdate(EnFish* this, PlayState* play) { void EnFish_OrdinaryUpdate(EnFish* this, PlayState* play) {
if (this->timer > 0 && CVarGetInteger(CVAR_CHEAT("NoFishDespawn"), 0) == 0) { if (GameInteractor_Should(VB_FISH_TIMER_TICK, this->timer > 0)) {
this->timer--; this->timer--;
} }

View file

@ -212,13 +212,6 @@ void EnInsect_Init(Actor* thisx, PlayState* play2) {
func_80A7D39C(this); func_80A7D39C(this);
// For bugs that aren't linked to a soil patch, we remove the "short lived" flag to prevent them from despawning
// And exit early to not increment the "bugs dropped count"
if (CVarGetInteger(CVAR_CHEAT("NoBugsDespawn"), 0) && this->soilActor == NULL) {
this->insectFlags &= ~4;
return;
}
D_80A7DEB8++; D_80A7DEB8++;
} else { } else {
rand = Rand_ZeroOne(); rand = Rand_ZeroOne();