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