1 #include "sv_freezetag.qh"
3 #include <server/elimination.qh>
4 #include <server/resources.qh>
6 float autocvar_g_freezetag_frozen_maxtime;
7 float autocvar_g_freezetag_revive_clearspeed;
8 float autocvar_g_freezetag_round_timelimit;
9 //int autocvar_g_freezetag_teams;
10 int autocvar_g_freezetag_teams_override;
11 float autocvar_g_freezetag_warmup;
13 void freezetag_count_alive_players()
16 for (int i = 1; i <= NUM_TEAMS; ++i)
18 Team_SetNumberOfAlivePlayers(Team_GetTeamFromIndex(i), 0);
20 FOREACH_CLIENT(IS_PLAYER(it) && Entity_HasValidTeam(it),
23 if (GetResource(it, RES_HEALTH) < 1 || STAT(FROZEN, it) == FROZEN_NORMAL)
27 entity team_ = Entity_GetTeam(it);
28 int num_alive = Team_GetNumberOfAlivePlayers(team_);
30 Team_SetNumberOfAlivePlayers(team_, num_alive);
32 FOREACH_CLIENT(IS_REAL_CLIENT(it),
34 STAT(REDALIVE, it) = Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(
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));
44 eliminatedPlayers.SendFlags |= 1;
47 bool freezetag_CheckTeams()
49 static float prev_missing_teams_mask;
50 if (Team_GetNumberOfAliveTeams() == NumTeams(freezetag_teams))
52 if(prev_missing_teams_mask > 0)
53 Kill_Notification(NOTIF_ALL, NULL, MSG_CENTER, CPID_MISSING_TEAMS);
54 prev_missing_teams_mask = -1;
57 if(total_players == 0)
59 if(prev_missing_teams_mask > 0)
60 Kill_Notification(NOTIF_ALL, NULL, MSG_CENTER, CPID_MISSING_TEAMS);
61 prev_missing_teams_mask = -1;
64 int missing_teams_mask = 0;
65 for (int i = 1; i <= NUM_TEAMS; ++i)
67 if ((freezetag_teams & Team_IndexToBit(i)) &&
68 (Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(i)) == 0))
70 missing_teams_mask |= Team_IndexToBit(i);
73 if(prev_missing_teams_mask != missing_teams_mask)
75 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_MISSING_TEAMS, missing_teams_mask);
76 prev_missing_teams_mask = missing_teams_mask;
81 int freezetag_getWinnerTeam()
84 if (Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(1)) >= 1)
86 winner_team = NUM_TEAM_1;
88 for (int i = 2; i <= NUM_TEAMS; ++i)
90 if (Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(i)) >= 1)
96 winner_team = Team_IndexToTeam(i);
103 return -1; // no player left
106 void nades_Clear(entity);
107 void nades_GiveBonus(entity player, float score);
109 bool freezetag_CheckWinner()
111 if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0)
113 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_OVER);
114 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_OVER);
115 FOREACH_CLIENT(IS_PLAYER(it), {
116 it.freezetag_frozen_timeout = 0;
117 it.freezetag_revive_time = 0;
121 round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
125 if (Team_GetNumberOfAliveTeams() > 1)
130 int winner_team = freezetag_getWinnerTeam();
133 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_WIN));
134 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_WIN));
135 TeamScore_AddToTeam(winner_team, ST_FT_ROUNDS, +1);
137 else if(winner_team == -1)
139 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_TIED);
140 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_TIED);
143 FOREACH_CLIENT(IS_PLAYER(it), {
144 it.freezetag_frozen_timeout = 0;
145 it.freezetag_revive_time = 0;
150 round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
154 entity freezetag_LastPlayerForTeam(entity this)
156 entity last_pl = NULL;
157 FOREACH_CLIENT(IS_PLAYER(it) && it != this && SAME_TEAM(it, this), {
158 if (STAT(FROZEN, it) != FROZEN_NORMAL && GetResource(it, RES_HEALTH) >= 1)
169 void freezetag_LastPlayerForTeam_Notify(entity this)
171 if(round_handler_IsActive())
172 if(round_handler_IsRoundStarted())
174 entity pl = freezetag_LastPlayerForTeam(this);
176 Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_ALONE);
180 void freezetag_Add_Score(entity targ, entity attacker)
184 // you froze your own dumb self
185 // counted as "suicide" already
186 GameRules_scoring_add(targ, SCORE, -1);
188 else if(IS_PLAYER(attacker))
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);
195 // else nothing - got frozen by the game type rules themselves
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)
201 if(STAT(FROZEN, targ))
204 targ.freezetag_frozen_time = time;
205 if (autocvar_g_freezetag_revive_auto && autocvar_g_freezetag_frozen_maxtime > 0)
206 targ.freezetag_frozen_timeout = time + autocvar_g_freezetag_frozen_maxtime;
208 Freeze(targ, 0, FROZEN_NORMAL, true);
210 freezetag_count_alive_players();
212 freezetag_Add_Score(targ, attacker);
215 bool freezetag_isEliminated(entity e)
217 if(IS_PLAYER(e) && (STAT(FROZEN, e) == FROZEN_NORMAL || IS_DEAD(e)))
227 void(entity this) havocbot_role_ft_freeing;
228 void(entity this) havocbot_role_ft_offense;
230 void havocbot_goalrating_ft_freeplayers(entity this, float ratingscale, vector org, float sradius)
232 entity best_pl = NULL;
233 float best_dist2 = FLOAT_MAX;
234 FOREACH_CLIENT(IS_PLAYER(it) && it != this && SAME_TEAM(it, this), {
235 if (STAT(FROZEN, it) == FROZEN_NORMAL)
237 if(vdist(it.origin - org, >, sradius))
239 navigation_routerating(this, it, ratingscale, 2000);
242 && GetResource(it, RES_HEALTH) < GetResource(this, RES_HEALTH) + 30
243 && vlen2(it.origin - org) < best_dist2)
245 // If teamate is not frozen still seek them out as fight better
247 best_dist2 = vlen2(it.origin - org);
248 if (best_dist2 < 700 ** 2)
251 best_dist2 = 0; // already close to a teammate
258 navigation_routerating(this, best_pl, ratingscale / 2, 2000);
261 void havocbot_role_ft_offense(entity this)
266 if (!this.havocbot_role_timeout)
267 this.havocbot_role_timeout = time + random() * 10 + 20;
269 // Count how many players on team are unfrozen.
271 FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, this) && STAT(FROZEN, it) != FROZEN_NORMAL, {
275 // If only one left on team or if role has timed out then start trying to free players.
276 if ((!unfrozen && STAT(FROZEN, this) != FROZEN_NORMAL) || time > this.havocbot_role_timeout)
278 LOG_TRACE("changing role to freeing");
279 this.havocbot_role = havocbot_role_ft_freeing;
280 this.havocbot_role_timeout = 0;
284 if (navigation_goalrating_timeout(this))
286 navigation_goalrating_start(this);
287 havocbot_goalrating_items(this, 12000, this.origin, 10000);
288 havocbot_goalrating_enemyplayers(this, 10000, this.origin, 10000);
289 havocbot_goalrating_ft_freeplayers(this, 9000, this.origin, 10000);
290 havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
291 navigation_goalrating_end(this);
293 navigation_goalrating_timeout_set(this);
297 void havocbot_role_ft_freeing(entity this)
302 if (!this.havocbot_role_timeout)
303 this.havocbot_role_timeout = time + random() * 10 + 20;
305 if (time > this.havocbot_role_timeout)
307 LOG_TRACE("changing role to offense");
308 this.havocbot_role = havocbot_role_ft_offense;
309 this.havocbot_role_timeout = 0;
313 if (navigation_goalrating_timeout(this))
315 navigation_goalrating_start(this);
316 havocbot_goalrating_items(this, 10000, this.origin, 10000);
317 havocbot_goalrating_enemyplayers(this, 5000, this.origin, 10000);
318 havocbot_goalrating_ft_freeplayers(this, 20000, this.origin, 10000);
319 havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
320 navigation_goalrating_end(this);
322 navigation_goalrating_timeout_set(this);
331 void ft_RemovePlayer(entity this)
333 if (STAT(FROZEN, this) != FROZEN_NORMAL)
334 freezetag_LastPlayerForTeam_Notify(this);
335 Unfreeze(this, false);
337 SetResourceExplicit(this, RES_HEALTH, 0); // neccessary to correctly count alive players
338 freezetag_count_alive_players();
341 MUTATOR_HOOKFUNCTION(ft, ClientDisconnect)
343 entity player = M_ARGV(0, entity);
345 ft_RemovePlayer(player);
349 MUTATOR_HOOKFUNCTION(ft, MakePlayerObserver)
351 entity player = M_ARGV(0, entity);
353 ft_RemovePlayer(player);
356 MUTATOR_HOOKFUNCTION(ft, PlayerDies)
358 entity frag_attacker = M_ARGV(1, entity);
359 entity frag_target = M_ARGV(2, entity);
360 float frag_deathtype = M_ARGV(3, float);
362 if(round_handler_IsActive())
363 if(round_handler_CountdownRunning())
365 if (STAT(FROZEN, frag_target) == FROZEN_NORMAL)
366 Unfreeze(frag_target, true);
367 freezetag_count_alive_players();
368 frag_target.respawn_time = time;
369 frag_target.respawn_flags |= RESPAWN_FORCE;
373 frag_target.respawn_time = time + 1;
374 frag_target.respawn_flags |= RESPAWN_FORCE;
376 // Cases DEATH_TEAMCHANGE and DEATH_AUTOTEAMCHANGE are needed to fix a bug whe
377 // you succeed changing team through the menu: you both really die (gibbing) and get frozen
378 if(ITEM_DAMAGE_NEEDKILL(frag_deathtype)
379 || frag_deathtype == DEATH_TEAMCHANGE.m_id || frag_deathtype == DEATH_AUTOTEAMCHANGE.m_id)
381 // let the player die, he will be automatically frozen when he respawns
382 if (STAT(FROZEN, frag_target) != FROZEN_NORMAL)
384 freezetag_Add_Score(frag_target, frag_attacker);
385 freezetag_count_alive_players();
386 freezetag_LastPlayerForTeam_Notify(frag_target);
387 frag_target.freezetag_frozen_timeout = -2; // freeze on respawn
391 float t = frag_target.freezetag_frozen_timeout;
392 float t2 = frag_target.freezetag_frozen_time;
393 Unfreeze(frag_target, false); // remove ice
394 // keep timeout value so it can be restored when player will be refrozen on respawn
395 // NOTE this can't be exactly -2 since game starts from time 2
396 frag_target.freezetag_frozen_timeout = -t;
397 frag_target.freezetag_frozen_time = t2;
402 if (STAT(FROZEN, frag_target) == FROZEN_NORMAL)
405 freezetag_Freeze(frag_target, frag_attacker);
406 freezetag_LastPlayerForTeam_Notify(frag_target);
408 if(frag_attacker == frag_target || frag_attacker == NULL)
410 if(IS_PLAYER(frag_target))
411 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_SELF);
412 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_SELF, frag_target.netname);
416 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_FREEZE, frag_target.netname, frag_attacker.netname);
422 MUTATOR_HOOKFUNCTION(ft, PlayerSpawn)
424 entity player = M_ARGV(0, entity);
426 if(player.freezetag_frozen_timeout == -1) // if PlayerSpawn is called by reset_map_players
427 return true; // do nothing, round is starting right now
429 if(player.freezetag_frozen_timeout <= -2) // player was dead
431 float t = player.freezetag_frozen_timeout;
432 float t2 = player.freezetag_frozen_time;
433 freezetag_Freeze(player, NULL);
436 player.freezetag_frozen_timeout = -t;
437 player.freezetag_frozen_time = t2;
442 freezetag_count_alive_players();
444 if(round_handler_IsActive())
445 if(round_handler_IsRoundStarted())
447 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_SPAWN_LATE);
448 freezetag_Freeze(player, NULL);
454 MUTATOR_HOOKFUNCTION(ft, reset_map_players)
456 FOREACH_CLIENT(IS_PLAYER(it), {
457 CS(it).killcount = 0;
458 it.freezetag_revive_time = 0;
459 it.freezetag_frozen_timeout = -1;
460 PutClientInServer(it);
461 it.freezetag_frozen_timeout = 0;
463 freezetag_count_alive_players();
467 MUTATOR_HOOKFUNCTION(ft, GiveFragsForKill, CBC_ORDER_FIRST)
469 M_ARGV(2, float) = 0; // no frags counted in Freeze Tag
473 MUTATOR_HOOKFUNCTION(ft, Unfreeze)
475 entity targ = M_ARGV(0, entity);
476 targ.freezetag_frozen_time = 0;
477 targ.freezetag_frozen_timeout = 0;
480 MUTATOR_HOOKFUNCTION(ft, Damage_Calculate)
482 entity frag_attacker = M_ARGV(1, entity);
483 entity frag_target = M_ARGV(2, entity);
484 //float frag_deathtype = M_ARGV(3, float);
485 //float frag_damage = M_ARGV(4, float);
486 vector frag_force = M_ARGV(6, vector);
488 if (STAT(FROZEN, frag_target) == FROZEN_NORMAL && autocvar_g_freezetag_revive_auto_reducible
489 && autocvar_g_freezetag_frozen_maxtime > 0 && autocvar_g_freezetag_revive_auto)
492 if ((autocvar_g_freezetag_revive_auto_reducible < 0 || DIFF_TEAM(frag_attacker, frag_target))
493 && frag_target.freezetag_frozen_timeout > time)
495 if (fabs(autocvar_g_freezetag_revive_auto_reducible) == 1)
497 float maxforce = autocvar_g_freezetag_revive_auto_reducible_maxforce;
498 t = vlen(frag_force);
499 // limit hit force considered at once, e.g when you have the Strength
500 // powerup but also with weapons that fire multiple projectiles at once (crylink)
501 if (frag_target.freezetag_frozen_force + t > maxforce)
503 t = max(0, maxforce - frag_target.freezetag_frozen_force);
504 frag_target.freezetag_frozen_force = maxforce;
507 frag_target.freezetag_frozen_force += t;
508 t *= autocvar_g_freezetag_revive_auto_reducible_forcefactor;
510 frag_target.freezetag_frozen_timeout -= t;
511 if (frag_target.freezetag_frozen_timeout < time)
512 frag_target.freezetag_frozen_timeout = time;
517 #ifdef IN_REVIVING_RANGE
518 #undef IN_REVIVING_RANGE
521 #define IN_REVIVING_RANGE(player, it, revive_extra_size) \
522 (it != player && !IS_DEAD(it) && SAME_TEAM(it, player) \
523 && boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
525 MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST)
530 if(round_handler_IsActive())
531 if(!round_handler_IsRoundStarted())
534 entity player = M_ARGV(0, entity);
535 //if (STAT(FROZEN, player) == FROZEN_NORMAL)
536 //if(player.freezetag_frozen_timeout > 0 && time < player.freezetag_frozen_timeout)
537 //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);
539 player.freezetag_frozen_force = 0;
541 if (!(frametime && IS_PLAYER(player)))
544 entity revivers_last = NULL;
545 entity revivers_first = NULL;
547 bool player_is_reviving = false;
549 vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
550 FOREACH_CLIENT(IS_PLAYER(it), {
551 // check if player is reviving anyone
552 if (STAT(FROZEN, it) == FROZEN_NORMAL)
554 if ((STAT(FROZEN, player) == FROZEN_NORMAL))
556 if (!IN_REVIVING_RANGE(player, it, revive_extra_size))
558 player_is_reviving = true;
562 if (!(STAT(FROZEN, player) == FROZEN_NORMAL))
563 continue; // both player and it are NOT frozen
564 if (!IN_REVIVING_RANGE(player, it, revive_extra_size))
567 // found a teammate that is reviving player
568 if (autocvar_g_freezetag_revive_time_to_score > 0 && STAT(FROZEN, player) == FROZEN_NORMAL)
570 it.freezetag_revive_time += frametime / autocvar_g_freezetag_revive_time_to_score;
571 while (it.freezetag_revive_time > 1)
573 GameRules_scoring_add(it, SCORE, +1);
574 it.freezetag_revive_time -= 1;
578 revivers_last.chain = it;
585 revivers_last.chain = NULL;
587 // allow normal revival during automatic revival
588 // (if we wouldn't allow it then freezetag_frozen_timeout should be checked too in the previous loop)
589 //if (STAT(FROZEN, player) == FROZEN_NORMAL) // redundant check
590 if (!n && player.freezetag_frozen_timeout > 0 && time >= player.freezetag_frozen_timeout)
593 float base_progress = 0;
594 if (STAT(FROZEN, player) == FROZEN_NORMAL && autocvar_g_freezetag_revive_auto
595 && autocvar_g_freezetag_frozen_maxtime > 0 && autocvar_g_freezetag_revive_auto_progress)
597 // NOTE if auto-revival is in progress, manual revive speed is reduced so that it always takes the same amount of time
598 base_progress = bound(0, (1 - (player.freezetag_frozen_timeout - time) / autocvar_g_freezetag_frozen_maxtime), 1);
601 if (!n) // no teammate nearby
603 float clearspeed = autocvar_g_freezetag_revive_clearspeed;
604 if (STAT(FROZEN, player) == FROZEN_NORMAL)
606 if (autocvar_g_freezetag_revive_time_to_score > 0)
608 if (STAT(REVIVE_PROGRESS, player) > base_progress)
610 // reduce auto-revival time based on manual revival progress
611 base_progress = STAT(REVIVE_PROGRESS, player);
612 player.freezetag_frozen_timeout = time + autocvar_g_freezetag_frozen_maxtime * (1 - STAT(REVIVE_PROGRESS, player));
614 // don't clear revive progress, it would allow stacking points
615 // by entering and exiting the revival zone many times
616 STAT(REVIVE_PROGRESS, player) = base_progress;
619 STAT(REVIVE_PROGRESS, player) = bound(base_progress, STAT(REVIVE_PROGRESS, player) - frametime * clearspeed * (1 - base_progress), 1);
621 else if (!STAT(FROZEN, player) && !player_is_reviving)
622 STAT(REVIVE_PROGRESS, player) = base_progress; // thawing nobody
624 else if (STAT(FROZEN, player) == FROZEN_NORMAL) // OK, there is at least one teammate reviving us
626 float spd = autocvar_g_freezetag_revive_speed_t2s;
627 if (autocvar_g_freezetag_revive_time_to_score <= 0)
628 spd = autocvar_g_freezetag_revive_speed * (1 - base_progress);
629 STAT(REVIVE_PROGRESS, player) = bound(base_progress, STAT(REVIVE_PROGRESS, player) + frametime * max(1/60, spd), 1);
631 if(STAT(REVIVE_PROGRESS, player) >= 1)
633 float frozen_time = time - player.freezetag_frozen_time;
634 Unfreeze(player, false);
635 SetResourceExplicit(player, RES_HEALTH, ((warmup_stage) ? warmup_start_health : start_health));
636 player.spawnshieldtime = time + autocvar_g_freezetag_revive_spawnshield;
637 freezetag_count_alive_players();
641 if(autocvar_sv_eventlog)
642 GameLogEcho(strcat(":ft:autorevival:", ftos(player.playerid)));
643 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_AUTO_REVIVED, frozen_time);
644 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_AUTO_REVIVED, player.netname, frozen_time);
648 // EVERY team mate nearby gets a point (even if multiple!)
649 for(entity it = revivers_first; it; it = it.chain)
651 GameRules_scoring_add(it, FREEZETAG_REVIVALS, +1);
652 if (autocvar_g_freezetag_revive_time_to_score <= 0)
653 GameRules_scoring_add(it, SCORE, +1);
654 nades_GiveBonus(it, autocvar_g_nades_bonus_score_low);
657 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, revivers_first.netname);
658 Send_Notification(NOTIF_ONE, revivers_first, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
659 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED, player.netname, revivers_first.netname);
660 if(autocvar_sv_eventlog)
662 string revivers = "";
663 for(entity it = revivers_first; it; it = it.chain)
664 revivers = strcat(revivers, ftos(it.playerid), ",");
665 revivers = substring(revivers, 0, strlen(revivers) - 1);
666 GameLogEcho(strcat(":ft:revival:", ftos(player.playerid), ":", revivers));
670 for(entity it = revivers_first; it; it = it.chain)
671 STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player);
674 if (STAT(FROZEN, player) == FROZEN_NORMAL)
676 entity player_wp = player.waypointsprite_attached;
677 if (n > 0 || (n == 0 && STAT(REVIVE_PROGRESS, player) > 0.95))
679 WaypointSprite_UpdateSprites(player_wp, WP_Reviving, WP_Null, WP_Null);
680 WaypointSprite_UpdateTeamRadar(player_wp, RADARICON_WAYPOINT, WP_REVIVING_COLOR);
684 WaypointSprite_UpdateSprites(player_wp, WP_Frozen, WP_Null, WP_Null);
685 WaypointSprite_UpdateTeamRadar(player_wp, RADARICON_WAYPOINT, WP_FROZEN_COLOR);
688 WaypointSprite_UpdateMaxHealth(player_wp, 1);
689 WaypointSprite_UpdateHealth(player_wp, STAT(REVIVE_PROGRESS, player));
695 MUTATOR_HOOKFUNCTION(ft, SetStartItems)
697 start_items &= ~(IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS);
698 start_health = warmup_start_health = cvar("g_ft_start_health");
699 start_armorvalue = warmup_start_armorvalue = cvar("g_ft_start_armor");
700 start_ammo_shells = warmup_start_ammo_shells = cvar("g_ft_start_ammo_shells");
701 start_ammo_nails = warmup_start_ammo_nails = cvar("g_ft_start_ammo_nails");
702 start_ammo_rockets = warmup_start_ammo_rockets = cvar("g_ft_start_ammo_rockets");
703 start_ammo_cells = warmup_start_ammo_cells = cvar("g_ft_start_ammo_cells");
704 start_ammo_plasma = warmup_start_ammo_plasma = cvar("g_ft_start_ammo_plasma");
705 start_ammo_fuel = warmup_start_ammo_fuel = cvar("g_ft_start_ammo_fuel");
708 MUTATOR_HOOKFUNCTION(ft, HavocBot_ChooseRole)
710 entity bot = M_ARGV(0, entity);
715 bot.havocbot_role = havocbot_role_ft_freeing;
717 bot.havocbot_role = havocbot_role_ft_offense;
720 // if bots spawn all at once assign them a more appropriated role after a while
721 if (time < CS(bot).jointime + 1)
722 bot.havocbot_role_timeout = time + 10 + random() * 10;
727 MUTATOR_HOOKFUNCTION(ft, TeamBalance_CheckAllowedTeams, CBC_ORDER_EXCLUSIVE)
729 M_ARGV(0, float) = freezetag_teams;
733 MUTATOR_HOOKFUNCTION(ft, SetWeaponArena)
735 if(M_ARGV(0, string) == "0" || M_ARGV(0, string) == "")
736 M_ARGV(0, string) = autocvar_g_freezetag_weaponarena;
739 MUTATOR_HOOKFUNCTION(ft, FragCenterMessage)
741 entity frag_attacker = M_ARGV(0, entity);
742 entity frag_target = M_ARGV(1, entity);
743 //float frag_deathtype = M_ARGV(2, float);
744 int kill_count_to_attacker = M_ARGV(3, int);
745 int kill_count_to_target = M_ARGV(4, int);
747 if(STAT(FROZEN, frag_target) == FROZEN_NORMAL)
748 return; // target was already frozen, so this is just pushing them off the cliff
750 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));
751 Send_Notification(NOTIF_ONE, frag_target, MSG_CHOICE, CHOICE_FRAGGED_FREEZE, frag_attacker.netname, kill_count_to_target,
752 GetResource(frag_attacker, RES_HEALTH), GetResource(frag_attacker, RES_ARMOR), (IS_BOT_CLIENT(frag_attacker) ? -1 : CS(frag_attacker).ping));
757 MUTATOR_HOOKFUNCTION(ft, SV_ParseServerCommand)
759 string cmd_name = M_ARGV(0, string);
760 if (cmd_name == "shuffleteams")
761 shuffleteams_on_reset_map = !(round_handler_IsActive() && !round_handler_IsRoundStarted());
765 MUTATOR_HOOKFUNCTION(ft, Scores_CountFragsRemaining)
767 // announce remaining frags
771 void freezetag_Initialize()
773 freezetag_teams = autocvar_g_freezetag_teams_override;
774 if(freezetag_teams < 2)
775 freezetag_teams = cvar("g_freezetag_teams"); // read the cvar directly as it gets written earlier in the same frame
777 freezetag_teams = BITS(bound(2, freezetag_teams, 4));
778 GameRules_scoring(freezetag_teams, SFL_SORT_PRIO_PRIMARY, 0, {
779 field_team(ST_FT_ROUNDS, "rounds", SFL_SORT_PRIO_PRIMARY);
780 field(SP_FREEZETAG_REVIVALS, "revivals", 0);
783 round_handler_Spawn(freezetag_CheckTeams, freezetag_CheckWinner, func_null);
784 round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
786 EliminatedPlayers_Init(freezetag_isEliminated);