![]() |
![]() ![]() |
![]() |
Tauphi |
![]()
Post
#1
|
Newbie ![]() Group: Members Posts: 5 Joined: 2-June 09 Member No.: 1,564 ![]() |
Hi all and Hi Cheeseh,
I am currently playing with the IBotManager interface of the Orange Box SDK, but my plugins always crash, when I call the CreateBot() function. The rcbot does work with the current TF2 version or? May I ask how you get it to work to add and control a bot with the "broken" IBotManager interface? Or did you find a workaround for it? Thanks in advance for tips and help! regards Andi |
Cheeseh |
![]()
Post
#2
|
![]() Admin ![]() ![]() ![]() ![]() ![]() Group: Admin Posts: 3,066 Joined: 11-September 03 From: uk Member No.: 1 ![]() |
Hi Andi
I'm using a complete workaround. The only workaround that I could think of is by adding a normal (braindead) TF2 bot. i.e. by using "bot" command. I do this automatically by using CODE engine->ServerCommand("bot"); but u might want to give the bot a name, so i do this somewhere global make a new bot name like.. CODE char *newbotname; CODE newbotname = YourGetBotNameFunction(); char cmd[256]; sprintf(cmd,"bot -name %s",botname); engine->ServerCommand(cmd); When the bot is added to the server, I get the EDICT from the ClientPutInServer (plugin function) but to do this u need to know that it is the bot you just added to the server, so when u call the bot add command u might want a variable like .. CODE bool ControlNextPlayer = false; CODE ControlNextPlayer = true; engine->ServerCommand("bot"); Check that the player connected is the bot by doing this. CODE void YOURPLUGIN::ClientPutInServer( edict_t *pEntity, char const *playername ) { if ( ControlNextPlayer ) { ControlNextPlayer = false; // ADD THIS pEntity TO YOUR BOT LIST HERE } CClients::clientConnected(pEntity); } Although this causes probalems because you can't get a IplayerInfo from the player at this point. So What I do is add the pEntity to a QUEUE at that point. CODE #include <queue> using namespace std; queue<edict_t *> ControlBotQueue; CODE void YOURPLUGIN::ClientPutInServer( edict_t *pEntity, char const *playername ) { if ( ControlNextPlayer ) { ControlNextPlayer = false; ControlBotQueue.push(pEntity); } CClients::clientConnected(pEntity); } In GameFrame check if the ControlBotQueue has any players in it CODE void YOURPLUGIN::GameFrame( bool simulating ) { if ( simulating ) { if ( !ControlBotQueue.empty() ) // got a player to control { edict_t *pPlayer = ControlBotQueue.front(); IPlayerInfo *p = playerinfomanager->GetPlayerInfo(pPlayer ); // PlayerInfo now valid if ( p ) { m_ControlQueue.pop(); // remove this guy // use this guy as a bot (put it in your list of bots and set it up) m_Bots[engine->IndexOfEdict(pPlayer ) - 1]->createBotFromEdict(pEdict,m_pNextProfile); } } // ... YOU BOT CODE AND STUFF ... } } hope it helps. |
Tauphi |
![]()
Post
#3
|
Newbie ![]() Group: Members Posts: 5 Joined: 2-June 09 Member No.: 1,564 ![]() |
Hi Cheeseh,
thanks for the great info, how you made it. But there is still one thing I don't understand... I had the idea too, to add a braindead bot with the "bot" command and to control that bot with it's own bot controller ... I used this OnGameFrame code for this: CODE void OnGameFrame( bool simulating ) { On every Game Frame I check all players if they are bots and have a bot controller. When I add a bot with "bot" it has that controller, so it seemed ok for me ...if ( simulating ) { for ( int client = 0; client < gpGlobals->maxClients; client++ ) { IGamePlayer *player = playerhelpers->GetGamePlayer(client); if ( player == NULL || !player->IsInGame() || !player->IsFakeClient() ) continue; IPlayerInfo *info = player->GetPlayerInfo(); if ( info == NULL ) continue; edict_t *edict = player->GetEdict(); if ( edict == NULL ) continue; IBotController *botc = botmanager->GetBotController(edict); if ( botc == NULL ) continue; CBotCmd cmd; Q_memset( &cmd, 0, sizeof( cmd ) ); cmd.buttons |= IN_DUCK; botc->PostClientMessagesSent(); botc->RunPlayerMove(&cmd); } } } Next is, that I create"buttons" which say to crouch all the time with IN_DUCK ... But when I run "RunPlayerMove" with the buttons nothing happens. Better said: Valves own Bot engine is running RunPlayerMove on every GameFrame, too. So the engine got told "crouch, dont crouch, crouch, dont crouch, and so on and so on" ... The crouch animation isn't fast enough, so it seems that nothing happens. Another thing is, when I set "bot_forceattack" to 1 the bots start firing their guns ... This shows, that the bot's own engine is running at the same time, too... I took a look into your source code and found your snippets about adding and controlling a bot ... but, how did you stop the bot's own engine? I hope you understand what I mean, my english is not the best ;D best regards Andi |
Cheeseh |
![]()
Post
#4
|
![]() Admin ![]() ![]() ![]() ![]() ![]() Group: Admin Posts: 3,066 Joined: 11-September 03 From: uk Member No.: 1 ![]() |
To be honest I don't know, I haven't tried bots crouching, I guess the same might happen come to think of it.
You could try 'bot_dontmove 1' command and it might stop some things from happening the tf2 inbuilt bot stuff will still be running in the background, so bot_mimic etc will take over control and stuff, even if you use CreateBot() I noticed TF2 still did this, so there is something dodgy going on behind the scenes and this could be the cause of the "fast gravity" glitch |
Tauphi |
![]()
Post
#5
|
Newbie ![]() Group: Members Posts: 5 Joined: 2-June 09 Member No.: 1,564 ![]() |
I already tried commands like "bot_dontmove" or so ... but TF2 is still using it's own engine to overwrite my set bot commands ...
I think valve's code looks a bit like this: CODE void Bot_Think( CPluginBot *pBot ) that their think function at least resets the CBotCmd object ....{ CBotCmd cmd; Q_memset( &cmd, 0, sizeof( cmd ) ); if ( bot_dontmove.GetInt() > 0 ) { //do something... } pBot->m_BotInterface->RunPlayerMove( &cmd ); } Did you ever have any contact to a guy from valve? I emailed Tony and Alfred about the broken IBotManager interface, but they never replied. Perhaps they are the wrong guys for that problem, but I don't know others of the team. |
Cheeseh |
![]()
Post
#6
|
![]() Admin ![]() ![]() ![]() ![]() ![]() Group: Admin Posts: 3,066 Joined: 11-September 03 From: uk Member No.: 1 ![]() |
If you have any questions/suggestions for valve I suggest using the hlcoders mailing list.
http://list.valvesoftware.com/mailman/listinfo/hlcoders I will need to ask them sometime about this also. |
Tauphi |
![]()
Post
#7
|
Newbie ![]() Group: Members Posts: 5 Joined: 2-June 09 Member No.: 1,564 ![]() |
I am on three lists ... hlcoders, hlds_linux and windows ...
I remember you already posted something about the bot interface a while ago. QUOTE *Bumps* But nobody had a solution and valve didn't post something I Tested the "sample_bot_plugin" code that comes with the SDK (and latest beta SDK) and it doesn't work either with TF2, it suffers the exact same problem. So I guess I'd like to see a newer version of the sample bot plugin code (and get Valve to have a look at it themselves!). Cheers! [rcbot]Cheeseh ![]() I think the best way would be to get a direct contact to one of the SDK developers at valve ... |
Cheeseh |
![]() ![]()
Post
#8
|
![]() Admin ![]() ![]() ![]() ![]() ![]() Group: Admin Posts: 3,066 Joined: 11-September 03 From: uk Member No.: 1 ![]() |
I am on three lists ... hlcoders, hlds_linux and windows ... I remember you already posted something about the bot interface a while ago.But nobody had a solution and valve didn't post something ![]() I think the best way would be to get a direct contact to one of the SDK developers at valve ... Yeah although thats what omnibot did last year, and it valve still hasn't done anything, not looking good..... |
Cheeseh |
![]()
Post
#9
|
![]() Admin ![]() ![]() ![]() ![]() ![]() Group: Admin Posts: 3,066 Joined: 11-September 03 From: uk Member No.: 1 ![]() |
|
Tauphi |
![]()
Post
#10
|
Newbie ![]() Group: Members Posts: 5 Joined: 2-June 09 Member No.: 1,564 ![]() |
actually the fact that the TF2 engine automatically calls runPlayerMove on all bots anyway kinda explains the Medic/Pyro bug + the gravity bug how ironic ... i always added bots with the "bot" command in my servers. then i thought, hey give them more features by editing the buttons with RunPlayerMove() ... i wrote a plugin which did it and all my bots got strange bugs like running around like super uber fast heros and this stuff ... thought ok, the tf2 engine runs RunPlayerMove, too, sure, that it creates problems ... I have to use CreateBot() instead ... ok looked into the serverplugin_sample ... wrote my small plugin .... bam server crash ... CreateBot() broken ... ---> WTF and now i hear that TF2 calls RunPlayerMove all the time :-/ ... i hate it ... what a waste of time ![]() but ... at least one positive thing about the IBotManager interface from mike durand: QUOTE Hi Andreas- I'll forward this issue to the TF2 dev team. -Mike |
![]() ![]() |
![]() |
Lo-Fi Version | Time is now: 19th June 2025 - 04:07 PM |