diff --git a/src/combat.cpp b/src/combat.cpp index 85558fc..b8affd6 100644 --- a/src/combat.cpp +++ b/src/combat.cpp @@ -135,7 +135,7 @@ bool Bot::isEnemyInDarkArea (edict_t *enemy) { const auto scolor = illum.getSkyColor (); // check if node near the enemy have a degraded light level - const auto enemyNodeIndex = graph.getNearest (m_enemy->v.origin); + const auto enemyNodeIndex = graph.getNearest (enemy->v.origin); if (!graph.exists (enemyNodeIndex)) { return false; @@ -273,12 +273,12 @@ bool Bot::checkBodyPartsWithHitboxes (edict_t *target) { const auto hitsTarget = [&] () -> bool { return result.flFraction >= 1.0f || result.pHit == target; }; + m_enemyParts = Visibility::None; // creatures can't hurt behind anything const auto ignoreFlags = m_isCreature ? TraceIgnore::None : TraceIgnore::Everything; // get the stomach hitbox - m_enemyParts = Visibility::None; game.testLine (eyes, m_hitboxEnumerator->get (target, PlayerPart::Stomach, refresh), ignoreFlags, self, &result); if (hitsTarget ()) { @@ -287,7 +287,6 @@ bool Bot::checkBodyPartsWithHitboxes (edict_t *target) { } // get the stomach hitbox - m_enemyParts = Visibility::None; game.testLine (eyes, m_hitboxEnumerator->get (target, PlayerPart::Head, refresh), ignoreFlags, self, &result); if (hitsTarget ()) { @@ -300,7 +299,6 @@ bool Bot::checkBodyPartsWithHitboxes (edict_t *target) { } // get the left hitbox - m_enemyParts = Visibility::None; game.testLine (eyes, m_hitboxEnumerator->get (target, PlayerPart::LeftArm, refresh), ignoreFlags, self, &result); if (hitsTarget ()) { @@ -311,7 +309,6 @@ bool Bot::checkBodyPartsWithHitboxes (edict_t *target) { } // get the right hitbox - m_enemyParts = Visibility::None; game.testLine (eyes, m_hitboxEnumerator->get (target, PlayerPart::RightArm, refresh), ignoreFlags, self, &result); if (hitsTarget ()) { @@ -322,7 +319,6 @@ bool Bot::checkBodyPartsWithHitboxes (edict_t *target) { } // get the feet spot - m_enemyParts = Visibility::None; game.testLine (eyes, m_hitboxEnumerator->get (target, PlayerPart::Feet, refresh), ignoreFlags, self, &result); if (hitsTarget ()) { diff --git a/src/engine.cpp b/src/engine.cpp index 5a04ab1..b3ca8fe 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -1496,27 +1496,25 @@ void PlayerHitboxEnumerator::update (edict_t *ent) { parts->head.z += bboxset[hitbox].bbmax.z; parts->head = { ent->v.origin.x, ent->v.origin.y, parts->head.z }; } - hitbox = kInvalidHitbox; // get the body (stomach) hitbox = getHitbox (studiohdr, bboxset, PlayerPart::Stomach); - if (hitbox != kInfiniteDistance) { + if (hitbox != kInvalidHitbox) { engfuncs.pfnGetBonePosition (ent, bboxset[hitbox].bone, parts->stomach, nullptr); } - hitbox = kInvalidHitbox; // get the left (arm) hitbox = getHitbox (studiohdr, bboxset, PlayerPart::LeftArm); - if (hitbox != kInfiniteDistance) { + if (hitbox != kInvalidHitbox) { engfuncs.pfnGetBonePosition (ent, bboxset[hitbox].bone, parts->left, nullptr); } // get the right (arm) hitbox = getHitbox (studiohdr, bboxset, PlayerPart::RightArm); - if (hitbox != kInfiniteDistance) { + if (hitbox != kInvalidHitbox) { engfuncs.pfnGetBonePosition (ent, bboxset[hitbox].bone, parts->right, nullptr); } return; diff --git a/src/vision.cpp b/src/vision.cpp index f0f7d06..e661aea 100644 --- a/src/vision.cpp +++ b/src/vision.cpp @@ -286,7 +286,6 @@ void Bot::updateLookAnglesNewbie (const Vector &direction, float delta) { const float offsetDelay = 1.2f; Vector stiffness {}; - Vector randomize {}; m_idealAngles = direction.get2d (); m_idealAngles.clampAngles (); @@ -303,6 +302,8 @@ void Bot::updateLookAnglesNewbie (const Vector &direction, float delta) { && ((pev->velocity.length () > 1.0f && m_angularDeviation.length () < 5.0f) || m_angularDeviation.length () < 1.0f)) { + Vector randomize {}; + // is the bot standing still ? if (pev->velocity.length () < 1.0f) { randomize = randomization * 0.2f; // randomize less