Skip to content

Commit

Permalink
100% OK zNPCTiki_InitStacking
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbruv committed Jun 23, 2024
1 parent b131bd9 commit 159a53e
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
72 changes: 53 additions & 19 deletions src/SB/Game/zNPCTypeTiki.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -76,24 +107,27 @@ 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,
xAnimDefaultBeforeEnter, NULL, NULL);
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;
Expand All @@ -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();

Expand Down Expand Up @@ -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();
Expand All @@ -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;
}
}
Expand All @@ -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);
}
Expand Down
48 changes: 24 additions & 24 deletions src/SB/Game/zNPCTypeTiki.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
#endif

0 comments on commit 159a53e

Please sign in to comment.