mirror of
https://github.com/ChocoTaco1/TacoServer.git
synced 2026-02-28 10:23:36 +00:00
Autobalance: TeamRank Selection
This commit is contained in:
parent
15f7cca19e
commit
e7c8115073
1 changed files with 55 additions and 10 deletions
|
|
@ -7,6 +7,15 @@
|
|||
// $Host::EnableAutobalance = 1;
|
||||
//
|
||||
// exec("scripts/autoexec/Autobalance.cs");
|
||||
//
|
||||
// How far behind otherteam must be to use All Mode.
|
||||
// Meaning picking from a pool of all players on the $BigTeam instead of just the lowest scoring players.
|
||||
// 400 equals 400 points. 4 caps behind.
|
||||
$Autobalance::AMThreshold = 300;
|
||||
// Based on BigTeams Top3 scorers. If BigTeams Top3 scorers is greater than the otherTeams Top3 + Top3Threshold. Use AllMode.
|
||||
$Autobalance::Top3Threshold = 300;
|
||||
// If it takes too long for specific canidates to die. After a time choose anyone.
|
||||
$Autobalance::Fallback = 90000;
|
||||
|
||||
// Run from TeamBalanceNotify.cs via NotifyUnbalanced
|
||||
function Autobalance( %game )
|
||||
|
|
@ -14,7 +23,7 @@ function Autobalance( %game )
|
|||
if(isEventPending($AutoBalanceSchedule))
|
||||
cancel($AutoBalanceSchedule);
|
||||
|
||||
if( $TBNStatus !$= "NOTIFY" ) //If Status has changed to EVEN or anything else (GameOver reset).
|
||||
if($TBNStatus !$= "NOTIFY") //If Status has changed to EVEN or anything else (GameOver reset).
|
||||
return;
|
||||
|
||||
//Difference Variables
|
||||
|
|
@ -28,33 +37,67 @@ function Autobalance( %game )
|
|||
$BigTeam = 2;
|
||||
else
|
||||
return;
|
||||
|
||||
$Autobalace::UseAllMode = 0;
|
||||
%otherTeam = $BigTeam == 1 ? 2 : 1;
|
||||
%bigTeamTop3 = $TeamRank[$BigTeam, 0].score + $TeamRank[$BigTeam, 1].score + $TeamRank[$BigTeam, 2].score;
|
||||
%otherTeamTop3 = $TeamRank[%otherTeam, 0].score + $TeamRank[%otherTeam, 1].score + $TeamRank[%otherTeam, 2].score;
|
||||
//Anyone who dies is eligable to switch
|
||||
//If BigTeam score is greater than otherteam score + threshold or BigTeam Top3 is greater than otherTeam Top3 + Top3Threshold
|
||||
if($TeamScore[$BigTeam] > ($TeamScore[%otherTeam] + $Autobalance::AMThreshold) || $TeamRank[%otherTeam, count] $= 0 || (%bigTeamTop3 > %otherTeamTop3 + $Autobalance::Top3Threshold))
|
||||
$Autobalace::UseAllMode = 1;
|
||||
//echo("Allmode " @ $Autobalace::UseAllMode);
|
||||
|
||||
%otherteam = $BigTeam == 1 ? 2 : 1;
|
||||
if($TeamRank[$BigTeam, count] - $TeamRank[%otherteam, count] >= 3)
|
||||
//Select lower half of team rank as canidates for team change
|
||||
if(!$Autobalace::UseAllMode)
|
||||
{
|
||||
$Autobalance::Max = mFloor($TeamRank[$BigTeam, count]/2);
|
||||
for(%i = $Autobalance::Max; %i < $TeamRank[$BigTeam, count]; %i++)
|
||||
{
|
||||
//echo(%i); echo($TeamRank[$BigTeam, %i].nameBase);
|
||||
$Autobalance::Canidate[%i] = $TeamRank[$BigTeam, %i];
|
||||
}
|
||||
%a = " selected";
|
||||
}
|
||||
|
||||
if($TeamRank[$BigTeam, count] - $TeamRank[%otherTeam, count] >= 3)
|
||||
%s = "s";
|
||||
|
||||
//Warning message
|
||||
messageAll('MsgTeamBalanceNotify', '\c1Teams are unbalanced: \c0Autobalance will switch the next respawning player%2 on Team %1.', $TeamName[$BigTeam], %s);
|
||||
messageAll('MsgTeamBalanceNotify', '\c1Teams are unbalanced: \c0Autobalance will switch the next%3 respawning player%2 on Team %1.', $TeamName[$BigTeam], %s, %a);
|
||||
}
|
||||
|
||||
// Return true if client is a canidate
|
||||
function CheckCanidate(%client)
|
||||
{
|
||||
for(%i = $Autobalance::Max; %i < $TeamRank[$BigTeam, count]; %i++)
|
||||
{
|
||||
if(%client $= $Autobalance::Canidate[%i])
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
package Autobalance
|
||||
{
|
||||
|
||||
// called from player scripts
|
||||
function DefaultGame::onClientKilled(%game, %clVictim, %clKiller, %damageType, %implement, %damageLocation)
|
||||
{
|
||||
parent::onClientKilled(%game, %clVictim, %clKiller, %damageType, %implement, %damageLocation);
|
||||
|
||||
if($BigTeam !$= "" && %clVictim.team == $BigTeam)
|
||||
{
|
||||
%otherteam = $BigTeam == 1 ? 2 : 1;
|
||||
if($TeamRank[$BigTeam, count] - $TeamRank[%otherteam, count] >= 2)
|
||||
%otherTeam = $BigTeam == 1 ? 2 : 1;
|
||||
if($TeamRank[$BigTeam, count] - $TeamRank[%otherTeam, count] >= 2)
|
||||
{
|
||||
//If someone switches to observer or disconnects
|
||||
if(%damageType !$= 0)
|
||||
if($Autobalance::CanidateFallbackTime $= "")
|
||||
$Autobalance::CanidateFallbackTime = getSimTime();
|
||||
|
||||
//damageType 0: If someone switches to observer or disconnects
|
||||
if(%damageType !$= 0 && (CheckCanidate(%clVictim) || $Autobalace::UseAllMode || (getSimTime() - $Autobalance::CanidateFallbackTime > $Autobalance::Fallback)))
|
||||
{
|
||||
echo(%clVictim.nameBase @ " has been moved to Team " @ %otherTeam @ " for balancing.");
|
||||
messageClient(%clVictim, 'MsgTeamBalanceNotify', '\c0You were switched to Team %1 for balancing.~wfx/powered/vehicle_screen_on.wav', $TeamName[%otherteam]);
|
||||
messageClient(%clVictim, 'MsgTeamBalanceNotify', '\c0You were switched to Team %1 for balancing.~wfx/powered/vehicle_screen_on.wav', $TeamName[%otherTeam]);
|
||||
messageAllExcept(%clVictim, -1, 'MsgTeamBalanceNotify', '~wfx/powered/vehicle_screen_on.wav');
|
||||
|
||||
Game.clientChangeTeam( %clVictim, %otherTeam, 0 );
|
||||
|
|
@ -64,6 +107,7 @@ function DefaultGame::onClientKilled(%game, %clVictim, %clKiller, %damageType, %
|
|||
{
|
||||
$BigTeam = "";
|
||||
ResetTBNStatus();
|
||||
deleteVariables("$Autobalace::Canidate*");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -74,6 +118,7 @@ function DefaultGame::gameOver(%game)
|
|||
|
||||
//Reset Autobalance
|
||||
$BigTeam = "";
|
||||
deleteVariables("$Autobalace::Canidate*");
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue