mirror of
https://github.com/ChocoTaco1/TacoServer.git
synced 2026-07-15 16:14:35 +00:00
AutoBalance/TeamBalance notify update
This commit is contained in:
parent
f3934b28c7
commit
a515a0d900
3 changed files with 207 additions and 171 deletions
|
|
@ -1,103 +1,128 @@
|
||||||
|
// Team Autobalance Script
|
||||||
|
//
|
||||||
|
// Determines which team needs players and proceeds to find candidates
|
||||||
|
// Candidates are based on low scores then switches the candidate
|
||||||
|
//
|
||||||
// Enable or Disable Autobalance
|
// Enable or Disable Autobalance
|
||||||
// $Host::EnableAutobalance = 1;
|
// $Host::EnableAutobalance = 1;
|
||||||
//
|
//
|
||||||
// Run from TeamBalanceNotify.cs via StatsUnbalanceSound( %game )
|
|
||||||
// Getting random client aspects run in GetTeamCounts.cs
|
|
||||||
//
|
// Run from TeamBalanceNotify.cs via UnbalancedSound( %game )
|
||||||
// Fire Autobalance
|
// Fire Autobalance
|
||||||
function Autobalance( %game, %AutobalanceSafetynetTrys )
|
function Autobalance( %game, %AutobalanceSafetynetTrys )
|
||||||
{
|
{
|
||||||
if( $CurrentMissionType !$= "LakRabbit" && $Host::EnableTeamBalanceNotify && $StatsMsgPlayed $= 1 && !$Host::TournamentMode )
|
//%AutobalanceDebug = true;
|
||||||
{
|
|
||||||
//%AutobalanceDebug = true;
|
//For autobalance
|
||||||
|
%lastclient1 = "";
|
||||||
|
%lastclient2 = "";
|
||||||
|
|
||||||
if( $Team1Difference == 1 || $Team2Difference == 1 || $PlayerCount[1] == $PlayerCount[2] )
|
//Team Count code by Keen
|
||||||
{
|
$PlayerCount[0] = 0;
|
||||||
$StatsMsgPlayed = 0;
|
$PlayerCount[1] = 0;
|
||||||
return;
|
$PlayerCount[2] = 0;
|
||||||
}
|
|
||||||
//Safetynet
|
|
||||||
else if(( $team1canidate $= "" && $Team1Difference >= 2 )||( $team2canidate $= "" && $Team2Difference >= 2 ))
|
|
||||||
{
|
|
||||||
%AutobalanceSafetynetTrys++; if(%AutobalanceSafetynetTrys $= 3) return;
|
|
||||||
|
|
||||||
if( %AutobalanceDebug )
|
for(%i = 0; %i < ClientGroup.getCount(); %i++)
|
||||||
{
|
{
|
||||||
if( $team1canidate $= "" ) $team1canidate = "NULL"; if( $team2canidate $= "" ) $team2canidate = "NULL";
|
%client = ClientGroup.getObject(%i);
|
||||||
messageAll('MsgTeamBalanceNotify', '\c0Autobalance error: %1, %2, %3, %4', $team1canidate, $team2canidate, $Team1Difference, $Team2Difference );
|
|
||||||
if( $team1canidate $= "NULL" ) $team1canidate = ""; if( $team2canidate $= "NULL" ) $team2canidate = "";
|
|
||||||
}
|
|
||||||
else if( $team1canidate $= "" && $team2canidate $= "" ) messageAll('MsgTeamBalanceNotify', '\c0Autobalance error: Both Teams' );
|
|
||||||
else if( $team1canidate $= "" ) messageAll('MsgTeamBalanceNotify', '\c0Autobalance error: Team1' );
|
|
||||||
else if( $team2canidate $= "" ) messageAll('MsgTeamBalanceNotify', '\c0Autobalance error: Team2' );
|
|
||||||
|
|
||||||
//Trigger GetCounts
|
//Pick a client for autobalance
|
||||||
ResetClientChangedTeams();
|
%team = %client.team;
|
||||||
//Rerun in 10 secs
|
if(%client.score < %lastclient[%team].score || %lastclient[%team] $= "")
|
||||||
schedule(10000, 0, "Autobalance", %game, %AutobalanceSafetynetTrys );
|
%teamcanidate[%team] = %client;
|
||||||
//Clear Canidates
|
|
||||||
$team1canidate = ""; $team2canidate = "";
|
%lastclient[%team] = %client;
|
||||||
return;
|
|
||||||
}
|
|
||||||
//Team 1
|
|
||||||
else if( $Team1Difference >= 2 )
|
|
||||||
{
|
|
||||||
if( %AutobalanceDebug )
|
|
||||||
{
|
|
||||||
if( $team1canidate $= "" ) $team1canidate = "NULL"; if( $team2canidate $= "" ) $team2canidate = "NULL";
|
|
||||||
messageAll('MsgTeamBalanceNotify', '\c0Autobalance stat: %1, %2, %3, %4', $team1canidate, $team2canidate, $Team1Difference, $Team2Difference );
|
|
||||||
if( $team1canidate $= "NULL" ) $team1canidate = ""; if( $team2canidate $= "NULL" ) $team2canidate = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
%client = $team1canidate;
|
//if(!%client.isAIControlled())
|
||||||
%team = $team1canidate.team;
|
$PlayerCount[%client.team]++;
|
||||||
%otherTeam = ( %team == 1 ) ? 2 : 1;
|
}
|
||||||
|
|
||||||
if( $team1canidate.team $= 1 )
|
//Difference Variables
|
||||||
{
|
%team1difference = $PlayerCount[1] - $PlayerCount[2];
|
||||||
Game.clientChangeTeam( %client, %otherTeam, 0 );
|
%team2difference = $PlayerCount[2] - $PlayerCount[1];
|
||||||
messageAll('MsgTeamBalanceNotify', '~wfx/powered/vehicle_screen_on.wav');
|
|
||||||
}
|
if( %team1difference == 1 || %team2difference == 1 || $PlayerCount[1] == $PlayerCount[2] )
|
||||||
else
|
{
|
||||||
messageAll('MsgTeamBalanceNotify', '\c0Autobalance error: Team1 mismatch.' );
|
$StatsMsgPlayed = 0;
|
||||||
|
return;
|
||||||
//Trigger GetCounts
|
}
|
||||||
ResetClientChangedTeams();
|
//Safetynet
|
||||||
//Reset Stats.
|
else if(( %teamcanidate1 $= "" && %team1difference >= 2 )||( %teamcanidate2 $= "" && %team2difference >= 2 ))
|
||||||
$StatsMsgPlayed = 0;
|
{
|
||||||
//Clear Canidates
|
%AutobalanceSafetynetTrys++; if(%AutobalanceSafetynetTrys $= 3) return;
|
||||||
$team1canidate = ""; $team2canidate = "";
|
|
||||||
return;
|
if( %AutobalanceDebug )
|
||||||
}
|
|
||||||
//Team 2
|
|
||||||
else if( $Team2Difference >= 2 )
|
|
||||||
{
|
{
|
||||||
if( %AutobalanceDebug )
|
if( %teamcanidate1 $= "" ) %teamcanidate1 = "NULL"; if( %teamcanidate2 $= "" ) %teamcanidate2 = "NULL";
|
||||||
{
|
messageAll('MsgTeamBalanceNotify', '\c0Autobalance error: %1, %2, %3, %4', %teamcanidate1, %teamcanidate2, %team1difference, %team2difference );
|
||||||
if( $team1canidate $= "" ) $team1canidate = "NULL"; if( $team2canidate $= "" ) $team2canidate = "NULL";
|
if( %teamcanidate1 $= "NULL" ) %teamcanidate1 = ""; if( %teamcanidate2 $= "NULL" ) %teamcanidate2 = "";
|
||||||
messageAll('MsgTeamBalanceNotify', '\c0Autobalance stat: %1, %2, %3, %4', $team1canidate, $team2canidate, $Team1Difference, $Team2Difference );
|
|
||||||
if( $team1canidate $= "NULL" ) $team1canidate = ""; if( $team2canidate $= "NULL" ) $team2canidate = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
%client = $team2canidate;
|
|
||||||
%team = $team2canidate.team;
|
|
||||||
%otherTeam = ( %team == 1 ) ? 2 : 1;
|
|
||||||
|
|
||||||
if( $team2canidate.team $= 2 )
|
|
||||||
{
|
|
||||||
Game.clientChangeTeam( %client, %otherTeam, 0 );
|
|
||||||
messageAll('MsgTeamBalanceNotify', '~wfx/powered/vehicle_screen_on.wav');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
messageAll('MsgTeamBalanceNotify', '\c0Autobalance error: Team2 mismatch.' );
|
|
||||||
|
|
||||||
//Trigger GetCounts
|
|
||||||
ResetClientChangedTeams();
|
|
||||||
//Reset Stats.
|
|
||||||
$StatsMsgPlayed = 0;
|
|
||||||
//Clear Canidates
|
|
||||||
$team1canidate = ""; $team2canidate = "";
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else if( %teamcanidate1 $= "" && %teamcanidate2 $= "" ) messageAll('MsgTeamBalanceNotify', '\c0Autobalance error: Both Teams' );
|
||||||
|
else if( %teamcanidate1 $= "" ) messageAll('MsgTeamBalanceNotify', '\c0Autobalance error: Team1' );
|
||||||
|
else if( %teamcanidate2 $= "" ) messageAll('MsgTeamBalanceNotify', '\c0Autobalance error: Team2' );
|
||||||
|
|
||||||
|
//Trigger GetCounts
|
||||||
|
ResetClientChangedTeams();
|
||||||
|
//Rerun in 10 secs
|
||||||
|
schedule(10000, 0, "Autobalance", %game, %AutobalanceSafetynetTrys );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//Team 1
|
||||||
|
else if( %team1difference >= 2 )
|
||||||
|
{
|
||||||
|
if( %AutobalanceDebug )
|
||||||
|
{
|
||||||
|
if( %teamcanidate1 $= "" ) %teamcanidate1 = "NULL"; if( %teamcanidate2 $= "" ) %teamcanidate2 = "NULL";
|
||||||
|
messageAll('MsgTeamBalanceNotify', '\c0Autobalance stat: %1, %2, %3, %4', %teamcanidate1, %teamcanidate2, %team1difference, %team2difference );
|
||||||
|
if( %teamcanidate1 $= "NULL" ) %teamcanidate1 = ""; if( %teamcanidate2 $= "NULL" ) %teamcanidate2 = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
%client = %teamcanidate1;
|
||||||
|
%team = %teamcanidate1.team;
|
||||||
|
%otherTeam = ( %team == 1 ) ? 2 : 1;
|
||||||
|
|
||||||
|
if( %teamcanidate1.team $= 1 )
|
||||||
|
{
|
||||||
|
Game.clientChangeTeam( %client, %otherTeam, 0 );
|
||||||
|
messageAll('MsgTeamBalanceNotify', '~wfx/powered/vehicle_screen_on.wav');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
messageAll('MsgTeamBalanceNotify', '\c0Autobalance error: Team1 mismatch.' );
|
||||||
|
|
||||||
|
//Trigger GetCounts
|
||||||
|
ResetClientChangedTeams();
|
||||||
|
//Reset Unbalanced
|
||||||
|
$UnbalancedMsgPlayed = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//Team 2
|
||||||
|
else if( %team2difference >= 2 )
|
||||||
|
{
|
||||||
|
if( %AutobalanceDebug )
|
||||||
|
{
|
||||||
|
if( %teamcanidate1 $= "" ) %teamcanidate1 = "NULL"; if( %teamcanidate2 $= "" ) %teamcanidate2 = "NULL";
|
||||||
|
messageAll('MsgTeamBalanceNotify', '\c0Autobalance stat: %1, %2, %3, %4', %teamcanidate1, %teamcanidate2, %team1difference, %team2difference );
|
||||||
|
if( %teamcanidate1 $= "NULL" ) %teamcanidate1 = ""; if( %teamcanidate2 $= "NULL" ) %teamcanidate2 = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
%client = %teamcanidate2;
|
||||||
|
%team = %teamcanidate2.team;
|
||||||
|
%otherTeam = ( %team == 1 ) ? 2 : 1;
|
||||||
|
|
||||||
|
if( %teamcanidate2.team $= 2 )
|
||||||
|
{
|
||||||
|
Game.clientChangeTeam( %client, %otherTeam, 0 );
|
||||||
|
messageAll('MsgTeamBalanceNotify', '~wfx/powered/vehicle_screen_on.wav');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
messageAll('MsgTeamBalanceNotify', '\c0Autobalance error: Team2 mismatch.' );
|
||||||
|
|
||||||
|
//Trigger GetCounts
|
||||||
|
ResetClientChangedTeams();
|
||||||
|
//Reset Unbalanced
|
||||||
|
$UnbalancedMsgPlayed = 0;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,14 +1,18 @@
|
||||||
// GetCounts was made to accurately keep track of how many players
|
// GetTeamCounts Script
|
||||||
// are on teams, on the server, on each team, spectator, etc.
|
|
||||||
// It runs every 5 seconds.
|
|
||||||
// It has since evolved into the place to inject other services
|
|
||||||
// and aspects within the server.
|
|
||||||
//
|
|
||||||
//
|
//
|
||||||
|
// GetTeamCounts was made to accurately keep track of how many players
|
||||||
|
// are on teams, on the server, on each team, observer, etc.
|
||||||
|
// AntiTurrets, Team Balance Notify, AntiCloak, AutoBalance, Base Rape and Base Rape Notify all rely on this.
|
||||||
|
// It runs every 5 seconds.
|
||||||
|
//
|
||||||
|
// Whether or not a portion of the script is run or not depends on
|
||||||
|
// if a player has switched teams or not. Or if a team changing event has occurred.
|
||||||
|
// This is triggered via various event functions throughout the game.
|
||||||
|
// All included in EvoClassicTaco.vl2
|
||||||
|
|
||||||
|
// Set reset string
|
||||||
$GetCountsClientTeamChange = true;
|
$GetCountsClientTeamChange = true;
|
||||||
|
|
||||||
|
|
||||||
package StartTeamCounts
|
package StartTeamCounts
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -35,28 +39,15 @@ function GetTeamCounts( %game, %client, %respawn )
|
||||||
$PlayerCount[1] = 0;
|
$PlayerCount[1] = 0;
|
||||||
$PlayerCount[2] = 0;
|
$PlayerCount[2] = 0;
|
||||||
|
|
||||||
//For autobalance
|
|
||||||
%lastclient1 = "";
|
|
||||||
%lastclient2 = "";
|
|
||||||
|
|
||||||
for(%i = 0; %i < ClientGroup.getCount(); %i++)
|
for(%i = 0; %i < ClientGroup.getCount(); %i++)
|
||||||
{
|
{
|
||||||
%client = ClientGroup.getObject(%i);
|
%client = ClientGroup.getObject(%i);
|
||||||
|
|
||||||
//Pick a client for autobalance
|
|
||||||
%team = %client.team;
|
|
||||||
if(%client.score < %lastclient[%team].score || %lastclient[%team] $= "") {
|
|
||||||
%teamcanidate[%team] = %client;
|
|
||||||
}
|
|
||||||
%lastclient[%team] = %client;
|
|
||||||
|
|
||||||
//if(!%client.isAIControlled())
|
//if(!%client.isAIControlled())
|
||||||
$PlayerCount[%client.team]++;
|
$PlayerCount[%client.team]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$team1canidate = %teamcanidate1;
|
|
||||||
$team2canidate = %teamcanidate2;
|
|
||||||
|
|
||||||
//echo ("$PlayerCount[0] " @ $PlayerCount[0]);
|
//echo ("$PlayerCount[0] " @ $PlayerCount[0]);
|
||||||
//echo ("$PlayerCount[1] " @ $PlayerCount[1]);
|
//echo ("$PlayerCount[1] " @ $PlayerCount[1]);
|
||||||
//echo ("$PlayerCount[2] " @ $PlayerCount[2]);
|
//echo ("$PlayerCount[2] " @ $PlayerCount[2]);
|
||||||
|
|
@ -66,13 +57,13 @@ function GetTeamCounts( %game, %client, %respawn )
|
||||||
//Amount of all players including observers
|
//Amount of all players including observers
|
||||||
$AllPlayerCount = $PlayerCount[1] + $PlayerCount[2] + $PlayerCount[0];
|
$AllPlayerCount = $PlayerCount[1] + $PlayerCount[2] + $PlayerCount[0];
|
||||||
//Difference Variables
|
//Difference Variables
|
||||||
$Team1Difference = $PlayerCount[1] - $PlayerCount[2];
|
%team1difference = $PlayerCount[1] - $PlayerCount[2];
|
||||||
$Team2Difference = $PlayerCount[2] - $PlayerCount[1];
|
%team2difference = $PlayerCount[2] - $PlayerCount[1];
|
||||||
|
|
||||||
//Start Base Rape Notify
|
//Start Base Rape Notify
|
||||||
schedule(500, 0, "NBRStatusNotify", %game);
|
schedule(500, 0, "NBRStatusNotify", %game);
|
||||||
//Start Team Balance Notify
|
//Start Team Balance Notify
|
||||||
schedule(1000, 0, "TeamBalanceNotify", %game );
|
schedule(1000, 0, "TeamBalanceNotify", %game, %team1difference, %team2difference);
|
||||||
//Start AntiCloak
|
//Start AntiCloak
|
||||||
schedule(1500, 0, "ActivateAntiCloak", %game);
|
schedule(1500, 0, "ActivateAntiCloak", %game);
|
||||||
//Start MapRepetitionChecker
|
//Start MapRepetitionChecker
|
||||||
|
|
@ -87,13 +78,10 @@ function GetTeamCounts( %game, %client, %respawn )
|
||||||
schedule(5000, 0, "GetTeamCounts");
|
schedule(5000, 0, "GetTeamCounts");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Run at DefaultGame::clientJoinTeam, DefaultGame::clientChangeTeam, DefaultGame::assignClientTeam in evo defaultgame.ovl
|
|
||||||
//Also Run at DefaultGame::onClientEnterObserverMode, DefaultGame::AIChangeTeam, DefaultGame::onClientLeaveGame, DefaultGame::forceObserver in evo defaultgame.ovl
|
|
||||||
//And finally GameConnection::onConnect in evo server.ovl
|
|
||||||
//Added so the bulk of GetCounts doesnt run when it doesnt need to causing unnecessary latency that may or may not have existed, but probably is good practice.
|
|
||||||
//GetCounts still runs every 5 seconds as it did, but whether or not someone has changed teams, joined obs, left, etc etc will decide whether or not the bulk of it runs.
|
|
||||||
|
|
||||||
//Let GetTeamCounts run if there is a Teamchange.
|
// Run at DefaultGame::clientJoinTeam, DefaultGame::clientChangeTeam, DefaultGame::assignClientTeam in evo defaultgame.ovl
|
||||||
|
// Also Run at DefaultGame::onClientEnterObserverMode, DefaultGame::AIChangeTeam, DefaultGame::onClientLeaveGame, DefaultGame::forceObserver in evo defaultgame.ovl
|
||||||
|
// And finally GameConnection::onConnect in evo server.ovl
|
||||||
function ResetClientChangedTeams()
|
function ResetClientChangedTeams()
|
||||||
{
|
{
|
||||||
$GetCountsClientTeamChange = true;
|
$GetCountsClientTeamChange = true;
|
||||||
|
|
|
||||||
|
|
@ -1,84 +1,107 @@
|
||||||
|
// Team Balance Notify Script
|
||||||
|
//
|
||||||
|
// Give the client a notification on the current state of balancing
|
||||||
|
// Furthermore if Autobalance is enabled. Proceed to Autobalancing
|
||||||
|
// Autobalance does not need TeamBalanceNotify to be enabled to run
|
||||||
|
//
|
||||||
// Enable or Disable
|
// Enable or Disable
|
||||||
// $Host::EnableTeamBalanceNotify = 1;
|
// $Host::EnableTeamBalanceNotify = 1;
|
||||||
// Enable or Disable Autobalance
|
// Enable or Disable Autobalance
|
||||||
// $Host::EnableAutobalance = 1;
|
// $Host::EnableAutobalance = 1;
|
||||||
//
|
//
|
||||||
// Give the client a notification on the current state of balancing.
|
|
||||||
//
|
|
||||||
// This function is in GetTeamCounts.cs
|
// This function is called in GetTeamCounts.cs
|
||||||
function TeamBalanceNotify( %game )
|
function TeamBalanceNotify( %game, %team1difference, %team2difference )
|
||||||
{
|
{
|
||||||
if( $CurrentMissionType !$= "LakRabbit" && $TotalTeamPlayerCount !$= 0 && $Host::EnableTeamBalanceNotify && !$Host::TournamentMode )
|
if( $CurrentMissionType !$= "LakRabbit" && $TotalTeamPlayerCount !$= 0 && !$Host::TournamentMode )
|
||||||
{
|
{
|
||||||
//echo ("%Team1Difference " @ %Team1Difference);
|
//echo ("%Team1Difference " @ %Team1Difference);
|
||||||
//echo ("%Team2Difference " @ %Team2Difference);
|
//echo ("%Team2Difference " @ %Team2Difference);
|
||||||
|
|
||||||
|
//Uneven
|
||||||
if( $PlayerCount[1] !$= $PlayerCount[2] )
|
if( $PlayerCount[1] !$= $PlayerCount[2] )
|
||||||
{
|
{
|
||||||
//Uneven. Reset Balanced.
|
//Reset Balanced.
|
||||||
$BalancedMsgPlayed = 0;
|
$BalancedMsgPlayed = 0;
|
||||||
|
|
||||||
if( $Team1Difference >= 2 || $Team2Difference >= 2 )
|
if( %team1difference >= 2 || %team2difference >= 2 )
|
||||||
{
|
{
|
||||||
if( $StatsMsgPlayed !$= 1)
|
if( $UnbalancedMsgPlayed !$= 1)
|
||||||
{
|
{
|
||||||
//Run once.
|
//Run once.
|
||||||
$StatsMsgPlayed = 1;
|
$UnbalancedMsgPlayed = 1;
|
||||||
//Start Sound Schedule for 60 secs
|
//Start Sound Schedule
|
||||||
schedule(15000, 0, "StatsUnbalanceSound", %game );
|
schedule(15000, 0, "UnbalancedSound", %game );
|
||||||
//For accurate msg when autobalance is disabled
|
|
||||||
if( !$Host::EnableAutobalance )
|
|
||||||
schedule(9000, 0, "ResetClientChangedTeams");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//If teams are balanced and teams dont equal 0.
|
//If teams are balanced
|
||||||
else if( $PlayerCount[1] == $PlayerCount[2] && $TotalTeamPlayerCount !$= 0 && $BalancedMsgPlayed !$= 1 )
|
else if( $PlayerCount[1] == $PlayerCount[2] && $TotalTeamPlayerCount !$= 0 && $BalancedMsgPlayed !$= 1 )
|
||||||
{
|
{
|
||||||
//messageAll('MsgTeamBalanceNotify', '\c1Teams are balanced.');
|
//messageAll('MsgTeamBalanceNotify', '\c1Teams are balanced.');
|
||||||
//Once per cycle.
|
//Once per cycle.
|
||||||
$BalancedMsgPlayed = 1;
|
$BalancedMsgPlayed = 1;
|
||||||
//Reset Stats.
|
//Reset Unbalanced.
|
||||||
$StatsMsgPlayed = 0;
|
$UnbalancedMsgPlayed = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Check to see if teams are still unbalanced
|
||||||
|
//Fire AutoBalance in 30 sec if enabled
|
||||||
|
function UnbalancedSound( %game )
|
||||||
|
{
|
||||||
|
if( $UnbalancedMsgPlayed $= 1 )
|
||||||
|
{
|
||||||
|
//Team Count code by Keen
|
||||||
|
$PlayerCount[0] = 0;
|
||||||
|
$PlayerCount[1] = 0;
|
||||||
|
$PlayerCount[2] = 0;
|
||||||
|
|
||||||
|
for(%i = 0; %i < ClientGroup.getCount(); %i++)
|
||||||
|
{
|
||||||
|
%client = ClientGroup.getObject(%i);
|
||||||
|
|
||||||
|
//if(!%client.isAIControlled())
|
||||||
|
$PlayerCount[%client.team]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Difference Variables
|
||||||
|
%team1difference = $PlayerCount[1] - $PlayerCount[2];
|
||||||
|
%team2difference = $PlayerCount[2] - $PlayerCount[1];
|
||||||
|
|
||||||
|
if( %team1difference == 1 || %team2difference == 1 || $PlayerCount[1] == $PlayerCount[2] )
|
||||||
|
{
|
||||||
|
//Reset
|
||||||
|
$UnbalancedMsgPlayed = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//Continue
|
||||||
|
else if( %team1difference >= 2 || %team2difference >= 2 )
|
||||||
|
{
|
||||||
|
//Autobalance Warning
|
||||||
|
if( $Host::EnableAutobalance )
|
||||||
|
{
|
||||||
|
messageAll('MsgTeamBalanceNotify', '\c1Teams are unbalanced: \c0Autobalance Initializing.~wgui/vote_nopass.wav');
|
||||||
|
schedule(30000, 0, "Autobalance", %game );
|
||||||
|
}
|
||||||
|
//If Autobalance is disabled, message only.
|
||||||
|
else if( $Host::EnableTeamBalanceNotify )
|
||||||
|
{
|
||||||
|
messageAll('MsgTeamBalanceNotify', '\c1Teams are unbalanced: \c0%1 vs %2 with %3 observers.~wgui/vote_nopass.wav', $PlayerCount[1], $PlayerCount[2], $PlayerCount[0] );
|
||||||
|
schedule(13000, 0, "ResetTeamBalanceNotifyGameOver");
|
||||||
|
schedule(15000, 0, "ResetClientChangedTeams");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Reset Notify at defaultgame::gameOver in evo defaultgame.ovl
|
//Reset Notify at defaultgame::gameOver in evo defaultgame.ovl
|
||||||
function ResetTeamBalanceNotifyGameOver()
|
function ResetTeamBalanceNotifyGameOver()
|
||||||
{
|
{
|
||||||
//Reset All TeamBalance Variables
|
//Reset All TeamBalance Variables
|
||||||
$BalancedMsgPlayed = -1;
|
$BalancedMsgPlayed = -1;
|
||||||
$StatsMsgPlayed = -1;
|
$UnbalancedMsgPlayed = -1;
|
||||||
}
|
|
||||||
|
|
||||||
//Check to see if teams are still unbalanced
|
|
||||||
//Fire AutoBalance in 30 sec if enabled
|
|
||||||
function StatsUnbalanceSound( %game )
|
|
||||||
{
|
|
||||||
if( $CurrentMissionType !$= "LakRabbit" && $Host::EnableTeamBalanceNotify && $StatsMsgPlayed $= 1 && !$Host::TournamentMode )
|
|
||||||
{
|
|
||||||
if( $Team1Difference == 1 || $Team2Difference == 1 || $PlayerCount[1] == $PlayerCount[2] )
|
|
||||||
{
|
|
||||||
$StatsMsgPlayed = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if( $Team1Difference >= 2 || $Team2Difference >= 2 )
|
|
||||||
{
|
|
||||||
if( $Host::EnableAutobalance )
|
|
||||||
{
|
|
||||||
messageAll('MsgTeamBalanceNotify', '\c1Teams are unbalanced: \c0Autobalance Initializing.~wgui/vote_nopass.wav');
|
|
||||||
//Schedule a GetCounts update before the autobalance fire
|
|
||||||
schedule(22000, 0, "ResetClientChangedTeams");
|
|
||||||
schedule(30000, 0, "Autobalance", %game );
|
|
||||||
}
|
|
||||||
//Disabled Autobalance messege
|
|
||||||
else
|
|
||||||
{
|
|
||||||
messageAll('MsgTeamBalanceNotify', '\c1Teams are unbalanced: \c0%1 vs %2 with %3 observers.~wgui/vote_nopass.wav', $PlayerCount[1], $PlayerCount[2], $PlayerCount[0] );
|
|
||||||
schedule(15000, 0, "ResetClientChangedTeams");
|
|
||||||
schedule(13000, 0, "ResetTeamBalanceNotifyGameOver");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue