]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/teamplay.qc
Merge branch 'master' into divVerent/crypto2
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / teamplay.qc
index 7b1a85abc7a8d3f7f5a0fb9c4f9266fd9f220825..04580e6c42eade3dc20fdfa0722dd970d93bff8f 100644 (file)
@@ -16,6 +16,8 @@ float IsTeamBalanceForced()
                return 0;
        if(cvar("g_campaign"))
                return 0;
+       if(cvar("bot_vs_human") && (c3==-1 && c4==-1))
+               return 0;
        if(!cvar("g_balance_teams_force"))
                return -1;
        return 1;
@@ -208,6 +210,9 @@ void InitGameplayMode()
        fraglimit_override = cvar("fraglimit_override");
        leadlimit_override = cvar("leadlimit_override");
 
+       if(cvar("g_dodging"))
+               MUTATOR_ADD(dodging);
+       
        if(g_dm)
        {
                game = GAME_DEATHMATCH;
@@ -312,7 +317,7 @@ void InitGameplayMode()
                ActivateTeamplay();
                fraglimit_override = cvar("g_keyhunt_point_limit");
                leadlimit_override = cvar("g_keyhunt_point_leadlimit");
-               kh_init();
+               MUTATOR_ADD(gamemode_keyhunt);
        }
 
        if(g_assault)
@@ -431,7 +436,7 @@ string GetClientVersionMessage() {
                if(self.version < cvar("gameversion")) {
                        versionmsg = "^3Your client version is outdated.\n\n\n### YOU WON'T BE ABLE TO PLAY ON THIS SERVER ###\n\n\nPlease update!!!^8";
                } else {
-                       versionmsg = "^3This server is using an outdated Nexuiz version.\n\n\n ### THIS SERVER IS INCOMPATIBLE AND THUS YOU CANNOT JOIN ###.^8";
+                       versionmsg = "^3This server is using an outdated Xonotic version.\n\n\n ### THIS SERVER IS INCOMPATIBLE AND THUS YOU CANNOT JOIN ###.^8";
                }
        } else {
                versionmsg = "^2client version and server version are compatible.^8";
@@ -489,11 +494,12 @@ void PrintWelcomeMessage(entity pl)
        }
 
 :normal
-       modifications = "";
+       ret_string = "";
+       MUTATOR_CALLHOOK(BuildMutatorsPrettyString);
+       modifications = ret_string;
+       
        if(g_minstagib)
                modifications = strcat(modifications, ", MinstaGib");
-       if(g_nixnex)
-               modifications = strcat(modifications, ", NixNex");
        if(g_weaponarena)
        {
                if(g_weaponarena_random)
@@ -530,7 +536,7 @@ void PrintWelcomeMessage(entity pl)
        local string versionmessage;
        versionmessage = GetClientVersionMessage();
 
-       s = strcat(s, NEWLINES, "This is Nexuiz ", cvar_string("g_nexuizversion"), "\n", versionmessage);
+       s = strcat(s, NEWLINES, "This is Xonotic ", cvar_string("g_xonoticversion"), "\n", versionmessage);
        s = strcat(s, "^8\n\nmatch type is ^1", gamemode_name, "^8\n");
 
        if(modifications != "")
@@ -621,7 +627,11 @@ void CheckAllowedTeams (entity for_whom)
        c1 = c2 = c3 = c4 = -1;
        cb1 = cb2 = cb3 = cb4 = 0;
 
-       if(g_onslaught)
+       if(cvar("g_campaign") && for_whom && clienttype(for_whom) == CLIENTTYPE_REAL)
+       {
+               c1 = 0; // only allow RED team for player joining
+       }
+       else if(g_onslaught)
        {
                // onslaught is special
                head = findchain(classname, "onslaught_generator");
@@ -647,13 +657,15 @@ void CheckAllowedTeams (entity for_whom)
        else
        {
                // cover anything else by treating it like tdm with no teams spawned
-               if(g_keyhunt)
-                       dm = kh_teams;
-               else if(g_race)
+               if(g_race)
                        dm = race_teams;
                else
                        dm = 2;
 
+               ret_float = dm;
+               MUTATOR_CALLHOOK(GetTeamCount);
+               dm = ret_float;
+
                if(dm >= 4)
                        c1 = c2 = c3 = c4 = 0;
                else if(dm >= 3)
@@ -684,7 +696,7 @@ void CheckAllowedTeams (entity for_whom)
        }
 
        // TODO: Balance quantity of bots across > 2 teams when bot_vs_human is set (and remove next line)
-       if(c3==-1&&c4==-1)
+       if(c3==-1 && c4==-1)
        if(cvar("bot_vs_human") && for_whom)
        {
                if(cvar("bot_vs_human") > 0)
@@ -711,6 +723,7 @@ float PlayerValue(entity p)
        if(IsTeamBalanceForced() == 1)
                return 1;
        return 1;
+       // FIXME: it always returns 1...
 }
 
 // c1...c4 should be set to -1 (not allowed) or 0 (allowed).
@@ -789,12 +802,14 @@ float FindSmallestTeam(entity pl, float ignore_pl)
        if(c4 >= 0)
                totalteams = totalteams + 1;
 
-       if(cvar("bot_vs_human"))
+       if(cvar("bot_vs_human") && totalteams == 1)
                totalteams += 1;
 
        if(totalteams <= 1)
        {
-               if(g_domination)
+               if(cvar("g_campaign") && pl && clienttype(pl) == CLIENTTYPE_REAL)
+                       return 1; // special case for campaign and player joining
+               else if(g_domination)
                        error("Too few teams available for domination\n");
                else if(g_ctf)
                        error("Too few teams available for ctf\n");
@@ -841,9 +856,9 @@ float FindSmallestTeam(entity pl, float ignore_pl)
        {
                // 1: use team count, if equal prefer own team
                if(c1 >= 0) RandomSelection_Add(world, 1, string_null, 1, (maxc - c1) + (self.team == COLOR_TEAM1) / 512.0);
-               if(c2 >= 0) RandomSelection_Add(world, 1, string_null, 1, (maxc - c1) + (self.team == COLOR_TEAM2) / 512.0);
-               if(c3 >= 0) RandomSelection_Add(world, 1, string_null, 1, (maxc - c1) + (self.team == COLOR_TEAM3) / 512.0);
-               if(c4 >= 0) RandomSelection_Add(world, 1, string_null, 1, (maxc - c1) + (self.team == COLOR_TEAM4) / 512.0);
+               if(c2 >= 0) RandomSelection_Add(world, 2, string_null, 1, (maxc - c1) + (self.team == COLOR_TEAM2) / 512.0);
+               if(c3 >= 0) RandomSelection_Add(world, 3, string_null, 1, (maxc - c1) + (self.team == COLOR_TEAM3) / 512.0);
+               if(c4 >= 0) RandomSelection_Add(world, 4, string_null, 1, (maxc - c1) + (self.team == COLOR_TEAM4) / 512.0);
        }
        else if(balance_type == 3)
        {
@@ -867,6 +882,33 @@ float JoinBestTeam(entity pl, float only_return_best, float forcebestteam)
        // find out what teams are available
        CheckAllowedTeams(pl);
 
+       // if we want the player in a certain team for campaign, force him there
+       if(cvar("g_campaign"))
+       if(clienttype(pl) == CLIENTTYPE_REAL) // only players, not bots
+       {
+               switch(cvar("g_campaign_forceteam"))
+               {
+                       case 1:
+                               SetPlayerColors(pl, COLOR_TEAM1 - 1);
+                               LogTeamchange(pl.playerid, pl.team, 2);
+                               return COLOR_TEAM1;
+                       case 2:
+                               SetPlayerColors(pl, COLOR_TEAM2 - 1);
+                               LogTeamchange(pl.playerid, pl.team, 2);
+                               return COLOR_TEAM2;
+                       case 3:
+                               SetPlayerColors(pl, COLOR_TEAM3 - 1);
+                               LogTeamchange(pl.playerid, pl.team, 2);
+                               return COLOR_TEAM3;
+                       case 4:
+                               SetPlayerColors(pl, COLOR_TEAM4 - 1);
+                               LogTeamchange(pl.playerid, pl.team, 2);
+                               return COLOR_TEAM4;
+                       default:
+                               break;
+               }
+       }
+
        // if we don't care what team he ends up on, put him on whatever team he entered as.
        // if he's not on a valid team, then let other code put him on the smallest team
        if(!forcebestteam)
@@ -899,7 +941,7 @@ float JoinBestTeam(entity pl, float only_return_best, float forcebestteam)
 
        smallest = FindSmallestTeam(pl, TRUE);
 
-       if(!only_return_best)
+       if(!only_return_best && !pl.bot_forced_team)
        {
                TeamchangeFrags(self);
                if(smallest == 1)