1 float previous_announcement_time;
2 float previous_game_starttime;
3 string previous_announcement;
5 // remaining maptime announcer sounds, true when sound was already played
9 void Announcer_Play(string announcement)
11 if((announcement != previous_announcement) || (time >= (previous_announcement_time + autocvar_cl_announcer_antispam)))
13 sound(world, CH_INFO, strcat("announcer/", autocvar_cl_announcer, "/", announcement, ".wav"), VOL_BASEVOICE, ATTN_NONE);
15 if(previous_announcement) { strunzone(previous_announcement); }
17 previous_announcement = strzone(announcement);
18 previous_announcement_time = time;
22 void Announcer_Countdown()
24 float starttime = getstatf(STAT_GAMESTARTTIME);
25 float countdown = (starttime - time);
26 float countdown_rounded = floor(0.5 + countdown);
28 if(countdown <= 0) // countdown has finished, starttime is now
30 if (!spectatee_status)
31 centerprint_generic(CPID_GAME_STARTING, _("^1Begin!"), 1, 0);
33 Announcer_Play("begin");
34 announcer_5min = announcer_1min = FALSE; // reset maptime announcers now as well
38 else // countdown is still going
40 if (!spectatee_status)
41 centerprint_generic(CPID_GAME_STARTING, _("^1Game starts in %d seconds"), 1, countdown_rounded);
43 if(countdown_rounded <= 3 && countdown_rounded >= 1)
44 Announcer_Play(ftos(countdown_rounded));
46 self.nextthink = (starttime - (countdown - 1));
51 * Checks whether the server initiated a map restart (stat_game_starttime changed)
53 * TODO: Use a better solution where a common shared entitiy is used that contains
54 * timelimit, fraglimit and game_starttime! Requires engine changes (remove STAT_TIMELIMIT
55 * and STAT_FRAGLIMIT to be auto-sent)
57 void Announcer_Gamestart()
59 float startTime = getstatf(STAT_GAMESTARTTIME);
61 if(previous_game_starttime != startTime)
63 if((time + 5.0) < startTime) // if connecting to server while restart was active don't always play prepareforbattle
64 Announcer_Play("prepareforbattle");
70 e.think = Announcer_Countdown;
71 e.nextthink = startTime - floor(startTime - time); //synchronize nextthink to startTime
75 previous_game_starttime = startTime;
79 // Plays the 1 minute or 5 minutes (of maptime) remaining sound, if client wants it
82 float timelimit = getstatf(STAT_TIMELIMIT);
83 float timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
84 float warmup_timeleft;
87 if(autocvar_g_warmup_limit > 0)
88 warmup_timeleft = max(0, autocvar_g_warmup_limit + getstatf(STAT_GAMESTARTTIME) - time);
91 if(autocvar_cl_announcer_maptime >= 2)
93 // make sure that after connect (and e.g. 4 minutes left) we will not get a wrong sound
96 if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timeleft > 300)
97 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft > 300))
98 announcer_5min = FALSE;
102 if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timelimit > 0 && timeleft < 300 && timeleft > 299)
103 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft < 300 && warmup_timeleft > 299))
105 //if we're in warmup mode, check whether there's a warmup timelimit
106 if not(autocvar_g_warmup_limit == -1 && warmup_stage)
108 announcer_5min = TRUE;
109 Announcer_Play("5minutesremain");
116 if((autocvar_cl_announcer_maptime == 1) || (autocvar_cl_announcer_maptime == 3))
120 if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timeleft > 60)
121 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft > 60))
122 announcer_1min = FALSE;
124 else if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timelimit > 0 && timeleft < 60)
125 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft < 60))
127 // if we're in warmup mode, check whether there's a warmup timelimit
128 if not(autocvar_g_warmup_limit == -1 && warmup_stage)
130 announcer_1min = TRUE;
131 Announcer_Play("1minuteremains");
139 Announcer_Gamestart();
143 void Announcer_Precache ()
145 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/1minuteremains.wav"));
146 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/5minutesremain.wav"));
148 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/electrobitch.wav"));
149 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/airshot.wav"));
150 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/03kills.wav"));
151 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/05kills.wav"));
152 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/10kills.wav"));
153 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/15kills.wav"));
154 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/20kills.wav"));
155 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/25kills.wav"));
156 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/30kills.wav"));
157 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/botlike.wav"));
158 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/yoda.wav"));
159 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/amazing.wav"));
160 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/awesome.wav"));
161 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/headshot.wav"));
162 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/impressive.wav"));
164 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/prepareforbattle.wav"));
165 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/begin.wav"));
166 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/timeoutcalled.wav"));
167 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/1fragleft.wav"));
168 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/2fragsleft.wav"));
169 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/3fragsleft.wav"));
170 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/terminated.wav"));
172 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/1.wav"));
173 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/2.wav"));
174 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/3.wav"));
175 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/4.wav"));
176 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/5.wav"));
177 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/6.wav"));
178 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/7.wav"));
179 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/8.wav"));
180 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/9.wav"));
181 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/10.wav"));
183 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/lastsecond.wav"));
184 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/narrowly.wav"));
186 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/voteaccept.wav"));
187 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/votecall.wav"));
188 precache_sound (strcat("announcer/", autocvar_cl_announcer, "/votefail.wav"));