7 // a border picture is a texture containing nine parts:
8 // 1/4 width: left part
9 // 1/2 width: middle part (stretched)
10 // 1/4 width: right part
12 // 1/4 height: top part
13 // 1/2 height: middle part (stretched)
14 // 1/4 height: bottom part
15 void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize)
17 if (theBorderSize_x < 0 && theBorderSize_y < 0) // draw whole image as it is
19 drawpic(theOrigin, pic, theSize, theColor, theAlpha, 0);
22 if (theBorderSize_x == 0 && theBorderSize_y == 0) // no border
24 // draw only the central part
25 drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
32 //pic = draw_UseSkinFor(pic);
33 width = eX * theSize_x;
34 height = eY * theSize_y;
35 if(theSize_x <= theBorderSize_x * 2)
37 // not wide enough... draw just left and right then
38 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
39 if(theSize_y <= theBorderSize_y * 2)
41 // not high enough... draw just corners
42 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
43 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
44 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
45 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
46 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
50 dY = theBorderSize_x * eY;
51 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
52 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
53 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
54 drawsubpic(theOrigin + width * 0.5 + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0' + eX - bW, '0 0.5 0' + bW, theColor, theAlpha, 0);
55 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
56 drawsubpic(theOrigin + width * 0.5 + height - dY, width * 0.5 + dY, pic, '0 0.75 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
61 if(theSize_y <= theBorderSize_y * 2)
63 // not high enough... draw just top and bottom then
64 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
65 dX = theBorderSize_x * eX;
66 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
67 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
68 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
69 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
70 drawsubpic(theOrigin + dX + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5 0 0' + bH, theColor, theAlpha, 0);
71 drawsubpic(theOrigin + width - dX + height * 0.5, dX + height * 0.5, pic, '0.75 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
75 dX = theBorderSize_x * eX;
76 dY = theBorderSize_x * eY;
77 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
78 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
79 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
80 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
81 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
82 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
83 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
84 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
85 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
90 vector HUD_Get_Num_Color (float x, float maxvalue)
95 color_x = sin(2*M_PI*time);
97 color_z = sin(2*M_PI*time);
99 else if(x > maxvalue * 0.75) {
100 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
101 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
104 else if(x > maxvalue * 0.5) {
105 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
106 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
107 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
109 else if(x > maxvalue * 0.25) {
112 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
114 else if(x > maxvalue * 0.1) {
116 color_y = (x-20)*90/27/100; // green value between 0 -> 1
117 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
125 blinkingamt = (1 - x/maxvalue/0.25);
128 color_x = color_x - color_x * blinkingamt * sin(2*M_PI*time);
129 color_y = color_y - color_y * blinkingamt * sin(2*M_PI*time);
130 color_z = color_z - color_z * blinkingamt * sin(2*M_PI*time);
135 float stringwidth_colors(string s, vector theSize)
137 return stringwidth(s, TRUE, theSize);
140 float stringwidth_nocolors(string s, vector theSize)
142 return stringwidth(s, FALSE, theSize);
145 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
147 position_x -= 2 / 3 * strlen(text) * scale_x;
148 drawstring(position, text, scale, rgb, alpha, flag);
151 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
153 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
154 drawstring(position, text, scale, rgb, alpha, flag);
157 // return the string of the given race place
158 string race_PlaceName(float pos) {
166 return sprintf(_("%dth"), pos);
169 // return the string of the onscreen race timer
170 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
178 if(histime == 0) // goal hit
182 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
192 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
198 lapstr = sprintf(_(" (-%dL)"), lapdelta);
201 else if(lapdelta < 0)
203 lapstr = sprintf(_(" (+%dL)"), -lapdelta);
207 else if(histime > 0) // anticipation
209 if(mytime >= histime)
210 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
212 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
219 cpname = _("Start line");
221 cpname = _("Finish line");
223 cpname = sprintf(_("Intermediate %d"), cp);
225 cpname = _("Finish line");
228 return strcat(col, cpname);
229 else if(hisname == "")
230 return strcat(col, sprintf(_("%s (%s)"), cpname, timestr));
232 return strcat(col, sprintf(_("%s (%s %s)"), cpname, timestr, strcat(hisname, col, lapstr)));
235 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
236 float race_CheckName(string net_name) {
238 for (i=RANKINGS_CNT-1;i>=0;--i)
239 if(grecordholder[i] == net_name)
250 // draw the background/borders
251 #define HUD_Panel_DrawBg(alpha)\
253 draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * alpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\
254 if(highlightedPanel == hud_configure_active_panel && autocvar__hud_configure)\
256 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);\
257 } ENDS_WITH_CURLY_BRACE
259 //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
260 void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, float vertical, float baralign, vector theColor, float theAlpha, float drawflag)
262 if(!length_ratio || !theAlpha)
268 if(length_ratio < -1)
271 else if(length_ratio < 0)
275 vector width, height;
277 pic = strcat(hud_skin_path, "/", pic, "_vertical");
278 if(precache_pic(pic) == "") {
279 pic = "gfx/hud/default/progressbar_vertical";
282 if (baralign == 1) // bottom align
283 theOrigin_y += (1 - length_ratio) * theSize_y;
284 else if (baralign == 2) // center align
285 theOrigin_y += 0.5 * (1 - length_ratio) * theSize_y;
286 else if (baralign == 3) // center align, positive values down, negative up
289 if (length_ratio > 0)
290 theOrigin_y += theSize_y;
293 theOrigin_y += (1 + length_ratio) * theSize_y;
294 length_ratio = -length_ratio;
297 theSize_y *= length_ratio;
300 width = eX * theSize_x;
301 height = eY * theSize_y;
302 if(theSize_y <= theSize_x * 2)
304 // button not high enough
305 // draw just upper and lower part then
306 square = eY * theSize_y * 0.5;
307 bH = eY * (0.25 * theSize_y / (theSize_x * 2));
308 drawsubpic(theOrigin, square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, drawflag);
309 drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, drawflag);
313 square = eY * theSize_x;
314 drawsubpic(theOrigin, width + square, pic, '0 0 0', '1 0.25 0', theColor, theAlpha, drawflag);
315 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5 0', theColor, theAlpha, drawflag);
316 drawsubpic(theOrigin + height - square, width + square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, drawflag);
319 pic = strcat(hud_skin_path, "/", pic);
320 if(precache_pic(pic) == "") {
321 pic = "gfx/hud/default/progressbar";
324 if (baralign == 1) // right align
325 theOrigin_x += (1 - length_ratio) * theSize_x;
326 else if (baralign == 2) // center align
327 theOrigin_x += 0.5 * (1 - length_ratio) * theSize_x;
328 else if (baralign == 3) // center align, positive values on the right, negative on the left
331 if (length_ratio > 0)
332 theOrigin_x += theSize_x;
335 theOrigin_x += (1 + length_ratio) * theSize_x;
336 length_ratio = -length_ratio;
339 theSize_x *= length_ratio;
342 width = eX * theSize_x;
343 height = eY * theSize_y;
344 if(theSize_x <= theSize_y * 2)
346 // button not wide enough
347 // draw just left and right part then
348 square = eX * theSize_x * 0.5;
349 bW = eX * (0.25 * theSize_x / (theSize_y * 2));
350 drawsubpic(theOrigin, square + height, pic, '0 0 0', eY + bW, theColor, theAlpha, drawflag);
351 drawsubpic(theOrigin + square, square + height, pic, eX - bW, eY + bW, theColor, theAlpha, drawflag);
355 square = eX * theSize_y;
356 drawsubpic(theOrigin, height + square, pic, '0 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
357 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0.25 0 0', '0.5 1 0', theColor, theAlpha, drawflag);
358 drawsubpic(theOrigin + width - square, height + square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
363 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
369 pic = strcat(hud_skin_path, "/num_leading");
370 if(precache_pic(pic) == "") {
371 pic = "gfx/hud/default/num_leading";
374 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
375 if(mySize_x/mySize_y > 2)
376 drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, pic, '0.25 0 0', '0.5 1 0', color, alpha, drawflag);
377 drawsubpic(pos + eX * mySize_x - eX * min(mySize_x * 0.5, mySize_y), eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0.75 0 0', '0.25 1 0', color, alpha, drawflag);
382 entity weaponorder[WEP_MAXCOUNT];
383 void weaponorder_swap(float i, float j, entity pass)
387 weaponorder[i] = weaponorder[j];
391 string weaponorder_cmp_str;
392 float weaponorder_cmp(float i, float j, entity pass)
395 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
396 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
397 return aj - ai; // the string is in REVERSE order (higher prio at the right is what we want, but higher prio first is the string)
400 float GetAmmoStat(float i)
404 case 0: return STAT_SHELLS;
405 case 1: return STAT_NAILS;
406 case 2: return STAT_ROCKETS;
407 case 3: return STAT_CELLS;
408 case 4: return STAT_FUEL;
413 float GetAmmoTypeForWep(float i)
417 case WEP_SHOTGUN: return 0;
418 case WEP_UZI: return 1;
419 case WEP_GRENADE_LAUNCHER: return 2;
420 case WEP_MINE_LAYER: return 2;
421 case WEP_ELECTRO: return 3;
422 case WEP_CRYLINK: return 3;
423 case WEP_HLAC: return 3;
424 case WEP_MINSTANEX: return 3;
425 case WEP_NEX: return 3;
426 case WEP_SNIPERRIFLE: return 1;
427 case WEP_HAGAR: return 2;
428 case WEP_ROCKET_LAUNCHER: return 2;
429 case WEP_SEEKER: return 2;
430 case WEP_FIREBALL: return 4;
431 case WEP_HOOK: return 3;
436 void HUD_Weapons(void)
439 float center_x, center_y;
441 if(!autocvar__hud_configure)
443 if(!autocvar_hud_panel_weapons) return;
444 if(spectatee_status == -1) return;
447 hud_configure_active_panel = HUD_PANEL_WEAPONS;
449 float timeout = autocvar_hud_panel_weapons_timeout;
450 float timeout_effect_length, timein_effect_length;
451 if (autocvar_hud_panel_weapons_timeout_effect == 0)
453 timeout_effect_length = 0;
454 timein_effect_length = 0;
458 timeout_effect_length = 0.75;
459 timein_effect_length = 0.375;
462 if (timeout && time >= weapontime + timeout + timeout_effect_length && !autocvar__hud_configure)
464 weaponprevtime = time;
468 HUD_Panel_UpdateCvars(weapons);
470 if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
472 f = (time - (weapontime + timeout)) / timeout_effect_length;
473 if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3)
475 panel_bg_alpha *= (1 - f);
476 panel_fg_alpha *= (1 - f);
478 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
480 f *= f; // for a cooler movement
481 center_x = panel_pos_x + panel_size_x/2;
482 center_y = panel_pos_y + panel_size_y/2;
483 screen_ar = vid_conwidth/vid_conheight;
484 if (center_x/center_y < screen_ar) //bottom left
486 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
487 panel_pos_y += f * (vid_conheight - panel_pos_y);
489 panel_pos_x -= f * (panel_pos_x + panel_size_x);
493 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
494 panel_pos_x += f * (vid_conwidth - panel_pos_x);
496 panel_pos_y -= f * (panel_pos_y + panel_size_y);
499 weaponprevtime = time - (1 - f) * timein_effect_length;
501 else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure)
503 f = (time - weaponprevtime) / timein_effect_length;
504 if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3)
506 panel_bg_alpha *= (f);
507 panel_fg_alpha *= (f);
509 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
511 f *= f; // for a cooler movement
513 center_x = panel_pos_x + panel_size_x/2;
514 center_y = panel_pos_y + panel_size_y/2;
515 screen_ar = vid_conwidth/vid_conheight;
516 if (center_x/center_y < screen_ar) //bottom left
518 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
519 panel_pos_y += f * (vid_conheight - panel_pos_y);
521 panel_pos_x -= f * (panel_pos_x + panel_size_x);
525 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
526 panel_pos_x += f * (vid_conwidth - panel_pos_x);
528 panel_pos_y -= f * (panel_pos_y + panel_size_y);
533 float i, weapid, wpnalpha, weapon_cnt;
535 // TODO make this configurable
536 if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
538 if(weaponorder_bypriority)
539 strunzone(weaponorder_bypriority);
540 if(weaponorder_byimpulse)
541 strunzone(weaponorder_byimpulse);
543 weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
544 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
545 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
548 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
550 self = get_weaponinfo(i);
551 if(self.impulse >= 0)
553 weaponorder[weapon_cnt] = self;
557 for(i = weapon_cnt; i < WEP_MAXCOUNT; ++i)
558 weaponorder[i] = NULL;
559 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
561 weaponorder_cmp_str = string_null;
567 panel_pos += '1 1 0' * panel_bg_padding;
568 panel_size -= '2 2 0' * panel_bg_padding;
571 if(autocvar_hud_panel_weapons_fade)
573 wpnalpha = 3.2 - 2 * (time - weapontime);
574 wpnalpha = bound(0.7, wpnalpha, 1) * panel_fg_alpha;
577 wpnalpha = panel_fg_alpha;
580 float aspect = autocvar_hud_panel_weapons_aspect;
581 rows = panel_size_y/panel_size_x;
582 rows = bound(1, floor((sqrt(4 * aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
584 columns = ceil(WEP_COUNT/rows);
587 float a, type, fullammo;
589 when = autocvar_hud_panel_weapons_complainbubble_time;
591 fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
599 wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
600 float barsize_x, barsize_y, baroffset_x, baroffset_y;
601 if (autocvar_hud_panel_weapons_ammo)
603 ammo_color = stov(autocvar_hud_panel_weapons_ammo_color);
604 ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha;
607 if(wpnsize_x/wpnsize_y > aspect)
609 barsize_x = aspect * wpnsize_y;
610 barsize_y = wpnsize_y;
611 baroffset_x = (wpnsize_x - barsize_x) / 2;
615 barsize_y = 1/aspect * wpnsize_x;
616 barsize_x = wpnsize_x;
617 baroffset_y = (wpnsize_y - barsize_y) / 2;
623 if(autocvar_hud_panel_weapons_accuracy && acc_levels)
625 show_accuracy = true;
626 if (acc_col_x[0] == -1)
627 for (i = 0; i < acc_levels; ++i)
628 acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
631 float weapons_st = getstati(STAT_WEAPONS);
633 for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
635 self = weaponorder[i];
636 if (!self || self.impulse < 0)
638 wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
640 weapid = self.impulse;
642 // draw background behind currently selected weapon
643 if(self.weapon == activeweapon)
644 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
646 // draw the weapon accuracy
649 weapon_stats = weapon_accuracy[self.weapon-WEP_FIRST];
650 if(weapon_stats >= 0)
652 // find the max level lower than weapon_stats
655 while ( j && weapon_stats < acc_lev[j] )
658 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
660 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
662 color = color + factor * (acc_col[j+1] - color);
664 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
668 // draw the weapon icon
669 if(weapons_st & self.weapons)
671 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
673 if(autocvar_hud_panel_weapons_label == 1) // weapon number
674 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
675 else if(autocvar_hud_panel_weapons_label == 2) // bind
676 drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
678 // draw ammo status bar
679 if(autocvar_hud_panel_weapons_ammo && self.weapon != WEP_TUBA && self.weapon != WEP_LASER && self.weapon != WEP_PORTO)
682 type = GetAmmoTypeForWep(self.weapon);
684 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
689 case 0: fullammo = autocvar_hud_panel_weapons_ammo_full_shells; break;
690 case 1: fullammo = autocvar_hud_panel_weapons_ammo_full_nails; break;
691 case 2: fullammo = autocvar_hud_panel_weapons_ammo_full_rockets; break;
692 case 3: fullammo = autocvar_hud_panel_weapons_ammo_full_cells; break;
693 case 4: fullammo = autocvar_hud_panel_weapons_ammo_full_fuel; break;
694 default: fullammo = 60;
698 wpnpos_x + baroffset_x,
699 wpnpos_y + baroffset_y,
700 barsize_x * bound(0, a/fullammo, 1),
702 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, ammo_color, ammo_alpha, DRAWFLAG_NORMAL);
708 // draw a "ghost weapon icon" if you don't have the weapon
711 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
714 // draw the complain message
715 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
719 if(complain_weapon_time + when > time)
722 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
726 if(complain_weapon_time + when > time)
733 if(complain_weapon_type == 0) {
734 s = _("Out of ammo");
735 color = stov(autocvar_hud_panel_weapons_complainbubble_color_outofammo);
737 else if(complain_weapon_type == 1) {
739 color = stov(autocvar_hud_panel_weapons_complainbubble_color_donthave);
742 s = _("Unavailable");
743 color = stov(autocvar_hud_panel_weapons_complainbubble_color_unavailable);
745 float padding = autocvar_hud_panel_weapons_complainbubble_padding;
746 drawpic_aspect_skin(wpnpos + '1 1 0' * padding, "weapon_complainbubble", wpnsize - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
747 drawstring_aspect(wpnpos + '1 1 0' * padding, s, wpnsize - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
763 float GetAmmoItemCode(float i)
767 case 0: return IT_SHELLS;
768 case 1: return IT_NAILS;
769 case 2: return IT_ROCKETS;
770 case 3: return IT_CELLS;
771 case 4: return IT_FUEL;
776 string GetAmmoPicture(float i)
780 case 0: return "ammo_shells";
781 case 1: return "ammo_bullets";
782 case 2: return "ammo_rockets";
783 case 3: return "ammo_cells";
784 case 4: return "ammo_fuel";
789 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
792 if(autocvar__hud_configure)
794 currently_selected = (itemcode == 2); //rockets always selected
795 a = 31 + mod(itemcode*93, 128);
798 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
807 if(currently_selected)
812 vector picpos, numpos;
813 if(autocvar_hud_panel_ammo_iconalign)
816 picpos = myPos + eX * 2 * mySize_y;
820 numpos = myPos + eX * mySize_y;
824 if (currently_selected)
825 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
827 if(a > 0 && autocvar_hud_panel_ammo_progressbar)
828 HUD_Panel_DrawProgressBar(myPos + eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize_x, mySize - eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize_x, autocvar_hud_panel_ammo_progressbar_name, a/autocvar_hud_panel_ammo_maxammo, 0, 0, color, autocvar_hud_progressbar_alpha * panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
830 if(autocvar_hud_panel_ammo_text)
833 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
834 else // "ghost" ammo count
835 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
838 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
839 else // "ghost" ammo icon
840 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
845 if(!autocvar__hud_configure)
847 if(!autocvar_hud_panel_ammo) return;
848 if(spectatee_status == -1) return;
851 hud_configure_active_panel = HUD_PANEL_AMMO;
853 HUD_Panel_UpdateCvars(ammo);
861 pos += '1 1 0' * panel_bg_padding;
862 mySize -= '2 2 0' * panel_bg_padding;
865 float rows, columns, row, column;
867 if (autocvar_hud_panel_ammo_onlycurrent)
871 rows = mySize_y/mySize_x;
872 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
873 // ^^^ ammo item aspect goes here
875 columns = ceil(AMMO_COUNT/rows);
877 ammo_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
882 if(ammo_size_x/ammo_size_y > 3)
884 newSize = 3 * ammo_size_y;
885 offset_x = ammo_size_x - newSize;
887 ammo_size_x = newSize;
891 newSize = 1/3 * ammo_size_x;
892 offset_y = ammo_size_y - newSize;
894 ammo_size_y = newSize;
897 float i, stat_items, currently_selected;
898 if (autocvar_hud_panel_ammo_onlycurrent)
900 if(autocvar__hud_configure)
902 DrawAmmoItem(pos, ammo_size, 2, true); //show rockets
905 stat_items = getstati(STAT_ITEMS);
906 for (i = 0; i < AMMO_COUNT; ++i) {
907 currently_selected = stat_items & GetAmmoItemCode(i);
908 if (currently_selected)
910 DrawAmmoItem(pos, ammo_size, i, true);
914 return; // nothing to display
917 stat_items = getstati(STAT_ITEMS);
918 for (i = 0; i < AMMO_COUNT; ++i) {
919 currently_selected = stat_items & GetAmmoItemCode(i);
920 DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected);
930 void DrawNumIcon(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float alpha)
932 vector newPos, newSize;
933 vector picpos, numpos;
937 if(mySize_y/mySize_x > 2)
939 newSize_y = 2 * mySize_x;
940 newSize_x = mySize_x;
942 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
947 newSize_x = 1/2 * mySize_y;
948 newSize_y = mySize_y;
950 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
957 picpos = newPos + eY * newSize_x;
962 numpos = newPos + eY * newSize_x;
966 drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
967 // make number smaller than icon, it looks better
968 // reduce only y to draw numbers with different number of digits with the same y size
969 numpos_y += newSize_y * ((1 - 0.7) / 2);
971 drawstring_aspect(numpos, ftos(x), newSize, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
975 if(mySize_x/mySize_y > 3)
977 newSize_x = 3 * mySize_y;
978 newSize_y = mySize_y;
980 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
985 newSize_y = 1/3 * mySize_x;
986 newSize_x = mySize_x;
988 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
992 if(icon_right_align) // right align
995 picpos = newPos + eX * 2 * newSize_y;
999 numpos = newPos + eX * newSize_y;
1003 drawstring_aspect(numpos, ftos(x), '2 1 0' * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1004 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1007 void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float fadelerp)
1010 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
1012 DrawNumIcon(myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, vertical, icon_right_align, color, (1 - fadelerp));
1017 void HUD_Powerups(void)
1019 float strength_time, shield_time;
1020 if(!autocvar__hud_configure)
1022 if(!autocvar_hud_panel_powerups) return;
1023 if(spectatee_status == -1) return;
1024 if not(getstati(STAT_ITEMS) & (IT_STRENGTH | IT_INVINCIBLE)) return;
1025 if (getstati(STAT_HEALTH) <= 0) return;
1027 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1028 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1032 hud_configure_active_panel = HUD_PANEL_POWERUPS;
1038 HUD_Panel_UpdateCvars(powerups);
1041 mySize = panel_size;
1043 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
1044 if(panel_bg_padding)
1046 pos += '1 1 0' * panel_bg_padding;
1047 mySize -= '2 2 0' * panel_bg_padding;
1050 float panel_ar = mySize_x/mySize_y;
1051 float is_vertical = (panel_ar < 1);
1052 vector shield_offset, strength_offset;
1053 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1056 if (autocvar_hud_panel_powerups_flip)
1057 shield_offset_x = mySize_x;
1059 strength_offset_x = mySize_x;
1064 if (autocvar_hud_panel_powerups_flip)
1065 shield_offset_y = mySize_y;
1067 strength_offset_y = mySize_y;
1070 float shield_baralign, strength_baralign;
1071 float shield_iconalign, strength_iconalign;
1072 if (autocvar_hud_panel_powerups_flip)
1074 strength_baralign = (autocvar_hud_panel_powerups_baralign == 2 || autocvar_hud_panel_powerups_baralign == 1);
1075 shield_baralign = (autocvar_hud_panel_powerups_baralign == 3 || autocvar_hud_panel_powerups_baralign == 1);
1076 strength_iconalign = (autocvar_hud_panel_powerups_iconalign == 2 || autocvar_hud_panel_powerups_iconalign == 1);
1077 shield_iconalign = (autocvar_hud_panel_powerups_iconalign == 3 || autocvar_hud_panel_powerups_iconalign == 1);
1081 shield_baralign = (autocvar_hud_panel_powerups_baralign == 2 || autocvar_hud_panel_powerups_baralign == 1);
1082 strength_baralign = (autocvar_hud_panel_powerups_baralign == 3 || autocvar_hud_panel_powerups_baralign == 1);
1083 shield_iconalign = (autocvar_hud_panel_powerups_iconalign == 2 || autocvar_hud_panel_powerups_iconalign == 1);
1084 strength_iconalign = (autocvar_hud_panel_powerups_iconalign == 3 || autocvar_hud_panel_powerups_iconalign == 1);
1089 const float maxshield = 30;
1090 float shield = ceil(shield_time);
1091 if(autocvar_hud_panel_powerups_progressbar)
1093 HUD_Panel_GetProgressBarColor(shield);
1094 HUD_Panel_DrawProgressBar(pos + shield_offset, mySize, autocvar_hud_panel_powerups_progressbar_shield, shield/maxshield, is_vertical, shield_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1096 if(autocvar_hud_panel_powerups_text)
1099 DrawNumIcon(pos + shield_offset, mySize, shield, "shield", is_vertical, shield_iconalign, '1 1 1', 1);
1101 DrawNumIcon_expanding(pos + shield_offset, mySize, shield, "shield", is_vertical, shield_iconalign, '1 1 1', bound(0, (shield - shield_time) / 0.5, 1));
1107 const float maxstrength = 30;
1108 float strength = ceil(strength_time);
1109 if(autocvar_hud_panel_powerups_progressbar)
1111 HUD_Panel_GetProgressBarColor(strength);
1112 HUD_Panel_DrawProgressBar(pos + strength_offset, mySize, autocvar_hud_panel_powerups_progressbar_strength, strength/maxstrength, is_vertical, strength_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1114 if(autocvar_hud_panel_powerups_text)
1117 DrawNumIcon(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', 1);
1119 DrawNumIcon_expanding(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', bound(0, (strength - strength_time) / 0.5, 1));
1124 // Health/armor (#3)
1127 // prev_* vars contain the health/armor at the previous FRAME
1128 // set to -1 when player is dead or was not playing
1129 float prev_health, prev_armor;
1130 float health_damagetime, armor_damagetime;
1131 float health_beforedamage, armor_beforedamage;
1132 // old_p_* vars keep track of previous values when smoothing value changes of the progressbar
1133 float old_p_health, old_p_armor;
1134 float old_p_healthtime, old_p_armortime;
1135 // prev_p_* vars contain the health/armor progressbar value at the previous FRAME
1136 // set to -1 to forcedly stop effects when we switch spectated player (e.g. from playerX: 70h to playerY: 50h)
1137 float prev_p_health, prev_p_armor;
1139 void HUD_HealthArmor(void)
1141 float armor, health, fuel;
1142 if(!autocvar__hud_configure)
1144 if(!autocvar_hud_panel_healtharmor) return;
1145 if(spectatee_status == -1) return;
1147 health = getstati(STAT_HEALTH);
1153 armor = getstati(STAT_ARMOR);
1155 // code to check for spectatee_status changes is in Ent_ClientData()
1156 // prev_p_health and prev_health can be set to -1 there
1158 if (prev_p_health == -1)
1161 health_beforedamage = 0;
1162 armor_beforedamage = 0;
1163 health_damagetime = 0;
1164 armor_damagetime = 0;
1165 prev_health = health;
1167 old_p_health = health;
1168 old_p_armor = armor;
1169 prev_p_health = health;
1170 prev_p_armor = armor;
1172 else if (prev_health == -1)
1174 //start the load effect
1175 health_damagetime = 0;
1176 armor_damagetime = 0;
1180 fuel = getstati(STAT_FUEL);
1184 hud_configure_active_panel = HUD_PANEL_HEALTHARMOR;
1191 HUD_Panel_UpdateCvars(healtharmor);
1194 mySize = panel_size;
1196 HUD_Panel_DrawBg(1);
1197 if(panel_bg_padding)
1199 pos += '1 1 0' * panel_bg_padding;
1200 mySize -= '2 2 0' * panel_bg_padding;
1203 float baralign = autocvar_hud_panel_healtharmor_baralign;
1204 float iconalign = autocvar_hud_panel_healtharmor_iconalign;
1206 float maxhealth = autocvar_hud_panel_healtharmor_maxhealth;
1207 float maxarmor = autocvar_hud_panel_healtharmor_maxarmor;
1208 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
1211 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1216 float maxtotal = maxhealth + maxarmor;
1218 if(v_z) // NOT fully armored
1220 biggercount = "health";
1221 if(autocvar_hud_panel_healtharmor_progressbar)
1223 HUD_Panel_GetProgressBarColor(health);
1224 HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_health, x/maxtotal, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1227 if(autocvar_hud_panel_healtharmor_text)
1228 drawpic_aspect_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "armor", '0.5 0.5 0' * mySize_y, '1 1 1', panel_fg_alpha * armor / health, DRAWFLAG_NORMAL);
1232 biggercount = "armor";
1233 if(autocvar_hud_panel_healtharmor_progressbar)
1235 HUD_Panel_GetProgressBarColor(armor);
1236 HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, x/maxtotal, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1239 if(autocvar_hud_panel_healtharmor_text)
1240 drawpic_aspect_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "health", '0.5 0.5 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1242 if(autocvar_hud_panel_healtharmor_text)
1243 DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, maxtotal), 1);
1247 HUD_Panel_GetProgressBarColor(fuel);
1248 HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.2 * mySize_y, "progressbar", fuel/100, 0, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
1253 float panel_ar = mySize_x/mySize_y;
1254 float is_vertical = (panel_ar < 1);
1255 vector health_offset, armor_offset;
1256 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1259 if (autocvar_hud_panel_healtharmor_flip)
1260 health_offset_x = mySize_x;
1262 armor_offset_x = mySize_x;
1267 if (autocvar_hud_panel_healtharmor_flip)
1268 health_offset_y = mySize_y;
1270 armor_offset_y = mySize_y;
1273 float health_baralign, armor_baralign, fuel_baralign;
1274 float health_iconalign, armor_iconalign;
1275 if (autocvar_hud_panel_healtharmor_flip)
1277 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1278 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1279 fuel_baralign = health_baralign;
1280 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1281 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1285 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1286 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1287 fuel_baralign = armor_baralign;
1288 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1289 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1294 if(autocvar_hud_panel_healtharmor_progressbar)
1296 HUD_Panel_GetProgressBarColor(health);
1297 float p_health, pain_health_alpha;
1299 pain_health_alpha = 1;
1300 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1302 if (autocvar_hud_panel_healtharmor_progressbar_gfx_smooth > 0)
1304 if (fabs(prev_health - health) >= autocvar_hud_panel_healtharmor_progressbar_gfx_smooth)
1306 if (time - old_p_healthtime < 1)
1307 old_p_health = prev_p_health;
1309 old_p_health = prev_health;
1310 old_p_healthtime = time;
1312 if (time - old_p_healthtime < 1)
1314 p_health += (old_p_health - health) * (1 - (time - old_p_healthtime));
1315 prev_p_health = p_health;
1318 if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0)
1320 if (prev_health - health >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
1322 if (time - health_damagetime >= 1)
1323 health_beforedamage = prev_health;
1324 health_damagetime = time;
1326 if (time - health_damagetime < 1)
1328 float health_damagealpha = 1 - (time - health_damagetime)*(time - health_damagetime);
1329 HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, health_beforedamage/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * health_damagealpha, DRAWFLAG_NORMAL);
1332 prev_health = health;
1334 if (health <= autocvar_hud_panel_healtharmor_progressbar_gfx_lowhealth)
1336 float BLINK_FACTOR = 0.15;
1337 float BLINK_BASE = 0.85;
1338 float BLINK_FREQ = 9;
1339 pain_health_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
1342 HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, p_health/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * pain_health_alpha, DRAWFLAG_NORMAL);
1344 if(autocvar_hud_panel_healtharmor_text)
1345 DrawNumIcon(pos + health_offset, mySize, health, "health", is_vertical, health_iconalign, HUD_Get_Num_Color(health, maxhealth), 1);
1350 if(autocvar_hud_panel_healtharmor_progressbar)
1352 HUD_Panel_GetProgressBarColor(armor);
1355 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1357 if (autocvar_hud_panel_healtharmor_progressbar_gfx_smooth > 0)
1359 if (fabs(prev_armor - armor) >= autocvar_hud_panel_healtharmor_progressbar_gfx_smooth)
1361 if (time - old_p_armortime < 1)
1362 old_p_armor = prev_p_armor;
1364 old_p_armor = prev_armor;
1365 old_p_armortime = time;
1367 if (time - old_p_armortime < 1)
1369 p_armor += (old_p_armor - armor) * (1 - (time - old_p_armortime));
1370 prev_p_armor = p_armor;
1373 if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0)
1375 if (prev_armor - armor >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
1377 if (time - armor_damagetime >= 1)
1378 armor_beforedamage = prev_armor;
1379 armor_damagetime = time;
1381 if (time - armor_damagetime < 1)
1383 float armor_damagealpha = 1 - (time - armor_damagetime)*(time - armor_damagetime);
1384 HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, armor_beforedamage/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * armor_damagealpha, DRAWFLAG_NORMAL);
1389 HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, p_armor/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1391 if(autocvar_hud_panel_healtharmor_text)
1392 DrawNumIcon(pos + armor_offset, mySize, armor, "armor", is_vertical, armor_iconalign, HUD_Get_Num_Color(armor, maxarmor), 1);
1398 mySize_x *= 0.2 / 2; //if vertical always halve x to not cover too much numbers with 3 digits
1402 mySize_x *= 2; //restore full panel size
1403 else if (panel_ar < 1/4)
1404 mySize_y *= 2; //restore full panel size
1405 HUD_Panel_GetProgressBarColor(fuel);
1406 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
1411 // Notification area (#4)
1414 string Weapon_SuicideMessage(float deathtype)
1416 w_deathtype = deathtype;
1417 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
1418 return w_deathtypestring;
1421 string Weapon_KillMessage(float deathtype)
1423 w_deathtype = deathtype;
1424 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
1425 return w_deathtypestring;
1428 #define KN_MAX_ENTRIES 10
1430 float killnotify_times[KN_MAX_ENTRIES];
1431 float killnotify_deathtype[KN_MAX_ENTRIES];
1432 float killnotify_actiontype[KN_MAX_ENTRIES]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
1433 string killnotify_attackers[KN_MAX_ENTRIES];
1434 string killnotify_victims[KN_MAX_ENTRIES];
1435 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
1439 kn_index = KN_MAX_ENTRIES-1;
1440 killnotify_times[kn_index] = time;
1441 killnotify_deathtype[kn_index] = wpn;
1442 killnotify_actiontype[kn_index] = actiontype;
1443 if(killnotify_attackers[kn_index])
1444 strunzone(killnotify_attackers[kn_index]);
1445 killnotify_attackers[kn_index] = strzone(attacker);
1446 if(killnotify_victims[kn_index])
1447 strunzone(killnotify_victims[kn_index]);
1448 killnotify_victims[kn_index] = strzone(victim);
1451 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
1454 float alsoprint, gentle;
1455 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
1456 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
1458 if ((msg == MSG_SUICIDE || msg == MSG_KILL || msg == MSG_KILL_ACTION) && gametype == GAME_CTS) // selfkill isn't interesting in CTS and only spams up the notify panel
1461 if(msg == MSG_SUICIDE) {
1462 w = DEATH_WEAPONOF(type);
1464 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1466 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
1467 } else if (type == DEATH_KILL) {
1468 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
1470 print (sprintf(_("^1%s^1 couldn't take it anymore\n"), s1));
1471 } else if (type == DEATH_ROT) {
1472 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1474 print (sprintf(_("^1%s^1 died\n"), s1));
1475 } else if (type == DEATH_NOAMMO) {
1476 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
1478 print (sprintf(_("^7%s^7 committed suicide. What's the point of living without ammo?\n"), s1));
1479 } else if (type == DEATH_CAMP) {
1480 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
1482 print (sprintf(_("^1%s^1 thought they found a nice camping ground\n"), s1));
1483 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
1484 HUD_KillNotify_Push(s1, "", 0, type);
1486 print (sprintf(_("^1%s^1 didn't become friends with the Lord of Teamplay\n"), s1));
1487 } else if (type == DEATH_CHEAT) {
1488 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1490 print (sprintf(_("^1%s^1 unfairly eliminated themself\n"), s1));
1491 } else if (type == DEATH_FIRE) {
1492 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1494 print (sprintf(_("^1%s^1 burned to death\n"), s1));
1495 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
1496 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1498 print (sprintf(_("^1%s^1 couldn't resist the urge to self-destruct\n"), s1));
1501 if (stof(s2) > 2) // killcount > 2
1502 print (sprintf(_("^1%s^1 ended it all after a %d kill spree\n"), s1, stof(s2)));
1503 } else if(msg == MSG_KILL) {
1504 w = DEATH_WEAPONOF(type);
1506 if((w == WEP_SNIPERRIFLE || w == WEP_MINSTANEX) && type & HITTYPE_HEADSHOT) // all headshot weapons go here
1507 HUD_KillNotify_Push(s1, s2, 1, DEATH_HEADSHOT);
1509 HUD_KillNotify_Push(s1, s2, 1, type);
1512 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
1514 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
1515 HUD_KillNotify_Push(s1, s2, 1, type);
1519 print (sprintf(_("^1%s^1 took action against a team mate\n"), s1));
1521 print (sprintf(_("^1%s^1 mows down a team mate\n"), s1));
1524 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
1526 print (sprintf(_("^1%s^1 ended a %d scoring spree by going against a team mate\n"), s1, stof(s3)));
1528 print (sprintf(_("^1%s^1 ended a %d kill spree by killing a team mate\n"), s1, stof(s3)));
1530 else if (stof(s2) > 2) {
1532 print (sprintf(_("^1%s^1's %s scoring spree was ended by a team mate!\n"), s1, stof(s3)));
1534 print (sprintf(_("^1%s^1's %s kill spree was ended by a team mate!\n"), s1, stof(s3)));
1537 else if(type == KILL_FIRST_BLOOD)
1538 print(sprintf(_("^1%s^1 drew first blood\n"), s1));
1539 else if (type == DEATH_TELEFRAG) {
1540 HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
1542 print (sprintf(_("^1%s^1 tried to occupy %s^1's teleport destination space\n"), s2, s1));
1544 print (sprintf(_("^1%s^1 was telefragged by %s\n"), s2, s1));
1546 else if (type == DEATH_DROWN) {
1547 HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN);
1549 print (sprintf(_("^1%s^1 was drowned by %s\n"), s2, s1));
1551 else if (type == DEATH_SLIME) {
1552 HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME);
1554 print (sprintf(_("^1%s^1 was slimed by %s\n"), s2, s1));
1556 else if (type == DEATH_LAVA) {
1557 HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA);
1559 print (sprintf(_("^1%s^1 was cooked by %s\n"), s2, s1));
1561 else if (type == DEATH_FALL) {
1562 HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL);
1564 print (sprintf(_("^1%s^1 was grounded by %s\n"), s2, s1));
1566 else if (type == DEATH_SHOOTING_STAR) {
1567 HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR);
1569 print (sprintf(_("^1%s^1 was shot into space by %s\n"), s2, s1));
1571 else if (type == DEATH_SWAMP) {
1572 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1574 print (sprintf(_("^1%s^1 was conserved by %s\n"), s2, s1));
1576 else if (type == DEATH_HURTTRIGGER)
1578 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1580 print(sprintf(_("^1%s^1 was thrown into a world of hurt by %s\n"), s2, s1));
1581 } else if(type == DEATH_SBCRUSH) {
1582 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1584 print (sprintf(_("^1%s^1 was crushed by %s\n"), s2, s1));
1585 } else if(type == DEATH_SBMINIGUN) {
1586 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1588 print (sprintf(_("^1%s^1 got shredded by %s\n"), s2, s1));
1589 } else if(type == DEATH_SBROCKET) {
1590 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1592 print (sprintf(_("^1%s^1 was blasted to bits by %s\n"), s2, s1));
1593 } else if(type == DEATH_SBBLOWUP) {
1594 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1596 print (sprintf(_("^1%s^1 got caught in the destruction of %s^1's vehicle\n"), s2, s1));
1597 } else if(type == DEATH_WAKIGUN) {
1598 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1600 print (sprintf(_("^1%s^1 was bolted down by %s\n"), s2, s1));
1601 } else if(type == DEATH_WAKIROCKET) {
1602 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1604 print (sprintf(_("^1%s^1 could find no shelter from %s^1's rockets\n"), s2, s1));
1605 } else if(type == DEATH_WAKIBLOWUP) {
1606 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1608 print (sprintf(_("^1%s^1 dies when %s^1's wakizashi dies.\n"), s2, s1));
1609 } else if(type == DEATH_TURRET) {
1610 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1612 print (sprintf(_("^1%s^1 was pushed into the line of fire by %s\n"), s2, s1));
1613 } else if(type == DEATH_TOUCHEXPLODE) {
1614 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1616 print (sprintf(_("^1%s^1 was pushed into an accident by %s\n"), s2, s1));
1617 } else if(type == DEATH_CHEAT) {
1618 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1620 print (sprintf(_("^1%s^1 was unfairly eliminated by %s\n"), s2, s1));
1621 } else if (type == DEATH_FIRE) {
1622 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1624 print (sprintf(_("^1%s^1 was burnt to death by %s\n"), s2, s1));
1625 } else if (type == DEATH_CUSTOM) {
1626 HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
1628 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1629 } else if (type == DEATH_HURTTRIGGER) {
1630 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1632 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1634 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1636 print (sprintf(_("^1%s^1 was fragged by %s\n"), s2, s1));
1638 } else if(msg == MSG_SPREE) {
1639 if(type == KILL_END_SPREE) {
1641 print (sprintf(_("^1%s^1's %s scoring spree was ended by %s\n"), s1, s2, s3));
1643 print (sprintf(_("^1%s^1's %s kill spree was ended by %s\n"), s1, s2, s3));
1644 } else if(type == KILL_SPREE) {
1646 print (sprintf(_("^1%s^1 made %s scores in a row\n"), s1, s2));
1648 print (sprintf(_("^1%s^1 has %s frags in a row\n"), s1, s2));
1649 } else if(type == KILL_SPREE_3) {
1651 print (sprintf(_("%s^7 made a ^1TRIPLE SCORE\n"), s1));
1653 print (sprintf(_("%s^7 made a ^1TRIPLE FRAG\n"), s1));
1654 } else if(type == KILL_SPREE_5) {
1656 print (sprintf(_("%s^7 unleashes ^1SCORING RAGE\n"), s1));
1658 print (sprintf(_("%s^7 unleashes ^1RAGE\n"), s1));
1659 } else if(type == KILL_SPREE_10) {
1661 print (sprintf(_("%s^7 made ^1TEN SCORES IN A ROW!\n"), s1));
1663 print (sprintf(_("%s^7 starts the ^1MASSACRE!\n"), s1));
1664 } else if(type == KILL_SPREE_15) {
1666 print (sprintf(_("%s^7 made ^1FIFTEEN SCORES IN A ROW!\n"), s1));
1668 print (sprintf(_("%s^7 executes ^1MAYHEM!\n"), s1));
1669 } else if(type == KILL_SPREE_20) {
1671 print (sprintf(_("%s^7 made ^1TWENTY SCORES IN A ROW!\n"), s1));
1673 print (sprintf(_("%s^7 is a ^1BERSERKER!\n"), s1));
1674 } else if(type == KILL_SPREE_25) {
1676 print (sprintf(_("%s^7 made ^1TWENTY FIVE SCORES IN A ROW!\n"), s1));
1678 print (sprintf(_("%s^7 inflicts ^1CARNAGE!\n"), s1));
1679 } else if(type == KILL_SPREE_30) {
1681 print (sprintf(_("%s^7 made ^1THIRTY SCORES IN A ROW!\n"), s1));
1683 print (sprintf(_("%s^7 unleashes ^1ARMAGEDDON!\n"), s1));
1685 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
1686 if (type == DEATH_DROWN) {
1687 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
1691 print (sprintf(_("^1%s^1 was in the water for too long\n"), s1));
1693 print (sprintf(_("^1%s^1 drowned\n"), s1));
1695 } else if (type == DEATH_SLIME) {
1696 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
1698 print (sprintf(_("^1%s^1 was slimed\n"), s1));
1699 } else if (type == DEATH_LAVA) {
1700 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
1704 print (sprintf(_("^1%s^1 found a hot place\n"), s1));
1706 print (sprintf(_("^1%s^1 turned into hot slag\n"), s1));
1708 } else if (type == DEATH_FALL) {
1709 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1713 print (sprintf(_("^1%s^1 tested gravity (and it worked)\n"), s1));
1715 print (sprintf(_("^1%s^1 hit the ground with a crunch\n"), s1));
1717 } else if (type == DEATH_SHOOTING_STAR) {
1718 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
1720 print (sprintf(_("^1%s^1 became a shooting star\n"), s1));
1721 } else if (type == DEATH_SWAMP) {
1722 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1726 print (sprintf(_("^1%s^1 discovered a swamp\n"), s1));
1728 print (sprintf(_("^1%s^1 is now conserved for centuries to come\n"), s1));
1730 } else if(type == DEATH_TURRET) {
1731 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1733 print (sprintf(_("^1%s^1 was mowed down by a turret \n"), s1));
1734 } else if (type == DEATH_CUSTOM) {
1735 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
1737 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1738 } else if (type == DEATH_HURTTRIGGER) {
1739 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
1741 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1742 } else if(type == DEATH_TOUCHEXPLODE) {
1743 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1745 print (sprintf(_("^1%s^1 died in an accident\n"), s1));
1746 } else if(type == DEATH_CHEAT) {
1747 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1749 print (sprintf(_("^1%s^1 was unfairly eliminated\n"), s1));
1750 } else if(type == DEATH_FIRE) {
1751 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1755 print (sprintf(_("^1%s^1 felt a little hot\n"), s1));
1757 print (sprintf(_("^1%s^1 burnt to death\n"), s1));
1760 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1764 print (sprintf(_("^1%s^1 needs a restart\n"), s1));
1766 print (sprintf(_("^1%s^1 died\n"), s1));
1769 } else if(msg == MSG_KILL_ACTION_SPREE) {
1771 print (sprintf(_("^1%s^1 needs a restart after a %d scoring spree\n"), s1, stof(s2)));
1773 print (sprintf(_("^1%s^1 died with a %d kill spree\n"), s1, stof(s2)));
1774 } else if(msg == MSG_INFO) {
1775 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
1776 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
1777 print(sprintf(_("%s^7 got the %s\n"), s1, s2));
1778 } else if(type == INFO_LOSTFLAG) {
1779 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
1780 print(sprintf(_("%s^7 lost the %s\n"), s1, s2));
1781 } else if(type == INFO_PICKUPFLAG) {
1782 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
1783 print(sprintf(_("%s^7 picked up the %s\n"), s1, s2));
1784 } else if(type == INFO_RETURNFLAG) {
1785 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
1786 print(sprintf(_("%s^7 returned the %s\n"), s1, s2));
1787 } else if(type == INFO_CAPTUREFLAG) {
1788 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
1789 print(sprintf(_("%s^7 captured the %s%s\n"), s1, s2, s3));
1791 } else if(msg == MSG_RACE) {
1792 if(type == RACE_SERVER_RECORD) {
1793 HUD_KillNotify_Push(s1, s2, 1, RACE_SERVER_RECORD);
1795 else if(type == RACE_NEW_RANK) {
1796 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_RANK);
1798 else if(type == RACE_NEW_TIME) {
1799 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_TIME);
1801 else if(type == RACE_FAIL) {
1802 HUD_KillNotify_Push(s1, s2, 1, RACE_FAIL);
1804 } else if(msg == MSG_KA) {
1805 if(type == KA_PICKUPBALL) {
1806 HUD_KillNotify_Push(s1, s2, 0, KA_PICKUPBALL);
1808 print (sprintf(_("%s^7 has picked up the ball!\n"), s1));
1810 else if(type == KA_DROPBALL) {
1811 HUD_KillNotify_Push(s1, s2, 0, KA_DROPBALL);
1813 print(sprintf(_("%s^7 has dropped the ball!\n"), s1));
1818 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
1820 void HUD_Centerprint(string s1, string s2, float type, float msg)
1823 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
1824 if(msg == MSG_SUICIDE) {
1825 if (type == DEATH_TEAMCHANGE) {
1826 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("You are now on: %s"), s1)));
1827 } else if (type == DEATH_AUTOTEAMCHANGE) {
1828 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("You have been moved into a different team to improve team balance\nYou are now on: %s"), s1)));
1829 } else if (type == DEATH_CAMP) {
1831 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Reconsider your tactics, camper!")));
1833 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Die camper!")));
1834 } else if (type == DEATH_NOAMMO) {
1836 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You are reinserted into the game for running out of ammo...")));
1838 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You were killed for running out of ammo...")));
1839 } else if (type == DEATH_ROT) {
1841 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You need to preserve your health")));
1843 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You grew too old without taking your medicine")));
1844 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
1846 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Don't go against team mates!")));
1848 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Don't shoot your team mates!")));
1849 } else if (type == DEATH_QUIET) {
1851 } else { // generic message
1853 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You need to be more careful!")));
1855 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You killed your own dumb self!")));
1857 } else if(msg == MSG_KILL) {
1858 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
1860 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1Moron! You went against %s, a team mate!"), s1)));
1862 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1Moron! You fragged %s, a team mate!"), s1)));
1864 } else if (type == KILL_FIRST_BLOOD) {
1866 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First score")));
1868 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First blood")));
1870 } else if (type == KILL_FIRST_VICTIM) {
1872 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First casualty")));
1874 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First victim")));
1876 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
1878 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You scored against ^7%s^1 who was typing!"), s1), s2));
1880 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You typefragged ^7%s"), s1), s2));
1882 } else if (type == KILL_TYPEFRAGGED) {
1884 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were scored against by ^7%s^1 while you were typing!"), s1), s2));
1886 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were typefragged by ^7%s"), s1), s2));
1888 } else if (type == KILL_FRAG) {
1890 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^4You scored against ^7%s"), s1), s2));
1892 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^4You fragged ^7%s"), s1), s2));
1894 } else { // generic message
1896 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were scored against by ^7%s"), s1), s2));
1898 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were fragged by ^7%s"), s1), s2));
1901 } else if(msg == MSG_KILL_ACTION) {
1902 // TODO: invent more centerprints here?
1903 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Watch your step!")));
1907 void HUD_Notify (void)
1909 if(!autocvar__hud_configure)
1911 if(!autocvar_hud_panel_notify) return;
1914 hud_configure_active_panel = HUD_PANEL_NOTIFY;
1916 HUD_Panel_UpdateCvars(notify);
1919 mySize = panel_size;
1921 HUD_Panel_DrawBg(1);
1922 if(panel_bg_padding)
1924 pos += '1 1 0' * panel_bg_padding;
1925 mySize -= '2 2 0' * panel_bg_padding;
1928 float entries, height;
1929 entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES);
1930 height = mySize_y/entries;
1933 float fontheight = height * autocvar_hud_panel_notify_fontsize;
1934 fontsize = '0.5 0.5 0' * fontheight;
1938 when = autocvar_hud_panel_notify_time;
1940 fadetime = autocvar_hud_panel_notify_fadetime;
1944 vector pos_attacker, pos_victim;
1946 float width_attacker;
1947 string attacker, victim;
1949 float i, j, w, step, limit;
1950 if(autocvar_hud_panel_notify_flip) //order items from the top down
1956 else //order items from the bottom up
1963 for(j = kn_index; i != limit; i += step, ++j)
1965 if(autocvar__hud_configure)
1969 else // inverse order
1970 a = entries - 1 - i;
1971 attacker = textShortenToWidth(sprintf(_("Player %d"), a+1), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
1972 victim = textShortenToWidth(sprintf(_("Player %d"), a+2), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
1973 s = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname);
1974 a = bound(0, (when - a) / 4, 1);
1975 goto hud_config_notifyprint;
1978 if (j == KN_MAX_ENTRIES)
1981 if(killnotify_times[j] + when > time)
1985 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
1999 w = DEATH_WEAPONOF(killnotify_deathtype[j]);
2001 // TODO: maybe print in team colors?
2004 if(killnotify_actiontype[j] == 0)
2006 if(killnotify_deathtype[j] == DEATH_GENERIC)
2010 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2012 s = "notify_outofammo";
2014 else if(killnotify_deathtype[j] == DEATH_KILL)
2016 s = "notify_selfkill";
2018 else if(killnotify_deathtype[j] == DEATH_CAMP)
2020 s = "notify_camping";
2022 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2024 s = "notify_teamkill_red";
2026 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2028 s = "notify_teamkill_blue";
2030 else if(killnotify_deathtype[j] == DEATH_DROWN)
2034 else if(killnotify_deathtype[j] == DEATH_SLIME)
2038 else if(killnotify_deathtype[j] == DEATH_LAVA)
2042 else if(killnotify_deathtype[j] == DEATH_FALL)
2046 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2048 s = "notify_shootingstar";
2050 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2054 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2056 if(killnotify_victims[j] == "^1RED^7 flag")
2058 s = "notify_red_taken";
2062 s = "notify_blue_taken";
2065 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2067 if(killnotify_victims[j] == "^1RED^7 flag")
2069 s = "notify_red_returned";
2073 s = "notify_blue_returned";
2076 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2078 if(killnotify_victims[j] == "^1RED^7 flag")
2080 s = "notify_red_lost";
2084 s = "notify_blue_lost";
2087 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
2089 if(killnotify_victims[j] == "^1RED^7 flag")
2091 s = "notify_red_captured";
2095 s = "notify_blue_captured";
2098 else if(killnotify_deathtype[j] == KA_DROPBALL)
2100 s = "notify_balldropped";
2102 else if(killnotify_deathtype[j] == KA_PICKUPBALL)
2104 s = "notify_ballpickedup";
2107 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2108 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2109 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2113 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2114 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2117 // X [did action to] Y
2120 if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
2122 s = "notify_melee_laser";
2124 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_SHOTGUN)
2126 s = "notify_melee_shotgun";
2128 else if(WEP_VALID(w))
2130 self = get_weaponinfo(w);
2131 s = strcat("weapon", self.netname);
2133 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2135 s = "notify_teamkill_red";
2137 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2139 s = "notify_teamkill_red";
2141 else if(killnotify_deathtype[j] == DEATH_TELEFRAG)
2143 s = "notify_telefrag";
2145 else if(killnotify_deathtype[j] == DEATH_DROWN)
2149 else if(killnotify_deathtype[j] == DEATH_SLIME)
2153 else if(killnotify_deathtype[j] == DEATH_LAVA)
2157 else if(killnotify_deathtype[j] == DEATH_FALL)
2161 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2163 s = "notify_shootingstar";
2165 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2169 else if(killnotify_deathtype[j] == DEATH_HEADSHOT)
2171 s = "notify_headshot";
2173 else if(killnotify_deathtype[j] == RACE_SERVER_RECORD)
2175 s = "race_newrecordserver";
2177 else if(killnotify_deathtype[j] == RACE_NEW_RANK)
2179 s = "race_newrankyellow";
2181 else if(killnotify_deathtype[j] == RACE_NEW_TIME)
2185 else if(killnotify_deathtype[j] == RACE_FAIL)
2190 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2191 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2192 :hud_config_notifyprint
2193 width_attacker = stringwidth(attacker, TRUE, fontsize);
2194 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2195 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2196 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2200 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2201 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2202 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2211 string seconds_tostring(float sec)
2214 minutes = floor(sec / 60);
2216 sec -= minutes * 60;
2217 return sprintf("%d:%02d", minutes, sec);
2220 void HUD_Timer(void)
2222 if(!autocvar__hud_configure)
2224 if(!autocvar_hud_panel_timer) return;
2227 hud_configure_active_panel = HUD_PANEL_TIMER;
2229 HUD_Panel_UpdateCvars(timer);
2232 mySize = panel_size;
2234 HUD_Panel_DrawBg(1);
2235 if(panel_bg_padding)
2237 pos += '1 1 0' * panel_bg_padding;
2238 mySize -= '2 2 0' * panel_bg_padding;
2242 float timelimit, elapsedTime, timeleft, minutesLeft;
2244 timelimit = getstatf(STAT_TIMELIMIT);
2246 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
2247 timeleft = ceil(timeleft);
2249 minutesLeft = floor(timeleft / 60);
2252 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
2253 timer_color = '1 1 1'; //white
2254 else if(minutesLeft >= 1)
2255 timer_color = '1 1 0'; //yellow
2257 timer_color = '1 0 0'; //red
2259 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
2260 if (time < getstatf(STAT_GAMESTARTTIME)) {
2261 //while restart is still active, show 00:00
2262 timer = seconds_tostring(0);
2264 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
2265 timer = seconds_tostring(elapsedTime);
2268 timer = seconds_tostring(timeleft);
2271 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2276 void HUD_Radar(void)
2278 if (!autocvar__hud_configure)
2280 if (autocvar_hud_panel_radar == 0) return;
2281 if (autocvar_hud_panel_radar != 2 && !teamplay) return;
2284 hud_configure_active_panel = HUD_PANEL_RADAR;
2286 HUD_Panel_UpdateCvars(radar);
2289 mySize = panel_size;
2291 HUD_Panel_DrawBg(1);
2292 if(panel_bg_padding)
2294 pos += '1 1 0' * panel_bg_padding;
2295 mySize -= '2 2 0' * panel_bg_padding;
2300 float scale2d, normalsize, bigsize;
2303 teamradar_origin2d = pos + 0.5 * mySize;
2304 teamradar_size2d = mySize;
2306 if(minimapname == "")
2309 teamradar_loadcvars();
2311 switch(hud_panel_radar_zoommode)
2315 f = current_zoomfraction;
2318 f = 1 - current_zoomfraction;
2328 switch(hud_panel_radar_rotation)
2331 teamradar_angle = view_angles_y - 90;
2334 teamradar_angle = 90 * hud_panel_radar_rotation;
2338 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
2339 teamradar_size2d = mySize;
2341 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
2343 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
2344 if(hud_panel_radar_rotation == 0)
2346 // max-min distance must fit the radar in any rotation
2347 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_scale));
2351 vector c0, c1, c2, c3, span;
2352 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
2353 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
2354 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
2355 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
2357 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
2358 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
2360 // max-min distance must fit the radar in x=x, y=y
2362 teamradar_size2d_x * scale2d / (1.05 * span_x),
2363 teamradar_size2d_y * scale2d / (1.05 * span_y)
2367 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
2368 if(bigsize > normalsize)
2369 normalsize = bigsize;
2373 + (1 - f) * normalsize;
2374 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
2376 + (1 - f) * view_origin);
2385 draw_teamradar_background(hud_panel_radar_foreground_alpha);
2387 for(tm = world; (tm = find(tm, classname, "radarlink")); )
2388 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
2389 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
2390 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
2391 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
2393 color2 = GetPlayerColor(tm.sv_entnum);
2394 //if(color == COLOR_SPECTATOR || color == color2)
2395 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
2397 draw_teamradar_player(view_origin, view_angles, '1 1 1');
2399 drawresetcliparea();
2404 void HUD_UpdatePlayerTeams();
2405 void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count)
2409 #define SCOREPANEL_MAX_ENTRIES 6
2410 #define SCOREPANEL_ASPECTRATIO 2
2411 const float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
2412 const vector fontsize = '1 1 0' * (mySize_y/entries);
2414 vector rgb, score_color;
2416 score_color = '1 1 1';
2418 const float name_size = mySize_x*0.75;
2419 const float spacing_size = mySize_x*0.04;
2420 const float highlight_alpha = 0.2;
2421 float i, me_printed, first_pl;
2424 if (autocvar__hud_configure)
2426 float players_per_team;
2429 // show team scores in the first line
2430 float score_size = mySize_x / team_count;
2431 players_per_team = max(2, ceil((entries - 1) / team_count));
2432 for(i=0; i<team_count; ++i) {
2433 if (i == floor((entries - 2) / players_per_team) || (entries == 1 && i == 0))
2434 HUD_Panel_DrawHighlight(pos + eX * score_size * i, eX * score_size + eY * fontsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2435 drawstring_aspect(pos + eX * score_size * i, ftos(175 - 23*i), eX * score_size + eY * fontsize_y, GetTeamRGB(ColorByTeam(i)) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2438 pos_y += fontsize_y;
2440 score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
2441 for (i=first_pl; i<entries; ++i)
2443 //simulate my score is lower than all displayed players,
2444 //so that I don't appear at all showing pure rankings.
2445 //This is to better show the difference between the 2 ranking views
2446 if (i == entries-1 && autocvar_hud_panel_score_rankings == 1)
2449 drawfill(pos, eX * mySize_x + eY * fontsize_y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2450 s = GetPlayerName(pl.sv_entnum);
2455 s = sprintf(_("Player %d"), i + 1 - first_pl);
2460 score_color = GetTeamRGB(ColorByTeam(floor((i - first_pl) / players_per_team))) * 0.8;
2461 s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
2462 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2463 drawstring(pos + eX * (name_size + spacing_size), ftos(score), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2464 pos_y += fontsize_y;
2469 if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
2470 HUD_UpdatePlayerTeams();
2473 // show team scores in the first line
2474 float score_size = mySize_x / team_count;
2475 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2476 if(tm.team == COLOR_SPECTATOR)
2478 if (tm.team == myteam)
2479 drawfill(pos + eX * score_size * i, eX * score_size + eY * fontsize_y, '1 1 1', highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2480 drawstring_aspect(pos + eX * score_size * i, ftos(tm.(teamscores[ts_primary])), eX * score_size + eY * fontsize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2484 pos_y += fontsize_y;
2485 tm = teams.sort_next;
2490 for (pl = players.sort_next; pl && i<entries; pl = pl.sort_next)
2492 if ((team_count && pl.team != tm.team) || pl.team == COLOR_SPECTATOR)
2495 if (i == entries-1 && !me_printed && pl != me)
2496 if (autocvar_hud_panel_score_rankings == 1 && spectatee_status != -1)
2498 for (pl = me.sort_next; pl; pl = pl.sort_next)
2499 if (pl.team != COLOR_SPECTATOR)
2503 rgb = '1 1 0'; //not last but not among the leading players: yellow
2505 rgb = '1 0 0'; //last: red
2512 rgb = '0 1 0'; //first: green
2514 drawfill(pos, eX * mySize_x + eY * fontsize_y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2517 score_color = GetTeamRGB(pl.team) * 0.8;
2518 s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
2519 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2520 drawstring(pos + eX * (name_size + spacing_size), ftos(pl.(scores[ps_primary])), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2521 pos_y += fontsize_y;
2524 while (i<entries && team_count && (tm = tm.sort_next) && (tm.team != COLOR_SPECTATOR || (tm = tm.sort_next)));
2527 void HUD_Score(void)
2529 if(!autocvar__hud_configure)
2531 if(!autocvar_hud_panel_score) return;
2532 if(spectatee_status == -1 && (gametype == GAME_RACE || gametype == GAME_CTS)) return;
2535 hud_configure_active_panel = HUD_PANEL_SCORE;
2537 HUD_Panel_UpdateCvars(score);
2540 mySize = panel_size;
2542 HUD_Panel_DrawBg(1);
2543 if(panel_bg_padding)
2545 pos += '1 1 0' * panel_bg_padding;
2546 mySize -= '2 2 0' * panel_bg_padding;
2549 float score, distribution;
2551 vector distribution_color;
2553 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
2555 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
2556 string timer, distrtimer;
2558 pl = players.sort_next;
2561 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
2562 if(pl.scores[ps_primary] == 0)
2565 score = me.(scores[ps_primary]);
2566 timer = TIME_ENCODED_TOSTRING(score);
2568 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
2569 // distribution display
2570 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2572 distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS);
2574 if (distribution <= 0) {
2575 distribution_color = '0 1 0';
2579 distribution_color = '1 0 0';
2582 drawstring_aspect(pos + eX * 0.75 * mySize_x, strcat(sign, distrtimer), eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2584 // race record display
2585 if (distribution <= 0)
2586 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2587 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2588 } else if (!teamplay) { // non-teamgames
2589 if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings)
2591 HUD_Score_Rankings(pos, mySize, me, 0);
2594 // me vector := [team/connected frags id]
2595 pl = players.sort_next;
2599 if(autocvar__hud_configure)
2602 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2606 score = me.(scores[ps_primary]);
2607 if(autocvar__hud_configure)
2610 if(distribution >= 5)
2611 distribution_color = eY;
2612 else if(distribution >= 0)
2613 distribution_color = '1 1 1';
2614 else if(distribution >= -5)
2615 distribution_color = '1 1 0';
2617 distribution_color = eX;
2619 string distribution_str;
2620 distribution_str = ftos(distribution);
2621 if (distribution >= 0)
2623 if (distribution > 0)
2624 distribution_str = strcat("+", distribution_str);
2625 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2627 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2628 drawstring_aspect(pos + eX * 0.75 * mySize_x, distribution_str, eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2629 } else { // teamgames
2630 float scores_count, row, column, rows, columns;
2632 vector score_pos, score_size; //for scores other than myteam
2633 if (spectatee_status == -1 || autocvar_hud_panel_score_rankings)
2635 for(tm = teams.sort_next; tm, tm.team != COLOR_SPECTATOR; tm = tm.sort_next)
2637 if (autocvar_hud_panel_score_rankings)
2639 HUD_Score_Rankings(pos, mySize, me, scores_count);
2642 rows = mySize_y/mySize_x;
2643 rows = bound(1, floor((sqrt(4 * (3/1) * rows * scores_count + rows * rows) + rows + 0.5) / 2), scores_count);
2644 // ^^^ ammo item aspect goes here
2646 columns = ceil(scores_count/rows);
2648 score_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
2651 if(score_size_x/score_size_y > 3)
2653 newSize = 3 * score_size_y;
2654 offset_x = score_size_x - newSize;
2655 pos_x += offset_x/2;
2656 score_size_x = newSize;
2660 newSize = 1/3 * score_size_x;
2661 offset_y = score_size_y - newSize;
2662 pos_y += offset_y/2;
2663 score_size_y = newSize;
2667 score_size = eX * mySize_x*(1/4) + eY * mySize_y*(1/3);
2669 float max_fragcount;
2670 max_fragcount = -99;
2671 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2672 if(tm.team == COLOR_SPECTATOR)
2674 score = tm.(teamscores[ts_primary]);
2675 if(autocvar__hud_configure)
2678 if (score > max_fragcount)
2679 max_fragcount = score;
2681 if (spectatee_status == -1)
2683 score_pos = pos + eX * column * (score_size_x + offset_x) + eY * row * (score_size_y + offset_y);
2684 if (max_fragcount == score)
2685 HUD_Panel_DrawHighlight(score_pos, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2686 drawstring_aspect(score_pos, ftos(score), score_size, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2694 else if(tm.team == myteam) {
2695 if (max_fragcount == score)
2696 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2697 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2699 if (max_fragcount == score)
2700 HUD_Panel_DrawHighlight(pos + eX * 0.75 * mySize_x + eY * (1/3) * rows * mySize_y, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2701 drawstring_aspect(pos + eX * 0.75 * mySize_x + eY * (1/3) * rows * mySize_y, ftos(score), score_size, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2710 void HUD_RaceTimer (void)
2712 if(!autocvar__hud_configure)
2714 if(!autocvar_hud_panel_racetimer) return;
2715 if(!(gametype == GAME_RACE || gametype == GAME_CTS)) return;
2716 if(spectatee_status == -1) return;
2719 hud_configure_active_panel = HUD_PANEL_RACETIMER;
2721 HUD_Panel_UpdateCvars(racetimer);
2724 mySize = panel_size;
2726 HUD_Panel_DrawBg(1);
2727 if(panel_bg_padding)
2729 pos += '1 1 0' * panel_bg_padding;
2730 mySize -= '2 2 0' * panel_bg_padding;
2733 // always force 4:1 aspect
2735 if(mySize_x/mySize_y > 4)
2737 newSize_x = 4 * mySize_y;
2738 newSize_y = mySize_y;
2740 pos_x = pos_x + (mySize_x - newSize_x) / 2;
2744 newSize_y = 1/4 * mySize_x;
2745 newSize_x = mySize_x;
2747 pos_y = pos_y + (mySize_y - newSize_y) / 2;
2752 string s, forcetime;
2754 if(autocvar__hud_configure)
2757 drawstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, FALSE, '0.60 0.60 0' * mySize_y), s, '0.60 0.60 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2758 s = _("^1Intermediate 1 (+15.42)");
2759 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.20 * mySize_y) + eY * 0.60 * mySize_y, s, '1 1 0' * 0.20 * mySize_y, panel_fg_alpha, DRAWFLAG_NORMAL);
2760 s = sprintf(_("^1PENALTY: %.1f (%s)"), 2, "missing a checkpoint");
2761 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.20 * mySize_y) + eY * 0.80 * mySize_y, s, '1 1 0' * 0.20 * mySize_y, panel_fg_alpha, DRAWFLAG_NORMAL);
2763 else if(race_checkpointtime)
2765 a = bound(0, 2 - (time - race_checkpointtime), 1);
2768 if(a > 0) // just hit a checkpoint?
2770 if(race_checkpoint != 254)
2772 if(race_time && race_previousbesttime)
2773 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
2775 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
2777 forcetime = TIME_ENCODED_TOSTRING(race_time);
2782 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
2784 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
2785 if(a > 0) // next one?
2787 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
2792 if(s != "" && a > 0)
2794 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2797 if(race_penaltytime)
2799 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
2802 s = sprintf(_("^1PENALTY: %.1f (%s)"), race_penaltytime * 0.1, race_penaltyreason);
2803 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.8 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2809 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
2810 drawstring_expanding(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(forcetime, FALSE, '1 1 0' * 0.6 * mySize_y), forcetime, '1 1 0' * 0.6 * mySize_y, '1 1 1', panel_fg_alpha, 0, a);
2815 if(race_laptime && race_checkpoint != 255)
2817 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
2818 drawstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, FALSE, '0.6 0.6 0' * mySize_y), s, '0.6 0.6 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2823 if(race_mycheckpointtime)
2825 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
2826 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
2827 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2829 if(race_othercheckpointtime && race_othercheckpointenemy != "")
2831 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
2832 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
2833 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2836 if(race_penaltytime && !race_penaltyaccumulator)
2838 t = race_penaltytime * 0.1 + race_penaltyeventtime;
2839 a = bound(0, (1 + t - time), 1);
2843 s = sprintf(_("^1PENALTY: %.1f (%s)"), (t - time) * 0.1, race_penaltyreason);
2845 s = sprintf(_("^2PENALTY: %.1f (%s)"), 0, race_penaltyreason);
2846 drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2854 float vote_yescount;
2857 float vote_highlighted; // currently selected vote
2859 float vote_active; // is there an active vote?
2860 float vote_prev; // previous state of vote_active to check for a change
2862 float vote_change; // "time" when vote_active changed
2864 void HUD_VoteWindow(void)
2866 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
2869 if (autocvar__hud_configure)
2873 print(_("^1You must answer before entering hud configure mode\n"));
2874 cvar_set("_hud_configure", "0");
2876 vote_called_vote = strzone(_("^2Name ^7instead of \"^1Unregistered player^7\" in stats"));
2877 uid2name_dialog = 1;
2880 if(!autocvar__hud_configure)
2882 if(!autocvar_hud_panel_vote) return;
2884 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
2885 panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
2887 if(panel_bg_alpha_str == "") {
2888 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
2890 panel_bg_alpha = stof(panel_bg_alpha_str);
2894 hud_configure_active_panel = HUD_PANEL_VOTE;
2903 if(vote_active != vote_prev) {
2905 vote_prev = vote_active;
2908 if(vote_active || autocvar__hud_configure)
2909 vote_alpha = bound(0, (time - vote_change) * 2, 1);
2911 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
2916 HUD_Panel_UpdateCvars(vote);
2920 panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight;
2921 panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
2924 // these must be below above block
2927 mySize = panel_size;
2929 a = vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
2930 HUD_Panel_DrawBg(a);
2931 a = panel_fg_alpha * a;
2933 if(panel_bg_padding)
2935 pos += '1 1 0' * panel_bg_padding;
2936 mySize -= '2 2 0' * panel_bg_padding;
2939 // always force 3:1 aspect
2941 if(mySize_x/mySize_y > 3)
2943 newSize_x = 3 * mySize_y;
2944 newSize_y = mySize_y;
2946 pos_x = pos_x + (mySize_x - newSize_x) / 2;
2950 newSize_y = 1/3 * mySize_x;
2951 newSize_x = mySize_x;
2953 pos_y = pos_y + (mySize_y - newSize_y) / 2;
2957 s = _("A vote has been called for:");
2959 s = _("Allow servers to store and display your name?");
2960 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
2961 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1/8), stringwidth_colors);
2962 if(autocvar__hud_configure)
2963 s = _("^1Configure the HUD");
2964 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
2966 // print the yes/no counts
2967 s = sprintf(_("Yes (%s): %d"), getcommandkey("vyes", "vyes"), vote_yescount);
2968 drawstring_aspect(pos + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '0 1 0', a, DRAWFLAG_NORMAL);
2969 s = sprintf(_("No (%s): %d"), getcommandkey("vno", "vno"), vote_nocount);
2970 drawstring_aspect(pos + eX * 0.5 * mySize_x + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '1 0 0', a, DRAWFLAG_NORMAL);
2972 // draw the progress bar backgrounds
2973 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
2975 // draw the highlights
2976 if(vote_highlighted == 1) {
2977 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
2978 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
2980 else if(vote_highlighted == 2) {
2981 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
2982 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
2985 // draw the progress bars
2986 if(vote_yescount && vote_needed)
2988 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
2989 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
2992 if(vote_nocount && vote_needed)
2994 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
2995 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
2998 drawresetcliparea();
3001 vote_highlighted = 0;
3005 // Mod icons panel (#10)
3008 float mod_active; // is there any active mod icon?
3010 // Clan Arena HUD modicons
3011 void HUD_Mod_CA(vector pos, vector mySize)
3013 mod_active = 1; // CA should never hide the mod icons panel
3014 float redalive, bluealive;
3015 redalive = getstati(STAT_REDALIVE);
3016 bluealive = getstati(STAT_BLUEALIVE);
3018 vector redpos, bluepos;
3019 if(mySize_x > mySize_y)
3022 bluepos = pos + eY * 0.5 * mySize_y;
3023 drawpic_aspect_skin(redpos, "player_red.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3024 drawstring_aspect(redpos + eX * 0.5 * mySize_x, ftos(redalive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3025 drawpic_aspect_skin(bluepos, "player_blue.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3026 drawstring_aspect(bluepos + eX * 0.5 * mySize_x, ftos(bluealive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3031 bluepos = pos + eY * 0.5 * mySize_y;
3032 drawpic_aspect_skin(redpos, "player_red.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3033 drawstring_aspect(redpos + eY * 0.3 * mySize_y, ftos(redalive), eX * mySize_x + eY * 0.2 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3034 drawpic_aspect_skin(bluepos, "player_blue.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3035 drawstring_aspect(bluepos + eY * 0.3 * mySize_y, ftos(bluealive), eX * mySize_x + eY * 0.2 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3039 // CTF HUD modicon section
3040 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3041 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3042 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3044 void HUD_Mod_CTF_Reset(void)
3046 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3049 void HUD_Mod_CTF(vector pos, vector mySize)
3051 vector redflag_pos, blueflag_pos;
3053 float f; // every function should have that
3055 float redflag, blueflag; // current status
3056 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3059 stat_items = getstati(STAT_ITEMS);
3060 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3061 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3063 if(redflag || blueflag)
3068 if(autocvar__hud_configure)
3074 // when status CHANGES, set old status into prevstatus and current status into status
3075 if (redflag != redflag_prevframe)
3077 redflag_statuschange_time = time;
3078 redflag_prevstatus = redflag_prevframe;
3079 redflag_prevframe = redflag;
3082 if (blueflag != blueflag_prevframe)
3084 blueflag_statuschange_time = time;
3085 blueflag_prevstatus = blueflag_prevframe;
3086 blueflag_prevframe = blueflag;
3089 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3090 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3092 float BLINK_FACTOR = 0.15;
3093 float BLINK_BASE = 0.85;
3095 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3097 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3099 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3101 string red_icon, red_icon_prevstatus;
3102 float red_alpha, red_alpha_prevstatus;
3103 red_alpha = red_alpha_prevstatus = 1;
3105 case 1: red_icon = "flag_red_taken"; break;
3106 case 2: red_icon = "flag_red_lost"; break;
3107 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3109 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3110 red_icon = "flag_red_shielded";
3112 red_icon = string_null;
3115 switch(redflag_prevstatus) {
3116 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3117 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3118 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3121 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3122 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3123 red_icon_prevstatus = "flag_red_shielded";
3125 red_icon_prevstatus = string_null;
3129 string blue_icon, blue_icon_prevstatus;
3130 float blue_alpha, blue_alpha_prevstatus;
3131 blue_alpha = blue_alpha_prevstatus = 1;
3133 case 1: blue_icon = "flag_blue_taken"; break;
3134 case 2: blue_icon = "flag_blue_lost"; break;
3135 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3137 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3138 blue_icon = "flag_blue_shielded";
3140 blue_icon = string_null;
3143 switch(blueflag_prevstatus) {
3144 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3145 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3146 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3149 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3150 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3151 blue_icon_prevstatus = "flag_blue_shielded";
3153 blue_icon_prevstatus = string_null;
3157 if(mySize_x > mySize_y) {
3158 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3160 blueflag_pos = pos + eX * 0.5 * mySize_x;
3163 redflag_pos = pos + eX * 0.5 * mySize_x;
3165 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3167 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3169 blueflag_pos = pos + eY * 0.5 * mySize_y;
3172 redflag_pos = pos + eY * 0.5 * mySize_y;
3174 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3177 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3178 if(red_icon_prevstatus && f < 1)
3179 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3181 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3183 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3184 if(blue_icon_prevstatus && f < 1)
3185 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3187 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3190 // Keyhunt HUD modicon section
3191 float kh_runheretime;
3193 void HUD_Mod_KH_Reset(void)
3198 void HUD_Mod_KH(vector pos, vector mySize)
3200 mod_active = 1; // keyhunt should never hide the mod icons panel
3204 vector p, pa, kh_size, kh_asize;
3206 kh_keys = getstati(STAT_KH_KEYS);
3209 if(mySize_x > mySize_y)
3211 p_y = pos_y + 0.25 * mySize_y;
3212 pa = p - eY * 0.25 * mySize_y;
3214 kh_size_x = mySize_x * 0.25;
3215 kh_size_y = 0.75 * mySize_y;
3216 kh_asize_x = mySize_x * 0.25;
3217 kh_asize_y = mySize_y * 0.25;
3221 p_y = pos_y + 0.125 * mySize_y;
3222 pa = p - eY * 0.125 * mySize_y;
3224 kh_size_x = mySize_x * 0.5;
3225 kh_size_y = 0.375 * mySize_y;
3226 kh_asize_x = mySize_x * 0.5;
3227 kh_asize_y = mySize_y * 0.125;
3234 for(i = 0; i < 4; ++i)
3236 key = floor(kh_keys / pow(32, i)) & 31;
3238 if(keyteam == 30 && keycount <= 4)
3240 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3244 // this yields 8 exactly if "RUN HERE" shows
3249 kh_runheretime = time;
3250 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3255 for(i = 0; i < 4; ++i)
3257 key = floor(kh_keys / pow(32, i)) & 31;
3270 default: // owned or dropped
3275 a = a * panel_fg_alpha;
3276 aa = aa * panel_fg_alpha;
3282 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3285 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3288 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3291 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3296 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3299 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3302 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3305 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3308 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3312 if(mySize_x > mySize_y)
3314 p_x += 0.25 * mySize_x;
3315 pa_x += 0.25 * mySize_x;
3321 p_y = pos_y + 0.625 * mySize_y;
3322 pa_y = pos_y + 0.5 * mySize_y;
3328 p_x += 0.5 * mySize_x;
3329 pa_x += 0.5 * mySize_x;
3335 // Keepaway HUD mod icon
3336 float kaball_prevstatus; // last remembered status
3337 float kaball_statuschange_time; // time when the status changed
3339 // we don't need to reset for keepaway since it immediately
3340 // autocorrects prevstatus as to if the player has the ball or not
3342 void HUD_Mod_Keepaway(vector pos, vector mySize)
3344 mod_active = 1; // keepaway should always show the mod HUD
3346 float BLINK_FACTOR = 0.15;
3347 float BLINK_BASE = 0.85;
3348 float BLINK_FREQ = 5;
3349 float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
3351 float stat_items = getstati(STAT_ITEMS);
3352 float kaball = (stat_items/IT_KEY1) & 1;
3354 if(kaball != kaball_prevstatus)
3356 kaball_statuschange_time = time;
3357 kaball_prevstatus = kaball;
3360 vector kaball_pos, kaball_size;
3362 if(mySize_x > mySize_y) {
3363 kaball_pos = pos + eX * 0.25 * mySize_x;
3364 kaball_size = eX * 0.5 * mySize_x + eY * mySize_y;
3366 kaball_pos = pos + eY * 0.25 * mySize_y;
3367 kaball_size = eY * 0.5 * mySize_y + eX * mySize_x;
3370 float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
3371 float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
3373 if(kaball_prevstatus && f < 1)
3374 drawpic_aspect_skin_expanding(kaball_pos, "keepawayball_carrying", kaball_size, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
3377 drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
3381 // Nexball HUD mod icon
3382 void HUD_Mod_NexBall(vector pos, vector mySize)
3384 float stat_items, nb_pb_starttime, dt, p;
3386 stat_items = getstati(STAT_ITEMS);
3387 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3389 if (stat_items & IT_KEY1)
3394 //Manage the progress bar if any
3395 if (nb_pb_starttime > 0)
3397 dt = mod(time - nb_pb_starttime, nb_pb_period);
3398 // one period of positive triangle
3399 p = 2 * dt / nb_pb_period;
3404 HUD_Panel_GetProgressBarColor(nexball);
3405 if(mySize_x > mySize_y)
3406 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, 0, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3408 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, 1, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3411 if (stat_items & IT_KEY1)
3412 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3415 // Race/CTS HUD mod icons
3416 float crecordtime_prev; // last remembered crecordtime
3417 float crecordtime_change_time; // time when crecordtime last changed
3418 float srecordtime_prev; // last remembered srecordtime
3419 float srecordtime_change_time; // time when srecordtime last changed
3421 float race_status_time;
3422 float race_status_prev;
3423 string race_status_name_prev;
3424 void HUD_Mod_Race(vector pos, vector mySize)
3426 mod_active = 1; // race should never hide the mod icons panel
3428 me = playerslots[player_localentnum - 1];
3430 float f; // yet another function has this
3431 score = me.(scores[ps_primary]);
3433 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3434 return; // no records in the actual race
3436 // clientside personal record
3438 if(gametype == GAME_CTS)
3442 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3444 if(score && (score < t || !t)) {
3445 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3446 if(autocvar_cl_autodemo_delete_keeprecords)
3448 f = autocvar_cl_autodemo_delete;
3450 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3454 if(t != crecordtime_prev) {
3455 crecordtime_prev = t;
3456 crecordtime_change_time = time;
3459 vector textPos, medalPos;
3461 if(mySize_x > mySize_y) {
3462 // text on left side
3463 squareSize = min(mySize_y, mySize_x/2);
3464 textPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eY * 0.5 * (mySize_y - squareSize);
3465 medalPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eX * 0.5 * mySize_x + eY * 0.5 * (mySize_y - squareSize);
3468 squareSize = min(mySize_x, mySize_y/2);
3469 textPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eX * 0.5 * (mySize_x - squareSize);
3470 medalPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eY * 0.5 * mySize_y + eX * 0.5 * (mySize_x - squareSize);
3473 f = time - crecordtime_change_time;
3476 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3477 drawstring_aspect(textPos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3479 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3480 drawstring_aspect(textPos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3481 drawstring_aspect_expanding(pos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
3482 drawstring_aspect_expanding(pos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
3486 t = race_server_record;
3487 if(t != srecordtime_prev) {
3488 srecordtime_prev = t;
3489 srecordtime_change_time = time;
3491 f = time - srecordtime_change_time;
3494 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3495 drawstring_aspect(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3497 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3498 drawstring_aspect(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3499 drawstring_aspect_expanding(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
3500 drawstring_aspect_expanding(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
3503 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
3504 race_status_time = time + 5;
3505 race_status_prev = race_status;
3506 if (race_status_name_prev)
3507 strunzone(race_status_name_prev);
3508 race_status_name_prev = strzone(race_status_name);
3513 a = bound(0, race_status_time - time, 1);
3516 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
3520 rank = race_CheckName(race_status_name);
3522 rankname = race_PlaceName(rank);
3525 namepos = medalPos + '0 0.8 0' * squareSize;
3527 rankpos = medalPos + '0 0.15 0' * squareSize;
3529 if(race_status == 0)
3530 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3531 else if(race_status == 1) {
3532 drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newtime", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3533 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3534 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3535 } else if(race_status == 2) {
3536 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
3537 drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrankgreen", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3539 drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrankyellow", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3540 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3541 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3542 } else if(race_status == 3) {
3543 drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrecordserver", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3544 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3545 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3548 if (race_status_time - time <= 0) {
3549 race_status_prev = -1;
3551 if(race_status_name)
3552 strunzone(race_status_name);
3553 race_status_name = string_null;
3554 if(race_status_name_prev)
3555 strunzone(race_status_name_prev);
3556 race_status_name_prev = string_null;
3560 void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, float layout, float i)
3562 float stat, pps_ratio;
3568 stat = getstatf(STAT_DOM_PPS_RED);
3569 pic = "dom_icon_red";
3573 stat = getstatf(STAT_DOM_PPS_BLUE);
3574 pic = "dom_icon_blue";
3578 stat = getstatf(STAT_DOM_PPS_YELLOW);
3579 pic = "dom_icon_yellow";
3583 stat = getstatf(STAT_DOM_PPS_PINK);
3584 pic = "dom_icon_pink";
3587 pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
3589 if(mySize_x/mySize_y > aspect_ratio)
3591 i = aspect_ratio * mySize_y;
3592 myPos_x = myPos_x + (mySize_x - i) / 2;
3597 i = 1/aspect_ratio * mySize_x;
3598 myPos_y = myPos_y + (mySize_y - i) / 2;
3602 if (layout) // show text too
3605 color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
3606 if (layout == 2) // average pps
3607 drawstring_aspect(myPos + eX * mySize_y, ftos_decimals(stat, 2), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
3608 else // percentage of average pps
3609 drawstring_aspect(myPos + eX * mySize_y, strcat( ftos(floor(pps_ratio*100 + 0.5)), "%" ), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
3613 drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3616 drawsetcliparea(myPos_x, myPos_y + mySize_y * (1 - pps_ratio), mySize_y, mySize_y * pps_ratio);
3617 drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3618 drawresetcliparea();
3622 void HUD_Mod_Dom(vector myPos, vector mySize)
3624 mod_active = 1; // required in each mod function that always shows something
3627 for(tm = teams.sort_next; tm; tm = tm.sort_next)
3628 if(tm.team != COLOR_SPECTATOR)
3631 float layout = autocvar_hud_panel_modicons_dom_layout;
3632 float rows, columns, aspect_ratio;
3633 rows = mySize_y/mySize_x;
3634 aspect_ratio = (layout) ? 3 : 1;
3635 rows = bound(1, floor((sqrt((4 * aspect_ratio * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count);
3636 columns = ceil(teams_count/rows);
3640 for(i=0; i<teams_count; ++i)
3642 vector pos, itemSize;
3643 pos = myPos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows);
3644 itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
3646 DrawDomItem(pos, itemSize, aspect_ratio, layout, i);
3657 float mod_prev; // previous state of mod_active to check for a change
3659 float mod_change; // "time" when mod_active changed
3661 void HUD_ModIcons(void)
3663 if(!autocvar__hud_configure)
3665 if(!autocvar_hud_panel_modicons) return;
3666 if (gametype != GAME_CTF && gametype != GAME_KEYHUNT && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && gametype != GAME_CA && gametype != GAME_FREEZETAG && gametype != GAME_KEEPAWAY && gametype != GAME_DOMINATION) return;
3669 hud_configure_active_panel = HUD_PANEL_MODICONS;
3671 HUD_Panel_UpdateCvars(modicons);
3674 mySize = panel_size;
3676 if(mod_active != mod_prev) {
3678 mod_prev = mod_active;
3681 if(mod_active || autocvar__hud_configure)
3682 mod_alpha = bound(0, (time - mod_change) * 2, 1);
3684 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
3687 HUD_Panel_DrawBg(mod_alpha);
3689 if(panel_bg_padding)
3691 pos += '1 1 0' * panel_bg_padding;
3692 mySize -= '2 2 0' * panel_bg_padding;
3695 // these MUST be ran in order to update mod_active
3696 if(gametype == GAME_KEYHUNT)
3697 HUD_Mod_KH(pos, mySize);
3698 else if(gametype == GAME_CTF || autocvar__hud_configure)
3699 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
3700 else if(gametype == GAME_NEXBALL)
3701 HUD_Mod_NexBall(pos, mySize);
3702 else if(gametype == GAME_CTS || gametype == GAME_RACE)
3703 HUD_Mod_Race(pos, mySize);
3704 else if(gametype == GAME_CA || gametype == GAME_FREEZETAG)
3705 HUD_Mod_CA(pos, mySize);
3706 else if(gametype == GAME_DOMINATION)
3707 HUD_Mod_Dom(pos, mySize);
3708 else if(gametype == GAME_KEEPAWAY)
3709 HUD_Mod_Keepaway(pos, mySize);
3712 // Draw pressed keys (#11)
3714 void HUD_DrawPressedKeys(void)
3716 if(!autocvar__hud_configure)
3718 if(!autocvar_hud_panel_pressedkeys) return;
3719 if(spectatee_status <= 0 && autocvar_hud_panel_pressedkeys < 2) return;
3722 hud_configure_active_panel = HUD_PANEL_PRESSEDKEYS;
3725 HUD_Panel_UpdateCvars(pressedkeys);
3728 mySize = panel_size;
3730 HUD_Panel_DrawBg(1);
3731 if(panel_bg_padding)
3733 pos += '1 1 0' * panel_bg_padding;
3734 mySize -= '2 2 0' * panel_bg_padding;
3737 // force custom aspect
3738 float aspect = autocvar_hud_panel_pressedkeys_aspect;
3742 if(mySize_x/mySize_y > aspect)
3744 newSize_x = aspect * mySize_y;
3745 newSize_y = mySize_y;
3747 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3751 newSize_y = 1/aspect * mySize_x;
3752 newSize_x = mySize_x;
3754 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3760 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
3762 pressedkeys = getstatf(STAT_PRESSED_KEYS);
3764 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3765 drawpic_aspect_skin(pos + eX * keysize_x, ((pressedkeys & KEY_FORWARD) ? "key_forward_inv.tga" : "key_forward.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3766 drawpic_aspect_skin(pos + eX * keysize_x * 2, ((pressedkeys & KEY_JUMP) ? "key_jump_inv.tga" : "key_jump.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3768 drawpic_aspect_skin(pos, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3769 drawpic_aspect_skin(pos + eX * keysize_x, ((pressedkeys & KEY_BACKWARD) ? "key_backward_inv.tga" : "key_backward.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3770 drawpic_aspect_skin(pos + eX * keysize_x * 2, ((pressedkeys & KEY_RIGHT) ? "key_right_inv.tga" : "key_right.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3773 // Handle chat as a panel (#12)
3777 if(!autocvar__hud_configure)
3779 if (!autocvar_hud_panel_chat)
3781 if (!autocvar_con_chatrect)
3782 cvar_set("con_chatrect", "0");
3787 hud_configure_active_panel = HUD_PANEL_CHAT;
3789 HUD_Panel_UpdateCvars(chat);
3791 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
3793 panel_pos_y = panel_bg_border;
3794 panel_size_y = vid_conheight - panel_bg_border * 2;
3795 if(panel_bg == "0") // force a border when maximized
3797 if(precache_pic(panel_bg) == "") {
3798 panel_bg = strcat(hud_skin_path, "/border_default");
3799 if(precache_pic(panel_bg) == "") {
3800 panel_bg = "gfx/hud/default/border_default";
3804 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an alpha of at least 0.75
3809 mySize = panel_size;
3811 HUD_Panel_DrawBg(1);
3813 if(panel_bg_padding)
3815 pos += '1 1 0' * panel_bg_padding;
3816 mySize -= '2 2 0' * panel_bg_padding;
3819 if (!autocvar_con_chatrect)
3820 cvar_set("con_chatrect", "1");
3822 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
3823 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
3825 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
3826 cvar_set("con_chat", ftos(floor(mySize_y/autocvar_con_chatsize - 0.5)));
3828 if(autocvar__hud_configure)
3831 chatsize = '1 1 0' * autocvar_con_chatsize;
3832 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
3834 for(i = 0; i < autocvar_con_chat; ++i)
3836 if(i == autocvar_con_chat - 1)
3839 a = panel_fg_alpha * floor(((i + 1) * 7 + autocvar_con_chattime)/45);
3840 drawcolorcodedstring(pos, textShortenToWidth(_("^3Player^7: This is the chat area."), mySize_x, chatsize, stringwidth_colors), chatsize, a, DRAWFLAG_NORMAL);
3841 pos_y += chatsize_y;
3846 // Engine info panel (#13)
3853 float frametimeavg1; // 1 frame ago
3854 float frametimeavg2; // 2 frames ago
3855 void HUD_EngineInfo(void)
3857 if(!autocvar__hud_configure)
3859 if(!autocvar_hud_panel_engineinfo) return;
3862 hud_configure_active_panel = HUD_PANEL_ENGINEINFO;
3864 HUD_Panel_UpdateCvars(engineinfo);
3867 mySize = panel_size;
3869 HUD_Panel_DrawBg(1);
3870 if(panel_bg_padding)
3872 pos += '1 1 0' * panel_bg_padding;
3873 mySize -= '2 2 0' * panel_bg_padding;
3876 float currentTime = gettime(GETTIME_REALTIME);
3877 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
3879 float currentframetime = currentTime - prevfps_time;
3880 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
3881 frametimeavg2 = frametimeavg1;
3882 frametimeavg1 = frametimeavg;
3885 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
3886 if(currentframetime > 0.0001) // filter out insane values which sometimes seem to occur and throw off the average? If you are getting 10,000 fps or more, then you don't need a framerate counter.
3888 if(fabs(prevfps - (1/frametimeavg)) > prevfps * cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_instantupdate_change_threshold")) // if there was a big jump in fps, just force prevfps at current (1/currentframetime) to make big updates instant
3889 prevfps = (1/currentframetime);
3890 prevfps = (1 - weight) * prevfps + weight * (1/frametimeavg); // framecounter just used so there's no need for a new variable, think of it as "frametime average"
3892 prevfps_time = currentTime;
3897 if(currentTime - prevfps_time > autocvar_hud_panel_engineinfo_framecounter_time)
3899 prevfps = framecounter/(currentTime - prevfps_time);
3901 prevfps_time = currentTime;
3906 color = HUD_Get_Num_Color (prevfps, 100);
3907 drawstring_aspect(pos, sprintf(_("FPS: %.*f"), autocvar_hud_panel_engineinfo_framecounter_decimals, prevfps), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
3910 // Info messages panel (#14)
3912 #define drawInfoMessage(s)\
3913 if(autocvar_hud_panel_infomessages_flip)\
3914 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\
3915 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
3917 void HUD_InfoMessages(void)
3919 if(!autocvar__hud_configure)
3921 if(!autocvar_hud_panel_infomessages) return;
3924 hud_configure_active_panel = HUD_PANEL_INFOMESSAGES;
3926 HUD_Panel_UpdateCvars(infomessages);
3929 mySize = panel_size;
3931 HUD_Panel_DrawBg(1);
3932 if(panel_bg_padding)
3934 pos += '1 1 0' * panel_bg_padding;
3935 mySize -= '2 2 0' * panel_bg_padding;
3938 // always force 5:1 aspect
3940 if(mySize_x/mySize_y > 5)
3942 newSize_x = 5 * mySize_y;
3943 newSize_y = mySize_y;
3945 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3949 newSize_y = 1/5 * mySize_x;
3950 newSize_x = mySize_x;
3952 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3961 fontsize = '0.20 0.20 0' * mySize_y;
3967 if(!autocvar__hud_configure)
3969 if(spectatee_status && !intermission)
3972 if(spectatee_status == -1)
3973 s = _("^1Observing");
3975 s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(spectatee_status - 1));
3978 if(spectatee_status == -1)
3979 s = sprintf(_("^1Press ^3%s^1 to spectate"), getcommandkey("primary fire", "+fire"));
3981 s = sprintf(_("^1Press ^3%s^1 for another player"), getcommandkey("primary fire", "+fire"));
3984 if(spectatee_status == -1)
3985 s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
3987 s = sprintf(_("^1Press ^3%s^1 to observe"), getcommandkey("secondary fire", "+fire2"));
3990 s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey("server info", "+show_info"));
3993 if(gametype == GAME_ARENA)
3994 s = _("^1Wait for your turn to join");
3995 else if(gametype == GAME_LMS)
3998 sk = playerslots[player_localentnum - 1];
3999 if(sk.(scores[ps_primary]) >= 666)
4000 s = _("^1Match has already begun");
4001 else if(sk.(scores[ps_primary]) > 0)
4002 s = _("^1You have no more lives left");
4004 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
4007 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
4010 //show restart countdown:
4011 if (time < getstatf(STAT_GAMESTARTTIME)) {
4013 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4014 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4015 s = sprintf(_("^1Game starts in ^3%d^1 seconds"), countdown);
4016 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4020 if(warmup_stage && !intermission)
4022 s = _("^2Currently in ^1warmup^2 stage!");
4027 if(mod(time, 1) >= 0.5)
4032 if(ready_waiting && !intermission && !spectatee_status)
4034 if(ready_waiting_for_me)
4037 s = sprintf(_("%sPress ^3%s%s to end warmup"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
4039 s = sprintf(_("%sPress ^3%s%s once you are ready"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
4044 s = _("^2Waiting for others to ready up to end warmup...");
4046 s = _("^2Waiting for others to ready up...");
4050 else if(warmup_stage && !intermission && !spectatee_status)
4052 s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey("ready", "ready"));
4056 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4058 float ts_min, ts_max;
4059 tm = teams.sort_next;
4062 for(; tm.sort_next; tm = tm.sort_next)
4064 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4066 if(!ts_min) ts_min = tm.team_size;
4067 else ts_min = min(ts_min, tm.team_size);
4068 if(!ts_max) ts_max = tm.team_size;
4069 else ts_max = max(ts_max, tm.team_size);
4071 if ((ts_max - ts_min) > 1)
4073 s = strcat(blinkcolor, _("Teamnumbers are unbalanced!"));
4074 tm = GetTeam(myteam, false);
4076 if (tm.team != COLOR_SPECTATOR)
4077 if (tm.team_size == ts_max)
4078 s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey("team menu", "menu_showteamselect"), blinkcolor));
4086 s = _("^7Press ^3ESC ^7to show HUD options.");
4088 s = _("^3Doubleclick ^7a panel for panel-specific options.");
4090 s = _("^3CTRL ^7to disable collision testing, ^3SHIFT ^7and");
4092 s = _("^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.");
4097 // Physics panel (#15)
4099 vector acc_prevspeed;
4100 float acc_prevtime, acc_avg, top_speed, top_speed_time;
4101 void HUD_Physics(void)
4103 if(!autocvar__hud_configure)
4105 if(!autocvar_hud_panel_physics) return;
4106 if(spectatee_status == -1 && autocvar_hud_panel_physics < 2) return;
4109 hud_configure_active_panel = HUD_PANEL_PHYSICS;
4111 HUD_Panel_UpdateCvars(physics);
4113 HUD_Panel_DrawBg(1);
4114 if(panel_bg_padding)
4116 panel_pos += '1 1 0' * panel_bg_padding;
4117 panel_size -= '2 2 0' * panel_bg_padding;
4121 float speed, conversion_factor;
4124 switch(autocvar_hud_panel_physics_speed_unit)
4129 conversion_factor = 1.0;
4133 conversion_factor = 0.0254;
4137 conversion_factor = 0.0254 * 3.6;
4141 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4145 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4149 float max_speed = floor( autocvar_hud_panel_physics_speed_max * conversion_factor + 0.5 );
4150 if (autocvar__hud_configure)
4151 speed = floor( max_speed * 0.65 + 0.5 );
4152 else if(autocvar_hud_panel_physics_speed_vertical)
4153 speed = floor( vlen(pmove_vel) * conversion_factor + 0.5 );
4155 speed = floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 );
4157 //compute acceleration
4158 float acceleration, f;
4159 if (autocvar__hud_configure)
4160 acceleration = autocvar_hud_panel_physics_acceleration_max * 0.3;
4163 // 1 m/s = 0.0254 qu/s; 1 g = 9.80665 m/s^2
4164 f = time - acc_prevtime;
4165 if(autocvar_hud_panel_physics_acceleration_vertical)
4166 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f) * (0.0254 / 9.80665);
4168 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f) * (0.0254 / 9.80665);
4169 acc_prevspeed = pmove_vel;
4170 acc_prevtime = time;
4172 f = bound(0, f * 10, 1);
4173 acc_avg = acc_avg * (1 - f) + acceleration * f;
4177 float panel_ar = panel_size_x/panel_size_y;
4178 vector speed_offset, acceleration_offset;
4181 panel_size_x *= 0.5;
4182 if (autocvar_hud_panel_physics_flip)
4183 speed_offset_x = panel_size_x;
4185 acceleration_offset_x = panel_size_x;
4189 panel_size_y *= 0.5;
4190 if (autocvar_hud_panel_physics_flip)
4191 speed_offset_y = panel_size_y;
4193 acceleration_offset_y = panel_size_y;
4195 float speed_baralign, acceleration_baralign;
4196 if (autocvar_hud_panel_physics_baralign == 1)
4197 acceleration_baralign = speed_baralign = 1;
4198 else if(autocvar_hud_panel_physics_baralign == 4)
4199 acceleration_baralign = speed_baralign = 2;
4200 else if (autocvar_hud_panel_physics_flip)
4202 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 2);
4203 speed_baralign = (autocvar_hud_panel_physics_baralign == 3);
4207 speed_baralign = (autocvar_hud_panel_physics_baralign == 2);
4208 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 3);
4210 if (autocvar_hud_panel_physics_acceleration_progressbar_mode == 0)
4211 acceleration_baralign = 3; //override hud_panel_physics_baralign value for acceleration
4215 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
4217 HUD_Panel_GetProgressBarColor(speed);
4218 HUD_Panel_DrawProgressBar(panel_pos + speed_offset, panel_size, "progressbar", speed/max_speed, 0, speed_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4220 vector tmp_offset, tmp_size;
4221 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
4223 tmp_size_x = panel_size_x * 0.75;
4224 tmp_size_y = panel_size_y;
4226 tmp_offset_x = panel_size_x - tmp_size_x;
4229 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4235 tmp_offset_x = tmp_size_x;
4236 if (autocvar_hud_panel_physics_speed_unit_show)
4239 tmp_size_x = panel_size_x * (1 - 0.75);
4240 tmp_size_y = panel_size_y * 0.4;
4241 drawstring_aspect(panel_pos + speed_offset + tmp_offset, unit, tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4245 //compute and draw top speed
4246 if (autocvar_hud_panel_physics_topspeed)
4247 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
4249 if (autocvar__hud_configure)
4251 top_speed = floor( max_speed * 0.75 + 0.5 );
4256 if (speed >= top_speed)
4259 top_speed_time = time;
4263 f = max(1, autocvar_hud_panel_physics_topspeed_time);
4264 // divide by f to make it start from 1
4265 f = cos( ((time - top_speed_time) / f) * PI/2 );
4267 else //hide top speed 0, it would be stupid
4272 //top speed progressbar peak
4273 if(speed < top_speed)
4274 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
4276 float peak_offset_x;
4278 if (speed_baralign == 0)
4279 peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x;
4280 else if (speed_baralign == 1)
4281 peak_offset_x = (1 - min(top_speed, max_speed)/max_speed) * panel_size_x;
4282 else if (speed_baralign == 2)
4283 peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x * 0.5;
4284 //if speed is not 0 the speed progressbar already fetched the color
4286 HUD_Panel_GetProgressBarColor(speed);
4287 peak_size_x = floor(panel_size_x * 0.01 + 1.5);
4288 peak_size_y = panel_size_y;
4289 if (speed_baralign == 2) // draw two peaks, on both sides
4291 drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size_x + peak_offset_x - peak_size_x), peak_size, progressbar_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4292 drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size_x - peak_offset_x + peak_size_x), peak_size, progressbar_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4295 drawfill(panel_pos + speed_offset + eX * (peak_offset_x - peak_size_x), peak_size, progressbar_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4299 tmp_offset_y = panel_size_y * 0.4;
4300 tmp_size_x = panel_size_x * (1 - 0.75);
4301 tmp_size_y = panel_size_y - tmp_offset_y;
4302 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(top_speed), tmp_size, '1 0 0', f * panel_fg_alpha, DRAWFLAG_NORMAL);
4310 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 3)
4312 if (acceleration < 0)
4313 HUD_Panel_GetProgressBarColor(acceleration_neg);
4315 HUD_Panel_GetProgressBarColor(acceleration);
4316 HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset, panel_size, "accelbar", acceleration/autocvar_hud_panel_physics_acceleration_max, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4318 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
4319 drawstring_aspect(panel_pos + acceleration_offset, strcat(ftos_decimals(acceleration, 2), "g"), panel_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4322 #define CENTERPRINT_MAX_MSGS 10
4323 #define CENTERPRINT_MAX_ENTRIES 50
4325 string centerprint_messages[CENTERPRINT_MAX_MSGS];
4326 float centerprint_msgID[CENTERPRINT_MAX_MSGS];
4327 float centerprint_time[CENTERPRINT_MAX_MSGS];
4329 string msg_without_CPID(string s)
4331 return substring(s, strstrofs(s, " ", 0) + 1, strlen(s));
4333 float get_CPID(string s)
4335 if(substring(s, 0, 1) != "\r")
4337 return stof(substring(s, 1, strstrofs(s, " ", 0)));
4339 void centerprint(string strMessage)
4343 if(autocvar_hud_panel_centerprint_time <= 0)
4346 if(strMessage == "")
4349 float new_id = get_CPID(strMessage);
4351 for (i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
4353 if (j == CENTERPRINT_MAX_MSGS)
4355 if (new_id && new_id == centerprint_msgID[j] && centerprint_time[j] + autocvar_hud_panel_centerprint_time >= time)
4357 if(centerprint_messages[j])
4358 strunzone(centerprint_messages[j]);
4359 centerprint_messages[j] == strzone(msg_without_CPID(strMessage));
4360 centerprint_time[j] = time;
4363 if(centerprint_messages[j] == strMessage)
4365 centerprint_time[j] = time;
4366 centerprint_msgID[j] = new_id;
4372 if (cpm_index == -1)
4373 cpm_index = CENTERPRINT_MAX_MSGS - 1;
4374 if(centerprint_messages[cpm_index])
4375 strunzone(centerprint_messages[cpm_index]);
4377 centerprint_messages[cpm_index] = strzone(msg_without_CPID(strMessage));
4379 centerprint_messages[cpm_index] = strzone(strMessage);
4380 centerprint_msgID[cpm_index] = new_id;
4381 centerprint_time[cpm_index] = time;
4384 // CenterPrint (#16)
4386 void HUD_CenterPrint (void)
4388 if(!autocvar__hud_configure)
4390 if(!autocvar_hud_panel_centerprint) return;
4393 hud_configure_active_panel = HUD_PANEL_CENTERPRINT;
4395 HUD_Panel_UpdateCvars(centerprint);
4397 HUD_Panel_DrawBg(1);
4398 if(panel_bg_padding)
4400 panel_pos += '1 1 0' * panel_bg_padding;
4401 panel_size -= '2 2 0' * panel_bg_padding;
4404 float entries, height;
4406 // entries = bound(1, floor(CENTERPRINT_MAX_ENTRIES * 4 * panel_size_y/panel_size_x), CENTERPRINT_MAX_ENTRIES);
4407 // height = panel_size_y/entries;
4408 // fontsize = '1 1 0' * height;
4409 height = vid_conheight/40 * autocvar_hud_panel_centerprint_fontscale;
4410 fontsize = '1 1 0' * height;
4411 entries = bound(1, floor(panel_size_y/height), CENTERPRINT_MAX_ENTRIES);
4414 float a, sz, fade, align;
4419 fade = min(autocvar_hud_panel_centerprint_time/8, 0.25);
4420 align = bound(0, autocvar_hud_panel_centerprint_align, 1);
4421 for (i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
4423 if (j == CENTERPRINT_MAX_MSGS)
4425 if (centerprint_time[j] + autocvar_hud_panel_centerprint_time < time)
4427 else if (centerprint_time[j] + autocvar_hud_panel_centerprint_time - fade > time)
4432 else if (centerprint_time[j] + autocvar_hud_panel_centerprint_time > time)
4434 a = (centerprint_time[j] + autocvar_hud_panel_centerprint_time - time) / fade;
4435 sz = 0.8 + a * (1 - 0.8);
4438 drawfontscale = sz * '1 1 0';
4439 n = tokenizebyseparator(centerprint_messages[j], "\n");
4440 for(k = 0; k < n; ++k)
4442 getWrappedLine_remaining = argv(k);
4443 while(getWrappedLine_remaining)
4445 ts = getWrappedLine(panel_size_x, fontsize, stringwidth_colors);
4449 pos_x = panel_pos_x + (panel_size_x - stringwidth(ts, TRUE, fontsize)) * align;
4450 drawcolorcodedstring(pos + '0 1 0' * 1.5 * (1 - sz) * fontsize_y, ts, fontsize, a, DRAWFLAG_NORMAL);
4451 pos_y += fontsize_y * 1.5;
4454 pos_y += fontsize_y;
4455 if (pos_y > panel_pos_y + panel_size_y - fontsize_y)
4457 drawfontscale = '1 1 0';
4463 pos_y -= 1.5 * fontsize_y * (1 - a*a);
4464 drawfontscale = '1 1 0';
4474 void HUD_Reset (void)
4476 // reset gametype specific icons
4477 if(gametype == GAME_KEYHUNT)
4479 else if(gametype == GAME_CTF)
4480 HUD_Mod_CTF_Reset();
4483 #define HUD_DrawPanel(id)\
4485 case (HUD_PANEL_RADAR):\
4486 HUD_Radar(); break;\
4487 case (HUD_PANEL_WEAPONS):\
4488 HUD_Weapons(); break;\
4489 case (HUD_PANEL_AMMO):\
4491 case (HUD_PANEL_POWERUPS):\
4492 HUD_Powerups(); break;\
4493 case (HUD_PANEL_HEALTHARMOR):\
4494 HUD_HealthArmor(); break;\
4495 case (HUD_PANEL_NOTIFY):\
4496 HUD_Notify(); break;\
4497 case (HUD_PANEL_TIMER):\
4498 HUD_Timer(); break;\
4499 case (HUD_PANEL_SCORE):\
4500 HUD_Score(); break;\
4501 case (HUD_PANEL_RACETIMER):\
4502 HUD_RaceTimer(); break;\
4503 case (HUD_PANEL_VOTE):\
4504 HUD_VoteWindow(); break;\
4505 case (HUD_PANEL_MODICONS):\
4506 HUD_ModIcons(); break;\
4507 case (HUD_PANEL_PRESSEDKEYS):\
4508 HUD_DrawPressedKeys(); break;\
4509 case (HUD_PANEL_CHAT):\
4511 case (HUD_PANEL_ENGINEINFO):\
4512 HUD_EngineInfo(); break;\
4513 case (HUD_PANEL_INFOMESSAGES):\
4514 HUD_InfoMessages(); break;\
4515 case (HUD_PANEL_PHYSICS):\
4516 HUD_Physics(); break;\
4517 case (HUD_PANEL_CENTERPRINT):\
4518 HUD_CenterPrint(); break;\
4519 } ENDS_WITH_CURLY_BRACE
4521 void HUD_Main (void)
4524 // global hud alpha fade
4525 if(menu_enabled == 1)
4528 hud_fade_alpha = (1 - autocvar__menu_alpha);
4530 if(scoreboard_fade_alpha)
4531 hud_fade_alpha = (1 - scoreboard_fade_alpha);
4533 if(intermission == 2) // no hud during mapvote
4535 if (autocvar__hud_configure) //force exit from hud config
4540 localcmd("togglemenu\n");
4542 cvar_set("_hud_configure", "0");
4546 else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
4549 if(!autocvar__hud_configure && !hud_fade_alpha)
4553 if (hud_skin_path != autocvar_hud_skin)
4556 strunzone(hud_skin_path);
4557 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
4560 // HUD configure visible grid
4561 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4563 hud_configure_gridSize_x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
4564 hud_configure_gridSize_y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
4565 hud_configure_realGridSize_x = hud_configure_gridSize_x * vid_conwidth;
4566 hud_configure_realGridSize_y = hud_configure_gridSize_y * vid_conheight;
4568 for(i = 0; i < 1/hud_configure_gridSize_x; ++i)
4569 drawfill(eX * i * hud_configure_realGridSize_x, eX + eY * vid_conheight, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4571 for(i = 0; i < 1/hud_configure_gridSize_y; ++i)
4572 drawfill(eY * i * hud_configure_realGridSize_y, eY + eX * vid_conwidth, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4575 current_player = (spectatee_status > 0) ? spectatee_status : player_localentnum;
4578 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4582 float hud_dock_color_team = autocvar_hud_dock_color_team;
4583 if((teamplay) && hud_dock_color_team) {
4584 f = stof(getplayerkey(current_player - 1, "colors"));
4585 color = colormapPaletteColor(mod(f, 16), 1) * hud_dock_color_team;
4587 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
4588 color = '1 0 0' * hud_dock_color_team;
4592 string hud_dock_color = autocvar_hud_dock_color;
4593 if(hud_dock_color == "shirt") {
4594 f = stof(getplayerkey(current_player - 1, "colors"));
4595 color = colormapPaletteColor(floor(f / 16), 0);
4597 else if(hud_dock_color == "pants") {
4598 f = stof(getplayerkey(current_player - 1, "colors"));
4599 color = colormapPaletteColor(mod(f, 16), 1);
4602 color = stov(hud_dock_color);
4606 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4607 if(precache_pic(pic) == "") {
4608 pic = strcat(hud_skin_path, "/dock_medium");
4609 if(precache_pic(pic) == "") {
4610 pic = "gfx/hud/default/dock_medium";
4613 drawpic('0 0 0', pic, eX * vid_conwidth + eY * vid_conheight, color, autocvar_hud_dock_alpha * hud_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
4616 // cache the panel order into the panel_order array
4617 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4618 for(i = 0; i < HUD_PANEL_NUM; ++i)
4619 panel_order[i] = -1;
4621 float p_num, warning;
4622 float argc = tokenize_console(autocvar__hud_panelorder);
4623 if (argc > HUD_PANEL_NUM)
4625 //first detect wrong/missing panel numbers
4626 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4627 p_num = stof(argv(i));
4628 if (p_num >= 0 && p_num < HUD_PANEL_NUM) { //correct panel number?
4629 if (panel_order[p_num] == -1) //found for the first time?
4630 s = strcat(s, ftos(p_num), " ");
4631 panel_order[p_num] = 1; //mark as found
4636 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4637 if (panel_order[i] == -1) {
4639 s = strcat(s, ftos(i), " "); //add missing panel number
4643 print(_("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n"));
4645 cvar_set("_hud_panelorder", s);
4646 if(hud_panelorder_prev)
4647 strunzone(hud_panelorder_prev);
4648 hud_panelorder_prev = strzone(s);
4650 //now properly set panel_order
4651 tokenize_console(s);
4652 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4653 panel_order[i] = stof(argv(i));
4657 // draw panels in order specified by panel_order array
4658 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
4659 if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice!
4660 HUD_DrawPanel(panel_order[i]);
4663 // draw chat panel on top if it is maximized
4664 if(autocvar__con_chat_maximized)
4665 HUD_Chat(); // HUD_DrawPanel(HUD_PANEL_CHAT);
4667 if (autocvar__hud_configure && spectatee_status && hud_configure_prev == -1) // try to join if we are in hud_configure mode, but still spectating, and in the first frame (in order to get rid of motd when launching a server via the menu "HUD Setup" button)
4668 localcmd("cmd selectteam auto; cmd join\n");
4670 if(autocvar__hud_configure && tab_panel != -1)
4672 HUD_Panel_UpdatePosSizeForId(tab_panel)
4673 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
4676 hud_configure_prev = autocvar__hud_configure;
4678 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again