]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/mutators/mutator/gamemode_freezetag.qc
14e345046b2db29a9011d60db40c594bdbea0fb8
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_freezetag.qc
1 #ifndef GAMEMODE_FREEZETAG_H
2 #define GAMEMODE_FREEZETAG_H
3
4 int autocvar_g_freezetag_point_limit;
5 int autocvar_g_freezetag_point_leadlimit;
6 bool autocvar_g_freezetag_team_spawns;
7 void freezetag_Initialize();
8
9 REGISTER_MUTATOR(ft, false)
10 {
11         MUTATOR_ONADD
12         {
13                 if (time > 1) // game loads at time 1
14                         error("This is a game type and it cannot be added at runtime.");
15                 freezetag_Initialize();
16
17                 ActivateTeamplay();
18                 SetLimits(autocvar_g_freezetag_point_limit, autocvar_g_freezetag_point_leadlimit, -1, -1);
19
20                 if (autocvar_g_freezetag_team_spawns)
21                         have_team_spawns = -1; // request team spawns
22         }
23
24         MUTATOR_ONROLLBACK_OR_REMOVE
25         {
26                 // we actually cannot roll back freezetag_Initialize here
27                 // BUT: we don't need to! If this gets called, adding always
28                 // succeeds.
29         }
30
31         MUTATOR_ONREMOVE
32         {
33                 LOG_INFO("This is a game type and it cannot be removed at runtime.");
34                 return -1;
35         }
36
37         return 0;
38 }
39
40 .float freezetag_frozen_time;
41 .float freezetag_frozen_timeout;
42 const float ICE_MAX_ALPHA = 1;
43 const float ICE_MIN_ALPHA = 0.1;
44 float freezetag_teams;
45
46 .float reviving; // temp var
47 #endif
48
49 #ifdef IMPLEMENTATION
50
51 float autocvar_g_freezetag_frozen_maxtime;
52 bool autocvar_g_freezetag_revive_nade;
53 float autocvar_g_freezetag_revive_nade_health;
54 float autocvar_g_freezetag_revive_extra_size;
55 float autocvar_g_freezetag_revive_speed;
56 float autocvar_g_freezetag_revive_clearspeed;
57 float autocvar_g_freezetag_round_timelimit;
58 int autocvar_g_freezetag_teams;
59 int autocvar_g_freezetag_teams_override;
60 float autocvar_g_freezetag_warmup;
61
62 const float SP_FREEZETAG_REVIVALS = 4;
63 void freezetag_ScoreRules(float teams)
64 {
65         ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, true); // SFL_SORT_PRIO_PRIMARY
66         ScoreInfo_SetLabel_PlayerScore(SP_FREEZETAG_REVIVALS, "revivals", 0);
67         ScoreRules_basics_end();
68 }
69
70 void freezetag_count_alive_players()
71 {
72         entity e;
73         total_players = redalive = bluealive = yellowalive = pinkalive = 0;
74         FOR_EACH_PLAYER(e)
75         {
76                 switch(e.team)
77                 {
78                         case NUM_TEAM_1: ++total_players; if(e.health >= 1 && e.frozen != 1) ++redalive; break;
79                         case NUM_TEAM_2: ++total_players; if(e.health >= 1 && e.frozen != 1) ++bluealive; break;
80                         case NUM_TEAM_3: ++total_players; if(e.health >= 1 && e.frozen != 1) ++yellowalive; break;
81                         case NUM_TEAM_4: ++total_players; if(e.health >= 1 && e.frozen != 1) ++pinkalive; break;
82                 }
83         }
84         FOR_EACH_REALCLIENT(e)
85         {
86                 e.redalive_stat = redalive;
87                 e.bluealive_stat = bluealive;
88                 e.yellowalive_stat = yellowalive;
89                 e.pinkalive_stat = pinkalive;
90         }
91
92         eliminatedPlayers.SendFlags |= 1;
93 }
94 #define FREEZETAG_ALIVE_TEAMS() ((redalive > 0) + (bluealive > 0) + (yellowalive > 0) + (pinkalive > 0))
95 #define FREEZETAG_ALIVE_TEAMS_OK() (FREEZETAG_ALIVE_TEAMS() == freezetag_teams)
96
97 float freezetag_CheckTeams()
98 {
99         static float prev_missing_teams_mask;
100         if(FREEZETAG_ALIVE_TEAMS_OK())
101         {
102                 if(prev_missing_teams_mask > 0)
103                         Kill_Notification(NOTIF_ALL, world, MSG_CENTER_CPID, CPID_MISSING_TEAMS);
104                 prev_missing_teams_mask = -1;
105                 return 1;
106         }
107         if(total_players == 0)
108         {
109                 if(prev_missing_teams_mask > 0)
110                         Kill_Notification(NOTIF_ALL, world, MSG_CENTER_CPID, CPID_MISSING_TEAMS);
111                 prev_missing_teams_mask = -1;
112                 return 0;
113         }
114         float missing_teams_mask = (!redalive) + (!bluealive) * 2;
115         if(freezetag_teams >= 3) missing_teams_mask += (!yellowalive) * 4;
116         if(freezetag_teams >= 4) missing_teams_mask += (!pinkalive) * 8;
117         if(prev_missing_teams_mask != missing_teams_mask)
118         {
119                 Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_MISSING_TEAMS, missing_teams_mask);
120                 prev_missing_teams_mask = missing_teams_mask;
121         }
122         return 0;
123 }
124
125 float freezetag_getWinnerTeam()
126 {
127         float winner_team = 0;
128         if(redalive >= 1)
129                 winner_team = NUM_TEAM_1;
130         if(bluealive >= 1)
131         {
132                 if(winner_team) return 0;
133                 winner_team = NUM_TEAM_2;
134         }
135         if(yellowalive >= 1)
136         {
137                 if(winner_team) return 0;
138                 winner_team = NUM_TEAM_3;
139         }
140         if(pinkalive >= 1)
141         {
142                 if(winner_team) return 0;
143                 winner_team = NUM_TEAM_4;
144         }
145         if(winner_team)
146                 return winner_team;
147         return -1; // no player left
148 }
149
150 float freezetag_CheckWinner()
151 {
152         entity e;
153         if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0)
154         {
155                 Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ROUND_OVER);
156                 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ROUND_OVER);
157                 FOR_EACH_PLAYER(e)
158                 {
159                         e.freezetag_frozen_timeout = 0;
160                         nades_Clear(e);
161                 }
162                 round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
163                 return 1;
164         }
165
166         if(FREEZETAG_ALIVE_TEAMS() > 1)
167                 return 0;
168
169         float winner_team;
170         winner_team = freezetag_getWinnerTeam();
171         if(winner_team > 0)
172         {
173                 Send_Notification(NOTIF_ALL, world, MSG_CENTER, APP_TEAM_NUM_4(winner_team, CENTER_ROUND_TEAM_WIN_));
174                 Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(winner_team, INFO_ROUND_TEAM_WIN_));
175                 TeamScore_AddToTeam(winner_team, ST_SCORE, +1);
176         }
177         else if(winner_team == -1)
178         {
179                 Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ROUND_TIED);
180                 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ROUND_TIED);
181         }
182
183         FOR_EACH_PLAYER(e)
184         {
185                 e.freezetag_frozen_timeout = 0;
186                 nades_Clear(e);
187         }
188         round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
189         return 1;
190 }
191
192 entity freezetag_LastPlayerForTeam()
193 {SELFPARAM();
194         entity pl, last_pl = world;
195         FOR_EACH_PLAYER(pl)
196         {
197                 if(pl.health >= 1)
198                 if(!pl.frozen)
199                 if(pl != self)
200                 if(pl.team == self.team)
201                 if(!last_pl)
202                         last_pl = pl;
203                 else
204                         return world;
205         }
206         return last_pl;
207 }
208
209 void freezetag_LastPlayerForTeam_Notify()
210 {
211         if(round_handler_IsActive())
212         if(round_handler_IsRoundStarted())
213         {
214                 entity pl = freezetag_LastPlayerForTeam();
215                 if(pl)
216                         Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_ALONE);
217         }
218 }
219
220 void freezetag_Add_Score(entity attacker)
221 {SELFPARAM();
222         if(attacker == self)
223         {
224                 // you froze your own dumb self
225                 // counted as "suicide" already
226                 PlayerScore_Add(self, SP_SCORE, -1);
227         }
228         else if(IS_PLAYER(attacker))
229         {
230                 // got frozen by an enemy
231                 // counted as "kill" and "death" already
232                 PlayerScore_Add(self, SP_SCORE, -1);
233                 PlayerScore_Add(attacker, SP_SCORE, +1);
234         }
235         // else nothing - got frozen by the game type rules themselves
236 }
237
238 void freezetag_Freeze(entity attacker)
239 {SELFPARAM();
240         if(self.frozen)
241                 return;
242
243         if(autocvar_g_freezetag_frozen_maxtime > 0)
244                 self.freezetag_frozen_timeout = time + autocvar_g_freezetag_frozen_maxtime;
245
246         Freeze(self, 0, 1, true);
247
248         freezetag_count_alive_players();
249
250         freezetag_Add_Score(attacker);
251 }
252
253 void freezetag_Unfreeze(entity attacker)
254 {SELFPARAM();
255         self.freezetag_frozen_time = 0;
256         self.freezetag_frozen_timeout = 0;
257
258         Unfreeze(self);
259 }
260
261 float freezetag_isEliminated(entity e)
262 {
263         if(IS_PLAYER(e) && (e.frozen == 1 || e.deadflag != DEAD_NO))
264                 return true;
265         return false;
266 }
267
268
269 // ================
270 // Bot player logic
271 // ================
272
273 void() havocbot_role_ft_freeing;
274 void() havocbot_role_ft_offense;
275
276 void havocbot_goalrating_freeplayers(float ratingscale, vector org, float sradius)
277 {SELFPARAM();
278         entity head;
279         float distance;
280
281         FOR_EACH_PLAYER(head)
282         {
283                 if ((head != self) && (head.team == self.team))
284                 {
285                         if (head.frozen == 1)
286                         {
287                                 distance = vlen(head.origin - org);
288                                 if (distance > sradius)
289                                         continue;
290                                 navigation_routerating(head, ratingscale, 2000);
291                         }
292                         else
293                         {
294                                 // If teamate is not frozen still seek them out as fight better
295                                 // in a group.
296                                 navigation_routerating(head, ratingscale/3, 2000);
297                         }
298                 }
299         }
300 }
301
302 void havocbot_role_ft_offense()
303 {SELFPARAM();
304         entity head;
305         float unfrozen;
306
307         if(self.deadflag != DEAD_NO)
308                 return;
309
310         if (!self.havocbot_role_timeout)
311                 self.havocbot_role_timeout = time + random() * 10 + 20;
312
313         // Count how many players on team are unfrozen.
314         unfrozen = 0;
315         FOR_EACH_PLAYER(head)
316         {
317                 if ((head.team == self.team) && (head.frozen != 1))
318                         unfrozen++;
319         }
320
321         // If only one left on team or if role has timed out then start trying to free players.
322         if (((unfrozen == 0) && (!self.frozen)) || (time > self.havocbot_role_timeout))
323         {
324                 LOG_TRACE("changing role to freeing\n");
325                 self.havocbot_role = havocbot_role_ft_freeing;
326                 self.havocbot_role_timeout = 0;
327                 return;
328         }
329
330         if (time > self.bot_strategytime)
331         {
332                 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
333
334                 navigation_goalrating_start();
335                 havocbot_goalrating_items(10000, self.origin, 10000);
336                 havocbot_goalrating_enemyplayers(20000, self.origin, 10000);
337                 havocbot_goalrating_freeplayers(9000, self.origin, 10000);
338                 //havocbot_goalrating_waypoints(1, self.origin, 1000);
339                 navigation_goalrating_end();
340         }
341 }
342
343 void havocbot_role_ft_freeing()
344 {SELFPARAM();
345         if(self.deadflag != DEAD_NO)
346                 return;
347
348         if (!self.havocbot_role_timeout)
349                 self.havocbot_role_timeout = time + random() * 10 + 20;
350
351         if (time > self.havocbot_role_timeout)
352         {
353                 LOG_TRACE("changing role to offense\n");
354                 self.havocbot_role = havocbot_role_ft_offense;
355                 self.havocbot_role_timeout = 0;
356                 return;
357         }
358
359         if (time > self.bot_strategytime)
360         {
361                 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
362
363                 navigation_goalrating_start();
364                 havocbot_goalrating_items(8000, self.origin, 10000);
365                 havocbot_goalrating_enemyplayers(10000, self.origin, 10000);
366                 havocbot_goalrating_freeplayers(20000, self.origin, 10000);
367                 //havocbot_goalrating_waypoints(1, self.origin, 1000);
368                 navigation_goalrating_end();
369         }
370 }
371
372
373 // ==============
374 // Hook Functions
375 // ==============
376
377 void ft_RemovePlayer()
378 {SELFPARAM();
379         self.health = 0; // neccessary to update correctly alive stats
380         if(!self.frozen)
381                 freezetag_LastPlayerForTeam_Notify();
382         freezetag_Unfreeze(world);
383         freezetag_count_alive_players();
384 }
385
386 MUTATOR_HOOKFUNCTION(ft, ClientDisconnect)
387 {SELFPARAM();
388         ft_RemovePlayer();
389         return 1;
390 }
391
392 MUTATOR_HOOKFUNCTION(ft, MakePlayerObserver)
393 {SELFPARAM();
394         ft_RemovePlayer();
395         return false;
396 }
397
398 MUTATOR_HOOKFUNCTION(ft, PlayerDies)
399 {SELFPARAM();
400         if(round_handler_IsActive())
401         if(round_handler_CountdownRunning())
402         {
403                 if(self.frozen)
404                         freezetag_Unfreeze(world);
405                 freezetag_count_alive_players();
406                 return 1; // let the player die so that he can respawn whenever he wants
407         }
408
409         // Cases DEATH_TEAMCHANGE and DEATH_AUTOTEAMCHANGE are needed to fix a bug whe
410         // you succeed changing team through the menu: you both really die (gibbing) and get frozen
411         if(ITEM_DAMAGE_NEEDKILL(frag_deathtype)
412                 || frag_deathtype == DEATH_TEAMCHANGE.m_id || frag_deathtype == DEATH_AUTOTEAMCHANGE.m_id)
413         {
414                 // let the player die, he will be automatically frozen when he respawns
415                 if(self.frozen != 1)
416                 {
417                         freezetag_Add_Score(frag_attacker);
418                         freezetag_count_alive_players();
419                         freezetag_LastPlayerForTeam_Notify();
420                 }
421                 else
422                         freezetag_Unfreeze(world); // remove ice
423                 self.health = 0; // Unfreeze resets health
424                 self.freezetag_frozen_timeout = -2; // freeze on respawn
425                 return 1;
426         }
427
428         if(self.frozen)
429                 return 1;
430
431         freezetag_Freeze(frag_attacker);
432         freezetag_LastPlayerForTeam_Notify();
433
434         if(frag_attacker == frag_target || frag_attacker == world)
435         {
436                 if(IS_PLAYER(frag_target))
437                         Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_SELF);
438                 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_SELF, frag_target.netname);
439         }
440         else
441         {
442                 if(IS_PLAYER(frag_target))
443                         Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_FROZEN, frag_attacker.netname);
444                 if(IS_PLAYER(frag_attacker))
445                         Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_FREEZETAG_FREEZE, frag_target.netname);
446                 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_FREEZE, frag_target.netname, frag_attacker.netname);
447         }
448
449         return 1;
450 }
451
452 MUTATOR_HOOKFUNCTION(ft, PlayerSpawn)
453 {SELFPARAM();
454         if(self.freezetag_frozen_timeout == -1) // if PlayerSpawn is called by reset_map_players
455                 return 1; // do nothing, round is starting right now
456
457         if(self.freezetag_frozen_timeout == -2) // player was dead
458         {
459                 freezetag_Freeze(world);
460                 return 1;
461         }
462
463         freezetag_count_alive_players();
464
465         if(round_handler_IsActive())
466         if(round_handler_IsRoundStarted())
467         {
468                 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_FREEZETAG_SPAWN_LATE);
469                 freezetag_Freeze(world);
470         }
471
472         return 1;
473 }
474
475 MUTATOR_HOOKFUNCTION(ft, reset_map_players)
476 {SELFPARAM();
477         entity e;
478         FOR_EACH_PLAYER(e)
479         {
480                 e.killcount = 0;
481                 e.freezetag_frozen_timeout = -1;
482                 setself(e);
483                 PutClientInServer();
484                 e.freezetag_frozen_timeout = 0;
485         }
486         freezetag_count_alive_players();
487         return 1;
488 }
489
490 MUTATOR_HOOKFUNCTION(ft, GiveFragsForKill, CBC_ORDER_FIRST)
491 {
492         frag_score = 0; // no frags counted in Freeze Tag
493         return 1;
494 }
495
496 MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST)
497 {SELFPARAM();
498         float n;
499
500         if(gameover)
501                 return 1;
502
503         if(self.frozen == 1)
504         {
505                 // keep health = 1
506                 self.pauseregen_finished = time + autocvar_g_balance_pause_health_regen;
507         }
508
509         if(round_handler_IsActive())
510         if(!round_handler_IsRoundStarted())
511                 return 1;
512
513         entity o;
514         o = world;
515         //if(self.frozen)
516         //if(self.freezetag_frozen_timeout > 0 && time < self.freezetag_frozen_timeout)
517                 //self.iceblock.alpha = ICE_MIN_ALPHA + (ICE_MAX_ALPHA - ICE_MIN_ALPHA) * (self.freezetag_frozen_timeout - time) / (self.freezetag_frozen_timeout - self.freezetag_frozen_time);
518
519         if(self.freezetag_frozen_timeout > 0 && time >= self.freezetag_frozen_timeout)
520                 n = -1;
521         else
522         {
523                 vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
524                 n = 0;
525                 FOR_EACH_PLAYER(other)
526                 if(self != other)
527                 if(other.frozen == 0)
528                 if(other.deadflag == DEAD_NO)
529                 if(SAME_TEAM(other, self))
530                 if(boxesoverlap(self.absmin - revive_extra_size, self.absmax + revive_extra_size, other.absmin, other.absmax))
531                 {
532                         if(!o)
533                                 o = other;
534                         if(self.frozen == 1)
535                                 other.reviving = true;
536                         ++n;
537                 }
538         }
539
540         if(n && self.frozen == 1) // OK, there is at least one teammate reviving us
541         {
542                 self.revive_progress = bound(0, self.revive_progress + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
543                 self.health = max(1, self.revive_progress * ((warmup_stage) ? warmup_start_health : start_health));
544
545                 if(self.revive_progress >= 1)
546                 {
547                         freezetag_Unfreeze(self);
548                         freezetag_count_alive_players();
549
550                         if(n == -1)
551                         {
552                                 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_FREEZETAG_AUTO_REVIVED, autocvar_g_freezetag_frozen_maxtime);
553                                 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_AUTO_REVIVED, self.netname, autocvar_g_freezetag_frozen_maxtime);
554                                 return 1;
555                         }
556
557                         // EVERY team mate nearby gets a point (even if multiple!)
558                         FOR_EACH_PLAYER(other)
559                         {
560                                 if(other.reviving)
561                                 {
562                                         PlayerScore_Add(other, SP_FREEZETAG_REVIVALS, +1);
563                                         PlayerScore_Add(other, SP_SCORE, +1);
564
565                                         nades_GiveBonus(other,autocvar_g_nades_bonus_score_low);
566                                 }
567                         }
568
569                         Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_FREEZETAG_REVIVED, o.netname);
570                         Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, self.netname);
571                         Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_REVIVED, self.netname, o.netname);
572                 }
573
574                 FOR_EACH_PLAYER(other)
575                 {
576                         if(other.reviving)
577                         {
578                                 other.revive_progress = self.revive_progress;
579                                 other.reviving = false;
580                         }
581                 }
582         }
583         else if(!n && self.frozen == 1) // only if no teammate is nearby will we reset
584         {
585                 self.revive_progress = bound(0, self.revive_progress - frametime * autocvar_g_freezetag_revive_clearspeed, 1);
586                 self.health = max(1, self.revive_progress * ((warmup_stage) ? warmup_start_health : start_health));
587         }
588         else if(!n && !self.frozen)
589         {
590                 self.revive_progress = 0; // thawing nobody
591         }
592
593         return 1;
594 }
595
596 MUTATOR_HOOKFUNCTION(ft, SetStartItems)
597 {
598         start_items &= ~IT_UNLIMITED_AMMO;
599         //start_health       = warmup_start_health       = cvar("g_lms_start_health");
600         //start_armorvalue   = warmup_start_armorvalue   = cvar("g_lms_start_armor");
601         start_ammo_shells  = warmup_start_ammo_shells  = cvar("g_lms_start_ammo_shells");
602         start_ammo_nails   = warmup_start_ammo_nails   = cvar("g_lms_start_ammo_nails");
603         start_ammo_rockets = warmup_start_ammo_rockets = cvar("g_lms_start_ammo_rockets");
604         start_ammo_cells   = warmup_start_ammo_cells   = cvar("g_lms_start_ammo_cells");
605         start_ammo_plasma  = warmup_start_ammo_plasma  = cvar("g_lms_start_ammo_plasma");
606         start_ammo_fuel    = warmup_start_ammo_fuel    = cvar("g_lms_start_ammo_fuel");
607
608         return 0;
609 }
610
611 MUTATOR_HOOKFUNCTION(ft, HavocBot_ChooseRole)
612 {SELFPARAM();
613         if (!self.deadflag)
614         {
615                 if (random() < 0.5)
616                         self.havocbot_role = havocbot_role_ft_freeing;
617                 else
618                         self.havocbot_role = havocbot_role_ft_offense;
619         }
620
621         return true;
622 }
623
624 MUTATOR_HOOKFUNCTION(ft, GetTeamCount, CBC_ORDER_EXCLUSIVE)
625 {
626         ret_float = freezetag_teams;
627         return false;
628 }
629
630 MUTATOR_HOOKFUNCTION(ft, SetWeaponArena)
631 {
632         // most weapons arena
633         if(ret_string == "0" || ret_string == "")
634                 ret_string = "most";
635         return false;
636 }
637
638 void freezetag_Initialize()
639 {
640         freezetag_teams = autocvar_g_freezetag_teams_override;
641         if(freezetag_teams < 2)
642                 freezetag_teams = autocvar_g_freezetag_teams;
643         freezetag_teams = bound(2, freezetag_teams, 4);
644         freezetag_ScoreRules(freezetag_teams);
645
646         round_handler_Spawn(freezetag_CheckTeams, freezetag_CheckWinner, func_null);
647         round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
648
649         addstat(STAT_REDALIVE, AS_INT, redalive_stat);
650         addstat(STAT_BLUEALIVE, AS_INT, bluealive_stat);
651         addstat(STAT_YELLOWALIVE, AS_INT, yellowalive_stat);
652         addstat(STAT_PINKALIVE, AS_INT, pinkalive_stat);
653
654         EliminatedPlayers_Init(freezetag_isEliminated);
655 }
656
657 #endif