本文整理汇总了C++中GS_TeamBasedGametype函数的典型用法代码示例。如果您正苦于以下问题:C++ GS_TeamBasedGametype函数的具体用法?C++ GS_TeamBasedGametype怎么用?C++ GS_TeamBasedGametype使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GS_TeamBasedGametype函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BOT_DMclass_CheckShot
//==========================================
// BOT_DMclass_CheckShot
// Checks if shot is blocked (doesn't verify it would hit)
//==========================================
static bool BOT_DMclass_CheckShot( edict_t *ent, vec3_t point )
{
trace_t tr;
vec3_t start, forward, right, offset;
if( random() > ent->ai->pers.cha.firerate )
return false;
AngleVectors( ent->r.client->ps.viewangles, forward, right, NULL );
VectorSet( offset, 0, 0, ent->viewheight );
G_ProjectSource( ent->s.origin, offset, forward, right, start );
// blocked, don't shoot
G_Trace( &tr, start, vec3_origin, vec3_origin, point, ent, MASK_AISOLID );
if( tr.fraction < 0.8f )
{
if( tr.ent < 1 || !game.edicts[tr.ent].takedamage || game.edicts[tr.ent].movetype == MOVETYPE_PUSH )
return false;
// check if the player we found is at our team
if( game.edicts[tr.ent].s.team == ent->s.team && GS_TeamBasedGametype() )
return false;
}
return true;
}
示例2: G_Match_ScorelimitHit
/*
* G_Match_ScorelimitHit
*/
bool G_Match_ScorelimitHit( void )
{
edict_t *e;
if( GS_MatchState() != MATCH_STATE_PLAYTIME )
return false;
if( g_scorelimit->integer )
{
if( !GS_TeamBasedGametype() )
{
for( e = game.edicts+1; PLAYERNUM( e ) < gs.maxclients; e++ )
{
if( !e->r.inuse )
continue;
if( e->r.client->level.stats.score >= g_scorelimit->integer )
return true;
}
}
else
{
int team;
for( team = TEAM_ALPHA; team < GS_MAX_TEAMS; team++ )
{
if( teamlist[team].stats.score >= g_scorelimit->integer )
return true;
}
}
}
return false;
}
示例3: G_Gametype_GENERIC_SetUpWarmup
void G_Gametype_GENERIC_SetUpWarmup( void )
{
level.gametype.readyAnnouncementEnabled = true;
level.gametype.scoreAnnouncementEnabled = false;
level.gametype.countdownEnabled = false;
level.gametype.pickableItemsMask = ( level.gametype.spawnableItemsMask|level.gametype.dropableItemsMask );
if( GS_Instagib() )
level.gametype.pickableItemsMask &= ~G_INSTAGIB_NEGATE_ITEMMASK;
if( GS_TeamBasedGametype() )
{
bool any = false;
int team;
for( team = TEAM_ALPHA; team < GS_MAX_TEAMS; team++ )
{
if( G_Teams_TeamIsLocked( team ) )
{
G_Teams_UnLockTeam( team );
any = true;
}
}
if( any )
G_PrintMsg( NULL, "Teams unlocked.\n" );
}
else
{
if( G_Teams_TeamIsLocked( TEAM_PLAYERS ) )
{
G_Teams_UnLockTeam( TEAM_PLAYERS );
G_PrintMsg( NULL, "Teams unlocked.\n" );
}
}
G_Teams_RemoveInvites();
}
示例4: G_RunGametype
/*
* G_RunGametype
*/
void G_RunGametype( void )
{
G_Teams_ExecuteChallengersQueue();
G_Teams_UpdateMembersList();
G_Match_CheckStateAbort();
G_UpdateScoreBoardMessages();
//check gametype specific rules
if( game.asEngine != NULL )
GT_asCallThinkRules();
else
G_Gametype_GENERIC_ThinkRules();
if( G_EachNewSecond() )
{
G_CheckNumBots();
G_TickOutPowerUps();
}
if( G_EachNewMinute() )
G_CheckEvenTeam();
G_Match_ScoreAnnouncement();
G_Match_ReadyAnnouncement();
if( GS_TeamBasedGametype() )
G_Teams_UpdateTeamInfoMessages();
G_asGarbageCollect( false );
}
示例5: G_Gametype_GENERIC_SetUpCountdown
void G_Gametype_GENERIC_SetUpCountdown( void )
{
bool any = false;
int team;
G_Match_RemoveAllProjectiles();
G_Items_RespawnByType( 0, 0, 0 ); // respawn all items
level.gametype.readyAnnouncementEnabled = false;
level.gametype.scoreAnnouncementEnabled = false;
level.gametype.countdownEnabled = true;
level.gametype.pickableItemsMask = 0; // disallow item pickup
if( GS_TeamBasedGametype() )
{
for( team = TEAM_ALPHA; team < GS_MAX_TEAMS; team++ )
if( G_Teams_LockTeam( team ) )
any = true;
}
else
{
if( G_Teams_LockTeam( TEAM_PLAYERS ) )
any = true;
}
if( any )
G_PrintMsg( NULL, "Teams locked.\n" );
G_AnnouncerSound( NULL, trap_SoundIndex( va( S_ANNOUNCER_COUNTDOWN_GET_READY_TO_FIGHT_1_to_2, ( rand()&1 )+1 ) ),
GS_MAX_TEAMS, true, NULL );
}
示例6: BOT_DMclass_PlayerWeight
float BOT_DMclass_PlayerWeight( edict_t *self, edict_t *enemy )
{
bool rage_mode = false;
if( !enemy || enemy == self )
return 0;
if( G_ISGHOSTING( enemy ) || enemy->flags & (FL_NOTARGET|FL_BUSY) )
return 0;
if( self->r.client->ps.inventory[POWERUP_QUAD] || self->r.client->ps.inventory[POWERUP_SHELL] )
rage_mode = true;
// don't fight against powerups.
if( enemy->r.client && ( enemy->r.client->ps.inventory[POWERUP_QUAD] || enemy->r.client->ps.inventory[POWERUP_SHELL] ) )
return 0.2;
//if not team based give some weight to every one
if( GS_TeamBasedGametype() && ( enemy->s.team == self->s.team ) )
return 0;
// if having EF_CARRIER we can assume it's someone important
if( enemy->s.effects & EF_CARRIER )
return 2.0f;
if( enemy == self->ai->last_attacker )
return rage_mode ? 4.0f : 1.0f;
return rage_mode ? 4.0f : 0.3f;
}
示例7: CG_ForceTeam
//==============
// CG_ForceTeam
//==============
static int CG_ForceTeam( int entNum, int team )
{
if( !GS_TeamBasedGametype() )
{
if( ISVIEWERENTITY( entNum ) )
{
if( cg_forceMyTeamAlpha->integer )
return TEAM_ALPHA;
}
else
{
if( cg_forceTeamPlayersTeamBeta->integer )
return TEAM_BETA;
}
return team;
}
else
{
int myteam = cg.predictedPlayerState.stats[STAT_TEAM];
if( cg_forceMyTeamAlpha->integer && myteam != TEAM_SPECTATOR )
{
if( team == myteam )
return TEAM_ALPHA;
if( team == TEAM_ALPHA )
return myteam;
}
return team;
}
}
示例8: Cmd_ChaseCam_f
/*
* Cmd_ChaseCam_f
*/
void Cmd_ChaseCam_f( edict_t *ent ) {
bool team_only;
const char *arg1;
if( ent->s.team != TEAM_SPECTATOR && !ent->r.client->teamstate.is_coach ) {
G_Teams_JoinTeam( ent, TEAM_SPECTATOR );
if( !CheckFlood( ent, false ) ) { // prevent 'joined spectators' spam
G_PrintMsg( NULL, "%s%s joined the %s%s team.\n", ent->r.client->netname,
S_COLOR_WHITE, GS_TeamName( ent->s.team ), S_COLOR_WHITE );
}
}
// & 1 = scorelead
// & 2 = powerups
// & 4 = objectives
// & 8 = fragger
if( ent->r.client->teamstate.is_coach && GS_TeamBasedGametype() ) {
team_only = true;
} else {
team_only = false;
}
arg1 = trap_Cmd_Argv( 1 );
if( trap_Cmd_Argc() < 2 ) {
G_ChasePlayer( ent, NULL, team_only, 0 );
} else if( !Q_stricmp( arg1, "auto" ) ) {
G_PrintMsg( ent, "Chasecam mode is 'auto'. It will follow the score leader when no powerup nor flag is carried.\n" );
G_ChasePlayer( ent, NULL, team_only, 7 );
} else if( !Q_stricmp( arg1, "carriers" ) ) {
G_PrintMsg( ent, "Chasecam mode is 'carriers'. It will switch to flag or powerup carriers when any of these items is picked up.\n" );
G_ChasePlayer( ent, NULL, team_only, 6 );
} else if( !Q_stricmp( arg1, "powerups" ) ) {
G_PrintMsg( ent, "Chasecam mode is 'powerups'. It will switch to powerup carriers when any of these items is picked up.\n" );
G_ChasePlayer( ent, NULL, team_only, 2 );
} else if( !Q_stricmp( arg1, "objectives" ) ) {
G_PrintMsg( ent, "Chasecam mode is 'objectives'. It will switch to objectives carriers when any of these items is picked up.\n" );
G_ChasePlayer( ent, NULL, team_only, 4 );
} else if( !Q_stricmp( arg1, "score" ) ) {
G_PrintMsg( ent, "Chasecam mode is 'score'. It will always follow the player with the best score.\n" );
G_ChasePlayer( ent, NULL, team_only, 1 );
} else if( !Q_stricmp( arg1, "fragger" ) ) {
G_PrintMsg( ent, "Chasecam mode is 'fragger'. The last fragging player will be followed.\n" );
G_ChasePlayer( ent, NULL, team_only, 8 );
} else if( !Q_stricmp( arg1, "help" ) ) {
G_PrintMsg( ent, "Chasecam modes:\n" );
G_PrintMsg( ent, "- 'auto': Chase the score leader unless there's an objective carrier or a powerup carrier.\n" );
G_PrintMsg( ent, "- 'carriers': User has pov control unless there's an objective carrier or a powerup carrier.\n" );
G_PrintMsg( ent, "- 'objectives': User has pov control unless there's an objective carrier.\n" );
G_PrintMsg( ent, "- 'powerups': User has pov control unless there's a flag carrier.\n" );
G_PrintMsg( ent, "- 'score': Always follow the score leader. User has no pov control.\n" );
G_PrintMsg( ent, "- 'none': Disable chasecam.\n" );
return;
} else {
G_ChasePlayer( ent, arg1, team_only, 0 );
}
G_Teams_LeaveChallengersQueue( ent );
}
示例9: GS_CheckBladeAutoAttack
static qboolean GS_CheckBladeAutoAttack( player_state_t *playerState, int timeDelta )
{
vec3_t origin, dir, end;
trace_t trace;
entity_state_t *targ, *player;
gs_weapon_definition_t *weapondef = GS_GetWeaponDef( WEAP_GUNBLADE );
if( playerState->POVnum <= 0 || (int)playerState->POVnum > gs.maxclients )
return qfalse;
if( !( playerState->pmove.stats[PM_STAT_FEATURES] & PMFEAT_GUNBLADEAUTOATTACK ) )
return qfalse;
VectorCopy( playerState->pmove.origin, origin );
origin[2] += playerState->viewheight;
AngleVectors( playerState->viewangles, dir, NULL, NULL );
VectorMA( origin, weapondef->firedef_weak.timeout, dir, end );
// check for a player to touch
module_Trace( &trace, origin, vec3_origin, vec3_origin, end, playerState->POVnum, CONTENTS_BODY, timeDelta );
if( trace.ent <= 0 || trace.ent > gs.maxclients )
return qfalse;
player = module_GetEntityState( playerState->POVnum, 0 );
targ = module_GetEntityState( trace.ent, 0 );
if( !( targ->effects & EF_TAKEDAMAGE ) || targ->type != ET_PLAYER )
return qfalse;
if( GS_TeamBasedGametype() && ( targ->team == player->team ) )
return qfalse;
return qtrue;
}
示例10: G_GameTypes_DenyJoinTeam
/*
* G_GameTypes_DenyJoinTeam
*/
static int G_GameTypes_DenyJoinTeam( edict_t *ent, int team )
{
if( team < 0 || team >= GS_MAX_TEAMS )
{
G_Printf( "WARNING: 'G_GameTypes_CanJoinTeam' parsing a unrecognized team value\n" );
return ER_TEAM_INVALID;
}
if( team == TEAM_SPECTATOR )
return ER_TEAM_OK;
if( GS_MatchState() > MATCH_STATE_PLAYTIME )
return ER_TEAM_MATCHSTATE;
// waiting for chanllengers queue to be executed
if( GS_HasChallengers() &&
game.realtime < level.spawnedTimeStamp + (unsigned)( G_CHALLENGERS_MIN_JOINTEAM_MAPTIME + game.snapFrameTime ) )
return ER_TEAM_CHALLENGERS;
// force eveyone to go through queue so things work on map change
if( GS_HasChallengers() && !ent->r.client->queueTimeStamp )
return ER_TEAM_CHALLENGERS;
//see if team is locked
if( G_Teams_TeamIsLocked( team ) && !G_Teams_PlayerIsInvited( team, ent ) )
return ER_TEAM_LOCKED;
if( GS_TeamBasedGametype() )
{
if( team >= TEAM_ALPHA && team < GS_MAX_TEAMS )
{
// see if team is full
int count = teamlist[team].numplayers;
if( ( count + 1 > level.gametype.maxPlayersPerTeam &&
level.gametype.maxPlayersPerTeam > 0 ) ||
( count + 1 > g_teams_maxplayers->integer &&
g_teams_maxplayers->integer > 0 ) )
return ER_TEAM_FULL;
if( !g_teams_allow_uneven->integer && !G_Teams_CanKeepEvenTeam( ent->s.team, team ) )
return ER_TEAM_UNEVEN;
return ER_TEAM_OK;
}
else
{
return ER_TEAM_INVALID;
}
}
else if( team == TEAM_PLAYERS )
{
return ER_TEAM_OK;
}
return ER_TEAM_INVALID;
}
示例11: InstantiateTeamBrain
AiBaseTeamBrain *AiBaseTeamBrain::InstantiateTeamBrain( int team, const char *gametype ) {
// Delegate construction to AiSquadBasedTeamBrain
if( GS_TeamBasedGametype() && !GS_InvidualGameType() ) {
return AiSquadBasedTeamBrain::InstantiateTeamBrain( team, gametype );
}
void *mem = G_Malloc( sizeof( AiBaseTeamBrain ) );
return new(mem)AiBaseTeamBrain( team );
}
示例12: G_Gametype_CanTeamDamage
/*
* G_Gametype_CanTeamDamage
*/
bool G_Gametype_CanTeamDamage( int damageflags )
{
if( damageflags & DAMAGE_NO_PROTECTION )
return true;
if( !GS_TeamBasedGametype() )
return true;
return g_allow_teamdamage->integer ? true : false;
}
示例13: G_Teams_AdvanceChallengersQueue
/*
* G_Teams_AdvanceChallengersQueue
*/
void G_Teams_AdvanceChallengersQueue( void )
{
int i, team, loserscount, winnerscount, playerscount = 0;
int maxscore = 999999;
edict_t *won, *e;
int START_TEAM = TEAM_PLAYERS, END_TEAM = TEAM_PLAYERS+1;
if( !GS_HasChallengers() )
return;
G_Teams_UpdateMembersList();
if( GS_TeamBasedGametype() )
{
START_TEAM = TEAM_ALPHA;
END_TEAM = GS_MAX_TEAMS;
}
// assign new timestamps to all the players inside teams
for( team = START_TEAM; team < END_TEAM; team++ )
{
playerscount += teamlist[team].numplayers;
}
if( !playerscount )
return;
loserscount = 0;
if( playerscount > 1 )
{
loserscount = (int)( playerscount / 2 );
}
winnerscount = playerscount - loserscount;
// put everyone who just played out of the challengers queue
for( team = START_TEAM; team < END_TEAM; team++ )
{
for( i = 0; i < teamlist[team].numplayers; i++ )
{
e = game.edicts + teamlist[team].playerIndices[i];
e->r.client->queueTimeStamp = 0;
}
}
// put (back) the best scoring players in first positions of challengers queue
for( i = 0; i < winnerscount; i++ )
{
won = G_Teams_BestScoreBelow( maxscore );
if( won )
{
maxscore = won->r.client->level.stats.score;
won->r.client->queueTimeStamp = 1 + ( winnerscount-i ); // never have 2 players with the same timestamp
}
}
}
示例14: Cmd_Timeout_f
/*
* Cmd_Timeout_f
*/
static void Cmd_Timeout_f( edict_t *ent )
{
int num;
if( ent->s.team == TEAM_SPECTATOR || GS_MatchState() != MATCH_STATE_PLAYTIME )
return;
if( GS_TeamBasedGametype() )
num = ent->s.team;
else
num = ENTNUM( ent )-1;
if( GS_MatchPaused() && ( level.timeout.endtime - level.timeout.time ) >= 2*TIMEIN_TIME )
{
G_PrintMsg( ent, "Timeout already in progress\n" );
return;
}
if( g_maxtimeouts->integer != -1 && level.timeout.used[num] >= g_maxtimeouts->integer )
{
if( g_maxtimeouts->integer == 0 )
G_PrintMsg( ent, "Timeouts are not allowed on this server\n" );
else if( GS_TeamBasedGametype() )
G_PrintMsg( ent, "Your team doesn't have any timeouts left\n" );
else
G_PrintMsg( ent, "You don't have any timeouts left\n" );
return;
}
G_PrintMsg( NULL, "%s%s called a timeout\n", ent->r.client->netname, S_COLOR_WHITE );
if( !GS_MatchPaused() )
G_AnnouncerSound( NULL, trap_SoundIndex( va( S_ANNOUNCER_TIMEOUT_TIMEOUT_1_to_2, ( rand()&1 )+1 ) ), GS_MAX_TEAMS, true, NULL );
level.timeout.used[num]++;
GS_GamestatSetFlag( GAMESTAT_FLAG_PAUSED, true );
level.timeout.caller = num;
level.timeout.endtime = level.timeout.time + TIMEOUT_TIME + FRAMETIME;
}
示例15: Cmd_Timein_f
/*
* Cmd_Timeout_f
*/
static void Cmd_Timein_f( edict_t *ent )
{
int num;
if( ent->s.team == TEAM_SPECTATOR )
return;
if( !GS_MatchPaused() )
{
G_PrintMsg( ent, "No timeout in progress.\n" );
return;
}
if( level.timeout.endtime - level.timeout.time <= 2 * TIMEIN_TIME )
{
G_PrintMsg( ent, "The timeout is about to end already.\n" );
return;
}
if( GS_TeamBasedGametype() )
num = ent->s.team;
else
num = ENTNUM( ent )-1;
if( level.timeout.caller != num )
{
if( GS_TeamBasedGametype() )
G_PrintMsg( ent, "Your team didn't call this timeout.\n" );
else
G_PrintMsg( ent, "You didn't call this timeout.\n" );
return;
}
level.timeout.endtime = level.timeout.time + TIMEIN_TIME + FRAMETIME;
G_AnnouncerSound( NULL, trap_SoundIndex( va( S_ANNOUNCER_TIMEOUT_TIMEIN_1_to_2, ( rand()&1 )+1 ) ), GS_MAX_TEAMS, true, NULL );
G_PrintMsg( NULL, "%s%s called a timein\n", ent->r.client->netname, S_COLOR_WHITE );
}