]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/shownames.qc
Merge branch 'master' into divVerent/csqcmodel
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / shownames.qc
index 3e9a22cfdb1b34d75077a2d1ca7e8d063984620b..21e8bcd420799ac3688e938abcefcc780cf67fd4 100644 (file)
@@ -4,25 +4,27 @@
 // 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)
                return;
-
-       if((ent.sv_entnum == player_localentnum) && !(autocvar_hud_shownames_self && 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);
 
        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;
                }
@@ -35,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
@@ -61,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;