mirror of
https://github.com/ChocoTaco1/TacoServer.git
synced 2026-03-06 13:10:21 +00:00
Conditional Autobalance
Added an All Mode if littleTeam is behind by set threshold
This commit is contained in:
parent
1daa583f41
commit
9642e893d0
1 changed files with 44 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue