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.nextthink = time;
45 FOR_EACH_REALCLIENT(e)
46 Send_CSQC_Centerprint_Generic(e, CPID_ROUND_STARTING, "Round will start in %d", 1, f);
47 self.cnt = self.cnt - 1;
51 round_handler_Reset(0);
53 self.nextthink = time + 1; // canRoundStart every second
57 if(self.canRoundEnd())
59 // schedule a new round
61 self.nextthink = time + self.delay;
65 self.nextthink = time; // canRoundEnd every frame
70 void round_handler_Spawn(float() canRoundStart_func, float() canRoundEnd_func, float the_delay, float the_count)
74 backtrace("Can't spawn round_handler again!");
77 round_handler = spawn();
78 round_handler.classname = "round_handler";
80 round_handler.think = round_handler_Think;
81 round_handler.canRoundStart = canRoundStart_func;
82 round_handler.canRoundEnd = canRoundEnd_func;
83 round_handler.delay = (the_delay > 0) ? the_delay : 0;
84 round_handler.count = fabs(floor(the_count));
85 round_handler.wait = FALSE;
86 round_handler.cnt = round_handler.count + 1;
87 round_handler.nextthink = max(time, game_starttime + 1);
90 float round_handler_IsActive()
92 return (round_handler != world);
95 float round_handler_AwaitingNextRound()
97 return (round_handler.wait);
100 float round_handler_CountdownRunning()
102 return (!round_handler.wait && round_handler.cnt);
105 float round_handler_IsRoundStarted()
107 return (!round_handler.wait && !round_handler.cnt);
110 void round_handler_Reset(float next_think)
113 round_handler.wait = FALSE;
114 if(round_handler.count)
115 if(round_handler.cnt < round_handler.count + 1)
117 FOR_EACH_REALCLIENT(e)
118 Send_CSQC_Centerprint_Generic_Expire(e, CPID_ROUND_STARTING);
119 round_handler.cnt = round_handler.count + 1;
121 round_handler.nextthink = next_think;
124 void round_handler_Remove()
126 remove(round_handler);
127 round_handler = world;