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