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