Replaced msec calculation method.
Currently used method is used by jkbotti.
This commit is contained in:
parent
2541f75a74
commit
973b336977
4 changed files with 50 additions and 16 deletions
|
|
@ -943,8 +943,8 @@ private:
|
|||
bool m_duckDefuse; // should or not bot duck to defuse bomb
|
||||
float m_duckDefuseCheckTime; // time to check for ducking for defuse
|
||||
|
||||
byte m_msecVal; // calculated msec value
|
||||
float m_msecInterval; // used for leon hartwig's method for msec calculation
|
||||
float m_msecVal; // calculated msec value
|
||||
float m_msecDel;
|
||||
|
||||
float m_frameInterval; // bot's frame interval
|
||||
float m_lastThinkTime; // time bot last thinked
|
||||
|
|
@ -1071,6 +1071,7 @@ private:
|
|||
int GetBestSecondaryWeaponCarried (void);
|
||||
|
||||
void RunPlayerMovement (void);
|
||||
void ThrottleMsec(void);
|
||||
void GetValidWaypoint (void);
|
||||
void ChangeWptIndex (int waypointIndex);
|
||||
bool IsDeadlyDrop (Vector targetOriginPos);
|
||||
|
|
|
|||
BIN
project/debug/inf.idb
Normal file
BIN
project/debug/inf.idb
Normal file
Binary file not shown.
|
|
@ -3031,10 +3031,12 @@ void Bot::Think (void)
|
|||
m_frameInterval = GetWorldTime () - m_lastThinkTime;
|
||||
m_lastThinkTime = GetWorldTime ();
|
||||
|
||||
// calculate msec value
|
||||
ThrottleMsec ();
|
||||
|
||||
// is bot movement enabled
|
||||
bool botMovement = false;
|
||||
|
||||
|
||||
if (m_notStarted) // if the bot hasn't selected stuff to start the game yet, go do that...
|
||||
StartGame (); // select team & class
|
||||
else if (!m_notKilled)
|
||||
|
|
@ -6104,6 +6106,47 @@ void Bot::MoveToVector (Vector to)
|
|||
FindPath (m_currentWaypointIndex, g_waypoint->FindNearest (to), 0);
|
||||
}
|
||||
|
||||
void Bot::ThrottleMsec (void)
|
||||
{
|
||||
m_msecVal = static_cast <int> (m_frameInterval * 1000.0);
|
||||
|
||||
// count up difference that integer conversion caused
|
||||
m_msecDel += m_frameInterval * 1000.0 - m_msecVal;
|
||||
|
||||
// remove effect of integer conversion and lost msecs on previous frames
|
||||
if (m_msecDel > 1.625f)
|
||||
{
|
||||
float diff = 1.625f;
|
||||
|
||||
if (m_msecDel > 60.0f)
|
||||
diff = 60.0f;
|
||||
else if (m_msecDel > 30.0f)
|
||||
diff = 30.0f;
|
||||
else if (m_msecDel > 15.0f)
|
||||
diff = 15.0f;
|
||||
else if (m_msecDel > 7.5f)
|
||||
diff = 7.5f;
|
||||
else if (m_msecDel > 3.25f)
|
||||
diff = 3.25f;
|
||||
|
||||
m_msecVal += diff - 0.5f;
|
||||
m_msecDel -= diff - 0.5f;
|
||||
}
|
||||
|
||||
if (m_msecVal < 1) // don't allow msec to be less than 1...
|
||||
{
|
||||
// adjust msecdel so we can correct lost msecs on following frames
|
||||
m_msecDel += m_msecVal - 1;
|
||||
m_msecVal = 1;
|
||||
}
|
||||
else if (m_msecVal > 100) // ...or greater than 100
|
||||
{
|
||||
// adjust msecdel so we can correct lost msecs on following frames
|
||||
m_msecDel += m_msecVal - 100;
|
||||
m_msecVal = 100;
|
||||
}
|
||||
}
|
||||
|
||||
void Bot::RunPlayerMovement (void)
|
||||
{
|
||||
// the purpose of this function is to compute, according to the specified computation
|
||||
|
|
@ -6120,16 +6163,6 @@ void Bot::RunPlayerMovement (void)
|
|||
// elapses, that bot will behave like a ghost : no movement, but bullets and players can
|
||||
// pass through it. Then, when the next frame will begin, the stucking problem will arise !
|
||||
|
||||
|
||||
m_msecVal = static_cast <byte> ((GetWorldTime () - m_msecInterval) * 1000.0f);
|
||||
|
||||
// update msec interval for last calculation method
|
||||
m_msecInterval = GetWorldTime ();
|
||||
|
||||
// validate range of the msec value
|
||||
if (m_msecVal > 2555)
|
||||
m_msecVal = 255;
|
||||
|
||||
(*g_engfuncs.pfnRunPlayerMove) (GetEntity (), m_moveAngles, m_moveSpeed, m_strafeSpeed, 0.0, pev->button, pev->impulse, m_msecVal);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -265,7 +265,9 @@ void BotManager::Think (void)
|
|||
}
|
||||
#else
|
||||
m_bots[i]->Think ();
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -826,8 +828,6 @@ Bot::Bot (edict_t *bot, int skill, int personality, int team, int member)
|
|||
|
||||
m_logotypeIndex = g_randGen.Long (0, 5);
|
||||
|
||||
// initialize msec value
|
||||
m_msecInterval = GetWorldTime ();
|
||||
m_msecVal = static_cast <byte> (g_pGlobals->frametime * 1000.0);
|
||||
|
||||
// assign how talkative this bot will be
|
||||
|
|
@ -838,7 +838,7 @@ Bot::Bot (edict_t *bot, int skill, int personality, int team, int member)
|
|||
m_skill = skill;
|
||||
m_weaponBurstMode = BM_OFF;
|
||||
|
||||
m_lastThinkTime = GetWorldTime ();
|
||||
m_lastThinkTime = GetWorldTime () - 0.1f;
|
||||
m_frameInterval = GetWorldTime ();
|
||||
|
||||
bot->v.idealpitch = bot->v.v_angle.x;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue