diff --git a/configure.py b/configure.py index 9da46f31..52e7af3f 100755 --- a/configure.py +++ b/configure.py @@ -153,7 +153,7 @@ LIBS = [ "MetroidPrime/Weapons/CWeapon", "MetroidPrime/CDamageVulnerability", "MetroidPrime/CActorLights", - "MetroidPrime/Enemies/CPatternedInfo", + ["MetroidPrime/Enemies/CPatternedInfo", True], "MetroidPrime/CSimpleShadow", "MetroidPrime/CActorParameters", "MetroidPrime/CInGameGuiManager", diff --git a/include/Kyoto/SObjectTag.hpp b/include/Kyoto/SObjectTag.hpp index 4547c7b7..0ee577de 100644 --- a/include/Kyoto/SObjectTag.hpp +++ b/include/Kyoto/SObjectTag.hpp @@ -1,6 +1,8 @@ #ifndef _SOBJECTTAG #define _SOBJECTTAG +#include "types.h" + #define kInvalidAssetId 0xFFFFFFFFu typedef uint CAssetId; diff --git a/include/MetroidPrime/CAnimationParameters.hpp b/include/MetroidPrime/CAnimationParameters.hpp new file mode 100644 index 00000000..1ed9af39 --- /dev/null +++ b/include/MetroidPrime/CAnimationParameters.hpp @@ -0,0 +1,21 @@ +#ifndef _CANIMATIONPARAMETERS +#define _CANIMATIONPARAMETERS + +#include "Kyoto/SObjectTag.hpp" +#include "Kyoto/Streams/CInputStream.hpp" + +class CAnimationParameters { + CAssetId x0_ancs; + uint x4_charIdx; + uint x8_defaultAnim; + +public: + CAnimationParameters(CAssetId ancs, uint charIdx, uint defaultAnim) + : x0_ancs(ancs), x4_charIdx(charIdx), x8_defaultAnim(defaultAnim) {} + + CAnimationParameters(CInputStream& in) + : x0_ancs(in.ReadLong()), x4_charIdx(in.ReadLong()), x8_defaultAnim(in.ReadLong()) {} +}; + + +#endif // _CANIMATIONPARAMETERS diff --git a/include/MetroidPrime/Enemies/CPatternedInfo.hpp b/include/MetroidPrime/Enemies/CPatternedInfo.hpp new file mode 100644 index 00000000..8ce1f74b --- /dev/null +++ b/include/MetroidPrime/Enemies/CPatternedInfo.hpp @@ -0,0 +1,76 @@ +#ifndef _CPATTERNEDINFO +#define _CPATTERNEDINFO + +#include "MetroidPrime/CAnimationParameters.hpp" +#include "MetroidPrime/CDamageInfo.hpp" +#include "MetroidPrime/CDamageVulnerability.hpp" +#include "MetroidPrime/CHealthInfo.hpp" + +#include "Kyoto/Math/CVector3f.hpp" +#include "Kyoto/SObjectTag.hpp" + +#include "rstl/pair.hpp" + +class CPatternedInfo { + friend class CPatterned; + float x0_mass; + float x4_speed; + float x8_turnSpeed; + float xc_detectionRange; + float x10_detectionHeightRange; + float x14_dectectionAngle; + float x18_minAttackRange; + float x1c_maxAttackRange; + float x20_averageAttackTime; + float x24_attackTimeVariation; + float x28_leashRadius; + float x2c_playerLeashRadius; + float x30_playerLeashTime; + CDamageInfo x34_contactDamageInfo; + float x50_damageWaitTime; + CHealthInfo x54_healthInfo; + CDamageVulnerability x5c_damageVulnerability; + float xc4_halfExtent; + float xc8_height; + CVector3f xcc_bodyOrigin; + float xd8_stepUpHeight; + float xdc_xDamage; + float xe0_frozenXDamage; + float xe4_xDamageDelay; + uint xe8_deathSfx; + CAnimationParameters xec_animParams; + bool xf8_active; + CAssetId xfc_stateMachineId; + float x100_intoFreezeDur; + float x104_outofFreezeDur; + float x108_freezeDur; + + uint x10c_pathfindingIndex; + + CVector3f x110_particle1Scale; + CAssetId x11c_particle1; + CAssetId x120_electric; + CVector3f x124_particle2Scale; + CAssetId x130_particle2; + + uint x134_iceShatterSfx; + +public: + CPatternedInfo(CInputStream& in, uint pcount); + static rstl::pair< bool, uint > HasCorrectParameterCount(CInputStream& in); + + float GetTurnSpeed() const { return x8_turnSpeed; } + float GetDetectionHeightRange() const { return x10_detectionHeightRange; } + const CHealthInfo& GetHealthInfo() const { return x54_healthInfo; } + const CDamageVulnerability& GetDamageVulnerability() const { return x5c_damageVulnerability; } + float GetHalfExtent() const { return xc4_halfExtent; } + float GetHeight() const { return xc8_height; } + CVector3f GetBodyOrigin() const { return xcc_bodyOrigin; } + CAnimationParameters& GetAnimationParameters() { return xec_animParams; } + const CAnimationParameters& GetAnimationParameters() const { return xec_animParams; } + u32 GetPathfindingIndex() const { return x10c_pathfindingIndex; } + bool GetActive() const { return xf8_active; } + void SetActive(bool active) { xf8_active = active; } +}; + +#endif // _CPATTERNEDINFO diff --git a/src/MetroidPrime/Enemies/CPatternedInfo.cpp b/src/MetroidPrime/Enemies/CPatternedInfo.cpp new file mode 100644 index 00000000..dba92a5b --- /dev/null +++ b/src/MetroidPrime/Enemies/CPatternedInfo.cpp @@ -0,0 +1,55 @@ +#include "MetroidPrime/Enemies/CPatternedInfo.hpp" + +#include "Kyoto/Audio/CSfxManager.hpp" +#include "Kyoto/Streams/CInputStream.hpp" + +CPatternedInfo::CPatternedInfo(CInputStream& in, uint pcount) +: x0_mass(in.ReadFloat()) +, x4_speed(in.ReadFloat()) +, x8_turnSpeed(in.ReadFloat()) +, xc_detectionRange(in.ReadFloat()) +, x10_detectionHeightRange(in.ReadFloat()) +, x14_dectectionAngle(in.ReadFloat()) +, x18_minAttackRange(in.ReadFloat()) +, x1c_maxAttackRange(in.ReadFloat()) +, x20_averageAttackTime(in.ReadFloat()) +, x24_attackTimeVariation(in.ReadFloat()) +, x28_leashRadius(in.ReadFloat()) +, x2c_playerLeashRadius(in.ReadFloat()) +, x30_playerLeashTime(in.ReadFloat()) +, x34_contactDamageInfo(in) +, x50_damageWaitTime(in.ReadFloat()) +, x54_healthInfo(in) +, x5c_damageVulnerability(in) +, xc4_halfExtent(in.ReadFloat()) +, xc8_height(in.ReadFloat()) +, xcc_bodyOrigin(in) +, xd8_stepUpHeight(in.ReadFloat()) +, xdc_xDamage(in.ReadFloat()) +, xe0_frozenXDamage(in.ReadFloat()) +, xe4_xDamageDelay(in.ReadFloat()) +, xe8_deathSfx(CSfxManager::TranslateSFXID(in.ReadLong())) +, xec_animParams(in) +, xf8_active(in.ReadBool()) +, xfc_stateMachineId(in.ReadLong()) +, x100_intoFreezeDur(in.ReadFloat()) +, x104_outofFreezeDur(in.ReadFloat()) +, x108_freezeDur(in.ReadFloat()) + +, x10c_pathfindingIndex(in.ReadLong()) + +, x110_particle1Scale(in) +, x11c_particle1(in.ReadLong()) +, x120_electric(in.ReadLong()) +, x124_particle2Scale(pcount >= 0x24 ? CVector3f(in) : CVector3f::Zero()) +, x130_particle2(pcount >= 0x25 ? in.ReadLong() : 0xffffffff) + +, x134_iceShatterSfx(pcount >= 0x26 ? CSfxManager::TranslateSFXID(in.ReadLong()) + : CSfxManager::kInternalInvalidSfxId) + +{} + +rstl::pair< bool, uint > CPatternedInfo::HasCorrectParameterCount(CInputStream& in) { + u32 pcount = in.ReadLong(); + return rstl::pair< bool, uint >((pcount >= 35 && pcount <= 38), pcount); +}