From: Samual Lenks Date: Wed, 3 Oct 2012 19:32:16 +0000 (-0400) Subject: More work on unifying team functions X-Git-Tag: xonotic-v0.7.0~62^2~23^2~388 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fbf83f546eb4266e347f7cb51cdcf6f07444c851;p=xonotic%2Fxonotic-data.pk3dir.git More work on unifying team functions --- diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 60bfec04b..87ba60608 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -241,6 +241,30 @@ float race_CheckName(string net_name) { return 0; } +float GetPlayerColorForce(float i) +{ + if(!teamplay) + return 0; + else + return stof(getplayerkeyvalue(i, "colors")) & 15; +} + +float GetPlayerColor(float i) +{ + if not(playerslots[i].gotscores) // unconnected + return FL_SPECTATOR; + else if(stof(getplayerkeyvalue(i, "frags")) == FRAGS_SPECTATOR) + return FL_SPECTATOR; + else + return GetPlayerColorForce(i); +} + +string GetPlayerName(float i) +{ + return ColorTranslateRGB(getplayerkeyvalue(i, "name")); +} + + /* ================== HUD panels @@ -2452,7 +2476,7 @@ void HUD_Radar(void) { color2 = GetPlayerColor(tm.sv_entnum); //if(color == FL_SPECTATOR || color == color2) - draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2)); + draw_teamradar_player(tm.origin, tm.angles, Team_ColorRGB(color2)); } draw_teamradar_player(view_origin, view_angles, '1 1 1'); @@ -2493,7 +2517,7 @@ void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count) for(i=0; i= rows) { @@ -2766,11 +2790,11 @@ void HUD_Score(void) else if(tm.team == myteam) { if (max_fragcount == score) HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL); } else { if (max_fragcount == score) HUD_Panel_DrawHighlight(pos + eX * 0.75 * mySize_x + eY * (1/3) * rows * mySize_y, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(pos + eX * 0.75 * mySize_x + eY * (1/3) * rows * mySize_y, ftos(score), score_size, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(pos + eX * 0.75 * mySize_x + eY * (1/3) * rows * mySize_y, ftos(score), score_size, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL); ++rows; } } diff --git a/qcsrc/client/progs.src b/qcsrc/client/progs.src index 7ea864d5d..5aec16ba0 100644 --- a/qcsrc/client/progs.src +++ b/qcsrc/client/progs.src @@ -40,7 +40,6 @@ movetypes.qh prandom.qh bgmscript.qh noise.qh -teamplay.qh tturrets.qh ../server/tturrets/include/turrets_early.qh ../server/movelib.qc @@ -56,7 +55,6 @@ projectile.qh sortlist.qc miscfunctions.qc -teamplay.qc ../server/t_items.qc teamradar.qc diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc index 417f97e0d..324c83b42 100644 --- a/qcsrc/client/scoreboard.qc +++ b/qcsrc/client/scoreboard.qc @@ -659,7 +659,7 @@ string HUD_FixScoreboardColumnWidth(float i, string str) void HUD_PrintScoreboardItem(vector pos, entity pl, float is_self, float pl_number) { vector tmp, rgb; - rgb = GetTeamRGB(pl.team); + rgb = Team_ColorRGB(pl.team); string str; float i, field; float is_spec; @@ -1245,7 +1245,7 @@ void HUD_DrawScoreboard() continue; draw_beginBoldFont(); - rgb = GetTeamRGB(tm.team); + rgb = Team_ColorRGB(tm.team); str = ftos(tm.(teamscores[ts_primary])); drawstring(pos + team_score_baseoffset - eX * stringwidth(str, FALSE, hud_fontsize * 1.5), str, hud_fontsize * 1.5, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL); @@ -1287,14 +1287,14 @@ void HUD_DrawScoreboard() } else if(autocvar_scoreboard_accuracy && spectatee_status != -1 && !warmup_stage) { if(teamplay) - pos = HUD_DrawScoreboardAccuracyStats(pos, GetTeamRGB(myteam), bg_size); + pos = HUD_DrawScoreboardAccuracyStats(pos, Team_ColorRGB(myteam), bg_size); else pos = HUD_DrawScoreboardAccuracyStats(pos, rgb, bg_size); } if(teamplay) - pos = HUD_DrawMapStats(pos, GetTeamRGB(myteam), bg_size); + pos = HUD_DrawMapStats(pos, Team_ColorRGB(myteam), bg_size); else pos = HUD_DrawMapStats(pos, rgb, bg_size); diff --git a/qcsrc/client/teamplay.qc b/qcsrc/client/teamplay.qc deleted file mode 100644 index 058b699ba..000000000 --- a/qcsrc/client/teamplay.qc +++ /dev/null @@ -1,69 +0,0 @@ -float TeamByColor(float color) -{ - switch(color) - { - case FL_TEAM_1: return 0; - case FL_TEAM_2: return 1; - case FL_TEAM_3: return 2; - case FL_TEAM_4: return 3; - default: return 0; - } -} -float ColorByTeam(float i) -{ - switch(i) - { - case 0: return FL_TEAM_1; - case 1: return FL_TEAM_2; - case 2: return FL_TEAM_3; - case 3: return FL_TEAM_4; - default: return FL_TEAM_1; - } -} - -float GetPlayerColorForce(float i) -{ - if(!teamplay) - return 0; - else - return stof(getplayerkeyvalue(i, "colors")) & 15; -} - -float GetPlayerColor(float i) -{ - if not(playerslots[i].gotscores) // unconnected - return FL_SPECTATOR; - else if(stof(getplayerkeyvalue(i, "frags")) == FRAGS_SPECTATOR) - return FL_SPECTATOR; - else - return GetPlayerColorForce(i); -} - -string GetPlayerName(float i) -{ - return ColorTranslateRGB(getplayerkeyvalue(i, "name")); -} - -vector GetTeamRGB(float color) -{ - switch(color) - { - default: return '1 1 1'; - case FL_TEAM_1: return '1 0 0'; // red - case FL_TEAM_2: return '0 0 1'; // blue - case FL_TEAM_3: return '1 1 0'; // yellow - case FL_TEAM_4: return '1 0 1'; // pink - } -} - -string GetTeamName(float color) -{ - switch(color) - { - default: return _("Spectators"); - case FL_TEAM_1: return _("Red Team"); - case FL_TEAM_2: return _("Blue Team"); - case FL_TEAM_3: return _("Yellow Team"); - case FL_TEAM_4: return _("Pink Team"); - } -} diff --git a/qcsrc/client/teamplay.qh b/qcsrc/client/teamplay.qh deleted file mode 100644 index 83359906b..000000000 --- a/qcsrc/client/teamplay.qh +++ /dev/null @@ -1,2 +0,0 @@ -float teamplay; -float myteam; diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index caca75999..b970907e5 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -90,7 +90,7 @@ var float autocvar_notification_ctf_pickup_enemy_verbose = TRUE; #endif #define MSG_INFO_NOTIFICATIONS \ MSG_INFO_NOTIF(INFO_EMPTY, 0, 0, NO_STR_ARG, XPND2("", ""), "", "", "") \ - MULTITEAM_INFO(INFO_SCORES_, 2, 0, 0, NO_STR_ARG, XPND2("", ""), "", _("^TC^TT ^BGteam scores!\n"), "") \ + MULTITEAM_INFO(INFO_SCORES_, 4, 0, 0, NO_STR_ARG, XPND2("", ""), "", _("^TC^TT ^BGteam scores!\n"), "") \ MULTITEAM_INFO(INFO_CTF_FLAGRETURN_DROPPED_, 2, 0, 0, NO_STR_ARG, XPND2("", ""), "", _("^BGThe ^TC^TT^BG flag was dropped in the base and returned itself\n"), "") \ MULTITEAM_INFO(INFO_CTF_FLAGRETURN_DAMAGED_, 2, 0, 0, NO_STR_ARG, XPND2("", ""), "", _("^BGThe ^TC^TT^BG flag was destroyed and returned to base\n"), "") \ MULTITEAM_INFO(INFO_CTF_FLAGRETURN_SPEEDRUN_, 2, 0, 1, f1/100, XPND2("", ""), "", _("^BGThe ^TC^TT^BG flag became impatient after ^F1%.2f^BG seconds and returned itself\n"), "") \ @@ -325,21 +325,31 @@ void Local_Notification(float net_type, float net_name, string s1, string s2, fl case MSG_INFO: { #define MSG_INFO_NOTIF(name,strnum,flnum,args,hudargs,icon,normal,gentle) \ - { NOTIF_MATCH(name, net_name) CHECK_AUTOCVAR(name) { print(sprintf(CCR(normal_or_gentle(normal, gentle)), args)); if(strtolower(icon) != "") { HUD_Notify_Push(icon, hudargs); } } } + { NOTIF_MATCH(name, net_name) CHECK_AUTOCVAR(name) \ + { \ + print(sprintf(CCR(normal_or_gentle(normal, gentle)), args)); \ + if(strtolower(icon) != "") { HUD_Notify_Push(icon, hudargs); } \ + } } MSG_INFO_NOTIFICATIONS break; } case MSG_CENTER: { #define MSG_CENTER_NOTIF(name,strnum,flnum,args,cpid,durcnt,normal,gentle) \ - { NOTIF_MATCH(name, net_name) CHECK_AUTOCVAR(name) { centerprint_generic(HANDLE_CPID(cpid), sprintf(CCR(normal_or_gentle(normal, gentle)), args), durcnt); } } + { NOTIF_MATCH(name, net_name) CHECK_AUTOCVAR(name) \ + { \ + centerprint_generic(HANDLE_CPID(cpid), sprintf(CCR(normal_or_gentle(normal, gentle)), args), durcnt); \ + } } MSG_CENTER_NOTIFICATIONS break; } case MSG_WEAPON: { #define MSG_WEAPON_NOTIF(name,strnum,flnum,args,normal,gentle) \ - { NOTIF_MATCH(name, net_name) CHECK_AUTOCVAR(name) { print("unhandled\n"); } } + { NOTIF_MATCH(name, net_name) CHECK_AUTOCVAR(name) \ + { \ + print("unhandled\n"); \ + } } MSG_WEAPON_NOTIFICATIONS break; } diff --git a/qcsrc/common/teams.qh b/qcsrc/common/teams.qh new file mode 100644 index 000000000..ef1b3c7f4 --- /dev/null +++ b/qcsrc/common/teams.qh @@ -0,0 +1,137 @@ +#ifdef TEAMNUMBERS_THAT_ARENT_STUPID +const float FL_TEAM_1 = 1; // red +const float FL_TEAM_2 = 2; // blue +const float FL_TEAM_3 = 3; // yellow +const float FL_TEAM_4 = 4; // pink +const float FL_SPECTATOR = 5; +#else +#ifdef CSQC +const float FL_TEAM_1 = 4; // red +const float FL_TEAM_2 = 13; // blue +const float FL_TEAM_3 = 12; // yellow +const float FL_TEAM_4 = 9; // pink +#else +const float FL_TEAM_1 = 5; // red +const float FL_TEAM_2 = 14; // blue +const float FL_TEAM_3 = 13; // yellow +const float FL_TEAM_4 = 10; // pink +#endif +const float FL_SPECTATOR = 1337; +#endif + +const string COL_TEAM_1 = "^1"; +const string COL_TEAM_2 = "^4"; +const string COL_TEAM_3 = "^3"; +const string COL_TEAM_4 = "^6"; +const string STR_TEAM_1 = _("Red"); +const string STR_TEAM_2 = _("Blue"); +const string STR_TEAM_3 = _("Yellow"); +const string STR_TEAM_4 = _("Pink"); +const string STR_TEAM = _("Team"); +const string STR_NEUTRAL = _("Neutral"); + +#ifdef CSQC +float teamplay; +float myteam; +#endif + +string Team_ColorCode(float teamid) +{ + switch(teamid) + { + case FL_TEAM_1: return COL_TEAM_1; + case FL_TEAM_2: return COL_TEAM_2; + case FL_TEAM_3: return COL_TEAM_3; + case FL_TEAM_4: return COL_TEAM_4; + } + + return "^7"; +} + +vector Team_ColorRGB(float teamid) +{ + switch(teamid) + { + #ifdef TEAMNUMBERS_THAT_ARENT_STUPID + case FL_TEAM_1: return '1 0 0'; // red + case FL_TEAM_2: return '0 0 1'; // blue + case FL_TEAM_3: return '1 1 0'; // yellow + case FL_TEAM_4: return '1 0 1'; // pink + #else + case FL_TEAM_1: return '1 0.0625 0.0625'; + case FL_TEAM_2: return '0.0625 0.0625 1'; + case FL_TEAM_3: return '1 1 0.0625'; + case FL_TEAM_4: return '1 0.0625 1'; + #endif + } + + return '0 0 0'; +} + +string Team_ColorName(float teamid) +{ + switch(teamid) + { + case FL_TEAM_1: return STR_TEAM_1; + case FL_TEAM_2: return STR_TEAM_2; + case FL_TEAM_3: return STR_TEAM_3; + case FL_TEAM_4: return STR_TEAM_4; + } + + return STR_NEUTRAL; +} + +float Team_ColorToTeam(string team_color) +{ + switch(strtolower(team_color)) + { + case "red": return FL_TEAM_1; + case "blue": return FL_TEAM_2; + case "yellow": return FL_TEAM_3; + case "pink": return FL_TEAM_4; + case "auto": return 0; + } + + return -1; +} + +float Team_NumberToTeam(float number) +{ + switch(number) + { + case 1: return FL_TEAM_1; + case 2: return FL_TEAM_2; + case 3: return FL_TEAM_3; + case 4: return FL_TEAM_4; + } + + return -1; +} + +float Team_TeamToNumber(float teamid) +{ + switch(teamid) + { + case FL_TEAM_1: return 1; + case FL_TEAM_2: return 2; + case FL_TEAM_3: return 3; + case FL_TEAM_4: return 4; + } + + return -1; +} + + +// legacy aliases for shitty code +float TeamByColor(float teamid) { return (Team_TeamToNumber(teamid) - 1); } +float ColorByTeam(float number) { return Team_NumberToTeam(number + 1); } + +// useful aliases +string Team_ColorName_Lower(float teamid) { return strtolower(Team_ColorName(teamid)); } +string Team_ColorName_Upper(float teamid) { return strtoupper(Team_ColorName(teamid)); } + +string Team_FullName(float teamid) { return strcat(Team_ColorName(teamid), " ", STR_TEAM, "^7"); } +string Team_ColoredFullName(float teamid) { return strcat(Team_ColorCode(teamid), Team_ColorName(teamid), " ", STR_TEAM, "^7"); } + +string Team_NumberToFullName(float number) { return Team_FullName(Team_NumberToTeam(number)); } +string Team_NumberToColoredFullName(float number) { return Team_ColoredFullName(Team_NumberToTeam(number)); } diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 8512f57df..006db3c36 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -1241,10 +1241,10 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2 } else { - self.killindicator.colormod = TeamColor(targetteam); + self.killindicator.colormod = Team_ColorRGB(targetteam); if(clienttype(self) == CLIENTTYPE_REAL) if(self.killindicator.cnt > 0) - Send_CSQC_Centerprint_Generic(self, CPID_TEAMCHANGE, strcat("Changing to ", ColoredTeamName(targetteam), " in %d seconds"), 1, self.killindicator.cnt); + Send_CSQC_Centerprint_Generic(self, CPID_TEAMCHANGE, strcat("^7Changing to ", Team_ColoredFullName(targetteam), "^7 in %d seconds"), 1, self.killindicator.cnt); } } @@ -1335,7 +1335,6 @@ ClientConnect Called when a client connects to the server ============= */ -string ColoredTeamName(float t); void DecodeLevelParms (void); //void dom_player_join_team(entity pl); void set_dom_state(entity e); @@ -1479,7 +1478,7 @@ void ClientConnect (void) bprint("^4", self.netname, "^4 connected"); if(self.classname != "observer" && (g_domination || g_ctf)) - bprint(" and joined the ", ColoredTeamName(self.team)); + bprint(" and joined the ", Team_ColoredFullName(self.team)); bprint("\n"); diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index f7c206091..cbec4f5ea 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -1425,5 +1425,5 @@ void MoveToTeam(entity client, float team_colour, float type, float show_message if not(show_message & 1) // admin message sprint(client, strcat("\{1}\{13}^3", admin_name(), "^7: You have been moved to the ", Team_ColorName_Lower(team_colour), " team\n")); // send a chat message - bprint(strcat(client.netname, " joined the ", ColoredTeamName(client.team), "\n")); + bprint(strcat(client.netname, " joined the ", Team_ColoredFullName(client.team), "\n")); } diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index c289334f2..fc2b3c0aa 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -961,21 +961,21 @@ void GameCommand_moveplayer(float request, float argc) if(teamplay) { // set up - float team_color; + float team_id; float save = client.team_forced; client.team_forced = 0; // find the team to move the player to - team_color = Team_ColorToNumber(destination); - if(team_color == client.team) // already on the destination team + team_id = Team_ColorToTeam(destination); + if(team_id == client.team) // already on the destination team { // keep the forcing undone - print("Player ", ftos(GetFilteredNumber(t)), " (", client.netname, ") is already on the ", ColoredTeamName(client.team), (targets ? ", skipping to next player.\n" : ".\n")); + print("Player ", ftos(GetFilteredNumber(t)), " (", client.netname, ") is already on the ", Team_ColoredFullName(client.team), (targets ? "^7, skipping to next player.\n" : "^7.\n")); continue; } - else if(team_color == 0) // auto team + else if(team_id == 0) // auto team { - team_color = Team_NumberToTeam(FindSmallestTeam(client, FALSE)); + team_id = Team_NumberToTeam(FindSmallestTeam(client, FALSE)); } else { @@ -984,7 +984,7 @@ void GameCommand_moveplayer(float request, float argc) client.team_forced = save; // Check to see if the destination team is even available - switch(team_color) + switch(team_id) { case FL_TEAM_1: if(c1 == -1) { print("Sorry, can't move player to red team if it doesn't exist.\n"); return; } break; case FL_TEAM_2: if(c2 == -1) { print("Sorry, can't move player to blue team if it doesn't exist.\n"); return; } break; @@ -996,9 +996,9 @@ void GameCommand_moveplayer(float request, float argc) // If so, lets continue and finally move the player client.team_forced = 0; - MoveToTeam(client, team_color, 6, stof(notify)); + MoveToTeam(client, team_id, 6, stof(notify)); successful = strcat(successful, (successful ? ", " : ""), client.netname); - print("Player ", ftos(GetFilteredNumber(t)), " (", client.netname, ") has been moved to the ", ColoredTeamName(team_color), ".\n"); + print("Player ", ftos(GetFilteredNumber(t)), " (", client.netname, ") has been moved to the ", Team_ColoredFullName(team_id), "^7.\n"); continue; } else diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index b32424d37..3a211853c 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -334,7 +334,7 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype) if (targ == attacker) // suicides { - s1 = ((deathtype == DEATH_TEAMCHANGE || deathtype == DEATH_AUTOTEAMCHANGE) ? ColoredTeamName(targ.team) : ""); + s1 = ((deathtype == DEATH_TEAMCHANGE || deathtype == DEATH_AUTOTEAMCHANGE) ? Team_ColoredFullName(targ.team) : ""); // no "killed your own dumb self" message in CTS if(!g_cts) { Obituary_Notification(targ, s1, "", "", deathtype); } diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 593d57d40..b32dec366 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -32,7 +32,6 @@ void WarpZone_crosshair_trace(entity pl) void() spawnfunc_info_player_deathmatch; // needed for the other spawnpoints void() spawnpoint_use; string GetMapname(); -string ColoredTeamName(float t); string admin_name(void) { diff --git a/qcsrc/server/mutators/gamemode_keyhunt.qc b/qcsrc/server/mutators/gamemode_keyhunt.qc index bcf42bbed..9bf9498c5 100644 --- a/qcsrc/server/mutators/gamemode_keyhunt.qc +++ b/qcsrc/server/mutators/gamemode_keyhunt.qc @@ -541,7 +541,7 @@ void kh_WinnerTeam(float teem) // runs when a team wins bprint(key.owner.netname); first = FALSE; } - bprint("^7 captured the keys for the ", ColoredTeamName(teem), "\n"); + bprint("^7 captured the keys for the ", Team_ColoredFullName(teem), "\n"); first = TRUE; midpoint = '0 0 0'; @@ -567,7 +567,7 @@ void kh_WinnerTeam(float teem) // runs when a team wins te_lightning2(world, lastorigin, firstorigin); } midpoint = midpoint * (1 / kh_teams); - te_customflash(midpoint, 1000, 1, TeamColor(teem) * 0.5 + '0.5 0.5 0.5'); // make the color >=0.5 in each component + te_customflash(midpoint, 1000, 1, Team_ColorRGB(teem) * 0.5 + '0.5 0.5 0.5'); // make the color >=0.5 in each component play2all(kh_sound_capture); kh_FinishRound(); @@ -596,7 +596,7 @@ void kh_LoserTeam(float teem, entity lostkey) // runs when a player pushes a fl kh_Scores_Event(attacker, world, "push", autocvar_g_balance_keyhunt_score_push, 0); PlayerScore_Add(attacker, SP_KH_PUSHES, 1); centerprint(attacker, "Your push is the best!"); - bprint("The ", ColoredTeamName(teem), "^7 could not take care of the ", lostkey.netname, "^7 when ", attacker.netname, "^7 came\n"); + bprint("The ", Team_ColoredFullName(teem), "^7 could not take care of the ", lostkey.netname, "^7 when ", attacker.netname, "^7 came\n"); } else { @@ -656,7 +656,7 @@ void kh_LoserTeam(float teem, entity lostkey) // runs when a player pushes a fl --j; } - bprint("The ", ColoredTeamName(teem), "^7 could not take care of the ", lostkey.netname, "\n"); + bprint("The ", Team_ColoredFullName(teem), "^7 could not take care of the ", lostkey.netname, "\n"); } play2all(kh_sound_destroy); te_tarexplosion(lostkey.origin); @@ -715,7 +715,7 @@ void kh_Key_Think() // runs all the time else Send_CSQC_Centerprint_Generic(head, CPID_KH_MSG, "All keys are in your team's hands!\n\nHelp the key carriers to meet!", 0, 0); else - Send_CSQC_Centerprint_Generic(head, CPID_KH_MSG, strcat("All keys are in the ", ColoredTeamName(kh_interferemsg_team), "^7's hands!\n\nInterfere ^1NOW^7!"), 0, 0); + Send_CSQC_Centerprint_Generic(head, CPID_KH_MSG, strcat("All keys are in the ", Team_ColoredFullName(kh_interferemsg_team), "^7's hands!\n\nInterfere ^1NOW^7!"), 0, 0); } } @@ -748,7 +748,7 @@ void kh_Key_Spawn(entity initial_owner, float angle, float i) // runs every tim key.kh_dropperteam = 0; key.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP; setsize(key, KH_KEY_MIN, KH_KEY_MAX); - key.colormod = TeamColor(initial_owner.team) * KH_KEY_BRIGHTNESS; + key.colormod = Team_ColorRGB(initial_owner.team) * KH_KEY_BRIGHTNESS; key.reset = key_reset; switch(initial_owner.team) @@ -876,7 +876,7 @@ string kh_CheckEnoughPlayers() // checks enough player are present, runs after { if(result != "") result = strcat(result, ", "); - result = strcat(result, ColoredTeamName(teem)); + result = strcat(result, Team_ColoredFullName(teem)); } } return result; diff --git a/qcsrc/server/mutators/gamemode_nexball.qc b/qcsrc/server/mutators/gamemode_nexball.qc index 433d781fb..f5b92a480 100644 --- a/qcsrc/server/mutators/gamemode_nexball.qc +++ b/qcsrc/server/mutators/gamemode_nexball.qc @@ -49,7 +49,7 @@ void nexball_setstatus(void) { if(self.ballcarried.teamtime && (self.ballcarried.teamtime < time)) { - bprint("The ", ColoredTeamName(self.team), " held the ball for too long.\n"); + bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n"); oldself = self; self = self.ballcarried; DropBall(self, self.owner.origin, '0 0 0'); @@ -204,7 +204,7 @@ void ResetBall(void) if(self.cnt < 2) // step 1 { if(time == self.teamtime) - bprint("The ", ColoredTeamName(self.team), " held the ball for too long.\n"); + bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n"); self.touch = SUB_Null; self.movetype = MOVETYPE_NOCLIP; self.velocity = '0 0 0'; // just in case? @@ -341,9 +341,9 @@ void GoalTouch(void) { LogNB("fault", ball.pusher); if(nb_teams == 2) - bprint(ColoredTeamName(otherteam), " gets a point due to ", pname, "^7's silliness.\n"); + bprint(Team_ColoredFullName(otherteam), " gets a point due to ", pname, "^7's silliness.\n"); else - bprint(ColoredTeamName(ball.team), " loses a point due to ", pname, "^7's silliness.\n"); + bprint(Team_ColoredFullName(ball.team), " loses a point due to ", pname, "^7's silliness.\n"); pscore = -1; } else if(self.team == GOAL_OUT) @@ -358,7 +358,7 @@ void GoalTouch(void) else //score { LogNB(strcat("goal:", ftos(self.team)), ball.pusher); - bprint("Goaaaaal! ", pname, "^7 scored a point for the ", ColoredTeamName(ball.team), ".\n"); + bprint("Goaaaaal! ", pname, "^7 scored a point for the ", Team_ColoredFullName(ball.team), ".\n"); pscore = 1; } diff --git a/qcsrc/server/mutators/gamemode_onslaught.qc b/qcsrc/server/mutators/gamemode_onslaught.qc index 70479625a..b09a9e982 100644 --- a/qcsrc/server/mutators/gamemode_onslaught.qc +++ b/qcsrc/server/mutators/gamemode_onslaught.qc @@ -596,7 +596,7 @@ void onslaught_generator_damage(entity inflictor, entity attacker, float damage, if (time > self.pain_finished) { self.pain_finished = time + 10; - bprint(ColoredTeamName(self.team), " generator under attack!\n"); + bprint(Team_ColoredFullName(self.team), " generator under attack!\n"); play2team(self.team, "onslaught/generator_underattack.wav"); } } @@ -612,19 +612,19 @@ void onslaught_generator_damage(entity inflictor, entity attacker, float damage, lh = ceil(self.lasthealth / 100) * 100; h = ceil(self.health / 100) * 100; if(lh != h) - bprint(ColoredTeamName(self.team), " generator has less than ", ftos(h), " health remaining\n"); + bprint(Team_ColoredFullName(self.team), " generator has less than ", ftos(h), " health remaining\n"); #endif self.lasthealth = self.health; } else if not(inWarmupStage) { if (attacker == self) - bprint(ColoredTeamName(self.team), " generator spontaneously exploded due to overtime!\n"); + bprint(Team_ColoredFullName(self.team), " generator spontaneously exploded due to overtime!\n"); else { string t; - t = ColoredTeamName(attacker.team); - bprint(ColoredTeamName(self.team), " generator destroyed by ", t, "!\n"); + t = Team_ColoredFullName(attacker.team); + bprint(Team_ColoredFullName(self.team), " generator destroyed by ", t, "!\n"); } self.iscaptured = FALSE; self.islinked = FALSE; @@ -1035,8 +1035,8 @@ void onslaught_controlpoint_icon_damage(entity inflictor, entity attacker, float pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1); { string t; - t = ColoredTeamName(attacker.team); - bprint(ColoredTeamName(self.team), " ", self.message, " control point destroyed by ", t, "\n"); + t = Team_ColoredFullName(attacker.team); + bprint(Team_ColoredFullName(self.team), " ", self.message, " control point destroyed by ", t, "\n"); ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 25, "models/onslaught/controlpoint_icon_gib1.md3", 3, FALSE); ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 45, "models/onslaught/controlpoint_icon_gib2.md3", 3, FALSE); ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 45, "models/onslaught/controlpoint_icon_gib2.md3", 3, FALSE); @@ -1234,7 +1234,7 @@ void onslaught_controlpoint_icon_buildthink() self.count = autocvar_g_onslaught_cp_regen * sys_frametime; // slow repair rate from now on self.think = onslaught_controlpoint_icon_think; sound(self, CH_TRIGGER, "onslaught/controlpoint_built.wav", VOL_BASE, ATTN_NORM); - bprint(ColoredTeamName(self.team), " captured ", self.owner.message, " control point\n"); + bprint(Team_ColoredFullName(self.team), " captured ", self.owner.message, " control point\n"); self.owner.iscaptured = TRUE; WaypointSprite_UpdateMaxHealth(self.owner.sprite, self.max_health); diff --git a/qcsrc/server/scores.qc b/qcsrc/server/scores.qc index 19d613b07..38425a8ba 100644 --- a/qcsrc/server/scores.qc +++ b/qcsrc/server/scores.qc @@ -775,7 +775,7 @@ void Score_NicePrint_Team(entity to, float t, float w) sk = teamscorekeepers[t - 1]; if(sk) { - s = strcat(s, ColoredTeamName(t)); + s = strcat(s, Team_ColoredFullName(t)); for(i = 0; i < MAX_TEAMSCORE; ++i) if(teamscores_label[i] != "") { diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index be6f34a6e..fd7b554ef 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -13,45 +13,6 @@ void TeamchangeFrags(entity e) PlayerScore_Clear(e); } -vector TeamColor(float teem) -{ - switch(teem) - { - case FL_TEAM_1: - return '1 0.0625 0.0625'; - case FL_TEAM_2: - return '0.0625 0.0625 1'; - case FL_TEAM_3: - return '1 1 0.0625'; - case FL_TEAM_4: - return '1 0.0625 1'; - default: - return '1 1 1'; - } -} - -string TeamName(float t) -{ - return strcat(Team_ColorName(t), " Team"); -} -string ColoredTeamName(float t) -{ - return strcat(Team_ColorCode(t), Team_ColorName(t), " Team^7"); -} -string TeamNoName(float t) -{ - // fixme: Search for team entities and get their .netname's! - if(t == 1) - return "Red Team"; - if(t == 2) - return "Blue Team"; - if(t == 3) - return "Yellow Team"; - if(t == 4) - return "Pink Team"; - return "Neutral Team"; -} - void dom_init(); void runematch_init(); void tdm_init(); @@ -431,7 +392,7 @@ void SetPlayerTeam(entity pl, float t, float s, float noprint) LogTeamchange(pl.playerid, pl.team, 3); // log manual team join if(!noprint) - bprint(pl.netname, "^7 has changed from ", TeamNoName(s), " to ", TeamNoName(t), "\n"); + bprint(pl.netname, "^7 has changed from ", Team_NumberToColoredFullName(s), "^7 to ", Team_NumberToColoredFullName(t), "\n"); } } @@ -1049,7 +1010,7 @@ void ShufflePlayerOutOfTeam (float source_team) if(selected.deadflag == DEAD_NO) Damage(selected, selected, selected, 100000, DEATH_AUTOTEAMCHANGE, selected.origin, '0 0 0'); - centerprint(selected, strcat("You have been moved into a different team to improve team balance\nYou are now on: ", ColoredTeamName(selected.team))); + centerprint(selected, strcat("You have been moved into a different team to improve team balance\nYou are now on: ", Team_ColoredFullName(selected.team))); } // code from here on is just to support maps that don't have team entities diff --git a/qcsrc/server/vehicles/vehicles.qc b/qcsrc/server/vehicles/vehicles.qc index 16a339e09..861f8ee4e 100644 --- a/qcsrc/server/vehicles/vehicles.qc +++ b/qcsrc/server/vehicles/vehicles.qc @@ -1033,7 +1033,7 @@ void vehicles_showwp() } if(teamplay && self.team) - rgb = TeamColor(self.team); + rgb = Team_ColorRGB(self.team); else rgb = '1 1 1'; WaypointSprite_Spawn("vehicle", 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, TRUE, RADARICON_POWERUP, rgb);