Bug fixes and updates

Fixed a bug where gameOver was being overridden twice.
The bulk of GetCounts only runs during teamchange events.
This commit is contained in:
ChocoTaco 2018-09-16 11:07:47 -04:00
parent 26586036bf
commit 330d4e4b51
3 changed files with 66 additions and 62 deletions

View file

@ -10,6 +10,7 @@ function CreateServer(%mission, %missionType)
parent::CreateServer(%mission, %missionType);
//Start
//Call for a GetTeamCount update
ResetClientChangedTeams();
GetTeamCounts( %game, %client, %respawn );
}
@ -26,16 +27,11 @@ function GetTeamCounts( %game, %client, %respawn )
deactivatePackage(StartTeamCounts);
}
//echo ("Clientgroup " @ ClientGroup.getCount());
//echo ("$PlayerCount[0] " @ $PlayerCount[0]);
//echo ("$PlayerCount[1] " @ $PlayerCount[1]);
//echo ("$PlayerCount[2] " @ $PlayerCount[2]);
//echo ("client.team " @ %client.team);
//Team Count code by Keen
$PlayerCount[0] = 0;
$PlayerCount[1] = 0;
$PlayerCount[2] = 0;
if($GetCountsClientTeamChange && $countdownStarted && $MatchStarted) {
//Team Count code by Keen
$PlayerCount[0] = 0;
$PlayerCount[1] = 0;
$PlayerCount[2] = 0;
for(%i = 0; %i < ClientGroup.getCount(); %i++)
{
@ -45,48 +41,53 @@ function GetTeamCounts( %game, %client, %respawn )
$PlayerCount[%client.team]++;
}
//echo ("Clientgroup " @ ClientGroup.getCount());
//echo ("$PlayerCount[0] " @ $PlayerCount[0]);
//echo ("$PlayerCount[1] " @ $PlayerCount[1]);
//echo ("$PlayerCount[2] " @ $PlayerCount[2]);
//echo ("client.team " @ %client.team);
//Other variables
//Amount of players on teams
$TotalTeamPlayerCount = $PlayerCount[1] + $PlayerCount[2];
//Amount of all players including observers
$AllPlayerCount = $PlayerCount[1] + $PlayerCount[2] + $PlayerCount[0];
//Call Team Balance Notify
//Make sure it's CTF Mode
if($CurrentMissionType $= "CTF" && $TotalTeamPlayerCount !$= 0 && $countdownStarted $= true && $MatchStarted $= true) {
TeamBalanceNotify::AtSpawn( %game, %client, %respawn );
//Start Base Rape Notify
//Make sure it's CTF Mode
if($CurrentMissionType $= "CTF") {
PlayerNotify::AtSpawn( %game, %client, %respawn );
}
//Call Team Balance Notify
//Make sure it's CTF Mode
if($CurrentMissionType $= "CTF" && $TotalTeamPlayerCount !$= 0) {
TeamBalanceNotify::AtSpawn( %game, %client, %respawn );
}
if($CurrentMissionType $= "sctf" && $TotalTeamPlayerCount !$= 0) {
TeamBalanceNotify::AtSpawn( %game, %client, %respawn );
}
//AntiCloak Start
//if($CurrentMissionType $= "CTF") {
//ActivateAntiCloak ();
//}
$GetCountsClientTeamChange = false;
}
if($CurrentMissionType $= "sctf" && $TotalTeamPlayerCount !$= 0 && $countdownStarted $= true && $MatchStarted $= true) {
TeamBalanceNotify::AtSpawn( %game, %client, %respawn );
}
//Start Base Rape Notify
//Make sure it's CTF Mode
if($CurrentMissionType $= "CTF" && $countdownStarted $= true && $MatchStarted $= true) {
PlayerNotify::AtSpawn( %game, %client, %respawn );
}
//AntiCloak Start
//if($CurrentMissionType $= "CTF") {
//ActivateAntiCloak ();
//}
//Call itself again. Every 5 seconds.
schedule(5000, 0, "GetTeamCounts");
}
//For instant Calls for an update
//function QuickTeamCounts( %game, %client, %respawn )
//{
//Team Count code by Keen
//$PlayerCount[0] = 0;
//$PlayerCount[1] = 0;
//$PlayerCount[2] = 0;
//for(%i = 0; %i < ClientGroup.getCount(); %i++)
//{
//%client = ClientGroup.getObject(%i);
//if(!%client.isAIControlled())
//$PlayerCount[%client.team]++;
//}
//}
//Run at DefaultGame::clientJoinTeam, DefaultGame::clientChangeTeam, DefaultGame::assignClientTeam in evo defaultgame.ovl
//Also Run at DefaultGame::onClientEnterObserverMode, DefaultGame::AIChangeTeam, DefaultGame::onClientLeaveGame, DefaultGame::forceObserver in evo defaultgame.ovl
//And finally GameConnection::onConnect in evo server.ovl
//Added so the bulk of GetCounts doesnt run when it doesnt need to causing unnecessary latency that may or may not have existed, but probably is good practice.
//GetCounts still runs every 5 seconds as it did, but whether or not someone has changed teams, joined obs, left, etc etc will decide whether or not the bulk of it runs.
function ResetClientChangedTeams() {
//Let GetTeamCounts run if there is a Teamchange.
$GetCountsClientTeamChange = true;
}

View file

@ -59,29 +59,19 @@ function TeamBalanceNotify::AtSpawn( %game, %client, %respawn )
}
}
//Called in evo in CTFGame.ovl
//Called in CTFGame::flagCap in evo CTFGame.ovl
//Allows for another unbalanced notification everytime the flag is capped.
function ResetUnbalancedNotifyPerCap()
{
$TeamBalanceNotifyCount = 0;
$StatsBalanceCount = 0;
}
//Start and Reset Notify
package TeamCountNotify {
//Reset Notify
function DefaultGame::gameOver( %game ) {
//Call default function
parent::gameOver( %game );
//Reset Notify at defaultgame::gameOver in evo defaultgame.ovl
function ResetTeamBalanceNotifyGameOver( %game ) {
//Reset TeamBalance Variables
$BalancedCount = -1;
$TeamBalanceNotifyCount = -1;
$StatsBalanceCount = -1;
}
};
// Prevent package from being activated if it is already
if (!isActivePackage(TeamCountNotify))
activatePackage(TeamCountNotify);