7 // a border picture is a texture containing nine parts:
8 // 1/4 width: left part
9 // 1/2 width: middle part (stretched)
10 // 1/4 width: right part
12 // 1/4 height: top part
13 // 1/2 height: middle part (stretched)
14 // 1/4 height: bottom part
15 void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize)
17 if (theBorderSize_x < 0 && theBorderSize_y < 0) // draw whole image as it is
19 drawpic(theOrigin, pic, theSize, theColor, theAlpha, 0);
22 if (theBorderSize_x == 0 && theBorderSize_y == 0) // no border
24 // draw only the central part
25 drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
32 //pic = draw_UseSkinFor(pic);
33 width = eX * theSize_x;
34 height = eY * theSize_y;
35 if(theSize_x <= theBorderSize_x * 2)
37 // not wide enough... draw just left and right then
38 bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
39 if(theSize_y <= theBorderSize_y * 2)
41 // not high enough... draw just corners
42 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
43 drawsubpic(theOrigin, width * 0.5 + height * 0.5, pic, '0 0 0', bW + bH, theColor, theAlpha, 0);
44 drawsubpic(theOrigin + width * 0.5, width * 0.5 + height * 0.5, pic, eX - bW, bW + bH, theColor, theAlpha, 0);
45 drawsubpic(theOrigin + height * 0.5, width * 0.5 + height * 0.5, pic, eY - bH, bW + bH, theColor, theAlpha, 0);
46 drawsubpic(theOrigin + theSize * 0.5, width * 0.5 + height * 0.5, pic, eX + eY - bW - bH, bW + bH, theColor, theAlpha, 0);
50 dY = theBorderSize_x * eY;
51 drawsubpic(theOrigin, width * 0.5 + dY, pic, '0 0 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
52 drawsubpic(theOrigin + width * 0.5, width * 0.5 + dY, pic, '0 0 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
53 drawsubpic(theOrigin + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0', '0 0.5 0' + bW, theColor, theAlpha, 0);
54 drawsubpic(theOrigin + width * 0.5 + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0' + eX - bW, '0 0.5 0' + bW, theColor, theAlpha, 0);
55 drawsubpic(theOrigin + height - dY, width * 0.5 + dY, pic, '0 0.75 0', '0 0.25 0' + bW, theColor, theAlpha, 0);
56 drawsubpic(theOrigin + width * 0.5 + height - dY, width * 0.5 + dY, pic, '0 0.75 0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
61 if(theSize_y <= theBorderSize_y * 2)
63 // not high enough... draw just top and bottom then
64 bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
65 dX = theBorderSize_x * eX;
66 drawsubpic(theOrigin, dX + height * 0.5, pic, '0 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
67 drawsubpic(theOrigin + dX, width - 2 * dX + height * 0.5, pic, '0.25 0 0', '0.5 0 0' + bH, theColor, theAlpha, 0);
68 drawsubpic(theOrigin + width - dX, dX + height * 0.5, pic, '0.75 0 0', '0.25 0 0' + bH, theColor, theAlpha, 0);
69 drawsubpic(theOrigin + height * 0.5, dX + height * 0.5, pic, '0 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
70 drawsubpic(theOrigin + dX + height * 0.5, width - 2 * dX + height * 0.5, pic, '0.25 0 0' + eY - bH, '0.5 0 0' + bH, theColor, theAlpha, 0);
71 drawsubpic(theOrigin + width - dX + height * 0.5, dX + height * 0.5, pic, '0.75 0 0' + eY - bH, '0.25 0 0' + bH, theColor, theAlpha, 0);
75 dX = theBorderSize_x * eX;
76 dY = theBorderSize_x * eY;
77 drawsubpic(theOrigin, dX + dY, pic, '0 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
78 drawsubpic(theOrigin + dX, width - 2 * dX + dY, pic, '0.25 0 0', '0.5 0.25 0', theColor, theAlpha, 0);
79 drawsubpic(theOrigin + width - dX, dX + dY, pic, '0.75 0 0', '0.25 0.25 0', theColor, theAlpha, 0);
80 drawsubpic(theOrigin + dY, dX + height - 2 * dY, pic, '0 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
81 drawsubpic(theOrigin + dY + dX, width - 2 * dX + height - 2 * dY, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
82 drawsubpic(theOrigin + dY + width - dX, dX + height - 2 * dY, pic, '0.75 0.25 0', '0.25 0.5 0', theColor, theAlpha, 0);
83 drawsubpic(theOrigin + height - dY, dX + dY, pic, '0 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
84 drawsubpic(theOrigin + height - dY + dX, width - 2 * dX + dY, pic, '0.25 0.75 0', '0.5 0.25 0', theColor, theAlpha, 0);
85 drawsubpic(theOrigin + height - dY + width - dX, dX + dY, pic, '0.75 0.75 0', '0.25 0.25 0', theColor, theAlpha, 0);
90 vector HUD_Get_Num_Color (float x, float maxvalue)
95 color_x = sin(2*M_PI*time);
97 color_z = sin(2*M_PI*time);
99 else if(x > maxvalue * 0.75) {
100 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
101 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
104 else if(x > maxvalue * 0.5) {
105 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
106 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
107 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
109 else if(x > maxvalue * 0.25) {
112 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
114 else if(x > maxvalue * 0.1) {
116 color_y = (x-20)*90/27/100; // green value between 0 -> 1
117 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
125 blinkingamt = (1 - x/maxvalue/0.25);
128 color_x = color_x - color_x * blinkingamt * sin(2*M_PI*time);
129 color_y = color_y - color_y * blinkingamt * sin(2*M_PI*time);
130 color_z = color_z - color_z * blinkingamt * sin(2*M_PI*time);
135 float stringwidth_colors(string s, vector theSize)
137 return stringwidth(s, TRUE, theSize);
140 float stringwidth_nocolors(string s, vector theSize)
142 return stringwidth(s, FALSE, theSize);
145 #define CENTERPRINT_MAX_LINES 30
146 string centerprint_messages[CENTERPRINT_MAX_LINES];
147 float centerprint_width[CENTERPRINT_MAX_LINES];
148 float centerprint_time;
149 float centerprint_expire;
150 float centerprint_num;
151 float centerprint_offset_hint;
152 vector centerprint_fontsize;
154 void centerprint(string strMessage)
156 float i, j, n, hcount;
159 centerprint_fontsize = HUD_GetFontsize("scr_centersize");
161 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
163 if(autocvar_scr_centertime <= 0)
169 // strip trailing newlines
170 j = strlen(strMessage) - 1;
171 while(substring(strMessage, j, 1) == "\n" && j >= 0)
173 strMessage = substring(strMessage, 0, j + 1);
178 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
180 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
182 strMessage = substring(strMessage, j, strlen(strMessage) - j);
183 centerprint_offset_hint = j;
188 // if we get here, we have a message. Initialize its height.
191 n = tokenizebyseparator(strMessage, "\n");
193 for(j = 0; j < n; ++j)
195 getWrappedLine_remaining = argv(j);
196 while(getWrappedLine_remaining)
198 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
199 if(centerprint_messages[i] != s) // don't fade the same message in, looks stupid
200 centerprint_time = time;
201 if(centerprint_messages[i])
202 strunzone(centerprint_messages[i]);
203 centerprint_messages[i] = strzone(s);
204 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
207 // half height for empty lines looks better
213 if(i >= CENTERPRINT_MAX_LINES)
219 h = centerprint_fontsize_y*hcount;
221 havail = vid_conheight;
222 if(autocvar_con_chatpos < 0)
223 havail -= (-autocvar_con_chatpos + autocvar_con_chat) * autocvar_con_chatsize; // avoid overlapping chat
224 if(havail > vid_conheight - 70)
225 havail = vid_conheight - 70; // avoid overlapping HUD
228 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
230 // here, the centerprint would cover the crosshair. REALLY BAD.
231 forbiddenmin = vid_conheight * 0.5 - h - 16;
232 forbiddenmax = vid_conheight * 0.5 + 16;
234 allowedmin = scoreboard_bottom;
235 allowedmax = havail - h;
236 preferred = (havail - h)/2;
239 // possible orderings (total: 4! / 4 = 6)
240 // allowedmin allowedmax forbiddenmin forbiddenmax
241 // forbiddenmin forbiddenmax allowedmin allowedmax
242 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
244 // forbidden doesn't matter in this case
245 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
247 // allowedmin forbiddenmin allowedmax forbiddenmax
248 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
250 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
252 // allowedmin forbiddenmin forbiddenmax allowedmax
253 else if(allowedmin < forbiddenmin)
255 // make sure the forbidden zone is not covered
256 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
257 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
259 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
261 // forbiddenmin allowedmin allowedmax forbiddenmax
262 else if(allowedmax < forbiddenmax)
264 // it's better to leave the allowed zone (overlap with scoreboard) than
265 // to cover the forbidden zone (crosshair)
266 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
267 centerprint_start_y = forbiddenmax;
269 centerprint_start_y = forbiddenmin;
271 // forbiddenmin allowedmin forbiddenmax allowedmax
274 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
281 centerprint_expire = time + autocvar_scr_centertime;
284 void HUD_DrawCenterPrint (void)
291 if(time - centerprint_time < 0.25)
292 a = (time - centerprint_time) / 0.25;
294 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
301 if(centerprint_num * autocvar_scr_centersize > 24 && scoreboard_active) // 24 = height of Scoreboard text
302 centerprint_start_y = scoreboard_bottom + centerprint_fontsize_y;
304 pos = centerprint_start;
305 for (i=0; i<centerprint_num; i = i + 1)
307 ts = centerprint_messages[i];
308 drawfontscale = sz * '1 1 0';
309 pos_x = (vid_conwidth - stringwidth(ts, TRUE, centerprint_fontsize)) * 0.5;
312 drawcolorcodedstring(pos + '0 1 0' * (1 - sz) * 0.5 *centerprint_fontsize_y, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
313 pos_y = pos_y + centerprint_fontsize_y;
316 // half height for empty lines looks better
317 pos_y = pos_y + sz * centerprint_fontsize_y * 0.5;
318 drawfontscale = '1 1 0';
322 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
324 position_x -= 2 / 3 * strlen(text) * scale_x;
325 drawstring(position, text, scale, rgb, alpha, flag);
328 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
330 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
331 drawstring(position, text, scale, rgb, alpha, flag);
334 // return the string of the given race place
335 string race_PlaceName(float pos) {
343 return sprintf(_("%dth"), pos);
346 // return the string of the onscreen race timer
347 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
355 if(histime == 0) // goal hit
359 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
369 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
375 lapstr = sprintf(_(" (-%dL)"), lapdelta);
378 else if(lapdelta < 0)
380 lapstr = sprintf(_(" (+%dL)"), -lapdelta);
384 else if(histime > 0) // anticipation
386 if(mytime >= histime)
387 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
389 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
396 cpname = _("Start line");
398 cpname = _("Finish line");
400 cpname = sprintf(_("Intermediate %d"), cp);
402 cpname = _("Finish line");
405 return strcat(col, cpname);
406 else if(hisname == "")
407 return strcat(col, sprintf(_("%s (%s)"), cpname, timestr));
409 return strcat(col, sprintf(_("%s (%s %s)"), cpname, timestr, strcat(hisname, col, lapstr)));
412 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
413 float race_CheckName(string net_name) {
415 for (i=RANKINGS_CNT-1;i>=0;--i)
416 if(grecordholder[i] == net_name)
427 // draw the background/borders
428 #define HUD_Panel_DrawBg(alpha)\
430 draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * alpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\
431 if(highlightedPanel == hud_configure_active_panel && autocvar__hud_configure)\
433 HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);\
434 } ENDS_WITH_CURLY_BRACE
436 //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
437 void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, float vertical, float baralign, vector theColor, float theAlpha, float drawflag)
439 if(!length_ratio || !theAlpha)
445 if(length_ratio < -1)
448 else if(length_ratio < 0)
452 vector width, height;
454 pic = strcat(hud_skin_path, "/", pic, "_vertical");
455 if(precache_pic(pic) == "") {
456 pic = "gfx/hud/default/progressbar_vertical";
459 if (baralign == 1) // bottom align
460 theOrigin_y += (1 - length_ratio) * theSize_y;
461 else if (baralign == 2) // center align
462 theOrigin_y += 0.5 * (1 - length_ratio) * theSize_y;
463 else if (baralign == 3) // center align, positive values down, negative up
466 if (length_ratio > 0)
467 theOrigin_y += theSize_y;
470 theOrigin_y += (1 + length_ratio) * theSize_y;
471 length_ratio = -length_ratio;
474 theSize_y *= length_ratio;
477 width = eX * theSize_x;
478 height = eY * theSize_y;
479 if(theSize_y <= theSize_x * 2)
481 // button not high enough
482 // draw just upper and lower part then
483 square = eY * theSize_y * 0.5;
484 bH = eY * (0.25 * theSize_y / (theSize_x * 2));
485 drawsubpic(theOrigin, square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, drawflag);
486 drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, drawflag);
490 square = eY * theSize_x;
491 drawsubpic(theOrigin, width + square, pic, '0 0 0', '1 0.25 0', theColor, theAlpha, drawflag);
492 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5 0', theColor, theAlpha, drawflag);
493 drawsubpic(theOrigin + height - square, width + square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, drawflag);
496 pic = strcat(hud_skin_path, "/", pic);
497 if(precache_pic(pic) == "") {
498 pic = "gfx/hud/default/progressbar";
501 if (baralign == 1) // right align
502 theOrigin_x += (1 - length_ratio) * theSize_x;
503 else if (baralign == 2) // center align
504 theOrigin_x += 0.5 * (1 - length_ratio) * theSize_x;
505 else if (baralign == 3) // center align, positive values on the right, negative on the left
508 if (length_ratio > 0)
509 theOrigin_x += theSize_x;
512 theOrigin_x += (1 + length_ratio) * theSize_x;
513 length_ratio = -length_ratio;
516 theSize_x *= length_ratio;
519 width = eX * theSize_x;
520 height = eY * theSize_y;
521 if(theSize_x <= theSize_y * 2)
523 // button not wide enough
524 // draw just left and right part then
525 square = eX * theSize_x * 0.5;
526 bW = eX * (0.25 * theSize_x / (theSize_y * 2));
527 drawsubpic(theOrigin, square + height, pic, '0 0 0', eY + bW, theColor, theAlpha, drawflag);
528 drawsubpic(theOrigin + square, square + height, pic, eX - bW, eY + bW, theColor, theAlpha, drawflag);
532 square = eX * theSize_y;
533 drawsubpic(theOrigin, height + square, pic, '0 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
534 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0.25 0 0', '0.5 1 0', theColor, theAlpha, drawflag);
535 drawsubpic(theOrigin + width - square, height + square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
540 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alpha, float drawflag)
546 pic = strcat(hud_skin_path, "/num_leading");
547 if(precache_pic(pic) == "") {
548 pic = "gfx/hud/default/num_leading";
551 drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, alpha, drawflag);
552 if(mySize_x/mySize_y > 2)
553 drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, pic, '0.25 0 0', '0.5 1 0', color, alpha, drawflag);
554 drawsubpic(pos + eX * mySize_x - eX * min(mySize_x * 0.5, mySize_y), eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0.75 0 0', '0.25 1 0', color, alpha, drawflag);
559 entity weaponorder[WEP_MAXCOUNT];
560 void weaponorder_swap(float i, float j, entity pass)
564 weaponorder[i] = weaponorder[j];
568 string weaponorder_cmp_str;
569 float weaponorder_cmp(float i, float j, entity pass)
572 ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
573 aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
574 return aj - ai; // the string is in REVERSE order (higher prio at the right is what we want, but higher prio first is the string)
577 float GetAmmoStat(float i)
581 case 0: return STAT_SHELLS;
582 case 1: return STAT_NAILS;
583 case 2: return STAT_ROCKETS;
584 case 3: return STAT_CELLS;
585 case 4: return STAT_FUEL;
590 float GetAmmoTypeForWep(float i)
594 case WEP_SHOTGUN: return 0;
595 case WEP_UZI: return 1;
596 case WEP_GRENADE_LAUNCHER: return 2;
597 case WEP_MINE_LAYER: return 2;
598 case WEP_ELECTRO: return 3;
599 case WEP_CRYLINK: return 3;
600 case WEP_HLAC: return 3;
601 case WEP_MINSTANEX: return 3;
602 case WEP_NEX: return 3;
603 case WEP_SNIPERRIFLE: return 1;
604 case WEP_HAGAR: return 2;
605 case WEP_ROCKET_LAUNCHER: return 2;
606 case WEP_SEEKER: return 2;
607 case WEP_FIREBALL: return 4;
608 case WEP_HOOK: return 3;
613 void HUD_Weapons(void)
616 float center_x, center_y;
618 if(!autocvar__hud_configure)
620 if(!autocvar_hud_panel_weapons) return;
621 if(spectatee_status == -1) return;
624 hud_configure_active_panel = HUD_PANEL_WEAPONS;
626 float timeout = autocvar_hud_panel_weapons_timeout;
627 float timeout_effect_length, timein_effect_length;
628 if (autocvar_hud_panel_weapons_timeout_effect == 0)
630 timeout_effect_length = 0;
631 timein_effect_length = 0;
635 timeout_effect_length = 0.75;
636 timein_effect_length = 0.375;
639 if (timeout && time >= weapontime + timeout + timeout_effect_length && !autocvar__hud_configure)
641 weaponprevtime = time;
645 HUD_Panel_UpdateCvars(weapons);
647 if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
649 f = (time - (weapontime + timeout)) / timeout_effect_length;
650 if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3)
652 panel_bg_alpha *= (1 - f);
653 panel_fg_alpha *= (1 - f);
655 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
657 f *= f; // for a cooler movement
658 center_x = panel_pos_x + panel_size_x/2;
659 center_y = panel_pos_y + panel_size_y/2;
660 screen_ar = vid_conwidth/vid_conheight;
661 if (center_x/center_y < screen_ar) //bottom left
663 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
664 panel_pos_y += f * (vid_conheight - panel_pos_y);
666 panel_pos_x -= f * (panel_pos_x + panel_size_x);
670 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
671 panel_pos_x += f * (vid_conwidth - panel_pos_x);
673 panel_pos_y -= f * (panel_pos_y + panel_size_y);
676 weaponprevtime = time - (1 - f) * timein_effect_length;
678 else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure)
680 f = (time - weaponprevtime) / timein_effect_length;
681 if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3)
683 panel_bg_alpha *= (f);
684 panel_fg_alpha *= (f);
686 if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
688 f *= f; // for a cooler movement
690 center_x = panel_pos_x + panel_size_x/2;
691 center_y = panel_pos_y + panel_size_y/2;
692 screen_ar = vid_conwidth/vid_conheight;
693 if (center_x/center_y < screen_ar) //bottom left
695 if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
696 panel_pos_y += f * (vid_conheight - panel_pos_y);
698 panel_pos_x -= f * (panel_pos_x + panel_size_x);
702 if ((vid_conwidth - center_x)/center_y < screen_ar) //right
703 panel_pos_x += f * (vid_conwidth - panel_pos_x);
705 panel_pos_y -= f * (panel_pos_y + panel_size_y);
710 float i, weapid, wpnalpha, weapon_cnt;
712 // TODO make this configurable
713 if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
715 if(weaponorder_bypriority)
716 strunzone(weaponorder_bypriority);
717 if(weaponorder_byimpulse)
718 strunzone(weaponorder_byimpulse);
720 weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
721 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
722 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
725 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
727 self = get_weaponinfo(i);
728 if(self.impulse >= 0)
730 weaponorder[weapon_cnt] = self;
734 for(i = weapon_cnt; i < WEP_MAXCOUNT; ++i)
735 weaponorder[i] = NULL;
736 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
738 weaponorder_cmp_str = string_null;
744 panel_pos += '1 1 0' * panel_bg_padding;
745 panel_size -= '2 2 0' * panel_bg_padding;
748 if(autocvar_hud_panel_weapons_fade)
750 wpnalpha = 3.2 - 2 * (time - weapontime);
751 wpnalpha = bound(0.7, wpnalpha, 1) * panel_fg_alpha;
754 wpnalpha = panel_fg_alpha;
757 float aspect = autocvar_hud_panel_weapons_aspect;
758 rows = panel_size_y/panel_size_x;
759 rows = bound(1, floor((sqrt(4 * aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
761 columns = ceil(WEP_COUNT/rows);
764 float a, type, fullammo;
766 when = autocvar_hud_panel_weapons_complainbubble_time;
768 fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
776 wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
777 float barsize_x, barsize_y, baroffset_x, baroffset_y;
778 if (autocvar_hud_panel_weapons_ammo)
780 ammo_color = stov(autocvar_hud_panel_weapons_ammo_color);
781 ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha;
784 if(wpnsize_x/wpnsize_y > aspect)
786 barsize_x = aspect * wpnsize_y;
787 barsize_y = wpnsize_y;
788 baroffset_x = (wpnsize_x - barsize_x) / 2;
792 barsize_y = 1/aspect * wpnsize_x;
793 barsize_x = wpnsize_x;
794 baroffset_y = (wpnsize_y - barsize_y) / 2;
800 if(autocvar_hud_panel_weapons_accuracy && acc_levels)
802 show_accuracy = true;
803 if (acc_col_x[0] == -1)
804 for (i = 0; i < acc_levels; ++i)
805 acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
808 float weapons_st = getstati(STAT_WEAPONS);
810 for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
812 self = weaponorder[i];
813 if (!self || self.impulse < 0)
815 wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
817 weapid = self.impulse;
819 // draw background behind currently selected weapon
820 if(self.weapon == activeweapon)
821 drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
823 // draw the weapon accuracy
826 weapon_stats = weapon_accuracy[self.weapon-WEP_FIRST];
827 if(weapon_stats >= 0)
829 // find the max level lower than weapon_stats
832 while ( j && weapon_stats < acc_lev[j] )
835 // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
837 factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
839 color = color + factor * (acc_col[j+1] - color);
841 drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
845 // draw the weapon icon
846 if(weapons_st & self.weapons)
848 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
850 if(autocvar_hud_panel_weapons_label == 1) // weapon number
851 drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
852 else if(autocvar_hud_panel_weapons_label == 2) // bind
853 drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
855 // draw ammo status bar
856 if(autocvar_hud_panel_weapons_ammo && self.weapon != WEP_TUBA && self.weapon != WEP_LASER && self.weapon != WEP_PORTO)
859 type = GetAmmoTypeForWep(self.weapon);
861 a = getstati(GetAmmoStat(type)); // how much ammo do we have?
866 case 0: fullammo = autocvar_hud_panel_weapons_ammo_full_shells; break;
867 case 1: fullammo = autocvar_hud_panel_weapons_ammo_full_nails; break;
868 case 2: fullammo = autocvar_hud_panel_weapons_ammo_full_rockets; break;
869 case 3: fullammo = autocvar_hud_panel_weapons_ammo_full_cells; break;
870 case 4: fullammo = autocvar_hud_panel_weapons_ammo_full_fuel; break;
871 default: fullammo = 60;
875 wpnpos_x + baroffset_x,
876 wpnpos_y + baroffset_y,
877 barsize_x * bound(0, a/fullammo, 1),
879 drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, ammo_color, ammo_alpha, DRAWFLAG_NORMAL);
885 // draw a "ghost weapon icon" if you don't have the weapon
888 drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
891 // draw the complain message
892 if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
896 if(complain_weapon_time + when > time)
899 a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
903 if(complain_weapon_time + when > time)
910 if(complain_weapon_type == 0) {
911 s = _("Out of ammo");
912 color = stov(autocvar_hud_panel_weapons_complainbubble_color_outofammo);
914 else if(complain_weapon_type == 1) {
916 color = stov(autocvar_hud_panel_weapons_complainbubble_color_donthave);
919 s = _("Unavailable");
920 color = stov(autocvar_hud_panel_weapons_complainbubble_color_unavailable);
922 float padding = autocvar_hud_panel_weapons_complainbubble_padding;
923 drawpic_aspect_skin(wpnpos + '1 1 0' * padding, "weapon_complainbubble", wpnsize - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
924 drawstring_aspect(wpnpos + '1 1 0' * padding, s, wpnsize - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
940 float GetAmmoItemCode(float i)
944 case 0: return IT_SHELLS;
945 case 1: return IT_NAILS;
946 case 2: return IT_ROCKETS;
947 case 3: return IT_CELLS;
948 case 4: return IT_FUEL;
953 string GetAmmoPicture(float i)
957 case 0: return "ammo_shells";
958 case 1: return "ammo_bullets";
959 case 2: return "ammo_rockets";
960 case 3: return "ammo_cells";
961 case 4: return "ammo_fuel";
966 void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected, float infinite_ammo)
969 if(autocvar__hud_configure)
971 currently_selected = (itemcode == 2); //rockets always selected
972 a = 31 + mod(itemcode*93, 128);
975 a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
979 color = '0 0.5 0.75';
986 if(currently_selected)
991 vector picpos, numpos;
992 if(autocvar_hud_panel_ammo_iconalign)
995 picpos = myPos + eX * 2 * mySize_y;
999 numpos = myPos + eX * mySize_y;
1003 if (currently_selected)
1004 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
1006 if(a > 0 && autocvar_hud_panel_ammo_progressbar)
1007 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);
1009 if(autocvar_hud_panel_ammo_text)
1011 if(a > 0 || infinite_ammo)
1012 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1013 else // "ghost" ammo count
1014 drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1016 if(a > 0 || infinite_ammo)
1017 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1018 else // "ghost" ammo icon
1019 drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
1024 if(!autocvar__hud_configure)
1026 if(!autocvar_hud_panel_ammo) return;
1027 if(spectatee_status == -1) return;
1030 hud_configure_active_panel = HUD_PANEL_AMMO;
1032 HUD_Panel_UpdateCvars(ammo);
1035 mySize = panel_size;
1037 HUD_Panel_DrawBg(1);
1038 if(panel_bg_padding)
1040 pos += '1 1 0' * panel_bg_padding;
1041 mySize -= '2 2 0' * panel_bg_padding;
1044 float rows, columns, row, column;
1046 if (autocvar_hud_panel_ammo_onlycurrent)
1050 rows = mySize_y/mySize_x;
1051 rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
1052 // ^^^ ammo item aspect goes here
1054 columns = ceil(AMMO_COUNT/rows);
1056 ammo_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
1061 if(ammo_size_x/ammo_size_y > 3)
1063 newSize = 3 * ammo_size_y;
1064 offset_x = ammo_size_x - newSize;
1065 pos_x += offset_x/2;
1066 ammo_size_x = newSize;
1070 newSize = 1/3 * ammo_size_x;
1071 offset_y = ammo_size_y - newSize;
1072 pos_y += offset_y/2;
1073 ammo_size_y = newSize;
1076 float i, stat_items, currently_selected, infinite_ammo;
1077 infinite_ammo = FALSE;
1078 if (autocvar_hud_panel_ammo_onlycurrent)
1080 if(autocvar__hud_configure)
1082 DrawAmmoItem(pos, ammo_size, 2, true, FALSE); //show rockets
1085 stat_items = getstati(STAT_ITEMS);
1086 if (stat_items & IT_UNLIMITED_WEAPON_AMMO)
1087 infinite_ammo = TRUE;
1088 for (i = 0; i < AMMO_COUNT; ++i) {
1089 currently_selected = stat_items & GetAmmoItemCode(i);
1090 if (currently_selected)
1092 DrawAmmoItem(pos, ammo_size, i, true, infinite_ammo);
1096 return; // nothing to display
1099 stat_items = getstati(STAT_ITEMS);
1100 if (stat_items & IT_UNLIMITED_WEAPON_AMMO)
1101 infinite_ammo = TRUE;
1102 for (i = 0; i < AMMO_COUNT; ++i) {
1103 currently_selected = stat_items & GetAmmoItemCode(i);
1104 DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected, infinite_ammo);
1109 column = column + 1;
1114 void DrawNumIcon(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float alpha)
1116 vector newPos, newSize;
1117 vector picpos, numpos;
1121 if(mySize_y/mySize_x > 2)
1123 newSize_y = 2 * mySize_x;
1124 newSize_x = mySize_x;
1126 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1131 newSize_x = 1/2 * mySize_y;
1132 newSize_y = mySize_y;
1134 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1138 if(icon_right_align)
1141 picpos = newPos + eY * newSize_x;
1146 numpos = newPos + eY * newSize_x;
1150 drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1151 // make number smaller than icon, it looks better
1152 // reduce only y to draw numbers with different number of digits with the same y size
1153 numpos_y += newSize_y * ((1 - 0.7) / 2);
1155 drawstring_aspect(numpos, ftos(x), newSize, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1159 if(mySize_x/mySize_y > 3)
1161 newSize_x = 3 * mySize_y;
1162 newSize_y = mySize_y;
1164 newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
1169 newSize_y = 1/3 * mySize_x;
1170 newSize_x = mySize_x;
1172 newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
1176 if(icon_right_align) // right align
1179 picpos = newPos + eX * 2 * newSize_y;
1183 numpos = newPos + eX * newSize_y;
1187 drawstring_aspect(numpos, ftos(x), '2 1 0' * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1188 drawpic_aspect_skin(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
1191 void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float fadelerp)
1194 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
1196 DrawNumIcon(myPos + expandingbox_resize_centered_box_offset(sz, mySize, 1), mySize * sz, x, icon, vertical, icon_right_align, color, (1 - fadelerp));
1201 void HUD_Powerups(void)
1203 float strength_time, shield_time;
1204 if(!autocvar__hud_configure)
1206 if(!autocvar_hud_panel_powerups) return;
1207 if(spectatee_status == -1) return;
1208 if not(getstati(STAT_ITEMS) & (IT_STRENGTH | IT_INVINCIBLE)) return;
1209 if (getstati(STAT_HEALTH) <= 0) return;
1211 strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
1212 shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
1216 hud_configure_active_panel = HUD_PANEL_POWERUPS;
1222 HUD_Panel_UpdateCvars(powerups);
1225 mySize = panel_size;
1227 HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
1228 if(panel_bg_padding)
1230 pos += '1 1 0' * panel_bg_padding;
1231 mySize -= '2 2 0' * panel_bg_padding;
1234 float panel_ar = mySize_x/mySize_y;
1235 float is_vertical = (panel_ar < 1);
1236 vector shield_offset, strength_offset;
1237 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1240 if (autocvar_hud_panel_powerups_flip)
1241 shield_offset_x = mySize_x;
1243 strength_offset_x = mySize_x;
1248 if (autocvar_hud_panel_powerups_flip)
1249 shield_offset_y = mySize_y;
1251 strength_offset_y = mySize_y;
1254 float shield_baralign, strength_baralign;
1255 float shield_iconalign, strength_iconalign;
1256 if (autocvar_hud_panel_powerups_flip)
1258 strength_baralign = (autocvar_hud_panel_powerups_baralign == 2 || autocvar_hud_panel_powerups_baralign == 1);
1259 shield_baralign = (autocvar_hud_panel_powerups_baralign == 3 || autocvar_hud_panel_powerups_baralign == 1);
1260 strength_iconalign = (autocvar_hud_panel_powerups_iconalign == 2 || autocvar_hud_panel_powerups_iconalign == 1);
1261 shield_iconalign = (autocvar_hud_panel_powerups_iconalign == 3 || autocvar_hud_panel_powerups_iconalign == 1);
1265 shield_baralign = (autocvar_hud_panel_powerups_baralign == 2 || autocvar_hud_panel_powerups_baralign == 1);
1266 strength_baralign = (autocvar_hud_panel_powerups_baralign == 3 || autocvar_hud_panel_powerups_baralign == 1);
1267 shield_iconalign = (autocvar_hud_panel_powerups_iconalign == 2 || autocvar_hud_panel_powerups_iconalign == 1);
1268 strength_iconalign = (autocvar_hud_panel_powerups_iconalign == 3 || autocvar_hud_panel_powerups_iconalign == 1);
1273 const float maxshield = 30;
1274 float shield = ceil(shield_time);
1275 if(autocvar_hud_panel_powerups_progressbar)
1277 HUD_Panel_GetProgressBarColor(shield);
1278 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);
1280 if(autocvar_hud_panel_powerups_text)
1283 DrawNumIcon(pos + shield_offset, mySize, shield, "shield", is_vertical, shield_iconalign, '1 1 1', 1);
1285 DrawNumIcon_expanding(pos + shield_offset, mySize, shield, "shield", is_vertical, shield_iconalign, '1 1 1', bound(0, (shield - shield_time) / 0.5, 1));
1291 const float maxstrength = 30;
1292 float strength = ceil(strength_time);
1293 if(autocvar_hud_panel_powerups_progressbar)
1295 HUD_Panel_GetProgressBarColor(strength);
1296 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);
1298 if(autocvar_hud_panel_powerups_text)
1301 DrawNumIcon(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', 1);
1303 DrawNumIcon_expanding(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', bound(0, (strength - strength_time) / 0.5, 1));
1308 // Health/armor (#3)
1311 // prev_* vars contain the health/armor at the previous FRAME
1312 // set to -1 when player is dead or was not playing
1313 float prev_health, prev_armor;
1314 float health_damagetime, armor_damagetime;
1315 float health_beforedamage, armor_beforedamage;
1316 // old_p_* vars keep track of previous values when smoothing value changes of the progressbar
1317 float old_p_health, old_p_armor;
1318 float old_p_healthtime, old_p_armortime;
1319 // prev_p_* vars contain the health/armor progressbar value at the previous FRAME
1320 // set to -1 to forcedly stop effects when we switch spectated player (e.g. from playerX: 70h to playerY: 50h)
1321 float prev_p_health, prev_p_armor;
1323 void HUD_HealthArmor(void)
1325 float armor, health, fuel;
1326 if(!autocvar__hud_configure)
1328 if(!autocvar_hud_panel_healtharmor) return;
1329 if(spectatee_status == -1) return;
1331 health = getstati(STAT_HEALTH);
1337 armor = getstati(STAT_ARMOR);
1339 // code to check for spectatee_status changes is in Ent_ClientData()
1340 // prev_p_health and prev_health can be set to -1 there
1342 if (prev_p_health == -1)
1345 health_beforedamage = 0;
1346 armor_beforedamage = 0;
1347 health_damagetime = 0;
1348 armor_damagetime = 0;
1349 prev_health = health;
1351 old_p_health = health;
1352 old_p_armor = armor;
1353 prev_p_health = health;
1354 prev_p_armor = armor;
1356 else if (prev_health == -1)
1358 //start the load effect
1359 health_damagetime = 0;
1360 armor_damagetime = 0;
1364 fuel = getstati(STAT_FUEL);
1368 hud_configure_active_panel = HUD_PANEL_HEALTHARMOR;
1375 HUD_Panel_UpdateCvars(healtharmor);
1378 mySize = panel_size;
1380 HUD_Panel_DrawBg(1);
1381 if(panel_bg_padding)
1383 pos += '1 1 0' * panel_bg_padding;
1384 mySize -= '2 2 0' * panel_bg_padding;
1387 float baralign = autocvar_hud_panel_healtharmor_baralign;
1388 float iconalign = autocvar_hud_panel_healtharmor_iconalign;
1390 float maxhealth = autocvar_hud_panel_healtharmor_maxhealth;
1391 float maxarmor = autocvar_hud_panel_healtharmor_maxarmor;
1392 if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
1395 v = healtharmor_maxdamage(health, armor, armorblockpercent);
1400 float maxtotal = maxhealth + maxarmor;
1402 if(v_z) // NOT fully armored
1404 biggercount = "health";
1405 if(autocvar_hud_panel_healtharmor_progressbar)
1407 HUD_Panel_GetProgressBarColor(health);
1408 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);
1411 if(autocvar_hud_panel_healtharmor_text)
1412 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);
1416 biggercount = "armor";
1417 if(autocvar_hud_panel_healtharmor_progressbar)
1419 HUD_Panel_GetProgressBarColor(armor);
1420 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);
1423 if(autocvar_hud_panel_healtharmor_text)
1424 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);
1426 if(autocvar_hud_panel_healtharmor_text)
1427 DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, maxtotal), 1);
1431 HUD_Panel_GetProgressBarColor(fuel);
1432 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);
1437 float panel_ar = mySize_x/mySize_y;
1438 float is_vertical = (panel_ar < 1);
1439 vector health_offset, armor_offset;
1440 if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
1443 if (autocvar_hud_panel_healtharmor_flip)
1444 health_offset_x = mySize_x;
1446 armor_offset_x = mySize_x;
1451 if (autocvar_hud_panel_healtharmor_flip)
1452 health_offset_y = mySize_y;
1454 armor_offset_y = mySize_y;
1457 float health_baralign, armor_baralign, fuel_baralign;
1458 float health_iconalign, armor_iconalign;
1459 if (autocvar_hud_panel_healtharmor_flip)
1461 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1462 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1463 fuel_baralign = health_baralign;
1464 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1465 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1469 health_baralign = (autocvar_hud_panel_healtharmor_baralign == 2 || autocvar_hud_panel_healtharmor_baralign == 1);
1470 armor_baralign = (autocvar_hud_panel_healtharmor_baralign == 3 || autocvar_hud_panel_healtharmor_baralign == 1);
1471 fuel_baralign = armor_baralign;
1472 health_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 2 || autocvar_hud_panel_healtharmor_iconalign == 1);
1473 armor_iconalign = (autocvar_hud_panel_healtharmor_iconalign == 3 || autocvar_hud_panel_healtharmor_iconalign == 1);
1478 if(autocvar_hud_panel_healtharmor_progressbar)
1480 HUD_Panel_GetProgressBarColor(health);
1481 float p_health, pain_health_alpha;
1483 pain_health_alpha = 1;
1484 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1486 if (autocvar_hud_panel_healtharmor_progressbar_gfx_smooth > 0)
1488 if (fabs(prev_health - health) >= autocvar_hud_panel_healtharmor_progressbar_gfx_smooth)
1490 if (time - old_p_healthtime < 1)
1491 old_p_health = prev_p_health;
1493 old_p_health = prev_health;
1494 old_p_healthtime = time;
1496 if (time - old_p_healthtime < 1)
1498 p_health += (old_p_health - health) * (1 - (time - old_p_healthtime));
1499 prev_p_health = p_health;
1502 if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0)
1504 if (prev_health - health >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
1506 if (time - health_damagetime >= 1)
1507 health_beforedamage = prev_health;
1508 health_damagetime = time;
1510 if (time - health_damagetime < 1)
1512 float health_damagealpha = 1 - (time - health_damagetime)*(time - health_damagetime);
1513 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);
1516 prev_health = health;
1518 if (health <= autocvar_hud_panel_healtharmor_progressbar_gfx_lowhealth)
1520 float BLINK_FACTOR = 0.15;
1521 float BLINK_BASE = 0.85;
1522 float BLINK_FREQ = 9;
1523 pain_health_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
1526 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);
1528 if(autocvar_hud_panel_healtharmor_text)
1529 DrawNumIcon(pos + health_offset, mySize, health, "health", is_vertical, health_iconalign, HUD_Get_Num_Color(health, maxhealth), 1);
1534 if(autocvar_hud_panel_healtharmor_progressbar)
1536 HUD_Panel_GetProgressBarColor(armor);
1539 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
1541 if (autocvar_hud_panel_healtharmor_progressbar_gfx_smooth > 0)
1543 if (fabs(prev_armor - armor) >= autocvar_hud_panel_healtharmor_progressbar_gfx_smooth)
1545 if (time - old_p_armortime < 1)
1546 old_p_armor = prev_p_armor;
1548 old_p_armor = prev_armor;
1549 old_p_armortime = time;
1551 if (time - old_p_armortime < 1)
1553 p_armor += (old_p_armor - armor) * (1 - (time - old_p_armortime));
1554 prev_p_armor = p_armor;
1557 if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0)
1559 if (prev_armor - armor >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
1561 if (time - armor_damagetime >= 1)
1562 armor_beforedamage = prev_armor;
1563 armor_damagetime = time;
1565 if (time - armor_damagetime < 1)
1567 float armor_damagealpha = 1 - (time - armor_damagetime)*(time - armor_damagetime);
1568 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);
1573 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);
1575 if(autocvar_hud_panel_healtharmor_text)
1576 DrawNumIcon(pos + armor_offset, mySize, armor, "armor", is_vertical, armor_iconalign, HUD_Get_Num_Color(armor, maxarmor), 1);
1582 mySize_x *= 0.2 / 2; //if vertical always halve x to not cover too much numbers with 3 digits
1586 mySize_x *= 2; //restore full panel size
1587 else if (panel_ar < 1/4)
1588 mySize_y *= 2; //restore full panel size
1589 HUD_Panel_GetProgressBarColor(fuel);
1590 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
1595 // Notification area (#4)
1598 string Weapon_SuicideMessage(float deathtype)
1600 w_deathtype = deathtype;
1601 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_SUICIDEMESSAGE);
1602 return w_deathtypestring;
1605 string Weapon_KillMessage(float deathtype)
1607 w_deathtype = deathtype;
1608 get_weaponinfo(DEATH_WEAPONOF(deathtype)).weapon_func(WR_KILLMESSAGE);
1609 return w_deathtypestring;
1612 #define KN_MAX_ENTRIES 10
1614 float killnotify_times[KN_MAX_ENTRIES];
1615 float killnotify_deathtype[KN_MAX_ENTRIES];
1616 float killnotify_actiontype[KN_MAX_ENTRIES]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
1617 string killnotify_attackers[KN_MAX_ENTRIES];
1618 string killnotify_victims[KN_MAX_ENTRIES];
1619 void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
1623 kn_index = KN_MAX_ENTRIES-1;
1624 killnotify_times[kn_index] = time;
1625 killnotify_deathtype[kn_index] = wpn;
1626 killnotify_actiontype[kn_index] = actiontype;
1627 if(killnotify_attackers[kn_index])
1628 strunzone(killnotify_attackers[kn_index]);
1629 killnotify_attackers[kn_index] = strzone(attacker);
1630 if(killnotify_victims[kn_index])
1631 strunzone(killnotify_victims[kn_index]);
1632 killnotify_victims[kn_index] = strzone(victim);
1635 void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
1638 float alsoprint, gentle;
1639 alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
1640 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
1642 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
1645 if(msg == MSG_SUICIDE) {
1646 w = DEATH_WEAPONOF(type);
1648 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1650 print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
1651 } else if (type == DEATH_KILL) {
1652 HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
1654 print (sprintf(_("^1%s^1 couldn't take it anymore\n"), s1));
1655 } else if (type == DEATH_ROT) {
1656 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1658 print (sprintf(_("^1%s^1 died\n"), s1));
1659 } else if (type == DEATH_NOAMMO) {
1660 HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
1662 print (sprintf(_("^7%s^7 committed suicide. What's the point of living without ammo?\n"), s1));
1663 } else if (type == DEATH_CAMP) {
1664 HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
1666 print (sprintf(_("^1%s^1 thought they found a nice camping ground\n"), s1));
1667 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
1668 HUD_KillNotify_Push(s1, "", 0, type);
1670 print (sprintf(_("^1%s^1 didn't become friends with the Lord of Teamplay\n"), s1));
1671 } else if (type == DEATH_CHEAT) {
1672 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1674 print (sprintf(_("^1%s^1 unfairly eliminated themself\n"), s1));
1675 } else if (type == DEATH_FIRE) {
1676 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1678 print (sprintf(_("^1%s^1 burned to death\n"), s1));
1679 } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
1680 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1682 print (sprintf(_("^1%s^1 couldn't resist the urge to self-destruct\n"), s1));
1685 if (stof(s2) > 2) // killcount > 2
1686 print (sprintf(_("^1%s^1 ended it all after a %d kill spree\n"), s1, stof(s2)));
1687 } else if(msg == MSG_KILL) {
1688 w = DEATH_WEAPONOF(type);
1690 if((w == WEP_SNIPERRIFLE || w == WEP_MINSTANEX) && type & HITTYPE_HEADSHOT) // all headshot weapons go here
1691 HUD_KillNotify_Push(s1, s2, 1, DEATH_HEADSHOT);
1693 HUD_KillNotify_Push(s1, s2, 1, type);
1696 print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
1698 else if(type == KILL_TEAM_RED || type == KILL_TEAM_BLUE || type == KILL_TEAM_SPREE) {
1699 HUD_KillNotify_Push(s1, s2, 1, type);
1703 print (sprintf(_("^1%s^1 took action against a team mate\n"), s1));
1705 print (sprintf(_("^1%s^1 mows down a team mate\n"), s1));
1708 if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
1710 print (sprintf(_("^1%s^1 ended a %d scoring spree by going against a team mate\n"), s1, stof(s3)));
1712 print (sprintf(_("^1%s^1 ended a %d kill spree by killing a team mate\n"), s1, stof(s3)));
1714 else if (stof(s2) > 2) {
1716 print (sprintf(_("^1%s^1's %s scoring spree was ended by a team mate!\n"), s1, stof(s3)));
1718 print (sprintf(_("^1%s^1's %s kill spree was ended by a team mate!\n"), s1, stof(s3)));
1721 else if(type == KILL_FIRST_BLOOD)
1722 print(sprintf(_("^1%s^1 drew first blood\n"), s1));
1723 else if (type == DEATH_TELEFRAG) {
1724 HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
1726 print (sprintf(_("^1%s^1 tried to occupy %s^1's teleport destination space\n"), s2, s1));
1728 print (sprintf(_("^1%s^1 was telefragged by %s\n"), s2, s1));
1730 else if (type == DEATH_DROWN) {
1731 HUD_KillNotify_Push(s1, s2, 1, DEATH_DROWN);
1733 print (sprintf(_("^1%s^1 was drowned by %s\n"), s2, s1));
1735 else if (type == DEATH_SLIME) {
1736 HUD_KillNotify_Push(s1, s2, 1, DEATH_SLIME);
1738 print (sprintf(_("^1%s^1 was slimed by %s\n"), s2, s1));
1740 else if (type == DEATH_LAVA) {
1741 HUD_KillNotify_Push(s1, s2, 1, DEATH_LAVA);
1743 print (sprintf(_("^1%s^1 was cooked by %s\n"), s2, s1));
1745 else if (type == DEATH_FALL) {
1746 HUD_KillNotify_Push(s1, s2, 1, DEATH_FALL);
1748 print (sprintf(_("^1%s^1 was grounded by %s\n"), s2, s1));
1750 else if (type == DEATH_SHOOTING_STAR) {
1751 HUD_KillNotify_Push(s1, s2, 1, DEATH_SHOOTING_STAR);
1753 print (sprintf(_("^1%s^1 was shot into space by %s\n"), s2, s1));
1755 else if (type == DEATH_SWAMP) {
1756 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1758 print (sprintf(_("^1%s^1 was conserved by %s\n"), s2, s1));
1760 else if (type == DEATH_HURTTRIGGER)
1762 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1764 print(sprintf(_("^1%s^1 was thrown into a world of hurt by %s\n"), s2, s1));
1765 } else if(type == DEATH_SBCRUSH) {
1766 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1768 print (sprintf(_("^1%s^1 was crushed by %s\n"), s2, s1));
1769 } else if(type == DEATH_SBMINIGUN) {
1770 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1772 print (sprintf(_("^1%s^1 got shredded by %s\n"), s2, s1));
1773 } else if(type == DEATH_SBROCKET) {
1774 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1776 print (sprintf(_("^1%s^1 was blasted to bits by %s\n"), s2, s1));
1777 } else if(type == DEATH_SBBLOWUP) {
1778 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1780 print (sprintf(_("^1%s^1 got caught in the destruction of %s^1's vehicle\n"), s2, s1));
1781 } else if(type == DEATH_WAKIGUN) {
1782 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1784 print (sprintf(_("^1%s^1 was bolted down by %s\n"), s2, s1));
1785 } else if(type == DEATH_WAKIROCKET) {
1786 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1788 print (sprintf(_("^1%s^1 could find no shelter from %s^1's rockets\n"), s2, s1));
1789 } else if(type == DEATH_WAKIBLOWUP) {
1790 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1792 print (sprintf(_("^1%s^1 dies when %s^1's wakizashi dies.\n"), s2, s1));
1793 } else if(type == DEATH_TURRET) {
1794 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1796 print (sprintf(_("^1%s^1 was pushed into the line of fire by %s\n"), s2, s1));
1797 } else if(type == DEATH_TOUCHEXPLODE) {
1798 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1800 print (sprintf(_("^1%s^1 was pushed into an accident by %s\n"), s2, s1));
1801 } else if(type == DEATH_CHEAT) {
1802 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1804 print (sprintf(_("^1%s^1 was unfairly eliminated by %s\n"), s2, s1));
1805 } else if (type == DEATH_FIRE) {
1806 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1808 print (sprintf(_("^1%s^1 was burnt to death by %s\n"), s2, s1));
1809 } else if (type == DEATH_CUSTOM) {
1810 HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
1812 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1813 } else if (type == DEATH_HURTTRIGGER) {
1814 HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
1816 print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
1818 HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
1820 print (sprintf(_("^1%s^1 was fragged by %s\n"), s2, s1));
1822 } else if(msg == MSG_SPREE) {
1823 if(type == KILL_END_SPREE) {
1825 print (sprintf(_("^1%s^1's %s scoring spree was ended by %s\n"), s1, s2, s3));
1827 print (sprintf(_("^1%s^1's %s kill spree was ended by %s\n"), s1, s2, s3));
1828 } else if(type == KILL_SPREE) {
1830 print (sprintf(_("^1%s^1 made %s scores in a row\n"), s1, s2));
1832 print (sprintf(_("^1%s^1 has %s frags in a row\n"), s1, s2));
1833 } else if(type == KILL_SPREE_3) {
1835 print (sprintf(_("%s^7 made a ^1TRIPLE SCORE\n"), s1));
1837 print (sprintf(_("%s^7 made a ^1TRIPLE FRAG\n"), s1));
1838 } else if(type == KILL_SPREE_5) {
1840 print (sprintf(_("%s^7 unleashes ^1SCORING RAGE\n"), s1));
1842 print (sprintf(_("%s^7 unleashes ^1RAGE\n"), s1));
1843 } else if(type == KILL_SPREE_10) {
1845 print (sprintf(_("%s^7 made ^1TEN SCORES IN A ROW!\n"), s1));
1847 print (sprintf(_("%s^7 starts the ^1MASSACRE!\n"), s1));
1848 } else if(type == KILL_SPREE_15) {
1850 print (sprintf(_("%s^7 made ^1FIFTEEN SCORES IN A ROW!\n"), s1));
1852 print (sprintf(_("%s^7 executes ^1MAYHEM!\n"), s1));
1853 } else if(type == KILL_SPREE_20) {
1855 print (sprintf(_("%s^7 made ^1TWENTY SCORES IN A ROW!\n"), s1));
1857 print (sprintf(_("%s^7 is a ^1BERSERKER!\n"), s1));
1858 } else if(type == KILL_SPREE_25) {
1860 print (sprintf(_("%s^7 made ^1TWENTY FIVE SCORES IN A ROW!\n"), s1));
1862 print (sprintf(_("%s^7 inflicts ^1CARNAGE!\n"), s1));
1863 } else if(type == KILL_SPREE_30) {
1865 print (sprintf(_("%s^7 made ^1THIRTY SCORES IN A ROW!\n"), s1));
1867 print (sprintf(_("%s^7 unleashes ^1ARMAGEDDON!\n"), s1));
1869 } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
1870 if (type == DEATH_DROWN) {
1871 HUD_KillNotify_Push(s1, "", 0, DEATH_DROWN);
1875 print (sprintf(_("^1%s^1 was in the water for too long\n"), s1));
1877 print (sprintf(_("^1%s^1 drowned\n"), s1));
1879 } else if (type == DEATH_SLIME) {
1880 HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
1882 print (sprintf(_("^1%s^1 was slimed\n"), s1));
1883 } else if (type == DEATH_LAVA) {
1884 HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
1888 print (sprintf(_("^1%s^1 found a hot place\n"), s1));
1890 print (sprintf(_("^1%s^1 turned into hot slag\n"), s1));
1892 } else if (type == DEATH_FALL) {
1893 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1897 print (sprintf(_("^1%s^1 tested gravity (and it worked)\n"), s1));
1899 print (sprintf(_("^1%s^1 hit the ground with a crunch\n"), s1));
1901 } else if (type == DEATH_SHOOTING_STAR) {
1902 HUD_KillNotify_Push(s1, "", 0, DEATH_SHOOTING_STAR);
1904 print (sprintf(_("^1%s^1 became a shooting star\n"), s1));
1905 } else if (type == DEATH_SWAMP) {
1906 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1910 print (sprintf(_("^1%s^1 discovered a swamp\n"), s1));
1912 print (sprintf(_("^1%s^1 is now conserved for centuries to come\n"), s1));
1914 } else if(type == DEATH_TURRET) {
1915 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1917 print (sprintf(_("^1%s^1 was mowed down by a turret \n"), s1));
1918 } else if (type == DEATH_CUSTOM) {
1919 HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
1921 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1922 } else if (type == DEATH_HURTTRIGGER) {
1923 HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
1925 print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
1926 } else if(type == DEATH_TOUCHEXPLODE) {
1927 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1929 print (sprintf(_("^1%s^1 died in an accident\n"), s1));
1930 } else if(type == DEATH_CHEAT) {
1931 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1933 print (sprintf(_("^1%s^1 was unfairly eliminated\n"), s1));
1934 } else if(type == DEATH_FIRE) {
1935 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1939 print (sprintf(_("^1%s^1 felt a little hot\n"), s1));
1941 print (sprintf(_("^1%s^1 burnt to death\n"), s1));
1944 HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
1948 print (sprintf(_("^1%s^1 needs a restart\n"), s1));
1950 print (sprintf(_("^1%s^1 died\n"), s1));
1953 } else if(msg == MSG_KILL_ACTION_SPREE) {
1955 print (sprintf(_("^1%s^1 needs a restart after a %d scoring spree\n"), s1, stof(s2)));
1957 print (sprintf(_("^1%s^1 died with a %d kill spree\n"), s1, stof(s2)));
1958 } else if(msg == MSG_INFO) {
1959 if(type == INFO_GOTFLAG) { // here, s2 is the flag name
1960 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
1961 print(sprintf(_("%s^7 got the %s\n"), s1, s2));
1962 } else if(type == INFO_LOSTFLAG) {
1963 HUD_KillNotify_Push(s1, s2, 0, INFO_LOSTFLAG);
1964 print(sprintf(_("%s^7 lost the %s\n"), s1, s2));
1965 } else if(type == INFO_PICKUPFLAG) {
1966 HUD_KillNotify_Push(s1, s2, 0, INFO_GOTFLAG);
1967 print(sprintf(_("%s^7 picked up the %s\n"), s1, s2));
1968 } else if(type == INFO_RETURNFLAG) {
1969 HUD_KillNotify_Push(s1, s2, 0, INFO_RETURNFLAG);
1970 print(sprintf(_("%s^7 returned the %s\n"), s1, s2));
1971 } else if(type == INFO_CAPTUREFLAG) {
1972 HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
1973 print(sprintf(_("%s^7 captured the %s%s\n"), s1, s2, s3));
1975 } else if(msg == MSG_RACE) {
1976 if(type == RACE_SERVER_RECORD) {
1977 HUD_KillNotify_Push(s1, s2, 1, RACE_SERVER_RECORD);
1979 else if(type == RACE_NEW_RANK) {
1980 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_RANK);
1982 else if(type == RACE_NEW_TIME) {
1983 HUD_KillNotify_Push(s1, s2, 1, RACE_NEW_TIME);
1985 else if(type == RACE_FAIL) {
1986 HUD_KillNotify_Push(s1, s2, 1, RACE_FAIL);
1988 } else if(msg == MSG_KA) {
1989 if(type == KA_PICKUPBALL) {
1990 HUD_KillNotify_Push(s1, s2, 0, KA_PICKUPBALL);
1992 print (sprintf(_("%s^7 has picked up the ball!\n"), s1));
1994 else if(type == KA_DROPBALL) {
1995 HUD_KillNotify_Push(s1, s2, 0, KA_DROPBALL);
1997 print(sprintf(_("%s^7 has dropped the ball!\n"), s1));
2002 #define DAMAGE_CENTERPRINT_SPACER NEWLINES
2004 void HUD_Centerprint(string s1, string s2, float type, float msg)
2007 gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
2008 if(msg == MSG_SUICIDE) {
2009 if (type == DEATH_TEAMCHANGE) {
2010 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("You are now on: %s"), s1)));
2011 } else if (type == DEATH_AUTOTEAMCHANGE) {
2012 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("You have been moved into a different team to improve team balance\nYou are now on: %s"), s1)));
2013 } else if (type == DEATH_CAMP) {
2015 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Reconsider your tactics, camper!")));
2017 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Die camper!")));
2018 } else if (type == DEATH_NOAMMO) {
2020 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You are reinserted into the game for running out of ammo...")));
2022 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You were killed for running out of ammo...")));
2023 } else if (type == DEATH_ROT) {
2025 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You need to preserve your health")));
2027 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You grew too old without taking your medicine")));
2028 } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2030 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Don't go against team mates!")));
2032 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Don't shoot your team mates!")));
2033 } else if (type == DEATH_QUIET) {
2035 } else { // generic message
2037 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You need to be more careful!")));
2039 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You killed your own dumb self!")));
2041 } else if(msg == MSG_KILL) {
2042 if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
2044 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1Moron! You went against %s, a team mate!"), s1)));
2046 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1Moron! You fragged %s, a team mate!"), s1)));
2048 } else if (type == KILL_FIRST_BLOOD) {
2050 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First score")));
2052 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First blood")));
2054 } else if (type == KILL_FIRST_VICTIM) {
2056 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First casualty")));
2058 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First victim")));
2060 } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
2062 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You scored against ^7%s^1 who was typing!"), s1), s2));
2064 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You typefragged ^7%s"), s1), s2));
2066 } else if (type == KILL_TYPEFRAGGED) {
2068 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were scored against by ^7%s^1 while you were typing!"), s1), s2));
2070 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were typefragged by ^7%s"), s1), s2));
2072 } else if (type == KILL_FRAG) {
2074 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^4You scored against ^7%s"), s1), s2));
2076 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^4You fragged ^7%s"), s1), s2));
2078 } else { // generic message
2080 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were scored against by ^7%s"), s1), s2));
2082 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were fragged by ^7%s"), s1), s2));
2085 } else if(msg == MSG_KILL_ACTION) {
2086 // TODO: invent more centerprints here?
2087 centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Watch your step!")));
2091 void HUD_Notify (void)
2093 if(!autocvar__hud_configure)
2095 if(!autocvar_hud_panel_notify) return;
2098 hud_configure_active_panel = HUD_PANEL_NOTIFY;
2100 HUD_Panel_UpdateCvars(notify);
2103 mySize = panel_size;
2105 HUD_Panel_DrawBg(1);
2106 if(panel_bg_padding)
2108 pos += '1 1 0' * panel_bg_padding;
2109 mySize -= '2 2 0' * panel_bg_padding;
2112 float entries, height;
2113 entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES);
2114 height = mySize_y/entries;
2117 float fontheight = height * autocvar_hud_panel_notify_fontsize;
2118 fontsize = '0.5 0.5 0' * fontheight;
2122 when = autocvar_hud_panel_notify_time;
2124 fadetime = autocvar_hud_panel_notify_fadetime;
2128 vector pos_attacker, pos_victim;
2130 float width_attacker;
2131 string attacker, victim;
2133 float i, j, w, step, limit;
2134 if(autocvar_hud_panel_notify_flip) //order items from the top down
2140 else //order items from the bottom up
2147 for(j = kn_index; i != limit; i += step, ++j)
2149 if(autocvar__hud_configure)
2153 else // inverse order
2154 a = entries - 1 - i;
2155 attacker = textShortenToWidth(sprintf(_("Player %d"), a+1), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2156 victim = textShortenToWidth(sprintf(_("Player %d"), a+2), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2157 s = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname);
2158 a = bound(0, (when - a) / 4, 1);
2159 goto hud_config_notifyprint;
2162 if (j == KN_MAX_ENTRIES)
2165 if(killnotify_times[j] + when > time)
2169 a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
2183 w = DEATH_WEAPONOF(killnotify_deathtype[j]);
2185 // TODO: maybe print in team colors?
2188 if(killnotify_actiontype[j] == 0)
2190 if(killnotify_deathtype[j] == DEATH_GENERIC)
2194 else if(killnotify_deathtype[j] == DEATH_NOAMMO)
2196 s = "notify_outofammo";
2198 else if(killnotify_deathtype[j] == DEATH_KILL)
2200 s = "notify_selfkill";
2202 else if(killnotify_deathtype[j] == DEATH_CAMP)
2204 s = "notify_camping";
2206 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2208 s = "notify_teamkill_red";
2210 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2212 s = "notify_teamkill_blue";
2214 else if(killnotify_deathtype[j] == DEATH_DROWN)
2218 else if(killnotify_deathtype[j] == DEATH_SLIME)
2222 else if(killnotify_deathtype[j] == DEATH_LAVA)
2226 else if(killnotify_deathtype[j] == DEATH_FALL)
2230 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2232 s = "notify_shootingstar";
2234 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM)
2238 else if(killnotify_deathtype[j] == INFO_GOTFLAG)
2240 if(killnotify_victims[j] == "^1RED^7 flag")
2242 s = "notify_red_taken";
2246 s = "notify_blue_taken";
2249 else if(killnotify_deathtype[j] == INFO_RETURNFLAG)
2251 if(killnotify_victims[j] == "^1RED^7 flag")
2253 s = "notify_red_returned";
2257 s = "notify_blue_returned";
2260 else if(killnotify_deathtype[j] == INFO_LOSTFLAG)
2262 if(killnotify_victims[j] == "^1RED^7 flag")
2264 s = "notify_red_lost";
2268 s = "notify_blue_lost";
2271 else if(killnotify_deathtype[j] == INFO_CAPTUREFLAG)
2273 if(killnotify_victims[j] == "^1RED^7 flag")
2275 s = "notify_red_captured";
2279 s = "notify_blue_captured";
2282 else if(killnotify_deathtype[j] == KA_DROPBALL)
2284 s = "notify_balldropped";
2286 else if(killnotify_deathtype[j] == KA_PICKUPBALL)
2288 s = "notify_ballpickedup";
2291 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2292 pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2293 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2297 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2298 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2301 // X [did action to] Y
2304 if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
2306 s = "notify_melee_laser";
2308 else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_SHOTGUN)
2310 s = "notify_melee_shotgun";
2312 else if(WEP_VALID(w))
2314 self = get_weaponinfo(w);
2315 s = strcat("weapon", self.netname);
2317 else if(killnotify_deathtype[j] == KILL_TEAM_RED)
2319 s = "notify_teamkill_red";
2321 else if(killnotify_deathtype[j] == KILL_TEAM_BLUE)
2323 s = "notify_teamkill_red";
2325 else if(killnotify_deathtype[j] == DEATH_TELEFRAG)
2327 s = "notify_telefrag";
2329 else if(killnotify_deathtype[j] == DEATH_DROWN)
2333 else if(killnotify_deathtype[j] == DEATH_SLIME)
2337 else if(killnotify_deathtype[j] == DEATH_LAVA)
2341 else if(killnotify_deathtype[j] == DEATH_FALL)
2345 else if(killnotify_deathtype[j] == DEATH_SHOOTING_STAR)
2347 s = "notify_shootingstar";
2349 else if(killnotify_deathtype[j] == DEATH_HURTTRIGGER || killnotify_deathtype[j] == DEATH_CUSTOM) // DEATH_CUSTOM is also void, right?
2353 else if(killnotify_deathtype[j] == DEATH_HEADSHOT)
2355 s = "notify_headshot";
2357 else if(killnotify_deathtype[j] == RACE_SERVER_RECORD)
2359 s = "race_newrecordserver";
2361 else if(killnotify_deathtype[j] == RACE_NEW_RANK)
2363 s = "race_newrankyellow";
2365 else if(killnotify_deathtype[j] == RACE_NEW_TIME)
2369 else if(killnotify_deathtype[j] == RACE_FAIL)
2374 attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2375 victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
2376 :hud_config_notifyprint
2377 width_attacker = stringwidth(attacker, TRUE, fontsize);
2378 pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2379 pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
2380 weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
2384 drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
2385 drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2386 drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
2395 string seconds_tostring(float sec)
2398 minutes = floor(sec / 60);
2400 sec -= minutes * 60;
2401 return sprintf("%d:%02d", minutes, sec);
2404 void HUD_Timer(void)
2406 if(!autocvar__hud_configure)
2408 if(!autocvar_hud_panel_timer) return;
2411 hud_configure_active_panel = HUD_PANEL_TIMER;
2413 HUD_Panel_UpdateCvars(timer);
2416 mySize = panel_size;
2418 HUD_Panel_DrawBg(1);
2419 if(panel_bg_padding)
2421 pos += '1 1 0' * panel_bg_padding;
2422 mySize -= '2 2 0' * panel_bg_padding;
2426 float timelimit, elapsedTime, timeleft, minutesLeft;
2428 timelimit = getstatf(STAT_TIMELIMIT);
2430 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
2431 timeleft = ceil(timeleft);
2433 minutesLeft = floor(timeleft / 60);
2436 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
2437 timer_color = '1 1 1'; //white
2438 else if(minutesLeft >= 1)
2439 timer_color = '1 1 0'; //yellow
2441 timer_color = '1 0 0'; //red
2443 if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) {
2444 if (time < getstatf(STAT_GAMESTARTTIME)) {
2445 //while restart is still active, show 00:00
2446 timer = seconds_tostring(0);
2448 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
2449 timer = seconds_tostring(elapsedTime);
2452 timer = seconds_tostring(timeleft);
2455 drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2460 void HUD_Radar(void)
2462 if (!autocvar__hud_configure)
2464 if (autocvar_hud_panel_radar == 0) return;
2465 if (autocvar_hud_panel_radar != 2 && !teamplay) return;
2468 hud_configure_active_panel = HUD_PANEL_RADAR;
2470 HUD_Panel_UpdateCvars(radar);
2473 mySize = panel_size;
2475 HUD_Panel_DrawBg(1);
2476 if(panel_bg_padding)
2478 pos += '1 1 0' * panel_bg_padding;
2479 mySize -= '2 2 0' * panel_bg_padding;
2484 float scale2d, normalsize, bigsize;
2487 teamradar_origin2d = pos + 0.5 * mySize;
2488 teamradar_size2d = mySize;
2490 if(minimapname == "")
2493 teamradar_loadcvars();
2495 switch(hud_panel_radar_zoommode)
2499 f = current_zoomfraction;
2502 f = 1 - current_zoomfraction;
2512 switch(hud_panel_radar_rotation)
2515 teamradar_angle = view_angles_y - 90;
2518 teamradar_angle = 90 * hud_panel_radar_rotation;
2522 scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
2523 teamradar_size2d = mySize;
2525 teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
2527 // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
2528 if(hud_panel_radar_rotation == 0)
2530 // max-min distance must fit the radar in any rotation
2531 bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_scale));
2535 vector c0, c1, c2, c3, span;
2536 c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
2537 c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
2538 c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
2539 c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
2541 span_x = max4(c0_x, c1_x, c2_x, c3_x) - min4(c0_x, c1_x, c2_x, c3_x);
2542 span_y = max4(c0_y, c1_y, c2_y, c3_y) - min4(c0_y, c1_y, c2_y, c3_y);
2544 // max-min distance must fit the radar in x=x, y=y
2546 teamradar_size2d_x * scale2d / (1.05 * span_x),
2547 teamradar_size2d_y * scale2d / (1.05 * span_y)
2551 normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_panel_radar_scale;
2552 if(bigsize > normalsize)
2553 normalsize = bigsize;
2557 + (1 - f) * normalsize;
2558 teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
2560 + (1 - f) * view_origin);
2569 draw_teamradar_background(hud_panel_radar_foreground_alpha);
2571 for(tm = world; (tm = find(tm, classname, "radarlink")); )
2572 draw_teamradar_link(tm.origin, tm.velocity, tm.team);
2573 for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
2574 draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
2575 for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
2577 color2 = GetPlayerColor(tm.sv_entnum);
2578 //if(color == COLOR_SPECTATOR || color == color2)
2579 draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
2581 draw_teamradar_player(view_origin, view_angles, '1 1 1');
2583 drawresetcliparea();
2588 void HUD_UpdatePlayerTeams();
2589 void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count)
2593 #define SCOREPANEL_MAX_ENTRIES 6
2594 #define SCOREPANEL_ASPECTRATIO 2
2595 const float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
2596 const vector fontsize = '1 1 0' * (mySize_y/entries);
2598 vector rgb, score_color;
2600 score_color = '1 1 1';
2602 const float name_size = mySize_x*0.75;
2603 const float spacing_size = mySize_x*0.04;
2604 const float highlight_alpha = 0.2;
2605 float i, me_printed, first_pl;
2608 if (autocvar__hud_configure)
2610 float players_per_team;
2613 // show team scores in the first line
2614 float score_size = mySize_x / team_count;
2615 players_per_team = max(2, ceil((entries - 1) / team_count));
2616 for(i=0; i<team_count; ++i) {
2617 if (i == floor((entries - 2) / players_per_team) || (entries == 1 && i == 0))
2618 HUD_Panel_DrawHighlight(pos + eX * score_size * i, eX * score_size + eY * fontsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2619 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);
2622 pos_y += fontsize_y;
2624 score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
2625 for (i=first_pl; i<entries; ++i)
2627 //simulate my score is lower than all displayed players,
2628 //so that I don't appear at all showing pure rankings.
2629 //This is to better show the difference between the 2 ranking views
2630 if (i == entries-1 && autocvar_hud_panel_score_rankings == 1)
2633 drawfill(pos, eX * mySize_x + eY * fontsize_y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2634 s = GetPlayerName(pl.sv_entnum);
2639 s = sprintf(_("Player %d"), i + 1 - first_pl);
2644 score_color = GetTeamRGB(ColorByTeam(floor((i - first_pl) / players_per_team))) * 0.8;
2645 s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
2646 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2647 drawstring(pos + eX * (name_size + spacing_size), ftos(score), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2648 pos_y += fontsize_y;
2653 if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
2654 HUD_UpdatePlayerTeams();
2657 // show team scores in the first line
2658 float score_size = mySize_x / team_count;
2659 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
2660 if(tm.team == COLOR_SPECTATOR)
2662 if (tm.team == myteam)
2663 drawfill(pos + eX * score_size * i, eX * score_size + eY * fontsize_y, '1 1 1', highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2664 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);
2668 pos_y += fontsize_y;
2669 tm = teams.sort_next;
2674 for (pl = players.sort_next; pl && i<entries; pl = pl.sort_next)
2676 if ((team_count && pl.team != tm.team) || pl.team == COLOR_SPECTATOR)
2679 if (i == entries-1 && !me_printed && pl != me)
2680 if (autocvar_hud_panel_score_rankings == 1 && spectatee_status != -1)
2682 for (pl = me.sort_next; pl; pl = pl.sort_next)
2683 if (pl.team != COLOR_SPECTATOR)
2687 rgb = '1 1 0'; //not last but not among the leading players: yellow
2689 rgb = '1 0 0'; //last: red
2696 rgb = '0 1 0'; //first: green
2698 drawfill(pos, eX * mySize_x + eY * fontsize_y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
2701 score_color = GetTeamRGB(pl.team) * 0.8;
2702 s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
2703 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2704 drawstring(pos + eX * (name_size + spacing_size), ftos(pl.(scores[ps_primary])), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
2705 pos_y += fontsize_y;
2708 while (i<entries && team_count && (tm = tm.sort_next) && (tm.team != COLOR_SPECTATOR || (tm = tm.sort_next)));
2711 void HUD_Score(void)
2713 if(!autocvar__hud_configure)
2715 if(!autocvar_hud_panel_score) return;
2716 if(spectatee_status == -1 && (gametype == GAME_RACE || gametype == GAME_CTS)) return;
2719 hud_configure_active_panel = HUD_PANEL_SCORE;
2721 HUD_Panel_UpdateCvars(score);
2724 mySize = panel_size;
2726 HUD_Panel_DrawBg(1);
2727 if(panel_bg_padding)
2729 pos += '1 1 0' * panel_bg_padding;
2730 mySize -= '2 2 0' * panel_bg_padding;
2733 float score, distribution;
2735 vector distribution_color;
2737 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
2739 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
2740 string timer, distrtimer;
2742 pl = players.sort_next;
2745 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
2746 if(pl.scores[ps_primary] == 0)
2749 score = me.(scores[ps_primary]);
2750 timer = TIME_ENCODED_TOSTRING(score);
2752 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
2753 // distribution display
2754 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2756 distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS);
2758 if (distribution <= 0) {
2759 distribution_color = '0 1 0';
2763 distribution_color = '1 0 0';
2766 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);
2768 // race record display
2769 if (distribution <= 0)
2770 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2771 drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2772 } else if (!teamplay) { // non-teamgames
2773 if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings)
2775 HUD_Score_Rankings(pos, mySize, me, 0);
2778 // me vector := [team/connected frags id]
2779 pl = players.sort_next;
2783 if(autocvar__hud_configure)
2786 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
2790 score = me.(scores[ps_primary]);
2791 if(autocvar__hud_configure)
2794 if(distribution >= 5)
2795 distribution_color = eY;
2796 else if(distribution >= 0)
2797 distribution_color = '1 1 1';
2798 else if(distribution >= -5)
2799 distribution_color = '1 1 0';
2801 distribution_color = eX;