diff --git a/autoexec/GetTeamCounts.cs b/autoexec/GetTeamCounts.cs index d9f276b..9e57e71 100644 --- a/autoexec/GetTeamCounts.cs +++ b/autoexec/GetTeamCounts.cs @@ -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]++; - //} -//} \ No newline at end of file +//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; +} diff --git a/autoexec/TeamBalanceNotify.cs b/autoexec/TeamBalanceNotify.cs index a6b88a4..e079c05 100644 --- a/autoexec/TeamBalanceNotify.cs +++ b/autoexec/TeamBalanceNotify.cs @@ -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); \ No newline at end of file diff --git a/defaultGame.cs b/defaultGame.cs index b8a8390..cedca4c 100644 --- a/defaultGame.cs +++ b/defaultGame.cs @@ -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) { @@ -152,7 +150,7 @@ function FlipFlop::playerTouch(%data, %flipflop, %player) function DefaultGame::initGameVars(%game) { - %game.SCORE_PER_SUICIDE = 0; + %game.SCORE_PER_SUICIDE = 0; %game.SCORE_PER_TEAMKILL = 0; %game.SCORE_PER_DEATH = 0; @@ -618,7 +616,7 @@ function DefaultGame::gameOver( %game ) // Default game does nothing... except lets the AI know the mission is over AIMissionEnd(); - + } //------------------------------------------------------------------------------ @@ -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' @@ -3178,7 +3191,7 @@ function DefaultGame::voteChangeTimeLimit( %game, %admin, %newLimit ) %cause = "(vote)"; } else - messageAll('MsgVoteFailed', '\c2The vote to change the mission time limit did not pass: %1 percent.', mFloor(%game.totalVotesFor/(ClientGroup.getCount() - $HostGameBotCount - %game.totalVotesNone) * 100)); + messageAll('MsgVoteFailed', '\c2The vote to change the mission time limit did not pass: %1 percent.', mFloor(%game.totalVotesFor/(ClientGroup.getCount() - $HostGameBotCount - %game.totalVotesNone) * 100)); } //if the time limit was actually changed... @@ -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)