1 void round_handler_Think()
7 round_handler_Reset(0);
8 round_handler_Remove();
15 self.cnt = self.count + 1; // init countdown
16 round_starttime = time + self.count;
20 if(self.cnt > 0) // countdown running
22 if(self.canRoundStart())
24 if(self.cnt == self.count + 1)
25 round_starttime = time + self.count;
30 self.round_endtime = time + self.round_timelimit;
31 self.nextthink = time;
36 self.cnt = self.cnt - 1;
40 round_handler_Reset(0);
42 self.nextthink = time + 1; // canRoundStart every second
46 if(self.canRoundEnd())
48 // schedule a new round
50 self.nextthink = time + self.delay;
54 self.nextthink = time; // canRoundEnd every frame
59 void round_handler_Init(float the_delay, float the_count, float the_round_timelimit)
61 round_handler.delay = (the_delay > 0) ? the_delay : 0;
62 round_handler.count = fabs(floor(the_count));
63 round_handler.cnt = round_handler.count + 1;
64 round_handler.round_timelimit = max(10, the_round_timelimit);
67 // NOTE: this is only needed because if round_handler spawns at time 1
68 // gamestarttime isn't initialized yet
69 void round_handler_FirstThink()
71 round_starttime = max(time, game_starttime) + round_handler.count;
72 round_handler.think = round_handler_Think;
73 round_handler.nextthink = max(time, game_starttime);
76 void round_handler_Spawn(float() canRoundStart_func, float() canRoundEnd_func, void() roundStart_func)
80 backtrace("Can't spawn round_handler again!");
83 round_handler = spawn();
84 round_handler.classname = "round_handler";
86 round_handler.think = round_handler_FirstThink;
87 round_handler.canRoundStart = canRoundStart_func;
88 round_handler.canRoundEnd = canRoundEnd_func;
89 round_handler.roundStart = roundStart_func;
90 round_handler.wait = FALSE;
91 round_handler_Init(5, 5, 180);
92 round_handler.nextthink = time;
95 void round_handler_Reset(float next_think)
97 round_handler.wait = FALSE;
98 if(round_handler.count)
99 if(round_handler.cnt < round_handler.count + 1)
100 round_handler.cnt = round_handler.count + 1;
101 round_handler.nextthink = next_think;
102 round_starttime = (next_think) ? (next_think + round_handler.count) : -1;
105 void round_handler_Remove()
107 remove(round_handler);
108 round_handler = world;