From 1cd59c900d16f038f13fb5f392f346cb8c2154a6 Mon Sep 17 00:00:00 2001 From: enneract Date: Sat, 20 Dec 2014 13:33:55 +0100 Subject: Track self damage in combat statistics. --- src/game/g_admin.c | 23 +++++++++++++++++------ src/game/g_combat.c | 12 ++++++++---- src/game/g_local.h | 1 + 3 files changed, 26 insertions(+), 10 deletions(-) (limited to 'src/game') diff --git a/src/game/g_admin.c b/src/game/g_admin.c index 36fa6be..90afa5c 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -4432,7 +4432,7 @@ qboolean G_admin_stats( gentity_t *ent ) if( !header ) { ADMBP( va( "^3stats: ^7combat statistics of %s^7:\n", targ->client->pers.netname ) ); - ADMBP( va( "^3%*s Dmg Acc FAc BAC FBA^7\n", + ADMBP( va( "^3%*s Dmg Acc FAc BAC FBA SAc^7\n", CSW_MAX_NAME_LEN, "Weapon" ) ); header = qtrue; } @@ -4444,7 +4444,7 @@ if( (b) == 0 ) \ ADMBP( " ^0n/a" ); \ else \ { \ - int _t = round( (float)(a)/(b) * 100.0f ); \ + int _t = MIN( (int)round( (float)(a)/(b) * 100.0f ), 999 ); \ ADMBP( va( " ^7%3d", _t ) ); \ } @@ -4452,25 +4452,36 @@ else \ cs->total - cs->friendly - cs->enemy_buildable - - cs->friendly_buildable ) + cs->friendly_buildable - + cs->self ) PRINT_ACC( cs->friendly, cs->total - cs->enemy - cs->enemy_buildable - - cs->friendly_buildable ) + cs->friendly_buildable - + cs->self ) PRINT_ACC( cs->enemy_buildable, cs->total - cs->enemy - cs->friendly - - cs->friendly_buildable ) + cs->friendly_buildable - + cs->self ) PRINT_ACC( cs->friendly_buildable, cs->total - cs->enemy - cs->enemy_buildable - - cs->friendly ) + cs->friendly - + cs->self ) + + PRINT_ACC( cs->self, + cs->total - + cs->enemy - + cs->friendly - + cs->enemy_buildable - + cs->friendly_buildable ) #undef PRINT_ACC diff --git a/src/game/g_combat.c b/src/game/g_combat.c index c8090d4..0e8db92 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -1819,7 +1819,9 @@ void G_CombatStats_Hit( gentity_t *ent, gentity_t *hit, combatStatsWeapon_t weap cs = ent->client->pers.combatStats + weapon; - if( hit->s.eType == ET_BUILDABLE ) + if( hit == ent ) + stat = &cs->self; + else if( hit->s.eType == ET_BUILDABLE ) { if( ent->client->pers.teamSelection == hit->buildableTeam ) stat = &cs->friendly_buildable; @@ -1843,7 +1845,8 @@ void G_CombatStats_Hit( gentity_t *ent, gentity_t *hit, combatStatsWeapon_t weap ( stat == &cs->friendly_buildable ) ? "a friendly buildable" : ( stat == &cs->enemy_buildable ) ? "an enemy buildable" : ( stat == &cs->friendly ) ? "a friendly player" : - "an enemy player", + ( stat == &cs->enemy ) ? "an enemy player" : + "themselves", hit - g_entities, cswStrings[ weapon ], damage ); @@ -1871,13 +1874,14 @@ void G_LogCombatStats( gentity_t *ent ) Com_sprintf( p, 4096 - ( p - buffer ), - " %s %i,%i,%i,%i,%i", + " %s %i,%i,%i,%i,%i,%i", cswStrings[ i ], cs->total, cs->enemy, cs->friendly, cs->enemy_buildable, - cs->friendly_buildable ); + cs->friendly_buildable, + cs->self ); while( *p ) p++; } diff --git a/src/game/g_local.h b/src/game/g_local.h index 918a809..0717e47 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -324,6 +324,7 @@ typedef struct int enemy_buildable; int friendly; int friendly_buildable; + int self; } combatStats_t; // client data that stays across multiple respawns, but is cleared -- cgit