7 // a border picture is a texture containing nine parts:
8 // 1/4 width: left part
9 // 1/2 width: middle part (stretched)
10 // 1/4 width: right part
12 // 1/4 height: top part
13 // 1/2 height: middle part (stretched)
14 // 1/4 height: bottom part
15 void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize)
17 if (theBorderSize_x < 0 && theBorderSize_y < 0) // draw whole image as it is
19 drawpic(theOrigin, pic, theSize, theColor, theAlpha, 0);
22 if (theBorderSize_x == 0 && theBorderSize_y == 0) // no border
24 // draw only the central part
25 drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
32 //pic = draw_UseSkinFor(pic);
33 width = eX * theSize_x;
34 height = eY * theSize_y;
35 if(theSize_x <= theBorderSize_x * 2)
37 // not wide enough... draw just left and right then
38 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
39 if(theSize_y <= theBorderSize_y * 2)
41 // not high enough... draw just corners
42 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
43 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
44 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
45 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
46 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
50 dY = theBorderSize_x * eY;
51 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
52 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
53 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
54 drawsubpic(theOrigin + width * 0.5 + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0' + eX - bW, '0 0.5 0' + bW, theColor, theAlpha, 0);
55 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
56 drawsubpic(theOrigin + width * 0.5 + height - dY, width * 0.5 + dY, pic, '0 0.75 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
61 if(theSize_y <= theBorderSize_y * 2)
63 // not high enough... draw just top and bottom then
64 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
65 dX = theBorderSize_x * eX;
66 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
67 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
68 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
69 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
70 drawsubpic(theOrigin + dX + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5 0 0' + bH, theColor, theAlpha, 0);
71 drawsubpic(theOrigin + width - dX + height * 0.5, dX + height * 0.5, pic, '0.75 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
75 dX = theBorderSize_x * eX;
76 dY = theBorderSize_x * eY;
77 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
78 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
79 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
80 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
81 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
82 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
83 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
84 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
85 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
90 vector HUD_Get_Num_Color (float x, float maxvalue)
95 color_x = sin(2*M_PI*time);
97 color_z = sin(2*M_PI*time);
99 else if(x > maxvalue * 0.75) {
100 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
101 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
104 else if(x > maxvalue * 0.5) {
105 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
106 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
107 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
109 else if(x > maxvalue * 0.25) {
112 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
114 else if(x > maxvalue * 0.1) {
116 color_y = (x-20)*90/27/100; // green value between 0 -> 1
117 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
125 blinkingamt = (1 - x/maxvalue/0.25);
128 color_x = color_x - color_x * blinkingamt * sin(2*M_PI*time);
129 color_y = color_y - color_y * blinkingamt * sin(2*M_PI*time);
130 color_z = color_z - color_z * blinkingamt * sin(2*M_PI*time);
135 float stringwidth_colors(string s, vector theSize)
137 return stringwidth(s, TRUE, theSize);
140 float stringwidth_nocolors(string s, vector theSize)
142 return stringwidth(s, FALSE, theSize);
145 #define CENTERPRINT_MAX_LINES 30
146 string centerprint_messages[CENTERPRINT_MAX_LINES];
147 float centerprint_width[CENTERPRINT_MAX_LINES];
148 float centerprint_time;
149 float centerprint_expire;
150 float centerprint_num;
151 float centerprint_offset_hint;
152 vector centerprint_fontsize;
154 void centerprint(string strMessage)
156 float i, j, n, hcount;
159 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
161 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
163 if(autocvar_scr_centertime <= 0)
169 // strip trailing newlines
170 j = strlen(strMessage) - 1;
171 while(substring(strMessage, j, 1) == "\n" && j >= 0)
173 strMessage = substring(strMessage, 0, j + 1);
178 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
180 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
182 strMessage = substring(strMessage, j, strlen(strMessage) - j);
183 centerprint_offset_hint = j;
188 // if we get here, we have a message. Initialize its height.
191 n = tokenizebyseparator(strMessage, "\n");
193 for(j = 0; j < n; ++j)
195 getWrappedLine_remaining = argv(j);
196 while(getWrappedLine_remaining)
198 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
199 if(centerprint_messages[i] != s) // don't fade the same message in, looks stupid
200 centerprint_time = time;
201 if(centerprint_messages[i])
202 strunzone(centerprint_messages[i]);
203 centerprint_messages[i] = strzone(s);
204 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
207 // half height for empty lines looks better
213 if(i >= CENTERPRINT_MAX_LINES)
219 h = centerprint_fontsize_y*hcount;
221 havail = vid_conheight;
222 if(autocvar_con_chatpos < 0)
223 havail -= (-autocvar_con_chatpos + autocvar_con_chat) * autocvar_con_chatsize; // avoid overlapping chat
224 if(havail > vid_conheight - 70)
225 havail = vid_conheight - 70; // avoid overlapping HUD
228 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
230 // here, the centerprint would cover the crosshair. REALLY BAD.
231 forbiddenmin = vid_conheight * 0.5 - h - 16;
232 forbiddenmax = vid_conheight * 0.5 + 16;
234 allowedmin = scoreboard_bottom;
235 allowedmax = havail - h;
236 preferred = (havail - h)/2;
239 // possible orderings (total: 4! / 4 = 6)
240 // allowedmin allowedmax forbiddenmin forbiddenmax
241 // forbiddenmin forbiddenmax allowedmin allowedmax
242 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
244 // forbidden doesn't matter in this case
245 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
247 // allowedmin forbiddenmin allowedmax forbiddenmax
248 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
250 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
252 // allowedmin forbiddenmin forbiddenmax allowedmax
253 else if(allowedmin < forbiddenmin)
255 // make sure the forbidden zone is not covered
256 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
257 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
259 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
261 // forbiddenmin allowedmin allowedmax forbiddenmax
262 else if(allowedmax < forbiddenmax)
264 // it's better to leave the allowed zone (overlap with scoreboard) than
265 // to cover the forbidden zone (crosshair)
266 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
267 centerprint_start_y = forbiddenmax;
269 centerprint_start_y = forbiddenmin;
271 // forbiddenmin allowedmin forbiddenmax allowedmax
274 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
281 centerprint_expire = time + autocvar_scr_centertime;
284 void HUD_DrawCenterPrint (void)
291 if(time - centerprint_time < 0.25)
292 a = (time - centerprint_time) / 0.25;
294 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
301 if(centerprint_num * autocvar_scr_centersize > 24 && scoreboard_active) // 24 = height of Scoreboard text
302 centerprint_start_y = scoreboard_bottom + centerprint_fontsize_y;
304 pos = centerprint_start;
305 for (i=0; i<centerprint_num; i = i + 1)
307 ts = centerprint_messages[i];
308 drawfontscale = sz * '1 1 0';
309 pos_x = (vid_conwidth - stringwidth(ts, TRUE, centerprint_fontsize)) * 0.5;
312 drawcolorcodedstring(pos + '0 1 0' * (1 - sz) * 0.5 *centerprint_fontsize_y, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
313 pos_y = pos_y + centerprint_fontsize_y;
316 // half height for empty lines looks better
317 pos_y = pos_y + sz * centerprint_fontsize_y * 0.5;
318 drawfontscale = '1 1 0';
322 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
324 position_x -= 2 / 3 * strlen(text) * scale_x;
325 drawstring(position, text, scale, rgb, alpha, flag);
328 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
330 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
331 drawstring(position, text, scale, rgb, alpha, flag);
334 // return the string of the given race place
335 string race_PlaceName(float pos) {
343 return sprintf(_("%dth"), pos);
346 // return the string of the onscreen race timer
347 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
355 if(histime == 0) // goal hit
359 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
369 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
375 lapstr = sprintf(_(" (-%dL)"), lapdelta);
378 else if(lapdelta < 0)
380 lapstr = sprintf(_(" (+%dL)"), -lapdelta);
384 else if(histime > 0) // anticipation
386 if(mytime >= histime)
387 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
389 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
396 cpname = _("Start line");
398 cpname = _("Finish line");
400 cpname = sprintf(_("Intermediate %d"), cp);
402 cpname = _("Finish line");
405 return strcat(col, cpname);
406 else if(hisname == "")
407 return strcat(col, sprintf(_("%s (%s)"), cpname, timestr));
409 return strcat(col, sprintf(_("%s (%s %s)"), cpname, timestr, strcat(hisname, col, lapstr)));
412 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
413 float race_CheckName(string net_name) {
415 for (i=RANKINGS_CNT-1;i>=0;--i)
416 if(grecordholder[i] == net_name)
427 // draw the background/borders
428 #define HUD_Panel_DrawBg(alpha)\
430 draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * alpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\
431 if(highlightedPanel == hud_configure_active_panel && autocvar__hud_configure)\
433 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);\
434 } ENDS_WITH_CURLY_BRACE
436 //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
437 void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, float vertical, float baralign, vector theColor, float theAlpha, float drawflag)
439 if(!length_ratio || !theAlpha)
445 if(length_ratio < -1)
448 else if(length_ratio < 0)
452 vector width, height;
454 pic = strcat(hud_skin_path, "/", pic, "_vertical");
455 if(precache_pic(pic) == "") {
456 pic = "gfx/hud/default/progressbar_vertical";
459 if (baralign == 1) // bottom align
460 theOrigin_y += (1 - length_ratio) * theSize_y;
461 else if (baralign == 2) // center align
462 theOrigin_y += 0.5 * (1 - length_ratio) * theSize_y;
463 else if (baralign == 3) // center align, positive values down, negative up
466 if (length_ratio > 0)
467 theOrigin_y += theSize_y;
470 theOrigin_y += (1 + length_ratio) * theSize_y;
471 length_ratio = -length_ratio;
474 theSize_y *= length_ratio;
477 width = eX * theSize_x;
478 height = eY * theSize_y;
479 if(theSize_y <= theSize_x * 2)
481 // button not high enough
482 // draw just upper and lower part then
483 square = eY * theSize_y * 0.5;
484 bH = eY * (0.25 * theSize_y / (theSize_x * 2));
485 drawsubpic(theOrigin, square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, drawflag);
486 drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, drawflag);
490 square = eY * theSize_x;
491 drawsubpic(theOrigin, width + square, pic, '0 0 0', '1 0.25 0', theColor, theAlpha, drawflag);
492 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5 0', theColor, theAlpha, drawflag);
493 drawsubpic(theOrigin + height - square, width + square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, drawflag);
496 pic = strcat(hud_skin_path, "/", pic);
497 if(precache_pic(pic) == "") {
498 pic = "gfx/hud/default/progressbar";
501 if (baralign == 1) // right align
502 theOrigin_x += (1 - length_ratio) * theSize_x;
503 else if (baralign == 2) // center align
504 theOrigin_x += 0.5 * (1 - length_ratio) * theSize_x;
505 else if (baralign == 3) // center align, positive values on the right, negative on the left
508 if (length_ratio > 0)
509 theOrigin_x += theSize_x;
512 theOrigin_x += (1 + length_ratio) * theSize_x;
513 length_ratio = -length_ratio;
516 theSize_x *= length_ratio;
519 width = eX * theSize_x;
520 height = eY * theSize_y;
521 if(theSize_x <= theSize_y * 2)
523 // button not wide enough
524 // draw just left and right part then
525 square = eX * theSize_x * 0.5;
526 bW = eX * (0.25 * theSize_x / (theSize_y * 2));
527 drawsubpic(theOrigin, square + height, pic, '0 0 0', eY + bW, theColor, theAlpha, drawflag);
528 drawsubpic(theOrigin + square, square + height, pic, eX - bW, eY + bW, theColor, theAlpha, drawflag);
532 square = eX * theSize_y;
533 drawsubpic(theOrigin, height + square, pic, '0 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
534 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0.25 0 0', '0.5 1 0', theColor, theAlpha, drawflag);
535 drawsubpic(theOrigin + width - square, height + square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
540 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
546 pic = strcat(hud_skin_path, "/num_leading");
547 if(precache_pic(pic) == "") {
548 pic = "gfx/hud/default/num_leading";
551 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
552 if(mySize_x/mySize_y > 2)
553 drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, pic, '0.25 0 0', '0.5 1 0', color, alpha, drawflag);
554 drawsubpic(pos + eX * mySize_x - eX * min(mySize_x * 0.5, mySize_y), eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0.75 0 0', '0.25 1 0', color, alpha, drawflag);
559 entity weaponorder[WEP_MAXCOUNT];
560 void weaponorder_swap(float i, float j, entity pass)
564 weaponorder[i] = weaponorder[j];
568 string weaponorder_cmp_str;
569 float weaponorder_cmp(float i, float j, entity pass)
572 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
573 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
574 return aj - ai; // the string is in REVERSE order (higher prio at the right is what we want, but higher prio first is the string)
577 float GetAmmoStat(float i)
581 case 0: return STAT_SHELLS;
582 case 1: return STAT_NAILS;
583 case 2: return STAT_ROCKETS;
584 case 3: return STAT_CELLS;
585 case 4: return STAT_FUEL;
590 float GetAmmoTypeForWep(float i)
594 case WEP_SHOTGUN: return 0;
595 case WEP_UZI: return 1;
596 case WEP_GRENADE_LAUNCHER: return 2;
597 case WEP_MINE_LAYER: return 2;
598 case WEP_ELECTRO: return 3;
599 case WEP_CRYLINK: return 3;
600 case WEP_HLAC: return 3;
601 case WEP_MINSTANEX: return 3;
602 case WEP_NEX: return 3;
603 case WEP_SNIPERRIFLE: return 1;
604 case WEP_HAGAR: return 2;
605 case WEP_ROCKET_LAUNCHER: return 2;
606 case WEP_SEEKER: return 2;
607 case WEP_FIREBALL: return 4;
608 case WEP_HOOK: return 3;
613 void HUD_Weapons(void)
616 float center_x, center_y;
618 if(!autocvar__hud_configure)
620 if(!autocvar_hud_panel_weapons) return;
621 if(spectatee_status == -1) return;
624 hud_configure_active_panel = HUD_PANEL_WEAPONS;
626 float timeout = autocvar_hud_panel_weapons_timeout;
627 float timeout_effect_length, timein_effect_length;
628 if (autocvar_hud_panel_weapons_timeout_effect == 0)
630 timeout_effect_length = 0;
631 timein_effect_length = 0;
635 timeout_effect_length = 0.75;
636 timein_effect_length = 0.375;
639 if (timeout && time >= weapontime + timeout + timeout_effect_length && !autocvar__hud_configure)
641 weaponprevtime = time;
645 HUD_Panel_UpdateCvars(weapons);
647 if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
649 f = (time - (weapontime + timeout)) / timeout_effect_length;
650 if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3)
652 panel_bg_alpha *= (1 - f);
653 panel_fg_alpha *= (1 - f);
655 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
657 f *= f; // for a cooler movement
658 center_x = panel_pos_x + panel_size_x/2;
659 center_y = panel_pos_y + panel_size_y/2;
660 screen_ar = vid_conwidth/vid_conheight;
661 if (center_x/center_y < screen_ar) //bottom left
663 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
664 panel_pos_y += f * (vid_conheight - panel_pos_y);
666 panel_pos_x -= f * (panel_pos_x + panel_size_x);
670 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
671 panel_pos_x += f * (vid_conwidth - panel_pos_x);
673 panel_pos_y -= f * (panel_pos_y + panel_size_y);
676 weaponprevtime = time - (1 - f) * timein_effect_length;
678 else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure)
680 f = (time - weaponprevtime) / timein_effect_length;
681 if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3)
683 panel_bg_alpha *= (f);
684 panel_fg_alpha *= (f);
686 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
688 f *= f; // for a cooler movement
690 center_x = panel_pos_x + panel_size_x/2;
691 center_y = panel_pos_y + panel_size_y/2;
692 screen_ar = vid_conwidth/vid_conheight;
693 if (center_x/center_y < screen_ar) //bottom left
695 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
696 panel_pos_y += f * (vid_conheight - panel_pos_y);
698 panel_pos_x -= f * (panel_pos_x + panel_size_x);
702 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
703 panel_pos_x += f * (vid_conwidth - panel_pos_x);
705 panel_pos_y -= f * (panel_pos_y + panel_size_y);
710 float i, weapid, wpnalpha, weapon_cnt;
712 // TODO make this configurable
713 if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
715 if(weaponorder_bypriority)
716 strunzone(weaponorder_bypriority);
717 if(weaponorder_byimpulse)
718 strunzone(weaponorder_byimpulse);
720 weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
721 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
722 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
725 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
727 self = get_weaponinfo(i);
728 if(self.impulse >= 0)
730 weaponorder[weapon_cnt] = self;
734 for(i = weapon_cnt; i < WEP_MAXCOUNT; ++i)
735 weaponorder[i] = NULL;
736 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
738 weaponorder_cmp_str = string_null;
744 panel_pos += '1 1 0' * panel_bg_padding;
745 panel_size -= '2 2 0' * panel_bg_padding;
748 if(autocvar_hud_panel_weapons_fade)
750 wpnalpha = 3.2 - 2 * (time - weapontime);
751 wpnalpha = bound(0.7, wpnalpha, 1) * panel_fg_alpha;
754 wpnalpha = panel_fg_alpha;
757 float aspect = autocvar_hud_panel_weapons_aspect;
758 rows = panel_size_y/panel_size_x;
759 rows = bound(1, floor((sqrt(4 * aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
761 columns = ceil(WEP_COUNT/rows);
764 float a, type, fullammo;
766 when = autocvar_hud_panel_weapons_complainbubble_time;
768 fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
776 wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
777 float barsize_x, barsize_y, baroffset_x, baroffset_y;
778 if (autocvar_hud_panel_weapons_ammo)
780 ammo_color = stov(autocvar_hud_panel_weapons_ammo_color);
781 ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha;
784 if(wpnsize_x/wpnsize_y > aspect)
786 barsize_x = aspect * wpnsize_y;
787 barsize_y = wpnsize_y;
788 baroffset_x = (wpnsize_x - barsize_x) / 2;
792 barsize_y = 1/aspect * wpnsize_x;
793 barsize_x = wpnsize_x;
794 baroffset_y = (wpnsize_y - barsize_y) / 2;
800 if(autocvar_hud_panel_weapons_accuracy && acc_levels)
802 show_accuracy = true;
803 if (acc_col_x[0] == -1)
804 for (i = 0; i < acc_levels; ++i)
805 acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
808 float weapons_st = getstati(STAT_WEAPONS);
810 for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
812 self = weaponorder[i];
813 if (!self || self.impulse < 0)
815 wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
817 weapid = self.impulse;
819 // draw background behind currently selected weapon
820 if(self.weapon == activeweapon)
821 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
823 // draw the weapon accuracy
826 weapon_stats = weapon_accuracy[self.weapon-WEP_FIRST];
827 if(weapon_stats >= 0)
829 // find the max level lower than weapon_stats
832 while ( j && weapon_stats < acc_lev[j] )
835 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
837 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
839 color = color + factor * (acc_col[j+1] - color);
841 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
845 // draw the weapon icon
846 if(weapons_st & self.weapons)
848 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
850 if(autocvar_hud_panel_weapons_label == 1) // weapon number
851 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
852 else if(autocvar_hud_panel_weapons_label == 2) // bind
853 drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
855 // draw ammo status bar
856 if(autocvar_hud_panel_weapons_ammo && self.weapon != WEP_TUBA && self.weapon != WEP_LASER && self.weapon != WEP_PORTO)
859 type = GetAmmoTypeForWep(self.weapon);
861 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
866 case 0: fullammo = autocvar_hud_panel_weapons_ammo_full_shells; break;
867 case 1: fullammo = autocvar_hud_panel_weapons_ammo_full_nails; break;
868 case 2: fullammo = autocvar_hud_panel_weapons_ammo_full_rockets; break;
869 case 3: fullammo = autocvar_hud_panel_weapons_ammo_full_cells; break;
870 case 4: fullammo = autocvar_hud_panel_weapons_ammo_full_fuel; break;
871 default: fullammo = 60;
875 wpnpos_x + baroffset_x,
876 wpnpos_y + baroffset_y,
877 barsize_x * bound(0, a/fullammo, 1),
879 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, ammo_color, ammo_alpha, DRAWFLAG_NORMAL);
885 // draw a "ghost weapon icon" if you don't have the weapon
888 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
891 // draw the complain message
892 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
896 if(complain_weapon_time + when > time)
899 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
903 if(complain_weapon_time + when > time)
910 if(complain_weapon_type == 0) {
911 s = _("Out of ammo");
912 color = stov(autocvar_hud_panel_weapons_complainbubble_color_outofammo);
914 else if(complain_weapon_type == 1) {
916 color = stov(autocvar_hud_panel_weapons_complainbubble_color_donthave);
919 s = _("Unavailable");
920 color = stov(autocvar_hud_panel_weapons_complainbubble_color_unavailable);
922 float padding = autocvar_hud_panel_weapons_complainbubble_padding;
923 drawpic_aspect_skin(wpnpos + '1 1 0' * padding, "weapon_complainbubble", wpnsize - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
924 drawstring_aspect(wpnpos + '1 1 0' * padding, s, wpnsize - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
940 float GetAmmoItemCode(float i)
944 case 0: return IT_SHELLS;
945 case 1: return IT_NAILS;
946 case 2: return IT_ROCKETS;
947 case 3: return IT_CELLS;
948 case 4: return IT_FUEL;
953 string GetAmmoPicture(float i)
957 case 0: return "ammo_shells";
958 case 1: return "ammo_bullets";
959 case 2: return "ammo_rockets";
960 case 3: return "ammo_cells";
961 case 4: return "ammo_fuel";
966 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
969 if(autocvar__hud_configure)
971 currently_selected = (itemcode == 2); //rockets always selected
972 a = 31 + mod(itemcode*93, 128);
975 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
984 if(currently_selected)
989 vector picpos, numpos;
990 if(autocvar_hud_panel_ammo_iconalign)
993 picpos = myPos + eX * 2 * mySize_y;
997 numpos = myPos + eX * mySize_y;
1001 if (currently_selected)
1002 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1004 if(a > 0 && autocvar_hud_panel_ammo_progressbar)
1005 HUD_Panel_DrawProgressBar(myPos + eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize_x, mySize - eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize_x, autocvar_hud_panel_ammo_progressbar_name, a/autocvar_hud_panel_ammo_maxammo, 0, 0, color, autocvar_hud_progressbar_alpha * panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1007 if(autocvar_hud_panel_ammo_text)
1010 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1011 else // "ghost" ammo count
1012 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1015 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1016 else // "ghost" ammo icon
1017 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1022 if(!autocvar__hud_configure)
1024 if(!autocvar_hud_panel_ammo) return;
1025 if(spectatee_status == -1) return;
1028 hud_configure_active_panel = HUD_PANEL_AMMO;
1030 HUD_Panel_UpdateCvars(ammo);
1033 mySize = panel_size;
1035 HUD_Panel_DrawBg(1);
1036 if(panel_bg_padding)
1038 pos += '1 1 0' * panel_bg_padding;
1039 mySize -= '2 2 0' * panel_bg_padding;
1042 float rows, columns, row, column;
1044 if (autocvar_hud_panel_ammo_onlycurrent)
1048 rows = mySize_y/mySize_x;
1049 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1050 // ^^^ ammo item aspect goes here
1052 columns = ceil(AMMO_COUNT/rows);
1054 ammo_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
1059 if(ammo_size_x/ammo_size_y > 3)
1061 newSize = 3 * ammo_size_y;
1062 offset_x = ammo_size_x - newSize;
1063 pos_x += offset_x/2;
1064 ammo_size_x = newSize;
1068 newSize = 1/3 * ammo_size_x;
1069 offset_y = ammo_size_y - newSize;
1070 pos_y += offset_y/2;
1071 ammo_size_y = newSize;
1074 float i, stat_items, currently_selected;
1075 if (autocvar_hud_panel_ammo_onlycurrent)
1077 if(autocvar__hud_configure)
1079 DrawAmmoItem(pos, ammo_size, 2, true); //show rockets
1082 stat_items = getstati(STAT_ITEMS);
1083 for (i = 0; i < AMMO_COUNT; ++i) {
1084 currently_selected = stat_items & GetAmmoItemCode(i);
1085 if (currently_selected)
1087 DrawAmmoItem(pos, ammo_size, i, true);
1091 return; // nothing to display
1094 stat_items = getstati(STAT_ITEMS);
1095 for (i = 0; i < AMMO_COUNT; ++i) {
1096 currently_selected = stat_items & GetAmmoItemCode(i);
1097 DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected);
1102 column = column + 1;
1107 void DrawNumIcon(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float alpha)
1109 vector newPos, newSize;
1110 vector picpos, numpos;
1114 if(mySize_y/mySize_x > 2)
1116 newSize_y = 2 * mySize_x;
1117 newSize_x = mySize_x;
1119 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1124 newSize_x = 1/2 * mySize_y;
1125 newSize_y = mySize_y;
1127 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1131 if(icon_right_align)
1134 picpos = newPos + eY * newSize_x;
1139 numpos = newPos + eY * newSize_x;
1143 drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1144 // make number smaller than icon, it looks better
1145 // reduce only y to draw numbers with different number of digits with the same y size
1146 numpos_y += newSize_y * ((1 - 0.7) / 2);
1148 drawstring_aspect(numpos, ftos(x), newSize, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1152 if(mySize_x/mySize_y > 3)
1154 newSize_x = 3 * mySize_y;
1155 newSize_y = mySize_y;
1157 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1162 newSize_y = 1/3 * mySize_x;
1163 newSize_x = mySize_x;
1165 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1169 if(icon_right_align) // right align
1172 picpos = newPos + eX * 2 * newSize_y;
1176 numpos = newPos + eX * newSize_y;
1180 drawstring_aspect(numpos, ftos(x), '2 1 0' * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1181 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1184 void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float fadelerp)
1187 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
1189 DrawNumIcon(myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, vertical, icon_right_align, color, (1 - fadelerp));
1194 void HUD_Powerups(void)
1196 float strength_time, shield_time;
1197 if(!autocvar__hud_configure)
1199 if(!autocvar_hud_panel_powerups) return;
1200 if(spectatee_status == -1) return;
1201 if not(getstati(STAT_ITEMS) & (IT_STRENGTH | IT_INVINCIBLE)) return;
1202 if (getstati(STAT_HEALTH) <= 0) return;
1204 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1205 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1209 hud_configure_active_panel = HUD_PANEL_POWERUPS;
1215 HUD_Panel_UpdateCvars(powerups);
1218 mySize = panel_size;
1220 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
1221 if(panel_bg_padding)
1223 pos += '1 1 0' * panel_bg_padding;
1224 mySize -= '2 2 0' * panel_bg_padding;
1227 float panel_ar = mySize_x/mySize_y;
1228 float is_vertical = (panel_ar < 1);
1229 vector shield_offset, strength_offset;
1230 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1233 if (autocvar_hud_panel_powerups_flip)
1234 shield_offset_x = mySize_x;
1236 strength_offset_x = mySize_x;
1241 if (autocvar_hud_panel_powerups_flip)
1242 shield_offset_y = mySize_y;
1244 strength_offset_y = mySize_y;
1247 float shield_baralign, strength_baralign;
1248 float shield_iconalign, strength_iconalign;
1249 if (autocvar_hud_panel_powerups_flip)
1251 strength_baralign = (autocvar_hud_panel_powerups_baralign == 2 || autocvar_hud_panel_powerups_baralign == 1);
1252 shield_baralign = (autocvar_hud_panel_powerups_baralign == 3 || autocvar_hud_panel_powerups_baralign == 1);
1253 strength_iconalign = (autocvar_hud_panel_powerups_iconalign == 2 || autocvar_hud_panel_powerups_iconalign == 1);
1254 shield_iconalign = (autocvar_hud_panel_powerups_iconalign == 3 || autocvar_hud_panel_powerups_iconalign == 1);
1258 shield_baralign = (autocvar_hud_panel_powerups_baralign == 2 || autocvar_hud_panel_powerups_baralign == 1);
1259 strength_baralign = (autocvar_hud_panel_powerups_baralign == 3 || autocvar_hud_panel_powerups_baralign == 1);
1260 shield_iconalign = (autocvar_hud_panel_powerups_iconalign == 2 || autocvar_hud_panel_powerups_iconalign == 1);
1261 strength_iconalign = (autocvar_hud_panel_powerups_iconalign == 3 || autocvar_hud_panel_powerups_iconalign == 1);
1266 const float maxshield = 30;
1267 float shield = ceil(shield_time);
1268 if(autocvar_hud_panel_powerups_progressbar)
1270 HUD_Panel_GetProgressBarColor(shield);
1271 HUD_Panel_DrawProgressBar(pos + shield_offset, mySize, autocvar_hud_panel_powerups_progressbar_shield, shield/maxshield, is_vertical, shield_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1273 if(autocvar_hud_panel_powerups_text)
1276 DrawNumIcon(pos + shield_offset, mySize, shield, "shield", is_vertical, shield_iconalign, '1 1 1', 1);
1278 DrawNumIcon_expanding(pos + shield_offset, mySize, shield, "shield", is_vertical, shield_iconalign, '1 1 1', bound(0, (shield - shield_time) / 0.5, 1));
1284 const float maxstrength = 30;
1285 float strength = ceil(strength_time);
1286 if(autocvar_hud_panel_powerups_progressbar)
1288 HUD_Panel_GetProgressBarColor(strength);
1289 HUD_Panel_DrawProgressBar(pos + strength_offset, mySize, autocvar_hud_panel_powerups_progressbar_strength, strength/maxstrength, is_vertical, strength_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
1291 if(autocvar_hud_panel_powerups_text)
1294 DrawNumIcon(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', 1);
1296 DrawNumIcon_expanding(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', bound(0, (strength - strength_time) / 0.5, 1));
1301 // Health/armor (#3)
1304 // prev_* vars contain the health/armor at the previous FRAME
1305 float prev_health, prev_armor;
1307 // *_time vars contain time at which damage happened
1308 // health_time -1 remembers that player was dead
1309 float health_time, armor_time;
1311 // saved_* vars contain the old health/armor value (before the damage happened)
1313 // -2: during the load effect (spawning)
1314 // -1: load or damage effect are ended normally
1315 // 0: when effects are forcedly stopped; this is to avoid unintended effects as soon as we switch spectated player (e.g. from playerX: 70h to playerY: 50h)
1316 var float saved_health = -2;
1317 var float saved_armor = -2;
1320 float old_healthtime;
1321 float last_p_health;
1323 void HUD_HealthArmor(void)
1325 float armor, health, fuel;
1326 if(!autocvar__hud_configure)
1328 if(!autocvar_hud_panel_healtharmor) return;
1329 if(spectatee_status == -1) return;
1331 health = getstati(STAT_HEALTH);
1338 // code to check for spectatee_status changes is in Ent_ClientData()
1340 if (health_time == -1)
1342 //start the load effect
1350 armor = getstati(STAT_ARMOR);
1351 fuel = getstati(STAT_FUEL);
1355 hud_configure_active_panel = HUD_PANEL_HEALTHARMOR;
1362 HUD_Panel_UpdateCvars(healtharmor);
1365 mySize = panel_size;
1367 HUD_Panel_DrawBg(1);
1368 if(panel_bg_padding)
1370 pos += '1 1 0' * panel_bg_padding;
1371 mySize -= '2 2 0' * panel_bg_padding;
1374 float baralign = autocvar_hud_panel_healtharmor_baralign;
1375 float iconalign = autocvar_hud_panel_healtharmor_iconalign;
1377 float maxhealth = autocvar_hud_panel_healtharmor_maxhealth;
1378 float maxarmor = autocvar_hud_panel_healtharmor_maxarmor;
1379 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
1382 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1387 float maxtotal = maxhealth + maxarmor;
1389 if(v_z) // NOT fully armored
1391 biggercount = "health";
1392 if(autocvar_hud_panel_healtharmor_progressbar)
1394 HUD_Panel_GetProgressBarColor(health);
1395 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);
1398 if(autocvar_hud_panel_healtharmor_text)
1399 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);
1403 biggercount = "armor";
1404 if(autocvar_hud_panel_healtharmor_progressbar)
1406 HUD_Panel_GetProgressBarColor(armor);
1407 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);
1410 if(autocvar_hud_panel_healtharmor_text)
1411 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);
1413 if(autocvar_hud_panel_healtharmor_text)
1414 DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, maxtotal), 1);
1418 HUD_Panel_GetProgressBarColor(fuel);
1419 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);
1424 float panel_ar = mySize_x/mySize_y;
1425 float is_vertical = (panel_ar < 1);
1426 vector health_offset, armor_offset;
1427 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1430 if (autocvar_hud_panel_healtharmor_flip)
1431 health_offset_x = mySize_x;
1433 armor_offset_x = mySize_x;
1438 if (autocvar_hud_panel_healtharmor_flip)
1439 health_offset_y = mySize_y;
1441 armor_offset_y = mySize_y;
1444 float health_baralign, armor_baralign, fuel_baralign;
1445 float health_iconalign, armor_iconalign;
1446 if (autocvar_hud_panel_healtharmor_flip)
1448 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1449 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1450 fuel_baralign = health_baralign;
1451 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1452 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1456 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1457 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1458 fuel_baralign = armor_baralign;
1459 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1460 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1465 if(autocvar_hud_panel_healtharmor_progressbar)
1467 HUD_Panel_GetProgressBarColor(health);
1468 float p_health, pain_health_alpha;
1470 pain_health_alpha = 1;
1471 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1473 if (fabs(prev_health - health) >= 2 && saved_health != -2)
1475 if (time - old_healthtime < 1)
1476 old_health = last_p_health;
1478 old_health = prev_health;
1479 old_healthtime = time;
1481 if (time - old_healthtime < 1)
1483 p_health += (old_health - health) * (1 - (time - old_healthtime));
1484 last_p_health = p_health;
1486 if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0 && saved_health == -1)
1488 if (prev_health == 0 || prev_health - health >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
1491 saved_health = prev_health;
1494 if (saved_health != -1)
1496 float d = time - health_time;
1499 if (saved_health == -2)
1500 p_health *= sqrt(d);
1503 HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, saved_health/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * (1 - d * d), DRAWFLAG_NORMAL);
1504 if (prev_health - health >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage) //refresh the effect if repeatedly damaged
1509 saved_health = -1; //damage effect ended
1511 prev_health = health;
1513 if (health <= 40 && saved_health != -2)
1515 float BLINK_FACTOR = 0.15;
1516 float BLINK_BASE = 0.85;
1517 float BLINK_FREQ = 9;
1518 pain_health_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
1521 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);
1523 if(autocvar_hud_panel_healtharmor_text)
1524 DrawNumIcon(pos + health_offset, mySize, health, "health", is_vertical, health_iconalign, HUD_Get_Num_Color(health, maxhealth), 1);
1529 if(autocvar_hud_panel_healtharmor_progressbar)
1531 HUD_Panel_GetProgressBarColor(armor);
1534 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1536 if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0 && saved_armor == -1)
1538 if (prev_armor == 0 || prev_armor - armor >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
1541 saved_armor = prev_armor;
1544 if (saved_armor != -1)
1546 float d = time - armor_time;
1549 if (saved_armor == -2)
1553 HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, saved_armor/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * (1 - d * d), DRAWFLAG_NORMAL);
1554 if (prev_armor - armor >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage) //refresh the effect if repeatedly damaged
1559 saved_armor = -1; //damage effect ended
1563 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);
1565 if(autocvar_hud_panel_healtharmor_text)
1566 DrawNumIcon(pos + armor_offset, mySize, armor, "armor", is_vertical, armor_iconalign, HUD_Get_Num_Color(armor, maxarmor), 1);
1572 mySize_x *= 0.2 / 2; //if vertical always halve x to not cover too much numbers with 3 digits
1576 mySize_x *= 2; //restore full panel size
1577 else if (panel_ar < 1/4)
1578 mySize_y *= 2; //restore full panel size
1579 HUD_Panel_GetProgressBarColor(fuel);
1580 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
1585 // Notification area (#4)
1588 string Weapon_SuicideMessage(float deathtype)
1590 w_deathtype = deathtype;
1591 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
1592 return w_deathtypestring;
1595 string Weapon_KillMessage(float deathtype)
1597 w_deathtype = deathtype;
1598 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
1599 return w_deathtypestring;
1602 #define KN_MAX_ENTRIES 10
1604 float killnotify_times[KN_MAX_ENTRIES];
1605 float killnotify_deathtype[KN_MAX_ENTRIES];
1606 float killnotify_actiontype[KN_MAX_ENTRIES]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
1607 string killnotify_attackers[KN_MAX_ENTRIES];
1608 string killnotify_victims[KN_MAX_ENTRIES];
1609 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
1613 kn_index = KN_MAX_ENTRIES-1;
1614 killnotify_times[kn_index] = time;
1615 killnotify_deathtype[kn_index] = wpn;
1616 killnotify_actiontype[kn_index] = actiontype;
1617 if(killnotify_attackers[kn_index])
1618 strunzone(killnotify_attackers[kn_index]);
1619 killnotify_attackers[kn_index] = strzone(attacker);
1620 if(killnotify_victims[kn_index])
1621 strunzone(killnotify_victims[kn_index]);
1622 killnotify_victims[kn_index] = strzone(victim);
1625 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
1628 float alsoprint, gentle;
1629 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
1630 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
1632 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
1635 if(msg == MSG_SUICIDE) {
1636 w = DEATH_WEAPONOF(type);
1638 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1640 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
1641 } else if (type == DEATH_KILL) {
1642 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
1644 print (sprintf(_("^1%s^1 couldn't take it anymore\n"), s1));
1645 } else if (type == DEATH_ROT) {
1646 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1648 print (sprintf(_("^1%s^1 died\n"), s1));
1649 } else if (type == DEATH_NOAMMO) {
1650 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
1652 print (sprintf(_("^7%s^7 committed suicide. What's the point of living without ammo?\n"), s1));
1653 } else if (type == DEATH_CAMP) {
1654 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
1656 print (sprintf(_("^1%s^1 thought they found a nice camping ground\n"), s1));
1657 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
1658 HUD_KillNotify_Push(s1, "", 0, type);
1660 print (sprintf(_("^1%s^1 didn't become friends with the Lord of Teamplay\n"), s1));
1661 } else if (type == DEATH_CHEAT) {
1662 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1664 print (sprintf(_("^1%s^1 unfairly eliminated themself\n"), s1));
1665 } else if (type == DEATH_FIRE) {
1666 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1668 print (sprintf(_("^1%s^1 burned to death\n"), s1));
1669 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
1670 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1672 print (sprintf(_("^1%s^1 couldn't resist the urge to self-destruct\n"), s1));
1675 if (stof(s2) > 2) // killcount > 2
1676 print (sprintf(_("^1%s^1 ended it all after a %d kill spree\n"), s1, stof(s2)));
1677 } else if(msg == MSG_KILL) {
1678 w = DEATH_WEAPONOF(type);
1680 if((w == WEP_SNIPERRIFLE || w == WEP_MINSTANEX) && type & HITTYPE_HEADSHOT) // all headshot weapons go here
1681 HUD_KillNotify_Push(s1, s2, 1, DEATH_HEADSHOT);
1683 HUD_KillNotify_Push(s1, s2, 1, type);
1686 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
1688 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
1689 HUD_KillNotify_Push(s1, s2, 1, type);
1693 print (sprintf(_("^1%s^1 took action against a team mate\n"), s1));
1695 print (sprintf(_("^1%s^1 mows down a team mate\n"), s1));
1698 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
1700 print (sprintf(_("^1%s^1 ended a %d scoring spree by going against a team mate\n"), s1, stof(s3)));
1702 print (sprintf(_("^1%s^1 ended a %d kill spree by killing a team mate\n"), s1, stof(s3)));
1704 else if (stof(s2) > 2) {
1706 print (sprintf(_("^1%s^1's %s scoring spree was ended by a team mate!\n"), s1, stof(s3)));
1708 print (sprintf(_("^1%s^1's %s kill spree was ended by a team mate!\n"), s1, stof(s3)));
1711 else if(type == KILL_FIRST_BLOOD)
1712 print(sprintf(_("^1%s^1 drew first blood\n"), s1));
1713 else if (type == DEATH_TELEFRAG) {
1714 HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
1716 print (sprintf(_("^1%s^1 tried to occupy %s^1's teleport destination space\n"), s2, s1));
1718 print (sprintf(_("^1%s^1 was telefragged by %s\n"), s2, s1));
1720 else if (type == DEATH_DROWN) {
1721 HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN);
1723 print (sprintf(_("^1%s^1 was drowned by %s\n"), s2, s1));
1725 else if (type == DEATH_SLIME) {
1726 HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME);
1728 print (sprintf(_("^1%s^1 was slimed by %s\n"), s2, s1));
1730 else if (type == DEATH_LAVA) {
1731 HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA);
1733 print (sprintf(_("^1%s^1 was cooked by %s\n"), s2, s1));
1735 else if (type == DEATH_FALL) {
1736 HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL);
1738 print (sprintf(_("^1%s^1 was grounded by %s\n"), s2, s1));
1740 else if (type == DEATH_SHOOTING_STAR) {
1741 HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR);
1743 print (sprintf(_("^1%s^1 was shot into space by %s\n"), s2, s1));
1745 else if (type == DEATH_SWAMP) {
1746 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1748 print (sprintf(_("^1%s^1 was conserved by %s\n"), s2, s1));
1750 else if (type == DEATH_HURTTRIGGER)
1752 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1754 print(sprintf(_("^1%s^1 was thrown into a world of hurt by %s\n"), s2, s1));
1755 } else if(type == DEATH_SBCRUSH) {
1756 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1758 print (sprintf(_("^1%s^1 was crushed by %s\n"), s2, s1));
1759 } else if(type == DEATH_SBMINIGUN) {
1760 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1762 print (sprintf(_("^1%s^1 got shredded by %s\n"), s2, s1));
1763 } else if(type == DEATH_SBROCKET) {
1764 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1766 print (sprintf(_("^1%s^1 was blasted to bits by %s\n"), s2, s1));
1767 } else if(type == DEATH_SBBLOWUP) {
1768 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1770 print (sprintf(_("^1%s^1 got caught in the destruction of %s^1's vehicle\n"), s2, s1));
1771 } else if(type == DEATH_WAKIGUN) {
1772 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1774 print (sprintf(_("^1%s^1 was bolted down by %s\n"), s2, s1));
1775 } else if(type == DEATH_WAKIROCKET) {
1776 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1778 print (sprintf(_("^1%s^1 could find no shelter from %s^1's rockets\n"), s2, s1));
1779 } else if(type == DEATH_WAKIBLOWUP) {
1780 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1782 print (sprintf(_("^1%s^1 dies when %s^1's wakizashi dies.\n"), s2, s1));
1783 } else if(type == DEATH_TURRET) {
1784 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1786 print (sprintf(_("^1%s^1 was pushed into the line of fire by %s\n"), s2, s1));
1787 } else if(type == DEATH_TOUCHEXPLODE) {
1788 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1790 print (sprintf(_("^1%s^1 was pushed into an accident by %s\n"), s2, s1));
1791 } else if(type == DEATH_CHEAT) {
1792 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1794 print (sprintf(_("^1%s^1 was unfairly eliminated by %s\n"), s2, s1));
1795 } else if (type == DEATH_FIRE) {
1796 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1798 print (sprintf(_("^1%s^1 was burnt to death by %s\n"), s2, s1));
1799 } else if (type == DEATH_CUSTOM) {
1800 HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
1802 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1803 } else if (type == DEATH_HURTTRIGGER) {
1804 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1806 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1808 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1810 print (sprintf(_("^1%s^1 was fragged by %s\n"), s2, s1));
1812 } else if(msg == MSG_SPREE) {
1813 if(type == KILL_END_SPREE) {
1815 print (sprintf(_("^1%s^1's %s scoring spree was ended by %s\n"), s1, s2, s3));
1817 print (sprintf(_("^1%s^1's %s kill spree was ended by %s\n"), s1, s2, s3));
1818 } else if(type == KILL_SPREE) {
1820 print (sprintf(_("^1%s^1 made %s scores in a row\n"), s1, s2));
1822 print (sprintf(_("^1%s^1 has %s frags in a row\n"), s1, s2));
1823 } else if(type == KILL_SPREE_3) {
1825 print (sprintf(_("%s^7 made a ^1TRIPLE SCORE\n"), s1));
1827 print (sprintf(_("%s^7 made a ^1TRIPLE FRAG\n"), s1));
1828 } else if(type == KILL_SPREE_5) {
1830 print (sprintf(_("%s^7 unleashes ^1SCORING RAGE\n"), s1));
1832 print (sprintf(_("%s^7 unleashes ^1RAGE\n"), s1));
1833 } else if(type == KILL_SPREE_10) {
1835 print (sprintf(_("%s^7 made ^1TEN SCORES IN A ROW!\n"), s1));
1837 print (sprintf(_("%s^7 starts the ^1MASSACRE!\n"), s1));
1838 } else if(type == KILL_SPREE_15) {
1840 print (sprintf(_("%s^7 made ^1FIFTEEN SCORES IN A ROW!\n"), s1));
1842 print (sprintf(_("%s^7 executes ^1MAYHEM!\n"), s1));
1843 } else if(type == KILL_SPREE_20) {
1845 print (sprintf(_("%s^7 made ^1TWENTY SCORES IN A ROW!\n"), s1));
1847 print (sprintf(_("%s^7 is a ^1BERSERKER!\n"), s1));
1848 } else if(type == KILL_SPREE_25) {
1850 print (sprintf(_("%s^7 made ^1TWENTY FIFE SCORES IN A ROW!\n"), s1));
1852 print (sprintf(_("%s^7 inflicts ^1CARNAGE!\n"), s1));
1853 } else if(type == KILL_SPREE_30) {
1855 print (sprintf(_("%s^7 made ^1THIRTY SCORES IN A ROW!\n"), s1));
1857 print (sprintf(_("%s^7 unleashes ^1ARMAGEDDON!\n"), s1));
1859 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
1860 if (type == DEATH_DROWN) {
1861 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
1865 print (sprintf(_("^1%s^1 was in the water for too long\n"), s1));
1867 print (sprintf(_("^1%s^1 drowned\n"), s1));
1869 } else if (type == DEATH_SLIME) {
1870 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
1872 print (sprintf(_("^1%s^1 was slimed\n"), s1));
1873 } else if (type == DEATH_LAVA) {
1874 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
1878 print (sprintf(_("^1%s^1 found a hot place\n"), s1));
1880 print (sprintf(_("^1%s^1 turned into hot slag\n"), s1));
1882 } else if (type == DEATH_FALL) {
1883 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1887 print (sprintf(_("^1%s^1 tested gravity (and it worked)\n"), s1));
1889 print (sprintf(_("^1%s^1 hit the ground with a crunch\n"), s1));
1891 } else if (type == DEATH_SHOOTING_STAR) {
1892 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
1894 print (sprintf(_("^1%s^1 became a shooting star\n"), s1));
1895 } else if (type == DEATH_SWAMP) {
1896 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1900 print (sprintf(_("^1%s^1 discovered a swamp\n"), s1));
1902 print (sprintf(_("^1%s^1 is now conserved for centuries to come\n"), s1));
1904 } else if(type == DEATH_TURRET) {
1905 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1907 print (sprintf(_("^1%s^1 was mowed down by a turret \n"), s1));
1908 } else if (type == DEATH_CUSTOM) {
1909 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
1911 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1912 } else if (type == DEATH_HURTTRIGGER) {
1913 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
1915 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1916 } else if(type == DEATH_TOUCHEXPLODE) {
1917 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1919 print (sprintf(_("^1%s^1 died in an accident\n"), s1));
1920 } else if(type == DEATH_CHEAT) {
1921 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1923 print (sprintf(_("^1%s^1 was unfairly eliminated\n"), s1));
1924 } else if(type == DEATH_FIRE) {
1925 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1929 print (sprintf(_("^1%s^1 felt a little hot\n"), s1));
1931 print (sprintf(_("^1%s^1 burnt to death\n"), s1));
1934 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1938 print (sprintf(_("^1%s^1 needs a restart\n"), s1));
1940 print (sprintf(_("^1%s^1 died\n"), s1));
1943 } else if(msg == MSG_KILL_ACTION_SPREE) {
1945 print (sprintf(_("^1%s^1 needs a restart after a %d scoring spree\n"), s1, stof(s2)));
1947 print (sprintf(_("^1%s^1 died with a %d kill spree\n"), s1, stof(s2)));
1948 } else if(msg == MSG_INFO) {
1949 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
1950 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
1951 print(sprintf(_("%s^7 got the %s\n"), s1, s2));
1952 } else if(type == INFO_LOSTFLAG) {
1953 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
1954 print(sprintf(_("%s^7 lost the %s\n"), s1, s2));
1955 } else if(type == INFO_PICKUPFLAG) {
1956 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
1957 print(sprintf(_("%s^7 picked up the %s\n"), s1, s2));
1958 } else if(type == INFO_RETURNFLAG) {
1959 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
1960 print(sprintf(_("%s^7 returned the %s\n"), s1, s2));
1961 } else if(type == INFO_CAPTUREFLAG) {
1962 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
1963 print(sprintf(_("%s^7 captured the %s%s\n"), s1, s2, s3));
1965 } else if(msg == MSG_RACE) {
1966 if(type == RACE_SERVER_RECORD) {
1967 HUD_KillNotify_Push(s1, s2, 1, RACE_SERVER_RECORD);
1969 else if(type == RACE_NEW_RANK) {
1970 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_RANK);
1972 else if(type == RACE_NEW_TIME) {
1973 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_TIME);
1975 else if(type == RACE_FAIL) {
1976 HUD_KillNotify_Push(s1, s2, 1, RACE_FAIL);
1978 } else if(msg == MSG_KA) {
1979 if(type == KA_PICKUPBALL) {
1980 HUD_KillNotify_Push(s1, s2, 0, KA_PICKUPBALL);
1982 print (sprintf(_("%s^7 has picked up the ball!\n"), s1));
1984 else if(type == KA_DROPBALL) {
1985 HUD_KillNotify_Push(s1, s2, 0, KA_DROPBALL);
1987 print(sprintf(_("%s^7 has dropped the ball!\n"), s1));
1992 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
1994 void HUD_Centerprint(string s1, string s2, float type, float msg)
1997 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
1998 if(msg == MSG_SUICIDE) {
1999 if (type == DEATH_TEAMCHANGE) {
2000 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("You are now on: %s"), s1)));
2001 } else if (type == DEATH_AUTOTEAMCHANGE) {
2002 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("You have been moved into a different team to improve team balance\nYou are now on: %s"), s1)));
2003 } else if (type == DEATH_CAMP) {
2005 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Reconsider your tactics, camper!")));
2007 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Die camper!")));
2008 } else if (type == DEATH_NOAMMO) {
2010 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You are reinserted into the game for running out of ammo...")));
2012 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You were killed for running out of ammo...")));
2013 } else if (type == DEATH_ROT) {
2015 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You need to preserve your health")));
2017 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You grew too old without taking your medicine")));
2018 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2020 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Don't go against team mates!")));
2022 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Don't shoot your team mates!")));
2023 } else if (type == DEATH_QUIET) {
2025 } else { // generic message
2027 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You need to be more careful!")));
2029 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You killed your own dumb self!")));
2031 } else if(msg == MSG_KILL) {
2032 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2034 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1Moron! You went against %s, a team mate!"), s1)));
2036 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1Moron! You fragged %s, a team mate!"), s1)));
2038 } else if (type == KILL_FIRST_BLOOD) {
2040 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First score")));
2042 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First blood")));
2044 } else if (type == KILL_FIRST_VICTIM) {
2046 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First casualty")));
2048 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First victim")));
2050 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2052 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You scored against ^7%s^1 who was typing!"), s1), s2));
2054 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You typefragged ^7%s"), s1), s2));
2056 } else if (type == KILL_TYPEFRAGGED) {
2058 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were scored against by ^7%s^1 while you were typing!"), s1), s2));
2060 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were typefragged by ^7%s"), s1), s2));
2062 } else if (type == KILL_FRAG) {
2064 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^4You scored against ^7%s"), s1), s2));
2066 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^4You fragged ^7%s"), s1), s2));
2068 } else { // generic message
2070 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were scored against by ^7%s"), s1), s2));
2072 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were fragged by ^7%s"), s1), s2));
2075 } else if(msg == MSG_KILL_ACTION) {
2076 // TODO: invent more centerprints here?
2077 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Watch your step!")));
2081 void HUD_Notify (void)
2083 if(!autocvar__hud_configure)
2085 if(!autocvar_hud_panel_notify) return;
2088 hud_configure_active_panel = HUD_PANEL_NOTIFY;
2090 HUD_Panel_UpdateCvars(notify);
2093 mySize = panel_size;
2095 HUD_Panel_DrawBg(1);
2096 if(panel_bg_padding)
2098 pos += '1 1 0' * panel_bg_padding;
2099 mySize -= '2 2 0' * panel_bg_padding;
2102 float entries, height;
2103 entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES);
2104 height = mySize_y/entries;
2107 float fontheight = height * autocvar_hud_panel_notify_fontsize;
2108 fontsize = '0.5 0.5 0' * fontheight;
2112 when = autocvar_hud_panel_notify_time;
2114 fadetime = autocvar_hud_panel_notify_fadetime;
2118 vector pos_attacker, pos_victim;
2120 float width_attacker;
2121 string attacker, victim;
2123 float i, j, w, step, limit;
2124 if(autocvar_hud_panel_notify_flip) //order items from the top down
2130 else //order items from the bottom up
2137 for(j = kn_index; i != limit; i += step, ++j)
2139 if(autocvar__hud_configure)
2143 else // inverse order
2144 a = entries - 1 - i;
2145 attacker = textShortenToWidth(sprintf(_("Player %d"), a+1), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2146 victim = textShortenToWidth(sprintf(_("Player %d"), a+2), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2147 s = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname);
2148 a = bound(0, (when - a) / 4, 1);
2149 goto hud_config_notifyprint;
2152 if (j == KN_MAX_ENTRIES)
2155 if(killnotify_times[j] + when > time)
2159 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2173 w = DEATH_WEAPONOF(killnotify_deathtype[j]);
2175 // TODO: maybe print in team colors?
2178 if(killnotify_actiontype[j] == 0)
2180 if(killnotify_deathtype[j] == DEATH_GENERIC)
2184 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2186 s = "notify_outofammo";
2188 else if(killnotify_deathtype[j] == DEATH_KILL)
2190 s = "notify_selfkill";
2192 else if(killnotify_deathtype[j] == DEATH_CAMP)
2194 s = "notify_camping";
2196 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2198 s = "notify_teamkill_red";
2200 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2202 s = "notify_teamkill_blue";
2204 else if(killnotify_deathtype[j] == DEATH_DROWN)
2208 else if(killnotify_deathtype[j] == DEATH_SLIME)
2212 else if(killnotify_deathtype[j] == DEATH_LAVA)
2216 else if(killnotify_deathtype[j] == DEATH_FALL)
2220 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2222 s = "notify_shootingstar";
2224 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2228 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2230 if(killnotify_victims[j] == "^1RED^7 flag")
2232 s = "notify_red_taken";
2236 s = "notify_blue_taken";
2239 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2241 if(killnotify_victims[j] == "^1RED^7 flag")
2243 s = "notify_red_returned";
2247 s = "notify_blue_returned";
2250 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2252 if(killnotify_victims[j] == "^1RED^7 flag")
2254 s = "notify_red_lost";
2258 s = "notify_blue_lost";
2261 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
2263 if(killnotify_victims[j] == "^1RED^7 flag")
2265 s = "notify_red_captured";
2269 s = "notify_blue_captured";
2272 else if(killnotify_deathtype[j] == KA_DROPBALL)
2274 s = "notify_balldropped";
2276 else if(killnotify_deathtype[j] == KA_PICKUPBALL)
2278 s = "notify_ballpickedup";
2281 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2282 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2283 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2287 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2288 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2291 // X [did action to] Y
2294 if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
2296 s = "notify_melee_laser";
2298 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_SHOTGUN)
2300 s = "notify_melee_shotgun";
2302 else if(WEP_VALID(w))
2304 self = get_weaponinfo(w);
2305 s = strcat("weapon", self.netname);
2307 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2309 s = "notify_teamkill_red";
2311 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2313 s = "notify_teamkill_red";
2315 else if(killnotify_deathtype[j] == DEATH_TELEFRAG)
2317 s = "notify_telefrag";
2319 else if(killnotify_deathtype[j] == DEATH_DROWN)
2323 else if(killnotify_deathtype[j] == DEATH_SLIME)
2327 else if(killnotify_deathtype[j] == DEATH_LAVA)
2331 else if(killnotify_deathtype[j] == DEATH_FALL)
2335 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2337 s = "notify_shootingstar";
2339 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2343 else if(killnotify_deathtype[j] == DEATH_HEADSHOT)
2345 s = "notify_headshot";
2347 else if(killnotify_deathtype[j] == RACE_SERVER_RECORD)
2349 s = "race_newrecordserver";
2351 else if(killnotify_deathtype[j] == RACE_NEW_RANK)
2353 s = "race_newrankyellow";
2355 else if(killnotify_deathtype[j] == RACE_NEW_TIME)
2359 else if(killnotify_deathtype[j] == RACE_FAIL)
2364 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2365 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2366 :hud_config_notifyprint
2367 width_attacker = stringwidth(attacker, TRUE, fontsize);
2368 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2369 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2370 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2374 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2375 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2376 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2385 string seconds_tostring(float sec)
2388 minutes = floor(sec / 60);
2390 sec -= minutes * 60;
2391 return sprintf("%d:%02d", minutes, sec);
2394 void HUD_Timer(void)
2396 if(!autocvar__hud_configure)
2398 if(!autocvar_hud_panel_timer) return;
2401 hud_configure_active_panel = HUD_PANEL_TIMER;
2403 HUD_Panel_UpdateCvars(timer);
2406 mySize = panel_size;
2408 HUD_Panel_DrawBg(1);
2409 if(panel_bg_padding)
2411 pos += '1 1 0' * panel_bg_padding;
2412 mySize -= '2 2 0' * panel_bg_padding;
2416 float timelimit, elapsedTime, timeleft, minutesLeft;
2418 timelimit = getstatf(STAT_TIMELIMIT);
2420 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
2421 timeleft = ceil(timeleft);
2423 minutesLeft = floor(timeleft / 60);
2426 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
2427 timer_color = '1 1 1'; //white
2428 else if(minutesLeft >= 1)
2429 timer_color = '1 1 0'; //yellow
2431 timer_color = '1 0 0'; //red
2433 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
2434 if (time < getstatf(STAT_GAMESTARTTIME)) {
2435 //while restart is still active, show 00:00
2436 timer = seconds_tostring(0);
2438 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
2439 timer = seconds_tostring(elapsedTime);
2442 timer = seconds_tostring(timeleft);
2445 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2450 void HUD_Radar(void)
2452 if (!autocvar__hud_configure)
2454 if (autocvar_hud_panel_radar == 0) return;
2455 if (autocvar_hud_panel_radar != 2 && !teamplay) return;
2458 hud_configure_active_panel = HUD_PANEL_RADAR;
2460 HUD_Panel_UpdateCvars(radar);
2463 mySize = panel_size;
2465 HUD_Panel_DrawBg(1);
2466 if(panel_bg_padding)
2468 pos += '1 1 0' * panel_bg_padding;
2469 mySize -= '2 2 0' * panel_bg_padding;
2474 float scale2d, normalsize, bigsize;
2477 teamradar_origin2d = pos + 0.5 * mySize;
2478 teamradar_size2d = mySize;
2480 if(minimapname == "")
2483 teamradar_loadcvars();
2485 switch(hud_panel_radar_zoommode)
2489 f = current_zoomfraction;
2492 f = 1 - current_zoomfraction;
2502 switch(hud_panel_radar_rotation)
2505 teamradar_angle = view_angles_y - 90;
2508 teamradar_angle = 90 * hud_panel_radar_rotation;
2512 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
2513 teamradar_size2d = mySize;
2515 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
2517 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
2518 if(hud_panel_radar_rotation == 0)
2520 // max-min distance must fit the radar in any rotation
2521 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_scale));
2525 vector c0, c1, c2, c3, span;
2526 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
2527 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
2528 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
2529 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
2531 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
2532 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
2534 // max-min distance must fit the radar in x=x, y=y
2536 teamradar_size2d_x * scale2d / (1.05 * span_x),
2537 teamradar_size2d_y * scale2d / (1.05 * span_y)
2541 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
2542 if(bigsize > normalsize)
2543 normalsize = bigsize;
2547 + (1 - f) * normalsize;
2548 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
2550 + (1 - f) * view_origin);
2559 draw_teamradar_background(hud_panel_radar_foreground_alpha);
2561 for(tm = world; (tm = find(tm, classname, "radarlink")); )
2562 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
2563 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
2564 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
2565 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
2567 color2 = GetPlayerColor(tm.sv_entnum);
2568 //if(color == COLOR_SPECTATOR || color == color2)
2569 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
2571 draw_teamradar_player(view_origin, view_angles, '1 1 1');
2573 drawresetcliparea();
2578 void HUD_UpdatePlayerTeams();
2579 void HUD_Score(void)
2581 if(!autocvar__hud_configure)
2583 if(!autocvar_hud_panel_score) return;
2584 if(spectatee_status == -1 && (gametype == GAME_RACE || gametype == GAME_CTS)) return;
2587 hud_configure_active_panel = HUD_PANEL_SCORE;
2589 HUD_Panel_UpdateCvars(score);
2592 mySize = panel_size;
2594 HUD_Panel_DrawBg(1);
2595 if(panel_bg_padding)
2597 pos += '1 1 0' * panel_bg_padding;
2598 mySize -= '2 2 0' * panel_bg_padding;
2601 float score, distribution;
2603 vector distribution_color;
2605 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
2607 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
2608 string timer, distrtimer;
2610 pl = players.sort_next;
2613 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
2614 if(pl.scores[ps_primary] == 0)
2617 score = me.(scores[ps_primary]);
2618 timer = TIME_ENCODED_TOSTRING(score);
2620 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
2621 // distribution display
2622 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2624 distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS);
2626 if (distribution <= 0) {
2627 distribution_color = '0 1 0';
2631 distribution_color = '1 0 0';
2634 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);
2636 // race record display
2637 if (distribution <= 0)
2638 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2639 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2640 } else if (!teamplay) { // non-teamgames
2641 if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings)
2643 #define SCOREPANEL_MAX_ENTRIES 6
2644 #define SCOREPANEL_ASPECTRATIO 2
2645 const float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
2646 const float height = mySize_y/entries;
2647 const vector fontsize = '0.9 0.9 0' * height;
2648 pos_y += height * (1 - 0.9) / 2;
2653 const float name_size = mySize_x*0.75;
2654 const float highlight_alpha = 0.2;
2655 float i, me_printed;
2657 if (autocvar__hud_configure)
2659 score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
2660 for (i=0; i<entries; ++i)
2662 //simulate my score is lower than all displayed players,
2663 //so that I don't appear at all showing pure rankings.
2664 //This is to better show the difference between the 2 ranking views
2665 if (i == entries-1 && autocvar_hud_panel_score_rankings == 1)
2668 drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2669 s = GetPlayerName(pl.sv_entnum);
2674 s = sprintf(_("Player %d"), i+1);
2678 s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
2679 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2680 drawstring(pos + eX * mySize_x*0.79, ftos(score), fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2686 if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
2687 HUD_UpdatePlayerTeams();
2689 for (pl = players.sort_next, i=0; pl && i<entries; pl = pl.sort_next, ++i)
2691 if (pl.team == COLOR_SPECTATOR)
2694 if (i == entries-1 && !me_printed && pl != me)
2695 if (autocvar_hud_panel_score_rankings == 1 && spectatee_status != -1)
2697 for (pl = me.sort_next; pl; pl = pl.sort_next)
2698 if (pl.team != COLOR_SPECTATOR)
2702 rgb = '1 1 0'; //not last but not among the leading players: yellow
2704 rgb = '1 0 0'; //last: red
2711 rgb = '0 1 0'; //first: green
2713 drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2715 s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
2716 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2717 drawstring(pos + eX * mySize_x*0.79, ftos(pl.(scores[ps_primary])), fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2722 // me vector := [team/connected frags id]
2723 pl = players.sort_next;
2727 if(autocvar__hud_configure)
2730 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2734 score = me.(scores[ps_primary]);
2735 if(autocvar__hud_configure)
2738 if(distribution >= 5)
2739 distribution_color = eY;
2740 else if(distribution >= 0)
2741 distribution_color = '1 1 1';
2742 else if(distribution >= -5)
2743 distribution_color = '1 1 0';
2745 distribution_color = eX;
2747 string distribution_str;
2748 distribution_str = ftos(distribution);
2749 if (distribution >= 0)
2751 if (distribution > 0)
2752 distribution_str = strcat("+", distribution_str);
2753 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2755 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2756 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);
2757 } else { // teamgames
2758 float max_fragcount;
2759 max_fragcount = -99;
2761 float scores_count, row, column, rows, columns;
2763 vector score_pos, score_size; //for scores other than myteam
2764 if (spectatee_status == -1)
2766 if (autocvar__hud_configure)
2768 else for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2769 if(tm.team == COLOR_SPECTATOR)
2773 rows = mySize_y/mySize_x;
2774 rows = bound(1, floor((sqrt(4 * (3/1) * rows * scores_count + rows * rows) + rows + 0.5) / 2), scores_count);
2775 // ^^^ ammo item aspect goes here
2777 columns = ceil(scores_count/rows);
2779 score_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
2782 if(score_size_x/score_size_y > 3)
2784 newSize = 3 * score_size_y;
2785 offset_x = score_size_x - newSize;
2786 pos_x += offset_x/2;
2787 score_size_x = newSize;
2791 newSize = 1/3 * score_size_x;
2792 offset_y = score_size_y - newSize;
2793 pos_y += offset_y/2;
2794 score_size_y = newSize;
2798 score_size = eX * mySize_x*(1/4) + eY * mySize_y*(1/3);
2799 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2800 if(tm.team == COLOR_SPECTATOR)
2802 score = tm.(teamscores[ts_primary]);
2803 if(autocvar__hud_configure)
2806 if (score > max_fragcount)
2807 max_fragcount = score;
2809 if (spectatee_status == -1)
2811 score_pos = pos + eX * column * (score_size_x + offset_x) + eY * row * (score_size_y + offset_y);
2812 if (max_fragcount == score)
2813 HUD_Panel_DrawHighlight(score_pos, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2814 drawstring_aspect(score_pos, ftos(score), score_size, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2822 else if(tm.team == myteam) {
2823 if (max_fragcount == score)
2824 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2825 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2827 if (max_fragcount == score)
2828 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);
2829 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);
2838 void HUD_RaceTimer (void)
2840 if(!autocvar__hud_configure)
2842 if(!autocvar_hud_panel_racetimer) return;
2843 if(!(gametype == GAME_RACE || gametype == GAME_CTS)) return;
2844 if(spectatee_status == -1) return;
2847 hud_configure_active_panel = HUD_PANEL_RACETIMER;
2849 HUD_Panel_UpdateCvars(racetimer);
2852 mySize = panel_size;
2854 HUD_Panel_DrawBg(1);
2855 if(panel_bg_padding)
2857 pos += '1 1 0' * panel_bg_padding;
2858 mySize -= '2 2 0' * panel_bg_padding;
2861 // always force 4:1 aspect
2863 if(mySize_x/mySize_y > 4)
2865 newSize_x = 4 * mySize_y;
2866 newSize_y = mySize_y;
2868 pos_x = pos_x + (mySize_x - newSize_x) / 2;
2872 newSize_y = 1/4 * mySize_x;
2873 newSize_x = mySize_x;
2875 pos_y = pos_y + (mySize_y - newSize_y) / 2;
2880 string s, forcetime;
2882 if(autocvar__hud_configure)
2885 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);
2886 s = _("^1Intermediate 1 (+15.42)");
2887 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);
2888 s = sprintf(_("^1PENALTY: %.1f (%s)"), 2, "missing a checkpoint");
2889 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);
2891 else if(race_checkpointtime)
2893 a = bound(0, 2 - (time - race_checkpointtime), 1);
2896 if(a > 0) // just hit a checkpoint?
2898 if(race_checkpoint != 254)
2900 if(race_time && race_previousbesttime)
2901 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
2903 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
2905 forcetime = TIME_ENCODED_TOSTRING(race_time);
2910 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
2912 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
2913 if(a > 0) // next one?
2915 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
2920 if(s != "" && a > 0)
2922 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);
2925 if(race_penaltytime)
2927 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
2930 s = sprintf(_("^1PENALTY: %.1f (%s)"), race_penaltytime * 0.1, race_penaltyreason);
2931 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);
2937 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
2938 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);
2943 if(race_laptime && race_checkpoint != 255)
2945 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
2946 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);
2951 if(race_mycheckpointtime)
2953 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
2954 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
2955 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);
2957 if(race_othercheckpointtime && race_othercheckpointenemy != "")
2959 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
2960 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
2961 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);
2964 if(race_penaltytime && !race_penaltyaccumulator)
2966 t = race_penaltytime * 0.1 + race_penaltyeventtime;
2967 a = bound(0, (1 + t - time), 1);
2971 s = sprintf(_("^1PENALTY: %.1f (%s)"), (t - time) * 0.1, race_penaltyreason);
2973 s = sprintf(_("^2PENALTY: %.1f (%s)"), 0, race_penaltyreason);
2974 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);
2982 float vote_yescount;
2985 float vote_highlighted; // currently selected vote
2987 float vote_active; // is there an active vote?
2988 float vote_prev; // previous state of vote_active to check for a change
2990 float vote_change; // "time" when vote_active changed
2992 void HUD_VoteWindow(void)
2994 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
2997 if (autocvar__hud_configure)
3001 print(_("^1You must answer before entering hud configure mode\n"));
3002 cvar_set("_hud_configure", "0");
3004 vote_called_vote = strzone(_("^2Name ^7instead of \"^1Unregistered player^7\" in stats"));
3005 uid2name_dialog = 1;
3008 if(!autocvar__hud_configure)
3010 if(!autocvar_hud_panel_vote) return;
3012 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
3013 panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
3015 if(panel_bg_alpha_str == "") {
3016 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
3018 panel_bg_alpha = stof(panel_bg_alpha_str);
3022 hud_configure_active_panel = HUD_PANEL_VOTE;
3031 if(vote_active != vote_prev) {
3033 vote_prev = vote_active;
3036 if(vote_active || autocvar__hud_configure)
3037 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3039 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3044 HUD_Panel_UpdateCvars(vote);
3048 panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight;
3049 panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
3052 // these must be below above block
3055 mySize = panel_size;
3057 a = vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3058 HUD_Panel_DrawBg(a);
3059 a = panel_fg_alpha * a;
3061 if(panel_bg_padding)
3063 pos += '1 1 0' * panel_bg_padding;
3064 mySize -= '2 2 0' * panel_bg_padding;
3067 // always force 3:1 aspect
3069 if(mySize_x/mySize_y > 3)
3071 newSize_x = 3 * mySize_y;
3072 newSize_y = mySize_y;
3074 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3078 newSize_y = 1/3 * mySize_x;
3079 newSize_x = mySize_x;
3081 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3085 s = _("A vote has been called for:");
3087 s = _("Allow servers to store and display your name?");
3088 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3089 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1/8), stringwidth_colors);
3090 if(autocvar__hud_configure)
3091 s = _("^1Configure the HUD");
3092 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
3094 // print the yes/no counts
3095 s = sprintf(_("Yes (%s): %d"), getcommandkey("vyes", "vyes"), vote_yescount);
3096 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);
3097 s = sprintf(_("No (%s): %d"), getcommandkey("vno", "vno"), vote_nocount);
3098 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);
3100 // draw the progress bar backgrounds
3101 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3103 // draw the highlights
3104 if(vote_highlighted == 1) {
3105 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3106 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3108 else if(vote_highlighted == 2) {
3109 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3110 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3113 // draw the progress bars
3114 if(vote_yescount && vote_needed)
3116 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3117 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3120 if(vote_nocount && vote_needed)
3122 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3123 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3126 drawresetcliparea();
3129 vote_highlighted = 0;
3133 // Mod icons panel (#10)
3136 float mod_active; // is there any active mod icon?
3138 // Clan Arena HUD modicons
3139 void HUD_Mod_CA(vector pos, vector mySize)
3141 mod_active = 1; // CA should never hide the mod icons panel
3142 float redalive, bluealive;
3143 redalive = getstati(STAT_REDALIVE);
3144 bluealive = getstati(STAT_BLUEALIVE);
3146 vector redpos, bluepos;
3147 if(mySize_x > mySize_y)
3150 bluepos = pos + eY * 0.5 * mySize_y;
3151 drawpic_aspect_skin(redpos, "player_red.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3152 drawstring_aspect(redpos + eX * 0.5 * mySize_x, ftos(redalive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3153 drawpic_aspect_skin(bluepos, "player_blue.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3154 drawstring_aspect(bluepos + eX * 0.5 * mySize_x, ftos(bluealive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3159 bluepos = pos + eY * 0.5 * mySize_y;
3160 drawpic_aspect_skin(redpos, "player_red.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3161 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);
3162 drawpic_aspect_skin(bluepos, "player_blue.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3163 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);
3167 // CTF HUD modicon section
3168 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3169 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3170 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3172 void HUD_Mod_CTF_Reset(void)
3174 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3177 void HUD_Mod_CTF(vector pos, vector mySize)
3179 vector redflag_pos, blueflag_pos;
3181 float f; // every function should have that
3183 float redflag, blueflag; // current status
3184 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3187 stat_items = getstati(STAT_ITEMS);
3188 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3189 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3191 if(redflag || blueflag)
3196 if(autocvar__hud_configure)
3202 // when status CHANGES, set old status into prevstatus and current status into status
3203 if (redflag != redflag_prevframe)
3205 redflag_statuschange_time = time;
3206 redflag_prevstatus = redflag_prevframe;
3207 redflag_prevframe = redflag;
3210 if (blueflag != blueflag_prevframe)
3212 blueflag_statuschange_time = time;
3213 blueflag_prevstatus = blueflag_prevframe;
3214 blueflag_prevframe = blueflag;
3217 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3218 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3220 float BLINK_FACTOR = 0.15;
3221 float BLINK_BASE = 0.85;
3223 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3225 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3227 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3229 string red_icon, red_icon_prevstatus;
3230 float red_alpha, red_alpha_prevstatus;
3231 red_alpha = red_alpha_prevstatus = 1;
3233 case 1: red_icon = "flag_red_taken"; break;
3234 case 2: red_icon = "flag_red_lost"; break;
3235 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3237 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3238 red_icon = "flag_red_shielded";
3240 red_icon = string_null;
3243 switch(redflag_prevstatus) {
3244 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3245 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3246 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3249 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3250 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3251 red_icon_prevstatus = "flag_red_shielded";
3253 red_icon_prevstatus = string_null;
3257 string blue_icon, blue_icon_prevstatus;
3258 float blue_alpha, blue_alpha_prevstatus;
3259 blue_alpha = blue_alpha_prevstatus = 1;
3261 case 1: blue_icon = "flag_blue_taken"; break;
3262 case 2: blue_icon = "flag_blue_lost"; break;
3263 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3265 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3266 blue_icon = "flag_blue_shielded";
3268 blue_icon = string_null;
3271 switch(blueflag_prevstatus) {
3272 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3273 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3274 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3277 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3278 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3279 blue_icon_prevstatus = "flag_blue_shielded";
3281 blue_icon_prevstatus = string_null;
3285 if(mySize_x > mySize_y) {
3286 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3288 blueflag_pos = pos + eX * 0.5 * mySize_x;
3291 redflag_pos = pos + eX * 0.5 * mySize_x;
3293 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3295 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3297 blueflag_pos = pos + eY * 0.5 * mySize_y;
3300 redflag_pos = pos + eY * 0.5 * mySize_y;
3302 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3305 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3306 if(red_icon_prevstatus && f < 1)
3307 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3309 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3311 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3312 if(blue_icon_prevstatus && f < 1)
3313 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3315 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3318 // Keyhunt HUD modicon section
3319 float kh_runheretime;
3321 void HUD_Mod_KH_Reset(void)
3326 void HUD_Mod_KH(vector pos, vector mySize)
3328 mod_active = 1; // keyhunt should never hide the mod icons panel
3332 vector p, pa, kh_size, kh_asize;
3334 kh_keys = getstati(STAT_KH_KEYS);
3337 if(mySize_x > mySize_y)
3339 p_y = pos_y + 0.25 * mySize_y;
3340 pa = p - eY * 0.25 * mySize_y;
3342 kh_size_x = mySize_x * 0.25;
3343 kh_size_y = 0.75 * mySize_y;
3344 kh_asize_x = mySize_x * 0.25;
3345 kh_asize_y = mySize_y * 0.25;
3349 p_y = pos_y + 0.125 * mySize_y;
3350 pa = p - eY * 0.125 * mySize_y;
3352 kh_size_x = mySize_x * 0.5;
3353 kh_size_y = 0.375 * mySize_y;
3354 kh_asize_x = mySize_x * 0.5;
3355 kh_asize_y = mySize_y * 0.125;
3362 for(i = 0; i < 4; ++i)
3364 key = floor(kh_keys / pow(32, i)) & 31;
3366 if(keyteam == 30 && keycount <= 4)
3368 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3372 // this yields 8 exactly if "RUN HERE" shows
3377 kh_runheretime = time;
3378 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3383 for(i = 0; i < 4; ++i)
3385 key = floor(kh_keys / pow(32, i)) & 31;
3398 default: // owned or dropped
3403 a = a * panel_fg_alpha;
3404 aa = aa * panel_fg_alpha;
3410 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3413 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3416 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3419 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3424 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3427 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3430 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3433 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3436 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3440 if(mySize_x > mySize_y)
3442 p_x += 0.25 * mySize_x;
3443 pa_x += 0.25 * mySize_x;
3449 p_y = pos_y + 0.625 * mySize_y;
3450 pa_y = pos_y + 0.5 * mySize_y;
3456 p_x += 0.5 * mySize_x;
3457 pa_x += 0.5 * mySize_x;
3463 // Keepaway HUD mod icon
3464 float kaball_prevstatus; // last remembered status
3465 float kaball_statuschange_time; // time when the status changed
3467 // we don't need to reset for keepaway since it immediately
3468 // autocorrects prevstatus as to if the player has the ball or not
3470 void HUD_Mod_Keepaway(vector pos, vector mySize)
3472 mod_active = 1; // keepaway should always show the mod HUD
3474 float BLINK_FACTOR = 0.15;
3475 float BLINK_BASE = 0.85;
3476 float BLINK_FREQ = 5;
3477 float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
3479 float stat_items = getstati(STAT_ITEMS);
3480 float kaball = (stat_items/IT_KEY1) & 1;
3482 if(kaball != kaball_prevstatus)
3484 kaball_statuschange_time = time;
3485 kaball_prevstatus = kaball;
3488 vector kaball_pos, kaball_size;
3490 if(mySize_x > mySize_y) {
3491 kaball_pos = pos + eX * 0.25 * mySize_x;
3492 kaball_size = eX * 0.5 * mySize_x + eY * mySize_y;
3494 kaball_pos = pos + eY * 0.25 * mySize_y;
3495 kaball_size = eY * 0.5 * mySize_y + eX * mySize_x;
3498 float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
3499 float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
3501 if(kaball_prevstatus && f < 1)
3502 drawpic_aspect_skin_expanding(kaball_pos, "keepawayball_carrying", kaball_size, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
3505 drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
3509 // Nexball HUD mod icon
3510 void HUD_Mod_NexBall(vector pos, vector mySize)
3512 float stat_items, nb_pb_starttime, dt, p;
3514 stat_items = getstati(STAT_ITEMS);
3515 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3517 if (stat_items & IT_KEY1)
3522 //Manage the progress bar if any
3523 if (nb_pb_starttime > 0)
3525 dt = mod(time - nb_pb_starttime, nb_pb_period);
3526 // one period of positive triangle
3527 p = 2 * dt / nb_pb_period;
3532 HUD_Panel_GetProgressBarColor(nexball);
3533 if(mySize_x > mySize_y)
3534 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, 0, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3536 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, 1, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3539 if (stat_items & IT_KEY1)
3540 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3543 // Race/CTS HUD mod icons
3544 float crecordtime_prev; // last remembered crecordtime
3545 float crecordtime_change_time; // time when crecordtime last changed
3546 float srecordtime_prev; // last remembered srecordtime
3547 float srecordtime_change_time; // time when srecordtime last changed
3549 float race_status_time;
3550 float race_status_prev;
3551 string race_status_name_prev;
3552 void HUD_Mod_Race(vector pos, vector mySize)
3554 mod_active = 1; // race should never hide the mod icons panel
3556 me = playerslots[player_localentnum - 1];
3558 float f; // yet another function has this
3559 score = me.(scores[ps_primary]);
3561 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3562 return; // no records in the actual race
3564 // clientside personal record
3566 if(gametype == GAME_CTS)
3570 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3572 if(score && (score < t || !t)) {
3573 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3574 if(autocvar_cl_autodemo_delete_keeprecords)
3576 f = autocvar_cl_autodemo_delete;
3578 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3582 if(t != crecordtime_prev) {
3583 crecordtime_prev = t;
3584 crecordtime_change_time = time;
3587 vector textPos, medalPos;
3589 if(mySize_x > mySize_y) {
3590 // text on left side
3591 squareSize = min(mySize_y, mySize_x/2);
3592 textPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eY * 0.5 * (mySize_y - squareSize);
3593 medalPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eX * 0.5 * mySize_x + eY * 0.5 * (mySize_y - squareSize);
3596 squareSize = min(mySize_x, mySize_y/2);
3597 textPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eX * 0.5 * (mySize_x - squareSize);
3598 medalPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eY * 0.5 * mySize_y + eX * 0.5 * (mySize_x - squareSize);
3601 f = time - crecordtime_change_time;
3604 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3605 drawstring_aspect(textPos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3607 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3608 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);
3609 drawstring_aspect_expanding(pos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
3610 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);
3614 t = race_server_record;
3615 if(t != srecordtime_prev) {
3616 srecordtime_prev = t;
3617 srecordtime_change_time = time;
3619 f = time - srecordtime_change_time;
3622 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3623 drawstring_aspect(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3625 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3626 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);
3627 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);
3628 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);
3631 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
3632 race_status_time = time + 5;
3633 race_status_prev = race_status;
3634 if (race_status_name_prev)
3635 strunzone(race_status_name_prev);
3636 race_status_name_prev = strzone(race_status_name);
3641 a = bound(0, race_status_time - time, 1);
3644 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
3648 rank = race_CheckName(race_status_name);
3650 rankname = race_PlaceName(rank);
3653 namepos = medalPos + '0 0.8 0' * squareSize;
3655 rankpos = medalPos + '0 0.15 0' * squareSize;
3657 if(race_status == 0)
3658 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3659 else if(race_status == 1) {
3660 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);
3661 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3662 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3663 } else if(race_status == 2) {
3664 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
3665 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);
3667 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);
3668 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3669 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3670 } else if(race_status == 3) {
3671 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);
3672 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3673 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3676 if (race_status_time - time <= 0) {
3677 race_status_prev = -1;
3679 if(race_status_name)
3680 strunzone(race_status_name);
3681 race_status_name = string_null;
3682 if(race_status_name_prev)
3683 strunzone(race_status_name_prev);
3684 race_status_name_prev = string_null;
3688 void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, float layout, float i)
3690 float stat, pps_ratio;
3696 stat = getstatf(STAT_DOM_PPS_RED);
3697 pic = "dom_icon_red";
3701 stat = getstatf(STAT_DOM_PPS_BLUE);
3702 pic = "dom_icon_blue";
3706 stat = getstatf(STAT_DOM_PPS_YELLOW);
3707 pic = "dom_icon_yellow";
3711 stat = getstatf(STAT_DOM_PPS_PINK);
3712 pic = "dom_icon_pink";
3715 pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
3717 if(mySize_x/mySize_y > aspect_ratio)
3719 i = aspect_ratio * mySize_y;
3720 myPos_x = myPos_x + (mySize_x - i) / 2;
3725 i = 1/aspect_ratio * mySize_x;
3726 myPos_y = myPos_y + (mySize_y - i) / 2;
3730 if (layout) // show text too
3733 color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
3734 if (layout == 2) // average pps
3735 drawstring_aspect(myPos + eX * mySize_y, ftos_decimals(stat, 2), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
3736 else // percentage of average pps
3737 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);
3741 drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3744 drawsetcliparea(myPos_x, myPos_y + mySize_y * (1 - pps_ratio), mySize_y, mySize_y * pps_ratio);
3745 drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3746 drawresetcliparea();
3750 void HUD_Mod_Dom(vector myPos, vector mySize)
3752 mod_active = 1; // required in each mod function that always shows something
3755 for(tm = teams.sort_next; tm; tm = tm.sort_next)
3756 if(tm.team != COLOR_SPECTATOR)
3759 float layout = autocvar_hud_panel_modicons_dom_layout;
3760 float rows, columns, aspect_ratio;
3761 rows = mySize_y/mySize_x;
3762 aspect_ratio = (layout) ? 3 : 1;
3763 rows = bound(1, floor((sqrt((4 * aspect_ratio * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count);
3764 columns = ceil(teams_count/rows);
3768 for(i=0; i<teams_count; ++i)
3770 vector pos, itemSize;
3771 pos = myPos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows);
3772 itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
3774 DrawDomItem(pos, itemSize, aspect_ratio, layout, i);
3785 float mod_prev; // previous state of mod_active to check for a change
3787 float mod_change; // "time" when mod_active changed
3789 void HUD_ModIcons(void)
3791 if(!autocvar__hud_configure)
3793 if(!autocvar_hud_panel_modicons) return;
3794 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;
3797 hud_configure_active_panel = HUD_PANEL_MODICONS;
3799 HUD_Panel_UpdateCvars(modicons);
3802 mySize = panel_size;
3804 if(mod_active != mod_prev) {
3806 mod_prev = mod_active;
3809 if(mod_active || autocvar__hud_configure)
3810 mod_alpha = bound(0, (time - mod_change) * 2, 1);
3812 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
3815 HUD_Panel_DrawBg(mod_alpha);
3817 if(panel_bg_padding)
3819 pos += '1 1 0' * panel_bg_padding;
3820 mySize -= '2 2 0' * panel_bg_padding;
3823 // these MUST be ran in order to update mod_active
3824 if(gametype == GAME_KEYHUNT)
3825 HUD_Mod_KH(pos, mySize);
3826 else if(gametype == GAME_CTF || autocvar__hud_configure)
3827 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
3828 else if(gametype == GAME_NEXBALL)
3829 HUD_Mod_NexBall(pos, mySize);
3830 else if(gametype == GAME_CTS || gametype == GAME_RACE)
3831 HUD_Mod_Race(pos, mySize);
3832 else if(gametype == GAME_CA || gametype == GAME_FREEZETAG)
3833 HUD_Mod_CA(pos, mySize);
3834 else if(gametype == GAME_DOMINATION)
3835 HUD_Mod_Dom(pos, mySize);
3836 else if(gametype == GAME_KEEPAWAY)
3837 HUD_Mod_Keepaway(pos, mySize);
3840 // Draw pressed keys (#11)
3842 void HUD_DrawPressedKeys(void)
3844 if(!autocvar__hud_configure)
3846 if(!autocvar_hud_panel_pressedkeys) return;
3847 if(spectatee_status <= 0 && autocvar_hud_panel_pressedkeys < 2) return;
3850 hud_configure_active_panel = HUD_PANEL_PRESSEDKEYS;
3853 HUD_Panel_UpdateCvars(pressedkeys);
3856 mySize = panel_size;
3858 HUD_Panel_DrawBg(1);
3859 if(panel_bg_padding)
3861 pos += '1 1 0' * panel_bg_padding;
3862 mySize -= '2 2 0' * panel_bg_padding;
3865 // force custom aspect
3866 float aspect = autocvar_hud_panel_pressedkeys_aspect;
3870 if(mySize_x/mySize_y > aspect)
3872 newSize_x = aspect * mySize_y;
3873 newSize_y = mySize_y;
3875 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3879 newSize_y = 1/aspect * mySize_x;
3880 newSize_x = mySize_x;
3882 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3888 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
3890 pressedkeys = getstatf(STAT_PRESSED_KEYS);
3892 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3893 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);
3894 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);
3896 drawpic_aspect_skin(pos, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3897 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);
3898 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);
3901 // Handle chat as a panel (#12)
3905 if(!autocvar__hud_configure)
3907 if (!autocvar_hud_panel_chat)
3909 if (!autocvar_con_chatrect)
3910 cvar_set("con_chatrect", "0");
3915 hud_configure_active_panel = HUD_PANEL_CHAT;
3917 HUD_Panel_UpdateCvars(chat);
3919 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
3921 panel_pos_y = panel_bg_border;
3922 panel_size_y = vid_conheight - panel_bg_border * 2;
3923 if(panel_bg == "0") // force a border when maximized
3925 if(precache_pic(panel_bg) == "") {
3926 panel_bg = strcat(hud_skin_path, "/border_default");
3927 if(precache_pic(panel_bg) == "") {
3928 panel_bg = "gfx/hud/default/border_default";
3932 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an alpha of at least 0.75
3937 mySize = panel_size;
3939 HUD_Panel_DrawBg(1);
3941 if(panel_bg_padding)
3943 pos += '1 1 0' * panel_bg_padding;
3944 mySize -= '2 2 0' * panel_bg_padding;
3947 if (!autocvar_con_chatrect)
3948 cvar_set("con_chatrect", "1");
3950 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
3951 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
3953 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
3954 cvar_set("con_chat", ftos(floor(mySize_y/autocvar_con_chatsize - 0.5)));
3956 if(autocvar__hud_configure)
3959 chatsize = '1 1 0' * autocvar_con_chatsize;
3960 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
3962 for(i = 0; i < autocvar_con_chat; ++i)
3964 if(i == autocvar_con_chat - 1)
3967 a = panel_fg_alpha * floor(((i + 1) * 7 + autocvar_con_chattime)/45);
3968 drawcolorcodedstring(pos, textShortenToWidth(_("^3Player^7: This is the chat area."), mySize_x, chatsize, stringwidth_colors), chatsize, a, DRAWFLAG_NORMAL);
3969 pos_y += chatsize_y;
3974 // Engine info panel (#13)
3981 float frametimeavg1; // 1 frame ago
3982 float frametimeavg2; // 2 frames ago
3983 void HUD_EngineInfo(void)
3985 if(!autocvar__hud_configure)
3987 if(!autocvar_hud_panel_engineinfo) return;
3990 hud_configure_active_panel = HUD_PANEL_ENGINEINFO;
3992 HUD_Panel_UpdateCvars(engineinfo);
3995 mySize = panel_size;
3997 HUD_Panel_DrawBg(1);
3998 if(panel_bg_padding)
4000 pos += '1 1 0' * panel_bg_padding;
4001 mySize -= '2 2 0' * panel_bg_padding;
4004 float currentTime = gettime(GETTIME_REALTIME);
4005 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
4007 float currentframetime = currentTime - prevfps_time;
4008 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4009 frametimeavg2 = frametimeavg1;
4010 frametimeavg1 = frametimeavg;
4013 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4014 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.
4016 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
4017 prevfps = (1/currentframetime);
4018 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"
4020 prevfps_time = currentTime;
4025 if(currentTime - prevfps_time > autocvar_hud_panel_engineinfo_framecounter_time)
4027 prevfps = framecounter/(currentTime - prevfps_time);
4029 prevfps_time = currentTime;
4034 color = HUD_Get_Num_Color (prevfps, 100);
4035 drawstring_aspect(pos, sprintf(_("FPS: %.*f"), autocvar_hud_panel_engineinfo_framecounter_decimals, prevfps), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4038 // Info messages panel (#14)
4040 #define drawInfoMessage(s)\
4041 if(autocvar_hud_panel_infomessages_flip)\
4042 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\
4043 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
4045 void HUD_InfoMessages(void)
4047 if(!autocvar__hud_configure)
4049 if(!autocvar_hud_panel_infomessages) return;
4052 hud_configure_active_panel = HUD_PANEL_INFOMESSAGES;
4054 HUD_Panel_UpdateCvars(infomessages);
4057 mySize = panel_size;
4059 HUD_Panel_DrawBg(1);
4060 if(panel_bg_padding)
4062 pos += '1 1 0' * panel_bg_padding;
4063 mySize -= '2 2 0' * panel_bg_padding;
4066 // always force 5:1 aspect
4068 if(mySize_x/mySize_y > 5)
4070 newSize_x = 5 * mySize_y;
4071 newSize_y = mySize_y;
4073 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4077 newSize_y = 1/5 * mySize_x;
4078 newSize_x = mySize_x;
4080 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4089 fontsize = '0.20 0.20 0' * mySize_y;
4092 if(spectatee_status != 0)
4098 if(!autocvar__hud_configure)
4100 if(spectatee_status && !intermission)
4102 if(spectatee_status == -1)
4103 s = _("^1Observing");
4105 s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(spectatee_status - 1));
4108 if(spectatee_status == -1)
4109 s = sprintf(_("^1Press ^3%s^1 to spectate"), getcommandkey("primary fire", "+fire"));
4111 s = sprintf(_("^1Press ^3%s^1 for another player"), getcommandkey("primary fire", "+fire"));
4114 if(spectatee_status == -1)
4115 s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
4117 s = sprintf(_("^1Press ^3%s^1 to observe"), getcommandkey("secondary fire", "+fire2"));
4120 s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey("server info", "+show_info"));
4123 if(gametype == GAME_ARENA)
4124 s = _("^1Wait for your turn to join");
4125 else if(gametype == GAME_LMS)
4128 sk = playerslots[player_localentnum - 1];
4129 if(sk.(scores[ps_primary]) >= 666)
4130 s = _("^1Match has already begun");
4131 else if(sk.(scores[ps_primary]) > 0)
4132 s = _("^1You have no more lives left");
4134 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
4137 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
4140 //show restart countdown:
4141 if (time < getstatf(STAT_GAMESTARTTIME)) {
4143 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4144 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4145 s = sprintf(_("^1Game starts in ^3%d^1 seconds"), countdown);
4146 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4150 if(warmup_stage && !intermission)
4152 s = _("^2Currently in ^1warmup^2 stage!");
4157 if(mod(time, 1) >= 0.5)
4162 if(ready_waiting && !intermission && !spectatee_status)
4164 if(ready_waiting_for_me)
4167 s = sprintf(_("%sPress ^3%s%s to end warmup"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
4169 s = sprintf(_("%sPress ^3%s%s once you are ready"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
4174 s = _("^2Waiting for others to ready up to end warmup...");
4176 s = _("^2Waiting for others to ready up...");
4180 else if(warmup_stage && !intermission && !spectatee_status)
4182 s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey("ready", "ready"));
4186 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4188 float ts_min, ts_max;
4189 tm = teams.sort_next;
4192 for(; tm.sort_next; tm = tm.sort_next)
4194 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4196 if(!ts_min) ts_min = tm.team_size;
4197 else ts_min = min(ts_min, tm.team_size);
4198 if(!ts_max) ts_max = tm.team_size;
4199 else ts_max = max(ts_max, tm.team_size);
4201 if ((ts_max - ts_min) > 1)
4203 s = strcat(blinkcolor, _("Teamnumbers are unbalanced!"));
4204 tm = GetTeam(myteam, false);
4206 if (tm.team != COLOR_SPECTATOR)
4207 if (tm.team_size == ts_max)
4208 s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey("team menu", "menu_showteamselect"), blinkcolor));
4216 s = _("^7Press ^3ESC ^7to show HUD options.");
4218 s = _("^3Doubleclick ^7a panel for panel-specific options.");
4220 s = _("^3CTRL ^7to disable collision testing, ^3SHIFT ^7and");
4222 s = _("^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.");
4227 // Physics panel (#15)
4229 vector acc_prevspeed;
4230 float acc_prevtime, acc_avg, top_speed, top_speed_time;
4231 void HUD_Physics(void)
4233 if(!autocvar__hud_configure)
4235 if(!autocvar_hud_panel_physics) return;
4236 if(spectatee_status == -1 && autocvar_hud_panel_physics < 2) return;
4239 hud_configure_active_panel = HUD_PANEL_PHYSICS;
4241 HUD_Panel_UpdateCvars(physics);
4243 HUD_Panel_DrawBg(1);
4244 if(panel_bg_padding)
4246 panel_pos += '1 1 0' * panel_bg_padding;
4247 panel_size -= '2 2 0' * panel_bg_padding;
4251 float speed, conversion_factor;
4254 switch(autocvar_hud_panel_physics_speed_unit)
4259 conversion_factor = 1.0;
4263 conversion_factor = 0.0254;
4267 conversion_factor = 0.0254 * 3.6;
4271 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4275 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4279 float max_speed = floor( autocvar_hud_panel_physics_speed_max * conversion_factor + 0.5 );
4280 if (autocvar__hud_configure)
4281 speed = floor( max_speed * 0.65 + 0.5 );
4282 else if(autocvar_hud_panel_physics_speed_vertical)
4283 speed = floor( vlen(pmove_vel) * conversion_factor + 0.5 );
4285 speed = floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 );
4287 //compute acceleration
4288 float acceleration, f;
4289 if (autocvar__hud_configure)
4290 acceleration = autocvar_hud_panel_physics_acceleration_max * 0.3;
4293 // 1 m/s = 0.0254 qu/s; 1 g = 9.80665 m/s^2
4294 f = time - acc_prevtime;
4295 if(autocvar_hud_panel_physics_acceleration_vertical)
4296 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f) * (0.0254 / 9.80665);
4298 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);
4299 acc_prevspeed = pmove_vel;
4300 acc_prevtime = time;
4302 f = bound(0, f * 10, 1);
4303 acc_avg = acc_avg * (1 - f) + acceleration * f;
4307 float panel_ar = panel_size_x/panel_size_y;
4308 vector speed_offset, acceleration_offset;
4311 panel_size_x *= 0.5;
4312 if (autocvar_hud_panel_physics_flip)
4313 speed_offset_x = panel_size_x;
4315 acceleration_offset_x = panel_size_x;
4319 panel_size_y *= 0.5;
4320 if (autocvar_hud_panel_physics_flip)
4321 speed_offset_y = panel_size_y;
4323 acceleration_offset_y = panel_size_y;
4325 float speed_baralign, acceleration_baralign;
4326 if (autocvar_hud_panel_physics_baralign == 1)
4327 acceleration_baralign = speed_baralign = 1;
4328 else if(autocvar_hud_panel_physics_baralign == 4)
4329 acceleration_baralign = speed_baralign = 2;
4330 else if (autocvar_hud_panel_physics_flip)
4332 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 2);
4333 speed_baralign = (autocvar_hud_panel_physics_baralign == 3);
4337 speed_baralign = (autocvar_hud_panel_physics_baralign == 2);
4338 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 3);
4340 if (autocvar_hud_panel_physics_acceleration_progressbar_mode == 0)
4341 acceleration_baralign = 3; //override hud_panel_physics_baralign value for acceleration
4345 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
4347 HUD_Panel_GetProgressBarColor(speed);
4348 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);
4350 vector tmp_offset, tmp_size;
4351 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
4353 tmp_size_x = panel_size_x * 0.75;
4354 tmp_size_y = panel_size_y;
4356 tmp_offset_x = panel_size_x - tmp_size_x;
4359 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4365 tmp_offset_x = tmp_size_x;
4366 if (autocvar_hud_panel_physics_speed_unit_show)
4369 tmp_size_x = panel_size_x * (1 - 0.75);
4370 tmp_size_y = panel_size_y * 0.4;
4371 drawstring_aspect(panel_pos + speed_offset + tmp_offset, unit, tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4375 //compute and draw top speed
4376 if (autocvar_hud_panel_physics_topspeed)
4377 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
4379 if (autocvar__hud_configure)
4381 top_speed = floor( max_speed * 0.75 + 0.5 );
4386 if (speed >= top_speed)
4389 top_speed_time = time;
4393 f = max(1, autocvar_hud_panel_physics_topspeed_time);
4394 // divide by f to make it start from 1
4395 f = cos( ((time - top_speed_time) / f) * PI/2 );
4397 else //hide top speed 0, it would be stupid
4402 //top speed progressbar peak
4403 if(speed < top_speed)
4404 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
4406 float peak_offset_x;
4408 if (speed_baralign == 0)
4409 peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x;
4410 else if (speed_baralign == 1)
4411 peak_offset_x = (1 - min(top_speed, max_speed)/max_speed) * panel_size_x;
4412 else if (speed_baralign == 2)
4413 peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x * 0.5;
4414 //if speed is not 0 the speed progressbar already fetched the color
4416 HUD_Panel_GetProgressBarColor(speed);
4417 peak_size_x = floor(panel_size_x * 0.01 + 1.5);
4418 peak_size_y = panel_size_y;
4419 if (speed_baralign == 2) // draw two peaks, on both sides
4421 drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size_x + peak_offset_x - peak_size_x), peak_size, progressbar_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
4422 drawfill(panel_pos + speed_offset + eX * (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);
4425 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);
4429 tmp_offset_y = panel_size_y * 0.4;
4430 tmp_size_x = panel_size_x * (1 - 0.75);
4431 tmp_size_y = panel_size_y - tmp_offset_y;
4432 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(top_speed), tmp_size, '1 0 0', f * panel_fg_alpha, DRAWFLAG_NORMAL);
4440 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 3)
4442 if (acceleration < 0)
4443 HUD_Panel_GetProgressBarColor(acceleration_neg);
4445 HUD_Panel_GetProgressBarColor(acceleration);
4446 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);
4448 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
4449 drawstring_aspect(panel_pos + acceleration_offset, strcat(ftos_decimals(acceleration, 2), "g"), panel_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4458 void HUD_Reset (void)
4460 // reset gametype specific icons
4461 if(gametype == GAME_KEYHUNT)
4463 else if(gametype == GAME_CTF)
4464 HUD_Mod_CTF_Reset();
4467 #define HUD_DrawPanel(id)\
4469 case (HUD_PANEL_RADAR):\
4470 HUD_Radar(); break;\
4471 case (HUD_PANEL_WEAPONS):\
4472 HUD_Weapons(); break;\
4473 case (HUD_PANEL_AMMO):\
4475 case (HUD_PANEL_POWERUPS):\
4476 HUD_Powerups(); break;\
4477 case (HUD_PANEL_HEALTHARMOR):\
4478 HUD_HealthArmor(); break;\
4479 case (HUD_PANEL_NOTIFY):\
4480 HUD_Notify(); break;\
4481 case (HUD_PANEL_TIMER):\
4482 HUD_Timer(); break;\
4483 case (HUD_PANEL_SCORE):\
4484 HUD_Score(); break;\
4485 case (HUD_PANEL_RACETIMER):\
4486 HUD_RaceTimer(); break;\
4487 case (HUD_PANEL_VOTE):\
4488 HUD_VoteWindow(); break;\
4489 case (HUD_PANEL_MODICONS):\
4490 HUD_ModIcons(); break;\
4491 case (HUD_PANEL_PRESSEDKEYS):\
4492 HUD_DrawPressedKeys(); break;\
4493 case (HUD_PANEL_CHAT):\
4495 case (HUD_PANEL_ENGINEINFO):\
4496 HUD_EngineInfo(); break;\
4497 case (HUD_PANEL_INFOMESSAGES):\
4498 HUD_InfoMessages(); break;\
4499 case (HUD_PANEL_PHYSICS):\
4500 HUD_Physics(); break;\
4501 } ENDS_WITH_CURLY_BRACE
4503 void HUD_Main (void)
4506 // global hud alpha fade
4507 if(menu_enabled == 1)
4510 hud_fade_alpha = (1 - autocvar__menu_alpha);
4512 if(scoreboard_fade_alpha)
4513 hud_fade_alpha = (1 - scoreboard_fade_alpha);
4515 if(intermission == 2) // no hud during mapvote
4517 else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
4520 if(!autocvar__hud_configure && !hud_fade_alpha)
4524 if (hud_skin_path != autocvar_hud_skin)
4527 strunzone(hud_skin_path);
4528 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
4531 // HUD configure visible grid
4532 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4534 hud_configure_gridSize_x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
4535 hud_configure_gridSize_y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
4536 hud_configure_realGridSize_x = hud_configure_gridSize_x * vid_conwidth;
4537 hud_configure_realGridSize_y = hud_configure_gridSize_y * vid_conheight;
4539 for(i = 0; i < 1/hud_configure_gridSize_x; ++i)
4540 drawfill(eX * i * hud_configure_realGridSize_x, eX + eY * vid_conheight, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4542 for(i = 0; i < 1/hud_configure_gridSize_y; ++i)
4543 drawfill(eY * i * hud_configure_realGridSize_y, eY + eX * vid_conwidth, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4546 current_player = (spectatee_status > 0) ? spectatee_status : player_localentnum;
4549 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4553 float hud_dock_color_team = autocvar_hud_dock_color_team;
4554 if((teamplay) && hud_dock_color_team) {
4555 f = stof(getplayerkey(current_player - 1, "colors"));
4556 color = colormapPaletteColor(mod(f, 16), 1) * hud_dock_color_team;
4558 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
4559 color = '1 0 0' * hud_dock_color_team;
4563 string hud_dock_color = autocvar_hud_dock_color;
4564 if(hud_dock_color == "shirt") {
4565 f = stof(getplayerkey(current_player - 1, "colors"));
4566 color = colormapPaletteColor(floor(f / 16), 0);
4568 else if(hud_dock_color == "pants") {
4569 f = stof(getplayerkey(current_player - 1, "colors"));
4570 color = colormapPaletteColor(mod(f, 16), 1);
4573 color = stov(hud_dock_color);
4577 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4578 if(precache_pic(pic) == "") {
4579 pic = strcat(hud_skin_path, "/dock_medium");
4580 if(precache_pic(pic) == "") {
4581 pic = "gfx/hud/default/dock_medium";
4584 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...
4587 // cache the panel order into the panel_order array
4588 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4589 for(i = 0; i < HUD_PANEL_NUM; ++i)
4590 panel_order[i] = -1;
4592 float p_num, warning;
4593 float argc = tokenize_console(autocvar__hud_panelorder);
4594 if (argc > HUD_PANEL_NUM)
4596 //first detect wrong/missing panel numbers
4597 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4598 p_num = stof(argv(i));
4599 if (p_num >= 0 && p_num < HUD_PANEL_NUM) { //correct panel number?
4600 if (panel_order[p_num] == -1) //found for the first time?
4601 s = strcat(s, ftos(p_num), " ");
4602 panel_order[p_num] = 1; //mark as found
4607 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4608 if (panel_order[i] == -1) {
4610 s = strcat(s, ftos(i), " "); //add missing panel number
4614 print(_("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n"));
4616 cvar_set("_hud_panelorder", s);
4617 if(hud_panelorder_prev)
4618 strunzone(hud_panelorder_prev);
4619 hud_panelorder_prev = strzone(s);
4621 //now properly set panel_order
4622 tokenize_console(s);
4623 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4624 panel_order[i] = stof(argv(i));
4628 // draw panels in order specified by panel_order array
4629 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
4630 if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice!
4631 HUD_DrawPanel(panel_order[i]);
4634 // draw chat panel on top if it is maximized
4635 if(autocvar__con_chat_maximized)
4636 HUD_Chat(); // HUD_DrawPanel(HUD_PANEL_CHAT);
4638 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)
4639 localcmd("cmd selectteam auto; cmd join\n");
4641 if(autocvar__hud_configure && tab_panel != -1)
4643 HUD_Panel_UpdatePosSizeForId(tab_panel)
4644 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
4647 hud_configure_prev = autocvar__hud_configure;
4649 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again