Hello!
Probably too late, but....
Function from leaked HL2 source code to control over a bot:
Code:
// Handle the "PossessBot" command.
void PossessBot_f()
{
CCSPlayer *pPlayer = CCSPlayer::Instance( UTIL_GetCommandClientIndex() );
if ( !pPlayer )
return;
// Put the local player in control of this bot.
if ( engine->Cmd_Argc() != 2 )
{
Warning( "PossessBot <client index>\n" );
return;
}
int iBotClient = atoi( engine->Cmd_Argv(1) );
int iBotEnt = iBotClient + 1;
if ( iBotClient < 0 ||
iBotClient >= gpGlobals->maxClients ||
pPlayer->entindex() == iBotEnt )
{
Warning( "PossessBot <client index>\n" );
}
else
{
edict_t *pPlayerData = pPlayer->pev;
edict_t *pBotData = engine->PEntityOfEntIndex( iBotEnt );
if ( pBotData && pBotData->m_pEnt )
{
// SWAP EDICTS
// Backup things we don't want to swap.
edict_t oldPlayerData = *pPlayerData;
edict_t oldBotData = *pBotData;
// Swap edicts.
edict_t tmp = *pPlayerData;
*pPlayerData = *pBotData;
*pBotData = tmp;
// Restore things we didn't want to swap.
//pPlayerData->m_EntitiesTouched = oldPlayerData.m_EntitiesTouched;
//pBotData->m_EntitiesTouched = oldBotData.m_EntitiesTouched;
CBaseEntity *pPlayerBaseEnt = CBaseEntity::Instance( pPlayerData );
CBaseEntity *pBotBaseEnt = CBaseEntity::Instance( pBotData );
// Make the other a bot and make the player not a bot.
pPlayerBaseEnt->RemoveFlag( FL_FAKECLIENT );
pBotBaseEnt->AddFlag( FL_FAKECLIENT );
// Point the CBaseEntities at the right players.
pPlayerBaseEnt->pev = pPlayerData;
pBotBaseEnt->pev = pBotData;
// Freeze the bot.
pBotBaseEnt->AddEFlags( EFL_BOT_FROZEN );
}
}
}
ConCommand cc_PossessBot( "PossessBot", PossessBot_f, "Toggle. Possess a bot.\n\tArguments: <bot client number>", FCVAR_CHEAT );