Commit f68c4c0c authored by Mikleo's avatar Mikleo
Browse files

--

parent 3a9f47e5
Pipeline #5990 passed with stages
in 17 seconds
......@@ -6,9 +6,9 @@ int wasTeamBalanced [MAXPLAYERS+1] = {false,...};
void OnPluginStart_SimpleBalance()
{
dp_simplebalance = CreateConVar("dp_simplebalance", "0", "simplebalance players with mmr. ");
dp_simplebalance_mmrmargin = CreateConVar("dp_simplebalance_mmrmargin", "40", "margin of mmr difference before players are autobalanced");
dp_simplebalance_mmrmargin = CreateConVar("dp_simplebalance_mmrmargin", "35", "margin of mmr difference before players are autobalanced");
dp_simplebalance_nocomm = CreateConVar("dp_simplebalance_nocomm", "0", "teambalance on infantry maps");
dp_simplebalance_playerratio = CreateConVar("dp_simplebalance_playerratio", "0.33", "proportion of players in teams before teambalance enabled ");
dp_simplebalance_playerratio = CreateConVar("dp_simplebalance_playerratio", "0.2", "proportion of players in teams before teambalance enabled ");
dp_simplebalance.AddChangeHook(dp_simplebalance_changed);
}
......@@ -23,18 +23,16 @@ void OnClientPutInServer_SimpleBalance(int client)
}
// true is allow team
// false is block team
bool CheckTeamBalance(int client,int currentTeam,int clientTeam)
{
// dont teambalance if it is not enabled or we are in a draft.
if(dp_simplebalance.IntValue == 0 )
// dont teambalance if it is not enabled
if(dp_simplebalance.IntValue == 0 || clientTeam < 2 || currentTeam == clientTeam)
return true;
int numplayers[2];
numplayers[0] = GetTeamClientCount(2);
numplayers[1] = GetTeamClientCount(3);
......@@ -46,7 +44,12 @@ bool CheckTeamBalance(int client,int currentTeam,int clientTeam)
{
ExecuteAutoBalance(client,3);
return false;
}
}
else if(clientTeam == 3)
{
ForceTeam(client,3);
return false;
}
}
else if(numplayers[0] < numplayers[1] )
{
......@@ -54,14 +57,17 @@ bool CheckTeamBalance(int client,int currentTeam,int clientTeam)
{
ExecuteAutoBalance(client,2);
return false;
}
}
else if(clientTeam == 2)
{
ForceTeam(client,2);
return false;
}
}
// dont teambalance infantry maps unless specified.
if(!EU_IsClassicMap() && dp_simplebalance_nocomm.IntValue == 0)
return true;
float ratings[MAXPLAYERS+1];
......@@ -99,29 +105,42 @@ bool CheckTeamBalance(int client,int currentTeam,int clientTeam)
}
}
float clientmmr = ratings[client];
int margin = dp_simplebalance_mmrmargin.IntValue;
float avgmmr = averagemmr[2];
// if autoassign assign a team based on mmr.
if(clientTeam == 4)
{
if((averagemmr[0] < averagemmr[1] && clientmmr > avgmmr) || (averagemmr[0] > averagemmr[1] && clientmmr <avgmmr))
{
ForceTeam(client,2);
return false;
}
else
{
ForceTeam(client,3);
return false;
}
}
float playerRatio = float(numplayers[0] + numplayers[1]) / float(GetClientCount(false));
int totalPlayersInTeam = numplayers[0] + numplayers[1];
float playerRatio = float(totalPlayersInTeam) / float(GetClientCount(false));
// if teams are not even and we are not in a team
if(numplayers[0] != numplayers[1] || currentTeam == clientTeam)
return true;
// if there are less players than our playerratio in teams dont teambalance
if(playerRatio < dp_simplebalance_playerratio.FloatValue)
// if there are less players than our playerratio or in a non classic map dont autobalance here
if(playerRatio < dp_simplebalance_playerratio.FloatValue || (EU_IsClassicMap() && dp_simplebalance_nocomm.IntValue == 0))
return true;
float clientmmr = ratings[client];
int margin = dp_simplebalance_mmrmargin.IntValue;
float avgmmr = averagemmr[2];
if(!wasTeamBalanced[client] && (clientTeam == 2 || clientTeam == 3))
{
......@@ -142,20 +161,7 @@ bool CheckTeamBalance(int client,int currentTeam,int clientTeam)
}
// if autoassign assign a team based on mmr.
if(clientTeam == 4)
{
if((averagemmr[0] < averagemmr[1] && clientmmr > avgmmr) || (averagemmr[0] > averagemmr[1] && clientmmr <avgmmr))
{
ForceTeam(client,2);
return false;
}
else
{
ForceTeam(client,3);
return false;
}
}
return true;
......
......@@ -8,7 +8,7 @@
#include <empstats>
#include <updater>
#define PluginVersion "0.85"
#define PluginVersion "0.86"
#define UPDATE_URL "https://sourcemod.docs.empiresmod.com/DraftPick/dist/updater.txt"
......
......@@ -4,7 +4,7 @@
{
"Version"
{
"Latest" "0.85"
"Latest" "0.86"
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment