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