CDamageVulnerability: Use matching GetVulnerability imp

This commit is contained in:
Phillip Stephens 2022-03-31 22:37:23 -07:00
parent 95b3859503
commit 6c449ca146
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
1 changed files with 21 additions and 30 deletions

View File

@ -216,49 +216,40 @@ bool CDamageVulnerability::WeaponHits(const CWeaponMode& mode, bool checkDirect)
return result; return result;
} }
inline EVulnerability direct_to_normal(EVulnerability vuln) {
if (vuln == EVulnerability::DirectWeak) {
return EVulnerability::Weak;
}
if (vuln == EVulnerability::DirectNormal) {
return EVulnerability::Normal;
}
if (vuln == EVulnerability::DirectImmune) {
return EVulnerability::Immune;
}
return vuln;
}
EVulnerability CDamageVulnerability::GetVulnerability(const CWeaponMode& mode, bool ignoreDirect) const { EVulnerability CDamageVulnerability::GetVulnerability(const CWeaponMode& mode, bool ignoreDirect) const {
const auto type = mode.GetType(); if (mode.GetType() < EWeaponType::Power || mode.GetType() > EWeaponType::OrangePhazon) {
if (type <= EWeaponType::None || type >= EWeaponType::Max) {
return EVulnerability::Deflect; return EVulnerability::Deflect;
} }
if (mode.IsInstantKill()) { if (mode.IsInstantKill()) {
return EVulnerability::Normal; return EVulnerability::Normal;
} }
auto vuln = x0_normal[u32(type)]; EVulnerability vuln = x0_normal[u32(mode.GetType())];
EWeaponType type = mode.GetType();
if (mode.IsCharged()) { if (mode.IsCharged()) {
if (type < EWeaponType::Bomb) { vuln = type < EWeaponType::Bomb ? x3c_charged[u32(type)] : EVulnerability::Normal;
vuln = x3c_charged[u32(type)];
} else {
vuln = EVulnerability::Normal;
}
} }
if (mode.IsComboed()) { if (mode.IsComboed()) {
if (type < EWeaponType::Bomb) { vuln = type < EWeaponType::Bomb ? x4c_combo[u32(type)] : EVulnerability::Normal;
vuln = x4c_combo[u32(type)];
} else {
vuln = EVulnerability::Normal;
}
} }
if (ignoreDirect == 1) {
if (ignoreDirect) {
return vuln; return vuln;
} }
return direct_to_normal(vuln);
if (vuln == EVulnerability::DirectWeak) {
return EVulnerability::Weak;
}
if (vuln == EVulnerability::DirectNormal) {
return EVulnerability::Normal;
}
if (vuln == EVulnerability::DirectImmune) {
return EVulnerability::Immune;
}
return vuln;
} }
} // namespace metaforce } // namespace metaforce