1 void round_handler_Think()
6 if(time <= game_starttime)
8 round_handler_Reset(game_starttime + 1);
14 round_handler_Reset(0);
15 round_handler_Remove();
23 self.cnt = self.count + 1; // init countdown
26 if(self.cnt > 0) // countdown running
28 if(self.canRoundStart())
31 if(f == 5) Announce("prepareforbattle");
32 else if(f == 3) Announce("3");
33 else if(f == 2) Announce("2");
34 else if(f == 1) Announce("1");
38 FOR_EACH_REALCLIENT(e)
39 Send_CSQC_Centerprint_Generic(e, CPID_ROUND_STARTING, "^1Begin!", 1, 0);
41 self.round_endtime = time + self.round_timelimit;
42 self.nextthink = time;
46 FOR_EACH_REALCLIENT(e)
47 Send_CSQC_Centerprint_Generic(e, CPID_ROUND_STARTING, "Round will start in %d", 1, f);
48 self.cnt = self.cnt - 1;
52 round_handler_Reset(0);
54 self.nextthink = time + 1; // canRoundStart every second
58 if(self.canRoundEnd())
60 // schedule a new round
62 self.nextthink = time + self.delay;
66 self.nextthink = time; // canRoundEnd every frame
71 void round_handler_Spawn(float() canRoundStart_func, float() canRoundEnd_func, float the_delay, float the_count, float the_round_timelimit)
75 backtrace("Can't spawn round_handler again!");
78 round_handler = spawn();
79 round_handler.classname = "round_handler";
81 round_handler.think = round_handler_Think;
82 round_handler.canRoundStart = canRoundStart_func;
83 round_handler.canRoundEnd = canRoundEnd_func;
84 round_handler.delay = (the_delay > 0) ? the_delay : 0;
85 round_handler.count = fabs(floor(the_count));
86 round_handler.wait = FALSE;
87 round_handler.cnt = round_handler.count + 1;
88 round_handler.round_timelimit = the_round_timelimit;
89 round_handler.nextthink = max(time, game_starttime + 1);
92 float round_handler_IsActive()
94 return (round_handler != world);
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 float round_handler_GetTimeLeft()
114 return (round_handler.round_endtime - time);
117 void round_handler_Reset(float next_think)
120 round_handler.wait = FALSE;
121 if(round_handler.count)
122 if(round_handler.cnt < round_handler.count + 1)
124 FOR_EACH_REALCLIENT(e)
125 Send_CSQC_Centerprint_Generic_Expire(e, CPID_ROUND_STARTING);
126 round_handler.cnt = round_handler.count + 1;
128 round_handler.nextthink = next_think;
131 void round_handler_Remove()
133 remove(round_handler);
134 round_handler = world;