.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   Half-Life 2 SDK (http://forums.bots-united.com/forumdisplay.php?f=62)
-   -   Hooking into HL2 DLL ? (http://forums.bots-united.com/showthread.php?t=3400)

dub 18-01-2005 14:18

Re: Hooking into HL2 DLL ?
 
Quote:

ugly, and won't work on Linux.
yeah, i need some linux/unix coding practice, never coded in linux/unix enviroment before.

found in CBasePlayer, might help.
Code:

// Run a user command. The default implementation calls ::PlayerRunCommand. In TF, this controls a vehicle if
        // the player is in one.
 virtual void                        PlayerRunCommand (CUserCmd *ucmd, IMoveHelper *moveHelper);

only problem is, i think this is for vehicles only. I tried with passing NULL on the movehelper and hl crashed :'(.

Cheeseh 18-01-2005 15:37

Re: Hooking into HL2 DLL ?
 
botmans method DOES still work. It's the CBasePlayer->ProcessUsercmds() that doesn't work anymore (as of latest cs:s update) I found the cbaseplayer method much tider though than the buffer writing and stuff, but hell it looks like it's gonna be the only way to do it. :)

dub 18-01-2005 18:58

Re: Hooking into HL2 DLL ?
 
cheeseh i thought botmans method was using the ProcessUsercmds, to get the bots to process movement.

SteveC 18-01-2005 19:51

Re: Hooking into HL2 DLL ?
 
The CBasePlayer->ProcessUserCommands() trick (which I started) doesn't work anymore as has been said, but the CBasePlayer->PlayerRunCommand() doesn't work either, even if you do pass the correct movehelper pointer. The debug error is that the function isn't returning as it expected so it sounds like Valve changed the CBasePlayer class, and therefore changed the virtual function table. However the SDK hasn't been updated (?), so currently we can't use the CBasePlayer class.
I don't know if Valve changed the CBasePlayer to stop us using it or if it was to fix some bugs. I think it's just something they had to do to get the bots working.

PS. Botmans way will always work, because it is based on building a network message. (until they re-write the netcode)

SteveC 18-01-2005 20:10

Re: Hooking into HL2 DLL ?
 
PS! They have changed stuff, because you can now add bots in HL2: DM !

dub 18-01-2005 20:20

Re: Hooking into HL2 DLL ?
 
maybe they chaged it to give us a way to access CBasePlayer & CBaseEntity without using any hacks too.

SteveC 18-01-2005 20:24

Re: Hooking into HL2 DLL ?
 
Hopefully. But we'll just have to wait.

Cheeseh 18-01-2005 20:30

Re: Hooking into HL2 DLL ?
 
botmans method is this ...

PHP Code:


void CBot 
:: runPlayerMove()
{
    static 
CUserCmd cmd;
    static 
bf_write write_buf;
    static 
bf_read read_buf;
    static 
unsigned char buffer[CMD_BUFFER_SIZE];  // shared buffer between write_buf and read_buf (EVIL!!!)

    //////////////////////////////////
    
memset(&cmd0sizeof(cmd));
    
//////////////////////////////////
    
cmd.forwardmove m_fForwardSpeed;
    
cmd.sidemove m_fSideSpeed;
    
cmd.upmove m_fUpSpeed;
    
cmd.buttons m_iButtons;
    
cmd.impulse m_iImpulse;
    
cmd.viewangles m_vViewAngles;

    
// SteveC:
    // this changes the fixangle from absolute (which isn't coded for) to none
    // note: has to be run here because it doesn't work in the addbot routine?!?!?
    
m_pBaseEdict->PlayerData()->fixangle FIXANGLE_NONE;
    
    
//////////////////////////////////
    
write_buf.StartWritingbufferCMD_BUFFER_SIZE );
    
WriteUsercmd( &write_buf, &cmd );  // by magic the same data appears in the read_buf!!!
    
read_buf.StartReadingbufferCMD_BUFFER_SIZE );  // this is truly EVIL!!!
    
gameclients->ProcessUsercmds(m_pEdict, &read_buf110falsefalse);
    
//////////////////////////////////


it still works, but as said before (again :P) SteveC's CBasePlayer->ProcessUserCmds doesn't work anymore

Cheeseh 18-01-2005 23:39

Re: Hooking into HL2 DLL ?
 
Quote:

Originally Posted by SteveC
PS! They have changed stuff, because you can now add bots in HL2: DM !

your own bots? when I try it still crashes in createFakeclient()

SteveC 19-01-2005 01:01

Re: Hooking into HL2 DLL ?
 
Yeah I had my own bot in HL2: DM. I hadn't converted my movement code so it didn't do anything, just floated there. But it was in the game, in a team, and alive. It died too with a high speed barrel :D !

I haven't done anything special, just refreshed the SDK content which might have changed stuff.


All times are GMT +2. The time now is 11:27.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.