]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
HUD hit indicator: allow displaying damage text together with the hit indicator ...
authorterencehill <piuntn@gmail.com>
Sat, 17 Feb 2024 16:06:57 +0000 (17:06 +0100)
committerterencehill <piuntn@gmail.com>
Sat, 17 Feb 2024 16:06:57 +0000 (17:06 +0100)
qcsrc/client/view.qc
qcsrc/client/view.qh
xonotic-client.cfg

index 5294e99c67269275634011b3182419e4da6148e4..0736ca4ec4518270f64f7e41eb637aab675b1e17 100644 (file)
@@ -832,7 +832,16 @@ void HitIndicatorShow()
                alpha *= 1 - (time - HitIndicator_time[i]) / HitIndicator_fade_time;
                float size = autocvar_cl_hit_indicator_size;
                size = map_bound_ranges(HitIndicator_damage[i], 30, 90, size, size * 2);
-               drawspritearrow(org, ang, '1 0 0', alpha, size, true);
+               org = drawspritearrow(org, ang, autocvar_cl_hit_indicator_color, alpha, size, true);
+
+               if (autocvar_cl_hit_indicator_text)
+               {
+                       string text = ftos(HitIndicator_damage[i]);
+                       vector t_size = autocvar_cl_hit_indicator_text_size * '1 1 0';
+                       org.x += map_ranges(ofs.x, -radius, radius, 0, -1) * stringwidth(text, false, t_size);
+                       org.y -= t_size.y * 0.5;
+                       drawstring_builtin(org, text, t_size, autocvar_cl_hit_indicator_text_color, alpha, DRAWFLAG_NORMAL);
+               }
        }
 }
 
index 758653d6abbca45ad4afe4cb980b2ace1897b0b7..d8312146cddb46d50419b5a236234fa258214da1 100644 (file)
@@ -95,10 +95,14 @@ bool autocvar_r_drawviewmodel;
 vector autocvar_cl_gunoffset;
 
 bool autocvar_cl_hit_indicator = 1;
+vector autocvar_cl_hit_indicator_color = '1 0 0';
 float autocvar_cl_hit_indicator_fade_alpha = 0.8;
 float autocvar_cl_hit_indicator_fade_time = 1.5;
 float autocvar_cl_hit_indicator_radius = 0.15;
 float autocvar_cl_hit_indicator_size = 1.1;
+bool autocvar_cl_hit_indicator_text;
+vector autocvar_cl_hit_indicator_text_color = '1 0.5 0.5';
+float autocvar_cl_hit_indicator_text_size = 11;
 const int HITINDICATOR_MAX_COUNT = 10;
 entity HitIndicator_attacker[HITINDICATOR_MAX_COUNT];
 float HitIndicator_damage[HITINDICATOR_MAX_COUNT];
index be016c423235efc63436322215860a024ae2a7c9..22c38fed1f30d1521603d508bcfb030437877444 100644 (file)
@@ -202,10 +202,14 @@ seta cl_voice_directional 1       "0 = all voices are non-directional, 1 = all voices
 seta cl_voice_directional_taunt_attenuation 0.5 "this defines the distance from which taunts can be heard"
 
 seta cl_hit_indicator 1 "show a 2d directional indicator around the screen center when a player hits you"
+seta cl_hit_indicator_color "1 0 0" "hit indicator color"
 seta cl_hit_indicator_fade_time 1.5 "how long hit indicator takes to fade away in seconds (max 2 seconds)"
 seta cl_hit_indicator_fade_alpha 0.8 "initial hit indicator alpha"
 seta cl_hit_indicator_radius 0.15 "show the directional indicator at this percentage of the screen from the center"
 seta cl_hit_indicator_size 1.1 "hit indicator size"
+seta cl_hit_indicator_text 0 "show damage text together with the hit indicator"
+seta cl_hit_indicator_text_color "1 0.5 0.5" "hit indicator text color"
+seta cl_hit_indicator_text_size 11 "hit indicator text size"
 
 seta cl_hitsound 1 "play a hit notifier sound when you have hit an enemy, 1: same pitch 2: decrease pitch with more damage 3: increase pitch with more damage"
 set cl_hitsound_antispam_time 0.05 "don't play the hitsound more often than this"