seta hud_weaponicons_number 1 "1 = show number of weapon, 2 = show bound key of weapon"
seta hud_weaponicons_complainbubble_time 1 "time that a new entry stays until it fades out"
seta hud_weaponicons_complainbubble_fadetime 0.25 "fade out time"
-seta hud_weaponicons_accuracy 1 "show accuracy as the weapon icon background"
-seta hud_weaponicons_accuracy_yellow 20 "percentage at which the accuracy color is yellow"
+seta hud_weaponicons_accuracy 1 "show accuracy color as the weapon icon background"
+seta hud_weaponicons_accuracy_color0 "1 0 0"
+seta hud_weaponicons_accuracy_color1 "1 1 0"
+seta hud_weaponicons_accuracy_color2 "0 1 0"
+seta hud_weaponicons_accuracy_color_levels "0 20 100" "accuracy values at which a specified color (hud_weaponicons_accuracy_color<X>) will be used. If your accuracy is between 2 of these values then a mix of the Xth and X+1th colors will be used. You can specify up to 10 values, in increasing order"
seta hud_weaponicons_ammo 1 "show ammo as a status bar"
seta hud_weaponicons_ammo_full_shells 40 "show 100% of the status bar at this ammo count"
seta hud_weaponicons_ammo_full_nails 100 "show 100% of the status bar at this ammo count"
}
}
+#define MAX_ACCURACY_LEVELS 10 // including implict levels 0 and 100
+float acc_lev[MAX_ACCURACY_LEVELS];
+
void HUD_WeaponIcons(void)
{
if(!autocvar_hud_weaponicons && !autocvar__hud_configure)
vector color;
vector wpnpos;
vector wpnsize;
+
+ float acc_levels;
+ if(autocvar_hud_weaponicons_accuracy && !(gametype == GAME_RACE || gametype == GAME_CTS))
+ {
+ acc_levels = tokenize(cvar_string("hud_weaponicons_accuracy_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));
+ }
+
for(i = 0; i < weapon_cnt; ++i)
{
wpnpos = pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_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(autocvar_hud_weaponicons_accuracy && !(gametype == GAME_RACE || gametype == GAME_CTS))
+ if(acc_levels)
{
if(weapon_damage)
weapon_stats = floor(100 * weapon_hit / weapon_damage);
- // yellow_accuracy = value at which accuracy becomes yellow
- if(weapon_stats >= 100) {
- color_x = 0;
- color_y = 1;
- }
- else if(weapon_stats > autocvar_hud_weaponicons_accuracy_yellow) {
- color_x = 1 - (weapon_stats-autocvar_hud_weaponicons_accuracy_yellow)/(100-autocvar_hud_weaponicons_accuracy_yellow); // red value between 1 -> 0
- color_y = 1;
- } else {
- color_x = 1;
- color_y = weapon_stats/autocvar_hud_weaponicons_accuracy_yellow; // green value between 0 -> 1
- }
- color_z = 0;
+ if (cvar("acc_colors_debug") >= 0)
+ weapon_stats = cvar("acc_colors_debug"); // TEST
+
+ // find the max level lower than weapon_stats
+ float j;
+ j = acc_levels-1;
+ while ( j && weapon_stats < acc_lev[j] )
+ --j;
+
+#define acc_color(i) stov(cvar_string(strcat("hud_weaponicons_accuracy_color", ftos(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);
if(weapon_damage)
drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);