diff --git a/ext/crlib b/ext/crlib index 60e0b07..3e1b576 160000 --- a/ext/crlib +++ b/ext/crlib @@ -1 +1 @@ -Subproject commit 60e0b07a5f4cf630cd2ad49112129ac3e5859b5d +Subproject commit 3e1b576f85c56a1909cb49008b1b23135b390edb diff --git a/src/combat.cpp b/src/combat.cpp index 671310e..6cf551e 100644 --- a/src/combat.cpp +++ b/src/combat.cpp @@ -1266,6 +1266,11 @@ void Bot::attackMovement () { if (m_difficulty >= Difficulty::Normal && (m_jumpTime + 5.0f < game.time () && isOnFloor () && rg.get (0, 1000) < (m_isReloading ? 8 : 2) && pev->velocity.length2d () > 150.0f) && !usesSniper ()) { pev->button |= IN_JUMP; } + + // do not move forward/backward is too far + if (distance > 1024.0) { + m_moveSpeed = 0.0f; + } } else if (m_fightStyle == Fight::Stay) { const bool alreadyDucking = m_duckTime > game.time () || isDucking (); diff --git a/src/manager.cpp b/src/manager.cpp index 24d2b61..3117f67 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -15,6 +15,8 @@ ConVar cv_quota ("yb_quota", "9", "Specifies the number bots to be added to the ConVar cv_quota_mode ("yb_quota_mode", "normal", "Specifies the type of quota.\nAllowed values: 'normal', 'fill', and 'match'.\nIf 'fill', the server will adjust bots to keep N players in the game, where N is yb_quota.\nIf 'match', the server will maintain a 1:N ratio of humans to bots, where N is yb_quota_match.", false); ConVar cv_quota_match ("yb_quota_match", "0", "Number of players to match if yb_quota_mode set to 'match'", true, 0.0f, static_cast (kGameMaxPlayers)); ConVar cv_think_fps ("yb_think_fps", "26.0", "Specifies how many times per second bot code will run.", true, 24.0f, 90.0f); +ConVar cv_think_fps_disable ("yb_think_fps_disable", "0", "Allows to completely disable think fps on Xash3D.", false, 0.0f, 1.0f, Var::Xash3D); + ConVar cv_autokill_delay ("yb_autokill_delay", "0.0", "Specifies amount of time in seconds when bots will be killed if no humans left alive.", true, 0.0f, 90.0f); ConVar cv_join_after_player ("yb_join_after_player", "0", "Specifies whether bots should join server, only when at least one human player in game."); @@ -1512,12 +1514,20 @@ void Bot::newRound () { if (rg.chance (50)) { pushChatterMessage (Chatter::NewRound); } - auto interval = cr::clamp (cv_think_fps.float_ (), 24.0f, 90.0f); + auto updateInterval = 1.0f / cr::clamp (cv_think_fps.float_ (), 24.0f, 90.0f); - if (game.is (GameFlags::Xash3D) && interval < 50.0f) { - interval = 50.0f; // xash works acceptable at 50fps + if (game.is (GameFlags::Xash3D)) { + if (cv_think_fps_disable.bool_ ()) { + updateInterval = 0.0f; + } + else if (updateInterval < 50.0f) { + updateInterval = 1.0f / 50.0f; // xash3d works acceptable at 50fps + } } - m_updateInterval = game.is (GameFlags::Legacy) ? 0.0f : 1.0f / interval; + else if (game.is (GameFlags::Legacy)) { + updateInterval = 0.0f; // legacy games behaves strange, when this enabled + } + m_updateInterval = updateInterval; } void Bot::resetPathSearchType () { diff --git a/src/vision.cpp b/src/vision.cpp index 2b0399e..baa5010 100644 --- a/src/vision.cpp +++ b/src/vision.cpp @@ -133,6 +133,7 @@ void Bot::updateAimDir () { return; // do not fail instantly } m_aimFlags &= ~AimFlags::PredictPath; + m_trackingEdict = nullptr; m_lookAtPredict = nullptr; }; @@ -142,7 +143,7 @@ void Bot::updateAimDir () { int predictNode = m_lastPredictIndex; if (predictNode != kInvalidNodeIndex) { - if (!vistab.visible (m_currentNodeIndex, predictNode)) { + if (!vistab.visible (m_currentNodeIndex, predictNode) || !vistab.visible (m_previousNodes[0], predictNode)) { predictNode = kInvalidNodeIndex; } }