added back frame skipping

This commit is contained in:
jeefo 2015-07-22 23:04:43 +03:00
commit 14ac18de31
4 changed files with 27 additions and 10 deletions

View file

@ -733,7 +733,7 @@ void Bot::FindItem (void)
{
allowPickup = false;
if (!m_defendedBomb && m_personality != PERSONALITY_RUSHER && Random.Long (0, 100) < 80)
if (!m_defendedBomb)
{
m_defendedBomb = true;
@ -2869,19 +2869,24 @@ void Bot::ChooseAimDirection (void)
m_lookAt = m_destOrigin;
}
static float ThinkFps = 1.0f / 30.0f;
void Bot::ThinkMain (void)
{
if (m_thinkFps < GetWorldTime ())
if (m_thinkFps <= GetWorldTime ())
{
// execute delayed think
Think ();
// skip some frames
m_thinkFps = GetWorldTime () + ThinkFps * Random.Float (0.95f, 1.05f);
m_thinkFps = GetWorldTime () + m_thinkInterval;
}
else
UpdateLookAngles ();
ThinkFrame ();
}
void Bot::ThinkFrame (void)
{
UpdateLookAngles ();
RunPlayerMovement ();
}
void Bot::Think (void)

View file

@ -1113,6 +1113,8 @@ void Bot::NewRound (void)
if (Random.Long (0, 100) < 50)
ChatterMessage (Chatter_NewRound);
m_thinkInterval = (1.0f / 30.0f) * Random.Float (0.95f, 1.05f);
}
void Bot::Kill (void)

View file

@ -3189,6 +3189,8 @@ 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;
@ -3203,8 +3205,8 @@ void Bot::UpdateLookAngles (void)
else if (accel < -accelerate)
accel = -accelerate;
m_lookYawVel += m_frameInterval * accel;
m_idealAngles.y += m_frameInterval * m_lookYawVel;
m_lookYawVel += delta * accel;
m_idealAngles.y += delta * m_lookYawVel;
}
float accel = 2.0f * stiffness * angleDiffPitch - damping * m_lookPitchVel;
@ -3213,8 +3215,8 @@ void Bot::UpdateLookAngles (void)
else if (accel < -accelerate)
accel = -accelerate;
m_lookPitchVel += m_frameInterval * accel;
m_idealAngles.x += m_frameInterval * m_lookPitchVel;
m_lookPitchVel += delta * accel;
m_idealAngles.x += delta * m_lookPitchVel;
if (m_idealAngles.x < -89.0f)
m_idealAngles.x = -89.0f;