Raised This Month: $32 Target: $400
 8% 

[TF2] IBotManager::CreateBot() problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tauphi
SourceMod Donor
Join Date: Sep 2004
Location: Germany
Old 06-01-2009 , 15:50   [TF2] IBotManager::CreateBot() problem
Reply With Quote #1

Hello,

when I try to use the IBotManager interface to add a bot player in TF2, the server crashes and I don't have an idea how to fix this.

Based on the serverplugin sample located in...
\hl2sdk-ob\utils\serverplugin_sample
... I tried to add a bot with the following code:

PHP Code:
void BotAdd_f() {
    if ( !
botmanager ) return;
    
edict_t *botEdict botmanager->CreateBot"botName" );

    
IPlayerInfo *info playerinfomanager->GetPlayerInfo(botEdict);
    
info->ChangeTeam(3);
    
helpers->ClientCommand(botEdict,"joinclass soldier");
}
ConCommand cc_Bot"plugin_bot_add"BotAdd_f"Add a bot." ); 
Here is the command "plugin_bot_add" which should create a bot named "botName" on the blue team as soldier. But after running that command I got a crash.

WinDbg's console looks like this:
Code:
ModLoad: 14090000 140be000   e:\tf2\orangebox\tf\addons\serverplugin_empty.dll
Loaded plugin "addons/serverplugin_empty"
L 06/01/2009 - 20:41:45: "botName<2><BOT><>" connected, address "none"
L 06/01/2009 - 20:41:45: "botName<2><BOT><>" entered the game
L 06/01/2009 - 20:41:45: "botName<2><BOT><Unassigned>" joined team "Blue"
L 06/01/2009 - 20:41:45: "botName<2><BOT><Blue>" changed role to "soldier"
(758.1094): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=ffffffff ebx=00000000 ecx=00000000 edx=0012e26c esi=0fb27b30 edi=0fa9ae38
eip=0f8705e6 esp=0012e1e0 ebp=00000001 iopl=0         nv up ei pl zr na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010246
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for e:\tf2\orangebox\tf\bin\server.dll - 
server!CTFAmmoPack::PackTouch+0x32b6:
0f8705e6 8b89fc000000    mov     ecx,dword ptr [ecx+0FCh] ds:0023:000000fc=????????
I also tried it with a sourcemod extension with the following code in a native function:
PHP Code:
cell_t AddBot(IPluginContext *pContext, const cell_t *params) {
    
edict_t *edict botmanager->CreateBot("bot_01");
    return 
1;

But this does crash the server, too, when i use "AddBot" in my plugin.

Does someone know about that problem or know how to fix this?
I wasted days into it to get it work, but nothing helped.

Thanks in advance
__________________
Tauphi is offline
Send a message via ICQ to Tauphi Send a message via Skype™ to Tauphi
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 06-01-2009 , 23:33   Re: [TF2] IBotManager::CreateBot() problem
Reply With Quote #2

Thats what happens when you rely on outdated headers from the SDK. If they change something then its going to do exactly what your describing.

You will need to do this the proper way and get the sigs, and call them/hook them/detour them/etc.
__________________
CrimsonGT is offline
pRED*
Join Date: Dec 2006
Old 06-02-2009 , 02:48   Re: [TF2] IBotManager::CreateBot() problem
Reply With Quote #3

IBotManager is a public interface, the offsets should be correct.
Try engine->CreateFakeClient()
pRED* is offline
Tauphi
SourceMod Donor
Join Date: Sep 2004
Location: Germany
Old 06-02-2009 , 17:33   Re: [TF2] IBotManager::CreateBot() problem
Reply With Quote #4

I already tried engine->CreateFakeClient() ... it worked, but it spawned a bot without a gun and it seemed that i cant let him move or so ...

but i didn't try soo much ... will do it again now ...

btw...
what is the difference between the offical ibotmanager interface function CreateBot and CreateFakeClient ?
__________________
Tauphi is offline
Send a message via ICQ to Tauphi Send a message via Skype™ to Tauphi
Tauphi
SourceMod Donor
Join Date: Sep 2004
Location: Germany
Old 06-02-2009 , 18:42   Re: [TF2] IBotManager::CreateBot() problem
Reply With Quote #5

ok ...

engine->CreateFakeClient() does not work, too...
the edict does not have an IBotController...
PHP Code:
edict_t *edict engine->CreateFakeClient("Bot01");
IBotController *botc botmanager->GetBotController(edict); 
botc is always NULL ... so im not able to call the RunPlayerMove function :-/

CreateBot does not work ... CreateFakeClient does not work ...
Any other ideas?

BTW: the author from rcbot told, that the IBotManager interface is broken/outdated since the Scout update in TF2 ... Does this mean, that only valve is able to "fix" this?
__________________
Tauphi is offline
Send a message via ICQ to Tauphi Send a message via Skype™ to Tauphi
Keeper
Senior Member
Join Date: Nov 2006
Old 06-02-2009 , 19:59   Re: [TF2] IBotManager::CreateBot() problem
Reply With Quote #6

It may be your interface version is the one from the SDK. What are you using to assign the botmanager?

GET_V_IFACE_CURRENT or GET_V_IFACE_ANY?
Keeper is offline
Tauphi
SourceMod Donor
Join Date: Sep 2004
Location: Germany
Old 06-03-2009 , 01:01   Re: [TF2] IBotManager::CreateBot() problem
Reply With Quote #7

PHP Code:
bool Sample::SDK_OnMetamodLoad(ISmmAPI *ismmchar *errorsize_t maxlenbool late) {
    
GET_V_IFACE_CURRENT(GetServerFactorybotmanagerIBotManagerINTERFACEVERSION_PLAYERBOTMANAGER);
    return 
true;

but i did try it with GET_V_IFACE_ANY, too. Both don't work
__________________
Tauphi is offline
Send a message via ICQ to Tauphi Send a message via Skype™ to Tauphi
pRED*
Join Date: Dec 2006
Old 06-03-2009 , 02:35   Re: [TF2] IBotManager::CreateBot() problem
Reply With Quote #8

If the interface definitions have changed it's possible to reverse engineer new ones from the binaries.

I'll try remember to have a look when I next have it open.
pRED* is offline
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 06-03-2009 , 08:40   Re: [TF2] IBotManager::CreateBot() problem
Reply With Quote #9

Quote:
Originally Posted by pRED* View Post
If the interface definitions have changed it's possible to reverse engineer new ones from the binaries.

I'll try remember to have a look when I next have it open.
I said they changed but noo, just had to try and contradict me.
__________________
CrimsonGT is offline
Cooltad
Veteran Member
Join Date: Apr 2008
Old 06-03-2009 , 09:07   Re: [TF2] IBotManager::CreateBot() problem
Reply With Quote #10

Quote:
Originally Posted by CrimsonGT View Post
I said they changed but noo, just had to try and contradict me.
I smell competition.
__________________
Please, give me some rep if you found what I posted useful. :]
Cooltad is offline
Reply


Thread Tools
Display Modes

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


All times are GMT -4. The time now is 12:28.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode