From 6491b5563ed0a803eaab38b9e77a0d1999b88034 Mon Sep 17 00:00:00 2001 From: escape209 Date: Sun, 16 Mar 2025 05:15:47 +0000 Subject: [PATCH] zNPCHazard stuff --- src/SB/Game/zNPCHazard.cpp | 95 +++++++++++++++++++++++++++++++++++- src/SB/Game/zNPCHazard.h | 4 ++ src/SB/Game/zNPCSupplement.h | 1 + 3 files changed, 99 insertions(+), 1 deletion(-) diff --git a/src/SB/Game/zNPCHazard.cpp b/src/SB/Game/zNPCHazard.cpp index a58fa65c5..de073479d 100644 --- a/src/SB/Game/zNPCHazard.cpp +++ b/src/SB/Game/zNPCHazard.cpp @@ -6,6 +6,8 @@ #include "zGlobals.h" #include "zNPCTypeCommon.h" #include "zNPCTypes.h" +#include "zNPCSupplement.h" +#include "xMath.h" extern U32 g_hash_hazanim[3]; extern char* g_strz_hazanim[3]; @@ -177,6 +179,56 @@ void NPCHazard::Reconfigure(en_npchaz haztype) } } +void NPCHazard::FreeModel() +{ + if (mdl_hazard != NULL) + { + xModelInstanceFree(mdl_hazard); + } + mdl_hazard = NULL; +} + +void NPCHazard::Discard() +{ + if ((flg_hazard & 1) != 0) + { + if (cb_notify != NULL) + { + cb_notify->Notify((en_haznote)0, this); + } + + Cleanup(); + + g_cnt_activehaz &= ~((g_cnt_activehaz-1) >> 31); + } +} + +void NPCHazard::Kill() +{ + if ((flg_hazard & 1) != 0) + { + if (cb_notify != NULL) + { + cb_notify->Notify(HAZ_NOTE_ABORT, this); + } + Discard(); + } +} + +void NPCHazard::Start(const xVec3* pos, F32 tym) +{ + if (tym > 0.0f) + { + tmr_remain = tym; + } + tym_lifespan = tmr_remain; + if (pos != NULL) + { + PosSet(pos); + } + flg_hazard |= 0x1a; +} + void NPCHazard::PosSet(const xVec3* pos) { if (pos != NULL) @@ -259,6 +311,45 @@ void NPCHazard::Upd_Patriot(F32) { } +S32 NPCHazard::KickSteamyStinky() +{ + S32 ok; + NPCHazard* haz = (NPCHazard *)HAZ_Acquire(); + + F32 tym_lifeOfChild = 0.25f; + + if (haz == NULL) + { + ok = 0; + } + else + { + if (haz->ConfigHelper(NPC_HAZ_TARTARSTINK) == 0) + { + haz->Discard(); + ok = 1; + } + else + { + haz->Start(&pos_hazard, tmr_remain - tym_lifeOfChild); + ok = 2; + } + } + return ok; +} + +void NPCHazard::TarTarGunkTrail() +{ + xVec3 pos = pos_hazard; + NPAR_EmitTarTarTrail(&pos, &g_Y3); +} + +void NPCHazard::ReconArfBone() +{ + Reconfigure(NPC_HAZ_ARFBONEBLAST); + Start(NULL, -1.0f); +} + void UVAModelInfo::Hemorrage() { model = 0; @@ -280,8 +371,10 @@ S32 UVAModelInfo::GetUV(RwTexCoords*& coords, S32& numVertices, RpAtomic* model) { return 0; } + coords = geom->texCoords[0]; - return (-(S32)coords->u | (U32)coords->u) >> 0x1f; + + return coords != NULL; } RwV3d* NPCHazard::At() const diff --git a/src/SB/Game/zNPCHazard.h b/src/SB/Game/zNPCHazard.h index a00887b7a..46283db59 100644 --- a/src/SB/Game/zNPCHazard.h +++ b/src/SB/Game/zNPCHazard.h @@ -211,6 +211,7 @@ struct NPCHazard NPCHazard(en_npchaz haztype); S32 ConfigHelper(en_npchaz haztype); void Reconfigure(en_npchaz haztype); + void FreeModel(); void SetNPCOwner(zNPCCommon* owner); void Start(const xVec3* pos, F32 tym); void MarkForRecycle(); @@ -224,6 +225,9 @@ struct NPCHazard S32 ColTestCyl(const xBound* bnd_tgt, F32 rad, F32 hyt); S32 ColPlyrSphere(F32 rad); S32 ColPlyrCyl(F32 rad, F32 hyt); + void TarTarGunkTrail(); + S32 KickSteamyStinky(); + void ReconArfBone(); void HurtThePlayer(); void TypData_RotMatSet(xMat3x3* mat); void TypData_RotMatApply(xMat3x3* mat); diff --git a/src/SB/Game/zNPCSupplement.h b/src/SB/Game/zNPCSupplement.h index bc0d6a0c2..d791bafc9 100644 --- a/src/SB/Game/zNPCSupplement.h +++ b/src/SB/Game/zNPCSupplement.h @@ -116,6 +116,7 @@ void NPCSupplement_ScenePostInit(); void NPCSupplement_Timestep(F32 dt); void NPAR_ScenePrepare(); void NPAR_SceneFinish(); +void NPAR_EmitTarTarTrail(const xVec3*, const xVec3*); NPARMgmt* NPAR_PartySetup(en_nparptyp parType, void** userData, NPARXtraData* xtraData); void NPAR_SceneReset(); void NPCC_ShadowCacheReset();