mirror of
https://github.com/ChocoTaco1/TacoServer.git
synced 2026-07-16 00:24:35 +00:00
Update Autobalance.cs
Vehicle detection
This commit is contained in:
parent
5147cc3631
commit
95b7acb9b7
1 changed files with 53 additions and 16 deletions
|
|
@ -42,8 +42,22 @@ function Autobalance( %game, %AutobalanceSafetynetTrys )
|
||||||
//If a team is behind pick anyone, not just a low scoring player
|
//If a team is behind pick anyone, not just a low scoring player
|
||||||
if( $TeamScore[%bigTeam] > ($TeamScore[%littleTeam] + $AllModeThreshold))
|
if( $TeamScore[%bigTeam] > ($TeamScore[%littleTeam] + $AllModeThreshold))
|
||||||
{
|
{
|
||||||
|
//We need to find out how many people are on a team holding flags and in vehicles to make the proper exceptions in the loop
|
||||||
|
for(%i = 0; %i < ClientGroup.getCount(); %i++)
|
||||||
|
{
|
||||||
|
%client = ClientGroup.getObject(%i);
|
||||||
|
%team = %client.team;
|
||||||
|
|
||||||
|
if(%team $= %bigTeam)
|
||||||
|
{
|
||||||
|
//Holding flag? In a Vehicle?
|
||||||
|
if(%client.player.holdingFlag !$= "" || isObject(%client.vehicleMounted))
|
||||||
|
%exceptioncount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
%UseAllMode = 1;
|
%UseAllMode = 1;
|
||||||
%autobalanceRandom = getRandom(1,($PlayerCount[%bigTeam] - 1));
|
%autobalanceRandom = getRandom(1,($TeamRank[%bigTeam, count] - %exceptioncount));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Pick a client for autobalance
|
//Pick a client for autobalance
|
||||||
|
|
@ -52,26 +66,49 @@ function Autobalance( %game, %AutobalanceSafetynetTrys )
|
||||||
%client = ClientGroup.getObject(%i);
|
%client = ClientGroup.getObject(%i);
|
||||||
%team = %client.team;
|
%team = %client.team;
|
||||||
|
|
||||||
//Holding flag?
|
if(%team $= %bigTeam)
|
||||||
if(%client.player.holdingFlag !$= "")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if(%UseAllMode)
|
|
||||||
{
|
{
|
||||||
//Try to pick any player
|
//Holding flag? In a Vehicle?
|
||||||
if(%autobalanceRandom == %AllmodeLoop || %lastclient[%team] $= "")
|
if(%client.player.holdingFlag !$= "" || isObject(%client.vehicleMounted))
|
||||||
%teamcanidate[%team] = %client;
|
continue;
|
||||||
|
|
||||||
%AllmodeLoop++;
|
if(%UseAllMode)
|
||||||
|
{
|
||||||
|
//Try to pick any player
|
||||||
|
if(%autobalanceRandom == %AllmodeLoop || %lastclient[%team] $= "")
|
||||||
|
%teamcanidate[%team] = %client;
|
||||||
|
|
||||||
|
%AllmodeLoop++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Try to pick a low scoring player
|
||||||
|
if(%client.score < %lastclient[%team].score || %lastclient[%team] $= "")
|
||||||
|
%teamcanidate[%team] = %client;
|
||||||
|
}
|
||||||
|
%lastclient[%team] = %client;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
|
||||||
|
//A situation where the whole team is in vehicles or holding a flag
|
||||||
|
//Pick anyone
|
||||||
|
if(%teamcanidate[%bigTeam] $= "")
|
||||||
|
{
|
||||||
|
//Pick a client for autobalance
|
||||||
|
for(%i = 0; %i < ClientGroup.getCount(); %i++)
|
||||||
{
|
{
|
||||||
//Normal circumstances
|
%client = ClientGroup.getObject(%i);
|
||||||
//Try to pick a low scoring player
|
%team = %client.team;
|
||||||
if(%client.score < %lastclient[%team].score || %lastclient[%team] $= "")
|
|
||||||
%teamcanidate[%team] = %client;
|
if(%team $= %bigTeam)
|
||||||
|
{
|
||||||
|
//Try to pick a low scoring player
|
||||||
|
if(%client.score < %lastclient[%team].score || %lastclient[%team] $= "")
|
||||||
|
%teamcanidate[%team] = %client;
|
||||||
|
|
||||||
|
%lastclient[%team] = %client;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
%lastclient[%team] = %client;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Debug
|
//Debug
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue