Ejemplo n.º 1
0
//==========================================
// BOT_ServerCommand
// Special server command processor
//==========================================
qboolean BOT_ServerCommand (void)
{
	char	*cmd, *name;

	cmd = gi.argv (1);

	if (!ctf->value)
		name = gi.argv(2);

	if (strlen(name) < 5)
	{
		name = bot_names[GetRandom(0, 7)];
	}

	if( !Q_stricmp (cmd, "addbot") )
	{ 
		if(ctf->value) // name, skin, team
			BOT_SpawnBot ( gi.argv(2), gi.argv(3), gi.argv(4), NULL );
		else // name, skin
			BOT_SpawnBot ( NULL, name, gi.argv(3), NULL );
	}	
	// removebot
    else if( !Q_stricmp (cmd, "removebot") )
    	BOT_RemoveBot(gi.argv(2));

	else if( !Q_stricmp (cmd, "editnodes") )
		AITools_InitEditnodes();

	else if( !Q_stricmp (cmd, "makenodes") )
		AITools_InitMakenodes();

	else if( !Q_stricmp (cmd, "savenodes") )
		AITools_SaveNodes();

	else if( !Q_stricmp (cmd, "addbotroam") )
		AITools_AddBotRoamNode();

	else if( !Q_stricmp (cmd, "addmonster") )
    	M_default_Spawn ();

	else
		return false;

	return true;
}
Ejemplo n.º 2
0
/*
* G_CheckNumBots
*/
static void G_CheckNumBots( void )
{
	edict_t	*ent;
	int desiredNumBots;

	if( level.spawnedTimeStamp + 5000 > game.realtime )
		return;

	// check sanity of g_numbots
	if( g_numbots->integer < 0 )
		trap_Cvar_Set( "g_numbots", "0" );

	if( g_numbots->integer > gs.maxclients )
		trap_Cvar_Set( "g_numbots", va( "%i", gs.maxclients ) );

	if( level.gametype.numBots > gs.maxclients )
		level.gametype.numBots = gs.maxclients;

	desiredNumBots = level.gametype.numBots ? level.gametype.numBots : g_numbots->integer;

	if( desiredNumBots < game.numBots )
	{
		// kick one bot
		for( ent = game.edicts + gs.maxclients; PLAYERNUM( ent ) >= 0; ent-- )
		{
			if( !ent->r.inuse || !( ent->r.svflags & SVF_FAKECLIENT ) )
				continue;
			if( AI_GetType( ent->ai ) == AI_ISBOT )
			{
				trap_DropClient( ent, DROP_TYPE_GENERAL, NULL );
				break;
			}
		}
		return;
	}

	if( desiredNumBots > game.numBots )
	{                                     // add a bot if there is room
		for( ent = game.edicts + 1; PLAYERNUM( ent ) < gs.maxclients && game.numBots < desiredNumBots; ent++ )
		{
			if( !ent->r.inuse && trap_GetClientState( PLAYERNUM( ent ) ) == CS_FREE )
				BOT_SpawnBot( NULL );
		}
	}
}