seta crosshair_hittest_showimpact 0 "move the crosshair to the actual impact location if obstructed"
// change color based on special case
-seta crosshair_color_by_health 0 "if enabled, crosshair color will depend on current health"
-seta crosshair_color_per_weapon 1 "when 1, each gun will display the crosshair with a different color"
-
-// change color randomly on a timer
-seta crosshair_rainbow 0
-seta crosshair_rainbow_delay 0.1
-seta crosshair_rainbow_brightness 2 "color brightness of the random crosshair colors"
+seta crosshair_color_special 1 "special color handling for crosshair... 1 = per-weapon crosshair color (see crosshair_per_weapon), 2 = crosshair changes color based on health, 3 = rainbow/random color selection"
+seta crosshair_color_special_rainbow_delay 0.1
+seta crosshair_color_special_rainbow_brightness 2 "color brightness of the random crosshair colors"
// ===============================
float checkfail[16];
-float last_flicker;
-vector previous_color;
+float rainbow_last_flicker;
+vector rainbow_prev_color;
#define BUTTON_3 4
#define BUTTON_4 8
string wcross_wep = "", wcross_name;
float wcross_scale, wcross_blur;
- if (autocvar_crosshair_per_weapon || autocvar_crosshair_color_per_weapon) {
+ if (autocvar_crosshair_per_weapon || (autocvar_crosshair_color_special == 1))
+ {
e = get_weaponinfo(switchingweapon);
if (e && e.netname != "")
{
}
}
}
- if(wcross_wep != "" && autocvar_crosshair_color_per_weapon)
- wcross_color = stov(cvar_string(strcat("crosshair_", wcross_wep, "_color")));
- else if(autocvar_crosshair_color_by_health)
- {
- float x = getstati(STAT_HEALTH);
-
- //x = red
- //y = green
- //z = blue
- wcross_color_z = 0;
+ //print(sprintf("crosshair style: %s\n", wcross_style));
+ wcross_name = strcat("gfx/crosshair", wcross_style);
- if(x > 200)
- {
- wcross_color_x = 0;
- wcross_color_y = 1;
- }
- else if(x > 150)
- {
- wcross_color_x = 0.4 - (x-150)*0.02 * 0.4;
- wcross_color_y = 0.9 + (x-150)*0.02 * 0.1;
- }
- else if(x > 100)
- {
- wcross_color_x = 1 - (x-100)*0.02 * 0.6;
- wcross_color_y = 1 - (x-100)*0.02 * 0.1;
- wcross_color_z = 1 - (x-100)*0.02;
- }
- else if(x > 50)
+ // MAIN CROSSHAIR COLOR DECISION
+ switch(autocvar_crosshair_color_special)
+ {
+ case 1: // crosshair_color_per_weapon
{
- wcross_color_x = 1;
- wcross_color_y = 1;
- wcross_color_z = 0.2 + (x-50)*0.02 * 0.8;
+ if(wcross_wep != "")
+ {
+ wcross_color = stov(cvar_string(sprintf("crosshair_%s_color", wcross_wep)));
+ break;
+ }
+ else { goto normalcolor; }
}
- else if(x > 20)
+
+ case 2: // crosshair_color_by_health
{
- wcross_color_x = 1;
- wcross_color_y = (x-20)*90/27/100;
- wcross_color_z = (x-20)*90/27/100 * 0.2;
+ float x = getstati(STAT_HEALTH);
+
+ //x = red
+ //y = green
+ //z = blue
+
+ wcross_color_z = 0;
+
+ if(x > 200)
+ {
+ wcross_color_x = 0;
+ wcross_color_y = 1;
+ }
+ else if(x > 150)
+ {
+ wcross_color_x = 0.4 - (x-150)*0.02 * 0.4;
+ wcross_color_y = 0.9 + (x-150)*0.02 * 0.1;
+ }
+ else if(x > 100)
+ {
+ wcross_color_x = 1 - (x-100)*0.02 * 0.6;
+ wcross_color_y = 1 - (x-100)*0.02 * 0.1;
+ wcross_color_z = 1 - (x-100)*0.02;
+ }
+ else if(x > 50)
+ {
+ wcross_color_x = 1;
+ wcross_color_y = 1;
+ wcross_color_z = 0.2 + (x-50)*0.02 * 0.8;
+ }
+ else if(x > 20)
+ {
+ wcross_color_x = 1;
+ wcross_color_y = (x-20)*90/27/100;
+ wcross_color_z = (x-20)*90/27/100 * 0.2;
+ }
+ else
+ {
+ wcross_color_x = 1;
+ wcross_color_y = 0;
+ }
+ break;
}
- else
+
+ case 3: // crosshair_color_rainbow
{
- wcross_color_x = 1;
- wcross_color_y = 0;
+ if(time >= rainbow_last_flicker)
+ {
+ rainbow_prev_color = randomvec() * autocvar_crosshair_color_special_rainbow_brightness;
+ rainbow_last_flicker = time + autocvar_crosshair_color_special_rainbow_delay;
+ }
+ wcross_color = rainbow_prev_color;
+ break;
}
+ :normalcolor
+ default: { wcross_color = stov(autocvar_crosshair_color); break; }
}
- else
- wcross_color = stov(autocvar_crosshair_color);
-
- wcross_name = strcat("gfx/crosshair", wcross_style);
if(autocvar_crosshair_effect_scalefade)
{
if(autocvar_crosshair_hitindication)
{
- vector hitindication_color = ((autocvar_crosshair_color_per_weapon) ? stov(autocvar_crosshair_hitindication_per_weapon_color) : stov(autocvar_crosshair_hitindication_color));
+ vector hitindication_color = ((autocvar_crosshair_color_special == 1) ? stov(autocvar_crosshair_hitindication_per_weapon_color) : stov(autocvar_crosshair_hitindication_color));
if(hitindication_crosshair_time < hit_time)
{
if (ring_value)
DrawCircleClippedPic(wcross_origin, wcross_size_x * ring_scale, ring_image, ring_value, ring_rgb, wcross_alpha * ring_alpha, DRAWFLAG_ADDITIVE);
}
-
- if(autocvar_crosshair_rainbow)
- {
- if(time >= last_flicker)
- {
- previous_color = randomvec() * autocvar_crosshair_rainbow_brightness;
- last_flicker = time + autocvar_crosshair_rainbow_delay;
- }
- wcross_color = previous_color;
- }
#define CROSSHAIR_DO_BLUR(M,sz,wcross_name,wcross_alpha) \
do \
string autocvar_crosshair;
float autocvar_crosshair_alpha;
string autocvar_crosshair_color;
-float autocvar_crosshair_color_per_weapon;
+float autocvar_crosshair_color_special;
+var float autocvar_crosshair_color_special_rainbow_brightness = 2;
+var float autocvar_crosshair_color_special_rainbow_delay = 0.1;
float autocvar_crosshair_dot;
float autocvar_crosshair_dot_alpha;
string autocvar_crosshair_dot_color;
float autocvar_crosshair_ring_reload_alpha;
float autocvar_crosshair_ring_reload_size;
float autocvar_crosshair_size;
-float autocvar_crosshair_rainbow;
-var float autocvar_crosshair_rainbow_brightness = 2;
-var float autocvar_crosshair_rainbow_delay = 0.1;
float autocvar_ekg;
float autocvar_fov;
float autocvar_g_balance_damagepush_speedfactor;
float autocvar_g_waypointsprite_timealphaexponent;
var float autocvar_g_waypointsprite_turrets = TRUE;
var float autocvar_g_waypointsprite_turrets_maxdist = 5000;
-
var float autocvar_hud_cursormode = TRUE;
float autocvar_hud_colorflash_alpha;
float autocvar_hud_configure_checkcollisions;
float autocvar_vid_conwidth;
float autocvar_vid_pixelheight;
float autocvar_viewsize;
-float autocvar_crosshair_color_by_health;
float autocvar_cl_hitsound;
float autocvar_cl_hitsound_antispam_time;
var float autocvar_cl_eventchase_death = 1;
me.TR(me);
me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Crosshair color:")));
setDependent(e, "crosshair_enabled", 1, 2);
- me.TD(me, 1, 1, e = makeXonoticRadioButton(5, "crosshair_color_per_weapon", string_null, _("Per weapon")));
+ me.TD(me, 1, 1, e = makeXonoticRadioButton(5, "crosshair_color_special", "1", _("Per weapon")));
setDependent(e, "crosshair_enabled", 1, 2);
- me.TD(me, 1, 1, e = makeXonoticRadioButton(5, "crosshair_color_by_health", string_null, _("By health")));
+ me.TD(me, 1, 1, e = makeXonoticRadioButton(5, "crosshair_color_special", "2", _("By health")));
setDependent(e, "crosshair_enabled", 1, 2);
me.TR(me);
me.TDempty(me, 0.1);
- me.TD(me, 1, 0.9, e = makeXonoticRadioButton(5, string_null, string_null, _("Custom")));
+ me.TD(me, 1, 0.9, e = makeXonoticRadioButton(5, "crosshair_color_special", "0", _("Custom")));
setDependent(e, "crosshair_enabled", 1, 2);
me.TD(me, 2, 2, e = makeXonoticColorpickerString("crosshair_color", "crosshair_color"));
- setDependentAND3(e, "crosshair_color_per_weapon", 0, 0, "crosshair_color_by_health", 0, 0, "crosshair_enabled", 1, 2);
+ setDependentAND(e, "crosshair_color_special", 0, 0, "crosshair_enabled", 1, 2);
me.TR(me);
me.TR(me);
me.TR(me);