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 roundstarttime = getstatf(STAT_ROUNDSTARTTIME);
20 if(roundstarttime == -1)
22 Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_ROUNDSTOP);
26 if(roundstarttime >= starttime)
27 starttime = roundstarttime;
28 if(starttime <= time && roundstarttime != starttime) // game start time has passed
29 announcer_5min = announcer_1min = FALSE; // reset maptime announcers now as well
31 float countdown = (starttime - time);
32 float countdown_rounded = floor(0.5 + countdown);
34 if(countdown <= 0) // countdown has finished, starttime is now
36 Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_BEGIN);
37 Local_Notification(MSG_MULTI, MULTI_COUNTDOWN_BEGIN);
41 else // countdown is still going
43 if(roundstarttime == starttime)
44 Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_ROUNDSTART, countdown_rounded);
46 Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_GAMESTART, countdown_rounded);
48 switch(countdown_rounded)
50 case 1: Local_Notification(MSG_ANNCE, ANNCE_NUM_1); break;
51 case 2: Local_Notification(MSG_ANNCE, ANNCE_NUM_2); break;
52 case 3: Local_Notification(MSG_ANNCE, ANNCE_NUM_3); break;
55 self.nextthink = (starttime - (countdown - 1));
60 * Checks whether the server initiated a map restart (stat_game_starttime changed)
62 * TODO: Use a better solution where a common shared entitiy is used that contains
63 * timelimit, fraglimit and game_starttime! Requires engine changes (remove STAT_TIMELIMIT
64 * and STAT_FRAGLIMIT to be auto-sent)
66 float previous_game_starttime;
67 void Announcer_Gamestart()
69 float startTime = getstatf(STAT_GAMESTARTTIME);
70 float roundstarttime = getstatf(STAT_ROUNDSTARTTIME);
71 if(roundstarttime > startTime)
72 startTime = roundstarttime;
74 if(previous_game_starttime != startTime)
76 if((time + 5.0) < startTime) // if connecting to server while restart was active don't always play prepareforbattle
77 Local_Notification(MSG_ANNCE, ANNCE_PREPARE);
81 entity e = find(world, classname, "announcer_countdown");
85 e.classname = "announcer_countdown";
86 e.think = Announcer_Countdown;
88 e.nextthink = startTime - floor(startTime - time); //synchronize nextthink to startTime
92 previous_game_starttime = startTime;
96 // Plays the 1 minute or 5 minutes (of maptime) remaining sound, if client wants it
99 float timelimit = getstatf(STAT_TIMELIMIT);
100 float timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
101 float warmup_timeleft = 0;
104 if(autocvar_g_warmup_limit > 0)
105 warmup_timeleft = max(0, autocvar_g_warmup_limit + getstatf(STAT_GAMESTARTTIME) - time);
108 if(autocvar_cl_announcer_maptime >= 2)
110 // make sure that after connect (and e.g. 4 minutes left) we will not get a wrong sound
113 if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timeleft > 300)
114 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft > 300))
115 announcer_5min = FALSE;
119 if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timelimit > 0 && timeleft < 300 && timeleft > 299)
120 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft < 300 && warmup_timeleft > 299))
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_5min = TRUE;
126 Local_Notification(MSG_ANNCE, ANNCE_REMAINING_MIN_5);
133 if((autocvar_cl_announcer_maptime == 1) || (autocvar_cl_announcer_maptime == 3))
137 if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timeleft > 60)
138 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft > 60))
139 announcer_1min = FALSE;
141 else if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timelimit > 0 && timeleft < 60)
142 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft < 60))
144 // if we're in warmup mode, check whether there's a warmup timelimit
145 if not(autocvar_g_warmup_limit == -1 && warmup_stage)
147 announcer_1min = TRUE;
148 Local_Notification(MSG_ANNCE, ANNCE_REMAINING_MIN_1);
156 Announcer_Gamestart();