本文整理汇总了C++中SetTeam函数的典型用法代码示例。如果您正苦于以下问题:C++ SetTeam函数的具体用法?C++ SetTeam怎么用?C++ SetTeam使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetTeam函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MovePlayer
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: Cmd_Follow_f
/* 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: G_smvAddView
// 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 );
}
示例4: ClientInactivityTimer
/*
=================
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;
}
示例5: G_refPlayerPut_cmd
// 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();
}
示例6: G_PutSpec_v
// *** 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);
}
示例7: MovePlayer
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;
}
示例8: RemoveDuelDrawLoser
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" );
}
}
示例9: SetTeam
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();
}
示例10: SetMaxHealth
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);
}
示例11: Cmd_FollowCycle_f
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
}
示例12: Svcmd_ForceTeam_f
/*
===================
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");
}
}
示例13: RemoveTournamentWinner
/*
=======================
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" );
}
示例14: G_ShuffleTeams
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\"" );
}
示例15: Svcmd_ForceTeam_f
/*
===================
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 );
}