CMetroid: Implement GetDamageVulnerability

This commit is contained in:
Luke Street 2020-05-08 05:05:47 -04:00
parent ca659bdcbc
commit ac30616efb
2 changed files with 73 additions and 5 deletions

View File

@ -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

View File

@ -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();
};