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