TacoServer/Classic/scripts/autoexec/TeamBalanceNotify.cs

84 lines
2.6 KiB
C#
Raw Normal View History

2019-02-06 18:39:36 +00:00
// Enable or Disable
// $Host::EnableTeamBalanceNotify = 1;
// Enable or Disable Autobalance
// $Host::EnableAutobalance = 1;
//
2019-02-06 18:39:36 +00:00
// Give the client a notification on the current state of balancing.
//
// This function is in GetTeamCounts.cs
2019-02-05 03:54:58 +00:00
function TeamBalanceNotify( %game )
2018-06-28 18:34:52 +00:00
{
2019-02-03 23:00:24 +00:00
if( $CurrentMissionType !$= "LakRabbit" && $TotalTeamPlayerCount !$= 0 && $Host::EnableTeamBalanceNotify && !$Host::TournamentMode )
2019-02-03 08:55:40 +00:00
{
2018-11-11 00:56:13 +00:00
//echo ("%Team1Difference " @ %Team1Difference);
//echo ("%Team2Difference " @ %Team2Difference);
if( $PlayerCount[1] !$= $PlayerCount[2] )
{
//Uneven. Reset Balanced.
2018-11-11 06:38:18 +00:00
$BalancedMsgPlayed = 0;
2018-11-11 00:56:13 +00:00
2019-02-03 08:55:40 +00:00
if( $Team1Difference >= 2 || $Team2Difference >= 2 )
{
if( $StatsMsgPlayed !$= 1)
2019-01-26 15:44:53 +00:00
{
//Run once.
$StatsMsgPlayed = 1;
2019-02-03 08:55:40 +00:00
//Start Sound Schedule for 60 secs
2019-02-05 03:54:58 +00:00
schedule(15000, 0, "StatsUnbalanceSound", %game );
//For accurate msg when autobalance is disabled
if( !$Host::EnableAutobalance )
schedule(9000, 0, "ResetClientChangedTeams");
2019-01-26 15:44:53 +00:00
}
2019-01-31 07:07:19 +00:00
}
2018-06-28 18:34:52 +00:00
}
2018-11-11 00:56:13 +00:00
//If teams are balanced and teams dont equal 0.
2018-11-11 06:38:18 +00:00
else if( $PlayerCount[1] == $PlayerCount[2] && $TotalTeamPlayerCount !$= 0 && $BalancedMsgPlayed !$= 1 )
2018-11-11 00:56:13 +00:00
{
2019-01-01 18:34:41 +00:00
//messageAll('MsgTeamBalanceNotify', '\c1Teams are balanced.');
2018-11-11 00:56:13 +00:00
//Once per cycle.
2018-11-11 06:38:18 +00:00
$BalancedMsgPlayed = 1;
2018-11-11 00:56:13 +00:00
//Reset Stats.
2018-11-11 06:38:18 +00:00
$StatsMsgPlayed = 0;
2018-06-28 18:34:52 +00:00
}
}
2018-06-28 18:34:52 +00:00
}
//Reset Notify at defaultgame::gameOver in evo defaultgame.ovl
2019-02-03 08:55:40 +00:00
function ResetTeamBalanceNotifyGameOver()
2018-11-11 00:56:13 +00:00
{
//Reset All TeamBalance Variables
$BalancedMsgPlayed = -1;
$StatsMsgPlayed = -1;
2019-01-01 18:34:41 +00:00
}
2019-02-03 23:00:24 +00:00
//Check to see if teams are still unbalanced
//Fire AutoBalance in 30 sec if enabled
2019-02-05 03:54:58 +00:00
function StatsUnbalanceSound( %game )
2019-01-01 18:34:41 +00:00
{
2019-02-03 23:00:24 +00:00
if( $CurrentMissionType !$= "LakRabbit" && $Host::EnableTeamBalanceNotify && $StatsMsgPlayed $= 1 && !$Host::TournamentMode )
2019-01-26 15:44:53 +00:00
{
2019-02-03 08:55:40 +00:00
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");
}
2019-02-03 08:55:40 +00:00
}
2019-01-26 15:44:53 +00:00
}
2019-02-03 08:55:40 +00:00
}