1 float scoreboard_alpha_bg;
2 float scoreboard_alpha_fg;
3 float scoreboard_highlight;
4 float scoreboard_highlight_alpha;
5 float scoreboard_highlight_alpha_self;
6 float scoreboard_alpha_name;
7 float scoreboard_alpha_name_self;
9 void drawstringright(vector, string, vector, vector, float, float);
10 void drawstringcenter(vector, string, vector, vector, float, float);
12 float SCOREBOARD_OFFSET = 50;
15 void HUD_FinaleOverlay()
18 pos_x = (vid_conwidth - 1)/2;
22 //drawpic(pos, "gfx/finale", '0 0 0', '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
24 //drawstring(pos, "END", hud_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);
28 void Cmd_HUD_SetFields(float argc);
33 ps_primary = ps_secondary = ts_primary = ts_secondary = -1;
34 for(i = 0; i < MAX_SCORE; ++i)
36 f = (scores_flags[i] & SFL_SORT_PRIO_MASK);
37 if(f == SFL_SORT_PRIO_PRIMARY)
39 if(f == SFL_SORT_PRIO_SECONDARY)
42 if(ps_secondary == -1)
43 ps_secondary = ps_primary;
45 for(i = 0; i < MAX_TEAMSCORE; ++i)
47 f = (teamscores_flags[i] & SFL_SORT_PRIO_MASK);
48 if(f == SFL_SORT_PRIO_PRIMARY)
50 if(f == SFL_SORT_PRIO_SECONDARY)
53 if(ts_secondary == -1)
54 ts_secondary = ts_primary;
59 void HUD_UpdatePlayerPos(entity pl);
60 float SetTeam(entity pl, float Team);
62 void HUD_UpdatePlayerTeams()
69 for(pl = players.sort_next; pl; pl = pl.sort_next)
72 Team = GetPlayerColor(pl.sv_entnum);
76 HUD_UpdatePlayerPos(pl);
80 pl = players.sort_next;
85 print(strcat("PNUM: ", ftos(num), "\n"));
90 float HUD_ComparePlayerScores(entity left, entity right)
93 vl = GetPlayerColor(left.sv_entnum);
94 vr = GetPlayerColor(right.sv_entnum);
106 if(vl == COLOR_SPECTATOR)
108 // FIRST the one with scores (spectators), THEN the ones without (downloaders)
110 if(!left.gotscores && right.gotscores)
115 vl = left.scores[ps_primary];
116 vr = right.scores[ps_primary];
117 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
119 if(vl == 0 && vr != 0)
121 if(vl != 0 && vr == 0)
125 return IS_INCREASING(scores_flags[ps_primary]);
127 return IS_DECREASING(scores_flags[ps_primary]);
129 vl = left.scores[ps_secondary];
130 vr = right.scores[ps_secondary];
131 if(scores_flags[ps_secondary] & SFL_ZERO_IS_WORST)
133 if(vl == 0 && vr != 0)
135 if(vl != 0 && vr == 0)
139 return IS_INCREASING(scores_flags[ps_secondary]);
141 return IS_DECREASING(scores_flags[ps_secondary]);
146 void HUD_UpdatePlayerPos(entity player)
148 for(other = player.sort_next; other && HUD_ComparePlayerScores(player, other); other = player.sort_next)
150 SORT_SWAP(player, other);
152 for(other = player.sort_prev; other != players && HUD_ComparePlayerScores(other, player); other = player.sort_prev)
154 SORT_SWAP(other, player);
158 float HUD_CompareTeamScores(entity left, entity right)
162 if(left.team == COLOR_SPECTATOR)
164 if(right.team == COLOR_SPECTATOR)
167 vl = left.teamscores[ts_primary];
168 vr = right.teamscores[ts_primary];
170 return IS_INCREASING(teamscores_flags[ts_primary]);
172 return IS_DECREASING(teamscores_flags[ts_primary]);
174 vl = left.teamscores[ts_secondary];
175 vr = right.teamscores[ts_secondary];
177 return IS_INCREASING(teamscores_flags[ts_secondary]);
179 return IS_DECREASING(teamscores_flags[ts_secondary]);
184 void HUD_UpdateTeamPos(entity Team)
186 for(other = Team.sort_next; other && HUD_CompareTeamScores(Team, other); other = Team.sort_next)
188 SORT_SWAP(Team, other);
190 for(other = Team.sort_prev; other != teams && HUD_CompareTeamScores(other, Team); other = Team.sort_prev)
192 SORT_SWAP(other, Team);
196 void Cmd_HUD_Help(float argc)
198 print("You can modify the scoreboard using the ^2scoreboard_columns_set command.\n");
199 print("^3|---------------------------------------------------------------|\n");
201 print("^2scoreboard_columns_set default\n");
202 print("^2scoreboard_columns_set ^7filed1 field2 ...\n");
203 print("The following field names are recognized (case insensitive):\n");
204 print("You can use a ^3|^7 to start the right-aligned fields.\n\n");
206 print("^3name^7 or ^3nick^7 Name of a player\n");
207 print("^3ping^7 Ping time\n");
208 print("^3pl^7 Packet loss\n");
209 print("^3kills^7 Number of kills\n");
210 print("^3deaths^7 Number of deaths\n");
211 print("^3suicides^7 Number of suicides\n");
212 print("^3frags^7 kills - suicides\n");
213 print("^3kd^7 The kill-death ratio\n");
214 print("^3caps^7 How often a flag (CTF) or a key (KeyHunt) was captured\n");
215 print("^3pickups^7 How often a flag (CTF) or a key (KeyHunt) was picked up\n");
216 print("^3fckills^7 Number of flag carrier kills\n");
217 print("^3returns^7 Number of flag returns\n");
218 print("^3drops^7 Number of flag drops\n");
219 print("^3lives^7 Number of lives (LMS)\n");
220 print("^3rank^7 Player rank\n");
221 print("^3pushes^7 Number of players pushed into void\n");
222 print("^3destroyed^7 Number of keys destroyed by pushing them into void\n");
223 print("^3kckills^7 Number of keys carrier kills\n");
224 print("^3losses^7 Number of times a key was lost\n");
225 print("^3laps^7 Number of laps finished (race/cts)\n");
226 print("^3time^7 Total time raced (race/cts)\n");
227 print("^3fastest^7 Time of fastest lap (race/cts)\n");
228 print("^3ticks^7 Number of ticks (DOM)\n");
229 print("^3takes^7 Number of domination points taken (DOM)\n");
230 print("^3score^7 Total score\n\n");
232 print("Before a field you can put a + or - sign, then a comma separated list\n");
233 print("of game types, then a slash, to make the field show up only in these\n");
234 print("or in all but these game types. You can also specify 'all' as a\n");
235 print("field to show all fields available for the current game mode.\n\n");
237 print("The special game type names 'teams' and 'noteams' can be used to\n");
238 print("include/exclude ALL teams/noteams game modes.\n\n");
240 print("Example: scoreboard_columns_set name ping pl | +ctf/field3 -dm/field4\n");
241 print("will display name, ping and pl aligned to the left, and the fields\n");
242 print("right of the vertical bar aligned to the right.\n");
243 print("'field3' will only be shown in CTF, and 'field4' will be shown in all\n");
244 print("other gamemodes except DM.\n");
247 string HUD_DefaultColumnLayout()
249 return strcat( // fteqcc sucks
251 "-teams,race,lms/kills -teams,lms/deaths -teams,lms,race/suicides -race,dm,tdm/frags ", // tdm already has this in "score"
252 "+ctf/caps +ctf/pickups +ctf/fckills +ctf/returns ",
253 "+lms/lives +lms/rank ",
254 "+kh/caps +kh/pushes +kh/destroyed ",
255 "?+race/laps ?+race/time ?+race/fastest ",
256 "+as/objectives +nexball/faults +nexball/goals ",
257 "-lms,race,nexball/score");
260 void Cmd_HUD_SetFields(float argc)
264 float have_name, have_primary, have_secondary, have_separator;
267 // TODO: re enable with gametype dependant cvars?
268 if(argc < 2) // no arguments provided
269 argc = tokenizebyseparator(strcat("x ", cvar_string("scoreboard_columns")), " ");
272 argc = tokenizebyseparator(strcat("x ", HUD_DefaultColumnLayout()), " ");
276 if(argv(1) == "default")
277 argc = tokenizebyseparator(strcat("x ", HUD_DefaultColumnLayout()), " ");
278 else if(argv(1) == "all")
281 s = "ping pl color name |";
282 for(i = 0; i < MAX_SCORE; ++i)
285 if(i != ps_secondary)
286 if(scores_label[i] != "")
287 s = strcat(s, " ", scores_label[i]);
289 if(ps_secondary != ps_primary)
290 s = strcat(s, " ", scores_label[ps_secondary]);
291 s = strcat(s, " ", scores_label[ps_primary]);
292 argc = tokenizebyseparator(strcat("x ", s), " ");
301 for(i = 0; i < argc - 1; ++i)
307 if(substring(str, 0, 1) == "?")
310 str = substring(str, 1, strlen(str) - 1);
313 slash = strstrofs(str, "/", 0);
316 pattern = substring(str, 0, slash);
317 str = substring(str, slash + 1, strlen(str) - (slash + 1));
319 if not(isGametypeInFilter(gametype, teamplay, pattern))
323 strunzone(hud_title[hud_num_fields]);
324 hud_title[hud_num_fields] = strzone(str);
325 hud_size[hud_num_fields] = stringwidth(str, FALSE, hud_fontsize);
326 str = strtolower(str);
329 hud_field[hud_num_fields] = SP_PING;
330 } else if(str == "pl") {
331 hud_field[hud_num_fields] = SP_PL;
332 } else if(str == "kd" || str == "kdr" || str == "kdratio" || str == "k/d") {
333 hud_field[hud_num_fields] = SP_KDRATIO;
334 } else if(str == "name" || str == "nick") {
335 hud_field[hud_num_fields] = SP_NAME;
337 } else if(str == "|") {
338 hud_field[hud_num_fields] = SP_SEPARATOR;
341 for(j = 0; j < MAX_SCORE; ++j)
342 if(str == strtolower(scores_label[j]))
343 goto found; // sorry, but otherwise fteqcc -O3 miscompiles this and warns about "unreachable code"
352 print(strcat("^1Error:^7 Unknown score field: '", str, "'\n"));
356 hud_field[hud_num_fields] = j;
359 if(j == ps_secondary)
363 if(hud_num_fields >= MAX_HUD_FIELDS)
367 if(scores_flags[ps_primary] & SFL_ALLOW_HIDE)
369 if(scores_flags[ps_secondary] & SFL_ALLOW_HIDE)
371 if(ps_primary == ps_secondary)
373 missing = (!have_primary) + (!have_secondary) + (!have_separator) + (!have_name);
375 if(hud_num_fields+missing < MAX_HUD_FIELDS)
379 strunzone(hud_title[hud_num_fields]);
380 for(i = hud_num_fields; i > 0; --i)
382 hud_title[i] = hud_title[i-1];
383 hud_size[i] = hud_size[i-1];
384 hud_field[i] = hud_field[i-1];
386 hud_title[0] = strzone("name");
387 hud_field[0] = SP_NAME;
389 print("fixed missing field 'name'\n");
393 strunzone(hud_title[hud_num_fields]);
394 for(i = hud_num_fields; i > 1; --i)
396 hud_title[i] = hud_title[i-1];
397 hud_size[i] = hud_size[i-1];
398 hud_field[i] = hud_field[i-1];
400 hud_title[1] = strzone("|");
401 hud_field[1] = SP_SEPARATOR;
402 hud_size[1] = stringwidth("|", FALSE, hud_fontsize);
404 print("fixed missing field '|'\n");
407 else if(!have_separator)
409 strunzone(hud_title[hud_num_fields]);
410 hud_title[hud_num_fields] = strzone("|");
411 hud_size[hud_num_fields] = stringwidth("|", FALSE, hud_fontsize);
412 hud_field[hud_num_fields] = SP_SEPARATOR;
414 print("fixed missing field '|'\n");
418 strunzone(hud_title[hud_num_fields]);
419 hud_title[hud_num_fields] = strzone(scores_label[ps_secondary]);
420 hud_size[hud_num_fields] = stringwidth(hud_title[hud_num_fields], FALSE, hud_fontsize);
421 hud_field[hud_num_fields] = ps_secondary;
423 print("fixed missing field '", scores_label[ps_secondary], "'\n");
427 strunzone(hud_title[hud_num_fields]);
428 hud_title[hud_num_fields] = strzone(scores_label[ps_primary]);
429 hud_size[hud_num_fields] = stringwidth(hud_title[hud_num_fields], FALSE, hud_fontsize);
430 hud_field[hud_num_fields] = ps_primary;
432 print("fixed missing field '", scores_label[ps_primary], "'\n");
436 hud_field[hud_num_fields] = SP_END;
440 vector hud_field_rgb;
441 string hud_field_icon0;
442 string hud_field_icon1;
443 string hud_field_icon2;
444 vector hud_field_icon0_rgb;
445 vector hud_field_icon1_rgb;
446 vector hud_field_icon2_rgb;
447 float hud_field_icon0_alpha;
448 float hud_field_icon1_alpha;
449 float hud_field_icon2_alpha;
450 string HUD_GetField(entity pl, float field)
452 float tmp, num, denom, f;
454 hud_field_rgb = '1 1 1';
455 hud_field_icon0 = "";
456 hud_field_icon1 = "";
457 hud_field_icon2 = "";
458 hud_field_icon0_rgb = '1 1 1';
459 hud_field_icon1_rgb = '1 1 1';
460 hud_field_icon2_rgb = '1 1 1';
461 hud_field_icon0_alpha = 1;
462 hud_field_icon1_alpha = 1;
463 hud_field_icon2_alpha = 1;
468 return "\x8D\x8D\x8D"; // >>> sign
469 //str = getplayerkey(pl.sv_entnum, "ping");
473 tmp = max(0, min(220, f-80)) / 220;
474 hud_field_rgb = '1 1 1' - '0 1 1'*tmp;
480 f = pl.ping_packetloss;
481 tmp = pl.ping_movementloss;
482 if(f == 0 && tmp == 0)
484 str = ftos(ceil(f * 100));
486 str = strcat(str, "~", ftos(ceil(tmp * 100)));
487 tmp = bound(0, f / 0.2 + tmp / 0.04, 1); // 20% is REALLY BAD pl
488 hud_field_rgb = '1 0.5 0.5' - '0 0.5 0.5'*tmp;
492 if(ready_waiting && pl.ready)
494 hud_field_icon0 = "gfx/scoreboard/player_ready";
498 f = stof(getplayerkey(pl.sv_entnum, "colors"));
500 hud_field_icon0 = "gfx/scoreboard/playercolor_base";
501 hud_field_icon1 = "gfx/scoreboard/playercolor_shirt";
502 hud_field_icon1_rgb = colormapPaletteColor(floor(f / 16), 0);
503 hud_field_icon2 = "gfx/scoreboard/playercolor_pants";
504 hud_field_icon2_rgb = colormapPaletteColor(mod(f, 16), 1);
507 return GetPlayerName(pl.sv_entnum);
510 f = pl.(scores[SP_KILLS]);
511 f -= pl.(scores[SP_SUICIDES]);
515 num = pl.(scores[SP_KILLS]);
516 denom = pl.(scores[SP_DEATHS]);
519 hud_field_rgb = '0 1 0';
521 } else if(num <= 0) {
522 hud_field_rgb = '1 0 0';
523 str = ftos(num/denom);
525 str = ftos(num/denom);
527 tmp = strstrofs(str, ".", 0);
529 str = substring(str, 0, tmp+2);
533 tmp = pl.(scores[field]);
534 f = scores_flags[field];
535 if(field == ps_primary)
536 hud_field_rgb = '1 1 0';
537 else if(field == ps_secondary)
538 hud_field_rgb = '0 1 1';
540 hud_field_rgb = '1 1 1';
541 return ScoreString(f, tmp);
546 float xmin, xmax, ymin, ymax, sbwidth;
547 float hud_fixscoreboardcolumnwidth_len;
548 float hud_fixscoreboardcolumnwidth_iconlen;
549 float hud_fixscoreboardcolumnwidth_marginlen;
551 string HUD_FixScoreboardColumnWidth(float i, string str)
555 field = hud_field[i];
557 hud_fixscoreboardcolumnwidth_iconlen = 0;
559 if(hud_field_icon0 != "")
561 sz = drawgetimagesize(hud_field_icon0);
563 if(hud_fixscoreboardcolumnwidth_iconlen < f)
564 hud_fixscoreboardcolumnwidth_iconlen = f;
567 if(hud_field_icon1 != "")
569 sz = drawgetimagesize(hud_field_icon1);
571 if(hud_fixscoreboardcolumnwidth_iconlen < f)
572 hud_fixscoreboardcolumnwidth_iconlen = f;
575 if(hud_field_icon2 != "")
577 sz = drawgetimagesize(hud_field_icon2);
579 if(hud_fixscoreboardcolumnwidth_iconlen < f)
580 hud_fixscoreboardcolumnwidth_iconlen = f;
583 hud_fixscoreboardcolumnwidth_iconlen *= hud_fontsize_y / hud_fontsize_x; // fix icon aspect
585 if(hud_fixscoreboardcolumnwidth_iconlen != 0)
586 hud_fixscoreboardcolumnwidth_marginlen = stringwidth(" ", FALSE, hud_fontsize);
588 hud_fixscoreboardcolumnwidth_marginlen = 0;
590 if(field == SP_NAME) // name gets all remaining space
593 namesize = sbwidth;// / hud_fontsize_x;
594 for(j = 0; j < hud_num_fields; ++j)
596 if (hud_field[i] != SP_SEPARATOR)
597 namesize -= hud_size[j] + 1;
599 hud_size[i] = namesize;
601 if (hud_fixscoreboardcolumnwidth_iconlen != 0)
602 namesize -= hud_fixscoreboardcolumnwidth_marginlen + hud_fixscoreboardcolumnwidth_iconlen;
603 str = textShortenToWidth(str, namesize, hud_fontsize, stringwidth_colors);
604 hud_fixscoreboardcolumnwidth_len = stringwidth(str, TRUE, hud_fontsize);
607 hud_fixscoreboardcolumnwidth_len = stringwidth(str, FALSE, hud_fontsize);
609 f = hud_fixscoreboardcolumnwidth_len + hud_fixscoreboardcolumnwidth_marginlen + hud_fixscoreboardcolumnwidth_iconlen;
616 void HUD_PrintScoreboardItem(vector pos, entity pl, float is_self, float pl_number)
619 rgb = GetTeamRGB(pl.team);
623 is_spec = (GetPlayerColor(pl.sv_entnum) == COLOR_SPECTATOR);
625 if((rgb == '1 1 1') && (!is_spec)) {
626 rgb_x = cvar("scoreboard_color_bg_r") + 0.5;
627 rgb_y = cvar("scoreboard_color_bg_g") + 0.5;
628 rgb_z = cvar("scoreboard_color_bg_b") + 0.5; }
632 tmp_y = hud_fontsize_y * 1.25;
635 // alternated rows highlighting
637 drawfill(pos - '1 1 0', tmp + '2 0 0', rgb, scoreboard_highlight_alpha_self, DRAWFLAG_NORMAL);
638 else if((scoreboard_highlight) && (!mod(pl_number,2)))
639 drawfill(pos - '1 1 0', tmp + '2 0 0', rgb, scoreboard_highlight_alpha, DRAWFLAG_NORMAL);
643 for(i = 0; i < hud_num_fields; ++i)
645 field = hud_field[i];
646 if(field == SP_SEPARATOR)
649 if(is_spec && field != SP_NAME && field != SP_PING) {
650 pos_x += hud_size[i] + hud_fontsize_x;
653 str = HUD_GetField(pl, field);
654 str = HUD_FixScoreboardColumnWidth(i, str);
656 pos_x += hud_size[i] + hud_fontsize_x;
658 if(field == SP_NAME) {
659 tmp_x = hud_size[i] - hud_fontsize_x*hud_fixscoreboardcolumnwidth_iconlen - hud_fixscoreboardcolumnwidth_marginlen + hud_fontsize_x;
661 drawcolorcodedstring(pos - tmp, str, hud_fontsize, scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
663 drawcolorcodedstring(pos - tmp, str, hud_fontsize, scoreboard_alpha_name, DRAWFLAG_NORMAL);
665 tmp_x = hud_fixscoreboardcolumnwidth_len + hud_fontsize_x;
667 drawstring(pos - tmp, str, hud_fontsize, hud_field_rgb, scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
669 drawstring(pos - tmp, str, hud_fontsize, hud_field_rgb, scoreboard_alpha_name, DRAWFLAG_NORMAL);
672 tmp_x = hud_size[i] + hud_fontsize_x;
673 if(hud_field_icon0 != "")
675 drawpic(pos - tmp, hud_field_icon0, '0 1 0' * hud_fontsize_y + '1 0 0' * hud_fontsize_x * hud_fixscoreboardcolumnwidth_iconlen, hud_field_icon1_rgb, hud_field_icon0_alpha * scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
677 drawpic(pos - tmp, hud_field_icon0, '0 1 0' * hud_fontsize_y + '1 0 0' * hud_fontsize_x * hud_fixscoreboardcolumnwidth_iconlen, hud_field_icon1_rgb, hud_field_icon0_alpha * scoreboard_alpha_name, DRAWFLAG_NORMAL);
678 if(hud_field_icon1 != "")
680 drawpic(pos - tmp, hud_field_icon1, '0 1 0' * hud_fontsize_y + '1 0 0' * hud_fontsize_x * hud_fixscoreboardcolumnwidth_iconlen, hud_field_icon1_rgb, hud_field_icon1_alpha * scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
682 drawpic(pos - tmp, hud_field_icon1, '0 1 0' * hud_fontsize_y + '1 0 0' * hud_fontsize_x * hud_fixscoreboardcolumnwidth_iconlen, hud_field_icon1_rgb, hud_field_icon1_alpha * scoreboard_alpha_name, DRAWFLAG_NORMAL);
683 if(hud_field_icon2 != "")
685 drawpic(pos - tmp, hud_field_icon2, '0 1 0' * hud_fontsize_y + '1 0 0' * hud_fontsize_x * hud_fixscoreboardcolumnwidth_iconlen, hud_field_icon2_rgb, hud_field_icon2_alpha * scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
687 drawpic(pos - tmp, hud_field_icon2, '0 1 0' * hud_fontsize_y + '1 0 0' * hud_fontsize_x * hud_fixscoreboardcolumnwidth_iconlen, hud_field_icon2_rgb, hud_field_icon2_alpha * scoreboard_alpha_name, DRAWFLAG_NORMAL);
690 if(hud_field[i] == SP_SEPARATOR)
693 for(i = hud_num_fields-1; i > 0; --i)
695 field = hud_field[i];
696 if(field == SP_SEPARATOR)
699 if(is_spec && field != SP_NAME && field != SP_PING) {
700 pos_x -= hud_size[i] + hud_fontsize_x;
704 str = HUD_GetField(pl, field);
705 str = HUD_FixScoreboardColumnWidth(i, str);
707 if(field == SP_NAME) {
708 tmp_x = hud_fixscoreboardcolumnwidth_len; // left or right aligned? let's put it right...
710 drawcolorcodedstring(pos - tmp, str, hud_fontsize, scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
712 drawcolorcodedstring(pos - tmp, str, hud_fontsize, scoreboard_alpha_name, DRAWFLAG_NORMAL);
714 tmp_x = hud_fixscoreboardcolumnwidth_len;
716 drawstring(pos - tmp, str, hud_fontsize, hud_field_rgb, scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
718 drawstring(pos - tmp, str, hud_fontsize, hud_field_rgb, scoreboard_alpha_name, DRAWFLAG_NORMAL);
722 if(hud_field_icon0 != "")
724 drawpic(pos - tmp, hud_field_icon0, '0 1 0' * hud_fontsize_y + '1 0 0' * hud_fontsize_x * hud_fixscoreboardcolumnwidth_iconlen, hud_field_icon1_rgb, hud_field_icon0_alpha * scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
726 drawpic(pos - tmp, hud_field_icon0, '0 1 0' * hud_fontsize_y + '1 0 0' * hud_fontsize_x * hud_fixscoreboardcolumnwidth_iconlen, hud_field_icon1_rgb, hud_field_icon0_alpha * scoreboard_alpha_name, DRAWFLAG_NORMAL);
727 if(hud_field_icon1 != "")
729 drawpic(pos - tmp, hud_field_icon1, '0 1 0' * hud_fontsize_y + '1 0 0' * hud_fontsize_x * hud_fixscoreboardcolumnwidth_iconlen, hud_field_icon1_rgb, hud_field_icon1_alpha * scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
731 drawpic(pos - tmp, hud_field_icon1, '0 1 0' * hud_fontsize_y + '1 0 0' * hud_fontsize_x * hud_fixscoreboardcolumnwidth_iconlen, hud_field_icon1_rgb, hud_field_icon1_alpha * scoreboard_alpha_name, DRAWFLAG_NORMAL);
732 if(hud_field_icon2 != "")
734 drawpic(pos - tmp, hud_field_icon2, '0 1 0' * hud_fontsize_y + '1 0 0' * hud_fontsize_x * hud_fixscoreboardcolumnwidth_iconlen, hud_field_icon2_rgb, hud_field_icon2_alpha * scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
736 drawpic(pos - tmp, hud_field_icon2, '0 1 0' * hud_fontsize_y + '1 0 0' * hud_fontsize_x * hud_fixscoreboardcolumnwidth_iconlen, hud_field_icon2_rgb, hud_field_icon2_alpha * scoreboard_alpha_name, DRAWFLAG_NORMAL);
737 pos_x -= hud_size[i] + hud_fontsize_x;
743 * HUD_Scoreboard_MakeTable
745 * Makes a table for a team (for all playing players in DM) and fills it
748 vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_size)
750 float body_table_height, i;
751 vector tmp, column_dim;
754 body_table_height = 1.25 * hud_fontsize_y * max(1, tm.team_size); // no player? show 1 empty line
759 tmp_y = 1.25 * hud_fontsize_y;
762 drawpic(pos, "gfx/scoreboard/scoreboard_tableheader", tmp, (rgb * hud_color_bg_team) + '0.5 0.5 0.5', scoreboard_alpha_bg, DRAWFLAG_NORMAL);
765 tmp_y += hud_border_thickness;
766 tmp_y += body_table_height;
767 drawborderlines(hud_border_thickness, pos, tmp, '0 0 0', scoreboard_alpha_bg, DRAWFLAG_NORMAL); // more transparency for the scoreboard
769 // separator header/table
770 pos_y += 1.25 * hud_fontsize_y;
771 tmp_y = hud_border_thickness;
772 drawfill(pos, tmp, '0 0 0', scoreboard_alpha_bg, DRAWFLAG_NORMAL);
774 pos_y += hud_border_thickness;
777 tmp_y = body_table_height;
778 drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * hud_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
780 // anyway, apply some color
781 //drawfill(pos, tmp + '2 0 0', rgb, 0.1, DRAWFLAG_NORMAL);
783 // go back to the top to make alternated columns highlighting and to print the strings
784 pos_y -= 1.25 * hud_fontsize_y;
785 pos_y -= hud_border_thickness;
789 if (scoreboard_highlight)
791 column_dim_y = 1.25 * hud_fontsize_y; // header
792 column_dim_y += hud_border_thickness;
793 column_dim_y += body_table_height;
796 // print the strings of the columns headers and draw the columns
797 for(i = 0; i < hud_num_fields; ++i)
799 if(hud_field[i] == SP_SEPARATOR)
801 column_dim_x = hud_size[i] + hud_fontsize_x;
802 if (scoreboard_highlight)
805 drawfill(pos - '0 1 0' - hud_fontsize_x / 2 * '1 0 0', column_dim, '0 0 0', scoreboard_alpha_bg * 0.2, DRAWFLAG_NORMAL);
807 drawstring(pos, hud_title[i], hud_fontsize, rgb * 1.5, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
808 pos_x += column_dim_x;
810 if(hud_field[i] == SP_SEPARATOR)
814 for(i = hud_num_fields-1; i > 0; --i)
816 if(hud_field[i] == SP_SEPARATOR)
819 pos_x -= hud_size[i];
821 if (scoreboard_highlight)
825 if (i == hud_num_fields-1)
826 column_dim_x = hud_size[i] + hud_fontsize_x / 2 + 1;
828 column_dim_x = hud_size[i] + hud_fontsize_x;
829 drawfill(pos - '0 1 0' - hud_fontsize_x / 2 * '1 0 0', column_dim, '0 0 0', scoreboard_alpha_bg * 0.2, DRAWFLAG_NORMAL);
833 tmp_x = stringwidth(hud_title[i], FALSE, hud_fontsize);
834 tmp_x = (hud_size[i] - tmp_x) * hud_fontsize_x;
835 drawstring(pos + tmp, hud_title[i], hud_fontsize, rgb * 1.5, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
836 pos_x -= hud_fontsize_x;
841 pos_y += 1.25 * hud_fontsize_y; // skip the header
842 pos_y += hud_border_thickness;
844 // fill the table and draw the rows
847 for(pl = players.sort_next; pl; pl = pl.sort_next)
849 if(pl.team != tm.team)
851 HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), i);
852 pos_y += 1.25 * hud_fontsize_y;
856 for(pl = players.sort_next; pl; pl = pl.sort_next)
858 if(pl.team == COLOR_SPECTATOR)
860 HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), i);
861 pos_y += 1.25 * hud_fontsize_y;
866 pos_y += 1.25 * hud_fontsize_y; // move to the end of the table
867 pos_y += 1.25 * hud_fontsize_y; // move empty row (out of the table)
872 float HUD_WouldDrawScoreboard() {
873 if (autocvar__hud_configure)
875 else if (scoreboard_showscores)
877 else if (intermission == 1)
879 else if (intermission == 2)
881 else if (getstati(STAT_HEALTH) <= 0 && cvar("cl_deathscoreboard"))
883 else if(scoreboard_showscores_force)
889 float average_accuracy;
890 vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
893 float weapon_hit, weapon_damage, weapon_stats;
894 float fontsize = 40 * 1/3;
895 float weapon_cnt = 12;
897 if(cvar("scoreboard_accuracy_doublerows"))
908 drawstring(pos, strcat("Accuracy stats (average ", ftos(average_accuracy), "%)"), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
912 tmp_y = height * rows;
914 drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * hud_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
915 drawborderlines(hud_accuracy_border_thickness, pos, tmp, '0 0 0', scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);
917 // column highlighting
918 for(i = 0; i < weapon_cnt/rows; ++i)
921 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', scoreboard_alpha_bg * 0.2, DRAWFLAG_NORMAL);
925 for(i = 0; i < rows; ++i)
927 drawfill(pos + '0 1 0' * height * (2/3) + '0 1 0' * height * i, '1 0 0' * sbwidth + '0 1 0' * fontsize, '1 1 1', scoreboard_highlight_alpha, DRAWFLAG_NORMAL);
930 drawfont = hud_bigfont;
931 average_accuracy = 0;
932 float weapons_with_stats;
933 weapons_with_stats = 0;
935 pos_x += sbwidth/weapon_cnt / 2;
937 if(getstati(STAT_SWITCHWEAPON) == WEP_MINSTANEX)
938 g_minstagib = 1; // TODO: real detection for minstagib?
940 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
942 self = get_weaponinfo(i);
945 if ((i == WEP_NEX && g_minstagib) || i == WEP_PORTO || (i == WEP_MINSTANEX && !g_minstagib) || i == WEP_TUBA || i == WEP_FIREBALL) // skip port-o-launch, nex || minstanex, tuba and fireball
947 weapon_hit = weapon_hits[i-WEP_FIRST];
948 weapon_damage = weapon_fired[i-WEP_FIRST];
950 weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100);
954 weapon_alpha = scoreboard_alpha_fg;
956 weapon_alpha = 0.2 * scoreboard_alpha_fg;
959 drawpic(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/weapon", self.netname), '1 0 0' * sbwidth * (1/weapon_cnt) + '0 1 0' * height * (2/3), '1 1 1', weapon_alpha, DRAWFLAG_NORMAL);
962 weapons_with_stats += 1;
963 average_accuracy += weapon_stats; // store sum of all accuracies in average_accuracy
966 s = strcat(ftos(weapon_stats),"%");
969 padding = ((sbwidth/weapon_cnt) - stringwidth(s, FALSE, '1 0 0' * fontsize)) / 2; // center the accuracy value
971 // yellow_accuracy = value at which accuracy becomes yellow
972 if(weapon_stats >= 100) {
976 else if(weapon_stats > autocvar_hud_weaponicons_accuracy_yellow) {
977 rgb_x = 1 - (weapon_stats-autocvar_hud_weaponicons_accuracy_yellow)/(100-autocvar_hud_weaponicons_accuracy_yellow); // red value between 1 -> 0
981 rgb_y = weapon_stats/autocvar_hud_weaponicons_accuracy_yellow; // green value between 0 -> 1
984 drawstring(pos + '1 0 0' * padding + '0 1 0' * height * (2/3), s, '1 1 0' * fontsize, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
986 pos_x += sbwidth/weapon_cnt * rows;
987 if(rows == 2 && i == 6) {
994 if(weapons_with_stats)
995 average_accuracy = floor(average_accuracy / weapons_with_stats);
998 pos_x -= sbwidth/weapon_cnt / 2;
1004 vector HUD_DrawScoreboardRankings(vector pos, entity pl, vector rgb, vector bg_size)
1007 RANKINGS_RECEIVED_CNT = 0;
1008 for (i=RANKINGS_CNT-1; i>=0; --i)
1010 RANKINGS_RECEIVED_CNT = RANKINGS_RECEIVED_CNT + 1;
1012 if (RANKINGS_RECEIVED_CNT == 0)
1016 is_spec = (GetPlayerColor(pl.sv_entnum) == COLOR_SPECTATOR);
1018 hl_rgb_x = cvar("scoreboard_color_bg_r") + 0.5;
1019 hl_rgb_y = cvar("scoreboard_color_bg_g") + 0.5;
1020 hl_rgb_z = cvar("scoreboard_color_bg_b") + 0.5;
1022 pos_y += hud_fontsize_y;
1023 drawstring(pos, strcat("Rankings"), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1024 pos_y += hud_fontsize_y;
1027 tmp_y = hud_fontsize_y * RANKINGS_RECEIVED_CNT;
1029 drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * hud_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
1030 drawborderlines(hud_border_thickness, pos, tmp, '0 0 0', scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);
1033 for(i = 0; i<RANKINGS_RECEIVED_CNT; ++i)
1040 n = grecordholder[i];
1041 p = race_PlaceName(i+1);
1042 if(grecordholder[i] == GetPlayerName(player_localentnum - 1))
1043 drawfill(pos, '1 0 0' * sbwidth + '0 1 0' * hud_fontsize_y, hl_rgb, scoreboard_highlight_alpha_self, DRAWFLAG_NORMAL);
1044 else if(!mod(i, 2) && scoreboard_highlight)
1045 drawfill(pos, '1 0 0' * sbwidth + '0 1 0' * hud_fontsize_y, hl_rgb, scoreboard_highlight_alpha, DRAWFLAG_NORMAL);
1046 drawstring(pos, p, hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1047 drawstring(pos + '3 0 0' * hud_fontsize_x, TIME_ENCODED_TOSTRING(t), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1048 drawcolorcodedstring(pos + '8 0 0' * hud_fontsize_x, n, hud_fontsize, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1049 pos += '0 1 0' * hud_fontsize_y;
1055 float scoreboard_fade_alpha;
1056 float hud_woulddrawscoreboard_prev;
1057 float hud_woulddrawscoreboard_change; // "time" at which HUD_WouldDrawScoreboard() changed
1058 void HUD_DrawScoreboard()
1060 HUD_UpdatePlayerTeams();
1062 float hud_woulddrawscoreboard;
1063 hud_woulddrawscoreboard = HUD_WouldDrawScoreboard();
1064 if(hud_woulddrawscoreboard != hud_woulddrawscoreboard_prev) {
1065 hud_woulddrawscoreboard_change = time;
1066 hud_woulddrawscoreboard_prev = hud_woulddrawscoreboard;
1069 float scoreboard_fadeinspeed = cvar_or("scoreboard_fadeinspeed", 10);
1070 float scoreboard_fadeoutspeed = cvar_or("scoreboard_fadeoutspeed", 5);
1071 if(hud_woulddrawscoreboard) {
1072 if (scoreboard_fadeinspeed)
1073 scoreboard_fade_alpha = bound (0, (time - hud_woulddrawscoreboard_change) * scoreboard_fadeinspeed, 1);
1075 scoreboard_fade_alpha = 1;
1078 if (scoreboard_fadeoutspeed)
1079 scoreboard_fade_alpha = bound (0, (1/scoreboard_fadeoutspeed - (time - hud_woulddrawscoreboard_change)) * scoreboard_fadeoutspeed, 1);
1081 scoreboard_fade_alpha = 0;
1083 if not(scoreboard_fade_alpha)
1086 scoreboard_alpha_bg = cvar("scoreboard_alpha_bg") * scoreboard_fade_alpha * (1 - cvar("_menu_alpha"));
1087 scoreboard_alpha_fg = cvar_or("scoreboard_alpha_fg", 1.0) * scoreboard_fade_alpha * (1 - cvar("_menu_alpha"));
1088 scoreboard_highlight = cvar("scoreboard_highlight");
1089 scoreboard_highlight_alpha = cvar_or("scoreboard_highlight_alpha", 0.10) * scoreboard_alpha_fg;
1090 scoreboard_highlight_alpha_self = cvar_or("scoreboard_highlight_alpha_self", 0.25) * scoreboard_alpha_fg;
1091 scoreboard_alpha_name = cvar_or("scoreboard_alpha_name", 0.9) * scoreboard_alpha_fg;
1092 scoreboard_alpha_name_self = cvar_or("scoreboard_alpha_name_self", 1) * scoreboard_alpha_fg;
1094 vector rgb, pos, tmp;
1097 sbwidth = HUD_GetWidth(6.5 * hud_fontsize_y);
1099 xmin = 0.5 * (vid_conwidth - sbwidth);
1100 ymin = SCOREBOARD_OFFSET;
1102 xmax = vid_conwidth - xmin;
1103 ymax = vid_conheight - 0.2*vid_conheight;
1105 // Initializes position
1111 drawfont = hud_bigfont;
1112 drawstringcenter('0 1 0' * ymin, "Scoreboard", '24 24 0', '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1115 pos_y += hud_fontsize_y;
1117 drawfont = hud_font;
1119 // Draw the scoreboard
1121 bg_size = drawgetimagesize("gfx/hud/scoreboard_scoreboard_bg");
1125 for(tm = teams.sort_next; tm; tm = tm.sort_next)
1127 if(tm.team == COLOR_SPECTATOR)
1130 rgb = GetTeamRGB(tm.team);
1131 drawstring(pos - '9.5 0 0' * hud_fontsize_y + '0 1 0' * hud_fontsize_y, ftos(tm.(teamscores[ts_primary])), '1 1 0' * hud_fontsize_y * 1.5, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1133 if(ts_primary != ts_secondary)
1134 drawstring(pos - '7.5 0 0' * hud_fontsize_y + '0 2.5 0' * hud_fontsize_y, ftos(tm.(teamscores[ts_secondary])), '1 1 0' * hud_fontsize_y * 1, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1136 pos = HUD_Scoreboard_MakeTable(pos, tm, rgb, bg_size);
1141 rgb_x = cvar("scoreboard_color_bg_r");
1142 rgb_y = cvar("scoreboard_color_bg_g");
1143 rgb_z = cvar("scoreboard_color_bg_b");
1145 for(tm = teams.sort_next; tm; tm = tm.sort_next)
1147 if(tm.team == COLOR_SPECTATOR)
1150 pos = HUD_Scoreboard_MakeTable(pos, tm, rgb, bg_size);
1154 if(gametype == GAME_CTS || gametype == GAME_RACE) {
1155 if(race_speedaward) {
1156 drawcolorcodedstring(pos, strcat("Speed award: ", ftos(race_speedaward), " (", race_speedaward_holder, ")"), hud_fontsize, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1157 pos_y += 1.25 * hud_fontsize_y;
1159 if(race_speedaward_alltimebest) {
1160 drawcolorcodedstring(pos, strcat("All-time fastest: ", ftos(race_speedaward_alltimebest), " (", race_speedaward_alltimebest_holder, ")"), hud_fontsize, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1161 pos_y += 1.25 * hud_fontsize_y;
1163 pos = HUD_DrawScoreboardRankings(pos, pl, rgb, bg_size);
1165 else if(cvar("scoreboard_accuracy") && spectatee_status != -1) {
1167 pos = HUD_DrawScoreboardAccuracyStats(pos, GetTeamRGB(myteam), bg_size);
1169 pos = HUD_DrawScoreboardAccuracyStats(pos, rgb, bg_size);
1172 tmp = pos + '0 1.5 0' * hud_fontsize_y;
1173 pos_y += 3 * hud_fontsize_y;
1178 for(pl = players.sort_next; pl; pl = pl.sort_next)
1180 if(pl.team != COLOR_SPECTATOR)
1182 HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), specs);
1183 pos_y += 1.25 * hud_fontsize_y;
1188 drawstring(tmp, "Spectators", hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1190 // Print info string
1193 str = strcat("playing on ^2", shortmapname, "^7");
1194 tl = getstatf(STAT_TIMELIMIT);
1195 fl = getstatf(STAT_FRAGLIMIT);
1196 ll = getstatf(STAT_LEADLIMIT);
1197 if(gametype == GAME_LMS)
1200 str = strcat(str, " for up to ^1", ftos(tl), " minutes^7");
1205 str = strcat(str, " for ^1", ftos(tl), " minutes^7");
1209 str = strcat(str, " or");
1212 str = strcat(str, " until ^3", ScoreString(teamscores_flags[ts_primary], fl));
1213 if(teamscores_label[ts_primary] == "score")
1214 str = strcat(str, " points^7");
1215 else if(teamscores_label[ts_primary] == "fastest")
1216 str = strcat(str, " is beaten^7");
1218 str = strcat(str, " ", teamscores_label[ts_primary]);
1222 str = strcat(str, " until ^3", ScoreString(scores_flags[ps_primary], fl));
1223 if(scores_label[ps_primary] == "score")
1224 str = strcat(str, " points^7");
1225 else if(scores_label[ps_primary] == "fastest")
1226 str = strcat(str, " is beaten^7");
1228 str = strcat(str, " ", scores_label[ps_primary]);
1233 if(tl > 0 || fl > 0)
1234 str = strcat(str, " or");
1237 str = strcat(str, " until a lead of ^3", ScoreString(teamscores_flags[ts_primary], ll));
1238 if(teamscores_label[ts_primary] == "score")
1239 str = strcat(str, " points^7");
1240 else if(teamscores_label[ts_primary] == "fastest")
1241 str = strcat(str, " is beaten^7");
1243 str = strcat(str, " ", teamscores_label[ts_primary]);
1247 str = strcat(str, " until a lead of ^3", ScoreString(scores_flags[ps_primary], ll));
1248 if(scores_label[ps_primary] == "score")
1249 str = strcat(str, " points^7");
1250 else if(scores_label[ps_primary] == "fastest")
1251 str = strcat(str, " is beaten^7");
1253 str = strcat(str, " ", scores_label[ps_primary]);
1259 pos_y += 1.2 * hud_fontsize_y;
1260 drawcolorcodedstring(pos + '0.5 0 0' * (sbwidth - stringwidth(str, TRUE, hud_fontsize)), str, hud_fontsize, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1262 scoreboard_bottom = pos_y + 2 * hud_fontsize_y;
1265 void HUD_DrawAccuracyStats_Description_Hitscan(vector position)
1267 drawstring(position + '0 3 0' * hud_fontsize_y, "Shots fired:", hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1268 drawstring(position + '0 5 0' * hud_fontsize_y, "Shots hit:", hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1269 drawstring(position + '0 7 0' * hud_fontsize_y, "Accuracy:", hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1270 drawstring(position + '0 9 0' * hud_fontsize_y, "Shots missed:", hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1273 void HUD_DrawAccuracyStats_Description_Splash(vector position)
1275 drawstring(position + '0 3 0' * hud_fontsize_y, "Maximum damage:", hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1276 drawstring(position + '0 5 0' * hud_fontsize_y, "Actual damage:", hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1277 drawstring(position + '0 7 0' * hud_fontsize_y, "Accuracy:", hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1278 drawstring(position + '0 9 0' * hud_fontsize_y, "Damage wasted:", hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1281 void HUD_DrawAccuracyStats()
1283 float i, count_hitscan, count_splash, row; // count is the number of 'colums'
1284 float weapon_hit, weapon_damage, weapon_stats;
1285 float left_border; // position where the weapons start, the description is in the border
1286 vector fill_colour, fill_size;
1288 vector border_colour;
1290 float col_margin = 20; // pixels between the columns
1291 float row_margin = 20; // pixels between the rows
1293 fill_size_x = 5 * hud_fontsize_x; // width of the background
1294 fill_size_y = 10 * hud_fontsize_y; // height of the background
1296 drawfont = hud_bigfont;
1298 pos_y = SCOREBOARD_OFFSET;
1300 drawstringcenter(pos, "Weapon Accuracy", 2 * hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1302 left_border = col_margin + 11 * hud_fontsize_x;
1304 drawfont = hud_font;
1309 if(mod(time, 1) >= 0.4)
1310 drawstringcenter(pos, "Stats are not tracked during warmup stage", hud_fontsize, '1 1 0', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1315 if(gametype == GAME_RACE || gametype == GAME_CTS)
1318 if(mod(time, 1) >= 0.4)
1319 drawstringcenter(pos, "Stats are not tracked in Race/CTS", hud_fontsize, '1 1 0', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1324 float top_border_hitscan = SCOREBOARD_OFFSET + 55; // position where the hitscan row starts: pixels down the screen
1325 HUD_DrawAccuracyStats_Description_Hitscan('1 0 0' * col_margin + '0 1 0' * top_border_hitscan);
1327 float top_border_splash = SCOREBOARD_OFFSET + 175; // position where the splash row starts: pixels down the screen
1328 HUD_DrawAccuracyStats_Description_Splash('1 0 0' * col_margin + '0 1 0' * top_border_splash);
1330 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
1332 self = get_weaponinfo(i);
1333 if not(self.weapons)
1335 weapon_hit = weapon_hits[i-WEP_FIRST];
1336 weapon_damage = weapon_fired[i-WEP_FIRST];
1337 border_colour = (i == activeweapon) ? '1 1 1' : '0 0 0'; // white or black border
1339 if (weapon_damage) {
1340 if (self.spawnflags & WEP_TYPE_SPLASH) {
1341 weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100);
1343 fill_colour_x = 1 - 0.015 * weapon_stats;
1344 fill_colour_y = 1 - 0.015 * (100 - weapon_stats);
1346 // how the background colour is calculated
1347 // % red green red_2 green_2
1348 // 0 1 0 1 - % * 0.015 1 - (100 - %) * 0.015
1349 // 10 0.85 0 1 - % * 0.015 1 - (100 - %) * 0.015
1350 // 20 0.70 0 1 - % * 0.015 1 - (100 - %) * 0.015
1351 // 30 0.55 0 1 - % * 0.015 1 - (100 - %) * 0.015
1352 // 40 0.40 0.10 1 - % * 0.015 1 - (100 - %) * 0.015
1353 // 50 0.25 0.25 1 - % * 0.015 1 - (100 - %) * 0.015
1354 // 60 0.10 0.40 1 - % * 0.015 1 - (100 - %) * 0.015
1355 // 70 0 0.55 1 - % * 0.015 1 - (100 - %) * 0.015
1356 // 80 0 0.70 1 - % * 0.015 1 - (100 - %) * 0.015
1357 // 90 0 0.85 1 - % * 0.015 1 - (100 - %) * 0.015
1358 // 100 0 1 1 - % * 0.015 1 - (100 - %) * 0.015
1360 if ((left_border + count_splash * (fill_size_x + col_margin) + fill_size_x) >= vid_conwidth)
1364 HUD_DrawAccuracyStats_Description_Splash('1 0 0' * col_margin + '0 1 0' * (top_border_splash + row * (fill_size_y + row_margin)));
1367 pos_x = left_border + count_splash * (fill_size_x + col_margin);
1368 pos_y = top_border_splash + row * (fill_size_y + row_margin);
1371 drawpic(pos, "gfx/scoreboard/accuracy_bg", fill_size , fill_colour, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
1372 drawborderlines(hud_border_thickness, pos, fill_size, border_colour, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
1375 drawpic(pos, strcat("gfx/weapons/weapon", self.netname), '1 0.5 0' * fill_size_x , '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1377 // the amount of shots fired or max damage
1378 drawstringright(pos + '4.5 0 0' * hud_fontsize_x + '0 3 0' * hud_fontsize_y, ftos(weapon_damage), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1380 // the amount of hits or actual damage
1381 drawstringright(pos + '4.5 0 0' * hud_fontsize_x + '0 5 0' * hud_fontsize_y, ftos(weapon_hit), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1384 drawstringright(pos + '4.5 0 0' * hud_fontsize_x + '0 7 0' * hud_fontsize_y, strcat(ftos(weapon_stats),"%"), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1386 // the amount of shots missed or damage wasted
1387 drawstringright(pos + '4.5 0 0' * hud_fontsize_x + '0 9 0' * hud_fontsize_y, ftos(max(0, weapon_damage - weapon_hit)), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1390 } else if (self.spawnflags & WEP_TYPE_HITSCAN) {
1391 weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100);
1393 fill_colour_x = 1 - 0.015 * weapon_stats;
1394 fill_colour_y = 1 - 0.015 * (100 - weapon_stats);
1396 // how the background colour is calculated
1397 // % red green red_2 green_2
1398 // 0 1 0 1 - % * 0.015 1 - (100 - %) * 0.015
1399 // 10 0.850 0 1 - % * 0.015 1 - (100 - %) * 0.015
1400 // 20 0.70 0 1 - % * 0.015 1 - (100 - %) * 0.015
1401 // 30 0.55 0 1 - % * 0.015 1 - (100 - %) * 0.015
1402 // 40 0.40 0.10 1 - % * 0.015 1 - (100 - %) * 0.015
1403 // 50 0.25 0.25 1 - % * 0.015 1 - (100 - %) * 0.015
1404 // 60 0.10 0.40 1 - % * 0.015 1 - (100 - %) * 0.015
1405 // 70 0 0.55 1 - % * 0.015 1 - (100 - %) * 0.015
1406 // 80 0 0.70 1 - % * 0.015 1 - (100 - %) * 0.015
1407 // 90 0 0.85 1 - % * 0.015 1 - (100 - %) * 0.015
1408 // 100 0 1 1 - % * 0.015 1 - (100 - %) * 0.015
1410 if ((left_border + count_hitscan * (fill_size_x + col_margin) + fill_size_x + cvar("stats_right_margin")) >= vid_conwidth)
1414 HUD_DrawAccuracyStats_Description_Hitscan('1 0 0' * col_margin + '0 1 0' * (top_border_hitscan + row * (fill_size_y + row_margin)));
1417 pos_x = left_border + count_hitscan * (fill_size_x + col_margin);
1418 pos_y = top_border_hitscan + row * (fill_size_y + row_margin);
1421 drawpic(pos, "gfx/scoreboard/accuracy_bg", fill_size , fill_colour, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
1422 drawborderlines(hud_border_thickness, pos, fill_size, border_colour, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
1425 drawpic(pos, strcat("gfx/weapons/weapon", self.netname), '1 0.5 0' * fill_size_x , '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1427 // the amount of shots fired or max damage
1428 drawstringright(pos + '4.5 0 0' * hud_fontsize_x + '0 3 0' * hud_fontsize_y, ftos(weapon_damage), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1430 // the amount of hits or actual damage
1431 drawstringright(pos + '4.5 0 0' * hud_fontsize_x + '0 5 0' * hud_fontsize_y, ftos(weapon_hit), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1434 drawstringright(pos + '4.5 0 0' * hud_fontsize_x + '0 7 0' * hud_fontsize_y, strcat(ftos(weapon_stats),"%"), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
1436 // the amount of shots missed or damage wasted
1437 drawstringright(pos + '4.5 0 0' * hud_fontsize_x + '0 9 0' * hud_fontsize_y, ftos(max(0, weapon_damage - weapon_hit)), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);