diff --git a/asm/MetroidPrime/BodyState/CBSAttack.s b/asm/MetroidPrime/BodyState/CBSAttack.s index bbf62f7b..a6d38274 100644 --- a/asm/MetroidPrime/BodyState/CBSAttack.s +++ b/asm/MetroidPrime/BodyState/CBSAttack.s @@ -3,8 +3,8 @@ .section .data .balign 8 -.global lbl_803E1370 -lbl_803E1370: +.global __vt__9CBSAttack +__vt__9CBSAttack: # ROM: 0x3DE370 .4byte 0 .4byte 0 @@ -44,14 +44,14 @@ __dt__9CBSAttackFv: /* 80134DE0 00131D40 93 E1 00 0C */ stw r31, 0xc(r1) /* 80134DE4 00131D44 7C 7F 1B 79 */ or. r31, r3, r3 /* 80134DE8 00131D48 41 82 00 5C */ beq lbl_80134E44 -/* 80134DEC 00131D4C 3C 60 80 3E */ lis r3, lbl_803E1370@ha +/* 80134DEC 00131D4C 3C 60 80 3E */ lis r3, __vt__9CBSAttack@ha /* 80134DF0 00131D50 34 1F 00 08 */ addic. r0, r31, 8 -/* 80134DF4 00131D54 38 03 13 70 */ addi r0, r3, lbl_803E1370@l +/* 80134DF4 00131D54 38 03 13 70 */ addi r0, r3, __vt__9CBSAttack@l /* 80134DF8 00131D58 90 1F 00 00 */ stw r0, 0(r31) /* 80134DFC 00131D5C 41 82 00 24 */ beq lbl_80134E20 -/* 80134E00 00131D60 3C 60 80 3E */ lis r3, lbl_803DAA08@ha +/* 80134E00 00131D60 3C 60 80 3E */ lis r3, __vt__11CBCSlideCmd@ha /* 80134E04 00131D64 34 1F 00 08 */ addic. r0, r31, 8 -/* 80134E08 00131D68 38 03 AA 08 */ addi r0, r3, lbl_803DAA08@l +/* 80134E08 00131D68 38 03 AA 08 */ addi r0, r3, __vt__11CBCSlideCmd@l /* 80134E0C 00131D6C 90 1F 00 08 */ stw r0, 8(r31) /* 80134E10 00131D70 41 82 00 10 */ beq lbl_80134E20 /* 80134E14 00131D74 3C 60 80 3E */ lis r3, __vt__13CBodyStateCmd@ha @@ -597,16 +597,16 @@ __ct__9CBSAttackFv: /* 8013559C 001324FC 94 21 FF E0 */ stwu r1, -0x20(r1) /* 801355A0 00132500 38 05 13 18 */ addi r0, r5, __vt__10CBodyState@l /* 801355A4 00132504 3C C0 80 5A */ lis r6, sZeroVector__9CVector3f@ha -/* 801355A8 00132508 3C 80 80 3E */ lis r4, lbl_803E1370@ha +/* 801355A8 00132508 3C 80 80 3E */ lis r4, __vt__9CBSAttack@ha /* 801355AC 0013250C 90 03 00 00 */ stw r0, 0(r3) -/* 801355B0 00132510 38 04 13 70 */ addi r0, r4, lbl_803E1370@l +/* 801355B0 00132510 38 04 13 70 */ addi r0, r4, __vt__9CBSAttack@l /* 801355B4 00132514 39 40 FF FF */ li r10, -1 /* 801355B8 00132518 90 03 00 00 */ stw r0, 0(r3) -/* 801355BC 0013251C 3C 80 80 3E */ lis r4, lbl_803DAA08@ha +/* 801355BC 0013251C 3C 80 80 3E */ lis r4, __vt__11CBCSlideCmd@ha /* 801355C0 00132520 39 26 66 A0 */ addi r9, r6, sZeroVector__9CVector3f@l /* 801355C4 00132524 3C A0 80 3E */ lis r5, __vt__13CBodyStateCmd@ha /* 801355C8 00132528 91 43 00 04 */ stw r10, 4(r3) -/* 801355CC 0013252C 38 04 AA 08 */ addi r0, r4, lbl_803DAA08@l +/* 801355CC 0013252C 38 04 AA 08 */ addi r0, r4, __vt__11CBCSlideCmd@l /* 801355D0 00132530 38 C5 AA 68 */ addi r6, r5, __vt__13CBodyStateCmd@l /* 801355D4 00132534 38 A0 00 11 */ li r5, 0x11 /* 801355D8 00132538 81 09 00 00 */ lwz r8, 0(r9) diff --git a/asm/MetroidPrime/BodyState/CBodyStateCmdMgr.s b/asm/MetroidPrime/BodyState/CBodyStateCmdMgr.s index 39fd05c4..e8cbbf0e 100644 --- a/asm/MetroidPrime/BodyState/CBodyStateCmdMgr.s +++ b/asm/MetroidPrime/BodyState/CBodyStateCmdMgr.s @@ -429,9 +429,9 @@ lbl_80131994: lbl_801319BC: /* 801319BC 0012E91C 34 1F 01 F8 */ addic. r0, r31, 0x1f8 /* 801319C0 0012E920 41 82 00 24 */ beq lbl_801319E4 -/* 801319C4 0012E924 3C 60 80 3E */ lis r3, lbl_803DAA08@ha +/* 801319C4 0012E924 3C 60 80 3E */ lis r3, __vt__11CBCSlideCmd@ha /* 801319C8 0012E928 34 1F 01 F8 */ addic. r0, r31, 0x1f8 -/* 801319CC 0012E92C 38 03 AA 08 */ addi r0, r3, lbl_803DAA08@l +/* 801319CC 0012E92C 38 03 AA 08 */ addi r0, r3, __vt__11CBCSlideCmd@l /* 801319D0 0012E930 90 1F 01 F8 */ stw r0, 0x1f8(r31) /* 801319D4 0012E934 41 82 00 10 */ beq lbl_801319E4 /* 801319D8 0012E938 3C 60 80 3E */ lis r3, __vt__13CBodyStateCmd@ha @@ -847,7 +847,7 @@ lbl_80131DA8: /* 80131FB4 0012EF14 C0 04 00 00 */ lfs f0, 0(r4) /* 80131FB8 0012EF18 3E 20 80 3E */ lis r17, lbl_803DAA5C@ha /* 80131FBC 0012EF1C 3E 00 80 3E */ lis r16, lbl_803DA9FC@ha -/* 80131FC0 0012EF20 3D E0 80 3E */ lis r15, lbl_803DAA08@ha +/* 80131FC0 0012EF20 3D E0 80 3E */ lis r15, __vt__11CBCSlideCmd@ha /* 80131FC4 0012EF24 D0 1A 00 0C */ stfs f0, 0xc(r26) /* 80131FC8 0012EF28 3B 23 01 AC */ addi r25, r3, 0x1ac /* 80131FCC 0012EF2C 38 00 00 0F */ li r0, 0xf @@ -859,7 +859,7 @@ lbl_80131DA8: /* 80131FE4 0012EF44 D0 1A 00 10 */ stfs f0, 0x10(r26) /* 80131FE8 0012EF48 3A E3 01 F8 */ addi r23, r3, 0x1f8 /* 80131FEC 0012EF4C 3A 00 00 11 */ li r16, 0x11 -/* 80131FF0 0012EF50 39 EF AA 08 */ addi r15, r15, lbl_803DAA08@l +/* 80131FF0 0012EF50 39 EF AA 08 */ addi r15, r15, __vt__11CBCSlideCmd@l /* 80131FF4 0012EF54 C0 0E 00 08 */ lfs f0, 8(r14) /* 80131FF8 0012EF58 D0 1A 00 14 */ stfs f0, 0x14(r26) /* 80131FFC 0012EF5C 90 BA 00 18 */ stw r5, 0x18(r26) diff --git a/asm/MetroidPrime/Enemies/CBeetle.s b/asm/MetroidPrime/Enemies/CBeetle.s index b81da300..9d366d16 100644 --- a/asm/MetroidPrime/Enemies/CBeetle.s +++ b/asm/MetroidPrime/Enemies/CBeetle.s @@ -2990,13 +2990,13 @@ lbl_800E53DC: /* 800E5408 000E2368 C0 3E 00 48 */ lfs f1, 0x48(r30) /* 800E540C 000E236C 38 E3 AA 68 */ addi r7, r3, __vt__13CBodyStateCmd@l /* 800E5410 000E2370 C0 1E 00 58 */ lfs f0, 0x58(r30) -/* 800E5414 000E2374 3C 80 80 3E */ lis r4, lbl_803DAA08@ha +/* 800E5414 000E2374 3C 80 80 3E */ lis r4, __vt__11CBCSlideCmd@ha /* 800E5418 000E2378 D0 41 00 08 */ stfs f2, 8(r1) /* 800E541C 000E237C 38 C0 00 11 */ li r6, 0x11 /* 800E5420 000E2380 80 7E 04 50 */ lwz r3, 0x450(r30) /* 800E5424 000E2384 38 00 00 00 */ li r0, 0 /* 800E5428 000E2388 D0 21 00 0C */ stfs f1, 0xc(r1) -/* 800E542C 000E238C 38 A4 AA 08 */ addi r5, r4, lbl_803DAA08@l +/* 800E542C 000E238C 38 A4 AA 08 */ addi r5, r4, __vt__11CBCSlideCmd@l /* 800E5430 000E2390 81 41 00 08 */ lwz r10, 8(r1) /* 800E5434 000E2394 3B E3 00 04 */ addi r31, r3, 4 /* 800E5438 000E2398 D0 01 00 10 */ stfs f0, 0x10(r1) @@ -3019,8 +3019,8 @@ lbl_800E53DC: /* 800E547C 000E23DC D0 01 00 34 */ stfs f0, 0x34(r1) /* 800E5480 000E23E0 48 04 BF B9 */ bl DeliverCmd__16CBodyStateCmdMgrF13EBodyStateCmd /* 800E5484 000E23E4 80 01 00 24 */ lwz r0, 0x24(r1) -/* 800E5488 000E23E8 3C 60 80 3E */ lis r3, lbl_803DAA08@ha -/* 800E548C 000E23EC 38 83 AA 08 */ addi r4, r3, lbl_803DAA08@l +/* 800E5488 000E23E8 3C 60 80 3E */ lis r3, __vt__11CBCSlideCmd@ha +/* 800E548C 000E23EC 38 83 AA 08 */ addi r4, r3, __vt__11CBCSlideCmd@l /* 800E5490 000E23F0 3C 60 80 3E */ lis r3, __vt__13CBodyStateCmd@ha /* 800E5494 000E23F4 90 1F 01 FC */ stw r0, 0x1fc(r31) /* 800E5498 000E23F8 38 63 AA 68 */ addi r3, r3, __vt__13CBodyStateCmd@l diff --git a/asm/MetroidPrime/Enemies/CPatterned.s b/asm/MetroidPrime/Enemies/CPatterned.s index aef69e4c..e6c8ddb6 100644 --- a/asm/MetroidPrime/Enemies/CPatterned.s +++ b/asm/MetroidPrime/Enemies/CPatterned.s @@ -315,8 +315,8 @@ lbl_803DA9FC: .4byte 0 .4byte __dt__10CBCJumpCmd -.global lbl_803DAA08 -lbl_803DAA08: +.global __vt__11CBCSlideCmd +__vt__11CBCSlideCmd: # ROM: 0x3D7A08 .4byte 0 .4byte 0 @@ -5858,8 +5858,8 @@ __dt__11CBCSlideCmd: /* 8007BEA4 00078E04 93 E1 00 0C */ stw r31, 0xc(r1) /* 8007BEA8 00078E08 7C 7F 1B 79 */ or. r31, r3, r3 /* 8007BEAC 00078E0C 41 82 00 30 */ beq lbl_8007BEDC -/* 8007BEB0 00078E10 3C 60 80 3E */ lis r3, lbl_803DAA08@ha -/* 8007BEB4 00078E14 38 03 AA 08 */ addi r0, r3, lbl_803DAA08@l +/* 8007BEB0 00078E10 3C 60 80 3E */ lis r3, __vt__11CBCSlideCmd@ha +/* 8007BEB4 00078E14 38 03 AA 08 */ addi r0, r3, __vt__11CBCSlideCmd@l /* 8007BEB8 00078E18 90 1F 00 00 */ stw r0, 0(r31) /* 8007BEBC 00078E1C 41 82 00 10 */ beq lbl_8007BECC /* 8007BEC0 00078E20 3C 60 80 3E */ lis r3, __vt__13CBodyStateCmd@ha diff --git a/configure.py b/configure.py index c5cc1a81..d3030a1b 100755 --- a/configure.py +++ b/configure.py @@ -184,7 +184,7 @@ LIBS = [ "MetroidPrime/Enemies/CFlickerBat", "MetroidPrime/BodyState/CBodyStateCmdMgr", ["MetroidPrime/BodyState/CBodyStateInfo", False], - "MetroidPrime/BodyState/CBSAttack", + ["MetroidPrime/BodyState/CBSAttack", False], ["MetroidPrime/BodyState/CBSDie", True], ["MetroidPrime/BodyState/CBSFall", False], ["MetroidPrime/BodyState/CBSGetup", True], diff --git a/include/MetroidPrime/ActorCommon.hpp b/include/MetroidPrime/ActorCommon.hpp new file mode 100644 index 00000000..f7516dc5 --- /dev/null +++ b/include/MetroidPrime/ActorCommon.hpp @@ -0,0 +1,159 @@ +#ifndef _ACTORCOMMON +#define _ACTORCOMMON + +enum EWeaponCollisionResponseTypes { + kWCR_None, + kWCR_Default, + kWCR_Unknown2, + kWCR_Metal, + kWCR_Grass, + kWCR_Ice, + kWCR_Goo, + kWCR_Wood, + kWCR_Water, + kWCR_Mud, + kWCR_Lava, + kWCR_Sand, + kWCR_Projectile, + kWCR_OtherProjectile, + kWCR_Unknown14, + kWCR_Unknown15, + kWCR_EnemyNormal, + kWCR_EnemySpecial, + kWCR_EnemyShielded, + kWCR_Unknown19, + kWCR_Unknown20, + kWCR_Unknown21, + kWCR_Unknown22, + kWCR_Unknown23, + kWCR_Unknown24, + kWCR_Unknown25, + kWCR_Unknown26, + kWCR_Unknown27, + kWCR_Unknown28, + kWCR_Unknown29, + kWCR_Unknown30, + kWCR_Unknown31, + kWCR_Unknown32, + kWCR_Unknown33, + kWCR_Unknown34, + kWCR_Unknown35, + kWCR_Unknown36, + kWCR_Unknown37, + kWCR_ChozoGhost, + kWCR_Unknown39, + kWCR_Unknown40, + kWCR_Unknown41, + kWCR_AtomicBeta, + kWCR_AtomicAlpha, + kWCR_Unknown44, + kWCR_Unknown45, + kWCR_Unknown46, + kWCR_Unknown47, + kWCR_Unknown48, + kWCR_Unknown49, + kWCR_Unknown50, + kWCR_Unknown51, + kWCR_Unknown52, + kWCR_Unknown53, + kWCR_Unknown54, + kWCR_Unknown55, + kWCR_Unknown56, + kWCR_Unknown57, + kWCR_Unknown58, + kWCR_Unknown59, + kWCR_Unknown60, + kWCR_Unknown61, + kWCR_Unknown62, + kWCR_Unknown63, + kWCR_Unknown64, + kWCR_Unknown65, + kWCR_Unknown66, + kWCR_Unknown67, + kWCR_Unknown68, + kWCR_Unknown69, + kWCR_Unknown70, + kWCR_Unknown71, + kWCR_Unknown72, + kWCR_Unknown73, + kWCR_Unknown74, + kWCR_Unknown75, + kWCR_Unknown76, + kWCR_Unknown77, + kWCR_Unknown78, + kWCR_Unknown79, + kWCR_Unknown80, + kWCR_Unknown81, + kWCR_Unknown82, + kWCR_Unknown83, + kWCR_Unknown84, + kWCR_Unknown85, + kWCR_Unknown86, + kWCR_Unknown87, + kWCR_Unknown88, + kWCR_Unknown89, + kWCR_Unknown90, + kWCR_Unknown91, + kWCR_AtomicBetaReflect, + kWCR_AtomicAlphaReflect, +}; +enum EProjectileAttrib { + kPA_None = 0, + kPA_PartialCharge = (1 << 0), + kPA_PlasmaProjectile = (1 << 1), + kPA_Charged = (1 << 2), + kPA_Ice = (1 << 3), + kPA_Wave = (1 << 4), + kPA_Plasma = (1 << 5), + kPA_Phazon = (1 << 6), + kPA_ComboShot = (1 << 7), + kPA_Bombs = (1 << 8), + kPA_PowerBombs = (1 << 9), + kPA_BigProjectile = (1 << 10), + kPA_ArmCannon = (1 << 11), + kPA_BigStrike = (1 << 12), + kPA_DamageFalloff = (1 << 13), + kPA_StaticInterference = (1 << 14), + kPA_PlayerUnFreeze = (1 << 15), + kPA_ParticleOPTS = (1 << 16), + kPA_KeepInCinematic = (1 << 17), +}; +enum EUserEventType { + kUE_Projectile = 0, + kUE_EggLay = 1, + kUE_LoopedSoundStop = 2, + kUE_AlignTargetPos = 3, + kUE_AlignTargetRot = 4, + kUE_ChangeMaterial = 5, + kUE_Delete = 6, + kUE_GenerateEnd = 7, + kUE_DamageOn = 8, + kUE_DamageOff = 9, + kUE_AlignTargetPosStart = 10, + kUE_DeGenerate = 11, + kUE_Landing = 12, + kUE_TakeOff = 13, + kUE_FadeIn = 14, + kUE_FadeOut = 15, + kUE_ScreenShake = 16, + kUE_BeginAction = 17, + kUE_EndAction = 18, + kUE_BecomeRagDoll = 19, + kUE_IkLock = 20, + kUE_IkRelease = 21, + kUE_BreakLockOn = 22, + kUE_BecomeShootThrough = 23, + kUE_RemoveCollision = 24, + kUE_ObjectPickUp = 25, + kUE_ObjectDrop = 26, + kUE_EventStart = 27, + kUE_EventStop = 28, + kUE_Activate = 29, + kUE_Deactivate = 30, + kUE_SoundPlay = 31, + kUE_SoundStop = 32, + kUE_EffectOn = 33, + kUE_EffectOff = 34, +}; + +#endif // _ACTORCOMMON diff --git a/include/MetroidPrime/BodyState/CBSAttack.hpp b/include/MetroidPrime/BodyState/CBSAttack.hpp new file mode 100644 index 00000000..fdadd6b0 --- /dev/null +++ b/include/MetroidPrime/BodyState/CBSAttack.hpp @@ -0,0 +1,31 @@ +#ifndef _CBSATTACK +#define _CBSATTACK + +#include "MetroidPrime/BodyState/CBodyState.hpp" + +#include "MetroidPrime/BodyState/CBodyStateCmdMgr.hpp" + +#include "Kyoto/Math/CVector3f.hpp" + +class CBSAttack : public CBodyState { +public: + CBSAttack(); + + bool CanShoot() const override { return false; } + void Start(CBodyController& bc, CStateManager& mgr) override; + pas::EAnimationState UpdateBody(float dt, CBodyController& bc, CStateManager& mgr) override; + void Shutdown(CBodyController&) override; + +private: + pas::EAnimationState x4_nextState; // = pas::kAS_Invalid; + CBCSlideCmd x8_slide; + CVector3f x20_targetPos; + float x2c_alignTargetPosStartTime; // = -1.f; + float x30_alignTargetPosTime; // = -1.f; + float x34_curTime; // = 0.f; + + pas::EAnimationState GetBodyStateTransition(float dt, CBodyController& bc); + void UpdatePhysicsActor(CBodyController& bc, float dt); +}; + +#endif // _CBSATTACK diff --git a/include/MetroidPrime/BodyState/CBodyStateCmdMgr.hpp b/include/MetroidPrime/BodyState/CBodyStateCmdMgr.hpp index 2fe778d1..6c95cdd5 100644 --- a/include/MetroidPrime/BodyState/CBodyStateCmdMgr.hpp +++ b/include/MetroidPrime/BodyState/CBodyStateCmdMgr.hpp @@ -6,8 +6,9 @@ #include "MetroidPrime/TGameTypes.hpp" #include "Kyoto/Animation/CharacterCommon.hpp" -#include "Kyoto/Math/CVector3f.hpp" #include "Kyoto/Math/CUnitVector3f.hpp" +#include "Kyoto/Math/CVector3f.hpp" + enum ESteeringBlendMode { kSBM_Normal, @@ -151,9 +152,14 @@ private: class CBCSlideCmd : public CBodyStateCmd { public: + explicit CBCSlideCmd() + : CBodyStateCmd(kBSC_Slide), x8_type(pas::kSlide_Invalid), xc_dir(CVector3f::Zero()) {} + CBCSlideCmd(pas::ESlideType type, const CVector3f& dir) : CBodyStateCmd(kBSC_Slide), x8_type(type), xc_dir(dir) {} + ~CBCSlideCmd() override {} + pas::ESlideType GetSlideType() const { return x8_type; } const CVector3f& GetSlideDirection() const { return xc_dir; } @@ -394,7 +400,7 @@ public: void DeliverCmd(const CBCLocomotionCmd& cmd); void DeliverCmd(EBodyStateCmd cmd); - void DeliverCmd(const CBodyStateCmd& cmd); + void DeliverCmd(const CBodyStateCmd& cmd) {} void DeliverCmd(const CBCGenerateCmd& cmd) { DeliverCmd(kBSC_Generate); @@ -408,6 +414,10 @@ public: DeliverCmd(kBSC_Scripted); x21c_scripted = cmd; } + void DeliverCmd(const CBCSlideCmd& cmd) { + DeliverCmd(cmd.GetCommandId()); + x1f8_slide = cmd; + } void DeliverTargetVector(const CVector3f& t) { x18_target = t; } diff --git a/include/MetroidPrime/CActor.hpp b/include/MetroidPrime/CActor.hpp index 28608806..96ed31ed 100644 --- a/include/MetroidPrime/CActor.hpp +++ b/include/MetroidPrime/CActor.hpp @@ -8,6 +8,7 @@ #include "MetroidPrime/CEntity.hpp" #include "MetroidPrime/CModelData.hpp" +#include "MetroidPrime/ActorCommon.hpp" #include "Kyoto/Audio/CSfxHandle.hpp" #include "Kyoto/Graphics/CColor.hpp" @@ -34,161 +35,6 @@ class CScriptWater; class CWeaponMode; class CInt32POINode; -enum EWeaponCollisionResponseTypes { - kWCR_None, - kWCR_Default, - kWCR_Unknown2, - kWCR_Metal, - kWCR_Grass, - kWCR_Ice, - kWCR_Goo, - kWCR_Wood, - kWCR_Water, - kWCR_Mud, - kWCR_Lava, - kWCR_Sand, - kWCR_Projectile, - kWCR_OtherProjectile, - kWCR_Unknown14, - kWCR_Unknown15, - kWCR_EnemyNormal, - kWCR_EnemySpecial, - kWCR_EnemyShielded, - kWCR_Unknown19, - kWCR_Unknown20, - kWCR_Unknown21, - kWCR_Unknown22, - kWCR_Unknown23, - kWCR_Unknown24, - kWCR_Unknown25, - kWCR_Unknown26, - kWCR_Unknown27, - kWCR_Unknown28, - kWCR_Unknown29, - kWCR_Unknown30, - kWCR_Unknown31, - kWCR_Unknown32, - kWCR_Unknown33, - kWCR_Unknown34, - kWCR_Unknown35, - kWCR_Unknown36, - kWCR_Unknown37, - kWCR_ChozoGhost, - kWCR_Unknown39, - kWCR_Unknown40, - kWCR_Unknown41, - kWCR_AtomicBeta, - kWCR_AtomicAlpha, - kWCR_Unknown44, - kWCR_Unknown45, - kWCR_Unknown46, - kWCR_Unknown47, - kWCR_Unknown48, - kWCR_Unknown49, - kWCR_Unknown50, - kWCR_Unknown51, - kWCR_Unknown52, - kWCR_Unknown53, - kWCR_Unknown54, - kWCR_Unknown55, - kWCR_Unknown56, - kWCR_Unknown57, - kWCR_Unknown58, - kWCR_Unknown59, - kWCR_Unknown60, - kWCR_Unknown61, - kWCR_Unknown62, - kWCR_Unknown63, - kWCR_Unknown64, - kWCR_Unknown65, - kWCR_Unknown66, - kWCR_Unknown67, - kWCR_Unknown68, - kWCR_Unknown69, - kWCR_Unknown70, - kWCR_Unknown71, - kWCR_Unknown72, - kWCR_Unknown73, - kWCR_Unknown74, - kWCR_Unknown75, - kWCR_Unknown76, - kWCR_Unknown77, - kWCR_Unknown78, - kWCR_Unknown79, - kWCR_Unknown80, - kWCR_Unknown81, - kWCR_Unknown82, - kWCR_Unknown83, - kWCR_Unknown84, - kWCR_Unknown85, - kWCR_Unknown86, - kWCR_Unknown87, - kWCR_Unknown88, - kWCR_Unknown89, - kWCR_Unknown90, - kWCR_Unknown91, - kWCR_AtomicBetaReflect, - kWCR_AtomicAlphaReflect, -}; -enum EProjectileAttrib { - kPA_None = 0, - kPA_PartialCharge = (1 << 0), - kPA_PlasmaProjectile = (1 << 1), - kPA_Charged = (1 << 2), - kPA_Ice = (1 << 3), - kPA_Wave = (1 << 4), - kPA_Plasma = (1 << 5), - kPA_Phazon = (1 << 6), - kPA_ComboShot = (1 << 7), - kPA_Bombs = (1 << 8), - kPA_PowerBombs = (1 << 9), - kPA_BigProjectile = (1 << 10), - kPA_ArmCannon = (1 << 11), - kPA_BigStrike = (1 << 12), - kPA_DamageFalloff = (1 << 13), - kPA_StaticInterference = (1 << 14), - kPA_PlayerUnFreeze = (1 << 15), - kPA_ParticleOPTS = (1 << 16), - kPA_KeepInCinematic = (1 << 17), -}; -enum EUserEventType { - kUE_Projectile = 0, - kUE_EggLay = 1, - kUE_LoopedSoundStop = 2, - kUE_AlignTargetPos = 3, - kUE_AlignTargetRot = 4, - kUE_ChangeMaterial = 5, - kUE_Delete = 6, - kUE_GenerateEnd = 7, - kUE_DamageOn = 8, - kUE_DamageOff = 9, - kUE_AlignTargetPosStart = 10, - kUE_DeGenerate = 11, - kUE_Landing = 12, - kUE_TakeOff = 13, - kUE_FadeIn = 14, - kUE_FadeOut = 15, - kUE_ScreenShake = 16, - kUE_BeginAction = 17, - kUE_EndAction = 18, - kUE_BecomeRagDoll = 19, - kUE_IkLock = 20, - kUE_IkRelease = 21, - kUE_BreakLockOn = 22, - kUE_BecomeShootThrough = 23, - kUE_RemoveCollision = 24, - kUE_ObjectPickUp = 25, - kUE_ObjectDrop = 26, - kUE_EventStart = 27, - kUE_EventStop = 28, - kUE_Activate = 29, - kUE_Deactivate = 30, - kUE_SoundPlay = 31, - kUE_SoundStop = 32, - kUE_EffectOn = 33, - kUE_EffectOff = 34, -}; - class CActor : public CEntity { public: enum EThermalFlags { diff --git a/include/MetroidPrime/CAnimData.hpp b/include/MetroidPrime/CAnimData.hpp index 635e4bd3..c1d50ee9 100644 --- a/include/MetroidPrime/CAnimData.hpp +++ b/include/MetroidPrime/CAnimData.hpp @@ -3,8 +3,10 @@ #include "types.h" +#include "MetroidPrime/ActorCommon.hpp" #include "MetroidPrime/CAdditiveAnimPlayback.hpp" #include "MetroidPrime/CAnimPlaybackParms.hpp" +#include "MetroidPrime/CCharAnimTime.hpp" #include "MetroidPrime/CCharacterInfo.hpp" #include "MetroidPrime/CHierarchyPoseBuilder.hpp" #include "MetroidPrime/CPOINode.hpp" @@ -37,6 +39,7 @@ public: x220_25_loop = v; x220_24_animating = true; } + void SetIsAnimating(bool v) { x220_24_animating = v; } void SetParticleEffectState(const rstl::string& name, bool active, CStateManager& mgr); @@ -98,7 +101,7 @@ public: // SetRandomPlaybackRate__9CAnimDataFR9CRandom16 void SetPlaybackRate(float set); void MultiplyPlaybackRate(float scale); - // GetTimeOfUserEvent__9CAnimDataCF14EUserEventTypeRC13CCharAnimTime + CCharAnimTime GetTimeOfUserEvent(EUserEventType type, const CCharAnimTime& time) const; // GetAdvancementDeltas__9CAnimDataCFRC13CCharAnimTimeRC13CCharAnimTime // Touch__9CAnimDataCFRC13CSkinnedModeli // InitializeEffects__9CAnimDataFR13CStateManagerRC9CVector3f @@ -107,7 +110,7 @@ public: void AddAdditiveAnimation(uint idx, float weight, bool active, bool fadeOut); void DelAdditiveAnimation(uint idx); bool IsAdditiveAnimation(uint idx) const; - const rstl::rc_ptr& GetAdditiveAnimationTree(uint idx) const; + const rstl::rc_ptr< CAnimTreeNode >& GetAdditiveAnimationTree(uint idx) const; // GetAnimationTree__9CAnimDataCFv // AnimationTree__9CAnimDataFv // IsAdditiveAnimation__9CAnimDataCFUi diff --git a/include/MetroidPrime/CCharAnimTime.hpp b/include/MetroidPrime/CCharAnimTime.hpp index bad42510..4f374c5b 100644 --- a/include/MetroidPrime/CCharAnimTime.hpp +++ b/include/MetroidPrime/CCharAnimTime.hpp @@ -14,8 +14,13 @@ public: }; float GetSeconds() const { return x0_time; } + explicit CCharAnimTime(EType type, float time) : x0_time(time), x4_type(type) {} CCharAnimTime(const CCharAnimTime& other) : x0_time(other.x0_time), x4_type(other.x4_type) {} + bool operator!=(const CCharAnimTime& other) const; + + static CCharAnimTime Infinity() { return CCharAnimTime(kT_Infinity, 1.0f); } + private: float x0_time; EType x4_type; diff --git a/src/MetroidPrime/BodyState/CBSAttack.cpp b/src/MetroidPrime/BodyState/CBSAttack.cpp new file mode 100644 index 00000000..99c69520 --- /dev/null +++ b/src/MetroidPrime/BodyState/CBSAttack.cpp @@ -0,0 +1,130 @@ +#include "MetroidPrime/BodyState/CBSAttack.hpp" + +#include "MetroidPrime/BodyState/CBodyController.hpp" +#include "MetroidPrime/CActor.hpp" +#include "MetroidPrime/CAnimData.hpp" +#include "MetroidPrime/CAnimPlaybackParms.hpp" +#include "MetroidPrime/CCharAnimTime.hpp" +#include "MetroidPrime/CPhysicsActor.hpp" +#include "MetroidPrime/CStateManager.hpp" + +#include "Kyoto/Animation/CPASAnimParmData.hpp" +#include "Kyoto/Animation/CPASDatabase.hpp" + +CBSAttack::CBSAttack() +: x4_nextState(pas::kAS_Invalid) +// , x8_slide(CBCSlideCmd()) +, x20_targetPos(CVector3f::Zero()) +, x2c_alignTargetPosStartTime(-1.f) +, x30_alignTargetPosTime(-1.f) +, x34_curTime(0.f) {} + +void CBSAttack::Start(CBodyController& bc, CStateManager& mgr) { + const CBCMeleeAttackCmd* cmd = + static_cast< const CBCMeleeAttackCmd* >(bc.CommandMgr().GetCmd(kBSC_MeleeAttack)); + const CPASDatabase& pasDatabase = bc.GetPASDatabase(); + const CPASAnimParmData parms(pas::kAS_MeleeAttack, + CPASAnimParm::FromEnum(cmd->GetAttackSeverity()), + CPASAnimParm::FromEnum(bc.GetLocomotionType())); + + const rstl::pair< float, int > best = pasDatabase.FindBestAnimation(parms, *mgr.Random(), -1); + const CAnimPlaybackParms playParms(best.second, -1, 1.f, true); + bc.SetCurrentAnimation(playParms, false, false); + if (cmd->HasAttackTargetPos()) { + x20_targetPos = cmd->GetAttackTargetPos(); + + CCharAnimTime evTime = bc.GetOwner().GetAnimationData()->GetTimeOfUserEvent( + kUE_AlignTargetPosStart, CCharAnimTime::Infinity()); + x2c_alignTargetPosStartTime = (evTime != CCharAnimTime::Infinity()) ? evTime.GetSeconds() : 0.f; + + evTime = bc.GetOwner().GetAnimationData()->GetTimeOfUserEvent(kUE_AlignTargetPos, + CCharAnimTime::Infinity()); + x30_alignTargetPosTime = + (evTime != CCharAnimTime::Infinity()) ? evTime.GetSeconds() : bc.GetAnimTimeRemaining(); + } else { + x20_targetPos = CVector3f::Zero(); + x2c_alignTargetPosStartTime = -1.f; + x30_alignTargetPosTime = -1.f; + } + + x4_nextState = pas::kAS_Locomotion; + x34_curTime = 0.f; +} + +pas::EAnimationState CBSAttack::UpdateBody(float dt, CBodyController& bc, CStateManager& mgr) { + x34_curTime += dt; + const pas::EAnimationState st = GetBodyStateTransition(dt, bc); + CBodyStateCmdMgr& commandMgr = bc.CommandMgr(); + if (st == pas::kAS_Invalid) { + if (commandMgr.GetTargetVector().IsNonZero()) { + bc.FaceDirection(commandMgr.GetTargetVector(), dt); + } + UpdatePhysicsActor(bc, dt); + } else if (st == pas::kAS_Slide) { + commandMgr.DeliverCmd(x8_slide); + } + return st; +} + +void CBSAttack::Shutdown(CBodyController&) {} + +pas::EAnimationState CBSAttack::GetBodyStateTransition(float dt, CBodyController& bc) { + CBodyStateCmdMgr& cmdMgr = bc.CommandMgr(); + + if (cmdMgr.GetCmd(kBSC_Hurled)) { + return pas::kAS_Hurled; + } + if (cmdMgr.GetCmd(kBSC_KnockDown)) { + return pas::kAS_Fall; + } + if (cmdMgr.GetCmd(kBSC_LoopHitReaction)) { + return pas::kAS_LoopReaction; + } + if (cmdMgr.GetCmd(kBSC_KnockBack)) { + return pas::kAS_KnockBack; + } + if (cmdMgr.GetCmd(kBSC_Locomotion)) { + return pas::kAS_Locomotion; + } + if (const CBCSlideCmd* cmd = static_cast< const CBCSlideCmd* >(cmdMgr.GetCmd(kBSC_Slide))) { + x8_slide = *cmd; + x4_nextState = pas::kAS_Slide; + } + if (cmdMgr.GetCmd(kBSC_Generate)) { + return pas::kAS_Generate; + } + if (bc.IsAnimationOver()) { + if (cmdMgr.GetCmd(kBSC_MeleeAttack)) { + return pas::kAS_MeleeAttack; + } + if (cmdMgr.GetCmd(kBSC_ProjectileAttack)) { + return pas::kAS_ProjectileAttack; + } + if (cmdMgr.GetCmd(kBSC_LoopAttack)) { + return pas::kAS_LoopAttack; + } + return x4_nextState; + } + if (cmdMgr.GetCmd(kBSC_NextState)) { + return x4_nextState; + } + return pas::kAS_Invalid; +} + +void CBSAttack::UpdatePhysicsActor(CBodyController& bc, float dt) { + if (!x20_targetPos.IsNonZero()) { + return; + } + + if (x34_curTime >= x2c_alignTargetPosStartTime && x34_curTime <= x30_alignTargetPosTime) { + + if (CPhysicsActor* act = TCastToPtr< CPhysicsActor >(&bc.GetOwner())) { + CVector3f delta = x20_targetPos - act->GetTranslation(); + const float dur = x30_alignTargetPosTime - x2c_alignTargetPosStartTime; + CVector3f deltaMod = (dur > 0.f) ? (delta * (dt / dur)) : delta; + + CVector3f impulse = act->GetMoveToORImpulseWR(act->GetTransform().TransposeRotate(deltaMod), dt); + act->ApplyImpulseWR(impulse, CAxisAngle::Identity()); + } + } +}