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;
}
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 {
const auto type = mode.GetType();
if (type <= EWeaponType::None || type >= EWeaponType::Max) {
if (mode.GetType() < EWeaponType::Power || mode.GetType() > EWeaponType::OrangePhazon) {
return EVulnerability::Deflect;
}
if (mode.IsInstantKill()) {
return EVulnerability::Normal;
}
auto vuln = x0_normal[u32(type)];
EVulnerability vuln = x0_normal[u32(mode.GetType())];
EWeaponType type = mode.GetType();
if (mode.IsCharged()) {
if (type < EWeaponType::Bomb) {
vuln = x3c_charged[u32(type)];
} else {
vuln = EVulnerability::Normal;
}
vuln = type < EWeaponType::Bomb ? x3c_charged[u32(type)] : EVulnerability::Normal;
}
if (mode.IsComboed()) {
if (type < EWeaponType::Bomb) {
vuln = x4c_combo[u32(type)];
} else {
vuln = EVulnerability::Normal;
}
vuln = type < EWeaponType::Bomb ? x4c_combo[u32(type)] : EVulnerability::Normal;
}
if (ignoreDirect) {
if (ignoreDirect == 1) {
return vuln;
}
if (vuln == EVulnerability::DirectWeak) {
return EVulnerability::Weak;
}
if (vuln == EVulnerability::DirectNormal) {
return EVulnerability::Normal;
}
if (vuln == EVulnerability::DirectImmune) {
return EVulnerability::Immune;
}
return vuln;
return direct_to_normal(vuln);
}
} // namespace metaforce