Cleaned up

This commit is contained in:
ChocoTaco1 2022-07-09 17:38:47 -04:00
parent 297053afdc
commit 164bdd3dcc
2 changed files with 75 additions and 80 deletions

View file

@ -15,30 +15,30 @@ $AntiPackIncludeShield = 0;
// Called in GetCounts.cs // Called in GetCounts.cs
function CheckAntiPack( %game ) function CheckAntiPack(%game)
{ {
//CTF only //CTF only
if( $Host::AntiPackEnable ) if($Host::AntiPackEnable && $CurrentMissionType $= "DM" || $CurrentMissionType $= "CTF")
{ {
//echo("TotalTeamPlayerCount " @ $TotalTeamPlayerCount); //echo("TotalTeamPlayerCount " @ $TotalTeamPlayerCount);
//echo("AntiPackPlayerCount " @ $AntiPackPlayerCount); //echo("AntiPackPlayerCount " @ $Host::AntiPackPlayerCount);
if( $TotalTeamPlayerCount < $Host::AntiPackPlayerCount ) if($TotalTeamPlayerCount < $Host::AntiPackPlayerCount)
{ {
if( $AntiPackStatus !$= "ACTIVEON" ) if($AntiPackStatus !$= "ACTIVEON")
$AntiPackStatus = "ON"; $AntiPackStatus = "ON";
} }
//Off //Off
else else
{ {
if( $AntiPackStatus !$= "ACTIVEOFF" ) if($AntiPackStatus !$= "ACTIVEOFF")
$AntiPackStatus = "OFF"; $AntiPackStatus = "OFF";
} }
} }
//All other cases outside of CTF //All other cases outside of CTF
else else
{ {
if( $AntiPackStatus !$= "ACTIVEOFF" ) if($AntiPackStatus !$= "ACTIVEOFF")
$AntiPackStatus = "OFF"; $AntiPackStatus = "OFF";
} }
@ -66,9 +66,9 @@ function CheckAntiPack( %game )
if(isActivePackage(AntiPackShield)) if(isActivePackage(AntiPackShield))
deactivatePackage(AntiPackShield); deactivatePackage(AntiPackShield);
$AntiPackStatus = "ACTIVEOFF"; $AntiPackStatus = "ACTIVEOFF";
case ACTIVEON: case ACTIVEON:
//Do Nothing //Do Nothing
case ACTIVEOFF: case ACTIVEOFF:
//Do Nothing //Do Nothing
} }
} }
@ -80,12 +80,12 @@ package AntiPackCloak
function CloakingPackImage::onActivate(%data, %obj, %slot) function CloakingPackImage::onActivate(%data, %obj, %slot)
{ {
if(%obj.reCloak !$= "") if(%obj.reCloak !$= "")
{ {
Cancel(%obj.reCloak); Cancel(%obj.reCloak);
%obj.reCloak = ""; %obj.reCloak = "";
} }
if(%obj.client.armor $= "Light") if(%obj.client.armor $= "Light")
{ {
// can the player currently cloak (function returns "true" or reason for failure)? // can the player currently cloak (function returns "true" or reason for failure)?
if(%obj.canCloak() $= "true") if(%obj.canCloak() $= "true")
@ -94,7 +94,7 @@ function CloakingPackImage::onActivate(%data, %obj, %slot)
{ {
// cancel recloak thread // cancel recloak thread
if(%obj.reCloak !$= "") if(%obj.reCloak !$= "")
{ {
Cancel(%obj.reCloak); Cancel(%obj.reCloak);
%obj.reCloak = ""; %obj.reCloak = "";
} }
@ -111,7 +111,7 @@ function CloakingPackImage::onActivate(%data, %obj, %slot)
%obj.setImageTrigger(%slot, false); %obj.setImageTrigger(%slot, false);
} }
} }
else else
{ {
// hopefully avoid some loopholes // hopefully avoid some loopholes
messageClient(%obj.client, 'MsgCloakingPackInvalid', '\c2Cloaking available for light armors only.'); messageClient(%obj.client, 'MsgCloakingPackInvalid', '\c2Cloaking available for light armors only.');
@ -146,7 +146,7 @@ function DefaultGame::gameOver(%game)
{ {
Parent::gameOver(%game); Parent::gameOver(%game);
if( $Host::AntiPackEnable ) if($Host::AntiPackEnable)
{ {
if($InvBanList[CTF, "CloakingPack"]) if($InvBanList[CTF, "CloakingPack"])
$InvBanList[CTF, "CloakingPack"] = 0; $InvBanList[CTF, "CloakingPack"] = 0;

View file

@ -18,9 +18,9 @@ $GetCountsStatus = "UPDATE";
package StartTeamCounts package StartTeamCounts
{ {
function CreateServer( %mission, %missionType ) function CreateServer(%mission, %missionType)
{ {
parent::CreateServer( %mission, %missionType ); parent::CreateServer(%mission, %missionType);
//Call for a GetTeamCount update //Call for a GetTeamCount update
GetTeamCounts(%game); GetTeamCounts(%game);
@ -37,40 +37,36 @@ if (!isActivePackage(StartTeamCounts))
function GetTeamCounts(%game) function GetTeamCounts(%game)
{ {
switch$($GetCountsStatus) if($GetCountsStatus)
{ {
case UPDATE: if($countdownStarted && $MatchStarted)
if($countdownStarted && $MatchStarted ) {
//Variables
$TotalTeamPlayerCount = $TeamRank[1, count] + $TeamRank[2, count];
$AllPlayerCount = $HostGamePlayerCount;
//Observers
$Observers = $HostGamePlayerCount - ($TeamRank[1, count] + $TeamRank[2, count]);
//echo("$PlayerCount[0] " @ $HostGamePlayerCount - ($TeamRank[1, count] + $TeamRank[2, count]));
//echo("$PlayerCount[1] " @ $TeamRank[1, count]);
//echo("$PlayerCount[2] " @ $TeamRank[2, count]);
if(!$Host::TournamentMode)
{ {
//Variables if($CurrentMissionType $= "CTF") //No SCtF
$TotalTeamPlayerCount = $TeamRank[1, count] + $TeamRank[2, count]; NBRStatusNotify(%game); //Base Rape
$AllPlayerCount = $HostGamePlayerCount;
//Observers if($CurrentMissionType $= "CTF" || $CurrentMissionType $= "DM")
$Observers = $HostGamePlayerCount - ($TeamRank[1, count] + $TeamRank[2, count]); CheckAntiPack(%game); //Limit certain packs with low numbers
//echo("$PlayerCount[0] " @ $HostGamePlayerCount - ($TeamRank[1, count] + $TeamRank[2, count])); if(Game.numTeams > 1)
//echo("$PlayerCount[1] " @ $TeamRank[1, count]); TeamBalanceNotify(%game); //Team Balance
//echo("$PlayerCount[2] " @ $TeamRank[2, count]);
if( !$Host::TournamentMode )
{
if($CurrentMissionType $= "CTF")
{
NBRStatusNotify(%game);
CheckAntiPack(%game);
}
else if($CurrentMissionType $= "DM")
CheckAntiPack(%game);
TeamBalanceNotify(%game); //Has check for # teams
}
//Set so counter wont run when it doesnt need to.
$GetCountsStatus = "IDLE";
} }
case IDLE:
//Do Nothing //Set so counter wont run when it doesnt need to.
$GetCountsStatus = 0;
}
} }
if(isEventPending($GetCountsSchedule)) if(isEventPending($GetCountsSchedule))
@ -81,12 +77,6 @@ function GetTeamCounts(%game)
} }
// Triggers a Full run
function ResetGetCountsStatus()
{
$GetCountsStatus = "UPDATE";
}
// Proper Overrides // Proper Overrides
// Events that determine a TeamGetCounts update // Events that determine a TeamGetCounts update
package TeamCountsTriggers package TeamCountsTriggers
@ -97,7 +87,7 @@ function DefaultGame::clientJoinTeam( %game, %client, %team, %respawn )
Parent::clientJoinTeam( %game, %client, %team, %respawn ); Parent::clientJoinTeam( %game, %client, %team, %respawn );
//Trigger GetCounts //Trigger GetCounts
ResetGetCountsStatus(); $GetCountsStatus = 1;
} }
function DefaultGame::clientChangeTeam(%game, %client, %team, %fromObs, %respawned) function DefaultGame::clientChangeTeam(%game, %client, %team, %fromObs, %respawned)
@ -105,7 +95,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
ResetGetCountsStatus(); $GetCountsStatus = 1;
} }
function DefaultGame::assignClientTeam(%game, %client, %respawn ) function DefaultGame::assignClientTeam(%game, %client, %respawn )
@ -113,7 +103,7 @@ function DefaultGame::assignClientTeam(%game, %client, %respawn )
Parent::assignClientTeam(%game, %client, %respawn ); Parent::assignClientTeam(%game, %client, %respawn );
//Trigger GetCounts //Trigger GetCounts
ResetGetCountsStatus(); $GetCountsStatus = 1;
} }
function DefaultGame::onClientEnterObserverMode( %game, %client ) function DefaultGame::onClientEnterObserverMode( %game, %client )
@ -121,7 +111,7 @@ function DefaultGame::onClientEnterObserverMode( %game, %client )
Parent::onClientEnterObserverMode( %game, %client ); Parent::onClientEnterObserverMode( %game, %client );
//Trigger GetCounts //Trigger GetCounts
ResetGetCountsStatus(); $GetCountsStatus = 1;
} }
function DefaultGame::AIChangeTeam(%game, %client, %newTeam) function DefaultGame::AIChangeTeam(%game, %client, %newTeam)
@ -129,7 +119,7 @@ function DefaultGame::AIChangeTeam(%game, %client, %newTeam)
Parent::AIChangeTeam(%game, %client, %newTeam); Parent::AIChangeTeam(%game, %client, %newTeam);
//Trigger GetCounts //Trigger GetCounts
ResetGetCountsStatus(); $GetCountsStatus = 1;
} }
function GameConnection::onConnect(%client, %name, %raceGender, %skin, %voice, %voicePitch) function GameConnection::onConnect(%client, %name, %raceGender, %skin, %voice, %voicePitch)
@ -137,7 +127,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
ResetGetCountsStatus(); $GetCountsStatus = 1;
} }
function DefaultGame::gameOver(%game) function DefaultGame::gameOver(%game)
@ -145,7 +135,7 @@ function DefaultGame::gameOver(%game)
Parent::gameOver(%game); Parent::gameOver(%game);
//Reset GetCounts //Reset GetCounts
ResetGetCountsStatus(); $GetCountsStatus = 1;
} }
function GameConnection::onDrop(%client, %reason) function GameConnection::onDrop(%client, %reason)
@ -153,11 +143,18 @@ function GameConnection::onDrop(%client, %reason)
Parent::onDrop(%client, %reason); Parent::onDrop(%client, %reason);
//Reset GetCounts //Reset GetCounts
ResetGetCountsStatus(); $GetCountsStatus = 1;
} }
}; };
//Reset GetCounts thru function
function ResetGetCountsStatus()
{
//Reset GetCounts
$GetCountsStatus = 1;
}
// Team Balance Notify Script // Team Balance Notify Script
// //
@ -178,10 +175,9 @@ function TeamBalanceNotify(%game)
if(!$Host::EnableTeamBalanceNotify && !$Host::EnableAutobalance) if(!$Host::EnableTeamBalanceNotify && !$Host::EnableAutobalance)
return; return;
if( Game.numTeams > 1 && $TotalTeamPlayerCount !$= 0 ) if($TotalTeamPlayerCount !$= 0)
{ {
//Uneven if($TeamRank[1, count] !$= $TeamRank[2, count]) //Uneven
if($TeamRank[1, count] !$= $TeamRank[2, count])
{ {
%team1difference = $TeamRank[1, count] - $TeamRank[2, count]; %team1difference = $TeamRank[1, count] - $TeamRank[2, count];
%team2difference = $TeamRank[2, count] - $TeamRank[1, count]; %team2difference = $TeamRank[2, count] - $TeamRank[1, count];
@ -198,8 +194,7 @@ function TeamBalanceNotify(%game)
//Man down. 6vs7, 4vs3 etc //Man down. 6vs7, 4vs3 etc
$TBNStatus = "UNEVEN"; $TBNStatus = "UNEVEN";
} }
//Teams are even else if($TeamRank[1, count] == $TeamRank[2, count] && $TBNStatus !$= "PLAYEDEVEN") //Teams are even
else if($TeamRank[1, count] == $TeamRank[2, count] && $TBNStatus !$= "PLAYEDEVEN" )
$TBNStatus = "EVEN"; $TBNStatus = "EVEN";
switch$($TBNStatus) switch$($TBNStatus)
@ -226,7 +221,7 @@ function TeamBalanceNotify(%game)
//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 NotifyUnbalanced( %game ) function NotifyUnbalanced(%game)
{ {
if(isEventPending($NotifySchedule)) if(isEventPending($NotifySchedule))
cancel($NotifySchedule); cancel($NotifySchedule);
@ -234,23 +229,23 @@ function NotifyUnbalanced( %game )
if(!$Host::EnableTeamBalanceNotify && !$Host::EnableAutobalance) if(!$Host::EnableTeamBalanceNotify && !$Host::EnableAutobalance)
return; return;
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; return;
//Difference Variables //Difference Variables
%team1difference = $TeamRank[1, count] - $TeamRank[2, count]; %team1difference = $TeamRank[1, count] - $TeamRank[2, count];
%team2difference = $TeamRank[2, count] - $TeamRank[1, count]; %team2difference = $TeamRank[2, count] - $TeamRank[1, count];
if( %team1difference >= 2 || %team2difference >= 2 ) if(%team1difference >= 2 || %team2difference >= 2)
{ {
//Autobalance Warning //Autobalance Warning
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');
$AutoBalanceSchedule = 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)
{ {
%observers = $HostGamePlayerCount - ($TeamRank[1, count] + $TeamRank[2, count]); %observers = $HostGamePlayerCount - ($TeamRank[1, count] + $TeamRank[2, count]);
messageAll('MsgTeamBalanceNotify', '\c1Teams are unbalanced: \c0%1 vs %2 with %3 observers.~wgui/vote_nopass.wav', $TeamRank[1, count], $TeamRank[2, count], %observers ); messageAll('MsgTeamBalanceNotify', '\c1Teams are unbalanced: \c0%1 vs %2 with %3 observers.~wgui/vote_nopass.wav', $TeamRank[1, count], $TeamRank[2, count], %observers );
@ -296,20 +291,20 @@ if (!isActivePackage(ResetTBNGameOver))
// //
// Called in GetTeamCounts.cs // Called in GetTeamCounts.cs
function NBRStatusNotify( %game ) function NBRStatusNotify(%game)
{ {
if( $Host::EnableNoBaseRapeNotify && $Host::NoBaseRapeEnabled ) if($Host::EnableNoBaseRapeNotify && $Host::NoBaseRapeEnabled)
{ {
//On //On
if( $Host::NoBaseRapePlayerCount > $TotalTeamPlayerCount ) if($Host::NoBaseRapePlayerCount > $TotalTeamPlayerCount)
{ {
if( $NBRStatus !$= "PLAYEDON" ) if($NBRStatus !$= "PLAYEDON")
$NBRStatus = "ON"; $NBRStatus = "ON";
} }
//Off //Off
else else
{ {
if( $NBRStatus !$= "PLAYEDOFF" ) if($NBRStatus !$= "PLAYEDOFF")
$NBRStatus = "OFF"; $NBRStatus = "OFF";
} }
@ -361,7 +356,7 @@ if (!isActivePackage(ResetNBRNotify))
// //
// Run from TeamBalanceNotify via NotifyUnbalanced // Run from TeamBalanceNotify via NotifyUnbalanced
function Autobalance( %game ) function Autobalance(%game)
{ {
if(isEventPending($AutoBalanceSchedule)) if(isEventPending($AutoBalanceSchedule))
cancel($AutoBalanceSchedule); cancel($AutoBalanceSchedule);
@ -377,9 +372,9 @@ function Autobalance( %game )
%team2difference = $TeamRank[2, count] - $TeamRank[1, count]; %team2difference = $TeamRank[2, count] - $TeamRank[1, count];
//Determine BigTeam //Determine BigTeam
if( %team1difference >= 2 ) if(%team1difference >= 2)
$BigTeam = 1; $BigTeam = 1;
else if( %team2difference >= 2 ) else if(%team2difference >= 2)
$BigTeam = 2; $BigTeam = 2;
else else
return; return;