CDamageVulnerability: Fix WeaponHits and WeaponHurts with near matching imps

This commit is contained in:
Phillip Stephens 2022-03-31 22:28:13 -07:00
parent 8ac39d1712
commit 95b3859503
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
1 changed files with 62 additions and 76 deletions

View File

@ -109,125 +109,111 @@ EDeflectType CDamageVulnerability::GetDeflectionType(const CWeaponMode& mode) co
}
bool CDamageVulnerability::WeaponHurts(const CWeaponMode& mode, bool ignoreDirect) const {
if (mode.GetType() == EWeaponType::None || mode.GetType() > EWeaponType::OrangePhazon) {
EWeaponType weaponType = mode.GetType();
if (weaponType < EWeaponType::Power || weaponType > EWeaponType::OrangePhazon) {
return false;
}
if (mode.IsInstantKill()) {
return true;
}
bool normalHurts = true;
const auto vuln = x0_normal[u32(mode.GetType())];
if (!ignoreDirect) {
bool directHurts = true;
if (!is_normal_or_weak(vuln) && vuln != EVulnerability::DirectWeak) {
directHurts = false;
}
if (!directHurts && vuln != EVulnerability::DirectNormal) {
normalHurts = false;
}
} else if (!is_normal_or_weak(vuln)) {
normalHurts = false;
EVulnerability vuln = x0_normal[u32(weaponType)];
bool normalHurts = ignoreDirect == 0 ? (is_normal_or_weak(vuln) || vuln == EVulnerability::DirectWeak ||
vuln == EVulnerability::DirectNormal)
: is_normal_or_weak(vuln);
bool chargedHurts;
if (weaponType < EWeaponType::Bomb) {
vuln = x3c_charged[u32(weaponType)];
chargedHurts = ignoreDirect == 0 ? (is_normal_or_weak(vuln) || vuln == EVulnerability::DirectWeak ||
vuln == EVulnerability::DirectNormal)
: is_normal_or_weak(vuln);
;
} else {
chargedHurts = true;
}
bool chargedHurts = true;
if (mode.GetType() < EWeaponType::Bomb) {
const auto chargedVuln = x3c_charged[u32(mode.GetType())];
if (!ignoreDirect) {
bool directHurts = true;
if (!is_normal_or_weak(chargedVuln) && chargedVuln != EVulnerability::DirectWeak) {
directHurts = false;
bool comboedHurts;
if (weaponType < EWeaponType::Bomb) {
vuln = x3c_charged[u32(weaponType)];
comboedHurts = ignoreDirect == 0 ? (is_normal_or_weak(vuln) || vuln == EVulnerability::DirectWeak ||
vuln == EVulnerability::DirectNormal)
: is_normal_or_weak(vuln);
;
} else {
comboedHurts = true;
}
if (!directHurts && chargedVuln != EVulnerability::DirectNormal) {
chargedHurts = false;
}
} else if (!is_normal_or_weak(chargedVuln)) {
chargedHurts = false;
}
bool result = false;
if ((normalHurts && !mode.IsCharged() && !mode.IsComboed()) || (chargedHurts && mode.IsCharged()) ||
(comboedHurts && mode.IsComboed())) {
result = true;
}
bool comboedHurts = true;
if (mode.GetType() < EWeaponType::Bomb) {
const auto comboedVuln = x4c_combo[u32(mode.GetType())];
if (!ignoreDirect) {
bool directHurts = true;
if (!is_normal_or_weak(comboedVuln) && comboedVuln != EVulnerability::DirectWeak) {
directHurts = false;
}
if (!directHurts && comboedVuln != EVulnerability::DirectNormal) {
comboedHurts = false;
}
} else if (!is_normal_or_weak(comboedVuln)) {
comboedHurts = false;
}
}
if (((!normalHurts || mode.IsCharged()) || mode.IsComboed()) && (!chargedHurts || !mode.IsCharged())) {
if (!comboedHurts) {
return false;
}
if (!mode.IsComboed()) {
return false;
}
}
return true;
return result;
}
bool CDamageVulnerability::WeaponHits(const CWeaponMode& mode, bool checkDirect) const {
if (mode.GetType() < EWeaponType::Power || mode.GetType() > EWeaponType::OrangePhazon) {
const EWeaponType weaponType = mode.GetType();
if (weaponType < EWeaponType::Power || weaponType > EWeaponType::OrangePhazon) {
return false;
}
if (mode.IsInstantKill()) {
return true;
}
auto vuln = x0_normal[u32(mode.GetType())];
bool normalHits = true;
EVulnerability vuln = x0_normal[u32(weaponType)];
bool normalHits;
if (!checkDirect) {
normalHits = is_not_deflect(vuln);
} else if (is_deflect_direct(vuln)) {
} else if (vuln == EVulnerability::Deflect ||
(static_cast<EVulnerability>((u32)vuln - (u32)EVulnerability::DirectWeak) <= EVulnerability::Normal) ||
vuln == EVulnerability::DirectImmune) {
normalHits = false;
} else {
normalHits = true;
}
bool chargedHits = true;
if (mode.GetType() < EWeaponType::Bomb) {
vuln = x3c_charged[u32(mode.GetType())];
bool chargedHits;
if (weaponType < EWeaponType::Bomb) {
vuln = x3c_charged[u32(weaponType)];
if (!checkDirect) {
chargedHits = is_not_deflect(vuln);
} else if (is_deflect_direct(vuln)) {
} else if (vuln == EVulnerability::Deflect ||
(static_cast<EVulnerability>((u32)vuln - (u32)EVulnerability::DirectWeak) <= EVulnerability::Normal) ||
vuln == EVulnerability::DirectImmune) {
chargedHits = false;
} else {
chargedHits = true;
}
} else {
chargedHits = true;
}
bool comboedHits = true;
if (mode.GetType() < EWeaponType::Bomb) {
vuln = x4c_combo[u32(mode.GetType())];
bool comboedHits;
if (weaponType < EWeaponType::Bomb) {
vuln = x4c_combo[u32(weaponType)];
if (!checkDirect) {
comboedHits = is_not_deflect(vuln);
} else if (is_deflect_direct(vuln)) {
} else if (vuln == EVulnerability::Deflect ||
(static_cast<EVulnerability>((u32)vuln - (u32)EVulnerability::DirectWeak) <= EVulnerability::Normal ||
vuln == EVulnerability::DirectImmune)) {
comboedHits = false;
} else {
comboedHits = true;
}
} else {
comboedHits = true;
}
if (normalHits && !mode.IsCharged() && !mode.IsComboed()) {
return true;
bool result = false;
if ((normalHits && !mode.IsCharged() && !mode.IsComboed()) || (chargedHits && mode.IsCharged()) ||
(comboedHits && mode.IsComboed())) {
result = true;
}
if (!chargedHits || !mode.IsCharged()) {
if (!comboedHits) {
return false;
}
if (!mode.IsComboed()) {
return false;
}
}
return true;
return result;
}
EVulnerability CDamageVulnerability::GetVulnerability(const CWeaponMode& mode, bool ignoreDirect) const {