From a1bd17b2d62edc1ef94039fc4853c5edff0ec77a Mon Sep 17 00:00:00 2001 From: Demur Rumed Date: Sun, 11 May 2025 17:18:55 +0000 Subject: [PATCH] hookify --- soh/soh/Enhancements/RebottleBlueFire.cpp | 25 +++++++++++++++++++ .../actors/ovl_En_Ice_Hono/z_en_ice_hono.c | 11 -------- 2 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 soh/soh/Enhancements/RebottleBlueFire.cpp diff --git a/soh/soh/Enhancements/RebottleBlueFire.cpp b/soh/soh/Enhancements/RebottleBlueFire.cpp new file mode 100644 index 000000000..8ca11e4e6 --- /dev/null +++ b/soh/soh/Enhancements/RebottleBlueFire.cpp @@ -0,0 +1,25 @@ +#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" +#include "soh/ShipInit.hpp" + +extern "C" { +#include "src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.h" +void EnIceHono_CapturableFlame(EnIceHono* thisx, PlayState* play); +u32 EnIceHono_InBottleRange(EnIceHono* thisx, PlayState* play); +} + +extern PlayState* gPlayState; + +void OnEnIceHonoUpdate(void* actor) { + EnIceHono* thisx = (EnIceHono*)actor; + if (thisx->actionFunc != EnIceHono_CapturableFlame && EnIceHono_InBottleRange(thisx, gPlayState)) { + // GI_MAX in this case allows the player to catch the actor in a bottle + Actor_OfferGetItem(&thisx->actor, gPlayState, GI_MAX, 60.0f, 100.0f); + } +} + +void RegisterRebottleBlueFire() { + COND_ID_HOOK(OnActorUpdate, ACTOR_EN_ICE_HONO, CVarGetInteger(CVAR_ENHANCEMENT("RebottleBlueFire"), 0), + OnEnIceHonoUpdate); +} + +static RegisterShipInitFunc initFunc(RegisterRebottleBlueFire, { CVAR_ENHANCEMENT("RebottleBlueFire") }); \ No newline at end of file diff --git a/soh/src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.c b/soh/src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.c index 7e000e1ed..f0e9cf64b 100644 --- a/soh/src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.c +++ b/soh/src/overlays/actors/ovl_En_Ice_Hono/z_en_ice_hono.c @@ -7,8 +7,6 @@ #include "z_en_ice_hono.h" #include "objects/gameplay_keep/gameplay_keep.h" -#include - #define FLAGS 0 void EnIceHono_Init(Actor* thisx, PlayState* play); @@ -298,10 +296,6 @@ void EnIceHono_SpreadFlames(EnIceHono* this, PlayState* play) { } } - if (CVarGetInteger(CVAR_ENHANCEMENT("RebottleBlueFire"), 0)) { - EnIceHono_CapturableFlame(this, play); - } - if (this->timer <= 0) { Actor_Kill(&this->actor); } @@ -337,11 +331,6 @@ void EnIceHono_SmallFlameMove(EnIceHono* this, PlayState* play) { this->alpha -= 10; this->alpha = CLAMP(this->alpha, 0, 255); } - - if (CVarGetInteger(CVAR_ENHANCEMENT("RebottleBlueFire"), 0)) { - EnIceHono_CapturableFlame(this, play); - } - if (this->timer <= 0) { Actor_Kill(&this->actor); }