ok, got the msec code from podbot_mm, thx kwo
This commit is contained in:
parent
b8cb81f97a
commit
0314cee6d3
3 changed files with 14 additions and 22 deletions
|
|
@ -909,10 +909,7 @@ private:
|
||||||
|
|
||||||
float m_frameInterval; // bot's frame interval
|
float m_frameInterval; // bot's frame interval
|
||||||
float m_lastCommandTime; // time bot last thinked
|
float m_lastCommandTime; // time bot last thinked
|
||||||
|
float m_msecValRest; // bot's msec value
|
||||||
float m_msecDel;
|
|
||||||
float m_msecVal;
|
|
||||||
float m_msecNum;
|
|
||||||
|
|
||||||
float m_reloadCheckTime; // time to check reloading
|
float m_reloadCheckTime; // time to check reloading
|
||||||
float m_zoomCheckTime; // time to check zoom again
|
float m_zoomCheckTime; // time to check zoom again
|
||||||
|
|
|
||||||
|
|
@ -5774,29 +5774,27 @@ void Bot::MoveToVector (Vector to)
|
||||||
byte Bot::ThrottledMsec (void)
|
byte Bot::ThrottledMsec (void)
|
||||||
{
|
{
|
||||||
// estimate msec to use for this command based on time passed from the previous command
|
// 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 ())
|
float msecVal = (GetWorldTime () - m_lastCommandTime) * 1000.0f;
|
||||||
{
|
|
||||||
m_msecDel = GetWorldTime () - 0.05f;
|
|
||||||
m_msecNum = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte newMsec = (GetWorldTime () - m_msecDel) * 1000 - m_msecNum; // optimal msec value since start of 1 sec period
|
int msecRest = 0;
|
||||||
m_msecNum = (GetWorldTime () - m_msecDel) * 1000; // value we have to add to reach optimum
|
byte newMsec = static_cast <byte> (msecVal);
|
||||||
|
|
||||||
// do we have to start a new 1 sec period?
|
if (newMsec < 10)
|
||||||
if (m_msecNum > 1000)
|
|
||||||
{
|
{
|
||||||
m_msecDel += m_msecNum / 1000;
|
msecVal = msecVal - static_cast <float> (newMsec) + m_msecValRest;
|
||||||
m_msecNum = 0;
|
msecRest = static_cast <int> (msecVal);
|
||||||
|
|
||||||
|
m_msecValRest = msecVal - static_cast <float> (msecRest);
|
||||||
}
|
}
|
||||||
|
newMsec += msecRest;
|
||||||
|
|
||||||
// bots are going to be slower than they should if this happens.
|
// bots are going to be slower than they should if this happens.
|
||||||
if (newMsec > 255)
|
if (newMsec > 100)
|
||||||
newMsec = 255;
|
newMsec = 100;
|
||||||
else if (newMsec < 1)
|
else if (newMsec < 1)
|
||||||
newMsec = 1;
|
newMsec = 1;
|
||||||
|
|
||||||
return static_cast <byte> (newMsec);
|
return newMsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bot::RunPlayerMovement (void)
|
void Bot::RunPlayerMovement (void)
|
||||||
|
|
|
||||||
|
|
@ -793,10 +793,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member)
|
||||||
|
|
||||||
m_lastCommandTime = GetWorldTime () - 0.1f;
|
m_lastCommandTime = GetWorldTime () - 0.1f;
|
||||||
m_frameInterval = GetWorldTime ();
|
m_frameInterval = GetWorldTime ();
|
||||||
|
m_msecValRest = 0.0f;
|
||||||
m_msecDel = 0.0f;
|
|
||||||
m_msecVal = 0.0f;
|
|
||||||
m_msecNum = 0.0f;
|
|
||||||
|
|
||||||
m_timePeriodicUpdate = 0.0f;
|
m_timePeriodicUpdate = 0.0f;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue