1 // self.isactive = player is in range and coordinates/status (health and armor) are up to date
2 // self.origin = player origin TODO: should maybe move this so it's the origin of the shownames tag already in SSQC for culling?
5 // self.sameteam = player is on same team as local client
9 if(!autocvar_hud_shownames)
12 if(self.sameteam || (!self.sameteam && autocvar_hud_shownames_enemies))
14 InterpolateOrigin_Do();
18 traceline(self.origin, view_origin, 1, self);
19 if(trace_endpos != view_origin) // fade out
21 self.alpha = max(0, self.alpha - 4 * frametime);
26 self.alpha = min(1, self.alpha + 4 * frametime);
29 /* WIP, why does trace_ent != self not work as intended here?
30 if(autocvar_hud_shownames_enemies != 2) // player has to point at enemy if so
32 traceline(view_origin, view_origin + view_forward * MAX_SHOT_DISTANCE, MOVETYPE_FLY, world);
33 print("trace_endpos: ", vtos(trace_endpos), " view_origin: ", vtos(view_origin), "\n");
39 // otherwise, increase alpha until 1
42 a = autocvar_hud_panel_fg_alpha * self.alpha;
44 // draw the sprite image
46 o = project_3d_to_2d(self.origin);
48 if not(o_z < 0 || o_x < 0 || o_y < 0 || o_x > vid_conwidth || o_y > vid_conheight)
53 mySize = (eX * autocvar_hud_shownames_aspect + eY) * autocvar_hud_shownames_height;
54 myPos = o - '0.5 0 0' * mySize_x - '0 1 0' * mySize_y;
56 vector iconpos, iconsize;
62 if(autocvar_hud_shownames_status)
66 iconsize = eX * 2 * mySize_y + eY * mySize_y;
67 // "ghost" backgrounds
68 drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '0 0 0', a * 0.5, DRAWFLAG_NORMAL);
69 drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor", '1 1 0' * iconsize_y, '0 0 0', a * 0.5, DRAWFLAG_NORMAL);
71 drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, self.healthvalue/autocvar_hud_panel_healtharmor_maxhealth), vid_conwidth, myPos_y + iconsize_y);
72 drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '1 1 1', a, DRAWFLAG_NORMAL);
74 drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, self.armorvalue/autocvar_hud_panel_healtharmor_maxarmor), vid_conwidth, myPos_y + iconsize_y);
75 drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor", '1 1 0' * iconsize_y, '1 1 1', a, DRAWFLAG_NORMAL);
78 else if(autocvar_hud_shownames_status == 2 && teamplay)
80 iconsize = eX * 2 * mySize_y + eY * mySize_y;
81 drawpic_aspect_skin(iconpos, "health_unknown", '1 1 0' * iconsize_y, '0 0 0', a, DRAWFLAG_NORMAL);
82 drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor_unknown", '1 1 0' * iconsize_y, '0 0 0', a, DRAWFLAG_NORMAL);
86 namepos = myPos + eX * 2 * iconsize_y + eY * 0.5 * (autocvar_hud_shownames_height - autocvar_hud_shownames_fontsize);
87 namesize = mySize_x - 2 * iconsize_y;
90 s = GetPlayerName(self.the_entnum-1);
91 s = textShortenToWidth(s, namesize, '1 1 0' * autocvar_hud_shownames_fontsize, stringwidth_colors);
94 width = stringwidth(s, TRUE, '1 1 0' * autocvar_hud_shownames_fontsize);
96 if (width != namesize)
97 namepos_x += (namesize - width) / 2;
98 drawcolorcodedstring(namepos, s, '1 1 0' * autocvar_hud_shownames_fontsize, a, DRAWFLAG_NORMAL);