Server Core Rework

More use of Switch cases and Scheduling tracking
This commit is contained in:
ChocoTaco 2019-12-11 16:30:37 -05:00
parent c95483c322
commit 4a7325a74d
5 changed files with 187 additions and 178 deletions

View file

@ -10,52 +10,38 @@
function NBRStatusNotify( %game )
{
if( $CurrentMissionType $= "CTF" && $Host::EnableNoBaseRapeNotify && !$Host::TournamentMode && $Host::EvoNoBaseRapeEnabled )
{
//echo ("%client " @ %client);
//echo ("$TeamBalanceClient " @ $TeamBalanceClient);
{
//On
if( $Host::EvoNoBaseRapeClassicPlayerCount > $TotalTeamPlayerCount )
if( $Host::EvoNoBaseRapeClassicPlayerCount > $TotalTeamPlayerCount )
{
if( $NoBaseRapeNotifyCount !$= 0 )
{
messageAll('MsgNoBaseRapeNotify', '\c1No Base Rape: \c0Enabled.');
$NoBaseRapeNotifyCount = 0;
}
if( $NBRStatus !$= "PLAYEDON" )
$NBRStatus = "ON";
}
//Off
else if( $NoBaseRapeNotifyCount !$= 1 )
else
{
messageAll('MsgNoBaseRapeNotify', '\c1No Base Rape: \c0Disabled.~wfx/misc/diagnostic_on.wav');
$NoBaseRapeNotifyCount = 1;
if( $NBRStatus !$= "PLAYEDOFF" )
$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)
// In the staticshape.ovl in evoClassic.vl2
// 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
// Reset gameover
package ResetNBRNotify
{
function DefaultGame::gameOver(%game)
@ -63,13 +49,32 @@ function DefaultGame::gameOver(%game)
Parent::gameOver(%game);
//Reset NoBaseRapeNotify
$NoBaseRapeNotifyCount = -1;
$NBRStatus = "IDLE";
}
};
// Prevent package from being activated if it is already
if (!isActivePackage(ResetNoBaseRapeNotify))
activatePackage(ResetNoBaseRapeNotify);
if (!isActivePackage(ResetNBRNotify))
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);
}