2018-11-04 16:59:10 -05:00
//Enable or Disable
//$Host::EnableTeamBalanceNotify = 1;
//
2018-06-28 14:34:52 -04:00
//Give the client a notification on the current state of balancing.
2018-11-10 19:56:13 -05:00
//This function is in GetTeamCounts.cs
2018-11-12 23:53:16 -05:00
function TeamBalanceNotify ( % game , % client , % respawn )
2018-06-28 14:34:52 -04:00
{
2018-11-04 16:59:10 -05:00
if ( $ CurrentMissionType ! $ = "LakRabbit" & & $ TotalTeamPlayerCount ! $ = 0 & & $ Host : : EnableTeamBalanceNotify )
{
2018-11-10 19:56:13 -05:00
//variables
% Team1Difference = $ PlayerCount [ 1 ] - $ PlayerCount [ 2 ] ;
% Team2Difference = $ PlayerCount [ 2 ] - $ PlayerCount [ 1 ] ;
2019-01-01 13:34:41 -05:00
//Make Global
$ Team1Difference = % Team1Difference ;
$ Team2Difference = % Team2Difference ;
2018-06-28 14:34:52 -04:00
2018-11-10 19:56:13 -05:00
//echo ("%Team1Difference " @ %Team1Difference);
//echo ("%Team2Difference " @ %Team2Difference);
if ( $ PlayerCount [ 1 ] ! $ = $ PlayerCount [ 2 ] )
{
//Uneven. Reset Balanced.
2018-11-11 01:38:18 -05:00
$ BalancedMsgPlayed = 0 ;
2018-11-10 19:56:13 -05:00
if ( % Team1Difference > = 2 | | % Team2Difference > = 2 )
{
2019-01-03 15:48:33 -05:00
if ( $ StatsBalancedSoundPlayed ! $ = 1 )
{
2019-01-19 14:58:42 -05:00
if ( $ UnbalancedMsgPlayed ! $ = 1 & & % Team2Difference = = 2 | | % Team1Difference = = 2 )
{
messageAll ( ' MsgTeamBalanceNotify ' , ' \ c1Teams are unbalanced . ' ) ;
//Once per cycle.
$ UnbalancedMsgPlayed = 1 ;
//Reset Stats.
$ StatsMsgPlayed = 0 ;
}
//Stats Aspect. 3 or more difference gets a stats notify.
else if ( $ StatsMsgPlayed ! $ = 1 )
{
messageAll ( ' MsgTeamBalanceNotify ' , ' \ c1Teams are unbalanced : \ c0It is currently % 1 vs % 2 with % 3 observers . ' , $ PlayerCount [ 1 ] , $ PlayerCount [ 2 ] , $ PlayerCount [ 0 ] ) ;
//Run once.
$ StatsMsgPlayed = 1 ;
}
2019-01-01 15:58:03 -05:00
//Called in 30 secs with sound
schedule ( 30000 , 0 , "StatsUnbalanceSound" ) ;
2019-01-03 15:48:33 -05:00
//Once per cycle.
$ StatsBalancedSoundPlayed = 1 ;
2018-11-10 19:56:13 -05:00
}
2018-06-28 14:34:52 -04:00
}
2019-01-19 14:58:42 -05:00
else if ( $ PlayerCount [ 1 ] ! $ = $ PlayerCount [ 2 ] )
{
$ StatsBalancedSoundPlayed = 0 ;
}
2018-06-28 14:34:52 -04:00
}
2018-11-10 19:56:13 -05:00
//If teams are balanced and teams dont equal 0.
2018-11-11 01:38:18 -05:00
else if ( $ PlayerCount [ 1 ] = = $ PlayerCount [ 2 ] & & $ TotalTeamPlayerCount ! $ = 0 & & $ BalancedMsgPlayed ! $ = 1 )
2018-11-10 19:56:13 -05:00
{
2019-01-01 13:34:41 -05:00
//messageAll('MsgTeamBalanceNotify', '\c1Teams are balanced.');
2018-11-10 19:56:13 -05:00
//Once per cycle.
2018-11-11 01:38:18 -05:00
$ BalancedMsgPlayed = 1 ;
2018-11-10 19:56:13 -05:00
//Reset unbalanced.
2018-11-11 01:38:18 -05:00
$ UnbalancedMsgPlayed = 0 ;
2018-11-10 19:56:13 -05:00
//Reset Stats.
2018-11-11 01:38:18 -05:00
$ StatsMsgPlayed = 0 ;
2019-01-03 15:48:33 -05:00
//Reset Stats with sound.
$ StatsBalancedSoundPlayed = 0 ;
2018-06-28 14:34:52 -04:00
}
2018-11-04 16:59:10 -05:00
}
2018-06-28 14:34:52 -04:00
}
2018-09-16 11:07:47 -04:00
//Reset Notify at defaultgame::gameOver in evo defaultgame.ovl
2018-11-10 19:56:13 -05:00
function ResetTeamBalanceNotifyGameOver ( % game )
{
//Reset All TeamBalance Variables
$ BalancedMsgPlayed = - 1 ;
$ UnbalancedMsgPlayed = - 1 ;
$ StatsMsgPlayed = - 1 ;
2019-01-03 15:48:33 -05:00
$ StatsBalancedSoundPlayed = - 1 ;
2019-01-01 13:34:41 -05:00
}
//Stats with Sound
//Called every 30 seconds
2019-01-03 15:48:33 -05:00
//2 or more difference
2019-01-01 13:34:41 -05:00
function StatsUnbalanceSound ( )
{
2019-01-03 15:48:33 -05:00
if ( $ Team1Difference > = 2 | | $ Team2Difference > = 2 )
2019-01-01 15:58:03 -05:00
{
2019-01-12 14:41:22 -05:00
//Added so the notification wont sound between the 5 sec interval of get counts and the 30 sec unbalanced notification when someone switches at the last minute before a check.
2019-01-12 13:56:06 -05:00
if ( ! $ GetCountsClientTeamChange )
{
messageAll ( ' MsgTeamBalanceNotify ' , ' \ c1Teams are unbalanced : \ c0It is currently % 1 vs % 2 with % 3 observers . ~ wfx / misc / bounty_objrem2 . wav ' , $ PlayerCount [ 1 ] , $ PlayerCount [ 2 ] , $ PlayerCount [ 0 ] ) ;
//Called in 30 secs with sound
schedule ( 30000 , 0 , "StatsUnbalanceSound" ) ;
}
2019-01-14 13:15:52 -05:00
else
//In the event that a player switches up instead of down during an interval the function can be called again.
schedule ( 5000 , 0 , "StatsUnbalanceSound" ) ;
2019-01-01 15:58:03 -05:00
}
2019-01-01 13:34:41 -05:00
else
2019-01-03 15:48:33 -05:00
{
$ StatsBalancedSoundPlayed = 0 ;
2019-01-01 13:34:41 -05:00
return ;
2019-01-03 15:48:33 -05:00
}
2019-01-01 13:34:41 -05:00
}