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 Local_Notification(MSG_MULTI, MULTI_COUNTDOWN_BEGIN);
31 announcer_5min = announcer_1min = FALSE; // reset maptime announcers now as well
35 else // countdown is still going
37 Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_GAMESTART, countdown_rounded);
39 switch(countdown_rounded)
41 case 1: Local_Notification(MSG_ANNCE, ANNCE_NUM_1); break;
42 case 2: Local_Notification(MSG_ANNCE, ANNCE_NUM_2); break;
43 case 3: Local_Notification(MSG_ANNCE, ANNCE_NUM_3); break;
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 Local_Notification(MSG_ANNCE, ANNCE_PREPARE);
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 = 0;
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 Local_Notification(MSG_ANNCE, ANNCE_REMAINING_MIN_5);
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 Local_Notification(MSG_ANNCE, ANNCE_REMAINING_MIN_1);
139 Announcer_Gamestart();
143 void Announcer_Precache ()