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)
31 Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_ROUNDSTART, countdown_rounded);
33 Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_GAMESTART, countdown_rounded);
35 switch(countdown_rounded)
37 case 1: Local_Notification(MSG_ANNCE, ANNCE_NUM_1); break;
38 case 2: Local_Notification(MSG_ANNCE, ANNCE_NUM_2); break;
39 case 3: Local_Notification(MSG_ANNCE, ANNCE_NUM_3); break;
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)
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);
68 entity e = find(world, classname, "announcer_countdown");
72 e.classname = "announcer_countdown";
73 e.think = Announcer_Countdown;
75 e.nextthink = startTime - floor(startTime - time); //synchronize nextthink to startTime
79 previous_game_starttime = startTime;
83 // Plays the 1 minute or 5 minutes (of maptime) remaining sound, if client wants it
86 float timelimit = getstatf(STAT_TIMELIMIT);
87 float timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
88 float warmup_timeleft = 0;
91 if(autocvar_g_warmup_limit > 0)
92 warmup_timeleft = max(0, autocvar_g_warmup_limit + getstatf(STAT_GAMESTARTTIME) - time);
95 if(autocvar_cl_announcer_maptime >= 2)
97 // make sure that after connect (and e.g. 4 minutes left) we will not get a wrong sound
100 if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timeleft > 300)
101 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft > 300))
102 announcer_5min = FALSE;
106 if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timelimit > 0 && timeleft < 300 && timeleft > 299)
107 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft < 300 && warmup_timeleft > 299))
109 //if we're in warmup mode, check whether there's a warmup timelimit
110 if not(autocvar_g_warmup_limit == -1 && warmup_stage)
112 announcer_5min = TRUE;
113 Local_Notification(MSG_ANNCE, ANNCE_REMAINING_MIN_5);
120 if((autocvar_cl_announcer_maptime == 1) || (autocvar_cl_announcer_maptime == 3))
124 if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timeleft > 60)
125 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft > 60))
126 announcer_1min = FALSE;
128 else if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timelimit > 0 && timeleft < 60)
129 || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft < 60))
131 // if we're in warmup mode, check whether there's a warmup timelimit
132 if not(autocvar_g_warmup_limit == -1 && warmup_stage)
134 announcer_1min = TRUE;
135 Local_Notification(MSG_ANNCE, ANNCE_REMAINING_MIN_1);
143 Announcer_Gamestart();