示例#1
0
static void
PodiumPlacementThink(gentity_t * podium)
{
  vec3_t vec;
  vec3_t origin;
  vec3_t f, r, u;

  podium->nextthink = level.time + 100;

  AngleVectors(level.intermission_angle, vec, NULL, NULL);
  VectorMA(level.intermission_origin,
	   trap_Cvar_VariableIntegerValue("g_podiumDist"), vec, origin);
  origin[2] -= trap_Cvar_VariableIntegerValue("g_podiumDrop");
  G_SetOrigin(podium, origin);

  if (podium1)
  {
    VectorSubtract(level.intermission_origin, podium->r.currentOrigin, vec);
    vectoangles(vec, podium1->s.apos.trBase);
    podium1->s.apos.trBase[PITCH] = 0;
    podium1->s.apos.trBase[ROLL] = 0;

    AngleVectors(podium1->s.apos.trBase, f, r, u);
    VectorMA(podium->r.currentOrigin, offsetFirst[0], f, vec);
    VectorMA(vec, offsetFirst[1], r, vec);
    VectorMA(vec, offsetFirst[2], u, vec);

    G_SetOrigin(podium1, vec);
  }

  if (podium2)
  {
    VectorSubtract(level.intermission_origin, podium->r.currentOrigin, vec);
    vectoangles(vec, podium2->s.apos.trBase);
    podium2->s.apos.trBase[PITCH] = 0;
    podium2->s.apos.trBase[ROLL] = 0;

    AngleVectors(podium2->s.apos.trBase, f, r, u);
    VectorMA(podium->r.currentOrigin, offsetSecond[0], f, vec);
    VectorMA(vec, offsetSecond[1], r, vec);
    VectorMA(vec, offsetSecond[2], u, vec);

    G_SetOrigin(podium2, vec);
  }

  if (podium3)
  {
    VectorSubtract(level.intermission_origin, podium->r.currentOrigin, vec);
    vectoangles(vec, podium3->s.apos.trBase);
    podium3->s.apos.trBase[PITCH] = 0;
    podium3->s.apos.trBase[ROLL] = 0;

    AngleVectors(podium3->s.apos.trBase, f, r, u);
    VectorMA(podium->r.currentOrigin, offsetThird[0], f, vec);
    VectorMA(vec, offsetThird[1], r, vec);
    VectorMA(vec, offsetThird[2], u, vec);

    G_SetOrigin(podium3, vec);
  }
}
示例#2
0
static gentity_t *SpawnPodium( void ) {
	gentity_t	*podium;
	vec3_t		vec;
	vec3_t		origin;

	podium = G_Spawn();
	if ( !podium ) {
		return NULL;
	}

	podium->classname = "podium";
	podium->s.eType = ET_GENERAL;
	podium->s.number = podium - g_entities;
	podium->clipmask = CONTENTS_SOLID;
	podium->r.contents = CONTENTS_SOLID;
	if (g_gametype.integer > GT_SINGLE_PLAYER)
		podium->s.modelindex = G_ModelIndex( TEAM_PODIUM_MODEL );
	else
		podium->s.modelindex = G_ModelIndex( SP_PODIUM_MODEL );

	AngleVectors( level.intermission_angle, vec, NULL, NULL );
	VectorMA( level.intermission_origin, trap_Cvar_VariableIntegerValue( "g_podiumDist" ), vec, origin );
	origin[2] -= trap_Cvar_VariableIntegerValue( "g_podiumDrop" );
	G_SetOrigin( podium, origin );

	VectorSubtract( level.intermission_origin, podium->r.currentOrigin, vec );
	podium->s.apos.trBase[YAW] = vectoyaw( vec );
	trap_LinkEntity (podium);

	podium->think = PodiumPlacementThink;
	podium->nextthink = level.time + 100;
	return podium;
}
示例#3
0
文件: g_bot.c 项目: otty/cake3
/*
===============
Svcmd_AddBot_f
===============
*/
void Svcmd_AddBot_f(void)
{
	float           skill;
	int             delay;
	char            name[MAX_TOKEN_CHARS];
	char            altname[MAX_TOKEN_CHARS];
	char            string[MAX_TOKEN_CHARS];
	char            team[MAX_TOKEN_CHARS];

	// are bots enabled?
	if(!trap_Cvar_VariableIntegerValue("bot_enable"))
	{
		return;
	}

	// name
	trap_Argv(1, name, sizeof(name));
	if(!name[0])
	{
		trap_Printf("Usage: Addbot <botname> [skill 1-5] [team] [msec delay] [altname]\n");
		return;
	}

	// skill
	trap_Argv(2, string, sizeof(string));
	if(!string[0])
	{
		skill = 4;
	}
	else
	{
		skill = atof(string);
	}

	// team
	trap_Argv(3, team, sizeof(team));

	// delay
	trap_Argv(4, string, sizeof(string));
	if(!string[0])
	{
		delay = 0;
	}
	else
	{
		delay = atoi(string);
	}

	// alternative name
	trap_Argv(5, altname, sizeof(altname));

	G_AddBot(name, skill, team, delay, altname);

	// if this was issued during gameplay and we are playing locally,
	// go ahead and load the bot's media immediately
	if(level.time - level.startTime > 1000 && trap_Cvar_VariableIntegerValue("cl_running"))
	{
		trap_SendServerCommand(-1, "loaddefered\n");	// FIXME: spelled wrong, but not changing for demo
	}
}
/*
===============
UI_InitGameinfo
===============
*/
void UI_InitGameinfo( void ) {

	UI_InitMemory();
	UI_LoadArenas();
	UI_LoadBots();

	uis.demoversion = !!trap_Cvar_VariableIntegerValue( "ui_demoq3" );
	uis.demotestversion = !!trap_Cvar_VariableIntegerValue( "ui_demoq3test" );
}
示例#5
0
/*
===============
G_LoadBots
===============
*/
static void G_LoadBots( void ) {
	vmCvar_t	botsFile;
	int			numdirs;
	char		filename[128];
	char		dirlist[1024];
	char*		dirptr;
	int			i;
	int			dirlen;

	if ( !trap_Cvar_VariableIntegerValue( "bot_enable" ) ) {
		return;
	}

	g_numBots = 0;

	trap_Cvar_Register( &botsFile, "g_botsFile", "", CVAR_INIT|CVAR_ROM );
	if( *botsFile.string ) {
		G_LoadBotsFromFile(botsFile.string);
	}
	else {
		G_LoadBotsFromFile("scripts/bots.txt");
	}

	// get all bots from .bot files
	numdirs = trap_FS_GetFileList("scripts", ".bot", dirlist, 1024 );
	dirptr  = dirlist;
	for (i = 0; i < numdirs; i++, dirptr += dirlen+1) {
		dirlen = strlen(dirptr);
		strcpy(filename, "scripts/");
		strcat(filename, dirptr);
		G_LoadBotsFromFile(filename);
	}
	trap_Printf( va( "%i bots parsed\n", g_numBots ) );
}
示例#6
0
文件: g_api.c 项目: ETrun/ETrun
/**
 * Checkpoints request command
 */
qboolean G_API_getPlayerCheckpoints(char *result, gentity_t *ent, char *userName, char *mapName, char *runName, int runNum, char *authToken) {
	char net_port[8]             = { 0 };
	char bufferRunNum[8]         = { 0 };
	char encodedMapName[255]     = { 0 };
	char encodedOptUserName[255] = { 0 };
	char encodedRunName[255]     = { 0 };
	char cphysics[8]             = { 0 };

	sprintf(net_port, "%d", trap_Cvar_VariableIntegerValue("net_port"));
	sprintf(bufferRunNum, "%d", runNum);
	sprintf(cphysics, "%d", physics.integer);

	if (url_encode(mapName, encodedMapName) == qfalse ||
	    url_encode(userName, encodedOptUserName) == qfalse ||
	    url_encode(runName, encodedRunName) == qfalse) {
		return qfalse;
	}

	// Check authtoken emptiness
	if (authToken[0] == '\0') {
		Q_strncpyz(authToken, "undefined", MAX_QPATH);
	}

	return G_AsyncAPICall("e", result, ent, 7, encodedMapName, encodedOptUserName, encodedRunName, bufferRunNum, authToken, cphysics, net_port);
}
示例#7
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;
}
示例#8
0
/*
==================
CG_RemapShader_f
==================
*/
static void CG_RemapShader_f( void ) {
	char shader1[MAX_QPATH];
	char shader2[MAX_QPATH];
	char timeoffset[MAX_QPATH];

	if ( cg.connected && trap_Cvar_VariableIntegerValue( "sv_pure" ) ) {
		CG_Printf( "%s command cannot be used on pure servers.\n", CG_Argv( 0 ) );
		return;
	}

	if (trap_Argc() < 2 || trap_Argc() > 4) {
		CG_Printf( "Usage: %s <original shader> [new shader] [time offset]\n", CG_Argv( 0 ) );
		return;
	}

	Q_strncpyz( shader1, CG_Argv( 1 ), sizeof(shader1) );
	Q_strncpyz( shader2, CG_Argv( 2 ), sizeof( shader2 ) );

	if ( !strlen( shader2 ) ) {
		// reset shader remap
		Q_strncpyz( shader2, shader1, sizeof(shader2) );
	}

	Q_strncpyz( timeoffset, CG_Argv( 3 ), sizeof( timeoffset ) );

	trap_R_RemapShader( shader1, shader2, timeoffset );
}
示例#9
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;
}
示例#10
0
/*
=======================================================================================================================================
FindEnemyByName
=======================================================================================================================================
*/
int FindEnemyByName(bot_state_t *bs, char *name) {
	int i;
	char buf[MAX_INFO_STRING];
	static int maxclients;

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

	for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
		if (BotSameTeam(bs, i)) {
			continue;
		}

		ClientName(i, buf, sizeof(buf));

		if (!Q_stricmp(buf, name)) {
			return i;
		}
	}

	for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
		if (BotSameTeam(bs, i)) {
			continue;
		}

		ClientName(i, buf, sizeof(buf));

		if (stristr(buf, name)) {
			return i;
		}
	}

	return -1;
}
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;
}
示例#12
0
文件: g_api.c 项目: ETrun/ETrun
/**
 * Map rank request command
 */
qboolean G_API_mapRank(char *result, gentity_t *ent, char *mapName, char *optUserName, char *optMapName, char *optRunName, char *optPhysicsName, char *authToken) {
	char net_port[8]                = { 0 };
	char cphysics[8]                = { 0 };
	char encodedMapName[255]        = { 0 };
	char encodedOptUserName[255]    = { 0 };
	char encodedOptMapName[255]     = { 0 };
	char encodedOptRunName[255]     = { 0 };
	char encodedOptPhysicsName[255] = { 0 };

	sprintf(net_port, "%d", trap_Cvar_VariableIntegerValue("net_port"));
	sprintf(cphysics, "%d", physics.integer);

	if (!check_string(optUserName) || !check_string(optMapName) || !check_string(optRunName) || !check_string(optPhysicsName)) {
		return qfalse;
	}

	if (url_encode(mapName, encodedMapName) == qfalse ||
	    url_encode(optUserName, encodedOptUserName) == qfalse ||
	    url_encode(optMapName, encodedOptMapName) == qfalse ||
	    url_encode(optRunName, encodedOptRunName) == qfalse ||
	    url_encode(optPhysicsName, encodedOptPhysicsName) == qfalse) {
		return qfalse;
	}

	// Check authtoken emptiness
	if (authToken[0] == '\0') {
		Q_strncpyz(authToken, "undefined", MAX_QPATH);
	}

	return G_AsyncAPICall("r", result, ent, 8, encodedOptUserName, encodedOptMapName, encodedOptRunName, encodedOptPhysicsName, encodedMapName, authToken, cphysics, net_port);
}
static void CG_Rocket_DFCMAlienEvolve( int handle, const char *data )
{
	class_t alienClass = (class_t) atoi( Info_ValueForKey( data, "1" ) );
	const char *Class = "";
	const char *Icon = "";
	const char *action = "";
	int cost = BG_ClassCanEvolveFromTo( cg.predictedPlayerState.stats[ STAT_CLASS ], alienClass, cg.predictedPlayerState.persistant[ PERS_CREDIT ] );

	if( cg.predictedPlayerState.stats[ STAT_CLASS ] == alienClass )
	{
		Class = "active";
		//Check mark icon. UTF-8 encoding of \uf00c
		Icon = "<icon class=\"current\">\xEF\x80\x8C</icon>";
	}
	else if ( !BG_ClassUnlocked( alienClass ) || BG_ClassDisabled( alienClass ) )
	{
		Class = "locked";
		//Padlock icon. UTF-8 encoding of \uf023
		Icon = "<icon>\xEF\x80\xA3</icon>";
	}
	else if ( !trap_Cvar_VariableIntegerValue( "x_freeUpgrades" ) && cost == -1 )
	{
		Class = "expensive";
		//$1 bill icon. UTF-8 encoding of \uf0d6
		Icon = "<icon>\xEF\x83\x96</icon>";
	}
	else
	{
		Class = "available";
		action =  va( "onClick='Cmd.exec(\"class %s\") Events.pushevent(\"hide %s\", event)'", BG_Class( alienClass )->name, rocketInfo.menu[ ROCKETMENU_ALIENEVOLVE ].id );
	}

	Rocket_DataFormatterFormattedData( handle, va( "<button class='alienevo %s' onMouseover='Events.pushevent(\"setDS alienEvolveList alienClasss %s\", event)' %s>%s<img src='/%s'/></button>", Class, Info_ValueForKey( data, "2" ), action, Icon, CG_GetShaderNameFromHandle( cg_classes[ alienClass ].classIcon )), false );
}
示例#14
0
qboolean G_ParseSpawnString( char *string ) {
	char	keyname[MAX_TOKEN_CHARS];
	char	*token;
	int		developer = trap_Cvar_VariableIntegerValue("developer");

	level.numSpawnVars = 0;
	level.numSpawnVarChars = 0;

	token = COM_Parse( &string );

	// parse the opening brace
	if (!strlen(token)) {
		// end of spawn string
		return qfalse;
	}
	if ( token[0] != '{' ) {
		G_Printf( "Error: found %s when expecting {\n",token );
		return qfalse;
	}

	// go through all the key / value pairs
	while ( 1 ) {
		// parse key
		token = COM_Parse( &string );
		if (!strlen(token)) {
			G_Printf( "Error: EOF without closing brace\n" );
			return qfalse;
		}

		if ( token[0] == '}' ) {
			break;
		}
		Q_strncpyz(keyname,token,sizeof(keyname));
		if (developer)
			G_Printf( S_COLOR_CYAN "G_ParseSpawnString: keyname = '%s'\n", keyname );

		// parse value
		token = COM_Parse( &string );
		if (!strlen(token)) {
			G_Printf( "Error: EOF without closing brace\n" );
			return qfalse;
		}
		if (developer)
			G_Printf( S_COLOR_CYAN "G_ParseSpawnString: value = '%s'\n", token );

		if ( token[0] == '}' ) {
			G_Printf( "Error: closing brace without data\n" );
			return qfalse;
		}
		if ( level.numSpawnVars == MAX_SPAWN_VARS ) {
			G_Printf( "Error: MAX_SPAWN_VARS\n" );
			return qfalse;
		}
		level.spawnVars[ level.numSpawnVars ][0] = G_AddSpawnVarToken( keyname );
		level.spawnVars[ level.numSpawnVars ][1] = G_AddSpawnVarToken( token );
		level.numSpawnVars++;
	}

	return qtrue;
}
示例#15
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;
}
示例#16
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;
}
示例#17
0
qboolean JMP_AdminNoAccess( int iID, int iCmd )
{
	if ( iCmd == DS_IGNORE )
	{
		return qfalse;
	}

	iCmd = ( iCmd == DS_WAKE ) ? DS_SLEEP : iCmd;
	iCmd = ( iCmd == DS_UNPUNISH ) ? DS_PUNISH : iCmd;
	iCmd = ( iCmd == DS_UNSILENCE ) ? DS_SILENCE : iCmd;

	if ( sPlayerData[iID]->iAdminLogged <= 0 )
	{
		JMP_AdminMessage( iID, "You are not logged in" );
		return qtrue;
	}

	if ( trap_Cvar_VariableIntegerValue( va( "jmp_AdminLvl%iCmd", sPlayerData[iID]->iAdminLogged )) & ( 1 << iCmd ))
	{
		return qfalse;
	}
	else
	{
		JMP_AdminMessage( iID, "Insufficient privileges" );
		return qtrue;
	}
}
示例#18
0
文件: g_api.c 项目: ETrun/ETrun
/**
 * Get config command
 */
qboolean G_API_getConfig(void) {
	char *buf                = NULL;
	char net_port[8]         = { 0 };
	char cphysics[8]         = { 0 };
	char encodedMapName[255] = { 0 };

	buf = malloc(LARGE_RESPONSE_MAX_SIZE * sizeof (char));

	if (!buf) {
		LDE("%s\n", "failed to allocate memory");

		return qfalse;
	}

	sprintf(net_port, "%d", trap_Cvar_VariableIntegerValue("net_port"));
	sprintf(cphysics, "%d", physics.integer);

	if (url_encode(level.rawmapname, encodedMapName) == qfalse) {
		free(buf);

		return qfalse;
	}

	return G_SyncAPICall("o", buf, NULL, 4, encodedMapName, GAME_VERSION_DATED, cphysics, net_port);
}
示例#19
0
/*
=======================================================================================================================================
FindClientByName
=======================================================================================================================================
*/
int FindClientByName(char *name) {
	int i;
	char buf[MAX_INFO_STRING];
	static int maxclients;

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

	for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
		ClientName(i, buf, sizeof(buf));

		if (!Q_stricmp(buf, name)) {
			return i;
		}
	}

	for (i = 0; i < maxclients && i < MAX_CLIENTS; i++) {
		ClientName(i, buf, sizeof(buf));

		if (stristr(buf, name)) {
			return i;
		}
	}

	return -1;
}
示例#20
0
/*
============
G_ItemDisabled
============
*/
int G_ItemDisabled( gitem_t *item ) {

	char name[128];

	Com_sprintf(name, sizeof(name), "disable_%s", item->classname);
	return trap_Cvar_VariableIntegerValue( name );
}
示例#21
0
/*
===============
SaveRegisteredItems

Write the needed items to a config string
so the client will know which ones to precache
===============
*/
void SaveRegisteredItems( void ) {
	char string[MAX_ITEMS + 1];
	int i;
	int count;

	count = 0;
	for ( i = 0 ; i < bg_numItems ; i++ ) {
		if ( itemRegistered[i] ) {
			count++;
			string[i] = '1';
		} else {
			string[i] = '0';
		}

		// DHM - Nerve :: Make sure and register all weapons we use in WolfMP
		if ( g_gametype.integer >= GT_WOLF && string[i] == '0' && bg_itemlist[i].giType == IT_WEAPON && BG_WeaponInWolfMP( bg_itemlist[i].giTag ) ) {
			count++;
			string[i] = '1';
		}
	}
	string[ bg_numItems ] = 0;

	if ( trap_Cvar_VariableIntegerValue( "g_gametype" ) != GT_SINGLE_PLAYER ) {
		G_Printf( "%i items registered\n", count );
	}
	trap_SetConfigstring( CS_ITEMS, string );
}
示例#22
0
/*
===============
UI_PlayerInfo_UpdateColor
===============
*/
void UI_PlayerInfo_UpdateColor( uiPlayerInfo_t *pi ) {
	CG_PlayerColorFromIndex( trap_Cvar_VariableIntegerValue( "color1" ), pi->color1 );

	pi->c1RGBA[0] = 255 * pi->color1[0];
	pi->c1RGBA[1] = 255 * pi->color1[1];
	pi->c1RGBA[2] = 255 * pi->color1[2];
	pi->c1RGBA[3] = 255;
}
/*
==================
G_WriteSessionData

==================
*/
void G_WriteSessionData( void )
{
  int    i;

  //TA: ?
  trap_Cvar_Set( "session", va( "%i", 0 ) );

  for( i = 0 ; i < level.maxclients ; i++ )
  {
    if( level.clients[ i ].pers.connected == CON_CONNECTED )
      G_WriteClientSessionData( &level.clients[ i ] );
  }

  // write values for sv_maxclients and sv_democlients because they invalidate session data
  trap_Cvar_Set( "session", va( "%i %i",
                 trap_Cvar_VariableIntegerValue( "sv_maxclients" ),
                 trap_Cvar_VariableIntegerValue( "sv_democlients" ) ) );
}
示例#24
0
文件: g_api.c 项目: ETrun/ETrun
/**
 * Login request command
 */
qboolean G_API_login(char *result, gentity_t *ent, char *authToken) {
	char net_port[8] = { 0 };
	char cphysics[8] = { 0 };

	sprintf(net_port, "%d", trap_Cvar_VariableIntegerValue("net_port"));
	sprintf(cphysics, "%d", physics.integer);

	return G_AsyncAPICall("l", result, ent, 3, authToken, cphysics, net_port);
}
示例#25
0
// Set disabled votes for client UI
void G_voteFlags(void)
{
	int i, flags = 0;
	
	for(i=0; i<numVotesAvailable; i++) {
		if(trap_Cvar_VariableIntegerValue(voteToggles[i].pszCvar) == 0) flags |= voteToggles[i].flag;
	}

	if(flags != voteFlags.integer) trap_Cvar_Set("voteFlags", va("%d", flags));
}
示例#26
0
文件: ai_cast.c 项目: natelo/rtcwPub
void AICast_Init (void)
{
	vmCvar_t	cvar;
	int	i;

	numSecrets = 0;
	numcast = 0;
	numSpawningCast = 0;
	saveGamePending = qtrue;

	trap_Cvar_Register( &aicast_debug, "aicast_debug", "0", 0 );
	trap_Cvar_Register( &aicast_debugname, "aicast_debugname", "", 0 );
	trap_Cvar_Register( &aicast_scripts, "aicast_scripts", "1", 0 );

	// (aicast_thinktime / sv_fps) * aicast_maxthink = number of cast's to think between each aicast frame
	// so..
	// (100 / 20) * 6 = 30
	//
	// so if the level has more than 30 AI cast's, they could start to bunch up, resulting in slower thinks

	trap_Cvar_Register( &cvar, "aicast_thinktime", "50", 0 );
	aicast_thinktime = trap_Cvar_VariableIntegerValue( "aicast_thinktime" );

	trap_Cvar_Register( &cvar, "aicast_maxthink", "12", 0 );
	aicast_maxthink = trap_Cvar_VariableIntegerValue( "aicast_maxthink" );

	aicast_maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );

	aicast_skillscale = (float)trap_Cvar_VariableIntegerValue( "g_gameSkill" ) / (float)GSKILL_MAX;

	caststates = G_Alloc( aicast_maxclients * sizeof(cast_state_t) );
	memset( caststates, 0, sizeof(caststates) );
	for (i=0; i<MAX_CLIENTS; i++) {
		caststates[i].entityNum = i;
	}

	// try and load in the AAS now, so we can interact with it during spawning of entities
	i = 0;
	trap_AAS_SetCurrentWorld(0);
	while (!trap_AAS_Initialized() && (i++ < 10)) {
		trap_BotLibStartFrame((float) level.time / 1000);
	}
}
示例#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;
}
示例#28
0
/*
===============
Svcmd_AddBot_f
===============
*/
void Svcmd_AddBot_f( void ) {
	int				skill;
	int				delay;
	char			name[MAX_TOKEN_CHARS];
	char			string[MAX_TOKEN_CHARS];
	char			team[MAX_TOKEN_CHARS];

	// are bots enabled?
	if ( !bot_enable.integer ) {
		return;
	}

	// name
	trap_Argv( 1, name, sizeof( name ) );	/// read it just so we can check if it's a name (old method)
	if ( name[0] && !Q_stricmp( name, "?" ) ) {
		trap_Printf( "Usage: Addbot [skill 1-4] [team (RED/BLUE)] [msec delay]\n" );
		return;
	}
	// CHRUKER: b070 - Was 'wolfbot' but this must match in case
	Q_strncpyz( name, "Wolfbot", sizeof( name ) );	// RF, hard code the bots for wolf
	if ( !name[0] ) {
		trap_Printf( "Usage: Addbot [skill 1-4] [team (RED/BLUE)] [msec delay]\n" );
		return;
	}

	// skill
	trap_Argv( 1, string, sizeof( string ) );
	if ( !string[0] ) {
		trap_Cvar_Update( &bot_defaultskill );
		skill = bot_defaultskill.integer;
	}
	else {
		skill = atoi( string );
	}

	// team
	trap_Argv( 2, team, sizeof( team ) );

	// delay
	trap_Argv( 3, string, sizeof( string ) );
	if ( !string[0] ) {
		delay = 0;
	}
	else {
		delay = atoi( string );
	}

	G_AddBot( name, skill, team, NULL, 0, 0, -1, NULL, NULL, -1, NULL, qfalse);

	// if this was issued during gameplay and we are playing locally,
	// go ahead and load the bot's media immediately
	if ( level.time - level.startTime > 1000 &&
		trap_Cvar_VariableIntegerValue( "cl_running" ) ) {
	}
}
示例#29
0
文件: g_api.c 项目: ETrun/ETrun
/**
 * Checkpoints request command
 */
qboolean G_API_randommap(char *result, gentity_t *ent, char *mapName) {
	char net_port[8]         = { 0 };
	char encodedMapName[255] = { 0 };
	char cphysics[8]         = { 0 };

	sprintf(net_port, "%d", trap_Cvar_VariableIntegerValue("net_port"));
	sprintf(cphysics, "%d", physics.integer);

	if (url_encode(mapName, encodedMapName) == qfalse) {
		return qfalse;
	}

	return G_AsyncAPICall("f", result, ent, 3, encodedMapName, cphysics, net_port);
}
static JSBool cvar_getint(JSContext *cx, unsigned argc, jsval *vp)
{
	JSString *s;
	char *message;
	jsval rval;
	int result;
	if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &s))
		return JS_FALSE;
	message = JS_EncodeString(cx, s);
	result = trap_Cvar_VariableIntegerValue(message);
	JS_free(cx, message);
	JS_NewNumberValue(cx, result, &rval);
	JS_SET_RVAL(cx, vp, rval);
	return JS_TRUE;	
}