diff options
author | Tim Angus <tim@ngus.net> | 2001-06-20 18:02:30 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2001-06-20 18:02:30 +0000 |
commit | ead0a752228fc74e748fb4d4bbd43c5399481faa (patch) | |
tree | 6226270febdfdc4d3b75851afc2753215b7e6a82 /src/game/g_client.c | |
parent | ba6e8c35bf5ffcdca53eb2345319c402ba50a86d (diff) |
Partially finished human economy
Diffstat (limited to 'src/game/g_client.c')
-rw-r--r-- | src/game/g_client.c | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/src/game/g_client.c b/src/game/g_client.c index 810ad6d6..96fb3651 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -533,16 +533,46 @@ void BodySink( gentity_t *ent ) { /* ================ -InfestBody +useBody -Called when a droid infests a body +Called when a body is used ================ */ -void InfestBody( gentity_t *self, gentity_t *other, gentity_t *activator ) +void useBody( gentity_t *self, gentity_t *other, gentity_t *activator ) { - if( activator->client->ps.stats[ STAT_PTEAM ] != PTE_DROIDS ) return; + int i, class; + int total = 0; + float numerator, denominator; + + if( activator->client->ps.stats[ STAT_PTEAM ] == PTE_DROIDS ) + { + G_AddPredictableEvent( activator, EV_MENU, MN_D_INFEST ); + } + else + { + //client has already raided this corpse + if( self->creditsHash[ activator->client->ps.clientNum ] ) return; + + numerator = self->credits[ activator->client->ps.clientNum ]; + class = self->s.clientNum; + + //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 == 0.0f ) numerator = denominator = 1.0f; + + //add credit + activator->client->ps.stats[ STAT_CREDIT ] += (int)( (float)BG_FindValueOfClass( class ) * + ( numerator / denominator ) ); - G_AddPredictableEvent( activator, EV_MENU, MN_D_INFEST ); + //prevent clients claiming credit twice + self->creditsHash[ activator->client->ps.clientNum ] = qtrue; + } } /* @@ -587,8 +617,7 @@ void SpawnCorpse( gentity_t *ent ) { body->clipmask = MASK_PLAYERSOLID; body->s.clientNum = ent->client->ps.stats[ STAT_PCLASS ]; - if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) - body->use = InfestBody; + body->use = useBody; switch ( body->s.legsAnim & ~ANIM_TOGGLEBIT ) { case BOTH_DEATH1: |