diff --git a/soh/soh/Enhancements/Cheats/DropsDontDie.cpp b/soh/soh/Enhancements/Cheats/DropsDontDie.cpp new file mode 100644 index 000000000..ccf4f339f --- /dev/null +++ b/soh/soh/Enhancements/Cheats/DropsDontDie.cpp @@ -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") }); diff --git a/soh/soh/Enhancements/Cheats/NoBugsDespawn.cpp b/soh/soh/Enhancements/Cheats/NoBugsDespawn.cpp new file mode 100644 index 000000000..b770ef863 --- /dev/null +++ b/soh/soh/Enhancements/Cheats/NoBugsDespawn.cpp @@ -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(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") }); diff --git a/soh/soh/Enhancements/Cheats/NoFishDespawn.cpp b/soh/soh/Enhancements/Cheats/NoFishDespawn.cpp new file mode 100644 index 000000000..7d8213f13 --- /dev/null +++ b/soh/soh/Enhancements/Cheats/NoFishDespawn.cpp @@ -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") }); diff --git a/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h b/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h index 635656c8d..8f1b6ebf8 100644 --- a/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h +++ b/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h @@ -1315,6 +1315,14 @@ typedef enum { // - `*EnItem00` VB_ITEM00_DESPAWN, + // #### `result` + // ```c + // this->unk_15A > 0 + // ``` + // #### `args` + // - `*EnItem00` + VB_ITEM00_TIMER_TICK, + // #### `result` // ```c // true @@ -2672,14 +2680,6 @@ typedef enum { // - `*BgHidanDalm` VB_HAMMER_TOTEM_BREAK, - // #### `result` - // ```c - // Actor_GetCollidedExplosive(play, &this->collider.base) != NULL - // ``` - // #### `args` - // - `*BgHidanKowarerukabe` - VB_FIRE_TEMPLE_BOMBABLE_WALL_BREAK, - // #### `result` // ```c // true @@ -2714,6 +2714,22 @@ typedef enum { // - `*FileChooseContext` 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` // ```c // true diff --git a/soh/src/code/z_en_item00.c b/soh/src/code/z_en_item00.c index e8e29a19d..b2da1c40d 100644 --- a/soh/src/code/z_en_item00.c +++ b/soh/src/code/z_en_item00.c @@ -3,7 +3,6 @@ #include "objects/gameplay_keep/gameplay_keep.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 "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.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--; - 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)) { diff --git a/soh/src/overlays/actors/ovl_En_Fish/z_en_fish.c b/soh/src/overlays/actors/ovl_En_Fish/z_en_fish.c index c8509aa51..7ee6432b2 100644 --- a/soh/src/overlays/actors/ovl_En_Fish/z_en_fish.c +++ b/soh/src/overlays/actors/ovl_En_Fish/z_en_fish.c @@ -8,6 +8,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "vt.h" #include "soh/ResourceManagerHelpers.h" +#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #define FLAGS 0 @@ -679,7 +680,7 @@ void EnFish_UpdateCutscene(EnFish* this, PlayState* play) { // Update functions and Draw 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--; } diff --git a/soh/src/overlays/actors/ovl_En_Insect/z_en_insect.c b/soh/src/overlays/actors/ovl_En_Insect/z_en_insect.c index 46199e841..87706b088 100644 --- a/soh/src/overlays/actors/ovl_En_Insect/z_en_insect.c +++ b/soh/src/overlays/actors/ovl_En_Insect/z_en_insect.c @@ -212,13 +212,6 @@ void EnInsect_Init(Actor* thisx, PlayState* play2) { 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++; } else { rand = Rand_ZeroOne();