![]() |
Bot respawn delay problem
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. |
Re: Bot respawn delay problem
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. |
Re: Bot respawn delay problem
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:
PS: this code is from HPB_Bot 4.0 and I didn't change it at all, thank. |
Re: Bot respawn delay problem
the ServerActivate function is in the dll.cpp file in HPB bot template, check it out :p
|
Re: Bot respawn delay problem
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.
|
Re: Bot respawn delay problem
I have added the following lines in dll.cpp and mark out the welcome message in StartFrame()
Code:
Code:
gFunctionTable.pfnServerActivate = ServerActivate; 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 ? |
Re: Bot respawn delay problem
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(). |
Re: Bot respawn delay problem
Thank for the information, I'll take a look of it. :)
|
All times are GMT +2. The time now is 23:18. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.