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