Update Autobalance.cs

Changed var
Flags are checked now for exceptions, not assumed
This commit is contained in:
ChocoTaco1 2020-08-24 17:56:36 -04:00
parent 81c80b0ef1
commit 51089168eb

View file

@ -43,7 +43,20 @@ function Autobalance( %game, %AutobalanceSafetynetTrys )
if( $TeamScore[%bigTeam] > ($TeamScore[%littleTeam] + $AllModeThreshold)) if( $TeamScore[%bigTeam] > ($TeamScore[%littleTeam] + $AllModeThreshold))
{ {
%UseAllMode = 1; %UseAllMode = 1;
%autobalanceRandom = getRandom(1,($TeamRank[%bigTeam, count] - 1)); //Find if anyone is holding a flag for exceptions for the loop
for(%i = 0; %i < ClientGroup.getCount(); %i++)
{
%client = ClientGroup.getObject(%i);
%team = %client.team;
if(%team $= %bigTeam)
{
//Holding flag?
if(%client.player.holdingFlag !$= "")
%exception = 1;
}
}
%autobalanceRandom = getRandom(1,($TeamRank[%bigTeam, count] - %exception));
} }
//Pick a client for autobalance //Pick a client for autobalance
@ -60,29 +73,27 @@ function Autobalance( %game, %AutobalanceSafetynetTrys )
if(%UseAllMode) if(%UseAllMode)
{ {
//Try to pick any player //Pick our random
if(%autobalanceRandom == %AllmodeLoop || %lastclient[%team] $= "") if(%autobalanceRandom == %AllmodeLoop || %canidate $= "")
%teamcanidate[%team] = %client; %canidate = %client;
%AllmodeLoop++; %AllmodeLoop++;
} }
else else
{ {
//Normal circumstances
//Try to pick a low scoring player //Try to pick a low scoring player
if(%client.score < %lastclient[%team].score || %lastclient[%team] $= "") if(%client.score < %canidate.score || %canidate $= "")
%teamcanidate[%team] = %client; %canidate = %client;
} }
%lastclient[%team] = %client;
} }
} }
//Debug //Debug
if( %AutobalanceDebug ) if( %AutobalanceDebug )
AutobalanceDebug(%teamcanidate1, %teamcanidate2, %team1difference, %team2difference, %bigTeam, %AutobalanceSafetynetTrys, %UseAllMode); AutobalanceDebug(%canidate, %team1difference, %team2difference, %bigTeam, %AutobalanceSafetynetTrys, %UseAllMode);
%client = %teamcanidate[%bigTeam]; %client = %canidate;
%team = %teamcanidate[%bigTeam].team; %team = %canidate.team;
%otherTeam = ( %team == 1 ) ? 2 : 1; %otherTeam = ( %team == 1 ) ? 2 : 1;
//Fire Autobalance //Fire Autobalance
@ -96,7 +107,7 @@ function Autobalance( %game, %AutobalanceSafetynetTrys )
ResetTBNStatus(); ResetTBNStatus();
} }
function AutobalanceDebug(%teamcanidate1, %teamcanidate2, %team1difference, %team2difference, %bigTeam, %AutobalanceSafetynetTrys, %UseAllMode) function AutobalanceDebug(%canidate, %team1difference, %team2difference, %bigTeam, %AutobalanceSafetynetTrys, %UseAllMode)
{ {
if( %teamcanidate[%bigTeam] $= "" ) if( %teamcanidate[%bigTeam] $= "" )
{ {
@ -104,9 +115,7 @@ function AutobalanceDebug(%teamcanidate1, %teamcanidate2, %team1difference, %tea
if(%AutobalanceSafetynetTrys $= 3) if(%AutobalanceSafetynetTrys $= 3)
return; return;
if( %teamcanidate1 $= "" && %teamcanidate2 $= "" ) if( %canidate $= "" )
%error = "Both Teams";
else if( %teamcanidate[%bigTeam] $= "" )
%error = "Team " @ %bigTeam; %error = "Team " @ %bigTeam;
if( %error !$= "" ) if( %error !$= "" )
@ -128,7 +137,7 @@ function AutobalanceDebug(%teamcanidate1, %teamcanidate2, %team1difference, %tea
if( %teamcanidate2 $= "" ) if( %teamcanidate2 $= "" )
%teamcanidate2 = "NULL"; %teamcanidate2 = "NULL";
messageAll('MsgTeamBalanceNotify', '\c0Autobalance stat: %1, %2, %3, %4, %5', %teamcanidate1, %team1difference, %teamcanidate2, %team2difference, %mode ); messageAll('MsgTeamBalanceNotify', '\c0Autobalance stat: %1, %2, %3, %4', %canidate, %team1difference, %team2difference, %mode );
return; return;
} }