1 void Announcer_Play(string announcement)
3 /*if((announcement != previous_announcement) || (time >= (previous_announcement_time + autocvar_cl_announcer_antispam)))
5 sound(world, CH_INFO, strcat("announcer/", autocvar_cl_announcer, "/", announcement, ".wav"), VOL_BASEVOICE, ATTN_NONE);
7 if(previous_announcement) { strunzone(previous_announcement); }
9 previous_announcement = strzone(announcement);
10 previous_announcement_time = time;
16 void Announcer_Countdown()
18 float starttime = getstatf(STAT_GAMESTARTTIME);
19 float countdown = (starttime - time);
20 float countdown_rounded = floor(0.5 + countdown);
22 if(countdown <= 0) // countdown has finished, starttime is now
24 Local_Notification(MSG_MULTI, MULTI_COUNTDOWN_BEGIN);
25 announcer_5min = announcer_1min = FALSE; // reset maptime announcers now as well
29 else // countdown is still going
31 Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_GAMESTART, countdown_rounded);
33 switch(countdown_rounded)
35 case 1: Local_Notification(MSG_ANNCE, ANNCE_NUM_1); break;
36 case 2: Local_Notification(MSG_ANNCE, ANNCE_NUM_2); break;
37 case 3: Local_Notification(MSG_ANNCE, ANNCE_NUM_3); break;
40 self.nextthink = (starttime - (countdown - 1));
45 * Checks whether the server initiated a map restart (stat_game_starttime changed)
47 * TODO: Use a better solution where a common shared entitiy is used that contains
48 * timelimit, fraglimit and game_starttime! Requires engine changes (remove STAT_TIMELIMIT
49 * and STAT_FRAGLIMIT to be auto-sent)
51 float previous_game_starttime;
52 void Announcer_Gamestart()
54 float startTime = getstatf(STAT_GAMESTARTTIME);
56 if(previous_game_starttime != startTime)
58 if((time + 5.0) < startTime) // if connecting to server while restart was active don't always play prepareforbattle
59 Local_Notification(MSG_ANNCE, ANNCE_PREPARE);
65 e.think = Announcer_Countdown;
66 e.nextthink = startTime - floor(startTime - time); //synchronize nextthink to startTime
70 previous_game_starttime = startTime;
74 // Plays the 1 minute or 5 minutes (of maptime) remaining sound, if client wants it
77 float timelimit = getstatf(STAT_TIMELIMIT);
78 float timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
79 float warmup_timeleft = 0;
82 if(autocvar_g_warmup_limit > 0)
83 warmup_timeleft = max(0, autocvar_g_warmup_limit + getstatf(STAT_GAMESTARTTIME) - time);
86 if(autocvar_cl_announcer_maptime >= 2)
88 // make sure that after connect (and e.g. 4 minutes left) we will not get a wrong sound
91 if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timeleft > 300)
92 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft > 300))
93 announcer_5min = FALSE;
97 if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timelimit > 0 && timeleft < 300 && timeleft > 299)
98 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft < 300 && warmup_timeleft > 299))
100 //if we're in warmup mode, check whether there's a warmup timelimit
101 if not(autocvar_g_warmup_limit == -1 && warmup_stage)
103 announcer_5min = TRUE;
104 Local_Notification(MSG_ANNCE, ANNCE_REMAINING_MIN_5);
111 if((autocvar_cl_announcer_maptime == 1) || (autocvar_cl_announcer_maptime == 3))
115 if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timeleft > 60)
116 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft > 60))
117 announcer_1min = FALSE;
119 else if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timelimit > 0 && timeleft < 60)
120 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft < 60))
122 // if we're in warmup mode, check whether there's a warmup timelimit
123 if not(autocvar_g_warmup_limit == -1 && warmup_stage)
125 announcer_1min = TRUE;
126 Local_Notification(MSG_ANNCE, ANNCE_REMAINING_MIN_1);
134 Announcer_Gamestart();