3 const int NUM_TEAMS = 4; ///< Number of teams in the game.
5 #ifdef TEAMNUMBERS_THAT_ARENT_STUPID
6 const int NUM_TEAM_1 = 1; // red
7 const int NUM_TEAM_2 = 2; // blue
8 const int NUM_TEAM_3 = 3; // yellow
9 const int NUM_TEAM_4 = 4; // pink
10 const int NUM_SPECTATOR = 5;
13 const int NUM_TEAM_1 = 4; // red
14 const int NUM_TEAM_2 = 13; // blue
15 const int NUM_TEAM_3 = 12; // yellow
16 const int NUM_TEAM_4 = 9; // pink
18 const int NUM_TEAM_1 = 5; // red
19 const int NUM_TEAM_2 = 14; // blue
20 const int NUM_TEAM_3 = 13; // yellow
21 const int NUM_TEAM_4 = 10; // pink
23 const int NUM_SPECTATOR = 1337;
26 const string COL_TEAM_1 = "^1";
27 const string COL_TEAM_2 = "^4";
28 const string COL_TEAM_3 = "^3";
29 const string COL_TEAM_4 = "^6";
30 // must be #defined, const globals drop the translation attribute
31 #define NAME_TEAM_1 CTX(_("TEAM^Red"))
32 #define NAME_TEAM_2 CTX(_("TEAM^Blue"))
33 #define NAME_TEAM_3 CTX(_("TEAM^Yellow"))
34 #define NAME_TEAM_4 CTX(_("TEAM^Pink"))
35 #define NAME_TEAM _("Team")
36 #define NAME_NEUTRAL _("Neutral")
38 // items colors, so they are handled properly in languages which decline things with grammatical gender
39 #define KEY_TEAM_1 CTX(_("KEY^Red"))
40 #define KEY_TEAM_2 CTX(_("KEY^Blue"))
41 #define KEY_TEAM_3 CTX(_("KEY^Yellow"))
42 #define KEY_TEAM_4 CTX(_("KEY^Pink"))
43 #define FLAG_TEAM_1 CTX(_("FLAG^Red"))
44 #define FLAG_TEAM_2 CTX(_("FLAG^Blue"))
45 #define FLAG_TEAM_3 CTX(_("FLAG^Yellow"))
46 #define FLAG_TEAM_4 CTX(_("FLAG^Pink"))
47 #define GENERATOR_TEAM_1 CTX(_("GENERATOR^Red"))
48 #define GENERATOR_TEAM_2 CTX(_("GENERATOR^Blue"))
49 #define GENERATOR_TEAM_3 CTX(_("GENERATOR^Yellow"))
50 #define GENERATOR_TEAM_4 CTX(_("GENERATOR^Pink"))
52 // used for replacement in filenames or such where the name CANNOT be allowed to be translated
53 const string STATIC_NAME_TEAM_1 = "Red";
54 const string STATIC_NAME_TEAM_2 = "Blue";
55 const string STATIC_NAME_TEAM_3 = "Yellow";
56 const string STATIC_NAME_TEAM_4 = "Pink";
62 // z411 used for custom names
65 string teamname_yellow;
69 string Team_ColorCode(int teamid)
73 case NUM_TEAM_1: return COL_TEAM_1;
74 case NUM_TEAM_2: return COL_TEAM_2;
75 case NUM_TEAM_3: return COL_TEAM_3;
76 case NUM_TEAM_4: return COL_TEAM_4;
82 vector Team_ColorRGB(int teamid)
86 case NUM_TEAM_1: return '1 0.0625 0.0625'; // 0xFF0F0F
87 case NUM_TEAM_2: return '0.0625 0.0625 1'; // 0x0F0FFF
88 case NUM_TEAM_3: return '1 1 0.0625'; // 0xFFFF0F
89 case NUM_TEAM_4: return '1 0.0625 1'; // 0xFF0FFF
96 string Team_CustomName(int teamid)
100 case NUM_TEAM_1: return ((teamname_red != "") ? teamname_red : "^1RED^7 team");
101 case NUM_TEAM_2: return ((teamname_blue != "")? teamname_blue : "^4BLUE^7 team");
102 case NUM_TEAM_3: return ((teamname_yellow != "") ? teamname_yellow : "^3YELLOW^7 team");
103 case NUM_TEAM_4: return ((teamname_pink != "") ? teamname_pink : "^6PINK^7 team");
110 string Team_ColorName(int teamid)
114 case NUM_TEAM_1: return NAME_TEAM_1;
115 case NUM_TEAM_2: return NAME_TEAM_2;
116 case NUM_TEAM_3: return NAME_TEAM_3;
117 case NUM_TEAM_4: return NAME_TEAM_4;
123 // used for replacement in filenames or such where the name CANNOT be allowed to be translated
124 string Static_Team_ColorName(int teamid)
128 case NUM_TEAM_1: return STATIC_NAME_TEAM_1;
129 case NUM_TEAM_2: return STATIC_NAME_TEAM_2;
130 case NUM_TEAM_3: return STATIC_NAME_TEAM_3;
131 case NUM_TEAM_4: return STATIC_NAME_TEAM_4;
137 float Team_ColorToTeam(string team_color)
139 switch(strtolower(team_color))
141 case "red": return NUM_TEAM_1;
142 case "blue": return NUM_TEAM_2;
143 case "yellow": return NUM_TEAM_3;
144 case "pink": return NUM_TEAM_4;
145 case "auto": return 0;
151 /// \brief Returns whether team value is valid.
152 /// \param[in] team_num Team to check.
153 /// \return True if team is valid, false otherwise.
154 bool Team_IsValidTeam(int team_num)
169 /// \brief Returns whether the team index is valid.
170 /// \param[in] index Team index to check.
171 /// \return True if team index is valid, false otherwise.
172 bool Team_IsValidIndex(int index)
187 /// \brief Converts team index into team value.
188 /// \param[in] index Team index to convert.
189 /// \return Team value.
190 int Team_IndexToTeam(int index)
194 case 1: return NUM_TEAM_1;
195 case 2: return NUM_TEAM_2;
196 case 3: return NUM_TEAM_3;
197 case 4: return NUM_TEAM_4;
202 /// \brief Converts team value into team index.
203 /// \param[in] team_num Team value to convert.
204 /// \return Team index.
205 int Team_TeamToIndex(int team_num)
209 case NUM_TEAM_1: return 1;
210 case NUM_TEAM_2: return 2;
211 case NUM_TEAM_3: return 3;
212 case NUM_TEAM_4: return 4;
217 /// \brief Converts team value into bit value that is used in team bitmasks.
218 /// \param[in] team_num Team value to convert.
219 /// \return Team bit.
220 int Team_TeamToBit(int team_num)
222 if (!Team_IsValidTeam(team_num))
226 return BIT(Team_TeamToIndex(team_num) - 1);
229 /// \brief Converts team index into bit value that is used in team bitmasks.
230 /// \param[in] index Team index to convert.
231 /// \return Team bit.
232 int Team_IndexToBit(int index)
234 return BIT(index - 1);
238 // legacy aliases for shitty code
239 #define TeamByColor(teamid) (Team_TeamToIndex(teamid) - 1)
240 #define ColorByTeam(number) Team_IndexToTeam(number + 1)
243 #define Team_ColorName_Lower(teamid) strtolower(Team_ColorName(teamid))
244 #define Team_ColorName_Upper(teamid) strtoupper(Team_ColorName(teamid))
246 // used for replacement in filenames or such where the name CANNOT be allowed to be translated
247 #define Static_Team_ColorName_Lower(teamid) strtolower(Static_Team_ColorName(teamid))
248 #define Static_Team_ColorName_Upper(teamid) strtoupper(Static_Team_ColorName(teamid))
250 #define Team_FullName(teamid) strcat(Team_ColorName(teamid), " ", NAME_TEAM, "^7")
251 #define Team_ColoredFullName(teamid) strcat(Team_ColorCode(teamid), Team_ColorName(teamid), " ", NAME_TEAM, "^7")
253 #define Team_IndexToFullName(index) Team_FullName(Team_IndexToTeam(index))
254 #define Team_IndexToColoredFullName(index) Team_ColoredFullName(Team_IndexToTeam(index))
256 // replace these flags in a string with the strings provided
257 #define TCR(input,type,team) strreplace("^TC", COL_TEAM_##team, strreplace("^TT", strtoupper(type##_TEAM_##team), input))
259 // safe team comparisons
260 #define SAME_TEAM(a,b) (teamplay ? (a.team == b.team) : (a == b))
261 #define DIFF_TEAM(a,b) (teamplay ? (a.team != b.team) : (a != b))