View Single Post
Re: Bot running speed
Old
  (#8)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,618
Join Date: Jul 2004
Location: Bulgaria
Default Re: Bot running speed - 03-08-2015

Okay then, just one more modification I can suggest that you can test out:

1. Define in bot_t structure the following variable:
float f_previous_command_time;
2. In bot_func.h declare this function:
Code:
byte ThrottledMsec( bot_t *pBot );
3. Then in bot.cpp
Code:
byte ThrottledMsec( bot_t *pBot )
{
	int newmsec = (int)( (gpGlobals->time - pBot->f_previous_command_time) * 1000 );
	if (newmsec > 255)  // Doh, bots are going to be slower than they should if this happens.
		newmsec = 255;		 // Upgrade that CPU or use less bots!

	return (byte)newmsec;
}
4. Somewhere in BotSpawnInit() function init our new variable like this:
Code:
pBot->f_previous_command_time = gpGlobals->time;
5. Then just before RunPlayerMove call do this:
Code:
// Adjust msec to command time interval
byte adjustedmsec = ThrottledMsec(pBot);

// save the command time
pBot->f_previous_command_time = gpGlobals->time;

g_engfuncs.pfnRunPlayerMove( pEdict, pEdict->v.v_angle, pBot->f_move_speed,
                                0, 0, pEdict->v.button, 0, adjustedmsec );
This is the code the official CSBot uses. I took from the example bot framework in the HLSDK on github and modified it a bit to pass nice with HPB_bot.
In this way if the RunPlayerMove() call modifies the globalTime it will be considered for the next bot in line. Also is more accurate if you decide to not call BotThink() each frame in order to save CPU.

Note: Beware that the HPB_bot have multiple places that calls RunPlayerMove(). Be sure to do this before each call.

EDIT: Actually yes, if you have some kind of video setting that will cause the msec value to go higher than 255, the bots will be slow. This is too much time between frames. So I guess that you had solved it.
  
Reply With Quote