fix: comparison typo in body checks

This commit is contained in:
jeefo 2023-05-08 00:57:46 +03:00
commit e38bca9c14
No known key found for this signature in database
GPG key ID: 927BCA0779BEA8ED

View file

@ -135,10 +135,14 @@ bool Bot::checkBodyParts (edict_t *target) {
// creatures can't hurt behind anything // creatures can't hurt behind anything
auto ignoreFlags = m_isCreature ? TraceIgnore::None : TraceIgnore::Everything; auto ignoreFlags = m_isCreature ? TraceIgnore::None : TraceIgnore::Everything;
const auto hitsTarget = [&] () -> bool {
return result.flFraction >= 1.0f || result.pHit == target;
};
m_enemyParts = Visibility::None; m_enemyParts = Visibility::None;
game.testLine (eyes, spot, ignoreFlags, self, &result); game.testLine (eyes, spot, ignoreFlags, self, &result);
if (result.flFraction >= 1.0f && result.pHit == target) { if (hitsTarget ()) {
m_enemyParts |= Visibility::Body; m_enemyParts |= Visibility::Body;
m_enemyOrigin = result.vecEndPos; m_enemyOrigin = result.vecEndPos;
} }
@ -147,7 +151,7 @@ bool Bot::checkBodyParts (edict_t *target) {
spot.z += 25.0f; spot.z += 25.0f;
game.testLine (eyes, spot, ignoreFlags, self, &result); game.testLine (eyes, spot, ignoreFlags, self, &result);
if (result.flFraction >= 1.0f && result.pHit == target) { if (hitsTarget ()) {
m_enemyParts |= Visibility::Head; m_enemyParts |= Visibility::Head;
m_enemyOrigin = result.vecEndPos; m_enemyOrigin = result.vecEndPos;
} }
@ -167,7 +171,7 @@ bool Bot::checkBodyParts (edict_t *target) {
} }
game.testLineChannel (TraceChannel::Enemy, eyes, spot, ignoreFlags, self, result); game.testLineChannel (TraceChannel::Enemy, eyes, spot, ignoreFlags, self, result);
if (result.flFraction >= 1.0f && result.pHit == target) { if (hitsTarget ()) {
m_enemyParts |= Visibility::Other; m_enemyParts |= Visibility::Other;
m_enemyOrigin = result.vecEndPos; m_enemyOrigin = result.vecEndPos;
@ -182,7 +186,7 @@ bool Bot::checkBodyParts (edict_t *target) {
game.testLineChannel (TraceChannel::Enemy, eyes, spot, ignoreFlags, self, result); game.testLineChannel (TraceChannel::Enemy, eyes, spot, ignoreFlags, self, result);
if (result.flFraction >= 1.0f && result.pHit == target) { if (hitsTarget ()) {
m_enemyParts |= Visibility::Other; m_enemyParts |= Visibility::Other;
m_enemyOrigin = result.vecEndPos; m_enemyOrigin = result.vecEndPos;
@ -192,7 +196,7 @@ bool Bot::checkBodyParts (edict_t *target) {
game.testLineChannel (TraceChannel::Enemy, eyes, spot, ignoreFlags, self, result); game.testLineChannel (TraceChannel::Enemy, eyes, spot, ignoreFlags, self, result);
if (result.flFraction >= 1.0f && result.pHit == target) { if (hitsTarget ()) {
m_enemyParts |= Visibility::Other; m_enemyParts |= Visibility::Other;
m_enemyOrigin = result.vecEndPos; m_enemyOrigin = result.vecEndPos;