Пример #1
0
int MovePlayer (void)
{
	int	i;

if ((gameData.app.nGameMode & GM_NETWORK) && (gameData.app.nGameMode & GM_TEAM)) {
	int name_index = 5;
	if (strlen (gameData.multigame.msg.szMsg) > 5)
		while (gameData.multigame.msg.szMsg [name_index] == ' ')
			name_index++;

	if (!NetworkIAmMaster ()) {
		HUDInitMessage (TXT_MOVE_RIGHTS, gameData.multiplayer.players [NetworkWhoIsMaster ()].callsign);
		return 1;
		}
	if (strlen (gameData.multigame.msg.szMsg) <= (size_t) name_index) {
		HUDInitMessage (TXT_MOVE_NAME);
		return 1;
		}
	for (i = 0; i < gameData.multiplayer.nPlayers; i++)
		if ((!strnicmp (gameData.multiplayer.players [i].callsign, &gameData.multigame.msg.szMsg [name_index], strlen (gameData.multigame.msg.szMsg)-name_index)) && (gameData.multiplayer.players [i].connected)) {
			if ((gameData.app.nGameMode & GM_CAPTURE) && (gameData.multiplayer.players [i].flags & PLAYER_FLAGS_FLAG)) {
				HUDInitMessage (TXT_MOVE_FLAG);
				return 1;
				}
			SetTeam (i, -1);
			break;
		}
	}
return 0;
}
Пример #2
0
/* LQ3A: Added eType variable. See LQ3A_FOLLOW_TYPE_* definitions for usage. */
void Cmd_Follow_f(gentity_t *ent, lq3a_follow_type_t eType) {
	int		i;
	char	arg[MAX_TOKEN_CHARS];

	if ( trap_Argc() != 2 ) {
		/* LQ3A */
		if ((ent->client->sess.spectatorState == SPECTATOR_FOLLOW) ||
				(ent->client->sess.spectatorState == SPECTATOR_FOLLOW_THIRDPERSON)) {
			StopFollowing( ent );
		}
		return;
	}

	trap_Argv( 1, arg, sizeof( arg ) );
	i = ClientNumberFromString( ent, arg );
	if ( i == -1 ) {
		return;
	}

	// can't follow self
	if ( &level.clients[ i ] == ent->client ) {
		return;
	}

	// can't follow another spectator
	if ( level.clients[ i ].sess.sessionTeam == TEAM_SPECTATOR ) {
		return;
	}

	// if they are playing a tournement game, count as a loss
	if ( (g_gametype.integer == GT_TOURNAMENT )
		&& ent->client->sess.sessionTeam == TEAM_FREE ) {
		ent->client->sess.losses++;
	}

	// first set them to spectator
	if ( ent->client->sess.sessionTeam != TEAM_SPECTATOR ) {

		/* LQ3A */
		SetTeam(ent, "spectator", qtrue);
	}

	/* LQ3A */
	switch (eType)
	{
	case LQ3A_FOLLOW_TYPE_THIRDPERSON:
		ent->client->sess.spectatorState = SPECTATOR_FOLLOW_THIRDPERSON;
		break;

//	case LQ3A_FOLLOW_AUTO:
//	case LQ3A_FOLLOW_TYPE_FIRSTPERSON:
	default:
		ent->client->sess.spectatorState = SPECTATOR_FOLLOW;
		break;
	}

	ent->client->sess.spectatorClient = i;
}
Пример #3
0
/*
=================
Cmd_FollowCycle_f
=================
*/
void Cmd_FollowCycle_f( gentity_t *ent, int dir ) {
	int		clientnum;
	int		original;

	// if they are playing a tournement game, count as a loss
	if ( (g_gametype.integer == GT_TOURNAMENT )
		&& ent->client->sess.sessionTeam == TEAM_FREE ) {
		ent->client->sess.losses++;
	}
	// first set them to spectator
	if ( ent->client->sess.spectatorState == SPECTATOR_NOT ) {
		SetTeam( ent, "spectator" );
	}

	if ( dir != 1 && dir != -1 ) {
		G_Error( "Cmd_FollowCycle_f: bad dir %i", dir );
	}

	// if dedicated follow client, just switch between the two auto clients
	if (ent->client->sess.spectatorClient < 0) {
		if (ent->client->sess.spectatorClient == -1) {
			ent->client->sess.spectatorClient = -2;
		} else if (ent->client->sess.spectatorClient == -2) {
			ent->client->sess.spectatorClient = -1;
		}
		return;
	}

	clientnum = ent->client->sess.spectatorClient;
	original = clientnum;
	do {
		clientnum += dir;
		if ( clientnum >= level.maxclients ) {
			clientnum = 0;
		}
		if ( clientnum < 0 ) {
			clientnum = level.maxclients - 1;
		}

		// can only follow connected clients
		if ( level.clients[ clientnum ].pers.connected != CON_CONNECTED ) {
			continue;
		}

		// can't follow another spectator
		if ( level.clients[ clientnum ].sess.sessionTeam == TEAM_SPECTATOR ) {
			continue;
		}

		// this is good, we can use it
		ent->client->sess.spectatorClient = clientnum;
		ent->client->sess.spectatorState = SPECTATOR_FOLLOW;
		return;
	} while ( clientnum != original );

	// leave it where it was
}
Пример #4
0
// Add a player entity to another player's multiview list
void G_smvAddView( gentity_t *ent, int pID ) {
	int i;
	mview_t *mv = NULL;
	gentity_t *v;

	if ( pID >= MAX_MVCLIENTS || G_smvLocateEntityInMVList( ent, pID, qfalse ) ) {
		return;
	}

	for ( i = 0; i < MULTIVIEW_MAXVIEWS; i++ ) {
		if ( !ent->client->pers.mv[i].fActive ) {
			mv = &ent->client->pers.mv[i];
			break;
		}
	}

	if ( mv == NULL ) {
		CP( va( "print \"[lof]** [lon]Sorry, no more MV slots available (all[lof] %d [lon]in use)[lof]\n\"", MULTIVIEW_MAXVIEWS ) );
		return;
	}

	mv->camera = G_Spawn();
	if ( mv->camera == NULL ) {
		return;
	}

	if ( ent->client->sess.sessionTeam == TEAM_SPECTATOR && /*ent->client->sess.sessionTeam != TEAM_SPECTATOR ||*/
		 ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) {
		SetTeam( ent, "s", qtrue, -1, -1, qfalse );
	} else if ( ent->client->sess.sessionTeam != TEAM_SPECTATOR && !( ent->client->ps.pm_flags & PMF_LIMBO ) ) {
		limbo( ent, qtrue );
	}

	ent->client->ps.clientNum = ent - g_entities;
	ent->client->sess.spectatorState = SPECTATOR_FREE;

	ent->client->pers.mvCount++;
	mv->fActive = qtrue;
	mv->entID = pID;

	v = mv->camera;
	v->classname = "misc_portal_surface";
	v->r.svFlags = SVF_PORTAL | SVF_SINGLECLIENT;   // Only merge snapshots for the target client
	v->r.singleClient = ent->s.number;
	v->s.eType = ET_PORTAL;

	VectorClear( v->r.mins );
	VectorClear( v->r.maxs );
	trap_LinkEntity( v );

	v->target_ent = &g_entities[pID];
	v->TargetFlag = pID;
	v->tagParent = ent;

	G_smvUpdateClientCSList( ent );
}
Пример #5
0
/*
=================
ClientInactivityTimer

Returns qfalse if the client is dropped
=================
*/
qboolean ClientInactivityTimer(gclient_t *client) {
	int i;
	int counter = 0;

	// suburb, take viewangles for inactivity drop instead of buttons
	for (i = 0; i < 3; ++i) {
		if (client->ps.viewangles[i] == client->pers.oldViewangles[i]) {
			counter++;
		}
	}

	// OSP - modified
	if ((g_inactivity.integer == 0 && client->sess.sessionTeam != TEAM_SPECTATOR) || (g_spectatorInactivity.integer == 0 && client->sess.sessionTeam == TEAM_SPECTATOR)) {

		// give everyone some time, so if the operator sets g_inactivity during
		// gameplay, everyone isn't kicked
		client->inactivityTime    = level.time + 60 * 1000;
		client->inactivityWarning = qfalse;
	} else if (counter != 3) {
		client->inactivityWarning = qfalse;
		client->inactivityTime    = level.time + 1000 * ((client->sess.sessionTeam != TEAM_SPECTATOR) ? g_inactivity.integer : g_spectatorInactivity.integer);
	} else if (!client->pers.localClient) {
		if (level.time > client->inactivityTime && client->inactivityWarning) {
			client->inactivityWarning = qfalse;
			client->inactivityTime    = level.time + 60 * 1000;

			// Nico, move inactive player to spec instead of kicking them
			// trap_DropClient( client - level.clients, "Dropped due to inactivity", 0 );

			AP(va("cpm \"%s ^7removed from teams due to inactivity! ^z(%i seconds) \n\"", client->pers.netname, g_inactivity.integer));
			SetTeam(g_entities + (client - level.clients), "s", -1, -1, qfalse);

			return qfalse;
		}

		if (!client->inactivityWarning && level.time > client->inactivityTime - 10000) {
			CPx(client - level.clients, "cp \"^310 seconds until inactivity drop!\n\"");
			CPx(client - level.clients, "print \"^310 seconds until inactivity drop!\n\"");
			G_Printf("10s inactivity warning issued to: %s\n", client->pers.netname);

			client->inactivityWarning = qtrue;
			client->inactivityTime    = level.time + 10000; // Just for safety
		}
	}

	// suburb, update viewangles
	if (counter != 3) {
		for (i = 0; i < 3; ++i) {
			client->pers.oldViewangles[i] = client->ps.viewangles[i];
		}
	}

	return qtrue;
}
Пример #6
0
// Puts a player on a team.
void G_refPlayerPut_cmd(gentity_t *ent, int team_id)
{
	int pid;
	char arg[MAX_TOKEN_CHARS];
	gentity_t *player;

	// Works for teamplayish matches
	if(g_gametype.integer < GT_WOLF) {
		G_refPrintf(ent, "\"put[allies|axis]\" only for team-based games!");
		return;
	}

	// Find the player to place.
	trap_Argv(2, arg, sizeof(arg));
	if((pid = ClientNumberFromString(ent, arg)) == -1) return;

	player = g_entities + pid;

	// Can only move to other teams.
	if(player->client->sess.sessionTeam == team_id) {
		G_refPrintf(ent, "\"%s\" is already on team %s!\n", player->client->pers.netname, aTeams[team_id]);
		return;
	}

	if(team_maxplayers.integer && TeamCount(-1, team_id) >= team_maxplayers.integer) {
		G_refPrintf(ent, "Sorry, the %s team is already full!\n",  aTeams[team_id]);
		return;
	}

	player->client->pers.invite = team_id;
	player->client->pers.ready = qfalse;

	if( team_id == TEAM_AXIS ) {
		SetTeam( player, "red", qtrue, -1, -1, qfalse );
	} else {
		SetTeam( player, "blue", qtrue, -1, -1, qfalse );
	}

	if(g_gamestate.integer == GS_WARMUP || g_gamestate.integer == GS_WARMUP_COUNTDOWN)
		G_readyMatchState();
}
Пример #7
0
// *** Player PutSpec ***
int G_PutSpec_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd)
{
	// yada - my ass... this isnt handled elsewhere at all
	//if( fRefereeCmd ){
	//	// handled elsewhere
	//	return(G_NOTFOUND);
	//}

	// Vote request (vote is being initiated)
	if(arg) {
		int pid;

		if(!vote_allow_putspec.integer && ent && !ent->client->sess.referee) {
			G_voteDisableMessage(ent, arg);
			return(G_INVALID);
		} else if(G_voteDescription(ent, fRefereeCmd, dwVoteIndex)) return(G_INVALID);
		else if((pid = ClientNumberFromString(ent, arg2)) == -1) return(G_INVALID);

		if(level.clients[pid].sess.referee) {
			G_refPrintf(ent, "Can't vote to PutSpec referees!");
			return(G_INVALID);
		}

		if(G_shrubbot_permission(&g_entities[pid], SBF_IMMUNITY)) {
			G_refPrintf( ent, "Can't vote to PutSpec admins!" );
			return G_INVALID;
		}

		if(level.clients[pid].sess.sessionTeam == TEAM_SPECTATOR ||
			level.clients[pid].sess.sessionTeam != ent->client->sess.sessionTeam) {
			G_refPrintf(ent, "You can only PutSpec players in your own team!");
			return G_INVALID;
		}

		Com_sprintf(level.voteInfo.vote_value, VOTE_MAXSTRING, "%d", pid);
		Com_sprintf(arg2, VOTE_MAXSTRING, "%s^7", level.clients[pid].pers.netname);

	// Vote action (vote has passed)
	} else {
		int pid = atoi(level.voteInfo.vote_value);

		SetTeam( &g_entities[pid], "s", qtrue, -1, -1, qfalse );
		trap_SendServerCommand( pid, va( "cpm \"^3You have been moved to the Spectators\"") );
		AP(va("cp \"%s ^3has been\nmoved to the Spectators!\n\"", level.clients[pid].pers.netname));
		ClientUserinfoChanged( pid );
		
		if(g_gamestate.integer == GS_WARMUP || g_gamestate.integer == GS_WARMUP_COUNTDOWN) {
			G_readyMatchState();
		}
	}

	return(G_OK);
}
Пример #8
0
int MovePlayer (void)
{
	int	i;

if ((gameData.app.nGameMode & GM_NETWORK) && (gameData.app.nGameMode & GM_TEAM)) {
	int name_index = 5;
	if (strlen (gameData.multigame.msg.szMsg) > 5)
		while (gameData.multigame.msg.szMsg [name_index] == ' ')
			name_index++;

	if (!NetworkIAmMaster ()) {
		HUDInitMessage (TXT_MOVE_RIGHTS, gameData.multiplayer.players [NetworkWhoIsMaster ()].callsign);
		return 1;
		}
	if (strlen (gameData.multigame.msg.szMsg) <= (size_t) name_index) {
		HUDInitMessage (TXT_MOVE_NAME);
		return 1;
		}
	for (i = 0; i < gameData.multiplayer.nPlayers; i++)
		if ((!strnicmp (gameData.multiplayer.players [i].callsign, &gameData.multigame.msg.szMsg [name_index], strlen (gameData.multigame.msg.szMsg)-name_index)) && (gameData.multiplayer.players [i].connected)) {
			if ((gameData.app.nGameMode & GM_CAPTURE) && (gameData.multiplayer.players [i].flags & PLAYER_FLAGS_FLAG)) {
				HUDInitMessage (TXT_MOVE_FLAG);
				return 1;
				}
#if 1
			SetTeam (i, -1);
#else
#if 0
			if (netGame.teamVector & (1<<i))
				netGame.teamVector&= (~ (1<<i));
			else
				netGame.teamVector|= (1<<i);
#else
				netGame.teamVector ^= (1<<i);
#endif
			for (t = 0;t<gameData.multiplayer.nPlayers;t++)
				if (gameData.multiplayer.players [t].connected)
					MultiResetObjectTexture (gameData.objs.objects + gameData.multiplayer.players [t].nObject);

			NetworkSendNetgameUpdate ();
			sprintf (gameData.multigame.msg.szMsg, TXT_TEAMCHANGE3, gameData.multiplayer.players [i].callsign);
			if (i == gameData.multiplayer.nLocalPlayer) {
				HUDInitMessage (TXT_TEAMCHANGE1);
				ResetCockpit ();
				}
			else
				HUDInitMessage (TXT_TEAMCHANGE2, gameData.multiplayer.players [i].callsign);
#endif
			break;
		}
	}
return 0;
}
Пример #9
0
void RemoveDuelDrawLoser(void)
{
	int clFirst = 0;
	int clSec = 0;
	int clFailure = 0;

	if ( level.clients[ level.sortedClients[0] ].pers.connected != CON_CONNECTED )
	{
		return;
	}
	if ( level.clients[ level.sortedClients[1] ].pers.connected != CON_CONNECTED )
	{
		return;
	}

	clFirst = level.clients[ level.sortedClients[0] ].ps.stats[STAT_HEALTH] + level.clients[ level.sortedClients[0] ].ps.stats[STAT_ARMOR];
	clSec = level.clients[ level.sortedClients[1] ].ps.stats[STAT_HEALTH] + level.clients[ level.sortedClients[1] ].ps.stats[STAT_ARMOR];

	if (clFirst > clSec)
	{
		clFailure = 1;
	}
	else if (clSec > clFirst)
	{
		clFailure = 0;
	}
	else
	{
		clFailure = 2;
	}

	if (clFailure != 2)
	{
		SetTeam( &g_entities[ level.sortedClients[clFailure] ], "s" );
	}
	else
	{ //we could be more elegant about this, but oh well.
		SetTeam( &g_entities[ level.sortedClients[1] ], "s" );
	}
}
Пример #10
0
void AXHackTrigger::HandleHacked(int32 NewTeam)
{
	SetTeam(NewTeam);

	for (int32 i = 0; i < ARRAY_COUNT(TeamProgress); i++)
	{
		TeamProgress[i] = 0;
	}
	UUTGameplayStatics::UTPlaySound(GetWorld(), HackCompletedSound, this, SRT_None);

	CurrentAmbientSound = NULL;
	AmbientSoundUpdated();
}
Пример #11
0
void AMech_RPGCharacter::SetupWithLoadout() {
	SetMaxHealth(startingLoadout.maxHealth);
	SetHealth(GetMaxHealth());
	SetDefenceModifier(startingLoadout.defenceModifier);
	SetHealthChangeModifier(startingLoadout.damageModifier);
	SetCanMove(startingLoadout.canMove);
	SetCanAttack(startingLoadout.canAttack);
	SetCanBeDamaged(startingLoadout.canBeDamaged);
	SetHealthRegen(startingLoadout.healthRegen);
	SetTeam(startingLoadout.team);
	SetSpeedModifier(startingLoadout.movementModifier);
	SetSpeed(startingLoadout.speed);
}
Пример #12
0
static void Cmd_FollowCycle_f( gentity_t *ent, int dir ) {
	int clientnum, original;

	// first set them to spectator
	if ( ent->client->sess.spectatorState == SPECTATOR_NOT ) {
		SetTeam( ent, "spectator" );
	}

	if ( dir != 1 && dir != -1 ) {
		trap->Error( ERR_DROP, "Cmd_FollowCycle_f: bad dir %i", dir );
	}

	// if dedicated follow client, just switch between the two auto clients
	if (ent->client->sess.spectatorClient < 0) {
		if (ent->client->sess.spectatorClient == -1) {
			ent->client->sess.spectatorClient = -2;
		} else if (ent->client->sess.spectatorClient == -2) {
			ent->client->sess.spectatorClient = -1;
		}
		return;
	}

	clientnum = ent->client->sess.spectatorClient;
	original = clientnum;
	do {
		clientnum += dir;
		if ( clientnum >= level.maxclients ) {
			clientnum = 0;
		}
		if ( clientnum < 0 ) {
			clientnum = level.maxclients - 1;
		}

		// can only follow connected clients
		if ( level.clients[ clientnum ].pers.connected != CON_CONNECTED ) {
			continue;
		}

		// can't follow another spectator
		if ( level.clients[ clientnum ].sess.sessionTeam == TEAM_SPECTATOR ) {
			continue;
		}

		// this is good, we can use it
		ent->client->sess.spectatorClient = clientnum;
		ent->client->sess.spectatorState = SPECTATOR_FOLLOW;
		return;
	} while ( clientnum != original );

	// leave it where it was
}
Пример #13
0
/**
 * @brief Update specs for blackout, as needed
 * @param[in] nTeam
 * @param[in] fLock
 */
void G_updateSpecLock(int nTeam, qboolean fLock)
{
	int       i;
	gentity_t *ent;

	teamInfo[nTeam].spec_lock = fLock;
	for (i = 0; i < level.numConnectedClients; i++)
	{
		ent = g_entities + level.sortedClients[i];

		if (ent->client->sess.referee)
		{
			continue;
		}

		ent->client->sess.spec_invite &= ~nTeam;

		if (ent->client->sess.sessionTeam != TEAM_SPECTATOR)
		{
			continue;
		}

		if (!fLock)
		{
			continue;
		}

#ifdef FEATURE_MULTIVIEW
		if (ent->client->pers.mvCount > 0)
		{
			G_smvRemoveInvalidClients(ent, nTeam);
		}
		else
#endif
		if (ent->client->sess.spectatorState == SPECTATOR_FOLLOW)
		{
			StopFollowing(ent);
			ent->client->sess.spec_team &= ~nTeam;
		}

#ifdef FEATURE_MULTIVIEW
		// ClientBegin sets blackout
		if (ent->client->pers.mvCount < 1)
		{
#endif
		SetTeam(ent, "s", qtrue, -1, -1, qfalse);
#ifdef FEATURE_MULTIVIEW
	}
#endif
	}
}
Пример #14
0
/*
===================
Svcmd_ForceTeamNum_f
Joe Kari: same than Svcmd_ForceTeam_f() except it accepts a client ID rather than its name. Usefull for RCON script bots.
Also, it prevent user from setting it to anything. Old Svcmd_ForceTeam_f() can lead to some bug.
*
forceteamnum <num> <team>
===================
*/
void Svcmd_ForceTeamNum_f( void ) {
	char		arg[MAX_TOKEN_CHARS];
	gclient_t	*cl;
	int		clientNum;

	trap_Argv( 1, arg, sizeof( arg ) );
	clientNum = atoi( arg );
	
	if ( clientNum >= level.maxclients || clientNum < 0 ) {
		Com_Printf("client not found\n");
		return;
	}
		                
	cl = &level.clients[ clientNum ] ;
	if ( cl->pers.connected != CON_CONNECTED ) {
		Com_Printf("client not found\n");
		return;
	}
	
	// set the team
	trap_Argv( 2, arg, sizeof( arg ) );
	
	if ( !Q_stricmp( arg, "lawmen" ) || !Q_stricmp( arg, "red" ) || !Q_stricmp( arg, "r" ) ) {
		SetTeam( &g_entities[cl - level.clients], "rs" );
	}
	else if ( !Q_stricmp( arg, "outlaws" ) || !Q_stricmp( arg, "blue" ) || !Q_stricmp( arg, "b" ) ) {
		SetTeam( &g_entities[cl - level.clients], "bs" );
	}
	else if ( !Q_stricmp( arg, "spectator" ) || !Q_stricmp( arg, "spec" ) || !Q_stricmp( arg, "s" ) ) {
		SetTeam( &g_entities[cl - level.clients], "s" );
	}
	else if ( !Q_stricmp( arg, "join" ) || !Q_stricmp( arg, "auto" ) ) {
		SetTeam( &g_entities[cl - level.clients], "join" );
	}
	else {
		Com_Printf("bad team name\n");
	}
}
Пример #15
0
/*
=======================
RemoveTournamentWinner
=======================
*/
void RemoveTournamentWinner() 
{
	if( theLevel.numPlayingClients_ != 2 ) 
		return;

	int clientNum = theLevel.sortedClients_[0];

	if( theLevel.getClient(clientNum)->pers_.connected_ != GameClient::ClientPersistant::CON_CONNECTED ) 
		return;

	// make them a spectator
	//SetTeam( &g_entities[ clientNum ], "s" );
	SetTeam( theLevel.getEntity(clientNum), "s" );
}
Пример #16
0
void G_ShuffleTeams( void ) {
	int i = 0, idnum = 0, cTeam = 0, cnt = 0;
	gentity_t *cl_ent = NULL;
	int sortClients[MAX_CLIENTS];

	for ( i = 0; i < level.numConnectedClients; i++ ) {
		idnum = level.sortedClients[i];
		cl_ent = &g_entities[idnum];

		if ( cl_ent->client->sess.sessionTeam != TEAM_RED && cl_ent->client->sess.sessionTeam != TEAM_BLUE ) {
			continue;
		}

		sortClients[cnt++] = level.sortedClients[i];
	}

	qsort( sortClients, cnt, sizeof(int), G_SortPlayersByScoreRate );

	for ( i = 0; i < cnt; i++ ) {
		idnum = sortClients[i];
		cl_ent = &g_entities[idnum];

		cTeam = (i % 2) + TEAM_RED;

		if ( cTeam != cl_ent->client->sess.sessionTeam ) {
			if ( cTeam == TEAM_RED ) {
				SetTeam( cl_ent, "r", qtrue );
			}
			else if ( cTeam == TEAM_BLUE ) {
				SetTeam( cl_ent, "b", qtrue );
			}
		}
	}

	trap->SendServerCommand( -1, "cp \"" S_COLOR_RED "Teams have been shuffled!\n\"" );
}
/*
===================
Svcmd_ForceTeam_f

forceteam <player> <team>
===================
*/
void	Svcmd_ForceTeam_f( void ) {
    gclient_t	*cl;
    char		str[MAX_TOKEN_CHARS];

    // find the player
    trap_Argv( 1, str, sizeof( str ) );
    cl = ClientForString( str );
    if ( !cl ) {
        return;
    }

    // set the team
    trap_Argv( 2, str, sizeof( str ) );
    SetTeam( &g_entities[cl - level.clients], str );
}
Пример #18
0
/*
=================
ClientInactivityTimer

Returns qfalse if the client is dropped
=================
*/
qboolean ClientInactivityTimer(gclient_t *client) {
	// OSP - modified
	if ((g_inactivity.integer == 0 && client->sess.sessionTeam != TEAM_SPECTATOR) || (g_spectatorInactivity.integer == 0 && client->sess.sessionTeam == TEAM_SPECTATOR)) {

		// give everyone some time, so if the operator sets g_inactivity during
		// gameplay, everyone isn't kicked
		client->inactivityTime    = level.time + 60 * 1000;
		client->inactivityWarning = qfalse;
	} else if (client->pers.cmd.forwardmove ||
	           client->pers.cmd.rightmove ||
	           client->pers.cmd.upmove ||
	           (client->pers.cmd.wbuttons & WBUTTON_ATTACK2) ||
	           (client->pers.cmd.buttons & BUTTON_ATTACK) ||
	           (client->pers.cmd.wbuttons & WBUTTON_LEANLEFT) ||
	           (client->pers.cmd.wbuttons & WBUTTON_LEANRIGHT)
	           || client->ps.pm_type == PM_DEAD) {

		client->inactivityWarning = qfalse;
		client->inactivityTime    = level.time + 1000 *
		                            ((client->sess.sessionTeam != TEAM_SPECTATOR) ?
		                          g_inactivity.integer :
		                          g_spectatorInactivity.integer);

	} else if (!client->pers.localClient) {
		if (level.time > client->inactivityTime && client->inactivityWarning) {
			client->inactivityWarning = qfalse;
			client->inactivityTime    = level.time + 60 * 1000;

			// Nico, move inactive player to spec instead of kicking them
			// trap_DropClient( client - level.clients, "Dropped due to inactivity", 0 );

			AP(va("cpm \"%s ^7removed from teams due to inactivity! ^z(%i seconds) \n\"", client->pers.netname, g_inactivity.integer));
			SetTeam(g_entities + (client - level.clients), "s", -1, -1, qfalse);

			return qfalse;
		}

		if (!client->inactivityWarning && level.time > client->inactivityTime - 10000) {
			CPx(client - level.clients, "cp \"^310 seconds until inactivity drop!\n\"");
			CPx(client - level.clients, "print \"^310 seconds until inactivity drop!\n\"");
			G_Printf("10s inactivity warning issued to: %s\n", client->pers.netname);

			client->inactivityWarning = qtrue;
			client->inactivityTime    = level.time + 10000; // Just for safety
		}
	}
	return qtrue;
}
/*
=======================
RemoveTournamentWinner
=======================
*/
void RemoveTournamentWinner( void ) {
	int			clientNum;

	if ( level.numPlayingClients != 2 ) {
		return;
	}

	clientNum = level.sortedClients[0];

	if ( level.clients[ clientNum ].pers.connected != CON_CONNECTED ) {
		return;
	}

	// make them a spectator
	SetTeam( &g_entities[ clientNum ], "s" );
}
Пример #20
0
void G_RemoveDuelist(int team)
{
	int i = 0;
	gentity_t *ent;
	while (i < MAX_CLIENTS)
	{
		ent = &g_entities[i];

		if (ent->inuse && ent->client && ent->client->sess.sessionTeam != TEAM_SPECTATOR &&
			ent->client->sess.duelTeam == team)
		{
			SetTeam(ent, "s");
		}
        i++;
	}
}
Пример #21
0
/*
 * Cmd_Team_f
 */
void
Cmd_Team_f(Gentity *ent)
{
	int	oldTeam;
	char	s[MAX_TOKEN_CHARS];

	if(trap_Argc() != 2){
		oldTeam = ent->client->sess.team;
		switch(oldTeam){
		case TEAM_BLUE:
			trap_SendServerCommand(ent-g_entities,
				"print \"Blue team\n\"");
			break;
		case TEAM_RED:
			trap_SendServerCommand(ent-g_entities,
				"print \"Red team\n\"");
			break;
		case TEAM_FREE:
			trap_SendServerCommand(ent-g_entities,
				"print \"Free team\n\"");
			break;
		case TEAM_SPECTATOR:
			trap_SendServerCommand(ent-g_entities,
				"print \"Spectator team\n\"");
			break;
		}
		return;
	}

	if(ent->client->switchTeamTime > level.time){
		trap_SendServerCommand(
			ent-g_entities,
			"print \"May not switch teams more than once per 5 seconds.\n\"");
		return;
	}

	/* if they are playing a tournement game, count as a loss */
	if((g_gametype.integer == GT_TOURNAMENT)
	   && ent->client->sess.team == TEAM_FREE)
		ent->client->sess.losses++;

	trap_Argv(1, s, sizeof(s));

	SetTeam(ent, s);

	ent->client->switchTeamTime = level.time + 5000;
}
Пример #22
0
CPlayer::~CPlayer ( void )
{
    // Make sure the script debugger doesn't reference us
    SetScriptDebugLevel ( 0 );    

    if ( m_pCamera )
    {
        // Remove the camera from its targets FollowingCameras list
        if ( m_pCamera->GetTarget () )
            m_pCamera->GetTarget ()->m_FollowingCameras.remove ( m_pCamera );
        delete m_pCamera;
        m_pCamera = NULL;
    }    

    // Make sure nobody's syncing us
    RemoveAllSyncingVehicles ();
    RemoveAllSyncingPeds ();
    RemoveAllSyncingObjects ();

    // Delete the player text manager
    delete m_pPlayerTextManager;

    // Destroy our nick
    if ( m_szNametagText )
    {
        delete [] m_szNametagText;
        m_szNametagText = NULL;
    }

    SetTeam ( NULL, true );

    delete m_pPad;

    delete m_pKeyBinds;

    // Unlink from manager
    Unlink ();

    // Unparent us (CElement's unparenting will crash because of the incomplete vtable at that point)
    m_bDoNotSendEntities = true;
    SetParentObject ( NULL );

    CElementRefManager::RemoveElementRefs ( ELEMENT_REF_DEBUG ( this, "CPlayer" ), &m_pTeam, NULL );
    CElementRefManager::RemoveElementListRef ( ELEMENT_REF_DEBUG ( this, "CPlayer m_lstBroadcastList" ), &m_lstBroadcastList );
    CElementRefManager::RemoveElementListRef ( ELEMENT_REF_DEBUG ( this, "CPlayer m_lstIgnoredList" ), &m_lstIgnoredList );
}
Пример #23
0
// Called when the game starts or when spawned
void AGameObject::BeginPlay()
{
  Super::BeginPlay();

  //LOG( "%s [%s]->AGameObject::BeginPlay()", *GetName(), *Name );
  Team* newTeam = Game->gm->teams[ Stats.TeamId ];
  if( !newTeam )
  {
    error( FS( "Team %d not created yet", Stats.TeamId ) );
    newTeam = Game->gm->teams[ Stats.TeamId ] =
      new Team( Stats.TeamId, "err-team", Alliances::Neutral, FLinearColor::Red );
  }
  
  SetTeam( newTeam );
  ID = Game->NextId();
  InitIcons();
}
Пример #24
0
void NS_HandleTeamMenu( gentity_t *ent, int menuSlot ) {
	if ( g_gametype.integer < GT_TEAM ) {
		switch ( menuSlot ) {
		case 1:
			SetTeam( ent, "free" );
			NS_NavySeals_ClientInit( ent, qtrue );
			break;
		case 2:
			SetTeam( ent, "spectator" );
			break;
		default:
			break;
		}
		return;
	}
	switch ( menuSlot ) {
	case 1:
		// if we're in LTS mode, wait for the next round
		if ( g_gametype.integer == GT_LTS ) {
			SetTeam( ent, "seals" );
		} else { // else place us immediately
			SetTeam( ent, "tangos" );
		}

		// first time we played. set custom class

		break;
	case 2:
		if ( g_gametype.integer == GT_LTS ) {
			SetTeam( ent, "seals" );
		} else {
			SetTeam( ent, "tangos" );
		}

		// first time we played. set custom class

		break;
	case 3:
		// respawn as spectator
		SetTeam( ent, "spectator" );
		SetClass( ent, CLASS_NONE );
		NS_OpenSpectatorMenu( ent );
		break;
	default:
		break;
	}
}
Пример #25
0
/*
=============
AddTournamentPlayer

If there are less than two tournament players, put a
spectator in the game and restart
=============
*/
void AddTournamentPlayer( void ) {
	int			i;
	gclient_t	*client;
	gclient_t	*nextInLine;

	if ( level.numPlayingClients >= 2 ) {
		return;
	}

	// never change during intermission
	if ( level.intermissiontime ) {
		return;
	}

	nextInLine = NULL;

	for ( i = 0 ; i < level.maxclients ; i++ ) {
		client = &level.clients[i];
		if ( client->pers.connected != CON_CONNECTED ) {
			continue;
		}
		if ( client->sess.sessionTeam != TEAM_SPECTATOR ) {
			continue;
		}
		// never select the dedicated follow or scoreboard clients
		if ( client->sess.spectatorState == SPECTATOR_SCOREBOARD || 
			client->sess.spectatorClient < 0  ) {
			continue;
		}

		if ( !nextInLine || client->sess.spectatorTime < nextInLine->sess.spectatorTime ) {
			nextInLine = client;
		}
	}

	if ( !nextInLine ) {
		return;
	}

	level.warmupTime = -1;

	// set them to free-for-all team
	SetTeam( &g_entities[ nextInLine - level.clients ], "f" );
}
Пример #26
0
std::unique_ptr<CBaseAlien> CBaseAlien::Create(
    const ObjectCreateParams& params,
    Gfx::COldModelManager* modelManager,
    Gfx::CEngine* engine)
{
    auto obj = MakeUnique<CBaseAlien>(params.id, params.type);

    obj->SetTeam(params.team);

    std::unique_ptr<CPhysics> physics = MakeUnique<CPhysics>(obj.get());

    std::unique_ptr<CMotion> motion;
    if ( params.type == OBJECT_MOTHER )
    {
        motion = MakeUnique<CMotionQueen>(obj.get());
    }
    if ( params.type == OBJECT_ANT )
    {
        motion = MakeUnique<CMotionAnt>(obj.get());
    }
    if ( params.type == OBJECT_SPIDER )
    {
        motion = MakeUnique<CMotionSpider>(obj.get());
    }
    if ( params.type == OBJECT_BEE )
    {
        motion = MakeUnique<CMotionBee>(obj.get());
    }
    if ( params.type == OBJECT_WORM )
    {
        motion = MakeUnique<CMotionWorm>(obj.get());
    }
    assert(motion != nullptr);

    physics->SetMotion(motion.get());
    motion->SetPhysics(physics.get());

    motion->Create(params.pos, params.angle, params.type, 0.0f, modelManager);

    obj->SetProgrammable();
    obj->SetMovable(std::move(motion), std::move(physics));

    return std::move(obj);
}
Пример #27
0
/*
 * Cmd_FollowCycle_f
 */
void
Cmd_FollowCycle_f(Gentity *ent, int dir)
{
	int	clientnum;
	int	original;

	/* if they are playing a tournement game, count as a loss */
	if((g_gametype.integer == GT_TOURNAMENT)
	   && ent->client->sess.team == TEAM_FREE)
		ent->client->sess.losses++;
	/* first set them to spectator */
	if(ent->client->sess.specstate == SPECTATOR_NOT)
		SetTeam(ent, "spectator");

	if(dir != 1 && dir != -1)
		G_Error("Cmd_FollowCycle_f: bad dir %i", dir);

	clientnum	= ent->client->sess.specclient;
	original	= clientnum;
	do {
		clientnum += dir;
		if(clientnum >= level.maxclients)
			clientnum = 0;
		if(clientnum < 0)
			clientnum = level.maxclients - 1;

		/* can only follow connected clients */
		if(level.clients[ clientnum ].pers.connected != CON_CONNECTED)
			continue;

		/* can't follow another spectator */
		if(level.clients[ clientnum ].sess.team ==
		   TEAM_SPECTATOR)
			continue;

		/* this is good, we can use it */
		ent->client->sess.specclient	= clientnum;
		ent->client->sess.specstate	= SPECTATOR_FOLLOW;
		return;
	} while(clientnum != original);

	/* leave it where it was */
}
Пример #28
0
// Removes a player from a team.
void G_refRemove_cmd(gentity_t *ent)
{
	int pid;
	char arg[MAX_TOKEN_CHARS];
	gentity_t *player;

	// Works for teamplayish matches
	if(g_gametype.integer < GT_WOLF) {
		G_refPrintf(ent, "\"remove\" only for team-based games!");
		return;
	}
	
	// yada - yeah right not giving an arg will end up as slot 0...
	// fixme: could maybe also be handled in ClientNumberFromString
	// if(ent&&!*s) return ent-g_entities;
	if(trap_Argc()!=3){
		G_refPrintf(ent,"Usage: \\ref remove <pid>");
		return;
	}

	// Find the player to remove.
	trap_Argv(2, arg, sizeof(arg));
	if((pid = ClientNumberFromString(ent, arg)) == -1) return;

	player = g_entities + pid;

	// Can only remove active players.
	if(player->client->sess.sessionTeam == TEAM_SPECTATOR) {
		G_refPrintf(ent, "You can only remove people in the game!");
		return;
	}

	// Announce the removal
	AP(va("cp \"%s\n^7removed from team %s\n\"", player->client->pers.netname, aTeams[player->client->sess.sessionTeam]));
	CPx(pid, va("print \"^5You've been removed from the %s team\n\"", aTeams[player->client->sess.sessionTeam]));

	SetTeam( player, "s", qtrue, -1, -1, qfalse );

	if(g_gamestate.integer == GS_WARMUP || g_gamestate.integer == GS_WARMUP_COUNTDOWN) {
		G_readyMatchState();
	}
}
Пример #29
0
/*
===================
Svcmd_ForceTeam_f

forceteam <player> <team>
===================
*/
void	Svcmd_ForceTeam_f( void ) {
	gclient_t	*cl;
	char		str[MAX_TOKEN_CHARS];

	if ( trap->Argc() < 3 ) {
		trap->Print("Usage: forceteam <player> <team>\n");
		return;
	}

	// find the player
	trap->Argv( 1, str, sizeof( str ) );
	cl = ClientForString( str );
	if ( !cl ) {
		return;
	}

	// set the team
	trap->Argv( 2, str, sizeof( str ) );
	SetTeam( &g_entities[cl - level.clients], str );
}
Пример #30
0
/*
===================
Svcmd_ForceTeam_f

forceTeam <player> <team>
===================
*/
void	Svcmd_ForceTeam_f( void ) {
	gplayer_t	*player;
	char		str[MAX_TOKEN_CHARS];

	if ( trap_Argc() < 3 ) {
		G_Printf("Usage: forceTeam <player> <team>\n");
		return;
	}

	// find the player
	trap_Argv( 1, str, sizeof( str ) );
	player = PlayerForString( str );
	if ( !player ) {
		return;
	}

	// set the team
	trap_Argv( 2, str, sizeof( str ) );
	SetTeam( &g_entities[player - level.players], str );
}