View Single Post
How to do correct movement
Old
  (#1)
SteveC
Member
 
Status: Offline
Posts: 37
Join Date: Jan 2005
Location: UK
Default How to do correct movement - 09-01-2005

To get the bots to move correctly in my plugin, http://forums.bots-united.com/showthread.php?t=3366 , I used the following function;

Quote:
void CBasePlayer:: ProcessUsercmds( CUserCmd *cmds, int numcmds, int totalcmds,
int dropped_packets, bool paused )
To get to this you need to get the CBasePlayer pointer, which I did with the following code;

Quote:
// entity index
iBotIndex=ENTINDEX(pEdict);
// base entity
pBaseEnt = CBaseEntity::Instance(pEdict);
// get the player entity
if ( pBaseEnt && pBaseEnt->IsPlayer() )
{
pPlayerEnt = static_cast< CBasePlayer * >( pBaseEnt );
}
if (!pPlayerEnt) return false;
Where pEdict is the bot edict_t, pBaseEnt is a CBaseEntity pointer, and pPlayer is the CBasePlayer pointer. I can't remember which files I needed to include to get this to work, but I think it was 'cbase.h' as it links to most things.

Last edited by SteveC; 09-01-2005 at 01:22..
  
Reply With Quote