mirror of
https://github.com/ChocoTaco1/TacoServer.git
synced 2026-07-14 07:34:36 +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
|
|
@ -13,51 +13,47 @@
|
||||||
function CheckAntiCloak( %game )
|
function CheckAntiCloak( %game )
|
||||||
{
|
{
|
||||||
//CTF only
|
//CTF only
|
||||||
if( $Host::AntiCloakEnable && $CurrentMissionType $= "CTF" )
|
if( $Host::AntiCloakEnable && $CurrentMissionType $= "CTF" && !$Host::TournamentMode )
|
||||||
{
|
{
|
||||||
//echo("TotalTeamPlayerCount " @ $TotalTeamPlayerCount);
|
//echo("TotalTeamPlayerCount " @ $TotalTeamPlayerCount);
|
||||||
//echo("AntiCloakPlayerCount " @ $AntiCloakPlayerCount);
|
//echo("AntiCloakPlayerCount " @ $AntiCloakPlayerCount);
|
||||||
|
|
||||||
//If server is in Tourny mode and the team population is lower than the AntiCloakPlayerCount cloak is not selectable.
|
if( $TotalTeamPlayerCount < $Host::AntiCloakPlayerCount )
|
||||||
if( !$Host::TournamentMode && $TotalTeamPlayerCount < $Host::AntiCloakPlayerCount )
|
|
||||||
{
|
{
|
||||||
if( $AntiCloakRunOnce !$= 0 )
|
if( $AntiCloakStatus !$= "ACTIVEON" )
|
||||||
{
|
$AntiCloakStatus = "ON";
|
||||||
$InvBanList[CTF, "CloakingPack"] = 1;
|
|
||||||
|
|
||||||
if(!isActivePackage(DisableCloakPack))
|
|
||||||
activatePackage(DisableCloakPack);
|
|
||||||
|
|
||||||
$AntiCloakRunOnce = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//Off
|
//Off
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( $AntiCloakRunOnce !$= 1 )
|
if( $AntiCloakStatus !$= "ACTIVEOFF" )
|
||||||
{
|
$AntiCloakStatus = "OFF";
|
||||||
$InvBanList[CTF, "CloakingPack"] = 0;
|
|
||||||
|
|
||||||
if(isActivePackage(DisableCloakPack))
|
|
||||||
deactivatePackage(DisableCloakPack);
|
|
||||||
|
|
||||||
$AntiCloakRunOnce = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//All other cases outside of CTF.
|
//All other cases outside of CTF
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( $AntiCloakRunOnce !$= 1 )
|
if( $AntiCloakStatus !$= "ACTIVEOFF" )
|
||||||
{
|
$AntiCloakStatus = "OFF";
|
||||||
|
}
|
||||||
|
|
||||||
|
switch$($AntiCloakStatus)
|
||||||
|
{
|
||||||
|
case ON:
|
||||||
|
$InvBanList[CTF, "CloakingPack"] = 1;
|
||||||
|
if(!isActivePackage(DisableCloakPack))
|
||||||
|
activatePackage(DisableCloakPack);
|
||||||
|
$AntiCloakStatus = "ACTIVEON";
|
||||||
|
case OFF:
|
||||||
$InvBanList[CTF, "CloakingPack"] = 0;
|
$InvBanList[CTF, "CloakingPack"] = 0;
|
||||||
|
|
||||||
if(isActivePackage(DisableCloakPack))
|
if(isActivePackage(DisableCloakPack))
|
||||||
deactivatePackage(DisableCloakPack);
|
deactivatePackage(DisableCloakPack);
|
||||||
|
$AntiCloakStatus = "ACTIVEOFF";
|
||||||
$AntiCloakRunOnce = 1;
|
case ACTIVEON:
|
||||||
}
|
//Do Nothing
|
||||||
}
|
case ACTIVEOFF:
|
||||||
|
//Do Nothing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// So if the player is able to get a cloakpack, he cant use it
|
// So if the player is able to get a cloakpack, he cant use it
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,12 @@ $AllModeThreshold = 400;
|
||||||
// Run from TeamBalanceNotify.cs via UnbalancedSound( %game )
|
// Run from TeamBalanceNotify.cs via UnbalancedSound( %game )
|
||||||
function Autobalance( %game, %AutobalanceSafetynetTrys )
|
function Autobalance( %game, %AutobalanceSafetynetTrys )
|
||||||
{
|
{
|
||||||
|
if(isEventPending($AutoBalanceSchedule))
|
||||||
|
cancel($AutoBalanceSchedule);
|
||||||
|
|
||||||
|
if( $TBNStatus !$= "NOTIFY" ) //If Status has changed to EVEN or anything else (GameOver reset).
|
||||||
|
return;
|
||||||
|
|
||||||
//Debug: Uncomment to enable
|
//Debug: Uncomment to enable
|
||||||
//%AutobalanceDebug = true;
|
//%AutobalanceDebug = true;
|
||||||
|
|
||||||
|
|
@ -43,7 +49,8 @@ function Autobalance( %game, %AutobalanceSafetynetTrys )
|
||||||
//If even, stop.
|
//If even, stop.
|
||||||
if( %team1difference == 1 || %team2difference == 1 || $PlayerCount[1] == $PlayerCount[2] )
|
if( %team1difference == 1 || %team2difference == 1 || $PlayerCount[1] == $PlayerCount[2] )
|
||||||
{
|
{
|
||||||
$StatsMsgPlayed = 0;
|
//Reset TBN
|
||||||
|
ResetTBNStatus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Determine bigTeam
|
//Determine bigTeam
|
||||||
|
|
@ -95,21 +102,14 @@ function Autobalance( %game, %AutobalanceSafetynetTrys )
|
||||||
%team = %teamcanidate[%bigTeam].team;
|
%team = %teamcanidate[%bigTeam].team;
|
||||||
%otherTeam = ( %team == 1 ) ? 2 : 1;
|
%otherTeam = ( %team == 1 ) ? 2 : 1;
|
||||||
|
|
||||||
if( %teamcanidate[%bigTeam].team $= %bigTeam )
|
// Fire Autobalance
|
||||||
{
|
Game.clientChangeTeam( %client, %otherTeam, 0 );
|
||||||
// Fire Autobalance
|
messageAll('MsgTeamBalanceNotify', '~wfx/powered/vehicle_screen_on.wav');
|
||||||
Game.clientChangeTeam( %client, %otherTeam, 0 );
|
|
||||||
messageAll('MsgTeamBalanceNotify', '~wfx/powered/vehicle_screen_on.wav');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
messageAll('MsgTeamBalanceNotify', '\c0Autobalance error: Team %1 mismatch.', %bigTeam );
|
|
||||||
|
|
||||||
|
|
||||||
//Trigger GetCounts
|
//Trigger GetCounts
|
||||||
ResetClientChangedTeams();
|
ResetGetCountsStatus();
|
||||||
//Reset Unbalanced
|
//Reset TBN
|
||||||
$UnbalancedMsgPlayed = 0;
|
ResetTBNStatus();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function AutobalanceDebug(%teamcanidate1, %teamcanidate2, %team1difference, %team2difference, %bigTeam, %AutobalanceSafetynetTrys, %UseAllMode)
|
function AutobalanceDebug(%teamcanidate1, %teamcanidate2, %team1difference, %team2difference, %bigTeam, %AutobalanceSafetynetTrys, %UseAllMode)
|
||||||
|
|
@ -129,7 +129,7 @@ function AutobalanceDebug(%teamcanidate1, %teamcanidate2, %team1difference, %tea
|
||||||
messageAll('MsgTeamBalanceNotify', '\c0Autobalance error: %1', %error );
|
messageAll('MsgTeamBalanceNotify', '\c0Autobalance error: %1', %error );
|
||||||
|
|
||||||
//Trigger GetCounts
|
//Trigger GetCounts
|
||||||
ResetClientChangedTeams();
|
ResetGetCountsStatus();
|
||||||
//Rerun in 10 secs
|
//Rerun in 10 secs
|
||||||
schedule(10000, 0, "Autobalance", %game, %AutobalanceSafetynetTrys );
|
schedule(10000, 0, "Autobalance", %game, %AutobalanceSafetynetTrys );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
// Set reset string
|
// Set reset string
|
||||||
$GetCountsClientTeamChange = true;
|
$GetCountsStatus = "UPDATE";
|
||||||
|
|
||||||
package StartTeamCounts
|
package StartTeamCounts
|
||||||
{
|
{
|
||||||
|
|
@ -35,55 +35,63 @@ if (!isActivePackage(StartTeamCounts))
|
||||||
|
|
||||||
function GetTeamCounts( %game, %client, %respawn )
|
function GetTeamCounts( %game, %client, %respawn )
|
||||||
{
|
{
|
||||||
//Get teamcounts
|
switch$($GetCountsStatus)
|
||||||
if( $GetCountsClientTeamChange && $countdownStarted && $MatchStarted )
|
{
|
||||||
{
|
case UPDATE:
|
||||||
//Team Count code by Keen
|
//Get teamcounts
|
||||||
$PlayerCount[0] = 0;
|
if($countdownStarted && $MatchStarted )
|
||||||
$PlayerCount[1] = 0;
|
{
|
||||||
$PlayerCount[2] = 0;
|
//Team Count code by Keen
|
||||||
|
$PlayerCount[0] = 0;
|
||||||
|
$PlayerCount[1] = 0;
|
||||||
|
$PlayerCount[2] = 0;
|
||||||
|
|
||||||
for(%i = 0; %i < ClientGroup.getCount(); %i++)
|
for(%i = 0; %i < ClientGroup.getCount(); %i++)
|
||||||
{
|
{
|
||||||
%client = ClientGroup.getObject(%i);
|
%client = ClientGroup.getObject(%i);
|
||||||
|
|
||||||
|
//if(!%client.isAIControlled())
|
||||||
|
$PlayerCount[%client.team]++;
|
||||||
|
}
|
||||||
|
|
||||||
//if(!%client.isAIControlled())
|
//echo ("$PlayerCount[0] " @ $PlayerCount[0]);
|
||||||
$PlayerCount[%client.team]++;
|
//echo ("$PlayerCount[1] " @ $PlayerCount[1]);
|
||||||
}
|
//echo ("$PlayerCount[2] " @ $PlayerCount[2]);
|
||||||
|
|
||||||
//echo ("$PlayerCount[0] " @ $PlayerCount[0]);
|
|
||||||
//echo ("$PlayerCount[1] " @ $PlayerCount[1]);
|
|
||||||
//echo ("$PlayerCount[2] " @ $PlayerCount[2]);
|
|
||||||
|
|
||||||
//Amount of players on teams
|
//Amount of players on teams
|
||||||
$TotalTeamPlayerCount = $PlayerCount[1] + $PlayerCount[2];
|
$TotalTeamPlayerCount = $PlayerCount[1] + $PlayerCount[2];
|
||||||
//Amount of all players including observers
|
//Amount of all players including observers
|
||||||
$AllPlayerCount = $PlayerCount[1] + $PlayerCount[2] + $PlayerCount[0];
|
$AllPlayerCount = $PlayerCount[1] + $PlayerCount[2] + $PlayerCount[0];
|
||||||
//Difference Variables
|
//Difference Variables
|
||||||
%team1difference = $PlayerCount[1] - $PlayerCount[2];
|
%team1difference = $PlayerCount[1] - $PlayerCount[2];
|
||||||
%team2difference = $PlayerCount[2] - $PlayerCount[1];
|
%team2difference = $PlayerCount[2] - $PlayerCount[1];
|
||||||
|
|
||||||
//Start Base Rape Notify
|
//Start Base Rape Notify
|
||||||
schedule(500, 0, "NBRStatusNotify", %game);
|
schedule(500, 0, "NBRStatusNotify", %game);
|
||||||
//Start Team Balance Notify
|
//Start Team Balance Notify
|
||||||
schedule(1000, 0, "TeamBalanceNotify", %game, %team1difference, %team2difference);
|
schedule(1000, 0, "TeamBalanceNotify", %game, %team1difference, %team2difference);
|
||||||
//Start AntiCloak
|
//Start AntiCloak
|
||||||
schedule(1500, 0, "CheckAntiCloak", %game);
|
schedule(1500, 0, "CheckAntiCloak", %game);
|
||||||
|
|
||||||
//Set so counter wont run when it doesnt need to.
|
//Set so counter wont run when it doesnt need to.
|
||||||
$GetCountsClientTeamChange = false;
|
$GetCountsStatus = "IDLE";
|
||||||
|
}
|
||||||
|
case IDLE:
|
||||||
|
//Do Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isEventPending($GetCountsSchedule))
|
||||||
|
cancel($GetCountsSchedule);
|
||||||
|
|
||||||
//Call itself again. Every 5 seconds.
|
//Call itself again. Every 5 seconds.
|
||||||
schedule(5000, 0, "GetTeamCounts");
|
$GetCountsSchedule = schedule(5000, 0, "GetTeamCounts");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Triggers a Full run
|
// Triggers a Full run
|
||||||
function ResetClientChangedTeams()
|
function ResetGetCountsStatus()
|
||||||
{
|
{
|
||||||
$GetCountsClientTeamChange = true;
|
$GetCountsStatus = "UPDATE";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Proper Overrides
|
// Proper Overrides
|
||||||
|
|
@ -96,7 +104,7 @@ function DefaultGame::clientJoinTeam( %game, %client, %team, %respawn )
|
||||||
Parent::clientJoinTeam( %game, %client, %team, %respawn );
|
Parent::clientJoinTeam( %game, %client, %team, %respawn );
|
||||||
|
|
||||||
//Trigger GetCounts
|
//Trigger GetCounts
|
||||||
ResetClientChangedTeams();
|
ResetGetCountsStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
function DefaultGame::clientChangeTeam(%game, %client, %team, %fromObs, %respawned)
|
function DefaultGame::clientChangeTeam(%game, %client, %team, %fromObs, %respawned)
|
||||||
|
|
@ -104,7 +112,7 @@ function DefaultGame::clientChangeTeam(%game, %client, %team, %fromObs, %respawn
|
||||||
Parent::clientChangeTeam(%game, %client, %team, %fromObs, %respawned);
|
Parent::clientChangeTeam(%game, %client, %team, %fromObs, %respawned);
|
||||||
|
|
||||||
//Trigger GetCounts
|
//Trigger GetCounts
|
||||||
ResetClientChangedTeams();
|
ResetGetCountsStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
function DefaultGame::assignClientTeam(%game, %client, %respawn )
|
function DefaultGame::assignClientTeam(%game, %client, %respawn )
|
||||||
|
|
@ -112,7 +120,7 @@ function DefaultGame::assignClientTeam(%game, %client, %respawn )
|
||||||
Parent::assignClientTeam(%game, %client, %respawn );
|
Parent::assignClientTeam(%game, %client, %respawn );
|
||||||
|
|
||||||
//Trigger GetCounts
|
//Trigger GetCounts
|
||||||
ResetClientChangedTeams();
|
ResetGetCountsStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
function DefaultGame::onClientEnterObserverMode( %game, %client )
|
function DefaultGame::onClientEnterObserverMode( %game, %client )
|
||||||
|
|
@ -120,7 +128,7 @@ function DefaultGame::onClientEnterObserverMode( %game, %client )
|
||||||
Parent::onClientEnterObserverMode( %game, %client );
|
Parent::onClientEnterObserverMode( %game, %client );
|
||||||
|
|
||||||
//Trigger GetCounts
|
//Trigger GetCounts
|
||||||
ResetClientChangedTeams();
|
ResetGetCountsStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
function DefaultGame::AIChangeTeam(%game, %client, %newTeam)
|
function DefaultGame::AIChangeTeam(%game, %client, %newTeam)
|
||||||
|
|
@ -128,15 +136,7 @@ function DefaultGame::AIChangeTeam(%game, %client, %newTeam)
|
||||||
Parent::AIChangeTeam(%game, %client, %newTeam);
|
Parent::AIChangeTeam(%game, %client, %newTeam);
|
||||||
|
|
||||||
//Trigger GetCounts
|
//Trigger GetCounts
|
||||||
ResetClientChangedTeams();
|
ResetGetCountsStatus();
|
||||||
}
|
|
||||||
|
|
||||||
function DefaultGame::forceObserver(%game, %client, %reason)
|
|
||||||
{
|
|
||||||
Parent::forceObserver(%game, %client, %reason);
|
|
||||||
|
|
||||||
//Trigger GetCounts
|
|
||||||
ResetClientChangedTeams();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function GameConnection::onConnect(%client, %name, %raceGender, %skin, %voice, %voicePitch)
|
function GameConnection::onConnect(%client, %name, %raceGender, %skin, %voice, %voicePitch)
|
||||||
|
|
@ -144,7 +144,7 @@ function GameConnection::onConnect(%client, %name, %raceGender, %skin, %voice, %
|
||||||
Parent::onConnect(%client, %name, %raceGender, %skin, %voice, %voicePitch);
|
Parent::onConnect(%client, %name, %raceGender, %skin, %voice, %voicePitch);
|
||||||
|
|
||||||
//Reset GetCounts
|
//Reset GetCounts
|
||||||
ResetClientChangedTeams();
|
ResetGetCountsStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
function DefaultGame::gameOver(%game)
|
function DefaultGame::gameOver(%game)
|
||||||
|
|
@ -152,7 +152,7 @@ function DefaultGame::gameOver(%game)
|
||||||
Parent::gameOver(%game);
|
Parent::gameOver(%game);
|
||||||
|
|
||||||
//Reset GetCounts
|
//Reset GetCounts
|
||||||
ResetClientChangedTeams();
|
ResetGetCountsStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
function GameConnection::onDrop(%client, %reason)
|
function GameConnection::onDrop(%client, %reason)
|
||||||
|
|
@ -160,7 +160,7 @@ function GameConnection::onDrop(%client, %reason)
|
||||||
Parent::onDrop(%client, %reason);
|
Parent::onDrop(%client, %reason);
|
||||||
|
|
||||||
//Reset GetCounts
|
//Reset GetCounts
|
||||||
ResetClientChangedTeams();
|
ResetGetCountsStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
@ -10,52 +10,38 @@
|
||||||
function NBRStatusNotify( %game )
|
function NBRStatusNotify( %game )
|
||||||
{
|
{
|
||||||
if( $CurrentMissionType $= "CTF" && $Host::EnableNoBaseRapeNotify && !$Host::TournamentMode && $Host::EvoNoBaseRapeEnabled )
|
if( $CurrentMissionType $= "CTF" && $Host::EnableNoBaseRapeNotify && !$Host::TournamentMode && $Host::EvoNoBaseRapeEnabled )
|
||||||
{
|
{
|
||||||
//echo ("%client " @ %client);
|
|
||||||
//echo ("$TeamBalanceClient " @ $TeamBalanceClient);
|
|
||||||
|
|
||||||
//On
|
//On
|
||||||
if( $Host::EvoNoBaseRapeClassicPlayerCount > $TotalTeamPlayerCount )
|
if( $Host::EvoNoBaseRapeClassicPlayerCount > $TotalTeamPlayerCount )
|
||||||
{
|
{
|
||||||
if( $NoBaseRapeNotifyCount !$= 0 )
|
if( $NBRStatus !$= "PLAYEDON" )
|
||||||
{
|
$NBRStatus = "ON";
|
||||||
messageAll('MsgNoBaseRapeNotify', '\c1No Base Rape: \c0Enabled.');
|
|
||||||
$NoBaseRapeNotifyCount = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//Off
|
//Off
|
||||||
else if( $NoBaseRapeNotifyCount !$= 1 )
|
else
|
||||||
{
|
{
|
||||||
messageAll('MsgNoBaseRapeNotify', '\c1No Base Rape: \c0Disabled.~wfx/misc/diagnostic_on.wav');
|
if( $NBRStatus !$= "PLAYEDOFF" )
|
||||||
$NoBaseRapeNotifyCount = 1;
|
$NBRStatus = "OFF";
|
||||||
|
}
|
||||||
|
|
||||||
|
switch$($NBRStatus)
|
||||||
|
{
|
||||||
|
case ON:
|
||||||
|
messageAll('MsgNoBaseRapeNotify', '\c1No Base Rape: \c0Enabled.');
|
||||||
|
$NBRStatus = "PLAYEDON";
|
||||||
|
case OFF:
|
||||||
|
messageAll('MsgNoBaseRapeNotify', '\c1No Base Rape: \c0Disabled.~wfx/misc/diagnostic_on.wav');
|
||||||
|
$NBRStatus = "PLAYEDOFF";
|
||||||
|
case PLAYEDON:
|
||||||
|
//Do Nothing
|
||||||
|
case PLAYEDOFF:
|
||||||
|
//Do Nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is at StaticShapeData::damageObject(%data, %targetObject, %sourceObject, %position, %amount, %damageType)
|
// Reset gameover
|
||||||
// In the staticshape.ovl in evoClassic.vl2
|
package ResetNBRNotify
|
||||||
// Plays a sound when a player hits a protected asset
|
|
||||||
function NBRAssetSound( %game, %sourceObject )
|
|
||||||
{
|
|
||||||
%client = %sourceObject;
|
|
||||||
|
|
||||||
if( !%client.NBRAssetSoundMsgPlayed && $CurrentMissionType $= "CTF" && $Host::EnableNoBaseRapeNotify && !$Host::TournamentMode && $Host::EvoNoBaseRapeEnabled )
|
|
||||||
{
|
|
||||||
messageClient(%sourceObject.client, 'MsgNoBaseRapeNotify', '\c2No Base Rape is enabled until %1 players.', $Host::EvoNoBaseRapeClassicPlayerCount );
|
|
||||||
|
|
||||||
%client.NBRAssetSoundMsgPlayed = true;
|
|
||||||
schedule(10000, 0, "ResetNBRAssetSound", %client );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cool down between messages
|
|
||||||
function ResetNBRAssetSound( %client )
|
|
||||||
{
|
|
||||||
%client.NBRAssetSoundMsgPlayed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset every map change
|
|
||||||
package ResetNoBaseRapeNotify
|
|
||||||
{
|
{
|
||||||
|
|
||||||
function DefaultGame::gameOver(%game)
|
function DefaultGame::gameOver(%game)
|
||||||
|
|
@ -63,13 +49,32 @@ function DefaultGame::gameOver(%game)
|
||||||
Parent::gameOver(%game);
|
Parent::gameOver(%game);
|
||||||
|
|
||||||
//Reset NoBaseRapeNotify
|
//Reset NoBaseRapeNotify
|
||||||
$NoBaseRapeNotifyCount = -1;
|
$NBRStatus = "IDLE";
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prevent package from being activated if it is already
|
// Prevent package from being activated if it is already
|
||||||
if (!isActivePackage(ResetNoBaseRapeNotify))
|
if (!isActivePackage(ResetNBRNotify))
|
||||||
activatePackage(ResetNoBaseRapeNotify);
|
activatePackage(ResetNBRNotify);
|
||||||
|
|
||||||
|
|
||||||
|
// This function is at StaticShapeData::damageObject(%data, %targetObject, %sourceObject, %position, %amount, %damageType) in the staticshape.ovl in evoClassic.vl2
|
||||||
|
// Plays a sound when a player hits a protected enemy asset
|
||||||
|
function NBRAssetSound( %game, %sourceObject )
|
||||||
|
{
|
||||||
|
//Wont play again until the schedule is done
|
||||||
|
if(!isEventPending(%sourceObject.NBRAssetSoundSchedule) && $CurrentMissionType $= "CTF" && $Host::EnableNoBaseRapeNotify && !$Host::TournamentMode && $Host::EvoNoBaseRapeEnabled )
|
||||||
|
{
|
||||||
|
messageClient(%sourceObject.client, 'MsgNoBaseRapeNotify', '\c2No Base Rape is enabled until %1 players.', $Host::EvoNoBaseRapeClassicPlayerCount );
|
||||||
|
%sourceObject.NBRAssetSoundSchedule = schedule(10000, 0, "ResetNBRAssetSound", %sourceObject );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Reset
|
||||||
|
function ResetNBRAssetSound( %sourceObject )
|
||||||
|
{
|
||||||
|
if(isEventPending(%sourceObject.NBRAssetSoundSchedule))
|
||||||
|
cancel(%sourceObject.NBRAssetSoundSchedule);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,48 +11,60 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
// This function is called in GetTeamCounts.cs
|
// Called in GetTeamCounts.cs
|
||||||
function TeamBalanceNotify( %game, %team1difference, %team2difference )
|
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 ("%Team1Difference " @ %Team1Difference);
|
||||||
//echo ("%Team2Difference " @ %Team2Difference);
|
//echo ("%Team2Difference " @ %Team2Difference);
|
||||||
|
|
||||||
//Uneven
|
//Uneven
|
||||||
if( $PlayerCount[1] !$= $PlayerCount[2] )
|
if( $PlayerCount[1] !$= $PlayerCount[2] )
|
||||||
{
|
{
|
||||||
//Reset Balanced.
|
if( %team1difference >= 2 || %team2difference >= 2 ) //Teams are unbalanced
|
||||||
$BalancedMsgPlayed = 0;
|
|
||||||
|
|
||||||
if( %team1difference >= 2 || %team2difference >= 2 )
|
|
||||||
{
|
{
|
||||||
if( $UnbalancedMsgPlayed !$= 1)
|
if( $TBNStatus !$= "NOTIFY" ) //Stops any new schedules
|
||||||
{
|
$TBNStatus = "UNBALANCED";
|
||||||
//Run once.
|
|
||||||
$UnbalancedMsgPlayed = 1;
|
|
||||||
//Start Sound Schedule
|
|
||||||
schedule(15000, 0, "UnbalancedSound", %game );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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
|
//Teams are even
|
||||||
else if( $PlayerCount[1] == $PlayerCount[2] && $TotalTeamPlayerCount !$= 0 && $BalancedMsgPlayed !$= 1 )
|
else if( $PlayerCount[1] == $PlayerCount[2] && $TBNStatus !$= "PLAYEDEVEN" )
|
||||||
|
$TBNStatus = "EVEN";
|
||||||
|
|
||||||
|
switch$($TBNStatus)
|
||||||
{
|
{
|
||||||
//messageAll('MsgTeamBalanceNotify', '\c1Teams are balanced.');
|
case IDLE:
|
||||||
//Once per cycle.
|
//Do Nothing
|
||||||
$BalancedMsgPlayed = 1;
|
case UNEVEN:
|
||||||
//Reset Unbalanced.
|
//Do Nothing
|
||||||
$UnbalancedMsgPlayed = 0;
|
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
|
//Check to see if teams are still unbalanced
|
||||||
//Fire AutoBalance in 30 sec if enabled
|
//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
|
//Team Count code by Keen
|
||||||
$PlayerCount[0] = 0;
|
$PlayerCount[0] = 0;
|
||||||
|
|
@ -73,8 +85,7 @@ function UnbalancedSound( %game )
|
||||||
|
|
||||||
if( %team1difference == 1 || %team2difference == 1 || $PlayerCount[1] == $PlayerCount[2] )
|
if( %team1difference == 1 || %team2difference == 1 || $PlayerCount[1] == $PlayerCount[2] )
|
||||||
{
|
{
|
||||||
//Reset
|
ResetTBNStatus();
|
||||||
$UnbalancedMsgPlayed = 0;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Continue
|
//Continue
|
||||||
|
|
@ -84,42 +95,39 @@ function UnbalancedSound( %game )
|
||||||
if( $Host::EnableAutobalance )
|
if( $Host::EnableAutobalance )
|
||||||
{
|
{
|
||||||
messageAll('MsgTeamBalanceNotify', '\c1Teams are unbalanced: \c0Autobalance Initializing.~wgui/vote_nopass.wav');
|
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.
|
//If Autobalance is disabled, message only.
|
||||||
else if( $Host::EnableTeamBalanceNotify )
|
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] );
|
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(13000, 0, "ResetTBNStatus");
|
||||||
schedule(15000, 0, "ResetClientChangedTeams");
|
schedule(15000, 0, "ResetGetCountsStatus");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset TBNStatus
|
||||||
// Reset Notify
|
function ResetTBNStatus()
|
||||||
function ResetTeamBalanceNotifyGameOver()
|
|
||||||
{
|
{
|
||||||
//Reset All TeamBalance Variables
|
$TBNStatus = "IDLE";
|
||||||
$BalancedMsgPlayed = -1;
|
|
||||||
$UnbalancedMsgPlayed = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset every map change
|
// Reset every map change
|
||||||
package ResetTeamBalanceNotify
|
package ResetTBNGameOver
|
||||||
{
|
{
|
||||||
|
|
||||||
function DefaultGame::gameOver(%game)
|
function DefaultGame::gameOver(%game)
|
||||||
{
|
{
|
||||||
Parent::gameOver(%game);
|
Parent::gameOver(%game);
|
||||||
|
|
||||||
//Reset All TeamBalance Variables
|
//Reset TBNStatus
|
||||||
ResetTeamBalanceNotifyGameOver();
|
ResetTBNStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prevent package from being activated if it is already
|
// Prevent package from being activated if it is already
|
||||||
if (!isActivePackage(ResetTeamBalanceNotify))
|
if (!isActivePackage(ResetTBNGameOver))
|
||||||
activatePackage(ResetTeamBalanceNotify);
|
activatePackage(ResetTBNGameOver);
|
||||||
Loading…
Add table
Add a link
Reference in a new issue