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_RIFLE: 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)
615 float i, f, screen_ar;
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 float weapons_st = getstati(STAT_WEAPONS);
649 if (!autocvar__hud_configure && autocvar_hud_panel_weapons_onlyowned)
651 vector old_panel_size;
652 for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
654 if(weapons_st & weaponorder[i].weapons)
657 // reduce size of the panel
658 if (panel_size_y > panel_size_x)
660 old_panel_size_y = panel_size_y;
661 panel_size_y *= weapon_count / WEP_COUNT;
662 panel_pos_y += (old_panel_size_y - panel_size_y) / 2;
666 old_panel_size_x = panel_size_x;
667 panel_size_x *= weapon_count / WEP_COUNT;
668 panel_pos_x += (old_panel_size_x - panel_size_x) / 2;
672 weapon_count = WEP_COUNT;
674 if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
676 f = (time - (weapontime + timeout)) / timeout_effect_length;
677 if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3)
679 panel_bg_alpha *= (1 - f);
680 panel_fg_alpha *= (1 - f);
682 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
684 f *= f; // for a cooler movement
685 center_x = panel_pos_x + panel_size_x/2;
686 center_y = panel_pos_y + panel_size_y/2;
687 screen_ar = vid_conwidth/vid_conheight;
688 if (center_x/center_y < screen_ar) //bottom left
690 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
691 panel_pos_y += f * (vid_conheight - panel_pos_y);
693 panel_pos_x -= f * (panel_pos_x + panel_size_x);
697 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
698 panel_pos_x += f * (vid_conwidth - panel_pos_x);
700 panel_pos_y -= f * (panel_pos_y + panel_size_y);
703 weaponprevtime = time - (1 - f) * timein_effect_length;
705 else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure)
707 f = (time - weaponprevtime) / timein_effect_length;
708 if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3)
710 panel_bg_alpha *= (f);
711 panel_fg_alpha *= (f);
713 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
715 f *= f; // for a cooler movement
717 center_x = panel_pos_x + panel_size_x/2;
718 center_y = panel_pos_y + panel_size_y/2;
719 screen_ar = vid_conwidth/vid_conheight;
720 if (center_x/center_y < screen_ar) //bottom left
722 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
723 panel_pos_y += f * (vid_conheight - panel_pos_y);
725 panel_pos_x -= f * (panel_pos_x + panel_size_x);
729 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
730 panel_pos_x += f * (vid_conwidth - panel_pos_x);
732 panel_pos_y -= f * (panel_pos_y + panel_size_y);
737 // TODO make this configurable
738 if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
741 if(weaponorder_bypriority)
742 strunzone(weaponorder_bypriority);
743 if(weaponorder_byimpulse)
744 strunzone(weaponorder_byimpulse);
746 weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
747 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
748 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
751 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
753 self = get_weaponinfo(i);
754 if(self.impulse >= 0)
756 weaponorder[weapon_cnt] = self;
760 for(i = weapon_cnt; i < WEP_MAXCOUNT; ++i)
761 weaponorder[i] = NULL;
762 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
764 weaponorder_cmp_str = string_null;
770 panel_pos += '1 1 0' * panel_bg_padding;
771 panel_size -= '2 2 0' * panel_bg_padding;
774 float weapid, wpnalpha;
776 if(autocvar_hud_panel_weapons_fade)
778 wpnalpha = 3.2 - 2 * (time - weapontime);
779 wpnalpha = bound(0.7, wpnalpha, 1) * panel_fg_alpha;
782 wpnalpha = panel_fg_alpha;
785 float aspect = autocvar_hud_panel_weapons_aspect;
786 rows = panel_size_y/panel_size_x;
787 rows = bound(1, floor((sqrt(4 * aspect * rows * weapon_count + rows * rows) + rows + 0.5) / 2), weapon_count);
789 columns = ceil(weapon_count/rows);
792 float a, type, fullammo;
794 when = autocvar_hud_panel_weapons_complainbubble_time;
796 fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
804 wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
805 float barsize_x, barsize_y, baroffset_x, baroffset_y;
806 if (autocvar_hud_panel_weapons_ammo)
808 ammo_color = stov(autocvar_hud_panel_weapons_ammo_color);
809 ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha;
812 if(wpnsize_x/wpnsize_y > aspect)
814 barsize_x = aspect * wpnsize_y;
815 barsize_y = wpnsize_y;
816 baroffset_x = (wpnsize_x - barsize_x) / 2;
820 barsize_y = 1/aspect * wpnsize_x;
821 barsize_x = wpnsize_x;
822 baroffset_y = (wpnsize_y - barsize_y) / 2;
828 if(autocvar_hud_panel_weapons_accuracy && acc_levels)
830 show_accuracy = true;
831 if (acc_col_x[0] == -1)
832 for (i = 0; i < acc_levels; ++i)
833 acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
836 for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
838 self = weaponorder[i];
839 if (!self || self.impulse < 0)
841 if (autocvar_hud_panel_weapons_onlyowned)
842 if (!(weapons_st & self.weapons))
843 if (!autocvar__hud_configure)
845 wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
847 weapid = self.impulse;
849 // draw background behind currently selected weapon
850 if(self.weapon == activeweapon)
851 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
853 // draw the weapon accuracy
856 weapon_stats = weapon_accuracy[self.weapon-WEP_FIRST];
857 if(weapon_stats >= 0)
859 // find the max level lower than weapon_stats
862 while ( j && weapon_stats < acc_lev[j] )
865 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
867 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
869 color = color + factor * (acc_col[j+1] - color);
871 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
875 // draw the weapon icon
876 if(weapons_st & self.weapons)
878 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
880 if(autocvar_hud_panel_weapons_label == 1) // weapon number
881 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
882 else if(autocvar_hud_panel_weapons_label == 2) // bind
883 drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
885 // draw ammo status bar
886 if(autocvar_hud_panel_weapons_ammo && self.weapon != WEP_TUBA && self.weapon != WEP_LASER && self.weapon != WEP_PORTO)
889 type = GetAmmoTypeForWep(self.weapon);
891 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
896 case 0: fullammo = autocvar_hud_panel_weapons_ammo_full_shells; break;
897 case 1: fullammo = autocvar_hud_panel_weapons_ammo_full_nails; break;
898 case 2: fullammo = autocvar_hud_panel_weapons_ammo_full_rockets; break;
899 case 3: fullammo = autocvar_hud_panel_weapons_ammo_full_cells; break;
900 case 4: fullammo = autocvar_hud_panel_weapons_ammo_full_fuel; break;
901 default: fullammo = 60;
905 wpnpos_x + baroffset_x,
906 wpnpos_y + baroffset_y,
907 barsize_x * bound(0, a/fullammo, 1),
909 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, ammo_color, ammo_alpha, DRAWFLAG_NORMAL);
915 // draw a "ghost weapon icon" if you don't have the weapon
918 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
921 // draw the complain message
922 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
926 if(complain_weapon_time + when > time)
929 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
933 if(complain_weapon_time + when > time)
940 if(complain_weapon_type == 0) {
941 s = _("Out of ammo");
942 color = stov(autocvar_hud_panel_weapons_complainbubble_color_outofammo);
944 else if(complain_weapon_type == 1) {
946 color = stov(autocvar_hud_panel_weapons_complainbubble_color_donthave);
949 s = _("Unavailable");
950 color = stov(autocvar_hud_panel_weapons_complainbubble_color_unavailable);
952 float padding = autocvar_hud_panel_weapons_complainbubble_padding;
953 drawpic_aspect_skin(wpnpos + '1 1 0' * padding, "weapon_complainbubble", wpnsize - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
954 drawstring_aspect(wpnpos + '1 1 0' * padding, s, wpnsize - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
970 float GetAmmoItemCode(float i)
974 case 0: return IT_SHELLS;
975 case 1: return IT_NAILS;
976 case 2: return IT_ROCKETS;
977 case 3: return IT_CELLS;
978 case 4: return IT_FUEL;
983 string GetAmmoPicture(float i)
987 case 0: return "ammo_shells";
988 case 1: return "ammo_bullets";
989 case 2: return "ammo_rockets";
990 case 3: return "ammo_cells";
991 case 4: return "ammo_fuel";
996 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
999 if(autocvar__hud_configure)
1001 currently_selected = (itemcode == 2); //rockets always selected
1002 a = 31 + mod(itemcode*93, 128);
1005 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1014 if(currently_selected)
1019 vector picpos, numpos;
1020 if(autocvar_hud_panel_ammo_iconalign)
1023 picpos = myPos + eX * 2 * mySize_y;
1027 numpos = myPos + eX * mySize_y;
1031 if (currently_selected)
1032 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1034 if(a > 0 && autocvar_hud_panel_ammo_progressbar)
1035 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);
1037 if(autocvar_hud_panel_ammo_text)
1040 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1041 else // "ghost" ammo count
1042 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1045 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1046 else // "ghost" ammo icon
1047 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1052 if(!autocvar__hud_configure)
1054 if(!autocvar_hud_panel_ammo) return;
1055 if(spectatee_status == -1) return;
1058 hud_configure_active_panel = HUD_PANEL_AMMO;
1060 HUD_Panel_UpdateCvars(ammo);
1063 mySize = panel_size;
1065 HUD_Panel_DrawBg(1);
1066 if(panel_bg_padding)
1068 pos += '1 1 0' * panel_bg_padding;
1069 mySize -= '2 2 0' * panel_bg_padding;
1072 float rows, columns, row, column;
1074 if (autocvar_hud_panel_ammo_onlycurrent)
1078 rows = mySize_y/mySize_x;
1079 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1080 // ^^^ ammo item aspect goes here
1082 columns = ceil(AMMO_COUNT/rows);
1084 ammo_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
1089 if(ammo_size_x/ammo_size_y > 3)
1091 newSize = 3 * ammo_size_y;
1092 offset_x = ammo_size_x - newSize;
1093 pos_x += offset_x/2;
1094 ammo_size_x = newSize;
1098 newSize = 1/3 * ammo_size_x;
1099 offset_y = ammo_size_y - newSize;
1100 pos_y += offset_y/2;
1101 ammo_size_y = newSize;
1104 float i, stat_items, currently_selected;
1105 if (autocvar_hud_panel_ammo_onlycurrent)
1107 if(autocvar__hud_configure)
1109 DrawAmmoItem(pos, ammo_size, 2, true); //show rockets
1112 stat_items = getstati(STAT_ITEMS);
1113 for (i = 0; i < AMMO_COUNT; ++i) {
1114 currently_selected = stat_items & GetAmmoItemCode(i);
1115 if (currently_selected)
1117 DrawAmmoItem(pos, ammo_size, i, true);
1121 return; // nothing to display
1124 stat_items = getstati(STAT_ITEMS);
1125 for (i = 0; i < AMMO_COUNT; ++i) {
1126 currently_selected = stat_items & GetAmmoItemCode(i);
1127 DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected);
1132 column = column + 1;
1137 void DrawNumIcon(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float alpha)
1139 vector newPos, newSize;
1140 vector picpos, numpos;
1144 if(mySize_y/mySize_x > 2)
1146 newSize_y = 2 * mySize_x;
1147 newSize_x = mySize_x;
1149 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1154 newSize_x = 1/2 * mySize_y;
1155 newSize_y = mySize_y;
1157 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1161 if(icon_right_align)
1164 picpos = newPos + eY * newSize_x;
1169 numpos = newPos + eY * newSize_x;
1173 drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1174 // make number smaller than icon, it looks better
1175 // reduce only y to draw numbers with different number of digits with the same y size
1176 numpos_y += newSize_y * ((1 - 0.7) / 2);
1178 drawstring_aspect(numpos, ftos(x), newSize, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1182 if(mySize_x/mySize_y > 3)
1184 newSize_x = 3 * mySize_y;
1185 newSize_y = mySize_y;
1187 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1192 newSize_y = 1/3 * mySize_x;
1193 newSize_x = mySize_x;
1195 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1199 if(icon_right_align) // right align
1202 picpos = newPos + eX * 2 * newSize_y;
1206 numpos = newPos + eX * newSize_y;
1210 drawstring_aspect(numpos, ftos(x), '2 1 0' * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1211 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1214 void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float fadelerp)
1217 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
1219 DrawNumIcon(myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, vertical, icon_right_align, color, (1 - fadelerp));
1224 void HUD_Powerups(void)
1226 float strength_time, shield_time;
1227 if(!autocvar__hud_configure)
1229 if(!autocvar_hud_panel_powerups) return;
1230 if(spectatee_status == -1) return;
1231 if not(getstati(STAT_ITEMS) & (IT_STRENGTH | IT_INVINCIBLE)) return;
1232 if (getstati(STAT_HEALTH) <= 0) return;
1234 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1235 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1239 hud_configure_active_panel = HUD_PANEL_POWERUPS;
1245 HUD_Panel_UpdateCvars(powerups);
1248 mySize = panel_size;
1250 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
1251 if(panel_bg_padding)
1253 pos += '1 1 0' * panel_bg_padding;
1254 mySize -= '2 2 0' * panel_bg_padding;
1257 float panel_ar = mySize_x/mySize_y;
1258 float is_vertical = (panel_ar < 1);
1259 vector shield_offset, strength_offset;
1260 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1263 if (autocvar_hud_panel_powerups_flip)
1264 shield_offset_x = mySize_x;
1266 strength_offset_x = mySize_x;
1271 if (autocvar_hud_panel_powerups_flip)
1272 shield_offset_y = mySize_y;
1274 strength_offset_y = mySize_y;
1277 float shield_baralign, strength_baralign;
1278 float shield_iconalign, strength_iconalign;
1279 if (autocvar_hud_panel_powerups_flip)
1281 strength_baralign = (autocvar_hud_panel_powerups_baralign == 2 || autocvar_hud_panel_powerups_baralign == 1);
1282 shield_baralign = (autocvar_hud_panel_powerups_baralign == 3 || autocvar_hud_panel_powerups_baralign == 1);
1283 strength_iconalign = (autocvar_hud_panel_powerups_iconalign == 2 || autocvar_hud_panel_powerups_iconalign == 1);
1284 shield_iconalign = (autocvar_hud_panel_powerups_iconalign == 3 || autocvar_hud_panel_powerups_iconalign == 1);
1288 shield_baralign = (autocvar_hud_panel_powerups_baralign == 2 || autocvar_hud_panel_powerups_baralign == 1);
1289 strength_baralign = (autocvar_hud_panel_powerups_baralign == 3 || autocvar_hud_panel_powerups_baralign == 1);
1290 shield_iconalign = (autocvar_hud_panel_powerups_iconalign == 2 || autocvar_hud_panel_powerups_iconalign == 1);
1291 strength_iconalign = (autocvar_hud_panel_powerups_iconalign == 3 || autocvar_hud_panel_powerups_iconalign == 1);
1296 const float maxshield = 30;
1297 float shield = ceil(shield_time);
1298 if(autocvar_hud_panel_powerups_progressbar)
1300 HUD_Panel_GetProgressBarColor(shield);
1301 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);
1303 if(autocvar_hud_panel_powerups_text)
1306 DrawNumIcon(pos + shield_offset, mySize, shield, "shield", is_vertical, shield_iconalign, '1 1 1', 1);
1308 DrawNumIcon_expanding(pos + shield_offset, mySize, shield, "shield", is_vertical, shield_iconalign, '1 1 1', bound(0, (shield - shield_time) / 0.5, 1));
1314 const float maxstrength = 30;
1315 float strength = ceil(strength_time);
1316 if(autocvar_hud_panel_powerups_progressbar)
1318 HUD_Panel_GetProgressBarColor(strength);
1319 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);
1321 if(autocvar_hud_panel_powerups_text)
1324 DrawNumIcon(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', 1);
1326 DrawNumIcon_expanding(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', bound(0, (strength - strength_time) / 0.5, 1));
1331 // Health/armor (#3)
1334 // prev_* vars contain the health/armor at the previous FRAME
1335 // set to -1 when player is dead or was not playing
1336 float prev_health, prev_armor;
1337 float health_damagetime, armor_damagetime;
1338 float health_beforedamage, armor_beforedamage;
1339 // old_p_* vars keep track of previous values when smoothing value changes of the progressbar
1340 float old_p_health, old_p_armor;
1341 float old_p_healthtime, old_p_armortime;
1342 // prev_p_* vars contain the health/armor progressbar value at the previous FRAME
1343 // set to -1 to forcedly stop effects when we switch spectated player (e.g. from playerX: 70h to playerY: 50h)
1344 float prev_p_health, prev_p_armor;
1346 void HUD_HealthArmor(void)
1348 float armor, health, fuel;
1349 if(!autocvar__hud_configure)
1351 if(!autocvar_hud_panel_healtharmor) return;
1352 if(spectatee_status == -1) return;
1354 health = getstati(STAT_HEALTH);
1360 armor = getstati(STAT_ARMOR);
1362 // code to check for spectatee_status changes is in Ent_ClientData()
1363 // prev_p_health and prev_health can be set to -1 there
1365 if (prev_p_health == -1)
1368 health_beforedamage = 0;
1369 armor_beforedamage = 0;
1370 health_damagetime = 0;
1371 armor_damagetime = 0;
1372 prev_health = health;
1374 old_p_health = health;
1375 old_p_armor = armor;
1376 prev_p_health = health;
1377 prev_p_armor = armor;
1379 else if (prev_health == -1)
1381 //start the load effect
1382 health_damagetime = 0;
1383 armor_damagetime = 0;
1387 fuel = getstati(STAT_FUEL);
1391 hud_configure_active_panel = HUD_PANEL_HEALTHARMOR;
1398 HUD_Panel_UpdateCvars(healtharmor);
1401 mySize = panel_size;
1403 HUD_Panel_DrawBg(1);
1404 if(panel_bg_padding)
1406 pos += '1 1 0' * panel_bg_padding;
1407 mySize -= '2 2 0' * panel_bg_padding;
1410 float baralign = autocvar_hud_panel_healtharmor_baralign;
1411 float iconalign = autocvar_hud_panel_healtharmor_iconalign;
1413 float maxhealth = autocvar_hud_panel_healtharmor_maxhealth;
1414 float maxarmor = autocvar_hud_panel_healtharmor_maxarmor;
1415 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
1418 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1423 float maxtotal = maxhealth + maxarmor;
1425 if(v_z) // NOT fully armored
1427 biggercount = "health";
1428 if(autocvar_hud_panel_healtharmor_progressbar)
1430 HUD_Panel_GetProgressBarColor(health);
1431 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);
1434 if(autocvar_hud_panel_healtharmor_text)
1435 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);
1439 biggercount = "armor";
1440 if(autocvar_hud_panel_healtharmor_progressbar)
1442 HUD_Panel_GetProgressBarColor(armor);
1443 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);
1446 if(autocvar_hud_panel_healtharmor_text)
1447 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);
1449 if(autocvar_hud_panel_healtharmor_text)
1450 DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, maxtotal), 1);
1454 HUD_Panel_GetProgressBarColor(fuel);
1455 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);
1460 float panel_ar = mySize_x/mySize_y;
1461 float is_vertical = (panel_ar < 1);
1462 vector health_offset, armor_offset;
1463 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1466 if (autocvar_hud_panel_healtharmor_flip)
1467 health_offset_x = mySize_x;
1469 armor_offset_x = mySize_x;
1474 if (autocvar_hud_panel_healtharmor_flip)
1475 health_offset_y = mySize_y;
1477 armor_offset_y = mySize_y;
1480 float health_baralign, armor_baralign, fuel_baralign;
1481 float health_iconalign, armor_iconalign;
1482 if (autocvar_hud_panel_healtharmor_flip)
1484 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1485 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1486 fuel_baralign = health_baralign;
1487 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1488 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1492 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1493 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1494 fuel_baralign = armor_baralign;
1495 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1496 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1501 if(autocvar_hud_panel_healtharmor_progressbar)
1503 HUD_Panel_GetProgressBarColor(health);
1504 float p_health, pain_health_alpha;
1506 pain_health_alpha = 1;
1507 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1509 if (autocvar_hud_panel_healtharmor_progressbar_gfx_smooth > 0)
1511 if (fabs(prev_health - health) >= autocvar_hud_panel_healtharmor_progressbar_gfx_smooth)
1513 if (time - old_p_healthtime < 1)
1514 old_p_health = prev_p_health;
1516 old_p_health = prev_health;
1517 old_p_healthtime = time;
1519 if (time - old_p_healthtime < 1)
1521 p_health += (old_p_health - health) * (1 - (time - old_p_healthtime));
1522 prev_p_health = p_health;
1525 if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0)
1527 if (prev_health - health >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
1529 if (time - health_damagetime >= 1)
1530 health_beforedamage = prev_health;
1531 health_damagetime = time;
1533 if (time - health_damagetime < 1)
1535 float health_damagealpha = 1 - (time - health_damagetime)*(time - health_damagetime);
1536 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);
1539 prev_health = health;
1541 if (health <= autocvar_hud_panel_healtharmor_progressbar_gfx_lowhealth)
1543 float BLINK_FACTOR = 0.15;
1544 float BLINK_BASE = 0.85;
1545 float BLINK_FREQ = 9;
1546 pain_health_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
1549 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);
1551 if(autocvar_hud_panel_healtharmor_text)
1552 DrawNumIcon(pos + health_offset, mySize, health, "health", is_vertical, health_iconalign, HUD_Get_Num_Color(health, maxhealth), 1);
1557 if(autocvar_hud_panel_healtharmor_progressbar)
1559 HUD_Panel_GetProgressBarColor(armor);
1562 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1564 if (autocvar_hud_panel_healtharmor_progressbar_gfx_smooth > 0)
1566 if (fabs(prev_armor - armor) >= autocvar_hud_panel_healtharmor_progressbar_gfx_smooth)
1568 if (time - old_p_armortime < 1)
1569 old_p_armor = prev_p_armor;
1571 old_p_armor = prev_armor;
1572 old_p_armortime = time;
1574 if (time - old_p_armortime < 1)
1576 p_armor += (old_p_armor - armor) * (1 - (time - old_p_armortime));
1577 prev_p_armor = p_armor;
1580 if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0)
1582 if (prev_armor - armor >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
1584 if (time - armor_damagetime >= 1)
1585 armor_beforedamage = prev_armor;
1586 armor_damagetime = time;
1588 if (time - armor_damagetime < 1)
1590 float armor_damagealpha = 1 - (time - armor_damagetime)*(time - armor_damagetime);
1591 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);
1596 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);
1598 if(autocvar_hud_panel_healtharmor_text)
1599 DrawNumIcon(pos + armor_offset, mySize, armor, "armor", is_vertical, armor_iconalign, HUD_Get_Num_Color(armor, maxarmor), 1);
1605 mySize_x *= 0.2 / 2; //if vertical always halve x to not cover too much numbers with 3 digits
1609 mySize_x *= 2; //restore full panel size
1610 else if (panel_ar < 1/4)
1611 mySize_y *= 2; //restore full panel size
1612 HUD_Panel_GetProgressBarColor(fuel);
1613 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
1618 // Notification area (#4)
1621 string Weapon_SuicideMessage(float deathtype)
1623 w_deathtype = deathtype;
1624 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
1625 return w_deathtypestring;
1628 string Weapon_KillMessage(float deathtype)
1630 w_deathtype = deathtype;
1631 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
1632 return w_deathtypestring;
1635 #define KN_MAX_ENTRIES 10
1637 float killnotify_times[KN_MAX_ENTRIES];
1638 float killnotify_deathtype[KN_MAX_ENTRIES];
1639 float killnotify_actiontype[KN_MAX_ENTRIES]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
1640 string killnotify_attackers[KN_MAX_ENTRIES];
1641 string killnotify_victims[KN_MAX_ENTRIES];
1642 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
1646 kn_index = KN_MAX_ENTRIES-1;
1647 killnotify_times[kn_index] = time;
1648 killnotify_deathtype[kn_index] = wpn;
1649 killnotify_actiontype[kn_index] = actiontype;
1650 if(killnotify_attackers[kn_index])
1651 strunzone(killnotify_attackers[kn_index]);
1652 killnotify_attackers[kn_index] = strzone(attacker);
1653 if(killnotify_victims[kn_index])
1654 strunzone(killnotify_victims[kn_index]);
1655 killnotify_victims[kn_index] = strzone(victim);
1658 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
1661 float alsoprint, gentle;
1662 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
1663 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
1665 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
1668 if(msg == MSG_SUICIDE) {
1669 w = DEATH_WEAPONOF(type);
1671 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1673 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
1674 } else if (type == DEATH_KILL) {
1675 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
1677 print (sprintf(_("^1%s^1 couldn't take it anymore\n"), s1));
1678 } else if (type == DEATH_ROT) {
1679 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1681 print (sprintf(_("^1%s^1 died\n"), s1));
1682 } else if (type == DEATH_NOAMMO) {
1683 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
1685 print (sprintf(_("^7%s^7 committed suicide. What's the point of living without ammo?\n"), s1));
1686 } else if (type == DEATH_CAMP) {
1687 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
1689 print (sprintf(_("^1%s^1 thought they found a nice camping ground\n"), s1));
1690 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
1691 HUD_KillNotify_Push(s1, "", 0, type);
1693 print (sprintf(_("^1%s^1 didn't become friends with the Lord of Teamplay\n"), s1));
1694 } else if (type == DEATH_CHEAT) {
1695 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1697 print (sprintf(_("^1%s^1 unfairly eliminated themself\n"), s1));
1698 } else if (type == DEATH_FIRE) {
1699 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1701 print (sprintf(_("^1%s^1 burned to death\n"), s1));
1702 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
1703 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1705 print (sprintf(_("^1%s^1 couldn't resist the urge to self-destruct\n"), s1));
1708 if (stof(s2) > 2) // killcount > 2
1709 print (sprintf(_("^1%s^1 ended it all after a %d kill spree\n"), s1, stof(s2)));
1710 } else if(msg == MSG_KILL) {
1711 w = DEATH_WEAPONOF(type);
1713 if((w == WEP_RIFLE || w == WEP_MINSTANEX) && type & HITTYPE_HEADSHOT) // all headshot weapons go here
1714 HUD_KillNotify_Push(s1, s2, 1, DEATH_HEADSHOT);
1716 HUD_KillNotify_Push(s1, s2, 1, type);
1719 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
1721 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
1722 HUD_KillNotify_Push(s1, s2, 1, type);
1726 print (sprintf(_("^1%s^1 took action against a team mate\n"), s1));
1728 print (sprintf(_("^1%s^1 mows down a team mate\n"), s1));
1731 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
1733 print (sprintf(_("^1%s^1 ended a %d scoring spree by going against a team mate\n"), s1, stof(s3)));
1735 print (sprintf(_("^1%s^1 ended a %d kill spree by killing a team mate\n"), s1, stof(s3)));
1737 else if (stof(s2) > 2) {
1739 print (sprintf(_("^1%s^1's %s scoring spree was ended by a team mate!\n"), s1, stof(s3)));
1741 print (sprintf(_("^1%s^1's %s kill spree was ended by a team mate!\n"), s1, stof(s3)));
1744 else if(type == KILL_FIRST_BLOOD)
1745 print(sprintf(_("^1%s^1 drew first blood\n"), s1));
1746 else if (type == DEATH_TELEFRAG) {
1747 HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
1749 print (sprintf(_("^1%s^1 tried to occupy %s^1's teleport destination space\n"), s2, s1));
1751 print (sprintf(_("^1%s^1 was telefragged by %s\n"), s2, s1));
1753 else if (type == DEATH_DROWN) {
1754 HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN);
1756 print (sprintf(_("^1%s^1 was drowned by %s\n"), s2, s1));
1758 else if (type == DEATH_SLIME) {
1759 HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME);
1761 print (sprintf(_("^1%s^1 was slimed by %s\n"), s2, s1));
1763 else if (type == DEATH_LAVA) {
1764 HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA);
1766 print (sprintf(_("^1%s^1 was cooked by %s\n"), s2, s1));
1768 else if (type == DEATH_FALL) {
1769 HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL);
1771 print (sprintf(_("^1%s^1 was grounded by %s\n"), s2, s1));
1773 else if (type == DEATH_SHOOTING_STAR) {
1774 HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR);
1776 print (sprintf(_("^1%s^1 was shot into space by %s\n"), s2, s1));
1778 else if (type == DEATH_SWAMP) {
1779 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1781 print (sprintf(_("^1%s^1 was conserved by %s\n"), s2, s1));
1783 else if (type == DEATH_HURTTRIGGER)
1785 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1787 print(sprintf(_("^1%s^1 was thrown into a world of hurt by %s\n"), s2, s1));
1788 } else if(type == DEATH_SBCRUSH) {
1789 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1791 print (sprintf(_("^1%s^1 was crushed by %s\n"), s2, s1));
1792 } else if(type == DEATH_SBMINIGUN) {
1793 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1795 print (sprintf(_("^1%s^1 got shredded by %s\n"), s2, s1));
1796 } else if(type == DEATH_SBROCKET) {
1797 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1799 print (sprintf(_("^1%s^1 was blasted to bits by %s\n"), s2, s1));
1800 } else if(type == DEATH_SBBLOWUP) {
1801 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1803 print (sprintf(_("^1%s^1 got caught in the destruction of %s^1's vehicle\n"), s2, s1));
1804 } else if(type == DEATH_WAKIGUN) {
1805 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1807 print (sprintf(_("^1%s^1 was bolted down by %s\n"), s2, s1));
1808 } else if(type == DEATH_WAKIROCKET) {
1809 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1811 print (sprintf(_("^1%s^1 could find no shelter from %s^1's rockets\n"), s2, s1));
1812 } else if(type == DEATH_WAKIBLOWUP) {
1813 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1815 print (sprintf(_("^1%s^1 dies when %s^1's wakizashi dies.\n"), s2, s1));
1816 } else if(type == DEATH_TURRET) {
1817 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1819 print (sprintf(_("^1%s^1 was pushed into the line of fire by %s\n"), s2, s1));
1820 } else if(type == DEATH_TOUCHEXPLODE) {
1821 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1823 print (sprintf(_("^1%s^1 was pushed into an accident by %s\n"), s2, s1));
1824 } else if(type == DEATH_CHEAT) {
1825 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1827 print (sprintf(_("^1%s^1 was unfairly eliminated by %s\n"), s2, s1));
1828 } else if (type == DEATH_FIRE) {
1829 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1831 print (sprintf(_("^1%s^1 was burnt to death by %s\n"), s2, s1));
1832 } else if (type == DEATH_CUSTOM) {
1833 HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
1835 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1836 } else if (type == DEATH_HURTTRIGGER) {
1837 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1839 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1841 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1843 print (sprintf(_("^1%s^1 was fragged by %s\n"), s2, s1));
1845 } else if(msg == MSG_SPREE) {
1846 if(type == KILL_END_SPREE) {
1848 print (sprintf(_("^1%s^1's %s scoring spree was ended by %s\n"), s1, s2, s3));
1850 print (sprintf(_("^1%s^1's %s kill spree was ended by %s\n"), s1, s2, s3));
1851 } else if(type == KILL_SPREE) {
1853 print (sprintf(_("^1%s^1 made %s scores in a row\n"), s1, s2));
1855 print (sprintf(_("^1%s^1 has %s frags in a row\n"), s1, s2));
1856 } else if(type == KILL_SPREE_3) {
1858 print (sprintf(_("%s^7 made a ^1TRIPLE SCORE\n"), s1));
1860 print (sprintf(_("%s^7 made a ^1TRIPLE FRAG\n"), s1));
1861 } else if(type == KILL_SPREE_5) {
1863 print (sprintf(_("%s^7 unleashes ^1SCORING RAGE\n"), s1));
1865 print (sprintf(_("%s^7 unleashes ^1RAGE\n"), s1));
1866 } else if(type == KILL_SPREE_10) {
1868 print (sprintf(_("%s^7 made ^1TEN SCORES IN A ROW!\n"), s1));
1870 print (sprintf(_("%s^7 starts the ^1MASSACRE!\n"), s1));
1871 } else if(type == KILL_SPREE_15) {
1873 print (sprintf(_("%s^7 made ^1FIFTEEN SCORES IN A ROW!\n"), s1));
1875 print (sprintf(_("%s^7 executes ^1MAYHEM!\n"), s1));
1876 } else if(type == KILL_SPREE_20) {
1878 print (sprintf(_("%s^7 made ^1TWENTY SCORES IN A ROW!\n"), s1));
1880 print (sprintf(_("%s^7 is a ^1BERSERKER!\n"), s1));
1881 } else if(type == KILL_SPREE_25) {
1883 print (sprintf(_("%s^7 made ^1TWENTY FIVE SCORES IN A ROW!\n"), s1));
1885 print (sprintf(_("%s^7 inflicts ^1CARNAGE!\n"), s1));
1886 } else if(type == KILL_SPREE_30) {
1888 print (sprintf(_("%s^7 made ^1THIRTY SCORES IN A ROW!\n"), s1));
1890 print (sprintf(_("%s^7 unleashes ^1ARMAGEDDON!\n"), s1));
1892 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
1893 if (type == DEATH_DROWN) {
1894 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
1898 print (sprintf(_("^1%s^1 was in the water for too long\n"), s1));
1900 print (sprintf(_("^1%s^1 drowned\n"), s1));
1902 } else if (type == DEATH_SLIME) {
1903 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
1905 print (sprintf(_("^1%s^1 was slimed\n"), s1));
1906 } else if (type == DEATH_LAVA) {
1907 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
1911 print (sprintf(_("^1%s^1 found a hot place\n"), s1));
1913 print (sprintf(_("^1%s^1 turned into hot slag\n"), s1));
1915 } else if (type == DEATH_FALL) {
1916 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1920 print (sprintf(_("^1%s^1 tested gravity (and it worked)\n"), s1));
1922 print (sprintf(_("^1%s^1 hit the ground with a crunch\n"), s1));
1924 } else if (type == DEATH_SHOOTING_STAR) {
1925 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
1927 print (sprintf(_("^1%s^1 became a shooting star\n"), s1));
1928 } else if (type == DEATH_SWAMP) {
1929 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1933 print (sprintf(_("^1%s^1 discovered a swamp\n"), s1));
1935 print (sprintf(_("^1%s^1 is now conserved for centuries to come\n"), s1));
1937 } else if(type == DEATH_TURRET) {
1938 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1940 print (sprintf(_("^1%s^1 was mowed down by a turret \n"), s1));
1941 } else if (type == DEATH_CUSTOM) {
1942 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
1944 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1945 } else if (type == DEATH_HURTTRIGGER) {
1946 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
1948 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1949 } else if(type == DEATH_TOUCHEXPLODE) {
1950 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1952 print (sprintf(_("^1%s^1 died in an accident\n"), s1));
1953 } else if(type == DEATH_CHEAT) {
1954 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1956 print (sprintf(_("^1%s^1 was unfairly eliminated\n"), s1));
1957 } else if(type == DEATH_FIRE) {
1958 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1962 print (sprintf(_("^1%s^1 felt a little hot\n"), s1));
1964 print (sprintf(_("^1%s^1 burnt to death\n"), s1));
1967 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1971 print (sprintf(_("^1%s^1 needs a restart\n"), s1));
1973 print (sprintf(_("^1%s^1 died\n"), s1));
1976 } else if(msg == MSG_KILL_ACTION_SPREE) {
1978 print (sprintf(_("^1%s^1 needs a restart after a %d scoring spree\n"), s1, stof(s2)));
1980 print (sprintf(_("^1%s^1 died with a %d kill spree\n"), s1, stof(s2)));
1981 } else if(msg == MSG_INFO) {
1982 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
1983 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
1984 print(sprintf(_("%s^7 got the %s\n"), s1, s2));
1985 } else if(type == INFO_LOSTFLAG) {
1986 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
1987 print(sprintf(_("%s^7 lost the %s\n"), s1, s2));
1988 } else if(type == INFO_PICKUPFLAG) {
1989 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
1990 print(sprintf(_("%s^7 picked up the %s\n"), s1, s2));
1991 } else if(type == INFO_RETURNFLAG) {
1992 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
1993 print(sprintf(_("%s^7 returned the %s\n"), s1, s2));
1994 } else if(type == INFO_CAPTUREFLAG) {
1995 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
1996 print(sprintf(_("%s^7 captured the %s%s\n"), s1, s2, s3));
1998 } else if(msg == MSG_RACE) {
1999 if(type == RACE_SERVER_RECORD) {
2000 HUD_KillNotify_Push(s1, s2, 1, RACE_SERVER_RECORD);
2002 else if(type == RACE_NEW_RANK) {
2003 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_RANK);
2005 else if(type == RACE_NEW_TIME) {
2006 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_TIME);
2008 else if(type == RACE_FAIL) {
2009 HUD_KillNotify_Push(s1, s2, 1, RACE_FAIL);
2011 } else if(msg == MSG_KA) {
2012 if(type == KA_PICKUPBALL) {
2013 HUD_KillNotify_Push(s1, s2, 0, KA_PICKUPBALL);
2015 print (sprintf(_("%s^7 has picked up the ball!\n"), s1));
2017 else if(type == KA_DROPBALL) {
2018 HUD_KillNotify_Push(s1, s2, 0, KA_DROPBALL);
2020 print(sprintf(_("%s^7 has dropped the ball!\n"), s1));
2025 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2027 void HUD_Centerprint(string s1, string s2, float type, float msg)
2030 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2031 if(msg == MSG_SUICIDE) {
2032 if (type == DEATH_TEAMCHANGE) {
2033 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("You are now on: %s"), s1)));
2034 } else if (type == DEATH_AUTOTEAMCHANGE) {
2035 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("You have been moved into a different team to improve team balance\nYou are now on: %s"), s1)));
2036 } else if (type == DEATH_CAMP) {
2038 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Reconsider your tactics, camper!")));
2040 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Die camper!")));
2041 } else if (type == DEATH_NOAMMO) {
2043 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You are reinserted into the game for running out of ammo...")));
2045 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You were killed for running out of ammo...")));
2046 } else if (type == DEATH_ROT) {
2048 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You need to preserve your health")));
2050 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You grew too old without taking your medicine")));
2051 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2053 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Don't go against team mates!")));
2055 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Don't shoot your team mates!")));
2056 } else if (type == DEATH_QUIET) {
2058 } else { // generic message
2060 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You need to be more careful!")));
2062 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You killed your own dumb self!")));
2064 } else if(msg == MSG_KILL) {
2065 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2067 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1Moron! You went against %s, a team mate!"), s1)));
2069 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1Moron! You fragged %s, a team mate!"), s1)));
2071 } else if (type == KILL_FIRST_BLOOD) {
2073 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First score")));
2075 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First blood")));
2077 } else if (type == KILL_FIRST_VICTIM) {
2079 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First casualty")));
2081 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First victim")));
2083 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2085 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You scored against ^7%s^1 who was typing!"), s1), s2));
2087 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You typefragged ^7%s"), s1), s2));
2089 } else if (type == KILL_TYPEFRAGGED) {
2091 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were scored against by ^7%s^1 while you were typing!"), s1), s2));
2093 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were typefragged by ^7%s"), s1), s2));
2095 } else if (type == KILL_FRAG) {
2097 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^4You scored against ^7%s"), s1), s2));
2099 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^4You fragged ^7%s"), s1), s2));
2101 } else { // generic message
2103 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were scored against by ^7%s"), s1), s2));
2105 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were fragged by ^7%s"), s1), s2));
2108 } else if(msg == MSG_KILL_ACTION) {
2109 // TODO: invent more centerprints here?
2110 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Watch your step!")));
2114 void HUD_Notify (void)
2116 if(!autocvar__hud_configure)
2118 if(!autocvar_hud_panel_notify) return;
2121 hud_configure_active_panel = HUD_PANEL_NOTIFY;
2123 HUD_Panel_UpdateCvars(notify);
2126 mySize = panel_size;
2128 HUD_Panel_DrawBg(1);
2129 if(panel_bg_padding)
2131 pos += '1 1 0' * panel_bg_padding;
2132 mySize -= '2 2 0' * panel_bg_padding;
2135 float entries, height;
2136 entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES);
2137 height = mySize_y/entries;
2140 float fontheight = height * autocvar_hud_panel_notify_fontsize;
2141 fontsize = '0.5 0.5 0' * fontheight;
2145 when = autocvar_hud_panel_notify_time;
2147 fadetime = autocvar_hud_panel_notify_fadetime;
2151 vector pos_attacker, pos_victim;
2153 float width_attacker;
2154 string attacker, victim;
2156 float i, j, w, step, limit;
2157 if(autocvar_hud_panel_notify_flip) //order items from the top down
2163 else //order items from the bottom up
2170 for(j = kn_index; i != limit; i += step, ++j)
2172 if(autocvar__hud_configure)
2176 else // inverse order
2177 a = entries - 1 - i;
2178 attacker = textShortenToWidth(sprintf(_("Player %d"), a+1), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2179 victim = textShortenToWidth(sprintf(_("Player %d"), a+2), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2180 s = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname);
2181 a = bound(0, (when - a) / 4, 1);
2182 goto hud_config_notifyprint;
2185 if (j == KN_MAX_ENTRIES)
2188 if(killnotify_times[j] + when > time)
2192 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2206 w = DEATH_WEAPONOF(killnotify_deathtype[j]);
2208 // TODO: maybe print in team colors?
2211 if(killnotify_actiontype[j] == 0)
2213 if(killnotify_deathtype[j] == DEATH_GENERIC)
2217 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2219 s = "notify_outofammo";
2221 else if(killnotify_deathtype[j] == DEATH_KILL)
2223 s = "notify_selfkill";
2225 else if(killnotify_deathtype[j] == DEATH_CAMP)
2227 s = "notify_camping";
2229 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2231 s = "notify_teamkill_red";
2233 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2235 s = "notify_teamkill_blue";
2237 else if(killnotify_deathtype[j] == DEATH_DROWN)
2241 else if(killnotify_deathtype[j] == DEATH_SLIME)
2245 else if(killnotify_deathtype[j] == DEATH_LAVA)
2249 else if(killnotify_deathtype[j] == DEATH_FALL)
2253 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2255 s = "notify_shootingstar";
2257 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2261 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2263 if(killnotify_victims[j] == "^1RED^7 flag")
2265 s = "notify_red_taken";
2269 s = "notify_blue_taken";
2272 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2274 if(killnotify_victims[j] == "^1RED^7 flag")
2276 s = "notify_red_returned";
2280 s = "notify_blue_returned";
2283 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2285 if(killnotify_victims[j] == "^1RED^7 flag")
2287 s = "notify_red_lost";
2291 s = "notify_blue_lost";
2294 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
2296 if(killnotify_victims[j] == "^1RED^7 flag")
2298 s = "notify_red_captured";
2302 s = "notify_blue_captured";
2305 else if(killnotify_deathtype[j] == KA_DROPBALL)
2307 s = "notify_balldropped";
2309 else if(killnotify_deathtype[j] == KA_PICKUPBALL)
2311 s = "notify_ballpickedup";
2314 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2315 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2316 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2320 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2321 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2324 // X [did action to] Y
2327 if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
2329 s = "notify_melee_laser";
2331 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_SHOTGUN)
2333 s = "notify_melee_shotgun";
2335 else if(WEP_VALID(w))
2337 self = get_weaponinfo(w);
2338 s = strcat("weapon", self.netname);
2340 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2342 s = "notify_teamkill_red";
2344 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2346 s = "notify_teamkill_red";
2348 else if(killnotify_deathtype[j] == DEATH_TELEFRAG)
2350 s = "notify_telefrag";
2352 else if(killnotify_deathtype[j] == DEATH_DROWN)
2356 else if(killnotify_deathtype[j] == DEATH_SLIME)
2360 else if(killnotify_deathtype[j] == DEATH_LAVA)
2364 else if(killnotify_deathtype[j] == DEATH_FALL)
2368 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2370 s = "notify_shootingstar";
2372 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2376 else if(killnotify_deathtype[j] == DEATH_HEADSHOT)
2378 s = "notify_headshot";
2380 else if(killnotify_deathtype[j] == RACE_SERVER_RECORD)
2382 s = "race_newrecordserver";
2384 else if(killnotify_deathtype[j] == RACE_NEW_RANK)
2386 s = "race_newrankyellow";
2388 else if(killnotify_deathtype[j] == RACE_NEW_TIME)
2392 else if(killnotify_deathtype[j] == RACE_FAIL)
2397 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2398 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2399 :hud_config_notifyprint
2400 width_attacker = stringwidth(attacker, TRUE, fontsize);
2401 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2402 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2403 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2407 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2408 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2409 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2418 string seconds_tostring(float sec)
2421 minutes = floor(sec / 60);
2423 sec -= minutes * 60;
2424 return sprintf("%d:%02d", minutes, sec);
2427 void HUD_Timer(void)
2429 if(!autocvar__hud_configure)
2431 if(!autocvar_hud_panel_timer) return;
2434 hud_configure_active_panel = HUD_PANEL_TIMER;
2436 HUD_Panel_UpdateCvars(timer);
2439 mySize = panel_size;
2441 HUD_Panel_DrawBg(1);
2442 if(panel_bg_padding)
2444 pos += '1 1 0' * panel_bg_padding;
2445 mySize -= '2 2 0' * panel_bg_padding;
2449 float timelimit, elapsedTime, timeleft, minutesLeft;
2451 timelimit = getstatf(STAT_TIMELIMIT);
2453 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
2454 timeleft = ceil(timeleft);
2456 minutesLeft = floor(timeleft / 60);
2459 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
2460 timer_color = '1 1 1'; //white
2461 else if(minutesLeft >= 1)
2462 timer_color = '1 1 0'; //yellow
2464 timer_color = '1 0 0'; //red
2466 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
2467 if (time < getstatf(STAT_GAMESTARTTIME)) {
2468 //while restart is still active, show 00:00
2469 timer = seconds_tostring(0);
2471 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
2472 timer = seconds_tostring(elapsedTime);
2475 timer = seconds_tostring(timeleft);
2478 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2483 void HUD_Radar(void)
2485 if (!autocvar__hud_configure)
2487 if (autocvar_hud_panel_radar == 0) return;
2488 if (autocvar_hud_panel_radar != 2 && !teamplay) return;
2491 hud_configure_active_panel = HUD_PANEL_RADAR;
2493 HUD_Panel_UpdateCvars(radar);
2496 mySize = panel_size;
2498 HUD_Panel_DrawBg(1);
2499 if(panel_bg_padding)
2501 pos += '1 1 0' * panel_bg_padding;
2502 mySize -= '2 2 0' * panel_bg_padding;
2507 float scale2d, normalsize, bigsize;
2510 teamradar_origin2d = pos + 0.5 * mySize;
2511 teamradar_size2d = mySize;
2513 if(minimapname == "")
2516 teamradar_loadcvars();
2518 switch(hud_panel_radar_zoommode)
2522 f = current_zoomfraction;
2525 f = 1 - current_zoomfraction;
2535 switch(hud_panel_radar_rotation)
2538 teamradar_angle = view_angles_y - 90;
2541 teamradar_angle = 90 * hud_panel_radar_rotation;
2545 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
2546 teamradar_size2d = mySize;
2548 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
2550 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
2551 if(hud_panel_radar_rotation == 0)
2553 // max-min distance must fit the radar in any rotation
2554 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_scale));
2558 vector c0, c1, c2, c3, span;
2559 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
2560 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
2561 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
2562 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
2564 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
2565 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
2567 // max-min distance must fit the radar in x=x, y=y
2569 teamradar_size2d_x * scale2d / (1.05 * span_x),
2570 teamradar_size2d_y * scale2d / (1.05 * span_y)
2574 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
2575 if(bigsize > normalsize)
2576 normalsize = bigsize;
2580 + (1 - f) * normalsize;
2581 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
2583 + (1 - f) * view_origin);
2592 draw_teamradar_background(hud_panel_radar_foreground_alpha);
2594 for(tm = world; (tm = find(tm, classname, "radarlink")); )
2595 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
2596 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
2597 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
2598 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
2600 color2 = GetPlayerColor(tm.sv_entnum);
2601 //if(color == COLOR_SPECTATOR || color == color2)
2602 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
2604 draw_teamradar_player(view_origin, view_angles, '1 1 1');
2606 drawresetcliparea();
2611 void HUD_UpdatePlayerTeams();
2612 void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count)
2616 #define SCOREPANEL_MAX_ENTRIES 6
2617 #define SCOREPANEL_ASPECTRATIO 2
2618 const float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
2619 const vector fontsize = '1 1 0' * (mySize_y/entries);
2621 vector rgb, score_color;
2623 score_color = '1 1 1';
2625 const float name_size = mySize_x*0.75;
2626 const float spacing_size = mySize_x*0.04;
2627 const float highlight_alpha = 0.2;
2628 float i, me_printed, first_pl;
2631 if (autocvar__hud_configure)
2633 float players_per_team;
2636 // show team scores in the first line
2637 float score_size = mySize_x / team_count;
2638 players_per_team = max(2, ceil((entries - 1) / team_count));
2639 for(i=0; i<team_count; ++i) {
2640 if (i == floor((entries - 2) / players_per_team) || (entries == 1 && i == 0))
2641 HUD_Panel_DrawHighlight(pos + eX * score_size * i, eX * score_size + eY * fontsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2642 drawstring_aspect(pos + eX * score_size * i, ftos(175 - 23*i), eX * score_size + eY * fontsize_y, GetTeamRGB(ColorByTeam(i)) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2645 pos_y += fontsize_y;
2647 score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
2648 for (i=first_pl; i<entries; ++i)
2650 //simulate my score is lower than all displayed players,
2651 //so that I don't appear at all showing pure rankings.
2652 //This is to better show the difference between the 2 ranking views
2653 if (i == entries-1 && autocvar_hud_panel_score_rankings == 1)
2656 drawfill(pos, eX * mySize_x + eY * fontsize_y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2657 s = GetPlayerName(pl.sv_entnum);
2662 s = sprintf(_("Player %d"), i + 1 - first_pl);
2667 score_color = GetTeamRGB(ColorByTeam(floor((i - first_pl) / players_per_team))) * 0.8;
2668 s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
2669 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2670 drawstring(pos + eX * (name_size + spacing_size), ftos(score), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2671 pos_y += fontsize_y;
2676 if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
2677 HUD_UpdatePlayerTeams();
2680 // show team scores in the first line
2681 float score_size = mySize_x / team_count;
2682 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2683 if(tm.team == COLOR_SPECTATOR)
2685 if (tm.team == myteam)
2686 drawfill(pos + eX * score_size * i, eX * score_size + eY * fontsize_y, '1 1 1', highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2687 drawstring_aspect(pos + eX * score_size * i, ftos(tm.(teamscores[ts_primary])), eX * score_size + eY * fontsize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2691 pos_y += fontsize_y;
2692 tm = teams.sort_next;
2697 for (pl = players.sort_next; pl && i<entries; pl = pl.sort_next)
2699 if ((team_count && pl.team != tm.team) || pl.team == COLOR_SPECTATOR)
2702 if (i == entries-1 && !me_printed && pl != me)
2703 if (autocvar_hud_panel_score_rankings == 1 && spectatee_status != -1)
2705 for (pl = me.sort_next; pl; pl = pl.sort_next)
2706 if (pl.team != COLOR_SPECTATOR)
2710 rgb = '1 1 0'; //not last but not among the leading players: yellow
2712 rgb = '1 0 0'; //last: red
2719 rgb = '0 1 0'; //first: green
2721 drawfill(pos, eX * mySize_x + eY * fontsize_y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2724 score_color = GetTeamRGB(pl.team) * 0.8;
2725 s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
2726 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2727 drawstring(pos + eX * (name_size + spacing_size), ftos(pl.(scores[ps_primary])), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2728 pos_y += fontsize_y;
2731 while (i<entries && team_count && (tm = tm.sort_next) && (tm.team != COLOR_SPECTATOR || (tm = tm.sort_next)));
2734 void HUD_Score(void)
2736 if(!autocvar__hud_configure)
2738 if(!autocvar_hud_panel_score) return;
2739 if(spectatee_status == -1 && (gametype == GAME_RACE || gametype == GAME_CTS)) return;
2742 hud_configure_active_panel = HUD_PANEL_SCORE;
2744 HUD_Panel_UpdateCvars(score);
2747 mySize = panel_size;
2749 HUD_Panel_DrawBg(1);
2750 if(panel_bg_padding)
2752 pos += '1 1 0' * panel_bg_padding;
2753 mySize -= '2 2 0' * panel_bg_padding;
2756 float score, distribution;
2758 vector distribution_color;
2760 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
2762 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
2763 string timer, distrtimer;
2765 pl = players.sort_next;
2768 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
2769 if(pl.scores[ps_primary] == 0)
2772 score = me.(scores[ps_primary]);
2773 timer = TIME_ENCODED_TOSTRING(score);
2775 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
2776 // distribution display
2777 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2779 distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS);
2781 if (distribution <= 0) {
2782 distribution_color = '0 1 0';
2786 distribution_color = '1 0 0';
2789 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);
2791 // race record display
2792 if (distribution <= 0)
2793 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2794 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2795 } else if (!teamplay) { // non-teamgames
2796 if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings)
2798 HUD_Score_Rankings(pos, mySize, me, 0);
2801 // me vector := [team/connected frags id]
2802 pl = players.sort_next;
2806 if(autocvar__hud_configure)
2809 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2813 score = me.(scores[ps_primary]);
2814 if(autocvar__hud_configure)
2817 if(distribution >= 5)
2818 distribution_color = eY;
2819 else if(distribution >= 0)
2820 distribution_color = '1 1 1';
2821 else if(distribution >= -5)
2822 distribution_color = '1 1 0';
2824 distribution_color = eX;
2826 string distribution_str;
2827 distribution_str = ftos(distribution);
2828 if (distribution >= 0)
2830 if (distribution > 0)
2831 distribution_str = strcat("+", distribution_str);
2832 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2834 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2835 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);
2836 } else { // teamgames
2837 float scores_count, row, column, rows, columns;
2839 vector score_pos, score_size; //for scores other than myteam
2840 if (spectatee_status == -1 || autocvar_hud_panel_score_rankings)
2842 for(tm = teams.sort_next; tm, tm.team != COLOR_SPECTATOR; tm = tm.sort_next)
2844 if (autocvar_hud_panel_score_rankings)
2846 HUD_Score_Rankings(pos, mySize, me, scores_count);
2849 rows = mySize_y/mySize_x;
2850 rows = bound(1, floor((sqrt(4 * (3/1) * rows * scores_count + rows * rows) + rows + 0.5) / 2), scores_count);
2851 // ^^^ ammo item aspect goes here
2853 columns = ceil(scores_count/rows);
2855 score_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
2858 if(score_size_x/score_size_y > 3)
2860 newSize = 3 * score_size_y;
2861 offset_x = score_size_x - newSize;
2862 pos_x += offset_x/2;
2863 score_size_x = newSize;
2867 newSize = 1/3 * score_size_x;
2868 offset_y = score_size_y - newSize;
2869 pos_y += offset_y/2;
2870 score_size_y = newSize;
2874 score_size = eX * mySize_x*(1/4) + eY * mySize_y*(1/3);
2876 float max_fragcount;
2877 max_fragcount = -99;
2878 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2879 if(tm.team == COLOR_SPECTATOR)
2881 score = tm.(teamscores[ts_primary]);
2882 if(autocvar__hud_configure)
2885 if (score > max_fragcount)
2886 max_fragcount = score;
2888 if (spectatee_status == -1)
2890 score_pos = pos + eX * column * (score_size_x + offset_x) + eY * row * (score_size_y + offset_y);
2891 if (max_fragcount == score)
2892 HUD_Panel_DrawHighlight(score_pos, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2893 drawstring_aspect(score_pos, ftos(score), score_size, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2901 else if(tm.team == myteam) {
2902 if (max_fragcount == score)
2903 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2904 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2906 if (max_fragcount == score)
2907 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);
2908 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);
2917 void HUD_RaceTimer (void)
2919 if(!autocvar__hud_configure)
2921 if(!autocvar_hud_panel_racetimer) return;
2922 if(!(gametype == GAME_RACE || gametype == GAME_CTS)) return;
2923 if(spectatee_status == -1) return;
2926 hud_configure_active_panel = HUD_PANEL_RACETIMER;
2928 HUD_Panel_UpdateCvars(racetimer);
2931 mySize = panel_size;
2933 HUD_Panel_DrawBg(1);
2934 if(panel_bg_padding)
2936 pos += '1 1 0' * panel_bg_padding;
2937 mySize -= '2 2 0' * panel_bg_padding;
2940 // always force 4:1 aspect
2942 if(mySize_x/mySize_y > 4)
2944 newSize_x = 4 * mySize_y;
2945 newSize_y = mySize_y;
2947 pos_x = pos_x + (mySize_x - newSize_x) / 2;
2951 newSize_y = 1/4 * mySize_x;
2952 newSize_x = mySize_x;
2954 pos_y = pos_y + (mySize_y - newSize_y) / 2;
2959 string s, forcetime;
2961 if(autocvar__hud_configure)
2964 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);
2965 s = _("^1Intermediate 1 (+15.42)");
2966 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);
2967 s = sprintf(_("^1PENALTY: %.1f (%s)"), 2, "missing a checkpoint");
2968 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);
2970 else if(race_checkpointtime)
2972 a = bound(0, 2 - (time - race_checkpointtime), 1);
2975 if(a > 0) // just hit a checkpoint?
2977 if(race_checkpoint != 254)
2979 if(race_time && race_previousbesttime)
2980 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
2982 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
2984 forcetime = TIME_ENCODED_TOSTRING(race_time);
2989 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
2991 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
2992 if(a > 0) // next one?
2994 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
2999 if(s != "" && a > 0)
3001 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);
3004 if(race_penaltytime)
3006 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3009 s = sprintf(_("^1PENALTY: %.1f (%s)"), race_penaltytime * 0.1, race_penaltyreason);
3010 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);
3016 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3017 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);
3022 if(race_laptime && race_checkpoint != 255)
3024 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3025 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);
3030 if(race_mycheckpointtime)
3032 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3033 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3034 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);
3036 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3038 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3039 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3040 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);
3043 if(race_penaltytime && !race_penaltyaccumulator)
3045 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3046 a = bound(0, (1 + t - time), 1);
3050 s = sprintf(_("^1PENALTY: %.1f (%s)"), (t - time) * 0.1, race_penaltyreason);
3052 s = sprintf(_("^2PENALTY: %.1f (%s)"), 0, race_penaltyreason);
3053 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);
3061 float vote_yescount;
3064 float vote_highlighted; // currently selected vote
3066 float vote_active; // is there an active vote?
3067 float vote_prev; // previous state of vote_active to check for a change
3069 float vote_change; // "time" when vote_active changed
3071 void HUD_VoteWindow(void)
3073 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
3076 if (autocvar__hud_configure)
3080 print(_("^1You must answer before entering hud configure mode\n"));
3081 cvar_set("_hud_configure", "0");
3083 vote_called_vote = strzone(_("^2Name ^7instead of \"^1Unregistered player^7\" in stats"));
3084 uid2name_dialog = 1;
3087 if(!autocvar__hud_configure)
3089 if(!autocvar_hud_panel_vote) return;
3091 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
3092 panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
3094 if(panel_bg_alpha_str == "") {
3095 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
3097 panel_bg_alpha = stof(panel_bg_alpha_str);
3101 hud_configure_active_panel = HUD_PANEL_VOTE;
3110 if(vote_active != vote_prev) {
3112 vote_prev = vote_active;
3115 if(vote_active || autocvar__hud_configure)
3116 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3118 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3123 HUD_Panel_UpdateCvars(vote);
3127 panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight;
3128 panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
3131 // these must be below above block
3134 mySize = panel_size;
3136 a = vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3137 HUD_Panel_DrawBg(a);
3138 a = panel_fg_alpha * a;
3140 if(panel_bg_padding)
3142 pos += '1 1 0' * panel_bg_padding;
3143 mySize -= '2 2 0' * panel_bg_padding;
3146 // always force 3:1 aspect
3148 if(mySize_x/mySize_y > 3)
3150 newSize_x = 3 * mySize_y;
3151 newSize_y = mySize_y;
3153 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3157 newSize_y = 1/3 * mySize_x;
3158 newSize_x = mySize_x;
3160 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3164 s = _("A vote has been called for:");
3166 s = _("Allow servers to store and display your name?");
3167 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3168 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1/8), stringwidth_colors);
3169 if(autocvar__hud_configure)
3170 s = _("^1Configure the HUD");
3171 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
3173 // print the yes/no counts
3174 s = sprintf(_("Yes (%s): %d"), getcommandkey("vyes", "vyes"), vote_yescount);
3175 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);
3176 s = sprintf(_("No (%s): %d"), getcommandkey("vno", "vno"), vote_nocount);
3177 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);
3179 // draw the progress bar backgrounds
3180 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3182 // draw the highlights
3183 if(vote_highlighted == 1) {
3184 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3185 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3187 else if(vote_highlighted == 2) {
3188 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3189 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3192 // draw the progress bars
3193 if(vote_yescount && vote_needed)
3195 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3196 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3199 if(vote_nocount && vote_needed)
3201 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3202 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3205 drawresetcliparea();
3208 vote_highlighted = 0;
3212 // Mod icons panel (#10)
3215 float mod_active; // is there any active mod icon?
3217 // Clan Arena HUD modicons
3218 void HUD_Mod_CA(vector pos, vector mySize)
3220 mod_active = 1; // CA should never hide the mod icons panel
3221 float redalive, bluealive;
3222 redalive = getstati(STAT_REDALIVE);
3223 bluealive = getstati(STAT_BLUEALIVE);
3225 vector redpos, bluepos;
3226 if(mySize_x > mySize_y)
3229 bluepos = pos + eY * 0.5 * mySize_y;
3230 drawpic_aspect_skin(redpos, "player_red.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3231 drawstring_aspect(redpos + eX * 0.5 * mySize_x, ftos(redalive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3232 drawpic_aspect_skin(bluepos, "player_blue.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3233 drawstring_aspect(bluepos + eX * 0.5 * mySize_x, ftos(bluealive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3238 bluepos = pos + eY * 0.5 * mySize_y;
3239 drawpic_aspect_skin(redpos, "player_red.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3240 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);
3241 drawpic_aspect_skin(bluepos, "player_blue.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3242 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);
3246 // CTF HUD modicon section
3247 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3248 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3249 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3251 void HUD_Mod_CTF_Reset(void)
3253 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3256 void HUD_Mod_CTF(vector pos, vector mySize)
3258 vector redflag_pos, blueflag_pos;
3260 float f; // every function should have that
3262 float redflag, blueflag; // current status
3263 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3266 stat_items = getstati(STAT_ITEMS);
3267 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3268 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3270 if(redflag || blueflag)
3275 if(autocvar__hud_configure)
3281 // when status CHANGES, set old status into prevstatus and current status into status
3282 if (redflag != redflag_prevframe)
3284 redflag_statuschange_time = time;
3285 redflag_prevstatus = redflag_prevframe;
3286 redflag_prevframe = redflag;
3289 if (blueflag != blueflag_prevframe)
3291 blueflag_statuschange_time = time;
3292 blueflag_prevstatus = blueflag_prevframe;
3293 blueflag_prevframe = blueflag;
3296 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3297 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3299 float BLINK_FACTOR = 0.15;
3300 float BLINK_BASE = 0.85;
3302 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3304 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3306 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3308 string red_icon, red_icon_prevstatus;
3309 float red_alpha, red_alpha_prevstatus;
3310 red_alpha = red_alpha_prevstatus = 1;
3312 case 1: red_icon = "flag_red_taken"; break;
3313 case 2: red_icon = "flag_red_lost"; break;
3314 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3316 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3317 red_icon = "flag_red_shielded";
3319 red_icon = string_null;
3322 switch(redflag_prevstatus) {
3323 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3324 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3325 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3328 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3329 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3330 red_icon_prevstatus = "flag_red_shielded";
3332 red_icon_prevstatus = string_null;
3336 string blue_icon, blue_icon_prevstatus;
3337 float blue_alpha, blue_alpha_prevstatus;
3338 blue_alpha = blue_alpha_prevstatus = 1;
3340 case 1: blue_icon = "flag_blue_taken"; break;
3341 case 2: blue_icon = "flag_blue_lost"; break;
3342 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3344 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3345 blue_icon = "flag_blue_shielded";
3347 blue_icon = string_null;
3350 switch(blueflag_prevstatus) {
3351 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3352 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3353 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3356 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3357 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3358 blue_icon_prevstatus = "flag_blue_shielded";
3360 blue_icon_prevstatus = string_null;
3364 if(mySize_x > mySize_y) {
3365 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3367 blueflag_pos = pos + eX * 0.5 * mySize_x;
3370 redflag_pos = pos + eX * 0.5 * mySize_x;
3372 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3374 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3376 blueflag_pos = pos + eY * 0.5 * mySize_y;
3379 redflag_pos = pos + eY * 0.5 * mySize_y;
3381 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3384 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3385 if(red_icon_prevstatus && f < 1)
3386 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3388 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3390 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3391 if(blue_icon_prevstatus && f < 1)
3392 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3394 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3397 // Keyhunt HUD modicon section
3398 float kh_runheretime;
3400 void HUD_Mod_KH_Reset(void)
3405 void HUD_Mod_KH(vector pos, vector mySize)
3407 mod_active = 1; // keyhunt should never hide the mod icons panel
3411 vector p, pa, kh_size, kh_asize;
3413 kh_keys = getstati(STAT_KH_KEYS);
3416 if(mySize_x > mySize_y)
3418 p_y = pos_y + 0.25 * mySize_y;
3419 pa = p - eY * 0.25 * mySize_y;
3421 kh_size_x = mySize_x * 0.25;
3422 kh_size_y = 0.75 * mySize_y;
3423 kh_asize_x = mySize_x * 0.25;
3424 kh_asize_y = mySize_y * 0.25;
3428 p_y = pos_y + 0.125 * mySize_y;
3429 pa = p - eY * 0.125 * mySize_y;
3431 kh_size_x = mySize_x * 0.5;
3432 kh_size_y = 0.375 * mySize_y;
3433 kh_asize_x = mySize_x * 0.5;
3434 kh_asize_y = mySize_y * 0.125;
3441 for(i = 0; i < 4; ++i)
3443 key = floor(kh_keys / pow(32, i)) & 31;
3445 if(keyteam == 30 && keycount <= 4)
3447 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3451 // this yields 8 exactly if "RUN HERE" shows
3456 kh_runheretime = time;
3457 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3462 for(i = 0; i < 4; ++i)
3464 key = floor(kh_keys / pow(32, i)) & 31;
3477 default: // owned or dropped
3482 a = a * panel_fg_alpha;
3483 aa = aa * panel_fg_alpha;
3489 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3492 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3495 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3498 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3503 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3506 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3509 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3512 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3515 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3519 if(mySize_x > mySize_y)
3521 p_x += 0.25 * mySize_x;
3522 pa_x += 0.25 * mySize_x;
3528 p_y = pos_y + 0.625 * mySize_y;
3529 pa_y = pos_y + 0.5 * mySize_y;
3535 p_x += 0.5 * mySize_x;
3536 pa_x += 0.5 * mySize_x;
3542 // Keepaway HUD mod icon
3543 float kaball_prevstatus; // last remembered status
3544 float kaball_statuschange_time; // time when the status changed
3546 // we don't need to reset for keepaway since it immediately
3547 // autocorrects prevstatus as to if the player has the ball or not
3549 void HUD_Mod_Keepaway(vector pos, vector mySize)
3551 mod_active = 1; // keepaway should always show the mod HUD
3553 float BLINK_FACTOR = 0.15;
3554 float BLINK_BASE = 0.85;
3555 float BLINK_FREQ = 5;
3556 float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
3558 float stat_items = getstati(STAT_ITEMS);
3559 float kaball = (stat_items/IT_KEY1) & 1;
3561 if(kaball != kaball_prevstatus)
3563 kaball_statuschange_time = time;
3564 kaball_prevstatus = kaball;
3567 vector kaball_pos, kaball_size;
3569 if(mySize_x > mySize_y) {
3570 kaball_pos = pos + eX * 0.25 * mySize_x;
3571 kaball_size = eX * 0.5 * mySize_x + eY * mySize_y;
3573 kaball_pos = pos + eY * 0.25 * mySize_y;
3574 kaball_size = eY * 0.5 * mySize_y + eX * mySize_x;
3577 float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
3578 float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
3580 if(kaball_prevstatus && f < 1)
3581 drawpic_aspect_skin_expanding(kaball_pos, "keepawayball_carrying", kaball_size, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
3584 drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
3588 // Nexball HUD mod icon
3589 void HUD_Mod_NexBall(vector pos, vector mySize)
3591 float stat_items, nb_pb_starttime, dt, p;
3593 stat_items = getstati(STAT_ITEMS);
3594 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3596 if (stat_items & IT_KEY1)
3601 //Manage the progress bar if any
3602 if (nb_pb_starttime > 0)
3604 dt = mod(time - nb_pb_starttime, nb_pb_period);
3605 // one period of positive triangle
3606 p = 2 * dt / nb_pb_period;
3611 HUD_Panel_GetProgressBarColor(nexball);
3612 if(mySize_x > mySize_y)
3613 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, 0, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3615 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, 1, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3618 if (stat_items & IT_KEY1)
3619 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3622 // Race/CTS HUD mod icons
3623 float crecordtime_prev; // last remembered crecordtime
3624 float crecordtime_change_time; // time when crecordtime last changed
3625 float srecordtime_prev; // last remembered srecordtime
3626 float srecordtime_change_time; // time when srecordtime last changed
3628 float race_status_time;
3629 float race_status_prev;
3630 string race_status_name_prev;
3631 void HUD_Mod_Race(vector pos, vector mySize)
3633 mod_active = 1; // race should never hide the mod icons panel
3635 me = playerslots[player_localentnum - 1];
3637 float f; // yet another function has this
3638 score = me.(scores[ps_primary]);
3640 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3641 return; // no records in the actual race
3643 // clientside personal record
3645 if(gametype == GAME_CTS)
3649 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3651 if(score && (score < t || !t)) {
3652 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3653 if(autocvar_cl_autodemo_delete_keeprecords)
3655 f = autocvar_cl_autodemo_delete;
3657 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3661 if(t != crecordtime_prev) {
3662 crecordtime_prev = t;
3663 crecordtime_change_time = time;
3666 vector textPos, medalPos;
3668 if(mySize_x > mySize_y) {
3669 // text on left side
3670 squareSize = min(mySize_y, mySize_x/2);
3671 textPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eY * 0.5 * (mySize_y - squareSize);
3672 medalPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eX * 0.5 * mySize_x + eY * 0.5 * (mySize_y - squareSize);
3675 squareSize = min(mySize_x, mySize_y/2);
3676 textPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eX * 0.5 * (mySize_x - squareSize);
3677 medalPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eY * 0.5 * mySize_y + eX * 0.5 * (mySize_x - squareSize);
3680 f = time - crecordtime_change_time;
3683 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3684 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);
3686 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3687 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);
3688 drawstring_aspect_expanding(pos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
3689 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);
3693 t = race_server_record;
3694 if(t != srecordtime_prev) {
3695 srecordtime_prev = t;
3696 srecordtime_change_time = time;
3698 f = time - srecordtime_change_time;
3701 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3702 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);
3704 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3705 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);
3706 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);
3707 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);
3710 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
3711 race_status_time = time + 5;
3712 race_status_prev = race_status;
3713 if (race_status_name_prev)
3714 strunzone(race_status_name_prev);
3715 race_status_name_prev = strzone(race_status_name);
3720 a = bound(0, race_status_time - time, 1);
3723 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
3727 rank = race_CheckName(race_status_name);
3729 rankname = race_PlaceName(rank);
3732 namepos = medalPos + '0 0.8 0' * squareSize;
3734 rankpos = medalPos + '0 0.15 0' * squareSize;
3736 if(race_status == 0)
3737 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3738 else if(race_status == 1) {
3739 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);
3740 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3741 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3742 } else if(race_status == 2) {
3743 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
3744 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);
3746 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);
3747 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3748 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3749 } else if(race_status == 3) {
3750 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);
3751 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3752 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3755 if (race_status_time - time <= 0) {
3756 race_status_prev = -1;
3758 if(race_status_name)
3759 strunzone(race_status_name);
3760 race_status_name = string_null;
3761 if(race_status_name_prev)
3762 strunzone(race_status_name_prev);
3763 race_status_name_prev = string_null;
3767 void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, float layout, float i)
3769 float stat, pps_ratio;
3775 stat = getstatf(STAT_DOM_PPS_RED);
3776 pic = "dom_icon_red";
3780 stat = getstatf(STAT_DOM_PPS_BLUE);
3781 pic = "dom_icon_blue";
3785 stat = getstatf(STAT_DOM_PPS_YELLOW);
3786 pic = "dom_icon_yellow";
3790 stat = getstatf(STAT_DOM_PPS_PINK);
3791 pic = "dom_icon_pink";
3794 pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
3796 if(mySize_x/mySize_y > aspect_ratio)
3798 i = aspect_ratio * mySize_y;
3799 myPos_x = myPos_x + (mySize_x - i) / 2;
3804 i = 1/aspect_ratio * mySize_x;
3805 myPos_y = myPos_y + (mySize_y - i) / 2;
3809 if (layout) // show text too
3812 color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
3813 if (layout == 2) // average pps
3814 drawstring_aspect(myPos + eX * mySize_y, ftos_decimals(stat, 2), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
3815 else // percentage of average pps
3816 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);
3820 drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3823 drawsetcliparea(myPos_x, myPos_y + mySize_y * (1 - pps_ratio), mySize_y, mySize_y * pps_ratio);
3824 drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3825 drawresetcliparea();
3829 void HUD_Mod_Dom(vector myPos, vector mySize)
3831 mod_active = 1; // required in each mod function that always shows something
3834 for(tm = teams.sort_next; tm; tm = tm.sort_next)
3835 if(tm.team != COLOR_SPECTATOR)
3838 float layout = autocvar_hud_panel_modicons_dom_layout;
3839 float rows, columns, aspect_ratio;
3840 rows = mySize_y/mySize_x;
3841 aspect_ratio = (layout) ? 3 : 1;
3842 rows = bound(1, floor((sqrt((4 * aspect_ratio * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count);
3843 columns = ceil(teams_count/rows);
3847 for(i=0; i<teams_count; ++i)
3849 vector pos, itemSize;
3850 pos = myPos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows);
3851 itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
3853 DrawDomItem(pos, itemSize, aspect_ratio, layout, i);
3864 float mod_prev; // previous state of mod_active to check for a change
3866 float mod_change; // "time" when mod_active changed
3868 void HUD_ModIcons(void)
3870 if(!autocvar__hud_configure)
3872 if(!autocvar_hud_panel_modicons) return;
3873 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;
3876 hud_configure_active_panel = HUD_PANEL_MODICONS;
3878 HUD_Panel_UpdateCvars(modicons);
3881 mySize = panel_size;
3883 if(mod_active != mod_prev) {
3885 mod_prev = mod_active;
3888 if(mod_active || autocvar__hud_configure)
3889 mod_alpha = bound(0, (time - mod_change) * 2, 1);
3891 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
3894 HUD_Panel_DrawBg(mod_alpha);
3896 if(panel_bg_padding)
3898 pos += '1 1 0' * panel_bg_padding;
3899 mySize -= '2 2 0' * panel_bg_padding;
3902 // these MUST be ran in order to update mod_active
3903 if(gametype == GAME_KEYHUNT)
3904 HUD_Mod_KH(pos, mySize);
3905 else if(gametype == GAME_CTF || autocvar__hud_configure)
3906 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
3907 else if(gametype == GAME_NEXBALL)
3908 HUD_Mod_NexBall(pos, mySize);
3909 else if(gametype == GAME_CTS || gametype == GAME_RACE)
3910 HUD_Mod_Race(pos, mySize);
3911 else if(gametype == GAME_CA || gametype == GAME_FREEZETAG)
3912 HUD_Mod_CA(pos, mySize);
3913 else if(gametype == GAME_DOMINATION)
3914 HUD_Mod_Dom(pos, mySize);
3915 else if(gametype == GAME_KEEPAWAY)
3916 HUD_Mod_Keepaway(pos, mySize);
3919 // Draw pressed keys (#11)
3921 void HUD_DrawPressedKeys(void)
3923 if(!autocvar__hud_configure)
3925 if(!autocvar_hud_panel_pressedkeys) return;
3926 if(spectatee_status <= 0 && autocvar_hud_panel_pressedkeys < 2) return;
3929 hud_configure_active_panel = HUD_PANEL_PRESSEDKEYS;
3932 HUD_Panel_UpdateCvars(pressedkeys);
3935 mySize = panel_size;
3937 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 // force custom aspect
3945 float aspect = autocvar_hud_panel_pressedkeys_aspect;
3949 if(mySize_x/mySize_y > aspect)
3951 newSize_x = aspect * mySize_y;
3952 newSize_y = mySize_y;
3954 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3958 newSize_y = 1/aspect * mySize_x;
3959 newSize_x = mySize_x;
3961 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3967 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
3969 pressedkeys = getstatf(STAT_PRESSED_KEYS);
3971 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3972 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);
3973 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);
3975 drawpic_aspect_skin(pos, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3976 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);
3977 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);
3980 // Handle chat as a panel (#12)
3984 if(!autocvar__hud_configure)
3986 if (!autocvar_hud_panel_chat)
3988 if (!autocvar_con_chatrect)
3989 cvar_set("con_chatrect", "0");
3994 hud_configure_active_panel = HUD_PANEL_CHAT;
3996 HUD_Panel_UpdateCvars(chat);
3998 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
4000 panel_pos_y = panel_bg_border;
4001 panel_size_y = vid_conheight - panel_bg_border * 2;
4002 if(panel_bg == "0") // force a border when maximized
4004 if(precache_pic(panel_bg) == "") {
4005 panel_bg = strcat(hud_skin_path, "/border_default");
4006 if(precache_pic(panel_bg) == "") {
4007 panel_bg = "gfx/hud/default/border_default";
4011 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an alpha of at least 0.75
4016 mySize = panel_size;
4018 HUD_Panel_DrawBg(1);
4020 if(panel_bg_padding)
4022 pos += '1 1 0' * panel_bg_padding;
4023 mySize -= '2 2 0' * panel_bg_padding;
4026 if (!autocvar_con_chatrect)
4027 cvar_set("con_chatrect", "1");
4029 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4030 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4032 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4033 cvar_set("con_chat", ftos(floor(mySize_y/autocvar_con_chatsize - 0.5)));
4035 if(autocvar__hud_configure)
4038 chatsize = '1 1 0' * autocvar_con_chatsize;
4039 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4041 for(i = 0; i < autocvar_con_chat; ++i)
4043 if(i == autocvar_con_chat - 1)
4046 a = panel_fg_alpha * floor(((i + 1) * 7 + autocvar_con_chattime)/45);
4047 drawcolorcodedstring(pos, textShortenToWidth(_("^3Player^7: This is the chat area."), mySize_x, chatsize, stringwidth_colors), chatsize, a, DRAWFLAG_NORMAL);
4048 pos_y += chatsize_y;
4053 // Engine info panel (#13)
4060 float frametimeavg1; // 1 frame ago
4061 float frametimeavg2; // 2 frames ago
4062 void HUD_EngineInfo(void)
4064 if(!autocvar__hud_configure)
4066 if(!autocvar_hud_panel_engineinfo) return;
4069 hud_configure_active_panel = HUD_PANEL_ENGINEINFO;
4071 HUD_Panel_UpdateCvars(engineinfo);
4074 mySize = panel_size;
4076 HUD_Panel_DrawBg(1);
4077 if(panel_bg_padding)
4079 pos += '1 1 0' * panel_bg_padding;
4080 mySize -= '2 2 0' * panel_bg_padding;
4083 float currentTime = gettime(GETTIME_REALTIME);
4084 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
4086 float currentframetime = currentTime - prevfps_time;
4087 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4088 frametimeavg2 = frametimeavg1;
4089 frametimeavg1 = frametimeavg;
4092 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4093 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.
4095 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
4096 prevfps = (1/currentframetime);
4097 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"
4099 prevfps_time = currentTime;
4104 if(currentTime - prevfps_time > autocvar_hud_panel_engineinfo_framecounter_time)
4106 prevfps = framecounter/(currentTime - prevfps_time);
4108 prevfps_time = currentTime;
4113 color = HUD_Get_Num_Color (prevfps, 100);
4114 drawstring_aspect(pos, sprintf(_("FPS: %.*f"), autocvar_hud_panel_engineinfo_framecounter_decimals, prevfps), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4117 // Info messages panel (#14)
4119 #define drawInfoMessage(s)\
4120 if(autocvar_hud_panel_infomessages_flip)\
4121 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\
4122 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
4124 void HUD_InfoMessages(void)
4126 if(!autocvar__hud_configure)
4128 if(!autocvar_hud_panel_infomessages) return;
4131 hud_configure_active_panel = HUD_PANEL_INFOMESSAGES;
4133 HUD_Panel_UpdateCvars(infomessages);
4136 mySize = panel_size;
4138 HUD_Panel_DrawBg(1);
4139 if(panel_bg_padding)
4141 pos += '1 1 0' * panel_bg_padding;
4142 mySize -= '2 2 0' * panel_bg_padding;
4145 // always force 5:1 aspect
4147 if(mySize_x/mySize_y > 5)
4149 newSize_x = 5 * mySize_y;
4150 newSize_y = mySize_y;
4152 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4156 newSize_y = 1/5 * mySize_x;
4157 newSize_x = mySize_x;
4159 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4168 fontsize = '0.20 0.20 0' * mySize_y;
4174 if(!autocvar__hud_configure)
4176 if(spectatee_status && !intermission)
4179 if(spectatee_status == -1)
4180 s = _("^1Observing");
4182 s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(spectatee_status - 1));
4185 if(spectatee_status == -1)
4186 s = sprintf(_("^1Press ^3%s^1 to spectate"), getcommandkey("primary fire", "+fire"));
4188 s = sprintf(_("^1Press ^3%s^1 for another player"), getcommandkey("primary fire", "+fire"));
4191 if(spectatee_status == -1)
4192 s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
4194 s = sprintf(_("^1Press ^3%s^1 to observe"), getcommandkey("secondary fire", "+fire2"));
4197 s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey("server info", "+show_info"));
4200 if(gametype == GAME_ARENA)
4201 s = _("^1Wait for your turn to join");
4202 else if(gametype == GAME_LMS)
4205 sk = playerslots[player_localentnum - 1];
4206 if(sk.(scores[ps_primary]) >= 666)
4207 s = _("^1Match has already begun");
4208 else if(sk.(scores[ps_primary]) > 0)
4209 s = _("^1You have no more lives left");
4211 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
4214 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
4217 //show restart countdown:
4218 if (time < getstatf(STAT_GAMESTARTTIME)) {
4220 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4221 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4222 s = sprintf(_("^1Game starts in ^3%d^1 seconds"), countdown);
4223 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4227 if(warmup_stage && !intermission)
4229 s = _("^2Currently in ^1warmup^2 stage!");
4234 if(mod(time, 1) >= 0.5)
4239 if(ready_waiting && !intermission && !spectatee_status)
4241 if(ready_waiting_for_me)
4244 s = sprintf(_("%sPress ^3%s%s to end warmup"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
4246 s = sprintf(_("%sPress ^3%s%s once you are ready"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
4251 s = _("^2Waiting for others to ready up to end warmup...");
4253 s = _("^2Waiting for others to ready up...");
4257 else if(warmup_stage && !intermission && !spectatee_status)
4259 s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey("ready", "ready"));
4263 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4265 float ts_min, ts_max;
4266 tm = teams.sort_next;
4269 for(; tm.sort_next; tm = tm.sort_next)
4271 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4273 if(!ts_min) ts_min = tm.team_size;
4274 else ts_min = min(ts_min, tm.team_size);
4275 if(!ts_max) ts_max = tm.team_size;
4276 else ts_max = max(ts_max, tm.team_size);
4278 if ((ts_max - ts_min) > 1)
4280 s = strcat(blinkcolor, _("Teamnumbers are unbalanced!"));
4281 tm = GetTeam(myteam, false);
4283 if (tm.team != COLOR_SPECTATOR)
4284 if (tm.team_size == ts_max)
4285 s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey("team menu", "menu_showteamselect"), blinkcolor));
4293 s = _("^7Press ^3ESC ^7to show HUD options.");
4295 s = _("^3Doubleclick ^7a panel for panel-specific options.");
4297 s = _("^3CTRL ^7to disable collision testing, ^3SHIFT ^7and");
4299 s = _("^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.");
4304 // Physics panel (#15)
4306 vector acc_prevspeed;
4307 float acc_prevtime, acc_avg, top_speed, top_speed_time;
4308 void HUD_Physics(void)
4310 if(!autocvar__hud_configure)
4312 if(!autocvar_hud_panel_physics) return;
4313 if(spectatee_status == -1 && autocvar_hud_panel_physics < 2) return;
4316 hud_configure_active_panel = HUD_PANEL_PHYSICS;
4318 HUD_Panel_UpdateCvars(physics);
4320 HUD_Panel_DrawBg(1);
4321 if(panel_bg_padding)
4323 panel_pos += '1 1 0' * panel_bg_padding;
4324 panel_size -= '2 2 0' * panel_bg_padding;
4328 float speed, conversion_factor;
4331 switch(autocvar_hud_panel_physics_speed_unit)
4336 conversion_factor = 1.0;
4340 conversion_factor = 0.0254;
4344 conversion_factor = 0.0254 * 3.6;
4348 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4352 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4356 float max_speed = floor( autocvar_hud_panel_physics_speed_max * conversion_factor + 0.5 );
4357 if (autocvar__hud_configure)
4358 speed = floor( max_speed * 0.65 + 0.5 );
4359 else if(autocvar_hud_panel_physics_speed_vertical)
4360 speed = floor( vlen(pmove_vel) * conversion_factor + 0.5 );
4362 speed = floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 );
4364 //compute acceleration
4365 float acceleration, f;
4366 if (autocvar__hud_configure)
4367 acceleration = autocvar_hud_panel_physics_acceleration_max * 0.3;
4370 // 1 m/s = 0.0254 qu/s; 1 g = 9.80665 m/s^2
4371 f = time - acc_prevtime;
4372 if(autocvar_hud_panel_physics_acceleration_vertical)
4373 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f) * (0.0254 / 9.80665);
4375 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);
4376 acc_prevspeed = pmove_vel;
4377 acc_prevtime = time;
4379 f = bound(0, f * 10, 1);
4380 acc_avg = acc_avg * (1 - f) + acceleration * f;
4384 float panel_ar = panel_size_x/panel_size_y;
4385 vector speed_offset, acceleration_offset;
4388 panel_size_x *= 0.5;
4389 if (autocvar_hud_panel_physics_flip)
4390 speed_offset_x = panel_size_x;
4392 acceleration_offset_x = panel_size_x;
4396 panel_size_y *= 0.5;
4397 if (autocvar_hud_panel_physics_flip)
4398 speed_offset_y = panel_size_y;
4400 acceleration_offset_y = panel_size_y;
4402 float speed_baralign, acceleration_baralign;
4403 if (autocvar_hud_panel_physics_baralign == 1)
4404 acceleration_baralign = speed_baralign = 1;
4405 else if(autocvar_hud_panel_physics_baralign == 4)
4406 acceleration_baralign = speed_baralign = 2;
4407 else if (autocvar_hud_panel_physics_flip)
4409 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 2);
4410 speed_baralign = (autocvar_hud_panel_physics_baralign == 3);
4414 speed_baralign = (autocvar_hud_panel_physics_baralign == 2);
4415 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 3);
4417 if (autocvar_hud_panel_physics_acceleration_progressbar_mode == 0)
4418 acceleration_baralign = 3; //override hud_panel_physics_baralign value for acceleration
4422 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
4424 HUD_Panel_GetProgressBarColor(speed);
4425 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);
4427 vector tmp_offset, tmp_size;
4428 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
4430 tmp_size_x = panel_size_x * 0.75;
4431 tmp_size_y = panel_size_y;
4433 tmp_offset_x = panel_size_x - tmp_size_x;
4436 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4442 tmp_offset_x = tmp_size_x;
4443 if (autocvar_hud_panel_physics_speed_unit_show)
4446 tmp_size_x = panel_size_x * (1 - 0.75);
4447 tmp_size_y = panel_size_y * 0.4;
4448 drawstring_aspect(panel_pos + speed_offset + tmp_offset, unit, tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4452 //compute and draw top speed
4453 if (autocvar_hud_panel_physics_topspeed)
4454 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
4456 if (autocvar__hud_configure)
4458 top_speed = floor( max_speed * 0.75 + 0.5 );
4463 if (speed >= top_speed)
4466 top_speed_time = time;
4470 f = max(1, autocvar_hud_panel_physics_topspeed_time);
4471 // divide by f to make it start from 1
4472 f = cos( ((time - top_speed_time) / f) * PI/2 );
4474 else //hide top speed 0, it would be stupid
4479 //top speed progressbar peak
4480 if(speed < top_speed)
4481 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
4483 float peak_offset_x;
4485 if (speed_baralign == 0)
4486 peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x;
4487 else if (speed_baralign == 1)
4488 peak_offset_x = (1 - min(top_speed, max_speed)/max_speed) * panel_size_x;
4489 else if (speed_baralign == 2)
4490 peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x * 0.5;
4491 //if speed is not 0 the speed progressbar already fetched the color
4493 HUD_Panel_GetProgressBarColor(speed);
4494 peak_size_x = floor(panel_size_x * 0.01 + 1.5);
4495 peak_size_y = panel_size_y;
4496 if (speed_baralign == 2) // draw two peaks, on both sides
4498 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);
4499 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);
4502 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);
4506 tmp_offset_y = panel_size_y * 0.4;
4507 tmp_size_x = panel_size_x * (1 - 0.75);
4508 tmp_size_y = panel_size_y - tmp_offset_y;
4509 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(top_speed), tmp_size, '1 0 0', f * panel_fg_alpha, DRAWFLAG_NORMAL);
4517 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 3)
4519 if (acceleration < 0)
4520 HUD_Panel_GetProgressBarColor(acceleration_neg);
4522 HUD_Panel_GetProgressBarColor(acceleration);
4523 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);
4525 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
4526 drawstring_aspect(panel_pos + acceleration_offset, strcat(ftos_decimals(acceleration, 2), "g"), panel_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4535 void HUD_Reset (void)
4537 // reset gametype specific icons
4538 if(gametype == GAME_KEYHUNT)
4540 else if(gametype == GAME_CTF)
4541 HUD_Mod_CTF_Reset();
4544 #define HUD_DrawPanel(id)\
4546 case (HUD_PANEL_RADAR):\
4547 HUD_Radar(); break;\
4548 case (HUD_PANEL_WEAPONS):\
4549 HUD_Weapons(); break;\
4550 case (HUD_PANEL_AMMO):\
4552 case (HUD_PANEL_POWERUPS):\
4553 HUD_Powerups(); break;\
4554 case (HUD_PANEL_HEALTHARMOR):\
4555 HUD_HealthArmor(); break;\
4556 case (HUD_PANEL_NOTIFY):\
4557 HUD_Notify(); break;\
4558 case (HUD_PANEL_TIMER):\
4559 HUD_Timer(); break;\
4560 case (HUD_PANEL_SCORE):\
4561 HUD_Score(); break;\
4562 case (HUD_PANEL_RACETIMER):\
4563 HUD_RaceTimer(); break;\
4564 case (HUD_PANEL_VOTE):\
4565 HUD_VoteWindow(); break;\
4566 case (HUD_PANEL_MODICONS):\
4567 HUD_ModIcons(); break;\
4568 case (HUD_PANEL_PRESSEDKEYS):\
4569 HUD_DrawPressedKeys(); break;\
4570 case (HUD_PANEL_CHAT):\
4572 case (HUD_PANEL_ENGINEINFO):\
4573 HUD_EngineInfo(); break;\
4574 case (HUD_PANEL_INFOMESSAGES):\
4575 HUD_InfoMessages(); break;\
4576 case (HUD_PANEL_PHYSICS):\
4577 HUD_Physics(); break;\
4578 } ENDS_WITH_CURLY_BRACE
4580 void HUD_Main (void)
4583 // global hud alpha fade
4584 if(menu_enabled == 1)
4587 hud_fade_alpha = (1 - autocvar__menu_alpha);
4589 if(scoreboard_fade_alpha)
4590 hud_fade_alpha = (1 - scoreboard_fade_alpha);
4592 if(intermission == 2) // no hud during mapvote
4594 if (autocvar__hud_configure) //force exit from hud config
4599 localcmd("togglemenu\n");
4601 cvar_set("_hud_configure", "0");
4605 else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
4608 if(!autocvar__hud_configure && !hud_fade_alpha)
4612 if (hud_skin_path != autocvar_hud_skin)
4615 strunzone(hud_skin_path);
4616 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
4619 // HUD configure visible grid
4620 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4622 hud_configure_gridSize_x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
4623 hud_configure_gridSize_y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
4624 hud_configure_realGridSize_x = hud_configure_gridSize_x * vid_conwidth;
4625 hud_configure_realGridSize_y = hud_configure_gridSize_y * vid_conheight;
4627 for(i = 0; i < 1/hud_configure_gridSize_x; ++i)
4628 drawfill(eX * i * hud_configure_realGridSize_x, eX + eY * vid_conheight, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4630 for(i = 0; i < 1/hud_configure_gridSize_y; ++i)
4631 drawfill(eY * i * hud_configure_realGridSize_y, eY + eX * vid_conwidth, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4634 current_player = (spectatee_status > 0) ? spectatee_status : player_localentnum;
4637 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4641 float hud_dock_color_team = autocvar_hud_dock_color_team;
4642 if((teamplay) && hud_dock_color_team) {
4643 f = stof(getplayerkey(current_player - 1, "colors"));
4644 color = colormapPaletteColor(mod(f, 16), 1) * hud_dock_color_team;
4646 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
4647 color = '1 0 0' * hud_dock_color_team;
4651 string hud_dock_color = autocvar_hud_dock_color;
4652 if(hud_dock_color == "shirt") {
4653 f = stof(getplayerkey(current_player - 1, "colors"));
4654 color = colormapPaletteColor(floor(f / 16), 0);
4656 else if(hud_dock_color == "pants") {
4657 f = stof(getplayerkey(current_player - 1, "colors"));
4658 color = colormapPaletteColor(mod(f, 16), 1);
4661 color = stov(hud_dock_color);
4665 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4666 if(precache_pic(pic) == "") {
4667 pic = strcat(hud_skin_path, "/dock_medium");
4668 if(precache_pic(pic) == "") {
4669 pic = "gfx/hud/default/dock_medium";
4672 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...
4675 // cache the panel order into the panel_order array
4676 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4677 for(i = 0; i < HUD_PANEL_NUM; ++i)
4678 panel_order[i] = -1;
4680 float p_num, warning;
4681 float argc = tokenize_console(autocvar__hud_panelorder);
4682 if (argc > HUD_PANEL_NUM)
4684 //first detect wrong/missing panel numbers
4685 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4686 p_num = stof(argv(i));
4687 if (p_num >= 0 && p_num < HUD_PANEL_NUM) { //correct panel number?
4688 if (panel_order[p_num] == -1) //found for the first time?
4689 s = strcat(s, ftos(p_num), " ");
4690 panel_order[p_num] = 1; //mark as found
4695 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4696 if (panel_order[i] == -1) {
4698 s = strcat(s, ftos(i), " "); //add missing panel number
4702 print(_("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n"));
4704 cvar_set("_hud_panelorder", s);
4705 if(hud_panelorder_prev)
4706 strunzone(hud_panelorder_prev);
4707 hud_panelorder_prev = strzone(s);
4709 //now properly set panel_order
4710 tokenize_console(s);
4711 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4712 panel_order[i] = stof(argv(i));
4716 // draw panels in order specified by panel_order array
4717 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
4718 if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice!
4719 HUD_DrawPanel(panel_order[i]);
4722 // draw chat panel on top if it is maximized
4723 if(autocvar__con_chat_maximized)
4724 HUD_Chat(); // HUD_DrawPanel(HUD_PANEL_CHAT);
4726 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)
4727 localcmd("cmd selectteam auto; cmd join\n");
4729 if(autocvar__hud_configure && tab_panel != -1)
4731 HUD_Panel_UpdatePosSizeForId(tab_panel)
4732 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
4735 hud_configure_prev = autocvar__hud_configure;
4737 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again