Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: Main.qc
- ===================================================================
- --- Main.qc (revision 6523)
- +++ Main.qc (working copy)
- @@ -86,6 +86,12 @@
- registercmd("+button4");
- registercmd("-button4");
- + registercmd("+showhitscanstats");
- + registercmd("-showhitscanstats");
- + registercmd("+showsplashstats");
- + registercmd("-showsplashstats");
- +
- +
- #ifndef CAMERATEST
- if(isdemo())
- {
- @@ -326,6 +332,18 @@
- } else if(strCmd == "-showscores") {
- sb_showscores = false;
- return true;
- + } else if(strCmd == "+showhitscanstats") {
- + sb_showhitscanstats = true;
- + return true;
- + } else if(strCmd == "-showhitscanstats") {
- + sb_showhitscanstats = false;
- + return true;
- + } else if(strCmd == "+showsplashstats") {
- + sb_showsplashstats = true;
- + return true;
- + } else if(strCmd == "-showsplashstats") {
- + sb_showsplashstats = false;
- + return true;
- }
- if(camera_active)
- Index: sbar.qc
- ===================================================================
- --- sbar.qc (revision 6523)
- +++ sbar.qc (working copy)
- @@ -1,3 +1,9 @@
- +void drawstringright(vector, string, vector, vector, float, float);
- +void drawstringcentre(vector, string, vector, vector, float, float);
- +void Sbar_DrawStats(float);
- +float weapon_hits[WEP_COUNT];
- +float weapon_fired[WEP_COUNT];
- +void Sbar_DrawStats_Description(float, vector);
- float last_weapon;
- float weapontime;
- @@ -6,6 +12,7 @@
- vector sbar;
- float sbar_alpha_fg;
- +float sbar_alpha_bg;
- float sbar_hudselector;
- float ps_primary, ps_secondary;
- @@ -20,7 +27,7 @@
- pos_x = (vid_conwidth - 1)/2;
- pos_y = 16;
- pos_z = 0;*/
- -
- +
- //drawpic(pos, "gfx/finale", '0 0 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
- //drawstring(pos, "END", sbar_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);
- @@ -835,7 +842,7 @@
- ymin = 45;
- xmax = vid_conwidth - xmin;
- - ymax = vid_conheight - 0.2*vid_conheight;
- + ymax = vid_conheight - 0.2*vid_conheight;
- center_x = xmin + 0.5*sbwidth;
- @@ -1773,15 +1780,27 @@
- }
- }
- +float weapon_hits[WEP_COUNT];
- +float weapon_fired[WEP_COUNT];
- +
- void Sbar_Draw (void)
- {
- float i;
- float x, fade;
- float stat_items, stat_weapons;
- + float weapon_number, weapon_stats;
- vector o; o = '1 0 0' * vid_conwidth;
- vector v;
- string s;
- + weapon_stats = getstati(STAT_DMGDONE_HITS);
- + weapon_number = weapon_stats & 63;
- + weapon_hits[weapon_number] = rint(weapon_stats / 64);
- +
- + weapon_stats = getstati(STAT_MAXDMG_FIRED);
- + weapon_number = weapon_stats & 63;
- + weapon_fired[weapon_number] = rint(weapon_stats / 64);
- +
- sbar_fontsize = Sbar_GetFontsize("sbar_fontsize");
- if(spectatee_status && !intermission)
- @@ -1933,11 +1952,23 @@
- Sbar_DrawScoreboard();
- Sbar_DrawCenterPrint();
- }
- + else if(sb_showsplashstats == 1)
- + {
- + Sbar_DrawStats(0);
- + }
- + else if(sb_showhitscanstats == 1)
- + {
- + Sbar_DrawStats(1);
- + }
- else if (intermission == 1)
- {
- Sbar_DrawScoreboard();
- Sbar_DrawCenterPrint();
- return;
- +// Sbar_DrawStats(0);
- +// return;
- +// Sbar_DrawStats(1);
- +// return;
- }
- else if (intermission == 2)
- {
- @@ -2190,3 +2221,130 @@
- drawpic(pos, "gfx/sb_flag_blue_shielded", '128 64 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); break;
- }
- }
- +
- +void Sbar_DrawStats(float type)
- +{
- + float i, count, row; // count is the number of 'colums'
- + float weapon_number, weapon_stats, weapon_hit, weapon_damage;
- + float col_margin; // the pixel distance between the columns
- + float left_border; // position where the weapons start, the description is in the border
- + float top_border; // position where the first row starts
- + float row_margin; // the pixel distance between the rows
- + vector fill_colour, fill_size;
- + vector pos;
- +
- + col_margin = 20; // pixels between the columns
- + row_margin = 20; // pixels between the rows
- + top_border = 120; // pixels down the screen
- +
- + fill_size_x = 5 * sbar_fontsize_x; // width of the background
- + fill_size_y = 10 * sbar_fontsize_y; // height of the background
- +
- +
- + if (type == 1)
- + { // hitscan stats
- + // 45 pixels is the same as the 'Scoreboard' heading
- + drawstringcentre('0 45 0', "Hitscan Accuracy", 2 * sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
- +
- + left_border = col_margin + 9 * sbar_fontsize_x;
- + }
- + else
- + {
- + drawstringcentre('0 45 0', "Splish, Splosh, Splash Accuracy", 2 * sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
- +
- + left_border = col_margin + 11 * sbar_fontsize_x;
- + }
- +
- + Sbar_DrawStats_Description(type, '1 0 0' * col_margin + '0 1 0' * top_border);
- +
- +
- + for(i = WEP_FIRST; i < WEP_LAST; ++i)
- + {
- + weapon_hit = weapon_hits[i];
- + weapon_damage = weapon_fired[i];
- +
- + weapon_number = cvar(strcat("weapon_type", ftos(i)));
- + if ((weapon_number != 42)) // print them all :)
- +// if ((weapon_number == type) && (weapon_damage))
- + {
- + weapon_stats = rint(100 * weapon_hit / weapon_damage);
- +
- + fill_colour_x = 1 - 0.015 * weapon_stats;
- + fill_colour_y = 1 - 0.015 * (100 - weapon_stats);
- +
- +// how the background colour is calculated
- +// % red green red_2 green_2
- +// 0 1 0 1 - % * 0.015 1 - (100 - %) * 0.015
- +// 10 0.85 0 1 - % * 0.015 1 - (100 - %) * 0.015
- +// 20 0.70 0 1 - % * 0.015 1 - (100 - %) * 0.015
- +// 30 0.55 0 1 - % * 0.015 1 - (100 - %) * 0.015
- +// 40 0.40 0.10 1 - % * 0.015 1 - (100 - %) * 0.015
- +// 50 0.25 0.25 1 - % * 0.015 1 - (100 - %) * 0.015
- +// 60 0.10 0.40 1 - % * 0.015 1 - (100 - %) * 0.015
- +// 70 0 0.55 1 - % * 0.015 1 - (100 - %) * 0.015
- +// 80 0 0.70 1 - % * 0.015 1 - (100 - %) * 0.015
- +// 90 0 0.85 1 - % * 0.015 1 - (100 - %) * 0.015
- +// 100 0 1 1 - % * 0.015 1 - (100 - %) * 0.015
- +
- + if ((left_border + count * (fill_size_x + col_margin) + fill_size_x + cvar("stats_right_margin")) >= vid_conwidth)
- + {
- + count = 0;
- + ++row;
- + Sbar_DrawStats_Description(type, '1 0 0' * col_margin + '0 1 0' * (top_border + row * (fill_size_y + row_margin)));
- + }
- +
- + pos_x = left_border + count * (fill_size_x + col_margin);
- + pos_y = top_border + row * (fill_size_y + row_margin);
- +
- +// background
- + drawfill(pos, fill_size , fill_colour, 0.4 * sbar_alpha_bg, DRAWFLAG_NORMAL);
- +
- +// the weapon
- + drawpic(pos, strcat("gfx/inv_weapon", ftos(i-1)), '1 0.5 0' * fill_size_x , '1 1 1', sbar_alpha_bg, DRAWFLAG_NORMAL);
- +
- +// the amount of shots fired or max damage
- + drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 3 0' * sbar_fontsize_y, ftos(weapon_damage), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
- +
- +// the amount of hits or actual damage
- + drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 5 0' * sbar_fontsize_y, ftos(weapon_hit), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
- +
- +// the accuracy
- + drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 7 0' * sbar_fontsize_y, strcat(ftos(weapon_stats),"%"), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
- +
- +// the amount of shots missed or damage wasted
- + drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 9 0' * sbar_fontsize_y, ftos(weapon_damage - weapon_hit), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
- +
- + ++count;
- + }
- + }
- +}
- +
- +void Sbar_DrawStats_Description(float type, vector position)
- +{
- + if (type == 1)
- + { // hitscan stats
- + drawstring(position + '0 3 0' * sbar_fontsize_y, "Shots fired:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
- + drawstring(position + '0 5 0' * sbar_fontsize_y, "Shots hit:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
- + drawstring(position + '0 7 0' * sbar_fontsize_y, "Accuracy:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
- + drawstring(position + '0 9 0' * sbar_fontsize_y, "Shots missed:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
- + }
- + else
- + {
- + drawstring(position + '0 3 0' * sbar_fontsize_y, "Maximum damage:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
- + drawstring(position + '0 5 0' * sbar_fontsize_y, "Actual damage:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
- + drawstring(position + '0 7 0' * sbar_fontsize_y, "Accuracy:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
- + drawstring(position + '0 9 0' * sbar_fontsize_y, "Damage wasted:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
- + }
- +}
- +
- +void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
- +{
- + position_x -= 2 / 3 * strlen(text) * scale_x;
- + drawstring(position, text, scale, rgb, alpha, flag);
- +}
- +
- +void drawstringcentre(vector position, string text, vector scale, vector rgb, float alpha, float flag)
- +{
- + position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
- + drawstring(position, text, scale, rgb, alpha, flag);
- +}
- Index: Defs.qc
- ===================================================================
- --- Defs.qc (revision 6523)
- +++ Defs.qc (working copy)
- @@ -150,6 +150,8 @@
- // Additional OPTIONAL Fields and Globals
- float intermission;
- float sb_showscores;
- +float sb_showhitscanstats;
- +float sb_showsplashstats;
- .string message;
- .float renderflags;
- // float coop;
- Index: View.qc
- ===================================================================
- --- View.qc (revision 6523)
- +++ View.qc (working copy)
- @@ -289,6 +289,7 @@
- }
- sbar_alpha_fg = cvar("sbar_alpha_fg" );
- + sbar_alpha_bg = cvar("sbar_alpha_bg" );
- sbar_hudselector = cvar("sbar_hudselector");
- ColorTranslateMode = cvar("cl_stripcolorcodes");
- activeweapon = getstati(STAT_SWITCHWEAPON);
Add Comment
Please, Sign In to add comment