Ejemplo n.º 1
0
/*QUAKED team_WOLF_objective (1 1 0.3) (-16 -16 -24) (16 16 32)
marker for objective

This marker will be used for computing effective radius for
dynamite damage, as well as generating a list of objectives
that players can elect to spawn near to in the limbo spawn
screen.

key "description" is short text key for objective name that
will appear in objective selection in limbo UI.
*/
void SP_team_WOLF_objective( gentity_t *ent ) {
	char *objectivename;
	char numspawntargets[128];
	static int numobjectives = 0;
	int cs_obj = CS_MULTI_SPAWNTARGETS;
	char cs[MAX_STRING_CHARS];
	vec3_t test;

	G_SpawnString( "description", "WARNING: No objective description set", &objectivename );

	if ( numobjectives == MAX_MULTI_SPAWNTARGETS ) {
		G_Error( "SP_team_WOLF_objective: exceeded MAX_MULTI_SPAWNTARGETS (%d)\n",MAX_MULTI_SPAWNTARGETS );
	} else { // Set config strings
		cs_obj += numobjectives;
		trap_GetConfigstring( cs_obj, cs, sizeof( cs ) );
		Info_SetValueForKey( cs, "spawn_targ", objectivename );
		trap_SetConfigstring( cs_obj, cs );
		VectorCopy( ent->s.origin, level.spawntargets[numobjectives] );
	}

	numobjectives++;

	// set current # spawntargets
	level.numspawntargets = numobjectives;
	trap_GetConfigstring( CS_MULTI_INFO, cs, sizeof( cs ) );
	sprintf( numspawntargets,"%d",numobjectives );
	Info_SetValueForKey( cs, "numspawntargets", numspawntargets );
	trap_SetConfigstring( CS_MULTI_INFO, cs );

	VectorCopy( level.spawntargets[numobjectives - 1],test );
	G_Printf( "OBJECTIVE %d: %s (total %s) x=%f %f %f\n",numobjectives,objectivename,numspawntargets,test[0],test[1],test[2] );
}
Ejemplo n.º 2
0
void objective_Register(gentity_t *self) {

	char numspawntargets[128];
	int  cs_obj = CS_MULTI_SPAWNTARGETS;
	char cs[MAX_STRING_CHARS];

	if (numobjectives == MAX_MULTI_SPAWNTARGETS) {
		G_Error("SP_team_WOLF_objective: exceeded MAX_MULTI_SPAWNTARGETS (%d)\n", MAX_MULTI_SPAWNTARGETS);
	} else {   // Set config strings
		cs_obj += numobjectives;
		trap_GetConfigstring(cs_obj, cs, sizeof (cs));
		Info_SetValueForKey(cs, "spawn_targ", self->message);
		Info_SetValueForKey(cs, "x", va("%i", (int)self->s.origin[0]));
		Info_SetValueForKey(cs, "y", va("%i", (int)self->s.origin[1]));
		if (level.ccLayers) {
			Info_SetValueForKey(cs, "z", va("%i", (int)self->s.origin[2]));
		}
		Info_SetValueForKey(cs, "t", va("%i", self->count2));
		self->use   = team_wolf_objective_use;
		self->count = cs_obj;
		trap_SetConfigstring(cs_obj, cs);
		VectorCopy(self->s.origin, level.spawntargets[numobjectives]);
	}

	numobjectives++;

	// set current # spawntargets
	level.numspawntargets = numobjectives;
	trap_GetConfigstring(CS_MULTI_INFO, cs, sizeof (cs));
	sprintf(numspawntargets, "%d", numobjectives);
	Info_SetValueForKey(cs, "numspawntargets", numspawntargets);
	trap_SetConfigstring(CS_MULTI_INFO, cs);
}
Ejemplo n.º 3
0
/*
==================
BotTeamplayReport
==================
*/
void BotTeamplayReport(void) {
	int i;
	char buf[MAX_INFO_STRING];

	BotAI_Print(PRT_MESSAGE, S_COLOR_RED"RED\n");
	for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
		//
		if ( !botstates[i] || !botstates[i]->inuse ) continue;
		//
		trap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));
		//if no config string or no name
		if (!strlen(buf) || !strlen(Info_ValueForKey(buf, "n"))) continue;
		//skip spectators
		if (atoi(Info_ValueForKey(buf, "t")) == TEAM_RED) {
			BotReportStatus(botstates[i]);
		}
	}
	BotAI_Print(PRT_MESSAGE, S_COLOR_BLUE"BLUE\n");
	for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
		//
		if ( !botstates[i] || !botstates[i]->inuse ) continue;
		//
		trap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));
		//if no config string or no name
		if (!strlen(buf) || !strlen(Info_ValueForKey(buf, "n"))) continue;
		//skip spectators
		if (atoi(Info_ValueForKey(buf, "t")) == TEAM_BLUE) {
			BotReportStatus(botstates[i]);
		}
	}
}
Ejemplo n.º 4
0
/**
 * @brief Prevent player always mounting the last gun used, on multiple tank maps.
 * Ported from the Bugfix project (#087)
 */
void G_RemoveConfigstringIndex(const char *name, int start, int max)
{
	int  i, j;
	char s[MAX_STRING_CHARS];

	if (!name || !name[0])
	{
		return;
	}

	for (i = 1; i < max; i++)
	{
		trap_GetConfigstring(start + i, s, sizeof(s));

		if (!s[0])
		{
			break;
		}

		if (strcmp(s, name) == 0)
		{
			trap_SetConfigstring(start + i, "");
			for (j = i + 1; j < max - 1; j++)
			{
				trap_GetConfigstring(start + j, s, sizeof(s));
				trap_SetConfigstring(start + j, "");
				trap_SetConfigstring(start + i, s);

			}
			break;
		}
	}
}
Ejemplo n.º 5
0
/*
=======================================================================================================================================
BotIsFirstInRankings
=======================================================================================================================================
*/
int BotIsFirstInRankings(bot_state_t *bs) {
	int i, score;
	char buf[MAX_INFO_STRING];
	playerState_t ps;

	score = bs->cur_ps.persistant[PERS_SCORE];

	for (i = 0; i < level.maxclients; i++) {
		trap_GetConfigstring(CS_PLAYERS + i, buf, sizeof(buf));
		// if no config string or no name
		if (!strlen(buf) || !strlen(Info_ValueForKey(buf, "n"))) {
			continue;
		}
		// skip spectators
		if (atoi(Info_ValueForKey(buf, "t")) == TEAM_SPECTATOR) {
			continue;
		}

		if (BotAI_GetClientState(i, &ps) && score < ps.persistant[PERS_SCORE]) {
			return qfalse;
		}
	}

	return qtrue;
}
Ejemplo n.º 6
0
/*
=======================================================================================================================================
BotFirstClientInRankings
=======================================================================================================================================
*/
char *BotFirstClientInRankings(void) {
	int i, bestscore, bestclient;
	char buf[MAX_INFO_STRING];
	static char name[32];
	playerState_t ps;

	bestscore = -999999;
	bestclient = 0;

	for (i = 0; i < level.maxclients; i++) {
		trap_GetConfigstring(CS_PLAYERS + i, buf, sizeof(buf));
		// if no config string or no name
		if (!strlen(buf) || !strlen(Info_ValueForKey(buf, "n"))) {
			continue;
		}
		// skip spectators
		if (atoi(Info_ValueForKey(buf, "t")) == TEAM_SPECTATOR) {
			continue;
		}

		if (BotAI_GetClientState(i, &ps) && ps.persistant[PERS_SCORE] > bestscore) {
			bestscore = ps.persistant[PERS_SCORE];
			bestclient = i;
		}
	}

	EasyClientName(bestclient, name, 32);
	return name;
}
Ejemplo n.º 7
0
/*
===================
G_ScriptAction_SetWinner

  syntax: wm_setwinner <team>

  team: 0==AXIS, 1==ALLIED
===================
*/
qboolean G_ScriptAction_SetWinner( gentity_t *ent, char *params ) {
    char *pString, *token;
    char cs[MAX_STRING_CHARS];

    int num;

    pString = params;
    token = COM_Parse( &pString );
    if ( !token[0] ) {
        G_Error( "G_ScriptAction_SetWinner: number parameter required\n" );
    }

    num = atoi( token );
    if ( num < -1 || num > 1 ) {
        G_Error( "G_ScriptAction_SetWinner: Invalid team number\n" );
    }

    trap_GetConfigstring( CS_MULTI_INFO, cs, sizeof( cs ) );

    Info_SetValueForKey( cs, "winner", token );

    trap_SetConfigstring( CS_MULTI_INFO, cs );

    return qtrue;
}
Ejemplo n.º 8
0
/*
===================
G_ScriptAction_ObjectiveAlliedDesc

  syntax: wm_objective_allied_desc <objective_number "Description in quotes">
===================
*/
qboolean G_ScriptAction_ObjectiveAlliedDesc( gentity_t *ent, char *params ) {
    char *pString, *token;
    char cs[MAX_STRING_CHARS];

    int num, cs_obj = CS_MULTI_OBJECTIVE1;

    pString = params;
    token = COM_Parse( &pString );
    if ( !token[0] ) {
        G_Error( "G_ScriptAction_ObjectiveAlliedDesc: number parameter required\n" );
    }

    num = atoi( token );
    if ( num < 1 || num > MAX_OBJECTIVES ) {
        G_Error( "G_ScriptAction_ObjectiveAlliedDesc: Invalid objective number\n" );
    }

    token = COM_Parse( &pString );
    if ( !token[0] ) {
        G_Error( "G_ScriptAction_ObjectiveAlliedDesc: description parameter required\n" );
    }

    // Move to correct objective config string
    cs_obj += ( num - 1 );

    trap_GetConfigstring( cs_obj, cs, sizeof( cs ) );

    Info_SetValueForKey( cs, "allied_desc", token );

    trap_SetConfigstring( cs_obj, cs );

    return qtrue;
}
int BotGetTeammates(bot_state_t *bs, int *teammates, int maxteammates) {

	int i, numteammates;
	char buf[MAX_INFO_STRING];
	static int maxclients;


	if (!maxclients)
		maxclients = trap_Cvar_VariableIntegerValue("sv_maxclients");

	//G_Printf("mates: ");

	numteammates = 0;
	for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
		trap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));
		//if no config string or no name
		if (!strlen(buf) || !strlen(Info_ValueForKey(buf, "n"))) continue;
		//skip spectators
		if (atoi(Info_ValueForKey(buf, "t")) == TEAM_SPECTATOR) continue;
		//
		if (BotSameTeam(bs, i)) {
			//
			teammates[numteammates++] = i;
			if (numteammates >= maxteammates) break;
			//G_Printf("/%s ", Info_ValueForKey(buf, "n"));
		}
	}
	//G_Printf("\n %d mates \n", numteammates);
	return numteammates;
}
Ejemplo n.º 10
0
/*
===================
G_ScriptAction_MapDescription

  syntax: wm_mapdescription <"long description of map in quotes">
===================
*/
qboolean G_ScriptAction_MapDescription( gentity_t *ent, char *params )
{
	char *pString, *token;
	char	cs[MAX_STRING_CHARS];

	pString = params;
	token = COM_Parse(&pString);
	trap_GetConfigstring( CS_MULTI_MAPDESC, cs, sizeof(cs) );

	if (g_goldrush.integer && !g_instaGib.integer)
	Q_strncpyz ( token, "^3Goldrush!\n^5-^3Steal the enemy gold!\n^5-^3Touch flags to score!\n^5-^3Gold weighs you down!\n^5-^3The more gold you have, the more points you get!", 1000 );
	if (g_goldrush.integer && g_instaGib.integer)
	Q_strncpyz ( token, "^3InstaGib Goldrush!\n^5-^3Steal the enemy gold!\n^5-^3One shot kills!\n^5-^3Touch flags to score!\n^5-^3Gold weighs you down!\n^5-^3The more gold you have, the more points you get!", 1000 );
	if (g_deathmatch.integer == 2)
	Q_strncpyz ( token, "^3Free for All!\n^5-^3Kill Everyone!\n^5-^3No Objectives!", 1000 );
	if (g_deathmatch.integer == 1)
	Q_strncpyz ( token, "^3Team Deathmatch!\n^5-^3Eliminate the other team!\n^5-^3No Objectives!", 1000 );
	
	if (g_SniperMode.integer && g_fraglimit.integer)
	Q_strncpyz ( token, va("^3Snipers Mode!\n^5-^3Use your sniper rifle to kill the other team!\n^5-^3First team to ^5%i ^3kills wins!\n^5-^3Use smoke can and binoculars for cover!", g_fraglimit.integer), 1000 );
	else if (g_SniperMode.integer && !g_fraglimit.integer)
	Q_strncpyz ( token, va("^3Snipers Mode!\n^5-^3Use your sniper rifle to kill the other team!\n^5-^3Use smoke can and binoculars for cover!"), 1000 );
		

	

	if ( Q_stricmp( cs, token ) ) {// NERVE - SMF - compare before setting, so we don't spam the clients during map_restart
	trap_SetConfigstring( CS_MULTI_MAPDESC, token );
	}

	return qtrue;
}
Ejemplo n.º 11
0
/*
===================
G_ScriptAction_SetWinner

  syntax: wm_setwinner <team>

  team: 0==AXIS, 1==ALLIED
===================
*/
qboolean G_ScriptAction_SetWinner( gentity_t *ent, char *params )
{
	char *pString, *token;
	char	cs[MAX_STRING_CHARS];
	int	num;

	if ( level.intermissiontime ) {
		return qtrue;
	}

	pString = params;
	token = COM_Parse(&pString);
	if (!token[0]) {
		G_Error( "G_ScriptAction_SetWinner: number parameter required\n" );
	}

	num = atoi( token );
	if ( num < -1 || num > 1 ) {
		G_Error( "G_ScriptAction_SetWinner: Invalid team number\n" );
	}

	trap_GetConfigstring( CS_MULTI_MAPWINNER, cs, sizeof(cs) );


	if(g_deathmatch.integer == 2)
			Q_strncpyz ( token, "5", 1000 );
	// NERVE - SMF - compare before setting, so we don't spam the clients during map_restart
	if ( Q_stricmp( Info_ValueForKey( cs, "winner" ), token ) ) {
		Info_SetValueForKey( cs, "winner", token );

		trap_SetConfigstring( CS_MULTI_MAPWINNER, cs );
	}

	return qtrue;
}
Ejemplo n.º 12
0
/*
===================
G_ScriptAction_NumberofObjectives

  syntax: wm_number_of_objectives <number>
===================
*/
qboolean G_ScriptAction_NumberofObjectives( gentity_t *ent, char *params )
{
	char *pString, *token;
	char	cs[MAX_STRING_CHARS];
	int	num;

	pString = params;
	token = COM_Parse(&pString);
	if (!token[0]) {
		G_Error( "G_ScriptAction_NumberofObjectives: number parameter required\n" );
	}

	num = atoi( token );
	if ( num < 1 || num > MAX_OBJECTIVES ) {
		G_Error( "G_ScriptAction_NumberofObjectives: Invalid number of objectives\n" );
	}
	
	
	trap_GetConfigstring( CS_MULTI_INFO, cs, sizeof(cs) );
	
	if(g_deathmatch.integer || g_goldrush.integer||g_SniperMode.integer)
				Q_strncpyz ( token, "0", 1000  );
	// NERVE - SMF - compare before setting, so we don't spam the clients during map_restart
	if ( Q_stricmp( Info_ValueForKey( cs, "numobjectives" ), token ) ) {

		Info_SetValueForKey( cs, "numobjectives", token );

		trap_SetConfigstring( CS_MULTI_INFO, cs );
	}

	
	//	trap_SetConfigstring( CS_MULTI_INFO, "0" );

	return qtrue;
}
Ejemplo n.º 13
0
/*
===================
G_ScriptAction_OverviewImage

  syntax: wm_mapdescription <shadername>
===================
*/
qboolean G_ScriptAction_OverviewImage( gentity_t *ent, char *params )			// NERVE - SMF
{
	char *pString, *token;
	char	cs[MAX_STRING_CHARS];

	pString = params;
	token = COM_Parse(&pString);
	if (!token[0]) {
		G_Error( "G_ScriptAction_OverviewImage: shader name required\n" );
	}

	trap_GetConfigstring( CS_MULTI_INFO, cs, sizeof(cs) );
	
	//No thanks s4nd..
	/*if(g_deathmatch.integer||g_goldrush.integer||g_SniperMode.integer)
	Q_strncpyz ( token, "S4NDMoD/s4ndmodlogo/S4NDMoDLogo.jpg", 1000 );*/

	// NERVE - SMF - compare before setting, so we don't spam the clients during map_restart
	if ( Q_stricmp( Info_ValueForKey( cs, "overviewimage" ), token ) ) {

		Info_SetValueForKey( cs, "overviewimage", token );
		trap_SetConfigstring( CS_MULTI_INFO, cs );
	}

	return qtrue;
}
Ejemplo n.º 14
0
static int GLua_Sys_GetCS(lua_State *L) {
	int csnum = luaL_checkint(L,1);
	char buff[2048];
	trap_GetConfigstring(csnum, buff, sizeof(buff));
	lua_pushstring(L,buff);
	return 1;
}
Ejemplo n.º 15
0
void BotMatch_WrongWall(bot_state_t* bs, bot_match_t *match){
	char netname[MAX_MESSAGE_SIZE];
	char buf[MAX_INFO_STRING];
	int client;

	if(gametype != GT_SPRAY)
		return;

	// talking about me ? (avoid clientfromname, its ambiguous)
	trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
	trap_GetConfigstring(CS_PLAYERS + bs->client, buf, sizeof(buf));
	Q_CleanStr( buf );
	if (!Q_stricmp(Info_ValueForKey(buf, "n"), netname)){
		// could be someone with same name, so make (more) sure
		if( ClientInSprayroom(bs->client) ){
			bs->which_wall = BotChooseCorrectWall(bs);
			bs->enemy = -1;
			// chat
			BotAI_BotInitialChat(bs, "wall_missed", NULL);
			trap_BotEnterChat(bs->cs, 0, CHAT_ALL);
			return;
		}
	}
	// check if opposite team
	client = ClientFromName(netname);
	if(!BotSameTeam(bs, client)){
		float rnd;
		// flame
		rnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_INSULT, 0, 1);
		if(random() > rnd) return;	
		BotAI_BotInitialChat(bs, "wall_insult", netname, NULL);
		trap_BotEnterChat(bs->cs, 0, CHAT_ALL);
	}
}
Ejemplo n.º 16
0
/*
===================
G_ScriptAction_NumberofObjectives

  syntax: wm_number_of_objectives <number>
===================
*/
qboolean G_ScriptAction_NumberofObjectives( gentity_t *ent, char *params ) {
    char *pString, *token;
    char cs[MAX_STRING_CHARS];

    int num;

    pString = params;
    token = COM_Parse( &pString );
    if ( !token[0] ) {
        G_Error( "G_ScriptAction_NumberofObjectives: number parameter required\n" );
    }

    num = atoi( token );
    if ( num < 1 || num > MAX_OBJECTIVES ) {
        G_Error( "G_ScriptAction_NumberofObjectives: Invalid number of objectives\n" );
    }

    trap_GetConfigstring( CS_MULTI_INFO, cs, sizeof( cs ) );

    Info_SetValueForKey( cs, "numobjectives", token );

    trap_SetConfigstring( CS_MULTI_INFO, cs );

    return qtrue;
}
Ejemplo n.º 17
0
/*
==================
BotRandomOpponentName
==================
*/
char *BotRandomOpponentName(bot_state_t *bs) {
	int i, count;
	char buf[MAX_INFO_STRING];
	int opponents[MAX_CLIENTS], numopponents;
	static char name[32];

	numopponents = 0;
	opponents[0] = 0;
	for (i = 0; i < level.maxclients; i++) {
		if (i == bs->client) continue;
		//
		trap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));
		//if no config string or no name
		if (!strlen(buf) || !strlen(Info_ValueForKey(buf, "n"))) continue;
		//skip spectators
		if (atoi(Info_ValueForKey(buf, "t")) == TEAM_SPECTATOR) continue;
		//skip team mates
		if (BotSameTeam(bs, i)) continue;
		//
		opponents[numopponents] = i;
		numopponents++;
	}
	count = random() * numopponents;
	for (i = 0; i < numopponents; i++) {
		count--;
		if (count <= 0) {
			EasyClientName(opponents[i], name, sizeof(name));
			return name;
		}
	}
	EasyClientName(opponents[0], name, sizeof(name));
	return name;
}
Ejemplo n.º 18
0
/*
==================
BotIsFirstInRankings
==================
*/
int BotIsFirstInRankings( bot_state_t *bs ) {
	int i, score;
	char buf[MAX_INFO_STRING];
	static int maxclients;
	playerState_t ps;

	if ( !maxclients ) {
		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
	}

	score = bs->cur_ps.persistant[PERS_SCORE];
	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
		//if no config string or no name
		if ( !strlen( buf ) || !strlen( Info_ValueForKey( buf, "n" ) ) ) {
			continue;
		}
		//skip spectators
		if ( atoi( Info_ValueForKey( buf, "t" ) ) == TEAM_SPECTATOR ) {
			continue;
		}
		//
		BotAI_GetClientState( i, &ps );
		if ( score < ps.persistant[PERS_SCORE] ) {
			return qfalse;
		}
	}
	return qtrue;
}
Ejemplo n.º 19
0
/*
==================
BotLastClientInRankings
==================
*/
char *BotLastClientInRankings( void ) {
	int i, worstscore, bestclient;
	char buf[MAX_INFO_STRING];
	static char name[32];
	static int maxclients;
	playerState_t ps;

	if ( !maxclients ) {
		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
	}

	worstscore = 999999;
	bestclient = 0;
	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
		//if no config string or no name
		if ( !strlen( buf ) || !strlen( Info_ValueForKey( buf, "n" ) ) ) {
			continue;
		}
		//skip spectators
		if ( atoi( Info_ValueForKey( buf, "t" ) ) == TEAM_SPECTATOR ) {
			continue;
		}
		//
		BotAI_GetClientState( i, &ps );
		if ( ps.persistant[PERS_SCORE] < worstscore ) {
			worstscore = ps.persistant[PERS_SCORE];
			bestclient = i;
		}
	}
	EasyClientName( bestclient, name, 32 );
	return name;
}
Ejemplo n.º 20
0
/*
==================
BotNumActivePlayers
==================
*/
int BotNumActivePlayers( void ) {
	int i, num;
	char buf[MAX_INFO_STRING];
	static int maxclients;

	if ( !maxclients ) {
		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
	}

	num = 0;
	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
		//if no config string or no name
		if ( !strlen( buf ) || !strlen( Info_ValueForKey( buf, "n" ) ) ) {
			continue;
		}
		//skip spectators
		if ( atoi( Info_ValueForKey( buf, "t" ) ) == TEAM_SPECTATOR ) {
			continue;
		}
		//
		num++;
	}
	return num;
}
Ejemplo n.º 21
0
void G_SetConfigStringValue( int num, const char* key, const char* value ) {
	char	cs[MAX_STRING_CHARS];
	
	trap_GetConfigstring( num, cs, sizeof(cs) );
	Info_SetValueForKey( cs, key, value );
	trap_SetConfigstring( num, cs );
}
Ejemplo n.º 22
0
/*
==============
BotUpdateInfoConfigStrings
==============
*/
void BotUpdateInfoConfigStrings(void) {
	int i;
	char buf[MAX_INFO_STRING];

	//let bot_report 0 run once to clear strings
	if (bot_report.modificationCount != level.botReportModificationCount) {
		level.botReportModificationCount = bot_report.modificationCount;
	}
	else if (!bot_report.integer) {
		return;
	}

	for (i = 0; i < level.maxplayers; i++) {
		//
		if ( !botstates[i] || !botstates[i]->inuse )
			continue;
		//
		trap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));
		//if no config string or no name
		if (!strlen(buf) || !strlen(Info_ValueForKey(buf, "n")))
			continue;
		//
		if (!bot_report.integer) {
			trap_SetConfigstring(CS_BOTINFO+i, "");
		}
		else {
			BotSetInfoConfigString(botstates[i]);
		}
	}
}
Ejemplo n.º 23
0
/*
================
G_FindConfigstringIndex

================
*/
int G_FindConfigstringIndex( const char *name, int start, int max, qboolean create ) {
	int i;
	char s[MAX_STRING_CHARS];

	if ( !name || !name[0] ) {
		return 0;
	}

	for ( i = 1 ; i < max ; i++ ) {
		trap_GetConfigstring( start + i, s, sizeof( s ) );
		if ( !s[0] ) {
			break;
		}
		if ( !strcmp( s, name ) ) {
			return i;
		}
	}

	if ( !create ) {
		return 0;
	}

	if ( i == max ) {
		G_Error( "G_FindConfigstringIndex: overflow" );
	}

	trap_SetConfigstring( start + i, name );

	return i;
}
Ejemplo n.º 24
0
/*
==================
BotNumTeamMates
==================
*/
int BotNumTeamMates( bot_state_t *bs ) {
	int i, numplayers;
	char buf[MAX_INFO_STRING];
	static int maxclients;

	if ( !maxclients ) {
		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
	}

	numplayers = 0;
	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
		//if no config string or no name
		if ( !strlen( buf ) || !strlen( Info_ValueForKey( buf, "n" ) ) ) {
			continue;
		}
		//skip spectators
		if ( atoi( Info_ValueForKey( buf, "t" ) ) == TEAM_SPECTATOR ) {
			continue;
		}
		//
		if ( BotSameTeam( bs, i ) ) {
			numplayers++;
		}
	}
	return numplayers;
}
Ejemplo n.º 25
0
int G_FindConfigstringByIndex( int index, int start, int max, char * nameOut, int nameBufferSize )
{
	if ( index < max )
	{
		trap_GetConfigstring( start + index, nameOut, nameBufferSize );
		return strlen( nameOut );
	}
	return 0;
}
Ejemplo n.º 26
0
int G_Surrender_v( gentity_t *ent, unsigned int dwVoteIndex,
		char *arg, char *arg2, qboolean fRefereeCmd )
{
	team_t team;
	
	// Vote request (vote is being initiated)
	if(arg) {
		if(g_gamestate.integer != GS_PLAYING) {
			return G_INVALID;
		}
		if(!vote_allow_surrender.integer)
			return G_INVALID;
			
		// yada - noone ever seemes to have thought of refs calling this
		if(	!ent||
				ent->client->sess.sessionTeam==TEAM_SPECTATOR
		){
			if(trap_Argc()==2){
				G_refPrintf(ent,"Usage: \\%s surrender <team>",fRefereeCmd?"ref":"callvote");
				return G_INVALID;
			}
			team=TeamFromString(arg2);
			if(	team!=TEAM_AXIS&&
					team!=TEAM_ALLIES
			){
				G_refPrintf(ent,"Invalid team specified.");
				return G_INVALID;
			}
			level.voteInfo.voteTeam=team;
		}else{
			team=ent->client->sess.sessionTeam;
		}
		
		Q_strncpyz(arg2,
			(team == TEAM_AXIS) ?
				"[AXIS]" : "[ALLIES]",
			VOTE_MAXSTRING);
	}
	// Vote action (vote has passed)
	else if(g_gamestate.integer == GS_PLAYING){
		char cs[MAX_STRING_CHARS];

		trap_GetConfigstring(CS_MULTI_MAPWINNER, cs, sizeof(cs));
		Info_SetValueForKey(cs, "winner",
			(level.voteInfo.voteTeam == TEAM_AXIS) ? "1" : "0");
		trap_SetConfigstring(CS_MULTI_MAPWINNER, cs);
		LogExit(va("%s Surrender\n",
			(level.voteInfo.voteTeam == TEAM_AXIS) ?
			"Axis" : "Allies"));
		AP(va("chat \"%s have surrendered!\" -1",
			(level.voteInfo.voteTeam == TEAM_AXIS) ?
			"^1AXIS^7" : "^4ALLIES^7"));
	}
	return(G_OK);
}
Ejemplo n.º 27
0
/*
==================
BotSortTeamMatesByBaseTravelTime
==================
*/
int BotSortTeamMatesByBaseTravelTime( bot_state_t *bs, int *teammates, int maxteammates ) {

	int i, j, k, numteammates, traveltime;
	char buf[MAX_INFO_STRING];
	static int maxclients;
	int traveltimes[MAX_CLIENTS];
	bot_goal_t *goal;

	if ( BotCTFTeam( bs ) == CTF_TEAM_RED ) {
		goal = &ctf_redflag;
	} else { goal = &ctf_blueflag;}

	if ( !maxclients ) {
		maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );
	}

	numteammates = 0;
	for ( i = 0; i < maxclients && i < MAX_CLIENTS; i++ ) {
		trap_GetConfigstring( CS_PLAYERS + i, buf, sizeof( buf ) );
		//if no config string or no name
		if ( !strlen( buf ) || !strlen( Info_ValueForKey( buf, "n" ) ) ) {
			continue;
		}
		//skip spectators
		if ( atoi( Info_ValueForKey( buf, "t" ) ) == TEAM_SPECTATOR ) {
			continue;
		}
		//
		if ( BotSameTeam( bs, i ) ) {
			//
			traveltime = BotClientTravelTimeToGoal( i, goal );
			//
			for ( j = 0; j < numteammates; j++ ) {
				if ( traveltime < traveltimes[j] ) {
					for ( k = numteammates; k > j; k-- ) {
						traveltimes[k] = traveltimes[k - 1];
						teammates[k] = teammates[k - 1];
					}
					traveltimes[j] = traveltime;
					teammates[j] = i;
					break;
				}
			}
			if ( j >= numteammates ) {
				traveltimes[j] = traveltime;
				teammates[j] = i;
			}
			numteammates++;
			if ( numteammates >= maxteammates ) {
				break;
			}
		}
	}
	return numteammates;
}
Ejemplo n.º 28
0
/*
==================
NumPlayersOnSameTeam
==================
*/
int NumPlayersOnSameTeam(bot_state_t *bs) {
	int i, num;
	char buf[MAX_INFO_STRING];

	num = 0;
	for (i = 0; i < level.maxplayers; i++) {
		trap_GetConfigstring(CS_PLAYERS+i, buf, MAX_INFO_STRING);
		if (strlen(buf)) {
			if (BotSameTeam(bs, i+1)) num++;
		}
	}
	return num;
}
Ejemplo n.º 29
0
/*
==============
BotUpdateInfoConfigStrings
==============
*/
void BotUpdateInfoConfigStrings(void) {
	int i;
	char buf[MAX_INFO_STRING];

	for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
		//
		if ( !botstates[i] || !botstates[i]->inuse )
			continue;
		//
		trap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));
		//if no config string or no name
		if (!strlen(buf) || !strlen(Info_ValueForKey(buf, "n")))
			continue;
		BotSetInfoConfigString(botstates[i]);
	}
}
Ejemplo n.º 30
0
/*
==================
BotNumActivePlayers
==================
*/
int BotNumActivePlayers(void) {
	int i, num;
	char buf[MAX_INFO_STRING];

	num = 0;
	for (i = 0; i < level.maxclients; i++) {
		trap_GetConfigstring(CS_PLAYERS+i, buf, sizeof(buf));
		//if no config string or no name
		if (!strlen(buf) || !strlen(Info_ValueForKey(buf, "n"))) continue;
		//skip spectators
		if (atoi(Info_ValueForKey(buf, "t")) == TEAM_SPECTATOR) continue;
		//
		num++;
	}
	return num;
}