From ac30616efb76c2e39da3f508ac819095fecbc4f6 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 8 May 2020 05:05:47 -0400 Subject: [PATCH] CMetroid: Implement GetDamageVulnerability --- Runtime/MP1/World/CMetroid.cpp | 70 +++++++++++++++++++++++++++++++++- Runtime/MP1/World/CMetroid.hpp | 8 ++-- 2 files changed, 73 insertions(+), 5 deletions(-) diff --git a/Runtime/MP1/World/CMetroid.cpp b/Runtime/MP1/World/CMetroid.cpp index e52ddb1cf..270ffc044 100644 --- a/Runtime/MP1/World/CMetroid.cpp +++ b/Runtime/MP1/World/CMetroid.cpp @@ -8,10 +8,46 @@ #include "Runtime/World/ScriptLoader.hpp" namespace urde::MP1 { +namespace { +constexpr CDamageVulnerability CDamageVulnerability_80571c64{ + EVulnerability::Deflect, EVulnerability::Deflect, EVulnerability::Deflect, EVulnerability::Immune, + EVulnerability::Deflect, EVulnerability::Normal, EVulnerability::Deflect, EVulnerability::Deflect, + EVulnerability::Normal, EVulnerability::Deflect, EVulnerability::Deflect, EVulnerability::Deflect, + EVulnerability::Deflect, EVulnerability::Deflect, EVulnerability::Deflect, EDeflectType::None, +}; + +constexpr CDamageVulnerability CDamageVulnerability_80571e6c{ + EVulnerability::Deflect, EVulnerability::Immune, EVulnerability::Deflect, EVulnerability::Deflect, + EVulnerability::Deflect, EVulnerability::Normal, EVulnerability::Deflect, EVulnerability::Deflect, + EVulnerability::Normal, EVulnerability::Deflect, EVulnerability::Deflect, EVulnerability::Deflect, + EVulnerability::Deflect, EVulnerability::Deflect, EVulnerability::Deflect, EDeflectType::None, +}; + +constexpr CDamageVulnerability CDamageVulnerability_80571ed4{ + EVulnerability::Deflect, EVulnerability::Deflect, EVulnerability::Immune, EVulnerability::Deflect, + EVulnerability::Deflect, EVulnerability::Normal, EVulnerability::Deflect, EVulnerability::Deflect, + EVulnerability::Normal, EVulnerability::Deflect, EVulnerability::Deflect, EVulnerability::Deflect, + EVulnerability::Deflect, EVulnerability::Deflect, EVulnerability::Deflect, EDeflectType::None, +}; + +constexpr CDamageVulnerability CDamageVulnerability_80571f3c{ + EVulnerability::Immune, EVulnerability::Deflect, EVulnerability::Deflect, EVulnerability::Deflect, + EVulnerability::Deflect, EVulnerability::Normal, EVulnerability::Deflect, EVulnerability::Deflect, + EVulnerability::Normal, EVulnerability::Deflect, EVulnerability::Deflect, EVulnerability::Deflect, + EVulnerability::Deflect, EVulnerability::Deflect, EVulnerability::Deflect, EDeflectType::None, +}; + +constexpr CDamageVulnerability CDamageVulnerability_80571fa4{ + EVulnerability::Deflect, EVulnerability::Deflect, EVulnerability::Deflect, EVulnerability::Deflect, + EVulnerability::Deflect, EVulnerability::Normal, EVulnerability::Deflect, EVulnerability::Deflect, + EVulnerability::Deflect, EVulnerability::Deflect, EVulnerability::Deflect, EVulnerability::Deflect, + EVulnerability::Deflect, EVulnerability::Deflect, EVulnerability::Deflect, EDeflectType::None, +}; +} // namespace CMetroidData::CMetroidData(CInputStream& in) -: x0_dVuln1(in) -, x68_dVuln2(in) +: x0_frozenVulnerability(in) +, x68_energyDrainVulnerability(in) , xd0_(in.readFloatBig()) , xd4_(in.readFloatBig()) , xd8_(in.readFloatBig()) @@ -120,4 +156,34 @@ EWeaponCollisionResponseTypes CMetroid::GetCollisionResponseType(const zeus::CVe return types; } +const CDamageVulnerability* CMetroid::GetDamageVulnerability() const { + if (IsSuckingEnergy()) { + if (x9c0_24_) { + return &x56c_data.GetEnergyDrainVulnerability(); + } + return &CDamageVulnerability_80571fa4; + } + if (x9bf_25_ && !x450_bodyController->IsFrozen()) { + return &x56c_data.GetEnergyDrainVulnerability(); + } + if (x450_bodyController->GetPercentageFrozen() > 0.f) { + return &x56c_data.GetFrozenVulnerability(); + } + if (x3fc_flavor == CPatterned::EFlavorType::Two) { + if (x7cc_animParmsidx == 1) { + return &CDamageVulnerability_80571c64; + } + if (x7cc_animParmsidx == 2) { + return &CDamageVulnerability_80571e6c; + } + if (x7cc_animParmsidx == 3) { + return &CDamageVulnerability_80571ed4; + } + if (x7cc_animParmsidx == 4) { + return &CDamageVulnerability_80571f3c; + } + } + return CAi::GetDamageVulnerability(); +} + } // namespace urde::MP1 diff --git a/Runtime/MP1/World/CMetroid.hpp b/Runtime/MP1/World/CMetroid.hpp index c2035bd07..638ffe294 100644 --- a/Runtime/MP1/World/CMetroid.hpp +++ b/Runtime/MP1/World/CMetroid.hpp @@ -16,8 +16,8 @@ namespace urde::MP1 { class CMetroidData { private: static constexpr u32 skNumProperties = 20; - CDamageVulnerability x0_dVuln1; - CDamageVulnerability x68_dVuln2; + CDamageVulnerability x0_frozenVulnerability; + CDamageVulnerability x68_energyDrainVulnerability; float xd0_; float xd4_; float xd8_; @@ -33,6 +33,8 @@ private: public: explicit CMetroidData(CInputStream& in); static u32 GetNumProperties() { return skNumProperties; } + const CDamageVulnerability& GetFrozenVulnerability() const { return x0_frozenVulnerability; } + const CDamageVulnerability& GetEnergyDrainVulnerability() const { return x68_energyDrainVulnerability; } bool GetStartsInWall() { return x128_24_startsInWall; } }; @@ -187,7 +189,7 @@ private: float GetDamageMultiplier() { return 0.5f * (GetGrowthStage() - 1.f) + 1.f; } float GetGrowthStage(); zeus::CVector3f GetAttackTargetPos(CStateManager& mgr); - bool IsSuckingEnergy(); + bool IsSuckingEnergy() const; void UpdateVolume(); void UpdateTouchBounds(); };