From eddaa24b1e214bff1fa0ffb1c1e6a4a865879d3b Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sun, 17 May 2020 12:25:04 -0400 Subject: [PATCH] CDamageVulnerability: Fix WeaponHits --- Runtime/World/CDamageVulnerability.cpp | 37 +++++++++++++++----------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/Runtime/World/CDamageVulnerability.cpp b/Runtime/World/CDamageVulnerability.cpp index 78938f847..e70954221 100644 --- a/Runtime/World/CDamageVulnerability.cpp +++ b/Runtime/World/CDamageVulnerability.cpp @@ -34,8 +34,9 @@ constexpr CDamageVulnerability CDamageVulnerability::sPassThroughVulnerability( EVulnerability::PassThrough, EVulnerability::PassThrough, EVulnerability::PassThrough, EVulnerability::PassThrough, EVulnerability::PassThrough, EVulnerability::PassThrough, EVulnerability::PassThrough, EDeflectType::None); -static constexpr bool is_not_immune(EVulnerability vuln) { - return vuln != EVulnerability::Immune && vuln != EVulnerability::DirectImmune; +static constexpr bool is_not_deflect_direct(EVulnerability vuln) { + return vuln != EVulnerability::Deflect && vuln != EVulnerability::DirectWeak && + vuln != EVulnerability::DirectNormal && vuln != EVulnerability::DirectImmune; } static constexpr bool is_normal_or_weak(EVulnerability vuln) { @@ -145,34 +146,40 @@ bool CDamageVulnerability::WeaponHurts(const CWeaponMode& mode, bool ignoreDirec } bool CDamageVulnerability::WeaponHits(const CWeaponMode& mode, bool checkDirect) const { - if (mode.GetType() == EWeaponType::None || mode.GetType() > EWeaponType::OrangePhazon) + if (mode.GetType() <= EWeaponType::None || mode.GetType() > EWeaponType::OrangePhazon) { return false; - if (mode.IsInstantKill()) + } + if (mode.IsInstantKill()) { return true; + } bool normalVuln; - if (!checkDirect) - normalVuln = (&x0_power)[u32(mode.GetType())] != EVulnerability::Immune; - else - normalVuln = is_not_immune((&x0_power)[u32(mode.GetType())]); + if (!checkDirect) { + normalVuln = (&x0_power)[u32(mode.GetType())] != EVulnerability::Deflect; + } else { + normalVuln = is_not_deflect_direct((&x0_power)[u32(mode.GetType())]); + } bool chargedVuln = true; bool comboedVuln = true; - if (mode.GetType() < EWeaponType::Bomb) { + const EVulnerability chargedPowerVuln = (&x3c_chargedPower)[u32(mode.GetType())]; + const EVulnerability superMissileVuln = (&x4c_superMissile)[u32(mode.GetType())]; if (!checkDirect) { - chargedVuln = (&x3c_chargedPower)[u32(mode.GetType())] != EVulnerability::Immune; - comboedVuln = (&x4c_superMissile)[u32(mode.GetType())] != EVulnerability::Immune; + chargedVuln = chargedPowerVuln != EVulnerability::Deflect; + comboedVuln = superMissileVuln != EVulnerability::Deflect; } else { - chargedVuln = is_not_immune((&x3c_chargedPower)[u32(mode.GetType())]); - comboedVuln = is_not_immune((&x4c_superMissile)[u32(mode.GetType())]); + chargedVuln = is_not_deflect_direct(chargedPowerVuln); + comboedVuln = is_not_deflect_direct(superMissileVuln); } } - if (normalVuln && !mode.IsCharged() && !mode.IsComboed()) + if (normalVuln && !mode.IsCharged() && !mode.IsComboed()) { return true; - if (chargedVuln && mode.IsCharged()) + } + if (chargedVuln && mode.IsCharged()) { return true; + } return comboedVuln && mode.IsComboed(); }