Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zPlatform matches + fix typo
Browse files Browse the repository at this point in the history
escape209 committed Sep 29, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 4a88323 commit 9f796f1
Showing 5 changed files with 117 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/SB/Core/x/xEnt.cpp
Original file line number Diff line number Diff line change
@@ -128,7 +128,7 @@ void xEntAddHittableFlag(xEnt* ent)
{
if (ent->baseType == eBaseTypeNPC || ent->baseType == eBaseTypeDestructObj ||
ent->baseType == eBaseTypeButton || ent->baseType == eBaseTypeBoulder ||
(ent->baseType == eBaseTypePlatform && ent->subType == ZPLATFROM_SUBTYPE_PADDLE))
(ent->baseType == eBaseTypePlatform && ent->subType == ZPLATFORM_SUBTYPE_PADDLE))
{
ent->moreFlags |= 0x10;
}
1 change: 1 addition & 0 deletions src/SB/Core/x/xEntDrive.h
Original file line number Diff line number Diff line change
@@ -34,5 +34,6 @@ struct xEntDrive
void xEntDriveInit(xEntDrive* drv, xEnt* driven);
void xEntDriveMount(xEntDrive* drv, xEnt* driver, F32 mt, const xCollis* coll);
void xEntDriveDismount(xEntDrive* drv, F32 dmt);
void xEntDriveUpdate(xEntDrive* drv, xScene* s, F32 dt, xEntFrame* frame);

#endif
1 change: 1 addition & 0 deletions src/SB/Game/zEntPlayer.h
Original file line number Diff line number Diff line change
@@ -391,6 +391,7 @@ void zEntPlayer_ShadowModelEnable();
void zEntPlayer_ShadowModelDisable();

void zEntPlayerJumpStart(class xEnt* ent, class zJumpParam* jump);
S32 zEntPlayer_IsSneaking();

void zEntPlayer_setBoulderMode(U32 mode);
void zEntPlayer_GiveHealth(S32);
113 changes: 113 additions & 0 deletions src/SB/Game/zPlatform.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
#include "zPlatform.h"
#include "zEnt.h"
#include "zEntPlayer.h"
#include "xEntDrive.h"
#include "zParEmitter.h"

#include "xMath.h"

#include <types.h>

zParEmitter* sEmitTremble;
zParEmitter* sEmitBreakaway;

extern char stringBase0[];

void genericPlatRender(xEnt* ent)
{
if (!ent->model || !xEntIsVisible(ent))
@@ -26,3 +37,105 @@ void zPlatform_Load(zPlatform* ent, xSerial* s)
{
zEntLoad(ent, s);
}

void zPlatform_Move(xEnt* entPlat, xScene* s, float dt, xEntFrame* frame)
{
zPlatform* plat = (zPlatform*)entPlat;
xEntMotionMove(&plat->motion, s, dt, frame);
xEntDriveUpdate(&plat->drv, s, dt, NULL);
}

void zPlatform_Tremble(zPlatform* plat, float ampl, float freq, float dur);

void zPlatform_Mount(zPlatform* ent)
{
if (ent->subType == ZPLATFORM_SUBTYPE_BREAKAWAY)
{
if (ent->state == 0)
{
if ((ent->passet->ba.breakflags & 1) && zEntPlayer_IsSneaking())
{
ent->state = 1;
}
else
{
ent->state = 2;

// Needs to be used or the comparison's operands will be swapped.
F32 restingSpeed = 0.0f;
if ( ent->passet->fr.fspeed != restingSpeed )
{
zPlatform_Tremble(ent, 0.06f, DEG2RAD(720), ent->passet->fr.fspeed + 1.0f);
}
}

}
}
}

void zPlatform_Setup(zPlatform* ent, xScene* sc)
{
zEntSetup((zEnt *)ent);
sEmitTremble = zParEmitterFind(stringBase0 + 0x36); // "PAREMIT_PLAT_TREMBLE"
sEmitBreakaway = zParEmitterFind(stringBase0 + 0x4b); // "PAREMIT_PLAT_BREAKAWAY"
if (ent->subType == ZPLATFORM_SUBTYPE_PADDLE)
{
ent->tmr = -1e38;
ent->state = 2;
ent->ctr = ent->passet->paddle.startOrient;
}
}

void zPlatformTranslate(xEnt* xent, xVec3* dpos, xMat4x3* dmat)
{
zPlatform* plat = (zPlatform*)xent;
xEntDefaultTranslate(xent,dpos,dmat);
xEntMotionTranslate(&plat->motion, dpos, dmat);
}

void zPlatform_BreakawayFallFX(zPlatform* ent, F32 dt)
{
if (sEmitBreakaway != NULL)
{
xParEmitterCustomSettings info;
info.custom_flags = 0x100;
info.pos = *xEntGetCenter(ent);
info.pos.y += 0.5f;
for (int iVar2 = 0; iVar2 < 25; iVar2++)
{
xParEmitterEmitCustom(sEmitBreakaway, 0.03333333f, &info);
}
}
}

U32 zMechIsStartingForth(zPlatform* ent, U16 param_2)
{
U32 ret;
xEntMotion* mot = &ent->motion;
if (mot->asset->mech.type == 4)
{
ret = (__cntlzw(1 - param_2) >> 5) & 0xff;
}
else
{
return (__cntlzw(param_2) >> 5) & 0xff;
}

return ret;
}

U32 zMechIsStartingBack(zPlatform* ent, U16 param_2)
{
U32 ret;
xEntMotion* mot = &ent->motion;
if (mot->asset->mech.type == 4)
{
ret = (__cntlzw(4 - param_2) >> 5) & 0xff;
}
else
{
return (__cntlzw(3 - param_2) >> 5) & 0xff;
}

return ret;
}
2 changes: 1 addition & 1 deletion src/SB/Game/zPlatform.h
Original file line number Diff line number Diff line change
@@ -158,7 +158,7 @@ struct zPlatform : zEnt
#define ZPLATFORM_SUBTYPE_BREAKAWAY 9
#define ZPLATFORM_SUBTYPE_SPRINGBOARD 10
#define ZPLATFORM_SUBTYPE_TEETER 11
#define ZPLATFROM_SUBTYPE_PADDLE 12
#define ZPLATFORM_SUBTYPE_PADDLE 12
#define ZPLATFORM_SUBTYPE_FM 13

void genericPlatRender(xEnt* ent);

0 comments on commit 9f796f1

Please sign in to comment.