mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-05-13 16:31:21 +00:00
CDamageVulnerability: Use matching functions for WeaponHits/Hurts
This commit is contained in:
parent
6c449ca146
commit
75630c87bd
@ -108,9 +108,14 @@ EDeflectType CDamageVulnerability::GetDeflectionType(const CWeaponMode& mode) co
|
|||||||
return x5c_deflected;
|
return x5c_deflected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool check_hurts(EVulnerability vuln, bool direct) {
|
||||||
|
return direct == 0
|
||||||
|
? (is_normal_or_weak(vuln) || vuln == EVulnerability::DirectWeak || vuln == EVulnerability::DirectNormal)
|
||||||
|
: is_normal_or_weak(vuln);
|
||||||
|
}
|
||||||
|
|
||||||
bool CDamageVulnerability::WeaponHurts(const CWeaponMode& mode, bool ignoreDirect) const {
|
bool CDamageVulnerability::WeaponHurts(const CWeaponMode& mode, bool ignoreDirect) const {
|
||||||
EWeaponType weaponType = mode.GetType();
|
if (mode.GetType() < EWeaponType::Power || mode.GetType() > EWeaponType::OrangePhazon) {
|
||||||
if (weaponType < EWeaponType::Power || weaponType > EWeaponType::OrangePhazon) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,102 +123,50 @@ bool CDamageVulnerability::WeaponHurts(const CWeaponMode& mode, bool ignoreDirec
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
EVulnerability vuln = x0_normal[u32(weaponType)];
|
bool normalHurts = check_hurts(x0_normal[u32(mode.GetType())], ignoreDirect);
|
||||||
bool normalHurts = ignoreDirect == 0 ? (is_normal_or_weak(vuln) || vuln == EVulnerability::DirectWeak ||
|
bool chargedHurts =
|
||||||
vuln == EVulnerability::DirectNormal)
|
(mode.GetType() < EWeaponType::Bomb) ? check_hurts(x3c_charged[u32(mode.GetType())], ignoreDirect) : true;
|
||||||
: is_normal_or_weak(vuln);
|
bool comboedHurts =
|
||||||
|
(mode.GetType() < EWeaponType::Bomb) ? check_hurts(x4c_combo[u32(mode.GetType())], ignoreDirect) : true;
|
||||||
|
|
||||||
bool chargedHurts;
|
return (normalHurts && !mode.IsCharged() && !mode.IsComboed()) || (chargedHurts && mode.IsCharged()) ||
|
||||||
if (weaponType < EWeaponType::Bomb) {
|
(comboedHurts && mode.IsComboed());
|
||||||
vuln = x3c_charged[u32(weaponType)];
|
}
|
||||||
chargedHurts = ignoreDirect == 0 ? (is_normal_or_weak(vuln) || vuln == EVulnerability::DirectWeak ||
|
|
||||||
vuln == EVulnerability::DirectNormal)
|
static inline bool check_hits(EVulnerability vuln, bool direct) {
|
||||||
: is_normal_or_weak(vuln);
|
if (!direct) {
|
||||||
;
|
return is_not_deflect(vuln);
|
||||||
} else {
|
|
||||||
chargedHurts = true;
|
|
||||||
}
|
}
|
||||||
|
if (vuln == EVulnerability::Deflect ||
|
||||||
bool comboedHurts;
|
(static_cast<EVulnerability>(static_cast<u32>(vuln) - static_cast<u32>(EVulnerability::DirectWeak)) <=
|
||||||
if (weaponType < EWeaponType::Bomb) {
|
EVulnerability::Normal) ||
|
||||||
vuln = x3c_charged[u32(weaponType)];
|
vuln == EVulnerability::DirectImmune) {
|
||||||
comboedHurts = ignoreDirect == 0 ? (is_normal_or_weak(vuln) || vuln == EVulnerability::DirectWeak ||
|
return false;
|
||||||
vuln == EVulnerability::DirectNormal)
|
|
||||||
: is_normal_or_weak(vuln);
|
|
||||||
;
|
|
||||||
} else {
|
|
||||||
comboedHurts = true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
bool result = false;
|
|
||||||
if ((normalHurts && !mode.IsCharged() && !mode.IsComboed()) || (chargedHurts && mode.IsCharged()) ||
|
|
||||||
(comboedHurts && mode.IsComboed())) {
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CDamageVulnerability::WeaponHits(const CWeaponMode& mode, bool checkDirect) const {
|
bool CDamageVulnerability::WeaponHits(const CWeaponMode& mode, bool checkDirect) const {
|
||||||
const EWeaponType weaponType = mode.GetType();
|
if (mode.GetType() < EWeaponType::Power || mode.GetType() > EWeaponType::OrangePhazon) {
|
||||||
if (weaponType < EWeaponType::Power || weaponType > EWeaponType::OrangePhazon) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (mode.IsInstantKill()) {
|
if (mode.IsInstantKill()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
EVulnerability vuln = x0_normal[u32(weaponType)];
|
bool normalHits = check_hits(x0_normal[u32(mode.GetType())], checkDirect);
|
||||||
bool normalHits;
|
bool chargedHits =
|
||||||
if (!checkDirect) {
|
mode.GetType() < EWeaponType::Bomb ? check_hits(x3c_charged[u32(mode.GetType())], checkDirect) : true;
|
||||||
normalHits = is_not_deflect(vuln);
|
bool comboedHits =
|
||||||
} else if (vuln == EVulnerability::Deflect ||
|
mode.GetType() < EWeaponType::Bomb ? check_hits(x4c_combo[u32(mode.GetType())], checkDirect) : true;
|
||||||
(static_cast<EVulnerability>((u32)vuln - (u32)EVulnerability::DirectWeak) <= EVulnerability::Normal) ||
|
|
||||||
vuln == EVulnerability::DirectImmune) {
|
|
||||||
normalHits = false;
|
|
||||||
} else {
|
|
||||||
normalHits = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool chargedHits;
|
|
||||||
if (weaponType < EWeaponType::Bomb) {
|
|
||||||
vuln = x3c_charged[u32(weaponType)];
|
|
||||||
if (!checkDirect) {
|
|
||||||
chargedHits = is_not_deflect(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;
|
|
||||||
if (weaponType < EWeaponType::Bomb) {
|
|
||||||
vuln = x4c_combo[u32(weaponType)];
|
|
||||||
if (!checkDirect) {
|
|
||||||
comboedHits = is_not_deflect(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;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
if ((normalHits && !mode.IsCharged() && !mode.IsComboed()) || (chargedHits && mode.IsCharged()) ||
|
if ((normalHits && !mode.IsCharged() && !mode.IsComboed()) || (chargedHits && mode.IsCharged()) ||
|
||||||
(comboedHits && mode.IsComboed())) {
|
(comboedHits && mode.IsComboed())) {
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return (normalHits && !mode.IsCharged() && !mode.IsComboed()) || (chargedHits && mode.IsCharged()) ||
|
||||||
|
(comboedHits && mode.IsComboed());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline EVulnerability direct_to_normal(EVulnerability vuln) {
|
inline EVulnerability direct_to_normal(EVulnerability vuln) {
|
||||||
@ -233,7 +186,7 @@ EVulnerability CDamageVulnerability::GetVulnerability(const CWeaponMode& mode, b
|
|||||||
if (mode.GetType() < EWeaponType::Power || mode.GetType() > EWeaponType::OrangePhazon) {
|
if (mode.GetType() < EWeaponType::Power || mode.GetType() > EWeaponType::OrangePhazon) {
|
||||||
return EVulnerability::Deflect;
|
return EVulnerability::Deflect;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode.IsInstantKill()) {
|
if (mode.IsInstantKill()) {
|
||||||
return EVulnerability::Normal;
|
return EVulnerability::Normal;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user