- Initialize accuracy levels only when the cvar hud_panel_weapons_accuracy_color_levels changes, not at every frame
- Show accuracy stats data without colors on the scoreboard if hud_panel_weapons_accuracy_color_levels is "", instead of not showing at all the whole accuracy panel
seta scoreboard_border_thickness 1 "scoreboard border thickness"
seta scoreboard_accuracy_border_thickness 1 "accuracy stats border thickness"
seta scoreboard_accuracy_doublerows 0 "use two rows instead of one"
-seta scoreboard_accuracy 1 "0 = no weapon accuracy stats panel on scoreboard"
+seta scoreboard_accuracy 1 "show accuracy stats panel on scoreboard"
seta scoreboard_color_bg_r 0 "red color component of the HUD background"
seta scoreboard_color_bg_g 0.25 "green color component of the HUD background"
seta scoreboard_color_bg_b 0.17 "blue color component of the HUD background"
case HUD_NORMAL:
// do some accuracy var caching
float i;
+ if(cvar_string("hud_panel_weapons_accuracy_color_levels") != acc_color_levels)
if(!(gametype == GAME_RACE || gametype == GAME_CTS))
{
- acc_levels = tokenize(cvar_string("hud_panel_weapons_accuracy_color_levels"));
+ acc_color_levels = cvar_string("hud_panel_weapons_accuracy_color_levels");
+ acc_levels = tokenize(acc_color_levels);
if (acc_levels > MAX_ACCURACY_LEVELS)
acc_levels = MAX_ACCURACY_LEVELS;
vector wpnpos;
vector wpnsize;
+ float show_accuracy;
+ if(autocvar_hud_panel_weapons_accuracy && acc_levels)
+ show_accuracy = true;
+
for(i = 0; i < weapon_cnt; ++i)
{
wpnpos = panel_pos + eX * column * panel_size_x*(1/columns) + eY * row * panel_size_y*(1/rows);
drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
// draw the weapon accuracy
- if(acc_levels)
+ if(show_accuracy)
{
float weapon_hit, weapon_damage;
weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
#define MAX_ACCURACY_LEVELS 10
float acc_lev[MAX_ACCURACY_LEVELS];
float acc_levels;
+string acc_color_levels;
float complain_weapon;
string complain_weapon_name;
if(getstati(STAT_SWITCHWEAPON) == WEP_MINSTANEX)
g_minstagib = 1; // TODO: real detection for minstagib?
+ if (!acc_levels)
+ rgb = '1 1 1';
+
for(i = WEP_FIRST; i <= WEP_LAST; ++i)
{
self = get_weaponinfo(i);
weapon_stats = floor(100 * weapon_hit / weapon_damage);
}
- // find the max level lower than weapon_stats
- float j;
- j = acc_levels-1;
- while ( j && weapon_stats < acc_lev[j] )
- --j;
-
- // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
- float factor;
- factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
- rgb = acc_color(j);
- rgb = rgb + factor * (acc_color(j+1) - rgb);
+ if (acc_levels)
+ {
+ // find the max level lower than weapon_stats
+ float j;
+ j = acc_levels-1;
+ while ( j && weapon_stats < acc_lev[j] )
+ --j;
+
+ // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
+ float factor;
+ factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
+ rgb = acc_color(j);
+ rgb = rgb + factor * (acc_color(j+1) - rgb);
+ }
drawstring(pos + '1 0 0' * padding + '0 1 0' * height * (2/3), s, '1 1 0' * fontsize, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
}