]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc
Merge branch 'master' into Lyberta/GamemodesSplit
[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_freeplayers(entity this, float ratingscale, vector org, float sradius)
230 {
231         float t;
232         FOREACH_CLIENT(IS_PLAYER(it) && it != this && SAME_TEAM(it, this), {
233                 if (STAT(FROZEN, it) == 1)
234                 {
235                         if(vdist(it.origin - org, >, sradius))
236                                 continue;
237                         navigation_routerating(this, it, ratingscale, 2000);
238                 }
239                 else if(vdist(it.origin - org, >, 400)) // avoid gathering all teammates in one place
240                 {
241                         // If teamate is not frozen still seek them out as fight better
242                         // in a group.
243                         t = 0.2 * 150 / (GetResourceAmount(this, RESOURCE_HEALTH) + GetResourceAmount(this, RESOURCE_ARMOR));
244                         navigation_routerating(this, it, t * ratingscale, 2000);
245                 }
246         });
247 }
248
249 void havocbot_role_ft_offense(entity this)
250 {
251         if(IS_DEAD(this))
252                 return;
253
254         if (!this.havocbot_role_timeout)
255                 this.havocbot_role_timeout = time + random() * 10 + 20;
256
257         // Count how many players on team are unfrozen.
258         int unfrozen = 0;
259         FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, this) && !(STAT(FROZEN, it) != 1), { unfrozen++; });
260
261         // If only one left on team or if role has timed out then start trying to free players.
262         if (((unfrozen == 0) && (!STAT(FROZEN, this))) || (time > this.havocbot_role_timeout))
263         {
264                 LOG_TRACE("changing role to freeing");
265                 this.havocbot_role = havocbot_role_ft_freeing;
266                 this.havocbot_role_timeout = 0;
267                 return;
268         }
269
270         if (navigation_goalrating_timeout(this))
271         {
272                 navigation_goalrating_start(this);
273                 havocbot_goalrating_items(this, 10000, this.origin, 10000);
274                 havocbot_goalrating_enemyplayers(this, 20000, this.origin, 10000);
275                 havocbot_goalrating_freeplayers(this, 9000, this.origin, 10000);
276                 havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
277                 navigation_goalrating_end(this);
278
279                 navigation_goalrating_timeout_set(this);
280         }
281 }
282
283 void havocbot_role_ft_freeing(entity this)
284 {
285         if(IS_DEAD(this))
286                 return;
287
288         if (!this.havocbot_role_timeout)
289                 this.havocbot_role_timeout = time + random() * 10 + 20;
290
291         if (time > this.havocbot_role_timeout)
292         {
293                 LOG_TRACE("changing role to offense");
294                 this.havocbot_role = havocbot_role_ft_offense;
295                 this.havocbot_role_timeout = 0;
296                 return;
297         }
298
299         if (navigation_goalrating_timeout(this))
300         {
301                 navigation_goalrating_start(this);
302                 havocbot_goalrating_items(this, 8000, this.origin, 10000);
303                 havocbot_goalrating_enemyplayers(this, 10000, this.origin, 10000);
304                 havocbot_goalrating_freeplayers(this, 20000, this.origin, 10000);
305                 havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
306                 navigation_goalrating_end(this);
307
308                 navigation_goalrating_timeout_set(this);
309         }
310 }
311
312
313 // ==============
314 // Hook Functions
315 // ==============
316
317 void ft_RemovePlayer(entity this)
318 {
319         SetResourceAmountExplicit(this, RESOURCE_HEALTH, 0); // neccessary to update correctly alive stats
320         if(!STAT(FROZEN, this))
321                 freezetag_LastPlayerForTeam_Notify(this);
322         Unfreeze(this);
323         freezetag_count_alive_players();
324 }
325
326 MUTATOR_HOOKFUNCTION(ft, ClientDisconnect)
327 {
328         entity player = M_ARGV(0, entity);
329
330         ft_RemovePlayer(player);
331         return true;
332 }
333
334 MUTATOR_HOOKFUNCTION(ft, MakePlayerObserver)
335 {
336         entity player = M_ARGV(0, entity);
337
338         ft_RemovePlayer(player);
339 }
340
341 MUTATOR_HOOKFUNCTION(ft, PlayerDies)
342 {
343         entity frag_attacker = M_ARGV(1, entity);
344         entity frag_target = M_ARGV(2, entity);
345         float frag_deathtype = M_ARGV(3, float);
346
347         if(round_handler_IsActive())
348         if(round_handler_CountdownRunning())
349         {
350                 if(STAT(FROZEN, frag_target))
351                         Unfreeze(frag_target);
352                 freezetag_count_alive_players();
353                 return true; // let the player die so that he can respawn whenever he wants
354         }
355
356         // Cases DEATH_TEAMCHANGE and DEATH_AUTOTEAMCHANGE are needed to fix a bug whe
357         // you succeed changing team through the menu: you both really die (gibbing) and get frozen
358         if(ITEM_DAMAGE_NEEDKILL(frag_deathtype)
359                 || frag_deathtype == DEATH_TEAMCHANGE.m_id || frag_deathtype == DEATH_AUTOTEAMCHANGE.m_id)
360         {
361                 // let the player die, he will be automatically frozen when he respawns
362                 if(STAT(FROZEN, frag_target) != 1)
363                 {
364                         freezetag_Add_Score(frag_target, frag_attacker);
365                         freezetag_count_alive_players();
366                         freezetag_LastPlayerForTeam_Notify(frag_target);
367                 }
368                 else
369                         Unfreeze(frag_target); // remove ice
370                 SetResourceAmountExplicit(frag_target, RESOURCE_HEALTH, 0); // Unfreeze resets health
371                 frag_target.freezetag_frozen_timeout = -2; // freeze on respawn
372                 return true;
373         }
374
375         if(STAT(FROZEN, frag_target))
376                 return true;
377
378         freezetag_Freeze(frag_target, frag_attacker);
379         freezetag_LastPlayerForTeam_Notify(frag_target);
380
381         if(frag_attacker == frag_target || frag_attacker == NULL)
382         {
383                 if(IS_PLAYER(frag_target))
384                         Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_SELF);
385                 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_SELF, frag_target.netname);
386         }
387         else
388         {
389                 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_FREEZE, frag_target.netname, frag_attacker.netname);
390         }
391
392         return true;
393 }
394
395 MUTATOR_HOOKFUNCTION(ft, PlayerSpawn)
396 {
397         entity player = M_ARGV(0, entity);
398
399         if(player.freezetag_frozen_timeout == -1) // if PlayerSpawn is called by reset_map_players
400                 return true; // do nothing, round is starting right now
401
402         if(player.freezetag_frozen_timeout == -2) // player was dead
403         {
404                 freezetag_Freeze(player, NULL);
405                 return true;
406         }
407
408         freezetag_count_alive_players();
409
410         if(round_handler_IsActive())
411         if(round_handler_IsRoundStarted())
412         {
413                 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_SPAWN_LATE);
414                 freezetag_Freeze(player, NULL);
415         }
416
417         return true;
418 }
419
420 MUTATOR_HOOKFUNCTION(ft, reset_map_players)
421 {
422         FOREACH_CLIENT(IS_PLAYER(it), {
423                 CS(it).killcount = 0;
424                 it.freezetag_frozen_timeout = -1;
425                 PutClientInServer(it);
426                 it.freezetag_frozen_timeout = 0;
427         });
428         freezetag_count_alive_players();
429         return true;
430 }
431
432 MUTATOR_HOOKFUNCTION(ft, GiveFragsForKill, CBC_ORDER_FIRST)
433 {
434         M_ARGV(2, float) = 0; // no frags counted in Freeze Tag
435         return true;
436 }
437
438 MUTATOR_HOOKFUNCTION(ft, Unfreeze)
439 {
440         entity targ = M_ARGV(0, entity);
441         targ.freezetag_frozen_time = 0;
442         targ.freezetag_frozen_timeout = 0;
443
444         freezetag_count_alive_players();
445 }
446
447 MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST)
448 {
449         if(game_stopped)
450                 return true;
451
452         if(round_handler_IsActive())
453         if(!round_handler_IsRoundStarted())
454                 return true;
455
456         int n;
457         entity o = NULL;
458         entity player = M_ARGV(0, entity);
459         //if(STAT(FROZEN, player))
460         //if(player.freezetag_frozen_timeout > 0 && time < player.freezetag_frozen_timeout)
461                 //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);
462
463         if(player.freezetag_frozen_timeout > 0 && time >= player.freezetag_frozen_timeout)
464                 n = -1;
465         else
466         {
467                 vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
468                 n = 0;
469                 FOREACH_CLIENT(IS_PLAYER(it) && it != player, {
470                         if(STAT(FROZEN, it) == 0)
471                         if(!IS_DEAD(it))
472                         if(SAME_TEAM(it, player))
473                         if(boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
474                         {
475                                 if(!o)
476                                         o = it;
477                                 if(STAT(FROZEN, player) == 1)
478                                         it.reviving = true;
479                                 ++n;
480                         }
481                 });
482
483         }
484
485         if(n && STAT(FROZEN, player) == 1) // OK, there is at least one teammate reviving us
486         {
487                 STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
488                 SetResourceAmountExplicit(player, RESOURCE_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * ((warmup_stage) ? warmup_start_health : start_health)));
489
490                 if(STAT(REVIVE_PROGRESS, player) >= 1)
491                 {
492                         Unfreeze(player);
493                         freezetag_count_alive_players();
494
495                         if(n == -1)
496                         {
497                                 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_AUTO_REVIVED, autocvar_g_freezetag_frozen_maxtime);
498                                 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_AUTO_REVIVED, player.netname, autocvar_g_freezetag_frozen_maxtime);
499                                 return true;
500                         }
501
502                         // EVERY team mate nearby gets a point (even if multiple!)
503                         FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, {
504                                 GameRules_scoring_add(it, FREEZETAG_REVIVALS, +1);
505                                 GameRules_scoring_add(it, SCORE, +1);
506                                 nades_GiveBonus(it,autocvar_g_nades_bonus_score_low);
507                         });
508
509                         Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, o.netname);
510                         Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
511                         Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED, player.netname, o.netname);
512                 }
513
514                 FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, {
515                         STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player);
516                         it.reviving = false;
517                 });
518         }
519         else if(!n && STAT(FROZEN, player) == 1) // only if no teammate is nearby will we reset
520         {
521                 STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) - frametime * autocvar_g_freezetag_revive_clearspeed, 1);
522                 SetResourceAmountExplicit(player, RESOURCE_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * ((warmup_stage) ? warmup_start_health : start_health)));
523         }
524         else if(!n && !STAT(FROZEN, player))
525         {
526                 STAT(REVIVE_PROGRESS, player) = 0; // thawing nobody
527         }
528
529         return true;
530 }
531
532 MUTATOR_HOOKFUNCTION(ft, SetStartItems)
533 {
534         start_items &= ~IT_UNLIMITED_AMMO;
535         //start_health       = warmup_start_health       = cvar("g_lms_start_health");
536         //start_armorvalue   = warmup_start_armorvalue   = cvar("g_lms_start_armor");
537         start_ammo_shells  = warmup_start_ammo_shells  = cvar("g_lms_start_ammo_shells");
538         start_ammo_nails   = warmup_start_ammo_nails   = cvar("g_lms_start_ammo_nails");
539         start_ammo_rockets = warmup_start_ammo_rockets = cvar("g_lms_start_ammo_rockets");
540         start_ammo_cells   = warmup_start_ammo_cells   = cvar("g_lms_start_ammo_cells");
541         start_ammo_plasma  = warmup_start_ammo_plasma  = cvar("g_lms_start_ammo_plasma");
542         start_ammo_fuel    = warmup_start_ammo_fuel    = cvar("g_lms_start_ammo_fuel");
543 }
544
545 MUTATOR_HOOKFUNCTION(ft, HavocBot_ChooseRole)
546 {
547         entity bot = M_ARGV(0, entity);
548
549         if (!IS_DEAD(bot))
550         {
551                 if (random() < 0.5)
552                         bot.havocbot_role = havocbot_role_ft_freeing;
553                 else
554                         bot.havocbot_role = havocbot_role_ft_offense;
555         }
556
557         return true;
558 }
559
560 MUTATOR_HOOKFUNCTION(ft, TeamBalance_CheckAllowedTeams, CBC_ORDER_EXCLUSIVE)
561 {
562         M_ARGV(0, float) = freezetag_teams;
563         return true;
564 }
565
566 MUTATOR_HOOKFUNCTION(ft, SetWeaponArena)
567 {
568         // most weapons arena
569         if(M_ARGV(0, string) == "0" || M_ARGV(0, string) == "")
570                 M_ARGV(0, string) = "most";
571 }
572
573 MUTATOR_HOOKFUNCTION(ft, FragCenterMessage)
574 {
575         entity frag_attacker = M_ARGV(0, entity);
576         entity frag_target = M_ARGV(1, entity);
577         //float frag_deathtype = M_ARGV(2, float);
578         int kill_count_to_attacker = M_ARGV(3, int);
579         int kill_count_to_target = M_ARGV(4, int);
580
581         if(STAT(FROZEN, frag_target))
582                 return; // target was already frozen, so this is just pushing them off the cliff
583
584         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));
585         Send_Notification(NOTIF_ONE, frag_target, MSG_CHOICE, CHOICE_FRAGGED_FREEZE, frag_attacker.netname, kill_count_to_target,
586                 GetResourceAmount(frag_attacker, RESOURCE_HEALTH), GetResourceAmount(frag_attacker, RESOURCE_ARMOR), (IS_BOT_CLIENT(frag_attacker) ? -1 : CS(frag_attacker).ping));
587
588         return true;
589 }
590
591 void freezetag_Initialize()
592 {
593         freezetag_teams = autocvar_g_freezetag_teams_override;
594         if(freezetag_teams < 2)
595                 freezetag_teams = cvar("g_freezetag_teams"); // read the cvar directly as it gets written earlier in the same frame
596
597         freezetag_teams = BITS(bound(2, freezetag_teams, 4));
598         GameRules_scoring(freezetag_teams, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, {
599                 field(SP_FREEZETAG_REVIVALS, "revivals", 0);
600         });
601
602         round_handler_Spawn(freezetag_CheckTeams, freezetag_CheckWinner, func_null);
603         round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
604
605         EliminatedPlayers_Init(freezetag_isEliminated);
606 }