// 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)
}
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);