Update Autobalance.cs

Built-in mode debug
This commit is contained in:
ChocoTaco 2019-11-20 15:46:28 -05:00
parent 124fd51f96
commit 3520f884d6

View file

@ -57,34 +57,31 @@ function Autobalance( %game, %AutobalanceSafetynetTrys )
//Toggle for All Mode //Toggle for All Mode
//If a team is behind pick anyone, not just a low scoring player //If a team is behind pick anyone, not just a low scoring player
if( $TeamScore[%bigTeam] > ($TeamScore[%littleTeam] + $AllModeThreshold) ) if( $TeamScore[%bigTeam] > ($TeamScore[%littleTeam] + $AllModeThreshold) )
{
%UseAllMode = 1; %UseAllMode = 1;
%autobalanceRandom = getRandom(1,($PlayerCount[%bigTeam] - 1));
}
//Pick a client for autobalance //Pick a client for autobalance
for(%i = 0; %i < ClientGroup.getCount(); %i++) for(%i = 0; %i < ClientGroup.getCount(); %i++)
{ {
%client = ClientGroup.getObject(%i); %client = ClientGroup.getObject(%i);
%team = %client.team;
if(%UseAllMode) if(%UseAllMode)
{ {
//Try to pick any player //Try to pick any player
%team = %client.team;
%autobalanceRandom = getRandom(1,($PlayerCount[%bigTeam] - 1));
if(%autobalanceRandom == %autobalanceLoop || %lastclient[%team] $= "") if(%autobalanceRandom == %autobalanceLoop || %lastclient[%team] $= "")
%teamcanidate[%team] = %client; %teamcanidate[%team] = %client;
%autobalanceLoop++; %autobalanceLoop++;
//echo("All Mode");
} }
else else
{ {
//Normal circumstances //Normal circumstances
//Try to pick a low scoring player //Try to pick a low scoring player
%team = %client.team;
if(%client.score < %lastclient[%team].score || %lastclient[%team] $= "") if(%client.score < %lastclient[%team].score || %lastclient[%team] $= "")
%teamcanidate[%team] = %client; %teamcanidate[%team] = %client;
//echo("Low Mode");
} }
%lastclient[%team] = %client; %lastclient[%team] = %client;
@ -92,7 +89,7 @@ function Autobalance( %game, %AutobalanceSafetynetTrys )
//Debug //Debug
if( %AutobalanceDebug ) if( %AutobalanceDebug )
AutobalanceDebug(%teamcanidate1, %teamcanidate2, %team1difference, %team2difference, %bigTeam, %AutobalanceSafetynetTrys); AutobalanceDebug(%teamcanidate1, %teamcanidate2, %team1difference, %team2difference, %bigTeam, %AutobalanceSafetynetTrys, %UseAllMode);
%client = %teamcanidate[%bigTeam]; %client = %teamcanidate[%bigTeam];
%team = %teamcanidate[%bigTeam].team; %team = %teamcanidate[%bigTeam].team;
@ -115,7 +112,7 @@ function Autobalance( %game, %AutobalanceSafetynetTrys )
return; return;
} }
function AutobalanceDebug(%teamcanidate1, %teamcanidate2, %team1difference, %team2difference, %bigTeam, %AutobalanceSafetynetTrys) function AutobalanceDebug(%teamcanidate1, %teamcanidate2, %team1difference, %team2difference, %bigTeam, %AutobalanceSafetynetTrys, %UseAllMode)
{ {
if( %teamcanidate[%bigTeam] $= "" ) if( %teamcanidate[%bigTeam] $= "" )
{ {
@ -136,13 +133,18 @@ function AutobalanceDebug(%teamcanidate1, %teamcanidate2, %team1difference, %tea
//Rerun in 10 secs //Rerun in 10 secs
schedule(10000, 0, "Autobalance", %game, %AutobalanceSafetynetTrys ); schedule(10000, 0, "Autobalance", %game, %AutobalanceSafetynetTrys );
} }
if(%UseAllMode)
%mode = "All Mode";
else
%mode = "Low Mode";
if( %teamcanidate1 $= "" ) if( %teamcanidate1 $= "" )
%teamcanidate1 = "NULL"; %teamcanidate1 = "NULL";
if( %teamcanidate2 $= "" ) if( %teamcanidate2 $= "" )
%teamcanidate2 = "NULL"; %teamcanidate2 = "NULL";
messageAll('MsgTeamBalanceNotify', '\c0Autobalance stat: %1, %2, %3, %4', %teamcanidate1, %team1difference, %teamcanidate2, %team2difference ); messageAll('MsgTeamBalanceNotify', '\c0Autobalance stat: %1, %2, %3, %4, %5', %teamcanidate1, %team1difference, %teamcanidate2, %team2difference, %mode );
return; return;
} }