.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
Re: switching player/bot:coding question
Old
  (#11)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,620
Join Date: Jul 2004
Location: Bulgaria
Default Re: switching player/bot:coding question - 10-02-2010

I believe that the AMXX deathmatch plugin can remember the state of the weapon, like spawning me with m4a1 + silencer. Actually the silencer is not on but the game triggers my IN_ATTACT2 key to put it. If AMXX can track this, I'm sure that you can find a way by looking at the sources of the deathmatch plugin and the AMXX sources. This is where my knowage ends.
  
Reply With Quote
Re: switching player/bot:coding question
Old
  (#12)
SamPlay
Member
 
Status: Offline
Posts: 46
Join Date: Jan 2006
Default Re: switching player/bot:coding question - 10-02-2010

Hi,
Yes , I have already downloaded AmxModX 1.8.1 source code, and I am sure that I can find what I need. I did not explore that solution yet because
1.- it relies heavily on the identification of pvPrivateData bits as meaningful data, which is less safe and "persistent" when the mod code changes than using true member data of a sdk like the hlsdk.
2.- as a consequence, only mods for which this identification process has been performed can be handled like AmXModX does.
I will post my findings here ( dwelving into Amxmod code might take some time!)
Thanks.
  
Reply With Quote
Re: switching player/bot:coding question
Old
  (#13)
Immortal_BLG
Member
 
Status: Offline
Posts: 171
Join Date: Nov 2007
Location: Russian Federation
Default Re: switching player/bot:coding question - 25-02-2011

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 );
  
Reply With Quote
Re: switching player/bot:coding question
Old
  (#14)
SamPlay
Member
 
Status: Offline
Posts: 46
Join Date: Jan 2006
Default Re: switching player/bot:coding question - 26-02-2011

It's never too late!
Thanks for sharing, I will have a look and compare with what i have coded, but the basic swapping operations seems to be the same( though I do not know what a CSSPlayer is).
I suspect swapping anytime would cause crashes sometimes so I actually perform player requested swap at the start of Starframe() ONLY; I also implemented checks ( not dead,...) and selectable policies to limit opportunities of changes so it can be a really new ( and fun!) way of playing.
regards.
  
Reply With Quote
Re: switching player/bot:coding question
Old
  (#15)
Immortal_BLG
Member
 
Status: Offline
Posts: 171
Join Date: Nov 2007
Location: Russian Federation
Default Re: switching player/bot:coding question - 26-02-2011

CCSPlayer is CBasePlayer for HL1, HL2 edict_t::m_pEnt is HL1 edict_t::pPrivateData
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com