As I've said, I don't know if it's a proper fix. The 100 skill bots are also affected.
There's a bad feedback in the code.
BotBodyTarget gets called even if the enemy is not visible anymore. The hearing capabilities of the bot are not an issue here. We can assume that it's deaf. I have seen bug in action in both situation, when the bot's enemy was very near and got behind an crate or a wall, and when the enemy was some distance away (when hearing is not possible even for a human).
The pBot->vecEnemy or pBot->vecLastEnemyOrigin are used in BotBodyTarget func, to compute local static 'target', then at the end of BotBodyTarget, vecRandom is added to 'enemy' and pBot->vecEnemy and pBot->vecLastEnemyOrigin get reinitialized with this last 'enemy' value. At the next game frame, same thing happens, using a pBot->vecEnemy or pBot->LastEnemyOrigin, that already has been scrambled by vecRandom in the previos frame. Remember, the enemy is not visible, pBot->vecEnemy or pBot->LastEnemyOrigin have not been refreshed.
Setting a constant vecRandom in BotFocusEnemy and adding some code in BotFocusEnemy func, where it calls BotBodyTarget func:
Code:
if (pHostEdict)
{
if ((pHostEdict->v.origin - pBot->pEdict->v.origin).Length() < 30.0)
{
UTIL_ServerPrint("[frame %4d before BotBodyTarget] pBot->vecEnemy = (%4.2f %4.2f %4.2f) pBot->vecLastEnemyOrigin = (%4.2f %4.2f %4.2f)\n",
g_iFrameCounter, pBot->vecEnemy.x, pBot->vecEnemy.y, pBot->vecEnemy.z, pBot->vecLastEnemyOrigin.x, pBot->vecLastEnemyOrigin.y, pBot->vecLastEnemyOrigin.z);
}
}
vecEnemy = BotBodyTarget(pBot->pBotEnemy, pBot);
if (pHostEdict)
{
if ((pHostEdict->v.origin - pBot->pEdict->v.origin).Length() < 30.0)
{
UTIL_ServerPrint("[frame %4d after BotBodyTarget] pBot->vecEnemy = (%4.2f %4.2f %4.2f) pBot->vecLastEnemyOrigin = (%4.2f %4.2f %4.2f)\n",
g_iFrameCounter, pBot->vecEnemy.x, pBot->vecEnemy.y, pBot->vecEnemy.z, pBot->vecLastEnemyOrigin.x, pBot->vecLastEnemyOrigin.y, pBot->vecLastEnemyOrigin.z);
}
}
Here's the output for one 100 skill bot, with a constant vecRandom (at the start of BotBodyTarget) set to (10.0,10.0.10.0) - it helps to observe the issue:
http://www.sendspace.com/file/3qn229
For example, check lines from 774 through 865, and then 928 through 989. Two bots playing on awp_india, one is being observed, while the other hides, then comes again in view, then hides, and so on.
I'm not the only one that has observed the bug, check what
Serious Sam said at the start of this page.