]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Implement fade delay feature which waits X seconds before beginning to show name...
authorSamual <samual@xonotic.org>
Tue, 30 Aug 2011 08:05:25 +0000 (04:05 -0400)
committerSamual <samual@xonotic.org>
Tue, 30 Aug 2011 08:05:25 +0000 (04:05 -0400)
qcsrc/client/shownames.qc
qcsrc/client/shownames.qh

index 8e13b722dfa47cbbd26a8968ddeda5a0d794aebd..3e9a22cfdb1b34d75077a2d1ca7e8d063984620b 100644 (file)
@@ -3,8 +3,10 @@
 // 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)
@@ -59,19 +61,27 @@ void Draw_ShowNames(entity ent)
                }
 
                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);
 
index 50380e8209531ce2552bd974dbff5e43ac4d8916..d30f1acce3801f0d4b948465fcb518286ac317a7 100644 (file)
@@ -1,4 +1,5 @@
 .float healthvalue;
 .float armorvalue;
 .float sameteam;
+.float fadedelay;