From: terencehill Date: Sat, 17 Feb 2024 16:06:57 +0000 (+0100) Subject: HUD hit indicator: allow displaying damage text together with the hit indicator ... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=74dec6c90f4c901a10cb108eb8138d041978cafb;p=xonotic%2Fxonotic-data.pk3dir.git HUD hit indicator: allow displaying damage text together with the hit indicator (disabled by default) --- diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 5294e99c6..0736ca4ec 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -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); + } } } diff --git a/qcsrc/client/view.qh b/qcsrc/client/view.qh index 758653d6a..d8312146c 100644 --- a/qcsrc/client/view.qh +++ b/qcsrc/client/view.qh @@ -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]; diff --git a/xonotic-client.cfg b/xonotic-client.cfg index be016c423..22c38fed1 100644 --- a/xonotic-client.cfg +++ b/xonotic-client.cfg @@ -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"