CDamageVulnerability: Fix WeaponHits

This commit is contained in:
Luke Street 2020-05-17 12:25:04 -04:00
parent 74d9bf4abc
commit eddaa24b1e
1 changed files with 22 additions and 15 deletions

View File

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