From 9642e893d00864965c61e472dec3649f0d8647e7 Mon Sep 17 00:00:00 2001 From: ChocoTaco Date: Wed, 20 Nov 2019 14:51:02 -0500 Subject: [PATCH] Conditional Autobalance Added an All Mode if littleTeam is behind by set threshold --- Classic/scripts/autoexec/Autobalance.cs | 50 ++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/Classic/scripts/autoexec/Autobalance.cs b/Classic/scripts/autoexec/Autobalance.cs index 6d3f0ea..90ae935 100644 --- a/Classic/scripts/autoexec/Autobalance.cs +++ b/Classic/scripts/autoexec/Autobalance.cs @@ -7,6 +7,11 @@ // $Host::EnableAutobalance = 1; // +// How far behind littleTeam must be to use All Mode. +// Meaning picking from a pool of all players on the bigTeam instead of just the lowest scoring player. +// 400 equals 400 points. 4 caps behind. +$AllModeThreshold = 400; + // Run from TeamBalanceNotify.cs via UnbalancedSound( %game ) function Autobalance( %game, %AutobalanceSafetynetTrys ) @@ -27,12 +32,6 @@ function Autobalance( %game, %AutobalanceSafetynetTrys ) for(%i = 0; %i < ClientGroup.getCount(); %i++) { %client = ClientGroup.getObject(%i); - - //Pick a client for autobalance - //Try to pick a low scoring player - %team = %client.team; - if(%client.score < %lastclient[%team].score || %lastclient[%team] $= "") - %teamcanidate[%team] = %client; %lastclient[%team] = %client; @@ -56,6 +55,44 @@ function Autobalance( %game, %AutobalanceSafetynetTrys ) else if( %team2difference >= 2 ) %bigTeam = 2; + %littleTeam = ( %bigTeam == 1 ) ? 2 : 1; + + //Toggle for All Mode + //If a team is behind pick anyone, not just a low scoring player + if( $TeamScore[%bigTeam] > ($TeamScore[%littleTeam] + $AllModeThreshold) ) + %UseAllMode = 1; + + //Pick a client for autobalance + for(%i = 0; %i < ClientGroup.getCount(); %i++) + { + %client = ClientGroup.getObject(%i); + + if(%UseAllMode) + { + //Try to pick any player + %team = %client.team; + %autobalanceRandom = getRandom(1,($PlayerCount[%bigTeam] - 1)); + if(%autobalanceRandom == %autobalanceLoop || %lastclient[%team] $= "") + %teamcanidate[%team] = %client; + + %autobalanceLoop++; + + //echo("All Mode"); + } + else + { + //Normal circumstances + //Try to pick a low scoring player + %team = %client.team; + if(%client.score < %lastclient[%team].score || %lastclient[%team] $= "") + %teamcanidate[%team] = %client; + + //echo("Low Mode"); + } + + %lastclient[%team] = %client; + } + //Debug if( %AutobalanceDebug ) AutobalanceDebug(%teamcanidate1, %teamcanidate2, %team1difference, %team2difference, %bigTeam, %AutobalanceSafetynetTrys); @@ -73,6 +110,7 @@ function Autobalance( %game, %AutobalanceSafetynetTrys ) else messageAll('MsgTeamBalanceNotify', '\c0Autobalance error: Team %1 mismatch.', %bigTeam ); + //Trigger GetCounts ResetClientChangedTeams(); //Reset Unbalanced