]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/teams.qh
Impulses: migration pathway
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / teams.qh
1 #ifndef TEAMS_H
2 #define TEAMS_H
3
4 #ifdef TEAMNUMBERS_THAT_ARENT_STUPID
5 const int NUM_TEAM_1 = 1;  // red
6 const int NUM_TEAM_2 = 2; // blue
7 const int NUM_TEAM_3 = 3; // yellow
8 const int NUM_TEAM_4 = 4; // pink
9 const int NUM_SPECTATOR = 5;
10 #else
11 #ifdef CSQC
12 const int NUM_TEAM_1 = 4;  // red
13 const int NUM_TEAM_2 = 13; // blue
14 const int NUM_TEAM_3 = 12; // yellow
15 const int NUM_TEAM_4 = 9; // pink
16 #else
17 const int NUM_TEAM_1 = 5;  // red
18 const int NUM_TEAM_2 = 14; // blue
19 const int NUM_TEAM_3 = 13; // yellow
20 const int NUM_TEAM_4 = 10; // pink
21 #endif
22 const int NUM_SPECTATOR = 1337;
23 #endif
24
25 const string COL_TEAM_1 = "^1";
26 const string COL_TEAM_2 = "^4";
27 const string COL_TEAM_3 = "^3";
28 const string COL_TEAM_4 = "^6";
29 const string NAME_TEAM_1 = _("Red");
30 const string NAME_TEAM_2 = _("Blue");
31 const string NAME_TEAM_3 = _("Yellow");
32 const string NAME_TEAM_4 = _("Pink");
33 const string NAME_TEAM = _("Team");
34 const string NAME_NEUTRAL = _("Neutral");
35
36 // used for replacement in filenames or such where the name CANNOT be allowed to be translated
37 const string STATIC_NAME_TEAM_1 = "Red";
38 const string STATIC_NAME_TEAM_2 = "Blue";
39 const string STATIC_NAME_TEAM_3 = "Yellow";
40 const string STATIC_NAME_TEAM_4 = "Pink";
41
42 #ifdef CSQC
43 float teamplay;
44 float myteam;
45 #endif
46
47 string Team_ColorCode(float teamid)
48 {
49     switch(teamid)
50     {
51                 case NUM_TEAM_1: return COL_TEAM_1;
52         case NUM_TEAM_2: return COL_TEAM_2;
53         case NUM_TEAM_3: return COL_TEAM_3;
54         case NUM_TEAM_4: return COL_TEAM_4;
55         }
56
57         return "^7";
58 }
59
60 vector Team_ColorRGB(float teamid)
61 {
62         switch(teamid)
63         {
64                 case NUM_TEAM_1: return '1 0.0625 0.0625'; // 0xFF0F0F
65                 case NUM_TEAM_2: return '0.0625 0.0625 1'; // 0x0F0FFF
66                 case NUM_TEAM_3: return '1 1 0.0625'; // 0xFFFF0F
67                 case NUM_TEAM_4: return '1 0.0625 1'; // 0xFF0FFF
68         }
69
70     return '0 0 0';
71 }
72
73 string Team_ColorName(float teamid)
74 {
75     switch(teamid)
76     {
77                 case NUM_TEAM_1: return NAME_TEAM_1;
78         case NUM_TEAM_2: return NAME_TEAM_2;
79         case NUM_TEAM_3: return NAME_TEAM_3;
80         case NUM_TEAM_4: return NAME_TEAM_4;
81         }
82
83     return NAME_NEUTRAL;
84 }
85
86 // used for replacement in filenames or such where the name CANNOT be allowed to be translated
87 string Static_Team_ColorName(float teamid)
88 {
89     switch(teamid)
90     {
91                 case NUM_TEAM_1: return STATIC_NAME_TEAM_1;
92         case NUM_TEAM_2: return STATIC_NAME_TEAM_2;
93         case NUM_TEAM_3: return STATIC_NAME_TEAM_3;
94         case NUM_TEAM_4: return STATIC_NAME_TEAM_4;
95         }
96
97     return NAME_NEUTRAL;
98 }
99
100 float Team_ColorToTeam(string team_color)
101 {
102         switch(strtolower(team_color))
103         {
104                 case "red": return NUM_TEAM_1;
105         case "blue": return NUM_TEAM_2;
106         case "yellow": return NUM_TEAM_3;
107         case "pink": return NUM_TEAM_4;
108         case "auto": return 0;
109         }
110
111         return -1;
112 }
113
114 float Team_NumberToTeam(float number)
115 {
116         switch(number)
117         {
118                 case 1: return NUM_TEAM_1;
119                 case 2: return NUM_TEAM_2;
120                 case 3: return NUM_TEAM_3;
121                 case 4: return NUM_TEAM_4;
122         }
123
124         return -1;
125 }
126
127 float Team_TeamToNumber(float teamid)
128 {
129         switch(teamid)
130         {
131                 case NUM_TEAM_1: return 1;
132                 case NUM_TEAM_2: return 2;
133                 case NUM_TEAM_3: return 3;
134                 case NUM_TEAM_4: return 4;
135         }
136
137         return -1;
138 }
139
140
141 // legacy aliases for shitty code
142 #define TeamByColor(teamid) (Team_TeamToNumber(teamid) - 1)
143 #define ColorByTeam(number) Team_NumberToTeam(number + 1)
144
145 // useful aliases
146 #define Team_ColorName_Lower(teamid) strtolower(Team_ColorName(teamid))
147 #define Team_ColorName_Upper(teamid) strtoupper(Team_ColorName(teamid))
148
149 // used for replacement in filenames or such where the name CANNOT be allowed to be translated
150 #define Static_Team_ColorName_Lower(teamid) strtolower(Static_Team_ColorName(teamid))
151 #define Static_Team_ColorName_Upper(teamid) strtoupper(Static_Team_ColorName(teamid))
152
153 #define Team_FullName(teamid) strcat(Team_ColorName(teamid), " ", NAME_TEAM, "^7")
154 #define Team_ColoredFullName(teamid) strcat(Team_ColorCode(teamid), Team_ColorName(teamid), " ", NAME_TEAM, "^7")
155
156 #define Team_NumberToFullName(number) Team_FullName(Team_NumberToTeam(number))
157 #define Team_NumberToColoredFullName(number) Team_ColoredFullName(Team_NumberToTeam(number))
158
159 // replace these flags in a string with the strings provided
160 #define TCR(input,teamcolor,teamtext) strreplace("^TC", teamcolor, strreplace("^TT", teamtext, input))
161
162 // safe team comparisons
163 #define SAME_TEAM(a,b) (teamplay ? ((a.team == b.team) ? 1 : 0) : ((a == b) ? 1 : 0))
164 #define DIFF_TEAM(a,b) (teamplay ? ((a.team != b.team) ? 1 : 0) : ((a != b) ? 1 : 0))
165
166 // used for notification system multi-team identifiers
167 #define APP_TEAM_NUM_2(num,prefix) ((num == NUM_TEAM_1) ? prefix##RED : prefix##BLUE)
168 #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)))
169 #define APP_TEAM_ENT_2(ent,prefix) ((ent.team == NUM_TEAM_1) ? prefix##RED : prefix##BLUE)
170 #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)))
171 #endif