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(roundstarttime == starttime)
32 Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_ROUNDSTART, countdown_rounded);
33 Local_Notification(MSG_ANNCE, Announcer_PickNumber(CNT_ROUNDSTART, countdown_rounded));
37 Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_GAMESTART, countdown_rounded);
38 Local_Notification(MSG_ANNCE, Announcer_PickNumber(CNT_GAMESTART, countdown_rounded));
41 self.nextthink = (starttime - (countdown - 1));
46 * Checks whether the server initiated a map restart (stat_game_starttime changed)
48 * TODO: Use a better solution where a common shared entitiy is used that contains
49 * timelimit, fraglimit and game_starttime! Requires engine changes (remove STAT_TIMELIMIT
50 * and STAT_FRAGLIMIT to be auto-sent)
52 float previous_game_starttime;
53 void Announcer_Gamestart()
55 float startTime = getstatf(STAT_GAMESTARTTIME);
56 float roundstarttime = getstatf(STAT_ROUNDSTARTTIME);
57 if(roundstarttime > startTime)
58 startTime = roundstarttime;
60 if(previous_game_starttime != startTime)
62 if((time + 5.0) < startTime) // if connecting to server while restart was active don't always play prepareforbattle
63 Local_Notification(MSG_ANNCE, ANNCE_PREPARE);
67 entity e = find(world, classname, "announcer_countdown");
71 e.classname = "announcer_countdown";
72 e.think = Announcer_Countdown;
74 e.nextthink = startTime - floor(startTime - time); //synchronize nextthink to startTime
78 previous_game_starttime = startTime;
82 // Plays the 1 minute or 5 minutes (of maptime) remaining sound, if client wants it
85 float timelimit = getstatf(STAT_TIMELIMIT);
86 float timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
87 float warmup_timeleft = 0;
90 if(autocvar_g_warmup_limit > 0)
91 warmup_timeleft = max(0, autocvar_g_warmup_limit + getstatf(STAT_GAMESTARTTIME) - time);
94 if(autocvar_cl_announcer_maptime >= 2)
96 // make sure that after connect (and e.g. 4 minutes left) we will not get a wrong sound
99 if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timeleft > 300)
100 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft > 300))
101 announcer_5min = FALSE;
105 if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timelimit > 0 && timeleft < 300 && timeleft > 299)
106 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft < 300 && warmup_timeleft > 299))
108 //if we're in warmup mode, check whether there's a warmup timelimit
109 if(!(autocvar_g_warmup_limit == -1 && warmup_stage))
111 announcer_5min = TRUE;
112 Local_Notification(MSG_ANNCE, ANNCE_REMAINING_MIN_5);
119 if((autocvar_cl_announcer_maptime == 1) || (autocvar_cl_announcer_maptime == 3))
123 if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timeleft > 60)
124 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft > 60))
125 announcer_1min = FALSE;
127 else if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timelimit > 0 && timeleft < 60)
128 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft < 60))
130 // if we're in warmup mode, check whether there's a warmup timelimit
131 if(!(autocvar_g_warmup_limit == -1 && warmup_stage))
133 announcer_1min = TRUE;
134 Local_Notification(MSG_ANNCE, ANNCE_REMAINING_MIN_1);
142 Announcer_Gamestart();