diff --git a/asm/MetroidPrime/BodyState/CBSTaunt.s b/asm/MetroidPrime/BodyState/CBSTaunt.s index d1b939d0..b144ff20 100644 --- a/asm/MetroidPrime/BodyState/CBSTaunt.s +++ b/asm/MetroidPrime/BodyState/CBSTaunt.s @@ -3,8 +3,8 @@ .section .data .balign 8 -.global lbl_803E2390 -lbl_803E2390: +.global __vt__8CBSTaunt +__vt__8CBSTaunt: # ROM: 0x3DF390 .4byte 0 .4byte 0 @@ -31,8 +31,8 @@ __dt__8CBSTauntFv: /* 801492BC 0014621C 93 E1 00 0C */ stw r31, 0xc(r1) /* 801492C0 00146220 7C 7F 1B 79 */ or. r31, r3, r3 /* 801492C4 00146224 41 82 00 30 */ beq lbl_801492F4 -/* 801492C8 00146228 3C 60 80 3E */ lis r3, lbl_803E2390@ha -/* 801492CC 0014622C 38 03 23 90 */ addi r0, r3, lbl_803E2390@l +/* 801492C8 00146228 3C 60 80 3E */ lis r3, __vt__8CBSTaunt@ha +/* 801492CC 0014622C 38 03 23 90 */ addi r0, r3, __vt__8CBSTaunt@l /* 801492D0 00146230 90 1F 00 00 */ stw r0, 0(r31) /* 801492D4 00146234 41 82 00 10 */ beq lbl_801492E4 /* 801492D8 00146238 3C 60 80 3E */ lis r3, __vt__10CBodyState@ha @@ -251,10 +251,10 @@ lbl_8014959C: .global __ct__8CBSTauntFv __ct__8CBSTauntFv: /* 801495B8 00146518 3C A0 80 3E */ lis r5, __vt__10CBodyState@ha -/* 801495BC 0014651C 3C 80 80 3E */ lis r4, lbl_803E2390@ha +/* 801495BC 0014651C 3C 80 80 3E */ lis r4, __vt__8CBSTaunt@ha /* 801495C0 00146520 38 A5 13 18 */ addi r5, r5, __vt__10CBodyState@l /* 801495C4 00146524 90 A3 00 00 */ stw r5, 0(r3) -/* 801495C8 00146528 38 04 23 90 */ addi r0, r4, lbl_803E2390@l +/* 801495C8 00146528 38 04 23 90 */ addi r0, r4, __vt__8CBSTaunt@l /* 801495CC 0014652C 90 03 00 00 */ stw r0, 0(r3) /* 801495D0 00146530 4E 80 00 20 */ blr diff --git a/configure.py b/configure.py index 8f7f1f94..1c6006be 100755 --- a/configure.py +++ b/configure.py @@ -206,7 +206,7 @@ LIBS = [ "MetroidPrime/BodyState/CBSJump", ["MetroidPrime/BodyState/CBSGenerate", True], "MetroidPrime/Enemies/CPuddleSpore", - "MetroidPrime/BodyState/CBSTaunt", + ["MetroidPrime/BodyState/CBSTaunt", True], "MetroidPrime/CSortedLists", ["MetroidPrime/ScriptObjects/CScriptDebugCameraWaypoint", True], ["MetroidPrime/ScriptObjects/CScriptSpiderBallAttractionSurface", False], diff --git a/include/MetroidPrime/BodyState/CBSTaunt.hpp b/include/MetroidPrime/BodyState/CBSTaunt.hpp new file mode 100644 index 00000000..5ddef1d2 --- /dev/null +++ b/include/MetroidPrime/BodyState/CBSTaunt.hpp @@ -0,0 +1,20 @@ +#ifndef _CBSTAUNT +#define _CBSTAUNT + +#include "MetroidPrime/BodyState/CBodyState.hpp" + +class CBSTaunt : public CBodyState { +public: + CBSTaunt(); + ~CBSTaunt(); + + void Start(CBodyController& bc, CStateManager& mgr) override; + pas::EAnimationState UpdateBody(float dt, CBodyController& bc, CStateManager& mgr) override; + void Shutdown(CBodyController&) override; + + private: + pas::EAnimationState GetBodyStateTransition(float dt, CBodyController& bc); + +}; + +#endif // _CBSTAUNT diff --git a/include/MetroidPrime/BodyState/CBodyController.hpp b/include/MetroidPrime/BodyState/CBodyController.hpp index 39cf7195..407e84a5 100644 --- a/include/MetroidPrime/BodyState/CBodyController.hpp +++ b/include/MetroidPrime/BodyState/CBodyController.hpp @@ -10,6 +10,8 @@ class CActor; class CPASDatabase; class CQuaternion; class CAnimPlaybackParms; +class CPASAnimParmData; +class CRandom16; class CBodyController { @@ -25,6 +27,7 @@ public: void SetCurrentAnimation(const CAnimPlaybackParms& parms, bool loop, bool noTrans); void FaceDirection(const CVector3f& v0, float dt); void EnableAnimation(bool enable); + void PlayBestAnimation(const CPASAnimParmData& parms, CRandom16& r); void SetFallState(pas::EFallState state); // { x2f0_fallState = state; } pas::EFallState GetFallState() const; // { return x2f0_fallState; } diff --git a/include/MetroidPrime/BodyState/CBodyStateCmdMgr.hpp b/include/MetroidPrime/BodyState/CBodyStateCmdMgr.hpp index 30449d2c..418f3756 100644 --- a/include/MetroidPrime/BodyState/CBodyStateCmdMgr.hpp +++ b/include/MetroidPrime/BodyState/CBodyStateCmdMgr.hpp @@ -70,7 +70,7 @@ public: , xc_24_loopAnim(false) , xc_25_timedLoop(false) , x10_loopDur(0.f) {} - + explicit CBCScriptedCmd(int i, bool b1, bool b2, float f) : CBodyStateCmd(kBSC_Scripted) , x8_anim(i) @@ -86,13 +86,26 @@ public: // -class CBCGetupCmd : public CBodyStateCmd { - pas::EGetupType x8_type; +class CBCTauntCmd : public CBodyStateCmd { +public: + explicit CBCTauntCmd() : CBodyStateCmd(kBSC_Taunt), x8_type(pas::kTT_Invalid) {} + explicit CBCTauntCmd(pas::ETauntType type) : CBodyStateCmd(kBSC_Taunt), x8_type(type) {} + pas::ETauntType GetTauntType() const { return x8_type; } +private: + pas::ETauntType x8_type; +}; + +// + +class CBCGetupCmd : public CBodyStateCmd { public: explicit CBCGetupCmd() : CBodyStateCmd(kBSC_Getup), x8_type(pas::kGetup_Invalid) {} explicit CBCGetupCmd(pas::EGetupType type) : CBodyStateCmd(kBSC_Getup), x8_type(type) {} pas::EGetupType GetGetupType() const { return x8_type; } + +private: + pas::EGetupType x8_type; }; // diff --git a/obj_files.mk b/obj_files.mk index 23cea8f0..cc99e077 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -171,7 +171,7 @@ METROIDPRIME :=\ $(BUILD_DIR)/asm/MetroidPrime/BodyState/CBSJump.o\ $(BUILD_DIR)/src/MetroidPrime/BodyState/CBSGenerate.o\ $(BUILD_DIR)/asm/MetroidPrime/Enemies/CPuddleSpore.o\ - $(BUILD_DIR)/asm/MetroidPrime/BodyState/CBSTaunt.o\ + $(BUILD_DIR)/src/MetroidPrime/BodyState/CBSTaunt.o\ $(BUILD_DIR)/asm/MetroidPrime/CSortedLists.o\ $(BUILD_DIR)/src/MetroidPrime/ScriptObjects/CScriptDebugCameraWaypoint.o\ $(BUILD_DIR)/asm/MetroidPrime/ScriptObjects/CScriptSpiderBallAttractionSurface.o\ diff --git a/src/MetroidPrime/BodyState/CBSTaunt.cpp b/src/MetroidPrime/BodyState/CBSTaunt.cpp new file mode 100644 index 00000000..7529c936 --- /dev/null +++ b/src/MetroidPrime/BodyState/CBSTaunt.cpp @@ -0,0 +1,53 @@ +#include "MetroidPrime/BodyState/CBSTaunt.hpp" + +#include "MetroidPrime/CStateManager.hpp" +#include "MetroidPrime/BodyState/CBodyController.hpp" + +#include "Kyoto/Animation/CPASAnimParmData.hpp" + +CBSTaunt::CBSTaunt() {} + +void CBSTaunt::Start(CBodyController& bc, CStateManager& mgr) { + const CBCTauntCmd* cmd = static_cast(bc.CommandMgr().GetCmd(kBSC_Taunt)); + const CPASAnimParmData parms(pas::kAS_Taunt, CPASAnimParm::FromEnum(cmd->GetTauntType())); + bc.PlayBestAnimation(parms, *mgr.Random()); +} + +pas::EAnimationState CBSTaunt::UpdateBody(float dt, CBodyController& bc, CStateManager& mgr) { + const pas::EAnimationState st = GetBodyStateTransition(dt, bc); + if (st == pas::kAS_Invalid) { + CBodyStateCmdMgr& cmdMgr = bc.CommandMgr(); + if (cmdMgr.GetTargetVector().IsNonZero()) { + bc.FaceDirection(cmdMgr.GetTargetVector(), dt); + } + } + return st; +} + +void CBSTaunt::Shutdown(CBodyController&) override {} + +pas::EAnimationState CBSTaunt::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 (bc.IsAnimationOver()) { + return pas::kAS_Locomotion; + } + return pas::kAS_Invalid; +} + +CBSTaunt::~CBSTaunt() {}