/* * SCB_ParsePlayerStats */ static void SCB_ParsePlayerStats( const char **s ) { int i, j, weak, strong; int shot_weak, hit_weak, shot_strong, hit_strong, hit_total, shot_total; unsigned int playerNum; if( !s || !*s ) return; playerNum = CG_ParseValue( s ); if( cg.frame.playerState.POVnum != playerNum + 1 ) return; memset( scb_player_stats, -1, sizeof( scb_player_stats ) ); j = 0; #define STATS_PERCENT(hit,total) ((hit) > 0 ? ((hit) == (total) ? 100 : (min( (int)( floor( ( 100.0f*(hit) ) / ( (float)(total) ) + 0.5f ) ), 99 ))) : -1) for( i = WEAP_GUNBLADE; i < WEAP_TOTAL; i++ ) { weak = j++; strong = j++; // total shot_total = CG_ParseValue( s ); if( shot_total == 0 ) continue; hit_total = CG_ParseValue( s ); shot_strong = shot_total; hit_strong = hit_total; if( i == WEAP_LASERGUN || i == WEAP_ELECTROBOLT ) { // strong shot_strong = CG_ParseValue( s ); if( shot_strong != shot_total ) hit_strong = CG_ParseValue( s ); } // weak shot_weak = shot_total - shot_strong; hit_weak = hit_total - hit_strong; scb_player_stats[weak] = STATS_PERCENT(hit_weak,shot_weak); scb_player_stats[strong] = STATS_PERCENT(hit_strong,shot_strong); } #undef STATS_PERCENT }
/* * SCR_DrawTeamTab */ static int SCR_DrawTeamTab( const char **ptrptr, int *curteam, int x, int y, int panelWidth, struct qfontface_s *font, struct qfontface_s *titleFont, int pass ) { const char *token; const char *layout, *titles; char type; int team, team_score, team_ping; int yoffset = 0, xoffset = 0; int dir = 0, align, width, height; vec4_t teamcolor = { 0.0f, 0.0f, 0.0f, 1.0f }, pingcolor; // team tab is always the same. Sets the current team and draws its score if( !(*ptrptr) || !(*ptrptr[0]) || *ptrptr[0] == '&' ) return yoffset; team = CG_ParseValue( ptrptr ); if( team < TEAM_PLAYERS || team > TEAM_BETA ) CG_Error( "SCR_ParseTeamTab: Invalid team value\n" ); *curteam = team; if( *ptrptr[0] == '&' ) return yoffset; team_score = CG_ParseValue( ptrptr ); if( *ptrptr[0] == '&' ) return yoffset; team_ping = CG_ParseValue( ptrptr ); if( ( team == TEAM_ALPHA ) || ( team == TEAM_BETA ) ) CG_TeamColor( team, teamcolor ); teamcolor[3] = SCB_BACKGROUND_ALPHA; // make transparent if( GS_TeamBasedGametype() ) // we only draw the team tabs in team based gametypes { dir = ( team == TEAM_ALPHA ) ? -1 : 1; align = ( team == TEAM_ALPHA ) ? ALIGN_RIGHT_TOP : ALIGN_LEFT_TOP; // draw the tab xoffset = ( SCB_CENTERMARGIN * dir ); width = ( cgs.vidWidth * 0.5 ) - SCB_CENTERMARGIN; height = trap_SCR_FontHeight( titleFont ) + 2; if( !pass ) { CG_DrawAlignPic( x + xoffset, y + yoffset + SCB_SCORENUMBER_SIZE - height, width, height, align, teamcolor, cgs.shaderWhite ); } if( pass ) { xoffset += ( ( 16 * cgs.vidHeight / 600 ) * dir ); CG_DrawHUDNumeric( x + xoffset, y + yoffset, align, colorWhite, SCB_SCORENUMBER_SIZE, SCB_SCORENUMBER_SIZE, team_score ); xoffset += ( ( SCB_SCORENUMBER_SIZE * strlen(va("%i", team_score)) + ( 16 * cgs.vidHeight / 600 ) ) * dir ); trap_SCR_DrawStringWidth( x + xoffset + ( ( SCB_TINYFIELD_PIXELWIDTH + ( 16 * cgs.vidHeight / 600 ) ) * dir ), y + yoffset + SCB_SCORENUMBER_SIZE - (trap_SCR_FontHeight( titleFont ) + 1), align, GS_TeamName( team ), SCB_TEAMNAME_PIXELWIDTH, titleFont, colorWhite ); CG_PingColor( team_ping, pingcolor ); trap_SCR_DrawStringWidth( x + xoffset, y + yoffset + SCB_SCORENUMBER_SIZE - (trap_SCR_FontHeight( font ) + 1), align, va( "%i", team_ping ), SCB_TINYFIELD_PIXELWIDTH, font, pingcolor ); } yoffset += SCB_SCORENUMBER_SIZE; } else { dir = 0; align = ALIGN_CENTER_TOP; } // draw the player tab column titles layout = cgs.configStrings[CS_SCB_PLAYERTAB_LAYOUT]; titles = cgs.configStrings[CS_SCB_PLAYERTAB_TITLES]; height = trap_SCR_FontHeight( font ); // start from the center again xoffset = CG_HorizontalAlignForWidth( 0, align, panelWidth ); xoffset += ( SCB_CENTERMARGIN * dir ); while( ( token = SCR_GetNextColumnLayout( &layout, &titles, &type, &width, font ) ) != NULL ) { if( SCR_SkipColumn( type ) ) continue; if( width ) { if( pass ) { trap_SCR_DrawClampString( x + xoffset, y + yoffset, CG_TranslateString( token ), x + xoffset, y + yoffset, x + xoffset + width, y + yoffset + height, font, colorWhite ); } xoffset += width; } } yoffset += trap_SCR_FontHeight( font ); return yoffset; }
/* * CG_SC_PrintPlayerStats */ static void CG_SC_PrintPlayerStats( const char *s, void ( *pp ) ) { int playerNum; int i, shot_weak, hit_weak, shot_strong, hit_strong, hit_total, shot_total; int total_damage_given, total_damage_received, health_taken, armor_taken; gsitem_t *item; void ( *print )( const char *format, ... ) = pp; playerNum = CG_ParseValue( &s ); if( playerNum < 0 || playerNum >= gs.maxclients ) return; // print stats to console/file print( "Stats for %s" S_COLOR_WHITE ":\r\n\r\n", cgs.clientInfo[playerNum].name ); print( " Weapon Weak Strong\r\n" ); print( " hit/shot percent hit/shot percent hit/shot percent\r\n" ); for( i = WEAP_GUNBLADE; i < WEAP_TOTAL; i++ ) { item = GS_FindItemByTag( i ); assert( item ); shot_total = CG_ParseValue( &s ); if( shot_total < 1 ) // only continue with registered shots continue; hit_total = CG_ParseValue( &s ); shot_strong = CG_ParseValue( &s ); hit_strong = (shot_strong != shot_total ? CG_ParseValue( &s ) : hit_total); shot_weak = shot_total - shot_strong; hit_weak = hit_total - hit_strong; // name print( "%s%2s" S_COLOR_WHITE ": ", item->color, item->shortname ); #define STATS_PERCENT(hit,total) ((total) == 0 ? 0 : ((hit) == (total) ? 100 : (float)(hit) * 100.0f / (float)(total))) // total print( S_COLOR_GREEN "%3i" S_COLOR_WHITE "/" S_COLOR_CYAN "%3i " S_COLOR_YELLOW "%2.1f", hit_total, shot_total, STATS_PERCENT( hit_total, shot_total ) ); // weak print( " " S_COLOR_GREEN "%3i" S_COLOR_WHITE "/" S_COLOR_CYAN "%3i " S_COLOR_YELLOW "%2.1f", hit_weak, shot_weak, STATS_PERCENT( hit_weak, shot_weak ) ); // strong print( " " S_COLOR_GREEN "%3i" S_COLOR_WHITE "/" S_COLOR_CYAN "%3i " S_COLOR_YELLOW "%2.1f", hit_strong, shot_strong, STATS_PERCENT( hit_strong, shot_strong ) ); print( "\r\n" ); } print( "\r\n" ); total_damage_given = CG_ParseValue( &s ); total_damage_received = CG_ParseValue( &s ); print( S_COLOR_YELLOW "Damage given/received: " S_COLOR_WHITE "%i/%i " S_COLOR_YELLOW "ratio: %s%3.2f\r\n", total_damage_given, total_damage_received, ( total_damage_given > total_damage_received ? S_COLOR_GREEN : S_COLOR_RED ), STATS_PERCENT( total_damage_given, total_damage_given + total_damage_received ) ); health_taken = CG_ParseValue( &s ); armor_taken = CG_ParseValue( &s ); print( S_COLOR_YELLOW "Health/Armor taken : " S_COLOR_CYAN "%i" S_COLOR_WHITE "/" S_COLOR_CYAN "%i\r\n", health_taken, armor_taken ); #undef STATS_PERCENT }