From 11d3ffe20e16abad9f23a1f953d41eba5ee36131 Mon Sep 17 00:00:00 2001 From: jeefo Date: Sun, 26 Jul 2015 13:02:05 +0300 Subject: [PATCH] runplayermove is now not called every frame, the same as main bot code this gives another fps boost for server perfomance, but gives a little shaky viewmodel (gun) drawing for bot while spectating him in firstperson mode. --- include/core.h | 1 + source/basecode.cpp | 2 +- source/manager.cpp | 6 +++++- source/navigate.cpp | 7 ++++--- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/core.h b/include/core.h index e377ffd..c3eb6c7 100644 --- a/include/core.h +++ b/include/core.h @@ -944,6 +944,7 @@ private: float m_lookYawVel; // look yaw velocity float m_lookPitchVel; // look pitch velocity + float m_lookUpdateTime; // lookangles update time bool m_moveToGoal; // bot currently moving to goal?? diff --git a/source/basecode.cpp b/source/basecode.cpp index 7fd53f7..2517a46 100644 --- a/source/basecode.cpp +++ b/source/basecode.cpp @@ -2886,7 +2886,7 @@ void Bot::ThinkMain (void) void Bot::ThinkFrame (void) { UpdateLookAngles (); - RunPlayerMovement (); + // RunPlayerMovement (); } void Bot::Think (void) diff --git a/source/manager.cpp b/source/manager.cpp index e9ba2aa..22170d0 100644 --- a/source/manager.cpp +++ b/source/manager.cpp @@ -220,7 +220,10 @@ Bot *BotManager::FindOneValidAliveBot (void) for (int i = 0; i < GetMaxClients (); i++) { - if (m_bots[i] != NULL && IsAlive (m_bots[i]->GetEntity ()) && foundBots.GetSize () < 5) + if (foundBots.GetSize () > 4) + break; + + if (m_bots[i] != NULL && IsAlive (m_bots[i]->GetEntity ())) foundBots.Push (i); } @@ -976,6 +979,7 @@ void Bot::NewRound (void) m_prevOrigin = Vector (9999.0, 9999.0, 9999.0); m_prevTime = GetWorldTime (); m_blindRecognizeTime = GetWorldTime (); + m_lookUpdateTime = GetWorldTime (); m_viewDistance = 4096.0; m_maxViewDistance = 4096.0; diff --git a/source/navigate.cpp b/source/navigate.cpp index 79a3458..cfe575e 100644 --- a/source/navigate.cpp +++ b/source/navigate.cpp @@ -3164,8 +3164,11 @@ void Bot::UpdateBodyAngles (void) void Bot::UpdateLookAngles (void) { + const float delta = GetWorldTime () - m_lookUpdateTime; + m_lookUpdateTime = GetWorldTime (); + // adjust all body and view angles to face an absolute vector - Vector direction = (m_lookAt - EyePosition ()).ToAngles () + pev->punchangle * (m_difficulty * 25) / 100.0; + Vector direction = (m_lookAt - EyePosition ()).ToAngles (); direction.x *= -1.0f; // invert for engine direction.ClampAngles (); @@ -3189,8 +3192,6 @@ void Bot::UpdateLookAngles (void) float angleDiffYaw = AngleNormalize (direction.y - m_idealAngles.y); float angleDiffPitch = AngleNormalize (direction.x - m_idealAngles.x); - const float delta = m_frameInterval; - if (angleDiffYaw < 1.0f && angleDiffYaw > -1.0f) { m_lookYawVel = 0.0f;