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);
45 warmuplimit = cvar("g_warmup_limit");
47 warmuptimeleft = max(0, warmuplimit + getstatf(STAT_GAMESTARTTIME) - time);
52 if (cvar("cl_sound_maptime_warning") >= 2) {
53 //make sure that after connect (and e.g. 4 minutes left) we will not get a wrong sound
56 if(((!warmup_stage || warmuplimit == 0) && timeleft > 300) || (warmup_stage && warmuplimit > 0 && warmuptimeleft > 300))
57 announcer_5min = FALSE;
59 else if (((!warmup_stage || warmuplimit == 0) && timelimit > 0 && timeleft < 300 && timeleft > 299) || (warmup_stage && warmuplimit > 0 && warmuptimeleft < 300 && warmuptimeleft > 299))
60 //if we're in warmup mode, check whether there's a warmup timelimit
61 if not (warmuplimit == -1 && warmup_stage) {
62 announcer_5min = TRUE;
63 //dprint("i will play the sound, I promise!\n");
64 sound(self, CHAN_VOICE, "announcer/robotic/5minutesremain.wav", VOL_BASEVOICE, ATTN_NONE);
69 if (cvar("cl_sound_maptime_warning") == 1 || cvar("cl_sound_maptime_warning") == 3) {
72 if(((!warmup_stage || warmuplimit == 0) && timeleft > 60) || (warmup_stage && warmuplimit > 0 && warmuptimeleft > 60))
73 announcer_1min = FALSE;
75 else if (((!warmup_stage || warmuplimit == 0) && timelimit > 0 && timeleft < 60) || (warmup_stage && warmuplimit > 0 && warmuptimeleft < 60))
76 //if we're in warmup mode, check whether there's a warmup timelimit
77 if not (warmuplimit == -1 && warmup_stage) {
78 announcer_1min = TRUE;
79 sound(self, CHAN_VOICE, "announcer/robotic/1minuteremains.wav", VOL_BASEVOICE, ATTN_NONE);
85 * Announce carried items (e.g. flags in CTF).
89 void carrierAnnouncer() {
90 float stat_items, redflag, blueflag;
94 if not(cvar("cl_notify_carried_items"))
97 stat_items = getstati(STAT_ITEMS);
99 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
100 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
102 if (redflag == 3 && redflag != redflag_prev) {
103 item = "^1RED^7 flag";
104 pickup = (redflag_prev == 2);
107 if (blueflag == 3 && blueflag != blueflag_prev) {
108 item = "^4BLUE^7 flag";
109 pickup = (blueflag_prev == 2);
115 if (cvar("cl_notify_carried_items") & 2)
116 centerprint(strcat("You picked up the ", item, "!"));
119 if (cvar("cl_notify_carried_items") & 1)
120 centerprint(strcat("You got the ", item, "!"));
124 blueflag_prev = blueflag;
125 redflag_prev = redflag;
129 * Add all future announcer sounds precaches here.
130 * TODO: make all announcer sound() calls client-side in the end, to allow queues etc.
134 * Add all future announcer sounds precaches here.
135 * TODO: make all announcer sound() calls client-side in the end, to allow queues etc.
137 void Announcer_Precache () {
138 precache_sound ("announcer/robotic/1minuteremains.wav");
139 precache_sound ("announcer/robotic/5minutesremain.wav");
148 for(e = prev.sort_next; e; prev = e, e = e.sort_next)
150 if(prev != e.sort_prev)
151 error(strcat("sort list chain error\nplease submit the output of 'prvm_edicts client' to the developers"));
155 for(e = prev.sort_next; e; prev = e, e = e.sort_next)
157 if(prev != e.sort_prev)
158 error(strcat("sort list chain error\nplease submit the output of 'prvm_edicts client' to the developers"));
163 float RegisterPlayer(entity player)
167 for(pl = players.sort_next; pl; pl = pl.sort_next)
169 error("Player already registered!");
170 player.sort_next = players.sort_next;
171 player.sort_prev = players;
172 if(players.sort_next)
173 players.sort_next.sort_prev = player;
174 players.sort_next = player;
179 void RemovePlayer(entity player)
184 for(pl = players.sort_next; pl && pl != player; pl = pl.sort_next)
189 error("Trying to remove a player which is not in the playerlist!");
192 parent.sort_next = player.sort_next;
194 player.sort_next.sort_prev = parent;
198 void MoveToLast(entity e)
210 float RegisterTeam(entity Team)
214 for(tm = teams.sort_next; tm; tm = tm.sort_next)
216 error("Team already registered!");
217 Team.sort_next = teams.sort_next;
218 Team.sort_prev = teams;
220 teams.sort_next.sort_prev = Team;
221 teams.sort_next = Team;
226 void RemoveTeam(entity Team)
231 for(tm = teams.sort_next; tm && tm != Team; tm = tm.sort_next)
236 print("Trying to remove a team which is not in the teamlist!");
239 parent.sort_next = Team.sort_next;
241 Team.sort_next.sort_prev = parent;
245 entity GetTeam(float Team, float add)
249 num = (Team == COLOR_SPECTATOR) ? 16 : Team;
251 return teamslots[num];
261 void CSQC_CheckEngine()
263 sbar_font = FONT_USER+1;
264 sbar_bigfont = FONT_USER+2;
267 vector Sbar_GetFontsize(string cvarname)
270 v = stov(cvar_string(cvarname));
279 float Sbar_GetWidth(float teamcolumnwidth)
282 f = cvar("sbar_width");
287 if(f > vid_conwidth - 2 * teamcolumnwidth)
288 f = vid_conwidth - 2 * teamcolumnwidth;
292 float PreviewExists(string name)
297 if(cvar("cl_readpicture_force"))
300 file = strcat(name, ".tga");
301 f = fopen(file, FILE_READ);
307 file = strcat(name, ".png");
308 f = fopen(file, FILE_READ);
314 file = strcat(name, ".jpg");
315 f = fopen(file, FILE_READ);
321 file = strcat(name, ".pcx");
322 f = fopen(file, FILE_READ);
331 vector rotate(vector v, float a)
334 // FTEQCC SUCKS AGAIN
335 w_x = v_x * cos(a) + v_y * sin(a);
336 w_y = -1 * v_x * sin(a) + v_y * cos(a);
340 float ColorTranslateMode;
342 string ColorTranslateRGB(string s)
344 if(ColorTranslateMode & 1)
345 return strdecolorize(s);
350 float cvar_or(string cv, float v)
360 vector project_3d_to_2d(vector vec)
362 vec = cs_project(vec);
363 if(cs_project_is_b0rked > 0)
365 vec_x *= vid_conwidth / vid_width;
366 vec_y *= vid_conheight / vid_height;
371 void dummyfunction(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8)
375 float expandingbox_sizefactor_from_fadelerp(float fadelerp)
377 return 1.2 / (1.2 - fadelerp);
380 vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float boxxsizefactor)
382 boxsize_x *= boxxsizefactor; // easier interface for text
383 return boxsize * (0.5 * (1 - sz));
386 void drawborderlines(float thickness, vector pos, vector dim, vector color, float alpha, float drawflag)
390 // left and right lines
392 line_dim_x = thickness;
394 drawfill(pos, line_dim, color, alpha, drawflag);
395 drawfill(pos + (dim_x + thickness) * '1 0 0', line_dim, color, alpha, drawflag);
397 // upper and lower lines
399 line_dim_x = dim_x + thickness * 2; // make upper and lower lines longer
400 line_dim_y = thickness;
401 drawfill(pos, line_dim, color, alpha, drawflag);
402 drawfill(pos + (dim_y + thickness) * '0 1 0', line_dim, color, alpha, drawflag);
405 void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, float alpha, float drawflag)
407 vector current_pos, end_pos, new_size, ratio;
408 end_pos = pos + area;
410 current_pos_y = pos_y;
411 while (current_pos_y < end_pos_y)
413 current_pos_x = pos_x;
414 while (current_pos_x < end_pos_x)
416 new_size_x = min(sz_x, end_pos_x - current_pos_x);
417 new_size_y = min(sz_y, end_pos_y - current_pos_y);
418 ratio_x = new_size_x / sz_x;
419 ratio_y = new_size_y / sz_y;
420 drawsubpic(current_pos, new_size, pic, '0 0 0', ratio, color, alpha, drawflag);
421 current_pos_x += sz_x;
423 current_pos_y += sz_y;
427 void drawpic_expanding(vector position, string pic, vector scale, vector rgb, float alpha, float flag, float fadelerp)
430 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
432 drawpic(position + expandingbox_resize_centered_box_offset(sz, scale, 1), pic, scale * sz, rgb, alpha * (1 - fadelerp), flag);
435 void drawpic_expanding_two(vector position, string pic, vector scale, vector rgb, float alpha, float flag, float fadelerp)
437 drawpic_expanding(position, pic, scale, rgb, alpha, flag, fadelerp);
438 drawpic(position, pic, scale, rgb, alpha * fadelerp, flag);
441 vector drawfontscale;
442 void drawstring_expanding(vector position, string text, vector scale, vector rgb, float alpha, float flag, float fadelerp)
445 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
447 if(cvar("menu_font_size_snapping_fix"))
448 drawfontscale = sz * '1 1 0';
450 drawfontscale = '1 1 0';
451 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0);
452 drawstring(position + expandingbox_resize_centered_box_offset(sz, scale, stringwidth(text, FALSE) / drawfontscale_x), text, scale * (sz / drawfontscale_x), rgb, alpha * (1 - fadelerp), flag);
453 if(cvar("menu_font_size_snapping_fix"))
454 drawfontscale = '1 1 0';
457 void drawcolorcodedstring_expanding(vector position, string text, vector scale, float alpha, float flag, float fadelerp)
460 sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
462 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0);
463 drawcolorcodedstring(position + expandingbox_resize_centered_box_offset(sz, scale, stringwidth(text, TRUE)), text, scale * sz, alpha * (1 - fadelerp), flag);