1 void round_handler_Think()
6 if(time < game_starttime)
9 round_handler_ResetCountdown();
10 self.nextthink = game_starttime + 1;
16 round_handler_ResetCountdown();
17 round_handler_Remove();
25 self.cnt = self.count + 1; // init countdown
28 if(self.cnt > 0) // countdown running
30 if(self.canRoundStart())
33 if(f == 5) Announce("prepareforbattle");
34 else if(f == 3) Announce("3");
35 else if(f == 2) Announce("2");
36 else if(f == 1) Announce("1");
40 FOR_EACH_REALCLIENT(e)
41 Send_CSQC_Centerprint_Generic(e, CPID_ROUND_STARTING, "^1Begin!", 1, 0);
43 self.nextthink = time;
47 FOR_EACH_REALCLIENT(e)
48 Send_CSQC_Centerprint_Generic(e, CPID_ROUND_STARTING, "Round will start in %d", 1, f);
49 self.cnt = self.cnt - 1;
53 round_handler_ResetCountdown();
55 self.nextthink = time + 1; // canRoundStart every second
59 if(self.canRoundEnd())
61 // schedule a new round
63 self.nextthink = time + self.delay;
67 self.nextthink = time; // canRoundEnd every frame
72 void round_handler_Spawn(float() canRoundStart_func, float() canRoundEnd_func, float the_delay, float the_count)
76 backtrace("Can't spawn round_handler again!");
79 round_handler = spawn();
80 round_handler.classname = "round_handler";
82 round_handler.think = round_handler_Think;
83 round_handler.canRoundStart = canRoundStart_func;
84 round_handler.canRoundEnd = canRoundEnd_func;
85 round_handler.delay = (the_delay > 0) ? the_delay : 0;
86 round_handler.count = fabs(floor(the_count));
87 round_handler.wait = FALSE;
88 round_handler.cnt = round_handler.count + 1;
89 round_handler.nextthink = time;
92 float round_handler_IsActive()
94 return (round_handler && time > game_starttime);
97 float round_handler_AwaitingNextRound()
99 return (round_handler.wait);
102 float round_handler_CountdownRunning()
104 return (!round_handler.wait && round_handler.cnt);
107 float round_handler_IsRoundStarted()
109 return (!round_handler.wait && !round_handler.cnt);
112 void round_handler_ResetCountdown()
115 if(round_handler.count)
116 if(round_handler.cnt < round_handler.count + 1)
118 FOR_EACH_REALCLIENT(e)
119 Send_CSQC_Centerprint_Generic_Expire(e, CPID_ROUND_STARTING);
120 round_handler.cnt = round_handler.count + 1;
124 void round_handler_Remove()
126 remove(round_handler);
127 round_handler = world;