.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
Bot respawn delay problem
Old
  (#1)
Tea
Guest
 
Status:
Posts: n/a
Default Bot respawn delay problem - 11-05-2004

Hi all, my bot is base on HPB_Bot, when the first map start, everything have no problem, bot will wait for 60 seconds before first spawn and the rest will wait for 2 seconds between each spawn.

But after the map change, they won't wait for 60 seconds before the first spawn anymore and they also won't wait 2 seconds between each spawn but they will spawn immediately. I didn't done something wrong at the dll.cpp since even the HPB_Bot 4.03 have the same problem and almost all the other bots have the same problem, it seem only check the bot_check_time = gpGlobals->time + 60.0; which under BOOL ClientConnect one time but not check it again after map change, but I think this is not the only problem since bot_cfg_pause_time = gpGlobals->time + 2.0; which not under BOOL ClientConnect.

Could someone give me some suggestion please ? thank you very much.
  
Reply With Quote
Re: Bot respawn delay problem
Old
  (#2)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Bot respawn delay problem - 12-05-2004

If you want your bots to wait 60 seconds before joining each time a new map start, then this
bot_check_time = gpGlobals->time + 60.0
should rather be put in ServerActivate(), because ServerActivate() is the first function called when a new map is about to start.

There are several ways in the code that lead to a bot being added. Do a search for each BotCreate() call, and check which one is called on the first map and which ones are called for the following ones. The difference among the checks that lead to BotCreate() will tell you all that you want to know.



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: Bot respawn delay problem
Old
  (#3)
Tea
Guest
 
Status:
Posts: n/a
Default Re: Bot respawn delay problem - 12-05-2004

Thank for the quick reply Pierre, but I did not found any ServerActivate(), do you mean the StartFrame () ? If yes here is the code :
Quote:

void StartFrame( void )
{
if (gpGlobals->deathmatch)
{
edict_t *pPlayer;
static int i, index, player_index, bot_index;
static float previous_time = -1.0;
char msg[256];
int count;

// if a new map has started then (MUST BE FIRST IN StartFrame)...
if ((gpGlobals->time + 0.1) < previous_time)
{
char filename[256];
char mapname[64];

// check if mapname_bot.cfg file exists...

strcpy(mapname, STRING(gpGlobals->mapname));
strcat(mapname, "_HPB_bot.cfg");

UTIL_BuildFileName(filename, "maps", mapname);

if ((bot_cfg_fp = fopen(filename, "r")) != NULL)
{
sprintf(msg, "Executing %s\n", filename);
ALERT( at_console, msg );

for (index = 0; index < 32; index++)
{
bots[index].is_used = FALSE;
bots[index].respawn_state = 0;
bots[index].f_kick_time = 0.0;
}

if (IsDedicatedServer)
bot_cfg_pause_time = gpGlobals->time + 5.0;
else
bot_cfg_pause_time = gpGlobals->time + 20.0;

}
else
{
count = 0;

// mark the bots as needing to be respawned...
for (index = 0; index < 32; index++)
{
if (count >= prev_num_bots)
{
bots[index].is_used = FALSE;
bots[index].respawn_state = 0;
bots[index].f_kick_time = 0.0;
}

if (bots[index].is_used) // is this slot used?
{
bots[index].respawn_state = RESPAWN_NEED_TO_RESPAWN;
count++;
}

// check for any bots that were very recently kicked...
if ((bots[index].f_kick_time + 5.0) > previous_time)
{
bots[index].respawn_state = RESPAWN_NEED_TO_RESPAWN;
count++;
}
else
bots[index].f_kick_time = 0.0; // reset to prevent false spawns later
}

// set the respawn time
if (IsDedicatedServer)
respawn_time = gpGlobals->time + 5.0;
else
respawn_time = gpGlobals->time + 20.0;
}

bot_check_time = gpGlobals->time + 60.0;
}

It did run this StartFrame when start a new map but not anymore for the next map, Pierre could you have a quick look to see what problem of this code ?

PS: this code is from HPB_Bot 4.0 and I didn't change it at all, thank.
  
Reply With Quote
Re: Bot respawn delay problem
Old
  (#4)
Cheeseh
[rcbot]
 
Cheeseh's Avatar
 
Status: Offline
Posts: 361
Join Date: Dec 2003
Location: China
Default Re: Bot respawn delay problem - 14-05-2004

the ServerActivate function is in the dll.cpp file in HPB bot template, check it out :p
  
Reply With Quote
Re: Bot respawn delay problem
Old
  (#5)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Bot respawn delay problem - 14-05-2004

If ServerActivate() isn't featured in the dll.cpp file of the HPB_bot 4.0 (which is a metamod plugin), that's because ServerActivate() isn't hooked yet by the HPB_bot in the list of the game DLL functions. Just add a hook for it like it is done for StartFrame, ClientConnect, etc.



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: Bot respawn delay problem
Old
  (#6)
Tea
Guest
 
Status:
Posts: n/a
Default Re: Bot respawn delay problem - 14-05-2004

I have added the following lines in dll.cpp and mark out the welcome message in StartFrame()

Code:
 
void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax )
{
 
	 if (!IsDedicatedServer)
	 {
		 if ((listenserver_edict != NULL) && (welcome_sent == FALSE) &&
			 (welcome_time < 1.0))
		 {
			// are they out of observer mode yet?
			if (IsAlive(listenserver_edict))
			 welcome_time = gpGlobals->time + 5.0; // welcome in 5 seconds
		 }
		 if ((welcome_time > 0.0) && (welcome_time < gpGlobals->time))
		 {
			char version[80];
			sprintf(version,"%s Version %d.%d\n", welcome_msg, VER_MAJOR, VER_MINOR);
			// let's send a welcome message to this client...
			UTIL_SayText(version, listenserver_edict);
		 }
	 }
 
	RETURN_META (MRES_IGNORED);
}
And this inside C_DLLEXPORT int GetEntityAPI2

Code:
gFunctionTable.pfnServerActivate = ServerActivate;
I am sure it never call the ServerActive() since I never saw the welcome message, am I miss something to add in dll.cpp ?

BTW if the ServerActive() really can't work than doesn't matter, because I knew the StartFrame() did call on every map change when I use welcome message to test it.

I have found out the reason why bots not delay when respawn because the bots never disconnect when map changed, I have tried not to use max_bot function but only type addbot in console to add 2 bots, but when the map changed, that 2 bots join the game again automatic, I think when the map changed, that 2 bots only respawn but not rejoin, that's why the bot_check_time not work for them again.

Hmm, any idea ?

Last edited by Tea; 15-05-2004 at 00:24..
  
Reply With Quote
Re: Bot respawn delay problem
Old
  (#7)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Bot respawn delay problem - 15-05-2004

hmm no, some explanation is needed here. Unless StartFrame() which is continuously called for each video frame, ServerActivate() is only called ONCE, when the server is about to start - and when no client has joined yet. That's why you can't see the welcome message (since you aren't connected to the server yet when ServerActivate() executes).

The bots are automatically disconnected by the server on map change (since a map change is in fact a server shutdown and a server restart). There's nothing the bot code can do against it. What botman did, however, is that he added some code to make the bots that WERE on the server during the last map be automatically re-added in the new one. Hence it's not a bug but a feature. If you want to change this, comment out this code and make the bot re-read the configuration file (with the "addbot" commands in it) that makes the bots be added the first time, at each map change and not at the first start of the game ; i.e, to do this, put this code in ServerActivate().



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: Bot respawn delay problem
Old
  (#8)
Tea
Guest
 
Status:
Posts: n/a
Default Re: Bot respawn delay problem - 16-05-2004

Thank for the information, I'll take a look of it.
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com