From 51089168ebae47f980dcf44ccdf701538626b9ea Mon Sep 17 00:00:00 2001 From: ChocoTaco1 Date: Mon, 24 Aug 2020 17:56:36 -0400 Subject: [PATCH] Update Autobalance.cs Changed var Flags are checked now for exceptions, not assumed --- Classic/scripts/autoexec/Autobalance.cs | 41 +++++++++++++++---------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/Classic/scripts/autoexec/Autobalance.cs b/Classic/scripts/autoexec/Autobalance.cs index 87b7f78..8e47a92 100644 --- a/Classic/scripts/autoexec/Autobalance.cs +++ b/Classic/scripts/autoexec/Autobalance.cs @@ -43,7 +43,20 @@ function Autobalance( %game, %AutobalanceSafetynetTrys ) if( $TeamScore[%bigTeam] > ($TeamScore[%littleTeam] + $AllModeThreshold)) { %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 @@ -60,29 +73,27 @@ function Autobalance( %game, %AutobalanceSafetynetTrys ) if(%UseAllMode) { - //Try to pick any player - if(%autobalanceRandom == %AllmodeLoop || %lastclient[%team] $= "") - %teamcanidate[%team] = %client; + //Pick our random + if(%autobalanceRandom == %AllmodeLoop || %canidate $= "") + %canidate = %client; %AllmodeLoop++; } else { - //Normal circumstances //Try to pick a low scoring player - if(%client.score < %lastclient[%team].score || %lastclient[%team] $= "") - %teamcanidate[%team] = %client; + if(%client.score < %canidate.score || %canidate $= "") + %canidate = %client; } - %lastclient[%team] = %client; } } //Debug if( %AutobalanceDebug ) - AutobalanceDebug(%teamcanidate1, %teamcanidate2, %team1difference, %team2difference, %bigTeam, %AutobalanceSafetynetTrys, %UseAllMode); + AutobalanceDebug(%canidate, %team1difference, %team2difference, %bigTeam, %AutobalanceSafetynetTrys, %UseAllMode); - %client = %teamcanidate[%bigTeam]; - %team = %teamcanidate[%bigTeam].team; + %client = %canidate; + %team = %canidate.team; %otherTeam = ( %team == 1 ) ? 2 : 1; //Fire Autobalance @@ -96,7 +107,7 @@ function Autobalance( %game, %AutobalanceSafetynetTrys ) ResetTBNStatus(); } -function AutobalanceDebug(%teamcanidate1, %teamcanidate2, %team1difference, %team2difference, %bigTeam, %AutobalanceSafetynetTrys, %UseAllMode) +function AutobalanceDebug(%canidate, %team1difference, %team2difference, %bigTeam, %AutobalanceSafetynetTrys, %UseAllMode) { if( %teamcanidate[%bigTeam] $= "" ) { @@ -104,9 +115,7 @@ function AutobalanceDebug(%teamcanidate1, %teamcanidate2, %team1difference, %tea if(%AutobalanceSafetynetTrys $= 3) return; - if( %teamcanidate1 $= "" && %teamcanidate2 $= "" ) - %error = "Both Teams"; - else if( %teamcanidate[%bigTeam] $= "" ) + if( %canidate $= "" ) %error = "Team " @ %bigTeam; if( %error !$= "" ) @@ -128,7 +137,7 @@ function AutobalanceDebug(%teamcanidate1, %teamcanidate2, %team1difference, %tea if( %teamcanidate2 $= "" ) %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; } \ No newline at end of file