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