576512570cc2dc016a0513b1fbee1d55750b6fc6
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / gamemode_freezetag.qc
1 .float freezetag_frozen_time;
2 .float freezetag_frozen_timeout;
3 .float freezetag_revive_progress;
4 .entity freezetag_ice;
5 #define ICE_MAX_ALPHA 1
6 #define ICE_MIN_ALPHA 0.1
7 float freezetag_teams;
8
9 void freezetag_count_alive_players()
10 {
11         entity e;
12         total_players = redalive = bluealive = yellowalive = pinkalive = 0;
13         FOR_EACH_PLAYER(e) {
14                 if(e.team == NUM_TEAM_1 && e.health >= 1)
15                 {
16                         ++total_players;
17                         if (!e.freezetag_frozen) ++redalive;
18                 }
19                 else if(e.team == NUM_TEAM_2 && e.health >= 1)
20                 {
21                         ++total_players;
22                         if (!e.freezetag_frozen) ++bluealive;
23                 }
24                 else if(e.team == NUM_TEAM_3 && e.health >= 1)
25                 {
26                         ++total_players;
27                         if (!e.freezetag_frozen) ++yellowalive;
28                 }
29                 else if(e.team == NUM_TEAM_4 && e.health >= 1)
30                 {
31                         ++total_players;
32                         if (!e.freezetag_frozen) ++pinkalive;
33                 }
34         }
35         FOR_EACH_REALCLIENT(e) {
36                 e.redalive_stat = redalive;
37                 e.bluealive_stat = bluealive;
38                 e.yellowalive_stat = yellowalive;
39                 e.pinkalive_stat = pinkalive;
40         }
41 }
42 #define FREEZETAG_ALIVE_TEAMS() ((redalive > 0) + (bluealive > 0) + (yellowalive > 0) + (pinkalive > 0))
43 #define FREEZETAG_ALIVE_TEAMS_OK() (FREEZETAG_ALIVE_TEAMS() == freezetag_teams)
44
45 float prev_total_players;
46 float freezetag_CheckTeams()
47 {
48         if(FREEZETAG_ALIVE_TEAMS_OK())
49         {
50                 if(prev_total_players > 0)
51                         Kill_Notification(NOTIF_ALL, world, MSG_CENTER_CPID, CPID_MISSING_TEAMS);
52                 prev_total_players = -1;
53                 return 1;
54         }
55         if(prev_total_players != total_players)
56         {
57                 float p1 = 0, p2 = 0, p3 = 0, p4 = 0;
58                 if(!redalive) p1 = NUM_TEAM_1;
59                 if(!bluealive) p2 = NUM_TEAM_2;
60                 if(freezetag_teams >= 3)
61                 if(!yellowalive) p3 = NUM_TEAM_3;
62                 if(freezetag_teams >= 4)
63                 if(!pinkalive) p4 = NUM_TEAM_4;
64                 Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_MISSING_TEAMS, p1, p2, p3, p4);
65                 prev_total_players = total_players;
66         }
67         return 0;
68 }
69
70 float freezetag_getWinnerTeam()
71 {
72         float winner_team = 0;
73         if(redalive >= 1)
74                 winner_team = NUM_TEAM_1;
75         if(bluealive >= 1)
76         {
77                 if(winner_team) return 0;
78                 winner_team = NUM_TEAM_2;
79         }
80         if(yellowalive >= 1)
81         {
82                 if(winner_team) return 0;
83                 winner_team = NUM_TEAM_3;
84         }
85         if(pinkalive >= 1)
86         {
87                 if(winner_team) return 0;
88                 winner_team = NUM_TEAM_4;
89         }
90         if(winner_team)
91                 return winner_team;
92         return -1; // no player left
93 }
94
95 float freezetag_CheckWinner()
96 {
97         entity e;
98         if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0)
99         {
100                 Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ROUND_OVER);
101                 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ROUND_OVER);
102                 FOR_EACH_PLAYER(e)
103                         e.freezetag_frozen_timeout = 0;
104                 round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
105                 return 1;
106         }
107
108         if(FREEZETAG_ALIVE_TEAMS() > 1)
109                 return 0;
110
111         float winner_team;
112         winner_team = freezetag_getWinnerTeam();
113         if(winner_team > 0)
114         {
115                 Send_Notification(NOTIF_ALL, world, MSG_CENTER, APP_TEAM_NUM_4(winner_team, CENTER_ROUND_TEAM_WIN_));
116                 Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(winner_team, INFO_ROUND_TEAM_WIN_));
117                 TeamScore_AddToTeam(winner_team, ST_SCORE, +1);
118         }
119         else if(winner_team == -1)
120         {
121                 Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ROUND_TIED);
122                 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ROUND_TIED);
123         }
124
125         FOR_EACH_PLAYER(e)
126                 e.freezetag_frozen_timeout = 0;
127         round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
128         return 1;
129 }
130
131 // this is needed to allow the player to turn his view around (fixangle can't
132 // be used to freeze his view, as that also changes the angles), while not
133 // turning that ice object with the player
134 void freezetag_Ice_Think()
135 {
136         setorigin(self, self.owner.origin - '0 0 16');
137         self.nextthink = time;
138 }
139
140 void freezetag_Add_Score(entity attacker)
141 {
142         if(attacker == self)
143         {
144                 // you froze your own dumb self
145                 // counted as "suicide" already
146                 PlayerScore_Add(self, SP_SCORE, -1);
147         }
148         else if(IS_PLAYER(attacker))
149         {
150                 // got frozen by an enemy
151                 // counted as "kill" and "death" already
152                 PlayerScore_Add(self, SP_SCORE, -1);
153                 PlayerScore_Add(attacker, SP_SCORE, +1);
154         }
155         // else nothing - got frozen by the game type rules themselves
156 }
157
158 void freezetag_Freeze(entity attacker)
159 {
160         if(self.freezetag_frozen)
161                 return;
162         self.freezetag_frozen = 1;
163         self.freezetag_frozen_time = time;
164         self.freezetag_revive_progress = 0;
165         self.health = 1;
166         if(autocvar_g_freezetag_frozen_maxtime > 0)
167                 self.freezetag_frozen_timeout = time + autocvar_g_freezetag_frozen_maxtime;
168
169         freezetag_count_alive_players();
170
171         entity ice;
172         ice = spawn();
173         ice.owner = self;
174         ice.classname = "freezetag_ice";
175         ice.think = freezetag_Ice_Think;
176         ice.nextthink = time;
177         ice.frame = floor(random() * 21); // ice model has 20 different looking frames
178         ice.alpha = ICE_MAX_ALPHA;
179         ice.colormod = Team_ColorRGB(self.team);
180         ice.glowmod = ice.colormod;
181         setmodel(ice, "models/ice/ice.md3");
182
183         self.freezetag_ice = ice;
184
185         RemoveGrapplingHook(self);
186
187         // add waypoint
188         WaypointSprite_Spawn("freezetag_frozen", 0, 0, self, '0 0 64', world, self.team, self, waypointsprite_attached, TRUE, RADARICON_WAYPOINT, '0.25 0.90 1');
189
190         freezetag_Add_Score(attacker);
191 }
192
193 void freezetag_Unfreeze(entity attacker)
194 {
195         self.freezetag_frozen = 0;
196         self.freezetag_frozen_time = 0;
197         self.freezetag_frozen_timeout = 0;
198         self.freezetag_revive_progress = 0;
199
200         remove(self.freezetag_ice);
201         self.freezetag_ice = world;
202
203         if(self.waypointsprite_attached)
204                 WaypointSprite_Kill(self.waypointsprite_attached);
205 }
206
207
208 // ================
209 // Bot player logic
210 // ================
211
212 void() havocbot_role_ft_freeing;
213 void() havocbot_role_ft_offense;
214
215 void havocbot_goalrating_freeplayers(float ratingscale, vector org, float sradius)
216 {
217         entity head;
218         float distance;
219
220         FOR_EACH_PLAYER(head)
221         {
222                 if ((head != self) && (head.team == self.team))
223                 {
224                         if (head.freezetag_frozen)
225                         {
226                                 distance = vlen(head.origin - org);
227                                 if (distance > sradius)
228                                         continue;
229                                 navigation_routerating(head, ratingscale, 2000);
230                         }
231                         else
232                         {
233                                 // If teamate is not frozen still seek them out as fight better
234                                 // in a group.
235                                 navigation_routerating(head, ratingscale/3, 2000);
236                         }
237                 }
238         }
239 }
240
241 void havocbot_role_ft_offense()
242 {
243         entity head;
244         float unfrozen;
245
246         if(self.deadflag != DEAD_NO)
247                 return;
248
249         if (!self.havocbot_role_timeout)
250                 self.havocbot_role_timeout = time + random() * 10 + 20;
251
252         // Count how many players on team are unfrozen.
253         unfrozen = 0;
254         FOR_EACH_PLAYER(head)
255         {
256                 if ((head.team == self.team) && (!head.freezetag_frozen))
257                         unfrozen++;
258         }
259
260         // If only one left on team or if role has timed out then start trying to free players.
261         if (((unfrozen == 0) && (!self.freezetag_frozen)) || (time > self.havocbot_role_timeout))
262         {
263                 dprint("changing role to freeing\n");
264                 self.havocbot_role = havocbot_role_ft_freeing;
265                 self.havocbot_role_timeout = 0;
266                 return;
267         }
268
269         if (time > self.bot_strategytime)
270         {
271                 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
272
273                 navigation_goalrating_start();
274                 havocbot_goalrating_items(10000, self.origin, 10000);
275                 havocbot_goalrating_enemyplayers(20000, self.origin, 10000);
276                 havocbot_goalrating_freeplayers(9000, self.origin, 10000);
277                 //havocbot_goalrating_waypoints(1, self.origin, 1000);
278                 navigation_goalrating_end();
279         }
280 }
281
282 void havocbot_role_ft_freeing()
283 {
284         if(self.deadflag != DEAD_NO)
285                 return;
286
287         if (!self.havocbot_role_timeout)
288                 self.havocbot_role_timeout = time + random() * 10 + 20;
289
290         if (time > self.havocbot_role_timeout)
291         {
292                 dprint("changing role to offense\n");
293                 self.havocbot_role = havocbot_role_ft_offense;
294                 self.havocbot_role_timeout = 0;
295                 return;
296         }
297
298         if (time > self.bot_strategytime)
299         {
300                 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
301
302                 navigation_goalrating_start();
303                 havocbot_goalrating_items(8000, self.origin, 10000);
304                 havocbot_goalrating_enemyplayers(10000, self.origin, 10000);
305                 havocbot_goalrating_freeplayers(20000, self.origin, 10000);
306                 //havocbot_goalrating_waypoints(1, self.origin, 1000);
307                 navigation_goalrating_end();
308         }
309 }
310
311
312 // ==============
313 // Hook Functions
314 // ==============
315
316 MUTATOR_HOOKFUNCTION(freezetag_RemovePlayer)
317 {
318         self.health = 0; // neccessary to update correctly alive stats
319         freezetag_Unfreeze(world);
320         freezetag_count_alive_players();
321         return 1;
322 }
323
324 MUTATOR_HOOKFUNCTION(freezetag_PlayerDies)
325 {
326         if(round_handler_IsActive())
327         if(round_handler_CountdownRunning())
328         {
329                 if(self.freezetag_frozen)
330                         freezetag_Unfreeze(world);
331                 freezetag_count_alive_players();
332                 return 1; // let the player die so that he can respawn whenever he wants
333         }
334
335         // Cases DEATH_TEAMCHANGE and DEATH_AUTOTEAMCHANGE are needed to fix a bug whe
336         // you succeed changing team through the menu: you both really die (gibbing) and get frozen
337         if(ITEM_DAMAGE_NEEDKILL(frag_deathtype)
338                 || frag_deathtype == DEATH_TEAMCHANGE || frag_deathtype == DEATH_AUTOTEAMCHANGE)
339         {
340                 // let the player die, he will be automatically frozen when he respawns
341                 if(!self.freezetag_frozen)
342                 {
343                         freezetag_Add_Score(frag_attacker);
344                         freezetag_count_alive_players();
345                 }
346                 else
347                         freezetag_Unfreeze(world); // remove ice
348                 self.freezetag_frozen_timeout = -2; // freeze on respawn
349                 return 1;
350         }
351
352         if(self.freezetag_frozen)
353                 return 1;
354
355         freezetag_Freeze(frag_attacker);
356
357         if(frag_attacker == frag_target || frag_attacker == world)
358         {
359                 if(IS_PLAYER(frag_target))
360                         Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_SELF);
361                 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_SELF, frag_target.netname);
362         }
363         else
364         {
365                 if(IS_PLAYER(frag_target))
366                         Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_FROZEN, frag_attacker.netname);
367                 if(IS_PLAYER(frag_attacker))
368                         Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_FREEZETAG_FREEZE, frag_target.netname);
369                 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_FREEZE, frag_target.netname, frag_attacker.netname);
370         }
371
372         frag_target.health = 1; // "respawn" the player :P
373
374         return 1;
375 }
376
377 MUTATOR_HOOKFUNCTION(freezetag_PlayerSpawn)
378 {
379         if(self.freezetag_frozen_timeout == -1) // if PlayerSpawn is called by reset_map_players
380                 return 1; // do nothing, round is starting right now
381
382         if(self.freezetag_frozen_timeout == -2) // player was dead
383         {
384                 freezetag_Freeze(world);
385                 return 1;
386         }
387
388         freezetag_count_alive_players();
389
390         if(round_handler_IsActive())
391         if(round_handler_IsRoundStarted())
392         {
393                 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_FREEZETAG_SPAWN_LATE);
394                 freezetag_Freeze(world);
395         }
396
397         return 1;
398 }
399
400 MUTATOR_HOOKFUNCTION(freezetag_reset_map_players)
401 {
402         FOR_EACH_PLAYER(self)
403         {
404                 if (self.freezetag_frozen)
405                         freezetag_Unfreeze(world);
406                 self.freezetag_frozen_timeout = -1;
407                 PutClientInServer();
408                 self.freezetag_frozen_timeout = 0;
409         }
410         freezetag_count_alive_players();
411         return 1;
412 }
413
414 MUTATOR_HOOKFUNCTION(freezetag_GiveFragsForKill)
415 {
416         frag_score = 0; // no frags counted in Freeze Tag
417         return 1;
418 }
419
420 .float reviving; // temp var
421 MUTATOR_HOOKFUNCTION(freezetag_PlayerPreThink)
422 {
423         float n;
424
425         if(gameover)
426                 return 1;
427
428         if(self.freezetag_frozen)
429         {
430                 // keep health = 1
431                 self.pauseregen_finished = time + autocvar_g_balance_pause_health_regen;
432         }
433
434         if(round_handler_IsActive())
435         if(!round_handler_IsRoundStarted())
436                 return 1;
437
438         entity o;
439         o = world;
440         if(self.freezetag_frozen_timeout > 0 && time < self.freezetag_frozen_timeout)
441                 self.freezetag_ice.alpha = ICE_MIN_ALPHA + (ICE_MAX_ALPHA - ICE_MIN_ALPHA) * (self.freezetag_frozen_timeout - time) / (self.freezetag_frozen_timeout - self.freezetag_frozen_time);
442
443         if(self.freezetag_frozen_timeout > 0 && time >= self.freezetag_frozen_timeout)
444                 n = -1;
445         else
446         {
447                 vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
448                 n = 0;
449                 FOR_EACH_PLAYER(other) if(self != other)
450                 {
451                         if(other.freezetag_frozen == 0)
452                         {
453                                 if(other.team == self.team)
454                                 {
455                                         if(boxesoverlap(self.absmin - revive_extra_size, self.absmax + revive_extra_size, other.absmin, other.absmax))
456                                         {
457                                                 if(!o)
458                                                         o = other;
459                                                 if(self.freezetag_frozen)
460                                                         other.reviving = TRUE;
461                                                 ++n;
462                                         }
463                                 }
464                         }
465                 }
466         }
467
468         if(n && self.freezetag_frozen) // OK, there is at least one teammate reviving us
469         {
470                 self.freezetag_revive_progress = bound(0, self.freezetag_revive_progress + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
471                 self.health = max(1, self.freezetag_revive_progress * autocvar_g_balance_health_start);
472
473                 if(self.freezetag_revive_progress >= 1)
474                 {
475                         freezetag_Unfreeze(self);
476                         freezetag_count_alive_players();
477
478                         if(n == -1)
479                         {
480                                 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_FREEZETAG_AUTO_REVIVED, autocvar_g_freezetag_frozen_maxtime);
481                                 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_AUTO_REVIVED, self.netname, autocvar_g_freezetag_frozen_maxtime);
482                                 return 1;
483                         }
484
485                         // EVERY team mate nearby gets a point (even if multiple!)
486                         FOR_EACH_PLAYER(other)
487                         {
488                                 if(other.reviving)
489                                 {
490                                         PlayerScore_Add(other, SP_FREEZETAG_REVIVALS, +1);
491                                         PlayerScore_Add(other, SP_SCORE, +1);
492                                 }
493                         }
494
495                         Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_FREEZETAG_REVIVED, o.netname);
496                         Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, self.netname);
497                         Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_REVIVED, self.netname, o.netname);
498                 }
499
500                 FOR_EACH_PLAYER(other)
501                 {
502                         if(other.reviving)
503                         {
504                                 other.freezetag_revive_progress = self.freezetag_revive_progress;
505                                 other.reviving = FALSE;
506                         }
507                 }
508         }
509         else if(!n && self.freezetag_frozen) // only if no teammate is nearby will we reset
510         {
511                 self.freezetag_revive_progress = bound(0, self.freezetag_revive_progress - frametime * autocvar_g_freezetag_revive_clearspeed, 1);
512                 self.health = max(1, self.freezetag_revive_progress * autocvar_g_balance_health_start);
513         }
514         else if(!n)
515         {
516                 self.freezetag_revive_progress = 0; // thawing nobody
517         }
518
519         return 1;
520 }
521
522 MUTATOR_HOOKFUNCTION(freezetag_PlayerPhysics)
523 {
524         if(self.freezetag_frozen)
525         {
526                 if(autocvar_sv_dodging_frozen && IS_REAL_CLIENT(self))
527                 {
528                         self.movement_x = bound(-5, self.movement_x, 5);
529                         self.movement_y = bound(-5, self.movement_y, 5);
530                         self.movement_z = bound(-5, self.movement_z, 5);
531                 }
532                 else
533                         self.movement = '0 0 0';
534                         
535                 self.disableclientprediction = 1;
536         }
537         return 1;
538 }
539
540 MUTATOR_HOOKFUNCTION(freezetag_PlayerDamage_Calculate)
541 {
542         if(frag_target.freezetag_frozen && frag_deathtype != DEATH_HURTTRIGGER)
543         {
544                 if(autocvar_g_freezetag_revive_falldamage > 0)
545                 if(frag_deathtype == DEATH_FALL)
546                 if(frag_damage >= autocvar_g_freezetag_revive_falldamage)
547                 {
548                         freezetag_Unfreeze(frag_target);
549                         frag_target.health = autocvar_g_freezetag_revive_falldamage_health;
550                         pointparticles(particleeffectnum("iceorglass"), frag_target.origin, '0 0 0', 3);
551                         Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_REVIVED_FALL, frag_target.netname);
552                         Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_FALL);
553                 }
554         
555                 frag_damage = 0;
556                 frag_force = frag_force * autocvar_g_freezetag_frozen_force;
557         }
558         return 1;
559 }
560
561 MUTATOR_HOOKFUNCTION(freezetag_PlayerJump)
562 {
563         if(self.freezetag_frozen)
564                 return TRUE; // no jumping in freezetag when frozen
565         
566         return FALSE;
567 }
568
569 MUTATOR_HOOKFUNCTION(freezetag_ForbidThrowCurrentWeapon)
570 {
571         if (self.freezetag_frozen)
572                 return 1;
573         return 0;
574 }
575
576 MUTATOR_HOOKFUNCTION(freezetag_ItemTouch)
577 {
578         if (other.freezetag_frozen)
579                 return MUT_ITEMTOUCH_RETURN;
580         return MUT_ITEMTOUCH_CONTINUE;
581 }
582
583 MUTATOR_HOOKFUNCTION(freezetag_BotRoles)
584 {
585         if not(self.deadflag)
586         {
587                 if (random() < 0.5)
588                         self.havocbot_role = havocbot_role_ft_freeing;
589                 else
590                         self.havocbot_role = havocbot_role_ft_offense;
591         }
592
593         return TRUE;
594 }
595
596 MUTATOR_HOOKFUNCTION(freezetag_SpectateCopy)
597 {
598         self.freezetag_frozen = other.freezetag_frozen;
599         self.freezetag_revive_progress = other.freezetag_revive_progress;
600         return 0;
601 }
602
603 MUTATOR_HOOKFUNCTION(freezetag_GetTeamCount)
604 {
605         ret_float = freezetag_teams;
606         return 0;
607 }
608
609 MUTATOR_HOOKFUNCTION(freezetag_VehicleTouch)
610 {
611         if(other.freezetag_frozen)
612                 return TRUE;
613                 
614         return FALSE;
615 }
616
617 void freezetag_Initialize()
618 {
619         precache_model("models/ice/ice.md3");
620
621         freezetag_teams = autocvar_g_freezetag_teams_override;
622         if(freezetag_teams < 2)
623                 freezetag_teams = autocvar_g_freezetag_teams;
624         freezetag_teams = bound(2, freezetag_teams, 4);
625         ScoreRules_freezetag(freezetag_teams);
626
627         round_handler_Spawn(freezetag_CheckTeams, freezetag_CheckWinner, func_null);
628         round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
629
630         addstat(STAT_REDALIVE, AS_INT, redalive_stat);
631         addstat(STAT_BLUEALIVE, AS_INT, bluealive_stat);
632         addstat(STAT_YELLOWALIVE, AS_INT, yellowalive_stat);
633         addstat(STAT_PINKALIVE, AS_INT, pinkalive_stat);
634
635         addstat(STAT_FROZEN, AS_INT, freezetag_frozen);
636         addstat(STAT_REVIVE_PROGRESS, AS_FLOAT, freezetag_revive_progress);
637 }
638
639 MUTATOR_DEFINITION(gamemode_freezetag)
640 {
641         MUTATOR_HOOK(MakePlayerObserver, freezetag_RemovePlayer, CBC_ORDER_ANY);
642         MUTATOR_HOOK(ClientDisconnect, freezetag_RemovePlayer, CBC_ORDER_ANY);
643         MUTATOR_HOOK(PlayerDies, freezetag_PlayerDies, CBC_ORDER_ANY);
644         MUTATOR_HOOK(PlayerSpawn, freezetag_PlayerSpawn, CBC_ORDER_ANY);
645         MUTATOR_HOOK(reset_map_players, freezetag_reset_map_players, CBC_ORDER_ANY);
646         MUTATOR_HOOK(GiveFragsForKill, freezetag_GiveFragsForKill, CBC_ORDER_FIRST);
647         MUTATOR_HOOK(PlayerPreThink, freezetag_PlayerPreThink, CBC_ORDER_FIRST);
648         MUTATOR_HOOK(PlayerPhysics, freezetag_PlayerPhysics, CBC_ORDER_FIRST);
649         MUTATOR_HOOK(PlayerDamage_Calculate, freezetag_PlayerDamage_Calculate, CBC_ORDER_ANY);
650         MUTATOR_HOOK(PlayerJump, freezetag_PlayerJump, CBC_ORDER_ANY);
651         MUTATOR_HOOK(ForbidThrowCurrentWeapon, freezetag_ForbidThrowCurrentWeapon, CBC_ORDER_ANY);
652         MUTATOR_HOOK(ItemTouch, freezetag_ItemTouch, CBC_ORDER_ANY);
653         MUTATOR_HOOK(HavocBot_ChooseRule, freezetag_BotRoles, CBC_ORDER_ANY);
654         MUTATOR_HOOK(SpectateCopy, freezetag_SpectateCopy, CBC_ORDER_ANY);
655         MUTATOR_HOOK(GetTeamCount, freezetag_GetTeamCount, CBC_ORDER_EXCLUSIVE);
656         MUTATOR_HOOK(VehicleTouch, freezetag_VehicleTouch, CBC_ORDER_ANY);
657
658         MUTATOR_ONADD
659         {
660                 if(time > 1) // game loads at time 1
661                         error("This is a game type and it cannot be added at runtime.");
662                 freezetag_Initialize();
663         }
664
665         MUTATOR_ONROLLBACK_OR_REMOVE
666         {
667                 // we actually cannot roll back freezetag_Initialize here
668                 // BUT: we don't need to! If this gets called, adding always
669                 // succeeds.
670         }
671
672         MUTATOR_ONREMOVE
673         {
674                 print("This is a game type and it cannot be removed at runtime.");
675                 return -1;
676         }
677
678         return 0;
679 }