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