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

Decompiling TWatergun #49

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions include/JSystem/J3D/J3DGraphAnimator/J3DModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ class J3DModel {
/* 0x08 */ u32 unk8;
/* 0x0C */ J3DCalcCallBack unkC;
char pad1[0x4];
/* 0x14 */ Vec unk14;
/* 0x20 */ Mtx unk20;
/* 0x14 */ Vec mBaseScale;
/* 0x20 */ Mtx mBaseMtx;
/* 0x50 */ u8* mScaleFlagArr;
/* 0x54 */ u8* mEvlpScaleFlagArr;
/* 0x58 */ Mtx* mNodeMatrices;
Expand Down
9 changes: 1 addition & 8 deletions include/Player/MarioInit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@
#define MARIOINIT_HPP

#include "System/ParamInst.hpp"

// TODO: move to a better file
#include "System/BaseParam.hpp"
class TParams {
public:
char* filename;
TBaseParam* head;
};
#include "System/Params.hpp"

// length 0x42C
class TDeParams : public TParams {
Expand Down
11 changes: 6 additions & 5 deletions include/Player/MarioMain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ struct TRidingInfo {
};

class TMarioGamePad;

class TYoshi;
class TWaterGun;
// TODO: Add fields
class TMario : public TTakeActor, public TDrawSyncCallback {
public:
Expand Down Expand Up @@ -45,7 +46,7 @@ class TMario : public TTakeActor, public TDrawSyncCallback {
void windMove(const JGeometry::TVec3<f32>&);
void flowMove(const JGeometry::TVec3<f32>&);
void warpRequest(const JGeometry::TVec3<f32>&, f32);
u32 onYoshi() const;
s32 onYoshi() const;
void throwMario(const JGeometry::TVec3<f32>&, f32);
u32 askJumpIntoWaterEffectExist() const;

Expand Down Expand Up @@ -101,18 +102,18 @@ class TMario : public TTakeActor, public TDrawSyncCallback {
s16 health; // 0x0120

u16 _122;
char _124[0x264];
char _124[0x260];

u16 blooperColor; // TODO: Make enum (0 = red, 1 = yellow, 2 = green)

char _38A[0x5A];

void* waterGun; // TWaterGun 0x3E4
TWaterGun* waterGun; // 0x3E4

u32 _3E8;
u32 _3EC;

void* yoshi; // TYoshi 0x3F0
TYoshi* yoshi; // TYoshi 0x3F0

char _3F4[0x0FC];

Expand Down
107 changes: 107 additions & 0 deletions include/Player/NozzleBase.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#ifndef NOZZLEBASE_HPP
#define NOZZLEBASE_HPP

#include <Dolphin/types.h>
#include <JSystem/JGeometry.hpp>
#include "System/ParamInst.hpp"
#include "System/Params.hpp"
#include <M3DUtil/MActor.hpp>

// struct TWaterEmitInfo : public TParams {
// TWaterEmitInfo(const char *prm);

// TParamT<s32> mNum;
// TParamT<s16> mAlive;
// TParamT<s16> mAttack;
// TParamT<JGeometry::TVec3<f32>> mDir;
// TParamT<JGeometry::TVec3<f32>> mPos;
// TParamT<JGeometry::TVec3<f32>> mV;
// TParamT<f32> mDirTremble;
// TParamT<f32> mPow;
// TParamT<f32> mPowTremble;
// TParamT<f32> mSize;
// TParamT<f32> mSizeTremble;
// TParamT<f32> mHitRadius;
// TParamT<f32> mHitHeight;
// TParamT<s32> mFlag;
// TParamT<s16> mType;

// private:
// TParamT<s16> __padding;
// };

class TWaterGun;
// class TMarioControllerWork;

class TNozzleBase {
public:
struct TEmitParams : public TParams {
TParamT<u8> mRocketType;
TParamT<f32> mNum;
TParamT<u16> mAttack;
TParamT<f32> mDirTremble;
TParamT<f32> mEmitPow;
TParamT<f32> mEmitCtrl;
TParamT<f32> mPowTremble;
TParamT<f32> mSize;
TParamT<f32> mSizeTremble;
TParamT<s32> mAmountMax;
TParamT<f32> mReactionPow;
TParamT<f32> mReactionY;
TParamT<s16> mDecRate;
TParamT<s16> mTriggerRate;
TParamT<s32> mDamageLoss;
TParamT<f32> mSuckRate;
TParamT<f32> mHitRadius;
TParamT<f32> mHitHeight;
TParamT<s16> mLAngleBase;
TParamT<s16> mLAngleNormal;
TParamT<s16> mLAngleSquat;
TParamT<s16> mLAngleMin;
TParamT<s16> mLAngleMax;
TParamT<s16> mLAngleChase;
TParamT<f32> mSizeMinPressure;
TParamT<f32> mSizeMaxPressure;
TParamT<f32> mNumMin;
TParamT<s16> mAttackMin;
TParamT<f32> mDirTrembleMin;
TParamT<f32> mEmitPowMin;
TParamT<f32> mSizeMin;
TParamT<f32> mMotorPowMin;
TParamT<f32> mMotorPowMax;
TParamT<f32> mReactionPowMin;
TParamT<f32> mInsidePressureDec;
TParamT<f32> mInsidePressureMax;
TParamT<s16> mTriggerTime;
TParamT<s16> mType;
TParamT<s16> mSideAngleMaxSide;
TParamT<s16> mSideAngleMaxFront;
TParamT<s16> mSideAngleMaxBack;
TParamT<f32> mRButtonMult;
TParamT<f32> mEmitPowScale;
} mEmitParams; // 0x0000

TNozzleBase(const char* name, const char* prm, TWaterGun* fludd);

virtual void init();
virtual s32 getNozzleKind() const;
virtual s16 getGunAngle();
virtual s16 getWaistAngle();
virtual void movement(const void*);
virtual void emitCommon(int, u32* /* WaterEmitInfo*/);
virtual void emit(int);
virtual void animation(int);

void calcGunAngle(const void*);

TWaterGun* mFludd; // 0x0368
u16 mAnimState;
s16 mGunAngle;
s16 mWaistAngle;
f32 _374;
f32 _378;
f32 _37C;
MActor* mActor;
}; // 0x384

#endif
29 changes: 29 additions & 0 deletions include/Player/NozzleTrigger.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef NOZZLETRIGGER_HPP
#define NOZZLETRIGGER_HPP

#include <Dolphin/types.h>
#include <Player/NozzleBase.hpp>

class TNozzleTrigger : public TNozzleBase {
public:
// Add constructor
TNozzleTrigger(const char* name, const char* prm, TWaterGun* fludd)
: TNozzleBase(name, prm, fludd)
{
mRunbleOnCharge = false;
mSprayState = INACTIVE;
mSprayQuarterFramesLeft = 0;
mTriggerFill = 0.0f;
mSoundID = 0;
}

enum SPRAYSTATE { INACTIVE, ACTIVE, DEAD };

bool mRunbleOnCharge; // 0x0384
u8 mSprayState; // 0x0385
s16 mSprayQuarterFramesLeft; // 0x0386
f32 mTriggerFill; // 0x0388
u32 mSoundID; // 0x038C
};

#endif
181 changes: 181 additions & 0 deletions include/Player/WaterGun.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
#ifndef WATERGUN_HPP
#define WATERGUN_HPP

#include <JSystem/JGeometry.hpp>
#include <JSystem/JDrama/JDRGraphics.hpp>
#include <Player/NozzleBase.hpp>
#include <Player/NozzleTrigger.hpp>
#include <JSystem/J3D/J3DGraphAnimator/J3DModel.hpp>
#include <Player/Yoshi.hpp>
#include <Player/MarioMain.hpp>

struct NozzleJointData {
u8 flags; // TODO: This is likely an enum. 0x1 is used, 0x4 is disabled.
u8 jointIndex;
};

struct NozzleData {
/* 0x00 */ u32 _00; // Number of water streams emitted by this nozzle
/* 0x04 */ u32 _04; // Unused padding
/* 0x08 */ const char* mHelmetPath; // Path to optional helmet model (used
// by underwater nozzle)
/* 0x0C */ const char* mPath; // Path to base nozzle model directory
/* 0x10 */ const char* mBmdPath; // Full path to nozzle's BMD model file
/* 0x14 */ u8 mNumEmitters; // Number of water emitter points on the nozzle
/* 0x15 */ u8 _15; // Unknown/padding
/* 0x16 */ NozzleJointData mJoints[3]; // Array of joint data for the nozzle
};

// Data structure containing model paths and configuration for each FLUDD nozzle
// type
class TNozzleBmdData {
public:
u8 getEmitterCount(int index) const { return mNozzles[index].mNumEmitters; }

u8 getFlags(int index, int jointIndex) const
{
return mNozzles[index].mJoints[jointIndex].flags;
}

u8 getJointIndex(int index, int jointIndex) const
{
return mNozzles[index].mJoints[jointIndex].jointIndex;
}

NozzleData mNozzles[6];
};
// Define the global variable in .data section
extern const TNozzleBmdData nozzleBmdData;

class TWaterGun {
public:
typedef u8 TNozzleType;
enum { Spray = 0, Rocket, Underwater, Yoshi, Hover, Turbo };

TWaterGun(TMario* mario);

virtual void perform(u32, JDrama::TGraphics*);

void calcAnimation(JDrama::TGraphics*);
void changeBackup();
void changeNozzle(TNozzleType, bool);
bool damage();
void emit();
TNozzleBase* getCurrentNozzle() const
{
return this->mNozzleList[this->mCurrentNozzle];
}
MtxPtr getEmitMtx(int);
void getEmitPosDirSpeed(int, JGeometry::TVec3<f32>* pos,
JGeometry::TVec3<f32>* dir,
JGeometry::TVec3<f32>* speed);
MtxPtr getNozzleMtx();
f32 getPressure();
f32 getPressureMax();
void init();
void initInLoadAfter();
bool isEmitting();
bool isPressureOn();
void movement();
void rotateProp(f32);
void setAmountToRate(f32);
void setBaseTRMtx(Mtx);
bool suck();
void startDashEffect();
void endDashEffect();
void getMarioUpperStatus();

inline MtxPtr getYoshiMtx()
{
TYoshi* yoshi = (TYoshi*)this->mMario->yoshi;
return yoshi->mActor->unk4->getAnmMtx(yoshi->mJoint);
}

inline MtxPtr getWillBeEmitted(int jointIndex)
{

// This entire block is likely an inlined function.
u8 currentNozzle = this->mCurrentNozzle;
s8 flag = nozzleBmdData.getFlags(currentNozzle, jointIndex);
if (flag < 3) {
return this->getCurrentNozzle()->mActor->unk4->getAnmMtx(
nozzleBmdData.getJointIndex(this->mCurrentNozzle, jointIndex));
} else if (flag == 3) {
return getYoshiMtx();
}
}

void decWater() { }

bool hasWater() const { return this->mCurrentWater > 0; }

u32 getWaterGunAnmId();

J3DModel* getModel() { return this->mFluddModel->unk4; }

void setEmitPt();

void finalDrawInitialize();
void entryAll();
void createGunBody();

// void triggerPressureMovement(const TMarioControllerWork &);

u16 mFlags; // 0x0000
TMario* mMario; // 0x0008
TNozzleBase mNozzleDeform; // 0x000C
TNozzleTrigger mNozzleDeformBomb; // 0x0390
TNozzleTrigger mNozzleRocket; // 0x0720
TNozzleBase mNozzleUnderWater; // 0x0AB0
TNozzleBase mNozzleYoshiDeform; // 0x0E34
TNozzleTrigger mNozzleYoshiDeformBomb; // 0x11B8
TNozzleTrigger mNozzleHover; // 0x1548
TNozzleTrigger mNozzleTurbo; // 0x18D8
TNozzleBase* mNozzleList[6]; // 0x1C68
s32 mCurrentWater; // 0x1C80
u8 mCurrentNozzle; // 0x1C84
u8 mSecondNozzle; // 0x1C85
bool mIsEmitWater; // 0x1C86
u8 _13; // 0x1C87
u32 _14; // 0x1C88
u8 mCurrentPressure; // 0x1c8c
u8 mPreviousPressure; // 0x1c8d
u8 _16; // 0x1c8e
u8 _17; // 0x1c8f
JGeometry::TVec3<f32> mEmitPos[4]; // 0x1C90
s16 _24; // 0x1CC0
s16 _1cc2; // 0x1CC2
s16 _1cc4; // 0x1CC4
s16 _1cc6; // 0x1CC6
f32 mNozzleSpeedY; // 0x1CC8
f32 mNozzleSpeedZ; // 0x1CCC
s16 _1cd0; // 0x1CD0
s16 _1cd2; // 0x1CD2
MActor* mFluddModel; // 0x1CD4 // MActor*
u8 mCurFluddTransformIdx; // 0x1CD8
u8 _27; // 0x1CD9
u16 _28; // 0x1CDA
f32 _25; // 0x1CDC
f32 _26; // 0x1CE0
JGeometry::TVec3<f32> mGeometry3; // 0x1CE4
JGeometry::TVec3<f32> mGeometry4; // 0x1CF0
f32 _1cfc; // 0x1CFC
f32 _1d00; // 0x1D00
f32 _1d04; // 0x1D04
u32 _18; // 0x1D08
u32 mEmitInfo; // 0x1D0C // TWaterEmitInfo
u32 _19; // 0x1D10

struct TWatergunParams : public TParams {
TParamT<f32> mRocketHeight;
TParamT<f32> mHoverHeight;
TParamT<f32> mLAngleNormal;
TParamT<f32> mNozzleAngleYSpeed;
TParamT<f32> mNozzleAngleYBrake;
TParamT<f32> mNozzleAngleYSpeedMax;
TParamT<s16> mHoverRotMax;
TParamT<f32> mChangeSpeed;
} mWatergunParams; // 0x1d14
};

#endif
Loading