continue to play with msec ;)
This commit is contained in:
parent
d4a6a30d3a
commit
b8cb81f97a
3 changed files with 29 additions and 4 deletions
|
|
@ -910,6 +910,10 @@ 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_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
|
||||||
float m_shieldCheckTime; // time to check shiled drawing again
|
float m_shieldCheckTime; // time to check shiled drawing again
|
||||||
|
|
@ -1041,7 +1045,7 @@ private:
|
||||||
int GetBestSecondaryWeaponCarried (void);
|
int GetBestSecondaryWeaponCarried (void);
|
||||||
|
|
||||||
void RunPlayerMovement (void);
|
void RunPlayerMovement (void);
|
||||||
byte ThrottledMsec (float input);
|
byte ThrottledMsec (void);
|
||||||
void GetValidWaypoint (void);
|
void GetValidWaypoint (void);
|
||||||
void ChangeWptIndex (int waypointIndex);
|
void ChangeWptIndex (int waypointIndex);
|
||||||
bool IsDeadlyDrop (Vector targetOriginPos);
|
bool IsDeadlyDrop (Vector targetOriginPos);
|
||||||
|
|
|
||||||
|
|
@ -5771,14 +5771,30 @@ void Bot::MoveToVector (Vector to)
|
||||||
FindPath (m_currentWaypointIndex, g_waypoint->FindNearest (to), 0);
|
FindPath (m_currentWaypointIndex, g_waypoint->FindNearest (to), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte Bot::ThrottledMsec (float input)
|
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
|
||||||
int newMsec = static_cast <int> (input * 1000);
|
if (m_msecDel + m_msecNum / 1000 < GetWorldTime () - 0.5f || m_msecDel > GetWorldTime ())
|
||||||
|
{
|
||||||
|
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
|
||||||
|
m_msecNum = (GetWorldTime () - m_msecDel) * 1000; // value we have to add to reach optimum
|
||||||
|
|
||||||
|
// do we have to start a new 1 sec period?
|
||||||
|
if (m_msecNum > 1000)
|
||||||
|
{
|
||||||
|
m_msecDel += m_msecNum / 1000;
|
||||||
|
m_msecNum = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// 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 > 255)
|
||||||
newMsec = 255;
|
newMsec = 255;
|
||||||
|
else if (newMsec < 1)
|
||||||
|
newMsec = 1;
|
||||||
|
|
||||||
return static_cast <byte> (newMsec);
|
return static_cast <byte> (newMsec);
|
||||||
}
|
}
|
||||||
|
|
@ -5801,7 +5817,7 @@ void Bot::RunPlayerMovement (void)
|
||||||
|
|
||||||
m_frameInterval = GetWorldTime () - m_lastCommandTime;
|
m_frameInterval = GetWorldTime () - m_lastCommandTime;
|
||||||
|
|
||||||
byte msecVal = ThrottledMsec (m_frameInterval);
|
byte msecVal = ThrottledMsec ();
|
||||||
m_lastCommandTime = GetWorldTime ();
|
m_lastCommandTime = GetWorldTime ();
|
||||||
|
|
||||||
(*g_engfuncs.pfnRunPlayerMove) (pev->pContainingEntity, m_moveAngles, m_moveSpeed, m_strafeSpeed, 0.0, pev->button, pev->impulse, msecVal);
|
(*g_engfuncs.pfnRunPlayerMove) (pev->pContainingEntity, m_moveAngles, m_moveSpeed, m_strafeSpeed, 0.0, pev->button, pev->impulse, msecVal);
|
||||||
|
|
|
||||||
|
|
@ -793,6 +793,11 @@ 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_msecDel = 0.0f;
|
||||||
|
m_msecVal = 0.0f;
|
||||||
|
m_msecNum = 0.0f;
|
||||||
|
|
||||||
m_timePeriodicUpdate = 0.0f;
|
m_timePeriodicUpdate = 0.0f;
|
||||||
|
|
||||||
bot->v.idealpitch = bot->v.v_angle.x;
|
bot->v.idealpitch = bot->v.v_angle.x;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue