1 float COLOR_TEAM1 = 5; // red
2 float COLOR_TEAM2 = 14; // blue
3 float COLOR_TEAM3 = 10; // pink
4 float COLOR_TEAM4 = 13; // yellow
7 float GAME_DEATHMATCH = 1;
8 float GAME_TEAM_DEATHMATCH = 2;
9 float GAME_DOMINATION = 3;
11 float GAME_RUNEMATCH = 5;
16 // client counts for each team
18 // # of bots on those teams
19 float cb1, cb2, cb3, cb4;
21 float g_domination, g_ctf, g_tdm;
23 float audit_teams_time;
26 string TeamName(float t)
28 // fixme: Search for team entities and get their .netname's!
37 return "Neutral Team";
39 string ColoredTeamName(float t)
41 // fixme: Search for team entities and get their .netname's!
43 return "^1Red Team^7";
45 return "^4Blue Team^7";
47 return "^6Pink Team^7";
49 return "^3Yellow Team^7";
50 return "Neutral Team";
52 string TeamNoName(float t)
54 // fixme: Search for team entities and get their .netname's!
63 return "Neutral Team";
68 void runematch_init();
71 void(entity pl) LogTeamchange =
74 if(!cvar("sv_eventlog"))
78 str = strcat(":team:", ftos(pl.playerid), ":");
79 str = strcat(str, ftos(pl.team));
80 GameLogEcho(str, FALSE);
85 cvar_set("g_tdm", "0");
86 cvar_set("g_domination", "0");
87 cvar_set("g_ctf", "0");
88 cvar_set("g_runematch", "0");
89 cvar_set("g_lms", "0");
90 cvar_set("g_arena", "0");
91 cvar_set("teamplay", "0");
94 cvar_set("exit_cfg", "");
97 void ActivateTeamplay()
99 float teamplay_default;
100 teamplay_default = cvar("teamplay_default");
103 cvar_set("teamplay", ftos(teamplay_default));
105 cvar_set("teamplay", "3");
108 string gamemode_name;
111 void InitGameplayMode()
113 float fraglimit_override, timelimit_override;
117 game = cvar ("gamecfg"); // load game options
119 // game cvars get reset before map changes
120 // then map's cfg sets them as desired
122 // FIXME: also set a message or game mode name to print to players when the join
124 // set both here, gamemode can override it later
125 timelimit_override = cvar("timelimit_override");
126 fraglimit_override = cvar("fraglimit_override");
128 if(game == GAME_DOMINATION || cvar("g_domination"))
131 game = GAME_DOMINATION;
132 cvar_set("g_domination", "1");
136 fraglimit_override = cvar("g_domination_point_limit");
138 gamemode_name = "Domination";
141 else if(game == GAME_CTF || cvar("g_ctf"))
145 cvar_set("g_ctf", "1");
149 fraglimit_override = cvar("g_ctf_capture_limit");
151 gamemode_name = "Capture the Flag";
154 else if((game == GAME_RUNEMATCH || cvar("g_runematch")) && !cvar("g_minstagib"))
156 game = GAME_RUNEMATCH;
157 cvar_set("g_runematch", "1");
159 if(cvar("deathmatch_force_teamplay"))
162 fraglimit_override = cvar("g_runematch_point_limit");
164 gamemode_name = "Rune Match";
170 else if(game == GAME_DEATHMATCH || game == GAME_TEAM_DEATHMATCH || cvar("g_tdm"))
172 if(!cvar("deathmatch"))
173 cvar_set("deathmatch", "1");
176 if(game == GAME_TEAM_DEATHMATCH || cvar("g_tdm") || cvar("deathmatch_force_teamplay"))
179 game = GAME_TEAM_DEATHMATCH;
180 gamemode_name = "Team Deathmatch";
183 cvar_set("g_tdm", "1");
188 game = GAME_DEATHMATCH;
189 gamemode_name = "Deathmatch";
193 fraglimit_override = cvar("fraglimit_override");
195 else if(game == GAME_LMS || cvar("g_lms"))
199 cvar_set("g_lms", "1");
200 fraglimit_override = cvar("g_lms_lives_override");
201 if(fraglimit_override == 0)
202 fraglimit_override = -1;
203 gamemode_name = "Last Man Standing";
205 lms_lowest_lives = 999;
207 else if(game == GAME_ARENA || cvar("g_arena"))
211 cvar_set("g_arena", "1");
212 fraglimit_override = cvar("g_arena_point_limit");
213 maxspawned = cvar("g_arena_maxspawned");
216 arena_roundbased = cvar("g_arena_roundbased");
217 gamemode_name = "Arena";
222 // we can only assume...
224 gamemode_name = "Deathmatch";
227 /* else if(game == GAME_TEAM_DEATHMATCH)
229 if(!cvar("deathmatch"))
230 cvar_set("deathmatch", "1");
232 //if(!cvar("teamplay"))
233 // cvar_set("teamplay", "3");
236 fraglimit_override = cvar("fraglimit_override");
239 // enforce the server's universal frag/time limits
240 if(fraglimit_override >= 0)
241 cvar_set("fraglimit", ftos(fraglimit_override));
242 if(timelimit_override >= 0)
243 cvar_set("timelimit", ftos(timelimit_override));
245 if (game == GAME_DOMINATION)//cvar("g_domination"))
247 else if (game == GAME_CTF)//cvar("g_ctf"))
249 else if (game == GAME_RUNEMATCH)//cvar("g_runematch"))
251 else if (game == GAME_TEAM_DEATHMATCH)//cvar("g_runematch"))
254 // those mutators rule each other out
255 if(cvar("g_minstagib"))
257 cvar_set("g_instagib", "0");
258 cvar_set("g_rocketarena", "0");
260 if(cvar("g_instagib"))
262 cvar_set("g_minstagib", "0");
263 cvar_set("g_rocketarena", "0");
265 if(cvar("g_rocketarena"))
267 cvar_set("g_instagib", "0");
268 cvar_set("g_minstagib", "0");
271 registercvar("_motd", "");
272 registercvar("_mutatormsg", "");
273 cvar_set("_motd", linewrap(cvar_string("sv_motd"), 50));
274 cvar_set("_mutatormsg", linewrap(cvar_string("g_mutatormsg"), 50));
277 string GetClientVersionMessage(float v) {
278 local string versionmsg;
280 versionmsg = "^1client is too old to get versioninfo.\n\n\n### YOU WON'T BE ABLE TO PLAY ON THIS SERVER ###\n\n\nUPDATE!!! (http://www.nexuiz.com)^8";
281 // either that or someone wants to be funny
282 } else if (v != cvar("gameversion")) {
283 if(v < cvar("gameversion")) {
284 versionmsg = "^3Your client version is outdated.\n\n\n### YOU WON'T BE ABLE TO PLAY ON THIS SERVER ###\n\n\nPlease update!!!^8";
286 versionmsg = "^3This server is using an outdated Nexuiz version.\n\n\n ### THIS SERVER IS INCOMPATIBLE AND THUS YOU CANNOT JOIN ###.^8";
289 versionmsg = "^2client version and server version are compatible.^8";
291 return strzone(versionmsg);
296 void PrintWelcomeMessage(entity pl)
298 string s, mutator, modifications;
300 /*if(self.welcomemessage_time < time)
302 if(self.welcomemessage_time2 > time)
304 self.welcomemessage_time2 = time + 0.8; */
306 if(self.classname == "observer")
308 if(cvar("g_lms") && self.frags <= 0 && self.frags > -666)
309 return centerprint(self, strcat(newlines, "^1You have no more lives left\nwait for next round\n\n\n^7press attack to spectate other players"));
310 else if(cvar("g_lms") && self.frags == -666)
311 return centerprint(self, strcat(newlines, "^1Match has already begun\nwait for next round\n\n\n^7press attack to spectate other players"));
313 else if(self.classname == "spectator")
315 if ((cvar("g_lms") && self.frags < 1) || cvar("g_arena"))
316 return centerprint(self, strcat(newlines, "spectating ", self.enemy.netname, "\n\n\n^7press attack for next player\npress attack2 for free fly mode"));
318 return centerprint(self, strcat(newlines, "spectating ", self.enemy.netname, "\n\n\n^7press jump to play\n^7press attack for next player\npress attack2 for free fly mode"));
322 if(self.welcomemessage_time2 > time) return;
323 self.welcomemessage_time2 = time + 1.0;
325 if(cvar("g_minstagib"))
326 mutator = "^2Minstagib ^1";
327 else if(cvar("g_instagib"))
328 mutator = "^2Instagib ^1";
329 else if(cvar("g_rocketarena"))
330 mutator = "^2Rocketarena ^1";
332 if(cvar("g_midair")) {
333 // to protect against unheedingly made changes
335 modifications = strcat(modifications, ", ");
337 modifications = "midair";
339 if(cvar("g_vampire")) {
341 modifications = strcat(modifications, ", ");
343 modifications = strcat(modifications, "vampire");
345 if(cvar("g_laserguided_missile")) {
347 modifications = strcat(modifications, ", ");
349 modifications = strcat(modifications, "laser-guided-missiles");
352 local string versionmessage;
353 versionmessage = GetClientVersionMessage(self.version);
355 s = strcat(s, newlines, "This is Nexuiz ", cvar_string("g_nexuizversion"), "\n", versionmessage);
356 s = strcat(s, "^8\n\nmatch type is ^1", mutator, gamemode_name, "^8\n");
358 if(modifications != "")
359 s = strcat(s, "^8\nactive modifications: ^3", modifications, "^8\n");
361 if((self.classname == "observer" || self.classname == "spectator") && self.version == cvar("gameversion")) {
363 s = strcat(s,"^7\n\n\npress jump to play\npress attack to spectate other players\n\n");
364 else if(self.spawnqueue_in)
366 s = strcat(s, "\n\n\n");
368 s = strcat(s, "^7current champion is: ", champion.netname, "\n\n");
369 s = strcat(s,"^7press attack to spectate other players\n\n");
376 if (cvar("g_grappling_hook"))
377 s = strcat(s, "\n\n^8grappling hook is enabled, press 'e' to use it\n");
379 if (cvar_string("_mutatormsg") != "") {
380 s = strcat(s, "\n\n^8special gameplay tips: ^7", cvar_string("_mutatormsg"));
383 if (cvar_string("_motd") != "") {
384 s = strcat(s, "\n\n^8MOTD: ^7", cvar_string("_motd"));
396 void SetPlayerColors(entity pl, float _color)
400 stuffcmd(pl, strcat("color ", s, " ", s, "\n") );
402 //pl.clientcolors = pl.clientcolors - (pl.clientcolors & 15) + cl;
403 pl.clientcolors = 16*cl + cl;*/
406 pants = _color & 0x0F;
407 shirt = _color & 0xF0;
411 setcolor(pl, 16*pants + pants);
413 setcolor(pl, shirt + pants);
417 void SetPlayerTeam(entity pl, float t, float s, float noprint)
422 _color = COLOR_TEAM4 - 1;
424 _color = COLOR_TEAM3 - 1;
426 _color = COLOR_TEAM2 - 1;
428 _color = COLOR_TEAM1 - 1;
430 SetPlayerColors(pl,_color);
432 if(!noprint && t != s)
434 //bprint(strcat(pl.netname, " has changed to ", TeamNoName(t), "\n"));
435 bprint(strcat(pl.netname, "^7 has changed from ", TeamNoName(s), " to ", TeamNoName(t), "\n"));
447 // set c1...c4 to show what teams are allowed
448 void CheckAllowedTeams ()
457 c1 = c2 = c3 = c4 = -1;
458 cb1 = cb2 = cb3 = cb4 = 0;
461 teament_name = "dom_team";
463 teament_name = "ctf_team";
465 teament_name = "tdm_team";
468 // cover anything else by treating it like tdm with no teams spawned
469 dm = cvar("g_tdm_teams");
471 error("g_tdm_teams < 2, not enough teams to play team deathmatch\n");
475 c1 = c2 = c3 = c4 = 0;
488 // first find out what teams are allowed
489 head = find(world, classname, teament_name);
492 if(!(g_domination && head.netname == ""))
494 if(head.team == COLOR_TEAM1)
498 if(head.team == COLOR_TEAM2)
502 if(head.team == COLOR_TEAM3)
506 if(head.team == COLOR_TEAM4)
511 head = find(head, classname, teament_name);
515 // c1...c4 should be set to -1 (not allowed) or 0 (allowed).
516 // teams that are allowed will now have their player counts stored in c1...c4
517 void GetTeamCounts(entity ignore)
520 // now count how many players are on each team already
522 // FIXME: also find and memorize the lowest-scoring bot on each team (in case players must be shuffled around)
523 // also remember the lowest-scoring player
525 head = find(world, classname, "player");
528 if(head != ignore)// && head.netname != "")
530 if(head.team == COLOR_TEAM1)
538 if(head.team == COLOR_TEAM2)
546 if(head.team == COLOR_TEAM3)
554 if(head.team == COLOR_TEAM4)
563 head = find(head, classname, "player");
567 // returns # of smallest team (1, 2, 3, 4)
568 // NOTE: Assumes CheckAllowedTeams has already been called!
569 float FindSmallestTeam(entity pl, float ignore_pl)
571 float totalteams, smallestteam, smallestteam_count, balance_type;
574 // find out what teams are available
575 //CheckAllowedTeams();
577 // make sure there are at least 2 teams to join
579 totalteams = totalteams + 1;
581 totalteams = totalteams + 1;
583 totalteams = totalteams + 1;
585 totalteams = totalteams + 1;
590 error("Too few teams available for domination\n");
592 error("Too few teams available for ctf\n");
594 error("Too few teams available for team deathmatch\n");
598 // count how many players are in each team
600 GetTeamCounts(world);
606 // c1...c4 now have counts of each team
607 // figure out which is smallest, giving priority to the team the player is already on as a tie-breaker
610 smallestteam_count = 999;
612 // 2 gives priority to what team you're already on, 1 goes in order
613 // 2 doesn't seem to work though...
616 if(balance_type == 1)
618 if(c1 >= 0 && c1 < smallestteam_count)
621 smallestteam_count = c1;
623 if(c2 >= 0 && c2 < smallestteam_count)
626 smallestteam_count = c2;
628 if(c3 >= 0 && c3 < smallestteam_count)
631 smallestteam_count = c3;
633 if(c4 >= 0 && c4 < smallestteam_count)
636 smallestteam_count = c4;
641 if(c1 >= 0 && (c1 < smallestteam_count ||
642 (c1 == smallestteam_count && self.team == COLOR_TEAM1) ) )
645 smallestteam_count = c1;
647 if(c2 >= 0 && c2 < (c2 < smallestteam_count ||
648 (c2 == smallestteam_count && self.team == COLOR_TEAM2) ) )
651 smallestteam_count = c2;
653 if(c3 >= 0 && c3 < (c3 < smallestteam_count ||
654 (c3 == smallestteam_count && self.team == COLOR_TEAM3) ) )
657 smallestteam_count = c3;
659 if(c4 >= 0 && c4 < (c4 < smallestteam_count ||
660 (c4 == smallestteam_count && self.team == COLOR_TEAM4) ) )
663 smallestteam_count = c4;
670 float JoinBestTeam(entity pl, float only_return_best)
672 float smallest, selectedteam;
674 g_domination = cvar("g_domination");
675 g_ctf = cvar("g_ctf");
677 // don't join a team if we're not playing a team game
678 if(!cvar("teamplay") && !g_domination && !g_ctf)
681 // find out what teams are available
685 if(cvar("g_domination"))
687 if(cvar("g_domination_default_teams") < 3)
689 if(cvar("g_domination_default_teams") < 4)
693 // if we don't care what team he ends up on, put him on whatever team he entered as.
694 // if he's not on a valid team, then let other code put him on the smallest team
695 if(!cvar("g_balance_teams") && !cvar("g_balance_teams_force"))
697 if( c1 >= 0 && pl.team == COLOR_TEAM1)
698 selectedteam = pl.team;
699 else if(c2 >= 0 && pl.team == COLOR_TEAM2)
700 selectedteam = pl.team;
701 else if(c3 >= 0 && pl.team == COLOR_TEAM3)
702 selectedteam = pl.team;
703 else if(c4 >= 0 && pl.team == COLOR_TEAM4)
704 selectedteam = pl.team;
709 if(!only_return_best)
711 SetPlayerColors(pl, selectedteam - 1);
716 // otherwise end up on the smallest team (handled below)
719 smallest = FindSmallestTeam(pl, TRUE);
722 if(!only_return_best)
726 SetPlayerColors(pl, COLOR_TEAM1 - 1);
728 else if(smallest == 2)
730 SetPlayerColors(pl, COLOR_TEAM2 - 1);
732 else if(smallest == 3)
734 SetPlayerColors(pl, COLOR_TEAM3 - 1);
736 else if(smallest == 4)
738 SetPlayerColors(pl, COLOR_TEAM4 - 1);
742 error("smallest team: invalid team\n");
745 if(pl.deadflag == DEAD_NO)
746 Damage(pl, pl, pl, 100000, DEATH_TEAMCHANGE, pl.origin, '0 0 0');
753 void SV_ChangeTeam(float _color)
755 float scolor, dcolor, steam, dteam, dbotcount, scount, dcount;
757 // in normal deathmatch we can just apply the color and we're done
758 if(!cvar("teamplay")) {
759 SetPlayerColors(self, _color);
763 scolor = self.clientcolors & 0x0F;
764 dcolor = _color & 0x0F;
766 if(scolor == COLOR_TEAM1 - 1)
768 else if(scolor == COLOR_TEAM2 - 1)
770 else if(scolor == COLOR_TEAM3 - 1)
772 else if(scolor == COLOR_TEAM4 - 1)
774 if(dcolor == COLOR_TEAM1 - 1)
776 else if(dcolor == COLOR_TEAM2 - 1)
778 else if(dcolor == COLOR_TEAM3 - 1)
780 else if(dcolor == COLOR_TEAM4 - 1)
783 // remap invalid teams in dom & ctf
784 if(cvar("g_ctf") && dteam == 3)
786 else if(cvar("g_ctf") && dteam == 4)
788 else if((cvar("g_domination") && cvar("g_domination_default_teams") < 3) || (cvar("g_tdm") && cvar("g_tdm_teams") < 3))
795 else if((cvar("g_domination") && cvar("g_domination_default_teams") < 4) || (cvar("g_tdm") && cvar("g_tdm_teams") < 4))
801 // not changing teams
804 //bprint("same team change\n");
805 SetPlayerTeam(self, dteam, steam, TRUE);
811 if(cvar("g_changeteam_banned"))
813 sprint(self, "Team changes not allowed\n");
814 return; // changing teams is not allowed
817 if(cvar("g_balance_teams_prevent_imbalance"))
819 // only allow changing to a smaller or equal size team
821 // find out what teams are available
823 // count how many players on each team
824 GetTeamCounts(world);
827 if(dteam == 1 && c1 >= 0)//dcolor == COLOR_TEAM1 - 1)
832 else if(dteam == 2 && c2 >= 0)//dcolor == COLOR_TEAM2 - 1)
837 else if(dteam == 3 && c3 >= 0)//dcolor == COLOR_TEAM3 - 1)
842 else if(dteam == 4 && c4 >= 0)//dcolor == COLOR_TEAM4 - 1)
849 sprint(self, "Cannot change to an invalid team\n");
855 if(steam == 1)//scolor == COLOR_TEAM1 - 1)
857 else if(steam == 2)//scolor == COLOR_TEAM2 - 1)
859 else if(steam == 3)//scolor == COLOR_TEAM3 - 1)
861 else if(steam == 4)//scolor == COLOR_TEAM4 - 1)
864 if(scount) // started at a valid, nonempty team
866 // check if we're trying to change to a larger team that doens't have bots to swap with
867 if(dcount >= scount && dbotcount <= 0)
869 sprint(self, "Cannot change to a larger team\n");
870 return; // can't change to a larger team
876 // bprint(strcat("allow change teams from ", ftos(steam), " to ", ftos(dteam), "\n"));
878 SetPlayerTeam(self, dteam, steam, FALSE);
879 if(cvar("teamplay") && self.classname == "player" && steam != dteam)
881 // kill player when changing teams
882 if(self.deadflag == DEAD_NO)
883 Damage(self, self, self, 100000, DEATH_TEAMCHANGE, self.origin, '0 0 0');
884 // reduce frags during a team change
885 self.frags = floor(self.frags * (cvar("g_changeteam_fragtransfer") / 100));
890 void ShufflePlayerOutOfTeam (float source_team)
892 float smallestteam, smallestteam_count, steam;
893 float lowest_bot_score, lowest_player_score;
894 entity head, lowest_bot, lowest_player, selected;
898 smallestteam_count = 999;
900 if(c1 >= 0 && c1 < smallestteam_count)
903 smallestteam_count = c1;
905 if(c2 >= 0 && c2 < smallestteam_count)
908 smallestteam_count = c2;
910 if(c3 >= 0 && c3 < smallestteam_count)
913 smallestteam_count = c3;
915 if(c4 >= 0 && c4 < smallestteam_count)
918 smallestteam_count = c4;
923 bprint("warning: no smallest team\n");
929 else if(source_team == 2)
931 else if(source_team == 3)
933 else if(source_team == 4)
937 lowest_bot_score = 9999;
938 lowest_player = world;
939 lowest_player_score = 9999;
941 // find the lowest-scoring player & bot of that team
942 head = find(world, classname, "player");
945 if(head.team == steam)
949 if(head.frags < lowest_bot_score)
952 lowest_bot_score = head.frags;
957 if(head.frags < lowest_player_score)
959 lowest_player = head;
960 lowest_player_score = head.frags;
964 head = find(head, classname, "player");
967 // prefers to move a bot...
968 if(lowest_bot != world)
969 selected = lowest_bot;
970 // but it will move a player if it has to
972 selected = lowest_player;
973 // don't do anything if it couldn't find anyone
976 bprint("warning: couldn't find a player to move from team\n");
980 // smallest team gains a member
981 if(smallestteam == 1)
985 else if(smallestteam == 2)
989 else if(smallestteam == 3)
993 else if(smallestteam == 4)
999 bprint("warning: destination team invalid\n");
1002 // source team loses a member
1003 if(source_team == 1)
1007 else if(source_team == 2)
1011 else if(source_team == 3)
1015 else if(source_team == 4)
1021 bprint("warning: source team invalid\n");
1025 // move the player to the new team
1026 SetPlayerTeam(selected, smallestteam, source_team, FALSE);
1028 if(selected.deadflag == DEAD_NO)
1029 Damage(selected, selected, selected, 100000, DEATH_AUTOTEAMCHANGE, selected.origin, '0 0 0');
1030 m = "You have been moved into a different team to improve team balance\nYou are now on: ";
1031 if (selected.team == 5)
1032 m = strcat(m, "^1Red Team");
1033 else if (selected.team == 14)
1034 m = strcat(m, "^4Blue Team");
1035 else if (selected.team == 10)
1036 m = strcat(m, "^6Pink Team");
1037 else if (selected.team == 13)
1038 m = strcat(m, "^3Yellow Team");
1039 centerprint(selected, m);
1042 // part of g_balance_teams_force
1043 // occasionally perform an audit of the teams to make
1044 // sure they're more or less balanced in player count.
1047 float numplayers, numteams, average;
1048 if(!cvar("g_balance_teams_force"))
1050 if(!cvar("teamplay"))
1053 if(audit_teams_time > time)
1056 audit_teams_time = time + 4 + random();
1058 // bprint("Auditing teams\n");
1060 CheckAllowedTeams();
1061 GetTeamCounts(world);
1064 numteams = numplayers = 0;
1067 numteams = numteams + 1;
1068 numplayers = numplayers + c1;
1072 numteams = numteams + 1;
1073 numplayers = numplayers + c2;
1077 numteams = numteams + 1;
1078 numplayers = numplayers + c3;
1082 numteams = numteams + 1;
1083 numplayers = numplayers + c4;
1087 return; // no players to move around
1089 return; // don't bother shuffling if for some reason there aren't any teams
1091 average = ceil(numplayers / numteams);
1094 return; // that's weird...
1096 if(c1 && c1 > average)
1098 bprint("Rebalancing Teams\n");
1099 //bprint("Shuffle from team 1\n");
1100 ShufflePlayerOutOfTeam(1);
1102 if(c2 && c2 > average)
1104 bprint("Rebalancing Teams\n");
1105 //bprint("Shuffle from team 2\n");
1106 ShufflePlayerOutOfTeam(2);
1108 if(c3 && c3 > average)
1110 bprint("Rebalancing Teams\n");
1111 //bprint("Shuffle from team 3\n");
1112 ShufflePlayerOutOfTeam(3);
1114 if(c4 && c4 > average)
1116 bprint("Rebalancing Teams\n");
1117 //bprint("Shuffle from team 4\n");
1118 ShufflePlayerOutOfTeam(4);
1121 // if teams are still unbalanced, balance them further in the next audit,
1122 // which will happen sooner (keep doing rapid audits until things are in order)
1123 audit_teams_time = time + 0.7 + random()*0.3;
1128 /*void(entity e, float first) UpdateTeamScore =
1133 WriteByte (MSG_ALL, SVC_UPDATENAME);
1134 WriteByte (MSG_ALL, clientno);
1135 WriteString (MSG_ALL, e.netname);
1137 WriteByte (MSG_ALL, SVC_UPDATECOLORS);
1138 WriteByte (MSG_ALL, clientno);
1139 WriteByte (MSG_ALL, e.b_shirt * 16 + who.b_pants);
1142 WriteByte (MSG_ALL, SVC_UPDATEFRAGS);
1143 WriteByte (MSG_ALL, clientno);
1144 WriteShort (MSG_ALL, e.frags + 10000);
1150 // code from here on is just to support maps that don't have team entities
1151 void tdm_spawnteam (string teamname, float teamcolor)
1155 e.classname = "tdm_team";
1156 e.netname = teamname;
1161 // spawn some default teams if the map is not set up for tdm
1162 void() tdm_spawnteams =
1166 numteams = cvar("g_tdm_teams");
1168 tdm_spawnteam("Red", 4);
1169 tdm_spawnteam("Blue", 13);
1172 void() tdm_delayedinit =
1174 self.think = SUB_Remove;
1175 self.nextthink = time;
1176 // if no teams are found, spawn defaults
1177 if (find(world, classname, "tdm_team") == world)
1185 e.think = tdm_delayedinit;
1186 e.nextthink = time + 0.1;