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