mirror of
https://github.com/ChocoTaco1/TacoServer.git
synced 2026-07-15 16:14:35 +00:00
Autobalance refinement
One counter
This commit is contained in:
parent
f7eea7f361
commit
f7bf26f5c3
2 changed files with 14 additions and 37 deletions
|
|
@ -3,51 +3,26 @@ function Autobalance( %game, %client, %respawn )
|
||||||
{
|
{
|
||||||
if( $CurrentMissionType !$= "LakRabbit" && $Host::EnableTeamBalanceNotify && $StatsMsgPlayed $= 1 && !$Host::TournamentMode )
|
if( $CurrentMissionType !$= "LakRabbit" && $Host::EnableTeamBalanceNotify && $StatsMsgPlayed $= 1 && !$Host::TournamentMode )
|
||||||
{
|
{
|
||||||
//Generate random to get random client
|
|
||||||
%team1random = getRandom(1,$PlayerCount[1]);
|
|
||||||
%team2random = getRandom(1,$PlayerCount[2]);
|
|
||||||
|
|
||||||
%AutobalanceCount[0] = 0;
|
|
||||||
%AutobalanceCount[1] = 0;
|
|
||||||
%AutobalanceCount[2] = 0;
|
|
||||||
|
|
||||||
for(%i = 0; %i < ClientGroup.getCount(); %i++)
|
|
||||||
{
|
|
||||||
%client = ClientGroup.getObject(%i);
|
|
||||||
|
|
||||||
//For autobalance
|
|
||||||
//Pick a random client on a team
|
|
||||||
if( %client.team == 1 && %team1random == %AutobalanceCount[1] )
|
|
||||||
%team1canidate = %client;
|
|
||||||
if( %client.team == 2 && %team2random == %AutobalanceCount[2] )
|
|
||||||
%team2canidate = %client;
|
|
||||||
|
|
||||||
//if(!%client.isAIControlled())
|
|
||||||
%AutobalanceCount[%client.team]++;
|
|
||||||
|
|
||||||
//Safetynet
|
|
||||||
if( %team1canidate $= "" )
|
|
||||||
%team1canidate = %client;
|
|
||||||
if( %team2canidate $= "" )
|
|
||||||
%team2canidate = %client;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( $Team1Difference == 1 || $Team2Difference == 1 || $PlayerCount[1] == $PlayerCount[2] )
|
if( $Team1Difference == 1 || $Team2Difference == 1 || $PlayerCount[1] == $PlayerCount[2] )
|
||||||
{
|
{
|
||||||
$StatsMsgPlayed = 0;
|
$StatsMsgPlayed = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Safetynet
|
//Safetynet
|
||||||
else if( team1canidate $= "" || team2canidate $= "" )
|
else if( $team1canidate $= "" || $team2canidate $= "" )
|
||||||
{
|
{
|
||||||
schedule(2500, 0, "Autobalance", %game, %client, %respawn);
|
messageAll('MsgTeamBalanceNotify', '\c0Autobalance error.');
|
||||||
|
//Trigger GetCounts
|
||||||
|
ResetClientChangedTeams();
|
||||||
|
//Reset Stats.
|
||||||
|
$StatsMsgPlayed = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Team 1
|
//Team 1
|
||||||
else if( $Team1Difference >= 2 )
|
else if( $Team1Difference >= 2 )
|
||||||
{
|
{
|
||||||
%client = %team1canidate;
|
%client = $team1canidate;
|
||||||
%team = %team1canidate.team;
|
%team = $team1canidate.team;
|
||||||
%otherTeam = ( %team == 1 ) ? 2 : 1;
|
%otherTeam = ( %team == 1 ) ? 2 : 1;
|
||||||
|
|
||||||
Game.clientChangeTeam( %client, %otherTeam, 0 );
|
Game.clientChangeTeam( %client, %otherTeam, 0 );
|
||||||
|
|
@ -62,8 +37,8 @@ function Autobalance( %game, %client, %respawn )
|
||||||
//Team 2
|
//Team 2
|
||||||
else if( $Team2Difference >= 2 )
|
else if( $Team2Difference >= 2 )
|
||||||
{
|
{
|
||||||
%client = %team2canidate;
|
%client = $team2canidate;
|
||||||
%team = %team2canidate.team;
|
%team = $team2canidate.team;
|
||||||
%otherTeam = ( %team == 1 ) ? 2 : 1;
|
%otherTeam = ( %team == 1 ) ? 2 : 1;
|
||||||
|
|
||||||
Game.clientChangeTeam( %client, %otherTeam, 0 );
|
Game.clientChangeTeam( %client, %otherTeam, 0 );
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,8 @@ function StatsUnbalanceSound( %game, %client, %respawn )
|
||||||
else if( $Team1Difference >= 2 || $Team2Difference >= 2 )
|
else if( $Team1Difference >= 2 || $Team2Difference >= 2 )
|
||||||
{
|
{
|
||||||
messageAll('MsgTeamBalanceNotify', '\c1Teams are unbalanced: \c0Autobalance Initializing.~wgui/vote_nopass.wav');
|
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, %client, %respawn);
|
schedule(30000, 0, "Autobalance", %game, %client, %respawn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue