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);
15 //reset maptime announcers now as well
16 announcer_5min = announcer_1min = FALSE;
22 if (!spectatee_status) //do cprint only for players
23 centerprint(strcat("^1Game starts in ", ftos(countdown_rounded), " seconds"));
25 if(countdown_rounded <= 3 && countdown_rounded >= 1) {
26 sound(self, CHAN_VOICE, strcat("announcer/robotic/", ftos(countdown_rounded), ".wav"), VOL_BASEVOICE, ATTN_NONE);
29 self.nextthink = getstatf(STAT_GAMESTARTTIME) - (countdown - 1);
34 * Plays the 1minute or 5 minutes (of maptime) remaining sound, if client wants it
36 void maptimeAnnouncer() {
38 timelimit = getstatf(STAT_TIMELIMIT);
40 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
43 if (cvar("cl_sound_maptime_warning") >= 2) {
44 //make sure that after connect (and e.g. 4 minutes left) we will not get a wrong sound
45 if (!announcer_5min && timelimit > 0 && timeleft < 300 && timeleft > 299) {
46 announcer_5min = TRUE;
47 //dprint("i will play the sound, I promise!\n");
48 sound(self, CHAN_VOICE, "announcer/robotic/5minutesremain.wav", VOL_BASEVOICE, ATTN_NONE);
54 if (cvar("cl_sound_maptime_warning") == 1 || cvar("cl_sound_maptime_warning") == 3) {
55 if (!announcer_1min && timelimit > 0 && timeleft < 60) {
56 announcer_1min = TRUE;
57 sound(self, CHAN_VOICE, "announcer/robotic/1minuteremains.wav", VOL_BASEVOICE, ATTN_NONE);
63 * Add all future announcer sounds precaches here.
64 * TODO: make all announcer sound() calls client-side in the end, to allow queues etc.
66 void Announcer_Precache () {
67 precache_sound ("announcer/robotic/1minuteremains.wav");
68 precache_sound ("announcer/robotic/5minutesremain.wav");
77 for(e = prev.sort_next; e; prev = e, e = e.sort_next)
79 if(prev != e.sort_prev)
80 error(strcat("sort list chain error\nplease submit the output of 'prvm_edicts client' to the developers"));
84 for(e = prev.sort_next; e; prev = e, e = e.sort_next)
86 if(prev != e.sort_prev)
87 error(strcat("sort list chain error\nplease submit the output of 'prvm_edicts client' to the developers"));
92 float RegisterPlayer(entity player)
96 for(pl = players.sort_next; pl; pl = pl.sort_next)
98 error("Player already registered!");
99 player.sort_next = players.sort_next;
100 player.sort_prev = players;
101 if(players.sort_next)
102 players.sort_next.sort_prev = player;
103 players.sort_next = player;
108 void RemovePlayer(entity player)
113 for(pl = players.sort_next; pl && pl != player; pl = pl.sort_next)
118 error("Trying to remove a player which is not in the playerlist!");
121 parent.sort_next = player.sort_next;
123 player.sort_next.sort_prev = parent;
127 void MoveToLast(entity e)
139 float RegisterTeam(entity Team)
143 for(tm = teams.sort_next; tm; tm = tm.sort_next)
145 error("Team already registered!");
146 Team.sort_next = teams.sort_next;
147 Team.sort_prev = teams;
149 teams.sort_next.sort_prev = Team;
150 teams.sort_next = Team;
155 void RemoveTeam(entity Team)
160 for(tm = teams.sort_next; tm && tm != Team; tm = tm.sort_next)
165 print("Trying to remove a team which is not in the teamlist!");
168 parent.sort_next = Team.sort_next;
170 Team.sort_next.sort_prev = parent;
174 entity GetTeam(float Team, float add)
178 num = (Team == COLOR_SPECTATOR) ? 16 : Team;
180 return teamslots[num];
190 void CSQC_CheckEngine()
192 sbar_font = FONT_USER+1;
193 sbar_bigfont = FONT_USER+2;
196 vector Sbar_GetFontsize(string cvarname)
199 v = stov(cvar_string(cvarname));
208 float Sbar_GetWidth(float teamcolumnwidth)
211 f = stof(cvar_string("sbar_width"));
216 if(f > vid_conwidth - 2 * teamcolumnwidth)
217 f = vid_conwidth - 2 * teamcolumnwidth;
221 float PreviewExists(string name)
226 if(cvar("cl_readpicture_force"))
229 file = strcat(name, ".tga");
230 f = fopen(file, FILE_READ);
236 file = strcat(name, ".png");
237 f = fopen(file, FILE_READ);
243 file = strcat(name, ".jpg");
244 f = fopen(file, FILE_READ);
250 file = strcat(name, ".pcx");
251 f = fopen(file, FILE_READ);
260 float PI = 3.14159265359;
261 float DEG2RAD = 0.01745329252;
262 vector rotate(vector v, float a)
265 // FTEQCC SUCKS AGAIN
266 w_x = v_x * cos(a) + v_y * sin(a);
267 w_y = -1 * v_x * sin(a) + v_y * cos(a);
271 float ColorTranslateMode;
273 string ColorTranslateRGB(string s)
275 if(ColorTranslateMode & 1)
276 return strdecolorize(s);
281 float cvar_or(string cv, float v)
291 vector project_3d_to_2d(vector vec)
293 vec = cs_project(vec);
294 if(cs_project_is_b0rked)
296 vec_x += vid_width / 2;
297 vec_y += vid_height / 2;
299 vec_x *= vid_conwidth / vid_width;
300 vec_y *= vid_conheight / vid_height;
304 void dummyfunction(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8)
308 float expandingbox_sizefactor_from_fadelerp(float fadelerp)
310 return 1.2 / (1.2 - fadelerp);
313 vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float boxxsizefactor)
315 boxsize_x *= boxxsizefactor; // easier interface for text
316 return boxsize * (0.5 * (1 - sz));
319 void drawborderlines(float thickness, vector pos, vector dim, vector color, float alpha, float drawflag)
323 // left and right lines
325 line_dim_x = thickness;
327 drawfill(pos, line_dim, color, alpha, drawflag);
328 drawfill(pos + (dim_x + thickness) * '1 0 0', line_dim, color, alpha, drawflag);
330 // upper and lower lines
332 line_dim_x = dim_x + thickness * 2; // make upper and lower lines longer
333 line_dim_y = thickness;
334 drawfill(pos, line_dim, color, alpha, drawflag);
335 drawfill(pos + (dim_y + thickness) * '0 1 0', line_dim, color, alpha, drawflag);
338 void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, float alpha, float drawflag)
340 vector current_pos, end_pos, new_size, ratio;
341 end_pos = pos + area;
343 current_pos_y = pos_y;
344 while (current_pos_y < end_pos_y)
346 current_pos_x = pos_x;
347 while (current_pos_x < end_pos_x)
349 new_size_x = min(sz_x, end_pos_x - current_pos_x);
350 new_size_y = min(sz_y, end_pos_y - current_pos_y);
351 ratio_x = new_size_x / sz_x;
352 ratio_y = new_size_y / sz_y;
353 drawsubpic(current_pos, new_size, pic, '0 0 0', ratio, color, alpha, drawflag);
354 current_pos_x += sz_x;
356 current_pos_y += sz_y;
360 void drawpic_expanding(vector position, string pic, vector scale, vector rgb, float alpha, float flag, float fadelerp)
363 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
365 drawpic(position + expandingbox_resize_centered_box_offset(sz, scale, 1), pic, scale * sz, rgb, alpha * (1 - fadelerp), flag);
368 void drawpic_expanding_two(vector position, string pic, vector scale, vector rgb, float alpha, float flag, float fadelerp)
370 drawpic_expanding(position, pic, scale, rgb, alpha, flag, fadelerp);
371 drawpic(position, pic, scale, rgb, alpha * fadelerp, flag);
374 void drawstring_expanding(vector position, string text, vector scale, vector rgb, float alpha, float flag, float fadelerp)
377 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
379 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0);
380 drawstring(position + expandingbox_resize_centered_box_offset(sz, scale, stringwidth(text, FALSE)), text, scale * sz, rgb, alpha * (1 - fadelerp), flag);
383 void drawcolorcodedstring_expanding(vector position, string text, vector scale, float alpha, float flag, float fadelerp)
386 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
388 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0);
389 drawcolorcodedstring(position + expandingbox_resize_centered_box_offset(sz, scale, stringwidth(text, TRUE)), text, scale * sz, alpha * (1 - fadelerp), flag);