mirror of
https://github.com/ChocoTaco1/TacoServer.git
synced 2026-03-25 14:29:07 +00:00
Server Core Rework
More use of Switch cases and Scheduling tracking
This commit is contained in:
parent
c95483c322
commit
4a7325a74d
5 changed files with 187 additions and 178 deletions
|
|
@ -11,48 +11,60 @@
|
|||
//
|
||||
|
||||
|
||||
// This function is called in GetTeamCounts.cs
|
||||
// Called in GetTeamCounts.cs
|
||||
function TeamBalanceNotify( %game, %team1difference, %team2difference )
|
||||
{
|
||||
if( $CurrentMissionType !$= "LakRabbit" && $TotalTeamPlayerCount !$= 0 && !$Host::TournamentMode )
|
||||
if( ($CurrentMissionType $= "CTF" || $CurrentMissionType $= "sctf") && $TotalTeamPlayerCount !$= 0 && !$Host::TournamentMode )
|
||||
{
|
||||
//echo ("%Team1Difference " @ %Team1Difference);
|
||||
//echo ("%Team2Difference " @ %Team2Difference);
|
||||
|
||||
//Uneven
|
||||
if( $PlayerCount[1] !$= $PlayerCount[2] )
|
||||
{
|
||||
//Reset Balanced.
|
||||
$BalancedMsgPlayed = 0;
|
||||
|
||||
if( %team1difference >= 2 || %team2difference >= 2 )
|
||||
{
|
||||
if( %team1difference >= 2 || %team2difference >= 2 ) //Teams are unbalanced
|
||||
{
|
||||
if( $UnbalancedMsgPlayed !$= 1)
|
||||
{
|
||||
//Run once.
|
||||
$UnbalancedMsgPlayed = 1;
|
||||
//Start Sound Schedule
|
||||
schedule(15000, 0, "UnbalancedSound", %game );
|
||||
}
|
||||
if( $TBNStatus !$= "NOTIFY" ) //Stops any new schedules
|
||||
$TBNStatus = "UNBALANCED";
|
||||
}
|
||||
else
|
||||
//Means teams arnt even, but arnt so uneven to do anything about. Meaning a team is a man down. 6vs7, 4vs3 etc
|
||||
$TBNStatus = "UNEVEN";
|
||||
}
|
||||
//If teams are balanced
|
||||
else if( $PlayerCount[1] == $PlayerCount[2] && $TotalTeamPlayerCount !$= 0 && $BalancedMsgPlayed !$= 1 )
|
||||
//Teams are even
|
||||
else if( $PlayerCount[1] == $PlayerCount[2] && $TBNStatus !$= "PLAYEDEVEN" )
|
||||
$TBNStatus = "EVEN";
|
||||
|
||||
switch$($TBNStatus)
|
||||
{
|
||||
//messageAll('MsgTeamBalanceNotify', '\c1Teams are balanced.');
|
||||
//Once per cycle.
|
||||
$BalancedMsgPlayed = 1;
|
||||
//Reset Unbalanced.
|
||||
$UnbalancedMsgPlayed = 0;
|
||||
case IDLE:
|
||||
//Do Nothing
|
||||
case UNEVEN:
|
||||
//Do Nothing
|
||||
case UNBALANCED:
|
||||
//Start Schedule to Notify
|
||||
$NotifySchedule = schedule(15000, 0, "NotifyUnbalanced", %game );
|
||||
$TBNStatus = "NOTIFY";
|
||||
case EVEN:
|
||||
//messageAll('MsgTeamBalanceNotify', '\c1Teams are balanced.');
|
||||
$TBNStatus = "PLAYEDEVEN";
|
||||
case PLAYEDEVEN:
|
||||
//Do Nothing
|
||||
case NOTIFY:
|
||||
//Do Nothing
|
||||
}
|
||||
}
|
||||
//echo($TBNStatus);
|
||||
}
|
||||
|
||||
//Check to see if teams are still unbalanced
|
||||
//Fire AutoBalance in 30 sec if enabled
|
||||
function UnbalancedSound( %game )
|
||||
function NotifyUnbalanced( %game )
|
||||
{
|
||||
if( $UnbalancedMsgPlayed $= 1 )
|
||||
if(isEventPending($NotifySchedule))
|
||||
cancel($NotifySchedule);
|
||||
|
||||
if( $TBNStatus $= "NOTIFY" ) //If Status has changed to EVEN or anything else.
|
||||
{
|
||||
//Team Count code by Keen
|
||||
$PlayerCount[0] = 0;
|
||||
|
|
@ -73,8 +85,7 @@ function UnbalancedSound( %game )
|
|||
|
||||
if( %team1difference == 1 || %team2difference == 1 || $PlayerCount[1] == $PlayerCount[2] )
|
||||
{
|
||||
//Reset
|
||||
$UnbalancedMsgPlayed = 0;
|
||||
ResetTBNStatus();
|
||||
return;
|
||||
}
|
||||
//Continue
|
||||
|
|
@ -84,42 +95,39 @@ function UnbalancedSound( %game )
|
|||
if( $Host::EnableAutobalance )
|
||||
{
|
||||
messageAll('MsgTeamBalanceNotify', '\c1Teams are unbalanced: \c0Autobalance Initializing.~wgui/vote_nopass.wav');
|
||||
schedule(30000, 0, "Autobalance", %game );
|
||||
$AutoBalanceSchedule = schedule(30000, 0, "Autobalance", %game );
|
||||
}
|
||||
//If Autobalance is disabled, message only.
|
||||
else if( $Host::EnableTeamBalanceNotify )
|
||||
{
|
||||
messageAll('MsgTeamBalanceNotify', '\c1Teams are unbalanced: \c0%1 vs %2 with %3 observers.~wgui/vote_nopass.wav', $PlayerCount[1], $PlayerCount[2], $PlayerCount[0] );
|
||||
schedule(13000, 0, "ResetTeamBalanceNotifyGameOver");
|
||||
schedule(15000, 0, "ResetClientChangedTeams");
|
||||
schedule(13000, 0, "ResetTBNStatus");
|
||||
schedule(15000, 0, "ResetGetCountsStatus");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Reset Notify
|
||||
function ResetTeamBalanceNotifyGameOver()
|
||||
// Reset TBNStatus
|
||||
function ResetTBNStatus()
|
||||
{
|
||||
//Reset All TeamBalance Variables
|
||||
$BalancedMsgPlayed = -1;
|
||||
$UnbalancedMsgPlayed = -1;
|
||||
$TBNStatus = "IDLE";
|
||||
}
|
||||
|
||||
// Reset every map change
|
||||
package ResetTeamBalanceNotify
|
||||
package ResetTBNGameOver
|
||||
{
|
||||
|
||||
function DefaultGame::gameOver(%game)
|
||||
{
|
||||
Parent::gameOver(%game);
|
||||
|
||||
//Reset All TeamBalance Variables
|
||||
ResetTeamBalanceNotifyGameOver();
|
||||
//Reset TBNStatus
|
||||
ResetTBNStatus();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Prevent package from being activated if it is already
|
||||
if (!isActivePackage(ResetTeamBalanceNotify))
|
||||
activatePackage(ResetTeamBalanceNotify);
|
||||
if (!isActivePackage(ResetTBNGameOver))
|
||||
activatePackage(ResetTBNGameOver);
|
||||
Loading…
Add table
Add a link
Reference in a new issue