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 #define CENTERPRINT_MAX_LINES 30
146 string centerprint_messages[CENTERPRINT_MAX_LINES];
147 float centerprint_width[CENTERPRINT_MAX_LINES];
148 float centerprint_time;
149 float centerprint_expire;
150 float centerprint_num;
151 float centerprint_offset_hint;
152 vector centerprint_fontsize;
154 void centerprint(string strMessage)
156 float i, j, n, hcount;
159 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
161 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
163 if(autocvar_scr_centertime <= 0)
169 // strip trailing newlines
170 j = strlen(strMessage) - 1;
171 while(substring(strMessage, j, 1) == "\n" && j >= 0)
173 strMessage = substring(strMessage, 0, j + 1);
178 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
180 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
182 strMessage = substring(strMessage, j, strlen(strMessage) - j);
183 centerprint_offset_hint = j;
188 // if we get here, we have a message. Initialize its height.
191 n = tokenizebyseparator(strMessage, "\n");
193 for(j = 0; j < n; ++j)
195 getWrappedLine_remaining = argv(j);
196 while(getWrappedLine_remaining)
198 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
199 if(centerprint_messages[i] != s) // don't fade the same message in, looks stupid
200 centerprint_time = time;
201 if(centerprint_messages[i])
202 strunzone(centerprint_messages[i]);
203 centerprint_messages[i] = strzone(s);
204 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
207 // half height for empty lines looks better
213 if(i >= CENTERPRINT_MAX_LINES)
219 h = centerprint_fontsize_y*hcount;
221 havail = vid_conheight;
222 if(autocvar_con_chatpos < 0)
223 havail -= (-autocvar_con_chatpos + autocvar_con_chat) * autocvar_con_chatsize; // avoid overlapping chat
224 if(havail > vid_conheight - 70)
225 havail = vid_conheight - 70; // avoid overlapping HUD
228 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
230 // here, the centerprint would cover the crosshair. REALLY BAD.
231 forbiddenmin = vid_conheight * 0.5 - h - 16;
232 forbiddenmax = vid_conheight * 0.5 + 16;
234 allowedmin = scoreboard_bottom;
235 allowedmax = havail - h;
236 preferred = (havail - h)/2;
239 // possible orderings (total: 4! / 4 = 6)
240 // allowedmin allowedmax forbiddenmin forbiddenmax
241 // forbiddenmin forbiddenmax allowedmin allowedmax
242 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
244 // forbidden doesn't matter in this case
245 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
247 // allowedmin forbiddenmin allowedmax forbiddenmax
248 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
250 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
252 // allowedmin forbiddenmin forbiddenmax allowedmax
253 else if(allowedmin < forbiddenmin)
255 // make sure the forbidden zone is not covered
256 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
257 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
259 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
261 // forbiddenmin allowedmin allowedmax forbiddenmax
262 else if(allowedmax < forbiddenmax)
264 // it's better to leave the allowed zone (overlap with scoreboard) than
265 // to cover the forbidden zone (crosshair)
266 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
267 centerprint_start_y = forbiddenmax;
269 centerprint_start_y = forbiddenmin;
271 // forbiddenmin allowedmin forbiddenmax allowedmax
274 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
281 centerprint_expire = time + autocvar_scr_centertime;
284 void HUD_DrawCenterPrint (void)
291 if(time - centerprint_time < 0.25)
292 a = (time - centerprint_time) / 0.25;
294 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
301 if(centerprint_num * autocvar_scr_centersize > 24 && scoreboard_active) // 24 = height of Scoreboard text
302 centerprint_start_y = scoreboard_bottom + centerprint_fontsize_y;
304 pos = centerprint_start;
305 for (i=0; i<centerprint_num; i = i + 1)
307 ts = centerprint_messages[i];
308 drawfontscale = sz * '1 1 0';
309 pos_x = (vid_conwidth - stringwidth(ts, TRUE, centerprint_fontsize)) * 0.5;
312 drawcolorcodedstring(pos + '0 1 0' * (1 - sz) * 0.5 *centerprint_fontsize_y, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
313 pos_y = pos_y + centerprint_fontsize_y;
316 // half height for empty lines looks better
317 pos_y = pos_y + sz * centerprint_fontsize_y * 0.5;
318 drawfontscale = '1 1 0';
322 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
324 position_x -= 2 / 3 * strlen(text) * scale_x;
325 drawstring(position, text, scale, rgb, alpha, flag);
328 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
330 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
331 drawstring(position, text, scale, rgb, alpha, flag);
334 // return the string of the given race place
335 string race_PlaceName(float pos) {
343 return sprintf(_("%dth"), pos);
346 // return the string of the onscreen race timer
347 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
355 if(histime == 0) // goal hit
359 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
369 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
375 lapstr = sprintf(_(" (-%dL)"), lapdelta);
378 else if(lapdelta < 0)
380 lapstr = sprintf(_(" (+%dL)"), -lapdelta);
384 else if(histime > 0) // anticipation
386 if(mytime >= histime)
387 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
389 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
396 cpname = _("Start line");
398 cpname = _("Finish line");
400 cpname = sprintf(_("Intermediate %d"), cp);
402 cpname = _("Finish line");
405 return strcat(col, cpname);
406 else if(hisname == "")
407 return strcat(col, sprintf(_("%s (%s)"), cpname, timestr));
409 return strcat(col, sprintf(_("%s (%s %s)"), cpname, timestr, strcat(hisname, col, lapstr)));
412 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
413 float race_CheckName(string net_name) {
415 for (i=RANKINGS_CNT-1;i>=0;--i)
416 if(grecordholder[i] == net_name)
427 // draw the background/borders
428 #define HUD_Panel_DrawBg(alpha)\
430 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));\
431 if(highlightedPanel == hud_configure_active_panel && autocvar__hud_configure)\
433 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);\
434 } ENDS_WITH_CURLY_BRACE
436 //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
437 void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, float vertical, float baralign, vector theColor, float theAlpha, float drawflag)
439 if(!length_ratio || !theAlpha)
445 if(length_ratio < -1)
448 else if(length_ratio < 0)
452 vector width, height;
454 pic = strcat(hud_skin_path, "/", pic, "_vertical");
455 if(precache_pic(pic) == "") {
456 pic = "gfx/hud/default/progressbar_vertical";
459 if (baralign == 1) // bottom align
460 theOrigin_y += (1 - length_ratio) * theSize_y;
461 else if (baralign == 2) // center align
462 theOrigin_y += 0.5 * (1 - length_ratio) * theSize_y;
463 else if (baralign == 3) // center align, positive values down, negative up
466 if (length_ratio > 0)
467 theOrigin_y += theSize_y;
470 theOrigin_y += (1 + length_ratio) * theSize_y;
471 length_ratio = -length_ratio;
474 theSize_y *= length_ratio;
477 width = eX * theSize_x;
478 height = eY * theSize_y;
479 if(theSize_y <= theSize_x * 2)
481 // button not high enough
482 // draw just upper and lower part then
483 square = eY * theSize_y * 0.5;
484 bH = eY * (0.25 * theSize_y / (theSize_x * 2));
485 drawsubpic(theOrigin, square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, drawflag);
486 drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, drawflag);
490 square = eY * theSize_x;
491 drawsubpic(theOrigin, width + square, pic, '0 0 0', '1 0.25 0', theColor, theAlpha, drawflag);
492 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5 0', theColor, theAlpha, drawflag);
493 drawsubpic(theOrigin + height - square, width + square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, drawflag);
496 pic = strcat(hud_skin_path, "/", pic);
497 if(precache_pic(pic) == "") {
498 pic = "gfx/hud/default/progressbar";
501 if (baralign == 1) // right align
502 theOrigin_x += (1 - length_ratio) * theSize_x;
503 else if (baralign == 2) // center align
504 theOrigin_x += 0.5 * (1 - length_ratio) * theSize_x;
505 else if (baralign == 3) // center align, positive values on the right, negative on the left
508 if (length_ratio > 0)
509 theOrigin_x += theSize_x;
512 theOrigin_x += (1 + length_ratio) * theSize_x;
513 length_ratio = -length_ratio;
516 theSize_x *= length_ratio;
519 width = eX * theSize_x;
520 height = eY * theSize_y;
521 if(theSize_x <= theSize_y * 2)
523 // button not wide enough
524 // draw just left and right part then
525 square = eX * theSize_x * 0.5;
526 bW = eX * (0.25 * theSize_x / (theSize_y * 2));
527 drawsubpic(theOrigin, square + height, pic, '0 0 0', eY + bW, theColor, theAlpha, drawflag);
528 drawsubpic(theOrigin + square, square + height, pic, eX - bW, eY + bW, theColor, theAlpha, drawflag);
532 square = eX * theSize_y;
533 drawsubpic(theOrigin, height + square, pic, '0 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
534 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0.25 0 0', '0.5 1 0', theColor, theAlpha, drawflag);
535 drawsubpic(theOrigin + width - square, height + square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
540 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
546 pic = strcat(hud_skin_path, "/num_leading");
547 if(precache_pic(pic) == "") {
548 pic = "gfx/hud/default/num_leading";
551 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
552 if(mySize_x/mySize_y > 2)
553 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);
554 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);
559 entity weaponorder[WEP_MAXCOUNT];
560 void weaponorder_swap(float i, float j, entity pass)
564 weaponorder[i] = weaponorder[j];
568 string weaponorder_cmp_str;
569 float weaponorder_cmp(float i, float j, entity pass)
572 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
573 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
574 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)
577 float GetAmmoStat(float i)
581 case 0: return STAT_SHELLS;
582 case 1: return STAT_NAILS;
583 case 2: return STAT_ROCKETS;
584 case 3: return STAT_CELLS;
585 case 4: return STAT_FUEL;
590 float GetAmmoTypeForWep(float i)
594 case WEP_SHOTGUN: return 0;
595 case WEP_UZI: return 1;
596 case WEP_GRENADE_LAUNCHER: return 2;
597 case WEP_MINE_LAYER: return 2;
598 case WEP_ELECTRO: return 3;
599 case WEP_CRYLINK: return 3;
600 case WEP_HLAC: return 3;
601 case WEP_MINSTANEX: return 3;
602 case WEP_NEX: return 3;
603 case WEP_SNIPERRIFLE: return 1;
604 case WEP_HAGAR: return 2;
605 case WEP_ROCKET_LAUNCHER: return 2;
606 case WEP_SEEKER: return 2;
607 case WEP_FIREBALL: return 4;
608 case WEP_HOOK: return 3;
613 void HUD_Weapons(void)
616 float center_x, center_y;
618 if(!autocvar__hud_configure)
620 if(!autocvar_hud_panel_weapons) return;
621 if(spectatee_status == -1) return;
624 hud_configure_active_panel = HUD_PANEL_WEAPONS;
626 float timeout = autocvar_hud_panel_weapons_timeout;
627 float timeout_effect_length, timein_effect_length;
628 if (autocvar_hud_panel_weapons_timeout_effect == 0)
630 timeout_effect_length = 0;
631 timein_effect_length = 0;
635 timeout_effect_length = 0.75;
636 timein_effect_length = 0.375;
639 if (timeout && time >= weapontime + timeout + timeout_effect_length && !autocvar__hud_configure)
641 weaponprevtime = time;
645 HUD_Panel_UpdateCvars(weapons);
647 if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
649 f = (time - (weapontime + timeout)) / timeout_effect_length;
650 if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3)
652 panel_bg_alpha *= (1 - f);
653 panel_fg_alpha *= (1 - f);
655 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
657 f *= f; // for a cooler movement
658 center_x = panel_pos_x + panel_size_x/2;
659 center_y = panel_pos_y + panel_size_y/2;
660 screen_ar = vid_conwidth/vid_conheight;
661 if (center_x/center_y < screen_ar) //bottom left
663 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
664 panel_pos_y += f * (vid_conheight - panel_pos_y);
666 panel_pos_x -= f * (panel_pos_x + panel_size_x);
670 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
671 panel_pos_x += f * (vid_conwidth - panel_pos_x);
673 panel_pos_y -= f * (panel_pos_y + panel_size_y);
676 weaponprevtime = time - (1 - f) * timein_effect_length;
678 else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure)
680 f = (time - weaponprevtime) / timein_effect_length;
681 if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3)
683 panel_bg_alpha *= (f);
684 panel_fg_alpha *= (f);
686 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
688 f *= f; // for a cooler movement
690 center_x = panel_pos_x + panel_size_x/2;
691 center_y = panel_pos_y + panel_size_y/2;
692 screen_ar = vid_conwidth/vid_conheight;
693 if (center_x/center_y < screen_ar) //bottom left
695 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
696 panel_pos_y += f * (vid_conheight - panel_pos_y);
698 panel_pos_x -= f * (panel_pos_x + panel_size_x);
702 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
703 panel_pos_x += f * (vid_conwidth - panel_pos_x);
705 panel_pos_y -= f * (panel_pos_y + panel_size_y);
710 float i, weapid, wpnalpha, weapon_cnt;
712 // TODO make this configurable
713 if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
715 if(weaponorder_bypriority)
716 strunzone(weaponorder_bypriority);
717 if(weaponorder_byimpulse)
718 strunzone(weaponorder_byimpulse);
720 weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
721 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
722 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
725 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
727 self = get_weaponinfo(i);
728 if(self.impulse >= 0)
730 weaponorder[weapon_cnt] = self;
734 for(i = weapon_cnt; i < WEP_MAXCOUNT; ++i)
735 weaponorder[i] = NULL;
736 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
738 weaponorder_cmp_str = string_null;
744 panel_pos += '1 1 0' * panel_bg_padding;
745 panel_size -= '2 2 0' * panel_bg_padding;
748 if(autocvar_hud_panel_weapons_fade)
750 wpnalpha = 3.2 - 2 * (time - weapontime);
751 wpnalpha = bound(0.7, wpnalpha, 1) * panel_fg_alpha;
754 wpnalpha = panel_fg_alpha;
757 float aspect = autocvar_hud_panel_weapons_aspect;
758 rows = panel_size_y/panel_size_x;
759 rows = bound(1, floor((sqrt(4 * aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
761 columns = ceil(WEP_COUNT/rows);
764 float a, type, fullammo;
766 when = autocvar_hud_panel_weapons_complainbubble_time;
768 fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
776 wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
777 float barsize_x, barsize_y, baroffset_x, baroffset_y;
778 if (autocvar_hud_panel_weapons_ammo)
780 ammo_color = stov(autocvar_hud_panel_weapons_ammo_color);
781 ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha;
784 if(wpnsize_x/wpnsize_y > aspect)
786 barsize_x = aspect * wpnsize_y;
787 barsize_y = wpnsize_y;
788 baroffset_x = (wpnsize_x - barsize_x) / 2;
792 barsize_y = 1/aspect * wpnsize_x;
793 barsize_x = wpnsize_x;
794 baroffset_y = (wpnsize_y - barsize_y) / 2;
800 if(autocvar_hud_panel_weapons_accuracy && acc_levels)
802 show_accuracy = true;
803 if (acc_col_x[0] == -1)
804 for (i = 0; i < acc_levels; ++i)
805 acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
808 float weapons_st = getstati(STAT_WEAPONS);
810 for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
812 self = weaponorder[i];
813 if (!self || self.impulse < 0)
815 wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
817 weapid = self.impulse;
819 // draw background behind currently selected weapon
820 if(self.weapon == activeweapon)
821 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
823 // draw the weapon accuracy
826 weapon_stats = weapon_accuracy[self.weapon-WEP_FIRST];
827 if(weapon_stats >= 0)
829 // find the max level lower than weapon_stats
832 while ( j && weapon_stats < acc_lev[j] )
835 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
837 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
839 color = color + factor * (acc_col[j+1] - color);
841 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
845 // draw the weapon icon
846 if(weapons_st & self.weapons)
848 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
850 if(autocvar_hud_panel_weapons_label == 1) // weapon number
851 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
852 else if(autocvar_hud_panel_weapons_label == 2) // bind
853 drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
855 // draw ammo status bar
856 if(autocvar_hud_panel_weapons_ammo && self.weapon != WEP_TUBA && self.weapon != WEP_LASER && self.weapon != WEP_PORTO)
859 type = GetAmmoTypeForWep(self.weapon);
861 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
866 case 0: fullammo = autocvar_hud_panel_weapons_ammo_full_shells; break;
867 case 1: fullammo = autocvar_hud_panel_weapons_ammo_full_nails; break;
868 case 2: fullammo = autocvar_hud_panel_weapons_ammo_full_rockets; break;
869 case 3: fullammo = autocvar_hud_panel_weapons_ammo_full_cells; break;
870 case 4: fullammo = autocvar_hud_panel_weapons_ammo_full_fuel; break;
871 default: fullammo = 60;
875 wpnpos_x + baroffset_x,
876 wpnpos_y + baroffset_y,
877 barsize_x * bound(0, a/fullammo, 1),
879 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, ammo_color, ammo_alpha, DRAWFLAG_NORMAL);
885 // draw a "ghost weapon icon" if you don't have the weapon
888 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
891 // draw the complain message
892 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
896 if(complain_weapon_time + when > time)
899 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
903 if(complain_weapon_time + when > time)
910 if(complain_weapon_type == 0) {
911 s = _("Out of ammo");
912 color = stov(autocvar_hud_panel_weapons_complainbubble_color_outofammo);
914 else if(complain_weapon_type == 1) {
916 color = stov(autocvar_hud_panel_weapons_complainbubble_color_donthave);
919 s = _("Unavailable");
920 color = stov(autocvar_hud_panel_weapons_complainbubble_color_unavailable);
922 float padding = autocvar_hud_panel_weapons_complainbubble_padding;
923 drawpic_aspect_skin(wpnpos + '1 1 0' * padding, "weapon_complainbubble", wpnsize - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
924 drawstring_aspect(wpnpos + '1 1 0' * padding, s, wpnsize - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
940 float GetAmmoItemCode(float i)
944 case 0: return IT_SHELLS;
945 case 1: return IT_NAILS;
946 case 2: return IT_ROCKETS;
947 case 3: return IT_CELLS;
948 case 4: return IT_FUEL;
953 string GetAmmoPicture(float i)
957 case 0: return "ammo_shells";
958 case 1: return "ammo_bullets";
959 case 2: return "ammo_rockets";
960 case 3: return "ammo_cells";
961 case 4: return "ammo_fuel";
966 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
969 if(autocvar__hud_configure)
971 currently_selected = (itemcode == 2); //rockets always selected
972 a = 31 + mod(itemcode*93, 128);
975 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
984 if(currently_selected)
989 vector picpos, numpos;
990 if(autocvar_hud_panel_ammo_iconalign)
993 picpos = myPos + eX * 2 * mySize_y;
997 numpos = myPos + eX * mySize_y;
1001 if (currently_selected)
1002 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1004 if(a > 0 && autocvar_hud_panel_ammo_progressbar)
1005 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);
1007 if(autocvar_hud_panel_ammo_text)
1010 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1011 else // "ghost" ammo count
1012 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1015 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1016 else // "ghost" ammo icon
1017 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1022 if(!autocvar__hud_configure)
1024 if(!autocvar_hud_panel_ammo) return;
1025 if(spectatee_status == -1) return;
1028 hud_configure_active_panel = HUD_PANEL_AMMO;
1030 HUD_Panel_UpdateCvars(ammo);
1033 mySize = panel_size;
1035 HUD_Panel_DrawBg(1);
1036 if(panel_bg_padding)
1038 pos += '1 1 0' * panel_bg_padding;
1039 mySize -= '2 2 0' * panel_bg_padding;
1042 float rows, columns, row, column;
1044 if (autocvar_hud_panel_ammo_onlycurrent)
1048 rows = mySize_y/mySize_x;
1049 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1050 // ^^^ ammo item aspect goes here
1052 columns = ceil(AMMO_COUNT/rows);
1054 ammo_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
1059 if(ammo_size_x/ammo_size_y > 3)
1061 newSize = 3 * ammo_size_y;
1062 offset_x = ammo_size_x - newSize;
1063 pos_x += offset_x/2;
1064 ammo_size_x = newSize;
1068 newSize = 1/3 * ammo_size_x;
1069 offset_y = ammo_size_y - newSize;
1070 pos_y += offset_y/2;
1071 ammo_size_y = newSize;
1074 float i, stat_items, currently_selected;
1075 if (autocvar_hud_panel_ammo_onlycurrent)
1077 if(autocvar__hud_configure)
1079 DrawAmmoItem(pos, ammo_size, 2, true); //show rockets
1082 stat_items = getstati(STAT_ITEMS);
1083 for (i = 0; i < AMMO_COUNT; ++i) {
1084 currently_selected = stat_items & GetAmmoItemCode(i);
1085 if (currently_selected)
1087 DrawAmmoItem(pos, ammo_size, i, true);
1091 return; // nothing to display
1094 stat_items = getstati(STAT_ITEMS);
1095 for (i = 0; i < AMMO_COUNT; ++i) {
1096 currently_selected = stat_items & GetAmmoItemCode(i);
1097 DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected);
1102 column = column + 1;
1107 void DrawNumIcon(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float alpha)
1109 vector newPos, newSize;
1110 vector picpos, numpos;
1114 if(mySize_y/mySize_x > 2)
1116 newSize_y = 2 * mySize_x;
1117 newSize_x = mySize_x;
1119 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1124 newSize_x = 1/2 * mySize_y;
1125 newSize_y = mySize_y;
1127 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1131 if(icon_right_align)
1134 picpos = newPos + eY * newSize_x;
1139 numpos = newPos + eY * newSize_x;
1143 drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1144 // make number smaller than icon, it looks better
1145 // reduce only y to draw numbers with different number of digits with the same y size
1146 numpos_y += newSize_y * ((1 - 0.7) / 2);
1148 drawstring_aspect(numpos, ftos(x), newSize, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1152 if(mySize_x/mySize_y > 3)
1154 newSize_x = 3 * mySize_y;
1155 newSize_y = mySize_y;
1157 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1162 newSize_y = 1/3 * mySize_x;
1163 newSize_x = mySize_x;
1165 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1169 if(icon_right_align) // right align
1172 picpos = newPos + eX * 2 * newSize_y;
1176 numpos = newPos + eX * newSize_y;
1180 drawstring_aspect(numpos, ftos(x), '2 1 0' * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1181 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1184 void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float fadelerp)
1187 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
1189 DrawNumIcon(myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, vertical, icon_right_align, color, (1 - fadelerp));
1194 void HUD_Powerups(void)
1196 float strength_time, shield_time;
1197 if(!autocvar__hud_configure)
1199 if(!autocvar_hud_panel_powerups) return;
1200 if(spectatee_status == -1) return;
1201 if not(getstati(STAT_ITEMS) & (IT_STRENGTH | IT_INVINCIBLE)) return;
1202 if (getstati(STAT_HEALTH) <= 0) return;
1204 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1205 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1209 hud_configure_active_panel = HUD_PANEL_POWERUPS;
1215 HUD_Panel_UpdateCvars(powerups);
1218 mySize = panel_size;
1220 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
1221 if(panel_bg_padding)
1223 pos += '1 1 0' * panel_bg_padding;
1224 mySize -= '2 2 0' * panel_bg_padding;
1227 float panel_ar = mySize_x/mySize_y;
1228 float is_vertical = (panel_ar < 1);
1229 vector shield_offset, strength_offset;
1230 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1233 if (autocvar_hud_panel_powerups_flip)
1234 shield_offset_x = mySize_x;
1236 strength_offset_x = mySize_x;
1241 if (autocvar_hud_panel_powerups_flip)
1242 shield_offset_y = mySize_y;
1244 strength_offset_y = mySize_y;
1247 float shield_baralign, strength_baralign;
1248 float shield_iconalign, strength_iconalign;
1249 if (autocvar_hud_panel_powerups_flip)
1251 strength_baralign = (autocvar_hud_panel_powerups_baralign == 2 || autocvar_hud_panel_powerups_baralign == 1);
1252 shield_baralign = (autocvar_hud_panel_powerups_baralign == 3 || autocvar_hud_panel_powerups_baralign == 1);
1253 strength_iconalign = (autocvar_hud_panel_powerups_iconalign == 2 || autocvar_hud_panel_powerups_iconalign == 1);
1254 shield_iconalign = (autocvar_hud_panel_powerups_iconalign == 3 || autocvar_hud_panel_powerups_iconalign == 1);
1258 shield_baralign = (autocvar_hud_panel_powerups_baralign == 2 || autocvar_hud_panel_powerups_baralign == 1);
1259 strength_baralign = (autocvar_hud_panel_powerups_baralign == 3 || autocvar_hud_panel_powerups_baralign == 1);
1260 shield_iconalign = (autocvar_hud_panel_powerups_iconalign == 2 || autocvar_hud_panel_powerups_iconalign == 1);
1261 strength_iconalign = (autocvar_hud_panel_powerups_iconalign == 3 || autocvar_hud_panel_powerups_iconalign == 1);
1266 const float maxshield = 30;
1267 float shield = ceil(shield_time);
1268 if(autocvar_hud_panel_powerups_progressbar)
1270 HUD_Panel_GetProgressBarColor(shield);
1271 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);
1273 if(autocvar_hud_panel_powerups_text)
1276 DrawNumIcon(pos + shield_offset, mySize, shield, "shield", is_vertical, shield_iconalign, '1 1 1', 1);
1278 DrawNumIcon_expanding(pos + shield_offset, mySize, shield, "shield", is_vertical, shield_iconalign, '1 1 1', bound(0, (shield - shield_time) / 0.5, 1));
1284 const float maxstrength = 30;
1285 float strength = ceil(strength_time);
1286 if(autocvar_hud_panel_powerups_progressbar)
1288 HUD_Panel_GetProgressBarColor(strength);
1289 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);
1291 if(autocvar_hud_panel_powerups_text)
1294 DrawNumIcon(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', 1);
1296 DrawNumIcon_expanding(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', bound(0, (strength - strength_time) / 0.5, 1));
1301 // Health/armor (#3)
1304 // prev_* vars contain the health/armor at the previous FRAME
1305 // set to -1 when player is dead or was not playing
1306 float prev_health, prev_armor;
1307 float health_damagetime, armor_damagetime;
1308 float health_beforedamage, armor_beforedamage;
1309 // old_p_* vars keep track of previous values when smoothing value changes of the progressbar
1310 float old_p_health, old_p_armor;
1311 float old_p_healthtime, old_p_armortime;
1312 // prev_p_* vars contain the health/armor progressbar value at the previous FRAME
1313 // set to -1 to forcedly stop effects when we switch spectated player (e.g. from playerX: 70h to playerY: 50h)
1314 float prev_p_health, prev_p_armor;
1316 void HUD_HealthArmor(void)
1318 float armor, health, fuel;
1319 if(!autocvar__hud_configure)
1321 if(!autocvar_hud_panel_healtharmor) return;
1322 if(spectatee_status == -1) return;
1324 health = getstati(STAT_HEALTH);
1330 armor = getstati(STAT_ARMOR);
1332 // code to check for spectatee_status changes is in Ent_ClientData()
1333 // prev_p_health and prev_health can be set to -1 there
1335 if (prev_p_health == -1)
1338 health_beforedamage = 0;
1339 armor_beforedamage = 0;
1340 health_damagetime = 0;
1341 armor_damagetime = 0;
1342 prev_health = health;
1344 old_p_health = health;
1345 old_p_armor = armor;
1346 prev_p_health = health;
1347 prev_p_armor = armor;
1349 else if (prev_health == -1)
1351 //start the load effect
1352 health_damagetime = 0;
1353 armor_damagetime = 0;
1357 fuel = getstati(STAT_FUEL);
1361 hud_configure_active_panel = HUD_PANEL_HEALTHARMOR;
1368 HUD_Panel_UpdateCvars(healtharmor);
1371 mySize = panel_size;
1373 HUD_Panel_DrawBg(1);
1374 if(panel_bg_padding)
1376 pos += '1 1 0' * panel_bg_padding;
1377 mySize -= '2 2 0' * panel_bg_padding;
1380 float baralign = autocvar_hud_panel_healtharmor_baralign;
1381 float iconalign = autocvar_hud_panel_healtharmor_iconalign;
1383 float maxhealth = autocvar_hud_panel_healtharmor_maxhealth;
1384 float maxarmor = autocvar_hud_panel_healtharmor_maxarmor;
1385 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
1388 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1393 float maxtotal = maxhealth + maxarmor;
1395 if(v_z) // NOT fully armored
1397 biggercount = "health";
1398 if(autocvar_hud_panel_healtharmor_progressbar)
1400 HUD_Panel_GetProgressBarColor(health);
1401 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);
1404 if(autocvar_hud_panel_healtharmor_text)
1405 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);
1409 biggercount = "armor";
1410 if(autocvar_hud_panel_healtharmor_progressbar)
1412 HUD_Panel_GetProgressBarColor(armor);
1413 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);
1416 if(autocvar_hud_panel_healtharmor_text)
1417 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);
1419 if(autocvar_hud_panel_healtharmor_text)
1420 DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, maxtotal), 1);
1424 HUD_Panel_GetProgressBarColor(fuel);
1425 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);
1430 float panel_ar = mySize_x/mySize_y;
1431 float is_vertical = (panel_ar < 1);
1432 vector health_offset, armor_offset;
1433 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1436 if (autocvar_hud_panel_healtharmor_flip)
1437 health_offset_x = mySize_x;
1439 armor_offset_x = mySize_x;
1444 if (autocvar_hud_panel_healtharmor_flip)
1445 health_offset_y = mySize_y;
1447 armor_offset_y = mySize_y;
1450 float health_baralign, armor_baralign, fuel_baralign;
1451 float health_iconalign, armor_iconalign;
1452 if (autocvar_hud_panel_healtharmor_flip)
1454 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1455 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1456 fuel_baralign = health_baralign;
1457 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1458 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1462 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1463 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1464 fuel_baralign = armor_baralign;
1465 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1466 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1471 if(autocvar_hud_panel_healtharmor_progressbar)
1473 HUD_Panel_GetProgressBarColor(health);
1474 float p_health, pain_health_alpha;
1476 pain_health_alpha = 1;
1477 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1479 if (fabs(prev_health - health) >= 2)
1481 if (time - old_p_healthtime < 1)
1482 old_p_health = prev_p_health;
1484 old_p_health = prev_health;
1485 old_p_healthtime = time;
1487 if (time - old_p_healthtime < 1)
1489 p_health += (old_p_health - health) * (1 - (time - old_p_healthtime));
1490 prev_p_health = p_health;
1492 if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0)
1494 if (prev_health - health >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
1496 if (time - health_damagetime >= 1)
1497 health_beforedamage = prev_health;
1498 health_damagetime = time;
1500 if (time - health_damagetime < 1)
1502 float health_damagealpha = 1 - (time - health_damagetime)*(time - health_damagetime);
1503 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);
1506 prev_health = health;
1510 float BLINK_FACTOR = 0.15;
1511 float BLINK_BASE = 0.85;
1512 float BLINK_FREQ = 9;
1513 pain_health_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
1516 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);
1518 if(autocvar_hud_panel_healtharmor_text)
1519 DrawNumIcon(pos + health_offset, mySize, health, "health", is_vertical, health_iconalign, HUD_Get_Num_Color(health, maxhealth), 1);
1524 if(autocvar_hud_panel_healtharmor_progressbar)
1526 HUD_Panel_GetProgressBarColor(armor);
1529 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1531 if (fabs(prev_armor - armor) >= 2)
1533 if (time - old_p_armortime < 1)
1534 old_p_armor = prev_p_armor;
1536 old_p_armor = prev_armor;
1537 old_p_armortime = time;
1539 if (time - old_p_armortime < 1)
1541 p_armor += (old_p_armor - armor) * (1 - (time - old_p_armortime));
1542 prev_p_armor = p_armor;
1544 if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0)
1546 if (prev_armor - armor >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
1548 if (time - armor_damagetime >= 1)
1549 armor_beforedamage = prev_armor;
1550 armor_damagetime = time;
1552 if (time - armor_damagetime < 1)
1554 float armor_damagealpha = 1 - (time - armor_damagetime)*(time - armor_damagetime);
1555 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);
1560 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);
1562 if(autocvar_hud_panel_healtharmor_text)
1563 DrawNumIcon(pos + armor_offset, mySize, armor, "armor", is_vertical, armor_iconalign, HUD_Get_Num_Color(armor, maxarmor), 1);
1569 mySize_x *= 0.2 / 2; //if vertical always halve x to not cover too much numbers with 3 digits
1573 mySize_x *= 2; //restore full panel size
1574 else if (panel_ar < 1/4)
1575 mySize_y *= 2; //restore full panel size
1576 HUD_Panel_GetProgressBarColor(fuel);
1577 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
1582 // Notification area (#4)
1585 string Weapon_SuicideMessage(float deathtype)
1587 w_deathtype = deathtype;
1588 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
1589 return w_deathtypestring;
1592 string Weapon_KillMessage(float deathtype)
1594 w_deathtype = deathtype;
1595 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
1596 return w_deathtypestring;
1599 #define KN_MAX_ENTRIES 10
1601 float killnotify_times[KN_MAX_ENTRIES];
1602 float killnotify_deathtype[KN_MAX_ENTRIES];
1603 float killnotify_actiontype[KN_MAX_ENTRIES]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
1604 string killnotify_attackers[KN_MAX_ENTRIES];
1605 string killnotify_victims[KN_MAX_ENTRIES];
1606 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
1610 kn_index = KN_MAX_ENTRIES-1;
1611 killnotify_times[kn_index] = time;
1612 killnotify_deathtype[kn_index] = wpn;
1613 killnotify_actiontype[kn_index] = actiontype;
1614 if(killnotify_attackers[kn_index])
1615 strunzone(killnotify_attackers[kn_index]);
1616 killnotify_attackers[kn_index] = strzone(attacker);
1617 if(killnotify_victims[kn_index])
1618 strunzone(killnotify_victims[kn_index]);
1619 killnotify_victims[kn_index] = strzone(victim);
1622 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
1625 float alsoprint, gentle;
1626 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
1627 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
1629 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
1632 if(msg == MSG_SUICIDE) {
1633 w = DEATH_WEAPONOF(type);
1635 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1637 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
1638 } else if (type == DEATH_KILL) {
1639 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
1641 print (sprintf(_("^1%s^1 couldn't take it anymore\n"), s1));
1642 } else if (type == DEATH_ROT) {
1643 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1645 print (sprintf(_("^1%s^1 died\n"), s1));
1646 } else if (type == DEATH_NOAMMO) {
1647 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
1649 print (sprintf(_("^7%s^7 committed suicide. What's the point of living without ammo?\n"), s1));
1650 } else if (type == DEATH_CAMP) {
1651 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
1653 print (sprintf(_("^1%s^1 thought they found a nice camping ground\n"), s1));
1654 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
1655 HUD_KillNotify_Push(s1, "", 0, type);
1657 print (sprintf(_("^1%s^1 didn't become friends with the Lord of Teamplay\n"), s1));
1658 } else if (type == DEATH_CHEAT) {
1659 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1661 print (sprintf(_("^1%s^1 unfairly eliminated themself\n"), s1));
1662 } else if (type == DEATH_FIRE) {
1663 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1665 print (sprintf(_("^1%s^1 burned to death\n"), s1));
1666 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
1667 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1669 print (sprintf(_("^1%s^1 couldn't resist the urge to self-destruct\n"), s1));
1672 if (stof(s2) > 2) // killcount > 2
1673 print (sprintf(_("^1%s^1 ended it all after a %d kill spree\n"), s1, stof(s2)));
1674 } else if(msg == MSG_KILL) {
1675 w = DEATH_WEAPONOF(type);
1677 if((w == WEP_SNIPERRIFLE || w == WEP_MINSTANEX) && type & HITTYPE_HEADSHOT) // all headshot weapons go here
1678 HUD_KillNotify_Push(s1, s2, 1, DEATH_HEADSHOT);
1680 HUD_KillNotify_Push(s1, s2, 1, type);
1683 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
1685 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
1686 HUD_KillNotify_Push(s1, s2, 1, type);
1690 print (sprintf(_("^1%s^1 took action against a team mate\n"), s1));
1692 print (sprintf(_("^1%s^1 mows down a team mate\n"), s1));
1695 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
1697 print (sprintf(_("^1%s^1 ended a %d scoring spree by going against a team mate\n"), s1, stof(s3)));
1699 print (sprintf(_("^1%s^1 ended a %d kill spree by killing a team mate\n"), s1, stof(s3)));
1701 else if (stof(s2) > 2) {
1703 print (sprintf(_("^1%s^1's %s scoring spree was ended by a team mate!\n"), s1, stof(s3)));
1705 print (sprintf(_("^1%s^1's %s kill spree was ended by a team mate!\n"), s1, stof(s3)));
1708 else if(type == KILL_FIRST_BLOOD)
1709 print(sprintf(_("^1%s^1 drew first blood\n"), s1));
1710 else if (type == DEATH_TELEFRAG) {
1711 HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
1713 print (sprintf(_("^1%s^1 tried to occupy %s^1's teleport destination space\n"), s2, s1));
1715 print (sprintf(_("^1%s^1 was telefragged by %s\n"), s2, s1));
1717 else if (type == DEATH_DROWN) {
1718 HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN);
1720 print (sprintf(_("^1%s^1 was drowned by %s\n"), s2, s1));
1722 else if (type == DEATH_SLIME) {
1723 HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME);
1725 print (sprintf(_("^1%s^1 was slimed by %s\n"), s2, s1));
1727 else if (type == DEATH_LAVA) {
1728 HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA);
1730 print (sprintf(_("^1%s^1 was cooked by %s\n"), s2, s1));
1732 else if (type == DEATH_FALL) {
1733 HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL);
1735 print (sprintf(_("^1%s^1 was grounded by %s\n"), s2, s1));
1737 else if (type == DEATH_SHOOTING_STAR) {
1738 HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR);
1740 print (sprintf(_("^1%s^1 was shot into space by %s\n"), s2, s1));
1742 else if (type == DEATH_SWAMP) {
1743 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1745 print (sprintf(_("^1%s^1 was conserved by %s\n"), s2, s1));
1747 else if (type == DEATH_HURTTRIGGER)
1749 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1751 print(sprintf(_("^1%s^1 was thrown into a world of hurt by %s\n"), s2, s1));
1752 } else if(type == DEATH_SBCRUSH) {
1753 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1755 print (sprintf(_("^1%s^1 was crushed by %s\n"), s2, s1));
1756 } else if(type == DEATH_SBMINIGUN) {
1757 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1759 print (sprintf(_("^1%s^1 got shredded by %s\n"), s2, s1));
1760 } else if(type == DEATH_SBROCKET) {
1761 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1763 print (sprintf(_("^1%s^1 was blasted to bits by %s\n"), s2, s1));
1764 } else if(type == DEATH_SBBLOWUP) {
1765 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1767 print (sprintf(_("^1%s^1 got caught in the destruction of %s^1's vehicle\n"), s2, s1));
1768 } else if(type == DEATH_WAKIGUN) {
1769 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1771 print (sprintf(_("^1%s^1 was bolted down by %s\n"), s2, s1));
1772 } else if(type == DEATH_WAKIROCKET) {
1773 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1775 print (sprintf(_("^1%s^1 could find no shelter from %s^1's rockets\n"), s2, s1));
1776 } else if(type == DEATH_WAKIBLOWUP) {
1777 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1779 print (sprintf(_("^1%s^1 dies when %s^1's wakizashi dies.\n"), s2, s1));
1780 } else if(type == DEATH_TURRET) {
1781 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1783 print (sprintf(_("^1%s^1 was pushed into the line of fire by %s\n"), s2, s1));
1784 } else if(type == DEATH_TOUCHEXPLODE) {
1785 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1787 print (sprintf(_("^1%s^1 was pushed into an accident by %s\n"), s2, s1));
1788 } else if(type == DEATH_CHEAT) {
1789 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1791 print (sprintf(_("^1%s^1 was unfairly eliminated by %s\n"), s2, s1));
1792 } else if (type == DEATH_FIRE) {
1793 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1795 print (sprintf(_("^1%s^1 was burnt to death by %s\n"), s2, s1));
1796 } else if (type == DEATH_CUSTOM) {
1797 HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
1799 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1800 } else if (type == DEATH_HURTTRIGGER) {
1801 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1803 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1805 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1807 print (sprintf(_("^1%s^1 was fragged by %s\n"), s2, s1));
1809 } else if(msg == MSG_SPREE) {
1810 if(type == KILL_END_SPREE) {
1812 print (sprintf(_("^1%s^1's %s scoring spree was ended by %s\n"), s1, s2, s3));
1814 print (sprintf(_("^1%s^1's %s kill spree was ended by %s\n"), s1, s2, s3));
1815 } else if(type == KILL_SPREE) {
1817 print (sprintf(_("^1%s^1 made %s scores in a row\n"), s1, s2));
1819 print (sprintf(_("^1%s^1 has %s frags in a row\n"), s1, s2));
1820 } else if(type == KILL_SPREE_3) {
1822 print (sprintf(_("%s^7 made a ^1TRIPLE SCORE\n"), s1));
1824 print (sprintf(_("%s^7 made a ^1TRIPLE FRAG\n"), s1));
1825 } else if(type == KILL_SPREE_5) {
1827 print (sprintf(_("%s^7 unleashes ^1SCORING RAGE\n"), s1));
1829 print (sprintf(_("%s^7 unleashes ^1RAGE\n"), s1));
1830 } else if(type == KILL_SPREE_10) {
1832 print (sprintf(_("%s^7 made ^1TEN SCORES IN A ROW!\n"), s1));
1834 print (sprintf(_("%s^7 starts the ^1MASSACRE!\n"), s1));
1835 } else if(type == KILL_SPREE_15) {
1837 print (sprintf(_("%s^7 made ^1FIFTEEN SCORES IN A ROW!\n"), s1));
1839 print (sprintf(_("%s^7 executes ^1MAYHEM!\n"), s1));
1840 } else if(type == KILL_SPREE_20) {
1842 print (sprintf(_("%s^7 made ^1TWENTY SCORES IN A ROW!\n"), s1));
1844 print (sprintf(_("%s^7 is a ^1BERSERKER!\n"), s1));
1845 } else if(type == KILL_SPREE_25) {
1847 print (sprintf(_("%s^7 made ^1TWENTY FIFE SCORES IN A ROW!\n"), s1));
1849 print (sprintf(_("%s^7 inflicts ^1CARNAGE!\n"), s1));
1850 } else if(type == KILL_SPREE_30) {
1852 print (sprintf(_("%s^7 made ^1THIRTY SCORES IN A ROW!\n"), s1));
1854 print (sprintf(_("%s^7 unleashes ^1ARMAGEDDON!\n"), s1));
1856 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
1857 if (type == DEATH_DROWN) {
1858 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
1862 print (sprintf(_("^1%s^1 was in the water for too long\n"), s1));
1864 print (sprintf(_("^1%s^1 drowned\n"), s1));
1866 } else if (type == DEATH_SLIME) {
1867 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
1869 print (sprintf(_("^1%s^1 was slimed\n"), s1));
1870 } else if (type == DEATH_LAVA) {
1871 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
1875 print (sprintf(_("^1%s^1 found a hot place\n"), s1));
1877 print (sprintf(_("^1%s^1 turned into hot slag\n"), s1));
1879 } else if (type == DEATH_FALL) {
1880 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1884 print (sprintf(_("^1%s^1 tested gravity (and it worked)\n"), s1));
1886 print (sprintf(_("^1%s^1 hit the ground with a crunch\n"), s1));
1888 } else if (type == DEATH_SHOOTING_STAR) {
1889 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
1891 print (sprintf(_("^1%s^1 became a shooting star\n"), s1));
1892 } else if (type == DEATH_SWAMP) {
1893 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1897 print (sprintf(_("^1%s^1 discovered a swamp\n"), s1));
1899 print (sprintf(_("^1%s^1 is now conserved for centuries to come\n"), s1));
1901 } else if(type == DEATH_TURRET) {
1902 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1904 print (sprintf(_("^1%s^1 was mowed down by a turret \n"), s1));
1905 } else if (type == DEATH_CUSTOM) {
1906 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
1908 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1909 } else if (type == DEATH_HURTTRIGGER) {
1910 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
1912 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1913 } else if(type == DEATH_TOUCHEXPLODE) {
1914 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1916 print (sprintf(_("^1%s^1 died in an accident\n"), s1));
1917 } else if(type == DEATH_CHEAT) {
1918 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1920 print (sprintf(_("^1%s^1 was unfairly eliminated\n"), s1));
1921 } else if(type == DEATH_FIRE) {
1922 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1926 print (sprintf(_("^1%s^1 felt a little hot\n"), s1));
1928 print (sprintf(_("^1%s^1 burnt to death\n"), s1));
1931 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1935 print (sprintf(_("^1%s^1 needs a restart\n"), s1));
1937 print (sprintf(_("^1%s^1 died\n"), s1));
1940 } else if(msg == MSG_KILL_ACTION_SPREE) {
1942 print (sprintf(_("^1%s^1 needs a restart after a %d scoring spree\n"), s1, stof(s2)));
1944 print (sprintf(_("^1%s^1 died with a %d kill spree\n"), s1, stof(s2)));
1945 } else if(msg == MSG_INFO) {
1946 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
1947 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
1948 print(sprintf(_("%s^7 got the %s\n"), s1, s2));
1949 } else if(type == INFO_LOSTFLAG) {
1950 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
1951 print(sprintf(_("%s^7 lost the %s\n"), s1, s2));
1952 } else if(type == INFO_PICKUPFLAG) {
1953 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
1954 print(sprintf(_("%s^7 picked up the %s\n"), s1, s2));
1955 } else if(type == INFO_RETURNFLAG) {
1956 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
1957 print(sprintf(_("%s^7 returned the %s\n"), s1, s2));
1958 } else if(type == INFO_CAPTUREFLAG) {
1959 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
1960 print(sprintf(_("%s^7 captured the %s%s\n"), s1, s2, s3));
1962 } else if(msg == MSG_RACE) {
1963 if(type == RACE_SERVER_RECORD) {
1964 HUD_KillNotify_Push(s1, s2, 1, RACE_SERVER_RECORD);
1966 else if(type == RACE_NEW_RANK) {
1967 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_RANK);
1969 else if(type == RACE_NEW_TIME) {
1970 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_TIME);
1972 else if(type == RACE_FAIL) {
1973 HUD_KillNotify_Push(s1, s2, 1, RACE_FAIL);
1975 } else if(msg == MSG_KA) {
1976 if(type == KA_PICKUPBALL) {
1977 HUD_KillNotify_Push(s1, s2, 0, KA_PICKUPBALL);
1979 print (sprintf(_("%s^7 has picked up the ball!\n"), s1));
1981 else if(type == KA_DROPBALL) {
1982 HUD_KillNotify_Push(s1, s2, 0, KA_DROPBALL);
1984 print(sprintf(_("%s^7 has dropped the ball!\n"), s1));
1989 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
1991 void HUD_Centerprint(string s1, string s2, float type, float msg)
1994 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
1995 if(msg == MSG_SUICIDE) {
1996 if (type == DEATH_TEAMCHANGE) {
1997 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("You are now on: %s"), s1)));
1998 } else if (type == DEATH_AUTOTEAMCHANGE) {
1999 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("You have been moved into a different team to improve team balance\nYou are now on: %s"), s1)));
2000 } else if (type == DEATH_CAMP) {
2002 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Reconsider your tactics, camper!")));
2004 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Die camper!")));
2005 } else if (type == DEATH_NOAMMO) {
2007 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You are reinserted into the game for running out of ammo...")));
2009 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You were killed for running out of ammo...")));
2010 } else if (type == DEATH_ROT) {
2012 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You need to preserve your health")));
2014 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You grew too old without taking your medicine")));
2015 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2017 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Don't go against team mates!")));
2019 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Don't shoot your team mates!")));
2020 } else if (type == DEATH_QUIET) {
2022 } else { // generic message
2024 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You need to be more careful!")));
2026 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You killed your own dumb self!")));
2028 } else if(msg == MSG_KILL) {
2029 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2031 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1Moron! You went against %s, a team mate!"), s1)));
2033 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1Moron! You fragged %s, a team mate!"), s1)));
2035 } else if (type == KILL_FIRST_BLOOD) {
2037 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First score")));
2039 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First blood")));
2041 } else if (type == KILL_FIRST_VICTIM) {
2043 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First casualty")));
2045 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First victim")));
2047 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2049 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You scored against ^7%s^1 who was typing!"), s1), s2));
2051 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You typefragged ^7%s"), s1), s2));
2053 } else if (type == KILL_TYPEFRAGGED) {
2055 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were scored against by ^7%s^1 while you were typing!"), s1), s2));
2057 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were typefragged by ^7%s"), s1), s2));
2059 } else if (type == KILL_FRAG) {
2061 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^4You scored against ^7%s"), s1), s2));
2063 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^4You fragged ^7%s"), s1), s2));
2065 } else { // generic message
2067 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were scored against by ^7%s"), s1), s2));
2069 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were fragged by ^7%s"), s1), s2));
2072 } else if(msg == MSG_KILL_ACTION) {
2073 // TODO: invent more centerprints here?
2074 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Watch your step!")));
2078 void HUD_Notify (void)
2080 if(!autocvar__hud_configure)
2082 if(!autocvar_hud_panel_notify) return;
2085 hud_configure_active_panel = HUD_PANEL_NOTIFY;
2087 HUD_Panel_UpdateCvars(notify);
2090 mySize = panel_size;
2092 HUD_Panel_DrawBg(1);
2093 if(panel_bg_padding)
2095 pos += '1 1 0' * panel_bg_padding;
2096 mySize -= '2 2 0' * panel_bg_padding;
2099 float entries, height;
2100 entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES);
2101 height = mySize_y/entries;
2104 float fontheight = height * autocvar_hud_panel_notify_fontsize;
2105 fontsize = '0.5 0.5 0' * fontheight;
2109 when = autocvar_hud_panel_notify_time;
2111 fadetime = autocvar_hud_panel_notify_fadetime;
2115 vector pos_attacker, pos_victim;
2117 float width_attacker;
2118 string attacker, victim;
2120 float i, j, w, step, limit;
2121 if(autocvar_hud_panel_notify_flip) //order items from the top down
2127 else //order items from the bottom up
2134 for(j = kn_index; i != limit; i += step, ++j)
2136 if(autocvar__hud_configure)
2140 else // inverse order
2141 a = entries - 1 - i;
2142 attacker = textShortenToWidth(sprintf(_("Player %d"), a+1), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2143 victim = textShortenToWidth(sprintf(_("Player %d"), a+2), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2144 s = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname);
2145 a = bound(0, (when - a) / 4, 1);
2146 goto hud_config_notifyprint;
2149 if (j == KN_MAX_ENTRIES)
2152 if(killnotify_times[j] + when > time)
2156 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2170 w = DEATH_WEAPONOF(killnotify_deathtype[j]);
2172 // TODO: maybe print in team colors?
2175 if(killnotify_actiontype[j] == 0)
2177 if(killnotify_deathtype[j] == DEATH_GENERIC)
2181 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2183 s = "notify_outofammo";
2185 else if(killnotify_deathtype[j] == DEATH_KILL)
2187 s = "notify_selfkill";
2189 else if(killnotify_deathtype[j] == DEATH_CAMP)
2191 s = "notify_camping";
2193 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2195 s = "notify_teamkill_red";
2197 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2199 s = "notify_teamkill_blue";
2201 else if(killnotify_deathtype[j] == DEATH_DROWN)
2205 else if(killnotify_deathtype[j] == DEATH_SLIME)
2209 else if(killnotify_deathtype[j] == DEATH_LAVA)
2213 else if(killnotify_deathtype[j] == DEATH_FALL)
2217 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2219 s = "notify_shootingstar";
2221 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2225 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2227 if(killnotify_victims[j] == "^1RED^7 flag")
2229 s = "notify_red_taken";
2233 s = "notify_blue_taken";
2236 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2238 if(killnotify_victims[j] == "^1RED^7 flag")
2240 s = "notify_red_returned";
2244 s = "notify_blue_returned";
2247 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2249 if(killnotify_victims[j] == "^1RED^7 flag")
2251 s = "notify_red_lost";
2255 s = "notify_blue_lost";
2258 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
2260 if(killnotify_victims[j] == "^1RED^7 flag")
2262 s = "notify_red_captured";
2266 s = "notify_blue_captured";
2269 else if(killnotify_deathtype[j] == KA_DROPBALL)
2271 s = "notify_balldropped";
2273 else if(killnotify_deathtype[j] == KA_PICKUPBALL)
2275 s = "notify_ballpickedup";
2278 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2279 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2280 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2284 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2285 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2288 // X [did action to] Y
2291 if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
2293 s = "notify_melee_laser";
2295 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_SHOTGUN)
2297 s = "notify_melee_shotgun";
2299 else if(WEP_VALID(w))
2301 self = get_weaponinfo(w);
2302 s = strcat("weapon", self.netname);
2304 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2306 s = "notify_teamkill_red";
2308 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2310 s = "notify_teamkill_red";
2312 else if(killnotify_deathtype[j] == DEATH_TELEFRAG)
2314 s = "notify_telefrag";
2316 else if(killnotify_deathtype[j] == DEATH_DROWN)
2320 else if(killnotify_deathtype[j] == DEATH_SLIME)
2324 else if(killnotify_deathtype[j] == DEATH_LAVA)
2328 else if(killnotify_deathtype[j] == DEATH_FALL)
2332 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2334 s = "notify_shootingstar";
2336 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2340 else if(killnotify_deathtype[j] == DEATH_HEADSHOT)
2342 s = "notify_headshot";
2344 else if(killnotify_deathtype[j] == RACE_SERVER_RECORD)
2346 s = "race_newrecordserver";
2348 else if(killnotify_deathtype[j] == RACE_NEW_RANK)
2350 s = "race_newrankyellow";
2352 else if(killnotify_deathtype[j] == RACE_NEW_TIME)
2356 else if(killnotify_deathtype[j] == RACE_FAIL)
2361 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2362 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2363 :hud_config_notifyprint
2364 width_attacker = stringwidth(attacker, TRUE, fontsize);
2365 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2366 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2367 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2371 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2372 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2373 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2382 string seconds_tostring(float sec)
2385 minutes = floor(sec / 60);
2387 sec -= minutes * 60;
2388 return sprintf("%d:%02d", minutes, sec);
2391 void HUD_Timer(void)
2393 if(!autocvar__hud_configure)
2395 if(!autocvar_hud_panel_timer) return;
2398 hud_configure_active_panel = HUD_PANEL_TIMER;
2400 HUD_Panel_UpdateCvars(timer);
2403 mySize = panel_size;
2405 HUD_Panel_DrawBg(1);
2406 if(panel_bg_padding)
2408 pos += '1 1 0' * panel_bg_padding;
2409 mySize -= '2 2 0' * panel_bg_padding;
2413 float timelimit, elapsedTime, timeleft, minutesLeft;
2415 timelimit = getstatf(STAT_TIMELIMIT);
2417 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
2418 timeleft = ceil(timeleft);
2420 minutesLeft = floor(timeleft / 60);
2423 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
2424 timer_color = '1 1 1'; //white
2425 else if(minutesLeft >= 1)
2426 timer_color = '1 1 0'; //yellow
2428 timer_color = '1 0 0'; //red
2430 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
2431 if (time < getstatf(STAT_GAMESTARTTIME)) {
2432 //while restart is still active, show 00:00
2433 timer = seconds_tostring(0);
2435 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
2436 timer = seconds_tostring(elapsedTime);
2439 timer = seconds_tostring(timeleft);
2442 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2447 void HUD_Radar(void)
2449 if (!autocvar__hud_configure)
2451 if (autocvar_hud_panel_radar == 0) return;
2452 if (autocvar_hud_panel_radar != 2 && !teamplay) return;
2455 hud_configure_active_panel = HUD_PANEL_RADAR;
2457 HUD_Panel_UpdateCvars(radar);
2460 mySize = panel_size;
2462 HUD_Panel_DrawBg(1);
2463 if(panel_bg_padding)
2465 pos += '1 1 0' * panel_bg_padding;
2466 mySize -= '2 2 0' * panel_bg_padding;
2471 float scale2d, normalsize, bigsize;
2474 teamradar_origin2d = pos + 0.5 * mySize;
2475 teamradar_size2d = mySize;
2477 if(minimapname == "")
2480 teamradar_loadcvars();
2482 switch(hud_panel_radar_zoommode)
2486 f = current_zoomfraction;
2489 f = 1 - current_zoomfraction;
2499 switch(hud_panel_radar_rotation)
2502 teamradar_angle = view_angles_y - 90;
2505 teamradar_angle = 90 * hud_panel_radar_rotation;
2509 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
2510 teamradar_size2d = mySize;
2512 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
2514 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
2515 if(hud_panel_radar_rotation == 0)
2517 // max-min distance must fit the radar in any rotation
2518 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_scale));
2522 vector c0, c1, c2, c3, span;
2523 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
2524 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
2525 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
2526 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
2528 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
2529 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
2531 // max-min distance must fit the radar in x=x, y=y
2533 teamradar_size2d_x * scale2d / (1.05 * span_x),
2534 teamradar_size2d_y * scale2d / (1.05 * span_y)
2538 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
2539 if(bigsize > normalsize)
2540 normalsize = bigsize;
2544 + (1 - f) * normalsize;
2545 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
2547 + (1 - f) * view_origin);
2556 draw_teamradar_background(hud_panel_radar_foreground_alpha);
2558 for(tm = world; (tm = find(tm, classname, "radarlink")); )
2559 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
2560 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
2561 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
2562 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
2564 color2 = GetPlayerColor(tm.sv_entnum);
2565 //if(color == COLOR_SPECTATOR || color == color2)
2566 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
2568 draw_teamradar_player(view_origin, view_angles, '1 1 1');
2570 drawresetcliparea();
2575 void HUD_UpdatePlayerTeams();
2576 void HUD_Score(void)
2578 if(!autocvar__hud_configure)
2580 if(!autocvar_hud_panel_score) return;
2581 if(spectatee_status == -1 && (gametype == GAME_RACE || gametype == GAME_CTS)) return;
2584 hud_configure_active_panel = HUD_PANEL_SCORE;
2586 HUD_Panel_UpdateCvars(score);
2589 mySize = panel_size;
2591 HUD_Panel_DrawBg(1);
2592 if(panel_bg_padding)
2594 pos += '1 1 0' * panel_bg_padding;
2595 mySize -= '2 2 0' * panel_bg_padding;
2598 float score, distribution;
2600 vector distribution_color;
2602 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
2604 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
2605 string timer, distrtimer;
2607 pl = players.sort_next;
2610 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
2611 if(pl.scores[ps_primary] == 0)
2614 score = me.(scores[ps_primary]);
2615 timer = TIME_ENCODED_TOSTRING(score);
2617 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
2618 // distribution display
2619 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2621 distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS);
2623 if (distribution <= 0) {
2624 distribution_color = '0 1 0';
2628 distribution_color = '1 0 0';
2631 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);
2633 // race record display
2634 if (distribution <= 0)
2635 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2636 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2637 } else if (!teamplay) { // non-teamgames
2638 if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings)
2640 #define SCOREPANEL_MAX_ENTRIES 6
2641 #define SCOREPANEL_ASPECTRATIO 2
2642 const float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
2643 const float height = mySize_y/entries;
2644 const vector fontsize = '0.9 0.9 0' * height;
2645 pos_y += height * (1 - 0.9) / 2;
2650 const float name_size = mySize_x*0.75;
2651 const float highlight_alpha = 0.2;
2652 float i, me_printed;
2654 if (autocvar__hud_configure)
2656 score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
2657 for (i=0; i<entries; ++i)
2659 //simulate my score is lower than all displayed players,
2660 //so that I don't appear at all showing pure rankings.
2661 //This is to better show the difference between the 2 ranking views
2662 if (i == entries-1 && autocvar_hud_panel_score_rankings == 1)
2665 drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2666 s = GetPlayerName(pl.sv_entnum);
2671 s = sprintf(_("Player %d"), i+1);
2675 s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
2676 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2677 drawstring(pos + eX * mySize_x*0.79, ftos(score), fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2683 if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
2684 HUD_UpdatePlayerTeams();
2686 for (pl = players.sort_next, i=0; pl && i<entries; pl = pl.sort_next, ++i)
2688 if (pl.team == COLOR_SPECTATOR)
2691 if (i == entries-1 && !me_printed && pl != me)
2692 if (autocvar_hud_panel_score_rankings == 1 && spectatee_status != -1)
2694 for (pl = me.sort_next; pl; pl = pl.sort_next)
2695 if (pl.team != COLOR_SPECTATOR)
2699 rgb = '1 1 0'; //not last but not among the leading players: yellow
2701 rgb = '1 0 0'; //last: red
2708 rgb = '0 1 0'; //first: green
2710 drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2712 s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
2713 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2714 drawstring(pos + eX * mySize_x*0.79, ftos(pl.(scores[ps_primary])), fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2719 // me vector := [team/connected frags id]
2720 pl = players.sort_next;
2724 if(autocvar__hud_configure)
2727 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2731 score = me.(scores[ps_primary]);
2732 if(autocvar__hud_configure)
2735 if(distribution >= 5)
2736 distribution_color = eY;
2737 else if(distribution >= 0)
2738 distribution_color = '1 1 1';
2739 else if(distribution >= -5)
2740 distribution_color = '1 1 0';
2742 distribution_color = eX;
2744 string distribution_str;
2745 distribution_str = ftos(distribution);
2746 if (distribution >= 0)
2748 if (distribution > 0)
2749 distribution_str = strcat("+", distribution_str);
2750 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2752 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2753 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);
2754 } else { // teamgames
2755 float max_fragcount;
2756 max_fragcount = -99;
2758 float scores_count, row, column, rows, columns;
2760 vector score_pos, score_size; //for scores other than myteam
2761 if (spectatee_status == -1)
2763 if (autocvar__hud_configure)
2765 else for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2766 if(tm.team == COLOR_SPECTATOR)
2770 rows = mySize_y/mySize_x;
2771 rows = bound(1, floor((sqrt(4 * (3/1) * rows * scores_count + rows * rows) + rows + 0.5) / 2), scores_count);
2772 // ^^^ ammo item aspect goes here
2774 columns = ceil(scores_count/rows);
2776 score_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
2779 if(score_size_x/score_size_y > 3)
2781 newSize = 3 * score_size_y;
2782 offset_x = score_size_x - newSize;
2783 pos_x += offset_x/2;
2784 score_size_x = newSize;
2788 newSize = 1/3 * score_size_x;
2789 offset_y = score_size_y - newSize;
2790 pos_y += offset_y/2;
2791 score_size_y = newSize;
2795 score_size = eX * mySize_x*(1/4) + eY * mySize_y*(1/3);
2796 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2797 if(tm.team == COLOR_SPECTATOR)
2799 score = tm.(teamscores[ts_primary]);
2800 if(autocvar__hud_configure)
2803 if (score > max_fragcount)
2804 max_fragcount = score;
2806 if (spectatee_status == -1)
2808 score_pos = pos + eX * column * (score_size_x + offset_x) + eY * row * (score_size_y + offset_y);
2809 if (max_fragcount == score)
2810 HUD_Panel_DrawHighlight(score_pos, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2811 drawstring_aspect(score_pos, ftos(score), score_size, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2819 else if(tm.team == myteam) {
2820 if (max_fragcount == score)
2821 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2822 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2824 if (max_fragcount == score)
2825 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);
2826 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);
2835 void HUD_RaceTimer (void)
2837 if(!autocvar__hud_configure)
2839 if(!autocvar_hud_panel_racetimer) return;
2840 if(!(gametype == GAME_RACE || gametype == GAME_CTS)) return;
2841 if(spectatee_status == -1) return;
2844 hud_configure_active_panel = HUD_PANEL_RACETIMER;
2846 HUD_Panel_UpdateCvars(racetimer);
2849 mySize = panel_size;
2851 HUD_Panel_DrawBg(1);
2852 if(panel_bg_padding)
2854 pos += '1 1 0' * panel_bg_padding;
2855 mySize -= '2 2 0' * panel_bg_padding;
2858 // always force 4:1 aspect
2860 if(mySize_x/mySize_y > 4)
2862 newSize_x = 4 * mySize_y;
2863 newSize_y = mySize_y;
2865 pos_x = pos_x + (mySize_x - newSize_x) / 2;
2869 newSize_y = 1/4 * mySize_x;
2870 newSize_x = mySize_x;
2872 pos_y = pos_y + (mySize_y - newSize_y) / 2;
2877 string s, forcetime;
2879 if(autocvar__hud_configure)
2882 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);
2883 s = _("^1Intermediate 1 (+15.42)");
2884 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);
2885 s = sprintf(_("^1PENALTY: %.1f (%s)"), 2, "missing a checkpoint");
2886 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);
2888 else if(race_checkpointtime)
2890 a = bound(0, 2 - (time - race_checkpointtime), 1);
2893 if(a > 0) // just hit a checkpoint?
2895 if(race_checkpoint != 254)
2897 if(race_time && race_previousbesttime)
2898 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
2900 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
2902 forcetime = TIME_ENCODED_TOSTRING(race_time);
2907 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
2909 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
2910 if(a > 0) // next one?
2912 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
2917 if(s != "" && a > 0)
2919 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);
2922 if(race_penaltytime)
2924 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
2927 s = sprintf(_("^1PENALTY: %.1f (%s)"), race_penaltytime * 0.1, race_penaltyreason);
2928 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);
2934 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
2935 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);
2940 if(race_laptime && race_checkpoint != 255)
2942 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
2943 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);
2948 if(race_mycheckpointtime)
2950 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
2951 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
2952 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);
2954 if(race_othercheckpointtime && race_othercheckpointenemy != "")
2956 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
2957 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
2958 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);
2961 if(race_penaltytime && !race_penaltyaccumulator)
2963 t = race_penaltytime * 0.1 + race_penaltyeventtime;
2964 a = bound(0, (1 + t - time), 1);
2968 s = sprintf(_("^1PENALTY: %.1f (%s)"), (t - time) * 0.1, race_penaltyreason);
2970 s = sprintf(_("^2PENALTY: %.1f (%s)"), 0, race_penaltyreason);
2971 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);
2979 float vote_yescount;
2982 float vote_highlighted; // currently selected vote
2984 float vote_active; // is there an active vote?
2985 float vote_prev; // previous state of vote_active to check for a change
2987 float vote_change; // "time" when vote_active changed
2989 void HUD_VoteWindow(void)
2991 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
2994 if (autocvar__hud_configure)
2998 print(_("^1You must answer before entering hud configure mode\n"));
2999 cvar_set("_hud_configure", "0");
3001 vote_called_vote = strzone(_("^2Name ^7instead of \"^1Unregistered player^7\" in stats"));
3002 uid2name_dialog = 1;
3005 if(!autocvar__hud_configure)
3007 if(!autocvar_hud_panel_vote) return;
3009 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
3010 panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
3012 if(panel_bg_alpha_str == "") {
3013 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
3015 panel_bg_alpha = stof(panel_bg_alpha_str);
3019 hud_configure_active_panel = HUD_PANEL_VOTE;
3028 if(vote_active != vote_prev) {
3030 vote_prev = vote_active;
3033 if(vote_active || autocvar__hud_configure)
3034 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3036 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3041 HUD_Panel_UpdateCvars(vote);
3045 panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight;
3046 panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
3049 // these must be below above block
3052 mySize = panel_size;
3054 a = vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3055 HUD_Panel_DrawBg(a);
3056 a = panel_fg_alpha * a;
3058 if(panel_bg_padding)
3060 pos += '1 1 0' * panel_bg_padding;
3061 mySize -= '2 2 0' * panel_bg_padding;
3064 // always force 3:1 aspect
3066 if(mySize_x/mySize_y > 3)
3068 newSize_x = 3 * mySize_y;
3069 newSize_y = mySize_y;
3071 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3075 newSize_y = 1/3 * mySize_x;
3076 newSize_x = mySize_x;
3078 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3082 s = _("A vote has been called for:");
3084 s = _("Allow servers to store and display your name?");
3085 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3086 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1/8), stringwidth_colors);
3087 if(autocvar__hud_configure)
3088 s = _("^1Configure the HUD");
3089 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
3091 // print the yes/no counts
3092 s = sprintf(_("Yes (%s): %d"), getcommandkey("vyes", "vyes"), vote_yescount);
3093 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);
3094 s = sprintf(_("No (%s): %d"), getcommandkey("vno", "vno"), vote_nocount);
3095 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);
3097 // draw the progress bar backgrounds
3098 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3100 // draw the highlights
3101 if(vote_highlighted == 1) {
3102 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3103 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3105 else if(vote_highlighted == 2) {
3106 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3107 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3110 // draw the progress bars
3111 if(vote_yescount && vote_needed)
3113 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3114 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3117 if(vote_nocount && vote_needed)
3119 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3120 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3123 drawresetcliparea();
3126 vote_highlighted = 0;
3130 // Mod icons panel (#10)
3133 float mod_active; // is there any active mod icon?
3135 // Clan Arena HUD modicons
3136 void HUD_Mod_CA(vector pos, vector mySize)
3138 mod_active = 1; // CA should never hide the mod icons panel
3139 float redalive, bluealive;
3140 redalive = getstati(STAT_REDALIVE);
3141 bluealive = getstati(STAT_BLUEALIVE);
3143 vector redpos, bluepos;
3144 if(mySize_x > mySize_y)
3147 bluepos = pos + eY * 0.5 * mySize_y;
3148 drawpic_aspect_skin(redpos, "player_red.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3149 drawstring_aspect(redpos + eX * 0.5 * mySize_x, ftos(redalive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3150 drawpic_aspect_skin(bluepos, "player_blue.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3151 drawstring_aspect(bluepos + eX * 0.5 * mySize_x, ftos(bluealive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3156 bluepos = pos + eY * 0.5 * mySize_y;
3157 drawpic_aspect_skin(redpos, "player_red.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3158 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);
3159 drawpic_aspect_skin(bluepos, "player_blue.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3160 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);
3164 // CTF HUD modicon section
3165 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3166 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3167 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3169 void HUD_Mod_CTF_Reset(void)
3171 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3174 void HUD_Mod_CTF(vector pos, vector mySize)
3176 vector redflag_pos, blueflag_pos;
3178 float f; // every function should have that
3180 float redflag, blueflag; // current status
3181 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3184 stat_items = getstati(STAT_ITEMS);
3185 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3186 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3188 if(redflag || blueflag)
3193 if(autocvar__hud_configure)
3199 // when status CHANGES, set old status into prevstatus and current status into status
3200 if (redflag != redflag_prevframe)
3202 redflag_statuschange_time = time;
3203 redflag_prevstatus = redflag_prevframe;
3204 redflag_prevframe = redflag;
3207 if (blueflag != blueflag_prevframe)
3209 blueflag_statuschange_time = time;
3210 blueflag_prevstatus = blueflag_prevframe;
3211 blueflag_prevframe = blueflag;
3214 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3215 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3217 float BLINK_FACTOR = 0.15;
3218 float BLINK_BASE = 0.85;
3220 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3222 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3224 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3226 string red_icon, red_icon_prevstatus;
3227 float red_alpha, red_alpha_prevstatus;
3228 red_alpha = red_alpha_prevstatus = 1;
3230 case 1: red_icon = "flag_red_taken"; break;
3231 case 2: red_icon = "flag_red_lost"; break;
3232 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3234 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3235 red_icon = "flag_red_shielded";
3237 red_icon = string_null;
3240 switch(redflag_prevstatus) {
3241 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3242 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3243 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3246 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3247 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3248 red_icon_prevstatus = "flag_red_shielded";
3250 red_icon_prevstatus = string_null;
3254 string blue_icon, blue_icon_prevstatus;
3255 float blue_alpha, blue_alpha_prevstatus;
3256 blue_alpha = blue_alpha_prevstatus = 1;
3258 case 1: blue_icon = "flag_blue_taken"; break;
3259 case 2: blue_icon = "flag_blue_lost"; break;
3260 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3262 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3263 blue_icon = "flag_blue_shielded";
3265 blue_icon = string_null;
3268 switch(blueflag_prevstatus) {
3269 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3270 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3271 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3274 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3275 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3276 blue_icon_prevstatus = "flag_blue_shielded";
3278 blue_icon_prevstatus = string_null;
3282 if(mySize_x > mySize_y) {
3283 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3285 blueflag_pos = pos + eX * 0.5 * mySize_x;
3288 redflag_pos = pos + eX * 0.5 * mySize_x;
3290 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3292 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3294 blueflag_pos = pos + eY * 0.5 * mySize_y;
3297 redflag_pos = pos + eY * 0.5 * mySize_y;
3299 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3302 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3303 if(red_icon_prevstatus && f < 1)
3304 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3306 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3308 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3309 if(blue_icon_prevstatus && f < 1)
3310 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3312 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3315 // Keyhunt HUD modicon section
3316 float kh_runheretime;
3318 void HUD_Mod_KH_Reset(void)
3323 void HUD_Mod_KH(vector pos, vector mySize)
3325 mod_active = 1; // keyhunt should never hide the mod icons panel
3329 vector p, pa, kh_size, kh_asize;
3331 kh_keys = getstati(STAT_KH_KEYS);
3334 if(mySize_x > mySize_y)
3336 p_y = pos_y + 0.25 * mySize_y;
3337 pa = p - eY * 0.25 * mySize_y;
3339 kh_size_x = mySize_x * 0.25;
3340 kh_size_y = 0.75 * mySize_y;
3341 kh_asize_x = mySize_x * 0.25;
3342 kh_asize_y = mySize_y * 0.25;
3346 p_y = pos_y + 0.125 * mySize_y;
3347 pa = p - eY * 0.125 * mySize_y;
3349 kh_size_x = mySize_x * 0.5;
3350 kh_size_y = 0.375 * mySize_y;
3351 kh_asize_x = mySize_x * 0.5;
3352 kh_asize_y = mySize_y * 0.125;
3359 for(i = 0; i < 4; ++i)
3361 key = floor(kh_keys / pow(32, i)) & 31;
3363 if(keyteam == 30 && keycount <= 4)
3365 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3369 // this yields 8 exactly if "RUN HERE" shows
3374 kh_runheretime = time;
3375 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3380 for(i = 0; i < 4; ++i)
3382 key = floor(kh_keys / pow(32, i)) & 31;
3395 default: // owned or dropped
3400 a = a * panel_fg_alpha;
3401 aa = aa * panel_fg_alpha;
3407 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3410 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3413 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3416 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3421 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3424 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3427 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3430 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3433 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3437 if(mySize_x > mySize_y)
3439 p_x += 0.25 * mySize_x;
3440 pa_x += 0.25 * mySize_x;
3446 p_y = pos_y + 0.625 * mySize_y;
3447 pa_y = pos_y + 0.5 * mySize_y;
3453 p_x += 0.5 * mySize_x;
3454 pa_x += 0.5 * mySize_x;
3460 // Keepaway HUD mod icon
3461 float kaball_prevstatus; // last remembered status
3462 float kaball_statuschange_time; // time when the status changed
3464 // we don't need to reset for keepaway since it immediately
3465 // autocorrects prevstatus as to if the player has the ball or not
3467 void HUD_Mod_Keepaway(vector pos, vector mySize)
3469 mod_active = 1; // keepaway should always show the mod HUD
3471 float BLINK_FACTOR = 0.15;
3472 float BLINK_BASE = 0.85;
3473 float BLINK_FREQ = 5;
3474 float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
3476 float stat_items = getstati(STAT_ITEMS);
3477 float kaball = (stat_items/IT_KEY1) & 1;
3479 if(kaball != kaball_prevstatus)
3481 kaball_statuschange_time = time;
3482 kaball_prevstatus = kaball;
3485 vector kaball_pos, kaball_size;
3487 if(mySize_x > mySize_y) {
3488 kaball_pos = pos + eX * 0.25 * mySize_x;
3489 kaball_size = eX * 0.5 * mySize_x + eY * mySize_y;
3491 kaball_pos = pos + eY * 0.25 * mySize_y;
3492 kaball_size = eY * 0.5 * mySize_y + eX * mySize_x;
3495 float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
3496 float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
3498 if(kaball_prevstatus && f < 1)
3499 drawpic_aspect_skin_expanding(kaball_pos, "keepawayball_carrying", kaball_size, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
3502 drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
3506 // Nexball HUD mod icon
3507 void HUD_Mod_NexBall(vector pos, vector mySize)
3509 float stat_items, nb_pb_starttime, dt, p;
3511 stat_items = getstati(STAT_ITEMS);
3512 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3514 if (stat_items & IT_KEY1)
3519 //Manage the progress bar if any
3520 if (nb_pb_starttime > 0)
3522 dt = mod(time - nb_pb_starttime, nb_pb_period);
3523 // one period of positive triangle
3524 p = 2 * dt / nb_pb_period;
3529 HUD_Panel_GetProgressBarColor(nexball);
3530 if(mySize_x > mySize_y)
3531 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, 0, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3533 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, 1, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3536 if (stat_items & IT_KEY1)
3537 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3540 // Race/CTS HUD mod icons
3541 float crecordtime_prev; // last remembered crecordtime
3542 float crecordtime_change_time; // time when crecordtime last changed
3543 float srecordtime_prev; // last remembered srecordtime
3544 float srecordtime_change_time; // time when srecordtime last changed
3546 float race_status_time;
3547 float race_status_prev;
3548 string race_status_name_prev;
3549 void HUD_Mod_Race(vector pos, vector mySize)
3551 mod_active = 1; // race should never hide the mod icons panel
3553 me = playerslots[player_localentnum - 1];
3555 float f; // yet another function has this
3556 score = me.(scores[ps_primary]);
3558 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3559 return; // no records in the actual race
3561 // clientside personal record
3563 if(gametype == GAME_CTS)
3567 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3569 if(score && (score < t || !t)) {
3570 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3571 if(autocvar_cl_autodemo_delete_keeprecords)
3573 f = autocvar_cl_autodemo_delete;
3575 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3579 if(t != crecordtime_prev) {
3580 crecordtime_prev = t;
3581 crecordtime_change_time = time;
3584 vector textPos, medalPos;
3586 if(mySize_x > mySize_y) {
3587 // text on left side
3588 squareSize = min(mySize_y, mySize_x/2);
3589 textPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eY * 0.5 * (mySize_y - squareSize);
3590 medalPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eX * 0.5 * mySize_x + eY * 0.5 * (mySize_y - squareSize);
3593 squareSize = min(mySize_x, mySize_y/2);
3594 textPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eX * 0.5 * (mySize_x - squareSize);
3595 medalPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eY * 0.5 * mySize_y + eX * 0.5 * (mySize_x - squareSize);
3598 f = time - crecordtime_change_time;
3601 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3602 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);
3604 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3605 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);
3606 drawstring_aspect_expanding(pos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
3607 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);
3611 t = race_server_record;
3612 if(t != srecordtime_prev) {
3613 srecordtime_prev = t;
3614 srecordtime_change_time = time;
3616 f = time - srecordtime_change_time;
3619 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3620 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);
3622 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3623 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);
3624 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);
3625 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);
3628 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
3629 race_status_time = time + 5;
3630 race_status_prev = race_status;
3631 if (race_status_name_prev)
3632 strunzone(race_status_name_prev);
3633 race_status_name_prev = strzone(race_status_name);
3638 a = bound(0, race_status_time - time, 1);
3641 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
3645 rank = race_CheckName(race_status_name);
3647 rankname = race_PlaceName(rank);
3650 namepos = medalPos + '0 0.8 0' * squareSize;
3652 rankpos = medalPos + '0 0.15 0' * squareSize;
3654 if(race_status == 0)
3655 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3656 else if(race_status == 1) {
3657 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);
3658 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3659 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3660 } else if(race_status == 2) {
3661 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
3662 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);
3664 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);
3665 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3666 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3667 } else if(race_status == 3) {
3668 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);
3669 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3670 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3673 if (race_status_time - time <= 0) {
3674 race_status_prev = -1;
3676 if(race_status_name)
3677 strunzone(race_status_name);
3678 race_status_name = string_null;
3679 if(race_status_name_prev)
3680 strunzone(race_status_name_prev);
3681 race_status_name_prev = string_null;
3685 void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, float layout, float i)
3687 float stat, pps_ratio;
3693 stat = getstatf(STAT_DOM_PPS_RED);
3694 pic = "dom_icon_red";
3698 stat = getstatf(STAT_DOM_PPS_BLUE);
3699 pic = "dom_icon_blue";
3703 stat = getstatf(STAT_DOM_PPS_YELLOW);
3704 pic = "dom_icon_yellow";
3708 stat = getstatf(STAT_DOM_PPS_PINK);
3709 pic = "dom_icon_pink";
3712 pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
3714 if(mySize_x/mySize_y > aspect_ratio)
3716 i = aspect_ratio * mySize_y;
3717 myPos_x = myPos_x + (mySize_x - i) / 2;
3722 i = 1/aspect_ratio * mySize_x;
3723 myPos_y = myPos_y + (mySize_y - i) / 2;
3727 if (layout) // show text too
3730 color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
3731 if (layout == 2) // average pps
3732 drawstring_aspect(myPos + eX * mySize_y, ftos_decimals(stat, 2), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
3733 else // percentage of average pps
3734 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);
3738 drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3741 drawsetcliparea(myPos_x, myPos_y + mySize_y * (1 - pps_ratio), mySize_y, mySize_y * pps_ratio);
3742 drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3743 drawresetcliparea();
3747 void HUD_Mod_Dom(vector myPos, vector mySize)
3749 mod_active = 1; // required in each mod function that always shows something
3752 for(tm = teams.sort_next; tm; tm = tm.sort_next)
3753 if(tm.team != COLOR_SPECTATOR)
3756 float layout = autocvar_hud_panel_modicons_dom_layout;
3757 float rows, columns, aspect_ratio;
3758 rows = mySize_y/mySize_x;
3759 aspect_ratio = (layout) ? 3 : 1;
3760 rows = bound(1, floor((sqrt((4 * aspect_ratio * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count);
3761 columns = ceil(teams_count/rows);
3765 for(i=0; i<teams_count; ++i)
3767 vector pos, itemSize;
3768 pos = myPos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows);
3769 itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
3771 DrawDomItem(pos, itemSize, aspect_ratio, layout, i);
3782 float mod_prev; // previous state of mod_active to check for a change
3784 float mod_change; // "time" when mod_active changed
3786 void HUD_ModIcons(void)
3788 if(!autocvar__hud_configure)
3790 if(!autocvar_hud_panel_modicons) return;
3791 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;
3794 hud_configure_active_panel = HUD_PANEL_MODICONS;
3796 HUD_Panel_UpdateCvars(modicons);
3799 mySize = panel_size;
3801 if(mod_active != mod_prev) {
3803 mod_prev = mod_active;
3806 if(mod_active || autocvar__hud_configure)
3807 mod_alpha = bound(0, (time - mod_change) * 2, 1);
3809 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
3812 HUD_Panel_DrawBg(mod_alpha);
3814 if(panel_bg_padding)
3816 pos += '1 1 0' * panel_bg_padding;
3817 mySize -= '2 2 0' * panel_bg_padding;
3820 // these MUST be ran in order to update mod_active
3821 if(gametype == GAME_KEYHUNT)
3822 HUD_Mod_KH(pos, mySize);
3823 else if(gametype == GAME_CTF || autocvar__hud_configure)
3824 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
3825 else if(gametype == GAME_NEXBALL)
3826 HUD_Mod_NexBall(pos, mySize);
3827 else if(gametype == GAME_CTS || gametype == GAME_RACE)
3828 HUD_Mod_Race(pos, mySize);
3829 else if(gametype == GAME_CA || gametype == GAME_FREEZETAG)
3830 HUD_Mod_CA(pos, mySize);
3831 else if(gametype == GAME_DOMINATION)
3832 HUD_Mod_Dom(pos, mySize);
3833 else if(gametype == GAME_KEEPAWAY)
3834 HUD_Mod_Keepaway(pos, mySize);
3837 // Draw pressed keys (#11)
3839 void HUD_DrawPressedKeys(void)
3841 if(!autocvar__hud_configure)
3843 if(!autocvar_hud_panel_pressedkeys) return;
3844 if(spectatee_status <= 0 && autocvar_hud_panel_pressedkeys < 2) return;
3847 hud_configure_active_panel = HUD_PANEL_PRESSEDKEYS;
3850 HUD_Panel_UpdateCvars(pressedkeys);
3853 mySize = panel_size;
3855 HUD_Panel_DrawBg(1);
3856 if(panel_bg_padding)
3858 pos += '1 1 0' * panel_bg_padding;
3859 mySize -= '2 2 0' * panel_bg_padding;
3862 // force custom aspect
3863 float aspect = autocvar_hud_panel_pressedkeys_aspect;
3867 if(mySize_x/mySize_y > aspect)
3869 newSize_x = aspect * mySize_y;
3870 newSize_y = mySize_y;
3872 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3876 newSize_y = 1/aspect * mySize_x;
3877 newSize_x = mySize_x;
3879 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3885 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
3887 pressedkeys = getstatf(STAT_PRESSED_KEYS);
3889 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3890 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);
3891 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);
3893 drawpic_aspect_skin(pos, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3894 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);
3895 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);
3898 // Handle chat as a panel (#12)
3902 if(!autocvar__hud_configure)
3904 if (!autocvar_hud_panel_chat)
3906 if (!autocvar_con_chatrect)
3907 cvar_set("con_chatrect", "0");
3912 hud_configure_active_panel = HUD_PANEL_CHAT;
3914 HUD_Panel_UpdateCvars(chat);
3916 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
3918 panel_pos_y = panel_bg_border;
3919 panel_size_y = vid_conheight - panel_bg_border * 2;
3920 if(panel_bg == "0") // force a border when maximized
3922 if(precache_pic(panel_bg) == "") {
3923 panel_bg = strcat(hud_skin_path, "/border_default");
3924 if(precache_pic(panel_bg) == "") {
3925 panel_bg = "gfx/hud/default/border_default";
3929 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an alpha of at least 0.75
3934 mySize = panel_size;
3936 HUD_Panel_DrawBg(1);
3938 if(panel_bg_padding)
3940 pos += '1 1 0' * panel_bg_padding;
3941 mySize -= '2 2 0' * panel_bg_padding;
3944 if (!autocvar_con_chatrect)
3945 cvar_set("con_chatrect", "1");
3947 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
3948 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
3950 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
3951 cvar_set("con_chat", ftos(floor(mySize_y/autocvar_con_chatsize - 0.5)));
3953 if(autocvar__hud_configure)
3956 chatsize = '1 1 0' * autocvar_con_chatsize;
3957 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
3959 for(i = 0; i < autocvar_con_chat; ++i)
3961 if(i == autocvar_con_chat - 1)
3964 a = panel_fg_alpha * floor(((i + 1) * 7 + autocvar_con_chattime)/45);
3965 drawcolorcodedstring(pos, textShortenToWidth(_("^3Player^7: This is the chat area."), mySize_x, chatsize, stringwidth_colors), chatsize, a, DRAWFLAG_NORMAL);
3966 pos_y += chatsize_y;
3971 // Engine info panel (#13)
3978 float frametimeavg1; // 1 frame ago
3979 float frametimeavg2; // 2 frames ago
3980 void HUD_EngineInfo(void)
3982 if(!autocvar__hud_configure)
3984 if(!autocvar_hud_panel_engineinfo) return;
3987 hud_configure_active_panel = HUD_PANEL_ENGINEINFO;
3989 HUD_Panel_UpdateCvars(engineinfo);
3992 mySize = panel_size;
3994 HUD_Panel_DrawBg(1);
3995 if(panel_bg_padding)
3997 pos += '1 1 0' * panel_bg_padding;
3998 mySize -= '2 2 0' * panel_bg_padding;
4001 float currentTime = gettime(GETTIME_REALTIME);
4002 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
4004 float currentframetime = currentTime - prevfps_time;
4005 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4006 frametimeavg2 = frametimeavg1;
4007 frametimeavg1 = frametimeavg;
4010 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4011 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.
4013 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
4014 prevfps = (1/currentframetime);
4015 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"
4017 prevfps_time = currentTime;
4022 if(currentTime - prevfps_time > autocvar_hud_panel_engineinfo_framecounter_time)
4024 prevfps = framecounter/(currentTime - prevfps_time);
4026 prevfps_time = currentTime;
4031 color = HUD_Get_Num_Color (prevfps, 100);
4032 drawstring_aspect(pos, sprintf(_("FPS: %.*f"), autocvar_hud_panel_engineinfo_framecounter_decimals, prevfps), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4035 // Info messages panel (#14)
4037 #define drawInfoMessage(s)\
4038 if(autocvar_hud_panel_infomessages_flip)\
4039 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\
4040 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
4042 void HUD_InfoMessages(void)
4044 if(!autocvar__hud_configure)
4046 if(!autocvar_hud_panel_infomessages) return;
4049 hud_configure_active_panel = HUD_PANEL_INFOMESSAGES;
4051 HUD_Panel_UpdateCvars(infomessages);
4054 mySize = panel_size;
4056 HUD_Panel_DrawBg(1);
4057 if(panel_bg_padding)
4059 pos += '1 1 0' * panel_bg_padding;
4060 mySize -= '2 2 0' * panel_bg_padding;
4063 // always force 5:1 aspect
4065 if(mySize_x/mySize_y > 5)
4067 newSize_x = 5 * mySize_y;
4068 newSize_y = mySize_y;
4070 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4074 newSize_y = 1/5 * mySize_x;
4075 newSize_x = mySize_x;
4077 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4086 fontsize = '0.20 0.20 0' * mySize_y;
4089 if(spectatee_status != 0)
4095 if(!autocvar__hud_configure)
4097 if(spectatee_status && !intermission)
4099 if(spectatee_status == -1)
4100 s = _("^1Observing");
4102 s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(spectatee_status - 1));
4105 if(spectatee_status == -1)
4106 s = sprintf(_("^1Press ^3%s^1 to spectate"), getcommandkey("primary fire", "+fire"));
4108 s = sprintf(_("^1Press ^3%s^1 for another player"), getcommandkey("primary fire", "+fire"));
4111 if(spectatee_status == -1)
4112 s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
4114 s = sprintf(_("^1Press ^3%s^1 to observe"), getcommandkey("secondary fire", "+fire2"));
4117 s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey("server info", "+show_info"));
4120 if(gametype == GAME_ARENA)
4121 s = _("^1Wait for your turn to join");
4122 else if(gametype == GAME_LMS)
4125 sk = playerslots[player_localentnum - 1];
4126 if(sk.(scores[ps_primary]) >= 666)
4127 s = _("^1Match has already begun");
4128 else if(sk.(scores[ps_primary]) > 0)
4129 s = _("^1You have no more lives left");
4131 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
4134 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
4137 //show restart countdown:
4138 if (time < getstatf(STAT_GAMESTARTTIME)) {
4140 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4141 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4142 s = sprintf(_("^1Game starts in ^3%d^1 seconds"), countdown);
4143 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4147 if(warmup_stage && !intermission)
4149 s = _("^2Currently in ^1warmup^2 stage!");
4154 if(mod(time, 1) >= 0.5)
4159 if(ready_waiting && !intermission && !spectatee_status)
4161 if(ready_waiting_for_me)
4164 s = sprintf(_("%sPress ^3%s%s to end warmup"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
4166 s = sprintf(_("%sPress ^3%s%s once you are ready"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
4171 s = _("^2Waiting for others to ready up to end warmup...");
4173 s = _("^2Waiting for others to ready up...");
4177 else if(warmup_stage && !intermission && !spectatee_status)
4179 s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey("ready", "ready"));
4183 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4185 float ts_min, ts_max;
4186 tm = teams.sort_next;
4189 for(; tm.sort_next; tm = tm.sort_next)
4191 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4193 if(!ts_min) ts_min = tm.team_size;
4194 else ts_min = min(ts_min, tm.team_size);
4195 if(!ts_max) ts_max = tm.team_size;
4196 else ts_max = max(ts_max, tm.team_size);
4198 if ((ts_max - ts_min) > 1)
4200 s = strcat(blinkcolor, _("Teamnumbers are unbalanced!"));
4201 tm = GetTeam(myteam, false);
4203 if (tm.team != COLOR_SPECTATOR)
4204 if (tm.team_size == ts_max)
4205 s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey("team menu", "menu_showteamselect"), blinkcolor));
4213 s = _("^7Press ^3ESC ^7to show HUD options.");
4215 s = _("^3Doubleclick ^7a panel for panel-specific options.");
4217 s = _("^3CTRL ^7to disable collision testing, ^3SHIFT ^7and");
4219 s = _("^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.");
4224 // Physics panel (#15)
4226 vector acc_prevspeed;
4227 float acc_prevtime, acc_avg, top_speed, top_speed_time;
4228 void HUD_Physics(void)
4230 if(!autocvar__hud_configure)
4232 if(!autocvar_hud_panel_physics) return;
4233 if(spectatee_status == -1 && autocvar_hud_panel_physics < 2) return;
4236 hud_configure_active_panel = HUD_PANEL_PHYSICS;
4238 HUD_Panel_UpdateCvars(physics);
4240 HUD_Panel_DrawBg(1);
4241 if(panel_bg_padding)
4243 panel_pos += '1 1 0' * panel_bg_padding;
4244 panel_size -= '2 2 0' * panel_bg_padding;
4248 float speed, conversion_factor;
4251 switch(autocvar_hud_panel_physics_speed_unit)
4256 conversion_factor = 1.0;
4260 conversion_factor = 0.0254;
4264 conversion_factor = 0.0254 * 3.6;
4268 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4272 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4276 float max_speed = floor( autocvar_hud_panel_physics_speed_max * conversion_factor + 0.5 );
4277 if (autocvar__hud_configure)
4278 speed = floor( max_speed * 0.65 + 0.5 );
4279 else if(autocvar_hud_panel_physics_speed_vertical)
4280 speed = floor( vlen(pmove_vel) * conversion_factor + 0.5 );
4282 speed = floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 );
4284 //compute acceleration
4285 float acceleration, f;
4286 if (autocvar__hud_configure)
4287 acceleration = autocvar_hud_panel_physics_acceleration_max * 0.3;
4290 // 1 m/s = 0.0254 qu/s; 1 g = 9.80665 m/s^2
4291 f = time - acc_prevtime;
4292 if(autocvar_hud_panel_physics_acceleration_vertical)
4293 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f) * (0.0254 / 9.80665);
4295 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);
4296 acc_prevspeed = pmove_vel;
4297 acc_prevtime = time;
4299 f = bound(0, f * 10, 1);
4300 acc_avg = acc_avg * (1 - f) + acceleration * f;
4304 float panel_ar = panel_size_x/panel_size_y;
4305 vector speed_offset, acceleration_offset;
4308 panel_size_x *= 0.5;
4309 if (autocvar_hud_panel_physics_flip)
4310 speed_offset_x = panel_size_x;
4312 acceleration_offset_x = panel_size_x;
4316 panel_size_y *= 0.5;
4317 if (autocvar_hud_panel_physics_flip)
4318 speed_offset_y = panel_size_y;
4320 acceleration_offset_y = panel_size_y;
4322 float speed_baralign, acceleration_baralign;
4323 if (autocvar_hud_panel_physics_baralign == 1)
4324 acceleration_baralign = speed_baralign = 1;
4325 else if(autocvar_hud_panel_physics_baralign == 4)
4326 acceleration_baralign = speed_baralign = 2;
4327 else if (autocvar_hud_panel_physics_flip)
4329 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 2);
4330 speed_baralign = (autocvar_hud_panel_physics_baralign == 3);
4334 speed_baralign = (autocvar_hud_panel_physics_baralign == 2);
4335 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 3);
4337 if (autocvar_hud_panel_physics_acceleration_progressbar_mode == 0)
4338 acceleration_baralign = 3; //override hud_panel_physics_baralign value for acceleration
4342 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
4344 HUD_Panel_GetProgressBarColor(speed);
4345 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);
4347 vector tmp_offset, tmp_size;
4348 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
4350 tmp_size_x = panel_size_x * 0.75;
4351 tmp_size_y = panel_size_y;
4353 tmp_offset_x = panel_size_x - tmp_size_x;
4356 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4362 tmp_offset_x = tmp_size_x;
4363 if (autocvar_hud_panel_physics_speed_unit_show)
4366 tmp_size_x = panel_size_x * (1 - 0.75);
4367 tmp_size_y = panel_size_y * 0.4;
4368 drawstring_aspect(panel_pos + speed_offset + tmp_offset, unit, tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4372 //compute and draw top speed
4373 if (autocvar_hud_panel_physics_topspeed)
4374 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
4376 if (autocvar__hud_configure)
4378 top_speed = floor( max_speed * 0.75 + 0.5 );
4383 if (speed >= top_speed)
4386 top_speed_time = time;
4390 f = max(1, autocvar_hud_panel_physics_topspeed_time);
4391 // divide by f to make it start from 1
4392 f = cos( ((time - top_speed_time) / f) * PI/2 );
4394 else //hide top speed 0, it would be stupid
4399 //top speed progressbar peak
4400 if(speed < top_speed)
4401 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
4403 float peak_offset_x;
4405 if (speed_baralign == 0)
4406 peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x;
4407 else if (speed_baralign == 1)
4408 peak_offset_x = (1 - min(top_speed, max_speed)/max_speed) * panel_size_x;
4409 else if (speed_baralign == 2)
4410 peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x * 0.5;
4411 //if speed is not 0 the speed progressbar already fetched the color
4413 HUD_Panel_GetProgressBarColor(speed);
4414 peak_size_x = floor(panel_size_x * 0.01 + 1.5);
4415 peak_size_y = panel_size_y;
4416 if (speed_baralign == 2) // draw two peaks, on both sides
4418 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);
4419 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);
4422 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);
4426 tmp_offset_y = panel_size_y * 0.4;
4427 tmp_size_x = panel_size_x * (1 - 0.75);
4428 tmp_size_y = panel_size_y - tmp_offset_y;
4429 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(top_speed), tmp_size, '1 0 0', f * panel_fg_alpha, DRAWFLAG_NORMAL);
4437 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 3)
4439 if (acceleration < 0)
4440 HUD_Panel_GetProgressBarColor(acceleration_neg);
4442 HUD_Panel_GetProgressBarColor(acceleration);
4443 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);
4445 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
4446 drawstring_aspect(panel_pos + acceleration_offset, strcat(ftos_decimals(acceleration, 2), "g"), panel_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4455 void HUD_Reset (void)
4457 // reset gametype specific icons
4458 if(gametype == GAME_KEYHUNT)
4460 else if(gametype == GAME_CTF)
4461 HUD_Mod_CTF_Reset();
4464 #define HUD_DrawPanel(id)\
4466 case (HUD_PANEL_RADAR):\
4467 HUD_Radar(); break;\
4468 case (HUD_PANEL_WEAPONS):\
4469 HUD_Weapons(); break;\
4470 case (HUD_PANEL_AMMO):\
4472 case (HUD_PANEL_POWERUPS):\
4473 HUD_Powerups(); break;\
4474 case (HUD_PANEL_HEALTHARMOR):\
4475 HUD_HealthArmor(); break;\
4476 case (HUD_PANEL_NOTIFY):\
4477 HUD_Notify(); break;\
4478 case (HUD_PANEL_TIMER):\
4479 HUD_Timer(); break;\
4480 case (HUD_PANEL_SCORE):\
4481 HUD_Score(); break;\
4482 case (HUD_PANEL_RACETIMER):\
4483 HUD_RaceTimer(); break;\
4484 case (HUD_PANEL_VOTE):\
4485 HUD_VoteWindow(); break;\
4486 case (HUD_PANEL_MODICONS):\
4487 HUD_ModIcons(); break;\
4488 case (HUD_PANEL_PRESSEDKEYS):\
4489 HUD_DrawPressedKeys(); break;\
4490 case (HUD_PANEL_CHAT):\
4492 case (HUD_PANEL_ENGINEINFO):\
4493 HUD_EngineInfo(); break;\
4494 case (HUD_PANEL_INFOMESSAGES):\
4495 HUD_InfoMessages(); break;\
4496 case (HUD_PANEL_PHYSICS):\
4497 HUD_Physics(); break;\
4498 } ENDS_WITH_CURLY_BRACE
4500 void HUD_Main (void)
4503 // global hud alpha fade
4504 if(menu_enabled == 1)
4507 hud_fade_alpha = (1 - autocvar__menu_alpha);
4509 if(scoreboard_fade_alpha)
4510 hud_fade_alpha = (1 - scoreboard_fade_alpha);
4512 if(intermission == 2) // no hud during mapvote
4514 else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
4517 if(!autocvar__hud_configure && !hud_fade_alpha)
4521 if (hud_skin_path != autocvar_hud_skin)
4524 strunzone(hud_skin_path);
4525 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
4528 // HUD configure visible grid
4529 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4531 hud_configure_gridSize_x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
4532 hud_configure_gridSize_y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
4533 hud_configure_realGridSize_x = hud_configure_gridSize_x * vid_conwidth;
4534 hud_configure_realGridSize_y = hud_configure_gridSize_y * vid_conheight;
4536 for(i = 0; i < 1/hud_configure_gridSize_x; ++i)
4537 drawfill(eX * i * hud_configure_realGridSize_x, eX + eY * vid_conheight, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4539 for(i = 0; i < 1/hud_configure_gridSize_y; ++i)
4540 drawfill(eY * i * hud_configure_realGridSize_y, eY + eX * vid_conwidth, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4543 current_player = (spectatee_status > 0) ? spectatee_status : player_localentnum;
4546 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4550 float hud_dock_color_team = autocvar_hud_dock_color_team;
4551 if((teamplay) && hud_dock_color_team) {
4552 f = stof(getplayerkey(current_player - 1, "colors"));
4553 color = colormapPaletteColor(mod(f, 16), 1) * hud_dock_color_team;
4555 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
4556 color = '1 0 0' * hud_dock_color_team;
4560 string hud_dock_color = autocvar_hud_dock_color;
4561 if(hud_dock_color == "shirt") {
4562 f = stof(getplayerkey(current_player - 1, "colors"));
4563 color = colormapPaletteColor(floor(f / 16), 0);
4565 else if(hud_dock_color == "pants") {
4566 f = stof(getplayerkey(current_player - 1, "colors"));
4567 color = colormapPaletteColor(mod(f, 16), 1);
4570 color = stov(hud_dock_color);
4574 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4575 if(precache_pic(pic) == "") {
4576 pic = strcat(hud_skin_path, "/dock_medium");
4577 if(precache_pic(pic) == "") {
4578 pic = "gfx/hud/default/dock_medium";
4581 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...
4584 // cache the panel order into the panel_order array
4585 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4586 for(i = 0; i < HUD_PANEL_NUM; ++i)
4587 panel_order[i] = -1;
4589 float p_num, warning;
4590 float argc = tokenize_console(autocvar__hud_panelorder);
4591 if (argc > HUD_PANEL_NUM)
4593 //first detect wrong/missing panel numbers
4594 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4595 p_num = stof(argv(i));
4596 if (p_num >= 0 && p_num < HUD_PANEL_NUM) { //correct panel number?
4597 if (panel_order[p_num] == -1) //found for the first time?
4598 s = strcat(s, ftos(p_num), " ");
4599 panel_order[p_num] = 1; //mark as found
4604 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4605 if (panel_order[i] == -1) {
4607 s = strcat(s, ftos(i), " "); //add missing panel number
4611 print(_("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n"));
4613 cvar_set("_hud_panelorder", s);
4614 if(hud_panelorder_prev)
4615 strunzone(hud_panelorder_prev);
4616 hud_panelorder_prev = strzone(s);
4618 //now properly set panel_order
4619 tokenize_console(s);
4620 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4621 panel_order[i] = stof(argv(i));
4625 // draw panels in order specified by panel_order array
4626 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
4627 if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice!
4628 HUD_DrawPanel(panel_order[i]);
4631 // draw chat panel on top if it is maximized
4632 if(autocvar__con_chat_maximized)
4633 HUD_Chat(); // HUD_DrawPanel(HUD_PANEL_CHAT);
4635 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)
4636 localcmd("cmd selectteam auto; cmd join\n");
4638 if(autocvar__hud_configure && tab_panel != -1)
4640 HUD_Panel_UpdatePosSizeForId(tab_panel)
4641 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
4644 hud_configure_prev = autocvar__hud_configure;
4646 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again