1 void Draw_WaypointSprite()
3 if(!autocvar_hud_shownames)
10 self.alpha = pow(bound(0, (self.fadetime - time) / self.lifetime, 1), waypointsprite_timealphaexponent);
14 if(self.hideflags & 2)
17 if(autocvar_cl_hidewaypoints >= 2)
20 if(self.hideflags & 1)
21 if(autocvar_cl_hidewaypoints)
22 return; // fixed waypoint
24 InterpolateOrigin_Do();
26 t = GetPlayerColor(player_localentnum - 1) + 1;
33 case SPRITERULE_DEFAULT:
37 spriteimage = self.netname;
42 spriteimage = self.netname;
44 case SPRITERULE_TEAMPLAY:
45 if(t == COLOR_SPECTATOR + 1)
46 spriteimage = self.netname3;
47 else if(self.team == t)
48 spriteimage = self.netname2;
50 spriteimage = self.netname;
53 error("Invalid waypointsprite rule!");
61 dist = vlen(self.origin - view_origin);
64 a = self.alpha * autocvar_hud_panel_fg_alpha;
66 if(self.maxdistance > waypointsprite_normdistance)
67 a *= pow(bound(0, (self.maxdistance - dist) / (self.maxdistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent);
68 else if(self.maxdistance > 0)
69 a *= pow(bound(0, (waypointsprite_fadedistance - dist) / (waypointsprite_fadedistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent) * (1 - waypointsprite_minalpha) + waypointsprite_minalpha;
74 // draw the sprite image
77 o = project_3d_to_2d(self.origin);
80 if(o_z < 0 || o_x < 0 || o_y < 0 || o_x > vid_conwidth || o_y > vid_conheight)
82 // scale it to be just in view
86 // get the waypoint angle vector
88 d_x = view_right * (self.origin - view_origin) * vid_conwidth / vid_width;
89 d_y = -view_up * (self.origin - view_origin) * vid_conheight / (vid_height * vid_pixelheight);
93 d = o - '0.5 0 0' * vid_conwidth - '0 0.5 0' * vid_conheight;
96 if(autocvar_v_flipped)
100 f1 = d_x / vid_conwidth;
101 f2 = d_y / vid_conheight;
103 if(max(f1, -f1) > max(f2, -f2))
134 o = d + '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
139 vidscale = max(vid_conwidth / vid_width, vid_conheight / vid_height);
141 t = stof(db_get(tempdb, strcat("/spriteframes/", spriteimage)));
143 spriteimage = strcat("models/sprites/", spriteimage);
145 spriteimage = strcat("models/sprites/", spriteimage, "_frame", ftos(mod(floor((max(0, time - self.spawntime)) * 2), t)));
147 float edgedistance_min, crosshairdistance;
148 edgedistance_min = min4(o_y, o_x,vid_conwidth - o_x, vid_conheight - o_y);
150 crosshairdistance = sqrt( pow(o_x - vid_conwidth/2, 2) + pow(o_y - vid_conheight/2, 2) );
152 t = waypointsprite_scale * vidscale;
153 a *= waypointsprite_alpha;
156 a = a * (1 - (1 - waypointsprite_distancefadealpha) * (bound(0, dist/waypointsprite_distancefadedistance, 1)));
157 t = t * (1 - (1 - waypointsprite_distancefadescale) * (bound(0, dist/waypointsprite_distancefadedistance, 1)));
159 if (edgedistance_min < waypointsprite_edgefadedistance) {
160 a = a * (1 - (1 - waypointsprite_edgefadealpha) * (1 - bound(0, edgedistance_min/waypointsprite_edgefadedistance, 1)));
161 t = t * (1 - (1 - waypointsprite_edgefadescale) * (1 - bound(0, edgedistance_min/waypointsprite_edgefadedistance, 1)));
163 if(crosshairdistance < waypointsprite_crosshairfadedistance) {
164 a = a * (1 - (1 - waypointsprite_crosshairfadealpha) * (1 - bound(0, crosshairdistance/waypointsprite_crosshairfadedistance, 1)));
165 t = t * (1 - (1 - waypointsprite_crosshairfadescale) * (1 - bound(0, crosshairdistance/waypointsprite_crosshairfadedistance, 1)));
167 drawrotpic(o, rot * 90 * DEG2RAD, spriteimage, SPRITE_SIZE * t, SPRITE_HOTSPOT * t, '1 1 1', a, DRAWFLAG_MIPMAP);
169 if(self.build_finished)
171 if(time < self.build_finished + 0.25)
173 if(time < self.build_started)
174 self.health = self.build_starthealth;
175 else if(time < self.build_finished)
176 self.health = (time - self.build_started) / (self.build_finished - self.build_started) * (1 - self.build_starthealth) + self.build_starthealth;
187 if(self.build_finished)
191 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);
195 float shownames_alpha;
196 void HUD_ShowNames(void)
198 // for each playerslot etc
200 vector iconpos, iconsize;
201 vector namepos, namesize;
202 if(mySize_x/mySize_y > 6)
205 iconsize = eX * 2 * mySize_y + eY * mySize_y;
207 namepos = myPos + eX * 2 * mySize_y;
208 namesize = eX * mySize_x - eX * 2 * mySize_y + eY * mySize_y;
212 iconpos = myPos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_y;
213 iconsize = eX * mySize_y + eY * 0.5 * mySize_y;
215 namepos = myPos + eY * 0.5 * mySize_y;
216 namesize = eX * mySize_x + eY * 0.5 * mySize_y;
219 if(shownames_health > 0) // otherwise player is an enemy
221 // "ghost" backgrounds
222 drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
223 drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor", '1 1 0' * iconsize_y, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
225 drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, shownames_health/autocvar_hud_panel_healtharmor_maxhealth), vid_conwidth, myPos_y + iconsize_y);
226 drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
228 drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, shownames_armor/autocvar_hud_panel_healtharmor_maxarmor), vid_conwidth, myPos_y + iconsize_y);
229 drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor", '1 1 0' * iconsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
234 drawpic_aspect_skin(iconpos, "health_unknown", '1 1 0' * iconsize_y, '0 0 0', panel_fg_alpha, DRAWFLAG_NORMAL);
235 drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor_unknown", '1 1 0' * iconsize_y, '0 0 0', panel_fg_alpha, DRAWFLAG_NORMAL);
238 if(autocvar__hud_configure)
239 drawcolorcodedstring_aspect(namepos, "Player1234", namesize, panel_fg_alpha, DRAWFLAG_NORMAL);
241 drawcolorcodedstring_aspect(namepos, shownames_netname, namesize, panel_fg_alpha, DRAWFLAG_NORMAL);