From a292d49abc077c24065db02c84b1c26d3f893cc3 Mon Sep 17 00:00:00 2001 From: terencehill Date: Wed, 14 Feb 2024 23:27:15 +0100 Subject: [PATCH] HUD hit indicator: bound cl_hit_indicator_fade_alpha and cl_hit_indicator_fade_time to acceptable values --- qcsrc/client/view.qc | 8 +++++--- qcsrc/client/view.qh | 1 + xonotic-client.cfg | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index b2524b455..211076f83 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -753,10 +753,12 @@ void View_EventChase(entity this) } } -#define HITINDICATOR_EXPIRED(i) (time >= HitIndicator_time[i] + autocvar_cl_hit_indicator_fade_time) +#define HITINDICATOR_EXPIRED(i) (time >= HitIndicator_time[i] + HitIndicator_fade_time) void HitIndicatorUpdate(float dmg, entity attacker) { + HitIndicator_fade_time = bound(0.1, autocvar_cl_hit_indicator_fade_time, 2); + int i = 0; int first_free_spot = -1; for (i = 0; i < HITINDICATOR_MAX_COUNT; ++i) @@ -811,8 +813,8 @@ void HitIndicatorShow() ofs = -ofs; } org = scr_center + ofs; - float alpha = autocvar_cl_hit_indicator_fade_alpha; - alpha *= 1 - (time - HitIndicator_time[i]) / autocvar_cl_hit_indicator_fade_time; + float alpha = bound(0, autocvar_cl_hit_indicator_fade_alpha, 1); + 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); diff --git a/qcsrc/client/view.qh b/qcsrc/client/view.qh index 73412793e..758653d6a 100644 --- a/qcsrc/client/view.qh +++ b/qcsrc/client/view.qh @@ -103,6 +103,7 @@ const int HITINDICATOR_MAX_COUNT = 10; entity HitIndicator_attacker[HITINDICATOR_MAX_COUNT]; float HitIndicator_damage[HITINDICATOR_MAX_COUNT]; int HitIndicator_time[HITINDICATOR_MAX_COUNT]; +float HitIndicator_fade_time; void calc_followmodel_ofs(entity view); diff --git a/xonotic-client.cfg b/xonotic-client.cfg index 3815bddda..be016c423 100644 --- a/xonotic-client.cfg +++ b/xonotic-client.cfg @@ -202,7 +202,7 @@ 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_fade_time 1.5 "how long hit indicator takes to fade away" +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" -- 2.39.2