Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zFX: Couple bits #383

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 158 additions & 9 deletions src/SB/Game/zFX.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "xEnt.h"
#include "xFX.h"
#include "xMath.h"
#include "xMath3.h"

#include "zHud.h"
#include "zFX.h"
#include "zScene.h"
#include "zTextBox.h"
Expand All @@ -23,9 +25,9 @@ extern zFXGooInstance zFXGooInstances[24];
extern char zFX_strings[];
extern ztextbox* goo_timer_textbox;

extern F32 lbl_803CD968; // 0.15f
extern F32 lbl_803CD96C; // 12.0f
extern F32 lbl_803CD970; // 2.0f
xVec3 bubblehit_pos_rnd;
xVec3 bubblehit_vel_rnd;
float bubblehit_vel_scale;

void xDrawSphere2(const xVec3*, F32, U32)
{
Expand All @@ -49,27 +51,26 @@ void zFX_SceneReset()
reset_entrails();
}

void zFXPatrickStun(xVec3* pos)
void zFXPatrickStun(const xVec3* pos)
{
xFXRingCreate(pos, &sPatrickStunRing[0]);
xFXRingCreate(pos, &sPatrickStunRing[1]);
xFXRingCreate(pos, &sPatrickStunRing[2]);
}

void zFXHammer(xVec3* pos)
void zFXHammer(const xVec3* pos)
{
xFXRingCreate(pos, &sHammerRing[0]);
// weird xrand arithmetic might have something to do with signed integers
zFX_SpawnBubbleSlam(pos, (xrand() & 31) + 32, lbl_803CD968, lbl_803CD96C, lbl_803CD970);
zFX_SpawnBubbleSlam(pos, (xrand() & 31) + 32, 0.15f, 12.0f, 2.0f);
}

void zFXPorterWave(xVec3* pos)
void zFXPorterWave(const xVec3* pos)
{
xFXRingCreate(pos, &sPorterRing[0]);
xFXRingCreate(pos, &sPorterRing[1]);
}

xFXRing* zFXMuscleArmWave(xVec3* pos)
xFXRing* zFXMuscleArmWave(const xVec3* pos)
{
return xFXRingCreate(pos, &sMuscleArmRing[0]);
}
Expand Down Expand Up @@ -127,6 +128,126 @@ void zFXUpdate(F32 dt)
namespace
{
void add_popper_tweaks() { }
void add_entrail_tweaks() { }

S32 count_faces(xModelInstance* mdl)
{
int i = 0;
for (; mdl != NULL; mdl = mdl->Next)
{
i += mdl->Data->geometry->numTriangles;
}
return i;
}

struct entrail_data
{
U16 flags;
U16 type;
xEnt* ent;
xVec3 loc;
xVec3 vel;
F32 emitted;

void reset();
void update(F32);
};

enum state_enum
{
STATE_NONE,
STATE_OFF,
STATE_ON
};

struct popper_data
{
state_enum state;
xEnt* ent;
RpAtomic* atomic[4];
U32 atomic_size;
F32 time;
F32 end_time;
union
{
xVec3 model_scale;
U32 pipe_flags;
};
F32 rate;
F32 vel;
F32 rloc;
F32 rvel;
F32 emitted;
S32 faces;
F32 radius;
F32 area;
F32 weight[768];
};

popper_data poppers[8];
entrail_data* entrails;
U32 entrails_size;

void entrail_data::reset()
{
flags = 0;
emitted = 0.0f;
}

void set_popper_alpha(popper_data& data, F32 alpha)
{
xEntShow(data.ent);
xModelInstance* p = data.ent->model;
p->Alpha = alpha;
p->Flags |= 0x4000;
p->PipeFlags = (p->PipeFlags & ~0xc) | 8;
}
}

void update_entrails(F32 val)
{
entrail_data* pData;
entrail_data* pEnd = &entrails[entrails_size];
for (pData = entrails; pData != pEnd; pData++)
{
pData->update(val);
}
}

void reset_entrails()
{
entrail_data* pData;
entrail_data* pEnd = &entrails[entrails_size];
for (pData = entrails; pData != pEnd; pData++)
{
pData->reset();
}
}

void zFX_SpawnBubbleHit(const xVec3* pos, unsigned int num, xVec3* pos_rnd, xVec3* vel_rnd, float vel_scale);
void zFX_SpawnBubbleTrail(const xVec3* pos, unsigned int num, const xVec3* pos_rnd, const xVec3* vel_rnd);

void zFX_SpawnBubbleHit(const xVec3* pos, U32 num)
{
zFX_SpawnBubbleHit
(
pos,
num,
&bubblehit_pos_rnd,
&bubblehit_vel_rnd,
bubblehit_vel_scale
);
}

void zFX_SpawnBubbleTrail(const xVec3* pos, U32 num)
{
zFX_SpawnBubbleTrail
(
pos,
num,
&bubblehit_pos_rnd,
&bubblehit_vel_rnd
);
}

void init_poppers()
Expand All @@ -135,6 +256,34 @@ void init_poppers()
add_popper_tweaks();
}

void reset_poppers()
{
popper_data* pData;
popper_data* pEnd = &poppers[sizeof(poppers) / sizeof(popper_data)];
for (pData = &poppers[0]; pData != pEnd; pData++)
{
pData->state = STATE_NONE;
pData->ent = NULL;
}
}

void zFXGooUpdateInstance(zFXGooInstance*, F32);

void zFXGooUpdate(F32 dt)
{
int i;
zFXGooInstance* pGoo = &zFXGooInstances[0];

for (i = 0 ; i < 0x18; i++)
{
if (pGoo->state != zFXGooStateInactive)
{
zFXGooUpdateInstance(pGoo, dt);
}
pGoo++;
}
}

void xDebugAddTweak(const char* unk1, const char* unk2, const tweak_callback* unk3, void* unk4,
U32 unk5)
{
Expand Down