Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

g_team.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Defines

#define CTF_ATTACKER_PROTECT_RADIUS   1000
#define CTF_CAPTURE_BONUS   5
#define CTF_CARRIER_DANGER_PROTECT_BONUS   2
#define CTF_CARRIER_DANGER_PROTECT_TIMEOUT   8000
#define CTF_CARRIER_PROTECT_BONUS   1
#define CTF_FLAG_BONUS   0
#define CTF_FLAG_DEFENSE_BONUS   1
#define CTF_FLAG_RETURN_TIME   40000
#define CTF_FRAG_CARRIER_ASSIST_BONUS   2
#define CTF_FRAG_CARRIER_ASSIST_TIMEOUT   10000
#define CTF_FRAG_CARRIER_BONUS   2
#define CTF_GRAPPLE_PULL_SPEED   750
#define CTF_GRAPPLE_SPEED   750
#define CTF_RECOVERY_BONUS   1
#define CTF_RETURN_FLAG_ASSIST_BONUS   1
#define CTF_RETURN_FLAG_ASSIST_TIMEOUT   10000
#define CTF_TARGET_PROTECT_RADIUS   1000
#define CTF_TEAM_BONUS   0
#define OVERLOAD_ATTACK_BASE_SOUND_TIME   20000

Functions

void AddTeamScore (vec3_t origin, int team, int score)
void CheckTeamStatus (void)
int OtherTeam (int team)
const char * OtherTeamName (int team)
int Pickup_Team (gentity_t *ent, gentity_t *other)
gentity_tSelectCTFSpawnPoint (team_t team, int teamstate, vec3_t origin, vec3_t angles)
void Team_CheckHurtCarrier (gentity_t *targ, gentity_t *attacker)
void Team_DroppedFlagThink (gentity_t *ent)
void Team_FragBonuses (gentity_t *targ, gentity_t *inflictor, gentity_t *attacker)
void Team_FreeEntity (gentity_t *ent)
gentity_tTeam_GetLocation (gentity_t *ent)
qboolean Team_GetLocationMsg (gentity_t *ent, char *loc, int loclen)
void Team_InitGame (void)
void Team_ReturnFlag (int team)
const char * TeamColorString (int team)
const char * TeamName (int team)
void TeamplayInfoMessage (gentity_t *ent)


Define Documentation

#define CTF_ATTACKER_PROTECT_RADIUS   1000
 

Definition at line 57 of file g_team.h.

Referenced by Team_FragBonuses().

#define CTF_CAPTURE_BONUS   5
 

Definition at line 41 of file g_team.h.

Referenced by Team_TouchOurFlag().

#define CTF_CARRIER_DANGER_PROTECT_BONUS   2
 

Definition at line 48 of file g_team.h.

Referenced by Team_FragBonuses().

#define CTF_CARRIER_DANGER_PROTECT_TIMEOUT   8000
 

Definition at line 59 of file g_team.h.

Referenced by Team_FragBonuses().

#define CTF_CARRIER_PROTECT_BONUS   1
 

Definition at line 49 of file g_team.h.

Referenced by Team_FragBonuses().

#define CTF_FLAG_BONUS   0
 

Definition at line 44 of file g_team.h.

Referenced by Team_TouchEnemyFlag().

#define CTF_FLAG_DEFENSE_BONUS   1
 

Definition at line 50 of file g_team.h.

Referenced by Team_FragBonuses().

#define CTF_FLAG_RETURN_TIME   40000
 

Definition at line 46 of file g_team.h.

#define CTF_FRAG_CARRIER_ASSIST_BONUS   2
 

Definition at line 52 of file g_team.h.

Referenced by Team_TouchOurFlag().

#define CTF_FRAG_CARRIER_ASSIST_TIMEOUT   10000
 

Definition at line 60 of file g_team.h.

Referenced by Team_TouchOurFlag().

#define CTF_FRAG_CARRIER_BONUS   2
 

Definition at line 45 of file g_team.h.

Referenced by Team_FragBonuses().

#define CTF_GRAPPLE_PULL_SPEED   750
 

Definition at line 64 of file g_team.h.

#define CTF_GRAPPLE_SPEED   750
 

Definition at line 63 of file g_team.h.

#define CTF_RECOVERY_BONUS   1
 

Definition at line 43 of file g_team.h.

Referenced by Team_TouchOurFlag().

#define CTF_RETURN_FLAG_ASSIST_BONUS   1
 

Definition at line 51 of file g_team.h.

Referenced by Team_TouchOurFlag().

#define CTF_RETURN_FLAG_ASSIST_TIMEOUT   10000
 

Definition at line 61 of file g_team.h.

Referenced by Team_TouchOurFlag().

#define CTF_TARGET_PROTECT_RADIUS   1000
 

Definition at line 56 of file g_team.h.

Referenced by Team_FragBonuses().

#define CTF_TEAM_BONUS   0
 

Definition at line 42 of file g_team.h.

Referenced by Team_TouchOurFlag().

#define OVERLOAD_ATTACK_BASE_SOUND_TIME   20000
 

Definition at line 66 of file g_team.h.


Function Documentation

void AddTeamScore vec3_t  origin,
int  team,
int  score
 

Definition at line 130 of file g_team.c.

References EV_GLOBAL_TEAM_SOUND, entityState_s::eventParm, G_TempEntity(), gentity_t, level, gentity_s::r, gentity_s::s, entityShared_t::svFlags, and level_locals_t::teamScores.

Referenced by Team_TouchOurFlag().

00130                                                       {
00131     gentity_t   *te;
00132 
00133     te = G_TempEntity(origin, EV_GLOBAL_TEAM_SOUND );
00134     te->r.svFlags |= SVF_BROADCAST;
00135 
00136     if ( team == TEAM_RED ) {
00137         if ( level.teamScores[ TEAM_RED ] + score == level.teamScores[ TEAM_BLUE ] ) {
00138             //teams are tied sound
00139             te->s.eventParm = GTS_TEAMS_ARE_TIED;
00140         }
00141         else if ( level.teamScores[ TEAM_RED ] <= level.teamScores[ TEAM_BLUE ] &&
00142                     level.teamScores[ TEAM_RED ] + score > level.teamScores[ TEAM_BLUE ]) {
00143             // red took the lead sound
00144             te->s.eventParm = GTS_REDTEAM_TOOK_LEAD;
00145         }
00146         else {
00147             // red scored sound
00148             te->s.eventParm = GTS_REDTEAM_SCORED;
00149         }
00150     }
00151     else {
00152         if ( level.teamScores[ TEAM_BLUE ] + score == level.teamScores[ TEAM_RED ] ) {
00153             //teams are tied sound
00154             te->s.eventParm = GTS_TEAMS_ARE_TIED;
00155         }
00156         else if ( level.teamScores[ TEAM_BLUE ] <= level.teamScores[ TEAM_RED ] &&
00157                     level.teamScores[ TEAM_BLUE ] + score > level.teamScores[ TEAM_RED ]) {
00158             // blue took the lead sound
00159             te->s.eventParm = GTS_BLUETEAM_TOOK_LEAD;
00160         }
00161         else {
00162             // blue scored sound
00163             te->s.eventParm = GTS_BLUETEAM_SCORED;
00164         }
00165     }
00166     level.teamScores[ team ] += score;
00167 }

Here is the call graph for this function:

void CheckTeamStatus void   ) 
 

Definition at line 1123 of file g_team.c.

References gentity_s::client, clientPersistant_t::connected, g_entities, g_maxclients, gentity_t, gentity_s::health, i, vmCvar_t::integer, gentity_s::inuse, level_locals_t::lastTeamLocationTime, level, playerTeamState_t::location, gclient_s::pers, gclient_s::sess, clientSession_t::sessionTeam, Team_GetLocation(), TEAM_RED, TeamplayInfoMessage(), clientPersistant_t::teamState, and level_locals_t::time.

Referenced by G_RunFrame().

01123                            {
01124     int i;
01125     gentity_t *loc, *ent;
01126 
01127     if (level.time - level.lastTeamLocationTime > TEAM_LOCATION_UPDATE_TIME) {
01128 
01129         level.lastTeamLocationTime = level.time;
01130 
01131         for (i = 0; i < g_maxclients.integer; i++) {
01132             ent = g_entities + i;
01133 
01134             if ( ent->client->pers.connected != CON_CONNECTED ) {
01135                 continue;
01136             }
01137 
01138             if (ent->inuse && (ent->client->sess.sessionTeam == TEAM_RED || ent->client->sess.sessionTeam == TEAM_BLUE)) {
01139                 loc = Team_GetLocation( ent );
01140                 if (loc)
01141                     ent->client->pers.teamState.location = loc->health;
01142                 else
01143                     ent->client->pers.teamState.location = 0;
01144             }
01145         }
01146 
01147         for (i = 0; i < g_maxclients.integer; i++) {
01148             ent = g_entities + i;
01149 
01150             if ( ent->client->pers.connected != CON_CONNECTED ) {
01151                 continue;
01152             }
01153 
01154             if (ent->inuse && (ent->client->sess.sessionTeam == TEAM_RED || ent->client->sess.sessionTeam == TEAM_BLUE)) {
01155                 TeamplayInfoMessage( ent );
01156             }
01157         }
01158     }
01159 }

Here is the call graph for this function:

int OtherTeam int  team  ) 
 

Definition at line 65 of file g_team.c.

Referenced by Team_FragBonuses(), and Team_TouchOurFlag().

00065                         {
00066     if (team==TEAM_RED)
00067         return TEAM_BLUE;
00068     else if (team==TEAM_BLUE)
00069         return TEAM_RED;
00070     return team;
00071 }

const char* OtherTeamName int  team  ) 
 

Definition at line 83 of file g_team.c.

00083                                     {
00084     if (team==TEAM_RED)
00085         return "BLUE";
00086     else if (team==TEAM_BLUE)
00087         return "RED";
00088     else if (team==TEAM_SPECTATOR)
00089         return "SPECTATOR";
00090     return "FREE";
00091 }

int Pickup_Team gentity_t ent,
gentity_t other
 

Definition at line 851 of file g_team.c.

References cl, gentity_s::classname, gentity_s::client, G_FreeEntity(), g_gametype, gclient_t, gentity_t, PrintMsg(), gentity_s::spawnflags, strcmp(), Team_TouchEnemyFlag(), and Team_TouchOurFlag().

Referenced by Touch_Item().

00851                                                     {
00852     int team;
00853     gclient_t *cl = other->client;
00854 
00855 #ifdef MISSIONPACK
00856     if( g_gametype.integer == GT_OBELISK ) {
00857         // there are no team items that can be picked up in obelisk
00858         G_FreeEntity( ent );
00859         return 0;
00860     }
00861 
00862     if( g_gametype.integer == GT_HARVESTER ) {
00863         // the only team items that can be picked up in harvester are the cubes
00864         if( ent->spawnflags != cl->sess.sessionTeam ) {
00865             cl->ps.generic1 += 1;
00866         }
00867         G_FreeEntity( ent );
00868         return 0;
00869     }
00870 #endif
00871     // figure out what team this flag is
00872     if( strcmp(ent->classname, "team_CTF_redflag") == 0 ) {
00873         team = TEAM_RED;
00874     }
00875     else if( strcmp(ent->classname, "team_CTF_blueflag") == 0 ) {
00876         team = TEAM_BLUE;
00877     }
00878 #ifdef MISSIONPACK
00879     else if( strcmp(ent->classname, "team_CTF_neutralflag") == 0  ) {
00880         team = TEAM_FREE;
00881     }
00882 #endif
00883     else {
00884         PrintMsg ( other, "Don't know what team the flag is on.\n");
00885         return 0;
00886     }
00887 #ifdef MISSIONPACK
00888     if( g_gametype.integer == GT_1FCTF ) {
00889         if( team == TEAM_FREE ) {
00890             return Team_TouchEnemyFlag( ent, other, cl->sess.sessionTeam );
00891         }
00892         if( team != cl->sess.sessionTeam) {
00893             return Team_TouchOurFlag( ent, other, cl->sess.sessionTeam );
00894         }
00895         return 0;
00896     }
00897 #endif
00898     // GT_CTF
00899     if( team == cl->sess.sessionTeam) {
00900         return Team_TouchOurFlag( ent, other, team );
00901     }
00902     return Team_TouchEnemyFlag( ent, other, team );
00903 }

Here is the call graph for this function:

gentity_t* SelectCTFSpawnPoint team_t  team,
int  teamstate,
vec3_t  origin,
vec3_t  angles
 

Definition at line 1033 of file g_team.c.

References entityState_s::angles, gentity_t, entityState_s::origin, gentity_s::s, SelectRandomTeamSpawnPoint(), SelectSpawnPoint(), vec3_origin, and VectorCopy.

Referenced by ClientSpawn().

01033                                                                                             {
01034     gentity_t   *spot;
01035 
01036     spot = SelectRandomTeamSpawnPoint ( teamstate, team );
01037 
01038     if (!spot) {
01039         return SelectSpawnPoint( vec3_origin, origin, angles );
01040     }
01041 
01042     VectorCopy (spot->s.origin, origin);
01043     origin[2] += 9;
01044     VectorCopy (spot->s.angles, angles);
01045 
01046     return spot;
01047 }

Here is the call graph for this function:

void Team_CheckHurtCarrier gentity_t targ,
gentity_t attacker
 

Definition at line 503 of file g_team.c.

References gentity_s::client, playerState_s::generic1, gentity_t, playerTeamState_t::lasthurtcarrier, level, gclient_s::pers, playerState_s::powerups, gclient_s::ps, gclient_s::sess, clientSession_t::sessionTeam, clientPersistant_t::teamState, and level_locals_t::time.

Referenced by G_Damage().

00504 {
00505     int flag_pw;
00506 
00507     if (!targ->client || !attacker->client)
00508         return;
00509 
00510     if (targ->client->sess.sessionTeam == TEAM_RED)
00511         flag_pw = PW_BLUEFLAG;
00512     else
00513         flag_pw = PW_REDFLAG;
00514 
00515     // flags
00516     if (targ->client->ps.powerups[flag_pw] &&
00517         targ->client->sess.sessionTeam != attacker->client->sess.sessionTeam)
00518         attacker->client->pers.teamState.lasthurtcarrier = level.time;
00519 
00520     // skulls
00521     if (targ->client->ps.generic1 &&
00522         targ->client->sess.sessionTeam != attacker->client->sess.sessionTeam)
00523         attacker->client->pers.teamState.lasthurtcarrier = level.time;
00524 }

void Team_DroppedFlagThink gentity_t ent  ) 
 

Definition at line 677 of file g_team.c.

References gentity_t, gitem_s::giTag, gentity_s::item, Team_ResetFlag(), and Team_ReturnFlagSound().

Referenced by Blocked_Door().

00677                                            {
00678     int     team = TEAM_FREE;
00679 
00680     if( ent->item->giTag == PW_REDFLAG ) {
00681         team = TEAM_RED;
00682     }
00683     else if( ent->item->giTag == PW_BLUEFLAG ) {
00684         team = TEAM_BLUE;
00685     }
00686     else if( ent->item->giTag == PW_NEUTRALFLAG ) {
00687         team = TEAM_FREE;
00688     }
00689 
00690     Team_ReturnFlagSound( Team_ResetFlag( team ), team );
00691     // Reset Flag will delete this entity
00692 }

Here is the call graph for this function:

void Team_FragBonuses gentity_t targ,
gentity_t inflictor,
gentity_t attacker
 

Definition at line 280 of file g_team.c.

References AddScore(), playerTeamState_t::basedefense, c, playerTeamState_t::carrierdefense, gentity_s::client, CTF_ATTACKER_PROTECT_RADIUS, CTF_CARRIER_DANGER_PROTECT_BONUS, CTF_CARRIER_DANGER_PROTECT_TIMEOUT, CTF_CARRIER_PROTECT_BONUS, CTF_FLAG_DEFENSE_BONUS, CTF_FRAG_CARRIER_BONUS, CTF_TARGET_PROTECT_RADIUS, entityShared_t::currentOrigin, EF_AWARD_ASSIST, EF_AWARD_DEFEND, EF_AWARD_EXCELLENT, EF_AWARD_GAUNTLET, EF_AWARD_IMPRESSIVE, playerState_s::eFlags, gentity_s::flags, FOFS, playerTeamState_t::fragcarrier, g_entities, G_Find(), g_gametype, g_maxclients, playerState_s::generic1, gentity_t, i, vmCvar_t::integer, gentity_s::inuse, playerTeamState_t::lastfraggedcarrier, playerTeamState_t::lasthurtcarrier, level, clientPersistant_t::netname, NULL, OnSameTeam(), OtherTeam(), gclient_s::pers, playerState_s::persistant, playerState_s::powerups, PrintMsg(), gclient_s::ps, gentity_s::r, gclient_s::rewardTime, S_COLOR_WHITE, gclient_s::sess, clientSession_t::sessionTeam, TEAM_BLUE, TEAM_RED, TeamName(), clientPersistant_t::teamState, level_locals_t::time, trap_InPVS(), v1, v2, vec3_t, VectorLength(), and VectorSubtract.

Referenced by player_die().

00281 {
00282     int i;
00283     gentity_t *ent;
00284     int flag_pw, enemy_flag_pw;
00285     int otherteam;
00286     int tokens;
00287     gentity_t *flag, *carrier = NULL;
00288     char *c;
00289     vec3_t v1, v2;
00290     int team;
00291 
00292     // no bonus for fragging yourself or team mates
00293     if (!targ->client || !attacker->client || targ == attacker || OnSameTeam(targ, attacker))
00294         return;
00295 
00296     team = targ->client->sess.sessionTeam;
00297     otherteam = OtherTeam(targ->client->sess.sessionTeam);
00298     if (otherteam < 0)
00299         return; // whoever died isn't on a team
00300 
00301     // same team, if the flag at base, check to he has the enemy flag
00302     if (team == TEAM_RED) {
00303         flag_pw = PW_REDFLAG;
00304         enemy_flag_pw = PW_BLUEFLAG;
00305     } else {
00306         flag_pw = PW_BLUEFLAG;
00307         enemy_flag_pw = PW_REDFLAG;
00308     }
00309 
00310     if (g_gametype.integer == GT_1FCTF) {
00311         enemy_flag_pw = PW_NEUTRALFLAG;
00312     } 
00313 
00314     // did the attacker frag the flag carrier?
00315     tokens = 0;
00316 #ifdef MISSIONPACK
00317     if( g_gametype.integer == GT_HARVESTER ) {
00318         tokens = targ->client->ps.generic1;
00319     }
00320 #endif
00321     if (targ->client->ps.powerups[enemy_flag_pw]) {
00322         attacker->client->pers.teamState.lastfraggedcarrier = level.time;
00323         AddScore(attacker, targ->r.currentOrigin, CTF_FRAG_CARRIER_BONUS);
00324         attacker->client->pers.teamState.fragcarrier++;
00325         PrintMsg(NULL, "%s" S_COLOR_WHITE " fragged %s's flag carrier!\n",
00326             attacker->client->pers.netname, TeamName(team));
00327 
00328         // the target had the flag, clear the hurt carrier
00329         // field on the other team
00330         for (i = 0; i < g_maxclients.integer; i++) {
00331             ent = g_entities + i;
00332             if (ent->inuse && ent->client->sess.sessionTeam == otherteam)
00333                 ent->client->pers.teamState.lasthurtcarrier = 0;
00334         }
00335         return;
00336     }
00337 
00338     // did the attacker frag a head carrier? other->client->ps.generic1
00339     if (tokens) {
00340         attacker->client->pers.teamState.lastfraggedcarrier = level.time;
00341         AddScore(attacker, targ->r.currentOrigin, CTF_FRAG_CARRIER_BONUS * tokens * tokens);
00342         attacker->client->pers.teamState.fragcarrier++;
00343         PrintMsg(NULL, "%s" S_COLOR_WHITE " fragged %s's skull carrier!\n",
00344             attacker->client->pers.netname, TeamName(team));
00345 
00346         // the target had the flag, clear the hurt carrier
00347         // field on the other team
00348         for (i = 0; i < g_maxclients.integer; i++) {
00349             ent = g_entities + i;
00350             if (ent->inuse && ent->client->sess.sessionTeam == otherteam)
00351                 ent->client->pers.teamState.lasthurtcarrier = 0;
00352         }
00353         return;
00354     }
00355 
00356     if (targ->client->pers.teamState.lasthurtcarrier &&
00357         level.time - targ->client->pers.teamState.lasthurtcarrier < CTF_CARRIER_DANGER_PROTECT_TIMEOUT &&
00358         !attacker->client->ps.powerups[flag_pw]) {
00359         // attacker is on the same team as the flag carrier and
00360         // fragged a guy who hurt our flag carrier
00361         AddScore(attacker, targ->r.currentOrigin, CTF_CARRIER_DANGER_PROTECT_BONUS);
00362 
00363         attacker->client->pers.teamState.carrierdefense++;
00364         targ->client->pers.teamState.lasthurtcarrier = 0;
00365 
00366         attacker->client->ps.persistant[PERS_DEFEND_COUNT]++;
00367         team = attacker->client->sess.sessionTeam;
00368         // add the sprite over the player's head
00369         attacker->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );
00370         attacker->client->ps.eFlags |= EF_AWARD_DEFEND;
00371         attacker->client->rewardTime = level.time + REWARD_SPRITE_TIME;
00372 
00373         return;
00374     }
00375 
00376     if (targ->client->pers.teamState.lasthurtcarrier &&
00377         level.time - targ->client->pers.teamState.lasthurtcarrier < CTF_CARRIER_DANGER_PROTECT_TIMEOUT) {
00378         // attacker is on the same team as the skull carrier and
00379         AddScore(attacker, targ->r.currentOrigin, CTF_CARRIER_DANGER_PROTECT_BONUS);
00380 
00381         attacker->client->pers.teamState.carrierdefense++;
00382         targ->client->pers.teamState.lasthurtcarrier = 0;
00383 
00384         attacker->client->ps.persistant[PERS_DEFEND_COUNT]++;
00385         team = attacker->client->sess.sessionTeam;
00386         // add the sprite over the player's head
00387         attacker->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );
00388         attacker->client->ps.eFlags |= EF_AWARD_DEFEND;
00389         attacker->client->rewardTime = level.time + REWARD_SPRITE_TIME;
00390 
00391         return;
00392     }
00393 
00394     // flag and flag carrier area defense bonuses
00395 
00396     // we have to find the flag and carrier entities
00397 
00398 #ifdef MISSIONPACK  
00399     if( g_gametype.integer == GT_OBELISK ) {
00400         // find the team obelisk
00401         switch (attacker->client->sess.sessionTeam) {
00402         case TEAM_RED:
00403             c = "team_redobelisk";
00404             break;
00405         case TEAM_BLUE:
00406             c = "team_blueobelisk";
00407             break;      
00408         default:
00409             return;
00410         }
00411         
00412     } else if (g_gametype.integer == GT_HARVESTER ) {
00413         // find the center obelisk
00414         c = "team_neutralobelisk";
00415     } else {
00416 #endif
00417     // find the flag
00418     switch (attacker->client->sess.sessionTeam) {
00419     case TEAM_RED:
00420         c = "team_CTF_redflag";
00421         break;
00422     case TEAM_BLUE:
00423         c = "team_CTF_blueflag";
00424         break;      
00425     default:
00426         return;
00427     }
00428     // find attacker's team's flag carrier
00429     for (i = 0; i < g_maxclients.integer; i++) {
00430         carrier = g_entities + i;
00431         if (carrier->inuse && carrier->client->ps.powerups[flag_pw])
00432             break;
00433         carrier = NULL;
00434     }
00435 #ifdef MISSIONPACK
00436     }
00437 #endif
00438     flag = NULL;
00439     while ((flag = G_Find (flag, FOFS(classname), c)) != NULL) {
00440         if (!(flag->flags & FL_DROPPED_ITEM))
00441             break;
00442     }
00443 
00444     if (!flag)
00445         return; // can't find attacker's flag
00446 
00447     // ok we have the attackers flag and a pointer to the carrier
00448 
00449     // check to see if we are defending the base's flag
00450     VectorSubtract(targ->r.currentOrigin, flag->r.currentOrigin, v1);
00451     VectorSubtract(attacker->r.currentOrigin, flag->r.currentOrigin, v2);
00452 
00453     if ( ( ( VectorLength(v1) < CTF_TARGET_PROTECT_RADIUS &&
00454         trap_InPVS(flag->r.currentOrigin, targ->r.currentOrigin ) ) ||
00455         ( VectorLength(v2) < CTF_TARGET_PROTECT_RADIUS &&
00456         trap_InPVS(flag->r.currentOrigin, attacker->r.currentOrigin ) ) ) &&
00457         attacker->client->sess.sessionTeam != targ->client->sess.sessionTeam) {
00458 
00459         // we defended the base flag
00460         AddScore(attacker, targ->r.currentOrigin, CTF_FLAG_DEFENSE_BONUS);
00461         attacker->client->pers.teamState.basedefense++;
00462 
00463         attacker->client->ps.persistant[PERS_DEFEND_COUNT]++;
00464         // add the sprite over the player's head
00465         attacker->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );
00466         attacker->client->ps.eFlags |= EF_AWARD_DEFEND;
00467         attacker->client->rewardTime = level.time + REWARD_SPRITE_TIME;
00468 
00469         return;
00470     }
00471 
00472     if (carrier && carrier != attacker) {
00473         VectorSubtract(targ->r.currentOrigin, carrier->r.currentOrigin, v1);
00474         VectorSubtract(attacker->r.currentOrigin, carrier->r.currentOrigin, v1);
00475 
00476         if ( ( ( VectorLength(v1) < CTF_ATTACKER_PROTECT_RADIUS &&
00477             trap_InPVS(carrier->r.currentOrigin, targ->r.currentOrigin ) ) ||
00478             ( VectorLength(v2) < CTF_ATTACKER_PROTECT_RADIUS &&
00479                 trap_InPVS(carrier->r.currentOrigin, attacker->r.currentOrigin ) ) ) &&
00480             attacker->client->sess.sessionTeam != targ->client->sess.sessionTeam) {
00481             AddScore(attacker, targ->r.currentOrigin, CTF_CARRIER_PROTECT_BONUS);
00482             attacker->client->pers.teamState.carrierdefense++;
00483 
00484             attacker->client->ps.persistant[PERS_DEFEND_COUNT]++;
00485             // add the sprite over the player's head
00486             attacker->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );
00487             attacker->client->ps.eFlags |= EF_AWARD_DEFEND;
00488             attacker->client->rewardTime = level.time + REWARD_SPRITE_TIME;
00489 
00490             return;
00491         }
00492     }
00493 }

Here is the call graph for this function:

void Team_FreeEntity gentity_t ent  ) 
 

Definition at line 656 of file g_team.c.

References gentity_t, gitem_s::giTag, gentity_s::item, TEAM_BLUE, TEAM_FREE, TEAM_RED, and Team_ReturnFlag().

Referenced by G_RunItem().

00656                                        {
00657     if( ent->item->giTag == PW_REDFLAG ) {
00658         Team_ReturnFlag( TEAM_RED );
00659     }
00660     else if( ent->item->giTag == PW_BLUEFLAG ) {
00661         Team_ReturnFlag( TEAM_BLUE );
00662     }
00663     else if( ent->item->giTag == PW_NEUTRALFLAG ) {
00664         Team_ReturnFlag( TEAM_FREE );
00665     }
00666 }

Here is the call graph for this function:

gentity_t* Team_GetLocation gentity_t ent  ) 
 

Definition at line 912 of file g_team.c.

References entityShared_t::currentOrigin, gentity_t, level, level_locals_t::locationHead, gentity_s::nextTrain, gentity_s::r, trap_InPVS(), vec3_t, and VectorCopy.

Referenced by CheckTeamStatus(), and Team_GetLocationMsg().

00913 {
00914     gentity_t       *eloc, *best;
00915     float           bestlen, len;
00916     vec3_t          origin;
00917 
00918     best = NULL;
00919     bestlen = 3*8192.0*8192.0;
00920 
00921     VectorCopy( ent->r.currentOrigin, origin );
00922 
00923     for (eloc = level.locationHead; eloc; eloc = eloc->nextTrain) {
00924         len = ( origin[0] - eloc->r.currentOrigin[0] ) * ( origin[0] - eloc->r.currentOrigin[0] )
00925             + ( origin[1] - eloc->r.currentOrigin[1] ) * ( origin[1] - eloc->r.currentOrigin[1] )
00926             + ( origin[2] - eloc->r.currentOrigin[2] ) * ( origin[2] - eloc->r.currentOrigin[2] );
00927 
00928         if ( len > bestlen ) {
00929             continue;
00930         }
00931 
00932         if ( !trap_InPVS( origin, eloc->r.currentOrigin ) ) {
00933             continue;
00934         }
00935 
00936         bestlen = len;
00937         best = eloc;
00938     }
00939 
00940     return best;
00941 }

Here is the call graph for this function:

qboolean Team_GetLocationMsg gentity_t ent,
char *  loc,
int  loclen
 

Definition at line 951 of file g_team.c.

References Com_sprintf(), gentity_s::count, gentity_t, gentity_s::message, Q_COLOR_ESCAPE, qboolean, S_COLOR_WHITE, and Team_GetLocation().

Referenced by G_Say().

00952 {
00953     gentity_t *best;
00954 
00955     best = Team_GetLocation( ent );
00956     
00957     if (!best)
00958         return qfalse;
00959 
00960     if (best->count) {
00961         if (best->count < 0)
00962             best->count = 0;
00963         if (best->count > 7)
00964             best->count = 7;
00965         Com_sprintf(loc, loclen, "%c%c%s" S_COLOR_WHITE, Q_COLOR_ESCAPE, best->count + '0', best->message );
00966     } else
00967         Com_sprintf(loc, loclen, "%s", best->message);
00968 
00969     return qtrue;
00970 }

Here is the call graph for this function:

void Team_InitGame void   ) 
 

Definition at line 45 of file g_team.c.

References teamgame_s::blueStatus, FLAG_ATBASE, teamgame_s::flagStatus, g_gametype, GT_1FCTF, GT_CTF, memset(), teamgame_s::redStatus, TEAM_BLUE, TEAM_FREE, TEAM_RED, Team_SetFlagStatus(), and teamgame.

Referenced by G_CheckTeamItems().

00045                            {
00046     memset(&teamgame, 0, sizeof teamgame);
00047 
00048     switch( g_gametype.integer ) {
00049     case GT_CTF:
00050         teamgame.redStatus = teamgame.blueStatus = -1; // Invalid to force update
00051         Team_SetFlagStatus( TEAM_RED, FLAG_ATBASE );
00052         Team_SetFlagStatus( TEAM_BLUE, FLAG_ATBASE );
00053         break;
00054 #ifdef MISSIONPACK
00055     case GT_1FCTF:
00056         teamgame.flagStatus = -1; // Invalid to force update
00057         Team_SetFlagStatus( TEAM_FREE, FLAG_ATBASE );
00058         break;
00059 #endif
00060     default:
00061         break;
00062     }
00063 }

Here is the call graph for this function:

void Team_ReturnFlag int  team  ) 
 

Definition at line 646 of file g_team.c.

References NULL, PrintMsg(), Team_ResetFlag(), Team_ReturnFlagSound(), and TeamName().

Referenced by player_die(), Team_FreeEntity(), and Use_target_remove_powerups().

00646                                  {
00647     Team_ReturnFlagSound(Team_ResetFlag(team), team);
00648     if( team == TEAM_FREE ) {
00649         PrintMsg(NULL, "The flag has returned!\n" );
00650     }
00651