diff --git a/include/core.h b/include/core.h index 390fd9f..7a23d40 100644 --- a/include/core.h +++ b/include/core.h @@ -909,10 +909,7 @@ private: float m_frameInterval; // bot's frame interval float m_lastCommandTime; // time bot last thinked - - float m_msecDel; - float m_msecVal; - float m_msecNum; + float m_msecValRest; // bot's msec value float m_reloadCheckTime; // time to check reloading float m_zoomCheckTime; // time to check zoom again diff --git a/source/basecode.cpp b/source/basecode.cpp index 5f5aeb8..d111506 100644 --- a/source/basecode.cpp +++ b/source/basecode.cpp @@ -5774,29 +5774,27 @@ void Bot::MoveToVector (Vector to) byte Bot::ThrottledMsec (void) { // estimate msec to use for this command based on time passed from the previous command - if (m_msecDel + m_msecNum / 1000 < GetWorldTime () - 0.5f || m_msecDel > GetWorldTime ()) - { - m_msecDel = GetWorldTime () - 0.05f; - m_msecNum = 0; - } + float msecVal = (GetWorldTime () - m_lastCommandTime) * 1000.0f; - byte newMsec = (GetWorldTime () - m_msecDel) * 1000 - m_msecNum; // optimal msec value since start of 1 sec period - m_msecNum = (GetWorldTime () - m_msecDel) * 1000; // value we have to add to reach optimum + int msecRest = 0; + byte newMsec = static_cast (msecVal); - // do we have to start a new 1 sec period? - if (m_msecNum > 1000) + if (newMsec < 10) { - m_msecDel += m_msecNum / 1000; - m_msecNum = 0; + msecVal = msecVal - static_cast (newMsec) + m_msecValRest; + msecRest = static_cast (msecVal); + + m_msecValRest = msecVal - static_cast (msecRest); } + newMsec += msecRest; // bots are going to be slower than they should if this happens. - if (newMsec > 255) - newMsec = 255; + if (newMsec > 100) + newMsec = 100; else if (newMsec < 1) newMsec = 1; - return static_cast (newMsec); + return newMsec; } void Bot::RunPlayerMovement (void) diff --git a/source/manager.cpp b/source/manager.cpp index 8d680dd..5a6c958 100644 --- a/source/manager.cpp +++ b/source/manager.cpp @@ -793,10 +793,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member) m_lastCommandTime = GetWorldTime () - 0.1f; m_frameInterval = GetWorldTime (); - - m_msecDel = 0.0f; - m_msecVal = 0.0f; - m_msecNum = 0.0f; + m_msecValRest = 0.0f; m_timePeriodicUpdate = 0.0f;