3 void Announcer_Countdown()
5 float starttime = getstatf(STAT_GAMESTARTTIME);
6 float roundstarttime = getstatf(STAT_ROUNDSTARTTIME);
7 if(roundstarttime == -1)
9 Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_ROUNDSTOP);
13 if(roundstarttime >= starttime)
14 starttime = roundstarttime;
15 if(starttime <= time && roundstarttime != starttime) // game start time has passed
16 announcer_5min = announcer_1min = FALSE; // reset maptime announcers now as well
18 float countdown = (starttime - time);
19 float countdown_rounded = floor(0.5 + countdown);
21 if(countdown <= 0) // countdown has finished, starttime is now
23 Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_BEGIN);
24 Local_Notification(MSG_MULTI, MULTI_COUNTDOWN_BEGIN);
28 else // countdown is still going
30 // if concomitant countdown to round start overrides countdown to game start
31 if(roundstarttime == starttime)
33 Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_ROUNDSTART, countdown_rounded);
34 Local_Notification(MSG_ANNCE, Announcer_PickNumber(CNT_ROUNDSTART, countdown_rounded));
38 Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_GAMESTART, countdown_rounded);
39 Local_Notification(MSG_ANNCE, Announcer_PickNumber(CNT_GAMESTART, countdown_rounded));
42 self.nextthink = (starttime - (countdown - 1));
47 * Checks whether the server initiated a map restart (stat_game_starttime changed)
49 * TODO: Use a better solution where a common shared entitiy is used that contains
50 * timelimit, fraglimit and game_starttime! Requires engine changes (remove STAT_TIMELIMIT
51 * and STAT_FRAGLIMIT to be auto-sent)
53 float previous_game_starttime;
54 void Announcer_Gamestart()
56 float startTime = getstatf(STAT_GAMESTARTTIME);
57 float roundstarttime = getstatf(STAT_ROUNDSTARTTIME);
58 if(roundstarttime > startTime)
59 startTime = roundstarttime;
61 if(previous_game_starttime != startTime)
65 entity e = find(world, classname, "announcer_countdown");
69 e.classname = "announcer_countdown";
70 e.think = Announcer_Countdown;
73 if(time + 5.0 < startTime) // if connecting to server while restart was active don't always play prepareforbattle
74 if(time > e.nextthink) // don't play it again if countdown was already going
75 Local_Notification(MSG_ANNCE, ANNCE_PREPARE);
77 e.nextthink = startTime - floor(startTime - time); //synchronize nextthink to startTime
81 previous_game_starttime = startTime;
85 // Plays the 1 minute or 5 minutes (of maptime) remaining sound, if client wants it
88 float timelimit = getstatf(STAT_TIMELIMIT);
89 float timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
90 float warmup_timeleft = 0;
93 if(autocvar_g_warmup_limit > 0)
94 warmup_timeleft = max(0, autocvar_g_warmup_limit + getstatf(STAT_GAMESTARTTIME) - time);
97 if(autocvar_cl_announcer_maptime >= 2)
99 // make sure that after connect (and e.g. 4 minutes left) we will not get a wrong sound
102 if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timeleft > 300)
103 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft > 300))
104 announcer_5min = FALSE;
108 if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timelimit > 0 && timeleft < 300 && timeleft > 299)
109 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft < 300 && warmup_timeleft > 299))
111 //if we're in warmup mode, check whether there's a warmup timelimit
112 if(!(autocvar_g_warmup_limit == -1 && warmup_stage))
114 announcer_5min = TRUE;
115 Local_Notification(MSG_ANNCE, ANNCE_REMAINING_MIN_5);
122 if((autocvar_cl_announcer_maptime == 1) || (autocvar_cl_announcer_maptime == 3))
126 if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timeleft > 60)
127 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft > 60))
128 announcer_1min = FALSE;
130 else if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timelimit > 0 && timeleft < 60)
131 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft < 60))
133 // if we're in warmup mode, check whether there's a warmup timelimit
134 if(!(autocvar_g_warmup_limit == -1 && warmup_stage))
136 announcer_1min = TRUE;
137 Local_Notification(MSG_ANNCE, ANNCE_REMAINING_MIN_1);
145 Announcer_Gamestart();