1 void round_handler_Think()
6 if(inWarmupStage || time < game_starttime)
8 self.nextthink = time + 1;
14 round_handler_ResetCountdown();
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_ResetCountdown();
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 = time;
90 float round_handler_IsActive()
92 return (round_handler && !inWarmupStage && time > game_starttime);
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_ResetCountdown()
113 if(round_handler.count)
114 if(round_handler.cnt < round_handler.count + 1)
116 FOR_EACH_REALCLIENT(e)
117 Send_CSQC_Centerprint_Generic_Expire(e, CPID_ROUND_STARTING);
118 round_handler.cnt = round_handler.count + 1;
122 void round_handler_Remove()
124 remove(round_handler);
125 round_handler = world;