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))
432 //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
433 void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, float vertical, float baralign, vector theColor, float theAlpha, float drawflag)
435 if(!length_ratio || !theAlpha)
441 if(length_ratio < -1)
444 else if(length_ratio < 0)
448 vector width, height;
450 pic = strcat(hud_skin_path, "/", pic, "_vertical");
451 if(precache_pic(pic) == "") {
452 pic = "gfx/hud/default/progressbar_vertical";
455 if (baralign == 1) // bottom align
456 theOrigin_y += (1 - length_ratio) * theSize_y;
457 else if (baralign == 2) // center align
458 theOrigin_y += 0.5 * (1 - length_ratio) * theSize_y;
459 else if (baralign == 3) // center align, positive values down, negative up
462 if (length_ratio > 0)
463 theOrigin_y += theSize_y;
466 theOrigin_y += (1 + length_ratio) * theSize_y;
467 length_ratio = -length_ratio;
470 theSize_y *= length_ratio;
473 width = eX * theSize_x;
474 height = eY * theSize_y;
475 if(theSize_y <= theSize_x * 2)
477 // button not high enough
478 // draw just upper and lower part then
479 square = eY * theSize_y * 0.5;
480 bH = eY * (0.25 * theSize_y / (theSize_x * 2));
481 drawsubpic(theOrigin, square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, drawflag);
482 drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, drawflag);
486 square = eY * theSize_x;
487 drawsubpic(theOrigin, width + square, pic, '0 0 0', '1 0.25 0', theColor, theAlpha, drawflag);
488 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5 0', theColor, theAlpha, drawflag);
489 drawsubpic(theOrigin + height - square, width + square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, drawflag);
492 pic = strcat(hud_skin_path, "/", pic);
493 if(precache_pic(pic) == "") {
494 pic = "gfx/hud/default/progressbar";
497 if (baralign == 1) // right align
498 theOrigin_x += (1 - length_ratio) * theSize_x;
499 else if (baralign == 2) // center align
500 theOrigin_x += 0.5 * (1 - length_ratio) * theSize_x;
501 else if (baralign == 3) // center align, positive values on the right, negative on the left
504 if (length_ratio > 0)
505 theOrigin_x += theSize_x;
508 theOrigin_x += (1 + length_ratio) * theSize_x;
509 length_ratio = -length_ratio;
512 theSize_x *= length_ratio;
515 width = eX * theSize_x;
516 height = eY * theSize_y;
517 if(theSize_x <= theSize_y * 2)
519 // button not wide enough
520 // draw just left and right part then
521 square = eX * theSize_x * 0.5;
522 bW = eX * (0.25 * theSize_x / (theSize_y * 2));
523 drawsubpic(theOrigin, square + height, pic, '0 0 0', eY + bW, theColor, theAlpha, drawflag);
524 drawsubpic(theOrigin + square, square + height, pic, eX - bW, eY + bW, theColor, theAlpha, drawflag);
528 square = eX * theSize_y;
529 drawsubpic(theOrigin, height + square, pic, '0 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
530 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0.25 0 0', '0.5 1 0', theColor, theAlpha, drawflag);
531 drawsubpic(theOrigin + width - square, height + square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
536 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
542 pic = strcat(hud_skin_path, "/num_leading");
543 if(precache_pic(pic) == "") {
544 pic = "gfx/hud/default/num_leading";
547 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
548 if(mySize_x/mySize_y > 2)
549 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);
550 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);
555 entity weaponorder[WEP_MAXCOUNT];
556 void weaponorder_swap(float i, float j, entity pass)
560 weaponorder[i] = weaponorder[j];
564 string weaponorder_cmp_str;
565 float weaponorder_cmp(float i, float j, entity pass)
568 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
569 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
570 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)
573 float GetAmmoStat(float i)
577 case 0: return STAT_SHELLS;
578 case 1: return STAT_NAILS;
579 case 2: return STAT_ROCKETS;
580 case 3: return STAT_CELLS;
581 case 4: return STAT_FUEL;
586 float GetAmmoTypeForWep(float i)
590 case WEP_SHOTGUN: return 0;
591 case WEP_UZI: return 1;
592 case WEP_GRENADE_LAUNCHER: return 2;
593 case WEP_MINE_LAYER: return 2;
594 case WEP_ELECTRO: return 3;
595 case WEP_CRYLINK: return 3;
596 case WEP_HLAC: return 3;
597 case WEP_MINSTANEX: return 3;
598 case WEP_NEX: return 3;
599 case WEP_RIFLE: return 1;
600 case WEP_HAGAR: return 2;
601 case WEP_ROCKET_LAUNCHER: return 2;
602 case WEP_SEEKER: return 2;
603 case WEP_FIREBALL: return 4;
604 case WEP_HOOK: return 3;
609 void HUD_Weapons(void)
611 float i, f, screen_ar;
612 float center_x, center_y;
613 if(hud != HUD_NORMAL) return;
614 if(!autocvar__hud_configure)
616 if(!autocvar_hud_panel_weapons) return;
617 if(spectatee_status == -1) return;
620 hud_configure_active_panel = HUD_PANEL_WEAPONS;
622 float timeout = autocvar_hud_panel_weapons_timeout;
623 float timeout_effect_length, timein_effect_length;
624 if (autocvar_hud_panel_weapons_timeout_effect == 0)
626 timeout_effect_length = 0;
627 timein_effect_length = 0;
631 timeout_effect_length = 0.75;
632 timein_effect_length = 0.375;
635 if (timeout && time >= weapontime + timeout + timeout_effect_length && !autocvar__hud_configure)
637 weaponprevtime = time;
641 HUD_Panel_UpdateCvars(weapons);
643 // TODO make this configurable
644 if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
647 if(weaponorder_bypriority)
648 strunzone(weaponorder_bypriority);
649 if(weaponorder_byimpulse)
650 strunzone(weaponorder_byimpulse);
652 weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
653 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
654 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
657 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
659 self = get_weaponinfo(i);
660 if(self.impulse >= 0)
662 weaponorder[weapon_cnt] = self;
666 for(i = weapon_cnt; i < WEP_MAXCOUNT; ++i)
667 weaponorder[i] = NULL;
668 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
670 weaponorder_cmp_str = string_null;
673 float when, fadetime;
674 when = autocvar_hud_panel_weapons_complainbubble_time;
675 fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
676 float weapons_st = getstati(STAT_WEAPONS);
678 if (autocvar_hud_panel_weapons_onlyowned)
680 if(autocvar__hud_configure && menu_enabled != 2)
681 HUD_Panel_DrawBg(1); // also draw the bg of the entire panel
683 vector old_panel_size;
684 for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
686 if(weapons_st & weaponorder[i].weapons)
689 if(!autocvar__hud_configure && (autocvar_hud_panel_weapons_complainbubble && time - complain_weapon_time < when + fadetime))// && complain_weapon >= 0
691 if (weapon_count == 0)
693 // reduce size of the panel
694 if (panel_size_y > panel_size_x)
696 old_panel_size_y = panel_size_y;
697 panel_size_y *= weapon_count / WEP_COUNT;
698 panel_pos_y += (old_panel_size_y - panel_size_y) / 2;
702 old_panel_size_x = panel_size_x;
703 panel_size_x *= weapon_count / WEP_COUNT;
704 panel_pos_x += (old_panel_size_x - panel_size_x) / 2;
708 weapon_count = WEP_COUNT;
710 if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
712 f = (time - (weapontime + timeout)) / timeout_effect_length;
713 if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3)
715 panel_bg_alpha *= (1 - f);
716 panel_fg_alpha *= (1 - f);
718 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
720 f *= f; // for a cooler movement
721 center_x = panel_pos_x + panel_size_x/2;
722 center_y = panel_pos_y + panel_size_y/2;
723 screen_ar = vid_conwidth/vid_conheight;
724 if (center_x/center_y < screen_ar) //bottom left
726 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
727 panel_pos_y += f * (vid_conheight - panel_pos_y);
729 panel_pos_x -= f * (panel_pos_x + panel_size_x);
733 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
734 panel_pos_x += f * (vid_conwidth - panel_pos_x);
736 panel_pos_y -= f * (panel_pos_y + panel_size_y);
739 weaponprevtime = time - (1 - f) * timein_effect_length;
741 else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure)
743 f = (time - weaponprevtime) / timein_effect_length;
744 if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3)
746 panel_bg_alpha *= (f);
747 panel_fg_alpha *= (f);
749 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
751 f *= f; // for a cooler movement
753 center_x = panel_pos_x + panel_size_x/2;
754 center_y = panel_pos_y + panel_size_y/2;
755 screen_ar = vid_conwidth/vid_conheight;
756 if (center_x/center_y < screen_ar) //bottom left
758 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
759 panel_pos_y += f * (vid_conheight - panel_pos_y);
761 panel_pos_x -= f * (panel_pos_x + panel_size_x);
765 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
766 panel_pos_x += f * (vid_conwidth - panel_pos_x);
768 panel_pos_y -= f * (panel_pos_y + panel_size_y);
776 panel_pos += '1 1 0' * panel_bg_padding;
777 panel_size -= '2 2 0' * panel_bg_padding;
780 float weapid, wpnalpha;
782 if(autocvar_hud_panel_weapons_fade)
784 wpnalpha = 3.2 - 2 * (time - weapontime);
785 wpnalpha = bound(0.7, wpnalpha, 1) * panel_fg_alpha;
788 wpnalpha = panel_fg_alpha;
791 float aspect = autocvar_hud_panel_weapons_aspect;
792 rows = panel_size_y/panel_size_x;
793 rows = bound(1, floor((sqrt(4 * aspect * rows * weapon_count + rows * rows) + rows + 0.5) / 2), weapon_count);
795 columns = ceil(weapon_count/rows);
798 float a, type, fullammo;
806 wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
807 float barsize_x, barsize_y, baroffset_x, baroffset_y;
808 if (autocvar_hud_panel_weapons_ammo)
810 ammo_color = stov(autocvar_hud_panel_weapons_ammo_color);
811 ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha;
814 if(wpnsize_x/wpnsize_y > aspect)
816 barsize_x = aspect * wpnsize_y;
817 barsize_y = wpnsize_y;
818 baroffset_x = (wpnsize_x - barsize_x) / 2;
822 barsize_y = 1/aspect * wpnsize_x;
823 barsize_x = wpnsize_x;
824 baroffset_y = (wpnsize_y - barsize_y) / 2;
830 if(autocvar_hud_panel_weapons_accuracy && acc_levels)
832 show_accuracy = true;
833 if (acc_col_x[0] == -1)
834 for (i = 0; i < acc_levels; ++i)
835 acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
838 for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
840 self = weaponorder[i];
841 if (!self || self.impulse < 0)
843 if (autocvar_hud_panel_weapons_onlyowned)
844 if (!((weapons_st & self.weapons) || (self.weapon == complain_weapon && time - complain_weapon_time < when + fadetime && autocvar_hud_panel_weapons_complainbubble)))
845 //if (!autocvar__hud_configure)
847 wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
849 weapid = self.impulse;
851 // draw background behind currently selected weapon
852 if(self.weapon == activeweapon)
853 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
855 // draw the weapon accuracy
858 weapon_stats = weapon_accuracy[self.weapon-WEP_FIRST];
859 if(weapon_stats >= 0)
861 // find the max level lower than weapon_stats
864 while ( j && weapon_stats < acc_lev[j] )
867 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
869 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
871 color = color + factor * (acc_col[j+1] - color);
873 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
877 // draw the weapon icon
878 if(weapons_st & self.weapons)
880 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
882 if(autocvar_hud_panel_weapons_label == 1) // weapon number
883 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
884 else if(autocvar_hud_panel_weapons_label == 2) // bind
885 drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
887 // draw ammo status bar
888 if(autocvar_hud_panel_weapons_ammo && self.weapon != WEP_TUBA && self.weapon != WEP_LASER && self.weapon != WEP_PORTO)
891 type = GetAmmoTypeForWep(self.weapon);
893 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
898 case 0: fullammo = autocvar_hud_panel_weapons_ammo_full_shells; break;
899 case 1: fullammo = autocvar_hud_panel_weapons_ammo_full_nails; break;
900 case 2: fullammo = autocvar_hud_panel_weapons_ammo_full_rockets; break;
901 case 3: fullammo = autocvar_hud_panel_weapons_ammo_full_cells; break;
902 case 4: fullammo = autocvar_hud_panel_weapons_ammo_full_fuel; break;
903 default: fullammo = 60;
907 wpnpos_x + baroffset_x,
908 wpnpos_y + baroffset_y,
909 barsize_x * bound(0, a/fullammo, 1),
911 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, ammo_color, ammo_alpha, DRAWFLAG_NORMAL);
917 // draw a "ghost weapon icon" if you don't have the weapon
920 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
923 // draw the complain message
924 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
928 if(complain_weapon_time + when > time)
931 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
935 if(complain_weapon_time + when > time)
942 if(complain_weapon_type == 0) {
943 s = _("Out of ammo");
944 color = stov(autocvar_hud_panel_weapons_complainbubble_color_outofammo);
946 else if(complain_weapon_type == 1) {
948 color = stov(autocvar_hud_panel_weapons_complainbubble_color_donthave);
951 s = _("Unavailable");
952 color = stov(autocvar_hud_panel_weapons_complainbubble_color_unavailable);
954 float padding = autocvar_hud_panel_weapons_complainbubble_padding;
955 drawpic_aspect_skin(wpnpos + '1 1 0' * padding, "weapon_complainbubble", wpnsize - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
956 drawstring_aspect(wpnpos + '1 1 0' * padding, s, wpnsize - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
972 float GetAmmoItemCode(float i)
976 case 0: return IT_SHELLS;
977 case 1: return IT_NAILS;
978 case 2: return IT_ROCKETS;
979 case 3: return IT_CELLS;
980 case 4: return IT_FUEL;
985 string GetAmmoPicture(float i)
989 case 0: return "ammo_shells";
990 case 1: return "ammo_bullets";
991 case 2: return "ammo_rockets";
992 case 3: return "ammo_cells";
993 case 4: return "ammo_fuel";
998 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
1001 if(autocvar__hud_configure)
1003 currently_selected = (itemcode == 2); //rockets always selected
1004 a = 31 + mod(itemcode*93, 128);
1007 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
1016 if(currently_selected)
1021 vector picpos, numpos;
1022 if(autocvar_hud_panel_ammo_iconalign)
1025 picpos = myPos + eX * 2 * mySize_y;
1029 numpos = myPos + eX * mySize_y;
1033 if (currently_selected)
1034 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1036 if(a > 0 && autocvar_hud_panel_ammo_progressbar)
1037 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);
1039 if(autocvar_hud_panel_ammo_text)
1042 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1043 else // "ghost" ammo count
1044 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1047 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1048 else // "ghost" ammo icon
1049 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1054 if(hud != HUD_NORMAL) return;
1055 if(!autocvar__hud_configure)
1057 if(!autocvar_hud_panel_ammo) return;
1058 if(spectatee_status == -1) return;
1061 hud_configure_active_panel = HUD_PANEL_AMMO;
1063 HUD_Panel_UpdateCvars(ammo);
1066 mySize = panel_size;
1068 HUD_Panel_DrawBg(1);
1069 if(panel_bg_padding)
1071 pos += '1 1 0' * panel_bg_padding;
1072 mySize -= '2 2 0' * panel_bg_padding;
1075 float rows, columns, row, column;
1077 if (autocvar_hud_panel_ammo_onlycurrent)
1081 rows = mySize_y/mySize_x;
1082 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1083 // ^^^ ammo item aspect goes here
1085 columns = ceil(AMMO_COUNT/rows);
1087 ammo_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
1092 if(ammo_size_x/ammo_size_y > 3)
1094 newSize = 3 * ammo_size_y;
1095 offset_x = ammo_size_x - newSize;
1096 pos_x += offset_x/2;
1097 ammo_size_x = newSize;
1101 newSize = 1/3 * ammo_size_x;
1102 offset_y = ammo_size_y - newSize;
1103 pos_y += offset_y/2;
1104 ammo_size_y = newSize;
1107 float i, stat_items, currently_selected;
1108 if (autocvar_hud_panel_ammo_onlycurrent)
1110 if(autocvar__hud_configure)
1112 DrawAmmoItem(pos, ammo_size, 2, true); //show rockets
1115 stat_items = getstati(STAT_ITEMS);
1116 for (i = 0; i < AMMO_COUNT; ++i) {
1117 currently_selected = stat_items & GetAmmoItemCode(i);
1118 if (currently_selected)
1120 DrawAmmoItem(pos, ammo_size, i, true);
1124 return; // nothing to display
1127 stat_items = getstati(STAT_ITEMS);
1128 for (i = 0; i < AMMO_COUNT; ++i) {
1129 currently_selected = stat_items & GetAmmoItemCode(i);
1130 DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected);
1135 column = column + 1;
1140 void DrawNumIcon(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float alpha)
1142 vector newPos, newSize;
1143 vector picpos, numpos;
1147 if(mySize_y/mySize_x > 2)
1149 newSize_y = 2 * mySize_x;
1150 newSize_x = mySize_x;
1152 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1157 newSize_x = 1/2 * mySize_y;
1158 newSize_y = mySize_y;
1160 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1164 if(icon_right_align)
1167 picpos = newPos + eY * newSize_x;
1172 numpos = newPos + eY * newSize_x;
1176 drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1177 // make number smaller than icon, it looks better
1178 // reduce only y to draw numbers with different number of digits with the same y size
1179 numpos_y += newSize_y * ((1 - 0.7) / 2);
1181 drawstring_aspect(numpos, ftos(x), newSize, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1185 if(mySize_x/mySize_y > 3)
1187 newSize_x = 3 * mySize_y;
1188 newSize_y = mySize_y;
1190 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1195 newSize_y = 1/3 * mySize_x;
1196 newSize_x = mySize_x;
1198 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1202 if(icon_right_align) // right align
1205 picpos = newPos + eX * 2 * newSize_y;
1209 numpos = newPos + eX * newSize_y;
1213 drawstring_aspect(numpos, ftos(x), '2 1 0' * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1214 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1217 void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float fadelerp)
1220 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
1222 DrawNumIcon(myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, vertical, icon_right_align, color, (1 - fadelerp));
1227 void HUD_Powerups(void)
1229 float strength_time, shield_time;
1230 if(!autocvar__hud_configure)
1232 if(!autocvar_hud_panel_powerups) return;
1233 if(spectatee_status == -1) return;
1234 if not(getstati(STAT_ITEMS) & (IT_STRENGTH | IT_INVINCIBLE)) return;
1235 if (getstati(STAT_HEALTH) <= 0) return;
1237 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1238 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1242 hud_configure_active_panel = HUD_PANEL_POWERUPS;
1248 HUD_Panel_UpdateCvars(powerups);
1251 mySize = panel_size;
1253 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
1254 if(panel_bg_padding)
1256 pos += '1 1 0' * panel_bg_padding;
1257 mySize -= '2 2 0' * panel_bg_padding;
1260 float panel_ar = mySize_x/mySize_y;
1261 float is_vertical = (panel_ar < 1);
1262 vector shield_offset, strength_offset;
1263 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1266 if (autocvar_hud_panel_powerups_flip)
1267 shield_offset_x = mySize_x;
1269 strength_offset_x = mySize_x;
1274 if (autocvar_hud_panel_powerups_flip)
1275 shield_offset_y = mySize_y;
1277 strength_offset_y = mySize_y;
1280 float shield_baralign, strength_baralign;
1281 float shield_iconalign, strength_iconalign;
1282 if (autocvar_hud_panel_powerups_flip)
1284 strength_baralign = (autocvar_hud_panel_powerups_baralign == 2 || autocvar_hud_panel_powerups_baralign == 1);
1285 shield_baralign = (autocvar_hud_panel_powerups_baralign == 3 || autocvar_hud_panel_powerups_baralign == 1);
1286 strength_iconalign = (autocvar_hud_panel_powerups_iconalign == 2 || autocvar_hud_panel_powerups_iconalign == 1);
1287 shield_iconalign = (autocvar_hud_panel_powerups_iconalign == 3 || autocvar_hud_panel_powerups_iconalign == 1);
1291 shield_baralign = (autocvar_hud_panel_powerups_baralign == 2 || autocvar_hud_panel_powerups_baralign == 1);
1292 strength_baralign = (autocvar_hud_panel_powerups_baralign == 3 || autocvar_hud_panel_powerups_baralign == 1);
1293 shield_iconalign = (autocvar_hud_panel_powerups_iconalign == 2 || autocvar_hud_panel_powerups_iconalign == 1);
1294 strength_iconalign = (autocvar_hud_panel_powerups_iconalign == 3 || autocvar_hud_panel_powerups_iconalign == 1);
1299 const float maxshield = 30;
1300 float shield = ceil(shield_time);
1301 if(autocvar_hud_panel_powerups_progressbar)
1303 HUD_Panel_GetProgressBarColor(shield);
1304 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);
1306 if(autocvar_hud_panel_powerups_text)
1309 DrawNumIcon(pos + shield_offset, mySize, shield, "shield", is_vertical, shield_iconalign, '1 1 1', 1);
1311 DrawNumIcon_expanding(pos + shield_offset, mySize, shield, "shield", is_vertical, shield_iconalign, '1 1 1', bound(0, (shield - shield_time) / 0.5, 1));
1317 const float maxstrength = 30;
1318 float strength = ceil(strength_time);
1319 if(autocvar_hud_panel_powerups_progressbar)
1321 HUD_Panel_GetProgressBarColor(strength);
1322 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);
1324 if(autocvar_hud_panel_powerups_text)
1327 DrawNumIcon(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', 1);
1329 DrawNumIcon_expanding(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', bound(0, (strength - strength_time) / 0.5, 1));
1334 // Health/armor (#3)
1337 // prev_* vars contain the health/armor at the previous FRAME
1338 // set to -1 when player is dead or was not playing
1339 float prev_health, prev_armor;
1340 float health_damagetime, armor_damagetime;
1341 float health_beforedamage, armor_beforedamage;
1342 // old_p_* vars keep track of previous values when smoothing value changes of the progressbar
1343 float old_p_health, old_p_armor;
1344 float old_p_healthtime, old_p_armortime;
1345 // prev_p_* vars contain the health/armor progressbar value at the previous FRAME
1346 // set to -1 to forcedly stop effects when we switch spectated player (e.g. from playerX: 70h to playerY: 50h)
1347 float prev_p_health, prev_p_armor;
1349 void HUD_HealthArmor(void)
1351 float armor, health, fuel;
1352 if(!autocvar__hud_configure)
1354 if(!autocvar_hud_panel_healtharmor) return;
1355 if(hud != HUD_NORMAL) return;
1356 if(spectatee_status == -1) return;
1358 health = getstati(STAT_HEALTH);
1364 armor = getstati(STAT_ARMOR);
1366 // code to check for spectatee_status changes is in Ent_ClientData()
1367 // prev_p_health and prev_health can be set to -1 there
1369 if (prev_p_health == -1)
1372 health_beforedamage = 0;
1373 armor_beforedamage = 0;
1374 health_damagetime = 0;
1375 armor_damagetime = 0;
1376 prev_health = health;
1378 old_p_health = health;
1379 old_p_armor = armor;
1380 prev_p_health = health;
1381 prev_p_armor = armor;
1383 else if (prev_health == -1)
1385 //start the load effect
1386 health_damagetime = 0;
1387 armor_damagetime = 0;
1391 fuel = getstati(STAT_FUEL);
1395 hud_configure_active_panel = HUD_PANEL_HEALTHARMOR;
1402 HUD_Panel_UpdateCvars(healtharmor);
1405 mySize = panel_size;
1407 HUD_Panel_DrawBg(1);
1408 if(panel_bg_padding)
1410 pos += '1 1 0' * panel_bg_padding;
1411 mySize -= '2 2 0' * panel_bg_padding;
1414 float baralign = autocvar_hud_panel_healtharmor_baralign;
1415 float iconalign = autocvar_hud_panel_healtharmor_iconalign;
1417 float maxhealth = autocvar_hud_panel_healtharmor_maxhealth;
1418 float maxarmor = autocvar_hud_panel_healtharmor_maxarmor;
1419 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
1422 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1427 float maxtotal = maxhealth + maxarmor;
1429 if(v_z) // NOT fully armored
1431 biggercount = "health";
1432 if(autocvar_hud_panel_healtharmor_progressbar)
1434 HUD_Panel_GetProgressBarColor(health);
1435 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);
1438 if(autocvar_hud_panel_healtharmor_text)
1439 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);
1443 biggercount = "armor";
1444 if(autocvar_hud_panel_healtharmor_progressbar)
1446 HUD_Panel_GetProgressBarColor(armor);
1447 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);
1450 if(autocvar_hud_panel_healtharmor_text)
1451 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);
1453 if(autocvar_hud_panel_healtharmor_text)
1454 DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, maxtotal), 1);
1458 HUD_Panel_GetProgressBarColor(fuel);
1459 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);
1464 float panel_ar = mySize_x/mySize_y;
1465 float is_vertical = (panel_ar < 1);
1466 vector health_offset, armor_offset;
1467 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1470 if (autocvar_hud_panel_healtharmor_flip)
1471 health_offset_x = mySize_x;
1473 armor_offset_x = mySize_x;
1478 if (autocvar_hud_panel_healtharmor_flip)
1479 health_offset_y = mySize_y;
1481 armor_offset_y = mySize_y;
1484 float health_baralign, armor_baralign, fuel_baralign;
1485 float health_iconalign, armor_iconalign;
1486 if (autocvar_hud_panel_healtharmor_flip)
1488 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1489 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1490 fuel_baralign = health_baralign;
1491 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1492 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1496 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1497 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1498 fuel_baralign = armor_baralign;
1499 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1500 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1505 if(autocvar_hud_panel_healtharmor_progressbar)
1507 HUD_Panel_GetProgressBarColor(health);
1508 float p_health, pain_health_alpha;
1510 pain_health_alpha = 1;
1511 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1513 if (autocvar_hud_panel_healtharmor_progressbar_gfx_smooth > 0)
1515 if (fabs(prev_health - health) >= autocvar_hud_panel_healtharmor_progressbar_gfx_smooth)
1517 if (time - old_p_healthtime < 1)
1518 old_p_health = prev_p_health;
1520 old_p_health = prev_health;
1521 old_p_healthtime = time;
1523 if (time - old_p_healthtime < 1)
1525 p_health += (old_p_health - health) * (1 - (time - old_p_healthtime));
1526 prev_p_health = p_health;
1529 if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0)
1531 if (prev_health - health >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
1533 if (time - health_damagetime >= 1)
1534 health_beforedamage = prev_health;
1535 health_damagetime = time;
1537 if (time - health_damagetime < 1)
1539 float health_damagealpha = 1 - (time - health_damagetime)*(time - health_damagetime);
1540 HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, health_beforedamage/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * health_damagealpha, DRAWFLAG_NORMAL);
1543 prev_health = health;
1545 if (health <= autocvar_hud_panel_healtharmor_progressbar_gfx_lowhealth)
1547 float BLINK_FACTOR = 0.15;
1548 float BLINK_BASE = 0.85;
1549 float BLINK_FREQ = 9;
1550 pain_health_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
1553 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);
1555 if(autocvar_hud_panel_healtharmor_text)
1556 DrawNumIcon(pos + health_offset, mySize, health, "health", is_vertical, health_iconalign, HUD_Get_Num_Color(health, maxhealth), 1);
1561 if(autocvar_hud_panel_healtharmor_progressbar)
1563 HUD_Panel_GetProgressBarColor(armor);
1566 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1568 if (autocvar_hud_panel_healtharmor_progressbar_gfx_smooth > 0)
1570 if (fabs(prev_armor - armor) >= autocvar_hud_panel_healtharmor_progressbar_gfx_smooth)
1572 if (time - old_p_armortime < 1)
1573 old_p_armor = prev_p_armor;
1575 old_p_armor = prev_armor;
1576 old_p_armortime = time;
1578 if (time - old_p_armortime < 1)
1580 p_armor += (old_p_armor - armor) * (1 - (time - old_p_armortime));
1581 prev_p_armor = p_armor;
1584 if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0)
1586 if (prev_armor - armor >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
1588 if (time - armor_damagetime >= 1)
1589 armor_beforedamage = prev_armor;
1590 armor_damagetime = time;
1592 if (time - armor_damagetime < 1)
1594 float armor_damagealpha = 1 - (time - armor_damagetime)*(time - armor_damagetime);
1595 HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, armor_beforedamage/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * armor_damagealpha, DRAWFLAG_NORMAL);
1600 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);
1602 if(autocvar_hud_panel_healtharmor_text)
1603 DrawNumIcon(pos + armor_offset, mySize, armor, "armor", is_vertical, armor_iconalign, HUD_Get_Num_Color(armor, maxarmor), 1);
1609 mySize_x *= 0.2 / 2; //if vertical always halve x to not cover too much numbers with 3 digits
1613 mySize_x *= 2; //restore full panel size
1614 else if (panel_ar < 1/4)
1615 mySize_y *= 2; //restore full panel size
1616 HUD_Panel_GetProgressBarColor(fuel);
1617 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
1622 // Notification area (#4)
1625 string Weapon_SuicideMessage(float deathtype)
1627 w_deathtype = deathtype;
1628 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
1629 return w_deathtypestring;
1632 string Weapon_KillMessage(float deathtype)
1634 w_deathtype = deathtype;
1635 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
1636 return w_deathtypestring;
1639 #define KN_MAX_ENTRIES 10
1641 float killnotify_times[KN_MAX_ENTRIES];
1642 float killnotify_deathtype[KN_MAX_ENTRIES];
1643 float killnotify_actiontype[KN_MAX_ENTRIES]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
1644 string killnotify_attackers[KN_MAX_ENTRIES];
1645 string killnotify_victims[KN_MAX_ENTRIES];
1646 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
1650 kn_index = KN_MAX_ENTRIES-1;
1651 killnotify_times[kn_index] = time;
1652 killnotify_deathtype[kn_index] = wpn;
1653 killnotify_actiontype[kn_index] = actiontype;
1654 if(killnotify_attackers[kn_index])
1655 strunzone(killnotify_attackers[kn_index]);
1656 killnotify_attackers[kn_index] = strzone(attacker);
1657 if(killnotify_victims[kn_index])
1658 strunzone(killnotify_victims[kn_index]);
1659 killnotify_victims[kn_index] = strzone(victim);
1662 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
1665 float alsoprint, gentle;
1666 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
1667 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
1669 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
1672 if(msg == MSG_SUICIDE) {
1673 w = DEATH_WEAPONOF(type);
1675 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1677 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
1678 } else if (type == DEATH_KILL) {
1679 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
1681 print (sprintf(_("^1%s^1 couldn't take it anymore\n"), s1));
1682 } else if (type == DEATH_ROT) {
1683 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1685 print (sprintf(_("^1%s^1 died\n"), s1));
1686 } else if (type == DEATH_NOAMMO) {
1687 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
1689 print (sprintf(_("^7%s^7 committed suicide. What's the point of living without ammo?\n"), s1));
1690 } else if (type == DEATH_CAMP) {
1691 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
1693 print (sprintf(_("^1%s^1 thought they found a nice camping ground\n"), s1));
1694 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
1695 HUD_KillNotify_Push(s1, "", 0, type);
1697 print (sprintf(_("^1%s^1 didn't become friends with the Lord of Teamplay\n"), s1));
1698 } else if (type == DEATH_CHEAT) {
1699 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1701 print (sprintf(_("^1%s^1 unfairly eliminated themself\n"), s1));
1702 } else if (type == DEATH_FIRE) {
1703 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1705 print (sprintf(_("^1%s^1 burned to death\n"), s1));
1706 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
1707 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1709 print (sprintf(_("^1%s^1 couldn't resist the urge to self-destruct\n"), s1));
1712 if (stof(s2) > 2) // killcount > 2
1713 print (sprintf(_("^1%s^1 ended it all after a %d kill spree\n"), s1, stof(s2)));
1714 } else if(msg == MSG_KILL) {
1715 w = DEATH_WEAPONOF(type);
1717 if((w == WEP_RIFLE || w == WEP_MINSTANEX) && type & HITTYPE_HEADSHOT) // all headshot weapons go here
1718 HUD_KillNotify_Push(s1, s2, 1, DEATH_HEADSHOT);
1720 HUD_KillNotify_Push(s1, s2, 1, type);
1723 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
1725 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
1726 HUD_KillNotify_Push(s1, s2, 1, type);
1730 print (sprintf(_("^1%s^1 took action against a team mate\n"), s1));
1732 print (sprintf(_("^1%s^1 mows down a team mate\n"), s1));
1735 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
1737 print (sprintf(_("^1%s^1 ended a %d scoring spree by going against a team mate\n"), s1, stof(s3)));
1739 print (sprintf(_("^1%s^1 ended a %d kill spree by killing a team mate\n"), s1, stof(s3)));
1741 else if (stof(s2) > 2) {
1743 print (sprintf(_("^1%s^1's %s scoring spree was ended by a team mate!\n"), s1, stof(s3)));
1745 print (sprintf(_("^1%s^1's %s kill spree was ended by a team mate!\n"), s1, stof(s3)));
1748 else if(type == KILL_FIRST_BLOOD)
1749 print(sprintf(_("^1%s^1 drew first blood\n"), s1));
1750 else if (type == DEATH_TELEFRAG) {
1751 HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
1753 print (sprintf(_("^1%s^1 tried to occupy %s^1's teleport destination space\n"), s2, s1));
1755 print (sprintf(_("^1%s^1 was telefragged by %s\n"), s2, s1));
1757 else if (type == DEATH_DROWN) {
1758 HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN);
1760 print (sprintf(_("^1%s^1 was drowned by %s\n"), s2, s1));
1762 else if (type == DEATH_SLIME) {
1763 HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME);
1765 print (sprintf(_("^1%s^1 was slimed by %s\n"), s2, s1));
1767 else if (type == DEATH_LAVA) {
1768 HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA);
1770 print (sprintf(_("^1%s^1 was cooked by %s\n"), s2, s1));
1772 else if (type == DEATH_FALL) {
1773 HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL);
1775 print (sprintf(_("^1%s^1 was grounded by %s\n"), s2, s1));
1777 else if (type == DEATH_SHOOTING_STAR) {
1778 HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR);
1780 print (sprintf(_("^1%s^1 was shot into space by %s\n"), s2, s1));
1782 else if (type == DEATH_SWAMP) {
1783 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1785 print (sprintf(_("^1%s^1 was conserved by %s\n"), s2, s1));
1787 else if (type == DEATH_HURTTRIGGER)
1789 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1791 print(sprintf(_("^1%s^1 was thrown into a world of hurt by %s\n"), s2, s1));
1792 } else if(type == DEATH_VHCRUSH) {
1793 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1795 print (sprintf(_("^1%s^1 was crushed by %s\n"), s2, s1));
1796 } else if(type == DEATH_SBMINIGUN) {
1797 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1799 print (sprintf(_("^1%s^1 got shredded by %s\n"), s2, s1));
1800 } else if(type == DEATH_SBROCKET) {
1801 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1803 print (sprintf(_("^1%s^1 was blasted to bits by %s\n"), s2, s1));
1804 } else if(type == DEATH_SBBLOWUP) {
1805 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1807 print (sprintf(_("^1%s^1 got caught in the destruction of %s^1's vehicle\n"), s2, s1));
1808 } else if(type == DEATH_WAKIGUN) {
1809 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1811 print (sprintf(_("^1%s^1 was bolted down by %s\n"), s2, s1));
1812 } else if(type == DEATH_WAKIROCKET) {
1813 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1815 print (sprintf(_("^1%s^1 could find no shelter from %s^1's rockets\n"), s2, s1));
1816 } else if(type == DEATH_WAKIBLOWUP) {
1817 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1819 print (sprintf(_("^1%s^1 dies when %s^1's wakizashi dies.\n"), s2, s1));
1820 } else if(type == DEATH_RAPTOR_CANNON) {
1821 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1823 print (sprintf(_("^1%s^1 nailed to hell by %s\n"), s2, s1));
1824 } else if(type == DEATH_RAPTOR_BOMB) {
1825 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1827 print (sprintf(_("^1%s^1 cluster crushed by %s\n"), s2, s1));
1828 } else if(type == DEATH_RAPTOR_DEATH) {
1829 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1831 print (sprintf(_("^1%s^1 dies when %s^1's raptor dies.\n"), s2, s1));
1832 } else if(type == DEATH_TURRET) {
1833 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1835 print (sprintf(_("^1%s^1 was pushed into the line of fire by %s\n"), s2, s1));
1836 } else if(type == DEATH_TOUCHEXPLODE) {
1837 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1839 print (sprintf(_("^1%s^1 was pushed into an accident by %s\n"), s2, s1));
1840 } else if(type == DEATH_CHEAT) {
1841 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1843 print (sprintf(_("^1%s^1 was unfairly eliminated by %s\n"), s2, s1));
1844 } else if (type == DEATH_FIRE) {
1845 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1847 print (sprintf(_("^1%s^1 was burnt to death by %s\n"), s2, s1));
1848 } else if (type == DEATH_CUSTOM) {
1849 HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
1851 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1852 } else if (type == DEATH_HURTTRIGGER) {
1853 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1855 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1857 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1859 print (sprintf(_("^1%s^1 was fragged by %s\n"), s2, s1));
1861 } else if(msg == MSG_SPREE) {
1862 if(type == KILL_END_SPREE) {
1864 print (sprintf(_("^1%s^1's %s scoring spree was ended by %s\n"), s1, s2, s3));
1866 print (sprintf(_("^1%s^1's %s kill spree was ended by %s\n"), s1, s2, s3));
1867 } else if(type == KILL_SPREE) {
1869 print (sprintf(_("^1%s^1 made %s scores in a row\n"), s1, s2));
1871 print (sprintf(_("^1%s^1 has %s frags in a row\n"), s1, s2));
1872 } else if(type == KILL_SPREE_3) {
1874 print (sprintf(_("%s^7 made a ^1TRIPLE SCORE\n"), s1));
1876 print (sprintf(_("%s^7 made a ^1TRIPLE FRAG\n"), s1));
1877 } else if(type == KILL_SPREE_5) {
1879 print (sprintf(_("%s^7 unleashes ^1SCORING RAGE\n"), s1));
1881 print (sprintf(_("%s^7 unleashes ^1RAGE\n"), s1));
1882 } else if(type == KILL_SPREE_10) {
1884 print (sprintf(_("%s^7 made ^1TEN SCORES IN A ROW!\n"), s1));
1886 print (sprintf(_("%s^7 starts the ^1MASSACRE!\n"), s1));
1887 } else if(type == KILL_SPREE_15) {
1889 print (sprintf(_("%s^7 made ^1FIFTEEN SCORES IN A ROW!\n"), s1));
1891 print (sprintf(_("%s^7 executes ^1MAYHEM!\n"), s1));
1892 } else if(type == KILL_SPREE_20) {
1894 print (sprintf(_("%s^7 made ^1TWENTY SCORES IN A ROW!\n"), s1));
1896 print (sprintf(_("%s^7 is a ^1BERSERKER!\n"), s1));
1897 } else if(type == KILL_SPREE_25) {
1899 print (sprintf(_("%s^7 made ^1TWENTY FIVE SCORES IN A ROW!\n"), s1));
1901 print (sprintf(_("%s^7 inflicts ^1CARNAGE!\n"), s1));
1902 } else if(type == KILL_SPREE_30) {
1904 print (sprintf(_("%s^7 made ^1THIRTY SCORES IN A ROW!\n"), s1));
1906 print (sprintf(_("%s^7 unleashes ^1ARMAGEDDON!\n"), s1));
1908 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
1909 if (type == DEATH_DROWN) {
1910 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
1914 print (sprintf(_("^1%s^1 was in the water for too long\n"), s1));
1916 print (sprintf(_("^1%s^1 drowned\n"), s1));
1918 } else if (type == DEATH_SLIME) {
1919 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
1921 print (sprintf(_("^1%s^1 was slimed\n"), s1));
1922 } else if (type == DEATH_LAVA) {
1923 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
1927 print (sprintf(_("^1%s^1 found a hot place\n"), s1));
1929 print (sprintf(_("^1%s^1 turned into hot slag\n"), s1));
1931 } else if (type == DEATH_FALL) {
1932 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1936 print (sprintf(_("^1%s^1 tested gravity (and it worked)\n"), s1));
1938 print (sprintf(_("^1%s^1 hit the ground with a crunch\n"), s1));
1940 } else if (type == DEATH_SHOOTING_STAR) {
1941 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
1943 print (sprintf(_("^1%s^1 became a shooting star\n"), s1));
1944 } else if (type == DEATH_SWAMP) {
1945 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1949 print (sprintf(_("^1%s^1 discovered a swamp\n"), s1));
1951 print (sprintf(_("^1%s^1 is now conserved for centuries to come\n"), s1));
1953 } else if(type == DEATH_TURRET) {
1954 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1956 print (sprintf(_("^1%s^1 was mowed down by a turret \n"), s1));
1957 } else if (type == DEATH_CUSTOM) {
1958 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
1960 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1961 } else if (type == DEATH_HURTTRIGGER) {
1962 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
1964 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1965 } else if(type == DEATH_TOUCHEXPLODE) {
1966 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1968 print (sprintf(_("^1%s^1 died in an accident\n"), s1));
1969 } else if(type == DEATH_CHEAT) {
1970 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1972 print (sprintf(_("^1%s^1 was unfairly eliminated\n"), s1));
1973 } else if(type == DEATH_FIRE) {
1974 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1978 print (sprintf(_("^1%s^1 felt a little hot\n"), s1));
1980 print (sprintf(_("^1%s^1 burnt to death\n"), s1));
1983 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1987 print (sprintf(_("^1%s^1 needs a restart\n"), s1));
1989 print (sprintf(_("^1%s^1 died\n"), s1));
1992 } else if(msg == MSG_KILL_ACTION_SPREE) {
1994 print (sprintf(_("^1%s^1 needs a restart after a %d scoring spree\n"), s1, stof(s2)));
1996 print (sprintf(_("^1%s^1 died with a %d kill spree\n"), s1, stof(s2)));
1997 } else if(msg == MSG_INFO) {
1998 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
1999 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2000 print(sprintf(_("%s^7 got the %s\n"), s1, s2));
2001 } else if(type == INFO_LOSTFLAG) {
2002 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
2003 print(sprintf(_("%s^7 lost the %s\n"), s1, s2));
2004 } else if(type == INFO_PICKUPFLAG) {
2005 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
2006 print(sprintf(_("%s^7 picked up the %s\n"), s1, s2));
2007 } else if(type == INFO_RETURNFLAG) {
2008 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
2009 print(sprintf(_("%s^7 returned the %s\n"), s1, s2));
2010 } else if(type == INFO_CAPTUREFLAG) {
2011 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
2012 print(sprintf(_("%s^7 captured the %s%s\n"), s1, s2, s3));
2014 } else if(msg == MSG_RACE) {
2015 if(type == RACE_SERVER_RECORD) {
2016 HUD_KillNotify_Push(s1, s2, 1, RACE_SERVER_RECORD);
2018 else if(type == RACE_NEW_RANK) {
2019 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_RANK);
2021 else if(type == RACE_NEW_TIME) {
2022 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_TIME);
2024 else if(type == RACE_FAIL) {
2025 HUD_KillNotify_Push(s1, s2, 1, RACE_FAIL);
2027 } else if(msg == MSG_KA) {
2028 if(type == KA_PICKUPBALL) {
2029 HUD_KillNotify_Push(s1, s2, 0, KA_PICKUPBALL);
2031 print (sprintf(_("%s^7 has picked up the ball!\n"), s1));
2033 else if(type == KA_DROPBALL) {
2034 HUD_KillNotify_Push(s1, s2, 0, KA_DROPBALL);
2036 print(sprintf(_("%s^7 has dropped the ball!\n"), s1));
2041 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2043 void HUD_Centerprint(string s1, string s2, float type, float msg)
2046 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2047 if(msg == MSG_SUICIDE) {
2048 if (type == DEATH_TEAMCHANGE) {
2049 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("You are now on: %s"), s1)));
2050 } else if (type == DEATH_AUTOTEAMCHANGE) {
2051 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("You have been moved into a different team to improve team balance\nYou are now on: %s"), s1)));
2052 } else if (type == DEATH_CAMP) {
2054 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Reconsider your tactics, camper!")));
2056 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Die camper!")));
2057 } else if (type == DEATH_NOAMMO) {
2059 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You are reinserted into the game for running out of ammo...")));
2061 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You were killed for running out of ammo...")));
2062 } else if (type == DEATH_ROT) {
2064 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You need to preserve your health")));
2066 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You grew too old without taking your medicine")));
2067 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2069 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Don't go against team mates!")));
2071 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Don't shoot your team mates!")));
2072 } else if (type == DEATH_QUIET) {
2074 } else { // generic message
2076 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You need to be more careful!")));
2078 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You killed your own dumb self!")));
2080 } else if(msg == MSG_KILL) {
2081 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2083 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1Moron! You went against ^7%s^1, a team mate!"), s1)));
2085 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1Moron! You fragged ^7%s^1, a team mate!"), s1)));
2087 } else if (type == KILL_FIRST_BLOOD) {
2089 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First score")));
2091 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First blood")));
2093 } else if (type == KILL_FIRST_VICTIM) {
2095 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First casualty")));
2097 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First victim")));
2099 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2101 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You scored against ^7%s^1 who was typing!"), s1), s2));
2103 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You typefragged ^7%s"), s1), s2));
2105 } else if (type == KILL_TYPEFRAGGED) {
2107 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were scored against by ^7%s^1 while you were typing!"), s1), s2));
2109 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were typefragged by ^7%s"), s1), s2));
2111 } else if (type == KILL_FRAG) {
2113 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^4You scored against ^7%s"), s1), s2));
2115 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^4You fragged ^7%s"), s1), s2));
2117 } else { // generic message
2119 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were scored against by ^7%s"), s1), s2));
2121 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were fragged by ^7%s"), s1), s2));
2124 } else if(msg == MSG_KILL_ACTION) {
2125 // TODO: invent more centerprints here?
2126 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Watch your step!")));
2130 void HUD_Notify (void)
2132 if(!autocvar__hud_configure)
2134 if(!autocvar_hud_panel_notify) return;
2137 hud_configure_active_panel = HUD_PANEL_NOTIFY;
2139 HUD_Panel_UpdateCvars(notify);
2142 mySize = panel_size;
2144 HUD_Panel_DrawBg(1);
2145 if(panel_bg_padding)
2147 pos += '1 1 0' * panel_bg_padding;
2148 mySize -= '2 2 0' * panel_bg_padding;
2151 float entries, height;
2152 entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES);
2153 height = mySize_y/entries;
2156 float fontheight = height * autocvar_hud_panel_notify_fontsize;
2157 fontsize = '0.5 0.5 0' * fontheight;
2161 when = autocvar_hud_panel_notify_time;
2163 fadetime = autocvar_hud_panel_notify_fadetime;
2167 vector pos_attacker, pos_victim;
2169 float width_attacker;
2170 string attacker, victim;
2172 float i, j, w, step, limit;
2173 if(autocvar_hud_panel_notify_flip) //order items from the top down
2179 else //order items from the bottom up
2186 for(j = kn_index; i != limit; i += step, ++j)
2188 if(autocvar__hud_configure)
2192 else // inverse order
2193 a = entries - 1 - i;
2194 attacker = textShortenToWidth(sprintf(_("Player %d"), a+1), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2195 victim = textShortenToWidth(sprintf(_("Player %d"), a+2), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2196 s = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname);
2197 a = bound(0, (when - a) / 4, 1);
2198 goto hud_config_notifyprint;
2201 if (j == KN_MAX_ENTRIES)
2204 if(killnotify_times[j] + when > time)
2208 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2222 w = DEATH_WEAPONOF(killnotify_deathtype[j]);
2224 // TODO: maybe print in team colors?
2227 if(killnotify_actiontype[j] == 0)
2229 if(killnotify_deathtype[j] == DEATH_GENERIC)
2233 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2235 s = "notify_outofammo";
2237 else if(killnotify_deathtype[j] == DEATH_KILL)
2239 s = "notify_selfkill";
2241 else if(killnotify_deathtype[j] == DEATH_CAMP)
2243 s = "notify_camping";
2245 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2247 s = "notify_teamkill_red";
2249 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2251 s = "notify_teamkill_blue";
2253 else if(killnotify_deathtype[j] == DEATH_DROWN)
2257 else if(killnotify_deathtype[j] == DEATH_SLIME)
2261 else if(killnotify_deathtype[j] == DEATH_LAVA)
2265 else if(killnotify_deathtype[j] == DEATH_FALL)
2269 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2271 s = "notify_shootingstar";
2273 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2277 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2279 if(killnotify_victims[j] == "^1RED^7 flag")
2281 s = "notify_red_taken";
2285 s = "notify_blue_taken";
2288 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2290 if(killnotify_victims[j] == "^1RED^7 flag")
2292 s = "notify_red_returned";
2296 s = "notify_blue_returned";
2299 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2301 if(killnotify_victims[j] == "^1RED^7 flag")
2303 s = "notify_red_lost";
2307 s = "notify_blue_lost";
2310 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
2312 if(killnotify_victims[j] == "^1RED^7 flag")
2314 s = "notify_red_captured";
2318 s = "notify_blue_captured";
2321 else if(killnotify_deathtype[j] == KA_DROPBALL)
2323 s = "notify_balldropped";
2325 else if(killnotify_deathtype[j] == KA_PICKUPBALL)
2327 s = "notify_ballpickedup";
2330 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2331 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2332 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2336 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2337 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2340 // X [did action to] Y
2343 if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
2345 s = "notify_melee_laser";
2347 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_SHOTGUN)
2349 s = "notify_melee_shotgun";
2351 else if(WEP_VALID(w))
2353 self = get_weaponinfo(w);
2354 s = strcat("weapon", self.netname);
2356 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2358 s = "notify_teamkill_red";
2360 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2362 s = "notify_teamkill_red";
2364 else if(killnotify_deathtype[j] == DEATH_TELEFRAG)
2366 s = "notify_telefrag";
2368 else if(killnotify_deathtype[j] == DEATH_DROWN)
2372 else if(killnotify_deathtype[j] == DEATH_SLIME)
2376 else if(killnotify_deathtype[j] == DEATH_LAVA)
2380 else if(killnotify_deathtype[j] == DEATH_FALL)
2384 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2386 s = "notify_shootingstar";
2388 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2392 else if(killnotify_deathtype[j] == DEATH_HEADSHOT)
2394 s = "notify_headshot";
2396 else if(killnotify_deathtype[j] == RACE_SERVER_RECORD)
2398 s = "race_newrecordserver";
2400 else if(killnotify_deathtype[j] == RACE_NEW_RANK)
2402 s = "race_newrankyellow";
2404 else if(killnotify_deathtype[j] == RACE_NEW_TIME)
2408 else if(killnotify_deathtype[j] == RACE_FAIL)
2413 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2414 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2415 :hud_config_notifyprint
2416 width_attacker = stringwidth(attacker, TRUE, fontsize);
2417 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2418 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2419 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2423 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2424 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2425 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2434 string seconds_tostring(float sec)
2437 minutes = floor(sec / 60);
2439 sec -= minutes * 60;
2440 return sprintf("%d:%02d", minutes, sec);
2443 void HUD_Timer(void)
2445 if(!autocvar__hud_configure)
2447 if(!autocvar_hud_panel_timer) return;
2450 hud_configure_active_panel = HUD_PANEL_TIMER;
2452 HUD_Panel_UpdateCvars(timer);
2455 mySize = panel_size;
2457 HUD_Panel_DrawBg(1);
2458 if(panel_bg_padding)
2460 pos += '1 1 0' * panel_bg_padding;
2461 mySize -= '2 2 0' * panel_bg_padding;
2465 float timelimit, elapsedTime, timeleft, minutesLeft;
2467 timelimit = getstatf(STAT_TIMELIMIT);
2469 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
2470 timeleft = ceil(timeleft);
2472 minutesLeft = floor(timeleft / 60);
2475 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
2476 timer_color = '1 1 1'; //white
2477 else if(minutesLeft >= 1)
2478 timer_color = '1 1 0'; //yellow
2480 timer_color = '1 0 0'; //red
2482 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
2483 if (time < getstatf(STAT_GAMESTARTTIME)) {
2484 //while restart is still active, show 00:00
2485 timer = seconds_tostring(0);
2487 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
2488 timer = seconds_tostring(elapsedTime);
2491 timer = seconds_tostring(timeleft);
2494 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2499 void HUD_Radar(void)
2501 if (!autocvar__hud_configure)
2503 if (autocvar_hud_panel_radar == 0) return;
2504 if (autocvar_hud_panel_radar != 2 && !teamplay) return;
2507 hud_configure_active_panel = HUD_PANEL_RADAR;
2509 HUD_Panel_UpdateCvars(radar);
2512 mySize = panel_size;
2514 HUD_Panel_DrawBg(1);
2515 if(panel_bg_padding)
2517 pos += '1 1 0' * panel_bg_padding;
2518 mySize -= '2 2 0' * panel_bg_padding;
2523 float scale2d, normalsize, bigsize;
2526 teamradar_origin2d = pos + 0.5 * mySize;
2527 teamradar_size2d = mySize;
2529 if(minimapname == "")
2532 teamradar_loadcvars();
2534 switch(hud_panel_radar_zoommode)
2538 f = current_zoomfraction;
2541 f = 1 - current_zoomfraction;
2551 switch(hud_panel_radar_rotation)
2554 teamradar_angle = view_angles_y - 90;
2557 teamradar_angle = 90 * hud_panel_radar_rotation;
2561 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
2562 teamradar_size2d = mySize;
2564 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
2566 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
2567 if(hud_panel_radar_rotation == 0)
2569 // max-min distance must fit the radar in any rotation
2570 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_scale));
2574 vector c0, c1, c2, c3, span;
2575 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
2576 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
2577 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
2578 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
2580 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
2581 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
2583 // max-min distance must fit the radar in x=x, y=y
2585 teamradar_size2d_x * scale2d / (1.05 * span_x),
2586 teamradar_size2d_y * scale2d / (1.05 * span_y)
2590 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
2591 if(bigsize > normalsize)
2592 normalsize = bigsize;
2596 + (1 - f) * normalsize;
2597 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
2599 + (1 - f) * view_origin);
2608 draw_teamradar_background(hud_panel_radar_foreground_alpha);
2610 for(tm = world; (tm = find(tm, classname, "radarlink")); )
2611 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
2612 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
2613 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
2614 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
2616 color2 = GetPlayerColor(tm.sv_entnum);
2617 //if(color == COLOR_SPECTATOR || color == color2)
2618 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
2620 draw_teamradar_player(view_origin, view_angles, '1 1 1');
2622 drawresetcliparea();
2627 void HUD_UpdatePlayerTeams();
2628 void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count)
2632 #define SCOREPANEL_MAX_ENTRIES 6
2633 #define SCOREPANEL_ASPECTRATIO 2
2634 const float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
2635 const vector fontsize = '1 1 0' * (mySize_y/entries);
2637 vector rgb, score_color;
2639 score_color = '1 1 1';
2641 const float name_size = mySize_x*0.75;
2642 const float spacing_size = mySize_x*0.04;
2643 const float highlight_alpha = 0.2;
2644 float i, me_printed, first_pl;
2647 if (autocvar__hud_configure)
2649 float players_per_team;
2652 // show team scores in the first line
2653 float score_size = mySize_x / team_count;
2654 players_per_team = max(2, ceil((entries - 1) / team_count));
2655 for(i=0; i<team_count; ++i) {
2656 if (i == floor((entries - 2) / players_per_team) || (entries == 1 && i == 0))
2657 HUD_Panel_DrawHighlight(pos + eX * score_size * i, eX * score_size + eY * fontsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2658 drawstring_aspect(pos + eX * score_size * i, ftos(175 - 23*i), eX * score_size + eY * fontsize_y, GetTeamRGB(ColorByTeam(i)) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2661 pos_y += fontsize_y;
2663 score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
2664 for (i=first_pl; i<entries; ++i)
2666 //simulate my score is lower than all displayed players,
2667 //so that I don't appear at all showing pure rankings.
2668 //This is to better show the difference between the 2 ranking views
2669 if (i == entries-1 && autocvar_hud_panel_score_rankings == 1)
2672 drawfill(pos, eX * mySize_x + eY * fontsize_y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2673 s = GetPlayerName(pl.sv_entnum);
2678 s = sprintf(_("Player %d"), i + 1 - first_pl);
2683 score_color = GetTeamRGB(ColorByTeam(floor((i - first_pl) / players_per_team))) * 0.8;
2684 s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
2685 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2686 drawstring(pos + eX * (name_size + spacing_size), ftos(score), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2687 pos_y += fontsize_y;
2692 if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
2693 HUD_UpdatePlayerTeams();
2696 // show team scores in the first line
2697 float score_size = mySize_x / team_count;
2698 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2699 if(tm.team == COLOR_SPECTATOR)
2701 if (tm.team == myteam)
2702 drawfill(pos + eX * score_size * i, eX * score_size + eY * fontsize_y, '1 1 1', highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2703 drawstring_aspect(pos + eX * score_size * i, ftos(tm.(teamscores[ts_primary])), eX * score_size + eY * fontsize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2707 pos_y += fontsize_y;
2708 tm = teams.sort_next;
2713 for (pl = players.sort_next; pl && i<entries; pl = pl.sort_next)
2715 if ((team_count && pl.team != tm.team) || pl.team == COLOR_SPECTATOR)
2718 if (i == entries-1 && !me_printed && pl != me)
2719 if (autocvar_hud_panel_score_rankings == 1 && spectatee_status != -1)
2721 for (pl = me.sort_next; pl; pl = pl.sort_next)
2722 if (pl.team != COLOR_SPECTATOR)
2726 rgb = '1 1 0'; //not last but not among the leading players: yellow
2728 rgb = '1 0 0'; //last: red
2735 rgb = '0 1 0'; //first: green
2737 drawfill(pos, eX * mySize_x + eY * fontsize_y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2740 score_color = GetTeamRGB(pl.team) * 0.8;
2741 s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
2742 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2743 drawstring(pos + eX * (name_size + spacing_size), ftos(pl.(scores[ps_primary])), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2744 pos_y += fontsize_y;
2747 while (i<entries && team_count && (tm = tm.sort_next) && (tm.team != COLOR_SPECTATOR || (tm = tm.sort_next)));
2750 void HUD_Score(void)
2752 if(!autocvar__hud_configure)
2754 if(!autocvar_hud_panel_score) return;
2755 if(spectatee_status == -1 && (gametype == GAME_RACE || gametype == GAME_CTS)) return;
2758 hud_configure_active_panel = HUD_PANEL_SCORE;
2760 HUD_Panel_UpdateCvars(score);
2763 mySize = panel_size;
2765 HUD_Panel_DrawBg(1);
2766 if(panel_bg_padding)
2768 pos += '1 1 0' * panel_bg_padding;
2769 mySize -= '2 2 0' * panel_bg_padding;
2772 float score, distribution;
2774 vector distribution_color;
2776 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
2778 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
2779 string timer, distrtimer;
2781 pl = players.sort_next;
2784 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
2785 if(pl.scores[ps_primary] == 0)
2788 score = me.(scores[ps_primary]);
2789 timer = TIME_ENCODED_TOSTRING(score);
2791 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
2792 // distribution display
2793 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2795 distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS);
2797 if (distribution <= 0) {
2798 distribution_color = '0 1 0';
2802 distribution_color = '1 0 0';
2805 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);
2807 // race record display
2808 if (distribution <= 0)
2809 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2810 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2811 } else if (!teamplay) { // non-teamgames
2812 if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings)
2814 HUD_Score_Rankings(pos, mySize, me, 0);
2817 // me vector := [team/connected frags id]
2818 pl = players.sort_next;
2822 if(autocvar__hud_configure)
2825 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2829 score = me.(scores[ps_primary]);
2830 if(autocvar__hud_configure)
2833 if(distribution >= 5)
2834 distribution_color = eY;
2835 else if(distribution >= 0)
2836 distribution_color = '1 1 1';
2837 else if(distribution >= -5)
2838 distribution_color = '1 1 0';
2840 distribution_color = eX;
2842 string distribution_str;
2843 distribution_str = ftos(distribution);
2844 if (distribution >= 0)
2846 if (distribution > 0)
2847 distribution_str = strcat("+", distribution_str);
2848 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2850 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2851 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);
2852 } else { // teamgames
2853 float scores_count, row, column, rows, columns;
2855 vector score_pos, score_size; //for scores other than myteam
2856 if (spectatee_status == -1 || autocvar_hud_panel_score_rankings)
2858 for(tm = teams.sort_next; tm, tm.team != COLOR_SPECTATOR; tm = tm.sort_next)
2860 if (autocvar_hud_panel_score_rankings)
2862 HUD_Score_Rankings(pos, mySize, me, scores_count);
2865 rows = mySize_y/mySize_x;
2866 rows = bound(1, floor((sqrt(4 * (3/1) * rows * scores_count + rows * rows) + rows + 0.5) / 2), scores_count);
2867 // ^^^ ammo item aspect goes here
2869 columns = ceil(scores_count/rows);
2871 score_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
2874 if(score_size_x/score_size_y > 3)
2876 newSize = 3 * score_size_y;
2877 offset_x = score_size_x - newSize;
2878 pos_x += offset_x/2;
2879 score_size_x = newSize;
2883 newSize = 1/3 * score_size_x;
2884 offset_y = score_size_y - newSize;
2885 pos_y += offset_y/2;
2886 score_size_y = newSize;
2890 score_size = eX * mySize_x*(1/4) + eY * mySize_y*(1/3);
2892 float max_fragcount;
2893 max_fragcount = -99;
2894 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2895 if(tm.team == COLOR_SPECTATOR)
2897 score = tm.(teamscores[ts_primary]);
2898 if(autocvar__hud_configure)
2901 if (score > max_fragcount)
2902 max_fragcount = score;
2904 if (spectatee_status == -1)
2906 score_pos = pos + eX * column * (score_size_x + offset_x) + eY * row * (score_size_y + offset_y);
2907 if (max_fragcount == score)
2908 HUD_Panel_DrawHighlight(score_pos, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2909 drawstring_aspect(score_pos, ftos(score), score_size, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2917 else if(tm.team == myteam) {
2918 if (max_fragcount == score)
2919 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2920 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
2922 if (max_fragcount == score)
2923 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);
2924 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);
2933 void HUD_RaceTimer (void)
2935 if(!autocvar__hud_configure)
2937 if(!autocvar_hud_panel_racetimer) return;
2938 if(!(gametype == GAME_RACE || gametype == GAME_CTS)) return;
2939 if(spectatee_status == -1) return;
2942 hud_configure_active_panel = HUD_PANEL_RACETIMER;
2944 HUD_Panel_UpdateCvars(racetimer);
2947 mySize = panel_size;
2949 HUD_Panel_DrawBg(1);
2950 if(panel_bg_padding)
2952 pos += '1 1 0' * panel_bg_padding;
2953 mySize -= '2 2 0' * panel_bg_padding;
2956 // always force 4:1 aspect
2958 if(mySize_x/mySize_y > 4)
2960 newSize_x = 4 * mySize_y;
2961 newSize_y = mySize_y;
2963 pos_x = pos_x + (mySize_x - newSize_x) / 2;
2967 newSize_y = 1/4 * mySize_x;
2968 newSize_x = mySize_x;
2970 pos_y = pos_y + (mySize_y - newSize_y) / 2;
2975 string s, forcetime;
2977 if(autocvar__hud_configure)
2980 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);
2981 s = _("^1Intermediate 1 (+15.42)");
2982 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);
2983 s = sprintf(_("^1PENALTY: %.1f (%s)"), 2, "missing a checkpoint");
2984 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);
2986 else if(race_checkpointtime)
2988 a = bound(0, 2 - (time - race_checkpointtime), 1);
2991 if(a > 0) // just hit a checkpoint?
2993 if(race_checkpoint != 254)
2995 if(race_time && race_previousbesttime)
2996 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
2998 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
3000 forcetime = TIME_ENCODED_TOSTRING(race_time);
3005 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
3007 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
3008 if(a > 0) // next one?
3010 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
3015 if(s != "" && a > 0)
3017 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);
3020 if(race_penaltytime)
3022 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
3025 s = sprintf(_("^1PENALTY: %.1f (%s)"), race_penaltytime * 0.1, race_penaltyreason);
3026 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);
3032 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
3033 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);
3038 if(race_laptime && race_checkpoint != 255)
3040 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
3041 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);
3046 if(race_mycheckpointtime)
3048 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
3049 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
3050 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);
3052 if(race_othercheckpointtime && race_othercheckpointenemy != "")
3054 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
3055 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
3056 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);
3059 if(race_penaltytime && !race_penaltyaccumulator)
3061 t = race_penaltytime * 0.1 + race_penaltyeventtime;
3062 a = bound(0, (1 + t - time), 1);
3066 s = sprintf(_("^1PENALTY: %.1f (%s)"), (t - time) * 0.1, race_penaltyreason);
3068 s = sprintf(_("^2PENALTY: %.1f (%s)"), 0, race_penaltyreason);
3069 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);
3077 float vote_yescount;
3080 float vote_highlighted; // currently selected vote
3082 float vote_active; // is there an active vote?
3083 float vote_prev; // previous state of vote_active to check for a change
3085 float vote_change; // "time" when vote_active changed
3087 void HUD_VoteWindow(void)
3089 if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
3092 if (autocvar__hud_configure)
3096 print(_("^1You must answer before entering hud configure mode\n"));
3097 cvar_set("_hud_configure", "0");
3099 vote_called_vote = strzone(_("^2Name ^7instead of \"^1Unregistered player^7\" in stats"));
3100 uid2name_dialog = 1;
3103 if(!autocvar__hud_configure)
3105 if(!autocvar_hud_panel_vote) return;
3107 panel_fg_alpha = autocvar_hud_panel_fg_alpha;
3108 panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
3110 if(panel_bg_alpha_str == "") {
3111 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
3113 panel_bg_alpha = stof(panel_bg_alpha_str);
3117 hud_configure_active_panel = HUD_PANEL_VOTE;
3126 if(vote_active != vote_prev) {
3128 vote_prev = vote_active;
3131 if(vote_active || autocvar__hud_configure)
3132 vote_alpha = bound(0, (time - vote_change) * 2, 1);
3134 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
3139 HUD_Panel_UpdateCvars(vote);
3143 panel_pos = eX * 0.3 * vid_conwidth + eY * 0.1 * vid_conheight;
3144 panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
3147 // these must be below above block
3150 mySize = panel_size;
3152 a = vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
3153 HUD_Panel_DrawBg(a);
3154 a = panel_fg_alpha * a;
3156 if(panel_bg_padding)
3158 pos += '1 1 0' * panel_bg_padding;
3159 mySize -= '2 2 0' * panel_bg_padding;
3162 // always force 3:1 aspect
3164 if(mySize_x/mySize_y > 3)
3166 newSize_x = 3 * mySize_y;
3167 newSize_y = mySize_y;
3169 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3173 newSize_y = 1/3 * mySize_x;
3174 newSize_x = mySize_x;
3176 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3180 s = _("A vote has been called for:");
3182 s = _("Allow servers to store and display your name?");
3183 drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3184 s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1/8), stringwidth_colors);
3185 if(autocvar__hud_configure)
3186 s = _("^1Configure the HUD");
3187 drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
3189 // print the yes/no counts
3190 s = sprintf(_("Yes (%s): %d"), getcommandkey("vyes", "vyes"), vote_yescount);
3191 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);
3192 s = sprintf(_("No (%s): %d"), getcommandkey("vno", "vno"), vote_nocount);
3193 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);
3195 // draw the progress bar backgrounds
3196 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3198 // draw the highlights
3199 if(vote_highlighted == 1) {
3200 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
3201 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3203 else if(vote_highlighted == 2) {
3204 drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
3205 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3208 // draw the progress bars
3209 if(vote_yescount && vote_needed)
3211 drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
3212 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3215 if(vote_nocount && vote_needed)
3217 drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
3218 drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
3221 drawresetcliparea();
3224 vote_highlighted = 0;
3228 // Mod icons panel (#10)
3231 float mod_active; // is there any active mod icon?
3233 // Clan Arena HUD modicons
3234 void HUD_Mod_CA(vector pos, vector mySize)
3236 mod_active = 1; // CA should never hide the mod icons panel
3237 float redalive, bluealive;
3238 redalive = getstati(STAT_REDALIVE);
3239 bluealive = getstati(STAT_BLUEALIVE);
3241 vector redpos, bluepos;
3242 if(mySize_x > mySize_y)
3245 bluepos = pos + eY * 0.5 * mySize_y;
3246 drawpic_aspect_skin(redpos, "player_red.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3247 drawstring_aspect(redpos + eX * 0.5 * mySize_x, ftos(redalive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3248 drawpic_aspect_skin(bluepos, "player_blue.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3249 drawstring_aspect(bluepos + eX * 0.5 * mySize_x, ftos(bluealive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3254 bluepos = pos + eY * 0.5 * mySize_y;
3255 drawpic_aspect_skin(redpos, "player_red.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3256 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);
3257 drawpic_aspect_skin(bluepos, "player_blue.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3258 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);
3262 // CTF HUD modicon section
3263 float redflag_prevframe, blueflag_prevframe; // status during previous frame
3264 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
3265 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
3267 void HUD_Mod_CTF_Reset(void)
3269 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
3272 void HUD_Mod_CTF(vector pos, vector mySize)
3274 vector redflag_pos, blueflag_pos;
3276 float f; // every function should have that
3278 float redflag, blueflag; // current status
3279 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
3282 stat_items = getstati(STAT_ITEMS);
3283 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
3284 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
3286 if(redflag || blueflag)
3291 if(autocvar__hud_configure)
3297 // when status CHANGES, set old status into prevstatus and current status into status
3298 if (redflag != redflag_prevframe)
3300 redflag_statuschange_time = time;
3301 redflag_prevstatus = redflag_prevframe;
3302 redflag_prevframe = redflag;
3305 if (blueflag != blueflag_prevframe)
3307 blueflag_statuschange_time = time;
3308 blueflag_prevstatus = blueflag_prevframe;
3309 blueflag_prevframe = blueflag;
3312 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
3313 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
3315 float BLINK_FACTOR = 0.15;
3316 float BLINK_BASE = 0.85;
3318 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
3320 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
3322 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
3324 string red_icon, red_icon_prevstatus;
3325 float red_alpha, red_alpha_prevstatus;
3326 red_alpha = red_alpha_prevstatus = 1;
3328 case 1: red_icon = "flag_red_taken"; break;
3329 case 2: red_icon = "flag_red_lost"; break;
3330 case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3332 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3333 red_icon = "flag_red_shielded";
3335 red_icon = string_null;
3338 switch(redflag_prevstatus) {
3339 case 1: red_icon_prevstatus = "flag_red_taken"; break;
3340 case 2: red_icon_prevstatus = "flag_red_lost"; break;
3341 case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3344 red_icon_prevstatus = "flag_red_carrying"; // make it more visible
3345 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
3346 red_icon_prevstatus = "flag_red_shielded";
3348 red_icon_prevstatus = string_null;
3352 string blue_icon, blue_icon_prevstatus;
3353 float blue_alpha, blue_alpha_prevstatus;
3354 blue_alpha = blue_alpha_prevstatus = 1;
3356 case 1: blue_icon = "flag_blue_taken"; break;
3357 case 2: blue_icon = "flag_blue_lost"; break;
3358 case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3360 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3361 blue_icon = "flag_blue_shielded";
3363 blue_icon = string_null;
3366 switch(blueflag_prevstatus) {
3367 case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
3368 case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
3369 case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
3372 blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
3373 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
3374 blue_icon_prevstatus = "flag_blue_shielded";
3376 blue_icon_prevstatus = string_null;
3380 if(mySize_x > mySize_y) {
3381 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3383 blueflag_pos = pos + eX * 0.5 * mySize_x;
3386 redflag_pos = pos + eX * 0.5 * mySize_x;
3388 flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
3390 if (myteam == COLOR_TEAM1) { // always draw own flag on left
3392 blueflag_pos = pos + eY * 0.5 * mySize_y;
3395 redflag_pos = pos + eY * 0.5 * mySize_y;
3397 flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
3400 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
3401 if(red_icon_prevstatus && f < 1)
3402 drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3404 drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
3406 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
3407 if(blue_icon_prevstatus && f < 1)
3408 drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
3410 drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
3413 // Keyhunt HUD modicon section
3414 float kh_runheretime;
3416 void HUD_Mod_KH_Reset(void)
3421 void HUD_Mod_KH(vector pos, vector mySize)
3423 mod_active = 1; // keyhunt should never hide the mod icons panel
3427 vector p, pa, kh_size, kh_asize;
3429 kh_keys = getstati(STAT_KH_KEYS);
3432 if(mySize_x > mySize_y)
3434 p_y = pos_y + 0.25 * mySize_y;
3435 pa = p - eY * 0.25 * mySize_y;
3437 kh_size_x = mySize_x * 0.25;
3438 kh_size_y = 0.75 * mySize_y;
3439 kh_asize_x = mySize_x * 0.25;
3440 kh_asize_y = mySize_y * 0.25;
3444 p_y = pos_y + 0.125 * mySize_y;
3445 pa = p - eY * 0.125 * mySize_y;
3447 kh_size_x = mySize_x * 0.5;
3448 kh_size_y = 0.375 * mySize_y;
3449 kh_asize_x = mySize_x * 0.5;
3450 kh_asize_y = mySize_y * 0.125;
3457 for(i = 0; i < 4; ++i)
3459 key = floor(kh_keys / pow(32, i)) & 31;
3461 if(keyteam == 30 && keycount <= 4)
3463 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
3467 // this yields 8 exactly if "RUN HERE" shows
3472 kh_runheretime = time;
3473 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
3478 for(i = 0; i < 4; ++i)
3480 key = floor(kh_keys / pow(32, i)) & 31;
3493 default: // owned or dropped
3498 a = a * panel_fg_alpha;
3499 aa = aa * panel_fg_alpha;
3505 drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3508 drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3511 drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3514 drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
3519 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
3522 drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3525 drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3528 drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3531 drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
3535 if(mySize_x > mySize_y)
3537 p_x += 0.25 * mySize_x;
3538 pa_x += 0.25 * mySize_x;
3544 p_y = pos_y + 0.625 * mySize_y;
3545 pa_y = pos_y + 0.5 * mySize_y;
3551 p_x += 0.5 * mySize_x;
3552 pa_x += 0.5 * mySize_x;
3558 // Keepaway HUD mod icon
3559 float kaball_prevstatus; // last remembered status
3560 float kaball_statuschange_time; // time when the status changed
3562 // we don't need to reset for keepaway since it immediately
3563 // autocorrects prevstatus as to if the player has the ball or not
3565 void HUD_Mod_Keepaway(vector pos, vector mySize)
3567 mod_active = 1; // keepaway should always show the mod HUD
3569 float BLINK_FACTOR = 0.15;
3570 float BLINK_BASE = 0.85;
3571 float BLINK_FREQ = 5;
3572 float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
3574 float stat_items = getstati(STAT_ITEMS);
3575 float kaball = (stat_items/IT_KEY1) & 1;
3577 if(kaball != kaball_prevstatus)
3579 kaball_statuschange_time = time;
3580 kaball_prevstatus = kaball;
3583 vector kaball_pos, kaball_size;
3585 if(mySize_x > mySize_y) {
3586 kaball_pos = pos + eX * 0.25 * mySize_x;
3587 kaball_size = eX * 0.5 * mySize_x + eY * mySize_y;
3589 kaball_pos = pos + eY * 0.25 * mySize_y;
3590 kaball_size = eY * 0.5 * mySize_y + eX * mySize_x;
3593 float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
3594 float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
3596 if(kaball_prevstatus && f < 1)
3597 drawpic_aspect_skin_expanding(kaball_pos, "keepawayball_carrying", kaball_size, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
3600 drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
3604 // Nexball HUD mod icon
3605 void HUD_Mod_NexBall(vector pos, vector mySize)
3607 float stat_items, nb_pb_starttime, dt, p;
3609 stat_items = getstati(STAT_ITEMS);
3610 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
3612 if (stat_items & IT_KEY1)
3617 //Manage the progress bar if any
3618 if (nb_pb_starttime > 0)
3620 dt = mod(time - nb_pb_starttime, nb_pb_period);
3621 // one period of positive triangle
3622 p = 2 * dt / nb_pb_period;
3627 HUD_Panel_GetProgressBarColor(nexball);
3628 if(mySize_x > mySize_y)
3629 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, 0, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3631 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, 1, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
3634 if (stat_items & IT_KEY1)
3635 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3638 // Race/CTS HUD mod icons
3639 float crecordtime_prev; // last remembered crecordtime
3640 float crecordtime_change_time; // time when crecordtime last changed
3641 float srecordtime_prev; // last remembered srecordtime
3642 float srecordtime_change_time; // time when srecordtime last changed
3644 float race_status_time;
3645 float race_status_prev;
3646 string race_status_name_prev;
3647 void HUD_Mod_Race(vector pos, vector mySize)
3649 mod_active = 1; // race should never hide the mod icons panel
3651 me = playerslots[player_localentnum - 1];
3653 float f; // yet another function has this
3654 score = me.(scores[ps_primary]);
3656 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
3657 return; // no records in the actual race
3659 // clientside personal record
3661 if(gametype == GAME_CTS)
3665 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
3667 if(score && (score < t || !t)) {
3668 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
3669 if(autocvar_cl_autodemo_delete_keeprecords)
3671 f = autocvar_cl_autodemo_delete;
3673 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
3677 if(t != crecordtime_prev) {
3678 crecordtime_prev = t;
3679 crecordtime_change_time = time;
3682 vector textPos, medalPos;
3684 if(mySize_x > mySize_y) {
3685 // text on left side
3686 squareSize = min(mySize_y, mySize_x/2);
3687 textPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eY * 0.5 * (mySize_y - squareSize);
3688 medalPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eX * 0.5 * mySize_x + eY * 0.5 * (mySize_y - squareSize);
3691 squareSize = min(mySize_x, mySize_y/2);
3692 textPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eX * 0.5 * (mySize_x - squareSize);
3693 medalPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eY * 0.5 * mySize_y + eX * 0.5 * (mySize_x - squareSize);
3696 f = time - crecordtime_change_time;
3699 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3700 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);
3702 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3703 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);
3704 drawstring_aspect_expanding(pos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
3705 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);
3709 t = race_server_record;
3710 if(t != srecordtime_prev) {
3711 srecordtime_prev = t;
3712 srecordtime_change_time = time;
3714 f = time - srecordtime_change_time;
3717 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3718 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);
3720 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3721 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);
3722 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);
3723 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);
3726 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
3727 race_status_time = time + 5;
3728 race_status_prev = race_status;
3729 if (race_status_name_prev)
3730 strunzone(race_status_name_prev);
3731 race_status_name_prev = strzone(race_status_name);
3736 a = bound(0, race_status_time - time, 1);
3739 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
3743 rank = race_CheckName(race_status_name);
3745 rankname = race_PlaceName(rank);
3748 namepos = medalPos + '0 0.8 0' * squareSize;
3750 rankpos = medalPos + '0 0.15 0' * squareSize;
3752 if(race_status == 0)
3753 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3754 else if(race_status == 1) {
3755 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);
3756 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3757 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3758 } else if(race_status == 2) {
3759 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
3760 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);
3762 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);
3763 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3764 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3765 } else if(race_status == 3) {
3766 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);
3767 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
3768 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
3771 if (race_status_time - time <= 0) {
3772 race_status_prev = -1;
3774 if(race_status_name)
3775 strunzone(race_status_name);
3776 race_status_name = string_null;
3777 if(race_status_name_prev)
3778 strunzone(race_status_name_prev);
3779 race_status_name_prev = string_null;
3783 void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, float layout, float i)
3785 float stat, pps_ratio;
3791 stat = getstatf(STAT_DOM_PPS_RED);
3792 pic = "dom_icon_red";
3796 stat = getstatf(STAT_DOM_PPS_BLUE);
3797 pic = "dom_icon_blue";
3801 stat = getstatf(STAT_DOM_PPS_YELLOW);
3802 pic = "dom_icon_yellow";
3806 stat = getstatf(STAT_DOM_PPS_PINK);
3807 pic = "dom_icon_pink";
3810 pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
3812 if(mySize_x/mySize_y > aspect_ratio)
3814 i = aspect_ratio * mySize_y;
3815 myPos_x = myPos_x + (mySize_x - i) / 2;
3820 i = 1/aspect_ratio * mySize_x;
3821 myPos_y = myPos_y + (mySize_y - i) / 2;
3825 if (layout) // show text too
3828 color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
3829 if (layout == 2) // average pps
3830 drawstring_aspect(myPos + eX * mySize_y, ftos_decimals(stat, 2), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
3831 else // percentage of average pps
3832 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);
3836 drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3839 drawsetcliparea(myPos_x, myPos_y + mySize_y * (1 - pps_ratio), mySize_y, mySize_y * pps_ratio);
3840 drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3841 drawresetcliparea();
3845 void HUD_Mod_Dom(vector myPos, vector mySize)
3847 mod_active = 1; // required in each mod function that always shows something
3850 for(tm = teams.sort_next; tm; tm = tm.sort_next)
3851 if(tm.team != COLOR_SPECTATOR)
3854 float layout = autocvar_hud_panel_modicons_dom_layout;
3855 float rows, columns, aspect_ratio;
3856 rows = mySize_y/mySize_x;
3857 aspect_ratio = (layout) ? 3 : 1;
3858 rows = bound(1, floor((sqrt((4 * aspect_ratio * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count);
3859 columns = ceil(teams_count/rows);
3863 for(i=0; i<teams_count; ++i)
3865 vector pos, itemSize;
3866 pos = myPos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows);
3867 itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
3869 DrawDomItem(pos, itemSize, aspect_ratio, layout, i);
3880 float mod_prev; // previous state of mod_active to check for a change
3882 float mod_change; // "time" when mod_active changed
3884 void HUD_ModIcons(void)
3886 if(!autocvar__hud_configure)
3888 if(!autocvar_hud_panel_modicons) return;
3889 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;
3892 hud_configure_active_panel = HUD_PANEL_MODICONS;
3894 HUD_Panel_UpdateCvars(modicons);
3897 mySize = panel_size;
3899 if(mod_active != mod_prev) {
3901 mod_prev = mod_active;
3904 if(mod_active || autocvar__hud_configure)
3905 mod_alpha = bound(0, (time - mod_change) * 2, 1);
3907 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
3910 HUD_Panel_DrawBg(mod_alpha);
3912 if(panel_bg_padding)
3914 pos += '1 1 0' * panel_bg_padding;
3915 mySize -= '2 2 0' * panel_bg_padding;
3918 // these MUST be ran in order to update mod_active
3919 if(gametype == GAME_KEYHUNT)
3920 HUD_Mod_KH(pos, mySize);
3921 else if(gametype == GAME_CTF || autocvar__hud_configure)
3922 HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
3923 else if(gametype == GAME_NEXBALL)
3924 HUD_Mod_NexBall(pos, mySize);
3925 else if(gametype == GAME_CTS || gametype == GAME_RACE)
3926 HUD_Mod_Race(pos, mySize);
3927 else if(gametype == GAME_CA || gametype == GAME_FREEZETAG)
3928 HUD_Mod_CA(pos, mySize);
3929 else if(gametype == GAME_DOMINATION)
3930 HUD_Mod_Dom(pos, mySize);
3931 else if(gametype == GAME_KEEPAWAY)
3932 HUD_Mod_Keepaway(pos, mySize);
3935 // Draw pressed keys (#11)
3937 void HUD_DrawPressedKeys(void)
3939 if(!autocvar__hud_configure)
3941 if(!autocvar_hud_panel_pressedkeys) return;
3942 if(spectatee_status <= 0 && autocvar_hud_panel_pressedkeys < 2) return;
3945 hud_configure_active_panel = HUD_PANEL_PRESSEDKEYS;
3948 HUD_Panel_UpdateCvars(pressedkeys);
3951 mySize = panel_size;
3953 HUD_Panel_DrawBg(1);
3954 if(panel_bg_padding)
3956 pos += '1 1 0' * panel_bg_padding;
3957 mySize -= '2 2 0' * panel_bg_padding;
3960 // force custom aspect
3961 float aspect = autocvar_hud_panel_pressedkeys_aspect;
3965 if(mySize_x/mySize_y > aspect)
3967 newSize_x = aspect * mySize_y;
3968 newSize_y = mySize_y;
3970 pos_x = pos_x + (mySize_x - newSize_x) / 2;
3974 newSize_y = 1/aspect * mySize_x;
3975 newSize_x = mySize_x;
3977 pos_y = pos_y + (mySize_y - newSize_y) / 2;
3983 keysize = eX * mySize_x * (1/3) + eY * mySize_y * 0.5;
3985 pressedkeys = getstatf(STAT_PRESSED_KEYS);
3987 drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3988 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);
3989 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);
3991 drawpic_aspect_skin(pos, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
3992 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);
3993 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);
3996 // Handle chat as a panel (#12)
4000 if(!autocvar__hud_configure)
4002 if (!autocvar_hud_panel_chat)
4004 if (!autocvar_con_chatrect)
4005 cvar_set("con_chatrect", "0");
4010 hud_configure_active_panel = HUD_PANEL_CHAT;
4012 HUD_Panel_UpdateCvars(chat);
4014 if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
4016 panel_pos_y = panel_bg_border;
4017 panel_size_y = vid_conheight - panel_bg_border * 2;
4018 if(panel_bg == "0") // force a border when maximized
4020 if(precache_pic(panel_bg) == "") {
4021 panel_bg = strcat(hud_skin_path, "/border_default");
4022 if(precache_pic(panel_bg) == "") {
4023 panel_bg = "gfx/hud/default/border_default";
4027 panel_bg_alpha = max(0.75, panel_bg_alpha); // force an alpha of at least 0.75
4032 mySize = panel_size;
4034 HUD_Panel_DrawBg(1);
4036 if(panel_bg_padding)
4038 pos += '1 1 0' * panel_bg_padding;
4039 mySize -= '2 2 0' * panel_bg_padding;
4042 if (!autocvar_con_chatrect)
4043 cvar_set("con_chatrect", "1");
4045 cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
4046 cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
4048 cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
4049 cvar_set("con_chat", ftos(floor(mySize_y/autocvar_con_chatsize - 0.5)));
4051 if(autocvar__hud_configure)
4054 chatsize = '1 1 0' * autocvar_con_chatsize;
4055 cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
4057 for(i = 0; i < autocvar_con_chat; ++i)
4059 if(i == autocvar_con_chat - 1)
4062 a = panel_fg_alpha * floor(((i + 1) * 7 + autocvar_con_chattime)/45);
4063 drawcolorcodedstring(pos, textShortenToWidth(_("^3Player^7: This is the chat area."), mySize_x, chatsize, stringwidth_colors), chatsize, a, DRAWFLAG_NORMAL);
4064 pos_y += chatsize_y;
4069 // Engine info panel (#13)
4076 float frametimeavg1; // 1 frame ago
4077 float frametimeavg2; // 2 frames ago
4078 void HUD_EngineInfo(void)
4080 if(!autocvar__hud_configure)
4082 if(!autocvar_hud_panel_engineinfo) return;
4085 hud_configure_active_panel = HUD_PANEL_ENGINEINFO;
4087 HUD_Panel_UpdateCvars(engineinfo);
4090 mySize = panel_size;
4092 HUD_Panel_DrawBg(1);
4093 if(panel_bg_padding)
4095 pos += '1 1 0' * panel_bg_padding;
4096 mySize -= '2 2 0' * panel_bg_padding;
4099 float currentTime = gettime(GETTIME_REALTIME);
4100 if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
4102 float currentframetime = currentTime - prevfps_time;
4103 frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
4104 frametimeavg2 = frametimeavg1;
4105 frametimeavg1 = frametimeavg;
4108 weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
4109 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.
4111 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
4112 prevfps = (1/currentframetime);
4113 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"
4115 prevfps_time = currentTime;
4120 if(currentTime - prevfps_time > autocvar_hud_panel_engineinfo_framecounter_time)
4122 prevfps = framecounter/(currentTime - prevfps_time);
4124 prevfps_time = currentTime;
4129 color = HUD_Get_Num_Color (prevfps, 100);
4130 drawstring_aspect(pos, sprintf(_("FPS: %.*f"), autocvar_hud_panel_engineinfo_framecounter_decimals, prevfps), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
4133 // Info messages panel (#14)
4135 #define drawInfoMessage(s)\
4136 if(autocvar_hud_panel_infomessages_flip)\
4137 o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\
4138 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
4140 void HUD_InfoMessages(void)
4142 if(!autocvar__hud_configure)
4144 if(!autocvar_hud_panel_infomessages) return;
4147 hud_configure_active_panel = HUD_PANEL_INFOMESSAGES;
4149 HUD_Panel_UpdateCvars(infomessages);
4152 mySize = panel_size;
4154 HUD_Panel_DrawBg(1);
4155 if(panel_bg_padding)
4157 pos += '1 1 0' * panel_bg_padding;
4158 mySize -= '2 2 0' * panel_bg_padding;
4161 // always force 5:1 aspect
4163 if(mySize_x/mySize_y > 5)
4165 newSize_x = 5 * mySize_y;
4166 newSize_y = mySize_y;
4168 pos_x = pos_x + (mySize_x - newSize_x) / 2;
4172 newSize_y = 1/5 * mySize_x;
4173 newSize_x = mySize_x;
4175 pos_y = pos_y + (mySize_y - newSize_y) / 2;
4184 fontsize = '0.20 0.20 0' * mySize_y;
4190 if(!autocvar__hud_configure)
4192 if(spectatee_status && !intermission)
4195 if(spectatee_status == -1)
4196 s = _("^1Observing");
4198 s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(spectatee_status - 1));
4201 if(spectatee_status == -1)
4202 s = sprintf(_("^1Press ^3%s^1 to spectate"), getcommandkey("primary fire", "+fire"));
4204 s = sprintf(_("^1Press ^3%s^1 for another player"), getcommandkey("primary fire", "+fire"));
4207 if(spectatee_status == -1)
4208 s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
4210 s = sprintf(_("^1Press ^3%s^1 to observe"), getcommandkey("secondary fire", "+fire2"));
4213 s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey("server info", "+show_info"));
4216 if(gametype == GAME_ARENA)
4217 s = _("^1Wait for your turn to join");
4218 else if(gametype == GAME_LMS)
4221 sk = playerslots[player_localentnum - 1];
4222 if(sk.(scores[ps_primary]) >= 666)
4223 s = _("^1Match has already begun");
4224 else if(sk.(scores[ps_primary]) > 0)
4225 s = _("^1You have no more lives left");
4227 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
4230 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
4233 //show restart countdown:
4234 if (time < getstatf(STAT_GAMESTARTTIME)) {
4236 //we need to ceil, otherwise the countdown would be off by .5 when using round()
4237 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
4238 s = sprintf(_("^1Game starts in ^3%d^1 seconds"), countdown);
4239 drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
4243 if(warmup_stage && !intermission)
4245 s = _("^2Currently in ^1warmup^2 stage!");
4250 if(mod(time, 1) >= 0.5)
4255 if(ready_waiting && !intermission && !spectatee_status)
4257 if(ready_waiting_for_me)
4260 s = sprintf(_("%sPress ^3%s%s to end warmup"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
4262 s = sprintf(_("%sPress ^3%s%s once you are ready"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
4267 s = _("^2Waiting for others to ready up to end warmup...");
4269 s = _("^2Waiting for others to ready up...");
4273 else if(warmup_stage && !intermission && !spectatee_status)
4275 s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey("ready", "ready"));
4279 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
4281 float ts_min, ts_max;
4282 tm = teams.sort_next;
4285 for(; tm.sort_next; tm = tm.sort_next)
4287 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
4289 if(!ts_min) ts_min = tm.team_size;
4290 else ts_min = min(ts_min, tm.team_size);
4291 if(!ts_max) ts_max = tm.team_size;
4292 else ts_max = max(ts_max, tm.team_size);
4294 if ((ts_max - ts_min) > 1)
4296 s = strcat(blinkcolor, _("Teamnumbers are unbalanced!"));
4297 tm = GetTeam(myteam, false);
4299 if (tm.team != COLOR_SPECTATOR)
4300 if (tm.team_size == ts_max)
4301 s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey("team menu", "menu_showteamselect"), blinkcolor));
4309 s = _("^7Press ^3ESC ^7to show HUD options.");
4311 s = _("^3Doubleclick ^7a panel for panel-specific options.");
4313 s = _("^3CTRL ^7to disable collision testing, ^3SHIFT ^7and");
4315 s = _("^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.");
4320 // Physics panel (#15)
4322 vector acc_prevspeed;
4323 float acc_prevtime, acc_avg, top_speed, top_speed_time;
4324 void HUD_Physics(void)
4326 if(!autocvar__hud_configure)
4328 if(!autocvar_hud_panel_physics) return;
4329 if(spectatee_status == -1 && autocvar_hud_panel_physics < 2) return;
4332 hud_configure_active_panel = HUD_PANEL_PHYSICS;
4334 HUD_Panel_UpdateCvars(physics);
4336 HUD_Panel_DrawBg(1);
4337 if(panel_bg_padding)
4339 panel_pos += '1 1 0' * panel_bg_padding;
4340 panel_size -= '2 2 0' * panel_bg_padding;
4344 float speed, conversion_factor;
4347 switch(autocvar_hud_panel_physics_speed_unit)
4352 conversion_factor = 1.0;
4356 conversion_factor = 0.0254;
4360 conversion_factor = 0.0254 * 3.6;
4364 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
4368 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
4372 float max_speed = floor( autocvar_hud_panel_physics_speed_max * conversion_factor + 0.5 );
4373 if (autocvar__hud_configure)
4374 speed = floor( max_speed * 0.65 + 0.5 );
4375 else if(autocvar_hud_panel_physics_speed_vertical)
4376 speed = floor( vlen(pmove_vel) * conversion_factor + 0.5 );
4378 speed = floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 );
4380 //compute acceleration
4381 float acceleration, f;
4382 if (autocvar__hud_configure)
4383 acceleration = autocvar_hud_panel_physics_acceleration_max * 0.3;
4386 // 1 m/s = 0.0254 qu/s; 1 g = 9.80665 m/s^2
4387 f = time - acc_prevtime;
4388 if(autocvar_hud_panel_physics_acceleration_vertical)
4389 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f) * (0.0254 / 9.80665);
4391 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);
4392 acc_prevspeed = pmove_vel;
4393 acc_prevtime = time;
4395 f = bound(0, f * 10, 1);
4396 acc_avg = acc_avg * (1 - f) + acceleration * f;
4400 float panel_ar = panel_size_x/panel_size_y;
4401 vector speed_offset, acceleration_offset;
4404 panel_size_x *= 0.5;
4405 if (autocvar_hud_panel_physics_flip)
4406 speed_offset_x = panel_size_x;
4408 acceleration_offset_x = panel_size_x;
4412 panel_size_y *= 0.5;
4413 if (autocvar_hud_panel_physics_flip)
4414 speed_offset_y = panel_size_y;
4416 acceleration_offset_y = panel_size_y;
4418 float speed_baralign, acceleration_baralign;
4419 if (autocvar_hud_panel_physics_baralign == 1)
4420 acceleration_baralign = speed_baralign = 1;
4421 else if(autocvar_hud_panel_physics_baralign == 4)
4422 acceleration_baralign = speed_baralign = 2;
4423 else if (autocvar_hud_panel_physics_flip)
4425 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 2);
4426 speed_baralign = (autocvar_hud_panel_physics_baralign == 3);
4430 speed_baralign = (autocvar_hud_panel_physics_baralign == 2);
4431 acceleration_baralign = (autocvar_hud_panel_physics_baralign == 3);
4433 if (autocvar_hud_panel_physics_acceleration_progressbar_mode == 0)
4434 acceleration_baralign = 3; //override hud_panel_physics_baralign value for acceleration
4438 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
4440 HUD_Panel_GetProgressBarColor(speed);
4441 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);
4443 vector tmp_offset, tmp_size;
4444 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
4446 tmp_size_x = panel_size_x * 0.75;
4447 tmp_size_y = panel_size_y;
4449 tmp_offset_x = panel_size_x - tmp_size_x;
4452 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4458 tmp_offset_x = tmp_size_x;
4459 if (autocvar_hud_panel_physics_speed_unit_show)
4462 tmp_size_x = panel_size_x * (1 - 0.75);
4463 tmp_size_y = panel_size_y * 0.4;
4464 drawstring_aspect(panel_pos + speed_offset + tmp_offset, unit, tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4468 //compute and draw top speed
4469 if (autocvar_hud_panel_physics_topspeed)
4470 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
4472 if (autocvar__hud_configure)
4474 top_speed = floor( max_speed * 0.75 + 0.5 );
4479 if (speed >= top_speed)
4482 top_speed_time = time;
4486 f = max(1, autocvar_hud_panel_physics_topspeed_time);
4487 // divide by f to make it start from 1
4488 f = cos( ((time - top_speed_time) / f) * PI/2 );
4490 else //hide top speed 0, it would be stupid
4495 //top speed progressbar peak
4496 if(speed < top_speed)
4497 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
4499 float peak_offset_x;
4501 if (speed_baralign == 0)
4502 peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x;
4503 else if (speed_baralign == 1)
4504 peak_offset_x = (1 - min(top_speed, max_speed)/max_speed) * panel_size_x;
4505 else if (speed_baralign == 2)
4506 peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x * 0.5;
4507 //if speed is not 0 the speed progressbar already fetched the color
4509 HUD_Panel_GetProgressBarColor(speed);
4510 peak_size_x = floor(panel_size_x * 0.01 + 1.5);
4511 peak_size_y = panel_size_y;
4512 if (speed_baralign == 2) // draw two peaks, on both sides
4514 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);
4515 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);
4518 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);
4522 tmp_offset_y = panel_size_y * 0.4;
4523 tmp_size_x = panel_size_x * (1 - 0.75);
4524 tmp_size_y = panel_size_y - tmp_offset_y;
4525 drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(top_speed), tmp_size, '1 0 0', f * panel_fg_alpha, DRAWFLAG_NORMAL);
4533 if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 3)
4535 if (acceleration < 0)
4536 HUD_Panel_GetProgressBarColor(acceleration_neg);
4538 HUD_Panel_GetProgressBarColor(acceleration);
4539 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);
4541 if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
4542 drawstring_aspect(panel_pos + acceleration_offset, strcat(ftos_decimals(acceleration, 2), "g"), panel_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
4551 void HUD_Reset (void)
4553 // reset gametype specific icons
4554 if(gametype == GAME_KEYHUNT)
4556 else if(gametype == GAME_CTF)
4557 HUD_Mod_CTF_Reset();
4560 #define HUD_DrawPanel(id)\
4562 case (HUD_PANEL_RADAR):\
4563 HUD_Radar(); break;\
4564 case (HUD_PANEL_WEAPONS):\
4565 HUD_Weapons(); break;\
4566 case (HUD_PANEL_AMMO):\
4568 case (HUD_PANEL_POWERUPS):\
4569 HUD_Powerups(); break;\
4570 case (HUD_PANEL_HEALTHARMOR):\
4571 HUD_HealthArmor(); break;\
4572 case (HUD_PANEL_NOTIFY):\
4573 HUD_Notify(); break;\
4574 case (HUD_PANEL_TIMER):\
4575 HUD_Timer(); break;\
4576 case (HUD_PANEL_SCORE):\
4577 HUD_Score(); break;\
4578 case (HUD_PANEL_RACETIMER):\
4579 HUD_RaceTimer(); break;\
4580 case (HUD_PANEL_VOTE):\
4581 HUD_VoteWindow(); break;\
4582 case (HUD_PANEL_MODICONS):\
4583 HUD_ModIcons(); break;\
4584 case (HUD_PANEL_PRESSEDKEYS):\
4585 HUD_DrawPressedKeys(); break;\
4586 case (HUD_PANEL_CHAT):\
4588 case (HUD_PANEL_ENGINEINFO):\
4589 HUD_EngineInfo(); break;\
4590 case (HUD_PANEL_INFOMESSAGES):\
4591 HUD_InfoMessages(); break;\
4592 case (HUD_PANEL_PHYSICS):\
4593 HUD_Physics(); break;\
4594 } ENDS_WITH_CURLY_BRACE
4596 void HUD_Main (void)
4599 // global hud alpha fade
4600 if(menu_enabled == 1)
4603 hud_fade_alpha = (1 - autocvar__menu_alpha);
4605 if(scoreboard_fade_alpha)
4606 hud_fade_alpha = (1 - scoreboard_fade_alpha);
4608 if(intermission == 2) // no hud during mapvote
4610 if (autocvar__hud_configure) //force exit from hud config
4615 localcmd("togglemenu\n");
4617 cvar_set("_hud_configure", "0");
4621 else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
4624 if(!autocvar__hud_configure && !hud_fade_alpha)
4628 if (hud_skin_path != autocvar_hud_skin)
4631 strunzone(hud_skin_path);
4632 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
4635 // HUD configure visible grid
4636 if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
4638 hud_configure_gridSize_x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
4639 hud_configure_gridSize_y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
4640 hud_configure_realGridSize_x = hud_configure_gridSize_x * vid_conwidth;
4641 hud_configure_realGridSize_y = hud_configure_gridSize_y * vid_conheight;
4643 for(i = 0; i < 1/hud_configure_gridSize_x; ++i)
4644 drawfill(eX * i * hud_configure_realGridSize_x, eX + eY * vid_conheight, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4646 for(i = 0; i < 1/hud_configure_gridSize_y; ++i)
4647 drawfill(eY * i * hud_configure_realGridSize_y, eY + eX * vid_conwidth, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
4650 current_player = (spectatee_status > 0) ? spectatee_status : player_localentnum;
4653 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
4657 float hud_dock_color_team = autocvar_hud_dock_color_team;
4658 if((teamplay) && hud_dock_color_team) {
4659 f = stof(getplayerkey(current_player - 1, "colors"));
4660 color = colormapPaletteColor(mod(f, 16), 1) * hud_dock_color_team;
4662 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
4663 color = '1 0 0' * hud_dock_color_team;
4667 string hud_dock_color = autocvar_hud_dock_color;
4668 if(hud_dock_color == "shirt") {
4669 f = stof(getplayerkey(current_player - 1, "colors"));
4670 color = colormapPaletteColor(floor(f / 16), 0);
4672 else if(hud_dock_color == "pants") {
4673 f = stof(getplayerkey(current_player - 1, "colors"));
4674 color = colormapPaletteColor(mod(f, 16), 1);
4677 color = stov(hud_dock_color);
4681 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
4682 if(precache_pic(pic) == "") {
4683 pic = strcat(hud_skin_path, "/dock_medium");
4684 if(precache_pic(pic) == "") {
4685 pic = "gfx/hud/default/dock_medium";
4688 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...
4691 // cache the panel order into the panel_order array
4692 if(autocvar__hud_panelorder != hud_panelorder_prev) {
4693 for(i = 0; i < HUD_PANEL_NUM; ++i)
4694 panel_order[i] = -1;
4696 float p_num, warning;
4697 float argc = tokenize_console(autocvar__hud_panelorder);
4698 if (argc > HUD_PANEL_NUM)
4700 //first detect wrong/missing panel numbers
4701 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4702 p_num = stof(argv(i));
4703 if (p_num >= 0 && p_num < HUD_PANEL_NUM) { //correct panel number?
4704 if (panel_order[p_num] == -1) //found for the first time?
4705 s = strcat(s, ftos(p_num), " ");
4706 panel_order[p_num] = 1; //mark as found
4711 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4712 if (panel_order[i] == -1) {
4714 s = strcat(s, ftos(i), " "); //add missing panel number
4718 print(_("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n"));
4720 cvar_set("_hud_panelorder", s);
4721 if(hud_panelorder_prev)
4722 strunzone(hud_panelorder_prev);
4723 hud_panelorder_prev = strzone(s);
4725 //now properly set panel_order
4726 tokenize_console(s);
4727 for(i = 0; i < HUD_PANEL_NUM; ++i) {
4728 panel_order[i] = stof(argv(i));
4732 // draw panels in order specified by panel_order array
4733 for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
4734 if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice!
4735 HUD_DrawPanel(panel_order[i]);
4738 // draw chat panel on top if it is maximized
4739 if(autocvar__con_chat_maximized)
4740 HUD_Chat(); // HUD_DrawPanel(HUD_PANEL_CHAT);
4742 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)
4743 localcmd("cmd selectteam auto; cmd join\n");
4745 if(autocvar__hud_configure)
4749 HUD_Panel_UpdatePosSizeForId(tab_panel)
4750 drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
4752 if(highlightedPanel != -1)
4754 HUD_Panel_UpdatePosSizeForId(highlightedPanel);
4755 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha));
4759 hud_configure_prev = autocvar__hud_configure;
4761 if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again