1 var float(string text, float handleColors) stringwidth;
6 void restartAnnouncer_Think() {
7 float countdown_rounded, countdown;
8 countdown = getstatf(STAT_GAMESTARTTIME) - time;
9 countdown_rounded = floor(0.5 + countdown);
11 if (!spectatee_status) //do cprint only for players
12 centerprint("^1Begin!");
14 sound(self, CHAN_VOICE, "announcer/robotic/begin.wav", VOL_BASEVOICE, ATTN_NONE);
19 if (!spectatee_status) //do cprint only for players
20 centerprint(strcat("^1Game starts in ", ftos(countdown_rounded), " seconds"));
22 if(countdown_rounded <= 3 && countdown_rounded >= 1) {
23 sound(self, CHAN_VOICE, strcat("announcer/robotic/", ftos(countdown_rounded), ".wav"), VOL_BASEVOICE, ATTN_NONE);
26 self.nextthink = getstatf(STAT_GAMESTARTTIME) - (countdown - 1);
36 for(e = prev.sort_next; e; prev = e, e = e.sort_next)
38 if(prev != e.sort_prev)
39 error(strcat("sort list chain error\nplease submit the output of 'prvm_edicts client' to the developers"));
43 for(e = prev.sort_next; e; prev = e, e = e.sort_next)
45 if(prev != e.sort_prev)
46 error(strcat("sort list chain error\nplease submit the output of 'prvm_edicts client' to the developers"));
51 float RegisterPlayer(entity player)
55 for(pl = players.sort_next; pl; pl = pl.sort_next)
57 error("Player already registered!");
58 player.sort_next = players.sort_next;
59 player.sort_prev = players;
61 players.sort_next.sort_prev = player;
62 players.sort_next = player;
67 void RemovePlayer(entity player)
72 for(pl = players.sort_next; pl && pl != player; pl = pl.sort_next)
77 error("Trying to remove a player which is not in the playerlist!");
80 parent.sort_next = player.sort_next;
82 player.sort_next.sort_prev = parent;
86 void MoveToLast(entity e)
98 float RegisterTeam(entity Team)
102 for(tm = teams.sort_next; tm; tm = tm.sort_next)
104 error("Team already registered!");
105 Team.sort_next = teams.sort_next;
106 Team.sort_prev = teams;
108 teams.sort_next.sort_prev = Team;
109 teams.sort_next = Team;
114 void RemoveTeam(entity Team)
119 for(tm = teams.sort_next; tm && tm != Team; tm = tm.sort_next)
124 print("Trying to remove a team which is not in the teamlist!");
127 parent.sort_next = Team.sort_next;
129 Team.sort_next.sort_prev = parent;
133 entity GetTeam(float Team, float add)
137 num = (Team == COLOR_SPECTATOR) ? 16 : Team;
139 return teamslots[num];
149 float stringwidth_oldfont(string text, float handleColors)
151 float i, len, ch, width;
156 for(i = 0; i < len; ++i)
158 if(substring(text, i, 1) == "^")
160 ch = str2chr(text, i+1);
161 if(ch >= '0' && ch <= '9')
163 else if(i+4 < len && ch == 'x')
165 ch = str2chr(text, i+2);
166 if ( (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F') )
168 ch = str2chr(text, i+3);
169 if ( (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F') )
171 ch = str2chr(text, i+4);
172 if ( (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F') )
183 void CSQC_CheckEngine()
186 registercvar("csqc_flags", "0");
187 csqc_flags = cvar("csqc_flags");
192 if(checkextension("DP_SV_WRITEPICTURE"))
194 stringwidth = stringwidth_engine;
195 sbar_font = FONT_USER+1;
196 sbar_bigfont = FONT_USER+2;
197 csqc_flags |= CSQC_FLAG_READPICTURE;
199 stringwidth = stringwidth_oldfont;
200 sbar_font = FONT_DEFAULT;
201 sbar_bigfont = FONT_DEFAULT;
204 if(strlennocol("^xFFF") == 0)
205 csqc_flags |= CSQC_FLAG_COLORCODES;
208 vector Sbar_GetFontsize(string cvarname)
210 if(csqc_flags & CSQC_FLAG_READPICTURE)
213 v = stov(cvar_string(cvarname));
224 float Sbar_GetWidth(float teamcolumnwidth)
226 if(csqc_flags & CSQC_FLAG_READPICTURE)
229 f = stof(cvar_string("sbar_width"));
234 if(f > vid_conwidth - 2 * teamcolumnwidth)
235 f = vid_conwidth - 2 * teamcolumnwidth;
241 float PreviewExists(string name)
246 if(cvar("cl_readpicture_force"))
249 file = strcat(name, ".tga");
250 f = fopen(file, FILE_READ);
256 file = strcat(name, ".png");
257 f = fopen(file, FILE_READ);
263 file = strcat(name, ".jpg");
264 f = fopen(file, FILE_READ);
270 file = strcat(name, ".pcx");
271 f = fopen(file, FILE_READ);
280 float PI = 3.14159265359;
281 float DEG2RAD = 0.01745329252;
282 vector rotate(vector v, float a)
285 // FTEQCC SUCKS AGAIN
286 w_x = v_x * cos(a) + v_y * sin(a);
287 w_y = -1 * v_x * sin(a) + v_y * cos(a);
291 float ColorTranslateMode;
293 string ColorTranslateRGB(string s)
295 if not(ColorTranslateMode & 2)
296 if(csqc_flags & CSQC_FLAG_COLORCODES)
298 if(ColorTranslateMode & 1)
299 return strdecolorize(s);
304 // running on an OLD engine!
305 // must translate ^xRGB codes to regular color codes
308 vector theTempColor, hsv;
314 for(i = 0; i < n; ++i)
316 ch = substring(s, i, 1);
319 ch2 = substring(s, i+1, 1);
322 s2 = strcat(s2, ch, ch2);
324 else if(ch2 == "0" || stof(ch2)) // digit?
326 if not(ColorTranslateMode & 1)
327 s2 = strcat(s2, ch, ch2);
329 else if(ch2 == "x") // ^x found
331 theTempColor = '0 0 0';
333 component = HEXDIGIT_TO_DEC(substring(s, i+2, 1));
334 if (component >= 0) // ^xr found
336 theTempColor_x = component/15;
338 component = HEXDIGIT_TO_DEC(substring(s, i+3, 1));
339 if (component >= 0) // ^xrg found
341 theTempColor_y = component/15;
343 component = HEXDIGIT_TO_DEC(substring(s, i+4, 1));
344 if (component >= 0) // ^xrgb found
346 theTempColor_z = component/15;
348 if not(ColorTranslateMode & 1)
350 hsv = rgb_to_hsv(theTempColor);
355 s2 = strcat(s2, "^0");
357 s2 = strcat(s2, "^7");
362 s2 = strcat(s2, "^1");
363 else if(hsv_x < 1.33333333333333333333)
364 s2 = strcat(s2, "^3");
366 s2 = strcat(s2, "^2");
367 else if(hsv_x < 3.33333333333333333333)
368 s2 = strcat(s2, "^5");
370 s2 = strcat(s2, "^4");
372 s2 = strcat(s2, "^6");
374 s2 = strcat(s2, "^1");
383 s2 = strcat(s2, substring(s, i, 4));
390 s2 = strcat(s, substring(s2, i, 3));
397 s2 = strcat(s, substring(s2, i, 2));
402 s2 = strcat(s2, ch, ch2);
413 float cvar_or(string cv, float v)
423 vector project_3d_to_2d(vector vec)
425 vec = cs_project(vec);
426 if(cs_project_is_b0rked)
428 vec_x += vid_width / 2;
429 vec_y += vid_height / 2;
431 vec_x *= vid_conwidth / vid_width;
432 vec_y *= vid_conheight / vid_height;
436 void dummyfunction(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8)
440 float expandingbox_sizefactor_from_fadelerp(float fadelerp)
442 return 1.2 / (1.2 - fadelerp);
445 vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float boxxsizefactor)
447 boxsize_x *= boxxsizefactor; // easier interface for text
448 return boxsize * (0.5 * (1 - sz));
451 void drawpic_expanding(vector position, string pic, vector scale, vector rgb, float alpha, float flag, float fadelerp)
454 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
456 drawpic(position + expandingbox_resize_centered_box_offset(sz, scale, 1), pic, scale * sz, rgb, alpha * (1 - fadelerp), flag);
459 void drawpic_expanding_two(vector position, string pic, vector scale, vector rgb, float alpha, float flag, float fadelerp)
461 drawpic_expanding(position, pic, scale, rgb, alpha, flag, fadelerp);
462 drawpic(position, pic, scale, rgb, alpha * fadelerp, flag);
465 void drawstring_expanding(vector position, string text, vector scale, vector rgb, float alpha, float flag, float fadelerp)
468 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
470 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0);
471 drawstring(position + expandingbox_resize_centered_box_offset(sz, scale, stringwidth(text, FALSE)), text, scale * sz, rgb, alpha * (1 - fadelerp), flag);
474 void drawcolorcodedstring_expanding(vector position, string text, vector scale, float alpha, float flag, float fadelerp)
477 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
479 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0);
480 drawcolorcodedstring(position + expandingbox_resize_centered_box_offset(sz, scale, stringwidth(text, TRUE)), text, scale * sz, alpha * (1 - fadelerp), flag);