Commit eddaa24b authored by encounter's avatar encounter

CDamageVulnerability: Fix WeaponHits

parent 74d9bf4a
......@@ -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();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment