From c2b48cf601a4ab170bdc809a052d1abab6ba7f83 Mon Sep 17 00:00:00 2001 From: Samual Date: Thu, 20 Oct 2011 00:29:35 -0400 Subject: [PATCH] New feature for hud_shownames: crosshairdistance - Basically, when enabled only show tags for players who are within X ddistance of your crosshair. This essentially simulates nearly the same behavior as old cl_shownames functionality... Some players may want this to not see too much clutter all the time. --- _hud_common.cfg | 7 +++++-- qcsrc/client/autocvars.qh | 3 +++ qcsrc/client/shownames.qc | 25 ++++++++++++++++++++----- qcsrc/client/shownames.qh | 2 +- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/_hud_common.cfg b/_hud_common.cfg index 1f14c116f..c46bbee71 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -73,7 +73,10 @@ seta hud_contents_water_alpha 0.5 "alpha of the water" seta hud_contents_water_color "0.4 0.3 0.3" "color blend when inside water" seta hud_shownames 1 "draw names and health/armor of nearby players" -seta hud_shownames_enemies 2 "1 = draw names of enemies you point at (TODO), 2 = draw names of all enemies in view" +seta hud_shownames_enemies 1 "show tags for enemies as well" +seta hud_shownames_crosshairdistance 0 "if set, only draw tags which came within this distance of your crosshair (25 recommended)" +seta hud_shownames_crosshairdistance_time 5 "how many seconds the tag is still visible after pointing at them" +seta hud_shownames_crosshairdistance_antioverlap 0 "allow antioverlap to work as normal even with crosshairdistance on" seta hud_shownames_self 0 "also include your own name to be shown when third person camera mode is on (chase_active/cl_eventchase)" seta hud_shownames_status 1 "1 = draw health/armor status of teammates" seta hud_shownames_statusbar_height 4 "height of status bar" @@ -85,5 +88,5 @@ seta hud_shownames_resize 1 "enable resizing of the names, then the size cvars w seta hud_shownames_mindistance 1000 "start fading alpha/size at this distance" seta hud_shownames_maxdistance 5000 "alpha/size is 0 at this distance" seta hud_shownames_antioverlap 1 "if two tags get too close to each other, fade out the one further away from you" -seta hud_shownames_antioverlap_distance 100 "2d distance to other tag after which to fade out" +seta hud_shownames_antioverlap_distance 50 "2d distance to other tag after which to fade out" seta hud_shownames_offset 52 "offset (along z-axis) tag from player origin by this many units" \ No newline at end of file diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index 897bb24e7..b0a11ad18 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -319,6 +319,9 @@ float autocvar_hud_showbinds; float autocvar_hud_showbinds_limit; float autocvar_hud_shownames; float autocvar_hud_shownames_enemies; +float autocvar_hud_shownames_crosshairdistance; +float autocvar_hud_shownames_crosshairdistance_time; +float autocvar_hud_shownames_crosshairdistance_antioverlap; float autocvar_hud_shownames_self; float autocvar_hud_shownames_status; float autocvar_hud_shownames_statusbar_height; diff --git a/qcsrc/client/shownames.qc b/qcsrc/client/shownames.qc index b13f6122c..21e8bcd42 100644 --- a/qcsrc/client/shownames.qc +++ b/qcsrc/client/shownames.qc @@ -4,9 +4,10 @@ // self.armorvalue // self.sameteam = player is on same team as local client // self.fadedelay = time to wait before name tag starts fading in for enemies +// self.pointtime = last time you pointed at this player // const float SHOWNAMES_FADESPEED = 4; -const float SHOWNAMES_FADEDELAY = 0.5; +const float SHOWNAMES_FADEDELAY = 0.4; void Draw_ShowNames(entity ent) { if(!autocvar_hud_shownames) @@ -21,9 +22,9 @@ void Draw_ShowNames(entity ent) if(ent.sameteam || (!ent.sameteam && autocvar_hud_shownames_enemies)) { ent.origin_z += autocvar_hud_shownames_offset; - + float hit; - if(ent.sameteam) + if(ent.sameteam && !autocvar_hud_shownames_crosshairdistance) { hit = 1; } @@ -36,10 +37,12 @@ void Draw_ShowNames(entity ent) hit = 1; } + // handle tag fading + float overlap, onscreen, crosshairdistance; vector o, eo; + o = project_3d_to_2d(ent.origin); - float overlap, onscreen; - + if(autocvar_hud_shownames_antioverlap) { // fade tag out if another tag that is closer to you overlaps @@ -62,6 +65,18 @@ void Draw_ShowNames(entity ent) } onscreen = (o_z >= 0 && o_x >= 0 && o_y >= 0 && o_x <= vid_conwidth && o_y <= vid_conheight); + crosshairdistance = sqrt( pow(o_x - vid_conwidth/2, 2) + pow(o_y - vid_conheight/2, 2) ); + + if(autocvar_hud_shownames_crosshairdistance) + { + if(autocvar_hud_shownames_crosshairdistance > crosshairdistance) + ent.pointtime = time; + + if not(ent.pointtime + autocvar_hud_shownames_crosshairdistance_time > time) + overlap = TRUE; + else + overlap = (autocvar_hud_shownames_crosshairdistance_antioverlap ? overlap : FALSE); // override what antioverlap says unless allowed by cvar. + } if(!ent.fadedelay) ent.fadedelay = time + SHOWNAMES_FADEDELAY; diff --git a/qcsrc/client/shownames.qh b/qcsrc/client/shownames.qh index d30f1acce..adbfa5712 100644 --- a/qcsrc/client/shownames.qh +++ b/qcsrc/client/shownames.qh @@ -2,4 +2,4 @@ .float armorvalue; .float sameteam; .float fadedelay; - +.float pointtime; -- 2.39.2