- 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;
-
- if(!ent.sameteam && (!onscreen || !hit)) // out of view, fade out
- {
- ent.alpha = max(0, ent.alpha - SHOWNAMES_FADESPEED * frametime);
- ent.fadedelay = 0; // reset fade in delay, enemy has left the view
- }
- else if(ent.csqcmodel_isdead) // dead player, fade out slowly
- 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 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);
-
- // multiply by player alpha
- if(!ent.sameteam || (ent.sv_entnum == player_localentnum))
- ent.alpha *= getplayeralpha(ent.sv_entnum-1);
-
- if(ent.alpha < ALPHA_MIN_VISIBLE && gametype != MAPINFO_TYPE_CTS)
- return;
-
- float dist;
- dist = vlen(ent.origin - view_origin);
-
- float a;
- a = autocvar_hud_shownames_alpha;
- a *= ent.alpha;
- if(autocvar_hud_shownames_maxdistance)
- {
- if(dist >= autocvar_hud_shownames_maxdistance)
- return;
- a *= ((autocvar_hud_shownames_maxdistance - autocvar_hud_shownames_mindistance) - max(0, dist - autocvar_hud_shownames_mindistance)) / (autocvar_hud_shownames_maxdistance - autocvar_hud_shownames_mindistance);
- }
-
- if(!a)
- return;
-
- float resize;
- resize = 1;
- if(autocvar_hud_shownames_resize) // limit resize so its never smaller than 0.5... gets unreadable
- resize = 0.5 + 0.5 * ((autocvar_hud_shownames_maxdistance - autocvar_hud_shownames_mindistance) - max(0, dist - autocvar_hud_shownames_mindistance)) / (autocvar_hud_shownames_maxdistance - autocvar_hud_shownames_mindistance);
-
- // draw the sprite image
- if(o.z >= 0)
+ break;
+ }
+ });
+ }
+ bool onscreen = (o.z >= 0 && o.x >= 0 && o.y >= 0 && o.x <= vid_conwidth && o.y <= vid_conheight);
+ if (autocvar_hud_shownames_crosshairdistance)
+ {
+ float d = autocvar_hud_shownames_crosshairdistance;
+ float w = o.x - vid_conwidth / 2;
+ float h = o.y - vid_conheight / 2;
+ if (d * d > w * w + h * h) this.pointtime = time;
+ if (this.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 (!this.fadedelay) this.fadedelay = time + SHOWNAMES_FADEDELAY;
+ if (this.csqcmodel_isdead) // dead player, fade out slowly
+ {
+ this.alpha = max(0, this.alpha - SHOWNAMES_FADESPEED * 0.25 * frametime);
+ }
+ else if (!onscreen || (!this.sameteam && !hit)) // out of view, fade out
+ {
+ this.alpha = max(0, this.alpha - SHOWNAMES_FADESPEED * frametime);
+ this.fadedelay = 0; // reset fade in delay, enemy has left the view
+ }
+ else if (overlap) // tag overlap detected, fade out
+ {
+ this.alpha = max(0, this.alpha - SHOWNAMES_FADESPEED * frametime);
+ }
+ else if (this.sameteam) // fade in for team mates
+ {
+ this.alpha = min(1, this.alpha + SHOWNAMES_FADESPEED * frametime);
+ }
+ else if (time > this.fadedelay) // fade in for enemies
+ {
+ this.alpha = min(1, this.alpha + SHOWNAMES_FADESPEED * frametime);
+ }
+ float a = autocvar_hud_shownames_alpha * this.alpha;
+ // multiply by player alpha
+ if (!this.sameteam || (this.sv_entnum == player_localentnum))
+ {
+ float f = entcs_GetAlpha(this.sv_entnum - 1);
+ if (f == 0) f = 1;
+ if (f < 0) f = 0;
+ // FIXME: alpha is negative when dead, breaking death fade
+ if (!this.csqcmodel_isdead) a *= f;
+ }
+ if (a < ALPHA_MIN_VISIBLE && gametype != MAPINFO_TYPE_CTS) return;
+ if (autocvar_hud_shownames_maxdistance)
+ {
+ if (dist >= autocvar_hud_shownames_maxdistance) return;
+ float f = autocvar_hud_shownames_maxdistance - autocvar_hud_shownames_mindistance;
+ a *= (f - max(0, dist - autocvar_hud_shownames_mindistance)) / f;
+ }
+ if (!a) return;
+ float resize = 1;
+ if (autocvar_hud_shownames_resize) // limit resize so its never smaller than 0.5... gets unreadable
+ {
+ float f = autocvar_hud_shownames_maxdistance - autocvar_hud_shownames_mindistance;
+ resize = 0.5 + 0.5 * (f - max(0, dist - autocvar_hud_shownames_mindistance)) / f;
+ }
+ // draw the sprite image
+ if (o.z >= 0)
+ {
+ o.z = 0;
+ vector mySize = (eX * autocvar_hud_shownames_aspect + eY) * autocvar_hud_shownames_fontsize;
+ vector myPos = o - '0.5 0 0' * mySize.x - '0 1 0' * mySize.y;
+ // size scaling
+ mySize.x *= resize;
+ mySize.y *= resize;
+ myPos.x += 0.5 * (mySize.x / resize - mySize.x);
+ myPos.y += (mySize.y / resize - mySize.y);
+ // this is where the origin of the string
+ vector namepos = myPos;
+ float namewidth = mySize.x;
+ if (autocvar_hud_shownames_status && this.sameteam)