float isNew;\r
entity o;\r
\r
- // damnit -.- don't want to go change every single .sv_entnum in sbar.qc AGAIN\r
+ // damnit -.- don't want to go change every single .sv_entnum in hud.qc AGAIN\r
// (no I've never heard of M-x replace-string, sed, or anything like that)\r
isNew = !self.owner; // workaround for DP bug\r
n = ReadByte()-1;\r
--- /dev/null
+void drawstringright(vector, string, vector, vector, float, float);\r
+void drawstringcenter(vector, string, vector, vector, float, float);\r
+\r
+float teamnagger;\r
+\r
+float weapon_hits[WEP_MAXCOUNT];\r
+float weapon_fired[WEP_MAXCOUNT];\r
+float weapon_number;\r
+\r
+float last_weapon;\r
+float weapontime;\r
+\r
+float sbar_alpha_fg;\r
+float sbar_alpha_bg;\r
+float sbar_color_bg_team;\r
+float sbar_border_thickness;\r
+float sbar_accuracy_border_thickness;\r
+float sbar_scoreboard_alpha_bg;\r
+float sbar_scoreboard_alpha_fg;\r
+float sbar_scoreboard_highlight;\r
+float sbar_scoreboard_highlight_alpha;\r
+float sbar_scoreboard_highlight_alpha_self;\r
+float sbar_hudselector;\r
+float sbar_accuracy_hud;\r
+float sbar_scoreboard_alpha_name;\r
+float sbar_scoreboard_alpha_name_self;\r
+\r
+float ps_primary, ps_secondary;\r
+float ts_primary, ts_secondary;\r
+\r
+vector color;\r
+\r
+void CSQC_kh_hudreset();\r
+void CSQC_kh_hud();\r
+void CSQC_ctf_hudreset();\r
+void CSQC_ctf_hud();\r
+void CSQC_race_hud();\r
+void MapVote_Draw();\r
+void Sbar_FinaleOverlay()\r
+{\r
+ /*vector pos;\r
+ pos_x = (vid_conwidth - 1)/2;\r
+ pos_y = 16;\r
+ pos_z = 0;*/\r
+\r
+ //drawpic(pos, "gfx/finale", '0 0 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+ //drawstring(pos, "END", sbar_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);\r
+ MapVote_Draw();\r
+}\r
+\r
+vector Sbar_AccuracyColor(float accuracy)\r
+{\r
+ vector rgb;\r
+ float yellow_accuracy = cvar("sbar_accuracy_yellow"); // value at which this function returns yellow\r
+ if(accuracy >= 100) {\r
+ rgb_x = 0;\r
+ rgb_y = 1;\r
+ }\r
+ else if(accuracy > yellow_accuracy) {\r
+ rgb_x = 1 - (accuracy-yellow_accuracy)/(100-yellow_accuracy); // red value between 1 -> 0\r
+ rgb_y = 1;\r
+ }\r
+ else {\r
+ rgb_x = 1;\r
+ rgb_y = accuracy/yellow_accuracy; // green value between 0 -> 1\r
+ }\r
+ rgb_z = 0;\r
+ return rgb;\r
+}\r
+\r
+void Sbar_DrawXNum (vector pos, float num, float digits, float showminusplus, float lettersize, vector rgb, float alpha, float dflags)\r
+{\r
+ float l;\r
+ string str, tmp, l_length, final_num;\r
+ float minus, plus;\r
+ vector vsize;\r
+\r
+ vsize_x = vsize_y = lettersize;\r
+ vsize_z = 0;\r
+\r
+ // showminusplus 1: always prefix with minus sign (useful in race distribution display)\r
+ // showminusplus 2: always prefix with plus sign (useful in race distribution display)\r
+ // showminusplus 3: prefix with minus sign if negative, plus sign if positive (useful in score distribution display)\r
+\r
+ if((showminusplus == 2 && num >= 0) || (num > 0 && showminusplus == 3))\r
+ {\r
+ plus = true;\r
+ } else\r
+ plus = false; \r
+\r
+ if(num < 0 || (num < 0 && showminusplus == 3) || (showminusplus == 1 && num <= 0))\r
+ {\r
+ minus = true;\r
+ num = -num;\r
+ } else\r
+ minus = false;\r
+\r
+ if(digits < 0)\r
+ {\r
+ tmp = ftos(num);\r
+ digits = -digits;\r
+ str = strcat(substring("0000000000", 0, digits - strlen(tmp)), tmp);\r
+ } else\r
+ str = ftos(num);\r
+\r
+ l = strlen(str);\r
+ l_length = ftos(l);\r
+\r
+ if(l > digits)\r
+ {\r
+ str = substring(str, l - digits, 999);\r
+ l = strlen(str);\r
+ }\r
+\r
+ if(minus)\r
+ final_num = "-";\r
+ else if(plus)\r
+ final_num = "+";\r
+\r
+ final_num = strcat(final_num, str);\r
+ drawstring(pos, final_num, vsize, rgb, alpha, dflags);\r
+}\r
+\r
+vector Sbar_NumColor (float x)\r
+{\r
+ if(x > 200) {\r
+ color_x = 0;\r
+ color_y = 1;\r
+ color_z = 0;\r
+ }\r
+ else if(x > 150) {\r
+ color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0\r
+ color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1\r
+ color_z = 0;\r
+ }\r
+ else if(x > 100) {\r
+ color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4\r
+ color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9\r
+ color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0\r
+ }\r
+ else if(x > 50) {\r
+ color_x = 1;\r
+ color_y = 1;\r
+ color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1\r
+ }\r
+ else if(x > 25) {\r
+ color_x = 1;\r
+ color_y = (x-25)*90/27/100; // green value between 0 -> 1\r
+ color_z = (x-25)*90/27/100 * 0.2; // blue value between 0 -> 0.2\r
+ }\r
+ else {\r
+ color_x = 1;\r
+ color_y = 0;\r
+ color_z = 0;\r
+ }\r
+ return color;\r
+}\r
+\r
+void Cmd_Sbar_SetFields(float argc);\r
+void Sbar_InitScores()\r
+{\r
+ float i, f;\r
+\r
+ ps_primary = ps_secondary = ts_primary = ts_secondary = -1;\r
+ for(i = 0; i < MAX_SCORE; ++i)\r
+ {\r
+ f = (scores_flags[i] & SFL_SORT_PRIO_MASK);\r
+ if(f == SFL_SORT_PRIO_PRIMARY)\r
+ ps_primary = i;\r
+ if(f == SFL_SORT_PRIO_SECONDARY)\r
+ ps_secondary = i;\r
+ }\r
+ if(ps_secondary == -1)\r
+ ps_secondary = ps_primary;\r
+\r
+ for(i = 0; i < MAX_TEAMSCORE; ++i)\r
+ {\r
+ f = (teamscores_flags[i] & SFL_SORT_PRIO_MASK);\r
+ if(f == SFL_SORT_PRIO_PRIMARY)\r
+ ts_primary = i;\r
+ if(f == SFL_SORT_PRIO_SECONDARY)\r
+ ts_secondary = i;\r
+ }\r
+ if(ts_secondary == -1)\r
+ ts_secondary = ts_primary;\r
+\r
+ Cmd_Sbar_SetFields(0);\r
+}\r
+\r
+void Sbar_UpdatePlayerPos(entity pl);\r
+float SetTeam(entity pl, float Team);\r
+//float lastpnum;\r
+void Sbar_UpdatePlayerTeams()\r
+{\r
+ float Team;\r
+ entity pl, tmp;\r
+ float num;\r
+\r
+ num = 0;\r
+ for(pl = players.sort_next; pl; pl = pl.sort_next)\r
+ {\r
+ num += 1;\r
+ Team = GetPlayerColor(pl.sv_entnum);\r
+ if(SetTeam(pl, Team))\r
+ {\r
+ tmp = pl.sort_prev;\r
+ Sbar_UpdatePlayerPos(pl);\r
+ if(tmp)\r
+ pl = tmp;\r
+ else\r
+ pl = players.sort_next;\r
+ }\r
+ }\r
+ /*\r
+ if(num != lastpnum)\r
+ print(strcat("PNUM: ", ftos(num), "\n"));\r
+ lastpnum = num;\r
+ */\r
+}\r
+\r
+float Sbar_ComparePlayerScores(entity left, entity right)\r
+{\r
+ float vl, vr;\r
+ vl = GetPlayerColor(left.sv_entnum);\r
+ vr = GetPlayerColor(right.sv_entnum);\r
+\r
+ if(!left.gotscores)\r
+ vl = COLOR_SPECTATOR;\r
+ if(!right.gotscores)\r
+ vr = COLOR_SPECTATOR;\r
+\r
+ if(vl > vr)\r
+ return true;\r
+ if(vl < vr)\r
+ return false;\r
+\r
+ if(vl == COLOR_SPECTATOR)\r
+ {\r
+ // FIRST the one with scores (spectators), THEN the ones without (downloaders)\r
+ // no other sorting\r
+ if(!left.gotscores && right.gotscores)\r
+ return true;\r
+ return false;\r
+ }\r
+\r
+ vl = left.scores[ps_primary];\r
+ vr = right.scores[ps_primary];\r
+ if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)\r
+ {\r
+ if(vl == 0 && vr != 0)\r
+ return 1;\r
+ if(vl != 0 && vr == 0)\r
+ return 0;\r
+ }\r
+ if(vl > vr)\r
+ return IS_INCREASING(scores_flags[ps_primary]);\r
+ if(vl < vr)\r
+ return IS_DECREASING(scores_flags[ps_primary]);\r
+\r
+ vl = left.scores[ps_secondary];\r
+ vr = right.scores[ps_secondary];\r
+ if(scores_flags[ps_secondary] & SFL_ZERO_IS_WORST)\r
+ {\r
+ if(vl == 0 && vr != 0)\r
+ return 1;\r
+ if(vl != 0 && vr == 0)\r
+ return 0;\r
+ }\r
+ if(vl > vr)\r
+ return IS_INCREASING(scores_flags[ps_secondary]);\r
+ if(vl < vr)\r
+ return IS_DECREASING(scores_flags[ps_secondary]);\r
+\r
+ return false;\r
+}\r
+\r
+void Sbar_UpdatePlayerPos(entity player)\r
+{\r
+ for(other = player.sort_next; other && Sbar_ComparePlayerScores(player, other); other = player.sort_next)\r
+ {\r
+ SORT_SWAP(player, other);\r
+ }\r
+ for(other = player.sort_prev; other != players && Sbar_ComparePlayerScores(other, player); other = player.sort_prev)\r
+ {\r
+ SORT_SWAP(other, player);\r
+ }\r
+}\r
+\r
+float Sbar_CompareTeamScores(entity left, entity right)\r
+{\r
+ float vl, vr;\r
+\r
+ if(left.team == COLOR_SPECTATOR)\r
+ return 1;\r
+ if(right.team == COLOR_SPECTATOR)\r
+ return 0;\r
+\r
+ vl = left.teamscores[ts_primary];\r
+ vr = right.teamscores[ts_primary];\r
+ if(vl > vr)\r
+ return IS_INCREASING(teamscores_flags[ts_primary]);\r
+ if(vl < vr)\r
+ return IS_DECREASING(teamscores_flags[ts_primary]);\r
+\r
+ vl = left.teamscores[ts_secondary];\r
+ vr = right.teamscores[ts_secondary];\r
+ if(vl > vr)\r
+ return IS_INCREASING(teamscores_flags[ts_secondary]);\r
+ if(vl < vr)\r
+ return IS_DECREASING(teamscores_flags[ts_secondary]);\r
+\r
+ return false;\r
+}\r
+\r
+void Sbar_UpdateTeamPos(entity Team)\r
+{\r
+ for(other = Team.sort_next; other && Sbar_CompareTeamScores(Team, other); other = Team.sort_next)\r
+ {\r
+ SORT_SWAP(Team, other);\r
+ }\r
+ for(other = Team.sort_prev; other != teams && Sbar_CompareTeamScores(other, Team); other = Team.sort_prev)\r
+ {\r
+ SORT_SWAP(other, Team);\r
+ }\r
+}\r
+\r
+void Cmd_Sbar_Help(float argc)\r
+{\r
+ print("You can modify the scoreboard using the ^2sbar_columns_set command.\n");\r
+ print("^3|---------------------------------------------------------------|\n");\r
+ print("Usage:\n");\r
+ print("^2sbar_columns_set default\n");\r
+ print("^2sbar_columns_set ^7filed1 field2 ...\n");\r
+ print("The following field names are recognized (case insensitive):\n");\r
+ print("You can use a ^3|^7 to start the right-aligned fields.\n\n");\r
+\r
+ print("^3name^7 or ^3nick^7 Name of a player\n");\r
+ print("^3ping^7 Ping time\n");\r
+ print("^3pl^7 Packet loss\n");\r
+ print("^3kills^7 Number of kills\n");\r
+ print("^3deaths^7 Number of deaths\n");\r
+ print("^3suicides^7 Number of suicides\n");\r
+ print("^3frags^7 kills - suicides\n");\r
+ print("^3kd^7 The kill-death ratio\n");\r
+ print("^3caps^7 How often a flag (CTF) or a key (KeyHunt) was captured\n");\r
+ print("^3pickups^7 How often a flag (CTF) or a key (KeyHunt) was picked up\n");\r
+ print("^3fckills^7 Number of flag carrier kills\n");\r
+ print("^3returns^7 Number of flag returns\n");\r
+ print("^3drops^7 Number of flag drops\n");\r
+ print("^3lives^7 Number of lives (LMS)\n");\r
+ print("^3rank^7 Player rank\n");\r
+ print("^3pushes^7 Number of players pushed into void\n");\r
+ print("^3destroyed^7 Number of keys destroyed by pushing them into void\n");\r
+ print("^3kckills^7 Number of keys carrier kills\n");\r
+ print("^3losses^7 Number of times a key was lost\n");\r
+ print("^3laps^7 Number of laps finished (race/cts)\n");\r
+ print("^3time^7 Total time raced (race/cts)\n");\r
+ print("^3fastest^7 Time of fastest lap (race/cts)\n");\r
+ print("^3ticks^7 Number of ticks (DOM)\n");\r
+ print("^3takes^7 Number of domination points taken (DOM)\n");\r
+ print("^3score^7 Total score\n\n");\r
+\r
+ print("Before a field you can put a + or - sign, then a comma separated list\n");\r
+ print("of game types, then a slash, to make the field show up only in these\n");\r
+ print("or in all but these game types. You can also specify 'all' as a\n");\r
+ print("field to show all fields available for the current game mode.\n\n");\r
+ \r
+ print("The special game type names 'teams' and 'noteams' can be used to\n");\r
+ print("include/exclude ALL teams/noteams game modes.\n\n");\r
+\r
+ print("Example: sbar_columns_set name ping pl | +ctf/field3 -dm/field4\n");\r
+ print("will display name, ping and pl aligned to the left, and the fields\n");\r
+ print("right of the vertical bar aligned to the right.\n");\r
+ print("'field3' will only be shown in CTF, and 'field4' will be shown in all\n");\r
+ print("other gamemodes except DM.\n");\r
+}\r
+\r
+string Sbar_DefaultColumnLayout()\r
+{\r
+ return strcat( // fteqcc sucks\r
+ "ping pl name | ",\r
+ "-teams,race,lms/kills -teams,lms/deaths -teams,lms,race/suicides -race,dm,tdm/frags ", // tdm already has this in "score"\r
+ "+ctf/caps +ctf/pickups +ctf/fckills +ctf/returns ",\r
+ "+lms/lives +lms/rank ",\r
+ "+kh/caps +kh/pushes +kh/destroyed ",\r
+ "?+race/laps ?+race/time ?+race/fastest ",\r
+ "-lms,race");\r
+}\r
+\r
+void Cmd_Sbar_SetFields(float argc)\r
+{\r
+ float i, j, slash;\r
+ string str, pattern;\r
+ float have_name, have_primary, have_secondary, have_separator;\r
+ float missing;\r
+\r
+ // TODO: re enable with gametype dependant cvars?\r
+ if(argc < 2) // no arguments provided\r
+ argc = tokenizebyseparator(strcat("x ", cvar_string("sbar_columns")), " ");\r
+\r
+ if(argc < 2)\r
+ argc = tokenizebyseparator(strcat("x ", Sbar_DefaultColumnLayout()), " ");\r
+\r
+ if(argc == 2)\r
+ {\r
+ if(argv(1) == "default")\r
+ argc = tokenizebyseparator(strcat("x ", Sbar_DefaultColumnLayout()), " ");\r
+ else if(argv(1) == "all")\r
+ {\r
+ string s;\r
+ s = "ping pl color name |";\r
+ for(i = 0; i < MAX_SCORE; ++i)\r
+ {\r
+ if(i != ps_primary)\r
+ if(i != ps_secondary)\r
+ if(scores_label[i] != "")\r
+ s = strcat(s, " ", scores_label[i]);\r
+ }\r
+ if(ps_secondary != ps_primary)\r
+ s = strcat(s, " ", scores_label[ps_secondary]);\r
+ s = strcat(s, " ", scores_label[ps_primary]);\r
+ argc = tokenizebyseparator(strcat("x ", s), " ");\r
+ }\r
+ }\r
+\r
+\r
+ sbar_num_fields = 0;\r
+\r
+ drawfont = sbar_font;\r
+\r
+ for(i = 0; i < argc - 1; ++i)\r
+ {\r
+ float nocomplain;\r
+ str = argv(i+1);\r
+\r
+ nocomplain = FALSE;\r
+ if(substring(str, 0, 1) == "?")\r
+ {\r
+ nocomplain = TRUE;\r
+ str = substring(str, 1, strlen(str) - 1);\r
+ }\r
+\r
+ slash = strstrofs(str, "/", 0);\r
+ if(slash >= 0)\r
+ {\r
+ pattern = substring(str, 0, slash);\r
+ str = substring(str, slash + 1, strlen(str) - (slash + 1));\r
+\r
+ if not(isGametypeInFilter(gametype, teamplay, pattern))\r
+ continue;\r
+ }\r
+\r
+ strunzone(sbar_title[sbar_num_fields]);\r
+ sbar_title[sbar_num_fields] = strzone(str);\r
+ sbar_size[sbar_num_fields] = stringwidth(str, FALSE, sbar_fontsize);\r
+ str = strtolower(str);\r
+\r
+ if(str == "ping") {\r
+ sbar_field[sbar_num_fields] = SP_PING;\r
+ } else if(str == "pl") {\r
+ sbar_field[sbar_num_fields] = SP_PL;\r
+ } else if(str == "kd" || str == "kdr" || str == "kdratio" || str == "k/d") {\r
+ sbar_field[sbar_num_fields] = SP_KDRATIO;\r
+ } else if(str == "name" || str == "nick") {\r
+ sbar_field[sbar_num_fields] = SP_NAME;\r
+ have_name = 1;\r
+ } else if(str == "|") {\r
+ sbar_field[sbar_num_fields] = SP_SEPARATOR;\r
+ have_separator = 1;\r
+ } else {\r
+ if(gametype == GAME_RPG)\r
+ return;\r
+\r
+ for(j = 0; j < MAX_SCORE; ++j)\r
+ if(str == strtolower(scores_label[j]))\r
+ goto found; // sorry, but otherwise fteqcc -O3 miscompiles this and warns about "unreachable code"\r
+:notfound\r
+ if(str == "frags")\r
+ j = SP_FRAGS;\r
+ else\r
+ {\r
+ if not(nocomplain)\r
+ print(strcat("^1Error:^7 Unknown score field: '", str, "'\n"));\r
+ continue;\r
+ }\r
+:found\r
+ sbar_field[sbar_num_fields] = j;\r
+ if(j == ps_primary)\r
+ have_primary = 1;\r
+ if(j == ps_secondary)\r
+ have_secondary = 1;\r
+ }\r
+ ++sbar_num_fields;\r
+ if(sbar_num_fields >= MAX_SBAR_FIELDS)\r
+ break;\r
+ }\r
+\r
+ if(scores_flags[ps_primary] & SFL_ALLOW_HIDE)\r
+ have_primary = 1;\r
+ if(scores_flags[ps_secondary] & SFL_ALLOW_HIDE)\r
+ have_secondary = 1;\r
+ if(ps_primary == ps_secondary)\r
+ have_secondary = 1;\r
+ missing = (!have_primary) + (!have_secondary) + (!have_separator) + (!have_name);\r
+\r
+ if(sbar_num_fields+missing < MAX_SBAR_FIELDS)\r
+ {\r
+ if(!have_name)\r
+ {\r
+ strunzone(sbar_title[sbar_num_fields]);\r
+ for(i = sbar_num_fields; i > 0; --i)\r
+ {\r
+ sbar_title[i] = sbar_title[i-1];\r
+ sbar_size[i] = sbar_size[i-1];\r
+ sbar_field[i] = sbar_field[i-1];\r
+ }\r
+ sbar_title[0] = strzone("name");\r
+ sbar_field[0] = SP_NAME;\r
+ ++sbar_num_fields;\r
+ print("fixed missing field 'name'\n");\r
+\r
+ if(!have_separator)\r
+ {\r
+ strunzone(sbar_title[sbar_num_fields]);\r
+ for(i = sbar_num_fields; i > 1; --i)\r
+ {\r
+ sbar_title[i] = sbar_title[i-1];\r
+ sbar_size[i] = sbar_size[i-1];\r
+ sbar_field[i] = sbar_field[i-1];\r
+ }\r
+ sbar_title[1] = strzone("|");\r
+ sbar_field[1] = SP_SEPARATOR;\r
+ sbar_size[1] = stringwidth("|", FALSE, sbar_fontsize);\r
+ ++sbar_num_fields;\r
+ print("fixed missing field '|'\n");\r
+ }\r
+ }\r
+ else if(!have_separator)\r
+ {\r
+ strunzone(sbar_title[sbar_num_fields]);\r
+ sbar_title[sbar_num_fields] = strzone("|");\r
+ sbar_size[sbar_num_fields] = stringwidth("|", FALSE, sbar_fontsize);\r
+ sbar_field[sbar_num_fields] = SP_SEPARATOR;\r
+ ++sbar_num_fields;\r
+ print("fixed missing field '|'\n");\r
+ }\r
+ if(!have_secondary)\r
+ {\r
+ strunzone(sbar_title[sbar_num_fields]);\r
+ sbar_title[sbar_num_fields] = strzone(scores_label[ps_secondary]);\r
+ sbar_size[sbar_num_fields] = stringwidth(sbar_title[sbar_num_fields], FALSE, sbar_fontsize);\r
+ sbar_field[sbar_num_fields] = ps_secondary;\r
+ ++sbar_num_fields;\r
+ print("fixed missing field '", scores_label[ps_secondary], "'\n");\r
+ }\r
+ if(!have_primary)\r
+ {\r
+ strunzone(sbar_title[sbar_num_fields]);\r
+ sbar_title[sbar_num_fields] = strzone(scores_label[ps_primary]);\r
+ sbar_size[sbar_num_fields] = stringwidth(sbar_title[sbar_num_fields], FALSE, sbar_fontsize);\r
+ sbar_field[sbar_num_fields] = ps_primary;\r
+ ++sbar_num_fields;\r
+ print("fixed missing field '", scores_label[ps_primary], "'\n");\r
+ }\r
+ }\r
+\r
+ sbar_field[sbar_num_fields] = SP_END;\r
+}\r
+\r
+// MOVEUP::\r
+vector sbar_field_rgb;\r
+string sbar_field_icon0;\r
+string sbar_field_icon1;\r
+string sbar_field_icon2;\r
+vector sbar_field_icon0_rgb;\r
+vector sbar_field_icon1_rgb;\r
+vector sbar_field_icon2_rgb;\r
+float sbar_field_icon0_alpha;\r
+float sbar_field_icon1_alpha;\r
+float sbar_field_icon2_alpha;\r
+string Sbar_GetField(entity pl, float field)\r
+{\r
+ float tmp, num, denom, f;\r
+ string str;\r
+ sbar_field_rgb = '1 1 1';\r
+ sbar_field_icon0 = "";\r
+ sbar_field_icon1 = "";\r
+ sbar_field_icon2 = "";\r
+ sbar_field_icon0_rgb = '1 1 1';\r
+ sbar_field_icon1_rgb = '1 1 1';\r
+ sbar_field_icon2_rgb = '1 1 1';\r
+ sbar_field_icon0_alpha = 1;\r
+ sbar_field_icon1_alpha = 1;\r
+ sbar_field_icon2_alpha = 1;\r
+ switch(field)\r
+ {\r
+ case SP_PING:\r
+ if not(pl.gotscores)\r
+ return "\x8D\x8D\x8D"; // >>> sign\r
+ //str = getplayerkey(pl.sv_entnum, "ping");\r
+ f = pl.ping;\r
+ if(f == 0)\r
+ return "N/A";\r
+ tmp = max(0, min(220, f-80)) / 220;\r
+ sbar_field_rgb = '1 1 1' - '0 1 1'*tmp;\r
+ return ftos(f);\r
+\r
+ case SP_PL:\r
+ if not(pl.gotscores)\r
+ return "N/A";\r
+ f = pl.ping_packetloss;\r
+ tmp = pl.ping_movementloss;\r
+ if(f == 0 && tmp == 0)\r
+ return "";\r
+ str = ftos(ceil(f * 100));\r
+ if(tmp != 0)\r
+ str = strcat(str, "~", ftos(ceil(tmp * 100)));\r
+ tmp = bound(0, f / 0.2 + tmp / 0.04, 1); // 20% is REALLY BAD pl\r
+ sbar_field_rgb = '1 0.5 0.5' - '0 0.5 0.5'*tmp;\r
+ return str;\r
+\r
+ case SP_NAME:\r
+ if(ready_waiting && pl.ready)\r
+ {\r
+ sbar_field_icon0 = "gfx/sb_player_ready";\r
+ }\r
+ else if(!teamplay)\r
+ {\r
+ f = stof(getplayerkey(pl.sv_entnum, "colors"));\r
+ {\r
+ sbar_field_icon0 = "gfx/sb_playercolor_base";\r
+ sbar_field_icon1 = "gfx/sb_playercolor_shirt";\r
+ sbar_field_icon1_rgb = colormapPaletteColor(floor(f / 16), 0);\r
+ sbar_field_icon2 = "gfx/sb_playercolor_pants";\r
+ sbar_field_icon2_rgb = colormapPaletteColor(mod(f, 16), 1);\r
+ }\r
+ }\r
+ return GetPlayerName(pl.sv_entnum);\r
+\r
+ case SP_FRAGS:\r
+ f = pl.(scores[SP_KILLS]);\r
+ f -= pl.(scores[SP_SUICIDES]);\r
+ return ftos(f);\r
+\r
+ case SP_KDRATIO:\r
+ num = pl.(scores[SP_KILLS]);\r
+ denom = pl.(scores[SP_DEATHS]);\r
+\r
+ if(denom == 0) {\r
+ sbar_field_rgb = '0 1 0';\r
+ str = ftos(num);\r
+ } else if(num <= 0) {\r
+ sbar_field_rgb = '1 0 0';\r
+ str = ftos(num/denom);\r
+ } else\r
+ str = ftos(num/denom);\r
+\r
+ tmp = strstrofs(str, ".", 0);\r
+ if(tmp > 0)\r
+ str = substring(str, 0, tmp+2);\r
+ return str;\r
+\r
+ default:\r
+ tmp = pl.(scores[field]);\r
+ f = scores_flags[field];\r
+ if(field == ps_primary)\r
+ sbar_field_rgb = '1 1 0';\r
+ else if(field == ps_secondary)\r
+ sbar_field_rgb = '0 1 1';\r
+ else\r
+ sbar_field_rgb = '1 1 1';\r
+ return ScoreString(f, tmp);\r
+ }\r
+ //return "error";\r
+}\r
+\r
+string Sbar_GetStomachField(entity pl, float field)\r
+{\r
+ switch(field)\r
+ {\r
+ case ST_HIGHLIGHT:\r
+ return ""; // the returned value is not used, we only need the field\r
+\r
+ case ST_NAME:\r
+ return GetPlayerName(pl.sv_entnum);\r
+\r
+ case ST_HEALTH:\r
+ return ftos(pl.plhealth);\r
+\r
+ default:\r
+ return "N/A";\r
+ }\r
+ //return "error";\r
+}\r
+\r
+string Sbar_GetStomachFieldPred(entity pl, float field)\r
+{\r
+ switch(field)\r
+ {\r
+ case STP_NAME:\r
+ return GetPlayerName(pl.sv_entnum);\r
+ default:\r
+ return "N/A";\r
+ }\r
+ //return "error";\r
+}\r
+\r
+float xmin, xmax, ymin, ymax, sbwidth;\r
+float sbar_fixscoreboardcolumnwidth_len;\r
+float sbar_fixscoreboardcolumnwidth_iconlen;\r
+float sbar_fixscoreboardcolumnwidth_marginlen;\r
+\r
+float stringwidth_colors(string s, vector theSize)\r
+{\r
+ return stringwidth(s, TRUE, theSize);\r
+}\r
+\r
+float stringwidth_nocolors(string s, vector theSize)\r
+{\r
+ return stringwidth(s, FALSE, theSize);\r
+}\r
+\r
+string Sbar_FixScoreboardColumnWidth(float i, string str)\r
+{\r
+ float field, f;\r
+ vector sz;\r
+ field = sbar_field[i];\r
+\r
+ sbar_fixscoreboardcolumnwidth_iconlen = 0;\r
+\r
+ if(sbar_field_icon0 != "")\r
+ {\r
+ sz = drawgetimagesize(sbar_field_icon0);\r
+ f = sz_x / sz_y;\r
+ if(sbar_fixscoreboardcolumnwidth_iconlen < f)\r
+ sbar_fixscoreboardcolumnwidth_iconlen = f;\r
+ }\r
+\r
+ if(sbar_field_icon1 != "")\r
+ {\r
+ sz = drawgetimagesize(sbar_field_icon1);\r
+ f = sz_x / sz_y;\r
+ if(sbar_fixscoreboardcolumnwidth_iconlen < f)\r
+ sbar_fixscoreboardcolumnwidth_iconlen = f;\r
+ }\r
+\r
+ if(sbar_field_icon2 != "")\r
+ {\r
+ sz = drawgetimagesize(sbar_field_icon2);\r
+ f = sz_x / sz_y;\r
+ if(sbar_fixscoreboardcolumnwidth_iconlen < f)\r
+ sbar_fixscoreboardcolumnwidth_iconlen = f;\r
+ }\r
+\r
+ sbar_fixscoreboardcolumnwidth_iconlen *= sbar_fontsize_y / sbar_fontsize_x; // fix icon aspect\r
+\r
+ if(sbar_fixscoreboardcolumnwidth_iconlen != 0)\r
+ sbar_fixscoreboardcolumnwidth_marginlen = stringwidth(" ", FALSE, sbar_fontsize);\r
+ else\r
+ sbar_fixscoreboardcolumnwidth_marginlen = 0;\r
+\r
+ if(field == SP_NAME) // name gets all remaining space\r
+ {\r
+ float namesize, j;\r
+ namesize = sbwidth;// / sbar_fontsize_x;\r
+ for(j = 0; j < sbar_num_fields; ++j)\r
+ if(j != i)\r
+ if (sbar_field[i] != SP_SEPARATOR)\r
+ namesize -= sbar_size[j] + 1;\r
+ namesize += 1;\r
+ sbar_size[i] = namesize;\r
+ \r
+ if (sbar_fixscoreboardcolumnwidth_iconlen != 0)\r
+ namesize -= sbar_fixscoreboardcolumnwidth_marginlen + sbar_fixscoreboardcolumnwidth_iconlen;\r
+ str = textShortenToWidth(str, namesize, sbar_fontsize, stringwidth_colors);\r
+ sbar_fixscoreboardcolumnwidth_len = stringwidth(str, TRUE, sbar_fontsize);\r
+ }\r
+ else\r
+ sbar_fixscoreboardcolumnwidth_len = stringwidth(str, FALSE, sbar_fontsize);\r
+ \r
+ f = sbar_fixscoreboardcolumnwidth_len + sbar_fixscoreboardcolumnwidth_marginlen + sbar_fixscoreboardcolumnwidth_iconlen;\r
+ if(sbar_size[i] < f)\r
+ sbar_size[i] = f;\r
+\r
+ return str;\r
+}\r
+\r
+void Sbar_PrintScoreboardItem(vector pos, entity pl, float is_self, float pl_number)\r
+{\r
+ vector tmp, rgb;\r
+ rgb = GetTeamRGB(pl.team);\r
+ string str;\r
+ float i, field;\r
+ float is_spec;\r
+ is_spec = (GetPlayerColor(pl.sv_entnum) == COLOR_SPECTATOR);\r
+ \r
+ if((rgb == '1 1 1') && (!is_spec))\r
+ rgb = stov(cvar_string("sbar_color_bg")) + '0.5 0.5 0.5';\r
+\r
+ // Layout:\r
+ tmp_x = sbwidth;\r
+ tmp_y = sbar_fontsize_y * 1.25;\r
+ tmp_z = 0;\r
+\r
+ // alternated rows highlighting\r
+ if(is_self)\r
+ drawfill(pos - '1 1 0', tmp + '2 0 0', rgb, sbar_scoreboard_highlight_alpha_self, DRAWFLAG_NORMAL);\r
+ else if((sbar_scoreboard_highlight) && (!mod(pl_number,2)))\r
+ drawfill(pos - '1 1 0', tmp + '2 0 0', rgb, sbar_scoreboard_highlight_alpha, DRAWFLAG_NORMAL);\r
+\r
+ tmp_y = 0;\r
+\r
+ for(i = 0; i < sbar_num_fields; ++i)\r
+ {\r
+ field = sbar_field[i];\r
+ if(field == SP_SEPARATOR)\r
+ break;\r
+\r
+ if(is_spec && field != SP_NAME && field != SP_PING) {\r
+ pos_x += sbar_size[i] + sbar_fontsize_x;\r
+ continue;\r
+ }\r
+ str = Sbar_GetField(pl, field);\r
+ str = Sbar_FixScoreboardColumnWidth(i, str);\r
+\r
+ pos_x += sbar_size[i] + sbar_fontsize_x;\r
+\r
+ if(field == SP_NAME) {\r
+ tmp_x = sbar_size[i] - sbar_fontsize_x*sbar_fixscoreboardcolumnwidth_iconlen - sbar_fixscoreboardcolumnwidth_marginlen + sbar_fontsize_x;\r
+ if (is_self)\r
+ drawcolorcodedstring(pos - tmp, str, sbar_fontsize, sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);\r
+ else\r
+ drawcolorcodedstring(pos - tmp, str, sbar_fontsize, sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);\r
+ } else {\r
+ tmp_x = sbar_fixscoreboardcolumnwidth_len + sbar_fontsize_x;\r
+ if (is_self)\r
+ drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);\r
+ else\r
+ drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);\r
+ }\r
+\r
+ tmp_x = sbar_size[i] + sbar_fontsize_x;\r
+ if(sbar_field_icon0 != "")\r
+ if (is_self)\r
+ 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
+ else\r
+ 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
+ if(sbar_field_icon1 != "")\r
+ if (is_self)\r
+ 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
+ else\r
+ 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
+ if(sbar_field_icon2 != "")\r
+ if (is_self)\r
+ 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
+ else\r
+ 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
+ }\r
+\r
+ if(sbar_field[i] == SP_SEPARATOR)\r
+ {\r
+ pos_x = xmax;\r
+ for(i = sbar_num_fields-1; i > 0; --i)\r
+ {\r
+ field = sbar_field[i];\r
+ if(field == SP_SEPARATOR)\r
+ break;\r
+\r
+ if(is_spec && field != SP_NAME && field != SP_PING) {\r
+ pos_x -= sbar_size[i] + sbar_fontsize_x;\r
+ continue;\r
+ }\r
+\r
+ str = Sbar_GetField(pl, field);\r
+ str = Sbar_FixScoreboardColumnWidth(i, str);\r
+\r
+ if(field == SP_NAME) {\r
+ tmp_x = sbar_fixscoreboardcolumnwidth_len; // left or right aligned? let's put it right...\r
+ if(is_self)\r
+ drawcolorcodedstring(pos - tmp, str, sbar_fontsize, sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);\r
+ else\r
+ drawcolorcodedstring(pos - tmp, str, sbar_fontsize, sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);\r
+ } else {\r
+ tmp_x = sbar_fixscoreboardcolumnwidth_len;\r
+ if(is_self)\r
+ drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);\r
+ else\r
+ drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);\r
+ }\r
+\r
+ tmp_x = sbar_size[i];\r
+ if(sbar_field_icon0 != "")\r
+ if (is_self)\r
+ 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
+ else\r
+ 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
+ if(sbar_field_icon1 != "")\r
+ if (is_self)\r
+ 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
+ else\r
+ 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
+ if(sbar_field_icon2 != "")\r
+ if (is_self)\r
+ 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
+ else\r
+ 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
+ pos_x -= sbar_size[i] + sbar_fontsize_x;\r
+ }\r
+ }\r
+}\r
+\r
+float fieldcounter;\r
+void Sbar_PrintStomachboardItem(vector pos, entity pl)\r
+{\r
+ // lists all players in the stomach\r
+\r
+ string str;\r
+ float f, field, field_number;\r
+ vector hl_color;\r
+ field_number = 3; // the number of components each row has\r
+\r
+ for(fieldcounter = 1; fieldcounter <= field_number; ++fieldcounter)\r
+ {\r
+ field = -fieldcounter;\r
+ str = Sbar_GetStomachField(pl, field);\r
+\r
+ // row highlighting\r
+ if(field == ST_HIGHLIGHT)\r
+ {\r
+ if(getstati(STAT_VORE_EATEN))\r
+ {\r
+ 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
+ hl_color = stov(cvar_string("sbar_stomachboard_color2"));\r
+ else\r
+ hl_color = stov(cvar_string("sbar_stomachboard_color3"));\r
+ }\r
+ else\r
+ hl_color = stov(cvar_string("sbar_stomachboard_color1"));\r
+ drawfill(pos - '0 0 0', '193 11 0', hl_color, cvar("sbar_stomachboard_highlight_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ }\r
+\r
+ if(field == ST_NAME) {\r
+ f = stof(getplayerkey(pl.sv_entnum, "colors"));\r
+ drawpic(pos, "gfx/sb_playercolor_base", '22 11 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawpic(pos, "gfx/sb_playercolor_shirt", '22 11 0', colormapPaletteColor(floor(f / 16), 0), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawpic(pos, "gfx/sb_playercolor_pants", '22 11 0', colormapPaletteColor(mod(f, 16), 1), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+ pos_x += 24;\r
+ drawcolorcodedstring(pos, textShortenToWidth(str, 138, '11 11 0', stringwidth_colors), '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ }\r
+\r
+ if(field == ST_HEALTH) {\r
+ pos_x += 138;\r
+ if(pl.sv_entnum == player_localentnum - 1 || (spectatee_status && pl.sv_entnum == spectatee_status - 1))\r
+ drawcolorcodedstring(pos, "self", '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ else\r
+ {\r
+ drawpic(pos, "gfx/hud/sb_health", '11 11 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+ pos_x += 9;\r
+ drawcolorcodedstring(pos, str, '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+float fieldcounter2;\r
+void Sbar_PrintStomachboardItemPred(vector pos, entity pl)\r
+{\r
+ // shows the name of our predator\r
+\r
+ string str;\r
+ float f, field, field_number;\r
+ field_number = 1; // the number of components each row has\r
+\r
+ for(fieldcounter2 = 1; fieldcounter2 <= field_number; ++fieldcounter2)\r
+ {\r
+ field = -fieldcounter2;\r
+ str = Sbar_GetStomachFieldPred(pl, field);\r
+\r
+ if(field == STP_NAME) {\r
+ f = stof(getplayerkey(pl.sv_entnum, "colors"));\r
+ drawpic(pos, "gfx/sb_playercolor_base", '22 11 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawpic(pos, "gfx/sb_playercolor_shirt", '22 11 0', colormapPaletteColor(floor(f / 16), 0), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawpic(pos, "gfx/sb_playercolor_pants", '22 11 0', colormapPaletteColor(mod(f, 16), 1), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+ pos_x += 24;\r
+ drawcolorcodedstring(pos, textShortenToWidth(str, 122, '11 11 0', stringwidth_colors), '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ }\r
+ }\r
+}\r
+\r
+/*\r
+ * Sbar_Scoreboard_MakeTable\r
+ *\r
+ * Makes a table for a team (for all playing players in DM) and fills it\r
+ */\r
+\r
+vector Sbar_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_size)\r
+{\r
+ float body_table_height, i;\r
+ vector tmp, column_dim;\r
+ entity pl;\r
+\r
+ body_table_height = 1.25 * sbar_fontsize_y * max(1, tm.team_size); // no player? show 1 empty line\r
+\r
+ pos -= '1 1 0';\r
+\r
+ tmp_x = sbwidth + 2;\r
+ tmp_y = 1.25 * sbar_fontsize_y;\r
+\r
+ // rounded header\r
+ drawpic(pos, "gfx/hud/sb_scoreboard_tableheader", tmp, (rgb * sbar_color_bg_team) + '0.5 0.5 0.5', sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL);\r
+\r
+ // table border\r
+ tmp_y += sbar_border_thickness;\r
+ tmp_y += body_table_height;\r
+ drawborderlines(sbar_border_thickness, pos, tmp, '0 0 0', sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL); // more transparency for the scoreboard\r
+\r
+ // separator header/table\r
+ pos_y += 1.25 * sbar_fontsize_y;\r
+ tmp_y = sbar_border_thickness;\r
+ drawfill(pos, tmp, '0 0 0', sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL);\r
+\r
+ pos_y += sbar_border_thickness;\r
+\r
+ // table background\r
+ tmp_y = body_table_height;\r
+ drawpic_tiled(pos, "gfx/hud/sb_scoreboard_bg", bg_size, tmp, rgb * sbar_color_bg_team, sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL);\r
+\r
+ // anyway, apply some color\r
+ //drawfill(pos, tmp + '2 0 0', rgb, 0.1, DRAWFLAG_NORMAL);\r
+\r
+ // go back to the top to make alternated columns highlighting and to print the strings\r
+ pos_y -= 1.25 * sbar_fontsize_y;\r
+ pos_y -= sbar_border_thickness;\r
+\r
+ pos += '1 1 0';\r
+\r
+ if (sbar_scoreboard_highlight)\r
+ {\r
+ column_dim_y = 1.25 * sbar_fontsize_y; // header\r
+ column_dim_y += sbar_border_thickness;\r
+ column_dim_y += body_table_height;\r
+ }\r
+\r
+ // print the strings of the columns headers and draw the columns\r
+ for(i = 0; i < sbar_num_fields; ++i)\r
+ {\r
+ if(sbar_field[i] == SP_SEPARATOR)\r
+ break;\r
+ column_dim_x = sbar_size[i] + sbar_fontsize_x;\r
+ if (sbar_scoreboard_highlight)\r
+ {\r
+ if (mod(i,2))\r
+ 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
+ }\r
+ drawstring(pos, sbar_title[i], sbar_fontsize, rgb * 1.5, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
+ pos_x += column_dim_x;\r
+ }\r
+ if(sbar_field[i] == SP_SEPARATOR)\r
+ {\r
+ pos_x = xmax;\r
+ tmp_y = 0;\r
+ for(i = sbar_num_fields-1; i > 0; --i)\r
+ {\r
+ if(sbar_field[i] == SP_SEPARATOR)\r
+ break;\r
+\r
+ pos_x -= sbar_size[i];\r
+\r
+ if (sbar_scoreboard_highlight)\r
+ {\r
+ if (!mod(i,2))\r
+ {\r
+ if (i == sbar_num_fields-1)\r
+ column_dim_x = sbar_size[i] + sbar_fontsize_x / 2 + 1;\r
+ else\r
+ column_dim_x = sbar_size[i] + sbar_fontsize_x;\r
+ 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
+ }\r
+ }\r
+\r
+ tmp_x = stringwidth(sbar_title[i], FALSE, sbar_fontsize);\r
+ tmp_x = sbar_size[i] - tmp_x;\r
+ drawstring(pos + tmp, sbar_title[i], sbar_fontsize, rgb * 1.5, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
+ pos_x -= sbar_fontsize_x;\r
+ }\r
+ }\r
+ \r
+ pos_x = xmin;\r
+ pos_y += 1.25 * sbar_fontsize_y; // skip the header\r
+ pos_y += sbar_border_thickness;\r
+\r
+ // fill the table and draw the rows\r
+ i = 0;\r
+ if (teamplay)\r
+ for(pl = players.sort_next; pl; pl = pl.sort_next)\r
+ {\r
+ if(pl.team != tm.team)\r
+ continue;\r
+ Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), i);\r
+ pos_y += 1.25 * sbar_fontsize_y;\r
+ ++i;\r
+ }\r
+ else\r
+ for(pl = players.sort_next; pl; pl = pl.sort_next)\r
+ {\r
+ if(pl.team == COLOR_SPECTATOR)\r
+ continue;\r
+ Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), i);\r
+ pos_y += 1.25 * sbar_fontsize_y;\r
+ ++i;\r
+ }\r
+ \r
+ if (i == 0)\r
+ pos_y += 1.25 * sbar_fontsize_y; // move to the end of the table\r
+ pos_y += 1.25 * sbar_fontsize_y; // move empty row (out of the table)\r
+\r
+ return pos;\r
+}\r
+\r
+float Sbar_WouldDrawScoreboard() {\r
+ if (sb_showscores)\r
+ return 1;\r
+ else if (intermission == 1)\r
+ return 1;\r
+ else if (intermission == 2)\r
+ return 1;\r
+ else if (getstati(STAT_HEALTH) <= 0 && cvar("cl_deathscoreboard"))\r
+ return 1;\r
+ else if(sb_showscores_force)\r
+ return 1;\r
+ return 0;\r
+}\r
+\r
+float average_accuracy;\r
+vector Sbar_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)\r
+{\r
+ float i;\r
+ float weapon_hit, weapon_damage, weapon_stats;\r
+ float fontsize = 40 * 1/3;\r
+ float xsave;\r
+ float weapon_cnt;\r
+ float rows;\r
+ if(cvar("sbar_accuracy_doublerows"))\r
+ rows = 2;\r
+ else\r
+ rows = 1;\r
+ float height = 40;\r
+\r
+ if(warmup_stage)\r
+ {\r
+ return pos;\r
+ }\r
+\r
+ xsave = pos_x;\r
+ drawstring(pos, strcat("Accuracy stats (average ", ftos(average_accuracy), "%)"), sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
+ pos_y += 18;\r
+ vector tmp;\r
+ tmp_x = sbwidth;\r
+ tmp_y = height * rows;\r
+\r
+ drawpic_tiled(pos, "gfx/hud/sb_scoreboard_bg", bg_size, tmp, rgb * sbar_color_bg_team, sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL);\r
+ drawborderlines(sbar_accuracy_border_thickness, pos, tmp, '0 0 0', sbar_scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);\r
+\r
+ // column highlighting\r
+ for(i = 0; i < weapon_cnt/rows; ++i)\r
+ {\r
+ if(!mod(i, 2))\r
+ 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
+ }\r
+\r
+ // row highlighting\r
+ for(i = 0; i < rows; ++i)\r
+ {\r
+ 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
+ }\r
+\r
+ // skip useless weapons\r
+ weapon_cnt = 0;\r
+ for(i = WEP_FIRST; i <= WEP_LAST; ++i)\r
+ {\r
+ self = get_weaponinfo(i);\r
+ if not(self.weapons)\r
+ continue;\r
+ ++weapon_cnt;\r
+ }\r
+\r
+ drawfont = sbar_bigfont;\r
+ average_accuracy = 0;\r
+ float weapons_with_stats;\r
+ weapons_with_stats = 0;\r
+ if(rows == 2)\r
+ pos_x += sbwidth/weapon_cnt / 2;\r
+\r
+ for(i = WEP_FIRST; i <= WEP_LAST; ++i)\r
+ {\r
+ self = get_weaponinfo(i);\r
+ if not(self.weapons)\r
+ continue;\r
+ weapon_hit = weapon_hits[i-WEP_FIRST];\r
+ weapon_damage = weapon_fired[i-WEP_FIRST];\r
+ if(weapon_damage)\r
+ weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100);\r
+ float weapon_alpha;\r
+\r
+ if(weapon_damage)\r
+ weapon_alpha = sbar_scoreboard_alpha_fg;\r
+ else\r
+ weapon_alpha = 0.2 * sbar_scoreboard_alpha_fg;\r
+\r
+ // weapon icon\r
+ drawpic(pos, strcat("gfx/hud/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
+ // the accuracy\r
+ if(weapon_damage) {\r
+ weapons_with_stats += 1;\r
+ average_accuracy += weapon_stats; // store sum of all accuracies in average_accuracy\r
+\r
+ string s;\r
+ s = strcat(ftos(weapon_stats),"%");\r
+\r
+ float padding;\r
+ padding = ((sbwidth/weapon_cnt) - stringwidth(s, FALSE, '1 0 0' * fontsize)) / 2; // center the accuracy value\r
+\r
+ rgb = Sbar_AccuracyColor(weapon_stats);\r
+ 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
+ }\r
+ pos_x += sbwidth/weapon_cnt * rows;\r
+ if(rows == 2 && i == 6) {\r
+ pos_x -= sbwidth;\r
+ pos_y += height;\r
+ }\r
+ }\r
+ drawfont = sbar_font;\r
+\r
+ if(weapons_with_stats)\r
+ average_accuracy = floor(average_accuracy / weapons_with_stats);\r
+\r
+ pos_x = xsave;\r
+ pos_y += height;\r
+ return pos;\r
+}\r
+\r
+string race_PlaceName(float pos) {\r
+ if(pos == 1)\r
+ return "1st";\r
+ else if(pos == 2)\r
+ return "2nd";\r
+ else if(pos == 3)\r
+ return "3rd";\r
+ else\r
+ return strcat(ftos(pos), "th");\r
+}\r
+\r
+vector Sbar_DrawScoreboardRankings(vector pos, entity pl, vector rgb, vector bg_size)\r
+{\r
+ float i;\r
+ RANKINGS_RECEIVED_CNT = 0;\r
+ for (i=RANKINGS_CNT-1; i>=0; --i)\r
+ if (grecordtime[i])\r
+ RANKINGS_RECEIVED_CNT = RANKINGS_RECEIVED_CNT + 1;\r
+\r
+ if (RANKINGS_RECEIVED_CNT == 0)\r
+ return pos;\r
+\r
+ float is_spec;\r
+ is_spec = (GetPlayerColor(pl.sv_entnum) == COLOR_SPECTATOR);\r
+ vector hl_rgb;\r
+ hl_rgb = stov(cvar_string("sbar_color_bg")) + '0.5 0.5 0.5';\r
+\r
+ pos_y += sbar_fontsize_y;\r
+ drawstring(pos, strcat("Rankings"), sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
+ pos_y += sbar_fontsize_y;\r
+ vector tmp;\r
+ tmp_x = sbwidth;\r
+ tmp_y = sbar_fontsize_y * RANKINGS_RECEIVED_CNT;\r
+\r
+ drawpic_tiled(pos, "gfx/hud/sb_scoreboard_bg", bg_size, tmp, rgb * sbar_color_bg_team, sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL);\r
+ drawborderlines(sbar_border_thickness, pos, tmp, '0 0 0', sbar_scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);\r
+\r
+ // row highlighting\r
+ for(i = 0; i<RANKINGS_RECEIVED_CNT; ++i)\r
+ {\r
+ string n, p;\r
+ float t;\r
+ t = grecordtime[i];\r
+ if (t == 0)\r
+ continue;\r
+ n = grecordholder[i];\r
+ p = race_PlaceName(i+1);\r
+ if(grecordholder[i] == GetPlayerName(player_localentnum - 1))\r
+ drawfill(pos, '1 0 0' * sbwidth + '0 1 0' * sbar_fontsize_y, hl_rgb, sbar_scoreboard_highlight_alpha_self, DRAWFLAG_NORMAL); \r
+ else if(!mod(i, 2) && sbar_scoreboard_highlight)\r
+ drawfill(pos, '1 0 0' * sbwidth + '0 1 0' * sbar_fontsize_y, hl_rgb, sbar_scoreboard_highlight_alpha, DRAWFLAG_NORMAL); \r
+ drawstring(pos, p, sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawstring(pos + '3 0 0' * sbar_fontsize_x, TIME_ENCODED_TOSTRING(t), sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawcolorcodedstring(pos + '8 0 0' * sbar_fontsize_x, n, sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
+ pos += '0 1 0' * sbar_fontsize_y;\r
+ }\r
+\r
+ return pos;\r
+}\r
+\r
+float scoreboard_bottom;\r
+float sbar_scoreboard_fade_alpha;\r
+float sbar_woulddrawscoreboard_prev;\r
+float sbar_woulddrawscoreboard_change; // "time" at which Sbar_WouldDrawScoreboard() changed\r
+void Sbar_DrawScoreboard()\r
+{\r
+ float sbar_woulddrawscoreboard; \r
+ sbar_woulddrawscoreboard = Sbar_WouldDrawScoreboard();\r
+ if(sbar_woulddrawscoreboard != sbar_woulddrawscoreboard_prev) {\r
+ sbar_woulddrawscoreboard_change = time;\r
+ sbar_woulddrawscoreboard_prev = sbar_woulddrawscoreboard;\r
+ }\r
+\r
+ float scoreboard_fadeinspeed = cvar_or("sbar_scoreboard_fadeinspeed", 10);\r
+ float scoreboard_fadeoutspeed = cvar_or("sbar_scoreboard_fadeoutspeed", 5);\r
+ if(sbar_woulddrawscoreboard) {\r
+ if (scoreboard_fadeinspeed)\r
+ sbar_scoreboard_fade_alpha = bound (0, (time - sbar_woulddrawscoreboard_change) * scoreboard_fadeinspeed, 1);\r
+ else\r
+ sbar_scoreboard_fade_alpha = 1;\r
+ }\r
+ else\r
+ if (scoreboard_fadeoutspeed)\r
+ sbar_scoreboard_fade_alpha = bound (0, (1/scoreboard_fadeoutspeed - (time - sbar_woulddrawscoreboard_change)) * scoreboard_fadeoutspeed, 1);\r
+ else\r
+ sbar_scoreboard_fade_alpha = 0;\r
+\r
+ if not(sbar_scoreboard_fade_alpha)\r
+ return;\r
+ \r
+ sbar_scoreboard_alpha_bg = cvar("sbar_scoreboard_alpha_bg") * sbar_scoreboard_fade_alpha;\r
+ sbar_scoreboard_alpha_fg = cvar_or("sbar_scoreboard_alpha_fg", 1.0) * sbar_scoreboard_fade_alpha;\r
+ sbar_scoreboard_highlight = cvar("sbar_scoreboard_highlight");\r
+ sbar_scoreboard_highlight_alpha = cvar_or("sbar_scoreboard_highlight_alpha", 0.10) * sbar_scoreboard_alpha_fg;\r
+ sbar_scoreboard_highlight_alpha_self = cvar_or("sbar_scoreboard_highlight_alpha_self", 0.25) * sbar_scoreboard_alpha_fg;\r
+ sbar_scoreboard_alpha_name = cvar_or("sbar_scoreboard_alpha_name", 0.9) * sbar_scoreboard_alpha_fg;\r
+ sbar_scoreboard_alpha_name_self = cvar_or("sbar_scoreboard_alpha_name_self", 1) * sbar_scoreboard_alpha_fg;\r
+ \r
+ vector rgb, pos, tmp;\r
+ entity pl, tm;\r
+\r
+ sbwidth = Sbar_GetWidth(6.5 * sbar_fontsize_y);\r
+\r
+ xmin = 0.5 * (vid_conwidth - sbwidth);\r
+ ymin = cvar("sbar_scoreboard_offset");\r
+\r
+ xmax = vid_conwidth - xmin;\r
+ ymax = vid_conheight - 0.2*vid_conheight;\r
+\r
+ // Initializes position\r
+ pos_x = xmin;\r
+ pos_y = ymin;\r
+ pos_z = 0;\r
+\r
+ // Heading\r
+ drawfont = sbar_bigfont;\r
+ if(gametype == GAME_RPG)\r
+ drawstringcenter('0 1 0' * ymin, "Players", '24 24 0', '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
+ else\r
+ drawstringcenter('0 1 0' * ymin, "Scoreboard", '24 24 0', '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+ pos_y += 24 + 4;\r
+ pos_y += sbar_fontsize_y;\r
+\r
+ drawfont = sbar_font;\r
+\r
+ // Draw the scoreboard\r
+ vector bg_size;\r
+ bg_size = drawgetimagesize("gfx/hud/sb_scoreboard_bg");\r
+\r
+ if(teamplay)\r
+ {\r
+ for(tm = teams.sort_next; tm; tm = tm.sort_next)\r
+ {\r
+ if(tm.team == COLOR_SPECTATOR)\r
+ continue;\r
+\r
+ rgb = GetTeamRGB(tm.team);\r
+ 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
+ \r
+ if(ts_primary != ts_secondary)\r
+ 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
+\r
+ pos = Sbar_Scoreboard_MakeTable(pos, tm, rgb, bg_size);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ rgb = stov(cvar_string("sbar_color_bg"));\r
+\r
+ for(tm = teams.sort_next; tm; tm = tm.sort_next)\r
+ {\r
+ if(tm.team == COLOR_SPECTATOR)\r
+ continue;\r
+\r
+ pos = Sbar_Scoreboard_MakeTable(pos, tm, rgb, bg_size);\r
+ }\r
+ }\r
+\r
+ if(gametype == GAME_CTS || gametype == GAME_RACE) {\r
+ if(race_speedaward) {\r
+ drawcolorcodedstring(pos, strcat("Speed award: ", ftos(race_speedaward), " (", race_speedaward_holder, ")"), sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
+ pos_y += 1.25 * sbar_fontsize_y;\r
+ }\r
+ if(race_speedaward_alltimebest) {\r
+ drawcolorcodedstring(pos, strcat("All-time fastest: ", ftos(race_speedaward_alltimebest), " (", race_speedaward_alltimebest_holder, ")"), sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
+ pos_y += 1.25 * sbar_fontsize_y;\r
+ }\r
+ pos = Sbar_DrawScoreboardRankings(pos, pl, rgb, bg_size);\r
+ }\r
+ else if(cvar("sbar_accuracy") && spectatee_status != -1) {\r
+ if(teamplay)\r
+ pos = Sbar_DrawScoreboardAccuracyStats(pos, GetTeamRGB(myteam), bg_size);\r
+ else\r
+ pos = Sbar_DrawScoreboardAccuracyStats(pos, rgb, bg_size);\r
+ }\r
+\r
+ tmp = pos + '0 1.5 0' * sbar_fontsize_y;\r
+ pos_y += 3 * sbar_fontsize_y;\r
+\r
+ // List spectators\r
+ float specs;\r
+ specs = 0;\r
+ for(pl = players.sort_next; pl; pl = pl.sort_next)\r
+ {\r
+ if(pl.team != COLOR_SPECTATOR)\r
+ continue;\r
+ Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), specs);\r
+ pos_y += 1.25 * sbar_fontsize_y;\r
+ ++specs;\r
+ }\r
+\r
+ if(specs)\r
+ drawstring(tmp, "Spectators", sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+ // Print info string\r
+ string str;\r
+ float tl, fl, ll;\r
+ if(gametype == GAME_RPG)\r
+ str = strcat("you are in ^2", shortmapname, "^7");\r
+ else\r
+ str = strcat("playing on ^2", shortmapname, "^7");\r
+ tl = getstatf(STAT_TIMELIMIT);\r
+ fl = getstatf(STAT_FRAGLIMIT);\r
+ ll = getstatf(STAT_LEADLIMIT);\r
+ if(gametype == GAME_LMS)\r
+ {\r
+ if(tl > 0)\r
+ str = strcat(str, " for up to ^1", ftos(tl), " minutes^7");\r
+ }\r
+ else\r
+ {\r
+ if(tl > 0)\r
+ str = strcat(str, " for ^1", ftos(tl), " minutes^7");\r
+ if(fl > 0 && !(gametype == GAME_RPG))\r
+ {\r
+ if(tl > 0)\r
+ str = strcat(str, " or");\r
+ if(teamplay)\r
+ {\r
+ str = strcat(str, " until ^3", ScoreString(teamscores_flags[ts_primary], fl));\r
+ if(teamscores_label[ts_primary] == "score")\r
+ str = strcat(str, " points^7");\r
+ else if(teamscores_label[ts_primary] == "fastest")\r
+ str = strcat(str, " is beaten^7");\r
+ else\r
+ str = strcat(str, " ", teamscores_label[ts_primary]);\r
+ }\r
+ else\r
+ {\r
+ str = strcat(str, " until ^3", ScoreString(scores_flags[ps_primary], fl));\r
+ if(scores_label[ps_primary] == "score")\r
+ str = strcat(str, " points^7");\r
+ else if(scores_label[ps_primary] == "fastest")\r
+ str = strcat(str, " is beaten^7");\r
+ else\r
+ str = strcat(str, " ", scores_label[ps_primary]);\r
+ }\r
+ }\r
+ if(ll > 0)\r
+ {\r
+ if(tl > 0 || fl > 0)\r
+ str = strcat(str, " or");\r
+ if(teamplay)\r
+ {\r
+ str = strcat(str, " until a lead of ^3", ScoreString(teamscores_flags[ts_primary], ll));\r
+ if(teamscores_label[ts_primary] == "score")\r
+ str = strcat(str, " points^7");\r
+ else if(teamscores_label[ts_primary] == "fastest")\r
+ str = strcat(str, " is beaten^7");\r
+ else\r
+ str = strcat(str, " ", teamscores_label[ts_primary]);\r
+ }\r
+ else\r
+ {\r
+ str = strcat(str, " until a lead of ^3", ScoreString(scores_flags[ps_primary], ll));\r
+ if(scores_label[ps_primary] == "score")\r
+ str = strcat(str, " points^7");\r
+ else if(scores_label[ps_primary] == "fastest")\r
+ str = strcat(str, " is beaten^7");\r
+ else\r
+ str = strcat(str, " ", scores_label[ps_primary]);\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+ pos_y += 1.2 * sbar_fontsize_y;\r
+ drawcolorcodedstring(pos + '0.5 0 0' * (sbwidth - stringwidth(str, TRUE, sbar_fontsize)), str, sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+ scoreboard_bottom = pos_y + 2 * sbar_fontsize_y;\r
+}\r
+\r
+string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)\r
+{\r
+ string col;\r
+ string timestr;\r
+ string cpname;\r
+ string lapstr;\r
+ lapstr = "";\r
+\r
+ if(histime == 0) // goal hit\r
+ {\r
+ if(mytime > 0)\r
+ {\r
+ timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));\r
+ col = "^1";\r
+ }\r
+ else if(mytime == 0)\r
+ {\r
+ timestr = "+0.0";\r
+ col = "^3";\r
+ }\r
+ else\r
+ {\r
+ timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));\r
+ col = "^2";\r
+ }\r
+\r
+ if(lapdelta > 0)\r
+ {\r
+ lapstr = strcat(" (-", ftos(lapdelta), "L)");\r
+ col = "^2";\r
+ }\r
+ else if(lapdelta < 0)\r
+ {\r
+ lapstr = strcat(" (+", ftos(-lapdelta), "L)");\r
+ col = "^1";\r
+ }\r
+ }\r
+ else if(histime > 0) // anticipation\r
+ {\r
+ if(mytime >= histime)\r
+ timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));\r
+ else\r
+ timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));\r
+ col = "^3";\r
+ }\r
+ else\r
+ col = "^7";\r
+\r
+ if(cp == 254)\r
+ cpname = "Start line";\r
+ else if(cp == 255)\r
+ cpname = "Finish line";\r
+ else if(cp)\r
+ cpname = strcat("Intermediate ", ftos(cp));\r
+ else\r
+ cpname = "Finish line";\r
+\r
+ if(histime < 0)\r
+ return strcat(col, cpname);\r
+ else if(hisname == "")\r
+ return strcat(col, cpname, " (", timestr, ")");\r
+ else\r
+ return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");\r
+}\r
+\r
+float race_CheckName(string net_name) { // Does the name already exist in rankings? In that case, where? (otherwise 0)\r
+ float i;\r
+ for (i=RANKINGS_CNT-1;i>=0;--i)\r
+ if(grecordholder[i] == net_name)\r
+ return i+1;\r
+ return 0;\r
+}\r
+\r
+float GetAmmoStat(float i)\r
+{\r
+ switch(i)\r
+ {\r
+ case 0: return STAT_FUEL;\r
+ default: return -1;\r
+ }\r
+}\r
+\r
+float GetAmmoItemCode(float i)\r
+{\r
+ switch(i)\r
+ {\r
+ case 0: return IT_FUEL;\r
+ default: return -1;\r
+ }\r
+}\r
+\r
+string GetAmmoPicture(float i)\r
+{\r
+ switch(i)\r
+ {\r
+ case 0:\r
+ if(getstati(STAT_ITEMS) & IT_FUEL_REGEN)\r
+ return "gfx/hud/sb_fuel_regen";\r
+ else\r
+ return "gfx/hud/sb_fuel";\r
+ default:\r
+ return "";\r
+ }\r
+}\r
+\r
+float race_status_time;\r
+float race_status_prev;\r
+string race_status_name_prev;\r
+void Sbar_DrawRaceStatus(vector pos)\r
+{\r
+ if (race_status != race_status_prev || race_status_name != race_status_name_prev) {\r
+ race_status_time = time + 5;\r
+ race_status_prev = race_status;\r
+ if (race_status_name_prev)\r
+ strunzone(race_status_name_prev);\r
+ race_status_name_prev = strzone(race_status_name);\r
+ }\r
+\r
+ float a;\r
+ a = bound(0, race_status_time - time, 1);\r
+\r
+ string s;\r
+ s = textShortenToWidth(race_status_name, 120, '10 10 0', stringwidth_colors);\r
+\r
+ float rank;\r
+ if(race_status > 0)\r
+ rank = race_CheckName(race_status_name);\r
+ string rankname;\r
+ rankname = race_PlaceName(rank);\r
+\r
+ if(race_status == 0)\r
+ drawpic(pos, "gfx/hud/race/newfail", '80 80 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);\r
+ else if(race_status == 1) {\r
+ drawpic(pos, "gfx/hud/race/newtime", '80 80 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL); \r
+ 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
+ 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
+ } else if(race_status == 2) {\r
+ if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)\r
+ drawpic(pos, "gfx/hud/race/newrankgreen", '80 80 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);\r
+ else\r
+ drawpic(pos, "gfx/hud/race/newrankyellow", '80 80 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);\r
+ 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
+ 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
+ } else if(race_status == 3) {\r
+ drawpic(pos, "gfx/hud/race/newrecordserver", '80 80 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);\r
+ 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
+ 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
+ }\r
+\r
+ if (race_status_time - time <= 0) {\r
+ race_status_prev = -1;\r
+ race_status = -1;\r
+ if(race_status_name)\r
+ strunzone(race_status_name);\r
+ race_status_name = string_null;\r
+ if(race_status_name_prev)\r
+ strunzone(race_status_name_prev);\r
+ race_status_name_prev = string_null;\r
+ }\r
+}\r
+\r
+void Sbar_Score()\r
+{\r
+ float score, distribution, leader;\r
+ vector score_pos, secondary_score_pos, race_score_pos, distribution_color;\r
+ string racetime, secondary_racetime;\r
+ entity tm, pl, me;\r
+ me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];\r
+\r
+ vector top;\r
+ top_x = vid_conwidth / 2;\r
+ top_y = 0;\r
+ top_z = 0;\r
+\r
+ if(gametype == GAME_RPG)\r
+ return;\r
+\r
+ score_pos = top + '-80 8 0';\r
+ secondary_score_pos = score_pos + '80 -6 0';\r
+\r
+ if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD\r
+ pl = players.sort_next;\r
+ if(pl == me)\r
+ pl = pl.sort_next;\r
+ if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)\r
+ if(pl.scores[ps_primary] == 0)\r
+ pl = world;\r
+\r
+ score = me.(scores[ps_primary]);\r
+\r
+ float racemin, racesec, racemsec;\r
+ float distsec, distmsec;\r
+ string s_racemin, s_racesec, s_racemsec;\r
+ \r
+ racemin = floor(score/(60 * TIME_FACTOR));\r
+ racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);\r
+ racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;\r
+\r
+ if(racemin < 10) s_racemin = strcat("0", ftos(racemin));\r
+ else s_racemin = ftos(racemin);\r
+ if(racesec < 10) s_racesec = strcat("0", ftos(racesec));\r
+ else s_racesec = ftos(racesec);\r
+ if(racemsec < 10) s_racemsec = strcat("0", ftos(racemsec));\r
+ else s_racemsec = ftos(racemsec);\r
+\r
+ if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {\r
+ // distribution display\r
+ distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);\r
+\r
+ if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)\r
+ distmsec = fabs(distribution);\r
+ else {\r
+ distsec = floor(fabs(distribution) / TIME_FACTOR);\r
+ distmsec = fabs(distribution) - distsec * TIME_FACTOR;\r
+ }\r
+\r
+ if (distribution < 0) {\r
+ distribution_color = '0 1 0';\r
+ secondary_racetime = "-"; // always prefix with minus sign\r
+ }\r
+ else if (distribution > 0) {\r
+ distribution_color = '1 0 0';\r
+ secondary_racetime = "+"; // minusplus 1: always prefix with plus sign\r
+ }\r
+ else\r
+ distribution_color = '1 1 1';\r
+\r
+ secondary_racetime = strcat(secondary_racetime, ftos(distsec), ".", ftos(distmsec));\r
+ drawstring(score_pos + '222 0 0' - '14 0 0', secondary_racetime, '14 14 0', distribution_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ }\r
+\r
+ racetime = strcat(s_racemin, " : ", s_racesec, " . ", s_racemsec);\r
+ race_score_pos = top + '0 0 0';\r
+ race_score_pos -= '1 0 0' * stringwidth(racetime, FALSE, '30 30 0') * 0.5;\r
+ drawstring(race_score_pos, racetime, '30 30 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+ } else if (!teamplay) { // non-teamgames, except race/cts\r
+ // me vector := [team/connected frags id]\r
+ pl = players.sort_next;\r
+ if(pl == me)\r
+ pl = pl.sort_next;\r
+\r
+ if(pl)\r
+ distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);\r
+ else\r
+ distribution = 0;\r
+\r
+ score = me.(scores[ps_primary]);\r
+ \r
+ if(distribution >= 5) {\r
+ distribution_color = '0 1 0';\r
+ leader = 1;\r
+ } else if(distribution >= 0) {\r
+ distribution_color = '1 1 1';\r
+ leader = 1;\r
+ } else if(distribution >= -5)\r
+ distribution_color = '1 1 0';\r
+ else\r
+ distribution_color = '1 0 0';\r
+ \r
+ Sbar_DrawXNum(secondary_score_pos, distribution, 6, 3, 16, distribution_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ Sbar_DrawXNum(score_pos, score, 6, 0, 34, distribution_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ } else { // teamgames\r
+ float max_fragcount;\r
+ max_fragcount = -999;\r
+\r
+ for(tm = teams.sort_next; tm; tm = tm.sort_next) {\r
+ if(tm.team == COLOR_SPECTATOR || !tm.team_size) // no players? don't display\r
+ continue;\r
+ score = tm.(teamscores[ts_primary]);\r
+ leader = 0;\r
+\r
+ if (score > max_fragcount)\r
+ max_fragcount = score;\r
+ \r
+ if(tm.team == myteam) {\r
+ if (max_fragcount == score)\r
+ leader = 1;\r
+ Sbar_DrawXNum(score_pos, score, 6, 0, 34, GetTeamRGB(tm.team), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ } else {\r
+ if (max_fragcount == score)\r
+ leader = 1;\r
+ Sbar_DrawXNum(secondary_score_pos, score, 6, 3, 16, GetTeamRGB(tm.team), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ secondary_score_pos = secondary_score_pos + '0 16 0';\r
+ }\r
+ }\r
+ }\r
+\r
+ if(gametype == GAME_RACE || gametype == GAME_CTS)\r
+ {\r
+ drawfont = sbar_bigfont;\r
+ float a, t;\r
+ vector m;\r
+ string s, forcetime;\r
+\r
+ m = '0.5 0 0' * vid_conwidth + '0 1 0' * cvar_or("cl_racetimer_position", 0.25) * vid_conheight;\r
+\r
+ if(race_checkpointtime)\r
+ {\r
+ a = bound(0, 2 - (time - race_checkpointtime), 1);\r
+ s = "";\r
+ forcetime = "";\r
+ if(a > 0) // just hit a checkpoint?\r
+ {\r
+ if(race_checkpoint != 254)\r
+ {\r
+ if(race_time && race_previousbesttime)\r
+ s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);\r
+ else\r
+ s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);\r
+ if(race_time)\r
+ forcetime = TIME_ENCODED_TOSTRING(race_time);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)\r
+ {\r
+ a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);\r
+ if(a > 0) // next one?\r
+ {\r
+ s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);\r
+ }\r
+ }\r
+ }\r
+\r
+ if(s != "" && a > 0)\r
+ {\r
+ dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)\r
+ //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);\r
+ 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
+ }\r
+\r
+ if(race_penaltytime)\r
+ {\r
+ a = bound(0, 2 - (time - race_penaltyeventtime), 1);\r
+ if(a > 0)\r
+ {\r
+ s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");\r
+ dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)\r
+ //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);\r
+ 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
+ }\r
+ }\r
+\r
+ if(forcetime != "")\r
+ {\r
+ a = bound(0, (time - race_checkpointtime) / 0.5, 1);\r
+ //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', sbar_alpha_fg, 0, a);\r
+ 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
+ }\r
+ else\r
+ a = 1;\r
+\r
+ if(race_laptime && race_checkpoint != 255)\r
+ {\r
+ s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));\r
+ //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);\r
+ 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
+ }\r
+ }\r
+ else\r
+ {\r
+ if(race_mycheckpointtime)\r
+ {\r
+ a = bound(0, 2 - (time - race_mycheckpointtime), 1);\r
+ s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);\r
+ dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)\r
+ //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);\r
+ 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
+ }\r
+ if(race_othercheckpointtime && race_othercheckpointenemy != "")\r
+ {\r
+ a = bound(0, 2 - (time - race_othercheckpointtime), 1);\r
+ s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);\r
+ dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)\r
+ //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);\r
+ 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
+ }\r
+\r
+ if(race_penaltytime && !race_penaltyaccumulator)\r
+ {\r
+ t = race_penaltytime * 0.1 + race_penaltyeventtime;\r
+ a = bound(0, (1 + t - time), 1);\r
+ if(a > 0)\r
+ {\r
+ if(time < t)\r
+ s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");\r
+ else\r
+ s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");\r
+ dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)\r
+ //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);\r
+ 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
+ }\r
+ }\r
+ }\r
+\r
+ drawfont = sbar_font;\r
+ }\r
+}\r
+\r
+void Sbar_Status()\r
+{\r
+ vector bottom;\r
+ bottom_x = vid_conwidth/2;\r
+ bottom_y = vid_conheight;\r
+ bottom_z = 0;\r
+\r
+ float armor, health, x, a;\r
+ armor = getstati(STAT_ARMOR);\r
+ health = getstati(STAT_HEALTH);\r
+\r
+ float stat_items;\r
+ stat_items = getstati(STAT_ITEMS);\r
+\r
+ vector health_pos, armor_pos, pos;\r
+ health_pos = bottom - '43 58 0';\r
+ armor_pos = bottom - '43 68 0';\r
+\r
+ if (cvar("viewsize") <= 100) {\r
+ if (teamplay)\r
+ drawpic(bottom - '96 96 0', "gfx/hud/bg_status", '192 96 0', GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // hud color = myteam color\r
+ else {\r
+ // allow for custom HUD colors in non-teamgames\r
+ color = stov(cvar_string("sbar_color_bg"));\r
+\r
+ drawpic(bottom - '96 96 0', "gfx/hud/bg_status", '192 96 0', color, sbar_alpha_bg, DRAWFLAG_NORMAL);\r
+ }\r
+ }\r
+\r
+ // armor\r
+ x = armor;\r
+ if (x > 0)\r
+ {\r
+ drawpic(armor_pos + '-8 -13.5 0', "gfx/hud/sb_armor", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ armor_pos -= '1 0 0' * stringwidth(ftos(x), FALSE, '12 12 0') * 0.5;\r
+ Sbar_DrawXNum(armor_pos, x, 3, 0, 12, Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ }\r
+\r
+ // health\r
+ x = health;\r
+ drawpic(health_pos + '-11 16 0', "gfx/hud/sb_health", '32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ health_pos -= '1 0 0' * stringwidth(ftos(x), FALSE, '22 22 0') * 0.5;\r
+ Sbar_DrawXNum(health_pos, x, 3, 0, 22, Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+ // ammo\r
+ pos_x = bottom_x + 140;\r
+ pos_y = bottom_y - 20;\r
+\r
+ float weapon_clipload, weapon_clipsize;\r
+ vector ammo_pos_offset;\r
+\r
+ // if we are using the jetpack, show fuel ammo. Otherwise show the ammo of our weapon\r
+ if(stat_items & IT_JETPACK && button_jetpack)\r
+ {\r
+ a = getstati(GetAmmoStat(0)); // how much fuel do we have?\r
+ drawpic(pos - '98 18 0', GetAmmoPicture(0), '20 20 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ ammo_pos_offset = '1 0 0' * stringwidth(ftos(a), FALSE, '16 16 0') * 0.5;\r
+ Sbar_DrawXNum(pos - '118 16 0' - ammo_pos_offset, a, 3, 0, 16, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ }\r
+ else\r
+ {\r
+ float i;\r
+ for (i = 0; i < 1; ++i)\r
+ {\r
+ if (stat_items & GetAmmoItemCode(i))\r
+ {\r
+ a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i?\r
+ drawpic(pos - '98 18 0', GetAmmoPicture(i), '20 20 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ weapon_clipsize = getstati(STAT_WEAPON_CLIPSIZE);\r
+ // if the weapon we're holding is reloadable, show both its ammo and load\r
+ if(weapon_clipsize)\r
+ {\r
+ weapon_clipload = getstati(STAT_WEAPON_CLIPLOAD);\r
+ if(weapon_clipload < 0) // we're reloading\r
+ {\r
+ ammo_pos_offset = '1 0 0' * stringwidth("- -", FALSE, '16 16 0') * 0.5;\r
+ drawstring(pos - '118 23 0' - ammo_pos_offset, "- -", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ }\r
+ else\r
+ {\r
+ ammo_pos_offset = '1 0 0' * stringwidth(ftos(weapon_clipload), FALSE, '16 16 0') * 0.5;\r
+ Sbar_DrawXNum(pos - '118 23 0' - ammo_pos_offset, weapon_clipload, 2, 0, 16, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ }\r
+ ammo_pos_offset = '1 0 0' * stringwidth(ftos(a), FALSE, '12 12 0') * 0.5;\r
+ Sbar_DrawXNum(pos - '118 7 0' - ammo_pos_offset, a, 3, 0, 12, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ }\r
+ else\r
+ {\r
+ ammo_pos_offset = '1 0 0' * stringwidth(ftos(a), FALSE, '16 16 0') * 0.5;\r
+ Sbar_DrawXNum(pos - '118 16 0' - ammo_pos_offset, a, 3, 0, 16, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ // weapon icon\r
+ entity e;\r
+ e = get_weaponinfo(activeweapon);\r
+ if (e && e.netname != "" && e.netname != "N/A")\r
+ drawpic(bottom - '96 96 0', strcat("gfx/hud/bg_status_activeweapon_", e.netname), '192 96 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+}\r
+\r
+void Sbar_Timer()\r
+{\r
+ float timelimit, elapsedTime, minutes, seconds, timeleft, minutesLeft, secondsLeft;\r
+ vector pos, bgpos, timer_color;\r
+ string finaltime;\r
+ bgpos = '0 0 0';\r
+ \r
+ vector topright;\r
+ topright = '0 0 0';\r
+ topright_x = vid_conwidth;\r
+ \r
+ float scale;\r
+ scale = cvar_or("sbar_timer_scale", 1);\r
+ timelimit = getstatf(STAT_TIMELIMIT);\r
+\r
+ if(gametype == GAME_RPG && !timelimit) // don't draw the timer in rpg if there's no time limit\r
+ return;\r
+\r
+ Sbar_DrawRaceStatus((topright_x - 100) * '1 0 0' + '0 30 0' * scale);\r
+ \r
+ timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);\r
+ timeleft = ceil(timeleft);\r
+ minutesLeft = floor(timeleft / 60);\r
+ secondsLeft = timeleft - minutesLeft*60;\r
+\r
+ if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit\r
+ timer_color = '1 1 1'; //white\r
+ else if(minutesLeft >= 1)\r
+ timer_color = '1 1 0'; //yellow\r
+ else\r
+ timer_color = '1 0 0'; //red\r
+\r
+ if (cvar("sbar_increment_maptime") || timelimit == 0 || warmup_stage) {\r
+ if (time < getstatf(STAT_GAMESTARTTIME)) {\r
+ //while restart is still active, show 00:00\r
+ minutes = seconds = 0;\r
+ } else {\r
+ elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127\r
+ minutes = floor(elapsedTime / 60);\r
+ seconds = elapsedTime - minutes*60;\r
+ }\r
+ if (minutes < 10)\r
+ bgpos_x = topright_x - (54 + 17 + 12) * scale;\r
+ else if (minutes < 100) // nudge the timer background left if more digits are drawn\r
+ bgpos_x = topright_x - (62 + 17 + 12) * scale;\r
+ else\r
+ bgpos_x = topright_x - (70 + 17 + 12) * scale;\r
+ bgpos_y = 0;\r
+ bgpos_z = 0;\r
+ } else {\r
+ minutes = minutesLeft;\r
+ seconds = secondsLeft;\r
+ if (minutes < 10) // nudge the timer background left if more digits are drawn\r
+ bgpos_x = topright_x - (54 + 17 + 12) * scale;\r
+ else if (minutes < 100)\r
+ bgpos_x = topright_x - (62 + 17 + 12) * scale;\r
+ else\r
+ bgpos_x = topright_x - (70 + 17 + 12) * scale;\r
+ bgpos_y = 0;\r
+ bgpos_z = 0;\r
+ }\r
+\r
+ if (cvar("viewsize") <= 100) { // draw timer background when viewsize <= 100\r
+ if (teamplay)\r
+ drawpic(bgpos, "gfx/hud/bg_timer", '120 30 0' * scale, GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // timer bg color = myteam color\r
+ else {\r
+ color = stov(cvar_string("sbar_color_bg"));\r
+\r
+ drawpic(bgpos, "gfx/hud/bg_timer", '120 30 0' * scale, color, sbar_alpha_bg, DRAWFLAG_NORMAL);\r
+ }\r
+ }\r
+\r
+ drawpic(topright - ('19 0 0' + '3 0 0' - '0 2 0'), "gfx/hud/sb_time", '22 22 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ finaltime = strcat(ftos(minutes), ":");\r
+ if(seconds < 10)\r
+ finaltime = strcat(finaltime, "0", ftos(seconds));\r
+ else\r
+ finaltime = strcat(finaltime, ftos(seconds));\r
+\r
+ pos = topright - ('24 -2 0' + '3 0 0' - '0 2 0');\r
+ pos -= '1 0 0' * stringwidth(finaltime, FALSE, 18 * scale * '1 1 0');\r
+ drawstring(pos, finaltime, 18 * scale * '1 1 0', timer_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+}\r
+\r
+void Sbar_Ring()\r
+{\r
+ vector ring_pos, ring1_color, ring2_color;\r
+ vector text_pos, text1_size, text2_size;\r
+ float ring1_alpha, ring2_alpha, ring1_size, ring1_clip, ring2_size, ring2_clip;\r
+ string text1_msg, text2_msg;\r
+\r
+ ring_pos_x = vid_conwidth / 2;\r
+ ring_pos_y = vid_conheight - vid_conheight / 3.5;\r
+ ring1_size = cvar("sbar_ring1_scale");\r
+ ring2_size = cvar("sbar_ring2_scale");\r
+ ring1_alpha = sbar_alpha_fg * cvar("sbar_ring1_alpha");\r
+ ring2_alpha = sbar_alpha_fg * cvar("sbar_ring2_alpha");\r
+ text1_size = '1 1 0' * cvar("sbar_ring1_text_scale");\r
+ text2_size = '1 1 0' * cvar("sbar_ring2_text_scale");\r
+\r
+ switch(getstati(STAT_SBRING1_TYPE))\r
+ {\r
+ case 0:\r
+ // ring disabled\r
+ break;\r
+ case 1:\r
+ // ring shows predator swallow progress, fills with progress\r
+ ring1_color = '0.5 1 0.5';\r
+ text1_msg = "Swallowing...";\r
+ break;\r
+ case 2:\r
+ // ring shows vore system delay, empties with progress\r
+ ring1_color = '0.5 0.5 1';\r
+ text1_msg = "Vore delay";\r
+ break;\r
+ case 3:\r
+ // ring shows stomach kick delay, empties with progress\r
+ ring1_color = '1 1 0.5';\r
+ text1_msg = "Kick delay";\r
+ break;\r
+ default:\r
+ print(strcat("^1Error:^7 Unknown ring type: ", ftos(getstati(STAT_SBRING1_TYPE)), "\n"));\r
+ break;\r
+ }\r
+ switch(getstati(STAT_SBRING2_TYPE))\r
+ {\r
+ case 0:\r
+ // ring disabled\r
+ break;\r
+ case 1:\r
+ // ring shows prey swallow progress, fills with progress\r
+ ring2_color = '1 0.5 0.5';\r
+ text2_msg = "Swallowed...";\r
+ break;\r
+ case 2:\r
+ // ring shows regurgitation preparing, fills with progress\r
+ ring2_color = '1 0.5 1';\r
+ text2_msg = "Regurgitating...";\r
+ break;\r
+ default:\r
+ print(strcat("^1Error:^7 Unknown ring type: ", ftos(getstati(STAT_SBRING1_TYPE)), "\n"));\r
+ break;\r
+ }\r
+ ring1_clip = getstatf(STAT_SBRING1_CLIP);\r
+ ring2_clip = getstatf(STAT_SBRING2_CLIP);\r
+\r
+ if(text1_msg != "" && cvar("sbar_ring1"))\r
+ {\r
+ DrawCircleClippedPic(ring_pos, ring1_size, "gfx/hud/sb_ring.tga", ring1_clip, ring1_color, ring1_alpha, DRAWFLAG_ADDITIVE);\r
+ text_pos_x = ring_pos_x - stringwidth(text1_msg, FALSE, text1_size) / 2;\r
+ text_pos_y = ring_pos_y - ring1_size / 2;\r
+ drawstring(text_pos, text1_msg, text1_size, ring1_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ }\r
+ if(text2_msg != "" && cvar("sbar_ring2"))\r
+ {\r
+ DrawCircleClippedPic(ring_pos, ring2_size, "gfx/hud/sb_ring.tga", ring2_clip, ring2_color, ring2_alpha, DRAWFLAG_ADDITIVE);\r
+ text_pos_x = ring_pos_x - stringwidth(text2_msg, FALSE, text2_size) / 2;\r
+ text_pos_y = ring_pos_y + ring1_size / 2;\r
+ drawstring(text_pos, text2_msg, text2_size, ring2_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ }\r
+}\r
+\r
+void CSQC_Strength_Timer() {\r
+ vector pos;\r
+ vector bottomright;\r
+\r
+ bottomright_x = vid_conwidth;\r
+ bottomright_y = vid_conheight;\r
+ bottomright_z = 0;\r
+\r
+ float stat_items, dt;\r
+ stat_items = getstati(STAT_ITEMS);\r
+ /*\r
+ if not(stat_items & IT_STRENGTH)\r
+ if not(stat_items & IT_INVINCIBLE)\r
+ return;\r
+ */\r
+\r
+ if (getstati(STAT_HEALTH) <= 0)\r
+ return;\r
+\r
+ vector picsize;\r
+ float strength_time, invincibility_time, countdown_fontsize;\r
+\r
+ picsize = '22 22 0';\r
+ countdown_fontsize = 18;\r
+\r
+ pos = bottomright - '34 48 0';\r
+\r
+ //strength\r
+ strength_time = getstatf(STAT_STRENGTH_FINISHED);\r
+ invincibility_time = getstatf(STAT_INVINCIBLE_FINISHED);\r
+\r
+ if (strength_time) {\r
+ dt = strength_time - time;\r
+ if(dt > 0)\r
+ {\r
+ if(dt < 5)\r
+ {\r
+ drawpic_expanding_two(pos, "gfx/hud/sb_str", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE,\r
+ bound(0, (ceil(dt) - dt) / 0.5, 1));\r
+ }\r
+ else\r
+ {\r
+ drawpic(pos, "gfx/hud/sb_str", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE);\r
+ }\r
+ Sbar_DrawXNum(pos - '30 -2 0', ceil(dt), 2, 0, countdown_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ }\r
+ else if(dt > -1)\r
+ {\r
+ drawpic_expanding(pos, "gfx/hud/sb_str", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE,\r
+ bound(0, -dt / 0.5, 1));\r
+ }\r
+ }\r
+\r
+ //invincibility\r
+ if (invincibility_time) {\r
+ dt = invincibility_time - time;\r
+ if(dt > 0)\r
+ {\r
+ if(dt < 5)\r
+ {\r
+ drawpic_expanding_two(pos - '0 -22 0', "gfx/hud/sb_invinc", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE,\r
+ bound(0, (ceil(dt) - dt) / 0.5, 1));\r
+ }\r
+ else\r
+ {\r
+ drawpic(pos - '0 -22 0', "gfx/hud/sb_invinc", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE);\r
+ }\r
+ Sbar_DrawXNum(pos - '30 -24 0', ceil(dt), 2, 0, countdown_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ }\r
+ else if(dt > -1)\r
+ {\r
+ drawpic_expanding(pos - '0 -22 0', "gfx/hud/sb_invinc", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE,\r
+ bound(0, -dt / 0.5, 1));\r
+ }\r
+ }\r
+}\r
+\r
+#define CENTERPRINT_MAX_LINES 30\r
+string centerprint_messages[CENTERPRINT_MAX_LINES];\r
+float centerprint_width[CENTERPRINT_MAX_LINES];\r
+vector centerprint_start;\r
+float centerprint_expire;\r
+float centerprint_num;\r
+float centerprint_offset_hint;\r
+vector centerprint_fontsize;\r
+\r
+void centerprint(string strMessage)\r
+{\r
+ float i, j, n, hcount;\r
+ string s;\r
+\r
+ centerprint_fontsize = Sbar_GetFontsize("scr_centersize");\r
+\r
+ centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out\r
+\r
+ if(cvar("scr_centertime") <= 0)\r
+ return;\r
+\r
+ if(strMessage == "")\r
+ return;\r
+\r
+ // strip trailing newlines\r
+ j = strlen(strMessage) - 1;\r
+ while(substring(strMessage, j, 1) == "\n" && j >= 0)\r
+ j = j - 1;\r
+ strMessage = substring(strMessage, 0, j + 1);\r
+\r
+ if(strMessage == "")\r
+ return;\r
+\r
+ // strip leading newlines and remember them, they are a hint that the message should be lower on the screen\r
+ j = 0;\r
+ while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))\r
+ j = j + 1;\r
+ strMessage = substring(strMessage, j, strlen(strMessage) - j);\r
+ centerprint_offset_hint = j;\r
+\r
+ if(strMessage == "")\r
+ return;\r
+\r
+ // if we get here, we have a message. Initialize its height.\r
+ centerprint_num = 0;\r
+\r
+ n = tokenizebyseparator(strMessage, "\n");\r
+ i = hcount = 0;\r
+ for(j = 0; j < n; ++j)\r
+ {\r
+ getWrappedLine_remaining = argv(j);\r
+ while(getWrappedLine_remaining)\r
+ {\r
+ s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);\r
+ if(centerprint_messages[i])\r
+ strunzone(centerprint_messages[i]);\r
+ centerprint_messages[i] = strzone(s);\r
+ centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);\r
+ ++i;\r
+\r
+ // half height for empty lines looks better\r
+ if(s == "")\r
+ hcount += 0.5;\r
+ else\r
+ hcount += 1;\r
+\r
+ if(i >= CENTERPRINT_MAX_LINES)\r
+ break;\r
+ }\r
+ }\r
+\r
+ float h, havail;\r
+ h = centerprint_fontsize_y*hcount;\r
+\r
+ havail = vid_conheight;\r
+ if(cvar("con_chatpos") < 0)\r
+ havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat\r
+ if(havail > vid_conheight / 4)\r
+ havail = vid_conheight / 4; // avoid overlapping HUD\r
+\r
+ centerprint_start_x = 0;\r
+\r
+#if 0\r
+ float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;\r
+\r
+ // here, the centerprint would cover the crosshair. REALLY BAD.\r
+ forbiddenmin = vid_conheight * 0.5 - h - 16;\r
+ forbiddenmax = vid_conheight * 0.5 + 16;\r
+\r
+ allowedmin = scoreboard_bottom;\r
+ allowedmax = havail - h;\r
+ preferred = (havail - h)/2;\r
+\r
+\r
+ // possible orderings (total: 4! / 4 = 6)\r
+ // allowedmin allowedmax forbiddenmin forbiddenmax\r
+ // forbiddenmin forbiddenmax allowedmin allowedmax\r
+ if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)\r
+ {\r
+ // forbidden doesn't matter in this case\r
+ centerprint_start_y = bound(allowedmin, preferred, allowedmax);\r
+ }\r
+ // allowedmin forbiddenmin allowedmax forbiddenmax\r
+ else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)\r
+ {\r
+ centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);\r
+ }\r
+ // allowedmin forbiddenmin forbiddenmax allowedmax\r
+ else if(allowedmin < forbiddenmin)\r
+ {\r
+ // make sure the forbidden zone is not covered\r
+ if(preferred > (forbiddenmin + forbiddenmax) * 0.5)\r
+ centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);\r
+ else\r
+ centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);\r
+ }\r
+ // forbiddenmin allowedmin allowedmax forbiddenmax\r
+ else if(allowedmax < forbiddenmax)\r
+ {\r
+ // it's better to leave the allowed zone (overlap with scoreboard) than\r
+ // to cover the forbidden zone (crosshair)\r
+ if(preferred > (forbiddenmin + forbiddenmax) * 0.5)\r
+ centerprint_start_y = forbiddenmax;\r
+ else\r
+ centerprint_start_y = forbiddenmin;\r
+ }\r
+ // forbiddenmin allowedmin forbiddenmax allowedmax\r
+ else\r
+ {\r
+ centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);\r
+ }\r
+#else\r
+ centerprint_start_y =\r
+ min(\r
+ max(\r
+ max(scoreboard_bottom, vid_conheight * 0.5 + 16),\r
+ (havail - h)/2\r
+ ),\r
+ havail - h\r
+ );\r
+#endif\r
+\r
+ centerprint_num = i;\r
+ centerprint_expire = time + cvar("scr_centertime");\r
+}\r
+\r
+void Sbar_DrawCenterPrint (void)\r
+{\r
+ float i;\r
+ vector pos;\r
+ string ts;\r
+ float a;\r
+\r
+ //if(time > centerprint_expire)\r
+ // return;\r
+\r
+ //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);\r
+ a = bound(0, 1 - 4 * (time - centerprint_expire), 1);\r
+ //sz = 1.2 / (a + 0.2);\r
+\r
+ if(a <= 0)\r
+ return;\r
+\r
+ pos = centerprint_start;\r
+ for (i=0; i<centerprint_num; i = i + 1)\r
+ {\r
+ pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;\r
+ ts = centerprint_messages[i];\r
+ if (ts != "")\r
+ {\r
+ dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)\r
+ drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);\r
+ // - '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
+ pos_y = pos_y + centerprint_fontsize_y;\r
+ }\r
+ else\r
+ // half height for empty lines looks better\r
+ pos_y = pos_y + centerprint_fontsize_y * 0.5;\r
+ }\r
+}\r
+\r
+vector Sbar_DrawNoteLine(vector offset, string s)\r
+{\r
+ dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)\r
+ drawcolorcodedstring(\r
+ offset - '1 0 0' * stringwidth(s, TRUE, sbar_fontsize),\r
+ s,\r
+ sbar_fontsize,\r
+ sbar_alpha_fg,\r
+ 0\r
+ );\r
+ return offset + sbar_fontsize_y * '0 1 0';\r
+}\r
+\r
+void Sbar_DrawPressedKeys(void)\r
+{\r
+ vector pos, bgsize;\r
+ float pressedkeys;\r
+\r
+ pos = stov(cvar_string("cl_showpressedkeys_position"));\r
+\r
+ bgsize = '126 75 0';\r
+\r
+ pos = '1 0 0' * (vid_conwidth - bgsize_x) * pos_x\r
+ + '0 1 0' * (vid_conheight - bgsize_y) * pos_y;\r
+ pos -= '-15 -6 0'; // adjust to the origin of these numbers\r
+\r
+ pressedkeys = getstatf(STAT_PRESSED_KEYS);\r
+ drawpic(pos + '-15 -6 0', "gfx/hud/keys/key_bg.tga", bgsize, '1 1 1', 0.1 * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawpic(pos + ' 83.5 9 0', ((pressedkeys & KEY_CROUCH) ? "gfx/hud/keys/key_crouch_inv.tga" : "gfx/hud/keys/key_crouch.tga"), ' 24 24 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawpic(pos + ' 32 -1.5 0', ((pressedkeys & KEY_FORWARD) ? "gfx/hud/keys/key_forward_inv.tga" : "gfx/hud/keys/key_forward.tga"), ' 32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawpic(pos + '-11.5 9 0', ((pressedkeys & KEY_JUMP) ? "gfx/hud/keys/key_jump_inv.tga" : "gfx/hud/keys/key_jump.tga"), ' 24 24 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawpic(pos + ' -1 32 0', ((pressedkeys & KEY_LEFT) ? "gfx/hud/keys/key_left_inv.tga" : "gfx/hud/keys/key_left.tga"), ' 32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawpic(pos + ' 32 32 0', ((pressedkeys & KEY_BACKWARD) ? "gfx/hud/keys/key_backward_inv.tga" : "gfx/hud/keys/key_backward.tga"), ' 32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawpic(pos + ' 65 32 0', ((pressedkeys & KEY_RIGHT) ? "gfx/hud/keys/key_right_inv.tga" : "gfx/hud/keys/key_right.tga"), ' 32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+}\r
+\r
+void Sbar_ShowSpeed(void)\r
+{\r
+ vector numsize;\r
+ float pos, conversion_factor;\r
+ string speed, zspeed, unit;\r
+\r
+ switch(cvar("cl_showspeed_unit"))\r
+ {\r
+ default:\r
+ case 0:\r
+ unit = "";\r
+ conversion_factor = 1.0;\r
+ break;\r
+ case 1:\r
+ unit = " qu/s";\r
+ conversion_factor = 1.0;\r
+ break;\r
+ case 2:\r
+ unit = " m/s";\r
+ conversion_factor = 0.0254;\r
+ break;\r
+ case 3:\r
+ unit = " km/h";\r
+ conversion_factor = 0.0254 * 3.6;\r
+ break;\r
+ case 4:\r
+ unit = " mph";\r
+ conversion_factor = 0.0254 * 3.6 * 0.6213711922;\r
+ break;\r
+ case 5:\r
+ unit = " knots";\r
+ conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h\r
+ break;\r
+ }\r
+\r
+ speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);\r
+\r
+ numsize_x = numsize_y = cvar("cl_showspeed_size");\r
+ pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");\r
+ \r
+ drawfont = sbar_bigfont;\r
+ drawstringcenter('1 0 0' + pos * '0 1 0', speed, numsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+ if (cvar("cl_showspeed_z") == 1) {\r
+ zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);\r
+ 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
+ }\r
+\r
+ drawfont = sbar_font;\r
+}\r
+\r
+vector acc_prevspeed;\r
+float acc_prevtime;\r
+float acc_avg;\r
+\r
+void Sbar_ShowAcceleration(void)\r
+{\r
+ float acceleration, sz, scale, alpha, f;\r
+ vector pos, top, rgb;\r
+ top_x = vid_conwidth/2;\r
+ top_y = 0;\r
+\r
+ f = time - acc_prevtime;\r
+ if(cvar("cl_showacceleration_z"))\r
+ acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);\r
+ else\r
+ acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);\r
+ acc_prevspeed = pmove_vel;\r
+ acc_prevtime = time;\r
+\r
+ f = bound(0, f * 10, 1);\r
+ acc_avg = acc_avg * (1 - f) + acceleration * f;\r
+ acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);\r
+\r
+ pos = top - sz/2 * '0 1 0' + (cvar("cl_showacceleration_position") * vid_conheight) * '0 1 0';\r
+\r
+ sz = cvar("cl_showacceleration_size");\r
+ scale = cvar("cl_showacceleration_scale");\r
+ alpha = cvar("cl_showacceleration_alpha");\r
+ if (cvar("cl_showacceleration_color_custom"))\r
+ rgb = stov(cvar_string("cl_showacceleration_color"));\r
+ else {\r
+ rgb = '1 1 1';\r
+ if (acceleration < 0) {\r
+ rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);\r
+ } else if (acceleration > 0) {\r
+ rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);\r
+ }\r
+ }\r
+ \r
+ if (acceleration > 0)\r
+ drawpic(pos, "gfx/hud/accelerometer_gradient", acceleration * scale * '40 0 0' + sz * '0 1 0', rgb, alpha * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ else if (acceleration < 0)\r
+ drawpic(pos + acceleration * scale * '40 0 0', "gfx/hud/accelerometer_gradient", -acceleration * scale * '40 0 0' + sz * '0 1 0', rgb, alpha * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+}\r
+\r
+void Sbar_DrawAccuracyStats_Description_Hitscan(vector position)\r
+{\r
+ drawstring(position + '0 3 0' * sbar_fontsize_y, "Shots fired:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawstring(position + '0 5 0' * sbar_fontsize_y, "Shots hit:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawstring(position + '0 7 0' * sbar_fontsize_y, "Accuracy:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawstring(position + '0 9 0' * sbar_fontsize_y, "Shots missed:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+}\r
+\r
+/*void Sbar_DrawAccuracyStats_Description_Splash(vector position)\r
+{\r
+ drawstring(position + '0 3 0' * sbar_fontsize_y, "Maximum damage:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawstring(position + '0 5 0' * sbar_fontsize_y, "Actual damage:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawstring(position + '0 7 0' * sbar_fontsize_y, "Accuracy:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawstring(position + '0 9 0' * sbar_fontsize_y, "Damage wasted:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+}*/ // we have no splash damage weapons, but keep this code just in case\r
+\r
+void Sbar_DrawAccuracyStats()\r
+{\r
+ float i, count_hitscan, /*count_splash,*/ row_hitscan/*, row_splash*/; // count is the number of 'colums'\r
+ float weapon_hit, weapon_damage, weapon_stats;\r
+ float left_border; // position where the weapons start, the description is in the border\r
+ vector fill_colour, fill_size;\r
+ vector pos;\r
+ vector border_colour;\r
+\r
+ float col_margin = 20; // pixels between the columns\r
+ float row_margin = 20; // pixels between the rows\r
+\r
+ fill_size_x = 5 * sbar_fontsize_x; // width of the background\r
+ fill_size_y = 10 * sbar_fontsize_y; // height of the background\r
+\r
+ drawfont = sbar_bigfont;\r
+ pos_x = 0;\r
+ pos_y = cvar("sbar_scoreboard_offset");\r
+ pos_z = 0;\r
+ drawstringcenter(pos, "Weapon Accuracy", 2 * sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+ left_border = col_margin + 11 * sbar_fontsize_x;\r
+\r
+ drawfont = sbar_font;\r
+\r
+ if(warmup_stage)\r
+ {\r
+ pos_y += 40;\r
+ if(mod(time, 1) >= 0.4)\r
+ drawstringcenter(pos, "Stats are not tracked during warmup stage", sbar_fontsize, '1 1 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+ return;\r
+ }\r
+\r
+ if(gametype == GAME_RACE || gametype == GAME_CTS)\r
+ {\r
+ pos_y += 40;\r
+ if(mod(time, 1) >= 0.4)\r
+ drawstringcenter(pos, "Stats are not tracked in Race/CTS", sbar_fontsize, '1 1 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+ return;\r
+ }\r
+\r
+ float top_border_hitscan = cvar("sbar_scoreboard_offset") + 55; // position where the hitscan row starts: pixels down the screen\r
+ Sbar_DrawAccuracyStats_Description_Hitscan('1 0 0' * col_margin + '0 1 0' * top_border_hitscan);\r
+\r
+// float top_border_splash = cvar("sbar_scoreboard_offset") + 175; // position where the splash row starts: pixels down the screen\r
+// Sbar_DrawAccuracyStats_Description_Splash('1 0 0' * col_margin + '0 1 0' * top_border_splash);\r
+\r
+ for(i = WEP_FIRST; i <= WEP_LAST; ++i)\r
+ {\r
+ self = get_weaponinfo(i);\r
+ if not(self.weapons)\r
+ continue;\r
+ weapon_hit = weapon_hits[i-WEP_FIRST];\r
+ weapon_damage = weapon_fired[i-WEP_FIRST];\r
+ border_colour = (i == activeweapon) ? '1 1 1' : '0 0 0'; // white or black border\r
+\r
+ if (weapon_damage) {\r
+ /*if (self.spawnflags & WEP_TYPE_SPLASH) {\r
+ weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100);\r
+\r
+ fill_colour_x = 1 - 0.015 * weapon_stats;\r
+ fill_colour_y = 1 - 0.015 * (100 - weapon_stats);\r
+\r
+ // how the background colour is calculated\r
+ // % red green red_2 green_2\r
+ // 0 1 0 1 - % * 0.015 1 - (100 - %) * 0.015\r
+ // 10 0.85 0 1 - % * 0.015 1 - (100 - %) * 0.015\r
+ // 20 0.70 0 1 - % * 0.015 1 - (100 - %) * 0.015\r
+ // 30 0.55 0 1 - % * 0.015 1 - (100 - %) * 0.015\r
+ // 40 0.40 0.10 1 - % * 0.015 1 - (100 - %) * 0.015\r
+ // 50 0.25 0.25 1 - % * 0.015 1 - (100 - %) * 0.015\r
+ // 60 0.10 0.40 1 - % * 0.015 1 - (100 - %) * 0.015\r
+ // 70 0 0.55 1 - % * 0.015 1 - (100 - %) * 0.015\r
+ // 80 0 0.70 1 - % * 0.015 1 - (100 - %) * 0.015\r
+ // 90 0 0.85 1 - % * 0.015 1 - (100 - %) * 0.015\r
+ // 100 0 1 1 - % * 0.015 1 - (100 - %) * 0.015\r
+\r
+ if ((left_border + count_splash * (fill_size_x + col_margin) + fill_size_x) >= vid_conwidth)\r
+ {\r
+ count_splash = 0;\r
+ ++row_splash;\r
+ Sbar_DrawAccuracyStats_Description_Splash('1 0 0' * col_margin + '0 1 0' * (top_border_splash + row_splash * (fill_size_y + row_margin)));\r
+ }\r
+\r
+ pos_x = left_border + count_splash * (fill_size_x + col_margin);\r
+ pos_y = top_border_splash + row_splash * (fill_size_y + row_margin);\r
+\r
+ // background\r
+ drawpic(pos, "gfx/hud/sb_accuracy", fill_size , fill_colour, sbar_alpha_bg, DRAWFLAG_NORMAL);\r
+ drawborderlines(sbar_border_thickness, pos, fill_size, border_colour, sbar_alpha_bg, DRAWFLAG_NORMAL);\r
+\r
+ // the weapon\r
+ drawpic(pos, strcat("gfx/hud/inv_weapon", self.netname), '1 0.5 0' * fill_size_x , '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+ // the amount of shots fired or max damage\r
+ 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
+\r
+ // the amount of hits or actual damage\r
+ 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
+\r
+ // the accuracy\r
+ 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
+\r
+ // the amount of shots missed or damage wasted\r
+ 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
+\r
+ ++count_splash;\r
+ } else*/ // we have no splash damage weapons, but keep this code just in case\r
+\r
+ if (self.spawnflags & WEP_TYPE_HITSCAN) {\r
+ weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100);\r
+\r
+ fill_colour_x = 1 - 0.015 * weapon_stats;\r
+ fill_colour_y = 1 - 0.015 * (100 - weapon_stats);\r
+\r
+ // how the background colour is calculated\r
+ // % red green red_2 green_2\r
+ // 0 1 0 1 - % * 0.015 1 - (100 - %) * 0.015\r
+ // 10 0.850 0 1 - % * 0.015 1 - (100 - %) * 0.015\r
+ // 20 0.70 0 1 - % * 0.015 1 - (100 - %) * 0.015\r
+ // 30 0.55 0 1 - % * 0.015 1 - (100 - %) * 0.015\r
+ // 40 0.40 0.10 1 - % * 0.015 1 - (100 - %) * 0.015\r
+ // 50 0.25 0.25 1 - % * 0.015 1 - (100 - %) * 0.015\r
+ // 60 0.10 0.40 1 - % * 0.015 1 - (100 - %) * 0.015\r
+ // 70 0 0.55 1 - % * 0.015 1 - (100 - %) * 0.015\r
+ // 80 0 0.70 1 - % * 0.015 1 - (100 - %) * 0.015\r
+ // 90 0 0.85 1 - % * 0.015 1 - (100 - %) * 0.015\r
+ // 100 0 1 1 - % * 0.015 1 - (100 - %) * 0.015\r
+\r
+ if ((left_border + count_hitscan * (fill_size_x + col_margin) + fill_size_x + cvar("stats_right_margin")) >= vid_conwidth)\r
+ {\r
+ count_hitscan = 0;\r
+ ++row_hitscan;\r
+ Sbar_DrawAccuracyStats_Description_Hitscan('1 0 0' * col_margin + '0 1 0' * (top_border_hitscan + row_hitscan * (fill_size_y + row_margin)));\r
+ }\r
+\r
+ pos_x = left_border + count_hitscan * (fill_size_x + col_margin);\r
+ pos_y = top_border_hitscan + row_hitscan * (fill_size_y + row_margin);\r
+\r
+ // background\r
+ drawpic(pos, "gfx/hud/sb_accuracy", fill_size , fill_colour, sbar_alpha_bg, DRAWFLAG_NORMAL);\r
+ drawborderlines(sbar_border_thickness, pos, fill_size, border_colour, sbar_alpha_bg, DRAWFLAG_NORMAL);\r
+\r
+ // the weapon\r
+ drawpic(pos, strcat("gfx/hud/inv_weapon", self.netname), '1 0.5 0' * fill_size_x , '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+ // the amount of shots fired or max damage\r
+ 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
+\r
+ // the amount of hits or actual damage\r
+ 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
+\r
+ // the accuracy\r
+ 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
+\r
+ // the amount of shots missed or damage wasted\r
+ 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
+\r
+ ++count_hitscan;\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)\r
+{\r
+ position_x -= 2 / 3 * strlen(text) * scale_x;\r
+ drawstring(position, text, scale, rgb, alpha, flag);\r
+}\r
+\r
+void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)\r
+{\r
+ position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);\r
+ drawstring(position, text, scale, rgb, alpha, flag);\r
+}\r
+\r
+void Sbar_Reset (void)\r
+{\r
+ // reset gametype specific icons\r
+ if(gametype == GAME_KEYHUNT)\r
+ CSQC_kh_hudreset();\r
+ else if(gametype == GAME_CTF)\r
+ CSQC_ctf_hudreset();\r
+}\r
+\r
+float vote_yescount;\r
+float vote_nocount;\r
+float vote_needed;\r
+float vote_highlighted; // currently selected vote\r
+\r
+float vote_active; // is there an active vote?\r
+float vote_prev; // previous state of vote_active to check for a change\r
+float vote_alpha;\r
+float vote_change; // "time" when vote_active changed\r
+\r
+vector stomachstatus_colorfade_current;\r
+vector StomachStatus_ColorFade(vector target_color)\r
+{\r
+ local float step;\r
+ step = cvar("sbar_stomachboard_status_fade") * frametime;\r
+\r
+ if(stomachstatus_colorfade_current_x >= target_color_x + step)\r
+ stomachstatus_colorfade_current_x -= step;\r
+ else if(stomachstatus_colorfade_current_x <= target_color_x - step)\r
+ stomachstatus_colorfade_current_x += step;\r
+\r
+ if(stomachstatus_colorfade_current_y >= target_color_y + step)\r
+ stomachstatus_colorfade_current_y -= step;\r
+ else if(stomachstatus_colorfade_current_y <= target_color_y - step)\r
+ stomachstatus_colorfade_current_y += step;\r
+\r
+ if(stomachstatus_colorfade_current_z >= target_color_z + step)\r
+ stomachstatus_colorfade_current_z -= step;\r
+ else if(stomachstatus_colorfade_current_z <= target_color_z - step)\r
+ stomachstatus_colorfade_current_z += step;\r
+\r
+ return stomachstatus_colorfade_current;\r
+}\r
+\r
+void Sbar_Draw (void)\r
+{\r
+ // vectors for top right, bottom right, bottom and bottom left corners\r
+ vector topright;\r
+ vector bottom;\r
+ vector bottomright;\r
+ vector bottomleft;\r
+\r
+ topright_x = vid_conwidth;\r
+ topright_y = 0;\r
+ topright_z = 0;\r
+\r
+ bottom_x = vid_conwidth/2;\r
+ bottom_y = vid_conheight;\r
+ bottom_z = 0;\r
+\r
+ bottomright_x = vid_conwidth;\r
+ bottomright_y = vid_conheight;\r
+ bottomright_z = 0;\r
+\r
+ bottomleft_x = 0;\r
+ bottomleft_y = vid_conheight;\r
+ bottomleft_z = 0;\r
+\r
+ sbar_alpha_bg = cvar("sbar_alpha_bg") * (1 - cvar("_menu_alpha"));\r
+ sbar_border_thickness = bound(0, cvar("sbar_border_thickness"), 5);\r
+ sbar_accuracy_border_thickness = bound(0, cvar_or("sbar_accuracy_border_thickness", 1), 5);\r
+ sbar_color_bg_team = cvar("sbar_color_bg_team");\r
+\r
+ float weapon_stats;\r
+ float fade;\r
+\r
+ weapon_stats = getstati(STAT_DAMAGE_HITS);\r
+ weapon_number = weapon_stats & 63;\r
+ weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);\r
+\r
+ weapon_stats = getstati(STAT_DAMAGE_FIRED);\r
+ weapon_number = weapon_stats & 63;\r
+ weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);\r
+\r
+ vector o; o = '1 0 0' * vid_conwidth;\r
+ o_y = 28; // move spectator text slightly down to prevent overlapping the timer\r
+\r
+ string s;\r
+ vector pos;\r
+ pos = '0 0 0';\r
+\r
+ sbar_fontsize = Sbar_GetFontsize("sbar_fontsize");\r
+ sbar_fontsize_spec = Sbar_GetFontsize("sbar_fontsize_spec");\r
+ if(sbar_fontsize != sbar_oldfontsize)\r
+ {\r
+ Cmd_Sbar_SetFields(0);\r
+ sbar_oldfontsize = sbar_fontsize;\r
+ }\r
+\r
+ if(spectatee_status && !intermission)\r
+ {\r
+ drawfont = sbar_bigfont;\r
+ if(spectatee_status == -1)\r
+ s = "^1Observing";\r
+ else\r
+ s = GetPlayerName(spectatee_status - 1);\r
+ // spectated player name between HUD and chat area, aligned to the left\r
+ pos_x = bottomleft_x;\r
+ pos_y = bottom_y - 200 - sbar_fontsize_spec_y;\r
+ s = textShortenToWidth(s, vid_conwidth/2.5, sbar_fontsize_spec, stringwidth_colors);\r
+ drawcolorcodedstring(pos, s, sbar_fontsize_spec, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawfont = sbar_font;\r
+\r
+ // spectator text in the upper right corner\r
+ if(spectatee_status == -1)\r
+ s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");\r
+ else\r
+ s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");\r
+ o = Sbar_DrawNoteLine(o, s);\r
+\r
+ if(spectatee_status == -1)\r
+ s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");\r
+ else\r
+ s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");\r
+ o = Sbar_DrawNoteLine(o, s);\r
+\r
+ s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");\r
+ o = Sbar_DrawNoteLine(o, s);\r
+\r
+ if(gametype == GAME_ARENA)\r
+ s = "^1Wait for your turn to join";\r
+ else if(gametype == GAME_LMS)\r
+ {\r
+ entity sk;\r
+ sk = playerslots[player_localentnum - 1];\r
+ if(sk.(scores[ps_primary]) >= 666)\r
+ s = "^1Match has already begun";\r
+ else if(sk.(scores[ps_primary]) > 0)\r
+ s = "^1You have no more lives left";\r
+ else\r
+ s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");\r
+ }\r
+ else\r
+ s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");\r
+ o = Sbar_DrawNoteLine(o, s);\r
+\r
+ //show restart countdown:\r
+ if (time < getstatf(STAT_GAMESTARTTIME)) {\r
+ float countdown;\r
+ //we need to ceil, otherwise the countdown would be off by .5 when using round()\r
+ countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);\r
+ s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");\r
+ o = Sbar_DrawNoteLine(o, s);\r
+ }\r
+ }\r
+ if(warmup_stage && !intermission)\r
+ {\r
+ s = "^2Currently in ^1warmup^2 stage!";\r
+ o = Sbar_DrawNoteLine(o, s);\r
+ }\r
+\r
+ // move more important stuff more to the middle so its more visible\r
+ o_y = vid_conheight * 0.66;\r
+\r
+ string blinkcolor;\r
+ if(mod(time, 1) >= 0.5)\r
+ blinkcolor = "^1";\r
+ else\r
+ blinkcolor = "^3";\r
+\r
+ if(ready_waiting && !intermission && !spectatee_status)\r
+ {\r
+ if(ready_waiting_for_me)\r
+ {\r
+ if(warmup_stage)\r
+ s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");\r
+ else\r
+ s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");\r
+ }\r
+ else\r
+ {\r
+ if(warmup_stage)\r
+ s = strcat("^2Waiting for others to ready up to end warmup...");\r
+ else\r
+ s = strcat("^2Waiting for others to ready up...");\r
+ }\r
+ o = Sbar_DrawNoteLine(o, s);\r
+ }\r
+ else if(warmup_stage && !intermission && !spectatee_status)\r
+ {\r
+ s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");\r
+ o = Sbar_DrawNoteLine(o, s);\r
+ }\r
+\r
+ if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)\r
+ {\r
+ entity tm;\r
+ float ts_min, ts_max;\r
+ tm = teams.sort_next;\r
+ if (tm)\r
+ {\r
+ for(; tm.sort_next; tm = tm.sort_next)\r
+ {\r
+ if(!tm.team_size || tm.team == COLOR_SPECTATOR)\r
+ continue;\r
+ if(!ts_min) ts_min = tm.team_size;\r
+ else ts_min = min(ts_min, tm.team_size);\r
+ if(!ts_max) ts_max = tm.team_size;\r
+ else ts_max = max(ts_max, tm.team_size);\r
+ }\r
+ if ((ts_max - ts_min) > 1)\r
+ {\r
+ s = strcat(blinkcolor, "Teamnumbers are unbalanced!");\r
+ tm = GetTeam(myteam, false);\r
+ if (tm)\r
+ if (tm.team != COLOR_SPECTATOR)\r
+ if (tm.team_size == ts_max)\r
+ s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");\r
+\r
+ o = Sbar_DrawNoteLine(o, s);\r
+ }\r
+ }\r
+ }\r
+\r
+ if(vote_active != vote_prev) {\r
+ vote_change = time;\r
+ vote_prev = bound(0, vote_active, 1);\r
+ }\r
+\r
+ if(vote_active)\r
+ vote_alpha = bound(0, (time - vote_change) * 2, 1);\r
+ else\r
+ vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);\r
+\r
+ if(vote_alpha) {\r
+ float a;\r
+ a = vote_alpha * bound(cvar_or("sbar_vote_alreadyvoted_alpha", 0.75), 1 - vote_highlighted, 1);\r
+\r
+ if (teamplay)\r
+ color = GetTeamRGB(myteam) * sbar_color_bg_team;\r
+ else\r
+ color = stov(cvar_string("sbar_color_bg"));\r
+\r
+ vector voteorigin = bottomright - '290 135 0';\r
+ vector votesize = '280 70 0';\r
+ drawpic(voteorigin, "gfx/hud/voteprogress_back", votesize, color, a * sbar_alpha_bg, DRAWFLAG_NORMAL);\r
+\r
+ s = "A vote has been called for: ";\r
+ 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
+ s = textShortenToWidth(vote_called_vote, votesize_x * 0.96, '10 0 0', stringwidth_colors);\r
+ 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
+\r
+ // print the yes/no counts\r
+ s = strcat("Yes: ", ftos(vote_yescount));\r
+ 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
+ s = strcat("No: ", ftos(vote_nocount));\r
+ 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
+\r
+ // draw the progress bars\r
+ drawsetcliparea(voteorigin_x, voteorigin_y, votesize_x * 0.5 * (vote_yescount/vote_needed), votesize_y);\r
+ drawpic(voteorigin, "gfx/hud/voteprogress_prog", votesize, '0 1 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+ drawsetcliparea(voteorigin_x + votesize_x - votesize_x * 0.5 * (vote_nocount/vote_needed), voteorigin_y, votesize_x * 0.5, votesize_y);\r
+ drawpic(voteorigin, "gfx/hud/voteprogress_prog", votesize, '1 0 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+ // draw the highlights\r
+ if(vote_highlighted == 1) {\r
+ drawsetcliparea(voteorigin_x, voteorigin_y, votesize_x * 0.5, votesize_y);\r
+ drawpic(voteorigin, "gfx/hud/voteprogress_voted", votesize, '0 1 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ }\r
+ else if(vote_highlighted == 2) {\r
+ drawsetcliparea(voteorigin_x + 0.5 * votesize_x, voteorigin_y, votesize_x * 0.5, votesize_y);\r
+ drawpic(voteorigin, "gfx/hud/voteprogress_voted", votesize, '1 0 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ }\r
+\r
+ drawresetcliparea();\r
+ }\r
+ else if(!vote_active) {\r
+ vote_highlighted = 0;\r
+ }\r
+\r
+ Sbar_UpdatePlayerTeams();\r
+ if (intermission == 2) // map voting screen\r
+ {\r
+ Sbar_Timer();\r
+ if(sb_showscores)\r
+ Sbar_DrawScoreboard();\r
+ else\r
+ Sbar_FinaleOverlay();\r
+\r
+ Sbar_Reset();\r
+ }\r
+ else if (sb_showscores_force || getstati(STAT_HEALTH) <= 0 || intermission == 1)\r
+ {\r
+ Sbar_DrawScoreboard();\r
+ Sbar_Score();\r
+ Sbar_Timer();\r
+ if(getstati(STAT_VORE_EATEN))\r
+ Sbar_Status();\r
+\r
+ Sbar_Reset();\r
+\r
+ StomachStatus_ColorFade('0 0 0');\r
+ }\r
+ else\r
+ {\r
+ if(sb_showaccuracy && spectatee_status != -1)\r
+ Sbar_DrawAccuracyStats();\r
+ else\r
+ Sbar_DrawScoreboard();\r
+\r
+ fade = 3.2 - 2 * (time - weapontime);\r
+ fade = bound(0.7, fade, 1);\r
+\r
+ // when a player's armor is below the necessary level, subsystems will not work\r
+ if(getstati(STAT_HEALTH) > 0)\r
+ {\r
+ vector warn_pos;\r
+ warn_pos_x = vid_conwidth / 2;\r
+ warn_pos_y = vid_conheight - vid_conheight / 2.5;\r
+ if(getstati(STAT_ARMOR) < g_power)\r
+ {\r
+ // subsystems are down\r
+ drawpic(warn_pos - '128 0 0', "gfx/hud/sb_power_fail", '256 256 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawpic(warn_pos - '16 0 0' + '0 150 0', "gfx/hud/sb_power_fail_icon", '32 32 0', '1 1 1', sbar_alpha_fg * (0.5 + sin(time * 5) / 2), DRAWFLAG_NORMAL);\r
+ power_boot = time + g_power_reboot;\r
+ return; // skip drawing the HUD\r
+ }\r
+ else if(time <= power_boot)\r
+ {\r
+ // subsystems are rebooting\r
+ drawpic(warn_pos - '128 0 0', "gfx/hud/sb_power_reboot", '256 256 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawpic(warn_pos - '16 0 0' + '0 150 0', "gfx/hud/sb_power_reboot_icon", '32 32 0', '1 1 1', sbar_alpha_fg * (0.5 + sin(time * 5) / 2), DRAWFLAG_NORMAL);\r
+ return; // skip drawing the HUD\r
+ }\r
+ }\r
+\r
+ if(g_vore) // only when the vore system is active\r
+ {\r
+ // draw the stomach board\r
+ if (cvar("viewsize") <= 100) {\r
+ if (teamplay)\r
+ drawpic(bottomleft- '0 256 0', "gfx/hud/bg_stomach", '256 256 0', GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // hud color = myteam color\r
+ else {\r
+ // allow for custom HUD colors in non-teamgames\r
+ color = stov(cvar_string("sbar_color_bg"));\r
+\r
+ drawpic(bottomleft - '0 256 0', "gfx/hud/bg_stomach", '256 256 0', color, sbar_alpha_bg, DRAWFLAG_NORMAL);\r
+ }\r
+ }\r
+\r
+ vector hl_color;\r
+ string hl_string;\r
+ if(getstati(STAT_VORE_EATEN))\r
+ {\r
+ 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
+ hl_color = stov(cvar_string("sbar_stomachboard_color2"));\r
+ else\r
+ hl_color = stov(cvar_string("sbar_stomachboard_color3"));\r
+ hl_string = "predator:";\r
+ }\r
+ else\r
+ {\r
+ hl_color = stov(cvar_string("sbar_stomachboard_color1"));\r
+ hl_string = "self:";\r
+ }\r
+ drawpic(bottomleft - '0 256 0', "gfx/hud/bg_stomach_status", '256 256 0', StomachStatus_ColorFade(hl_color), cvar("sbar_stomachboard_status_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawstring(bottomleft - '-80 173 0', hl_string, '11 11 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+ float stomach_load, stomach_maxload; // shows the predator's stomach load when we are eaten, and ours otherwise\r
+ stomach_load = getstati(STAT_VORE_LOAD);\r
+ stomach_maxload = getstati(STAT_VORE_MAXLOAD);\r
+\r
+ vector status_pos;\r
+ string status_text, status_color;\r
+ float status_size;\r
+ status_color = rgb_to_hexcolor('0.5 0.5 0.5' + Sbar_NumColor(stomach_maxload) * 0.5); // twice brighter than health / armor colors\r
+ if(stomach_load)\r
+ {\r
+ status_text = strcat(ftos(stomach_load), "^8/", status_color, ftos(stomach_maxload));\r
+ status_pos = bottomleft - '-43 168 0';\r
+ status_size = 16;\r
+ }\r
+ else if(g_healthsize_center >= 0) // no point in showing it otherwise\r
+ {\r
+ status_text = strcat(status_color, ftos(stomach_maxload));\r
+ status_pos = bottomleft - '-43 170 0';\r
+ status_size = 20;\r
+ }\r
+ status_pos -= '1 0 0' * stringwidth(status_text, TRUE, '1 0 0' * status_size) * 0.5;\r
+ drawcolorcodedstring(status_pos, status_text, '1 1 0' * status_size, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+ if(getstati(STAT_VORE_DIGESTING)) // we are currently digesting\r
+ drawpic(bottomleft - '-35 149 0', "gfx/hud/sb_digestion", '16 16 0', '0 1 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ else if(stomach_load) // we can digest at this time\r
+ drawpic(bottomleft - '-35 149 0', "gfx/hud/sb_digestion", '16 16 0', '0.25 0.25 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ else // we cannot digest at this time\r
+ drawpic(bottomleft - '-35 149 0', "gfx/hud/sb_digestion", '16 16 0', '0.25 0 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+ // draw the stomach board player list\r
+ entity pl, pred;\r
+ float f, l;\r
+\r
+ pos = bottomleft;\r
+ for(pl = players.sort_next; pl; pl = pl.sort_next)\r
+ {\r
+ if(pl.team == COLOR_SPECTATOR)\r
+ continue;\r
+\r
+ if(getstati(STAT_VORE_EATEN))\r
+ f = pl.plpredator == getstati(STAT_VORE_EATEN);\r
+ else\r
+ {\r
+ if(spectatee_status)\r
+ f = pl.plpredator == spectatee_status;\r
+ else\r
+ f = pl.plpredator == player_localentnum;\r
+ }\r
+\r
+ if(f && l <= 8) // limit the stomach board to 9 entries due to the HUD design\r
+ {\r
+ Sbar_PrintStomachboardItem(pos - '-16 124 0', pl);\r
+ pos_y += 1.1 * sbar_fontsize_y;\r
+ l += 1;\r
+ }\r
+\r
+ // set the predator's name\r
+ if(getstati(STAT_VORE_EATEN))\r
+ {\r
+ if(pl.sv_entnum == getstati(STAT_VORE_EATEN) - 1)\r
+ pred = pl;\r
+ }\r
+ else if(pl.sv_entnum == player_localentnum - 1 || pl.sv_entnum == spectatee_status - 1)\r
+ pred = pl; // show us or the spectated player\r
+ }\r
+\r
+ // draw the predator's name\r
+ Sbar_PrintStomachboardItemPred(bottomleft - '-76 150 0', pred);\r
+ }\r
+\r
+ // draw status, scores, timer, and ring\r
+ Sbar_Status();\r
+ Sbar_Score();\r
+ Sbar_Timer();\r
+ Sbar_Ring();\r
+\r
+ // draw strength/invincibility icon and timer\r
+ CSQC_Strength_Timer();\r
+\r
+ // draw gametype specific icons\r
+ if(gametype == GAME_KEYHUNT)\r
+ CSQC_kh_hud();\r
+ else if(gametype == GAME_CTF)\r
+ CSQC_ctf_hud();\r
+ else if(gametype == GAME_CTS || gametype == GAME_RACE)\r
+ CSQC_race_hud();\r
+\r
+ // draw the canleave message\r
+ if(getstati(STAT_VORE_CANLEAVE))\r
+ if not(spectatee_status) // this message doesn't address spectated players\r
+ {\r
+ s = strcat("^7Press ^3", getcommandkey("jump", "+jump"), " ^7to exit");\r
+ pos_x = bottom_x - stringwidth(s, TRUE, '0 0 0') * 16 / 2;\r
+ pos_y = bottom_y - 120;\r
+ drawcolorcodedstring(pos, s, '16 16 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ }\r
+ }\r
+ return;\r
+}\r
+\r
+// CTF HUD\r
+float redflag_prevframe, blueflag_prevframe; // status during previous frame\r
+float redflag_prevstatus, blueflag_prevstatus; // last remembered status\r
+float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed\r
+\r
+void CSQC_ctf_hudreset(void)\r
+{\r
+ redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;\r
+}\r
+\r
+void CSQC_ctf_hud(void)\r
+{\r
+ vector top, redflag_pos, blueflag_pos, sz;\r
+ float f; // every function should have that\r
+ top_x = vid_conwidth / 2;\r
+ top_y = 0;\r
+ top_z = 0;\r
+\r
+ float redflag, blueflag; // current status\r
+ float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed\r
+ float stat_items;\r
+\r
+ stat_items = getstati(STAT_ITEMS);\r
+ redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;\r
+ blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;\r
+\r
+ // when status CHANGES, set old status into prevstatus and current status into status\r
+ if (redflag != redflag_prevframe)\r
+ {\r
+ redflag_statuschange_time = time;\r
+ redflag_prevstatus = redflag_prevframe;\r
+ redflag_prevframe = redflag;\r
+ }\r
+\r
+ if (blueflag != blueflag_prevframe)\r
+ {\r
+ blueflag_statuschange_time = time;\r
+ blueflag_prevstatus = blueflag_prevframe;\r
+ blueflag_prevframe = blueflag;\r
+ }\r
+ \r
+ redflag_statuschange_elapsedtime = time - redflag_statuschange_time;\r
+ blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;\r
+\r
+ float BLINK_FACTOR = 0.15;\r
+ float BLINK_BASE = 0.85;\r
+ // note:\r
+ // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)\r
+ // thus\r
+ // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)\r
+ // ensure RMS == 1\r
+ float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz\r
+\r
+ string red_icon, red_icon_prevstatus;\r
+ float red_alpha, red_alpha_prevstatus;\r
+ red_alpha = red_alpha_prevstatus = 1;\r
+ switch(redflag) {\r
+ case 1: red_icon = "gfx/hud/sb_flag_red_taken"; break;\r
+ case 2: red_icon = "gfx/hud/sb_flag_red_lost"; break;\r
+ case 3: red_icon = "gfx/hud/sb_flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;\r
+ default:\r
+ if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))\r
+ red_icon = "gfx/hud/sb_flag_red_shielded";\r
+ else\r
+ red_icon = string_null;\r
+ break;\r
+ }\r
+ switch(redflag_prevstatus) {\r
+ case 1: red_icon_prevstatus = "gfx/hud/sb_flag_red_taken"; break;\r
+ case 2: red_icon_prevstatus = "gfx/hud/sb_flag_red_lost"; break;\r
+ case 3: red_icon_prevstatus = "gfx/hud/sb_flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;\r
+ default:\r
+ if(redflag == 3)\r
+ red_icon_prevstatus = "gfx/hud/sb_flag_red_carrying"; // make it more visible\r
+ else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))\r
+ red_icon_prevstatus = "gfx/hud/sb_flag_red_shielded";\r
+ else\r
+ red_icon_prevstatus = string_null;\r
+ break;\r
+ }\r
+\r
+ string blue_icon, blue_icon_prevstatus;\r
+ float blue_alpha, blue_alpha_prevstatus;\r
+ blue_alpha = blue_alpha_prevstatus = 1;\r
+ switch(blueflag) {\r
+ case 1: blue_icon = "gfx/hud/sb_flag_blue_taken"; break;\r
+ case 2: blue_icon = "gfx/hud/sb_flag_blue_lost"; break;\r
+ case 3: blue_icon = "gfx/hud/sb_flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;\r
+ default:\r
+ if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))\r
+ blue_icon = "gfx/hud/sb_flag_blue_shielded";\r
+ else\r
+ blue_icon = string_null;\r
+ break;\r
+ }\r
+ switch(blueflag_prevstatus) {\r
+ case 1: blue_icon_prevstatus = "gfx/hud/sb_flag_blue_taken"; break;\r
+ case 2: blue_icon_prevstatus = "gfx/hud/sb_flag_blue_lost"; break;\r
+ case 3: blue_icon_prevstatus = "gfx/hud/sb_flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;\r
+ default:\r
+ if(blueflag == 3)\r
+ blue_icon_prevstatus = "gfx/hud/sb_flag_blue_carrying"; // make it more visible\r
+ else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))\r
+ blue_icon_prevstatus = "gfx/hud/sb_flag_blue_shielded";\r
+ else\r
+ blue_icon_prevstatus = string_null;\r
+ break;\r
+ }\r
+\r
+ if (myteam == COLOR_TEAM1) { // always draw own flag on left\r
+ redflag_pos = top + '-52 50 0';\r
+ blueflag_pos = top + '0 40 0';\r
+ } else {\r
+ blueflag_pos = top + '-52 50 0';\r
+ redflag_pos = top + '0 40 0';\r
+ }\r
+ \r
+ sz = '52 52 0';\r
+ \r
+ f = bound(0, redflag_statuschange_elapsedtime*2, 1);\r
+ if(red_icon_prevstatus && f < 1)\r
+ drawpic_expanding(redflag_pos, red_icon_prevstatus, sz, '1 1 1', sbar_alpha_fg * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);\r
+ if(red_icon)\r
+ drawpic(redflag_pos, red_icon, sz, '1 1 1', sbar_alpha_fg * red_alpha * f, DRAWFLAG_NORMAL);\r
+\r
+ f = bound(0, blueflag_statuschange_elapsedtime*2, 1);\r
+ if(blue_icon_prevstatus && f < 1)\r
+ drawpic_expanding(blueflag_pos, blue_icon_prevstatus, sz, '1 1 1', sbar_alpha_fg * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);\r
+ if(blue_icon)\r
+ drawpic(blueflag_pos, blue_icon, sz, '1 1 1', sbar_alpha_fg * blue_alpha * f, DRAWFLAG_NORMAL);\r
+}\r
+\r
+// Keyhunt HUD\r
+float kh_runheretime;\r
+\r
+void CSQC_kh_hudreset(void)\r
+{\r
+ kh_runheretime = 0;\r
+}\r
+\r
+void CSQC_kh_hud(void)\r
+{\r
+ float kh_keys;\r
+ float keyteam;\r
+ float a, aa;\r
+ vector p, pa, kh_size, kh_asize;\r
+\r
+ vector top;\r
+ top_x = vid_conwidth / 2;\r
+ top_y = 0;\r
+ top_z = 0;\r
+\r
+ p = top + '-50 64 0';\r
+\r
+ kh_keys = getstati(STAT_KH_KEYS);\r
+\r
+ kh_size = '19 34 0';\r
+ kh_asize = '19 10 0';\r
+ pa = p + '0 -10 0';\r
+\r
+ float i, key;\r
+\r
+ float keycount;\r
+ keycount = 0;\r
+ for(i = 0; i < 4; ++i)\r
+ {\r
+ key = floor(kh_keys / pow(32, i)) & 31;\r
+ keyteam = key - 1;\r
+ if(keyteam == 30 && keycount <= 4)\r
+ keycount += 4;\r
+ if(keyteam == myteam || keyteam == -1 || keyteam == 30)\r
+ keycount += 1;\r
+ }\r
+ // this yields 8 exactly if "RUN HERE" shows\r
+\r
+ if(keycount == 8)\r
+ {\r
+ if(!kh_runheretime)\r
+ kh_runheretime = time;\r
+ pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE\r
+ }\r
+ else\r
+ kh_runheretime = 0;\r
+\r
+ for(i = 0; i < 4; ++i)\r
+ {\r
+ key = floor(kh_keys / pow(32, i)) & 31;\r
+ keyteam = key - 1;\r
+ switch(keyteam)\r
+ {\r
+ case 30: // my key\r
+ keyteam = myteam;\r
+ a = 1;\r
+ aa = 1;\r
+ break;\r
+ case -1: // no key\r
+ a = 0;\r
+ aa = 0;\r
+ break;\r
+ default: // owned or dropped\r
+ a = 0.2;\r
+ aa = 0.5;\r
+ break;\r
+ }\r
+ a = a * sbar_alpha_fg;\r
+ aa = aa * sbar_alpha_fg;\r
+ if(a > 0)\r
+ {\r
+ switch(keyteam)\r
+ {\r
+ case COLOR_TEAM1:\r
+ drawpic (pa, "gfx/hud/sb_kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key\r
+ break;\r
+ case COLOR_TEAM2:\r
+ drawpic (pa, "gfx/hud/sb_kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key\r
+ break;\r
+ case COLOR_TEAM3:\r
+ drawpic (pa, "gfx/hud/sb_kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key\r
+ break;\r
+ case COLOR_TEAM4:\r
+ drawpic (pa, "gfx/hud/sb_kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!\r
+ {\r
+ case 0:\r
+ drawpic (p, "gfx/hud/sb_kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key\r
+ break;\r
+ case 1:\r
+ drawpic (p, "gfx/hud/sb_kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key\r
+ break;\r
+ case 2:\r
+ drawpic (p, "gfx/hud/sb_kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key\r
+ break;\r
+ case 3:\r
+ drawpic (p, "gfx/hud/sb_kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key\r
+ break;\r
+ }\r
+ }\r
+ p_x += 24;\r
+ pa_x += 24;\r
+ }\r
+}\r
+\r
+float crecordtime_prev; // last remembered crecordtime\r
+float crecordtime_change_time; // time when crecordtime last changed\r
+float srecordtime_prev; // last remembered srecordtime\r
+float srecordtime_change_time; // time when srecordtime last changed\r
+void CSQC_race_hud(void) \r
+{\r
+ entity me;\r
+ me = playerslots[player_localentnum - 1];\r
+ float t, score;\r
+ float f; // yet another function has this\r
+ score = me.(scores[ps_primary]);\r
+\r
+ if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD\r
+ return; // no records in the actual race\r
+\r
+ drawfont = sbar_bigfont;\r
+ vector pos;\r
+ pos_x = 2;\r
+ pos_y = vid_conheight - 272;\r
+\r
+ // clientside personal record\r
+ string rr;\r
+ if(gametype == GAME_CTS)\r
+ rr = CTS_RECORD;\r
+ else\r
+ rr = RACE_RECORD;\r
+ t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));\r
+\r
+ if(score && score < t || !t)\r
+ db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));\r
+\r
+ if(t != crecordtime_prev) {\r
+ crecordtime_prev = t;\r
+ crecordtime_change_time = time;\r
+ }\r
+ f = time - crecordtime_change_time;\r
+\r
+ if (f > 1) {\r
+ drawstring(pos, "Personal best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawstring(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ } else {\r
+ drawstring(pos, "Personal best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawstring(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawstring_expanding(pos, "Personal best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL, f);\r
+ drawstring_expanding(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL, f);\r
+ }\r
+\r
+ // server record\r
+ pos_y += 26;\r
+ t = race_server_record;\r
+ if(t != srecordtime_prev) {\r
+ srecordtime_prev = t;\r
+ srecordtime_change_time = time;\r
+ }\r
+ f = time - srecordtime_change_time;\r
+\r
+ if (f > 1) {\r
+ drawstring(pos, "Server best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawstring(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ } else {\r
+ drawstring(pos, "Server best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawstring(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+ drawstring_expanding(pos, "Server best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL, f);\r
+ drawstring_expanding(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL, f);\r
+ }\r
+ drawfont = sbar_font;\r
+}\r
\r
ctf.qc\r
\r
-sbar.qc\r
+hud.qc\r
mapvoting.qc\r
\r
rubble.qc\r
+++ /dev/null
-void drawstringright(vector, string, vector, vector, float, float);\r
-void drawstringcenter(vector, string, vector, vector, float, float);\r
-\r
-float teamnagger;\r
-\r
-float weapon_hits[WEP_MAXCOUNT];\r
-float weapon_fired[WEP_MAXCOUNT];\r
-float weapon_number;\r
-\r
-float last_weapon;\r
-float weapontime;\r
-\r
-float sbar_alpha_fg;\r
-float sbar_alpha_bg;\r
-float sbar_color_bg_team;\r
-float sbar_border_thickness;\r
-float sbar_accuracy_border_thickness;\r
-float sbar_scoreboard_alpha_bg;\r
-float sbar_scoreboard_alpha_fg;\r
-float sbar_scoreboard_highlight;\r
-float sbar_scoreboard_highlight_alpha;\r
-float sbar_scoreboard_highlight_alpha_self;\r
-float sbar_hudselector;\r
-float sbar_accuracy_hud;\r
-float sbar_scoreboard_alpha_name;\r
-float sbar_scoreboard_alpha_name_self;\r
-\r
-float ps_primary, ps_secondary;\r
-float ts_primary, ts_secondary;\r
-\r
-vector color;\r
-\r
-void CSQC_kh_hudreset();\r
-void CSQC_kh_hud();\r
-void CSQC_ctf_hudreset();\r
-void CSQC_ctf_hud();\r
-void CSQC_race_hud();\r
-void MapVote_Draw();\r
-void Sbar_FinaleOverlay()\r
-{\r
- /*vector pos;\r
- pos_x = (vid_conwidth - 1)/2;\r
- pos_y = 16;\r
- pos_z = 0;*/\r
-\r
- //drawpic(pos, "gfx/finale", '0 0 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-\r
- //drawstring(pos, "END", sbar_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);\r
- MapVote_Draw();\r
-}\r
-\r
-vector Sbar_AccuracyColor(float accuracy)\r
-{\r
- vector rgb;\r
- float yellow_accuracy = cvar("sbar_accuracy_yellow"); // value at which this function returns yellow\r
- if(accuracy >= 100) {\r
- rgb_x = 0;\r
- rgb_y = 1;\r
- }\r
- else if(accuracy > yellow_accuracy) {\r
- rgb_x = 1 - (accuracy-yellow_accuracy)/(100-yellow_accuracy); // red value between 1 -> 0\r
- rgb_y = 1;\r
- }\r
- else {\r
- rgb_x = 1;\r
- rgb_y = accuracy/yellow_accuracy; // green value between 0 -> 1\r
- }\r
- rgb_z = 0;\r
- return rgb;\r
-}\r
-\r
-void Sbar_DrawXNum (vector pos, float num, float digits, float showminusplus, float lettersize, vector rgb, float alpha, float dflags)\r
-{\r
- float l;\r
- string str, tmp, l_length, final_num;\r
- float minus, plus;\r
- vector vsize;\r
-\r
- vsize_x = vsize_y = lettersize;\r
- vsize_z = 0;\r
-\r
- // showminusplus 1: always prefix with minus sign (useful in race distribution display)\r
- // showminusplus 2: always prefix with plus sign (useful in race distribution display)\r
- // showminusplus 3: prefix with minus sign if negative, plus sign if positive (useful in score distribution display)\r
-\r
- if((showminusplus == 2 && num >= 0) || (num > 0 && showminusplus == 3))\r
- {\r
- plus = true;\r
- } else\r
- plus = false; \r
-\r
- if(num < 0 || (num < 0 && showminusplus == 3) || (showminusplus == 1 && num <= 0))\r
- {\r
- minus = true;\r
- num = -num;\r
- } else\r
- minus = false;\r
-\r
- if(digits < 0)\r
- {\r
- tmp = ftos(num);\r
- digits = -digits;\r
- str = strcat(substring("0000000000", 0, digits - strlen(tmp)), tmp);\r
- } else\r
- str = ftos(num);\r
-\r
- l = strlen(str);\r
- l_length = ftos(l);\r
-\r
- if(l > digits)\r
- {\r
- str = substring(str, l - digits, 999);\r
- l = strlen(str);\r
- }\r
-\r
- if(minus)\r
- final_num = "-";\r
- else if(plus)\r
- final_num = "+";\r
-\r
- final_num = strcat(final_num, str);\r
- drawstring(pos, final_num, vsize, rgb, alpha, dflags);\r
-}\r
-\r
-vector Sbar_NumColor (float x)\r
-{\r
- if(x > 200) {\r
- color_x = 0;\r
- color_y = 1;\r
- color_z = 0;\r
- }\r
- else if(x > 150) {\r
- color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0\r
- color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1\r
- color_z = 0;\r
- }\r
- else if(x > 100) {\r
- color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4\r
- color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9\r
- color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0\r
- }\r
- else if(x > 50) {\r
- color_x = 1;\r
- color_y = 1;\r
- color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1\r
- }\r
- else if(x > 25) {\r
- color_x = 1;\r
- color_y = (x-25)*90/27/100; // green value between 0 -> 1\r
- color_z = (x-25)*90/27/100 * 0.2; // blue value between 0 -> 0.2\r
- }\r
- else {\r
- color_x = 1;\r
- color_y = 0;\r
- color_z = 0;\r
- }\r
- return color;\r
-}\r
-\r
-void Cmd_Sbar_SetFields(float argc);\r
-void Sbar_InitScores()\r
-{\r
- float i, f;\r
-\r
- ps_primary = ps_secondary = ts_primary = ts_secondary = -1;\r
- for(i = 0; i < MAX_SCORE; ++i)\r
- {\r
- f = (scores_flags[i] & SFL_SORT_PRIO_MASK);\r
- if(f == SFL_SORT_PRIO_PRIMARY)\r
- ps_primary = i;\r
- if(f == SFL_SORT_PRIO_SECONDARY)\r
- ps_secondary = i;\r
- }\r
- if(ps_secondary == -1)\r
- ps_secondary = ps_primary;\r
-\r
- for(i = 0; i < MAX_TEAMSCORE; ++i)\r
- {\r
- f = (teamscores_flags[i] & SFL_SORT_PRIO_MASK);\r
- if(f == SFL_SORT_PRIO_PRIMARY)\r
- ts_primary = i;\r
- if(f == SFL_SORT_PRIO_SECONDARY)\r
- ts_secondary = i;\r
- }\r
- if(ts_secondary == -1)\r
- ts_secondary = ts_primary;\r
-\r
- Cmd_Sbar_SetFields(0);\r
-}\r
-\r
-void Sbar_UpdatePlayerPos(entity pl);\r
-float SetTeam(entity pl, float Team);\r
-//float lastpnum;\r
-void Sbar_UpdatePlayerTeams()\r
-{\r
- float Team;\r
- entity pl, tmp;\r
- float num;\r
-\r
- num = 0;\r
- for(pl = players.sort_next; pl; pl = pl.sort_next)\r
- {\r
- num += 1;\r
- Team = GetPlayerColor(pl.sv_entnum);\r
- if(SetTeam(pl, Team))\r
- {\r
- tmp = pl.sort_prev;\r
- Sbar_UpdatePlayerPos(pl);\r
- if(tmp)\r
- pl = tmp;\r
- else\r
- pl = players.sort_next;\r
- }\r
- }\r
- /*\r
- if(num != lastpnum)\r
- print(strcat("PNUM: ", ftos(num), "\n"));\r
- lastpnum = num;\r
- */\r
-}\r
-\r
-float Sbar_ComparePlayerScores(entity left, entity right)\r
-{\r
- float vl, vr;\r
- vl = GetPlayerColor(left.sv_entnum);\r
- vr = GetPlayerColor(right.sv_entnum);\r
-\r
- if(!left.gotscores)\r
- vl = COLOR_SPECTATOR;\r
- if(!right.gotscores)\r
- vr = COLOR_SPECTATOR;\r
-\r
- if(vl > vr)\r
- return true;\r
- if(vl < vr)\r
- return false;\r
-\r
- if(vl == COLOR_SPECTATOR)\r
- {\r
- // FIRST the one with scores (spectators), THEN the ones without (downloaders)\r
- // no other sorting\r
- if(!left.gotscores && right.gotscores)\r
- return true;\r
- return false;\r
- }\r
-\r
- vl = left.scores[ps_primary];\r
- vr = right.scores[ps_primary];\r
- if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)\r
- {\r
- if(vl == 0 && vr != 0)\r
- return 1;\r
- if(vl != 0 && vr == 0)\r
- return 0;\r
- }\r
- if(vl > vr)\r
- return IS_INCREASING(scores_flags[ps_primary]);\r
- if(vl < vr)\r
- return IS_DECREASING(scores_flags[ps_primary]);\r
-\r
- vl = left.scores[ps_secondary];\r
- vr = right.scores[ps_secondary];\r
- if(scores_flags[ps_secondary] & SFL_ZERO_IS_WORST)\r
- {\r
- if(vl == 0 && vr != 0)\r
- return 1;\r
- if(vl != 0 && vr == 0)\r
- return 0;\r
- }\r
- if(vl > vr)\r
- return IS_INCREASING(scores_flags[ps_secondary]);\r
- if(vl < vr)\r
- return IS_DECREASING(scores_flags[ps_secondary]);\r
-\r
- return false;\r
-}\r
-\r
-void Sbar_UpdatePlayerPos(entity player)\r
-{\r
- for(other = player.sort_next; other && Sbar_ComparePlayerScores(player, other); other = player.sort_next)\r
- {\r
- SORT_SWAP(player, other);\r
- }\r
- for(other = player.sort_prev; other != players && Sbar_ComparePlayerScores(other, player); other = player.sort_prev)\r
- {\r
- SORT_SWAP(other, player);\r
- }\r
-}\r
-\r
-float Sbar_CompareTeamScores(entity left, entity right)\r
-{\r
- float vl, vr;\r
-\r
- if(left.team == COLOR_SPECTATOR)\r
- return 1;\r
- if(right.team == COLOR_SPECTATOR)\r
- return 0;\r
-\r
- vl = left.teamscores[ts_primary];\r
- vr = right.teamscores[ts_primary];\r
- if(vl > vr)\r
- return IS_INCREASING(teamscores_flags[ts_primary]);\r
- if(vl < vr)\r
- return IS_DECREASING(teamscores_flags[ts_primary]);\r
-\r
- vl = left.teamscores[ts_secondary];\r
- vr = right.teamscores[ts_secondary];\r
- if(vl > vr)\r
- return IS_INCREASING(teamscores_flags[ts_secondary]);\r
- if(vl < vr)\r
- return IS_DECREASING(teamscores_flags[ts_secondary]);\r
-\r
- return false;\r
-}\r
-\r
-void Sbar_UpdateTeamPos(entity Team)\r
-{\r
- for(other = Team.sort_next; other && Sbar_CompareTeamScores(Team, other); other = Team.sort_next)\r
- {\r
- SORT_SWAP(Team, other);\r
- }\r
- for(other = Team.sort_prev; other != teams && Sbar_CompareTeamScores(other, Team); other = Team.sort_prev)\r
- {\r
- SORT_SWAP(other, Team);\r
- }\r
-}\r
-\r
-void Cmd_Sbar_Help(float argc)\r
-{\r
- print("You can modify the scoreboard using the ^2sbar_columns_set command.\n");\r
- print("^3|---------------------------------------------------------------|\n");\r
- print("Usage:\n");\r
- print("^2sbar_columns_set default\n");\r
- print("^2sbar_columns_set ^7filed1 field2 ...\n");\r
- print("The following field names are recognized (case insensitive):\n");\r
- print("You can use a ^3|^7 to start the right-aligned fields.\n\n");\r
-\r
- print("^3name^7 or ^3nick^7 Name of a player\n");\r
- print("^3ping^7 Ping time\n");\r
- print("^3pl^7 Packet loss\n");\r
- print("^3kills^7 Number of kills\n");\r
- print("^3deaths^7 Number of deaths\n");\r
- print("^3suicides^7 Number of suicides\n");\r
- print("^3frags^7 kills - suicides\n");\r
- print("^3kd^7 The kill-death ratio\n");\r
- print("^3caps^7 How often a flag (CTF) or a key (KeyHunt) was captured\n");\r
- print("^3pickups^7 How often a flag (CTF) or a key (KeyHunt) was picked up\n");\r
- print("^3fckills^7 Number of flag carrier kills\n");\r
- print("^3returns^7 Number of flag returns\n");\r
- print("^3drops^7 Number of flag drops\n");\r
- print("^3lives^7 Number of lives (LMS)\n");\r
- print("^3rank^7 Player rank\n");\r
- print("^3pushes^7 Number of players pushed into void\n");\r
- print("^3destroyed^7 Number of keys destroyed by pushing them into void\n");\r
- print("^3kckills^7 Number of keys carrier kills\n");\r
- print("^3losses^7 Number of times a key was lost\n");\r
- print("^3laps^7 Number of laps finished (race/cts)\n");\r
- print("^3time^7 Total time raced (race/cts)\n");\r
- print("^3fastest^7 Time of fastest lap (race/cts)\n");\r
- print("^3ticks^7 Number of ticks (DOM)\n");\r
- print("^3takes^7 Number of domination points taken (DOM)\n");\r
- print("^3score^7 Total score\n\n");\r
-\r
- print("Before a field you can put a + or - sign, then a comma separated list\n");\r
- print("of game types, then a slash, to make the field show up only in these\n");\r
- print("or in all but these game types. You can also specify 'all' as a\n");\r
- print("field to show all fields available for the current game mode.\n\n");\r
- \r
- print("The special game type names 'teams' and 'noteams' can be used to\n");\r
- print("include/exclude ALL teams/noteams game modes.\n\n");\r
-\r
- print("Example: sbar_columns_set name ping pl | +ctf/field3 -dm/field4\n");\r
- print("will display name, ping and pl aligned to the left, and the fields\n");\r
- print("right of the vertical bar aligned to the right.\n");\r
- print("'field3' will only be shown in CTF, and 'field4' will be shown in all\n");\r
- print("other gamemodes except DM.\n");\r
-}\r
-\r
-string Sbar_DefaultColumnLayout()\r
-{\r
- return strcat( // fteqcc sucks\r
- "ping pl name | ",\r
- "-teams,race,lms/kills -teams,lms/deaths -teams,lms,race/suicides -race,dm,tdm/frags ", // tdm already has this in "score"\r
- "+ctf/caps +ctf/pickups +ctf/fckills +ctf/returns ",\r
- "+lms/lives +lms/rank ",\r
- "+kh/caps +kh/pushes +kh/destroyed ",\r
- "?+race/laps ?+race/time ?+race/fastest ",\r
- "-lms,race");\r
-}\r
-\r
-void Cmd_Sbar_SetFields(float argc)\r
-{\r
- float i, j, slash;\r
- string str, pattern;\r
- float have_name, have_primary, have_secondary, have_separator;\r
- float missing;\r
-\r
- // TODO: re enable with gametype dependant cvars?\r
- if(argc < 2) // no arguments provided\r
- argc = tokenizebyseparator(strcat("x ", cvar_string("sbar_columns")), " ");\r
-\r
- if(argc < 2)\r
- argc = tokenizebyseparator(strcat("x ", Sbar_DefaultColumnLayout()), " ");\r
-\r
- if(argc == 2)\r
- {\r
- if(argv(1) == "default")\r
- argc = tokenizebyseparator(strcat("x ", Sbar_DefaultColumnLayout()), " ");\r
- else if(argv(1) == "all")\r
- {\r
- string s;\r
- s = "ping pl color name |";\r
- for(i = 0; i < MAX_SCORE; ++i)\r
- {\r
- if(i != ps_primary)\r
- if(i != ps_secondary)\r
- if(scores_label[i] != "")\r
- s = strcat(s, " ", scores_label[i]);\r
- }\r
- if(ps_secondary != ps_primary)\r
- s = strcat(s, " ", scores_label[ps_secondary]);\r
- s = strcat(s, " ", scores_label[ps_primary]);\r
- argc = tokenizebyseparator(strcat("x ", s), " ");\r
- }\r
- }\r
-\r
-\r
- sbar_num_fields = 0;\r
-\r
- drawfont = sbar_font;\r
-\r
- for(i = 0; i < argc - 1; ++i)\r
- {\r
- float nocomplain;\r
- str = argv(i+1);\r
-\r
- nocomplain = FALSE;\r
- if(substring(str, 0, 1) == "?")\r
- {\r
- nocomplain = TRUE;\r
- str = substring(str, 1, strlen(str) - 1);\r
- }\r
-\r
- slash = strstrofs(str, "/", 0);\r
- if(slash >= 0)\r
- {\r
- pattern = substring(str, 0, slash);\r
- str = substring(str, slash + 1, strlen(str) - (slash + 1));\r
-\r
- if not(isGametypeInFilter(gametype, teamplay, pattern))\r
- continue;\r
- }\r
-\r
- strunzone(sbar_title[sbar_num_fields]);\r
- sbar_title[sbar_num_fields] = strzone(str);\r
- sbar_size[sbar_num_fields] = stringwidth(str, FALSE, sbar_fontsize);\r
- str = strtolower(str);\r
-\r
- if(str == "ping") {\r
- sbar_field[sbar_num_fields] = SP_PING;\r
- } else if(str == "pl") {\r
- sbar_field[sbar_num_fields] = SP_PL;\r
- } else if(str == "kd" || str == "kdr" || str == "kdratio" || str == "k/d") {\r
- sbar_field[sbar_num_fields] = SP_KDRATIO;\r
- } else if(str == "name" || str == "nick") {\r
- sbar_field[sbar_num_fields] = SP_NAME;\r
- have_name = 1;\r
- } else if(str == "|") {\r
- sbar_field[sbar_num_fields] = SP_SEPARATOR;\r
- have_separator = 1;\r
- } else {\r
- if(gametype == GAME_RPG)\r
- return;\r
-\r
- for(j = 0; j < MAX_SCORE; ++j)\r
- if(str == strtolower(scores_label[j]))\r
- goto found; // sorry, but otherwise fteqcc -O3 miscompiles this and warns about "unreachable code"\r
-:notfound\r
- if(str == "frags")\r
- j = SP_FRAGS;\r
- else\r
- {\r
- if not(nocomplain)\r
- print(strcat("^1Error:^7 Unknown score field: '", str, "'\n"));\r
- continue;\r
- }\r
-:found\r
- sbar_field[sbar_num_fields] = j;\r
- if(j == ps_primary)\r
- have_primary = 1;\r
- if(j == ps_secondary)\r
- have_secondary = 1;\r
- }\r
- ++sbar_num_fields;\r
- if(sbar_num_fields >= MAX_SBAR_FIELDS)\r
- break;\r
- }\r
-\r
- if(scores_flags[ps_primary] & SFL_ALLOW_HIDE)\r
- have_primary = 1;\r
- if(scores_flags[ps_secondary] & SFL_ALLOW_HIDE)\r
- have_secondary = 1;\r
- if(ps_primary == ps_secondary)\r
- have_secondary = 1;\r
- missing = (!have_primary) + (!have_secondary) + (!have_separator) + (!have_name);\r
-\r
- if(sbar_num_fields+missing < MAX_SBAR_FIELDS)\r
- {\r
- if(!have_name)\r
- {\r
- strunzone(sbar_title[sbar_num_fields]);\r
- for(i = sbar_num_fields; i > 0; --i)\r
- {\r
- sbar_title[i] = sbar_title[i-1];\r
- sbar_size[i] = sbar_size[i-1];\r
- sbar_field[i] = sbar_field[i-1];\r
- }\r
- sbar_title[0] = strzone("name");\r
- sbar_field[0] = SP_NAME;\r
- ++sbar_num_fields;\r
- print("fixed missing field 'name'\n");\r
-\r
- if(!have_separator)\r
- {\r
- strunzone(sbar_title[sbar_num_fields]);\r
- for(i = sbar_num_fields; i > 1; --i)\r
- {\r
- sbar_title[i] = sbar_title[i-1];\r
- sbar_size[i] = sbar_size[i-1];\r
- sbar_field[i] = sbar_field[i-1];\r
- }\r
- sbar_title[1] = strzone("|");\r
- sbar_field[1] = SP_SEPARATOR;\r
- sbar_size[1] = stringwidth("|", FALSE, sbar_fontsize);\r
- ++sbar_num_fields;\r
- print("fixed missing field '|'\n");\r
- }\r
- }\r
- else if(!have_separator)\r
- {\r
- strunzone(sbar_title[sbar_num_fields]);\r
- sbar_title[sbar_num_fields] = strzone("|");\r
- sbar_size[sbar_num_fields] = stringwidth("|", FALSE, sbar_fontsize);\r
- sbar_field[sbar_num_fields] = SP_SEPARATOR;\r
- ++sbar_num_fields;\r
- print("fixed missing field '|'\n");\r
- }\r
- if(!have_secondary)\r
- {\r
- strunzone(sbar_title[sbar_num_fields]);\r
- sbar_title[sbar_num_fields] = strzone(scores_label[ps_secondary]);\r
- sbar_size[sbar_num_fields] = stringwidth(sbar_title[sbar_num_fields], FALSE, sbar_fontsize);\r
- sbar_field[sbar_num_fields] = ps_secondary;\r
- ++sbar_num_fields;\r
- print("fixed missing field '", scores_label[ps_secondary], "'\n");\r
- }\r
- if(!have_primary)\r
- {\r
- strunzone(sbar_title[sbar_num_fields]);\r
- sbar_title[sbar_num_fields] = strzone(scores_label[ps_primary]);\r
- sbar_size[sbar_num_fields] = stringwidth(sbar_title[sbar_num_fields], FALSE, sbar_fontsize);\r
- sbar_field[sbar_num_fields] = ps_primary;\r
- ++sbar_num_fields;\r
- print("fixed missing field '", scores_label[ps_primary], "'\n");\r
- }\r
- }\r
-\r
- sbar_field[sbar_num_fields] = SP_END;\r
-}\r
-\r
-// MOVEUP::\r
-vector sbar_field_rgb;\r
-string sbar_field_icon0;\r
-string sbar_field_icon1;\r
-string sbar_field_icon2;\r
-vector sbar_field_icon0_rgb;\r
-vector sbar_field_icon1_rgb;\r
-vector sbar_field_icon2_rgb;\r
-float sbar_field_icon0_alpha;\r
-float sbar_field_icon1_alpha;\r
-float sbar_field_icon2_alpha;\r
-string Sbar_GetField(entity pl, float field)\r
-{\r
- float tmp, num, denom, f;\r
- string str;\r
- sbar_field_rgb = '1 1 1';\r
- sbar_field_icon0 = "";\r
- sbar_field_icon1 = "";\r
- sbar_field_icon2 = "";\r
- sbar_field_icon0_rgb = '1 1 1';\r
- sbar_field_icon1_rgb = '1 1 1';\r
- sbar_field_icon2_rgb = '1 1 1';\r
- sbar_field_icon0_alpha = 1;\r
- sbar_field_icon1_alpha = 1;\r
- sbar_field_icon2_alpha = 1;\r
- switch(field)\r
- {\r
- case SP_PING:\r
- if not(pl.gotscores)\r
- return "\x8D\x8D\x8D"; // >>> sign\r
- //str = getplayerkey(pl.sv_entnum, "ping");\r
- f = pl.ping;\r
- if(f == 0)\r
- return "N/A";\r
- tmp = max(0, min(220, f-80)) / 220;\r
- sbar_field_rgb = '1 1 1' - '0 1 1'*tmp;\r
- return ftos(f);\r
-\r
- case SP_PL:\r
- if not(pl.gotscores)\r
- return "N/A";\r
- f = pl.ping_packetloss;\r
- tmp = pl.ping_movementloss;\r
- if(f == 0 && tmp == 0)\r
- return "";\r
- str = ftos(ceil(f * 100));\r
- if(tmp != 0)\r
- str = strcat(str, "~", ftos(ceil(tmp * 100)));\r
- tmp = bound(0, f / 0.2 + tmp / 0.04, 1); // 20% is REALLY BAD pl\r
- sbar_field_rgb = '1 0.5 0.5' - '0 0.5 0.5'*tmp;\r
- return str;\r
-\r
- case SP_NAME:\r
- if(ready_waiting && pl.ready)\r
- {\r
- sbar_field_icon0 = "gfx/sb_player_ready";\r
- }\r
- else if(!teamplay)\r
- {\r
- f = stof(getplayerkey(pl.sv_entnum, "colors"));\r
- {\r
- sbar_field_icon0 = "gfx/sb_playercolor_base";\r
- sbar_field_icon1 = "gfx/sb_playercolor_shirt";\r
- sbar_field_icon1_rgb = colormapPaletteColor(floor(f / 16), 0);\r
- sbar_field_icon2 = "gfx/sb_playercolor_pants";\r
- sbar_field_icon2_rgb = colormapPaletteColor(mod(f, 16), 1);\r
- }\r
- }\r
- return GetPlayerName(pl.sv_entnum);\r
-\r
- case SP_FRAGS:\r
- f = pl.(scores[SP_KILLS]);\r
- f -= pl.(scores[SP_SUICIDES]);\r
- return ftos(f);\r
-\r
- case SP_KDRATIO:\r
- num = pl.(scores[SP_KILLS]);\r
- denom = pl.(scores[SP_DEATHS]);\r
-\r
- if(denom == 0) {\r
- sbar_field_rgb = '0 1 0';\r
- str = ftos(num);\r
- } else if(num <= 0) {\r
- sbar_field_rgb = '1 0 0';\r
- str = ftos(num/denom);\r
- } else\r
- str = ftos(num/denom);\r
-\r
- tmp = strstrofs(str, ".", 0);\r
- if(tmp > 0)\r
- str = substring(str, 0, tmp+2);\r
- return str;\r
-\r
- default:\r
- tmp = pl.(scores[field]);\r
- f = scores_flags[field];\r
- if(field == ps_primary)\r
- sbar_field_rgb = '1 1 0';\r
- else if(field == ps_secondary)\r
- sbar_field_rgb = '0 1 1';\r
- else\r
- sbar_field_rgb = '1 1 1';\r
- return ScoreString(f, tmp);\r
- }\r
- //return "error";\r
-}\r
-\r
-string Sbar_GetStomachField(entity pl, float field)\r
-{\r
- switch(field)\r
- {\r
- case ST_HIGHLIGHT:\r
- return ""; // the returned value is not used, we only need the field\r
-\r
- case ST_NAME:\r
- return GetPlayerName(pl.sv_entnum);\r
-\r
- case ST_HEALTH:\r
- return ftos(pl.plhealth);\r
-\r
- default:\r
- return "N/A";\r
- }\r
- //return "error";\r
-}\r
-\r
-string Sbar_GetStomachFieldPred(entity pl, float field)\r
-{\r
- switch(field)\r
- {\r
- case STP_NAME:\r
- return GetPlayerName(pl.sv_entnum);\r
- default:\r
- return "N/A";\r
- }\r
- //return "error";\r
-}\r
-\r
-float xmin, xmax, ymin, ymax, sbwidth;\r
-float sbar_fixscoreboardcolumnwidth_len;\r
-float sbar_fixscoreboardcolumnwidth_iconlen;\r
-float sbar_fixscoreboardcolumnwidth_marginlen;\r
-\r
-float stringwidth_colors(string s, vector theSize)\r
-{\r
- return stringwidth(s, TRUE, theSize);\r
-}\r
-\r
-float stringwidth_nocolors(string s, vector theSize)\r
-{\r
- return stringwidth(s, FALSE, theSize);\r
-}\r
-\r
-string Sbar_FixScoreboardColumnWidth(float i, string str)\r
-{\r
- float field, f;\r
- vector sz;\r
- field = sbar_field[i];\r
-\r
- sbar_fixscoreboardcolumnwidth_iconlen = 0;\r
-\r
- if(sbar_field_icon0 != "")\r
- {\r
- sz = drawgetimagesize(sbar_field_icon0);\r
- f = sz_x / sz_y;\r
- if(sbar_fixscoreboardcolumnwidth_iconlen < f)\r
- sbar_fixscoreboardcolumnwidth_iconlen = f;\r
- }\r
-\r
- if(sbar_field_icon1 != "")\r
- {\r
- sz = drawgetimagesize(sbar_field_icon1);\r
- f = sz_x / sz_y;\r
- if(sbar_fixscoreboardcolumnwidth_iconlen < f)\r
- sbar_fixscoreboardcolumnwidth_iconlen = f;\r
- }\r
-\r
- if(sbar_field_icon2 != "")\r
- {\r
- sz = drawgetimagesize(sbar_field_icon2);\r
- f = sz_x / sz_y;\r
- if(sbar_fixscoreboardcolumnwidth_iconlen < f)\r
- sbar_fixscoreboardcolumnwidth_iconlen = f;\r
- }\r
-\r
- sbar_fixscoreboardcolumnwidth_iconlen *= sbar_fontsize_y / sbar_fontsize_x; // fix icon aspect\r
-\r
- if(sbar_fixscoreboardcolumnwidth_iconlen != 0)\r
- sbar_fixscoreboardcolumnwidth_marginlen = stringwidth(" ", FALSE, sbar_fontsize);\r
- else\r
- sbar_fixscoreboardcolumnwidth_marginlen = 0;\r
-\r
- if(field == SP_NAME) // name gets all remaining space\r
- {\r
- float namesize, j;\r
- namesize = sbwidth;// / sbar_fontsize_x;\r
- for(j = 0; j < sbar_num_fields; ++j)\r
- if(j != i)\r
- if (sbar_field[i] != SP_SEPARATOR)\r
- namesize -= sbar_size[j] + 1;\r
- namesize += 1;\r
- sbar_size[i] = namesize;\r
- \r
- if (sbar_fixscoreboardcolumnwidth_iconlen != 0)\r
- namesize -= sbar_fixscoreboardcolumnwidth_marginlen + sbar_fixscoreboardcolumnwidth_iconlen;\r
- str = textShortenToWidth(str, namesize, sbar_fontsize, stringwidth_colors);\r
- sbar_fixscoreboardcolumnwidth_len = stringwidth(str, TRUE, sbar_fontsize);\r
- }\r
- else\r
- sbar_fixscoreboardcolumnwidth_len = stringwidth(str, FALSE, sbar_fontsize);\r
- \r
- f = sbar_fixscoreboardcolumnwidth_len + sbar_fixscoreboardcolumnwidth_marginlen + sbar_fixscoreboardcolumnwidth_iconlen;\r
- if(sbar_size[i] < f)\r
- sbar_size[i] = f;\r
-\r
- return str;\r
-}\r
-\r
-void Sbar_PrintScoreboardItem(vector pos, entity pl, float is_self, float pl_number)\r
-{\r
- vector tmp, rgb;\r
- rgb = GetTeamRGB(pl.team);\r
- string str;\r
- float i, field;\r
- float is_spec;\r
- is_spec = (GetPlayerColor(pl.sv_entnum) == COLOR_SPECTATOR);\r
- \r
- if((rgb == '1 1 1') && (!is_spec))\r
- rgb = stov(cvar_string("sbar_color_bg")) + '0.5 0.5 0.5';\r
-\r
- // Layout:\r
- tmp_x = sbwidth;\r
- tmp_y = sbar_fontsize_y * 1.25;\r
- tmp_z = 0;\r
-\r
- // alternated rows highlighting\r
- if(is_self)\r
- drawfill(pos - '1 1 0', tmp + '2 0 0', rgb, sbar_scoreboard_highlight_alpha_self, DRAWFLAG_NORMAL);\r
- else if((sbar_scoreboard_highlight) && (!mod(pl_number,2)))\r
- drawfill(pos - '1 1 0', tmp + '2 0 0', rgb, sbar_scoreboard_highlight_alpha, DRAWFLAG_NORMAL);\r
-\r
- tmp_y = 0;\r
-\r
- for(i = 0; i < sbar_num_fields; ++i)\r
- {\r
- field = sbar_field[i];\r
- if(field == SP_SEPARATOR)\r
- break;\r
-\r
- if(is_spec && field != SP_NAME && field != SP_PING) {\r
- pos_x += sbar_size[i] + sbar_fontsize_x;\r
- continue;\r
- }\r
- str = Sbar_GetField(pl, field);\r
- str = Sbar_FixScoreboardColumnWidth(i, str);\r
-\r
- pos_x += sbar_size[i] + sbar_fontsize_x;\r
-\r
- if(field == SP_NAME) {\r
- tmp_x = sbar_size[i] - sbar_fontsize_x*sbar_fixscoreboardcolumnwidth_iconlen - sbar_fixscoreboardcolumnwidth_marginlen + sbar_fontsize_x;\r
- if (is_self)\r
- drawcolorcodedstring(pos - tmp, str, sbar_fontsize, sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);\r
- else\r
- drawcolorcodedstring(pos - tmp, str, sbar_fontsize, sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);\r
- } else {\r
- tmp_x = sbar_fixscoreboardcolumnwidth_len + sbar_fontsize_x;\r
- if (is_self)\r
- drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);\r
- else\r
- drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);\r
- }\r
-\r
- tmp_x = sbar_size[i] + sbar_fontsize_x;\r
- if(sbar_field_icon0 != "")\r
- if (is_self)\r
- 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
- else\r
- 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
- if(sbar_field_icon1 != "")\r
- if (is_self)\r
- 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
- else\r
- 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
- if(sbar_field_icon2 != "")\r
- if (is_self)\r
- 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
- else\r
- 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
- }\r
-\r
- if(sbar_field[i] == SP_SEPARATOR)\r
- {\r
- pos_x = xmax;\r
- for(i = sbar_num_fields-1; i > 0; --i)\r
- {\r
- field = sbar_field[i];\r
- if(field == SP_SEPARATOR)\r
- break;\r
-\r
- if(is_spec && field != SP_NAME && field != SP_PING) {\r
- pos_x -= sbar_size[i] + sbar_fontsize_x;\r
- continue;\r
- }\r
-\r
- str = Sbar_GetField(pl, field);\r
- str = Sbar_FixScoreboardColumnWidth(i, str);\r
-\r
- if(field == SP_NAME) {\r
- tmp_x = sbar_fixscoreboardcolumnwidth_len; // left or right aligned? let's put it right...\r
- if(is_self)\r
- drawcolorcodedstring(pos - tmp, str, sbar_fontsize, sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);\r
- else\r
- drawcolorcodedstring(pos - tmp, str, sbar_fontsize, sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);\r
- } else {\r
- tmp_x = sbar_fixscoreboardcolumnwidth_len;\r
- if(is_self)\r
- drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);\r
- else\r
- drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);\r
- }\r
-\r
- tmp_x = sbar_size[i];\r
- if(sbar_field_icon0 != "")\r
- if (is_self)\r
- 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
- else\r
- 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
- if(sbar_field_icon1 != "")\r
- if (is_self)\r
- 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
- else\r
- 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
- if(sbar_field_icon2 != "")\r
- if (is_self)\r
- 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
- else\r
- 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
- pos_x -= sbar_size[i] + sbar_fontsize_x;\r
- }\r
- }\r
-}\r
-\r
-float fieldcounter;\r
-void Sbar_PrintStomachboardItem(vector pos, entity pl)\r
-{\r
- // lists all players in the stomach\r
-\r
- string str;\r
- float f, field, field_number;\r
- vector hl_color;\r
- field_number = 3; // the number of components each row has\r
-\r
- for(fieldcounter = 1; fieldcounter <= field_number; ++fieldcounter)\r
- {\r
- field = -fieldcounter;\r
- str = Sbar_GetStomachField(pl, field);\r
-\r
- // row highlighting\r
- if(field == ST_HIGHLIGHT)\r
- {\r
- if(getstati(STAT_VORE_EATEN))\r
- {\r
- 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
- hl_color = stov(cvar_string("sbar_stomachboard_color2"));\r
- else\r
- hl_color = stov(cvar_string("sbar_stomachboard_color3"));\r
- }\r
- else\r
- hl_color = stov(cvar_string("sbar_stomachboard_color1"));\r
- drawfill(pos - '0 0 0', '193 11 0', hl_color, cvar("sbar_stomachboard_highlight_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- }\r
-\r
- if(field == ST_NAME) {\r
- f = stof(getplayerkey(pl.sv_entnum, "colors"));\r
- drawpic(pos, "gfx/sb_playercolor_base", '22 11 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawpic(pos, "gfx/sb_playercolor_shirt", '22 11 0', colormapPaletteColor(floor(f / 16), 0), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawpic(pos, "gfx/sb_playercolor_pants", '22 11 0', colormapPaletteColor(mod(f, 16), 1), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-\r
- pos_x += 24;\r
- drawcolorcodedstring(pos, textShortenToWidth(str, 138, '11 11 0', stringwidth_colors), '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- }\r
-\r
- if(field == ST_HEALTH) {\r
- pos_x += 138;\r
- if(pl.sv_entnum == player_localentnum - 1 || (spectatee_status && pl.sv_entnum == spectatee_status - 1))\r
- drawcolorcodedstring(pos, "self", '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- else\r
- {\r
- drawpic(pos, "gfx/hud/sb_health", '11 11 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-\r
- pos_x += 9;\r
- drawcolorcodedstring(pos, str, '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- }\r
- }\r
- }\r
-}\r
-\r
-float fieldcounter2;\r
-void Sbar_PrintStomachboardItemPred(vector pos, entity pl)\r
-{\r
- // shows the name of our predator\r
-\r
- string str;\r
- float f, field, field_number;\r
- field_number = 1; // the number of components each row has\r
-\r
- for(fieldcounter2 = 1; fieldcounter2 <= field_number; ++fieldcounter2)\r
- {\r
- field = -fieldcounter2;\r
- str = Sbar_GetStomachFieldPred(pl, field);\r
-\r
- if(field == STP_NAME) {\r
- f = stof(getplayerkey(pl.sv_entnum, "colors"));\r
- drawpic(pos, "gfx/sb_playercolor_base", '22 11 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawpic(pos, "gfx/sb_playercolor_shirt", '22 11 0', colormapPaletteColor(floor(f / 16), 0), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawpic(pos, "gfx/sb_playercolor_pants", '22 11 0', colormapPaletteColor(mod(f, 16), 1), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-\r
- pos_x += 24;\r
- drawcolorcodedstring(pos, textShortenToWidth(str, 122, '11 11 0', stringwidth_colors), '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- }\r
- }\r
-}\r
-\r
-/*\r
- * Sbar_Scoreboard_MakeTable\r
- *\r
- * Makes a table for a team (for all playing players in DM) and fills it\r
- */\r
-\r
-vector Sbar_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_size)\r
-{\r
- float body_table_height, i;\r
- vector tmp, column_dim;\r
- entity pl;\r
-\r
- body_table_height = 1.25 * sbar_fontsize_y * max(1, tm.team_size); // no player? show 1 empty line\r
-\r
- pos -= '1 1 0';\r
-\r
- tmp_x = sbwidth + 2;\r
- tmp_y = 1.25 * sbar_fontsize_y;\r
-\r
- // rounded header\r
- drawpic(pos, "gfx/hud/sb_scoreboard_tableheader", tmp, (rgb * sbar_color_bg_team) + '0.5 0.5 0.5', sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL);\r
-\r
- // table border\r
- tmp_y += sbar_border_thickness;\r
- tmp_y += body_table_height;\r
- drawborderlines(sbar_border_thickness, pos, tmp, '0 0 0', sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL); // more transparency for the scoreboard\r
-\r
- // separator header/table\r
- pos_y += 1.25 * sbar_fontsize_y;\r
- tmp_y = sbar_border_thickness;\r
- drawfill(pos, tmp, '0 0 0', sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL);\r
-\r
- pos_y += sbar_border_thickness;\r
-\r
- // table background\r
- tmp_y = body_table_height;\r
- drawpic_tiled(pos, "gfx/hud/sb_scoreboard_bg", bg_size, tmp, rgb * sbar_color_bg_team, sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL);\r
-\r
- // anyway, apply some color\r
- //drawfill(pos, tmp + '2 0 0', rgb, 0.1, DRAWFLAG_NORMAL);\r
-\r
- // go back to the top to make alternated columns highlighting and to print the strings\r
- pos_y -= 1.25 * sbar_fontsize_y;\r
- pos_y -= sbar_border_thickness;\r
-\r
- pos += '1 1 0';\r
-\r
- if (sbar_scoreboard_highlight)\r
- {\r
- column_dim_y = 1.25 * sbar_fontsize_y; // header\r
- column_dim_y += sbar_border_thickness;\r
- column_dim_y += body_table_height;\r
- }\r
-\r
- // print the strings of the columns headers and draw the columns\r
- for(i = 0; i < sbar_num_fields; ++i)\r
- {\r
- if(sbar_field[i] == SP_SEPARATOR)\r
- break;\r
- column_dim_x = sbar_size[i] + sbar_fontsize_x;\r
- if (sbar_scoreboard_highlight)\r
- {\r
- if (mod(i,2))\r
- 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
- }\r
- drawstring(pos, sbar_title[i], sbar_fontsize, rgb * 1.5, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
- pos_x += column_dim_x;\r
- }\r
- if(sbar_field[i] == SP_SEPARATOR)\r
- {\r
- pos_x = xmax;\r
- tmp_y = 0;\r
- for(i = sbar_num_fields-1; i > 0; --i)\r
- {\r
- if(sbar_field[i] == SP_SEPARATOR)\r
- break;\r
-\r
- pos_x -= sbar_size[i];\r
-\r
- if (sbar_scoreboard_highlight)\r
- {\r
- if (!mod(i,2))\r
- {\r
- if (i == sbar_num_fields-1)\r
- column_dim_x = sbar_size[i] + sbar_fontsize_x / 2 + 1;\r
- else\r
- column_dim_x = sbar_size[i] + sbar_fontsize_x;\r
- 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
- }\r
- }\r
-\r
- tmp_x = stringwidth(sbar_title[i], FALSE, sbar_fontsize);\r
- tmp_x = sbar_size[i] - tmp_x;\r
- drawstring(pos + tmp, sbar_title[i], sbar_fontsize, rgb * 1.5, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
- pos_x -= sbar_fontsize_x;\r
- }\r
- }\r
- \r
- pos_x = xmin;\r
- pos_y += 1.25 * sbar_fontsize_y; // skip the header\r
- pos_y += sbar_border_thickness;\r
-\r
- // fill the table and draw the rows\r
- i = 0;\r
- if (teamplay)\r
- for(pl = players.sort_next; pl; pl = pl.sort_next)\r
- {\r
- if(pl.team != tm.team)\r
- continue;\r
- Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), i);\r
- pos_y += 1.25 * sbar_fontsize_y;\r
- ++i;\r
- }\r
- else\r
- for(pl = players.sort_next; pl; pl = pl.sort_next)\r
- {\r
- if(pl.team == COLOR_SPECTATOR)\r
- continue;\r
- Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), i);\r
- pos_y += 1.25 * sbar_fontsize_y;\r
- ++i;\r
- }\r
- \r
- if (i == 0)\r
- pos_y += 1.25 * sbar_fontsize_y; // move to the end of the table\r
- pos_y += 1.25 * sbar_fontsize_y; // move empty row (out of the table)\r
-\r
- return pos;\r
-}\r
-\r
-float Sbar_WouldDrawScoreboard() {\r
- if (sb_showscores)\r
- return 1;\r
- else if (intermission == 1)\r
- return 1;\r
- else if (intermission == 2)\r
- return 1;\r
- else if (getstati(STAT_HEALTH) <= 0 && cvar("cl_deathscoreboard"))\r
- return 1;\r
- else if(sb_showscores_force)\r
- return 1;\r
- return 0;\r
-}\r
-\r
-float average_accuracy;\r
-vector Sbar_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)\r
-{\r
- float i;\r
- float weapon_hit, weapon_damage, weapon_stats;\r
- float fontsize = 40 * 1/3;\r
- float xsave;\r
- float weapon_cnt;\r
- float rows;\r
- if(cvar("sbar_accuracy_doublerows"))\r
- rows = 2;\r
- else\r
- rows = 1;\r
- float height = 40;\r
-\r
- if(warmup_stage)\r
- {\r
- return pos;\r
- }\r
-\r
- xsave = pos_x;\r
- drawstring(pos, strcat("Accuracy stats (average ", ftos(average_accuracy), "%)"), sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
- pos_y += 18;\r
- vector tmp;\r
- tmp_x = sbwidth;\r
- tmp_y = height * rows;\r
-\r
- drawpic_tiled(pos, "gfx/hud/sb_scoreboard_bg", bg_size, tmp, rgb * sbar_color_bg_team, sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL);\r
- drawborderlines(sbar_accuracy_border_thickness, pos, tmp, '0 0 0', sbar_scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);\r
-\r
- // column highlighting\r
- for(i = 0; i < weapon_cnt/rows; ++i)\r
- {\r
- if(!mod(i, 2))\r
- 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
- }\r
-\r
- // row highlighting\r
- for(i = 0; i < rows; ++i)\r
- {\r
- 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
- }\r
-\r
- // skip useless weapons\r
- weapon_cnt = 0;\r
- for(i = WEP_FIRST; i <= WEP_LAST; ++i)\r
- {\r
- self = get_weaponinfo(i);\r
- if not(self.weapons)\r
- continue;\r
- ++weapon_cnt;\r
- }\r
-\r
- drawfont = sbar_bigfont;\r
- average_accuracy = 0;\r
- float weapons_with_stats;\r
- weapons_with_stats = 0;\r
- if(rows == 2)\r
- pos_x += sbwidth/weapon_cnt / 2;\r
-\r
- for(i = WEP_FIRST; i <= WEP_LAST; ++i)\r
- {\r
- self = get_weaponinfo(i);\r
- if not(self.weapons)\r
- continue;\r
- weapon_hit = weapon_hits[i-WEP_FIRST];\r
- weapon_damage = weapon_fired[i-WEP_FIRST];\r
- if(weapon_damage)\r
- weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100);\r
- float weapon_alpha;\r
-\r
- if(weapon_damage)\r
- weapon_alpha = sbar_scoreboard_alpha_fg;\r
- else\r
- weapon_alpha = 0.2 * sbar_scoreboard_alpha_fg;\r
-\r
- // weapon icon\r
- drawpic(pos, strcat("gfx/hud/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
- // the accuracy\r
- if(weapon_damage) {\r
- weapons_with_stats += 1;\r
- average_accuracy += weapon_stats; // store sum of all accuracies in average_accuracy\r
-\r
- string s;\r
- s = strcat(ftos(weapon_stats),"%");\r
-\r
- float padding;\r
- padding = ((sbwidth/weapon_cnt) - stringwidth(s, FALSE, '1 0 0' * fontsize)) / 2; // center the accuracy value\r
-\r
- rgb = Sbar_AccuracyColor(weapon_stats);\r
- 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
- }\r
- pos_x += sbwidth/weapon_cnt * rows;\r
- if(rows == 2 && i == 6) {\r
- pos_x -= sbwidth;\r
- pos_y += height;\r
- }\r
- }\r
- drawfont = sbar_font;\r
-\r
- if(weapons_with_stats)\r
- average_accuracy = floor(average_accuracy / weapons_with_stats);\r
-\r
- pos_x = xsave;\r
- pos_y += height;\r
- return pos;\r
-}\r
-\r
-string race_PlaceName(float pos) {\r
- if(pos == 1)\r
- return "1st";\r
- else if(pos == 2)\r
- return "2nd";\r
- else if(pos == 3)\r
- return "3rd";\r
- else\r
- return strcat(ftos(pos), "th");\r
-}\r
-\r
-vector Sbar_DrawScoreboardRankings(vector pos, entity pl, vector rgb, vector bg_size)\r
-{\r
- float i;\r
- RANKINGS_RECEIVED_CNT = 0;\r
- for (i=RANKINGS_CNT-1; i>=0; --i)\r
- if (grecordtime[i])\r
- RANKINGS_RECEIVED_CNT = RANKINGS_RECEIVED_CNT + 1;\r
-\r
- if (RANKINGS_RECEIVED_CNT == 0)\r
- return pos;\r
-\r
- float is_spec;\r
- is_spec = (GetPlayerColor(pl.sv_entnum) == COLOR_SPECTATOR);\r
- vector hl_rgb;\r
- hl_rgb = stov(cvar_string("sbar_color_bg")) + '0.5 0.5 0.5';\r
-\r
- pos_y += sbar_fontsize_y;\r
- drawstring(pos, strcat("Rankings"), sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
- pos_y += sbar_fontsize_y;\r
- vector tmp;\r
- tmp_x = sbwidth;\r
- tmp_y = sbar_fontsize_y * RANKINGS_RECEIVED_CNT;\r
-\r
- drawpic_tiled(pos, "gfx/hud/sb_scoreboard_bg", bg_size, tmp, rgb * sbar_color_bg_team, sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL);\r
- drawborderlines(sbar_border_thickness, pos, tmp, '0 0 0', sbar_scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);\r
-\r
- // row highlighting\r
- for(i = 0; i<RANKINGS_RECEIVED_CNT; ++i)\r
- {\r
- string n, p;\r
- float t;\r
- t = grecordtime[i];\r
- if (t == 0)\r
- continue;\r
- n = grecordholder[i];\r
- p = race_PlaceName(i+1);\r
- if(grecordholder[i] == GetPlayerName(player_localentnum - 1))\r
- drawfill(pos, '1 0 0' * sbwidth + '0 1 0' * sbar_fontsize_y, hl_rgb, sbar_scoreboard_highlight_alpha_self, DRAWFLAG_NORMAL); \r
- else if(!mod(i, 2) && sbar_scoreboard_highlight)\r
- drawfill(pos, '1 0 0' * sbwidth + '0 1 0' * sbar_fontsize_y, hl_rgb, sbar_scoreboard_highlight_alpha, DRAWFLAG_NORMAL); \r
- drawstring(pos, p, sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
- drawstring(pos + '3 0 0' * sbar_fontsize_x, TIME_ENCODED_TOSTRING(t), sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
- drawcolorcodedstring(pos + '8 0 0' * sbar_fontsize_x, n, sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
- pos += '0 1 0' * sbar_fontsize_y;\r
- }\r
-\r
- return pos;\r
-}\r
-\r
-float scoreboard_bottom;\r
-float sbar_scoreboard_fade_alpha;\r
-float sbar_woulddrawscoreboard_prev;\r
-float sbar_woulddrawscoreboard_change; // "time" at which Sbar_WouldDrawScoreboard() changed\r
-void Sbar_DrawScoreboard()\r
-{\r
- float sbar_woulddrawscoreboard; \r
- sbar_woulddrawscoreboard = Sbar_WouldDrawScoreboard();\r
- if(sbar_woulddrawscoreboard != sbar_woulddrawscoreboard_prev) {\r
- sbar_woulddrawscoreboard_change = time;\r
- sbar_woulddrawscoreboard_prev = sbar_woulddrawscoreboard;\r
- }\r
-\r
- float scoreboard_fadeinspeed = cvar_or("sbar_scoreboard_fadeinspeed", 10);\r
- float scoreboard_fadeoutspeed = cvar_or("sbar_scoreboard_fadeoutspeed", 5);\r
- if(sbar_woulddrawscoreboard) {\r
- if (scoreboard_fadeinspeed)\r
- sbar_scoreboard_fade_alpha = bound (0, (time - sbar_woulddrawscoreboard_change) * scoreboard_fadeinspeed, 1);\r
- else\r
- sbar_scoreboard_fade_alpha = 1;\r
- }\r
- else\r
- if (scoreboard_fadeoutspeed)\r
- sbar_scoreboard_fade_alpha = bound (0, (1/scoreboard_fadeoutspeed - (time - sbar_woulddrawscoreboard_change)) * scoreboard_fadeoutspeed, 1);\r
- else\r
- sbar_scoreboard_fade_alpha = 0;\r
-\r
- if not(sbar_scoreboard_fade_alpha)\r
- return;\r
- \r
- sbar_scoreboard_alpha_bg = cvar("sbar_scoreboard_alpha_bg") * sbar_scoreboard_fade_alpha;\r
- sbar_scoreboard_alpha_fg = cvar_or("sbar_scoreboard_alpha_fg", 1.0) * sbar_scoreboard_fade_alpha;\r
- sbar_scoreboard_highlight = cvar("sbar_scoreboard_highlight");\r
- sbar_scoreboard_highlight_alpha = cvar_or("sbar_scoreboard_highlight_alpha", 0.10) * sbar_scoreboard_alpha_fg;\r
- sbar_scoreboard_highlight_alpha_self = cvar_or("sbar_scoreboard_highlight_alpha_self", 0.25) * sbar_scoreboard_alpha_fg;\r
- sbar_scoreboard_alpha_name = cvar_or("sbar_scoreboard_alpha_name", 0.9) * sbar_scoreboard_alpha_fg;\r
- sbar_scoreboard_alpha_name_self = cvar_or("sbar_scoreboard_alpha_name_self", 1) * sbar_scoreboard_alpha_fg;\r
- \r
- vector rgb, pos, tmp;\r
- entity pl, tm;\r
-\r
- sbwidth = Sbar_GetWidth(6.5 * sbar_fontsize_y);\r
-\r
- xmin = 0.5 * (vid_conwidth - sbwidth);\r
- ymin = cvar("sbar_scoreboard_offset");\r
-\r
- xmax = vid_conwidth - xmin;\r
- ymax = vid_conheight - 0.2*vid_conheight;\r
-\r
- // Initializes position\r
- pos_x = xmin;\r
- pos_y = ymin;\r
- pos_z = 0;\r
-\r
- // Heading\r
- drawfont = sbar_bigfont;\r
- if(gametype == GAME_RPG)\r
- drawstringcenter('0 1 0' * ymin, "Players", '24 24 0', '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
- else\r
- drawstringcenter('0 1 0' * ymin, "Scoreboard", '24 24 0', '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
-\r
- pos_y += 24 + 4;\r
- pos_y += sbar_fontsize_y;\r
-\r
- drawfont = sbar_font;\r
-\r
- // Draw the scoreboard\r
- vector bg_size;\r
- bg_size = drawgetimagesize("gfx/hud/sb_scoreboard_bg");\r
-\r
- if(teamplay)\r
- {\r
- for(tm = teams.sort_next; tm; tm = tm.sort_next)\r
- {\r
- if(tm.team == COLOR_SPECTATOR)\r
- continue;\r
-\r
- rgb = GetTeamRGB(tm.team);\r
- 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
- \r
- if(ts_primary != ts_secondary)\r
- 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
-\r
- pos = Sbar_Scoreboard_MakeTable(pos, tm, rgb, bg_size);\r
- }\r
- }\r
- else\r
- {\r
- rgb = stov(cvar_string("sbar_color_bg"));\r
-\r
- for(tm = teams.sort_next; tm; tm = tm.sort_next)\r
- {\r
- if(tm.team == COLOR_SPECTATOR)\r
- continue;\r
-\r
- pos = Sbar_Scoreboard_MakeTable(pos, tm, rgb, bg_size);\r
- }\r
- }\r
-\r
- if(gametype == GAME_CTS || gametype == GAME_RACE) {\r
- if(race_speedaward) {\r
- drawcolorcodedstring(pos, strcat("Speed award: ", ftos(race_speedaward), " (", race_speedaward_holder, ")"), sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
- pos_y += 1.25 * sbar_fontsize_y;\r
- }\r
- if(race_speedaward_alltimebest) {\r
- drawcolorcodedstring(pos, strcat("All-time fastest: ", ftos(race_speedaward_alltimebest), " (", race_speedaward_alltimebest_holder, ")"), sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
- pos_y += 1.25 * sbar_fontsize_y;\r
- }\r
- pos = Sbar_DrawScoreboardRankings(pos, pl, rgb, bg_size);\r
- }\r
- else if(cvar("sbar_accuracy") && spectatee_status != -1) {\r
- if(teamplay)\r
- pos = Sbar_DrawScoreboardAccuracyStats(pos, GetTeamRGB(myteam), bg_size);\r
- else\r
- pos = Sbar_DrawScoreboardAccuracyStats(pos, rgb, bg_size);\r
- }\r
-\r
- tmp = pos + '0 1.5 0' * sbar_fontsize_y;\r
- pos_y += 3 * sbar_fontsize_y;\r
-\r
- // List spectators\r
- float specs;\r
- specs = 0;\r
- for(pl = players.sort_next; pl; pl = pl.sort_next)\r
- {\r
- if(pl.team != COLOR_SPECTATOR)\r
- continue;\r
- Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), specs);\r
- pos_y += 1.25 * sbar_fontsize_y;\r
- ++specs;\r
- }\r
-\r
- if(specs)\r
- drawstring(tmp, "Spectators", sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
-\r
- // Print info string\r
- string str;\r
- float tl, fl, ll;\r
- if(gametype == GAME_RPG)\r
- str = strcat("you are in ^2", shortmapname, "^7");\r
- else\r
- str = strcat("playing on ^2", shortmapname, "^7");\r
- tl = getstatf(STAT_TIMELIMIT);\r
- fl = getstatf(STAT_FRAGLIMIT);\r
- ll = getstatf(STAT_LEADLIMIT);\r
- if(gametype == GAME_LMS)\r
- {\r
- if(tl > 0)\r
- str = strcat(str, " for up to ^1", ftos(tl), " minutes^7");\r
- }\r
- else\r
- {\r
- if(tl > 0)\r
- str = strcat(str, " for ^1", ftos(tl), " minutes^7");\r
- if(fl > 0 && !(gametype == GAME_RPG))\r
- {\r
- if(tl > 0)\r
- str = strcat(str, " or");\r
- if(teamplay)\r
- {\r
- str = strcat(str, " until ^3", ScoreString(teamscores_flags[ts_primary], fl));\r
- if(teamscores_label[ts_primary] == "score")\r
- str = strcat(str, " points^7");\r
- else if(teamscores_label[ts_primary] == "fastest")\r
- str = strcat(str, " is beaten^7");\r
- else\r
- str = strcat(str, " ", teamscores_label[ts_primary]);\r
- }\r
- else\r
- {\r
- str = strcat(str, " until ^3", ScoreString(scores_flags[ps_primary], fl));\r
- if(scores_label[ps_primary] == "score")\r
- str = strcat(str, " points^7");\r
- else if(scores_label[ps_primary] == "fastest")\r
- str = strcat(str, " is beaten^7");\r
- else\r
- str = strcat(str, " ", scores_label[ps_primary]);\r
- }\r
- }\r
- if(ll > 0)\r
- {\r
- if(tl > 0 || fl > 0)\r
- str = strcat(str, " or");\r
- if(teamplay)\r
- {\r
- str = strcat(str, " until a lead of ^3", ScoreString(teamscores_flags[ts_primary], ll));\r
- if(teamscores_label[ts_primary] == "score")\r
- str = strcat(str, " points^7");\r
- else if(teamscores_label[ts_primary] == "fastest")\r
- str = strcat(str, " is beaten^7");\r
- else\r
- str = strcat(str, " ", teamscores_label[ts_primary]);\r
- }\r
- else\r
- {\r
- str = strcat(str, " until a lead of ^3", ScoreString(scores_flags[ps_primary], ll));\r
- if(scores_label[ps_primary] == "score")\r
- str = strcat(str, " points^7");\r
- else if(scores_label[ps_primary] == "fastest")\r
- str = strcat(str, " is beaten^7");\r
- else\r
- str = strcat(str, " ", scores_label[ps_primary]);\r
- }\r
- }\r
- }\r
-\r
-\r
- pos_y += 1.2 * sbar_fontsize_y;\r
- drawcolorcodedstring(pos + '0.5 0 0' * (sbwidth - stringwidth(str, TRUE, sbar_fontsize)), str, sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);\r
-\r
- scoreboard_bottom = pos_y + 2 * sbar_fontsize_y;\r
-}\r
-\r
-string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)\r
-{\r
- string col;\r
- string timestr;\r
- string cpname;\r
- string lapstr;\r
- lapstr = "";\r
-\r
- if(histime == 0) // goal hit\r
- {\r
- if(mytime > 0)\r
- {\r
- timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));\r
- col = "^1";\r
- }\r
- else if(mytime == 0)\r
- {\r
- timestr = "+0.0";\r
- col = "^3";\r
- }\r
- else\r
- {\r
- timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));\r
- col = "^2";\r
- }\r
-\r
- if(lapdelta > 0)\r
- {\r
- lapstr = strcat(" (-", ftos(lapdelta), "L)");\r
- col = "^2";\r
- }\r
- else if(lapdelta < 0)\r
- {\r
- lapstr = strcat(" (+", ftos(-lapdelta), "L)");\r
- col = "^1";\r
- }\r
- }\r
- else if(histime > 0) // anticipation\r
- {\r
- if(mytime >= histime)\r
- timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));\r
- else\r
- timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));\r
- col = "^3";\r
- }\r
- else\r
- col = "^7";\r
-\r
- if(cp == 254)\r
- cpname = "Start line";\r
- else if(cp == 255)\r
- cpname = "Finish line";\r
- else if(cp)\r
- cpname = strcat("Intermediate ", ftos(cp));\r
- else\r
- cpname = "Finish line";\r
-\r
- if(histime < 0)\r
- return strcat(col, cpname);\r
- else if(hisname == "")\r
- return strcat(col, cpname, " (", timestr, ")");\r
- else\r
- return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");\r
-}\r
-\r
-float race_CheckName(string net_name) { // Does the name already exist in rankings? In that case, where? (otherwise 0)\r
- float i;\r
- for (i=RANKINGS_CNT-1;i>=0;--i)\r
- if(grecordholder[i] == net_name)\r
- return i+1;\r
- return 0;\r
-}\r
-\r
-float GetAmmoStat(float i)\r
-{\r
- switch(i)\r
- {\r
- case 0: return STAT_FUEL;\r
- default: return -1;\r
- }\r
-}\r
-\r
-float GetAmmoItemCode(float i)\r
-{\r
- switch(i)\r
- {\r
- case 0: return IT_FUEL;\r
- default: return -1;\r
- }\r
-}\r
-\r
-string GetAmmoPicture(float i)\r
-{\r
- switch(i)\r
- {\r
- case 0:\r
- if(getstati(STAT_ITEMS) & IT_FUEL_REGEN)\r
- return "gfx/hud/sb_fuel_regen";\r
- else\r
- return "gfx/hud/sb_fuel";\r
- default:\r
- return "";\r
- }\r
-}\r
-\r
-float race_status_time;\r
-float race_status_prev;\r
-string race_status_name_prev;\r
-void Sbar_DrawRaceStatus(vector pos)\r
-{\r
- if (race_status != race_status_prev || race_status_name != race_status_name_prev) {\r
- race_status_time = time + 5;\r
- race_status_prev = race_status;\r
- if (race_status_name_prev)\r
- strunzone(race_status_name_prev);\r
- race_status_name_prev = strzone(race_status_name);\r
- }\r
-\r
- float a;\r
- a = bound(0, race_status_time - time, 1);\r
-\r
- string s;\r
- s = textShortenToWidth(race_status_name, 120, '10 10 0', stringwidth_colors);\r
-\r
- float rank;\r
- if(race_status > 0)\r
- rank = race_CheckName(race_status_name);\r
- string rankname;\r
- rankname = race_PlaceName(rank);\r
-\r
- if(race_status == 0)\r
- drawpic(pos, "gfx/hud/race/newfail", '80 80 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);\r
- else if(race_status == 1) {\r
- drawpic(pos, "gfx/hud/race/newtime", '80 80 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL); \r
- 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
- 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
- } else if(race_status == 2) {\r
- if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)\r
- drawpic(pos, "gfx/hud/race/newrankgreen", '80 80 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);\r
- else\r
- drawpic(pos, "gfx/hud/race/newrankyellow", '80 80 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);\r
- 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
- 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
- } else if(race_status == 3) {\r
- drawpic(pos, "gfx/hud/race/newrecordserver", '80 80 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);\r
- 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
- 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
- }\r
-\r
- if (race_status_time - time <= 0) {\r
- race_status_prev = -1;\r
- race_status = -1;\r
- if(race_status_name)\r
- strunzone(race_status_name);\r
- race_status_name = string_null;\r
- if(race_status_name_prev)\r
- strunzone(race_status_name_prev);\r
- race_status_name_prev = string_null;\r
- }\r
-}\r
-\r
-void Sbar_Score()\r
-{\r
- float score, distribution, leader;\r
- vector score_pos, secondary_score_pos, race_score_pos, distribution_color;\r
- string racetime, secondary_racetime;\r
- entity tm, pl, me;\r
- me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];\r
-\r
- vector top;\r
- top_x = vid_conwidth / 2;\r
- top_y = 0;\r
- top_z = 0;\r
-\r
- if(gametype == GAME_RPG)\r
- return;\r
-\r
- score_pos = top + '-80 8 0';\r
- secondary_score_pos = score_pos + '80 -6 0';\r
-\r
- if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD\r
- pl = players.sort_next;\r
- if(pl == me)\r
- pl = pl.sort_next;\r
- if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)\r
- if(pl.scores[ps_primary] == 0)\r
- pl = world;\r
-\r
- score = me.(scores[ps_primary]);\r
-\r
- float racemin, racesec, racemsec;\r
- float distsec, distmsec;\r
- string s_racemin, s_racesec, s_racemsec;\r
- \r
- racemin = floor(score/(60 * TIME_FACTOR));\r
- racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);\r
- racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;\r
-\r
- if(racemin < 10) s_racemin = strcat("0", ftos(racemin));\r
- else s_racemin = ftos(racemin);\r
- if(racesec < 10) s_racesec = strcat("0", ftos(racesec));\r
- else s_racesec = ftos(racesec);\r
- if(racemsec < 10) s_racemsec = strcat("0", ftos(racemsec));\r
- else s_racemsec = ftos(racemsec);\r
-\r
- if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {\r
- // distribution display\r
- distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);\r
-\r
- if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)\r
- distmsec = fabs(distribution);\r
- else {\r
- distsec = floor(fabs(distribution) / TIME_FACTOR);\r
- distmsec = fabs(distribution) - distsec * TIME_FACTOR;\r
- }\r
-\r
- if (distribution < 0) {\r
- distribution_color = '0 1 0';\r
- secondary_racetime = "-"; // always prefix with minus sign\r
- }\r
- else if (distribution > 0) {\r
- distribution_color = '1 0 0';\r
- secondary_racetime = "+"; // minusplus 1: always prefix with plus sign\r
- }\r
- else\r
- distribution_color = '1 1 1';\r
-\r
- secondary_racetime = strcat(secondary_racetime, ftos(distsec), ".", ftos(distmsec));\r
- drawstring(score_pos + '222 0 0' - '14 0 0', secondary_racetime, '14 14 0', distribution_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- }\r
-\r
- racetime = strcat(s_racemin, " : ", s_racesec, " . ", s_racemsec);\r
- race_score_pos = top + '0 0 0';\r
- race_score_pos -= '1 0 0' * stringwidth(racetime, FALSE, '30 30 0') * 0.5;\r
- drawstring(race_score_pos, racetime, '30 30 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-\r
- } else if (!teamplay) { // non-teamgames, except race/cts\r
- // me vector := [team/connected frags id]\r
- pl = players.sort_next;\r
- if(pl == me)\r
- pl = pl.sort_next;\r
-\r
- if(pl)\r
- distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);\r
- else\r
- distribution = 0;\r
-\r
- score = me.(scores[ps_primary]);\r
- \r
- if(distribution >= 5) {\r
- distribution_color = '0 1 0';\r
- leader = 1;\r
- } else if(distribution >= 0) {\r
- distribution_color = '1 1 1';\r
- leader = 1;\r
- } else if(distribution >= -5)\r
- distribution_color = '1 1 0';\r
- else\r
- distribution_color = '1 0 0';\r
- \r
- Sbar_DrawXNum(secondary_score_pos, distribution, 6, 3, 16, distribution_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- Sbar_DrawXNum(score_pos, score, 6, 0, 34, distribution_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- } else { // teamgames\r
- float max_fragcount;\r
- max_fragcount = -999;\r
-\r
- for(tm = teams.sort_next; tm; tm = tm.sort_next) {\r
- if(tm.team == COLOR_SPECTATOR || !tm.team_size) // no players? don't display\r
- continue;\r
- score = tm.(teamscores[ts_primary]);\r
- leader = 0;\r
-\r
- if (score > max_fragcount)\r
- max_fragcount = score;\r
- \r
- if(tm.team == myteam) {\r
- if (max_fragcount == score)\r
- leader = 1;\r
- Sbar_DrawXNum(score_pos, score, 6, 0, 34, GetTeamRGB(tm.team), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- } else {\r
- if (max_fragcount == score)\r
- leader = 1;\r
- Sbar_DrawXNum(secondary_score_pos, score, 6, 3, 16, GetTeamRGB(tm.team), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- secondary_score_pos = secondary_score_pos + '0 16 0';\r
- }\r
- }\r
- }\r
-\r
- if(gametype == GAME_RACE || gametype == GAME_CTS)\r
- {\r
- drawfont = sbar_bigfont;\r
- float a, t;\r
- vector m;\r
- string s, forcetime;\r
-\r
- m = '0.5 0 0' * vid_conwidth + '0 1 0' * cvar_or("cl_racetimer_position", 0.25) * vid_conheight;\r
-\r
- if(race_checkpointtime)\r
- {\r
- a = bound(0, 2 - (time - race_checkpointtime), 1);\r
- s = "";\r
- forcetime = "";\r
- if(a > 0) // just hit a checkpoint?\r
- {\r
- if(race_checkpoint != 254)\r
- {\r
- if(race_time && race_previousbesttime)\r
- s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);\r
- else\r
- s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);\r
- if(race_time)\r
- forcetime = TIME_ENCODED_TOSTRING(race_time);\r
- }\r
- }\r
- else\r
- {\r
- if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)\r
- {\r
- a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);\r
- if(a > 0) // next one?\r
- {\r
- s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);\r
- }\r
- }\r
- }\r
-\r
- if(s != "" && a > 0)\r
- {\r
- dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)\r
- //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);\r
- 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
- }\r
-\r
- if(race_penaltytime)\r
- {\r
- a = bound(0, 2 - (time - race_penaltyeventtime), 1);\r
- if(a > 0)\r
- {\r
- s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");\r
- dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)\r
- //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);\r
- 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
- }\r
- }\r
-\r
- if(forcetime != "")\r
- {\r
- a = bound(0, (time - race_checkpointtime) / 0.5, 1);\r
- //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', sbar_alpha_fg, 0, a);\r
- 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
- }\r
- else\r
- a = 1;\r
-\r
- if(race_laptime && race_checkpoint != 255)\r
- {\r
- s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));\r
- //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);\r
- 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
- }\r
- }\r
- else\r
- {\r
- if(race_mycheckpointtime)\r
- {\r
- a = bound(0, 2 - (time - race_mycheckpointtime), 1);\r
- s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);\r
- dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)\r
- //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);\r
- 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
- }\r
- if(race_othercheckpointtime && race_othercheckpointenemy != "")\r
- {\r
- a = bound(0, 2 - (time - race_othercheckpointtime), 1);\r
- s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);\r
- dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)\r
- //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);\r
- 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
- }\r
-\r
- if(race_penaltytime && !race_penaltyaccumulator)\r
- {\r
- t = race_penaltytime * 0.1 + race_penaltyeventtime;\r
- a = bound(0, (1 + t - time), 1);\r
- if(a > 0)\r
- {\r
- if(time < t)\r
- s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");\r
- else\r
- s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");\r
- dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)\r
- //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);\r
- 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
- }\r
- }\r
- }\r
-\r
- drawfont = sbar_font;\r
- }\r
-}\r
-\r
-void Sbar_Status()\r
-{\r
- vector bottom;\r
- bottom_x = vid_conwidth/2;\r
- bottom_y = vid_conheight;\r
- bottom_z = 0;\r
-\r
- float armor, health, x, a;\r
- armor = getstati(STAT_ARMOR);\r
- health = getstati(STAT_HEALTH);\r
-\r
- float stat_items;\r
- stat_items = getstati(STAT_ITEMS);\r
-\r
- vector health_pos, armor_pos, pos;\r
- health_pos = bottom - '43 58 0';\r
- armor_pos = bottom - '43 68 0';\r
-\r
- if (cvar("viewsize") <= 100) {\r
- if (teamplay)\r
- drawpic(bottom - '96 96 0', "gfx/hud/bg_status", '192 96 0', GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // hud color = myteam color\r
- else {\r
- // allow for custom HUD colors in non-teamgames\r
- color = stov(cvar_string("sbar_color_bg"));\r
-\r
- drawpic(bottom - '96 96 0', "gfx/hud/bg_status", '192 96 0', color, sbar_alpha_bg, DRAWFLAG_NORMAL);\r
- }\r
- }\r
-\r
- // armor\r
- x = armor;\r
- if (x > 0)\r
- {\r
- drawpic(armor_pos + '-8 -13.5 0', "gfx/hud/sb_armor", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- armor_pos -= '1 0 0' * stringwidth(ftos(x), FALSE, '12 12 0') * 0.5;\r
- Sbar_DrawXNum(armor_pos, x, 3, 0, 12, Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- }\r
-\r
- // health\r
- x = health;\r
- drawpic(health_pos + '-11 16 0', "gfx/hud/sb_health", '32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- health_pos -= '1 0 0' * stringwidth(ftos(x), FALSE, '22 22 0') * 0.5;\r
- Sbar_DrawXNum(health_pos, x, 3, 0, 22, Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-\r
- // ammo\r
- pos_x = bottom_x + 140;\r
- pos_y = bottom_y - 20;\r
-\r
- float weapon_clipload, weapon_clipsize;\r
- vector ammo_pos_offset;\r
-\r
- // if we are using the jetpack, show fuel ammo. Otherwise show the ammo of our weapon\r
- if(stat_items & IT_JETPACK && button_jetpack)\r
- {\r
- a = getstati(GetAmmoStat(0)); // how much fuel do we have?\r
- drawpic(pos - '98 18 0', GetAmmoPicture(0), '20 20 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- ammo_pos_offset = '1 0 0' * stringwidth(ftos(a), FALSE, '16 16 0') * 0.5;\r
- Sbar_DrawXNum(pos - '118 16 0' - ammo_pos_offset, a, 3, 0, 16, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- }\r
- else\r
- {\r
- float i;\r
- for (i = 0; i < 1; ++i)\r
- {\r
- if (stat_items & GetAmmoItemCode(i))\r
- {\r
- a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i?\r
- drawpic(pos - '98 18 0', GetAmmoPicture(i), '20 20 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- weapon_clipsize = getstati(STAT_WEAPON_CLIPSIZE);\r
- // if the weapon we're holding is reloadable, show both its ammo and load\r
- if(weapon_clipsize)\r
- {\r
- weapon_clipload = getstati(STAT_WEAPON_CLIPLOAD);\r
- if(weapon_clipload < 0) // we're reloading\r
- {\r
- ammo_pos_offset = '1 0 0' * stringwidth("- -", FALSE, '16 16 0') * 0.5;\r
- drawstring(pos - '118 23 0' - ammo_pos_offset, "- -", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- }\r
- else\r
- {\r
- ammo_pos_offset = '1 0 0' * stringwidth(ftos(weapon_clipload), FALSE, '16 16 0') * 0.5;\r
- Sbar_DrawXNum(pos - '118 23 0' - ammo_pos_offset, weapon_clipload, 2, 0, 16, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- }\r
- ammo_pos_offset = '1 0 0' * stringwidth(ftos(a), FALSE, '12 12 0') * 0.5;\r
- Sbar_DrawXNum(pos - '118 7 0' - ammo_pos_offset, a, 3, 0, 12, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- }\r
- else\r
- {\r
- ammo_pos_offset = '1 0 0' * stringwidth(ftos(a), FALSE, '16 16 0') * 0.5;\r
- Sbar_DrawXNum(pos - '118 16 0' - ammo_pos_offset, a, 3, 0, 16, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- }\r
- }\r
- }\r
- }\r
-\r
- // weapon icon\r
- entity e;\r
- e = get_weaponinfo(activeweapon);\r
- if (e && e.netname != "" && e.netname != "N/A")\r
- drawpic(bottom - '96 96 0', strcat("gfx/hud/bg_status_activeweapon_", e.netname), '192 96 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-}\r
-\r
-void Sbar_Timer()\r
-{\r
- float timelimit, elapsedTime, minutes, seconds, timeleft, minutesLeft, secondsLeft;\r
- vector pos, bgpos, timer_color;\r
- string finaltime;\r
- bgpos = '0 0 0';\r
- \r
- vector topright;\r
- topright = '0 0 0';\r
- topright_x = vid_conwidth;\r
- \r
- float scale;\r
- scale = cvar_or("sbar_timer_scale", 1);\r
- timelimit = getstatf(STAT_TIMELIMIT);\r
-\r
- if(gametype == GAME_RPG && !timelimit) // don't draw the timer in rpg if there's no time limit\r
- return;\r
-\r
- Sbar_DrawRaceStatus((topright_x - 100) * '1 0 0' + '0 30 0' * scale);\r
- \r
- timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);\r
- timeleft = ceil(timeleft);\r
- minutesLeft = floor(timeleft / 60);\r
- secondsLeft = timeleft - minutesLeft*60;\r
-\r
- if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit\r
- timer_color = '1 1 1'; //white\r
- else if(minutesLeft >= 1)\r
- timer_color = '1 1 0'; //yellow\r
- else\r
- timer_color = '1 0 0'; //red\r
-\r
- if (cvar("sbar_increment_maptime") || timelimit == 0 || warmup_stage) {\r
- if (time < getstatf(STAT_GAMESTARTTIME)) {\r
- //while restart is still active, show 00:00\r
- minutes = seconds = 0;\r
- } else {\r
- elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127\r
- minutes = floor(elapsedTime / 60);\r
- seconds = elapsedTime - minutes*60;\r
- }\r
- if (minutes < 10)\r
- bgpos_x = topright_x - (54 + 17 + 12) * scale;\r
- else if (minutes < 100) // nudge the timer background left if more digits are drawn\r
- bgpos_x = topright_x - (62 + 17 + 12) * scale;\r
- else\r
- bgpos_x = topright_x - (70 + 17 + 12) * scale;\r
- bgpos_y = 0;\r
- bgpos_z = 0;\r
- } else {\r
- minutes = minutesLeft;\r
- seconds = secondsLeft;\r
- if (minutes < 10) // nudge the timer background left if more digits are drawn\r
- bgpos_x = topright_x - (54 + 17 + 12) * scale;\r
- else if (minutes < 100)\r
- bgpos_x = topright_x - (62 + 17 + 12) * scale;\r
- else\r
- bgpos_x = topright_x - (70 + 17 + 12) * scale;\r
- bgpos_y = 0;\r
- bgpos_z = 0;\r
- }\r
-\r
- if (cvar("viewsize") <= 100) { // draw timer background when viewsize <= 100\r
- if (teamplay)\r
- drawpic(bgpos, "gfx/hud/bg_timer", '120 30 0' * scale, GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // timer bg color = myteam color\r
- else {\r
- color = stov(cvar_string("sbar_color_bg"));\r
-\r
- drawpic(bgpos, "gfx/hud/bg_timer", '120 30 0' * scale, color, sbar_alpha_bg, DRAWFLAG_NORMAL);\r
- }\r
- }\r
-\r
- drawpic(topright - ('19 0 0' + '3 0 0' - '0 2 0'), "gfx/hud/sb_time", '22 22 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- finaltime = strcat(ftos(minutes), ":");\r
- if(seconds < 10)\r
- finaltime = strcat(finaltime, "0", ftos(seconds));\r
- else\r
- finaltime = strcat(finaltime, ftos(seconds));\r
-\r
- pos = topright - ('24 -2 0' + '3 0 0' - '0 2 0');\r
- pos -= '1 0 0' * stringwidth(finaltime, FALSE, 18 * scale * '1 1 0');\r
- drawstring(pos, finaltime, 18 * scale * '1 1 0', timer_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-}\r
-\r
-void Sbar_Ring()\r
-{\r
- vector ring_pos, ring1_color, ring2_color;\r
- vector text_pos, text1_size, text2_size;\r
- float ring1_alpha, ring2_alpha, ring1_size, ring1_clip, ring2_size, ring2_clip;\r
- string text1_msg, text2_msg;\r
-\r
- ring_pos_x = vid_conwidth / 2;\r
- ring_pos_y = vid_conheight - vid_conheight / 3.5;\r
- ring1_size = cvar("sbar_ring1_scale");\r
- ring2_size = cvar("sbar_ring2_scale");\r
- ring1_alpha = sbar_alpha_fg * cvar("sbar_ring1_alpha");\r
- ring2_alpha = sbar_alpha_fg * cvar("sbar_ring2_alpha");\r
- text1_size = '1 1 0' * cvar("sbar_ring1_text_scale");\r
- text2_size = '1 1 0' * cvar("sbar_ring2_text_scale");\r
-\r
- switch(getstati(STAT_SBRING1_TYPE))\r
- {\r
- case 0:\r
- // ring disabled\r
- break;\r
- case 1:\r
- // ring shows predator swallow progress, fills with progress\r
- ring1_color = '0.5 1 0.5';\r
- text1_msg = "Swallowing...";\r
- break;\r
- case 2:\r
- // ring shows vore system delay, empties with progress\r
- ring1_color = '0.5 0.5 1';\r
- text1_msg = "Vore delay";\r
- break;\r
- case 3:\r
- // ring shows stomach kick delay, empties with progress\r
- ring1_color = '1 1 0.5';\r
- text1_msg = "Kick delay";\r
- break;\r
- default:\r
- print(strcat("^1Error:^7 Unknown ring type: ", ftos(getstati(STAT_SBRING1_TYPE)), "\n"));\r
- break;\r
- }\r
- switch(getstati(STAT_SBRING2_TYPE))\r
- {\r
- case 0:\r
- // ring disabled\r
- break;\r
- case 1:\r
- // ring shows prey swallow progress, fills with progress\r
- ring2_color = '1 0.5 0.5';\r
- text2_msg = "Swallowed...";\r
- break;\r
- case 2:\r
- // ring shows regurgitation preparing, fills with progress\r
- ring2_color = '1 0.5 1';\r
- text2_msg = "Regurgitating...";\r
- break;\r
- default:\r
- print(strcat("^1Error:^7 Unknown ring type: ", ftos(getstati(STAT_SBRING1_TYPE)), "\n"));\r
- break;\r
- }\r
- ring1_clip = getstatf(STAT_SBRING1_CLIP);\r
- ring2_clip = getstatf(STAT_SBRING2_CLIP);\r
-\r
- if(text1_msg != "" && cvar("sbar_ring1"))\r
- {\r
- DrawCircleClippedPic(ring_pos, ring1_size, "gfx/hud/sb_ring.tga", ring1_clip, ring1_color, ring1_alpha, DRAWFLAG_ADDITIVE);\r
- text_pos_x = ring_pos_x - stringwidth(text1_msg, FALSE, text1_size) / 2;\r
- text_pos_y = ring_pos_y - ring1_size / 2;\r
- drawstring(text_pos, text1_msg, text1_size, ring1_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- }\r
- if(text2_msg != "" && cvar("sbar_ring2"))\r
- {\r
- DrawCircleClippedPic(ring_pos, ring2_size, "gfx/hud/sb_ring.tga", ring2_clip, ring2_color, ring2_alpha, DRAWFLAG_ADDITIVE);\r
- text_pos_x = ring_pos_x - stringwidth(text2_msg, FALSE, text2_size) / 2;\r
- text_pos_y = ring_pos_y + ring1_size / 2;\r
- drawstring(text_pos, text2_msg, text2_size, ring2_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- }\r
-}\r
-\r
-void CSQC_Strength_Timer() {\r
- vector pos;\r
- vector bottomright;\r
-\r
- bottomright_x = vid_conwidth;\r
- bottomright_y = vid_conheight;\r
- bottomright_z = 0;\r
-\r
- float stat_items, dt;\r
- stat_items = getstati(STAT_ITEMS);\r
- /*\r
- if not(stat_items & IT_STRENGTH)\r
- if not(stat_items & IT_INVINCIBLE)\r
- return;\r
- */\r
-\r
- if (getstati(STAT_HEALTH) <= 0)\r
- return;\r
-\r
- vector picsize;\r
- float strength_time, invincibility_time, countdown_fontsize;\r
-\r
- picsize = '22 22 0';\r
- countdown_fontsize = 18;\r
-\r
- pos = bottomright - '34 48 0';\r
-\r
- //strength\r
- strength_time = getstatf(STAT_STRENGTH_FINISHED);\r
- invincibility_time = getstatf(STAT_INVINCIBLE_FINISHED);\r
-\r
- if (strength_time) {\r
- dt = strength_time - time;\r
- if(dt > 0)\r
- {\r
- if(dt < 5)\r
- {\r
- drawpic_expanding_two(pos, "gfx/hud/sb_str", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE,\r
- bound(0, (ceil(dt) - dt) / 0.5, 1));\r
- }\r
- else\r
- {\r
- drawpic(pos, "gfx/hud/sb_str", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE);\r
- }\r
- Sbar_DrawXNum(pos - '30 -2 0', ceil(dt), 2, 0, countdown_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- }\r
- else if(dt > -1)\r
- {\r
- drawpic_expanding(pos, "gfx/hud/sb_str", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE,\r
- bound(0, -dt / 0.5, 1));\r
- }\r
- }\r
-\r
- //invincibility\r
- if (invincibility_time) {\r
- dt = invincibility_time - time;\r
- if(dt > 0)\r
- {\r
- if(dt < 5)\r
- {\r
- drawpic_expanding_two(pos - '0 -22 0', "gfx/hud/sb_invinc", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE,\r
- bound(0, (ceil(dt) - dt) / 0.5, 1));\r
- }\r
- else\r
- {\r
- drawpic(pos - '0 -22 0', "gfx/hud/sb_invinc", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE);\r
- }\r
- Sbar_DrawXNum(pos - '30 -24 0', ceil(dt), 2, 0, countdown_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- }\r
- else if(dt > -1)\r
- {\r
- drawpic_expanding(pos - '0 -22 0', "gfx/hud/sb_invinc", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE,\r
- bound(0, -dt / 0.5, 1));\r
- }\r
- }\r
-}\r
-\r
-#define CENTERPRINT_MAX_LINES 30\r
-string centerprint_messages[CENTERPRINT_MAX_LINES];\r
-float centerprint_width[CENTERPRINT_MAX_LINES];\r
-vector centerprint_start;\r
-float centerprint_expire;\r
-float centerprint_num;\r
-float centerprint_offset_hint;\r
-vector centerprint_fontsize;\r
-\r
-void centerprint(string strMessage)\r
-{\r
- float i, j, n, hcount;\r
- string s;\r
-\r
- centerprint_fontsize = Sbar_GetFontsize("scr_centersize");\r
-\r
- centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out\r
-\r
- if(cvar("scr_centertime") <= 0)\r
- return;\r
-\r
- if(strMessage == "")\r
- return;\r
-\r
- // strip trailing newlines\r
- j = strlen(strMessage) - 1;\r
- while(substring(strMessage, j, 1) == "\n" && j >= 0)\r
- j = j - 1;\r
- strMessage = substring(strMessage, 0, j + 1);\r
-\r
- if(strMessage == "")\r
- return;\r
-\r
- // strip leading newlines and remember them, they are a hint that the message should be lower on the screen\r
- j = 0;\r
- while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))\r
- j = j + 1;\r
- strMessage = substring(strMessage, j, strlen(strMessage) - j);\r
- centerprint_offset_hint = j;\r
-\r
- if(strMessage == "")\r
- return;\r
-\r
- // if we get here, we have a message. Initialize its height.\r
- centerprint_num = 0;\r
-\r
- n = tokenizebyseparator(strMessage, "\n");\r
- i = hcount = 0;\r
- for(j = 0; j < n; ++j)\r
- {\r
- getWrappedLine_remaining = argv(j);\r
- while(getWrappedLine_remaining)\r
- {\r
- s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);\r
- if(centerprint_messages[i])\r
- strunzone(centerprint_messages[i]);\r
- centerprint_messages[i] = strzone(s);\r
- centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);\r
- ++i;\r
-\r
- // half height for empty lines looks better\r
- if(s == "")\r
- hcount += 0.5;\r
- else\r
- hcount += 1;\r
-\r
- if(i >= CENTERPRINT_MAX_LINES)\r
- break;\r
- }\r
- }\r
-\r
- float h, havail;\r
- h = centerprint_fontsize_y*hcount;\r
-\r
- havail = vid_conheight;\r
- if(cvar("con_chatpos") < 0)\r
- havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat\r
- if(havail > vid_conheight / 4)\r
- havail = vid_conheight / 4; // avoid overlapping HUD\r
-\r
- centerprint_start_x = 0;\r
-\r
-#if 0\r
- float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;\r
-\r
- // here, the centerprint would cover the crosshair. REALLY BAD.\r
- forbiddenmin = vid_conheight * 0.5 - h - 16;\r
- forbiddenmax = vid_conheight * 0.5 + 16;\r
-\r
- allowedmin = scoreboard_bottom;\r
- allowedmax = havail - h;\r
- preferred = (havail - h)/2;\r
-\r
-\r
- // possible orderings (total: 4! / 4 = 6)\r
- // allowedmin allowedmax forbiddenmin forbiddenmax\r
- // forbiddenmin forbiddenmax allowedmin allowedmax\r
- if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)\r
- {\r
- // forbidden doesn't matter in this case\r
- centerprint_start_y = bound(allowedmin, preferred, allowedmax);\r
- }\r
- // allowedmin forbiddenmin allowedmax forbiddenmax\r
- else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)\r
- {\r
- centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);\r
- }\r
- // allowedmin forbiddenmin forbiddenmax allowedmax\r
- else if(allowedmin < forbiddenmin)\r
- {\r
- // make sure the forbidden zone is not covered\r
- if(preferred > (forbiddenmin + forbiddenmax) * 0.5)\r
- centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);\r
- else\r
- centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);\r
- }\r
- // forbiddenmin allowedmin allowedmax forbiddenmax\r
- else if(allowedmax < forbiddenmax)\r
- {\r
- // it's better to leave the allowed zone (overlap with scoreboard) than\r
- // to cover the forbidden zone (crosshair)\r
- if(preferred > (forbiddenmin + forbiddenmax) * 0.5)\r
- centerprint_start_y = forbiddenmax;\r
- else\r
- centerprint_start_y = forbiddenmin;\r
- }\r
- // forbiddenmin allowedmin forbiddenmax allowedmax\r
- else\r
- {\r
- centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);\r
- }\r
-#else\r
- centerprint_start_y =\r
- min(\r
- max(\r
- max(scoreboard_bottom, vid_conheight * 0.5 + 16),\r
- (havail - h)/2\r
- ),\r
- havail - h\r
- );\r
-#endif\r
-\r
- centerprint_num = i;\r
- centerprint_expire = time + cvar("scr_centertime");\r
-}\r
-\r
-void Sbar_DrawCenterPrint (void)\r
-{\r
- float i;\r
- vector pos;\r
- string ts;\r
- float a;\r
-\r
- //if(time > centerprint_expire)\r
- // return;\r
-\r
- //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);\r
- a = bound(0, 1 - 4 * (time - centerprint_expire), 1);\r
- //sz = 1.2 / (a + 0.2);\r
-\r
- if(a <= 0)\r
- return;\r
-\r
- pos = centerprint_start;\r
- for (i=0; i<centerprint_num; i = i + 1)\r
- {\r
- pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;\r
- ts = centerprint_messages[i];\r
- if (ts != "")\r
- {\r
- dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)\r
- drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);\r
- // - '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
- pos_y = pos_y + centerprint_fontsize_y;\r
- }\r
- else\r
- // half height for empty lines looks better\r
- pos_y = pos_y + centerprint_fontsize_y * 0.5;\r
- }\r
-}\r
-\r
-vector Sbar_DrawNoteLine(vector offset, string s)\r
-{\r
- dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)\r
- drawcolorcodedstring(\r
- offset - '1 0 0' * stringwidth(s, TRUE, sbar_fontsize),\r
- s,\r
- sbar_fontsize,\r
- sbar_alpha_fg,\r
- 0\r
- );\r
- return offset + sbar_fontsize_y * '0 1 0';\r
-}\r
-\r
-void Sbar_DrawPressedKeys(void)\r
-{\r
- vector pos, bgsize;\r
- float pressedkeys;\r
-\r
- pos = stov(cvar_string("cl_showpressedkeys_position"));\r
-\r
- bgsize = '126 75 0';\r
-\r
- pos = '1 0 0' * (vid_conwidth - bgsize_x) * pos_x\r
- + '0 1 0' * (vid_conheight - bgsize_y) * pos_y;\r
- pos -= '-15 -6 0'; // adjust to the origin of these numbers\r
-\r
- pressedkeys = getstatf(STAT_PRESSED_KEYS);\r
- drawpic(pos + '-15 -6 0', "gfx/hud/keys/key_bg.tga", bgsize, '1 1 1', 0.1 * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawpic(pos + ' 83.5 9 0', ((pressedkeys & KEY_CROUCH) ? "gfx/hud/keys/key_crouch_inv.tga" : "gfx/hud/keys/key_crouch.tga"), ' 24 24 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawpic(pos + ' 32 -1.5 0', ((pressedkeys & KEY_FORWARD) ? "gfx/hud/keys/key_forward_inv.tga" : "gfx/hud/keys/key_forward.tga"), ' 32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawpic(pos + '-11.5 9 0', ((pressedkeys & KEY_JUMP) ? "gfx/hud/keys/key_jump_inv.tga" : "gfx/hud/keys/key_jump.tga"), ' 24 24 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawpic(pos + ' -1 32 0', ((pressedkeys & KEY_LEFT) ? "gfx/hud/keys/key_left_inv.tga" : "gfx/hud/keys/key_left.tga"), ' 32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawpic(pos + ' 32 32 0', ((pressedkeys & KEY_BACKWARD) ? "gfx/hud/keys/key_backward_inv.tga" : "gfx/hud/keys/key_backward.tga"), ' 32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawpic(pos + ' 65 32 0', ((pressedkeys & KEY_RIGHT) ? "gfx/hud/keys/key_right_inv.tga" : "gfx/hud/keys/key_right.tga"), ' 32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-}\r
-\r
-void Sbar_ShowSpeed(void)\r
-{\r
- vector numsize;\r
- float pos, conversion_factor;\r
- string speed, zspeed, unit;\r
-\r
- switch(cvar("cl_showspeed_unit"))\r
- {\r
- default:\r
- case 0:\r
- unit = "";\r
- conversion_factor = 1.0;\r
- break;\r
- case 1:\r
- unit = " qu/s";\r
- conversion_factor = 1.0;\r
- break;\r
- case 2:\r
- unit = " m/s";\r
- conversion_factor = 0.0254;\r
- break;\r
- case 3:\r
- unit = " km/h";\r
- conversion_factor = 0.0254 * 3.6;\r
- break;\r
- case 4:\r
- unit = " mph";\r
- conversion_factor = 0.0254 * 3.6 * 0.6213711922;\r
- break;\r
- case 5:\r
- unit = " knots";\r
- conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h\r
- break;\r
- }\r
-\r
- speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);\r
-\r
- numsize_x = numsize_y = cvar("cl_showspeed_size");\r
- pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");\r
- \r
- drawfont = sbar_bigfont;\r
- drawstringcenter('1 0 0' + pos * '0 1 0', speed, numsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-\r
- if (cvar("cl_showspeed_z") == 1) {\r
- zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);\r
- 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
- }\r
-\r
- drawfont = sbar_font;\r
-}\r
-\r
-vector acc_prevspeed;\r
-float acc_prevtime;\r
-float acc_avg;\r
-\r
-void Sbar_ShowAcceleration(void)\r
-{\r
- float acceleration, sz, scale, alpha, f;\r
- vector pos, top, rgb;\r
- top_x = vid_conwidth/2;\r
- top_y = 0;\r
-\r
- f = time - acc_prevtime;\r
- if(cvar("cl_showacceleration_z"))\r
- acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);\r
- else\r
- acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);\r
- acc_prevspeed = pmove_vel;\r
- acc_prevtime = time;\r
-\r
- f = bound(0, f * 10, 1);\r
- acc_avg = acc_avg * (1 - f) + acceleration * f;\r
- acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);\r
-\r
- pos = top - sz/2 * '0 1 0' + (cvar("cl_showacceleration_position") * vid_conheight) * '0 1 0';\r
-\r
- sz = cvar("cl_showacceleration_size");\r
- scale = cvar("cl_showacceleration_scale");\r
- alpha = cvar("cl_showacceleration_alpha");\r
- if (cvar("cl_showacceleration_color_custom"))\r
- rgb = stov(cvar_string("cl_showacceleration_color"));\r
- else {\r
- rgb = '1 1 1';\r
- if (acceleration < 0) {\r
- rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);\r
- } else if (acceleration > 0) {\r
- rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);\r
- }\r
- }\r
- \r
- if (acceleration > 0)\r
- drawpic(pos, "gfx/hud/accelerometer_gradient", acceleration * scale * '40 0 0' + sz * '0 1 0', rgb, alpha * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- else if (acceleration < 0)\r
- drawpic(pos + acceleration * scale * '40 0 0', "gfx/hud/accelerometer_gradient", -acceleration * scale * '40 0 0' + sz * '0 1 0', rgb, alpha * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-}\r
-\r
-void Sbar_DrawAccuracyStats_Description_Hitscan(vector position)\r
-{\r
- drawstring(position + '0 3 0' * sbar_fontsize_y, "Shots fired:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawstring(position + '0 5 0' * sbar_fontsize_y, "Shots hit:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawstring(position + '0 7 0' * sbar_fontsize_y, "Accuracy:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawstring(position + '0 9 0' * sbar_fontsize_y, "Shots missed:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-}\r
-\r
-/*void Sbar_DrawAccuracyStats_Description_Splash(vector position)\r
-{\r
- drawstring(position + '0 3 0' * sbar_fontsize_y, "Maximum damage:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawstring(position + '0 5 0' * sbar_fontsize_y, "Actual damage:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawstring(position + '0 7 0' * sbar_fontsize_y, "Accuracy:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawstring(position + '0 9 0' * sbar_fontsize_y, "Damage wasted:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-}*/ // we have no splash damage weapons, but keep this code just in case\r
-\r
-void Sbar_DrawAccuracyStats()\r
-{\r
- float i, count_hitscan, /*count_splash,*/ row_hitscan/*, row_splash*/; // count is the number of 'colums'\r
- float weapon_hit, weapon_damage, weapon_stats;\r
- float left_border; // position where the weapons start, the description is in the border\r
- vector fill_colour, fill_size;\r
- vector pos;\r
- vector border_colour;\r
-\r
- float col_margin = 20; // pixels between the columns\r
- float row_margin = 20; // pixels between the rows\r
-\r
- fill_size_x = 5 * sbar_fontsize_x; // width of the background\r
- fill_size_y = 10 * sbar_fontsize_y; // height of the background\r
-\r
- drawfont = sbar_bigfont;\r
- pos_x = 0;\r
- pos_y = cvar("sbar_scoreboard_offset");\r
- pos_z = 0;\r
- drawstringcenter(pos, "Weapon Accuracy", 2 * sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-\r
- left_border = col_margin + 11 * sbar_fontsize_x;\r
-\r
- drawfont = sbar_font;\r
-\r
- if(warmup_stage)\r
- {\r
- pos_y += 40;\r
- if(mod(time, 1) >= 0.4)\r
- drawstringcenter(pos, "Stats are not tracked during warmup stage", sbar_fontsize, '1 1 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-\r
- return;\r
- }\r
-\r
- if(gametype == GAME_RACE || gametype == GAME_CTS)\r
- {\r
- pos_y += 40;\r
- if(mod(time, 1) >= 0.4)\r
- drawstringcenter(pos, "Stats are not tracked in Race/CTS", sbar_fontsize, '1 1 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-\r
- return;\r
- }\r
-\r
- float top_border_hitscan = cvar("sbar_scoreboard_offset") + 55; // position where the hitscan row starts: pixels down the screen\r
- Sbar_DrawAccuracyStats_Description_Hitscan('1 0 0' * col_margin + '0 1 0' * top_border_hitscan);\r
-\r
-// float top_border_splash = cvar("sbar_scoreboard_offset") + 175; // position where the splash row starts: pixels down the screen\r
-// Sbar_DrawAccuracyStats_Description_Splash('1 0 0' * col_margin + '0 1 0' * top_border_splash);\r
-\r
- for(i = WEP_FIRST; i <= WEP_LAST; ++i)\r
- {\r
- self = get_weaponinfo(i);\r
- if not(self.weapons)\r
- continue;\r
- weapon_hit = weapon_hits[i-WEP_FIRST];\r
- weapon_damage = weapon_fired[i-WEP_FIRST];\r
- border_colour = (i == activeweapon) ? '1 1 1' : '0 0 0'; // white or black border\r
-\r
- if (weapon_damage) {\r
- /*if (self.spawnflags & WEP_TYPE_SPLASH) {\r
- weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100);\r
-\r
- fill_colour_x = 1 - 0.015 * weapon_stats;\r
- fill_colour_y = 1 - 0.015 * (100 - weapon_stats);\r
-\r
- // how the background colour is calculated\r
- // % red green red_2 green_2\r
- // 0 1 0 1 - % * 0.015 1 - (100 - %) * 0.015\r
- // 10 0.85 0 1 - % * 0.015 1 - (100 - %) * 0.015\r
- // 20 0.70 0 1 - % * 0.015 1 - (100 - %) * 0.015\r
- // 30 0.55 0 1 - % * 0.015 1 - (100 - %) * 0.015\r
- // 40 0.40 0.10 1 - % * 0.015 1 - (100 - %) * 0.015\r
- // 50 0.25 0.25 1 - % * 0.015 1 - (100 - %) * 0.015\r
- // 60 0.10 0.40 1 - % * 0.015 1 - (100 - %) * 0.015\r
- // 70 0 0.55 1 - % * 0.015 1 - (100 - %) * 0.015\r
- // 80 0 0.70 1 - % * 0.015 1 - (100 - %) * 0.015\r
- // 90 0 0.85 1 - % * 0.015 1 - (100 - %) * 0.015\r
- // 100 0 1 1 - % * 0.015 1 - (100 - %) * 0.015\r
-\r
- if ((left_border + count_splash * (fill_size_x + col_margin) + fill_size_x) >= vid_conwidth)\r
- {\r
- count_splash = 0;\r
- ++row_splash;\r
- Sbar_DrawAccuracyStats_Description_Splash('1 0 0' * col_margin + '0 1 0' * (top_border_splash + row_splash * (fill_size_y + row_margin)));\r
- }\r
-\r
- pos_x = left_border + count_splash * (fill_size_x + col_margin);\r
- pos_y = top_border_splash + row_splash * (fill_size_y + row_margin);\r
-\r
- // background\r
- drawpic(pos, "gfx/hud/sb_accuracy", fill_size , fill_colour, sbar_alpha_bg, DRAWFLAG_NORMAL);\r
- drawborderlines(sbar_border_thickness, pos, fill_size, border_colour, sbar_alpha_bg, DRAWFLAG_NORMAL);\r
-\r
- // the weapon\r
- drawpic(pos, strcat("gfx/hud/inv_weapon", self.netname), '1 0.5 0' * fill_size_x , '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-\r
- // the amount of shots fired or max damage\r
- 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
-\r
- // the amount of hits or actual damage\r
- 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
-\r
- // the accuracy\r
- 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
-\r
- // the amount of shots missed or damage wasted\r
- 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
-\r
- ++count_splash;\r
- } else*/ // we have no splash damage weapons, but keep this code just in case\r
-\r
- if (self.spawnflags & WEP_TYPE_HITSCAN) {\r
- weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100);\r
-\r
- fill_colour_x = 1 - 0.015 * weapon_stats;\r
- fill_colour_y = 1 - 0.015 * (100 - weapon_stats);\r
-\r
- // how the background colour is calculated\r
- // % red green red_2 green_2\r
- // 0 1 0 1 - % * 0.015 1 - (100 - %) * 0.015\r
- // 10 0.850 0 1 - % * 0.015 1 - (100 - %) * 0.015\r
- // 20 0.70 0 1 - % * 0.015 1 - (100 - %) * 0.015\r
- // 30 0.55 0 1 - % * 0.015 1 - (100 - %) * 0.015\r
- // 40 0.40 0.10 1 - % * 0.015 1 - (100 - %) * 0.015\r
- // 50 0.25 0.25 1 - % * 0.015 1 - (100 - %) * 0.015\r
- // 60 0.10 0.40 1 - % * 0.015 1 - (100 - %) * 0.015\r
- // 70 0 0.55 1 - % * 0.015 1 - (100 - %) * 0.015\r
- // 80 0 0.70 1 - % * 0.015 1 - (100 - %) * 0.015\r
- // 90 0 0.85 1 - % * 0.015 1 - (100 - %) * 0.015\r
- // 100 0 1 1 - % * 0.015 1 - (100 - %) * 0.015\r
-\r
- if ((left_border + count_hitscan * (fill_size_x + col_margin) + fill_size_x + cvar("stats_right_margin")) >= vid_conwidth)\r
- {\r
- count_hitscan = 0;\r
- ++row_hitscan;\r
- Sbar_DrawAccuracyStats_Description_Hitscan('1 0 0' * col_margin + '0 1 0' * (top_border_hitscan + row_hitscan * (fill_size_y + row_margin)));\r
- }\r
-\r
- pos_x = left_border + count_hitscan * (fill_size_x + col_margin);\r
- pos_y = top_border_hitscan + row_hitscan * (fill_size_y + row_margin);\r
-\r
- // background\r
- drawpic(pos, "gfx/hud/sb_accuracy", fill_size , fill_colour, sbar_alpha_bg, DRAWFLAG_NORMAL);\r
- drawborderlines(sbar_border_thickness, pos, fill_size, border_colour, sbar_alpha_bg, DRAWFLAG_NORMAL);\r
-\r
- // the weapon\r
- drawpic(pos, strcat("gfx/hud/inv_weapon", self.netname), '1 0.5 0' * fill_size_x , '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-\r
- // the amount of shots fired or max damage\r
- 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
-\r
- // the amount of hits or actual damage\r
- 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
-\r
- // the accuracy\r
- 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
-\r
- // the amount of shots missed or damage wasted\r
- 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
-\r
- ++count_hitscan;\r
- }\r
- }\r
- }\r
-}\r
-\r
-void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)\r
-{\r
- position_x -= 2 / 3 * strlen(text) * scale_x;\r
- drawstring(position, text, scale, rgb, alpha, flag);\r
-}\r
-\r
-void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)\r
-{\r
- position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);\r
- drawstring(position, text, scale, rgb, alpha, flag);\r
-}\r
-\r
-void Sbar_Reset (void)\r
-{\r
- // reset gametype specific icons\r
- if(gametype == GAME_KEYHUNT)\r
- CSQC_kh_hudreset();\r
- else if(gametype == GAME_CTF)\r
- CSQC_ctf_hudreset();\r
-}\r
-\r
-float vote_yescount;\r
-float vote_nocount;\r
-float vote_needed;\r
-float vote_highlighted; // currently selected vote\r
-\r
-float vote_active; // is there an active vote?\r
-float vote_prev; // previous state of vote_active to check for a change\r
-float vote_alpha;\r
-float vote_change; // "time" when vote_active changed\r
-\r
-vector stomachstatus_colorfade_current;\r
-vector StomachStatus_ColorFade(vector target_color)\r
-{\r
- local float step;\r
- step = cvar("sbar_stomachboard_status_fade") * frametime;\r
-\r
- if(stomachstatus_colorfade_current_x >= target_color_x + step)\r
- stomachstatus_colorfade_current_x -= step;\r
- else if(stomachstatus_colorfade_current_x <= target_color_x - step)\r
- stomachstatus_colorfade_current_x += step;\r
-\r
- if(stomachstatus_colorfade_current_y >= target_color_y + step)\r
- stomachstatus_colorfade_current_y -= step;\r
- else if(stomachstatus_colorfade_current_y <= target_color_y - step)\r
- stomachstatus_colorfade_current_y += step;\r
-\r
- if(stomachstatus_colorfade_current_z >= target_color_z + step)\r
- stomachstatus_colorfade_current_z -= step;\r
- else if(stomachstatus_colorfade_current_z <= target_color_z - step)\r
- stomachstatus_colorfade_current_z += step;\r
-\r
- return stomachstatus_colorfade_current;\r
-}\r
-\r
-void Sbar_Draw (void)\r
-{\r
- // vectors for top right, bottom right, bottom and bottom left corners\r
- vector topright;\r
- vector bottom;\r
- vector bottomright;\r
- vector bottomleft;\r
-\r
- topright_x = vid_conwidth;\r
- topright_y = 0;\r
- topright_z = 0;\r
-\r
- bottom_x = vid_conwidth/2;\r
- bottom_y = vid_conheight;\r
- bottom_z = 0;\r
-\r
- bottomright_x = vid_conwidth;\r
- bottomright_y = vid_conheight;\r
- bottomright_z = 0;\r
-\r
- bottomleft_x = 0;\r
- bottomleft_y = vid_conheight;\r
- bottomleft_z = 0;\r
-\r
- sbar_alpha_bg = cvar("sbar_alpha_bg") * (1 - cvar("_menu_alpha"));\r
- sbar_border_thickness = bound(0, cvar("sbar_border_thickness"), 5);\r
- sbar_accuracy_border_thickness = bound(0, cvar_or("sbar_accuracy_border_thickness", 1), 5);\r
- sbar_color_bg_team = cvar("sbar_color_bg_team");\r
-\r
- float weapon_stats;\r
- float fade;\r
-\r
- weapon_stats = getstati(STAT_DAMAGE_HITS);\r
- weapon_number = weapon_stats & 63;\r
- weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);\r
-\r
- weapon_stats = getstati(STAT_DAMAGE_FIRED);\r
- weapon_number = weapon_stats & 63;\r
- weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);\r
-\r
- vector o; o = '1 0 0' * vid_conwidth;\r
- o_y = 28; // move spectator text slightly down to prevent overlapping the timer\r
-\r
- string s;\r
- vector pos;\r
- pos = '0 0 0';\r
-\r
- sbar_fontsize = Sbar_GetFontsize("sbar_fontsize");\r
- sbar_fontsize_spec = Sbar_GetFontsize("sbar_fontsize_spec");\r
- if(sbar_fontsize != sbar_oldfontsize)\r
- {\r
- Cmd_Sbar_SetFields(0);\r
- sbar_oldfontsize = sbar_fontsize;\r
- }\r
-\r
- if(spectatee_status && !intermission)\r
- {\r
- drawfont = sbar_bigfont;\r
- if(spectatee_status == -1)\r
- s = "^1Observing";\r
- else\r
- s = GetPlayerName(spectatee_status - 1);\r
- // spectated player name between HUD and chat area, aligned to the left\r
- pos_x = bottomleft_x;\r
- pos_y = bottom_y - 200 - sbar_fontsize_spec_y;\r
- s = textShortenToWidth(s, vid_conwidth/2.5, sbar_fontsize_spec, stringwidth_colors);\r
- drawcolorcodedstring(pos, s, sbar_fontsize_spec, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawfont = sbar_font;\r
-\r
- // spectator text in the upper right corner\r
- if(spectatee_status == -1)\r
- s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");\r
- else\r
- s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");\r
- o = Sbar_DrawNoteLine(o, s);\r
-\r
- if(spectatee_status == -1)\r
- s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");\r
- else\r
- s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");\r
- o = Sbar_DrawNoteLine(o, s);\r
-\r
- s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");\r
- o = Sbar_DrawNoteLine(o, s);\r
-\r
- if(gametype == GAME_ARENA)\r
- s = "^1Wait for your turn to join";\r
- else if(gametype == GAME_LMS)\r
- {\r
- entity sk;\r
- sk = playerslots[player_localentnum - 1];\r
- if(sk.(scores[ps_primary]) >= 666)\r
- s = "^1Match has already begun";\r
- else if(sk.(scores[ps_primary]) > 0)\r
- s = "^1You have no more lives left";\r
- else\r
- s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");\r
- }\r
- else\r
- s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");\r
- o = Sbar_DrawNoteLine(o, s);\r
-\r
- //show restart countdown:\r
- if (time < getstatf(STAT_GAMESTARTTIME)) {\r
- float countdown;\r
- //we need to ceil, otherwise the countdown would be off by .5 when using round()\r
- countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);\r
- s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");\r
- o = Sbar_DrawNoteLine(o, s);\r
- }\r
- }\r
- if(warmup_stage && !intermission)\r
- {\r
- s = "^2Currently in ^1warmup^2 stage!";\r
- o = Sbar_DrawNoteLine(o, s);\r
- }\r
-\r
- // move more important stuff more to the middle so its more visible\r
- o_y = vid_conheight * 0.66;\r
-\r
- string blinkcolor;\r
- if(mod(time, 1) >= 0.5)\r
- blinkcolor = "^1";\r
- else\r
- blinkcolor = "^3";\r
-\r
- if(ready_waiting && !intermission && !spectatee_status)\r
- {\r
- if(ready_waiting_for_me)\r
- {\r
- if(warmup_stage)\r
- s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");\r
- else\r
- s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");\r
- }\r
- else\r
- {\r
- if(warmup_stage)\r
- s = strcat("^2Waiting for others to ready up to end warmup...");\r
- else\r
- s = strcat("^2Waiting for others to ready up...");\r
- }\r
- o = Sbar_DrawNoteLine(o, s);\r
- }\r
- else if(warmup_stage && !intermission && !spectatee_status)\r
- {\r
- s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");\r
- o = Sbar_DrawNoteLine(o, s);\r
- }\r
-\r
- if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)\r
- {\r
- entity tm;\r
- float ts_min, ts_max;\r
- tm = teams.sort_next;\r
- if (tm)\r
- {\r
- for(; tm.sort_next; tm = tm.sort_next)\r
- {\r
- if(!tm.team_size || tm.team == COLOR_SPECTATOR)\r
- continue;\r
- if(!ts_min) ts_min = tm.team_size;\r
- else ts_min = min(ts_min, tm.team_size);\r
- if(!ts_max) ts_max = tm.team_size;\r
- else ts_max = max(ts_max, tm.team_size);\r
- }\r
- if ((ts_max - ts_min) > 1)\r
- {\r
- s = strcat(blinkcolor, "Teamnumbers are unbalanced!");\r
- tm = GetTeam(myteam, false);\r
- if (tm)\r
- if (tm.team != COLOR_SPECTATOR)\r
- if (tm.team_size == ts_max)\r
- s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");\r
-\r
- o = Sbar_DrawNoteLine(o, s);\r
- }\r
- }\r
- }\r
-\r
- if(vote_active != vote_prev) {\r
- vote_change = time;\r
- vote_prev = bound(0, vote_active, 1);\r
- }\r
-\r
- if(vote_active)\r
- vote_alpha = bound(0, (time - vote_change) * 2, 1);\r
- else\r
- vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);\r
-\r
- if(vote_alpha) {\r
- float a;\r
- a = vote_alpha * bound(cvar_or("sbar_vote_alreadyvoted_alpha", 0.75), 1 - vote_highlighted, 1);\r
-\r
- if (teamplay)\r
- color = GetTeamRGB(myteam) * sbar_color_bg_team;\r
- else\r
- color = stov(cvar_string("sbar_color_bg"));\r
-\r
- vector voteorigin = bottomright - '290 135 0';\r
- vector votesize = '280 70 0';\r
- drawpic(voteorigin, "gfx/hud/voteprogress_back", votesize, color, a * sbar_alpha_bg, DRAWFLAG_NORMAL);\r
-\r
- s = "A vote has been called for: ";\r
- 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
- s = textShortenToWidth(vote_called_vote, votesize_x * 0.96, '10 0 0', stringwidth_colors);\r
- 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
-\r
- // print the yes/no counts\r
- s = strcat("Yes: ", ftos(vote_yescount));\r
- 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
- s = strcat("No: ", ftos(vote_nocount));\r
- 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
-\r
- // draw the progress bars\r
- drawsetcliparea(voteorigin_x, voteorigin_y, votesize_x * 0.5 * (vote_yescount/vote_needed), votesize_y);\r
- drawpic(voteorigin, "gfx/hud/voteprogress_prog", votesize, '0 1 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-\r
- drawsetcliparea(voteorigin_x + votesize_x - votesize_x * 0.5 * (vote_nocount/vote_needed), voteorigin_y, votesize_x * 0.5, votesize_y);\r
- drawpic(voteorigin, "gfx/hud/voteprogress_prog", votesize, '1 0 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-\r
- // draw the highlights\r
- if(vote_highlighted == 1) {\r
- drawsetcliparea(voteorigin_x, voteorigin_y, votesize_x * 0.5, votesize_y);\r
- drawpic(voteorigin, "gfx/hud/voteprogress_voted", votesize, '0 1 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- }\r
- else if(vote_highlighted == 2) {\r
- drawsetcliparea(voteorigin_x + 0.5 * votesize_x, voteorigin_y, votesize_x * 0.5, votesize_y);\r
- drawpic(voteorigin, "gfx/hud/voteprogress_voted", votesize, '1 0 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- }\r
-\r
- drawresetcliparea();\r
- }\r
- else if(!vote_active) {\r
- vote_highlighted = 0;\r
- }\r
-\r
- Sbar_UpdatePlayerTeams();\r
- if (intermission == 2) // map voting screen\r
- {\r
- Sbar_Timer();\r
- if(sb_showscores)\r
- Sbar_DrawScoreboard();\r
- else\r
- Sbar_FinaleOverlay();\r
-\r
- Sbar_Reset();\r
- }\r
- else if (sb_showscores_force || getstati(STAT_HEALTH) <= 0 || intermission == 1)\r
- {\r
- Sbar_DrawScoreboard();\r
- Sbar_Score();\r
- Sbar_Timer();\r
- if(getstati(STAT_VORE_EATEN))\r
- Sbar_Status();\r
-\r
- Sbar_Reset();\r
-\r
- StomachStatus_ColorFade('0 0 0');\r
- }\r
- else\r
- {\r
- if(sb_showaccuracy && spectatee_status != -1)\r
- Sbar_DrawAccuracyStats();\r
- else\r
- Sbar_DrawScoreboard();\r
-\r
- fade = 3.2 - 2 * (time - weapontime);\r
- fade = bound(0.7, fade, 1);\r
-\r
- // when a player's armor is below the necessary level, subsystems will not work\r
- if(getstati(STAT_HEALTH) > 0)\r
- {\r
- vector warn_pos;\r
- warn_pos_x = vid_conwidth / 2;\r
- warn_pos_y = vid_conheight - vid_conheight / 2.5;\r
- if(getstati(STAT_ARMOR) < g_power)\r
- {\r
- // subsystems are down\r
- drawpic(warn_pos - '128 0 0', "gfx/hud/sb_power_fail", '256 256 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawpic(warn_pos - '16 0 0' + '0 150 0', "gfx/hud/sb_power_fail_icon", '32 32 0', '1 1 1', sbar_alpha_fg * (0.5 + sin(time * 5) / 2), DRAWFLAG_NORMAL);\r
- power_boot = time + g_power_reboot;\r
- return; // skip drawing the HUD\r
- }\r
- else if(time <= power_boot)\r
- {\r
- // subsystems are rebooting\r
- drawpic(warn_pos - '128 0 0', "gfx/hud/sb_power_reboot", '256 256 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawpic(warn_pos - '16 0 0' + '0 150 0', "gfx/hud/sb_power_reboot_icon", '32 32 0', '1 1 1', sbar_alpha_fg * (0.5 + sin(time * 5) / 2), DRAWFLAG_NORMAL);\r
- return; // skip drawing the HUD\r
- }\r
- }\r
-\r
- if(g_vore) // only when the vore system is active\r
- {\r
- // draw the stomach board\r
- if (cvar("viewsize") <= 100) {\r
- if (teamplay)\r
- drawpic(bottomleft- '0 256 0', "gfx/hud/bg_stomach", '256 256 0', GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // hud color = myteam color\r
- else {\r
- // allow for custom HUD colors in non-teamgames\r
- color = stov(cvar_string("sbar_color_bg"));\r
-\r
- drawpic(bottomleft - '0 256 0', "gfx/hud/bg_stomach", '256 256 0', color, sbar_alpha_bg, DRAWFLAG_NORMAL);\r
- }\r
- }\r
-\r
- vector hl_color;\r
- string hl_string;\r
- if(getstati(STAT_VORE_EATEN))\r
- {\r
- 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
- hl_color = stov(cvar_string("sbar_stomachboard_color2"));\r
- else\r
- hl_color = stov(cvar_string("sbar_stomachboard_color3"));\r
- hl_string = "predator:";\r
- }\r
- else\r
- {\r
- hl_color = stov(cvar_string("sbar_stomachboard_color1"));\r
- hl_string = "self:";\r
- }\r
- drawpic(bottomleft - '0 256 0', "gfx/hud/bg_stomach_status", '256 256 0', StomachStatus_ColorFade(hl_color), cvar("sbar_stomachboard_status_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawstring(bottomleft - '-80 173 0', hl_string, '11 11 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-\r
- float stomach_load, stomach_maxload; // shows the predator's stomach load when we are eaten, and ours otherwise\r
- stomach_load = getstati(STAT_VORE_LOAD);\r
- stomach_maxload = getstati(STAT_VORE_MAXLOAD);\r
-\r
- vector status_pos;\r
- string status_text, status_color;\r
- float status_size;\r
- status_color = rgb_to_hexcolor('0.5 0.5 0.5' + Sbar_NumColor(stomach_maxload) * 0.5); // twice brighter than health / armor colors\r
- if(stomach_load)\r
- {\r
- status_text = strcat(ftos(stomach_load), "^8/", status_color, ftos(stomach_maxload));\r
- status_pos = bottomleft - '-43 168 0';\r
- status_size = 16;\r
- }\r
- else if(g_healthsize_center >= 0) // no point in showing it otherwise\r
- {\r
- status_text = strcat(status_color, ftos(stomach_maxload));\r
- status_pos = bottomleft - '-43 170 0';\r
- status_size = 20;\r
- }\r
- status_pos -= '1 0 0' * stringwidth(status_text, TRUE, '1 0 0' * status_size) * 0.5;\r
- drawcolorcodedstring(status_pos, status_text, '1 1 0' * status_size, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-\r
- if(getstati(STAT_VORE_DIGESTING)) // we are currently digesting\r
- drawpic(bottomleft - '-35 149 0', "gfx/hud/sb_digestion", '16 16 0', '0 1 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- else if(stomach_load) // we can digest at this time\r
- drawpic(bottomleft - '-35 149 0', "gfx/hud/sb_digestion", '16 16 0', '0.25 0.25 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- else // we cannot digest at this time\r
- drawpic(bottomleft - '-35 149 0', "gfx/hud/sb_digestion", '16 16 0', '0.25 0 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-\r
- // draw the stomach board player list\r
- entity pl, pred;\r
- float f, l;\r
-\r
- pos = bottomleft;\r
- for(pl = players.sort_next; pl; pl = pl.sort_next)\r
- {\r
- if(pl.team == COLOR_SPECTATOR)\r
- continue;\r
-\r
- if(getstati(STAT_VORE_EATEN))\r
- f = pl.plpredator == getstati(STAT_VORE_EATEN);\r
- else\r
- {\r
- if(spectatee_status)\r
- f = pl.plpredator == spectatee_status;\r
- else\r
- f = pl.plpredator == player_localentnum;\r
- }\r
-\r
- if(f && l <= 8) // limit the stomach board to 9 entries due to the HUD design\r
- {\r
- Sbar_PrintStomachboardItem(pos - '-16 124 0', pl);\r
- pos_y += 1.1 * sbar_fontsize_y;\r
- l += 1;\r
- }\r
-\r
- // set the predator's name\r
- if(getstati(STAT_VORE_EATEN))\r
- {\r
- if(pl.sv_entnum == getstati(STAT_VORE_EATEN) - 1)\r
- pred = pl;\r
- }\r
- else if(pl.sv_entnum == player_localentnum - 1 || pl.sv_entnum == spectatee_status - 1)\r
- pred = pl; // show us or the spectated player\r
- }\r
-\r
- // draw the predator's name\r
- Sbar_PrintStomachboardItemPred(bottomleft - '-76 150 0', pred);\r
- }\r
-\r
- // draw status, scores, timer, and ring\r
- Sbar_Status();\r
- Sbar_Score();\r
- Sbar_Timer();\r
- Sbar_Ring();\r
-\r
- // draw strength/invincibility icon and timer\r
- CSQC_Strength_Timer();\r
-\r
- // draw gametype specific icons\r
- if(gametype == GAME_KEYHUNT)\r
- CSQC_kh_hud();\r
- else if(gametype == GAME_CTF)\r
- CSQC_ctf_hud();\r
- else if(gametype == GAME_CTS || gametype == GAME_RACE)\r
- CSQC_race_hud();\r
-\r
- // draw the canleave message\r
- if(getstati(STAT_VORE_CANLEAVE))\r
- if not(spectatee_status) // this message doesn't address spectated players\r
- {\r
- s = strcat("^7Press ^3", getcommandkey("jump", "+jump"), " ^7to exit");\r
- pos_x = bottom_x - stringwidth(s, TRUE, '0 0 0') * 16 / 2;\r
- pos_y = bottom_y - 120;\r
- drawcolorcodedstring(pos, s, '16 16 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- }\r
- }\r
- return;\r
-}\r
-\r
-// CTF HUD\r
-float redflag_prevframe, blueflag_prevframe; // status during previous frame\r
-float redflag_prevstatus, blueflag_prevstatus; // last remembered status\r
-float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed\r
-\r
-void CSQC_ctf_hudreset(void)\r
-{\r
- redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;\r
-}\r
-\r
-void CSQC_ctf_hud(void)\r
-{\r
- vector top, redflag_pos, blueflag_pos, sz;\r
- float f; // every function should have that\r
- top_x = vid_conwidth / 2;\r
- top_y = 0;\r
- top_z = 0;\r
-\r
- float redflag, blueflag; // current status\r
- float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed\r
- float stat_items;\r
-\r
- stat_items = getstati(STAT_ITEMS);\r
- redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;\r
- blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;\r
-\r
- // when status CHANGES, set old status into prevstatus and current status into status\r
- if (redflag != redflag_prevframe)\r
- {\r
- redflag_statuschange_time = time;\r
- redflag_prevstatus = redflag_prevframe;\r
- redflag_prevframe = redflag;\r
- }\r
-\r
- if (blueflag != blueflag_prevframe)\r
- {\r
- blueflag_statuschange_time = time;\r
- blueflag_prevstatus = blueflag_prevframe;\r
- blueflag_prevframe = blueflag;\r
- }\r
- \r
- redflag_statuschange_elapsedtime = time - redflag_statuschange_time;\r
- blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;\r
-\r
- float BLINK_FACTOR = 0.15;\r
- float BLINK_BASE = 0.85;\r
- // note:\r
- // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)\r
- // thus\r
- // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)\r
- // ensure RMS == 1\r
- float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz\r
-\r
- string red_icon, red_icon_prevstatus;\r
- float red_alpha, red_alpha_prevstatus;\r
- red_alpha = red_alpha_prevstatus = 1;\r
- switch(redflag) {\r
- case 1: red_icon = "gfx/hud/sb_flag_red_taken"; break;\r
- case 2: red_icon = "gfx/hud/sb_flag_red_lost"; break;\r
- case 3: red_icon = "gfx/hud/sb_flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;\r
- default:\r
- if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))\r
- red_icon = "gfx/hud/sb_flag_red_shielded";\r
- else\r
- red_icon = string_null;\r
- break;\r
- }\r
- switch(redflag_prevstatus) {\r
- case 1: red_icon_prevstatus = "gfx/hud/sb_flag_red_taken"; break;\r
- case 2: red_icon_prevstatus = "gfx/hud/sb_flag_red_lost"; break;\r
- case 3: red_icon_prevstatus = "gfx/hud/sb_flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;\r
- default:\r
- if(redflag == 3)\r
- red_icon_prevstatus = "gfx/hud/sb_flag_red_carrying"; // make it more visible\r
- else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))\r
- red_icon_prevstatus = "gfx/hud/sb_flag_red_shielded";\r
- else\r
- red_icon_prevstatus = string_null;\r
- break;\r
- }\r
-\r
- string blue_icon, blue_icon_prevstatus;\r
- float blue_alpha, blue_alpha_prevstatus;\r
- blue_alpha = blue_alpha_prevstatus = 1;\r
- switch(blueflag) {\r
- case 1: blue_icon = "gfx/hud/sb_flag_blue_taken"; break;\r
- case 2: blue_icon = "gfx/hud/sb_flag_blue_lost"; break;\r
- case 3: blue_icon = "gfx/hud/sb_flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;\r
- default:\r
- if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))\r
- blue_icon = "gfx/hud/sb_flag_blue_shielded";\r
- else\r
- blue_icon = string_null;\r
- break;\r
- }\r
- switch(blueflag_prevstatus) {\r
- case 1: blue_icon_prevstatus = "gfx/hud/sb_flag_blue_taken"; break;\r
- case 2: blue_icon_prevstatus = "gfx/hud/sb_flag_blue_lost"; break;\r
- case 3: blue_icon_prevstatus = "gfx/hud/sb_flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;\r
- default:\r
- if(blueflag == 3)\r
- blue_icon_prevstatus = "gfx/hud/sb_flag_blue_carrying"; // make it more visible\r
- else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))\r
- blue_icon_prevstatus = "gfx/hud/sb_flag_blue_shielded";\r
- else\r
- blue_icon_prevstatus = string_null;\r
- break;\r
- }\r
-\r
- if (myteam == COLOR_TEAM1) { // always draw own flag on left\r
- redflag_pos = top + '-52 50 0';\r
- blueflag_pos = top + '0 40 0';\r
- } else {\r
- blueflag_pos = top + '-52 50 0';\r
- redflag_pos = top + '0 40 0';\r
- }\r
- \r
- sz = '52 52 0';\r
- \r
- f = bound(0, redflag_statuschange_elapsedtime*2, 1);\r
- if(red_icon_prevstatus && f < 1)\r
- drawpic_expanding(redflag_pos, red_icon_prevstatus, sz, '1 1 1', sbar_alpha_fg * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);\r
- if(red_icon)\r
- drawpic(redflag_pos, red_icon, sz, '1 1 1', sbar_alpha_fg * red_alpha * f, DRAWFLAG_NORMAL);\r
-\r
- f = bound(0, blueflag_statuschange_elapsedtime*2, 1);\r
- if(blue_icon_prevstatus && f < 1)\r
- drawpic_expanding(blueflag_pos, blue_icon_prevstatus, sz, '1 1 1', sbar_alpha_fg * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);\r
- if(blue_icon)\r
- drawpic(blueflag_pos, blue_icon, sz, '1 1 1', sbar_alpha_fg * blue_alpha * f, DRAWFLAG_NORMAL);\r
-}\r
-\r
-// Keyhunt HUD\r
-float kh_runheretime;\r
-\r
-void CSQC_kh_hudreset(void)\r
-{\r
- kh_runheretime = 0;\r
-}\r
-\r
-void CSQC_kh_hud(void)\r
-{\r
- float kh_keys;\r
- float keyteam;\r
- float a, aa;\r
- vector p, pa, kh_size, kh_asize;\r
-\r
- vector top;\r
- top_x = vid_conwidth / 2;\r
- top_y = 0;\r
- top_z = 0;\r
-\r
- p = top + '-50 64 0';\r
-\r
- kh_keys = getstati(STAT_KH_KEYS);\r
-\r
- kh_size = '19 34 0';\r
- kh_asize = '19 10 0';\r
- pa = p + '0 -10 0';\r
-\r
- float i, key;\r
-\r
- float keycount;\r
- keycount = 0;\r
- for(i = 0; i < 4; ++i)\r
- {\r
- key = floor(kh_keys / pow(32, i)) & 31;\r
- keyteam = key - 1;\r
- if(keyteam == 30 && keycount <= 4)\r
- keycount += 4;\r
- if(keyteam == myteam || keyteam == -1 || keyteam == 30)\r
- keycount += 1;\r
- }\r
- // this yields 8 exactly if "RUN HERE" shows\r
-\r
- if(keycount == 8)\r
- {\r
- if(!kh_runheretime)\r
- kh_runheretime = time;\r
- pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE\r
- }\r
- else\r
- kh_runheretime = 0;\r
-\r
- for(i = 0; i < 4; ++i)\r
- {\r
- key = floor(kh_keys / pow(32, i)) & 31;\r
- keyteam = key - 1;\r
- switch(keyteam)\r
- {\r
- case 30: // my key\r
- keyteam = myteam;\r
- a = 1;\r
- aa = 1;\r
- break;\r
- case -1: // no key\r
- a = 0;\r
- aa = 0;\r
- break;\r
- default: // owned or dropped\r
- a = 0.2;\r
- aa = 0.5;\r
- break;\r
- }\r
- a = a * sbar_alpha_fg;\r
- aa = aa * sbar_alpha_fg;\r
- if(a > 0)\r
- {\r
- switch(keyteam)\r
- {\r
- case COLOR_TEAM1:\r
- drawpic (pa, "gfx/hud/sb_kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key\r
- break;\r
- case COLOR_TEAM2:\r
- drawpic (pa, "gfx/hud/sb_kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key\r
- break;\r
- case COLOR_TEAM3:\r
- drawpic (pa, "gfx/hud/sb_kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key\r
- break;\r
- case COLOR_TEAM4:\r
- drawpic (pa, "gfx/hud/sb_kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key\r
- break;\r
- default:\r
- break;\r
- }\r
- switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!\r
- {\r
- case 0:\r
- drawpic (p, "gfx/hud/sb_kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key\r
- break;\r
- case 1:\r
- drawpic (p, "gfx/hud/sb_kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key\r
- break;\r
- case 2:\r
- drawpic (p, "gfx/hud/sb_kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key\r
- break;\r
- case 3:\r
- drawpic (p, "gfx/hud/sb_kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key\r
- break;\r
- }\r
- }\r
- p_x += 24;\r
- pa_x += 24;\r
- }\r
-}\r
-\r
-float crecordtime_prev; // last remembered crecordtime\r
-float crecordtime_change_time; // time when crecordtime last changed\r
-float srecordtime_prev; // last remembered srecordtime\r
-float srecordtime_change_time; // time when srecordtime last changed\r
-void CSQC_race_hud(void) \r
-{\r
- entity me;\r
- me = playerslots[player_localentnum - 1];\r
- float t, score;\r
- float f; // yet another function has this\r
- score = me.(scores[ps_primary]);\r
-\r
- if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD\r
- return; // no records in the actual race\r
-\r
- drawfont = sbar_bigfont;\r
- vector pos;\r
- pos_x = 2;\r
- pos_y = vid_conheight - 272;\r
-\r
- // clientside personal record\r
- string rr;\r
- if(gametype == GAME_CTS)\r
- rr = CTS_RECORD;\r
- else\r
- rr = RACE_RECORD;\r
- t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));\r
-\r
- if(score && score < t || !t)\r
- db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));\r
-\r
- if(t != crecordtime_prev) {\r
- crecordtime_prev = t;\r
- crecordtime_change_time = time;\r
- }\r
- f = time - crecordtime_change_time;\r
-\r
- if (f > 1) {\r
- drawstring(pos, "Personal best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawstring(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- } else {\r
- drawstring(pos, "Personal best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawstring(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawstring_expanding(pos, "Personal best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL, f);\r
- drawstring_expanding(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL, f);\r
- }\r
-\r
- // server record\r
- pos_y += 26;\r
- t = race_server_record;\r
- if(t != srecordtime_prev) {\r
- srecordtime_prev = t;\r
- srecordtime_change_time = time;\r
- }\r
- f = time - srecordtime_change_time;\r
-\r
- if (f > 1) {\r
- drawstring(pos, "Server best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawstring(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- } else {\r
- drawstring(pos, "Server best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawstring(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
- drawstring_expanding(pos, "Server best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL, f);\r
- drawstring_expanding(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL, f);\r
- }\r
- drawfont = sbar_font;\r
-}\r
\r
void() teamradar_view =\r
{\r
- local float color1, color2; // color already declared as a global in sbar.qc\r
+ local float color1, color2; // color already declared as a global in hud.qc\r
local vector rgb;\r
local entity tm;\r
float scale2d, normalsize, bigsize;\r