]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/teamplay.qc
Remove runematch gamemode
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / teamplay.qc
index 64013bd2c69e773379661b7af3ac54821cf9cad3..ab586a1ac4ed849303c3b618722d619e5d3575fd 100644 (file)
@@ -6,22 +6,7 @@ float c1, c2, c3, c4;
 // # of bots on those teams
 float cb1, cb2, cb3, cb4;
 
-float audit_teams_time;
-
-float IsTeamBalanceForced()
-{
-       if(intermission_running)
-               return 0; // no rebalancing whatsoever please
-       if(!teamplay)
-               return 0;
-       if(autocvar_g_campaign)
-               return 0;
-       if(autocvar_bot_vs_human && (c3==-1 && c4==-1))
-               return 0;
-       if(!autocvar_g_balance_teams_force)
-               return -1;
-       return 1;
-}
+//float audit_teams_time;
 
 void TeamchangeFrags(entity e)
 {
@@ -67,9 +52,6 @@ string TeamNoName(float t)
        return "Neutral Team";
 }
 
-void dom_init();
-void ctf_init();
-void runematch_init();
 void tdm_init();
 void entcs_init();
 
@@ -150,28 +132,19 @@ void InitGameplayMode()
                ActivateTeamplay();
                fraglimit_override = autocvar_g_domination_point_limit;
                leadlimit_override = autocvar_g_domination_point_leadlimit;
-               dom_init();
+               MUTATOR_ADD(gamemode_domination);
                have_team_spawns = -1; // request team spawns
        }
 
        if(g_ctf)
        {
                ActivateTeamplay();
-               g_ctf_ignore_frags = autocvar_g_ctf_ignore_frags;
                fraglimit_override = autocvar_capturelimit_override;
                leadlimit_override = autocvar_captureleadlimit_override;
-               ctf_init();
+               MUTATOR_ADD(gamemode_ctf);
                have_team_spawns = -1; // request team spawns
        }
 
-       if(g_runematch)
-       {
-               // ActivateTeamplay();
-               fraglimit_override = autocvar_g_runematch_point_limit;
-               leadlimit_override = autocvar_g_runematch_point_leadlimit;
-               runematch_init();
-       }
-
        if(g_lms)
        {
                fraglimit_override = autocvar_g_lms_lives_override;
@@ -228,6 +201,7 @@ void InitGameplayMode()
        {
                ActivateTeamplay();
                have_team_spawns = -1; // request team spawns
+               MUTATOR_ADD(gamemode_onslaught);
        }
 
        if(g_race)
@@ -562,8 +536,6 @@ void CheckAllowedTeams (entity for_whom)
 
 float PlayerValue(entity p)
 {
-       if(IsTeamBalanceForced() == 1)
-               return 1;
        return 1;
        // FIXME: it always returns 1...
 }
@@ -681,6 +653,14 @@ float TeamSmallerEqThanTeam(float ta, float tb, entity e)
                }
        }
        
+       // keep teams alive (teams of size 0 always count as smaller, ignoring score)
+       if(ca < 1)
+               if(cb >= 1)
+                       return TRUE;
+       if(ca >= 1)
+               if(cb < 1)
+                       return FALSE;
+
        // first, normalize
        f = max(ca, cb, 1);
        ca /= f;
@@ -844,7 +824,7 @@ float JoinBestTeam(entity pl, float only_return_best, float forcebestteam)
 //void() ctf_playerchanged;
 void SV_ChangeTeam(float _color)
 {
-       float scolor, dcolor, steam, dteam, dbotcount, scount, dcount;
+       float scolor, dcolor, steam, dteam; //, dbotcount, scount, dcount;
 
        // in normal deathmatch we can just apply the color and we're done
        if(!teamplay) {
@@ -892,7 +872,8 @@ void SV_ChangeTeam(float _color)
                return; // changing teams is not allowed
        }
 
-       if(autocvar_g_balance_teams_prevent_imbalance)
+       // autocvar_g_balance_teams_prevent_imbalance only makes sense if autocvar_g_balance_teams is on, as it makes the team selection dialog pointless
+       if(autocvar_g_balance_teams && autocvar_g_balance_teams_prevent_imbalance)
        {
                GetTeamCounts(self);
                if(!TeamSmallerEqThanTeam(dteam, steam, self))
@@ -918,7 +899,6 @@ void SV_ChangeTeam(float _color)
                if(self.deadflag == DEAD_NO)
                        Damage(self, self, self, 100000, DEATH_TEAMCHANGE, self.origin, '0 0 0');
        }
-       //ctf_playerchanged();
 }
 
 void ShufflePlayerOutOfTeam (float source_team)
@@ -1062,87 +1042,6 @@ void ShufflePlayerOutOfTeam (float source_team)
        centerprint(selected, strcat("You have been moved into a different team to improve team balance\nYou are now on: ", ColoredTeamName(selected.team)));
 }
 
-void CauseRebalance(float source_team, float howmany_toomany)
-{
-       if(IsTeamBalanceForced() == 1)
-       {
-               bprint("Rebalancing Teams\n");
-               ShufflePlayerOutOfTeam(source_team);
-       }
-}
-
-// part of g_balance_teams_force
-// occasionally perform an audit of the teams to make
-// sure they're more or less balanced in player count.
-void AuditTeams()
-{
-       float numplayers, numteams, smallest, toomany;
-       float balance;
-       balance = IsTeamBalanceForced();
-       if(balance == 0)
-               return;
-
-       if(audit_teams_time > time)
-               return;
-
-       audit_teams_time = time + 4 + random();
-
-//     bprint("Auditing teams\n");
-
-       CheckAllowedTeams(world);
-       GetTeamCounts(world);
-
-
-       numteams = numplayers = smallest = 0;
-       if(c1 >= 0)
-       {
-               numteams = numteams + 1;
-               numplayers = numplayers + c1;
-               smallest = c1;
-       }
-       if(c2 >= 0)
-       {
-               numteams = numteams + 1;
-               numplayers = numplayers + c2;
-               if(c2 < smallest)
-                       smallest = c2;
-       }
-       if(c3 >= 0)
-       {
-               numteams = numteams + 1;
-               numplayers = numplayers + c3;
-               if(c3 < smallest)
-                       smallest = c3;
-       }
-       if(c4 >= 0)
-       {
-               numteams = numteams + 1;
-               numplayers = numplayers + c4;
-               if(c4 < smallest)
-                       smallest = c4;
-       }
-
-       if(numplayers <= 0)
-               return; // no players to move around
-       if(numteams < 2)
-               return; // don't bother shuffling if for some reason there aren't any teams
-
-       toomany = smallest + 1;
-
-       if(c1 && c1 > toomany)
-               CauseRebalance(1, c1 - toomany);
-       if(c2 && c2 > toomany)
-               CauseRebalance(2, c2 - toomany);
-       if(c3 && c3 > toomany)
-               CauseRebalance(3, c3 - toomany);
-       if(c4 && c4 > toomany)
-               CauseRebalance(4, c4 - toomany);
-
-       // if teams are still unbalanced, balance them further in the next audit,
-       // which will happen sooner (keep doing rapid audits until things are in order)
-       audit_teams_time = time + 0.7 + random()*0.3;
-}
-
 // code from here on is just to support maps that don't have team entities
 void tdm_spawnteam (string teamname, float teamcolor)
 {