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_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"
seta hud_shownames_aspect 8 "aspect ratio of total drawing area per name"
float autocvar_hud_showbinds_limit;
float autocvar_hud_shownames;
float autocvar_hud_shownames_enemies;
+float autocvar_hud_shownames_self;
float autocvar_hud_shownames_status;
float autocvar_hud_shownames_statusbar_height;
float autocvar_hud_shownames_aspect;
// self.healthvalue
// 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
//
const float SHOWNAMES_FADESPEED = 4;
+const float SHOWNAMES_FADEDELAY = 0.5;
void Draw_ShowNames(entity ent)
{
if(!autocvar_hud_shownames)
return;
-
- if(ent.sv_entnum == player_localentnum && !autocvar_chase_active)
- return;
+
+ if((ent.sv_entnum == player_localentnum) || (ent.sv_entnum == spectatee_status)) // ent is me or person i'm spectating
+ if not (autocvar_hud_shownames_self && autocvar_chase_active)
+ return;
makevectors(view_angles);
}
onscreen = (o_z >= 0 && o_x >= 0 && o_y >= 0 && o_x <= vid_conwidth && o_y <= vid_conheight);
+
+ if(!ent.fadedelay)
+ ent.fadedelay = time + SHOWNAMES_FADEDELAY;
if(!ent.sameteam && (!onscreen || !hit)) // out of view, fade out
- ent.alpha = max(0, ent.alpha - SHOWNAMES_FADESPEED * frametime);
+ {
+ ent.alpha = max(0, ent.alpha - SHOWNAMES_FADESPEED * frametime);
+ ent.fadedelay = 0; // reset fade in delay, enemy has left the view
+ }
else if(ent.healthvalue < 1) // dead player, fade out slowly
- ent.alpha = max(0, ent.alpha - SHOWNAMES_FADESPEED * 0.25 * frametime);
+ ent.alpha = max(0, ent.alpha - SHOWNAMES_FADESPEED * 0.25 * frametime);
else if(overlap) // tag overlap detected, fade out
- ent.alpha = max(0, ent.alpha - SHOWNAMES_FADESPEED * frametime);
- else // fade in
+ ent.alpha = max(0, ent.alpha - SHOWNAMES_FADESPEED * frametime);
+ else if(ent.sameteam) // fade in for team mates
+ ent.alpha = min(1, ent.alpha + SHOWNAMES_FADESPEED * frametime);
+ else if(time > ent.fadedelay) // fade in for enemies
ent.alpha = min(1, ent.alpha + SHOWNAMES_FADESPEED * frametime);
if(!ent.alpha)
return;
-
+
float dist;
dist = vlen(ent.origin - view_origin);