1 void drawstringright(vector, string, vector, vector, float, float);
\r
2 void drawstringcenter(vector, string, vector, vector, float, float);
\r
6 float weapon_hits[WEP_MAXCOUNT];
\r
7 float weapon_fired[WEP_MAXCOUNT];
\r
13 float sbar_alpha_fg;
\r
14 float sbar_alpha_bg;
\r
15 float sbar_color_bg_team;
\r
16 float sbar_border_thickness;
\r
17 float sbar_accuracy_border_thickness;
\r
18 float sbar_scoreboard_alpha_bg;
\r
19 float sbar_scoreboard_alpha_fg;
\r
20 float sbar_scoreboard_highlight;
\r
21 float sbar_scoreboard_highlight_alpha;
\r
22 float sbar_scoreboard_highlight_alpha_self;
\r
23 float sbar_hudselector;
\r
24 float sbar_accuracy_hud;
\r
25 float sbar_scoreboard_alpha_name;
\r
26 float sbar_scoreboard_alpha_name_self;
\r
28 string portrait_image, portrait_name;
\r
29 float portrait_time;
\r
31 float ps_primary, ps_secondary;
\r
32 float ts_primary, ts_secondary;
\r
36 void CSQC_kh_hudreset();
\r
38 void CSQC_ctf_hudreset();
\r
39 void CSQC_ctf_hud();
\r
40 void CSQC_race_hud();
\r
41 void MapVote_Draw();
\r
42 void Sbar_FinaleOverlay()
\r
45 pos_x = (vid_conwidth - 1)/2;
\r
49 //drawpic(pos, "gfx/finale", '0 0 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
51 //drawstring(pos, "END", sbar_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);
\r
55 vector Sbar_AccuracyColor(float accuracy)
\r
58 float yellow_accuracy = cvar("sbar_accuracy_yellow"); // value at which this function returns yellow
\r
59 if(accuracy >= 100) {
\r
63 else if(accuracy > yellow_accuracy) {
\r
64 rgb_x = 1 - (accuracy-yellow_accuracy)/(100-yellow_accuracy); // red value between 1 -> 0
\r
69 rgb_y = accuracy/yellow_accuracy; // green value between 0 -> 1
\r
75 vector Sbar_ConvertToScreen_PicScale(vector dimensions)
\r
78 sz_x = vid_conwidth * dimensions_x;
\r
79 sz_y = vid_conheight * dimensions_y;
\r
82 vector Sbar_ConvertToScreen_PicPosition(vector position, vector dimensions)
\r
85 sz = Sbar_ConvertToScreen_PicScale(dimensions);
\r
86 pos_x = (vid_conwidth / 2) * bound(0, 1 + position_x, 2);
\r
88 pos_y = (vid_conheight / 2) * bound(0, 1 - position_y, 2);
\r
92 vector Sbar_ConvertToScreen_TextPosition(string text, vector position, float lettersize)
\r
95 sz_x = sz_y = lettersize;
\r
96 pos_x = (vid_conwidth / 2) * bound(0, 1 + position_x, 2);
\r
97 pos_x -= stringwidth(text, TRUE, sz) * 0.5;
\r
98 pos_y = (vid_conheight / 2) * bound(0, 1 - position_y, 2);
\r
103 void Sbar_DrawPic(string pic, vector position, vector dimensions, float background)
\r
106 pos = Sbar_ConvertToScreen_PicPosition(position, dimensions);
\r
107 sz = Sbar_ConvertToScreen_PicScale(dimensions);
\r
112 drawpic(pos, pic, sz, GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // hud color = myteam color
\r
114 drawpic(pos, pic, sz, stov(cvar_string("sbar_color_bg")), sbar_alpha_bg, DRAWFLAG_NORMAL);
\r
117 drawpic(pos, pic, sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
120 void Sbar_DrawString(string text, vector position, float lettersize)
\r
123 pos = Sbar_ConvertToScreen_TextPosition(text, position, lettersize);
\r
124 sz_x = sz_y = lettersize;
\r
126 drawcolorcodedstring(pos, text, sz, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
129 void Sbar_DrawXNum (vector position, float num, float digits, float showminusplus, float lettersize, vector rgb, float alpha, float dflags)
\r
132 string str, tmp, l_length, final_num;
\r
135 // showminusplus 1: always prefix with minus sign (useful in race distribution display)
\r
136 // showminusplus 2: always prefix with plus sign (useful in race distribution display)
\r
137 // showminusplus 3: prefix with minus sign if negative, plus sign if positive (useful in score distribution display)
\r
139 if((showminusplus == 2 && num >= 0) || (num > 0 && showminusplus == 3))
\r
145 if(num < 0 || (num < 0 && showminusplus == 3) || (showminusplus == 1 && num <= 0))
\r
156 str = strcat(substring("0000000000", 0, digits - strlen(tmp)), tmp);
\r
161 l_length = ftos(l);
\r
165 str = substring(str, l - digits, 999);
\r
173 final_num = strcat(final_num, str);
\r
176 pos = Sbar_ConvertToScreen_TextPosition(final_num, position, lettersize);
\r
177 sz_x = sz_y = lettersize;
\r
179 drawstring(pos, final_num, sz, rgb, alpha, dflags);
\r
182 vector Sbar_NumColor (float x)
\r
190 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
\r
191 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
\r
195 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
\r
196 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
\r
197 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
\r
202 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
\r
206 color_y = (x-25)*90/27/100; // green value between 0 -> 1
\r
207 color_z = (x-25)*90/27/100 * 0.2; // blue value between 0 -> 0.2
\r
217 void Cmd_Sbar_SetFields(float argc);
\r
218 void Sbar_InitScores()
\r
222 ps_primary = ps_secondary = ts_primary = ts_secondary = -1;
\r
223 for(i = 0; i < MAX_SCORE; ++i)
\r
225 f = (scores_flags[i] & SFL_SORT_PRIO_MASK);
\r
226 if(f == SFL_SORT_PRIO_PRIMARY)
\r
228 if(f == SFL_SORT_PRIO_SECONDARY)
\r
231 if(ps_secondary == -1)
\r
232 ps_secondary = ps_primary;
\r
234 for(i = 0; i < MAX_TEAMSCORE; ++i)
\r
236 f = (teamscores_flags[i] & SFL_SORT_PRIO_MASK);
\r
237 if(f == SFL_SORT_PRIO_PRIMARY)
\r
239 if(f == SFL_SORT_PRIO_SECONDARY)
\r
242 if(ts_secondary == -1)
\r
243 ts_secondary = ts_primary;
\r
245 Cmd_Sbar_SetFields(0);
\r
248 void Sbar_UpdatePlayerPos(entity pl);
\r
249 float SetTeam(entity pl, float Team);
\r
251 void Sbar_UpdatePlayerTeams()
\r
258 for(pl = players.sort_next; pl; pl = pl.sort_next)
\r
261 Team = GetPlayerColor(pl.sv_entnum);
\r
262 if(SetTeam(pl, Team))
\r
264 tmp = pl.sort_prev;
\r
265 Sbar_UpdatePlayerPos(pl);
\r
269 pl = players.sort_next;
\r
273 if(num != lastpnum)
\r
274 print(strcat("PNUM: ", ftos(num), "\n"));
\r
279 float Sbar_ComparePlayerScores(entity left, entity right)
\r
282 vl = GetPlayerColor(left.sv_entnum);
\r
283 vr = GetPlayerColor(right.sv_entnum);
\r
285 if(!left.gotscores)
\r
286 vl = COLOR_SPECTATOR;
\r
287 if(!right.gotscores)
\r
288 vr = COLOR_SPECTATOR;
\r
295 if(vl == COLOR_SPECTATOR)
\r
297 // FIRST the one with scores (spectators), THEN the ones without (downloaders)
\r
298 // no other sorting
\r
299 if(!left.gotscores && right.gotscores)
\r
304 vl = left.scores[ps_primary];
\r
305 vr = right.scores[ps_primary];
\r
306 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
\r
308 if(vl == 0 && vr != 0)
\r
310 if(vl != 0 && vr == 0)
\r
314 return IS_INCREASING(scores_flags[ps_primary]);
\r
316 return IS_DECREASING(scores_flags[ps_primary]);
\r
318 vl = left.scores[ps_secondary];
\r
319 vr = right.scores[ps_secondary];
\r
320 if(scores_flags[ps_secondary] & SFL_ZERO_IS_WORST)
\r
322 if(vl == 0 && vr != 0)
\r
324 if(vl != 0 && vr == 0)
\r
328 return IS_INCREASING(scores_flags[ps_secondary]);
\r
330 return IS_DECREASING(scores_flags[ps_secondary]);
\r
335 void Sbar_UpdatePlayerPos(entity player)
\r
337 for(other = player.sort_next; other && Sbar_ComparePlayerScores(player, other); other = player.sort_next)
\r
339 SORT_SWAP(player, other);
\r
341 for(other = player.sort_prev; other != players && Sbar_ComparePlayerScores(other, player); other = player.sort_prev)
\r
343 SORT_SWAP(other, player);
\r
347 float Sbar_CompareTeamScores(entity left, entity right)
\r
351 if(left.team == COLOR_SPECTATOR)
\r
353 if(right.team == COLOR_SPECTATOR)
\r
356 vl = left.teamscores[ts_primary];
\r
357 vr = right.teamscores[ts_primary];
\r
359 return IS_INCREASING(teamscores_flags[ts_primary]);
\r
361 return IS_DECREASING(teamscores_flags[ts_primary]);
\r
363 vl = left.teamscores[ts_secondary];
\r
364 vr = right.teamscores[ts_secondary];
\r
366 return IS_INCREASING(teamscores_flags[ts_secondary]);
\r
368 return IS_DECREASING(teamscores_flags[ts_secondary]);
\r
373 void Sbar_UpdateTeamPos(entity Team)
\r
375 for(other = Team.sort_next; other && Sbar_CompareTeamScores(Team, other); other = Team.sort_next)
\r
377 SORT_SWAP(Team, other);
\r
379 for(other = Team.sort_prev; other != teams && Sbar_CompareTeamScores(other, Team); other = Team.sort_prev)
\r
381 SORT_SWAP(other, Team);
\r
385 void Cmd_Sbar_Help(float argc)
\r
387 print("You can modify the scoreboard using the ^2sbar_columns_set command.\n");
\r
388 print("^3|---------------------------------------------------------------|\n");
\r
390 print("^2sbar_columns_set default\n");
\r
391 print("^2sbar_columns_set ^7filed1 field2 ...\n");
\r
392 print("The following field names are recognized (case insensitive):\n");
\r
393 print("You can use a ^3|^7 to start the right-aligned fields.\n\n");
\r
395 print("^3name^7 or ^3nick^7 Name of a player\n");
\r
396 print("^3ping^7 Ping time\n");
\r
397 print("^3pl^7 Packet loss\n");
\r
398 print("^3kills^7 Number of kills\n");
\r
399 print("^3deaths^7 Number of deaths\n");
\r
400 print("^3suicides^7 Number of suicides\n");
\r
401 print("^3frags^7 kills - suicides\n");
\r
402 print("^3kd^7 The kill-death ratio\n");
\r
403 print("^3caps^7 How often a flag (CTF) or a key (KeyHunt) was captured\n");
\r
404 print("^3pickups^7 How often a flag (CTF) or a key (KeyHunt) was picked up\n");
\r
405 print("^3fckills^7 Number of flag carrier kills\n");
\r
406 print("^3returns^7 Number of flag returns\n");
\r
407 print("^3drops^7 Number of flag drops\n");
\r
408 print("^3lives^7 Number of lives (LMS)\n");
\r
409 print("^3rank^7 Player rank\n");
\r
410 print("^3pushes^7 Number of players pushed into void\n");
\r
411 print("^3destroyed^7 Number of keys destroyed by pushing them into void\n");
\r
412 print("^3kckills^7 Number of keys carrier kills\n");
\r
413 print("^3losses^7 Number of times a key was lost\n");
\r
414 print("^3laps^7 Number of laps finished (race/cts)\n");
\r
415 print("^3time^7 Total time raced (race/cts)\n");
\r
416 print("^3fastest^7 Time of fastest lap (race/cts)\n");
\r
417 print("^3ticks^7 Number of ticks (DOM)\n");
\r
418 print("^3takes^7 Number of domination points taken (DOM)\n");
\r
419 print("^3score^7 Total score\n\n");
\r
421 print("Before a field you can put a + or - sign, then a comma separated list\n");
\r
422 print("of game types, then a slash, to make the field show up only in these\n");
\r
423 print("or in all but these game types. You can also specify 'all' as a\n");
\r
424 print("field to show all fields available for the current game mode.\n\n");
\r
426 print("The special game type names 'teams' and 'noteams' can be used to\n");
\r
427 print("include/exclude ALL teams/noteams game modes.\n\n");
\r
429 print("Example: sbar_columns_set name ping pl | +ctf/field3 -dm/field4\n");
\r
430 print("will display name, ping and pl aligned to the left, and the fields\n");
\r
431 print("right of the vertical bar aligned to the right.\n");
\r
432 print("'field3' will only be shown in CTF, and 'field4' will be shown in all\n");
\r
433 print("other gamemodes except DM.\n");
\r
436 string Sbar_DefaultColumnLayout()
\r
438 return strcat( // fteqcc sucks
\r
440 "-teams,race,lms/kills -teams,lms/deaths -teams,lms,race/suicides -race,dm,tdm/frags ", // tdm already has this in "score"
\r
441 "+ctf/caps +ctf/pickups +ctf/fckills +ctf/returns ",
\r
442 "+lms/lives +lms/rank ",
\r
443 "+kh/caps +kh/pushes +kh/destroyed ",
\r
444 "?+race/laps ?+race/time ?+race/fastest ",
\r
448 void Cmd_Sbar_SetFields(float argc)
\r
451 string str, pattern;
\r
452 float have_name, have_primary, have_secondary, have_separator;
\r
455 // TODO: re enable with gametype dependant cvars?
\r
456 if(argc < 2) // no arguments provided
\r
457 argc = tokenizebyseparator(strcat("x ", cvar_string("sbar_columns")), " ");
\r
460 argc = tokenizebyseparator(strcat("x ", Sbar_DefaultColumnLayout()), " ");
\r
464 if(argv(1) == "default")
\r
465 argc = tokenizebyseparator(strcat("x ", Sbar_DefaultColumnLayout()), " ");
\r
466 else if(argv(1) == "all")
\r
469 s = "ping pl color name |";
\r
470 for(i = 0; i < MAX_SCORE; ++i)
\r
472 if(i != ps_primary)
\r
473 if(i != ps_secondary)
\r
474 if(scores_label[i] != "")
\r
475 s = strcat(s, " ", scores_label[i]);
\r
477 if(ps_secondary != ps_primary)
\r
478 s = strcat(s, " ", scores_label[ps_secondary]);
\r
479 s = strcat(s, " ", scores_label[ps_primary]);
\r
480 argc = tokenizebyseparator(strcat("x ", s), " ");
\r
485 sbar_num_fields = 0;
\r
487 drawfont = sbar_font;
\r
489 for(i = 0; i < argc - 1; ++i)
\r
494 nocomplain = FALSE;
\r
495 if(substring(str, 0, 1) == "?")
\r
498 str = substring(str, 1, strlen(str) - 1);
\r
501 slash = strstrofs(str, "/", 0);
\r
504 pattern = substring(str, 0, slash);
\r
505 str = substring(str, slash + 1, strlen(str) - (slash + 1));
\r
507 if not(isGametypeInFilter(gametype, teamplay, pattern))
\r
511 strunzone(sbar_title[sbar_num_fields]);
\r
512 sbar_title[sbar_num_fields] = strzone(str);
\r
513 sbar_size[sbar_num_fields] = stringwidth(str, FALSE, sbar_fontsize);
\r
514 str = strtolower(str);
\r
516 if(str == "ping") {
\r
517 sbar_field[sbar_num_fields] = SP_PING;
\r
518 } else if(str == "pl") {
\r
519 sbar_field[sbar_num_fields] = SP_PL;
\r
520 } else if(str == "kd" || str == "kdr" || str == "kdratio" || str == "k/d") {
\r
521 sbar_field[sbar_num_fields] = SP_KDRATIO;
\r
522 } else if(str == "name" || str == "nick") {
\r
523 sbar_field[sbar_num_fields] = SP_NAME;
\r
525 } else if(str == "|") {
\r
526 sbar_field[sbar_num_fields] = SP_SEPARATOR;
\r
527 have_separator = 1;
\r
529 if(gametype == GAME_RPG)
\r
532 for(j = 0; j < MAX_SCORE; ++j)
\r
533 if(str == strtolower(scores_label[j]))
\r
534 goto found; // sorry, but otherwise fteqcc -O3 miscompiles this and warns about "unreachable code"
\r
541 print(strcat("^1Error:^7 Unknown score field: '", str, "'\n"));
\r
545 sbar_field[sbar_num_fields] = j;
\r
546 if(j == ps_primary)
\r
548 if(j == ps_secondary)
\r
549 have_secondary = 1;
\r
552 if(sbar_num_fields >= MAX_SBAR_FIELDS)
\r
556 if(scores_flags[ps_primary] & SFL_ALLOW_HIDE)
\r
558 if(scores_flags[ps_secondary] & SFL_ALLOW_HIDE)
\r
559 have_secondary = 1;
\r
560 if(ps_primary == ps_secondary)
\r
561 have_secondary = 1;
\r
562 missing = (!have_primary) + (!have_secondary) + (!have_separator) + (!have_name);
\r
564 if(sbar_num_fields+missing < MAX_SBAR_FIELDS)
\r
568 strunzone(sbar_title[sbar_num_fields]);
\r
569 for(i = sbar_num_fields; i > 0; --i)
\r
571 sbar_title[i] = sbar_title[i-1];
\r
572 sbar_size[i] = sbar_size[i-1];
\r
573 sbar_field[i] = sbar_field[i-1];
\r
575 sbar_title[0] = strzone("name");
\r
576 sbar_field[0] = SP_NAME;
\r
578 print("fixed missing field 'name'\n");
\r
580 if(!have_separator)
\r
582 strunzone(sbar_title[sbar_num_fields]);
\r
583 for(i = sbar_num_fields; i > 1; --i)
\r
585 sbar_title[i] = sbar_title[i-1];
\r
586 sbar_size[i] = sbar_size[i-1];
\r
587 sbar_field[i] = sbar_field[i-1];
\r
589 sbar_title[1] = strzone("|");
\r
590 sbar_field[1] = SP_SEPARATOR;
\r
591 sbar_size[1] = stringwidth("|", FALSE, sbar_fontsize);
\r
593 print("fixed missing field '|'\n");
\r
596 else if(!have_separator)
\r
598 strunzone(sbar_title[sbar_num_fields]);
\r
599 sbar_title[sbar_num_fields] = strzone("|");
\r
600 sbar_size[sbar_num_fields] = stringwidth("|", FALSE, sbar_fontsize);
\r
601 sbar_field[sbar_num_fields] = SP_SEPARATOR;
\r
603 print("fixed missing field '|'\n");
\r
605 if(!have_secondary)
\r
607 strunzone(sbar_title[sbar_num_fields]);
\r
608 sbar_title[sbar_num_fields] = strzone(scores_label[ps_secondary]);
\r
609 sbar_size[sbar_num_fields] = stringwidth(sbar_title[sbar_num_fields], FALSE, sbar_fontsize);
\r
610 sbar_field[sbar_num_fields] = ps_secondary;
\r
612 print("fixed missing field '", scores_label[ps_secondary], "'\n");
\r
616 strunzone(sbar_title[sbar_num_fields]);
\r
617 sbar_title[sbar_num_fields] = strzone(scores_label[ps_primary]);
\r
618 sbar_size[sbar_num_fields] = stringwidth(sbar_title[sbar_num_fields], FALSE, sbar_fontsize);
\r
619 sbar_field[sbar_num_fields] = ps_primary;
\r
621 print("fixed missing field '", scores_label[ps_primary], "'\n");
\r
625 sbar_field[sbar_num_fields] = SP_END;
\r
628 string Sbar_GetTexture(string img)
\r
630 string path = cvar_string("hud_style");
\r
631 return strcat("gfx/hud/", path, "/", img);
\r
635 vector sbar_field_rgb;
\r
636 string sbar_field_icon0;
\r
637 string sbar_field_icon1;
\r
638 string sbar_field_icon2;
\r
639 vector sbar_field_icon0_rgb;
\r
640 vector sbar_field_icon1_rgb;
\r
641 vector sbar_field_icon2_rgb;
\r
642 float sbar_field_icon0_alpha;
\r
643 float sbar_field_icon1_alpha;
\r
644 float sbar_field_icon2_alpha;
\r
645 string Sbar_GetField(entity pl, float field)
\r
647 float tmp, num, denom, f;
\r
649 sbar_field_rgb = '1 1 1';
\r
650 sbar_field_icon0 = "";
\r
651 sbar_field_icon1 = "";
\r
652 sbar_field_icon2 = "";
\r
653 sbar_field_icon0_rgb = '1 1 1';
\r
654 sbar_field_icon1_rgb = '1 1 1';
\r
655 sbar_field_icon2_rgb = '1 1 1';
\r
656 sbar_field_icon0_alpha = 1;
\r
657 sbar_field_icon1_alpha = 1;
\r
658 sbar_field_icon2_alpha = 1;
\r
662 if not(pl.gotscores)
\r
663 return "\x8D\x8D\x8D"; // >>> sign
\r
664 //str = getplayerkey(pl.sv_entnum, "ping");
\r
668 tmp = max(0, min(220, f-80)) / 220;
\r
669 sbar_field_rgb = '1 1 1' - '0 1 1'*tmp;
\r
673 if not(pl.gotscores)
\r
675 f = pl.ping_packetloss;
\r
676 tmp = pl.ping_movementloss;
\r
677 if(f == 0 && tmp == 0)
\r
679 str = ftos(ceil(f * 100));
\r
681 str = strcat(str, "~", ftos(ceil(tmp * 100)));
\r
682 tmp = bound(0, f / 0.2 + tmp / 0.04, 1); // 20% is REALLY BAD pl
\r
683 sbar_field_rgb = '1 0.5 0.5' - '0 0.5 0.5'*tmp;
\r
687 if(ready_waiting && pl.ready)
\r
689 sbar_field_icon0 = "gfx/sb_player_ready";
\r
693 f = stof(getplayerkey(pl.sv_entnum, "colors"));
\r
695 sbar_field_icon0 = Sbar_GetTexture("sb_playercolor_base");
\r
696 sbar_field_icon1 = Sbar_GetTexture("sb_playercolor_shirt");
\r
697 sbar_field_icon1_rgb = colormapPaletteColor(floor(f / 16), 0);
\r
698 sbar_field_icon2 = Sbar_GetTexture("sb_playercolor_pants");
\r
699 sbar_field_icon2_rgb = colormapPaletteColor(mod(f, 16), 1);
\r
702 return GetPlayerName(pl.sv_entnum);
\r
705 f = pl.(scores[SP_KILLS]);
\r
706 f -= pl.(scores[SP_SUICIDES]);
\r
710 num = pl.(scores[SP_KILLS]);
\r
711 denom = pl.(scores[SP_DEATHS]);
\r
714 sbar_field_rgb = '0 1 0';
\r
716 } else if(num <= 0) {
\r
717 sbar_field_rgb = '1 0 0';
\r
718 str = ftos(num/denom);
\r
720 str = ftos(num/denom);
\r
722 tmp = strstrofs(str, ".", 0);
\r
724 str = substring(str, 0, tmp+2);
\r
728 tmp = pl.(scores[field]);
\r
729 f = scores_flags[field];
\r
730 if(field == ps_primary)
\r
731 sbar_field_rgb = '1 1 0';
\r
732 else if(field == ps_secondary)
\r
733 sbar_field_rgb = '0 1 1';
\r
735 sbar_field_rgb = '1 1 1';
\r
736 return ScoreString(f, tmp);
\r
741 string Sbar_GetStomachField(entity pl, float field)
\r
746 return ""; // the returned value is not used, we only need the field
\r
749 return GetPlayerName(pl.sv_entnum);
\r
752 return ftos(pl.plhealth);
\r
760 string Sbar_GetStomachFieldPred(entity pl, float field)
\r
765 return GetPlayerName(pl.sv_entnum);
\r
772 vector Sbar_GetVoreColor()
\r
774 // gets color based on vore status
\r
775 if(getstati(STAT_VORE_EATEN))
\r
777 if(teamplay && (GetPlayerColor(getstati(STAT_VORE_EATEN) - 1) == GetPlayerColor(player_localentnum - 1) || GetPlayerColor(getstati(STAT_VORE_EATEN) - 1) == GetPlayerColor(spectatee_status - 1))) // same team
\r
778 return stov(cvar_string("sbar_stomachboard_color2"));
\r
780 return stov(cvar_string("sbar_stomachboard_color3"));
\r
783 return stov(cvar_string("sbar_stomachboard_color1"));
\r
786 vector colorfade_current;
\r
787 vector Sbar_ColorFade(vector target_color)
\r
790 step = cvar("sbar_stomachboard_status_fade") * frametime;
\r
792 if(colorfade_current_x >= target_color_x + step)
\r
793 colorfade_current_x -= step;
\r
794 else if(colorfade_current_x <= target_color_x - step)
\r
795 colorfade_current_x += step;
\r
797 if(colorfade_current_y >= target_color_y + step)
\r
798 colorfade_current_y -= step;
\r
799 else if(colorfade_current_y <= target_color_y - step)
\r
800 colorfade_current_y += step;
\r
802 if(colorfade_current_z >= target_color_z + step)
\r
803 colorfade_current_z -= step;
\r
804 else if(colorfade_current_z <= target_color_z - step)
\r
805 colorfade_current_z += step;
\r
807 return colorfade_current;
\r
810 float xmin, xmax, ymin, ymax, sbwidth;
\r
811 float sbar_fixscoreboardcolumnwidth_len;
\r
812 float sbar_fixscoreboardcolumnwidth_iconlen;
\r
813 float sbar_fixscoreboardcolumnwidth_marginlen;
\r
815 float stringwidth_colors(string s, vector theSize)
\r
817 return stringwidth(s, TRUE, theSize);
\r
820 float stringwidth_nocolors(string s, vector theSize)
\r
822 return stringwidth(s, FALSE, theSize);
\r
825 string Sbar_FixScoreboardColumnWidth(float i, string str)
\r
829 field = sbar_field[i];
\r
831 sbar_fixscoreboardcolumnwidth_iconlen = 0;
\r
833 if(sbar_field_icon0 != "")
\r
835 sz = drawgetimagesize(sbar_field_icon0);
\r
837 if(sbar_fixscoreboardcolumnwidth_iconlen < f)
\r
838 sbar_fixscoreboardcolumnwidth_iconlen = f;
\r
841 if(sbar_field_icon1 != "")
\r
843 sz = drawgetimagesize(sbar_field_icon1);
\r
845 if(sbar_fixscoreboardcolumnwidth_iconlen < f)
\r
846 sbar_fixscoreboardcolumnwidth_iconlen = f;
\r
849 if(sbar_field_icon2 != "")
\r
851 sz = drawgetimagesize(sbar_field_icon2);
\r
853 if(sbar_fixscoreboardcolumnwidth_iconlen < f)
\r
854 sbar_fixscoreboardcolumnwidth_iconlen = f;
\r
857 sbar_fixscoreboardcolumnwidth_iconlen *= sbar_fontsize_y / sbar_fontsize_x; // fix icon aspect
\r
859 if(sbar_fixscoreboardcolumnwidth_iconlen != 0)
\r
860 sbar_fixscoreboardcolumnwidth_marginlen = stringwidth(" ", FALSE, sbar_fontsize);
\r
862 sbar_fixscoreboardcolumnwidth_marginlen = 0;
\r
864 if(field == SP_NAME) // name gets all remaining space
\r
867 namesize = sbwidth;// / sbar_fontsize_x;
\r
868 for(j = 0; j < sbar_num_fields; ++j)
\r
870 if (sbar_field[i] != SP_SEPARATOR)
\r
871 namesize -= sbar_size[j] + 1;
\r
873 sbar_size[i] = namesize;
\r
875 if (sbar_fixscoreboardcolumnwidth_iconlen != 0)
\r
876 namesize -= sbar_fixscoreboardcolumnwidth_marginlen + sbar_fixscoreboardcolumnwidth_iconlen;
\r
877 str = textShortenToWidth(str, namesize, sbar_fontsize, stringwidth_colors);
\r
878 sbar_fixscoreboardcolumnwidth_len = stringwidth(str, TRUE, sbar_fontsize);
\r
881 sbar_fixscoreboardcolumnwidth_len = stringwidth(str, FALSE, sbar_fontsize);
\r
883 f = sbar_fixscoreboardcolumnwidth_len + sbar_fixscoreboardcolumnwidth_marginlen + sbar_fixscoreboardcolumnwidth_iconlen;
\r
884 if(sbar_size[i] < f)
\r
890 void Sbar_PrintScoreboardItem(vector pos, entity pl, float is_self, float pl_number)
\r
893 rgb = GetTeamRGB(pl.team);
\r
897 is_spec = (GetPlayerColor(pl.sv_entnum) == COLOR_SPECTATOR);
\r
899 if((rgb == '1 1 1') && (!is_spec))
\r
900 rgb = stov(cvar_string("sbar_color_bg")) + '0.5 0.5 0.5';
\r
904 tmp_y = sbar_fontsize_y * 1.25;
\r
907 // alternated rows highlighting
\r
909 drawfill(pos - '1 1 0', tmp + '2 0 0', rgb, sbar_scoreboard_highlight_alpha_self, DRAWFLAG_NORMAL);
\r
910 else if((sbar_scoreboard_highlight) && (!mod(pl_number,2)))
\r
911 drawfill(pos - '1 1 0', tmp + '2 0 0', rgb, sbar_scoreboard_highlight_alpha, DRAWFLAG_NORMAL);
\r
915 for(i = 0; i < sbar_num_fields; ++i)
\r
917 field = sbar_field[i];
\r
918 if(field == SP_SEPARATOR)
\r
921 if(is_spec && field != SP_NAME && field != SP_PING) {
\r
922 pos_x += sbar_size[i] + sbar_fontsize_x;
\r
925 str = Sbar_GetField(pl, field);
\r
926 str = Sbar_FixScoreboardColumnWidth(i, str);
\r
928 pos_x += sbar_size[i] + sbar_fontsize_x;
\r
930 if(field == SP_NAME) {
\r
931 tmp_x = sbar_size[i] - sbar_fontsize_x*sbar_fixscoreboardcolumnwidth_iconlen - sbar_fixscoreboardcolumnwidth_marginlen + sbar_fontsize_x;
\r
933 drawcolorcodedstring(pos - tmp, str, sbar_fontsize, sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
\r
935 drawcolorcodedstring(pos - tmp, str, sbar_fontsize, sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);
\r
937 tmp_x = sbar_fixscoreboardcolumnwidth_len + sbar_fontsize_x;
\r
939 drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
\r
941 drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);
\r
944 tmp_x = sbar_size[i] + sbar_fontsize_x;
\r
945 if(sbar_field_icon0 != "")
\r
947 drawpic(pos - tmp, sbar_field_icon0, '0 1 0' * sbar_fontsize_y + '1 0 0' * sbar_fontsize_x * sbar_fixscoreboardcolumnwidth_iconlen, sbar_field_icon1_rgb, sbar_field_icon0_alpha * sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
\r
949 drawpic(pos - tmp, sbar_field_icon0, '0 1 0' * sbar_fontsize_y + '1 0 0' * sbar_fontsize_x * sbar_fixscoreboardcolumnwidth_iconlen, sbar_field_icon1_rgb, sbar_field_icon0_alpha * sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);
\r
950 if(sbar_field_icon1 != "")
\r
952 drawpic(pos - tmp, sbar_field_icon1, '0 1 0' * sbar_fontsize_y + '1 0 0' * sbar_fontsize_x * sbar_fixscoreboardcolumnwidth_iconlen, sbar_field_icon1_rgb, sbar_field_icon1_alpha * sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
\r
954 drawpic(pos - tmp, sbar_field_icon1, '0 1 0' * sbar_fontsize_y + '1 0 0' * sbar_fontsize_x * sbar_fixscoreboardcolumnwidth_iconlen, sbar_field_icon1_rgb, sbar_field_icon1_alpha * sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);
\r
955 if(sbar_field_icon2 != "")
\r
957 drawpic(pos - tmp, sbar_field_icon2, '0 1 0' * sbar_fontsize_y + '1 0 0' * sbar_fontsize_x * sbar_fixscoreboardcolumnwidth_iconlen, sbar_field_icon2_rgb, sbar_field_icon2_alpha * sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
\r
959 drawpic(pos - tmp, sbar_field_icon2, '0 1 0' * sbar_fontsize_y + '1 0 0' * sbar_fontsize_x * sbar_fixscoreboardcolumnwidth_iconlen, sbar_field_icon2_rgb, sbar_field_icon2_alpha * sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);
\r
962 if(sbar_field[i] == SP_SEPARATOR)
\r
965 for(i = sbar_num_fields-1; i > 0; --i)
\r
967 field = sbar_field[i];
\r
968 if(field == SP_SEPARATOR)
\r
971 if(is_spec && field != SP_NAME && field != SP_PING) {
\r
972 pos_x -= sbar_size[i] + sbar_fontsize_x;
\r
976 str = Sbar_GetField(pl, field);
\r
977 str = Sbar_FixScoreboardColumnWidth(i, str);
\r
979 if(field == SP_NAME) {
\r
980 tmp_x = sbar_fixscoreboardcolumnwidth_len; // left or right aligned? let's put it right...
\r
982 drawcolorcodedstring(pos - tmp, str, sbar_fontsize, sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
\r
984 drawcolorcodedstring(pos - tmp, str, sbar_fontsize, sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);
\r
986 tmp_x = sbar_fixscoreboardcolumnwidth_len;
\r
988 drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
\r
990 drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);
\r
993 tmp_x = sbar_size[i];
\r
994 if(sbar_field_icon0 != "")
\r
996 drawpic(pos - tmp, sbar_field_icon0, '0 1 0' * sbar_fontsize_y + '1 0 0' * sbar_fontsize_x * sbar_fixscoreboardcolumnwidth_iconlen, sbar_field_icon1_rgb, sbar_field_icon0_alpha * sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
\r
998 drawpic(pos - tmp, sbar_field_icon0, '0 1 0' * sbar_fontsize_y + '1 0 0' * sbar_fontsize_x * sbar_fixscoreboardcolumnwidth_iconlen, sbar_field_icon1_rgb, sbar_field_icon0_alpha * sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);
\r
999 if(sbar_field_icon1 != "")
\r
1001 drawpic(pos - tmp, sbar_field_icon1, '0 1 0' * sbar_fontsize_y + '1 0 0' * sbar_fontsize_x * sbar_fixscoreboardcolumnwidth_iconlen, sbar_field_icon1_rgb, sbar_field_icon1_alpha * sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
\r
1003 drawpic(pos - tmp, sbar_field_icon1, '0 1 0' * sbar_fontsize_y + '1 0 0' * sbar_fontsize_x * sbar_fixscoreboardcolumnwidth_iconlen, sbar_field_icon1_rgb, sbar_field_icon1_alpha * sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);
\r
1004 if(sbar_field_icon2 != "")
\r
1006 drawpic(pos - tmp, sbar_field_icon2, '0 1 0' * sbar_fontsize_y + '1 0 0' * sbar_fontsize_x * sbar_fixscoreboardcolumnwidth_iconlen, sbar_field_icon2_rgb, sbar_field_icon2_alpha * sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
\r
1008 drawpic(pos - tmp, sbar_field_icon2, '0 1 0' * sbar_fontsize_y + '1 0 0' * sbar_fontsize_x * sbar_fixscoreboardcolumnwidth_iconlen, sbar_field_icon2_rgb, sbar_field_icon2_alpha * sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);
\r
1009 pos_x -= sbar_size[i] + sbar_fontsize_x;
\r
1014 void Sbar_PrintStomachboardItem(entity pl, vector position, vector dimensions)
\r
1016 // lists all players in the stomach
\r
1019 float f, field, field_number;
\r
1020 field_number = 3; // the number of components each row has
\r
1022 position = Sbar_ConvertToScreen_PicPosition(position, dimensions);
\r
1023 dimensions = Sbar_ConvertToScreen_PicScale(dimensions);
\r
1025 // set font size to the height of each entry
\r
1027 font_sz_x = font_sz_y = dimensions_y;
\r
1029 float fieldcounter;
\r
1030 for(fieldcounter = 1; fieldcounter <= field_number; ++fieldcounter)
\r
1033 field = -fieldcounter;
\r
1034 str = Sbar_GetStomachField(pl, field);
\r
1036 // row highlighting
\r
1037 if(field == ST_HIGHLIGHT)
\r
1042 drawfill(pos, sz, Sbar_ColorFade(Sbar_GetVoreColor()), cvar("sbar_stomachboard_highlight_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1045 if(field == ST_NAME) {
\r
1046 pos_x = position_x + dimensions_x * cvar("hud_item_preylist_colors_location");
\r
1047 sz_x = dimensions_x * cvar("hud_item_preylist_colors_length");
\r
1049 f = stof(getplayerkey(pl.sv_entnum, "colors"));
\r
1050 drawpic(pos, Sbar_GetTexture("sb_playercolor_base"), sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1051 drawpic(pos, Sbar_GetTexture("sb_playercolor_shirt"), sz, colormapPaletteColor(floor(f / 16), 0), sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1052 drawpic(pos, Sbar_GetTexture("sb_playercolor_pants"), sz, colormapPaletteColor(mod(f, 16), 1), sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1054 pos_x = position_x + dimensions_x * cvar("hud_item_preylist_name_location");
\r
1055 sz_x = dimensions_x * cvar("hud_item_preylist_name_length");
\r
1056 drawcolorcodedstring(pos, textShortenToWidth(str, sz_x, font_sz, stringwidth_colors), font_sz, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1059 if(field == ST_HEALTH) {
\r
1060 pos_x = position_x + dimensions_x * cvar("hud_item_preylist_health_icon_location");
\r
1061 sz_x = dimensions_x * cvar("hud_item_preylist_health_icon_length");
\r
1063 if not(pl.sv_entnum == player_localentnum - 1 || (spectatee_status && pl.sv_entnum == spectatee_status - 1))
\r
1065 drawpic(pos, Sbar_GetTexture("sb_health"), sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1067 pos_x = position_x + dimensions_x * cvar("hud_item_preylist_health_text_location");
\r
1068 sz_x = dimensions_x * cvar("hud_item_preylist_health_text_length");
\r
1069 drawcolorcodedstring(pos, textShortenToWidth(str, sz_x, font_sz, stringwidth_colors), font_sz, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1075 void Sbar_PrintStomachboardItemPred(entity pl, vector position, vector dimensions)
\r
1077 // shows the name of our predator
\r
1080 float f, field, field_number;
\r
1081 field_number = 2; // the number of components each row has
\r
1083 position = Sbar_ConvertToScreen_PicPosition(position, dimensions);
\r
1084 dimensions = Sbar_ConvertToScreen_PicScale(dimensions);
\r
1086 // set font size to the height of each entry
\r
1088 font_sz_x = font_sz_y = dimensions_y;
\r
1090 float fieldcounter;
\r
1091 for(fieldcounter = 1; fieldcounter <= field_number; ++fieldcounter)
\r
1094 field = -fieldcounter;
\r
1095 str = Sbar_GetStomachFieldPred(pl, field);
\r
1097 // row highlighting
\r
1098 if(field == ST_HIGHLIGHT)
\r
1103 drawfill(pos, sz, Sbar_ColorFade(Sbar_GetVoreColor()), cvar("sbar_stomachboard_highlight_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1106 if(field == STP_NAME) {
\r
1107 pos_x = position_x + dimensions_x * cvar("hud_item_predator_colors_location");
\r
1108 sz_x = dimensions_x * cvar("hud_item_predator_colors_length");
\r
1109 f = stof(getplayerkey(pl.sv_entnum, "colors"));
\r
1110 drawpic(pos, Sbar_GetTexture("sb_playercolor_base"), sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1111 drawpic(pos, Sbar_GetTexture("sb_playercolor_shirt"), sz, colormapPaletteColor(floor(f / 16), 0), sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1112 drawpic(pos, Sbar_GetTexture("sb_playercolor_pants"), sz, colormapPaletteColor(mod(f, 16), 1), sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1114 pos_x = position_x + dimensions_x * cvar("hud_item_predator_name_location");
\r
1115 sz_x = dimensions_x * cvar("hud_item_predator_name_length");
\r
1116 drawcolorcodedstring(pos, textShortenToWidth(str, sz_x, font_sz, stringwidth_colors), font_sz, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1122 * Sbar_Scoreboard_MakeTable
\r
1124 * Makes a table for a team (for all playing players in DM) and fills it
\r
1127 vector Sbar_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_size)
\r
1129 float body_table_height, i;
\r
1130 vector tmp, column_dim;
\r
1133 body_table_height = 1.25 * sbar_fontsize_y * max(1, tm.team_size); // no player? show 1 empty line
\r
1137 tmp_x = sbwidth + 2;
\r
1138 tmp_y = 1.25 * sbar_fontsize_y;
\r
1141 drawpic(pos, Sbar_GetTexture("sb_scoreboard_tableheader"), tmp, (rgb * sbar_color_bg_team) + '0.5 0.5 0.5', sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL);
\r
1144 tmp_y += sbar_border_thickness;
\r
1145 tmp_y += body_table_height;
\r
1146 drawborderlines(sbar_border_thickness, pos, tmp, '0 0 0', sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL); // more transparency for the scoreboard
\r
1148 // separator header/table
\r
1149 pos_y += 1.25 * sbar_fontsize_y;
\r
1150 tmp_y = sbar_border_thickness;
\r
1151 drawfill(pos, tmp, '0 0 0', sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL);
\r
1153 pos_y += sbar_border_thickness;
\r
1155 // table background
\r
1156 tmp_y = body_table_height;
\r
1157 drawpic_tiled(pos, Sbar_GetTexture("sb_scoreboard_bg"), bg_size, tmp, rgb * sbar_color_bg_team, sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL);
\r
1159 // anyway, apply some color
\r
1160 //drawfill(pos, tmp + '2 0 0', rgb, 0.1, DRAWFLAG_NORMAL);
\r
1162 // go back to the top to make alternated columns highlighting and to print the strings
\r
1163 pos_y -= 1.25 * sbar_fontsize_y;
\r
1164 pos_y -= sbar_border_thickness;
\r
1168 if (sbar_scoreboard_highlight)
\r
1170 column_dim_y = 1.25 * sbar_fontsize_y; // header
\r
1171 column_dim_y += sbar_border_thickness;
\r
1172 column_dim_y += body_table_height;
\r
1175 // print the strings of the columns headers and draw the columns
\r
1176 for(i = 0; i < sbar_num_fields; ++i)
\r
1178 if(sbar_field[i] == SP_SEPARATOR)
\r
1180 column_dim_x = sbar_size[i] + sbar_fontsize_x;
\r
1181 if (sbar_scoreboard_highlight)
\r
1184 drawfill(pos - '0 1 0' - sbar_fontsize_x / 2 * '1 0 0', column_dim, '0 0 0', sbar_scoreboard_alpha_bg * 0.2, DRAWFLAG_NORMAL);
\r
1186 drawstring(pos, sbar_title[i], sbar_fontsize, rgb * 1.5, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1187 pos_x += column_dim_x;
\r
1189 if(sbar_field[i] == SP_SEPARATOR)
\r
1193 for(i = sbar_num_fields-1; i > 0; --i)
\r
1195 if(sbar_field[i] == SP_SEPARATOR)
\r
1198 pos_x -= sbar_size[i];
\r
1200 if (sbar_scoreboard_highlight)
\r
1204 if (i == sbar_num_fields-1)
\r
1205 column_dim_x = sbar_size[i] + sbar_fontsize_x / 2 + 1;
\r
1207 column_dim_x = sbar_size[i] + sbar_fontsize_x;
\r
1208 drawfill(pos - '0 1 0' - sbar_fontsize_x / 2 * '1 0 0', column_dim, '0 0 0', sbar_scoreboard_alpha_bg * 0.2, DRAWFLAG_NORMAL);
\r
1212 tmp_x = stringwidth(sbar_title[i], FALSE, sbar_fontsize);
\r
1213 tmp_x = sbar_size[i] - tmp_x;
\r
1214 drawstring(pos + tmp, sbar_title[i], sbar_fontsize, rgb * 1.5, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1215 pos_x -= sbar_fontsize_x;
\r
1220 pos_y += 1.25 * sbar_fontsize_y; // skip the header
\r
1221 pos_y += sbar_border_thickness;
\r
1223 // fill the table and draw the rows
\r
1226 for(pl = players.sort_next; pl; pl = pl.sort_next)
\r
1228 if(pl.team != tm.team)
\r
1230 Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), i);
\r
1231 pos_y += 1.25 * sbar_fontsize_y;
\r
1235 for(pl = players.sort_next; pl; pl = pl.sort_next)
\r
1237 if(pl.team == COLOR_SPECTATOR)
\r
1239 Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), i);
\r
1240 pos_y += 1.25 * sbar_fontsize_y;
\r
1245 pos_y += 1.25 * sbar_fontsize_y; // move to the end of the table
\r
1246 pos_y += 1.25 * sbar_fontsize_y; // move empty row (out of the table)
\r
1251 float Sbar_WouldDrawScoreboard() {
\r
1252 if (sb_showscores)
\r
1254 else if (intermission == 1)
\r
1256 else if (intermission == 2)
\r
1258 else if (getstati(STAT_HEALTH) <= 0 && cvar("cl_deathscoreboard"))
\r
1260 else if(sb_showscores_force)
\r
1265 float average_accuracy;
\r
1266 vector Sbar_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
\r
1269 float weapon_hit, weapon_damage, weapon_stats;
\r
1270 float fontsize = 40 * 1/3;
\r
1274 if(cvar("sbar_accuracy_doublerows"))
\r
1278 float height = 40;
\r
1286 drawstring(pos, strcat("Accuracy stats (average ", ftos(average_accuracy), "%)"), sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1290 tmp_y = height * rows;
\r
1292 drawpic_tiled(pos, Sbar_GetTexture("sb_scoreboard_bg"), bg_size, tmp, rgb * sbar_color_bg_team, sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL);
\r
1293 drawborderlines(sbar_accuracy_border_thickness, pos, tmp, '0 0 0', sbar_scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);
\r
1295 // column highlighting
\r
1296 for(i = 0; i < weapon_cnt/rows; ++i)
\r
1299 drawfill(pos + '1 0 0' * (sbwidth/weapon_cnt) * rows * i, '0 1 0' * height * rows + '1 0 0' * (sbwidth/weapon_cnt) * rows, '0 0 0', sbar_scoreboard_alpha_bg * 0.2, DRAWFLAG_NORMAL);
\r
1302 // row highlighting
\r
1303 for(i = 0; i < rows; ++i)
\r
1305 drawfill(pos + '0 1 0' * height * (2/3) + '0 1 0' * height * i, '1 0 0' * sbwidth + '0 1 0' * fontsize, '1 1 1', sbar_scoreboard_highlight_alpha, DRAWFLAG_NORMAL);
\r
1308 // skip useless weapons
\r
1310 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
\r
1312 self = get_weaponinfo(i);
\r
1313 if not(self.weapons)
\r
1318 drawfont = sbar_bigfont;
\r
1319 average_accuracy = 0;
\r
1320 float weapons_with_stats;
\r
1321 weapons_with_stats = 0;
\r
1323 pos_x += sbwidth/weapon_cnt / 2;
\r
1325 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
\r
1327 self = get_weaponinfo(i);
\r
1328 if not(self.weapons)
\r
1330 weapon_hit = weapon_hits[i-WEP_FIRST];
\r
1331 weapon_damage = weapon_fired[i-WEP_FIRST];
\r
1333 weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100);
\r
1334 float weapon_alpha;
\r
1337 weapon_alpha = sbar_scoreboard_alpha_fg;
\r
1339 weapon_alpha = 0.2 * sbar_scoreboard_alpha_fg;
\r
1342 drawpic(pos, Sbar_GetTexture(strcat("inv_weapon", self.netname)), '1 0 0' * sbwidth * (1/weapon_cnt) + '0 1 0' * height * (2/3), '1 1 1', weapon_alpha, DRAWFLAG_NORMAL);
\r
1344 if(weapon_damage) {
\r
1345 weapons_with_stats += 1;
\r
1346 average_accuracy += weapon_stats; // store sum of all accuracies in average_accuracy
\r
1349 s = strcat(ftos(weapon_stats),"%");
\r
1352 padding = ((sbwidth/weapon_cnt) - stringwidth(s, FALSE, '1 0 0' * fontsize)) / 2; // center the accuracy value
\r
1354 rgb = Sbar_AccuracyColor(weapon_stats);
\r
1355 drawstring(pos + '1 0 0' * padding + '0 1 0' * height * (2/3), s, '1 1 0' * fontsize, rgb, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1357 pos_x += sbwidth/weapon_cnt * rows;
\r
1358 if(rows == 2 && i == 6) {
\r
1363 drawfont = sbar_font;
\r
1365 if(weapons_with_stats)
\r
1366 average_accuracy = floor(average_accuracy / weapons_with_stats);
\r
1373 string race_PlaceName(float pos) {
\r
1381 return strcat(ftos(pos), "th");
\r
1384 vector Sbar_DrawScoreboardRankings(vector pos, entity pl, vector rgb, vector bg_size)
\r
1387 RANKINGS_RECEIVED_CNT = 0;
\r
1388 for (i=RANKINGS_CNT-1; i>=0; --i)
\r
1389 if (grecordtime[i])
\r
1390 RANKINGS_RECEIVED_CNT = RANKINGS_RECEIVED_CNT + 1;
\r
1392 if (RANKINGS_RECEIVED_CNT == 0)
\r
1396 is_spec = (GetPlayerColor(pl.sv_entnum) == COLOR_SPECTATOR);
\r
1398 hl_rgb = stov(cvar_string("sbar_color_bg")) + '0.5 0.5 0.5';
\r
1400 pos_y += sbar_fontsize_y;
\r
1401 drawstring(pos, strcat("Rankings"), sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1402 pos_y += sbar_fontsize_y;
\r
1405 tmp_y = sbar_fontsize_y * RANKINGS_RECEIVED_CNT;
\r
1407 drawpic_tiled(pos, Sbar_GetTexture("sb_scoreboard_bg"), bg_size, tmp, rgb * sbar_color_bg_team, sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL);
\r
1408 drawborderlines(sbar_border_thickness, pos, tmp, '0 0 0', sbar_scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);
\r
1410 // row highlighting
\r
1411 for(i = 0; i<RANKINGS_RECEIVED_CNT; ++i)
\r
1415 t = grecordtime[i];
\r
1418 n = grecordholder[i];
\r
1419 p = race_PlaceName(i+1);
\r
1420 if(grecordholder[i] == GetPlayerName(player_localentnum - 1))
\r
1421 drawfill(pos, '1 0 0' * sbwidth + '0 1 0' * sbar_fontsize_y, hl_rgb, sbar_scoreboard_highlight_alpha_self, DRAWFLAG_NORMAL);
\r
1422 else if(!mod(i, 2) && sbar_scoreboard_highlight)
\r
1423 drawfill(pos, '1 0 0' * sbwidth + '0 1 0' * sbar_fontsize_y, hl_rgb, sbar_scoreboard_highlight_alpha, DRAWFLAG_NORMAL);
\r
1424 drawstring(pos, p, sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1425 drawstring(pos + '3 0 0' * sbar_fontsize_x, TIME_ENCODED_TOSTRING(t), sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1426 drawcolorcodedstring(pos + '8 0 0' * sbar_fontsize_x, n, sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1427 pos += '0 1 0' * sbar_fontsize_y;
\r
1433 float scoreboard_bottom;
\r
1434 float sbar_scoreboard_fade_alpha;
\r
1435 float sbar_woulddrawscoreboard_prev;
\r
1436 float sbar_woulddrawscoreboard_change; // "time" at which Sbar_WouldDrawScoreboard() changed
\r
1437 void Sbar_DrawScoreboard()
\r
1439 float sbar_woulddrawscoreboard;
\r
1440 sbar_woulddrawscoreboard = Sbar_WouldDrawScoreboard();
\r
1441 if(sbar_woulddrawscoreboard != sbar_woulddrawscoreboard_prev) {
\r
1442 sbar_woulddrawscoreboard_change = time;
\r
1443 sbar_woulddrawscoreboard_prev = sbar_woulddrawscoreboard;
\r
1446 float scoreboard_fadeinspeed = cvar_or("sbar_scoreboard_fadeinspeed", 10);
\r
1447 float scoreboard_fadeoutspeed = cvar_or("sbar_scoreboard_fadeoutspeed", 5);
\r
1448 if(sbar_woulddrawscoreboard) {
\r
1449 if (scoreboard_fadeinspeed)
\r
1450 sbar_scoreboard_fade_alpha = bound (0, (time - sbar_woulddrawscoreboard_change) * scoreboard_fadeinspeed, 1);
\r
1452 sbar_scoreboard_fade_alpha = 1;
\r
1455 if (scoreboard_fadeoutspeed)
\r
1456 sbar_scoreboard_fade_alpha = bound (0, (1/scoreboard_fadeoutspeed - (time - sbar_woulddrawscoreboard_change)) * scoreboard_fadeoutspeed, 1);
\r
1458 sbar_scoreboard_fade_alpha = 0;
\r
1460 if not(sbar_scoreboard_fade_alpha)
\r
1463 sbar_scoreboard_alpha_bg = cvar("sbar_scoreboard_alpha_bg") * sbar_scoreboard_fade_alpha;
\r
1464 sbar_scoreboard_alpha_fg = cvar_or("sbar_scoreboard_alpha_fg", 1.0) * sbar_scoreboard_fade_alpha;
\r
1465 sbar_scoreboard_highlight = cvar("sbar_scoreboard_highlight");
\r
1466 sbar_scoreboard_highlight_alpha = cvar_or("sbar_scoreboard_highlight_alpha", 0.10) * sbar_scoreboard_alpha_fg;
\r
1467 sbar_scoreboard_highlight_alpha_self = cvar_or("sbar_scoreboard_highlight_alpha_self", 0.25) * sbar_scoreboard_alpha_fg;
\r
1468 sbar_scoreboard_alpha_name = cvar_or("sbar_scoreboard_alpha_name", 0.9) * sbar_scoreboard_alpha_fg;
\r
1469 sbar_scoreboard_alpha_name_self = cvar_or("sbar_scoreboard_alpha_name_self", 1) * sbar_scoreboard_alpha_fg;
\r
1471 vector rgb, pos, tmp;
\r
1474 sbwidth = Sbar_GetWidth(6.5 * sbar_fontsize_y);
\r
1476 xmin = 0.5 * (vid_conwidth - sbwidth);
\r
1477 ymin = cvar("sbar_scoreboard_offset");
\r
1479 xmax = vid_conwidth - xmin;
\r
1480 ymax = vid_conheight - 0.2*vid_conheight;
\r
1482 // Initializes position
\r
1488 drawfont = sbar_bigfont;
\r
1489 if(gametype == GAME_RPG)
\r
1490 drawstringcenter('0 1 0' * ymin, "Players", '24 24 0', '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1492 drawstringcenter('0 1 0' * ymin, "Scoreboard", '24 24 0', '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1495 pos_y += sbar_fontsize_y;
\r
1497 drawfont = sbar_font;
\r
1499 // Draw the scoreboard
\r
1501 bg_size = drawgetimagesize(Sbar_GetTexture("sb_scoreboard_bg"));
\r
1505 for(tm = teams.sort_next; tm; tm = tm.sort_next)
\r
1507 if(tm.team == COLOR_SPECTATOR)
\r
1510 rgb = GetTeamRGB(tm.team);
\r
1511 Sbar_DrawXNum(pos - '9.5 0 0' * sbar_fontsize_y + '0 1 0' * sbar_fontsize_y, tm.(teamscores[ts_primary]), 6, 0, sbar_fontsize_y * 1.5, rgb, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1513 if(ts_primary != ts_secondary)
\r
1514 Sbar_DrawXNum(pos - '7.5 0 0' * sbar_fontsize_y + '0 2.5 0' * sbar_fontsize_y, tm.(teamscores[ts_secondary]), 6, 0, sbar_fontsize_y * 1, rgb, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1516 pos = Sbar_Scoreboard_MakeTable(pos, tm, rgb, bg_size);
\r
1521 rgb = stov(cvar_string("sbar_color_bg"));
\r
1523 for(tm = teams.sort_next; tm; tm = tm.sort_next)
\r
1525 if(tm.team == COLOR_SPECTATOR)
\r
1528 pos = Sbar_Scoreboard_MakeTable(pos, tm, rgb, bg_size);
\r
1532 if(gametype == GAME_CTS || gametype == GAME_RACE) {
\r
1533 if(race_speedaward) {
\r
1534 drawcolorcodedstring(pos, strcat("Speed award: ", ftos(race_speedaward), " (", race_speedaward_holder, ")"), sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1535 pos_y += 1.25 * sbar_fontsize_y;
\r
1537 if(race_speedaward_alltimebest) {
\r
1538 drawcolorcodedstring(pos, strcat("All-time fastest: ", ftos(race_speedaward_alltimebest), " (", race_speedaward_alltimebest_holder, ")"), sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1539 pos_y += 1.25 * sbar_fontsize_y;
\r
1541 pos = Sbar_DrawScoreboardRankings(pos, pl, rgb, bg_size);
\r
1543 else if(cvar("sbar_accuracy") && spectatee_status != -1) {
\r
1545 pos = Sbar_DrawScoreboardAccuracyStats(pos, GetTeamRGB(myteam), bg_size);
\r
1547 pos = Sbar_DrawScoreboardAccuracyStats(pos, rgb, bg_size);
\r
1550 tmp = pos + '0 1.5 0' * sbar_fontsize_y;
\r
1551 pos_y += 3 * sbar_fontsize_y;
\r
1553 // List spectators
\r
1556 for(pl = players.sort_next; pl; pl = pl.sort_next)
\r
1558 if(pl.team != COLOR_SPECTATOR)
\r
1560 Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), specs);
\r
1561 pos_y += 1.25 * sbar_fontsize_y;
\r
1566 drawstring(tmp, "Spectators", sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1568 // Print info string
\r
1571 if(gametype == GAME_RPG)
\r
1572 str = strcat("you are in ^2", shortmapname, "^7");
\r
1574 str = strcat("playing on ^2", shortmapname, "^7");
\r
1575 tl = getstatf(STAT_TIMELIMIT);
\r
1576 fl = getstatf(STAT_FRAGLIMIT);
\r
1577 ll = getstatf(STAT_LEADLIMIT);
\r
1578 if(gametype == GAME_LMS)
\r
1581 str = strcat(str, " for up to ^1", ftos(tl), " minutes^7");
\r
1586 str = strcat(str, " for ^1", ftos(tl), " minutes^7");
\r
1587 if(fl > 0 && !(gametype == GAME_RPG))
\r
1590 str = strcat(str, " or");
\r
1593 str = strcat(str, " until ^3", ScoreString(teamscores_flags[ts_primary], fl));
\r
1594 if(teamscores_label[ts_primary] == "score")
\r
1595 str = strcat(str, " points^7");
\r
1596 else if(teamscores_label[ts_primary] == "fastest")
\r
1597 str = strcat(str, " is beaten^7");
\r
1599 str = strcat(str, " ", teamscores_label[ts_primary]);
\r
1603 str = strcat(str, " until ^3", ScoreString(scores_flags[ps_primary], fl));
\r
1604 if(scores_label[ps_primary] == "score")
\r
1605 str = strcat(str, " points^7");
\r
1606 else if(scores_label[ps_primary] == "fastest")
\r
1607 str = strcat(str, " is beaten^7");
\r
1609 str = strcat(str, " ", scores_label[ps_primary]);
\r
1614 if(tl > 0 || fl > 0)
\r
1615 str = strcat(str, " or");
\r
1618 str = strcat(str, " until a lead of ^3", ScoreString(teamscores_flags[ts_primary], ll));
\r
1619 if(teamscores_label[ts_primary] == "score")
\r
1620 str = strcat(str, " points^7");
\r
1621 else if(teamscores_label[ts_primary] == "fastest")
\r
1622 str = strcat(str, " is beaten^7");
\r
1624 str = strcat(str, " ", teamscores_label[ts_primary]);
\r
1628 str = strcat(str, " until a lead of ^3", ScoreString(scores_flags[ps_primary], ll));
\r
1629 if(scores_label[ps_primary] == "score")
\r
1630 str = strcat(str, " points^7");
\r
1631 else if(scores_label[ps_primary] == "fastest")
\r
1632 str = strcat(str, " is beaten^7");
\r
1634 str = strcat(str, " ", scores_label[ps_primary]);
\r
1640 pos_y += 1.2 * sbar_fontsize_y;
\r
1641 drawcolorcodedstring(pos + '0.5 0 0' * (sbwidth - stringwidth(str, TRUE, sbar_fontsize)), str, sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1643 // print information about respawn status
\r
1644 float respawn_time = getstatf(STAT_RESPAWN_TIME);
\r
1647 if(respawn_time < 0)
\r
1649 // a negative number means we are awaiting respawn, time value is still the same
\r
1650 respawn_time *= -1; // remove mark now that we checked it
\r
1651 if(getstati(STAT_VORE_EATEN))
\r
1652 str = strcat("^1Will respawn after leaving the stomach");
\r
1653 else if(time >= respawn_time) // don't show a negative value while the server is respawning the player (lag)
\r
1654 str = strcat("^1Respawning...");
\r
1656 str = strcat("^1Respawning in ^3", ftos_decimals(respawn_time - time, 2), "^1 seconds...");
\r
1658 else if(time < respawn_time)
\r
1659 str = strcat("You are dead, wait ^3", ftos_decimals(respawn_time - time, 2), "^7 seconds before respawning");
\r
1660 else if(time >= respawn_time)
\r
1661 str = strcat("You are dead, press ^2", getcommandkey("primary fire", "+fire"), "^7 to respawn");
\r
1663 pos_y += 1.2 * sbar_fontsize_y;
\r
1664 drawcolorcodedstring(pos + '0.5 0 0' * (sbwidth - stringwidth(str, TRUE, sbar_fontsize)), str, sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1667 scoreboard_bottom = pos_y + 2 * sbar_fontsize_y;
\r
1670 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
\r
1678 if(histime == 0) // goal hit
\r
1682 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
\r
1685 else if(mytime == 0)
\r
1692 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
\r
1698 lapstr = strcat(" (-", ftos(lapdelta), "L)");
\r
1701 else if(lapdelta < 0)
\r
1703 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
\r
1707 else if(histime > 0) // anticipation
\r
1709 if(mytime >= histime)
\r
1710 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
\r
1712 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
\r
1719 cpname = "Start line";
\r
1720 else if(cp == 255)
\r
1721 cpname = "Finish line";
\r
1723 cpname = strcat("Intermediate ", ftos(cp));
\r
1725 cpname = "Finish line";
\r
1728 return strcat(col, cpname);
\r
1729 else if(hisname == "")
\r
1730 return strcat(col, cpname, " (", timestr, ")");
\r
1732 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
\r
1735 float race_CheckName(string net_name) { // Does the name already exist in rankings? In that case, where? (otherwise 0)
\r
1737 for (i=RANKINGS_CNT-1;i>=0;--i)
\r
1738 if(grecordholder[i] == net_name)
\r
1743 float GetAmmoStat(float i)
\r
1747 case 0: return STAT_FUEL;
\r
1748 default: return -1;
\r
1752 float GetAmmoItemCode(float i)
\r
1756 case 0: return IT_FUEL;
\r
1757 default: return -1;
\r
1761 string GetAmmoPicture(float i)
\r
1766 if(getstati(STAT_ITEMS) & IT_FUEL_REGEN)
\r
1767 return Sbar_GetTexture("sb_fuel_regen");
\r
1769 return Sbar_GetTexture("sb_fuel");
\r
1775 void Sbar_DrawBackgrounds()
\r
1777 // Draw all backgrounds defined by our HUD setup
\r
1778 if (cvar("viewsize") > 100 || !sbar_hudselector)
\r
1781 float total = cvar("hud_backgrounds");
\r
1783 for(i = 1; i <= total; i++)
\r
1785 string img = Sbar_GetTexture(cvar_string(strcat("hud_background_", ftos(i), "_texture")));
\r
1786 vector pos = stov(cvar_string(strcat("hud_background_", ftos(i), "_position")));
\r
1787 vector sz = stov(cvar_string(strcat("hud_background_", ftos(i), "_scale")));
\r
1789 pos = Sbar_ConvertToScreen_PicPosition(pos, sz);
\r
1790 sz = Sbar_ConvertToScreen_PicScale(sz);
\r
1793 switch(cvar(strcat("hud_background_", ftos(i), "_colortype")))
\r
1797 col = GetTeamRGB(myteam) * sbar_color_bg_team;
\r
1799 col = stov(cvar_string("sbar_color_bg"));
\r
1802 col = Sbar_ColorFade(Sbar_GetVoreColor());
\r
1809 drawpic(pos, img, sz, col, sbar_alpha_bg, DRAWFLAG_NORMAL);
\r
1813 float race_status_time;
\r
1814 float race_status_prev;
\r
1815 string race_status_name_prev;
\r
1816 void Sbar_DrawRaceStatus(vector pos)
\r
1818 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
\r
1819 race_status_time = time + 5;
\r
1820 race_status_prev = race_status;
\r
1821 if (race_status_name_prev)
\r
1822 strunzone(race_status_name_prev);
\r
1823 race_status_name_prev = strzone(race_status_name);
\r
1827 a = bound(0, race_status_time - time, 1);
\r
1830 s = textShortenToWidth(race_status_name, 120, '10 10 0', stringwidth_colors);
\r
1833 if(race_status > 0)
\r
1834 rank = race_CheckName(race_status_name);
\r
1836 rankname = race_PlaceName(rank);
\r
1838 if(race_status == 0)
\r
1839 drawpic(pos, Sbar_GetTexture("race/newfail"), '80 80 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1840 else if(race_status == 1) {
\r
1841 drawpic(pos, Sbar_GetTexture("race/newtime"), '80 80 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1842 drawcolorcodedstring(pos + '40 80 0' - '1 0 0' * stringwidth(s, TRUE, '5 0 0'), s, '10 10 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1843 drawstring(pos + '40 20 0' - '1 0 0' * stringwidth(rankname, TRUE, '7 0 0'), rankname, '14 14 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1844 } else if(race_status == 2) {
\r
1845 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
\r
1846 drawpic(pos, Sbar_GetTexture("race/newrankgreen"), '80 80 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1848 drawpic(pos, Sbar_GetTexture("race/newrankyellow"), '80 80 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1849 drawcolorcodedstring(pos + '40 80 0' - '1 0 0' * stringwidth(s, TRUE, '5 0 0'), s, '10 10 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1850 drawstring(pos + '40 20 0' - '1 0 0' * stringwidth(rankname, TRUE, '7 0 0'), rankname, '14 14 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1851 } else if(race_status == 3) {
\r
1852 drawpic(pos, Sbar_GetTexture("race/newrecordserver"), '80 80 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1853 drawcolorcodedstring(pos + '40 80 0' - '1 0 0' * stringwidth(s, TRUE, '5 0 0'), s, '10 10 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1854 drawstring(pos + '40 20 0' - '1 0 0' * stringwidth(rankname, TRUE, '7 0 0'), rankname, '14 14 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1857 if (race_status_time - time <= 0) {
\r
1858 race_status_prev = -1;
\r
1860 if(race_status_name)
\r
1861 strunzone(race_status_name);
\r
1862 race_status_name = string_null;
\r
1863 if(race_status_name_prev)
\r
1864 strunzone(race_status_name_prev);
\r
1865 race_status_name_prev = string_null;
\r
1869 void Sbar_Portrait()
\r
1871 // draws the portrait, using the values set in Ent_ReadPortrait
\r
1873 // make the portrait slide in and out of the left edge
\r
1875 float fade1_start, fade1_end, fade2_start, fade2_end;
\r
1876 float fade_in, fade_out;
\r
1878 fade_time = cvar("sbar_portrait_time") * bound(0, cvar("sbar_portrait_fade"), 0.5);
\r
1880 fade1_start = portrait_time + cvar("sbar_portrait_time") - fade_time;
\r
1881 fade1_end = portrait_time + cvar("sbar_portrait_time");
\r
1882 fade2_start = portrait_time;
\r
1883 fade2_end = portrait_time + fade_time;
\r
1885 fade_in = bound(0, (time / fade1_end - 1) / (fade1_start / fade1_end - 1), 1);
\r
1886 fade_out = 1 - bound(0, (time / fade2_end - 1) / (fade2_start / fade2_end - 1), 1);
\r
1888 vector left, fade_pos;
\r
1890 left_y = vid_conheight / 2;
\r
1891 fade_pos_x = -130 * fade_in * fade_out;
\r
1893 if(!cvar("sbar_portrait"))
\r
1896 if(portrait_time + cvar("sbar_portrait_time") >= time)
\r
1898 if(portrait_image && portrait_name) // prevent using bad strings
\r
1900 drawpic(left - '120 80 0' - fade_pos, portrait_image, '120 160 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1901 drawcolorcodedstring(left - '120 -80 0' - fade_pos, textShortenToWidth(portrait_name, 120, '12 12 0', stringwidth_colors), '12 12 0', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1906 // free unused strings from memory
\r
1907 if(portrait_image)
\r
1909 strunzone(portrait_image);
\r
1910 portrait_image = string_null;
\r
1914 strunzone(portrait_name);
\r
1915 portrait_name = string_null;
\r
1922 float score, distribution, leader;
\r
1923 vector distribution_color;
\r
1924 string racetime, secondary_racetime;
\r
1925 entity tm, pl, me;
\r
1926 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
\r
1928 if(gametype == GAME_RPG)
\r
1931 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
\r
1932 pl = players.sort_next;
\r
1934 pl = pl.sort_next;
\r
1935 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
\r
1936 if(pl.scores[ps_primary] == 0)
\r
1939 score = me.(scores[ps_primary]);
\r
1941 float racemin, racesec, racemsec;
\r
1942 float distsec, distmsec;
\r
1943 string s_racemin, s_racesec, s_racemsec;
\r
1945 racemin = floor(score/(60 * TIME_FACTOR));
\r
1946 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
\r
1947 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
\r
1949 if(racemin < 10) s_racemin = strcat("0", ftos(racemin));
\r
1950 else s_racemin = ftos(racemin);
\r
1951 if(racesec < 10) s_racesec = strcat("0", ftos(racesec));
\r
1952 else s_racesec = ftos(racesec);
\r
1953 if(racemsec < 10) s_racemsec = strcat("0", ftos(racemsec));
\r
1954 else s_racemsec = ftos(racemsec);
\r
1956 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
\r
1957 // distribution display
\r
1958 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
\r
1960 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
\r
1961 distmsec = fabs(distribution);
\r
1963 distsec = floor(fabs(distribution) / TIME_FACTOR);
\r
1964 distmsec = fabs(distribution) - distsec * TIME_FACTOR;
\r
1967 if (distribution < 0) {
\r
1968 distribution_color = '0 1 0';
\r
1969 secondary_racetime = "-"; // always prefix with minus sign
\r
1971 else if (distribution > 0) {
\r
1972 distribution_color = '1 0 0';
\r
1973 secondary_racetime = "+"; // minusplus 1: always prefix with plus sign
\r
1976 distribution_color = '1 1 1';
\r
1978 secondary_racetime = strcat(secondary_racetime, ftos(distsec), ".", ftos(distmsec));
\r
1979 drawstring(Sbar_ConvertToScreen_TextPosition(secondary_racetime, stov(cvar_string("hud_item_score_race_secondary_text_position")), cvar("hud_item_score_race_secondary_text_scale")), secondary_racetime, '1 1 0' * cvar("hud_item_score_race_secondary_text_scale"), distribution_color, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1982 racetime = strcat(s_racemin, " : ", s_racesec, " . ", s_racemsec);
\r
1983 Sbar_DrawString(racetime, stov(cvar_string("hud_item_score_race_primary_text_position")), cvar("hud_item_score_race_primary_text_scale"));
\r
1985 } else if (!teamplay) { // non-teamgames, except race/cts
\r
1986 // me vector := [team/connected frags id]
\r
1987 pl = players.sort_next;
\r
1989 pl = pl.sort_next;
\r
1992 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
\r
1996 score = me.(scores[ps_primary]);
\r
1998 if(distribution >= 5) {
\r
1999 distribution_color = '0 1 0';
\r
2001 } else if(distribution >= 0) {
\r
2002 distribution_color = '1 1 1';
\r
2004 } else if(distribution >= -5)
\r
2005 distribution_color = '1 1 0';
\r
2007 distribution_color = '1 0 0';
\r
2009 Sbar_DrawXNum(stov(cvar_string("hud_item_score_nonteam_secondary_text_position")), distribution, 6, 3, cvar("hud_item_score_nonteam_secondary_text_scale"), distribution_color, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2010 Sbar_DrawXNum(stov(cvar_string("hud_item_score_nonteam_primary_text_position")), score, 6, 0, cvar("hud_item_score_nonteam_primary_text_scale"), distribution_color, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2011 } else { // teamgames
\r
2012 float max_fragcount;
\r
2013 max_fragcount = -999;
\r
2015 vector pos = stov(cvar_string("hud_item_score_team_secondary_text_position"));
\r
2016 vector sz = '1 1 0' * cvar("hud_item_score_team_secondary_text_scale");
\r
2017 sz_x = sz_x / vid_conwidth;
\r
2018 sz_y = sz_y / vid_height * 2;
\r
2019 vector dir = stov(cvar_string("hud_item_score_team_secondary_entry_spacing"));
\r
2020 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
\r
2021 if(tm.team == COLOR_SPECTATOR || !tm.team_size) // no players? don't display
\r
2023 score = tm.(teamscores[ts_primary]);
\r
2026 if (score > max_fragcount)
\r
2027 max_fragcount = score;
\r
2029 if(tm.team == myteam) {
\r
2030 if (max_fragcount == score)
\r
2032 Sbar_DrawXNum(stov(cvar_string("hud_item_score_team_primary_text_position")), score, 6, 0, cvar("hud_item_score_team_primary_text_scale"), GetTeamRGB(tm.team), sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2034 if (max_fragcount == score)
\r
2036 Sbar_DrawXNum(pos, score, 6, 3, cvar("hud_item_score_team_secondary_text_scale"), GetTeamRGB(tm.team), sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2037 pos_x += sz_x * dir_x;
\r
2038 pos_y += sz_y * dir_y;
\r
2043 if(gametype == GAME_RACE || gametype == GAME_CTS)
\r
2045 drawfont = sbar_bigfont;
\r
2048 string s, forcetime;
\r
2050 m = '0.5 0 0' * vid_conwidth + '0 1 0' * cvar_or("cl_racetimer_position", 0.25) * vid_conheight;
\r
2052 if(race_checkpointtime)
\r
2054 a = bound(0, 2 - (time - race_checkpointtime), 1);
\r
2057 if(a > 0) // just hit a checkpoint?
\r
2059 if(race_checkpoint != 254)
\r
2061 if(race_time && race_previousbesttime)
\r
2062 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
\r
2064 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
\r
2066 forcetime = TIME_ENCODED_TOSTRING(race_time);
\r
2071 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
\r
2073 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
\r
2074 if(a > 0) // next one?
\r
2076 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
\r
2081 if(s != "" && a > 0)
\r
2083 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
\r
2084 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
2085 drawcolorcodedstring(m - '0 16 0' - '0.5 0 0' * stringwidth(s, TRUE, '16 16 0'), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
2088 if(race_penaltytime)
\r
2090 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
\r
2093 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
\r
2094 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
\r
2095 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
2096 drawcolorcodedstring(m - '0 32 0' - '0.5 0 0' * stringwidth(s, TRUE, '16 16 0'), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
2100 if(forcetime != "")
\r
2102 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
\r
2103 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', sbar_alpha_fg, 0, a);
\r
2104 drawstring_expanding(m - '1 0 0' * stringwidth(forcetime, FALSE, '16 0 0'), forcetime, '32 32 0', '1 1 1', sbar_alpha_fg, 0, a);
\r
2109 if(race_laptime && race_checkpoint != 255)
\r
2111 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
\r
2112 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
2113 drawstring(m - '0.5 0 0' * stringwidth(s, FALSE, '32 32 0'), s, '32 32 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
2118 if(race_mycheckpointtime)
\r
2120 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
\r
2121 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
\r
2122 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
\r
2123 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
2124 drawcolorcodedstring(m - '0 16 0' - '0.5 0 0' * stringwidth(s, TRUE, '16 16 0'), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
2126 if(race_othercheckpointtime && race_othercheckpointenemy != "")
\r
2128 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
\r
2129 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
\r
2130 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
\r
2131 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
2132 drawcolorcodedstring(m - '0 0 0' - '0.5 0 0' * stringwidth(s, TRUE, '16 16 0'), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
2135 if(race_penaltytime && !race_penaltyaccumulator)
\r
2137 t = race_penaltytime * 0.1 + race_penaltyeventtime;
\r
2138 a = bound(0, (1 + t - time), 1);
\r
2142 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
\r
2144 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
\r
2145 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
\r
2146 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
2147 drawcolorcodedstring(m - '0 32 0' - '0.5 0 0' * stringwidth(s, TRUE, '16 16 0'), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
2152 drawfont = sbar_font;
\r
2156 void Sbar_Status()
\r
2158 float armor, health, x, a;
\r
2159 armor = getstati(STAT_ARMOR);
\r
2160 health = getstati(STAT_HEALTH);
\r
2163 stat_items = getstati(STAT_ITEMS);
\r
2169 Sbar_DrawPic(Sbar_GetTexture("sb_armor"), stov(cvar_string("hud_item_armor_icon_position")), stov(cvar_string("hud_item_armor_icon_scale")), FALSE);
\r
2170 Sbar_DrawXNum(stov(cvar_string("hud_item_armor_text_position")), x, 3, 0, cvar("hud_item_armor_text_scale"), Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2175 Sbar_DrawPic(Sbar_GetTexture("sb_health"), stov(cvar_string("hud_item_health_icon_position")), stov(cvar_string("hud_item_health_icon_scale")), FALSE);
\r
2176 Sbar_DrawXNum(stov(cvar_string("hud_item_health_text_position")), x, 3, 0, cvar("hud_item_health_text_scale"), Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2178 // if we are dead, we can skip the HUD from here
\r
2183 float weapon_clipload, weapon_clipsize;
\r
2185 // if we are using the jetpack, show fuel ammo. Otherwise show the ammo of our weapon
\r
2186 if(stat_items & IT_JETPACK && button_jetpack)
\r
2188 a = getstati(GetAmmoStat(0)); // how much fuel do we have?
\r
2189 Sbar_DrawPic(GetAmmoPicture(0), stov(cvar_string("hud_item_ammo_icon_position")), stov(cvar_string("hud_item_ammo_noload_icon_scale")), FALSE);
\r
2190 Sbar_DrawXNum(stov(cvar_string("hud_item_ammo_noload_text_position")), a, 3, 0, cvar("hud_item_ammo_noload_text_scale"), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2195 for (i = 0; i < 1; ++i)
\r
2197 // Since fuel is currently the only ammo, always show it on the HUD.
\r
2198 // In case we ever get more ammos, comment the line below back in.
\r
2199 // if (stat_items & GetAmmoItemCode(i))
\r
2201 a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i?
\r
2202 Sbar_DrawPic(GetAmmoPicture(i), stov(cvar_string("hud_item_ammo_icon_position")), stov(cvar_string("hud_item_ammo_icon_scale")), FALSE);
\r
2203 weapon_clipsize = getstati(STAT_WEAPON_CLIPSIZE);
\r
2205 // if the weapon we're holding is reloadable, show both its ammo and load
\r
2206 if(weapon_clipsize)
\r
2208 weapon_clipload = getstati(STAT_WEAPON_CLIPLOAD);
\r
2209 if(weapon_clipload < 0) // we're reloading
\r
2210 Sbar_DrawString("- -", stov(cvar_string("hud_item_ammo_load_clip_text_position")), cvar("hud_item_ammo_load_clip_text_scale"));
\r
2212 Sbar_DrawXNum(stov(cvar_string("hud_item_ammo_load_clip_text_position")), weapon_clipload, 2, 0, cvar("hud_item_ammo_load_clip_text_scale"), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2213 Sbar_DrawXNum(stov(cvar_string("hud_item_ammo_load_text_position")), a, 3, 0, cvar("hud_item_ammo_load_text_scale"), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2217 Sbar_DrawXNum(stov(cvar_string("hud_item_ammo_noload_text_position")), a, 3, 0, cvar("hud_item_ammo_noload_text_scale"), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2225 e = get_weaponinfo(activeweapon);
\r
2226 if (e && e.netname != "" && e.netname != "N/A")
\r
2227 Sbar_DrawPic(Sbar_GetTexture(strcat("sb_activeweapon_", e.netname)), stov(cvar_string("hud_item_weapon_position")), stov(cvar_string("hud_item_weapon_scale")), FALSE);
\r
2232 float timelimit, elapsedTime, minutes, seconds, timeleft, minutesLeft, secondsLeft;
\r
2233 vector timer_color;
\r
2236 timelimit = getstatf(STAT_TIMELIMIT);
\r
2238 if(gametype == GAME_RPG && !timelimit) // don't draw the timer in rpg if there's no time limit
\r
2241 Sbar_DrawRaceStatus('0 20 0');
\r
2243 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
\r
2244 timeleft = ceil(timeleft);
\r
2245 minutesLeft = floor(timeleft / 60);
\r
2246 secondsLeft = timeleft - minutesLeft*60;
\r
2248 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
\r
2249 timer_color = '1 1 1'; //white
\r
2250 else if(minutesLeft >= 1)
\r
2251 timer_color = '1 1 0'; //yellow
\r
2253 timer_color = '1 0 0'; //red
\r
2255 if (cvar("sbar_increment_maptime") || timelimit == 0 || warmup_stage) {
\r
2256 if (time < getstatf(STAT_GAMESTARTTIME)) {
\r
2257 //while restart is still active, show 00:00
\r
2258 minutes = seconds = 0;
\r
2260 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
\r
2261 minutes = floor(elapsedTime / 60);
\r
2262 seconds = elapsedTime - minutes*60;
\r
2265 minutes = minutesLeft;
\r
2266 seconds = secondsLeft;
\r
2269 Sbar_DrawPic(Sbar_GetTexture("sb_time"), stov(cvar_string("hud_item_timer_icon_position")), stov(cvar_string("hud_item_timer_icon_scale")), FALSE);
\r
2271 finaltime = strcat(ftos(minutes), ":");
\r
2273 finaltime = strcat(finaltime, "0", ftos(seconds));
\r
2275 finaltime = strcat(finaltime, ftos(seconds));
\r
2277 drawstring(Sbar_ConvertToScreen_TextPosition(finaltime, stov(cvar_string("hud_item_timer_text_position")), cvar("hud_item_timer_text_scale")), finaltime, '1 1 0' * cvar("hud_item_timer_text_scale"), timer_color, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2282 vector ring_pos, ring1_color, ring2_color;
\r
2283 vector text_pos, text1_size, text2_size;
\r
2284 float ring1_alpha, ring2_alpha, ring1_size, ring1_clip, ring2_size, ring2_clip;
\r
2285 string text1_msg, text2_msg;
\r
2287 ring_pos_x = vid_conwidth / 2;
\r
2288 ring_pos_y = vid_conheight - vid_conheight / 3.5;
\r
2289 ring1_size = cvar("sbar_ring1_scale");
\r
2290 ring2_size = cvar("sbar_ring2_scale");
\r
2291 ring1_alpha = sbar_alpha_fg * cvar("sbar_ring1_alpha");
\r
2292 ring2_alpha = sbar_alpha_fg * cvar("sbar_ring2_alpha");
\r
2293 text1_size = '1 1 0' * cvar("sbar_ring1_text_scale");
\r
2294 text2_size = '1 1 0' * cvar("sbar_ring2_text_scale");
\r
2296 switch(getstati(STAT_SBRING1_TYPE))
\r
2302 // ring shows predator swallow progress, fills with progress
\r
2303 ring1_color = '0.5 1 0.5';
\r
2304 text1_msg = "Swallowing...";
\r
2307 // ring shows vore system delay, empties with progress
\r
2308 ring1_color = '0.5 0.5 1';
\r
2309 text1_msg = "Vore delay";
\r
2312 // ring shows stomach kick delay, empties with progress
\r
2313 ring1_color = '1 1 0.5';
\r
2314 text1_msg = "Kick delay";
\r
2317 print(strcat("^1Error:^7 Unknown ring type: ", ftos(getstati(STAT_SBRING1_TYPE)), "\n"));
\r
2320 switch(getstati(STAT_SBRING2_TYPE))
\r
2326 // ring shows prey swallow progress, fills with progress
\r
2327 ring2_color = '1 0.5 0.5';
\r
2328 text2_msg = "Swallowed...";
\r
2331 // ring shows regurgitation preparing, fills with progress
\r
2332 ring2_color = '1 0.5 1';
\r
2333 text2_msg = "Regurgitating...";
\r
2336 print(strcat("^1Error:^7 Unknown ring type: ", ftos(getstati(STAT_SBRING1_TYPE)), "\n"));
\r
2339 ring1_clip = getstatf(STAT_SBRING1_CLIP);
\r
2340 ring2_clip = getstatf(STAT_SBRING2_CLIP);
\r
2342 if(text1_msg != "" && cvar("sbar_ring1"))
\r
2344 DrawCircleClippedPic(ring_pos, ring1_size, Sbar_GetTexture("sb_ring.tga"), ring1_clip, ring1_color, ring1_alpha, DRAWFLAG_ADDITIVE);
\r
2345 text_pos_x = ring_pos_x - stringwidth(text1_msg, FALSE, text1_size) / 2;
\r
2346 text_pos_y = ring_pos_y - ring1_size / 2;
\r
2347 drawstring(text_pos, text1_msg, text1_size, ring1_color, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2349 if(text2_msg != "" && cvar("sbar_ring2"))
\r
2351 DrawCircleClippedPic(ring_pos, ring2_size, Sbar_GetTexture("sb_ring.tga"), ring2_clip, ring2_color, ring2_alpha, DRAWFLAG_ADDITIVE);
\r
2352 text_pos_x = ring_pos_x - stringwidth(text2_msg, FALSE, text2_size) / 2;
\r
2353 text_pos_y = ring_pos_y + ring1_size / 2;
\r
2354 drawstring(text_pos, text2_msg, text2_size, ring2_color, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2358 void CSQC_Strength_Timer() {
\r
2359 float stat_items, dt;
\r
2360 stat_items = getstati(STAT_ITEMS);
\r
2362 if not(stat_items & IT_STRENGTH)
\r
2363 if not(stat_items & IT_INVINCIBLE)
\r
2367 if (getstati(STAT_HEALTH) <= 0)
\r
2371 float strength_time, invincibility_time;
\r
2374 strength_time = getstatf(STAT_STRENGTH_FINISHED);
\r
2375 if (strength_time) {
\r
2376 dt = strength_time - time;
\r
2377 pos = Sbar_ConvertToScreen_PicPosition(stov(cvar_string("hud_item_strength_icon_position")), stov(cvar_string("hud_item_strength_icon_scale")));
\r
2378 sz = Sbar_ConvertToScreen_PicScale(stov(cvar_string("hud_item_strength_icon_scale")));
\r
2383 drawpic_expanding_two(pos, Sbar_GetTexture("sb_str"), sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE,
\r
2384 bound(0, (ceil(dt) - dt) / 0.5, 1));
\r
2388 drawpic(pos, Sbar_GetTexture("sb_str"), sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE);
\r
2390 Sbar_DrawXNum(stov(cvar_string("hud_item_strength_text_position")), ceil(dt), 2, 0, cvar("hud_item_strength_text_scale"), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2394 drawpic_expanding(pos, Sbar_GetTexture("sb_str"), sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE,
\r
2395 bound(0, -dt / 0.5, 1));
\r
2400 invincibility_time = getstatf(STAT_INVINCIBLE_FINISHED);
\r
2401 if (invincibility_time) {
\r
2402 dt = invincibility_time - time;
\r
2403 pos = Sbar_ConvertToScreen_PicPosition(stov(cvar_string("hud_item_invincible_icon_position")), stov(cvar_string("hud_item_invincible_icon_scale")));
\r
2404 sz = Sbar_ConvertToScreen_PicScale(stov(cvar_string("hud_item_invincible_icon_scale")));
\r
2409 drawpic_expanding_two(pos, Sbar_GetTexture("sb_invinc"), sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE,
\r
2410 bound(0, (ceil(dt) - dt) / 0.5, 1));
\r
2414 drawpic(pos, Sbar_GetTexture("sb_invinc"), sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE);
\r
2416 Sbar_DrawXNum(stov(cvar_string("hud_item_invincible_text_position")), ceil(dt), 2, 0, cvar("hud_item_invincible_text_scale"), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2420 drawpic_expanding(pos, Sbar_GetTexture("sb_invinc"), sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE,
\r
2421 bound(0, -dt / 0.5, 1));
\r
2426 #define CENTERPRINT_MAX_LINES 30
\r
2427 string centerprint_messages[CENTERPRINT_MAX_LINES];
\r
2428 float centerprint_width[CENTERPRINT_MAX_LINES];
\r
2429 vector centerprint_start;
\r
2430 float centerprint_expire;
\r
2431 float centerprint_num;
\r
2432 float centerprint_offset_hint;
\r
2433 vector centerprint_fontsize;
\r
2435 void centerprint(string strMessage)
\r
2437 float i, j, n, hcount;
\r
2440 centerprint_fontsize = Sbar_GetFontsize("scr_centersize");
\r
2442 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
\r
2444 if(cvar("scr_centertime") <= 0)
\r
2447 if(strMessage == "")
\r
2450 // strip trailing newlines
\r
2451 j = strlen(strMessage) - 1;
\r
2452 while(substring(strMessage, j, 1) == "\n" && j >= 0)
\r
2454 strMessage = substring(strMessage, 0, j + 1);
\r
2456 if(strMessage == "")
\r
2459 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
\r
2461 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
\r
2463 strMessage = substring(strMessage, j, strlen(strMessage) - j);
\r
2464 centerprint_offset_hint = j;
\r
2466 if(strMessage == "")
\r
2469 // if we get here, we have a message. Initialize its height.
\r
2470 centerprint_num = 0;
\r
2472 n = tokenizebyseparator(strMessage, "\n");
\r
2474 for(j = 0; j < n; ++j)
\r
2476 getWrappedLine_remaining = argv(j);
\r
2477 while(getWrappedLine_remaining)
\r
2479 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
\r
2480 if(centerprint_messages[i])
\r
2481 strunzone(centerprint_messages[i]);
\r
2482 centerprint_messages[i] = strzone(s);
\r
2483 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
\r
2486 // half height for empty lines looks better
\r
2492 if(i >= CENTERPRINT_MAX_LINES)
\r
2498 h = centerprint_fontsize_y*hcount;
\r
2500 havail = vid_conheight;
\r
2501 if(cvar("con_chatpos") < 0)
\r
2502 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
\r
2503 if(havail > vid_conheight / 4)
\r
2504 havail = vid_conheight / 4; // avoid overlapping HUD
\r
2506 centerprint_start_x = 0;
\r
2509 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
\r
2511 // here, the centerprint would cover the crosshair. REALLY BAD.
\r
2512 forbiddenmin = vid_conheight * 0.5 - h - 16;
\r
2513 forbiddenmax = vid_conheight * 0.5 + 16;
\r
2515 allowedmin = scoreboard_bottom;
\r
2516 allowedmax = havail - h;
\r
2517 preferred = (havail - h)/2;
\r
2520 // possible orderings (total: 4! / 4 = 6)
\r
2521 // allowedmin allowedmax forbiddenmin forbiddenmax
\r
2522 // forbiddenmin forbiddenmax allowedmin allowedmax
\r
2523 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
\r
2525 // forbidden doesn't matter in this case
\r
2526 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
\r
2528 // allowedmin forbiddenmin allowedmax forbiddenmax
\r
2529 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
\r
2531 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
\r
2533 // allowedmin forbiddenmin forbiddenmax allowedmax
\r
2534 else if(allowedmin < forbiddenmin)
\r
2536 // make sure the forbidden zone is not covered
\r
2537 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
\r
2538 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
\r
2540 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
\r
2542 // forbiddenmin allowedmin allowedmax forbiddenmax
\r
2543 else if(allowedmax < forbiddenmax)
\r
2545 // it's better to leave the allowed zone (overlap with scoreboard) than
\r
2546 // to cover the forbidden zone (crosshair)
\r
2547 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
\r
2548 centerprint_start_y = forbiddenmax;
\r
2550 centerprint_start_y = forbiddenmin;
\r
2552 // forbiddenmin allowedmin forbiddenmax allowedmax
\r
2555 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
\r
2558 centerprint_start_y =
\r
2561 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
\r
2568 centerprint_num = i;
\r
2569 centerprint_expire = time + cvar("scr_centertime");
\r
2572 void Sbar_DrawCenterPrint (void)
\r
2579 //if(time > centerprint_expire)
\r
2582 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
\r
2583 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
\r
2584 //sz = 1.2 / (a + 0.2);
\r
2589 pos = centerprint_start;
\r
2590 for (i=0; i<centerprint_num; i = i + 1)
\r
2592 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
\r
2593 ts = centerprint_messages[i];
\r
2596 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
\r
2597 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
\r
2598 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
\r
2599 pos_y = pos_y + centerprint_fontsize_y;
\r
2602 // half height for empty lines looks better
\r
2603 pos_y = pos_y + centerprint_fontsize_y * 0.5;
\r
2607 vector Sbar_DrawNoteLine(vector offset, string s)
\r
2609 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
\r
2610 drawcolorcodedstring(
\r
2611 offset - '1 0 0' * stringwidth(s, TRUE, sbar_fontsize),
\r
2617 return offset + sbar_fontsize_y * '0 1 0';
\r
2620 void Sbar_DrawPressedKeys(void)
\r
2622 vector pos, bgsize;
\r
2623 float pressedkeys;
\r
2625 pos = stov(cvar_string("cl_showpressedkeys_position"));
\r
2627 bgsize = '126 75 0';
\r
2629 pos = '1 0 0' * (vid_conwidth - bgsize_x) * pos_x
\r
2630 + '0 1 0' * (vid_conheight - bgsize_y) * pos_y;
\r
2631 pos -= '-15 -6 0'; // adjust to the origin of these numbers
\r
2633 pressedkeys = getstatf(STAT_PRESSED_KEYS);
\r
2634 drawpic(pos + '-15 -6 0', Sbar_GetTexture("keys/key_bg.tga"), bgsize, '1 1 1', 0.1 * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2635 drawpic(pos + ' 83.5 9 0', Sbar_GetTexture((pressedkeys & KEY_CROUCH) ? "keys/key_crouch_inv.tga" : "keys/key_crouch.tga"), ' 24 24 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2636 drawpic(pos + ' 32 -1.5 0', Sbar_GetTexture((pressedkeys & KEY_FORWARD) ? "keys/key_forward_inv.tga" : "keys/key_forward.tga"), ' 32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2637 drawpic(pos + '-11.5 9 0', Sbar_GetTexture((pressedkeys & KEY_JUMP) ? "keys/key_jump_inv.tga" : "keys/key_jump.tga"), ' 24 24 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2638 drawpic(pos + ' -1 32 0', Sbar_GetTexture((pressedkeys & KEY_LEFT) ? "keys/key_left_inv.tga" : "keys/key_left.tga"), ' 32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2639 drawpic(pos + ' 32 32 0', Sbar_GetTexture((pressedkeys & KEY_BACKWARD) ? "keys/key_backward_inv.tga" : "keys/key_backward.tga"), ' 32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2640 drawpic(pos + ' 65 32 0', Sbar_GetTexture((pressedkeys & KEY_RIGHT) ? "keys/key_right_inv.tga" : "keys/key_right.tga"), ' 32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2643 void Sbar_ShowSpeed(void)
\r
2646 float pos, conversion_factor;
\r
2647 string speed, zspeed, unit;
\r
2649 switch(cvar("cl_showspeed_unit"))
\r
2654 conversion_factor = 1.0;
\r
2658 conversion_factor = 1.0;
\r
2662 conversion_factor = 0.0254;
\r
2666 conversion_factor = 0.0254 * 3.6;
\r
2670 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
\r
2674 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
\r
2678 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
\r
2680 numsize_x = numsize_y = cvar("cl_showspeed_size");
\r
2681 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
\r
2683 drawfont = sbar_bigfont;
\r
2684 drawstringcenter('1 0 0' + pos * '0 1 0', speed, numsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2686 if (cvar("cl_showspeed_z") == 1) {
\r
2687 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
\r
2688 drawstringcenter('1 0 0' + pos * '0 1 0' + numsize_y * '0 1 0', zspeed, numsize * 0.5, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2691 drawfont = sbar_font;
\r
2694 vector acc_prevspeed;
\r
2695 float acc_prevtime;
\r
2698 void Sbar_ShowAcceleration(void)
\r
2700 float acceleration, sz, scale, alpha, f;
\r
2701 vector pos, top, rgb;
\r
2702 top_x = vid_conwidth/2;
\r
2705 f = time - acc_prevtime;
\r
2706 if(cvar("cl_showacceleration_z"))
\r
2707 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
\r
2709 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
\r
2710 acc_prevspeed = pmove_vel;
\r
2711 acc_prevtime = time;
\r
2713 f = bound(0, f * 10, 1);
\r
2714 acc_avg = acc_avg * (1 - f) + acceleration * f;
\r
2715 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
\r
2717 pos = top - sz/2 * '0 1 0' + (cvar("cl_showacceleration_position") * vid_conheight) * '0 1 0';
\r
2719 sz = cvar("cl_showacceleration_size");
\r
2720 scale = cvar("cl_showacceleration_scale");
\r
2721 alpha = cvar("cl_showacceleration_alpha");
\r
2722 if (cvar("cl_showacceleration_color_custom"))
\r
2723 rgb = stov(cvar_string("cl_showacceleration_color"));
\r
2726 if (acceleration < 0) {
\r
2727 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
\r
2728 } else if (acceleration > 0) {
\r
2729 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
\r
2733 if (acceleration > 0)
\r
2734 drawpic(pos, Sbar_GetTexture("accelerometer_gradient"), acceleration * scale * '40 0 0' + sz * '0 1 0', rgb, alpha * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2735 else if (acceleration < 0)
\r
2736 drawpic(pos + acceleration * scale * '40 0 0', Sbar_GetTexture("accelerometer_gradient"), -acceleration * scale * '40 0 0' + sz * '0 1 0', rgb, alpha * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2739 void Sbar_DrawAccuracyStats_Description_Hitscan(vector position)
\r
2741 drawstring(position + '0 3 0' * sbar_fontsize_y, "Shots fired:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2742 drawstring(position + '0 5 0' * sbar_fontsize_y, "Shots hit:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2743 drawstring(position + '0 7 0' * sbar_fontsize_y, "Accuracy:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2744 drawstring(position + '0 9 0' * sbar_fontsize_y, "Shots missed:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2747 /*void Sbar_DrawAccuracyStats_Description_Splash(vector position)
\r
2749 drawstring(position + '0 3 0' * sbar_fontsize_y, "Maximum damage:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2750 drawstring(position + '0 5 0' * sbar_fontsize_y, "Actual damage:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2751 drawstring(position + '0 7 0' * sbar_fontsize_y, "Accuracy:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2752 drawstring(position + '0 9 0' * sbar_fontsize_y, "Damage wasted:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2753 }*/ // we have no splash damage weapons, but keep this code just in case
\r
2755 void Sbar_DrawAccuracyStats()
\r
2757 float i, count_hitscan, /*count_splash,*/ row_hitscan/*, row_splash*/; // count is the number of 'colums'
\r
2758 float weapon_hit, weapon_damage, weapon_stats;
\r
2759 float left_border; // position where the weapons start, the description is in the border
\r
2760 vector fill_colour, fill_size;
\r
2762 vector border_colour;
\r
2764 float col_margin = 20; // pixels between the columns
\r
2765 float row_margin = 20; // pixels between the rows
\r
2767 fill_size_x = 5 * sbar_fontsize_x; // width of the background
\r
2768 fill_size_y = 10 * sbar_fontsize_y; // height of the background
\r
2770 drawfont = sbar_bigfont;
\r
2772 pos_y = cvar("sbar_scoreboard_offset");
\r
2774 drawstringcenter(pos, "Weapon Accuracy", 2 * sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2776 left_border = col_margin + 11 * sbar_fontsize_x;
\r
2778 drawfont = sbar_font;
\r
2783 if(mod(time, 1) >= 0.4)
\r
2784 drawstringcenter(pos, "Stats are not tracked during warmup stage", sbar_fontsize, '1 1 0', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2789 if(gametype == GAME_RACE || gametype == GAME_CTS)
\r
2792 if(mod(time, 1) >= 0.4)
\r
2793 drawstringcenter(pos, "Stats are not tracked in Race/CTS", sbar_fontsize, '1 1 0', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2798 float top_border_hitscan = cvar("sbar_scoreboard_offset") + 55; // position where the hitscan row starts: pixels down the screen
\r
2799 Sbar_DrawAccuracyStats_Description_Hitscan('1 0 0' * col_margin + '0 1 0' * top_border_hitscan);
\r
2801 // float top_border_splash = cvar("sbar_scoreboard_offset") + 175; // position where the splash row starts: pixels down the screen
\r
2802 // Sbar_DrawAccuracyStats_Description_Splash('1 0 0' * col_margin + '0 1 0' * top_border_splash);
\r
2804 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
\r
2806 self = get_weaponinfo(i);
\r
2807 if not(self.weapons)
\r
2809 weapon_hit = weapon_hits[i-WEP_FIRST];
\r
2810 weapon_damage = weapon_fired[i-WEP_FIRST];
\r
2811 border_colour = (i == activeweapon) ? '1 1 1' : '0 0 0'; // white or black border
\r
2813 if (weapon_damage) {
\r
2814 /*if (self.spawnflags & WEP_TYPE_SPLASH) {
\r
2815 weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100);
\r
2817 fill_colour_x = 1 - 0.015 * weapon_stats;
\r
2818 fill_colour_y = 1 - 0.015 * (100 - weapon_stats);
\r
2820 // how the background colour is calculated
\r
2821 // % red green red_2 green_2
\r
2822 // 0 1 0 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2823 // 10 0.85 0 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2824 // 20 0.70 0 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2825 // 30 0.55 0 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2826 // 40 0.40 0.10 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2827 // 50 0.25 0.25 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2828 // 60 0.10 0.40 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2829 // 70 0 0.55 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2830 // 80 0 0.70 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2831 // 90 0 0.85 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2832 // 100 0 1 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2834 if ((left_border + count_splash * (fill_size_x + col_margin) + fill_size_x) >= vid_conwidth)
\r
2838 Sbar_DrawAccuracyStats_Description_Splash('1 0 0' * col_margin + '0 1 0' * (top_border_splash + row_splash * (fill_size_y + row_margin)));
\r
2841 pos_x = left_border + count_splash * (fill_size_x + col_margin);
\r
2842 pos_y = top_border_splash + row_splash * (fill_size_y + row_margin);
\r
2845 drawpic(pos, Sbar_GetTexture("sb_accuracy"), fill_size , fill_colour, sbar_alpha_bg, DRAWFLAG_NORMAL);
\r
2846 drawborderlines(sbar_border_thickness, pos, fill_size, border_colour, sbar_alpha_bg, DRAWFLAG_NORMAL);
\r
2849 drawpic(pos, Sbar_GetTexture("inv_weapon"), self.netname), '1 0.5 0' * fill_size_x , '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2851 // the amount of shots fired or max damage
\r
2852 drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 3 0' * sbar_fontsize_y, ftos(weapon_damage), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2854 // the amount of hits or actual damage
\r
2855 drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 5 0' * sbar_fontsize_y, ftos(weapon_hit), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2858 drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 7 0' * sbar_fontsize_y, strcat(ftos(weapon_stats),"%"), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2860 // the amount of shots missed or damage wasted
\r
2861 drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 9 0' * sbar_fontsize_y, ftos(max(0, weapon_damage - weapon_hit)), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2864 } else*/ // we have no splash damage weapons, but keep this code just in case
\r
2866 if (self.spawnflags & WEP_TYPE_HITSCAN) {
\r
2867 weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100);
\r
2869 fill_colour_x = 1 - 0.015 * weapon_stats;
\r
2870 fill_colour_y = 1 - 0.015 * (100 - weapon_stats);
\r
2872 // how the background colour is calculated
\r
2873 // % red green red_2 green_2
\r
2874 // 0 1 0 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2875 // 10 0.850 0 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2876 // 20 0.70 0 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2877 // 30 0.55 0 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2878 // 40 0.40 0.10 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2879 // 50 0.25 0.25 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2880 // 60 0.10 0.40 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2881 // 70 0 0.55 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2882 // 80 0 0.70 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2883 // 90 0 0.85 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2884 // 100 0 1 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2886 if ((left_border + count_hitscan * (fill_size_x + col_margin) + fill_size_x + cvar("stats_right_margin")) >= vid_conwidth)
\r
2888 count_hitscan = 0;
\r
2890 Sbar_DrawAccuracyStats_Description_Hitscan('1 0 0' * col_margin + '0 1 0' * (top_border_hitscan + row_hitscan * (fill_size_y + row_margin)));
\r
2893 pos_x = left_border + count_hitscan * (fill_size_x + col_margin);
\r
2894 pos_y = top_border_hitscan + row_hitscan * (fill_size_y + row_margin);
\r
2897 drawpic(pos, Sbar_GetTexture("sb_accuracy"), fill_size , fill_colour, sbar_alpha_bg, DRAWFLAG_NORMAL);
\r
2898 drawborderlines(sbar_border_thickness, pos, fill_size, border_colour, sbar_alpha_bg, DRAWFLAG_NORMAL);
\r
2901 drawpic(pos, Sbar_GetTexture(strcat("inv_weapon", self.netname)), '1 0.5 0' * fill_size_x , '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2903 // the amount of shots fired or max damage
\r
2904 drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 3 0' * sbar_fontsize_y, ftos(weapon_damage), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2906 // the amount of hits or actual damage
\r
2907 drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 5 0' * sbar_fontsize_y, ftos(weapon_hit), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2910 drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 7 0' * sbar_fontsize_y, strcat(ftos(weapon_stats),"%"), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2912 // the amount of shots missed or damage wasted
\r
2913 drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 9 0' * sbar_fontsize_y, ftos(max(0, weapon_damage - weapon_hit)), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2921 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
\r
2923 position_x -= 2 / 3 * strlen(text) * scale_x;
\r
2924 drawstring(position, text, scale, rgb, alpha, flag);
\r
2927 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
\r
2929 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
\r
2930 drawstring(position, text, scale, rgb, alpha, flag);
\r
2933 void Sbar_Reset (void)
\r
2935 // reset gametype specific icons
\r
2936 if(gametype == GAME_KEYHUNT)
\r
2937 CSQC_kh_hudreset();
\r
2938 else if(gametype == GAME_CTF)
\r
2939 CSQC_ctf_hudreset();
\r
2942 float vote_yescount;
\r
2943 float vote_nocount;
\r
2944 float vote_needed;
\r
2945 float vote_highlighted; // currently selected vote
\r
2947 float vote_active; // is there an active vote?
\r
2948 float vote_prev; // previous state of vote_active to check for a change
\r
2950 float vote_change; // "time" when vote_active changed
\r
2952 void Sbar_Draw (void)
\r
2954 // vectors for top right, bottom right, bottom and bottom left corners
\r
2957 vector bottomright;
\r
2958 vector bottomleft;
\r
2960 topright_x = vid_conwidth;
\r
2964 bottom_x = vid_conwidth/2;
\r
2965 bottom_y = vid_conheight;
\r
2968 bottomright_x = vid_conwidth;
\r
2969 bottomright_y = vid_conheight;
\r
2970 bottomright_z = 0;
\r
2973 bottomleft_y = vid_conheight;
\r
2976 sbar_alpha_bg = cvar("sbar_alpha_bg") * (1 - cvar("_menu_alpha"));
\r
2977 sbar_border_thickness = bound(0, cvar("sbar_border_thickness"), 5);
\r
2978 sbar_accuracy_border_thickness = bound(0, cvar_or("sbar_accuracy_border_thickness", 1), 5);
\r
2979 sbar_color_bg_team = cvar("sbar_color_bg_team");
\r
2981 float weapon_stats;
\r
2984 weapon_stats = getstati(STAT_DAMAGE_HITS);
\r
2985 weapon_number = weapon_stats & 63;
\r
2986 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
\r
2988 weapon_stats = getstati(STAT_DAMAGE_FIRED);
\r
2989 weapon_number = weapon_stats & 63;
\r
2990 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
\r
2992 vector o; o = '1 0 0' * vid_conwidth;
\r
2993 o_y = 28; // move spectator text slightly down to prevent overlapping the timer
\r
2999 sbar_fontsize = Sbar_GetFontsize("sbar_fontsize");
\r
3000 sbar_fontsize_spec = Sbar_GetFontsize("sbar_fontsize_spec");
\r
3001 if(sbar_fontsize != sbar_oldfontsize)
\r
3003 Cmd_Sbar_SetFields(0);
\r
3004 sbar_oldfontsize = sbar_fontsize;
\r
3007 if(spectatee_status && !intermission)
\r
3009 drawfont = sbar_bigfont;
\r
3010 if(spectatee_status == -1)
\r
3011 s = "^1Observing";
\r
3013 s = GetPlayerName(spectatee_status - 1);
\r
3014 // spectated player name between HUD and chat area, aligned to the left
\r
3015 pos_x = bottomleft_x;
\r
3016 pos_y = bottom_y - 200 - sbar_fontsize_spec_y;
\r
3017 s = textShortenToWidth(s, vid_conwidth/2.5, sbar_fontsize_spec, stringwidth_colors);
\r
3018 drawcolorcodedstring(pos, s, sbar_fontsize_spec, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3019 drawfont = sbar_font;
\r
3021 // spectator text in the upper right corner
\r
3022 if(spectatee_status == -1)
\r
3023 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
\r
3025 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
\r
3026 o = Sbar_DrawNoteLine(o, s);
\r
3028 if(spectatee_status == -1)
\r
3029 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
\r
3031 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
\r
3032 o = Sbar_DrawNoteLine(o, s);
\r
3034 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
\r
3035 o = Sbar_DrawNoteLine(o, s);
\r
3037 if(gametype == GAME_ARENA)
\r
3038 s = "^1Wait for your turn to join";
\r
3039 else if(gametype == GAME_LMS)
\r
3042 sk = playerslots[player_localentnum - 1];
\r
3043 if(sk.(scores[ps_primary]) >= 666)
\r
3044 s = "^1Match has already begun";
\r
3045 else if(sk.(scores[ps_primary]) > 0)
\r
3046 s = "^1You have no more lives left";
\r
3048 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
\r
3051 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
\r
3052 o = Sbar_DrawNoteLine(o, s);
\r
3054 //show restart countdown:
\r
3055 if (time < getstatf(STAT_GAMESTARTTIME)) {
\r
3057 //we need to ceil, otherwise the countdown would be off by .5 when using round()
\r
3058 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
\r
3059 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
\r
3060 o = Sbar_DrawNoteLine(o, s);
\r
3063 if(warmup_stage && !intermission)
\r
3065 s = "^2Currently in ^1warmup^2 stage!";
\r
3066 o = Sbar_DrawNoteLine(o, s);
\r
3069 // move more important stuff more to the middle so its more visible
\r
3070 o_y = vid_conheight * 0.66;
\r
3072 string blinkcolor;
\r
3073 if(mod(time, 1) >= 0.5)
\r
3074 blinkcolor = "^1";
\r
3076 blinkcolor = "^3";
\r
3078 if(ready_waiting && !intermission && !spectatee_status)
\r
3080 if(ready_waiting_for_me)
\r
3083 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
\r
3085 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
\r
3090 s = strcat("^2Waiting for others to ready up to end warmup...");
\r
3092 s = strcat("^2Waiting for others to ready up...");
\r
3094 o = Sbar_DrawNoteLine(o, s);
\r
3096 else if(warmup_stage && !intermission && !spectatee_status)
\r
3098 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
\r
3099 o = Sbar_DrawNoteLine(o, s);
\r
3102 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
\r
3105 float ts_min, ts_max;
\r
3106 tm = teams.sort_next;
\r
3109 for(; tm.sort_next; tm = tm.sort_next)
\r
3111 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
\r
3113 if(!ts_min) ts_min = tm.team_size;
\r
3114 else ts_min = min(ts_min, tm.team_size);
\r
3115 if(!ts_max) ts_max = tm.team_size;
\r
3116 else ts_max = max(ts_max, tm.team_size);
\r
3118 if ((ts_max - ts_min) > 1)
\r
3120 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
\r
3121 tm = GetTeam(myteam, false);
\r
3123 if (tm.team != COLOR_SPECTATOR)
\r
3124 if (tm.team_size == ts_max)
\r
3125 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
\r
3127 o = Sbar_DrawNoteLine(o, s);
\r
3132 if(vote_active != vote_prev) {
\r
3133 vote_change = time;
\r
3134 vote_prev = bound(0, vote_active, 1);
\r
3138 vote_alpha = bound(0, (time - vote_change) * 2, 1);
\r
3140 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
\r
3144 a = vote_alpha * bound(cvar_or("sbar_vote_alreadyvoted_alpha", 0.75), 1 - vote_highlighted, 1);
\r
3147 color = GetTeamRGB(myteam) * sbar_color_bg_team;
\r
3149 color = stov(cvar_string("sbar_color_bg"));
\r
3151 vector voteorigin = bottomright - '290 135 0';
\r
3152 vector votesize = '280 70 0';
\r
3153 drawpic(voteorigin, Sbar_GetTexture("voteprogress_back"), votesize, color, a * sbar_alpha_bg, DRAWFLAG_NORMAL);
\r
3155 s = "A vote has been called for: ";
\r
3156 drawstring(voteorigin + '0.5 0 0' * votesize_x + '0 0.1 0' * votesize_y - '1 0 0' * stringwidth(s, FALSE, '6 0 0'), s, '12 12 0', '1 1 1', a * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3157 s = textShortenToWidth(vote_called_vote, votesize_x * 0.96, '10 0 0', stringwidth_colors);
\r
3158 drawcolorcodedstring(voteorigin + '0.52 0 0' * votesize_x + '0 0.3 0' * votesize_y - '1 0 0' * stringwidth(s, FALSE, '5 0 0'), s, '10 10 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3160 // print the yes/no counts
\r
3161 s = strcat("Yes: ", ftos(vote_yescount));
\r
3162 drawstring(voteorigin + '0 0.6 0' * votesize_y + '0.02 0 0' * votesize_x, s, '12 12 0', '0 1 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3163 s = strcat("No: ", ftos(vote_nocount));
\r
3164 drawstring(voteorigin + '0 0.6 0' * votesize_y + '0.98 0 0' * votesize_x - '1 0 0' * stringwidth(s, FALSE, '12 0 0'), s, '12 12 0', '1 0 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3166 // draw the progress bars
\r
3167 drawsetcliparea(voteorigin_x, voteorigin_y, votesize_x * 0.5 * (vote_yescount/vote_needed), votesize_y);
\r
3168 drawpic(voteorigin, Sbar_GetTexture("voteprogress_prog"), votesize, '0 1 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3170 drawsetcliparea(voteorigin_x + votesize_x - votesize_x * 0.5 * (vote_nocount/vote_needed), voteorigin_y, votesize_x * 0.5, votesize_y);
\r
3171 drawpic(voteorigin, Sbar_GetTexture("voteprogress_prog"), votesize, '1 0 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3173 // draw the highlights
\r
3174 if(vote_highlighted == 1) {
\r
3175 drawsetcliparea(voteorigin_x, voteorigin_y, votesize_x * 0.5, votesize_y);
\r
3176 drawpic(voteorigin, Sbar_GetTexture("voteprogress_voted"), votesize, '0 1 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3178 else if(vote_highlighted == 2) {
\r
3179 drawsetcliparea(voteorigin_x + 0.5 * votesize_x, voteorigin_y, votesize_x * 0.5, votesize_y);
\r
3180 drawpic(voteorigin, Sbar_GetTexture("voteprogress_voted"), votesize, '1 0 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3183 drawresetcliparea();
\r
3185 else if(!vote_active) {
\r
3186 vote_highlighted = 0;
\r
3189 Sbar_UpdatePlayerTeams();
\r
3190 if (intermission == 2) // map voting screen
\r
3194 Sbar_DrawScoreboard();
\r
3196 Sbar_FinaleOverlay();
\r
3200 else if (sb_showscores_force || getstati(STAT_HEALTH) <= 0 || intermission == 1)
\r
3202 Sbar_DrawScoreboard();
\r
3206 if(getstati(STAT_VORE_EATEN))
\r
3211 Sbar_ColorFade('0 0 0');
\r
3215 if(sb_showaccuracy && spectatee_status != -1)
\r
3216 Sbar_DrawAccuracyStats();
\r
3218 Sbar_DrawScoreboard();
\r
3220 fade = 3.2 - 2 * (time - weapontime);
\r
3221 fade = bound(0.7, fade, 1);
\r
3223 // when a player's armor is below the necessary level, subsystems will not work
\r
3224 if(getstati(STAT_HEALTH) > 0)
\r
3227 warn_pos_x = vid_conwidth / 2;
\r
3228 warn_pos_y = vid_conheight - vid_conheight / 2.5;
\r
3229 if(getstati(STAT_ARMOR) < g_power)
\r
3231 // subsystems are down
\r
3232 drawpic(warn_pos - '128 0 0', Sbar_GetTexture("sb_power_fail"), '256 256 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3233 drawpic(warn_pos - '16 0 0' + '0 150 0', Sbar_GetTexture("sb_power_fail_icon"), '32 32 0', '1 1 1', sbar_alpha_fg * (0.5 + sin(time * 5) / 2), DRAWFLAG_NORMAL);
\r
3234 power_boot = time + g_power_reboot;
\r
3235 Sbar_Portrait(); // draw the portrait still
\r
3236 return; // skip drawing the HUD
\r
3238 else if(time <= power_boot)
\r
3240 // subsystems are rebooting
\r
3241 drawpic(warn_pos - '128 0 0', Sbar_GetTexture("sb_power_reboot"), '256 256 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3242 drawpic(warn_pos - '16 0 0' + '0 150 0', Sbar_GetTexture("sb_power_reboot_icon"), '32 32 0', '1 1 1', sbar_alpha_fg * (0.5 + sin(time * 5) / 2), DRAWFLAG_NORMAL);
\r
3243 Sbar_Portrait(); // draw the portrait still
\r
3244 return; // skip drawing the HUD
\r
3248 Sbar_DrawBackgrounds();
\r
3250 if(g_vore) // only when the vore system is active
\r
3252 // draw the stomach board
\r
3254 float stomach_load, stomach_maxload; // shows the predator's stomach load when we are eaten, and ours otherwise
\r
3255 stomach_load = getstati(STAT_VORE_LOAD);
\r
3256 stomach_maxload = getstati(STAT_VORE_MAXLOAD);
\r
3258 vector status_pos;
\r
3259 string status_text, status_color;
\r
3260 float status_size;
\r
3261 status_color = rgb_to_hexcolor('0.5 0.5 0.5' + Sbar_NumColor(stomach_maxload) * 0.5); // twice brighter than health / armor colors
\r
3264 status_text = strcat(ftos(stomach_load), "^8/", status_color, ftos(stomach_maxload));
\r
3265 status_pos = stov(cvar_string("hud_item_stomach_load_double_text_position"));
\r
3266 status_size = cvar("hud_item_stomach_load_double_text_scale");
\r
3270 status_text = strcat(status_color, ftos(stomach_maxload));
\r
3271 status_pos = stov(cvar_string("hud_item_stomach_load_single_text_position"));
\r
3272 status_size = cvar("hud_item_stomach_load_single_text_scale");
\r
3274 Sbar_DrawString(status_text, status_pos, status_size);
\r
3276 if(getstati(STAT_VORE_DIGESTING)) // we are currently digesting
\r
3277 Sbar_DrawPic(Sbar_GetTexture("sb_digestion_active"), stov(cvar_string("hud_item_digestion_icon_position")), stov(cvar_string("hud_item_digestion_icon_scale")), FALSE);
\r
3278 else if(stomach_load) // we can digest at this time
\r
3279 Sbar_DrawPic(Sbar_GetTexture("sb_digestion_possible"), stov(cvar_string("hud_item_digestion_icon_position")), stov(cvar_string("hud_item_digestion_icon_scale")), FALSE);
\r
3280 else // we cannot digest at this time
\r
3281 Sbar_DrawPic(Sbar_GetTexture("sb_digestion_impossible"), stov(cvar_string("hud_item_digestion_icon_position")), stov(cvar_string("hud_item_digestion_icon_scale")), FALSE);
\r
3283 // draw the stomach board player list
\r
3287 hud_total_prey = 0;
\r
3288 pos = stov(cvar_string("hud_item_preylist_position"));
\r
3289 vector sz = stov(cvar_string("hud_item_preylist_scale"));
\r
3290 vector dir = stov(cvar_string("hud_item_preylist_entry_spacing")) * 2;
\r
3291 for(pl = players.sort_next; pl; pl = pl.sort_next)
\r
3293 if(pl.team == COLOR_SPECTATOR)
\r
3296 if(getstati(STAT_VORE_EATEN))
\r
3297 f = pl.plpredator == getstati(STAT_VORE_EATEN);
\r
3300 if(spectatee_status)
\r
3301 f = pl.plpredator == spectatee_status;
\r
3303 f = pl.plpredator == player_localentnum;
\r
3308 if(l < cvar("hud_item_preylist_entry_number")) // limit the stomach board to the given number of entries
\r
3310 Sbar_PrintStomachboardItem(pl, pos, sz);
\r
3312 // advance position for each entry
\r
3313 pos_x += sz_x * dir_x;
\r
3314 pos_y += sz_y * dir_y;
\r
3320 // set the predator's name
\r
3321 if(getstati(STAT_VORE_EATEN))
\r
3323 if(pl.sv_entnum == getstati(STAT_VORE_EATEN) - 1)
\r
3326 else if(pl.sv_entnum == player_localentnum - 1 || pl.sv_entnum == spectatee_status - 1)
\r
3327 pred = pl; // show us or the spectated player
\r
3330 // draw the predator's name
\r
3331 Sbar_PrintStomachboardItemPred(pred, stov(cvar_string("hud_item_predator_position")), stov(cvar_string("hud_item_predator_scale")));
\r
3334 // draw status, scores, timer, ring and portrait
\r
3341 // draw strength/invincibility icon and timer
\r
3342 CSQC_Strength_Timer();
\r
3344 // draw gametype specific icons
\r
3345 if(gametype == GAME_KEYHUNT)
\r
3347 else if(gametype == GAME_CTF)
\r
3349 else if(gametype == GAME_CTS || gametype == GAME_RACE)
\r
3352 // draw the canleave message
\r
3353 if(getstati(STAT_VORE_CANLEAVE))
\r
3354 if not(spectatee_status) // this message doesn't address spectated players
\r
3356 s = strcat("^7Press ^3", getcommandkey("jump", "+jump"), " ^7to exit");
\r
3357 pos_x = bottom_x - stringwidth(s, TRUE, '0 0 0') * 16 / 2;
\r
3358 pos_y = bottom_y - 120;
\r
3359 drawcolorcodedstring(pos, s, '16 16 0', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3366 float redflag_prevframe, blueflag_prevframe; // status during previous frame
\r
3367 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
\r
3368 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
\r
3370 void CSQC_ctf_hudreset(void)
\r
3372 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
\r
3375 void CSQC_ctf_hud(void)
\r
3377 vector top, redflag_pos, blueflag_pos, sz;
\r
3378 float f; // every function should have that
\r
3379 top_x = vid_conwidth / 2;
\r
3383 float redflag, blueflag; // current status
\r
3384 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
\r
3387 stat_items = getstati(STAT_ITEMS);
\r
3388 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
\r
3389 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
\r
3391 // when status CHANGES, set old status into prevstatus and current status into status
\r
3392 if (redflag != redflag_prevframe)
\r
3394 redflag_statuschange_time = time;
\r
3395 redflag_prevstatus = redflag_prevframe;
\r
3396 redflag_prevframe = redflag;
\r
3399 if (blueflag != blueflag_prevframe)
\r
3401 blueflag_statuschange_time = time;
\r
3402 blueflag_prevstatus = blueflag_prevframe;
\r
3403 blueflag_prevframe = blueflag;
\r
3406 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
\r
3407 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
\r
3409 float BLINK_FACTOR = 0.15;
\r
3410 float BLINK_BASE = 0.85;
\r
3412 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
\r
3414 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
\r
3415 // ensure RMS == 1
\r
3416 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
\r
3418 string red_icon, red_icon_prevstatus;
\r
3419 float red_alpha, red_alpha_prevstatus;
\r
3420 red_alpha = red_alpha_prevstatus = 1;
\r
3422 case 1: red_icon = Sbar_GetTexture("sb_flag_red_taken"); break;
\r
3423 case 2: red_icon = Sbar_GetTexture("sb_flag_red_lost"); break;
\r
3424 case 3: red_icon = Sbar_GetTexture("sb_flag_red_carrying"); red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
\r
3426 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
\r
3427 red_icon = Sbar_GetTexture("sb_flag_red_shielded");
\r
3429 red_icon = string_null;
\r
3432 switch(redflag_prevstatus) {
\r
3433 case 1: red_icon_prevstatus = Sbar_GetTexture("sb_flag_red_taken"); break;
\r
3434 case 2: red_icon_prevstatus = Sbar_GetTexture("sb_flag_red_lost"); break;
\r
3435 case 3: red_icon_prevstatus = Sbar_GetTexture("sb_flag_red_carrying"); red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
\r
3438 red_icon_prevstatus = Sbar_GetTexture("sb_flag_red_carrying"); // make it more visible
\r
3439 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
\r
3440 red_icon_prevstatus = Sbar_GetTexture("sb_flag_red_shielded");
\r
3442 red_icon_prevstatus = string_null;
\r
3446 string blue_icon, blue_icon_prevstatus;
\r
3447 float blue_alpha, blue_alpha_prevstatus;
\r
3448 blue_alpha = blue_alpha_prevstatus = 1;
\r
3449 switch(blueflag) {
\r
3450 case 1: blue_icon = Sbar_GetTexture("sb_flag_blue_taken"); break;
\r
3451 case 2: blue_icon = Sbar_GetTexture("sb_flag_blue_lost"); break;
\r
3452 case 3: blue_icon = Sbar_GetTexture("sb_flag_blue_carrying"); blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
\r
3454 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
\r
3455 blue_icon = Sbar_GetTexture("sb_flag_blue_shielded");
\r
3457 blue_icon = string_null;
\r
3460 switch(blueflag_prevstatus) {
\r
3461 case 1: blue_icon_prevstatus = Sbar_GetTexture("sb_flag_blue_taken"); break;
\r
3462 case 2: blue_icon_prevstatus = Sbar_GetTexture("sb_flag_blue_lost"); break;
\r
3463 case 3: blue_icon_prevstatus = Sbar_GetTexture("sb_flag_blue_carrying"); blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
\r
3466 blue_icon_prevstatus = Sbar_GetTexture("sb_flag_blue_carrying"); // make it more visible
\r
3467 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
\r
3468 blue_icon_prevstatus = Sbar_GetTexture("sb_flag_blue_shielded");
\r
3470 blue_icon_prevstatus = string_null;
\r
3474 if (myteam == COLOR_TEAM1) { // always draw own flag on left
\r
3475 redflag_pos = top + '-52 50 0';
\r
3476 blueflag_pos = top + '0 40 0';
\r
3478 blueflag_pos = top + '-52 50 0';
\r
3479 redflag_pos = top + '0 40 0';
\r
3484 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
\r
3485 if(red_icon_prevstatus && f < 1)
\r
3486 drawpic_expanding(redflag_pos, red_icon_prevstatus, sz, '1 1 1', sbar_alpha_fg * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
\r
3488 drawpic(redflag_pos, red_icon, sz, '1 1 1', sbar_alpha_fg * red_alpha * f, DRAWFLAG_NORMAL);
\r
3490 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
\r
3491 if(blue_icon_prevstatus && f < 1)
\r
3492 drawpic_expanding(blueflag_pos, blue_icon_prevstatus, sz, '1 1 1', sbar_alpha_fg * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
\r
3494 drawpic(blueflag_pos, blue_icon, sz, '1 1 1', sbar_alpha_fg * blue_alpha * f, DRAWFLAG_NORMAL);
\r
3498 float kh_runheretime;
\r
3500 void CSQC_kh_hudreset(void)
\r
3502 kh_runheretime = 0;
\r
3505 void CSQC_kh_hud(void)
\r
3510 vector p, pa, kh_size, kh_asize;
\r
3513 top_x = vid_conwidth / 2;
\r
3517 p = top + '-50 64 0';
\r
3519 kh_keys = getstati(STAT_KH_KEYS);
\r
3521 kh_size = '19 34 0';
\r
3522 kh_asize = '19 10 0';
\r
3523 pa = p + '0 -10 0';
\r
3529 for(i = 0; i < 4; ++i)
\r
3531 key = floor(kh_keys / pow(32, i)) & 31;
\r
3532 keyteam = key - 1;
\r
3533 if(keyteam == 30 && keycount <= 4)
\r
3535 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
\r
3538 // this yields 8 exactly if "RUN HERE" shows
\r
3542 if(!kh_runheretime)
\r
3543 kh_runheretime = time;
\r
3544 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
\r
3547 kh_runheretime = 0;
\r
3549 for(i = 0; i < 4; ++i)
\r
3551 key = floor(kh_keys / pow(32, i)) & 31;
\r
3552 keyteam = key - 1;
\r
3555 case 30: // my key
\r
3560 case -1: // no key
\r
3564 default: // owned or dropped
\r
3569 a = a * sbar_alpha_fg;
\r
3570 aa = aa * sbar_alpha_fg;
\r
3576 drawpic (pa, Sbar_GetTexture("sb_kh_redarrow"), kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
\r
3579 drawpic (pa, Sbar_GetTexture("sb_kh_bluearrow"), kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
\r
3582 drawpic (pa, Sbar_GetTexture("sb_kh_yellowarrow"), kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
\r
3585 drawpic (pa, Sbar_GetTexture("sb_kh_pinkarrow"), kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
\r
3590 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
\r
3593 drawpic (p, Sbar_GetTexture("sb_kh_red"), kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
\r
3596 drawpic (p, Sbar_GetTexture("sb_kh_blue"), kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
\r
3599 drawpic (p, Sbar_GetTexture("sb_kh_yellow"), kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
\r
3602 drawpic (p, Sbar_GetTexture("sb_kh_pink"), kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
\r
3611 float crecordtime_prev; // last remembered crecordtime
\r
3612 float crecordtime_change_time; // time when crecordtime last changed
\r
3613 float srecordtime_prev; // last remembered srecordtime
\r
3614 float srecordtime_change_time; // time when srecordtime last changed
\r
3615 void CSQC_race_hud(void)
\r
3618 me = playerslots[player_localentnum - 1];
\r
3620 float f; // yet another function has this
\r
3621 score = me.(scores[ps_primary]);
\r
3623 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
\r
3624 return; // no records in the actual race
\r
3626 drawfont = sbar_bigfont;
\r
3629 pos_y = vid_conheight - 272;
\r
3631 // clientside personal record
\r
3633 if(gametype == GAME_CTS)
\r
3637 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
\r
3639 if(score && score < t || !t)
\r
3640 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
\r
3642 if(t != crecordtime_prev) {
\r
3643 crecordtime_prev = t;
\r
3644 crecordtime_change_time = time;
\r
3646 f = time - crecordtime_change_time;
\r
3649 drawstring(pos, "Personal best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3650 drawstring(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3652 drawstring(pos, "Personal best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3653 drawstring(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3654 drawstring_expanding(pos, "Personal best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL, f);
\r
3655 drawstring_expanding(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL, f);
\r
3660 t = race_server_record;
\r
3661 if(t != srecordtime_prev) {
\r
3662 srecordtime_prev = t;
\r
3663 srecordtime_change_time = time;
\r
3665 f = time - srecordtime_change_time;
\r
3668 drawstring(pos, "Server best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3669 drawstring(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3671 drawstring(pos, "Server best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3672 drawstring(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3673 drawstring_expanding(pos, "Server best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL, f);
\r
3674 drawstring_expanding(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL, f);
\r
3676 drawfont = sbar_font;
\r
3679 void Ent_ReadPortrait()
\r
3681 // receives portrait values, which are used in Sbar_Portrait
\r
3683 string pl_model, pl_name, img;
\r
3686 pl_model = ReadString();
\r
3687 pl_skin = ReadByte();
\r
3688 pl_name = ReadString();
\r
3690 // update existing portraits
\r
3692 strunzone(portrait_name);
\r
3693 if(portrait_image)
\r
3694 strunzone(portrait_image);
\r
3696 portrait_time = time;
\r
3697 portrait_name = strzone(pl_name);
\r
3699 // obtain the image name from the text file
\r
3700 float glob, i, fh;
\r
3703 glob = search_begin("models/player/*.txt", TRUE, TRUE);
\r
3706 for(i = 0; i < search_getsize(glob); ++i)
\r
3708 fn = search_getfilename(glob, i);
\r
3709 fh = fopen(fn, FILE_READ);
\r
3713 fgets(fh); // skip name
\r
3715 if(pl_skin == stof(fgets(fh)))
\r
3716 if(pl_model == fgets(fh))
\r
3717 portrait_image = strzone(img);
\r