![]() |
![]() |
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. |
![]() ![]() |
![]() |
Lo-Fi Version | Time is now: 20th June 2025 - 05:25 PM |