1 // playerslots[i].isactive = player is in range and coordinates/status (health and armor) are up to date
2 // playerslots[i].origin = player origin TODO: should maybe move this so it's the origin of the shownames tag already in SSQC for culling?
3 // playerslots[i].healthvalue
4 // playerslots[i].armorvalue
5 // playerslots[i].sameteam = player is on same team as local client
9 if(!autocvar_hud_shownames)
13 for(i = 0; i <= 255; ++i) // 255 players is engine limit
15 if(playerslots[i].isactive) // are the player coordinates/status current?
16 if(playerslots[i].sameteam || (!playerslots[i].sameteam && autocvar_hud_shownames_enemies))
21 a = autocvar_hud_panel_fg_alpha;
23 t = GetPlayerColor(player_localentnum - 1) + 1;
26 dist = vlen(self.origin - view_origin);
29 if(self.maxdistance > waypointsprite_normdistance)
30 a *= pow(bound(0, (self.maxdistance - dist) / (self.maxdistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent);
31 else if(self.maxdistance > 0)
32 a *= pow(bound(0, (waypointsprite_fadedistance - dist) / (waypointsprite_fadedistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent) * (1 - waypointsprite_minalpha) + waypointsprite_minalpha;
39 self = playerslots[i];
40 InterpolateOrigin_Do();
43 // draw the sprite image
45 o = project_3d_to_2d(playerslots[i].origin);
50 mySize = (eX * autocvar_hud_shownames_aspect + eY) * autocvar_hud_shownames_height;
51 myPos = o - '0.5 0 0' * mySize_x - '0 1 0' * mySize_y;
53 vector iconpos, iconsize;
54 vector namepos, namesize;
58 if(autocvar_hud_shownames_status)
60 if(playerslots[i].sameteam)
62 iconsize = eX * 2 * mySize_y + eY * mySize_y;
63 // "ghost" backgrounds
64 drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '0 0 0', a * 0.5, DRAWFLAG_NORMAL);
65 drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor", '1 1 0' * iconsize_y, '0 0 0', a * 0.5, DRAWFLAG_NORMAL);
67 drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, playerslots[i].healthvalue/autocvar_hud_panel_healtharmor_maxhealth), vid_conwidth, myPos_y + iconsize_y);
68 drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '1 1 1', a, DRAWFLAG_NORMAL);
70 drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, playerslots[i].armorvalue/autocvar_hud_panel_healtharmor_maxarmor), vid_conwidth, myPos_y + iconsize_y);
71 drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor", '1 1 0' * iconsize_y, '1 1 1', a, DRAWFLAG_NORMAL);
74 else if(autocvar_hud_shownames_status == 2)
76 iconsize = eX * 2 * mySize_y + eY * mySize_y;
77 drawpic_aspect_skin(iconpos, "health_unknown", '1 1 0' * iconsize_y, '0 0 0', a, DRAWFLAG_NORMAL);
78 drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor_unknown", '1 1 0' * iconsize_y, '0 0 0', a, DRAWFLAG_NORMAL);
82 namepos = myPos + eX * 2 * iconsize_y;
83 namesize = eX * mySize_x - eX * 2 * iconsize_y + eY * mySize_y;
85 drawcolorcodedstring_aspect(namepos, GetPlayerName(i), namesize, a, DRAWFLAG_NORMAL);
87 /* Or maybe a health bar instead?
92 if(self.build_finished)
96 drawhealthbar(o, rot * 90 * DEG2RAD, self.health, SPRITE_SIZE * t, SPRITE_HOTSPOT * t, SPRITE_HEALTHBAR_WIDTH * t, SPRITE_HEALTHBAR_HEIGHT * t, SPRITE_HEALTHBAR_MARGIN * t, SPRITE_HEALTHBAR_BORDER * t, align, self.teamradar_color, a * SPRITE_HEALTHBAR_BORDERALPHA, self.teamradar_color, a * SPRITE_HEALTHBAR_HEALTHALPHA, DRAWFLAG_NORMAL);