]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/mutators/mutator/gamemode_domination.qc
Kill the ret_string global
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_domination.qc
1 #include "gamemode_domination.qh"
2 #ifndef GAMEMODE_DOMINATION_H
3 #define GAMEMODE_DOMINATION_H
4
5 #define autocvar_g_domination_point_limit cvar("g_domination_point_limit")
6 bool autocvar_g_domination_roundbased;
7 int autocvar_g_domination_roundbased_point_limit;
8 int autocvar_g_domination_point_leadlimit;
9
10 void dom_Initialize();
11
12 REGISTER_MUTATOR(dom, false)
13 {
14         MUTATOR_ONADD
15         {
16                 if (time > 1) // game loads at time 1
17                         error("This is a game type and it cannot be added at runtime.");
18                 dom_Initialize();
19
20                 int fraglimit_override = autocvar_g_domination_point_limit;
21                 if (autocvar_g_domination_roundbased && autocvar_g_domination_roundbased_point_limit)
22                         fraglimit_override = autocvar_g_domination_roundbased_point_limit;
23
24                 ActivateTeamplay();
25                 SetLimits(fraglimit_override, autocvar_g_domination_point_leadlimit, autocvar_timelimit_override, -1);
26                 have_team_spawns = -1; // request team spawns
27         }
28
29         MUTATOR_ONREMOVE
30         {
31                 LOG_INFO("This is a game type and it cannot be removed at runtime.");
32                 return -1;
33         }
34
35         return 0;
36 }
37
38 // score rule declarations
39 const float ST_DOM_TICKS = 1;
40 const float SP_DOM_TICKS = 4;
41 const float SP_DOM_TAKES = 5;
42 const float ST_DOM_CAPS = 1;
43 const float SP_DOM_CAPS = 4;
44
45 // pps: points per second
46 .float dom_total_pps = _STAT(DOM_TOTAL_PPS);
47 .float dom_pps_red = _STAT(DOM_PPS_RED);
48 .float dom_pps_blue = _STAT(DOM_PPS_BLUE);
49 .float dom_pps_yellow = _STAT(DOM_PPS_YELLOW);
50 .float dom_pps_pink = _STAT(DOM_PPS_PINK);
51 float total_pps;
52 float pps_red;
53 float pps_blue;
54 float pps_yellow;
55 float pps_pink;
56
57 // capture declarations
58 .float enemy_playerid;
59 .entity sprite;
60 .float captime;
61
62 // misc globals
63 float domination_roundbased;
64 float domination_teams;
65 #endif
66
67 #ifdef IMPLEMENTATION
68
69 #include <server/teamplay.qh>
70
71 bool g_domination;
72
73 int autocvar_g_domination_default_teams;
74 bool autocvar_g_domination_disable_frags;
75 int autocvar_g_domination_point_amt;
76 bool autocvar_g_domination_point_fullbright;
77 float autocvar_g_domination_round_timelimit;
78 float autocvar_g_domination_warmup;
79 float autocvar_g_domination_point_rate;
80 int autocvar_g_domination_teams_override;
81
82 void dom_EventLog(string mode, float team_before, entity actor) // use an alias for easy changing and quick editing later
83 {
84         if(autocvar_sv_eventlog)
85                 GameLogEcho(strcat(":dom:", mode, ":", ftos(team_before), ((actor != world) ? (strcat(":", ftos(actor.playerid))) : "")));
86 }
87
88 void set_dom_state(entity e)
89 {
90         e.dom_total_pps = total_pps;
91         e.dom_pps_red = pps_red;
92         e.dom_pps_blue = pps_blue;
93         if(domination_teams >= 3)
94                 e.dom_pps_yellow = pps_yellow;
95         if(domination_teams >= 4)
96                 e.dom_pps_pink = pps_pink;
97 }
98
99 void dompoint_captured ()
100 {SELFPARAM();
101         entity head;
102         float old_delay, old_team, real_team;
103
104         // now that the delay has expired, switch to the latest team to lay claim to this point
105         head = self.owner;
106
107         real_team = self.cnt;
108         self.cnt = -1;
109
110         dom_EventLog("taken", self.team, self.dmg_inflictor);
111         self.dmg_inflictor = world;
112
113         self.goalentity = head;
114         self.model = head.mdl;
115         self.modelindex = head.dmg;
116         self.skin = head.skin;
117
118         float points, wait_time;
119         if (autocvar_g_domination_point_amt)
120                 points = autocvar_g_domination_point_amt;
121         else
122                 points = self.frags;
123         if (autocvar_g_domination_point_rate)
124                 wait_time = autocvar_g_domination_point_rate;
125         else
126                 wait_time = self.wait;
127
128         if(domination_roundbased)
129                 bprint(sprintf("^3%s^3%s\n", head.netname, self.message));
130         else
131                 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_DOMINATION_CAPTURE_TIME, head.netname, self.message, points, wait_time);
132
133         if(self.enemy.playerid == self.enemy_playerid)
134                 PlayerScore_Add(self.enemy, SP_DOM_TAKES, 1);
135         else
136                 self.enemy = world;
137
138         if (head.noise != "")
139                 if(self.enemy)
140                         _sound(self.enemy, CH_TRIGGER, head.noise, VOL_BASE, ATTEN_NORM);
141                 else
142                         _sound(self, CH_TRIGGER, head.noise, VOL_BASE, ATTEN_NORM);
143         if (head.noise1 != "")
144                 play2all(head.noise1);
145
146         self.delay = time + wait_time;
147
148         // do trigger work
149         old_delay = self.delay;
150         old_team = self.team;
151         self.team = real_team;
152         self.delay = 0;
153         SUB_UseTargets (self, self, NULL);
154         self.delay = old_delay;
155         self.team = old_team;
156
157         entity msg = WP_DomNeut;
158         switch(self.team)
159         {
160                 case NUM_TEAM_1: msg = WP_DomRed; break;
161                 case NUM_TEAM_2: msg = WP_DomBlue; break;
162                 case NUM_TEAM_3: msg = WP_DomYellow; break;
163                 case NUM_TEAM_4: msg = WP_DomPink; break;
164         }
165
166         WaypointSprite_UpdateSprites(self.sprite, msg, WP_Null, WP_Null);
167
168         total_pps = 0, pps_red = 0, pps_blue = 0, pps_yellow = 0, pps_pink = 0;
169         for(head = world; (head = find(head, classname, "dom_controlpoint")) != world; )
170         FOREACH_ENTITY_CLASS("dom_controlpoint", true, LAMBDA(
171                 if (autocvar_g_domination_point_amt)
172                         points = autocvar_g_domination_point_amt;
173                 else
174                         points = it.frags;
175                 if (autocvar_g_domination_point_rate)
176                         wait_time = autocvar_g_domination_point_rate;
177                 else
178                         wait_time = it.wait;
179                 switch(it.goalentity.team)
180                 {
181                         case NUM_TEAM_1: pps_red += points/wait_time; break;
182                         case NUM_TEAM_2: pps_blue += points/wait_time; break;
183                         case NUM_TEAM_3: pps_yellow += points/wait_time; break;
184                         case NUM_TEAM_4: pps_pink += points/wait_time; break;
185                 }
186                 total_pps += points/wait_time;
187         ));
188
189         WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_DOMPOINT, colormapPaletteColor(self.goalentity.team - 1, 0));
190         WaypointSprite_Ping(self.sprite);
191
192         self.captime = time;
193
194         FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(set_dom_state(it)));
195 }
196
197 void AnimateDomPoint()
198 {SELFPARAM();
199         if(self.pain_finished > time)
200                 return;
201         self.pain_finished = time + self.t_width;
202         if(self.nextthink > self.pain_finished)
203                 self.nextthink = self.pain_finished;
204
205         self.frame = self.frame + 1;
206         if(self.frame > self.t_length)
207                 self.frame = 0;
208 }
209
210 void dompointthink(entity this)
211 {
212         float fragamt;
213
214         self.nextthink = time + 0.1;
215
216         //self.frame = self.frame + 1;
217         //if(self.frame > 119)
218         //      self.frame = 0;
219         AnimateDomPoint();
220
221         // give points
222
223         if (gameover || self.delay > time || time < game_starttime)     // game has ended, don't keep giving points
224                 return;
225
226         if(autocvar_g_domination_point_rate)
227                 self.delay = time + autocvar_g_domination_point_rate;
228         else
229                 self.delay = time + self.wait;
230
231         // give credit to the team
232         // NOTE: this defaults to 0
233         if (!domination_roundbased)
234         if (self.goalentity.netname != "")
235         {
236                 if(autocvar_g_domination_point_amt)
237                         fragamt = autocvar_g_domination_point_amt;
238                 else
239                         fragamt = self.frags;
240                 TeamScore_AddToTeam(self.goalentity.team, ST_SCORE, fragamt);
241                 TeamScore_AddToTeam(self.goalentity.team, ST_DOM_TICKS, fragamt);
242
243                 // give credit to the individual player, if he is still there
244                 if (self.enemy.playerid == self.enemy_playerid)
245                 {
246                         PlayerScore_Add(self.enemy, SP_SCORE, fragamt);
247                         PlayerScore_Add(self.enemy, SP_DOM_TICKS, fragamt);
248                 }
249                 else
250                         self.enemy = world;
251         }
252 }
253
254 void dompointtouch(entity this)
255 {
256         entity head;
257         if (!IS_PLAYER(other))
258                 return;
259         if (other.health < 1)
260                 return;
261
262         if(round_handler_IsActive() && !round_handler_IsRoundStarted())
263                 return;
264
265         if(time < self.captime + 0.3)
266                 return;
267
268         // only valid teams can claim it
269         head = find(world, classname, "dom_team");
270         while (head && head.team != other.team)
271                 head = find(head, classname, "dom_team");
272         if (!head || head.netname == "" || head == self.goalentity)
273                 return;
274
275         // delay capture
276
277         self.team = self.goalentity.team; // this stores the PREVIOUS team!
278
279         self.cnt = other.team;
280         self.owner = head; // team to switch to after the delay
281         self.dmg_inflictor = other;
282
283         // self.state = 1;
284         // self.delay = time + cvar("g_domination_point_capturetime");
285         //self.nextthink = time + cvar("g_domination_point_capturetime");
286         //self.think = dompoint_captured;
287
288         // go to neutral team in the mean time
289         head = find(world, classname, "dom_team");
290         while (head && head.netname != "")
291                 head = find(head, classname, "dom_team");
292         if(head == world)
293                 return;
294
295         WaypointSprite_UpdateSprites(self.sprite, WP_DomNeut, WP_Null, WP_Null);
296         WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_DOMPOINT, '0 1 1');
297         WaypointSprite_Ping(self.sprite);
298
299         self.goalentity = head;
300         self.model = head.mdl;
301         self.modelindex = head.dmg;
302         self.skin = head.skin;
303
304         self.enemy = other; // individual player scoring
305         self.enemy_playerid = other.playerid;
306         dompoint_captured();
307 }
308
309 void dom_controlpoint_setup(entity this)
310 {
311         entity head;
312         // find the spawnfunc_dom_team representing unclaimed points
313         head = find(world, classname, "dom_team");
314         while(head && head.netname != "")
315                 head = find(head, classname, "dom_team");
316         if (!head)
317                 objerror("no spawnfunc_dom_team with netname \"\" found\n");
318
319         // copy important properties from spawnfunc_dom_team entity
320         self.goalentity = head;
321         _setmodel(self, head.mdl); // precision already set
322         self.skin = head.skin;
323
324         self.cnt = -1;
325
326         if(self.message == "")
327                 self.message = " has captured a control point";
328
329         if(self.frags <= 0)
330                 self.frags = 1;
331         if(self.wait <= 0)
332                 self.wait = 5;
333
334         float points, waittime;
335         if (autocvar_g_domination_point_amt)
336                 points = autocvar_g_domination_point_amt;
337         else
338                 points = self.frags;
339         if (autocvar_g_domination_point_rate)
340                 waittime = autocvar_g_domination_point_rate;
341         else
342                 waittime = self.wait;
343
344         total_pps += points/waittime;
345
346         if(!self.t_width)
347                 self.t_width = 0.02; // frame animation rate
348         if(!self.t_length)
349                 self.t_length = 239; // maximum frame
350
351         setthink(self, dompointthink);
352         self.nextthink = time;
353         settouch(self, dompointtouch);
354         self.solid = SOLID_TRIGGER;
355         self.flags = FL_ITEM;
356         setsize(self, '-32 -32 -32', '32 32 32');
357         setorigin(self, self.origin + '0 0 20');
358         droptofloor(self);
359
360         waypoint_spawnforitem(self);
361         WaypointSprite_SpawnFixed(WP_DomNeut, self.origin + '0 0 32', self, sprite, RADARICON_DOMPOINT);
362 }
363
364 float total_controlpoints;
365 void Domination_count_controlpoints()
366 {
367         entity e;
368         total_controlpoints = redowned = blueowned = yellowowned = pinkowned = 0;
369         for(e = world; (e = find(e, classname, "dom_controlpoint")) != world; )
370         {
371                 ++total_controlpoints;
372                 redowned += (e.goalentity.team == NUM_TEAM_1);
373                 blueowned += (e.goalentity.team == NUM_TEAM_2);
374                 yellowowned += (e.goalentity.team == NUM_TEAM_3);
375                 pinkowned += (e.goalentity.team == NUM_TEAM_4);
376         }
377 }
378
379 float Domination_GetWinnerTeam()
380 {
381         float winner_team = 0;
382         if(redowned == total_controlpoints)
383                 winner_team = NUM_TEAM_1;
384         if(blueowned == total_controlpoints)
385         {
386                 if(winner_team) return 0;
387                 winner_team = NUM_TEAM_2;
388         }
389         if(yellowowned == total_controlpoints)
390         {
391                 if(winner_team) return 0;
392                 winner_team = NUM_TEAM_3;
393         }
394         if(pinkowned == total_controlpoints)
395         {
396                 if(winner_team) return 0;
397                 winner_team = NUM_TEAM_4;
398         }
399         if(winner_team)
400                 return winner_team;
401         return -1; // no control points left?
402 }
403
404 #define DOM_OWNED_CONTROLPOINTS() ((redowned > 0) + (blueowned > 0) + (yellowowned > 0) + (pinkowned > 0))
405 #define DOM_OWNED_CONTROLPOINTS_OK() (DOM_OWNED_CONTROLPOINTS() < total_controlpoints)
406 float Domination_CheckWinner()
407 {
408         if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0)
409         {
410                 Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ROUND_OVER);
411                 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ROUND_OVER);
412                 round_handler_Init(5, autocvar_g_domination_warmup, autocvar_g_domination_round_timelimit);
413                 return 1;
414         }
415
416         Domination_count_controlpoints();
417
418         float winner_team = Domination_GetWinnerTeam();
419
420         if(winner_team == -1)
421                 return 0;
422
423         if(winner_team > 0)
424         {
425                 Send_Notification(NOTIF_ALL, world, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_WIN));
426                 Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_WIN));
427                 TeamScore_AddToTeam(winner_team, ST_DOM_CAPS, +1);
428         }
429         else if(winner_team == -1)
430         {
431                 Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ROUND_TIED);
432                 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ROUND_TIED);
433         }
434
435         round_handler_Init(5, autocvar_g_domination_warmup, autocvar_g_domination_round_timelimit);
436
437         return 1;
438 }
439
440 float Domination_CheckPlayers()
441 {
442         return 1;
443 }
444
445 void Domination_RoundStart()
446 {
447         FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(it.player_blocked = false));
448 }
449
450 //go to best items, or control points you don't own
451 void havocbot_role_dom(entity this)
452 {
453         if(IS_DEAD(this))
454                 return;
455
456         if (this.bot_strategytime < time)
457         {
458                 this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
459                 navigation_goalrating_start(this);
460                 havocbot_goalrating_controlpoints(this, 10000, this.origin, 15000);
461                 havocbot_goalrating_items(this, 8000, this.origin, 8000);
462                 //havocbot_goalrating_enemyplayers(this, 3000, this.origin, 2000);
463                 //havocbot_goalrating_waypoints(1, this.origin, 1000);
464                 navigation_goalrating_end(this);
465         }
466 }
467
468 MUTATOR_HOOKFUNCTION(dom, GetTeamCount)
469 {
470         // fallback?
471         M_ARGV(0, float) = domination_teams;
472         string ret_string = "dom_team";
473
474         entity head = find(world, classname, ret_string);
475         while(head)
476         {
477                 if(head.netname != "")
478                 {
479                         switch(head.team)
480                         {
481                                 case NUM_TEAM_1: c1 = 0; break;
482                                 case NUM_TEAM_2: c2 = 0; break;
483                                 case NUM_TEAM_3: c3 = 0; break;
484                                 case NUM_TEAM_4: c4 = 0; break;
485                         }
486                 }
487
488                 head = find(head, classname, ret_string);
489         }
490
491         M_ARGV(1, string) = string_null;
492
493         return true;
494 }
495
496 MUTATOR_HOOKFUNCTION(dom, reset_map_players)
497 {
498         total_pps = 0, pps_red = 0, pps_blue = 0, pps_yellow = 0, pps_pink = 0;
499         FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
500                 WITHSELF(it, PutClientInServer());
501                 if(domination_roundbased)
502                         it.player_blocked = 1;
503                 if(IS_REAL_CLIENT(it))
504                         set_dom_state(it);
505         ));
506         return 1;
507 }
508
509 MUTATOR_HOOKFUNCTION(dom, PlayerSpawn)
510 {
511         entity player = M_ARGV(0, entity);
512
513         if(domination_roundbased)
514         if(!round_handler_IsRoundStarted())
515                 player.player_blocked = 1;
516         else
517                 player.player_blocked = 0;
518         return false;
519 }
520
521 MUTATOR_HOOKFUNCTION(dom, ClientConnect)
522 {
523         entity player = M_ARGV(0, entity);
524
525         set_dom_state(player);
526 }
527
528 MUTATOR_HOOKFUNCTION(dom, HavocBot_ChooseRole)
529 {
530         entity bot = M_ARGV(0, entity);
531
532         bot.havocbot_role = havocbot_role_dom;
533         return true;
534 }
535
536 /*QUAKED spawnfunc_dom_controlpoint (0 .5 .8) (-16 -16 -24) (16 16 32)
537 Control point for Domination gameplay.
538 */
539 spawnfunc(dom_controlpoint)
540 {
541         if(!g_domination)
542         {
543                 remove(this);
544                 return;
545         }
546         setthink(this, dom_controlpoint_setup);
547         this.nextthink = time + 0.1;
548         this.reset = dom_controlpoint_setup;
549
550         if(!this.scale)
551                 this.scale = 0.6;
552
553         this.effects = this.effects | EF_LOWPRECISION;
554         if (autocvar_g_domination_point_fullbright)
555                 this.effects |= EF_FULLBRIGHT;
556 }
557
558 /*QUAKED spawnfunc_dom_team (0 .5 .8) (-32 -32 -24) (32 32 32)
559 Team declaration for Domination gameplay, this allows you to decide what team
560 names and control point models are used in your map.
561
562 Note: If you use spawnfunc_dom_team entities you must define at least 3 and only two
563 can have netname set!  The nameless team owns all control points at start.
564
565 Keys:
566 "netname"
567  Name of the team (for example Red Team, Blue Team, Green Team, Yellow Team, Life, Death, etc)
568 "cnt"
569  Scoreboard color of the team (for example 4 is red and 13 is blue)
570 "model"
571  Model to use for control points owned by this team (for example
572  "progs/b_g_key.mdl" is a gold keycard, and "progs/b_s_key.mdl" is a silver
573  keycard)
574 "skin"
575  Skin of the model to use (for team skins on a single model)
576 "noise"
577  Sound to play when this team captures a point.
578  (this is a localized sound, like a small alarm or other effect)
579 "noise1"
580  Narrator speech to play when this team captures a point.
581  (this is a global sound, like "Red team has captured a control point")
582 */
583
584 spawnfunc(dom_team)
585 {
586         if(!g_domination || autocvar_g_domination_teams_override >= 2)
587         {
588                 remove(this);
589                 return;
590         }
591         precache_model(this.model);
592         if (this.noise != "")
593                 precache_sound(this.noise);
594         if (this.noise1 != "")
595                 precache_sound(this.noise1);
596         this.classname = "dom_team";
597         _setmodel(this, this.model); // precision not needed
598         this.mdl = this.model;
599         this.dmg = this.modelindex;
600         this.model = "";
601         this.modelindex = 0;
602         // this would have to be changed if used in quakeworld
603         if(this.cnt)
604                 this.team = this.cnt + 1; // WHY are these different anyway?
605 }
606
607 // scoreboard setup
608 void ScoreRules_dom(float teams)
609 {
610         if(domination_roundbased)
611         {
612                 ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, 0, true);
613                 ScoreInfo_SetLabel_TeamScore  (ST_DOM_CAPS, "caps", SFL_SORT_PRIO_PRIMARY);
614                 ScoreInfo_SetLabel_PlayerScore(SP_DOM_TAKES, "takes", 0);
615                 ScoreRules_basics_end();
616         }
617         else
618         {
619                 float sp_domticks, sp_score;
620                 sp_score = sp_domticks = 0;
621                 if(autocvar_g_domination_disable_frags)
622                         sp_domticks = SFL_SORT_PRIO_PRIMARY;
623                 else
624                         sp_score = SFL_SORT_PRIO_PRIMARY;
625                 ScoreRules_basics(teams, sp_score, sp_score, true);
626                 ScoreInfo_SetLabel_TeamScore  (ST_DOM_TICKS,    "ticks",     sp_domticks);
627                 ScoreInfo_SetLabel_PlayerScore(SP_DOM_TICKS,    "ticks",     sp_domticks);
628                 ScoreInfo_SetLabel_PlayerScore(SP_DOM_TAKES,    "takes",     0);
629                 ScoreRules_basics_end();
630         }
631 }
632
633 // code from here on is just to support maps that don't have control point and team entities
634 void dom_spawnteam (string teamname, float teamcolor, string pointmodel, float pointskin, Sound capsound, string capnarration, string capmessage)
635 {
636     TC(Sound, capsound);
637     entity e = new_pure(dom_team);
638         e.netname = strzone(teamname);
639         e.cnt = teamcolor;
640         e.model = pointmodel;
641         e.skin = pointskin;
642         e.noise = strzone(Sound_fixpath(capsound));
643         e.noise1 = strzone(capnarration);
644         e.message = strzone(capmessage);
645
646         // this code is identical to spawnfunc_dom_team
647         _setmodel(e, e.model); // precision not needed
648         e.mdl = e.model;
649         e.dmg = e.modelindex;
650         e.model = "";
651         e.modelindex = 0;
652         // this would have to be changed if used in quakeworld
653         e.team = e.cnt + 1;
654
655         //eprint(e);
656 }
657
658 void dom_spawnpoint(vector org)
659 {
660         entity e = spawn();
661         e.classname = "dom_controlpoint";
662         setthink(e, spawnfunc_dom_controlpoint);
663         e.nextthink = time;
664         setorigin(e, org);
665         spawnfunc_dom_controlpoint(e);
666 }
667
668 // spawn some default teams if the map is not set up for domination
669 void dom_spawnteams(int teams)
670 {
671     TC(int, teams);
672         dom_spawnteam(Team_ColoredFullName(NUM_TEAM_1), NUM_TEAM_1-1, "models/domination/dom_red.md3", 0, SND_DOM_CLAIM, "", "Red team has captured a control point");
673         dom_spawnteam(Team_ColoredFullName(NUM_TEAM_2), NUM_TEAM_2-1, "models/domination/dom_blue.md3", 0, SND_DOM_CLAIM, "", "Blue team has captured a control point");
674         if(teams >= 3)
675                 dom_spawnteam(Team_ColoredFullName(NUM_TEAM_3), NUM_TEAM_3-1, "models/domination/dom_yellow.md3", 0, SND_DOM_CLAIM, "", "Yellow team has captured a control point");
676         if(teams >= 4)
677                 dom_spawnteam(Team_ColoredFullName(NUM_TEAM_4), NUM_TEAM_4-1, "models/domination/dom_pink.md3", 0, SND_DOM_CLAIM, "", "Pink team has captured a control point");
678         dom_spawnteam("", 0, "models/domination/dom_unclaimed.md3", 0, SND_Null, "", "");
679 }
680
681 void dom_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up.
682 {
683         // if no teams are found, spawn defaults
684         if(find(world, classname, "dom_team") == world || autocvar_g_domination_teams_override >= 2)
685         {
686                 LOG_TRACE("No \"dom_team\" entities found on this map, creating them anyway.\n");
687                 domination_teams = bound(2, ((autocvar_g_domination_teams_override < 2) ? autocvar_g_domination_default_teams : autocvar_g_domination_teams_override), 4);
688                 dom_spawnteams(domination_teams);
689         }
690
691         CheckAllowedTeams(world);
692         domination_teams = ((c4>=0) ? 4 : (c3>=0) ? 3 : 2);
693
694         domination_roundbased = autocvar_g_domination_roundbased;
695
696         ScoreRules_dom(domination_teams);
697
698         if(domination_roundbased)
699         {
700                 round_handler_Spawn(Domination_CheckPlayers, Domination_CheckWinner, Domination_RoundStart);
701                 round_handler_Init(5, autocvar_g_domination_warmup, autocvar_g_domination_round_timelimit);
702         }
703 }
704
705 void dom_Initialize()
706 {
707         g_domination = true;
708         InitializeEntity(world, dom_DelayedInit, INITPRIO_GAMETYPE);
709 }
710
711 #endif