From 159a53e76f1697cbb0f665f7eef3639316ee3757 Mon Sep 17 00:00:00 2001 From: Matt P <5638426+mattbruv@users.noreply.github.com> Date: Sat, 22 Jun 2024 20:52:59 -0500 Subject: [PATCH] 100% OK zNPCTiki_InitStacking --- .vscode/settings.json | 2 +- src/SB/Game/zNPCTypeTiki.cpp | 72 ++++++++++++++++++++++++++---------- src/SB/Game/zNPCTypeTiki.h | 48 ++++++++++++------------ 3 files changed, 78 insertions(+), 44 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index fd9c4e5..8fe7e6b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,7 +5,7 @@ }, "[cpp]": { "files.encoding": "utf8", - "editor.defaultFormatter": "xaver.clang-format" + "editor.defaultFormatter": "ms-vscode.cpptools" }, "[python]": { "editor.defaultFormatter": "ms-python.black-formatter" diff --git a/src/SB/Game/zNPCTypeTiki.cpp b/src/SB/Game/zNPCTypeTiki.cpp index cbbc650..a14fa85 100644 --- a/src/SB/Game/zNPCTypeTiki.cpp +++ b/src/SB/Game/zNPCTypeTiki.cpp @@ -8,9 +8,9 @@ #define ANIM_COUNT 2 -extern const char *g_strz_tikianim[ANIM_COUNT]; +extern const char* g_strz_tikianim[ANIM_COUNT]; extern uint32 g_hash_tikianim[ANIM_COUNT]; -extern zParEmitter *cloudEmitter; +extern zParEmitter* cloudEmitter; extern xParEmitterCustomSettings thunderEmitterInfo; extern char zNPCTypeTiki_stringBase0[]; extern float32 _862; @@ -51,9 +51,40 @@ void zNPCTiki_InitFX(zScene* scene) } */ -xFactoryInst *ZNPC_Create_Tiki(int32 who, RyzMemGrow *grow, void *) +void test(int32 a) { - zNPCTiki *tiki = NULL; +} + +extern uint32 orphanList; + +void zNPCTiki_InitStacking(zScene* zsc) +{ + for (int32 i = 0; i < zsc->num_npcs; i++) + { + xNPCBasic* npc = (xNPCBasic*)zsc->npcs[i]; + + if ((npc->SelfType() & 0xffffff00) == 'NTT\0') + { + zNPCTiki* tiki = (zNPCTiki*)npc; + + if (npc->SelfType() != 'NTT1' && (tiki->FindParents(zsc), tiki->numParents == 0)) + { + float32 dh = tiki->landHt - tiki->bound.box.box.lower.y; + tiki->bound.box.box.lower.y += dh; + tiki->bound.cyl.h += dh; + tiki->bound.sph.center.y += dh; + tiki->model->Mat->pos.y += dh; + } + tiki->tikiFlag &= ~0x1; + } + } + + orphanList = 0; +} + +xFactoryInst* ZNPC_Create_Tiki(int32 who, RyzMemGrow* grow, void*) +{ + zNPCTiki* tiki = NULL; switch (who) { @@ -76,14 +107,14 @@ xFactoryInst *ZNPC_Create_Tiki(int32 who, RyzMemGrow *grow, void *) return tiki; } -void ZNPC_Destroy_Tiki(xFactoryInst *inst) +void ZNPC_Destroy_Tiki(xFactoryInst* inst) { delete inst; } -xAnimTable *ZNPC_AnimTable_Tiki() +xAnimTable* ZNPC_AnimTable_Tiki() { - xAnimTable *table; + xAnimTable* table; table = xAnimTableNew(zNPCTypeTiki_stringBase0 + 0x3a, NULL, 0); xAnimTableNewState(table, g_strz_tikianim[1], 0x110, 1, _862, NULL, NULL, _858_2, NULL, NULL, @@ -91,9 +122,12 @@ xAnimTable *ZNPC_AnimTable_Tiki() return table; } -void zNPCTiki::Damage(en_NPC_DAMAGE_TYPE damtype, xBase *who, const xVec3 *vec_hit) +void zNPCTiki::Damage(en_NPC_DAMAGE_TYPE damtype, xBase* who, const xVec3* vec_hit) { - if (((xNPCBasic::SelfType() != 'NTT4') || (damtype == DMGTYP_CRUISEBUBBLE) || (damtype - DMGTYP_THUNDER_TIKI_EXPLOSION <= (uint32)1) || (damtype - DMGTYP_INSTAKILL <= (uint32)1)) && this->flg_vuln != 0) + if (((xNPCBasic::SelfType() != 'NTT4') || (damtype == DMGTYP_CRUISEBUBBLE) || + (damtype - DMGTYP_THUNDER_TIKI_EXPLOSION <= (uint32)1) || + (damtype - DMGTYP_INSTAKILL <= (uint32)1)) && + this->flg_vuln != 0) { this->psy_instinct->GoalSet('NGT4', 0); this->flg_vuln = 0; @@ -104,10 +138,10 @@ void zNPCTiki::Reset() { zNPCCommon::Reset(); - xVec3Add((xVec3 *)&bound.sph.r, (xVec3 *)&origLocalBound.sph.r, (xVec3 *)&model->Mat->pos); - xVec3Add((xVec3 *)&bound.box.box.lower, (xVec3 *)&origLocalBound.box.box.lower, - (xVec3 *)&model->Mat->pos); - xVec3Add((xVec3 *)&bound.pad[3], (xVec3 *)&origLocalBound.pad[3], (xVec3 *)&model->Mat->pos); + xVec3Add((xVec3*)&bound.sph.r, (xVec3*)&origLocalBound.sph.r, (xVec3*)&model->Mat->pos); + xVec3Add((xVec3*)&bound.box.box.lower, (xVec3*)&origLocalBound.box.box.lower, + (xVec3*)&model->Mat->pos); + xVec3Add((xVec3*)&bound.pad[3], (xVec3*)&origLocalBound.pad[3], (xVec3*)&model->Mat->pos); xNPCBasic::RestoreColFlags(); @@ -145,7 +179,7 @@ void zNPCTiki::Reset() t1 = _858_2; t2 = _1084; t3 = _1084; - xVec3Copy((xVec3 *)&v1, (xVec3 *)&model->Mat->pos); + xVec3Copy((xVec3*)&v1, (xVec3*)&model->Mat->pos); break; case 0x4e545433: t1 = xurand(); @@ -166,19 +200,19 @@ void zNPCTiki::Setup() { zNPCCommon::Setup(); - xVec3Copy((xVec3 *)&lastAt, (xVec3 *)&model->Mat->at); + xVec3Copy((xVec3*)&lastAt, (xVec3*)&model->Mat->at); } void zNPCTiki::ParseINI() { zNPCCommon::ParseINI(); cfg_npc->snd_traxShare = g_sndTrax_TikiShared; - NPCS_SndTablePrepare((NPCSndTrax *)&g_sndTrax_TikiShared); + NPCS_SndTablePrepare((NPCSndTrax*)&g_sndTrax_TikiShared); switch (xNPCBasic::SelfType()) { case 'NTT3': cfg_npc->snd_trax = g_sndTrax_TikiThunder; - NPCS_SndTablePrepare((NPCSndTrax *)&g_sndTrax_TikiThunder); + NPCS_SndTablePrepare((NPCSndTrax*)&g_sndTrax_TikiThunder); break; } } @@ -193,11 +227,11 @@ void AnimPick() xStrHash(zNPCTypeTiki_stringBase0 + 0x51); } -void zNPCTiki::Move(xScene *xscn, float32 dt, xEntFrame *) +void zNPCTiki::Move(xScene* xscn, float32 dt, xEntFrame*) { } -void zNPCTiki::BUpdate(xVec3 *pos) +void zNPCTiki::BUpdate(xVec3* pos) { xEntDefaultBoundUpdate(this, pos); } diff --git a/src/SB/Game/zNPCTypeTiki.h b/src/SB/Game/zNPCTypeTiki.h index 08e1174..c753967 100644 --- a/src/SB/Game/zNPCTypeTiki.h +++ b/src/SB/Game/zNPCTypeTiki.h @@ -17,39 +17,39 @@ struct zNPCTiki : zNPCCommon float32 t3; xVec3 v1; float32 vel; - float32 landHt; - xEnt* nonTikiParent; - xVec3 nonTikiParentDisp; - uint8 numParents; - zNPCTiki* parents[4]; + float32 landHt; // 0x328 + xEnt *nonTikiParent; // 0x32c + xVec3 nonTikiParentDisp; // 0x330 + uint8 numParents; // 0x33c + zNPCTiki *parents[4]; // 0x340 uint8 numChildren; - zNPCTiki* children[4]; - zNPCTiki* nextOrphan; + zNPCTiki *children[4]; + zNPCTiki *nextOrphan; // 0x364 uint32 updatedParents; int32 contactParent; - void* tikiAnim; + void *tikiAnim; float32 tikiAnimTime; zNPCTiki(int32); void RemoveFromFamily(); - void FindParents(zScene* zsc); + void FindParents(zScene *zsc); - void Init(xEntAsset* entass); + void Init(xEntAsset *entass); void Reset(); void Setup(); - void Process(xScene* xscn, float32 dt); - void BUpdate(xVec3* pos); - virtual void Move(xScene* xscn, float32 dt, xEntFrame*); - int32 SysEvent(xBase* from, xBase* to, uint32 toEvent, float32* toParam, xBase* toParamWidget, - int32* handled); + void Process(xScene *xscn, float32 dt); + void BUpdate(xVec3 *pos); + virtual void Move(xScene *xscn, float32 dt, xEntFrame *); + int32 SysEvent(xBase *from, xBase *to, uint32 toEvent, float32 *toParam, xBase *toParamWidget, + int32 *handled); void ParseINI(); void SelfSetup(); int32 IsHealthy(); virtual int32 IsAlive(); - virtual void Damage(en_NPC_DAMAGE_TYPE damtype, xBase* who, const xVec3* vec_hit); - virtual int32 Respawn(xVec3* pos, zMovePoint* mvptFirst, zMovePoint* mvptSpawnRef); - virtual void DuploOwner(zNPCCommon* duper); + virtual void Damage(en_NPC_DAMAGE_TYPE damtype, xBase *who, const xVec3 *vec_hit); + virtual int32 Respawn(xVec3 *pos, zMovePoint *mvptFirst, zMovePoint *mvptSpawnRef); + virtual void DuploOwner(zNPCCommon *duper); virtual void DuploNotice(); virtual int32 CanRope(); int32 SetCarryState(en_NPC_CARRY_STATE cs); @@ -58,10 +58,10 @@ struct zNPCTiki : zNPCCommon void ZNPC_Tiki_Startup(); void ZNPC_Tiki_Shutdown(); -void zNPCTiki_InitStacking(zScene* zsc); -void zNPCTiki_InitFX(zScene*); -void zNPCTiki_ExplodeFX(zNPCTiki* tiki); -xFactoryInst* ZNPC_Create_Tiki(int32 who, RyzMemGrow* grow, void*); -void ZNPC_Destroy_Tiki(xFactoryInst* inst); +void zNPCTiki_InitStacking(zScene *zsc); +void zNPCTiki_InitFX(zScene *); +void zNPCTiki_ExplodeFX(zNPCTiki *tiki); +xFactoryInst *ZNPC_Create_Tiki(int32 who, RyzMemGrow *grow, void *); +void ZNPC_Destroy_Tiki(xFactoryInst *inst); -#endif \ No newline at end of file +#endif