diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2020-04-08 08:44:41 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2020-04-08 08:44:41 +0200 |
commit | 8847ac53638653fd1dbe4d18c5d90e66db434047 (patch) | |
tree | c75713bf4c46e93c3470ab2010968e5a75cacd6a /src | |
parent | 9fd2c5dec3a26ff238a783fbfde1c299f0447b4d (diff) |
Track funds in /mystats; minor frac. evos fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/game/g_active.c | 2 | ||||
-rw-r--r-- | src/game/g_buildable.c | 12 | ||||
-rw-r--r-- | src/game/g_client.c | 26 | ||||
-rw-r--r-- | src/game/g_cmds.c | 44 | ||||
-rw-r--r-- | src/game/g_combat.c | 29 | ||||
-rw-r--r-- | src/game/g_local.h | 4 |
6 files changed, 82 insertions, 35 deletions
diff --git a/src/game/g_active.c b/src/game/g_active.c index 1dd27f4..b4fc9ee 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -1437,10 +1437,12 @@ static void ClientGradualFunds( gentity_t *ent ) { case PTE_ALIENS: G_AddCreditToClient( ent->client, FREEKILL_ALIEN, qtrue ); + ent->client->pers.statscounters.earned += FREEKILL_ALIEN; break; case PTE_HUMANS: G_AddCreditToClient( ent->client, FREEKILL_HUMAN, qtrue ); + ent->client->pers.statscounters.earned += FREEKILL_HUMAN; break; } diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index c82677e..de3c800 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -672,9 +672,15 @@ void ASpawn_Die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int if( attacker->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) { if( self->s.modelindex == BA_A_OVERMIND ) + { G_AddCreditToClient( attacker->client, OVERMIND_VALUE, qtrue ); + attacker->client->pers.statscounters.earned += OVERMIND_VALUE; + } else if( self->s.modelindex == BA_A_SPAWN ) + { G_AddCreditToClient( attacker->client, ASPAWN_VALUE, qtrue ); + attacker->client->pers.statscounters.earned += ASPAWN_VALUE; + } } else { @@ -2691,9 +2697,15 @@ void HSpawn_Die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int if( attacker->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) { if( self->s.modelindex == BA_H_REACTOR ) + { G_AddCreditToClient( attacker->client, REACTOR_VALUE, qtrue ); + attacker->client->pers.statscounters.earned += REACTOR_VALUE; + } else if( self->s.modelindex == BA_H_SPAWN ) + { G_AddCreditToClient( attacker->client, HSPAWN_VALUE, qtrue ); + attacker->client->pers.statscounters.earned += HSPAWN_VALUE; + } } else { diff --git a/src/game/g_client.c b/src/game/g_client.c index 45737f1..871bacb 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -133,12 +133,21 @@ void G_OverflowCredits( gclient_t *doner, int credits ) if( vic->client->ps.persistant[ PERS_CREDIT ] + credits > maxCredits ) { - credits -= maxCredits - vic->client->ps.persistant[ PERS_CREDIT ]; - vic->client->ps.persistant[ PERS_CREDIT ] = maxCredits; + int amount; + + amount = maxCredits - vic->client->ps.persistant[ PERS_CREDIT ]; + credits -= amount; + vic->client->ps.persistant[ PERS_CREDIT ] += amount; + + doner->pers.statscounters.overflowed += amount; + vic->client->pers.statscounters.received += amount; } else { vic->client->ps.persistant[ PERS_CREDIT ] += credits; + + doner->pers.statscounters.overflowed += credits; + vic->client->pers.statscounters.received += credits; return; } } @@ -158,12 +167,21 @@ void G_OverflowCredits( gclient_t *doner, int credits ) if( cl->ps.persistant[ PERS_CREDIT ] + credits > maxCredits ) { - credits -= maxCredits - cl->ps.persistant[ PERS_CREDIT ]; - cl->ps.persistant[ PERS_CREDIT ] = maxCredits; + int amount; + + amount = maxCredits - cl->ps.persistant[ PERS_CREDIT ]; + credits -= amount; + cl->ps.persistant[ PERS_CREDIT ] += amount; + + doner->pers.statscounters.overflowed += amount; + cl->pers.statscounters.received += amount; } else { cl->ps.persistant[ PERS_CREDIT ] += credits; + + doner->pers.statscounters.overflowed += credits; + cl->pers.statscounters.received += credits; return; } } diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index d9edc16..02bb9c8 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -691,25 +691,7 @@ void G_ChangeTeam( gentity_t *ent, pTeam_t newTeam ) } ent->client->ps.persistant[ PERS_KILLED ] = 0; - ent->client->pers.statscounters.kills = 0; - ent->client->pers.statscounters.structskilled = 0; - ent->client->pers.statscounters.assists = 0; - ent->client->pers.statscounters.repairspoisons = 0; - ent->client->pers.statscounters.headshots = 0; - ent->client->pers.statscounters.hits = 0; - ent->client->pers.statscounters.hitslocational = 0; - ent->client->pers.statscounters.deaths = 0; - ent->client->pers.statscounters.feeds = 0; - ent->client->pers.statscounters.suicides = 0; - ent->client->pers.statscounters.teamkills = 0; - ent->client->pers.statscounters.dmgdone = 0; - ent->client->pers.statscounters.structdmgdone = 0; - ent->client->pers.statscounters.ffdmgdone = 0; - ent->client->pers.statscounters.structsbuilt = 0; - ent->client->pers.statscounters.timealive = 0; - ent->client->pers.statscounters.timeinbase = 0; - ent->client->pers.statscounters.dretchbasytime = 0; - ent->client->pers.statscounters.jetpackusewallwalkusetime = 0; + memset( &ent->client->pers.statscounters, 0, sizeof( statsCounters_t ) ); if( G_admin_permission( ent, ADMF_DBUILDER ) ) { @@ -4072,9 +4054,9 @@ void Cmd_MyStats_f( gentity_t *ent ) if(!ent) return; - if( !level.intermissiontime && ent->client->pers.statscounters.timeLastViewed && (level.time - ent->client->pers.statscounters.timeLastViewed) <60000 ) + if( !level.intermissiontime && ent->client->pers.statscounters.timeLastViewed && (level.time - ent->client->pers.statscounters.timeLastViewed) < 10000 ) { - ADMP( "You may only check your stats once per minute and during intermission.\n"); + ADMP( "You may only check your stats once every 10 seconds and during intermission.\n"); return; } @@ -4120,7 +4102,7 @@ char *G_statsString( statsCounters_t *sc, pTeam_t *pt ) if( sc->hitslocational ) percentHeadshots = (int)(100 * (float) sc->headshots / ((float) (sc->hitslocational) ) ); - s = va( "^3Kills:^7 %3i ^3StructKills:^7 %3i ^3Assists:^7 %3i^7 ^3Poisons:^7 %3i ^3Headshots:^7 %3i (%3i)\n^3Deaths:^7 %3i ^3Feeds:^7 %3i ^3Suicides:^7 %3i ^3TKs:^7 %3i ^3Avg Lifespan:^7 %4d:%02d\n^3Damage to:^7 ^3Enemies:^7 %5i ^3Structs:^7 %5i ^3Friendlies:^7 %3i \n^3Structs Built:^7 %3i ^3Time Near Base:^7 %3i ^3Time wallwalking:^7 %3i\n", + s = va( "^3Kills:^7 %3i ^3StructKills:^7 %3i ^3Assists:^7 %3i^7 ^3Poisons:^7 %3i ^3Headshots:^7 %3i (%3i)\n^3Deaths:^7 %3i ^3Feeds:^7 %3i ^3Suicides:^7 %3i ^3TKs:^7 %3i ^3Avg Lifespan:^7 %4d:%02d\n^3Damage to:^7 ^3Enemies:^7 %5i ^3Structs:^7 %5i ^3Friendlies:^7 %3i \n^3Structs Built:^7 %3i ^3Time Near Base:^7 %3i ^3Time wallwalking:^7 %3i\n^3Earned:^7 %6.3f ^3Shared:^7 %6.3f ^3Overflowed:^7 %6.3f ^3Recvd:^7 %6.3f\n", sc->kills, sc->structskilled, sc->assists, @@ -4138,14 +4120,18 @@ char *G_statsString( statsCounters_t *sc, pTeam_t *pt ) sc->ffdmgdone, sc->structsbuilt, percentNearBase, - percentJetpackWallwalk + percentJetpackWallwalk, + sc->earned / EVO_TO_CREDS_RATE, + sc->shared / EVO_TO_CREDS_RATE, + sc->overflowed / EVO_TO_CREDS_RATE, + sc->received / EVO_TO_CREDS_RATE ); } else if( *pt == PTE_HUMANS ) { if( sc->timealive ) percentJetpackWallwalk = (int)(100 * (float) sc->jetpackusewallwalkusetime / ((float) ( sc->timealive ) ) ); - s = va( "^3Kills:^7 %3i ^3StructKills:^7 %3i ^3Assists:^7 %3i \n^3Deaths:^7 %3i ^3Feeds:^7 %3i ^3Suicides:^7 %3i ^3TKs:^7 %3i ^3Avg Lifespan:^7 %4d:%02d\n^3Damage to:^7 ^3Enemies:^7 %5i ^3Structs:^7 %5i ^3Friendlies:^7 %3i \n^3Structs Built:^7 %3i ^3Repairs:^7 %4i ^3Time Near Base:^7 %3i ^3Time Jetpacking:^7 %3i\n", + s = va( "^3Kills:^7 %3i ^3StructKills:^7 %3i ^3Assists:^7 %3i \n^3Deaths:^7 %3i ^3Feeds:^7 %3i ^3Suicides:^7 %3i ^3TKs:^7 %3i ^3Avg Lifespan:^7 %4d:%02d\n^3Damage to:^7 ^3Enemies:^7 %5i ^3Structs:^7 %5i ^3Friendlies:^7 %3i \n^3Structs Built:^7 %3i ^3Repairs:^7 %4i ^3Time Near Base:^7 %3i ^3Time Jetpacking:^7 %3i\n^3Earned:^7 %6d ^3Shared:^7 %6d ^3Overflowed:^7 %6d ^3Recvd:^7 %6d\n", sc->kills, sc->structskilled, sc->assists, @@ -4161,7 +4147,11 @@ char *G_statsString( statsCounters_t *sc, pTeam_t *pt ) sc->structsbuilt, sc->repairspoisons, percentNearBase, - percentJetpackWallwalk + percentJetpackWallwalk, + sc->earned, + sc->shared, + sc->overflowed, + sc->received ); } else s="No stats available\n"; @@ -5036,6 +5026,8 @@ void Cmd_Share_f( gentity_t *ent ) // transfer credits G_AddCreditToClient( ent->client, -creds, qfalse ); G_AddCreditToClient( &(level.clients[ clientNum ]), creds, qtrue ); + ent->client->pers.statscounters.shared += creds; + level.clients[ clientNum ].pers.statscounters.received += creds; if( team == PTE_ALIENS ) { @@ -5160,6 +5152,7 @@ void Cmd_Donate_f( gentity_t *ent ) { } if( amounts[ i ] ) { G_AddCreditToClient( &(level.clients[ i ]), amounts[ i ], qtrue ); + level.clients[ i ].pers.statscounters.received += amounts[ i ]; donated = qtrue; value -= amounts[ i ]; if( value < portion ) break; @@ -5169,6 +5162,7 @@ void Cmd_Donate_f( gentity_t *ent ) { // transfer funds G_AddCreditToClient( ent->client, value - total, qtrue ); + ent->client->pers.statscounters.shared += value - total; if( ent->client->pers.teamSelection == PTE_ALIENS ) { diff --git a/src/game/g_combat.c b/src/game/g_combat.c index aef76d1..9fb920f 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -266,9 +266,15 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int if( !g_retribution.integer ) { if( attacker->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) + { G_AddCreditToClient( attacker->client, -FREEKILL_ALIEN, qtrue ); + attacker->client->pers.statscounters.earned -= FREEKILL_ALIEN; + } else if( attacker->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) + { G_AddCreditToClient( attacker->client, -FREEKILL_HUMAN, qtrue ); + attacker->client->pers.statscounters.earned -= FREEKILL_HUMAN; + } } } else @@ -358,6 +364,9 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int G_AddCreditToClient( self->client, price, qtrue ); G_AddCreditToClient( g_entities[ i ].client, -price, qtrue ); + self->client->pers.statscounters.received += price; + g_entities[ i ].client->pers.statscounters.shared += price; + trap_SendServerCommand( self->client->ps.clientNum, va( "print \"Received ^3%d credits ^7from %s ^7in retribution.\n\"", price, g_entities[ i ].client->pers.netname ) ); @@ -418,13 +427,16 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int G_AddCreditToClient( self->client, toPay[ i ], qtrue ); G_AddCreditToClient( g_entities[ i ].client, -toPay[ i ], qtrue ); + + self->client->pers.statscounters.received += toPay[ i ]; + g_entities[ i ].client->pers.statscounters.shared += toPay[ i ]; trap_SendServerCommand( self->client->ps.clientNum, - va( "print \"Received ^3%d ^7evos from %s ^7in retribution.\n\"", - toPay[ i ], g_entities[ i ].client->pers.netname ) ); + va( "print \"Received ^3%.3f ^7evos from %s ^7in retribution.\n\"", + toPay[ i ] / EVO_TO_CREDS_RATE, g_entities[ i ].client->pers.netname ) ); trap_SendServerCommand( g_entities[ i ].client->ps.clientNum, - va( "print \"Transfered ^3%d ^7evos to %s ^7in retribution.\n\"", - toPay[ i ], self->client->pers.netname ) ); + va( "print \"Transfered ^3%.3f ^7evos to %s ^7in retribution.\n\"", + toPay[ i ] / EVO_TO_CREDS_RATE, self->client->pers.netname ) ); } } } @@ -462,6 +474,8 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int for( i = 0; i < MAX_CLIENTS; i++ ) { + int amount; + player = g_entities + i; if( !player->client ) @@ -481,8 +495,9 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int } //add credit - G_AddCreditToClient( player->client, - (int)( classValue * percentDamage ), qtrue ); + amount = classValue * percentDamage; + G_AddCreditToClient( player->client, amount, qtrue ); + player->client->pers.statscounters.earned += amount; } } else if( self->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) @@ -523,6 +538,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int { //add kills G_AddCreditToClient( player->client, frags, qtrue ); + player->client->pers.statscounters.earned += frags; //can't revist this account later self->credits[ i ] = 0; @@ -564,6 +580,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int //add kills G_AddCreditToClient( player->client, 1, qtrue ); + player->client->pers.statscounters.earned += 1; //can't revist this account again self->credits[ topClient ] = 0; diff --git a/src/game/g_local.h b/src/game/g_local.h index b00c958..315e95e 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -364,6 +364,10 @@ typedef struct int timeLastViewed; int AllstatstimeLastViewed; int spreebleeds; + int earned; + int shared; + int overflowed; + int received; } statsCounters_t; typedef struct |