summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/bg_public.h6
-rw-r--r--src/game/g_client.c90
-rw-r--r--src/game/g_cmds.c12
-rw-r--r--src/game/g_combat.c193
-rw-r--r--src/game/g_team.c13
5 files changed, 139 insertions, 175 deletions
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index 793ca64a..69843c79 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -266,12 +266,8 @@ typedef enum {
PERS_EXCELLENT_COUNT,
PERS_GAUNTLET_FRAG_COUNT,
PERS_ACCURACY_SHOTS,
- PERS_ACCURACY_HITS,
+ PERS_ACCURACY_HITS
//TA: FIXME: /\ get rid of award counts to make some room
-
- //TA: extra gubbins
- PERS_POINTS,
- PERS_TOTALPOINTS
} persEnum_t;
diff --git a/src/game/g_client.c b/src/game/g_client.c
index 5decc90b..ae435f88 100644
--- a/src/game/g_client.c
+++ b/src/game/g_client.c
@@ -568,18 +568,39 @@ BodySink
After sitting around for five seconds, fall into the ground and dissapear
=============
*/
-void BodySink( gentity_t *ent ) {
- if ( level.time - ent->timestamp > 6500 ) {
- // the body ques are never actually freed, they are just unlinked
- trap_UnlinkEntity( ent );
- ent->physicsObject = qfalse;
+void BodySink( gentity_t *ent )
+{
+ //arbituary number > 100 and < time since nextthink was set
+ if( level.time - ent->nextthink > 1000 )
+ ent->timestamp = level.time;
+
+ if( level.time - ent->timestamp > 6500 )
+ {
+ G_FreeEntity( ent );
return;
}
+
ent->nextthink = level.time + 100;
- ent->s.pos.trBase[2] -= 1;
+ ent->s.pos.trBase[ 2 ] -= 1;
}
+/*
+=============
+BodyFree
+
+After sitting around for a while the body becomes a freebie
+=============
+*/
+void BodyFree( gentity_t *ent )
+{
+ ent->killedBy = -1;
+
+ //if not claimed in the next minute destroy
+ ent->think = BodySink;
+ ent->nextthink = level.time + 60000;
+}
+
/*
================
@@ -595,7 +616,6 @@ void useBody( gentity_t *self, gentity_t *other, gentity_t *activator )
float numerator, denominator;
vec3_t up = { 0.0, 0.0, 1.0 };
-
if( activator->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS )
{
//can't pick teammates bodies to bits
@@ -617,48 +637,6 @@ void useBody( gentity_t *self, gentity_t *other, gentity_t *activator )
if( i < PCL_NUM_CLASSES )
G_AddPredictableEvent( activator, EV_MENU, MN_A_INFEST );
}
- else
- {
- clientNum = activator->client->ps.clientNum;
- numerator = self->credits[ clientNum ];
- class = self->s.clientNum;
-
- //can't pick teammates bodies to bits
- if( !Q_stricmp( self->classname, "humanCorpse" ) )
- return;
-
- //client has already raided this corpse
- if( self->creditsHash[ clientNum ] )
- return;
-
- //total up all the damage done by every client
- for( i = 0; i < MAX_CLIENTS; i++ )
- total += self->credits[ i ];
-
- denominator = total;
-
- //if no one did any damage client must have been killed by defense or suicide
- //body is a "free for all"
- if( !total ) numerator = denominator = 1.0f;
-
- //add credit
- activator->client->ps.stats[ STAT_CREDIT ] += (int)( (float)BG_FindValueOfClass( class ) *
- ( numerator / denominator ) );
-
- //prevent clients claiming credit twice
- self->creditsHash[ clientNum ] = qtrue;
-
- //if this corpse has been 100% claimed destroy it
- for( i = 0; i < MAX_CLIENTS; i++ )
- {
- if( ( self->credits[ clientNum ] == 0 || !self->creditsHash[ clientNum ] ) && total != 0 )
- continue;
-
- G_AddEvent( self, EV_GIB_ALIEN, DirToByte( up ) );
- self->freeAfterEvent = qtrue;
- break;
- }
- }
}
/*
@@ -679,7 +657,7 @@ void SpawnCorpse( gentity_t *ent )
VectorCopy( ent->r.currentOrigin, origin );
- /*trap_UnlinkEntity( ent );*/
+ trap_UnlinkEntity( ent );
// if client is in a nodrop area, don't leave the body
contents = trap_PointContents( origin, -1 );
@@ -706,11 +684,17 @@ void SpawnCorpse( gentity_t *ent )
body->killedBy = buildable->builtBy;
else // *shrugs* probably killed by some map entity - freebie
body->killedBy = -1;
+
+ //the body becomes free in a minute
+ body->think = BodyFree;
+ body->nextthink = level.time + 60000;
}
else
{
body->classname = "alienCorpse";
- for( i = 0; i < MAX_CLIENTS; body->credits[ i ] = ent->credits[ i++ ] );
+
+ body->think = BodySink;
+ body->nextthink = level.time + 60000;
}
body->s = ent->s;
@@ -720,8 +704,8 @@ void SpawnCorpse( gentity_t *ent )
body->s.number = body - g_entities;
body->timestamp = level.time;
body->s.event = 0;
- body->r.contents = CONTENTS_BODY;
- body->clipmask = MASK_PLAYERSOLID;
+ body->r.contents = CONTENTS_CORPSE;
+ body->clipmask = MASK_SHOT;
body->s.clientNum = ent->client->ps.stats[ STAT_PCLASS ];
body->use = useBody;
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 8388b01a..5e59827c 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -2036,6 +2036,16 @@ void Cmd_Sell_f( gentity_t *ent )
}
}
+/*
+=================
+Cmd_Statement_f
+=================
+*/
+void Cmd_Statement_f( gentity_t *ent )
+{
+ trap_SendServerCommand( ent-g_entities, va("print \"Credits: %d\n\"",
+ ent->client->ps.stats[ STAT_CREDIT ] ) );
+}
/*
=================
@@ -2381,6 +2391,8 @@ void ClientCommand( int clientNum ) {
Cmd_Buy_f( ent );
else if (Q_stricmp (cmd, "sell") == 0)
Cmd_Sell_f( ent );
+ else if (Q_stricmp (cmd, "statement") == 0)
+ Cmd_Statement_f( ent );
else if (Q_stricmp (cmd, "deposit") == 0)
Cmd_Deposit_f( ent );
else if (Q_stricmp (cmd, "withdraw") == 0)
diff --git a/src/game/g_combat.c b/src/game/g_combat.c
index fd6548fd..9c2ef786 100644
--- a/src/game/g_combat.c
+++ b/src/game/g_combat.c
@@ -44,51 +44,6 @@ void AddScore( gentity_t *ent, int score ) {
CalculateRanks();
}
-
-/*
-============
-AddPoints
-
-Adds points to both the client and his team
-============
-*/
-void AddPoints( gentity_t *ent, int score )
-{
- if ( !ent->client ) {
- return;
- }
- // no scoring during pre-match warmup
- if ( level.warmupTime ) {
- return;
- }
- ent->client->ps.persistant[PERS_POINTS] += score;
- ent->client->ps.persistant[PERS_TOTALPOINTS] += score;
-
- /*if (g_gametype.integer == GT_TEAM)
- level.teamScores[ ent->client->ps.persistant[PERS_TEAM] ] += score;
- CalculateRanks();*/
-}
-
-
-/*
-============
-CalculatePoints
-
-Calculates the points to given to a client
-============
-*/
-int CalculatePoints( gentity_t *victim, gentity_t *attacker )
-{
- int victim_value, attacker_value;
-
- if( !victim->client || !attacker->client )
- return 0;
-
- return 1;
-
-}
-
-
/*
=================
TossClientItems
@@ -308,7 +263,8 @@ void CheckAlmostScored( gentity_t *self, gentity_t *attacker ) {
player_die
==================
*/
-void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath ) {
+void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath )
+{
gentity_t *ent;
int anim;
int contents;
@@ -316,44 +272,39 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
int i;
char *killerName, *obit;
- if ( self->client->ps.pm_type == PM_DEAD ) {
+ if( self->client->ps.pm_type == PM_DEAD )
return;
- }
- if ( level.intermissiontime ) {
+ if( level.intermissiontime )
return;
- }
-
- //TA: prolly dont need this
- // check for an almost capture
- //CheckAlmostCapture( self, attacker );
- // check for a player that almost brought in cubes
- //CheckAlmostScored( self, attacker );
self->client->ps.pm_type = PM_DEAD;
- if ( attacker ) {
+ if( attacker )
+ {
killer = attacker->s.number;
- if ( attacker->client ) {
+
+ if( attacker->client )
killerName = attacker->client->pers.netname;
- } else {
+ else
killerName = "<non-client>";
- }
- } else {
+ }
+ else
+ {
killer = ENTITYNUM_WORLD;
killerName = "<world>";
}
- if ( killer < 0 || killer >= MAX_CLIENTS ) {
+ if( killer < 0 || killer >= MAX_CLIENTS )
+ {
killer = ENTITYNUM_WORLD;
killerName = "<world>";
}
- if ( meansOfDeath < 0 || meansOfDeath >= sizeof( modNames ) / sizeof( modNames[0] ) ) {
+ if( meansOfDeath < 0 || meansOfDeath >= sizeof( modNames ) / sizeof( modNames[0] ) )
obit = "<bad obituary>";
- } else {
+ else
obit = modNames[ meansOfDeath ];
- }
G_LogPrintf("Kill: %i %i %i: %s killed %s by %s\n",
killer, self->s.number, meansOfDeath, killerName,
@@ -370,14 +321,17 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
self->client->ps.persistant[PERS_KILLED]++;
- if (attacker && attacker->client) {
+ if( attacker && attacker->client )
+ {
attacker->client->lastkilled_client = self->s.number;
- if ( attacker == self || OnSameTeam (self, attacker ) ) {
+
+ if( attacker == self || OnSameTeam( self, attacker ) )
+ {
AddScore( attacker, -1 );
- AddPoints( attacker, -10 );
- } else {
+ }
+ else
+ {
AddScore( attacker, 1 );
- AddPoints( attacker, CalculatePoints( self, attacker ) );
attacker->client->lastKillTime = level.time;
@@ -385,36 +339,63 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
level.alienKills++;
else if( attacker->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS )
level.humanKills++;
+
}
- } else {
+ }
+ else
+ {
AddScore( self, -1 );
- AddPoints( self, -10 );
}
+ if( self->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS )
+ {
+ int clientNum = attacker->client->ps.clientNum;
+ float denominator, numerator = self->credits[ clientNum ];
+ int classValue = BG_FindValueOfClass( self->client->ps.stats[ STAT_PCLASS ] );
+ int total = 0;
+ gentity_t *player;
+
+ //total up all the damage done by every client
+ for( i = 0; i < MAX_CLIENTS; i++ )
+ total += self->credits[ i ];
+
+ denominator = total;
+
+ //if this corpse has been 100% claimed destroy it
+ for( i = 0; i < MAX_CLIENTS; i++ )
+ {
+ player = g_entities + i;
+
+ if( player->client && player->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS )
+ {
+ numerator = self->credits[ i ];
+
+ //add credit
+ player->client->ps.stats[ STAT_CREDIT ] += (int)( (float)classValue * ( numerator / denominator ) );
+ }
+ }
+ }
+
// Add team bonuses
//Team_FragBonuses(self, inflictor, attacker);
- // if client is in a nodrop area, don't drop anything (but return CTF flags!)
- contents = trap_PointContents( self->r.currentOrigin, -1 );
- if ( !( contents & CONTENTS_NODROP ) )
- //TossClientItems( self );
-
Cmd_Score_f( self ); // show scores
+
// send updated scores to any clients that are following this one,
// or they would get stale scoreboards
- for ( i = 0 ; i < level.maxclients ; i++ ) {
+ for( i = 0 ; i < level.maxclients ; i++ )
+ {
gclient_t *client;
- client = &level.clients[i];
- if ( client->pers.connected != CON_CONNECTED ) {
+ client = &level.clients[ i ];
+ if( client->pers.connected != CON_CONNECTED )
continue;
- }
- if ( client->sess.sessionTeam != TEAM_SPECTATOR ) {
+
+ if( client->sess.sessionTeam != TEAM_SPECTATOR )
continue;
- }
- if ( client->sess.spectatorClient == self->s.number ) {
+
+ if( client->sess.spectatorClient == self->s.number )
Cmd_Score_f( g_entities + i );
- }
}
self->client->pers.pclass = 0; //TA: reset the classtype
@@ -426,9 +407,9 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
self->r.contents = CONTENTS_BODY;
//self->r.contents = CONTENTS_CORPSE;
- self->s.angles[0] = 0;
- self->s.angles[2] = 0;
- LookAtKiller (self, inflictor, attacker);
+ self->s.angles[ 0 ] = 0;
+ self->s.angles[ 2 ] = 0;
+ LookAtKiller( self, inflictor, attacker );
VectorCopy( self->s.angles, self->client->ps.viewangles );
@@ -441,34 +422,30 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
self->client->respawnTime = level.time + 1700;
// remove powerups
- memset( self->client->ps.powerups, 0, sizeof(self->client->ps.powerups) );
+ memset( self->client->ps.powerups, 0, sizeof( self->client->ps.powerups ) );
- // never gib in a nodrop
- /*if ( self->health <= GIB_HEALTH && !(contents & CONTENTS_NODROP) && g_blood.integer ) {
- // gib death
- GibEntity( self, killer );
- } else*/ {
+ {
// normal death
static int i;
- switch ( i ) {
- case 0:
- anim = BOTH_DEATH1;
- break;
- case 1:
- anim = BOTH_DEATH2;
- break;
- case 2:
- default:
- anim = BOTH_DEATH3;
- break;
+ switch( i )
+ {
+ case 0:
+ anim = BOTH_DEATH1;
+ break;
+ case 1:
+ anim = BOTH_DEATH2;
+ break;
+ case 2:
+ default:
+ anim = BOTH_DEATH3;
+ break;
}
// for the no-blood option, we need to prevent the health
// from going to gib level
- if ( self->health <= GIB_HEALTH ) {
+ if( self->health <= GIB_HEALTH )
self->health = GIB_HEALTH+1;
- }
self->client->ps.legsAnim =
( ( self->client->ps.legsAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim;
@@ -484,7 +461,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
i = ( i + 1 ) % 3;
}
- trap_LinkEntity (self);
+ trap_LinkEntity( self );
}
diff --git a/src/game/g_team.c b/src/game/g_team.c
index 74817043..d8eb900e 100644
--- a/src/game/g_team.c
+++ b/src/game/g_team.c
@@ -157,18 +157,13 @@ void AddTeamScore(vec3_t origin, int team, int score) {
OnSameTeam
==============
*/
-qboolean OnSameTeam( gentity_t *ent1, gentity_t *ent2 ) {
- if ( !ent1->client || !ent2->client ) {
- return qfalse;
- }
-
- if ( g_gametype.integer < GT_TEAM ) {
+qboolean OnSameTeam( gentity_t *ent1, gentity_t *ent2 )
+{
+ if( !ent1->client || !ent2->client )
return qfalse;
- }
- if ( ent1->client->sess.sessionTeam == ent2->client->sess.sessionTeam ) {
+ if( ent1->client->ps.stats[ STAT_PTEAM ] == ent2->client->ps.stats[ STAT_PTEAM ] )
return qtrue;
- }
return qfalse;
}