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,12 +27,7 @@ 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);
if($GetCountsClientTeamChange && $countdownStarted && $MatchStarted) {
//Team Count code by Keen
$PlayerCount[0] = 0;
$PlayerCount[1] = 0;
@ -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 );
}
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) {
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;
}
//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);

View file

@ -1,7 +1,5 @@
//$MissionName is the file name of the mission
//$MapName is the displayed name(no underscore,spaces)
//$GameType (CTF,Hunters)
function DefaultGame::activatePackages(%game)
{
@ -1153,6 +1151,7 @@ function DefaultGame::forceObserver( %game, %client, %reason )
// call the onEvent for this game type
%game.onClientEnterObserverMode(%client); //Bounty uses this to remove this client from others' hit lists
}
function DefaultGame::displayDeathMessages(%game, %clVictim, %clKiller, %damageType, %implement)
@ -1430,6 +1429,8 @@ function DefaultGame::clientJoinTeam( %game, %client, %team, %respawn )
logEcho(%client.nameBase@" (cl "@%client@") joined team "@%client.team);
//Trigger GetCounts
ResetClientChangedTeams();
}
function DefaultGame::AIHasJoined(%game, %client)
@ -1483,6 +1484,8 @@ function DefaultGame::AIChangeTeam(%game, %client, %newTeam)
messageAllExcept( %client, -1, 'MsgClientJoinTeam', '\c1bot %1 has switched to team %2.', %client.name, %game.getTeamName(%client.team), %client, %client.team );
//Trigger GetCounts
ResetClientChangedTeams();
}
function DefaultGame::clientChangeTeam(%game, %client, %team, %fromObs, %respawned) // z0dd - ZOD, 6/06/02. Don't send a message if player used respawn feature. Added %respawned
@ -1558,6 +1561,9 @@ function DefaultGame::clientChangeTeam(%game, %client, %team, %fromObs, %respawn
// MES - switch objective hud lines when client switches teams
messageClient(%client, 'MsgCheckTeamLines', "", %client.team);
logEcho(%client.nameBase@" (cl "@%client@") switched to team "@%client.team);
//Trigger GetCounts
ResetClientChangedTeams();
}
// missioncleanup and missiongroup are checked prior to entering game code
@ -1640,6 +1646,9 @@ function DefaultGame::onClientLeaveGame(%game, %client)
//remove them from the team rank arrays
%game.removeFromTeamRankArray(%client);
logEcho(%client.nameBase@" (cl "@%client@") dropped");
//Trigger GetCounts
ResetClientChangedTeams();
}
function DefaultGame::clientMissionDropReady(%game, %client)
@ -1771,6 +1780,10 @@ function DefaultGame::testDrop( %game, %client )
function DefaultGame::onClientEnterObserverMode( %game, %client )
{
// Default game doesn't care...
//Trigger GetCounts
ResetClientChangedTeams();
}
// from 'item.cs'
@ -3755,7 +3768,7 @@ function notifyMatchEnd(%time)
if (%seconds > 1) {
MessageAll('MsgMissionEnd', '\c2Match ends in %1 seconds.~wfx/misc/hunters_%1.wav', %seconds);
if (%seconds == 60) {
MessageAll('MsgNotifyEvoNextMission', '\c2Next Mission: \c3%1', $EvoCachedNextMission);
MessageAll('MsgNotifyEvoNextMission', '\c2Next Mission: \c1%1', $EvoCachedNextMission);
}
}
else if (%seconds == 1)