added back frame skipping
This commit is contained in:
parent
5174799000
commit
14ac18de31
4 changed files with 27 additions and 10 deletions
|
|
@ -1177,6 +1177,7 @@ public:
|
||||||
float m_fearLevel; // dynamic fear level (in game)
|
float m_fearLevel; // dynamic fear level (in game)
|
||||||
float m_nextEmotionUpdate; // next time to sanitize emotions
|
float m_nextEmotionUpdate; // next time to sanitize emotions
|
||||||
float m_thinkFps; // skip some frames in bot thinking
|
float m_thinkFps; // skip some frames in bot thinking
|
||||||
|
float m_thinkInterval; // interval between frames
|
||||||
|
|
||||||
int m_actMessageIndex; // current processed message
|
int m_actMessageIndex; // current processed message
|
||||||
int m_pushMessageIndex; // offset for next pushed message
|
int m_pushMessageIndex; // offset for next pushed message
|
||||||
|
|
@ -1239,8 +1240,15 @@ public:
|
||||||
inline Vector Center (void) { return (pev->absmax + pev->absmin) * 0.5; };
|
inline Vector Center (void) { return (pev->absmax + pev->absmin) * 0.5; };
|
||||||
inline Vector EyePosition (void) { return pev->origin + pev->view_ofs; };
|
inline Vector EyePosition (void) { return pev->origin + pev->view_ofs; };
|
||||||
|
|
||||||
|
// things that should be executed every frame
|
||||||
|
void ThinkFrame (void);
|
||||||
|
|
||||||
|
// the main function that decides intervals of running bot ai
|
||||||
void ThinkMain (void);
|
void ThinkMain (void);
|
||||||
|
|
||||||
|
/// the things that can be executed while skipping frames
|
||||||
void Think (void);
|
void Think (void);
|
||||||
|
|
||||||
void NewRound (void);
|
void NewRound (void);
|
||||||
void EquipInBuyzone (int buyCount);
|
void EquipInBuyzone (int buyCount);
|
||||||
void PushMessageQueue (int message);
|
void PushMessageQueue (int message);
|
||||||
|
|
|
||||||
|
|
@ -733,7 +733,7 @@ void Bot::FindItem (void)
|
||||||
{
|
{
|
||||||
allowPickup = false;
|
allowPickup = false;
|
||||||
|
|
||||||
if (!m_defendedBomb && m_personality != PERSONALITY_RUSHER && Random.Long (0, 100) < 80)
|
if (!m_defendedBomb)
|
||||||
{
|
{
|
||||||
m_defendedBomb = true;
|
m_defendedBomb = true;
|
||||||
|
|
||||||
|
|
@ -2869,19 +2869,24 @@ void Bot::ChooseAimDirection (void)
|
||||||
m_lookAt = m_destOrigin;
|
m_lookAt = m_destOrigin;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float ThinkFps = 1.0f / 30.0f;
|
|
||||||
|
|
||||||
void Bot::ThinkMain (void)
|
void Bot::ThinkMain (void)
|
||||||
{
|
{
|
||||||
if (m_thinkFps < GetWorldTime ())
|
if (m_thinkFps <= GetWorldTime ())
|
||||||
{
|
{
|
||||||
|
// execute delayed think
|
||||||
Think ();
|
Think ();
|
||||||
|
|
||||||
// skip some frames
|
// skip some frames
|
||||||
m_thinkFps = GetWorldTime () + ThinkFps * Random.Float (0.95f, 1.05f);
|
m_thinkFps = GetWorldTime () + m_thinkInterval;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
UpdateLookAngles ();
|
ThinkFrame ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bot::ThinkFrame (void)
|
||||||
|
{
|
||||||
|
UpdateLookAngles ();
|
||||||
|
RunPlayerMovement ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bot::Think (void)
|
void Bot::Think (void)
|
||||||
|
|
|
||||||
|
|
@ -1113,6 +1113,8 @@ void Bot::NewRound (void)
|
||||||
|
|
||||||
if (Random.Long (0, 100) < 50)
|
if (Random.Long (0, 100) < 50)
|
||||||
ChatterMessage (Chatter_NewRound);
|
ChatterMessage (Chatter_NewRound);
|
||||||
|
|
||||||
|
m_thinkInterval = (1.0f / 30.0f) * Random.Float (0.95f, 1.05f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bot::Kill (void)
|
void Bot::Kill (void)
|
||||||
|
|
|
||||||
|
|
@ -3189,6 +3189,8 @@ void Bot::UpdateLookAngles (void)
|
||||||
float angleDiffYaw = AngleNormalize (direction.y - m_idealAngles.y);
|
float angleDiffYaw = AngleNormalize (direction.y - m_idealAngles.y);
|
||||||
float angleDiffPitch = AngleNormalize (direction.x - m_idealAngles.x);
|
float angleDiffPitch = AngleNormalize (direction.x - m_idealAngles.x);
|
||||||
|
|
||||||
|
const float delta = m_frameInterval;
|
||||||
|
|
||||||
if (angleDiffYaw < 1.0f && angleDiffYaw > -1.0f)
|
if (angleDiffYaw < 1.0f && angleDiffYaw > -1.0f)
|
||||||
{
|
{
|
||||||
m_lookYawVel = 0.0f;
|
m_lookYawVel = 0.0f;
|
||||||
|
|
@ -3203,8 +3205,8 @@ void Bot::UpdateLookAngles (void)
|
||||||
else if (accel < -accelerate)
|
else if (accel < -accelerate)
|
||||||
accel = -accelerate;
|
accel = -accelerate;
|
||||||
|
|
||||||
m_lookYawVel += m_frameInterval * accel;
|
m_lookYawVel += delta * accel;
|
||||||
m_idealAngles.y += m_frameInterval * m_lookYawVel;
|
m_idealAngles.y += delta * m_lookYawVel;
|
||||||
}
|
}
|
||||||
float accel = 2.0f * stiffness * angleDiffPitch - damping * m_lookPitchVel;
|
float accel = 2.0f * stiffness * angleDiffPitch - damping * m_lookPitchVel;
|
||||||
|
|
||||||
|
|
@ -3213,8 +3215,8 @@ void Bot::UpdateLookAngles (void)
|
||||||
else if (accel < -accelerate)
|
else if (accel < -accelerate)
|
||||||
accel = -accelerate;
|
accel = -accelerate;
|
||||||
|
|
||||||
m_lookPitchVel += m_frameInterval * accel;
|
m_lookPitchVel += delta * accel;
|
||||||
m_idealAngles.x += m_frameInterval * m_lookPitchVel;
|
m_idealAngles.x += delta * m_lookPitchVel;
|
||||||
|
|
||||||
if (m_idealAngles.x < -89.0f)
|
if (m_idealAngles.x < -89.0f)
|
||||||
m_idealAngles.x = -89.0f;
|
m_idealAngles.x = -89.0f;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue