Xonotic
sv_freezetag.qc
Go to the documentation of this file.
1 #include "sv_freezetag.qh"
2 
4 #include <server/elimination.qh>
5 
9 //int autocvar_g_freezetag_teams;
12 
21 
23 {
24  total_players = 0;
25  for (int i = 1; i <= NUM_TEAMS; ++i)
26  {
28  }
30  {
31  ++total_players;
32  if (GetResource(it, RES_HEALTH) < 1 || STAT(FROZEN, it) == FROZEN_NORMAL)
33  {
34  continue;
35  }
36  entity team_ = Entity_GetTeam(it);
37  int num_alive = Team_GetNumberOfAlivePlayers(team_);
38  ++num_alive;
39  Team_SetNumberOfAlivePlayers(team_, num_alive);
40  });
42  {
43  STAT(REDALIVE, it) = Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(1));
44  STAT(BLUEALIVE, it) = Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(2));
45  STAT(YELLOWALIVE, it) = Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(3));
46  STAT(PINKALIVE, it) = Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(4));
47  });
48 
49  eliminatedPlayers.SendFlags |= 1;
50 }
51 
53 {
54  static float prev_missing_teams_mask;
56  {
57  if(prev_missing_teams_mask > 0)
58  Kill_Notification(NOTIF_ALL, NULL, MSG_CENTER, CPID_MISSING_TEAMS);
59  prev_missing_teams_mask = -1;
60  return true;
61  }
62  if(total_players == 0)
63  {
64  if(prev_missing_teams_mask > 0)
65  Kill_Notification(NOTIF_ALL, NULL, MSG_CENTER, CPID_MISSING_TEAMS);
66  prev_missing_teams_mask = -1;
67  return false;
68  }
69  int missing_teams_mask = 0;
70  for (int i = 1; i <= NUM_TEAMS; ++i)
71  {
72  if ((freezetag_teams & Team_IndexToBit(i)) &&
74  {
75  missing_teams_mask |= Team_IndexToBit(i);
76  }
77  }
78  if(prev_missing_teams_mask != missing_teams_mask)
79  {
80  Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_MISSING_TEAMS, missing_teams_mask);
81  prev_missing_teams_mask = missing_teams_mask;
82  }
83  return false;
84 }
85 
86 void nades_Clear(entity);
87 void nades_GiveBonus(entity player, float score);
88 
90 {
92  {
93  Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_OVER);
94  Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_OVER);
96  it.freezetag_frozen_timeout = 0;
97  it.freezetag_revive_time = 0;
98  nades_Clear(it);
99  });
100  game_stopped = true;
102  return true;
103  }
104 
105  int winner_team = Team_GetWinnerAliveTeam();
106  if (!winner_team)
107  return false;
108 
109  if(winner_team > 0)
110  {
111  Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_WIN));
112  Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_WIN));
113  TeamScore_AddToTeam(winner_team, ST_FT_ROUNDS, +1);
114  }
115  else if(winner_team == -1)
116  {
117  Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_TIED);
118  Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_TIED);
119  }
120 
122  it.freezetag_frozen_timeout = 0;
123  it.freezetag_revive_time = 0;
124  nades_Clear(it);
125  });
126 
127  game_stopped = true;
129  return true;
130 }
131 
133 {
134  entity last_pl = NULL;
135  FOREACH_CLIENT(IS_PLAYER(it) && it != this && SAME_TEAM(it, this), {
136  if (STAT(FROZEN, it) != FROZEN_NORMAL && GetResource(it, RES_HEALTH) >= 1)
137  {
138  if (!last_pl)
139  last_pl = it;
140  else
141  return NULL;
142  }
143  });
144  return last_pl;
145 }
146 
148 {
151  {
153  if(pl)
154  Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_ALONE);
155  }
156 }
157 
158 void freezetag_Add_Score(entity targ, entity attacker)
159 {
160  if(attacker == targ)
161  {
162  // you froze your own dumb self
163  // counted as "suicide" already
164  GameRules_scoring_add(targ, SCORE, -1);
165  }
166  else if(IS_PLAYER(attacker))
167  {
168  // got frozen by an enemy
169  // counted as "kill" and "death" already
170  GameRules_scoring_add(targ, SCORE, -1);
171  GameRules_scoring_add(attacker, SCORE, +1);
172  }
173  // else nothing - got frozen by the game type rules themselves
174 }
175 
176 // to be called when the player is frozen by freezetag (on death, spectator join etc), gives the score
177 void freezetag_Freeze(entity targ, entity attacker)
178 {
179  if(STAT(FROZEN, targ))
180  return;
181 
182  targ.freezetag_frozen_time = time;
184  targ.freezetag_frozen_timeout = time + autocvar_g_freezetag_frozen_maxtime;
185 
186  Freeze(targ, 0, FROZEN_NORMAL, true);
187 
189 
190  freezetag_Add_Score(targ, attacker);
191 }
192 
194 {
195  if(IS_PLAYER(e) && (STAT(FROZEN, e) == FROZEN_NORMAL || IS_DEAD(e)))
196  return true;
197  return false;
198 }
199 
200 
201 // ================
202 // Bot player logic
203 // ================
204 
207 
208 void havocbot_goalrating_ft_freeplayers(entity this, float ratingscale, vector org, float sradius)
209 {
210  entity best_pl = NULL;
211  float best_dist2 = FLOAT_MAX;
212  FOREACH_CLIENT(IS_PLAYER(it) && it != this && SAME_TEAM(it, this), {
213  if (STAT(FROZEN, it) == FROZEN_NORMAL)
214  {
215  if(vdist(it.origin - org, >, sradius))
216  continue;
217  navigation_routerating(this, it, ratingscale, 2000);
218  }
219  else if (best_dist2
220  && GetResource(it, RES_HEALTH) < GetResource(this, RES_HEALTH) + 30
221  && vlen2(it.origin - org) < best_dist2)
222  {
223  // If teamate is not frozen still seek them out as fight better
224  // in a group.
225  best_dist2 = vlen2(it.origin - org);
226  if (best_dist2 < 700 ** 2)
227  {
228  best_pl = NULL;
229  best_dist2 = 0; // already close to a teammate
230  }
231  else
232  best_pl = it;
233  }
234  });
235  if (best_pl)
236  navigation_routerating(this, best_pl, ratingscale / 2, 2000);
237 }
238 
240 {
241  if(IS_DEAD(this))
242  return;
243 
244  if (!this.havocbot_role_timeout)
245  this.havocbot_role_timeout = time + random() * 10 + 20;
246 
247  // Count how many players on team are unfrozen.
248  int unfrozen = 0;
249  FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, this) && STAT(FROZEN, it) != FROZEN_NORMAL, {
250  unfrozen++;
251  });
252 
253  // If only one left on team or if role has timed out then start trying to free players.
254  if ((!unfrozen && STAT(FROZEN, this) != FROZEN_NORMAL) || time > this.havocbot_role_timeout)
255  {
256  LOG_TRACE("changing role to freeing");
257  this.havocbot_role = havocbot_role_ft_freeing;
258  this.havocbot_role_timeout = 0;
259  return;
260  }
261 
263  {
265  havocbot_goalrating_items(this, 12000, this.origin, 10000);
266  havocbot_goalrating_enemyplayers(this, 10000, this.origin, 10000);
267  havocbot_goalrating_ft_freeplayers(this, 9000, this.origin, 10000);
268  havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
270 
272  }
273 }
274 
276 {
277  if(IS_DEAD(this))
278  return;
279 
280  if (!this.havocbot_role_timeout)
281  this.havocbot_role_timeout = time + random() * 10 + 20;
282 
283  if (time > this.havocbot_role_timeout)
284  {
285  LOG_TRACE("changing role to offense");
286  this.havocbot_role = havocbot_role_ft_offense;
287  this.havocbot_role_timeout = 0;
288  return;
289  }
290 
292  {
294  havocbot_goalrating_items(this, 10000, this.origin, 10000);
295  havocbot_goalrating_enemyplayers(this, 5000, this.origin, 10000);
296  havocbot_goalrating_ft_freeplayers(this, 20000, this.origin, 10000);
297  havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
299 
301  }
302 }
303 
304 
305 // ==============
306 // Hook Functions
307 // ==============
308 
310 {
311  if (STAT(FROZEN, this) != FROZEN_NORMAL)
313  Unfreeze(this, false);
314 
315  SetResourceExplicit(this, RES_HEALTH, 0); // neccessary to correctly count alive players
317 }
318 
320 {
321  entity player = M_ARGV(0, entity);
322 
323  ft_RemovePlayer(player);
324  return true;
325 }
326 
327 MUTATOR_HOOKFUNCTION(ft, MakePlayerObserver)
328 {
329  entity player = M_ARGV(0, entity);
330 
331  ft_RemovePlayer(player);
332 }
333 
334 MUTATOR_HOOKFUNCTION(ft, PlayerDies)
335 {
336  entity frag_attacker = M_ARGV(1, entity);
337  entity frag_target = M_ARGV(2, entity);
338  float frag_deathtype = M_ARGV(3, float);
339 
342  {
343  if (STAT(FROZEN, frag_target) == FROZEN_NORMAL)
344  Unfreeze(frag_target, true);
346  frag_target.respawn_time = time;
347  frag_target.respawn_flags |= RESPAWN_FORCE;
348  return true;
349  }
350 
351  frag_target.respawn_time = time + 1;
352  frag_target.respawn_flags |= RESPAWN_FORCE;
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) != FROZEN_NORMAL)
361  {
362  freezetag_Add_Score(frag_target, frag_attacker);
365  frag_target.freezetag_frozen_timeout = -2; // freeze on respawn
366  }
367  else
368  {
369  float t = frag_target.freezetag_frozen_timeout;
370  float t2 = frag_target.freezetag_frozen_time;
371  Unfreeze(frag_target, false); // remove ice
372  // keep timeout value so it can be restored when player will be refrozen on respawn
373  // NOTE this can't be exactly -2 since game starts from time 2
374  frag_target.freezetag_frozen_timeout = -t;
375  frag_target.freezetag_frozen_time = t2;
376  }
377  return true;
378  }
379 
380  if (STAT(FROZEN, frag_target) == FROZEN_NORMAL)
381  return true;
382 
383  freezetag_Freeze(frag_target, frag_attacker);
385 
386  if(frag_attacker == frag_target || frag_attacker == NULL)
387  {
388  if(IS_PLAYER(frag_target))
389  Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_SELF);
390  Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_SELF, frag_target.netname);
391  }
392  else
393  {
394  Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_FREEZE, frag_target.netname, frag_attacker.netname);
395  }
396 
397  return true;
398 }
399 
400 MUTATOR_HOOKFUNCTION(ft, PlayerSpawn)
401 {
402  entity player = M_ARGV(0, entity);
403 
404  if(player.freezetag_frozen_timeout == -1) // if PlayerSpawn is called by reset_map_players
405  return true; // do nothing, round is starting right now
406 
407  if(player.freezetag_frozen_timeout <= -2) // player was dead
408  {
409  float t = player.freezetag_frozen_timeout;
410  float t2 = player.freezetag_frozen_time;
411  freezetag_Freeze(player, NULL);
412  if (t < -2)
413  {
414  player.freezetag_frozen_timeout = -t;
415  player.freezetag_frozen_time = t2;
416  }
417  return true;
418  }
419 
421 
424  {
425  Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_SPAWN_LATE);
426  freezetag_Freeze(player, NULL);
427  }
428 
429  return true;
430 }
431 
432 MUTATOR_HOOKFUNCTION(ft, reset_map_players)
433 {
435  CS(it).killcount = 0;
436  it.freezetag_revive_time = 0;
437  it.freezetag_frozen_timeout = -1;
438  PutClientInServer(it);
439  it.freezetag_frozen_timeout = 0;
440  });
442  return true;
443 }
444 
445 MUTATOR_HOOKFUNCTION(ft, GiveFragsForKill, CBC_ORDER_FIRST)
446 {
447  M_ARGV(2, float) = 0; // no frags counted in Freeze Tag
448  return true;
449 }
450 
452 {
453  entity targ = M_ARGV(0, entity);
454  targ.freezetag_frozen_time = 0;
455  targ.freezetag_frozen_timeout = 0;
456 }
457 
458 MUTATOR_HOOKFUNCTION(ft, Damage_Calculate)
459 {
460  entity frag_attacker = M_ARGV(1, entity);
461  entity frag_target = M_ARGV(2, entity);
462  //float frag_deathtype = M_ARGV(3, float);
463  //float frag_damage = M_ARGV(4, float);
464  vector frag_force = M_ARGV(6, vector);
465 
466  if (STAT(FROZEN, frag_target) == FROZEN_NORMAL && autocvar_g_freezetag_revive_auto_reducible
468  {
469  float t = 0;
470  if ((autocvar_g_freezetag_revive_auto_reducible < 0 || DIFF_TEAM(frag_attacker, frag_target))
471  && frag_target.freezetag_frozen_timeout > time)
472  {
474  {
476  t = vlen(frag_force);
477  // limit hit force considered at once, e.g when you have the Strength
478  // powerup but also with weapons that fire multiple projectiles at once (crylink)
479  if (frag_target.freezetag_frozen_force + t > maxforce)
480  {
481  t = max(0, maxforce - frag_target.freezetag_frozen_force);
482  frag_target.freezetag_frozen_force = maxforce;
483  }
484  else
485  frag_target.freezetag_frozen_force += t;
487  }
488  frag_target.freezetag_frozen_timeout -= t;
489  if (frag_target.freezetag_frozen_timeout < time)
490  frag_target.freezetag_frozen_timeout = time;
491  }
492  }
493 }
494 
495 #ifdef IN_REVIVING_RANGE
496  #undef IN_REVIVING_RANGE
497 #endif
498 
499 #define IN_REVIVING_RANGE(player, it, revive_extra_size) \
500  (it != player && !IS_DEAD(it) && SAME_TEAM(it, player) \
501  && boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
502 
504 {
505  if(game_stopped)
506  return true;
507 
510  return true;
511 
512  entity player = M_ARGV(0, entity);
513  //if (STAT(FROZEN, player) == FROZEN_NORMAL)
514  //if(player.freezetag_frozen_timeout > 0 && time < player.freezetag_frozen_timeout)
515  //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);
516 
517  player.freezetag_frozen_force = 0;
518 
519  if (!(frametime && IS_PLAYER(player)))
520  return true;
521 
522  entity revivers_last = NULL;
523  entity revivers_first = NULL;
524 
525  bool player_is_reviving = false;
526  int n = 0;
527  vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
529  // check if player is reviving anyone
530  if (STAT(FROZEN, it) == FROZEN_NORMAL)
531  {
532  if ((STAT(FROZEN, player) == FROZEN_NORMAL))
533  continue;
534  if (!IN_REVIVING_RANGE(player, it, revive_extra_size))
535  continue;
536  player_is_reviving = true;
537  break;
538  }
539 
540  if (!(STAT(FROZEN, player) == FROZEN_NORMAL))
541  continue; // both player and it are NOT frozen
542  if (!IN_REVIVING_RANGE(player, it, revive_extra_size))
543  continue;
544 
545  // found a teammate that is reviving player
546  if (autocvar_g_freezetag_revive_time_to_score > 0 && STAT(FROZEN, player) == FROZEN_NORMAL)
547  {
548  it.freezetag_revive_time += frametime / autocvar_g_freezetag_revive_time_to_score;
549  while (it.freezetag_revive_time > 1)
550  {
551  GameRules_scoring_add(it, SCORE, +1);
552  it.freezetag_revive_time -= 1;
553  }
554  }
555  if (revivers_last)
556  revivers_last.chain = it;
557  revivers_last = it;
558  if (!revivers_first)
559  revivers_first = it;
560  ++n;
561  });
562  if (revivers_last)
563  revivers_last.chain = NULL;
564 
565  // allow normal revival during automatic revival
566  // (if we wouldn't allow it then freezetag_frozen_timeout should be checked too in the previous loop)
567  //if (STAT(FROZEN, player) == FROZEN_NORMAL) // redundant check
568  if (!n && player.freezetag_frozen_timeout > 0 && time >= player.freezetag_frozen_timeout)
569  n = -1;
570 
571  float base_progress = 0;
572  if (STAT(FROZEN, player) == FROZEN_NORMAL && autocvar_g_freezetag_revive_auto
574  {
575  // NOTE if auto-revival is in progress, manual revive speed is reduced so that it always takes the same amount of time
576  base_progress = bound(0, (1 - (player.freezetag_frozen_timeout - time) / autocvar_g_freezetag_frozen_maxtime), 1);
577  }
578 
579  if (!n) // no teammate nearby
580  {
581  float clearspeed = autocvar_g_freezetag_revive_clearspeed;
582  if (STAT(FROZEN, player) == FROZEN_NORMAL)
583  {
585  {
586  if (STAT(REVIVE_PROGRESS, player) > base_progress)
587  {
588  // reduce auto-revival time based on manual revival progress
589  base_progress = STAT(REVIVE_PROGRESS, player);
590  player.freezetag_frozen_timeout = time + autocvar_g_freezetag_frozen_maxtime * (1 - STAT(REVIVE_PROGRESS, player));
591  }
592  // don't clear revive progress, it would allow stacking points
593  // by entering and exiting the revival zone many times
594  STAT(REVIVE_PROGRESS, player) = base_progress;
595  }
596  else
597  STAT(REVIVE_PROGRESS, player) = bound(base_progress, STAT(REVIVE_PROGRESS, player) - frametime * clearspeed * (1 - base_progress), 1);
598  }
599  else if (!STAT(FROZEN, player) && !player_is_reviving)
600  STAT(REVIVE_PROGRESS, player) = base_progress; // thawing nobody
601  }
602  else if (STAT(FROZEN, player) == FROZEN_NORMAL) // OK, there is at least one teammate reviving us
603  {
606  spd = autocvar_g_freezetag_revive_speed * (1 - base_progress);
607  STAT(REVIVE_PROGRESS, player) = bound(base_progress, STAT(REVIVE_PROGRESS, player) + frametime * max(1/60, spd), 1);
608 
609  if(STAT(REVIVE_PROGRESS, player) >= 1)
610  {
611  float frozen_time = time - player.freezetag_frozen_time;
612  Unfreeze(player, false);
614  player.spawnshieldtime = time + autocvar_g_freezetag_revive_spawnshield;
616 
617  if(n == -1)
618  {
620  GameLogEcho(strcat(":ft:autorevival:", ftos(player.playerid)));
621  Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_AUTO_REVIVED, frozen_time);
622  Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_AUTO_REVIVED, player.netname, frozen_time);
623  return true;
624  }
625 
626  // EVERY team mate nearby gets a point (even if multiple!)
627  for(entity it = revivers_first; it; it = it.chain)
628  {
629  GameRules_scoring_add(it, FREEZETAG_REVIVALS, +1);
631  GameRules_scoring_add(it, SCORE, +1);
632  nades_GiveBonus(it, autocvar_g_nades_bonus_score_low);
633  }
634 
635  Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, revivers_first.netname);
636  Send_Notification(NOTIF_ONE, revivers_first, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
637  Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED, player.netname, revivers_first.netname);
639  {
640  string revivers = "";
641  for(entity it = revivers_first; it; it = it.chain)
642  revivers = strcat(revivers, ftos(it.playerid), ",");
643  revivers = substring(revivers, 0, strlen(revivers) - 1);
644  GameLogEcho(strcat(":ft:revival:", ftos(player.playerid), ":", revivers));
645  }
646  }
647 
648  for(entity it = revivers_first; it; it = it.chain)
649  STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player);
650  }
651 
652  if (STAT(FROZEN, player) == FROZEN_NORMAL)
653  {
654  entity player_wp = player.waypointsprite_attached;
655  if (n > 0 || (n == 0 && STAT(REVIVE_PROGRESS, player) > 0.95))
656  {
657  WaypointSprite_UpdateSprites(player_wp, WP_Reviving, WP_Null, WP_Null);
658  WaypointSprite_UpdateTeamRadar(player_wp, RADARICON_WAYPOINT, WP_REVIVING_COLOR);
659  }
660  else
661  {
662  WaypointSprite_UpdateSprites(player_wp, WP_Frozen, WP_Null, WP_Null);
663  WaypointSprite_UpdateTeamRadar(player_wp, RADARICON_WAYPOINT, WP_FROZEN_COLOR);
664  }
665 
666  WaypointSprite_UpdateMaxHealth(player_wp, 1);
667  WaypointSprite_UpdateHealth(player_wp, STAT(REVIVE_PROGRESS, player));
668  }
669 
670  return true;
671 }
672 
673 MUTATOR_HOOKFUNCTION(ft, SetStartItems)
674 {
675  start_items &= ~(IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS);
676  if(!cvar("g_use_ammunition"))
677  start_items |= IT_UNLIMITED_AMMO;
678 
687 }
688 
689 MUTATOR_HOOKFUNCTION(ft, HavocBot_ChooseRole)
690 {
691  entity bot = M_ARGV(0, entity);
692 
693  if (!IS_DEAD(bot))
694  {
695  if (random() < 0.5)
696  bot.havocbot_role = havocbot_role_ft_freeing;
697  else
698  bot.havocbot_role = havocbot_role_ft_offense;
699  }
700 
701  // if bots spawn all at once assign them a more appropriated role after a while
702  if (time < CS(bot).jointime + 1)
703  bot.havocbot_role_timeout = time + 10 + random() * 10;
704 
705  return true;
706 }
707 
709 {
710  M_ARGV(0, float) = freezetag_teams;
711  return true;
712 }
713 
714 MUTATOR_HOOKFUNCTION(ft, SetWeaponArena)
715 {
716  if(M_ARGV(0, string) == "0" || M_ARGV(0, string) == "")
718 }
719 
720 MUTATOR_HOOKFUNCTION(ft, FragCenterMessage)
721 {
722  entity frag_attacker = M_ARGV(0, entity);
723  entity frag_target = M_ARGV(1, entity);
724  //float frag_deathtype = M_ARGV(2, float);
725  int kill_count_to_attacker = M_ARGV(3, int);
726  int kill_count_to_target = M_ARGV(4, int);
727 
728  if(STAT(FROZEN, frag_target) == FROZEN_NORMAL)
729  return; // target was already frozen, so this is just pushing them off the cliff
730 
731  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));
732  Send_Notification(NOTIF_ONE, frag_target, MSG_CHOICE, CHOICE_FRAGGED_FREEZE, frag_attacker.netname, kill_count_to_target,
733  GetResource(frag_attacker, RES_HEALTH), GetResource(frag_attacker, RES_ARMOR), (IS_BOT_CLIENT(frag_attacker) ? -1 : CS(frag_attacker).ping));
734 
735  return true;
736 }
737 
738 MUTATOR_HOOKFUNCTION(ft, SV_ParseServerCommand)
739 {
740  string cmd_name = M_ARGV(0, string);
741  if (cmd_name == "shuffleteams")
743  return false;
744 }
745 
746 MUTATOR_HOOKFUNCTION(ft, Scores_CountFragsRemaining)
747 {
748  // announce remaining frags
749  return true;
750 }
751 
753 {
755  if(freezetag_teams < 2)
756  freezetag_teams = cvar("g_freezetag_teams"); // read the cvar directly as it gets written earlier in the same frame
757 
760  field_team(ST_FT_ROUNDS, "rounds", SFL_SORT_PRIO_PRIMARY);
761  field(SP_FREEZETAG_REVIVALS, "revivals", 0);
762  });
763 
766 
768 }
const int NUM_TEAMS
Number of teams in the game.
Definition: teams.qh:3
float autocvar_g_ft_start_ammo_fuel
Definition: sv_freezetag.qc:20
int Team_IndexToBit(int index)
Converts team index into bit value that is used in team bitmasks.
Definition: teams.qh:211
const int RESPAWN_FORCE
Definition: client.qh:330
#define APP_TEAM_NUM(num, prefix)
Definition: all.qh:85
#define round_handler_IsActive()
#define GameRules_scoring(teams, spprio, stprio, fields)
Definition: sv_rules.qh:53
float havocbot_role_timeout
Definition: api.qh:46
float autocvar_g_ft_start_ammo_cells
Definition: sv_freezetag.qc:18
bool freezetag_CheckTeams()
Definition: sv_freezetag.qc:52
float start_ammo_rockets
Definition: world.qh:87
void freezetag_Initialize()
void navigation_goalrating_start(entity this)
Definition: navigation.qc:1830
void(entity this) havocbot_role_ft_freeing
const int CBC_ORDER_EXCLUSIVE
Definition: base.qh:9
void havocbot_goalrating_items(entity this, float ratingscale, vector org, float sradius)
Definition: roles.qc:106
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
Definition: cl_resources.qc:15
int NumTeams(int teams)
Definition: scores_rules.qc:17
float start_ammo_fuel
Definition: world.qh:90
float warmup_start_ammo_shells
Definition: world.qh:104
void navigation_goalrating_end(entity this)
Definition: navigation.qc:1845
int autocvar_g_freezetag_revive_auto_reducible
Definition: sv_freezetag.qh:40
Header file that describes the resource system.
float autocvar_g_freezetag_revive_speed_t2s
Definition: sv_freezetag.qh:45
float autocvar_g_ft_start_health
Definition: sv_freezetag.qc:13
void round_handler_Spawn(bool() canRoundStart_func, bool() canRoundEnd_func, void() roundStart_func)
float autocvar_g_freezetag_revive_clearspeed
Definition: sv_freezetag.qc:7
entity freezetag_LastPlayerForTeam(entity this)
float TeamScore_AddToTeam(int t, float scorefield, float score)
Adds a score to the given team.
Definition: scores.qc:108
float autocvar_g_ft_start_ammo_rockets
Definition: sv_freezetag.qc:17
bool freezetag_isEliminated(entity e)
entity() spawn
void EliminatedPlayers_Init(float(entity) isEliminated_func)
Definition: elimination.qc:27
int Team_GetNumberOfAlivePlayers(entity team_ent)
Returns the number of alive players in a team.
Definition: teamplay.qc:85
ClientState CS(Client this)
Definition: state.qh:47
void Freeze(entity targ, float revivespeed, int frozen_type, bool show_waypoint)
Definition: damage.qc:494
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
#define GameRules_scoring_add(client, fld, value)
Definition: sv_rules.qh:78
float autocvar_g_freezetag_revive_time_to_score
Definition: sv_freezetag.qh:46
float autocvar_g_ft_start_ammo_plasma
Definition: sv_freezetag.qc:19
bool warmup_stage
Definition: main.qh:103
const int SFL_SORT_PRIO_PRIMARY
Definition: scores.qh:127
int start_items
Definition: world.qh:84
float start_ammo_shells
Definition: world.qh:85
origin
Definition: ent_cs.qc:114
float ping
Definition: main.qh:138
#define round_handler_IsRoundStarted()
#define DIFF_TEAM(a, b)
Definition: teams.qh:240
float autocvar_g_ft_start_armor
Definition: sv_freezetag.qc:14
void PlayerPreThink(entity this)
Definition: client.qc:2402
void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org, float sradius)
Definition: roles.qc:176
float autocvar_g_freezetag_revive_auto_reducible_maxforce
Definition: sv_freezetag.qh:42
entity Entity_GetTeam(entity this)
Returns the team entity of the given entity.
Definition: teamplay.qc:181
float warmup_start_ammo_plasma
Definition: world.qh:108
ClientDisconnect(this)
void freezetag_Freeze(entity targ, entity attacker)
float autocvar_g_freezetag_revive_extra_size
Definition: sv_freezetag.qh:43
void navigation_routerating(entity this, entity e, float f, float rangebias)
Definition: navigation.qc:1220
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
string autocvar_g_freezetag_weaponarena
Definition: sv_freezetag.qh:9
const vector WP_REVIVING_COLOR
Definition: all.inc:9
void freezetag_Add_Score(entity targ, entity attacker)
RES_HEALTH
Definition: ent_cs.qc:126
float autocvar_g_freezetag_warmup
Definition: sv_freezetag.qc:11
bool Entity_HasValidTeam(entity this)
Returns whether the given entity belongs to a valid team.
Definition: teamplay.qc:171
void Unfreeze(entity targ, bool reset_health)
Definition: damage.qc:546
float autocvar_g_freezetag_frozen_maxtime
Definition: sv_freezetag.qc:6
void nades_GiveBonus(entity player, float score)
int autocvar_g_freezetag_teams_override
Definition: sv_freezetag.qc:10
float warmup_start_ammo_cells
Definition: world.qh:107
#define vlen2(v)
Definition: vector.qh:4
float warmup_start_ammo_fuel
Definition: world.qh:109
bool navigation_goalrating_timeout(entity this)
Definition: navigation.qc:43
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
void havocbot_goalrating_ft_freeplayers(entity this, float ratingscale, vector org, float sradius)
const int FROZEN_NORMAL
Definition: damage.qh:109
float start_ammo_cells
Definition: world.qh:88
void freezetag_count_alive_players()
Definition: sv_freezetag.qc:22
float autocvar_g_freezetag_round_timelimit
Definition: sv_freezetag.qc:8
float autocvar_g_freezetag_revive_speed
Definition: sv_freezetag.qh:44
const int CBC_ORDER_FIRST
Definition: base.qh:7
#define NULL
Definition: post.qh:17
float frametime
Definition: csprogsdefs.qc:17
void Team_SetNumberOfAlivePlayers(entity team_ent, int number)
Sets the number of alive players in a team.
Definition: teamplay.qc:90
float jointime
Definition: client.qh:64
#define round_handler_GetEndTime()
void GameLogEcho(string s)
Definition: gamelog.qc:12
#define SAME_TEAM(a, b)
Definition: teams.qh:239
#define M_ARGV(x, type)
Definition: events.qh:17
#define IS_DEAD(s)
Definition: utils.qh:26
int Team_GetNumberOfAliveTeams()
Returns the number of alive teams.
Definition: teamplay.qc:110
entity Team_GetTeamFromIndex(int index)
Returns the global team entity at the given index.
Definition: teamplay.qc:57
void navigation_goalrating_timeout_set(entity this)
Definition: navigation.qc:19
int total_players
Definition: sv_rules.qh:8
float warmup_start_armorvalue
Definition: world.qh:111
int autocvar_g_freezetag_revive_auto_progress
Definition: sv_freezetag.qh:39
vector(float skel, float bonenum) _skel_get_boneabs_hidden
#define ITEM_DAMAGE_NEEDKILL(dt)
Definition: items.qh:130
bool shuffleteams_on_reset_map
Definition: sv_cmd.qh:7
#define IN_REVIVING_RANGE(player, it, revive_extra_size)
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
float start_health
Definition: world.qh:98
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition: vector.qh:8
#define LOG_TRACE(...)
Definition: log.qh:81
entity eliminatedPlayers
Definition: elimination.qh:3
float warmup_start_ammo_rockets
Definition: world.qh:106
float autocvar_g_ft_start_ammo_shells
Definition: sv_freezetag.qc:15
bool autocvar_g_freezetag_revive_auto
Definition: sv_freezetag.qh:38
void havocbot_goalrating_waypoints(entity this, float ratingscale, vector org, float sradius)
Definition: roles.qc:16
float autocvar_g_ft_start_ammo_nails
Definition: sv_freezetag.qc:16
float start_ammo_nails
Definition: world.qh:86
const vector WP_FROZEN_COLOR
Definition: all.inc:8
#define IS_BOT_CLIENT(v)
want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v))
Definition: utils.qh:15
void freezetag_LastPlayerForTeam_Notify(entity this)
float warmup_start_health
Definition: world.qh:110
void ft_RemovePlayer(entity this)
float autocvar_g_freezetag_revive_auto_reducible_forcefactor
Definition: sv_freezetag.qh:41
int Team_GetWinnerAliveTeam()
Returns the winner team.
Definition: teamplay.qc:95
PutClientInServer(this)
entity TeamBalance_CheckAllowedTeams(entity for_whom)
Checks whether the player can join teams according to global configuration and mutator settings...
Definition: teamplay.qc:487
void havocbot_role_ft_offense(entity this)
bool autocvar_sv_eventlog
Definition: gamelog.qh:3
if(IS_DEAD(this))
Definition: impulse.qc:92
float time
Definition: csprogsdefs.qc:16
float start_armorvalue
Definition: world.qh:99
const int ST_FT_ROUNDS
Definition: sv_freezetag.qh:11
void round_handler_Init(float the_delay, float the_count, float the_round_timelimit)
bool freezetag_CheckWinner()
Definition: sv_freezetag.qc:89
float start_ammo_plasma
Definition: world.qh:89
void nades_Clear(entity)
#define IS_PLAYER(v)
Definition: utils.qh:9
#define BITS(n)
Definition: bits.qh:9
MUTATOR_HOOKFUNCTION(ft, ClientDisconnect)
var void func_null()
const float FLOAT_MAX
Definition: float.qh:3
float autocvar_g_freezetag_revive_spawnshield
Definition: sv_freezetag.qh:49
float freezetag_teams
Definition: sv_freezetag.qh:36
#define round_handler_CountdownRunning()
float warmup_start_ammo_nails
Definition: world.qh:105
void havocbot_role_ft_freeing(entity this)