From 9ae7c38b804bd93996b4b3b2eca9b3a8170b875a Mon Sep 17 00:00:00 2001 From: commandcobra7 <91374215+commandcobra7@users.noreply.github.com> Date: Mon, 15 May 2023 11:44:02 +0300 Subject: [PATCH] fix: removed unnecessary codes in ladder handling fix: collision case the bot can jump if it's not on the ladder, so it won't press the jump button when going up the ladder --- src/botlib.cpp | 4 ++-- src/navigate.cpp | 12 ++---------- src/vision.cpp | 2 +- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/botlib.cpp b/src/botlib.cpp index a99fc29..546ce3c 100644 --- a/src/botlib.cpp +++ b/src/botlib.cpp @@ -1608,7 +1608,7 @@ void Bot::refreshEnemyPredict () { if (game.isNullEntity (m_enemy) && !game.isNullEntity (m_lastEnemy) && !m_lastEnemyOrigin.empty ()) { const auto distanceToLastEnemySq = m_lastEnemyOrigin.distanceSq (pev->origin); - if (distanceToLastEnemySq > cr::sqrf (384.0f) && (distanceToLastEnemySq < cr::sqrf (1600.0f) || usesSniper ())) { + if (distanceToLastEnemySq > cr::sqrf (384.0f) && (distanceToLastEnemySq < cr::sqrf (2048.0f) || usesSniper ())) { m_aimFlags |= AimFlags::PredictPath; } const bool denyLastEnemy = pev->velocity.lengthSq2d () > 0.0f && distanceToLastEnemySq < cr::sqrf (256.0f); @@ -2653,7 +2653,7 @@ void Bot::frame () { } // clear enemy far away - if (!m_lastEnemyOrigin.empty () && !game.isNullEntity (m_lastEnemy) && pev->origin.distanceSq (m_lastEnemyOrigin) >= cr::sqrf (2048.0)) { + if (!m_lastEnemyOrigin.empty () && !game.isNullEntity (m_lastEnemy) && pev->origin.distanceSq (m_lastEnemyOrigin) >= cr::sqrf (2048.0f)) { m_lastEnemy = nullptr; m_lastEnemyOrigin = nullptr; } diff --git a/src/navigate.cpp b/src/navigate.cpp index 6c2ba7e..7b0e84b 100644 --- a/src/navigate.cpp +++ b/src/navigate.cpp @@ -694,7 +694,7 @@ void Bot::checkTerrain (float movedDistance, const Vector &dirNormal) { if (m_collStateIndex < kMaxCollideMoves) { switch (m_collideMoves[m_collStateIndex]) { case CollisionState::Jump: - if (isOnFloor () || isInWater ()) { + if ((isOnFloor () || isInWater ()) && !isOnLadder ()) { pev->button |= IN_JUMP; } break; @@ -888,15 +888,7 @@ bool Bot::updateNavigation () { } } - if (m_pathFlags & NodeFlag::Ladder) { - if (!m_pathWalk.empty ()) { - if (m_pathWalk.hasNext ()) { - if (graph[m_pathWalk.next ()].flags & NodeFlag::Ladder || isOnLadder ()) { - m_path->radius = 17.0f; - } - } - } - + if ((m_pathFlags & NodeFlag::Ladder) || isOnLadder ()) { if (graph.exists (m_previousNodes[0]) && (graph[m_previousNodes[0]].flags & NodeFlag::Ladder)) { if (cr::abs (m_pathOrigin.z - pev->origin.z) > 5.0f) { m_pathOrigin.z += pev->origin.z - m_pathOrigin.z; diff --git a/src/vision.cpp b/src/vision.cpp index 09c2595..e1072b5 100644 --- a/src/vision.cpp +++ b/src/vision.cpp @@ -199,7 +199,7 @@ void Bot::updateAimDir () { auto dangerIndex = practice.getIndex (m_team, m_currentNodeIndex, m_currentNodeIndex); if (graph.exists (dangerIndex) && vistab.visible (m_currentNodeIndex, dangerIndex) && !(graph[dangerIndex].flags & NodeFlag::Crouch)) { - if (pev->origin.distanceSq (graph[dangerIndex].origin) < cr::sqrf (160.0f)) { + if (pev->origin.distanceSq (graph[dangerIndex].origin) < cr::sqrf (512.0f)) { m_lookAt = m_destOrigin; } else {