Removed lots of things

Removed all unused things from g_team.c and related things
This commit is contained in:
Walter Julius Hennecke 2012-11-15 23:43:56 +01:00
parent 973b0e2211
commit db0df99793
11 changed files with 39 additions and 752 deletions

View file

@ -67,6 +67,10 @@ potential spawning position for deathmatch games.
void SP_info_player_deathmatch( gentity_t *ent ) {
int i;
if(strcmp(ent->classname, "info_player_deathmatch")) {
ent->classname = G_NewString("info_player_deathmatch");
}
G_SpawnInt( "nobots", "0", &i);
if ( i ) {
ent->flags |= FL_NO_BOTS;
@ -96,7 +100,7 @@ On spawn will reset classname sppropriately and respawn itself.
* Spawn function for player start spawnpoint which actually the same as deatchmatch spawnpoint
*/
void SP_info_player_start(gentity_t *ent) {
ent->classname = "info_player_deathmatch";
ent->classname = G_NewString("info_player_deathmatch");
SP_info_player_deathmatch( ent );
}
@ -1948,12 +1952,6 @@ void ClientSpawn(gentity_t *ent, int rpgx_spawn, qboolean fromDeath ) {
if ( client->sess.sessionTeam == TEAM_SPECTATOR ) {
spawnPoint = SelectSpectatorSpawnPoint (
spawn_origin, spawn_angles);
} else if (g_gametype.integer >= GT_TEAM) {
spawnPoint = SelectCTFSpawnPoint (
ent,
client->sess.sessionTeam,
client->pers.teamState.state,
spawn_origin, spawn_angles);
} else {
do {
// the first spawn should be at a good looking spot

View file

@ -1471,12 +1471,10 @@ static void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chat
clientPersistant_t *entPers = &entClient->pers;
clientPersistant_t *tarPers = NULL;
clientSession_t *entSess = &entClient->sess;
clientSession_t *tarSess =NULL;
if(target && target->client) {
tarClient = target->client;
tarPers = &tarClient->pers;
tarSess =&tarClient->sess;
}
if ( g_gametype.integer < GT_TEAM && mode == SAY_TEAM ) {
@ -1530,21 +1528,13 @@ static void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chat
color = COLOR_WHITE;
break;
case SAY_TELL:
if (target && g_gametype.integer >= GT_TEAM && tarSess &&
tarSess->sessionTeam == entSess->sessionTeam && tarPers &&
Team_GetLocationMsg(ent, location, sizeof(location)))
Com_sprintf (name, sizeof(name), "^7%s ^7from %s%c%c (%s): ", tarPers->netname, entPers->netname, Q_COLOR_ESCAPE, COLOR_WHITE, location );
else if(tarPers)
if(tarPers)
Com_sprintf (name, sizeof(name), "^7%s ^7from %s%c%c: ", tarPers->netname, entPers->netname, Q_COLOR_ESCAPE, COLOR_WHITE );
else return;
color = COLOR_MAGENTA;
break;
case SAY_TELL2:
if (target && g_gametype.integer >= GT_TEAM && tarSess &&
tarSess->sessionTeam == entSess->sessionTeam && tarPers &&
Team_GetLocationMsg(ent, location, sizeof(location)))
Com_sprintf (name, sizeof(name), "^7%s ^7from %s%c%c (%s): ", tarPers->netname, entPers->netname, Q_COLOR_ESCAPE, COLOR_WHITE, location );
else if(tarPers)
if(tarPers)
Com_sprintf (name, sizeof(name), "^7%s ^7from %s%c%c: ", tarPers->netname, entPers->netname, Q_COLOR_ESCAPE, COLOR_WHITE );
else return;
color = COLOR_MAGENTA;

View file

@ -601,7 +601,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
////////////////////////////////////////////////////////////////////////
if (attacker && attacker->client)
{
if ( attacker == self || OnSameTeam (self, attacker ) )
if ( attacker == self )
{
if ( meansOfDeath != MOD_RESPAWN )
{//just changing class
@ -1079,7 +1079,7 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
gclient_t *client;
int take=0;
int knockback;
qboolean bFriend = (targ && attacker) ? OnSameTeam( targ, attacker ) : qfalse;
qboolean bFriend = qfalse;
if(!targ) return;
@ -1176,7 +1176,7 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
if ( knockback && targ->client )
{
//if it's non-radius damage knockback from a teammate, don't do it if the damage won't be taken
if ( (dflags&DAMAGE_ALL_TEAMS) || (dflags&DAMAGE_RADIUS) || g_friendlyFire.integer || !attacker->client || !OnSameTeam (targ, attacker) )
if ( (dflags&DAMAGE_ALL_TEAMS) || (dflags&DAMAGE_RADIUS) || g_friendlyFire.integer || !attacker->client )
{
vec3_t kvel;
float mass;
@ -1215,7 +1215,7 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
// if the attacker was on the same team
// check for completely getting out of the damage
if ( !(dflags & DAMAGE_NO_PROTECTION) ) {
if ( !(dflags&DAMAGE_ALL_TEAMS) && mod != MOD_TELEFRAG && mod != MOD_DETPACK && targ != attacker && OnSameTeam (targ, attacker) )
if ( !(dflags&DAMAGE_ALL_TEAMS) && mod != MOD_TELEFRAG && mod != MOD_DETPACK && targ != attacker )
{
if ( attacker->client && targ->client )
{//this only matters between clients
@ -1294,9 +1294,6 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
}
}
// See if it's the player hurting the emeny flag carrier
Team_CheckHurtCarrier(targ, attacker);
if (targ->client) {
// set the last client who damaged the target
targ->client->lasthurt_client = attacker->s.number;

View file

@ -567,7 +567,7 @@ void Touch_Item (gentity_t *ent, gentity_t *other, trace_t *trace) {
respawn = Pickup_Powerup(ent, other);
break;
case IT_TEAM:
respawn = Pickup_Team(ent, other);
respawn = 0; // TODO remove?
break;
case IT_HOLDABLE:
respawn = Pickup_Holdable(ent, other);
@ -710,24 +710,8 @@ gentity_t *LaunchItem( gitem_t *item, gentity_t *who, vec3_t origin, vec3_t velo
Padd_Add(dropped, who, txt);
}
if (item->giType == IT_TEAM) { // Special case for CTF flags
gentity_t *te;
VectorSet (dropped->r.mins, -23, -23, -15);
VectorSet (dropped->r.maxs, 23, 23, 31);
dropped->think = Team_DroppedFlagThink;
dropped->nextthink = level.time + 30000;
Team_CheckDroppedItem( dropped );
// make the sound call for a dropped flag
te = G_TempEntity( dropped->s.pos.trBase, EV_TEAM_SOUND );
te->s.eventParm = DROPPED_FLAG_SOUND;
te->r.svFlags |= SVF_BROADCAST;
} else { // auto-remove after 30 seconds
dropped->think = G_FreeEntity;
dropped->nextthink = level.time + 6000000; //30000; // RPG-X: Marcin: increased - 03/12/2008
}
dropped->think = G_FreeEntity;
dropped->nextthink = level.time + 6000000; //30000; // RPG-X: Marcin: increased - 03/12/2008
dropped->flags = flags; // FL_DROPPED_ITEM; // RPG-X: Marcin: for ThrowWeapon - 03/12/2008
@ -991,31 +975,6 @@ qboolean FinishSpawningDecoy( gentity_t *ent, int itemIndex )
qboolean itemRegistered[MAX_ITEMS];
/*
==================
G_CheckTeamItems
==================
*/
void G_CheckTeamItems( void ) {
// Set up team stuff
Team_InitGame();
if ( g_gametype.integer == GT_CTF ) {
gitem_t *item;
// make sure we actually have two flags...
item = BG_FindItem( "team_CTF_redflag" );
if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
G_Printf( "^1WARNING: No team_CTF_redflag in map" );
}
item = BG_FindItem( "team_CTF_blueflag" );
if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
G_Printf( "^1WARNING: No team_CTF_blueflag in map" );
}
}
}
/*
==============
ClearRegisteredItems
@ -1248,11 +1207,7 @@ void G_RunItem( gentity_t *ent ) {
// if it is in a nodrop volume, remove it
contents = trap_PointContents( ent->r.currentOrigin, -1 );
if ( contents & CONTENTS_NODROP ) {
if (ent->item && ent->item->giType == IT_TEAM) {
Team_FreeEntity(ent);
} else {
G_FreeEntity( ent );
}
G_FreeEntity( ent );
return;
}

View file

@ -762,8 +762,6 @@ void Padd_Add( gentity_t *key, gentity_t *who, char *txt);
char *Padd_Get( gentity_t *key, gentity_t *who );
void Padd_Remove( gentity_t *key );
void G_CheckTeamItems( void );
void G_RunItem( gentity_t *ent );
void RespawnItem( gentity_t *ent );
@ -1191,13 +1189,6 @@ void Cmd_Ready_f (gentity_t *ent);
void ThrowWeapon( gentity_t *ent, char *txt );
gentity_t *DropWeapon( gentity_t *ent, gitem_t *item, float angle, int flags, char *txt );
//
// g_team.c
//
qboolean OnSameTeam( gentity_t *ent1, gentity_t *ent2 );
void Team_CheckDroppedItem( gentity_t *dropped );
//
// g_mem.c
//

View file

@ -1855,9 +1855,6 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) {
// general initialization
G_FindTeams();
// make sure we have flags for CTF, etc
G_CheckTeamItems();
SaveRegisteredItems();
G_Printf ("-----------------------------------\n");

View file

@ -1171,11 +1171,6 @@ Blocked_Door
void Blocked_Door( gentity_t *ent, gentity_t *other ) {
// remove anything other than a client
if ( !other->client ) {
// except CTF flags!!!!
if( other->s.eType == ET_ITEM && other->item->giType == IT_TEAM ) {
Team_DroppedFlagThink( other );
return;
}
G_TempEntity( other->s.origin, EV_ITEM_POP );
G_FreeEntity( other );
return;

View file

@ -204,12 +204,6 @@ void SP_shooter_plasma( gentity_t *ent );
void SP_shooter_grenade( gentity_t *ent );
void SP_shooter_torpedo( gentity_t *ent );
void SP_team_CTF_redplayer( gentity_t *ent );
void SP_team_CTF_blueplayer( gentity_t *ent );
void SP_team_CTF_redspawn( gentity_t *ent );
void SP_team_CTF_bluespawn( gentity_t *ent );
// extra Trek stuff
void SP_fx_spark ( gentity_t *ent );
void SP_fx_steam ( gentity_t *ent );
@ -394,11 +388,11 @@ spawn_t spawns[] = {
{"shooter_plasma", SP_shooter_plasma},
{"shooter_torpedo", SP_shooter_torpedo},
{"team_CTF_redplayer", SP_team_CTF_redplayer},
{"team_CTF_blueplayer", SP_team_CTF_blueplayer},
{"team_CTF_redplayer", SP_info_player_deathmatch},
{"team_CTF_blueplayer", SP_info_player_deathmatch},
{"team_CTF_redspawn", SP_team_CTF_redspawn},
{"team_CTF_bluespawn", SP_team_CTF_bluespawn},
{"team_CTF_redspawn", SP_info_player_deathmatch},
{"team_CTF_bluespawn", SP_info_player_deathmatch},
// extra Trek stuff
{"fx_spark", SP_fx_spark},

View file

@ -22,431 +22,24 @@ typedef struct teamgame_s
teamgame_t teamgame;
void Team_SetFlagStatus( int team, flagStatus_t status );
void Team_InitGame(void)
{
memset(&teamgame, 0, sizeof teamgame);
teamgame.redStatus = teamgame.blueStatus = -1; // Invalid to force update
Team_SetFlagStatus( TEAM_RED, FLAG_ATBASE );
Team_SetFlagStatus( TEAM_BLUE, FLAG_ATBASE );
// set config strings for what the two teams are for use in the cgame that renders the CTF flags
trap_SetConfigstring( CS_RED_GROUP, g_team_group_red.string);
trap_SetConfigstring( CS_BLUE_GROUP, g_team_group_blue.string);
}
int OtherTeam(int team) {
if (team==TEAM_RED)
return TEAM_BLUE;
else if (team==TEAM_BLUE)
return TEAM_RED;
return team;
}
const char *TeamName(int team) {
if (team==TEAM_RED)
return "RED";
else if (team==TEAM_BLUE)
return "BLUE";
else if (team==TEAM_SPECTATOR)
if (team==TEAM_SPECTATOR)
return "SPECTATOR";
return "FREE";
}
const char *OtherTeamName(int team) {
if (team==TEAM_RED)
return "BLUE";
else if (team==TEAM_BLUE)
return "RED";
else if (team==TEAM_SPECTATOR)
if (team==TEAM_SPECTATOR)
return "SPECTATOR";
return "FREE";
}
const char *TeamColorString(int team) {
if (team==TEAM_RED)
return S_COLOR_RED;
else if (team==TEAM_BLUE)
return S_COLOR_BLUE;
else if (team==TEAM_SPECTATOR)
if (team==TEAM_SPECTATOR)
return S_COLOR_YELLOW;
return S_COLOR_WHITE;
}
// NULL for everyone
void QDECL PrintMsg( gentity_t *ent, const char *fmt, ... ) __attribute__ ((format (printf, 2, 3)));
void QDECL PrintMsg( gentity_t *ent, const char *fmt, ... ) {
char msg[1024];
va_list argptr;
char *p;
va_start (argptr,fmt);
if (vsprintf (msg, fmt, argptr) > sizeof(msg)) {
G_Error ( "%s", "PrintMsg overrun" );
}
va_end (argptr);
// double quotes are bad
while ((p = strchr(msg, '"')) != NULL)
*p = '\'';
trap_SendServerCommand ( ( (ent == NULL) ? -1 : ent-g_entities ), va("print \"%s\"", msg ));
}
/*
==============
OnSameTeam
==============
*/
qboolean OnSameTeam( gentity_t *ent1, gentity_t *ent2 ) {
if (( g_gametype.integer == GT_FFA ) || (g_gametype.integer == GT_TOURNAMENT) || (g_gametype.integer == GT_SINGLE_PLAYER))
{
return qfalse;
}
if ( !ent1->client || !ent2->client ) {
if ( !ent1->client && !ent2->client )
{
if ( ent1->team && ent2->team && atoi( ent1->team ) == atoi( ent2->team ) )
{
return qtrue;
}
}
else if ( !ent1->client )
{
if ( ent1->team && atoi( ent1->team ) == ent2->client->sess.sessionTeam )
{
return qtrue;
}
}
else// if ( !ent2->client )
{
if ( ent2->team && ent1->client->sess.sessionTeam == atoi( ent2->team ) )
{
return qtrue;
}
}
return qfalse;
}
if ( ent1->client->sess.sessionTeam == ent2->client->sess.sessionTeam ) {
return qtrue;
}
return qfalse;
}
void Team_SetFlagStatus( int team, flagStatus_t status )
{
qboolean modified = qfalse;
switch (team) {
case TEAM_RED :
if ( teamgame.redStatus != status ) {
teamgame.redStatus = status;
modified = qtrue;
}
break;
case TEAM_BLUE :
if ( teamgame.blueStatus != status ) {
teamgame.blueStatus = status;
modified = qtrue;
}
break;
}
if (modified) {
char st[4];
st[0] = '0' + (int)teamgame.redStatus;
st[1] = '0' + (int)teamgame.blueStatus;
st[2] = 0;
trap_SetConfigstring( CS_FLAGSTATUS, st );
}
}
void Team_CheckDroppedItem( gentity_t *dropped )
{
/*if (dropped->item->giTag == PW_REDFLAG)
Team_SetFlagStatus( TEAM_RED, FLAG_DROPPED );
else if (dropped->item->giTag == PW_BORG_ADAPT)
Team_SetFlagStatus( TEAM_BLUE, FLAG_DROPPED );*/
}
/*
================
Team_FragBonuses
Calculate the bonuses for flag defense, flag carrier defense, etc.
Note that bonuses are not cumlative. You get one, they are in importance
order.
================
*/
void Team_FragBonuses(gentity_t *targ, gentity_t *inflictor, gentity_t *attacker)
{
//int i;
//gentity_t *ent;
//int flag_pw, enemy_flag_pw;
int otherteam;
gentity_t *flag, *carrier = NULL;
char *c;
vec3_t v1, v2;
int team;
// no bonus for fragging yourself
if (!targ->client || attacker == NULL || !attacker->client || targ == attacker)
return;
team = targ->client->sess.sessionTeam;
otherteam = OtherTeam(targ->client->sess.sessionTeam);
if (otherteam < 0)
return; // whoever died isn't on a team
// same team, if the flag at base, check to he has the enemy flag
/*if (team == TEAM_RED) {
flag_pw = PW_REDFLAG;
enemy_flag_pw = PW_REDFLAG;
} else {
flag_pw = PW_REDFLAG;
enemy_flag_pw = PW_REDFLAG;
}*/
// did the attacker frag the flag carrier?
/*if (targ->client->ps.powerups[enemy_flag_pw]) {
attacker->client->pers.teamState.lastfraggedcarrier = level.time;
AddScore(attacker, CTF_FRAG_CARRIER_BONUS);
attacker->client->pers.teamState.fragcarrier++;
PrintMsg(NULL, "%s" S_COLOR_WHITE " eliminated %s's flag carrier!\n",
attacker->client->pers.netname, TeamName(team));
// the target had the flag, clear the hurt carrier
// field on the other team
for (i = 0; i < g_maxclients.integer; i++) {
ent = g_entities + i;
if (ent->inuse && ent->client->sess.sessionTeam == otherteam)
ent->client->pers.teamState.lasthurtcarrier = 0;
}
return;
}*/
if (targ->client->pers.teamState.lasthurtcarrier &&
level.time - targ->client->pers.teamState.lasthurtcarrier < CTF_CARRIER_DANGER_PROTECT_TIMEOUT /*&&
!attacker->client->ps.powerups[flag_pw]*/) {
// attacker is on the same team as the flag carrier and
// fragged a guy who hurt our flag carrier
AddScore(attacker, CTF_CARRIER_DANGER_PROTECT_BONUS);
attacker->client->pers.teamState.carrierdefense++;
targ->client->pers.teamState.lasthurtcarrier = 0;
team = attacker->client->sess.sessionTeam;
PrintMsg(NULL, "%s" S_COLOR_WHITE " defends %s's flag carrier against an aggressive enemy\n",
attacker->client->pers.netname, TeamName(team));
return;
}
// flag and flag carrier area defense bonuses
// we have to find the flag and carrier entities
// find the flag
switch (attacker->client->sess.sessionTeam) {
case TEAM_RED:
c = "team_CTF_redflag";
break;
case TEAM_BLUE:
c = "team_CTF_blueflag";
break;
default:
return;
}
flag = NULL;
while ((flag = G_Find (flag, FOFS(classname), c)) != NULL) {
if (!(flag->flags & FL_DROPPED_ITEM))
break;
}
if (!flag)
return; // can't find attacker's flag
// find attacker's team's flag carrier
/*for (i = 0; i < g_maxclients.integer; i++) {
carrier = g_entities + i;
if (carrier->inuse && carrier->client->ps.powerups[flag_pw])
break;
carrier = NULL;
}*/
// ok we have the attackers flag and a pointer to the carrier
// check to see if we are defending the base's flag
VectorSubtract(targ->r.currentOrigin, flag->r.currentOrigin, v1);
VectorSubtract(attacker->r.currentOrigin, flag->r.currentOrigin, v2);
if ( ( ( VectorLength(v1) < CTF_TARGET_PROTECT_RADIUS &&
trap_InPVS(flag->r.currentOrigin, targ->r.currentOrigin ) ) ||
( VectorLength(v2) < CTF_TARGET_PROTECT_RADIUS &&
trap_InPVS(flag->r.currentOrigin, attacker->r.currentOrigin ) ) ) &&
attacker->client->sess.sessionTeam != targ->client->sess.sessionTeam) {
// we defended the base flag
AddScore(attacker, CTF_FLAG_DEFENSE_BONUS);
attacker->client->pers.teamState.basedefense++;
if (flag->r.svFlags & SVF_NOCLIENT) {
PrintMsg(NULL, "%s" S_COLOR_WHITE " defends the %s base.\n",
attacker->client->pers.netname,
TeamName(attacker->client->sess.sessionTeam));
} else {
PrintMsg(NULL, "%s" S_COLOR_WHITE " defends the %s flag.\n",
attacker->client->pers.netname,
TeamName(attacker->client->sess.sessionTeam));
}
return;
}
if (carrier && carrier != attacker) {
VectorSubtract(targ->r.currentOrigin, carrier->r.currentOrigin, v1);
VectorSubtract(attacker->r.currentOrigin, carrier->r.currentOrigin, v1);
if ( ( ( VectorLength(v1) < CTF_ATTACKER_PROTECT_RADIUS &&
trap_InPVS(carrier->r.currentOrigin, targ->r.currentOrigin ) ) ||
( VectorLength(v2) < CTF_ATTACKER_PROTECT_RADIUS &&
trap_InPVS(carrier->r.currentOrigin, attacker->r.currentOrigin ) ) ) &&
attacker->client->sess.sessionTeam != targ->client->sess.sessionTeam) {
AddScore(attacker, CTF_CARRIER_PROTECT_BONUS);
attacker->client->pers.teamState.carrierdefense++;
PrintMsg(NULL, "%s" S_COLOR_WHITE " defends the %s's flag carrier.\n",
attacker->client->pers.netname,
TeamName(attacker->client->sess.sessionTeam));
return;
}
}
}
/*
================
Team_CheckHurtCarrier
Check to see if attacker hurt the flag carrier. Needed when handing out bonuses for assistance to flag
carrier defense.
================
*/
void Team_CheckHurtCarrier(gentity_t *targ, gentity_t *attacker)
{
//int flag_pw;
if (!targ->client || !attacker->client)
return;
/*if (targ->client->sess.sessionTeam == TEAM_RED)
flag_pw = PW_REDFLAG;
else
flag_pw = PW_REDFLAG;*/
/*if (targ->client->ps.powerups[flag_pw] &&
targ->client->sess.sessionTeam != attacker->client->sess.sessionTeam)
attacker->client->pers.teamState.lasthurtcarrier = level.time;*/
}
gentity_t *Team_ResetFlag(int team)
{
char *c;
gentity_t *ent, *rent = NULL;
switch (team) {
case TEAM_RED:
c = "team_CTF_redflag";
break;
case TEAM_BLUE:
c = "team_CTF_blueflag";
break;
default:
return NULL;
}
ent = NULL;
while ((ent = G_Find (ent, FOFS(classname), c)) != NULL) {
if (ent->flags & FL_DROPPED_ITEM)
G_FreeEntity(ent);
else {
rent = ent;
RespawnItem(ent);
}
}
Team_SetFlagStatus( team, FLAG_ATBASE );
return rent;
}
void Team_ResetFlags(void)
{
Team_ResetFlag(TEAM_RED);
Team_ResetFlag(TEAM_BLUE);
}
void Team_ReturnFlagSound(gentity_t *ent, int team)
{
// play powerup spawn sound to all clients
gentity_t *te;
if (ent == NULL) {
G_Printf ("Warning: NULL passed to Team_ReturnFlagSound\n");
return;
}
te = G_TempEntity( ent->s.pos.trBase, EV_TEAM_SOUND );
te->s.eventParm = RETURN_FLAG_SOUND;
te->s.otherEntityNum = team;
te->r.svFlags |= SVF_BROADCAST;
}
void Team_ReturnFlag(int team)
{
Team_ReturnFlagSound(Team_ResetFlag(team), team);
PrintMsg(NULL, "The %s flag has returned!\n", TeamName(team));
}
void Team_FreeEntity(gentity_t *ent)
{
/*if (ent->item->giTag == PW_REDFLAG)
Team_ReturnFlag(TEAM_RED);
else if (ent->item->giTag == PW_BORG_ADAPT)
Team_ReturnFlag(TEAM_BLUE);*/
}
/*
==============
Team_DroppedFlagThink
Automatically set in Launch_Item if the item is one of the flags
Flags are unique in that if they are dropped, the base flag must be respawned when they time out
==============
*/
void Team_DroppedFlagThink(gentity_t *ent)
{
/*if (ent->item->giTag == PW_REDFLAG)
Team_ReturnFlagSound(Team_ResetFlag(TEAM_RED), TEAM_RED);
else if (ent->item->giTag == PW_BORG_ADAPT)
Team_ReturnFlagSound(Team_ResetFlag(TEAM_BLUE), TEAM_BLUE);*/
// Reset Flag will delete this entity
}
int Pickup_Team( gentity_t *ent, gentity_t *other ) {
return 0;
}
/*
===========
Team_GetLocation
@ -514,94 +107,7 @@ qboolean Team_GetLocationMsg(gentity_t *ent, char *loc, int loclen)
return qtrue;
}
/*---------------------------------------------------------------------------*/
/*
================
SelectRandomDeathmatchSpawnPoint
go to a random point that doesn't telefrag
================
*/
#define MAX_TEAM_SPAWN_POINTS 32
gentity_t *SelectRandomTeamSpawnPoint( gentity_t *ent, int teamstate, team_t team ) {
gentity_t *spot;
int count;
int selection;
gentity_t *spots[MAX_TEAM_SPAWN_POINTS];
char *classname;
if (teamstate == TEAM_BEGIN) {
if (team == TEAM_RED)
classname = "team_CTF_redplayer";
else if (team == TEAM_BLUE)
classname = "team_CTF_blueplayer";
else
return NULL;
} else {
if (team == TEAM_RED)
classname = "team_CTF_redspawn";
else if (team == TEAM_BLUE)
classname = "team_CTF_bluespawn";
else
return NULL;
}
count = 0;
spot = NULL;
while ((spot = G_Find (spot, FOFS(classname), classname)) != NULL) {
if ( teamstate != TEAM_BEGIN) {
if ( spot->spawnflags & 1 ) {
//not an active spawn point
continue;
}
}
if ( SpotWouldTelefrag( spot ) ) {
continue;
}
spots[ count ] = spot;
if (++count == MAX_TEAM_SPAWN_POINTS)
break;
}
if ( !count ) { // no spots that won't telefrag
return G_Find( NULL, FOFS(classname), classname);
}
selection = rand() % count;
return spots[ selection ];
}
/*
===========
SelectCTFSpawnPoint
============
*/
gentity_t *SelectCTFSpawnPoint ( gentity_t *ent, team_t team, int teamstate, vec3_t origin, vec3_t angles ) {
gentity_t *spot;
spot = SelectRandomTeamSpawnPoint ( ent, teamstate, team );
if (!spot) {
return SelectSpawnPoint( vec3_origin, origin, angles );
}
VectorCopy (spot->s.origin, origin);
origin[2] += 9;
VectorCopy (spot->s.angles, angles);
return spot;
}
/*---------------------------------------------------------------------------*/
/*static int QDECL SortClients( const void *a, const void *b ) {
return *(int *)a - *(int *)b;
}*/
/*
==================
CheckHealthInfoMessage
@ -719,12 +225,7 @@ void TeamplayInfoMessage( gentity_t *ent ) {
int i, j;
gentity_t *player;
int cnt;
//int h, a;
//TiM : Send data regardless
/*if ( ! ent->client->pers.teamInfo )
return;*/
//don't bother sending during intermission?
if ( level.intermissiontime )
return;
@ -739,10 +240,6 @@ void TeamplayInfoMessage( gentity_t *ent ) {
}
}
// We have the top eight players, sort them by clientNum
//TiM
//qsort( clients, cnt, sizeof( clients[0] ), SortClients );
// send the latest information on all clients
string[0] = 0;
stringlength = 0;
@ -750,21 +247,10 @@ void TeamplayInfoMessage( gentity_t *ent ) {
for (i = 0, cnt = 0; i < g_maxclients.integer && cnt < TEAM_MAXOVERLAY; i++) {
player = g_entities + i;
//RPG-X | Phenix | 05/03/2005
if (player->inuse /*&& player->client->sess.sessionTeam ==
ent->client->sess.sessionTeam*/ ) {
/*h = player->client->ps.stats[STAT_HEALTH];
a = player->client->ps.stats[STAT_ARMOR];
if (h < 0) h = 0;
if (a < 0) a = 0;*/
if (player->inuse) {
//to counter for the fact we could pwn the server doing this, remove all superfluous data
Com_sprintf (entry, sizeof(entry),
" %i %i ", //%i %i %i %i
// level.sortedClients[i], player->client->pers.teamState.location, h, a,
i, player->client->pers.teamState.location/*, h, a,
player->client->ps.weapon, player->s.powerups*/);
Com_sprintf (entry, sizeof(entry), " %i %i ", i, player->client->pers.teamState.location);
j = strlen(entry);
if (stringlength + j > sizeof(string))
break;
@ -789,9 +275,7 @@ void CheckTeamStatus(void)
for (i = 0; i < g_maxclients.integer; i++) {
ent = g_entities + i;
if (ent->inuse /*&&
(ent->client->sess.sessionTeam == TEAM_RED ||
ent->client->sess.sessionTeam == TEAM_BLUE)*/ ) {
if (ent->inuse) {
loc = Team_GetLocation( ent );
if (loc)
ent->client->pers.teamState.location = loc->health;
@ -802,9 +286,7 @@ void CheckTeamStatus(void)
for (i = 0; i < g_maxclients.integer; i++) {
ent = g_entities + i;
if (ent->inuse /*&&
(ent->client->sess.sessionTeam == TEAM_RED ||
ent->client->sess.sessionTeam == TEAM_BLUE)*/) {
if (ent->inuse) {
TeamplayInfoMessage( ent );
}
}
@ -813,88 +295,5 @@ void CheckTeamStatus(void)
}
}
/*-----------------------------------------------------------------*/
/*QUAKED team_CTF_redplayer (1 0 0) (-16 -16 -16) (16 16 32) BORGQUEEN
-----DESCRIPTION-----
Only in CTF games. Red players spawn here at game start.
This is not used in RPG-X.
-----SPAWNFLAGS-----
1: BORGQUEEN - The player that is the Borg Queen will spawn here
-----KEYS-----
none
*/
void SP_team_CTF_redplayer( gentity_t *ent ) {
if ( ent->spawnflags & 1 )
{
initialBorgTeam = TEAM_RED;
borgQueenStartPoint = ent->s.number;
}
}
/*QUAKED team_CTF_blueplayer (0 0 1) (-16 -16 -16) (16 16 32) BORGQUEEN
-----DESCRIPTION-----
Only in CTF games. Blue players spawn here at game start.
This is not used in RPG-X.
-----SPAWNFLAGS-----
1: BORGQUEEN - The player that is the Borg Queen will spawn here
-----KEYS-----
none
*/
void SP_team_CTF_blueplayer( gentity_t *ent ) {
if ( ent->spawnflags & 1 )
{
initialBorgTeam = TEAM_BLUE;
borgQueenStartPoint = ent->s.number;
}
}
void spawnpoint_toggle_active( gentity_t *ent, gentity_t *other, gentity_t *activator )
{
ent->spawnflags ^= 1;
}
/*QUAKED team_CTF_redspawn (1 0 0) (-16 -16 -24) (16 16 32) STARTOFF
-----DESCRIPTION-----
potential spawning position for red team in CTF games, AFTER game start
Targets will be fired when someone spawns in on them.
This is not used in RPG-X.
-----SPAWNFLAGS-----
STARTOFF - won't be considered as a spawn point until used
-----KEYS-----
targetname - when used, toggles between active and incative spawn point
*/
void SP_team_CTF_redspawn(gentity_t *ent) {
if ( ent->targetname )
{
ent->use = spawnpoint_toggle_active;
}
}
/*QUAKED team_CTF_bluespawn (0 0 1) (-16 -16 -24) (16 16 32) STARTOFF
-----DESCRIPTION-----
potential spawning position for blue team in CTF games, AFTER game start
Targets will be fired when someone spawns in on them.
-----SPAWNFLAGS-----
STARTOFF - won't be considered as a spawn point until used
-----KEYS-----
targetname - when used, toggles between active and incative spawn point
*/
void SP_team_CTF_bluespawn(gentity_t *ent) {
if ( ent->targetname )
{
ent->use = spawnpoint_toggle_active;
}
}

View file

@ -26,22 +26,10 @@
// Prototypes
int OtherTeam(int team);
const char *TeamName(int team);
const char *OtherTeamName(int team);
const char *TeamColorString(int team);
//void AddTeamScore(vec3_t origin, int team, int score);
void Team_DroppedFlagThink(gentity_t *ent);
void Team_FragBonuses(gentity_t *targ, gentity_t *inflictor, gentity_t *attacker);
void Team_CheckHurtCarrier(gentity_t *targ, gentity_t *attacker);
void Team_InitGame(void);
void Team_ReturnFlag(int team);
void Team_FreeEntity(gentity_t *ent);
gentity_t *SelectCTFSpawnPoint ( gentity_t *ent, team_t team, int teamstate, vec3_t origin, vec3_t angles );
gentity_t *Team_GetLocation(gentity_t *ent);
qboolean Team_GetLocationMsg(gentity_t *ent, char *loc, int loclen);
void TeamplayInfoMessage( gentity_t *ent );
void CheckTeamStatus(void);
int Pickup_Team( gentity_t *ent, gentity_t *other );
void TeamplayInfoMessage( gentity_t *ent ); // needed for locations ... TODO move from team to somewhere else
void CheckTeamStatus(void); // needed for locations ... TODO move from team to somewhere else

View file

@ -1110,7 +1110,7 @@ static qboolean SearchTarget(gentity_t *ent, vec3_t start, vec3_t end)
trap_Trace (&tr, start, NULL, NULL, end, ent->s.number, MASK_SHOT );
traceEnt = &g_entities[ tr.entityNum ];
if (traceEnt->takedamage && traceEnt->client && !OnSameTeam(traceEnt, &g_entities[ent->r.ownerNum]))
if (traceEnt->takedamage && traceEnt->client)
{
ent->target_ent = traceEnt;
VectorSubtract(ent->target_ent->r.currentOrigin, ent->r.currentOrigin, fwd);
@ -1339,10 +1339,6 @@ qboolean LogAccuracyHit( gentity_t *target, gentity_t *attacker ) {
return qfalse;
}
if ( OnSameTeam( target, attacker ) ) {
return qfalse;
}
return qtrue;
}
@ -1670,7 +1666,8 @@ static void WP_SprayVoyagerHypo( gentity_t *ent, qboolean alt_fire )
tr_ent = &g_entities[tr.entityNum];
/* RPG-X: RedTechie - Medics can revive dead people */
if( (tr_ent && tr_ent->client) && (tr_ent->health == 1) && (tr_ent->client->ps.pm_type == PM_DEAD)){ tr_entPs = &tr_ent->client->ps;
if( (tr_ent && tr_ent->client) && (tr_ent->health == 1) && (tr_ent->client->ps.pm_type == PM_DEAD)){
tr_entPs = &tr_ent->client->ps;
if(rpg_medicsrevive.integer == 1){
ClientSpawn(tr_ent, 1, qtrue);
@ -1691,30 +1688,16 @@ static void WP_SprayVoyagerHypo( gentity_t *ent, qboolean alt_fire )
/*tr_entPs->stats[STAT_HOLDABLE_ITEM] = HI_NONE;*/
}
/* RPG-X: RedTechie - Regular functions still work */
}else if ( tr_ent && tr_ent->client && tr_ent->health > 0 )
{
} else if ( tr_ent && tr_ent->client && tr_ent->health > 0 ) {
tr_entPs = &tr_ent->client->ps;
if ( rpg_rpg.integer > 0 && g_gametype.integer < GT_TEAM )
{
if(alt_fire && rpg_hypoMelee.integer) { /* alt fire and hypo melee enabled */
tr_ent->health = 0;
player_die( tr_ent, ent, ent, 100, MOD_KNOCKOUT );
G_LogWeaponFire( ent->s.number, WP_12 );
} else { /* else just heal */
if ( tr_ent->health < tr_entPs->stats[STAT_MAX_HEALTH] )
{
tr_ent->health = tr_entPs->stats[STAT_MAX_HEALTH]; /*+20*/
}
}
else
{
if ( !OnSameTeam(tr_ent, ent) || g_gametype.integer < GT_TEAM )
{
tr_ent->health = 0;
player_die( tr_ent, ent, ent, 100, MOD_KNOCKOUT );
G_LogWeaponFire( ent->s.number, WP_12 );
}
else if ( OnSameTeam(tr_ent, ent) )
{
if ( tr_ent->health < tr_entPs->stats[STAT_MAX_HEALTH] )
{
tr_ent->health = tr_ent->health + 20;
}
tr_ent->health = tr_entPs->stats[STAT_MAX_HEALTH];
}
}
}