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))
{
- if(acc_color_levels)
- strunzone(acc_color_levels);
- acc_color_levels = strzone(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;
-
- for (i = 0; i < acc_levels; ++i)
- acc_lev[i] = stof(argv(i));
+ if(cvar_string("hud_panel_weapons_accuracy_color_levels") != acc_color_levels)
+ {
+ if(acc_color_levels)
+ strunzone(acc_color_levels);
+ acc_color_levels = strzone(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;
+
+ for (i = 0; i < acc_levels; ++i)
+ acc_lev[i] = stof(argv(i));
+ }
+ // let know that acc_col[] needs to be loaded
+ acc_col_x[0] = -1;
}
HUD_Main(); // always run these functions for alpha checks
float show_accuracy;
if(cvar("hud_panel_weapons_accuracy") && acc_levels)
+ {
+ if (acc_col_x[0] == -1)
+ for (i = 0; i < acc_levels; ++i)
+ acc_col[i] = stov(cvar_string(strcat("hud_panel_weapons_accuracy_color", ftos(i))));
show_accuracy = true;
+ }
float label = cvar("hud_panel_weapons_label");
for(i = 0; i < weapon_cnt; ++i)
// 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]);
- color = acc_color(j);
- color = color + factor * (acc_color(j+1) - color);
+ color = acc_col[j];
+ color = color + factor * (acc_col[j+1] - color);
if(weapon_damage)
drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
float weapon_hits[WEP_MAXCOUNT];
float weapon_fired[WEP_MAXCOUNT];
-#define acc_color(i) stov(cvar_string(strcat("hud_panel_weapons_accuracy_color", ftos(i))))
#define MAX_ACCURACY_LEVELS 10
float acc_lev[MAX_ACCURACY_LEVELS];
+vector acc_col[MAX_ACCURACY_LEVELS];
float acc_levels;
string acc_color_levels;
if (!acc_levels)
rgb = '1 1 1';
+ else if (acc_col_x[0] == -1)
+ for (i = 0; i < acc_levels; ++i)
+ acc_col[i] = stov(cvar_string(strcat("hud_panel_weapons_accuracy_color", ftos(i))));
for(i = WEP_FIRST; i <= WEP_LAST; ++i)
{
// 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);
+ rgb = acc_col[j];
+ rgb = rgb + factor * (acc_col[j+1] - rgb);
}
drawstring(pos + '1 0 0' * padding + '0 1 0' * weapon_height, s, '1 1 0' * fontsize, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL);