]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/teams.qh
Rename defs to qh
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / teams.qh
1 #ifndef TEAMS_H
2 #define TEAMS_H
3
4 #if defined(CSQC)
5         #include "util-pre.qh"
6         #include "../client/sys-pre.qh"
7         #include "../dpdefs/csprogsdefs.qh"
8         #include "../client/sys-post.qh"
9         #include "../client/defs.qh"
10         #include "../dpdefs/keycodes.qh"
11         #include "constants.qh"
12         #include "stats.qh"
13         #include "../warpzonelib/anglestransform.qh"
14         #include "../warpzonelib/mathlib.qh"
15         #include "../warpzonelib/common.qh"
16         #include "../warpzonelib/client.qh"
17         #include "playerstats.qh"
18 #elif defined(MENUQC)
19         #include "util-pre.qh"
20     #include "../menu/sys-pre.qh"
21     #include "../dpdefs/menudefs.qh"
22     #include "../dpdefs/keycodes.qh"
23     #include "../menu/sys-post.qh"
24     #include "../menu/config.qh"
25     #include "../warpzonelib/mathlib.qh"
26     #include "util.qh"
27     #include "test.qh"
28     #include "../menu/oo/base.qh"
29     #include "playerstats.qh"
30 #elif defined(SVQC)
31         #include "util-pre.qh"
32     #include "../server/sys-pre.qh"
33     #include "../dpdefs/progsdefs.qh"
34     #include "../dpdefs/dpextensions.qh"
35     #include "../server/sys-post.qh"
36     #include "../warpzonelib/anglestransform.qh"
37     #include "../warpzonelib/mathlib.qh"
38     #include "../warpzonelib/common.qh"
39     #include "../warpzonelib/util_server.qh"
40     #include "../warpzonelib/server.qh"
41     #include "constants.qh"
42     #include "stats.qh"
43 #endif
44
45 #ifdef TEAMNUMBERS_THAT_ARENT_STUPID
46 const int NUM_TEAM_1 = 1;  // red
47 const int NUM_TEAM_2 = 2; // blue
48 const int NUM_TEAM_3 = 3; // yellow
49 const int NUM_TEAM_4 = 4; // pink
50 const int NUM_SPECTATOR = 5;
51 #else
52 #ifdef CSQC
53 const int NUM_TEAM_1 = 4;  // red
54 const int NUM_TEAM_2 = 13; // blue
55 const int NUM_TEAM_3 = 12; // yellow
56 const int NUM_TEAM_4 = 9; // pink
57 #else
58 const int NUM_TEAM_1 = 5;  // red
59 const int NUM_TEAM_2 = 14; // blue
60 const int NUM_TEAM_3 = 13; // yellow
61 const int NUM_TEAM_4 = 10; // pink
62 #endif
63 const int NUM_SPECTATOR = 1337;
64 #endif
65
66 const string COL_TEAM_1 = "^1";
67 const string COL_TEAM_2 = "^4";
68 const string COL_TEAM_3 = "^3";
69 const string COL_TEAM_4 = "^6";
70 const string NAME_TEAM_1 = _("Red");
71 const string NAME_TEAM_2 = _("Blue");
72 const string NAME_TEAM_3 = _("Yellow");
73 const string NAME_TEAM_4 = _("Pink");
74 const string NAME_TEAM = _("Team");
75 const string NAME_NEUTRAL = _("Neutral");
76
77 // used for replacement in filenames or such where the name CANNOT be allowed to be translated
78 const string STATIC_NAME_TEAM_1 = "Red";
79 const string STATIC_NAME_TEAM_2 = "Blue";
80 const string STATIC_NAME_TEAM_3 = "Yellow";
81 const string STATIC_NAME_TEAM_4 = "Pink";
82
83 #ifdef CSQC
84 float teamplay;
85 float myteam;
86 #endif
87
88 string Team_ColorCode(float teamid)
89 {
90     switch(teamid)
91     {
92                 case NUM_TEAM_1: return COL_TEAM_1;
93         case NUM_TEAM_2: return COL_TEAM_2;
94         case NUM_TEAM_3: return COL_TEAM_3;
95         case NUM_TEAM_4: return COL_TEAM_4;
96         }
97
98         return "^7";
99 }
100
101 vector Team_ColorRGB(float teamid)
102 {
103         switch(teamid)
104         {
105                 case NUM_TEAM_1: return '1 0.0625 0.0625'; // 0xFF0F0F
106                 case NUM_TEAM_2: return '0.0625 0.0625 1'; // 0x0F0FFF
107                 case NUM_TEAM_3: return '1 1 0.0625'; // 0xFFFF0F
108                 case NUM_TEAM_4: return '1 0.0625 1'; // 0xFF0FFF
109         }
110
111     return '0 0 0';
112 }
113
114 string Team_ColorName(float teamid)
115 {
116     switch(teamid)
117     {
118                 case NUM_TEAM_1: return NAME_TEAM_1;
119         case NUM_TEAM_2: return NAME_TEAM_2;
120         case NUM_TEAM_3: return NAME_TEAM_3;
121         case NUM_TEAM_4: return NAME_TEAM_4;
122         }
123
124     return NAME_NEUTRAL;
125 }
126
127 // used for replacement in filenames or such where the name CANNOT be allowed to be translated
128 string Static_Team_ColorName(float teamid)
129 {
130     switch(teamid)
131     {
132                 case NUM_TEAM_1: return STATIC_NAME_TEAM_1;
133         case NUM_TEAM_2: return STATIC_NAME_TEAM_2;
134         case NUM_TEAM_3: return STATIC_NAME_TEAM_3;
135         case NUM_TEAM_4: return STATIC_NAME_TEAM_4;
136         }
137
138     return NAME_NEUTRAL;
139 }
140
141 float Team_ColorToTeam(string team_color)
142 {
143         switch(strtolower(team_color))
144         {
145                 case "red": return NUM_TEAM_1;
146         case "blue": return NUM_TEAM_2;
147         case "yellow": return NUM_TEAM_3;
148         case "pink": return NUM_TEAM_4;
149         case "auto": return 0;
150         }
151
152         return -1;
153 }
154
155 float Team_NumberToTeam(float number)
156 {
157         switch(number)
158         {
159                 case 1: return NUM_TEAM_1;
160                 case 2: return NUM_TEAM_2;
161                 case 3: return NUM_TEAM_3;
162                 case 4: return NUM_TEAM_4;
163         }
164
165         return -1;
166 }
167
168 float Team_TeamToNumber(float teamid)
169 {
170         switch(teamid)
171         {
172                 case NUM_TEAM_1: return 1;
173                 case NUM_TEAM_2: return 2;
174                 case NUM_TEAM_3: return 3;
175                 case NUM_TEAM_4: return 4;
176         }
177
178         return -1;
179 }
180
181
182 // legacy aliases for shitty code
183 #define TeamByColor(teamid) (Team_TeamToNumber(teamid) - 1)
184 #define ColorByTeam(number) Team_NumberToTeam(number + 1)
185
186 // useful aliases
187 #define Team_ColorName_Lower(teamid) strtolower(Team_ColorName(teamid))
188 #define Team_ColorName_Upper(teamid) strtoupper(Team_ColorName(teamid))
189
190 // used for replacement in filenames or such where the name CANNOT be allowed to be translated
191 #define Static_Team_ColorName_Lower(teamid) strtolower(Static_Team_ColorName(teamid))
192 #define Static_Team_ColorName_Upper(teamid) strtoupper(Static_Team_ColorName(teamid))
193
194 #define Team_FullName(teamid) strcat(Team_ColorName(teamid), " ", NAME_TEAM, "^7")
195 #define Team_ColoredFullName(teamid) strcat(Team_ColorCode(teamid), Team_ColorName(teamid), " ", NAME_TEAM, "^7")
196
197 #define Team_NumberToFullName(number) Team_FullName(Team_NumberToTeam(number))
198 #define Team_NumberToColoredFullName(number) Team_ColoredFullName(Team_NumberToTeam(number))
199
200 // replace these flags in a string with the strings provided
201 #define TCR(input,teamcolor,teamtext) strreplace("^TC", teamcolor, strreplace("^TT", teamtext, input))
202
203 // safe team comparisons
204 #define SAME_TEAM(a,b) (teamplay ? ((a.team == b.team) ? 1 : 0) : ((a == b) ? 1 : 0))
205 #define DIFF_TEAM(a,b) (teamplay ? ((a.team != b.team) ? 1 : 0) : ((a != b) ? 1 : 0))
206
207 // used for notification system multi-team identifiers
208 #define APP_TEAM_NUM_2(num,prefix) ((num == NUM_TEAM_1) ? prefix##RED : prefix##BLUE)
209 #define APP_TEAM_NUM_4(num,prefix) ((num == NUM_TEAM_1) ? prefix##RED : ((num == NUM_TEAM_2) ? prefix##BLUE : ((num == NUM_TEAM_3) ? prefix##YELLOW : prefix##PINK)))
210 #define APP_TEAM_ENT_2(ent,prefix) ((ent.team == NUM_TEAM_1) ? prefix##RED : prefix##BLUE)
211 #define APP_TEAM_ENT_4(ent,prefix) ((ent.team == NUM_TEAM_1) ? prefix##RED : ((ent.team == NUM_TEAM_2) ? prefix##BLUE : ((ent.team == NUM_TEAM_3) ? prefix##YELLOW : prefix##PINK)))
212 #endif