Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions src/SB/Game/zAssetTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,10 @@ U8 dummyEffectCB(U32, xAnimActiveEffect*, xAnimSingle*, void*)
{
return 0;
}


U32 xSndPlay3D(U32 id, F32 vol, F32 pitch, U32 priority, U32 flags,
xEnt* ent, F32 radius, sound_category category, F32 delay)
{
return xSndPlay3D(id, vol, pitch, priority, flags, ent, radius / 4.0f, radius, category, delay);
}
4 changes: 4 additions & 0 deletions src/SB/Game/zAssetTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <types.h>
#include <rwcore.h>
#include <rpworld.h>
#include "xSnd.h"

#include "xJSP.h"

Expand All @@ -16,4 +17,7 @@ struct RwMemory
void FootstepHackSceneEnter();
void jsp_shadow_hack(xJSPHeader* param_1);

U32 xSndPlay3D(U32 id, F32 vol, F32 pitch, U32 priority, U32 flags, xEnt* pos, F32 radius,
sound_category category, F32 delay);

#endif
4 changes: 1 addition & 3 deletions src/SB/Game/zEnt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -925,9 +925,7 @@ xMat4x3* xEntGetFrame(const xEnt* ent)
void xSndPlay3D(U32 id, F32 vol, F32 pitch, U32 priority, U32 flags, const xVec3* pos, F32 radius,
sound_category category, F32 delay)
{
// This is UB to assign radius in the function call like this, but the assembly matches a *=
// so maybe HI made a mistake here.
xSndPlay3D(id, vol, pitch, priority, flags, pos, radius *= 0.25f, radius, category, delay);
xSndPlay3D(id, vol, pitch, priority, flags, pos, radius / 4.0f, radius, category, delay);
}

S32 xNPCBasic::SelfType() const
Expand Down
123 changes: 122 additions & 1 deletion src/SB/Game/zLasso.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

#include <types.h>

static u32 sLassoRaster;
static u32 sNumGuideLists;
static zLassoGuide* sCurrentGuide;
static void* lnverts;

static zLassoGuideList sGuideList[64];

static s32 negativeHondaX = 1;

void zLasso_InitTimer(zLasso* lasso, F32 interpTime)
{
lasso->secsTotal = interpTime;
Expand Down Expand Up @@ -35,4 +44,116 @@ void zLasso_InitTimer(zLasso* lasso, F32 interpTime)
lasso->reindex[2] = 2;
lasso->reindex[3] = 3;
lasso->reindex[4] = 4;
}
}

void zLasso_ResetTimer(zLasso* lasso, F32 interpTime)
{
f32 temp_f0;
f32 temp_f0_2;

lasso->secsTotal = interpTime;
lasso->secsLeft = interpTime;
temp_f0 = lasso->crRadius;
lasso->stRadius = temp_f0;
lasso->tgRadius = temp_f0;
temp_f0_2 = lasso->crSlack;
lasso->stSlack = temp_f0_2;
lasso->tgSlack = temp_f0_2;
xVec3Copy(&lasso->stNormal, &lasso->crNormal);
xVec3Copy(&lasso->tgNormal, &lasso->crNormal);
xVec3Add(&lasso->stCenter, &lasso->crCenter, &lasso->anchor);
}

void fizzicalRadius(zLasso* lasso, f32 arg1, xVec3* arg2)
{
lasso->crRadius = -((2.0f * (0.75f - lasso->crSlack) * arg1) - lasso->crRadius);
if (lasso->crRadius < 0.0f)
{
lasso->crRadius = 0.0f;
}
}

void fizzicalCenter(zLasso* lasso, f32 arg1, xVec3* arg2)
{
xVec3AddScaled(&lasso->crCenter, &lasso->lastRefs[lasso->reindex[4]], -0.2f);
xVec3AddScaled(&lasso->crCenter, arg2, 0.2f);
}

void fizzicalNormal(zLasso* lasso, f32 arg1, xVec3* arg2)
{
xVec3 sp8;
f32 temp_f31;

xVec3Sub(&sp8, &lasso->lastRefs[lasso->reindex[0]], &lasso->lastRefs[lasso->reindex[1]]);
temp_f31 = xVec3Dot(&lasso->crNormal, &sp8);
xVec3AddScaled(&lasso->crNormal, &sp8, 1.1f * (-temp_f31 / xVec3Length(&sp8)));
xVec3Normalize(&lasso->crNormal, &lasso->crNormal);
}

void fizzicalHonda(zLasso* lasso, f32 arg1, xVec3* arg2)
{
xVec3* temp_r3;

xVec3SMul(&lasso->honda, arg2, -1.0f);
xVec3AddScaled(&lasso->honda, &lasso->lastRefs[lasso->reindex[0]], 0.571429f);
xVec3AddScaled(&lasso->honda, &lasso->lastRefs[lasso->reindex[1]], 0.285714f);
xVec3AddScaled(&lasso->honda, &lasso->lastRefs[lasso->reindex[2]], 0.142857f);
xVec3AddScaled(&lasso->honda, &lasso->crNormal, -xVec3Dot(&lasso->crNormal, &lasso->honda));
temp_r3 = &lasso->honda;
xVec3Normalize(temp_r3, temp_r3);
xVec3SMulBy(&lasso->honda, lasso->crRadius);
if (((s32)negativeHondaX != 0) && (lasso->honda.x > 0.0f))
{
xSndPlay3D(xStrHash(&"rope\0sound_rope_windup"[5]), 0.77f, 0.0f, 0U, 0x10000U,
&lasso->anchor, 100.0f, (sound_category)0, 0.0f);
negativeHondaX = 0;
}
if (lasso->honda.x < 0.0f)
{
negativeHondaX = 1;
}
xVec3AddTo(&lasso->honda, &lasso->crCenter);
}

void nonfizzicalHonda(zLasso* lasso, f32 arg1, xVec3* arg2)
{
f32 temp_f1;

xVec3Sub(&lasso->honda, arg2, &lasso->crCenter);
xVec3AddScaled(&lasso->honda, &lasso->crNormal, -xVec3Dot(&lasso->honda, &lasso->crNormal));
temp_f1 = xVec3Length2(&lasso->honda);
if (temp_f1 < 0.00001f)
{
lasso->honda.x = lasso->crNormal.y;
lasso->honda.y = -lasso->crNormal.x;
lasso->honda.z = 0.0f;
xVec3SMulBy(&lasso->honda, lasso->crRadius / xsqrt(xVec3Length2(&lasso->honda)));
xVec3AddTo(&lasso->honda, &lasso->crCenter);
return;
}
xVec3SMulBy(&lasso->honda, lasso->crRadius / xsqrt(temp_f1));
xVec3AddTo(&lasso->honda, &lasso->crCenter);
}

void fizzicalSlack(zLasso* lasso, f32 arg1, xVec3* arg2)
{
f32 temp_f1;

lasso->crSlack += (2.0f * (lasso->lastDist - lasso->currDist)) - (0.6f * arg1);
temp_f1 = lasso->crSlack;
if (temp_f1 < 0.0f)
{
lasso->crSlack = 0.0f;
return;
}
if (temp_f1 > 1.0f)
{
lasso->crSlack = 1.0f;
}
}

void zLasso_scenePrepare()
{
sNumGuideLists = 0;
sCurrentGuide = NULL;
}
29 changes: 23 additions & 6 deletions src/SB/Game/zLasso.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@

#include "xMath3.h"
#include "xModel.h"
#include "xString.h"
#include "zEnt.h"

struct zLasso
{
U32 flags;
F32 secsTotal;
F32 secsLeft;
F32 stRadius;
F32 tgRadius;
F32 tgRadius; // 0x10
F32 crRadius;
xVec3 stCenter;
xVec3 tgCenter;
xVec3 crCenter;
xVec3 stNormal;
xVec3 stCenter; // 0x18
xVec3 tgCenter; // 0x24
xVec3 crCenter; // 0x30
xVec3 stNormal; // 0x3C
xVec3 tgNormal;
xVec3 crNormal;
xVec3 crNormal; // 0x48
xVec3 honda;
F32 stSlack;
F32 stSlackDist;
Expand All @@ -33,9 +35,24 @@ struct zLasso
xModelInstance* model;
};

struct zLassoGuide
{
xModelInstance* poly;
xAnimState* lassoAnim;
S32 vertMap[16];
};

struct zLassoGuideList // Size: 0xE0
{
xEnt* target;
U32 numGuides;
zLassoGuide guide[3];
};

void zLasso_scenePrepare();
void zLasso_InitTimer(zLasso* lasso, F32 interpTime);
void zLasso_ResetTimer(zLasso* lasso, F32 interpTime);
void zLasso_AddGuide(xEnt* ent, xAnimState* lassoAnim, xModelInstance modelInst);
void zLasso_SetGuide(xEnt* ent, xAnimState* lassoAnim);
void zLasso_InterpToGuide(zLasso* lasso);

Expand Down