remove of pod-bot-mm msec method

fixed weird aiming on low fps machines
fixed potential crash bug in weaponn selection code
This commit is contained in:
jeefo 2015-08-03 00:05:27 +03:00
commit ac3a5c7c3f
6 changed files with 14 additions and 31 deletions

View file

@ -905,7 +905,6 @@ private:
float m_frameInterval; // bot's frame interval
float m_lastCommandTime; // time bot last thinked
float m_msecValRest; // bot's msec value
float m_reloadCheckTime; // time to check reloading
float m_zoomCheckTime; // time to check zoom again

View file

@ -225,10 +225,15 @@ namespace Math
#endif
}
inline float AngleDiff (float destAngle, float srcAngle)
static inline float AngleDiff (float destAngle, float srcAngle)
{
return AngleNormalize (destAngle - srcAngle);
}
template <typename Type> Type Clamp (Type x, Type a, Type b)
{
return x < a ? a : (x > b ? b : x);
}
}
//

View file

@ -3206,7 +3206,7 @@ void Bot::RunTask_Normal (void)
m_moveSpeed = GetWalkSpeed ();
// bot hasn't seen anything in a long time and is asking his teammates to report in
if (m_seeEnemyTime + Random.Float (30.0, 80.0) < GetWorldTime () && Random.Long (0, 100) < 70 && g_timeRoundStart + 20.0 < GetWorldTime () && m_askCheckTime + Random.Float (20.0, 30.0) < GetWorldTime ())
if (m_seeEnemyTime + Random.Float (45.0f, 80.0f) < GetWorldTime () && Random.Long (0, 100) < 30 && g_timeRoundStart + 20.0 < GetWorldTime () && m_askCheckTime + Random.Float (20.0, 30.0) < GetWorldTime ())
{
m_askCheckTime = GetWorldTime ();
RadioMessage (Radio_ReportTeam);
@ -5695,27 +5695,6 @@ void Bot::MoveToVector (const Vector &to)
byte Bot::ThrottledMsec (void)
{
// estimate msec to use for this command based on time passed from the previous command
#if 0
float msecVal = (GetWorldTime () - m_lastCommandTime) * 1000.0f;
int msecRest = 0;
byte newMsec = static_cast <byte> (msecVal);
if (newMsec < 10)
{
msecVal -= static_cast <float> (newMsec) + m_msecValRest;
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.
if (newMsec > 100)
newMsec = 100;
else if (newMsec < 1)
newMsec = 1;
#endif
byte adjustedMsec = static_cast <byte> ((GetWorldTime () - m_lastCommandTime) * 1000.0f);

View file

@ -1421,7 +1421,7 @@ void Bot::SelectBestWeapon (void)
ammoLeft = true;
// is no ammo required for this weapon OR enough ammo available to fire
if (g_weaponDefs[id].ammo1 < 0 || m_ammo[g_weaponDefs[id].ammo1] >= selectTab[selectIndex].minPrimaryAmmo)
if (g_weaponDefs[id].ammo1 < 0 || (g_weaponDefs[id].ammo1 < 32 && m_ammo[g_weaponDefs[id].ammo1] >= selectTab[selectIndex].minPrimaryAmmo))
ammoLeft = true;
if (ammoLeft)

View file

@ -837,7 +837,6 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, c
m_lastCommandTime = GetWorldTime () - 0.1f;
m_frameInterval = GetWorldTime ();
m_msecValRest = 0.0f;
m_timePeriodicUpdate = 0.0f;
switch (personality)
@ -1089,8 +1088,9 @@ void Bot::NewRound (void)
m_isUsingGrenade = false;
m_blindButton = 0;
m_blindTime = 0.0;
m_jumpTime = 0.0;
m_blindTime = 0.0f;
m_jumpTime = 0.0f;
m_jumpStateTimer = 0.0f;
m_jumpFinished = false;
m_isStuck = false;

View file

@ -3154,7 +3154,7 @@ void Bot::UpdateBodyAngles (void)
void Bot::UpdateLookAngles (void)
{
const float delta = GetWorldTime () - m_lookUpdateTime;
const float delta = Clamp <float> (GetWorldTime () - m_lookUpdateTime, MATH_EQEPSILON, 0.05f);
m_lookUpdateTime = GetWorldTime ();
// adjust all body and view angles to face an absolute vector
@ -3188,8 +3188,8 @@ void Bot::UpdateLookAngles (void)
m_idealAngles = pev->v_angle;
float angleDiffYaw = AngleNormalize (direction.y - m_idealAngles.y);
float angleDiffPitch = AngleNormalize (direction.x - m_idealAngles.x);
float angleDiffYaw = AngleDiff (direction.y, m_idealAngles.y);
float angleDiffPitch = AngleDiff (direction.x, m_idealAngles.x);
if (angleDiffYaw < 1.0f && angleDiffYaw > -1.0f)
{