Update zDarkTigerStats.cs

This commit is contained in:
ChocoTaco 2021-06-02 12:55:33 -04:00
parent fb9d35a6c2
commit 99a48e65a5

View file

@ -11,9 +11,10 @@
// Version 8.0 - More Stats / Fixes / Server Event Log // Version 8.0 - More Stats / Fixes / Server Event Log
// Note See bottom of file for full log // Note See bottom of file for full log
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//-----------Settings------------ //-----------Settings------------
//Notes score ui width is 592 //Notes score ui width is 592
$dtStats::version = 8.9; $dtStats::version = 9.0;
//disable stats system //disable stats system
$dtStats::Enable = 1; $dtStats::Enable = 1;
//enable disable map stats //enable disable map stats
@ -291,6 +292,8 @@ $dtStats::FV[$dtStats::FC["CTFGame","TG"]++,"CTFGame","TG"] = "timeOnTeamZero";
$dtStats::FV[$dtStats::FC["CTFGame","TG"]++,"CTFGame","TG"] = "timeOnTeamOne"; $dtStats::FV[$dtStats::FC["CTFGame","TG"]++,"CTFGame","TG"] = "timeOnTeamOne";
$dtStats::FV[$dtStats::FC["CTFGame","TG"]++,"CTFGame","TG"] = "timeOnTeamTwo"; $dtStats::FV[$dtStats::FC["CTFGame","TG"]++,"CTFGame","TG"] = "timeOnTeamTwo";
$dtStats::FV[$dtStats::FC["CTFGame","TG"]++,"CTFGame","TG"] = "matchRunTime"; $dtStats::FV[$dtStats::FC["CTFGame","TG"]++,"CTFGame","TG"] = "matchRunTime";
$dtStats::FV[$dtStats::FC["CTFGame","Game"]++,"CTFGame","Game"] = "teamOneCapTimes";
$dtStats::FV[$dtStats::FC["CTFGame","Game"]++,"CTFGame","Game"] = "teamTwoCapTimes";
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
//Unused vars needed for stats back up //Unused vars needed for stats back up
$dtStats::uGFV[$dtStats::uGFC["CTFGame"]++,"CTFGame"] = "returnPts"; $dtStats::uGFV[$dtStats::uGFC["CTFGame"]++,"CTFGame"] = "returnPts";
@ -421,7 +424,8 @@ $dtStats::FV[$dtStats::FC["SCtFGame","TG"]++,"SCtFGame","TG"] = "timeOnTeamZero"
$dtStats::FV[$dtStats::FC["SCtFGame","TG"]++,"SCtFGame","TG"] = "timeOnTeamOne"; $dtStats::FV[$dtStats::FC["SCtFGame","TG"]++,"SCtFGame","TG"] = "timeOnTeamOne";
$dtStats::FV[$dtStats::FC["SCtFGame","TG"]++,"SCtFGame","TG"] = "timeOnTeamTwo"; $dtStats::FV[$dtStats::FC["SCtFGame","TG"]++,"SCtFGame","TG"] = "timeOnTeamTwo";
$dtStats::FV[$dtStats::FC["SCtFGame","TG"]++,"SCtFGame","TG"] = "matchRunTime"; $dtStats::FV[$dtStats::FC["SCtFGame","TG"]++,"SCtFGame","TG"] = "matchRunTime";
$dtStats::FV[$dtStats::FC["SCtFGame","Game"]++,"SCtFGame","Game"] = "teamOneCapTimes";
$dtStats::FV[$dtStats::FC["SCtFGame","Game"]++,"SCtFGame","Game"] = "teamTwoCapTimes";
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// DuelGame // DuelGame
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -637,7 +641,10 @@ $dtStats::FV[$dtStats::FC["TG"]++,"TG"] = "lightningMAEVKills";
$dtStats::FV[$dtStats::FC["TG"]++,"TG"] = "EVHitWep"; $dtStats::FV[$dtStats::FC["TG"]++,"TG"] = "EVHitWep";
$dtStats::FV[$dtStats::FC["TG"]++,"TG"] = "EVMAHit"; $dtStats::FV[$dtStats::FC["TG"]++,"TG"] = "EVMAHit";
$dtStats::FV[$dtStats::FC["Game"]++,"Game"] = "startPCT";
$dtStats::FV[$dtStats::FC["Game"]++,"Game"] = "endPCT";
$dtStats::FV[$dtStats::FC["Game"]++,"Game"] = "mapSkip";
$dtStats::FV[$dtStats::FC["Game"]++,"Game"] = "clientQuit";
$dtStats::FV[$dtStats::FC["TG"]++,"TG"] = "totalWepDmg"; $dtStats::FV[$dtStats::FC["TG"]++,"TG"] = "totalWepDmg";
$dtStats::FV[$dtStats::FC["TG"]++,"TG"] = "timeTL"; $dtStats::FV[$dtStats::FC["TG"]++,"TG"] = "timeTL";
$dtStats::FV[$dtStats::FC["Avg"]++,"Avg"] = "timeTL"; $dtStats::FV[$dtStats::FC["Avg"]++,"Avg"] = "timeTL";
@ -1825,6 +1832,12 @@ package dtStats{
} }
//error("assignClientTeam" SPC %client.team SPC %respawn); //error("assignClientTeam" SPC %client.team SPC %respawn);
} }
//function DefaultGame::startMatch(%game){
//parent::startMatch(%game);
//if($dtStats::Enable){
//
//}
//}
function RepairPack::onThrow(%data,%obj,%shape){ function RepairPack::onThrow(%data,%obj,%shape){
parent::onThrow(%data,%obj,%shape); parent::onThrow(%data,%obj,%shape);
if($dtStats::Enable){ if($dtStats::Enable){
@ -2454,15 +2467,30 @@ package dtStatsGame{
function CTFGame::flagCap(%game, %player){ function CTFGame::flagCap(%game, %player){
if($dtStats::Enable){ if($dtStats::Enable){
%flag = %player.holdingFlag; %flag = %player.holdingFlag;
%clTeam = %player.client.team;
%dtStats = %player.client.dtStats;
%time = ((getSimTime() - $missionStartTime)/1000)/60;
if(%clTeam == 1){
if(!%dtStats.teamOneCapTimes)
%dtStats.teamOneCapTimes = cropFloat(%time,1);
else
%dtStats.teamOneCapTimes = %dtStats.teamOneCapTimes @ "," @ cropFloat(%time,1);
}
else{
if(!%dtStats.teamTwoCapTimes)
%dtStats.teamTwoCapTimes = cropFloat(%time,1);
else
%dtStats.teamTwoCapTimes = %dtStats.teamTwoCapTimes @ "," @ cropFloat(%time,1);
}
if(%game.dtTotalFlagTime[%flag]){ if(%game.dtTotalFlagTime[%flag]){
%heldTime = (getSimTime() - %game.dtTotalFlagTime[%flag])/1000; %heldTime = (getSimTime() - %game.dtTotalFlagTime[%flag])/1000;
if(%heldTime < %player.client.dtStats.heldTimeSec || !%player.client.dtStats.heldTimeSec){ if(%heldTime < %dtStats.heldTimeSec || !%dtStats.heldTimeSec){
if($TeamRank[2,"count"] > 5 && $TeamRank[1,"count"] > 5){ if($TeamRank[2,"count"] > 5 && $TeamRank[1,"count"] > 5){
%player.client.dtStats.heldTimeSec = %heldTime; %dtStats.heldTimeSec = %heldTime;
%player.client.dtStats.heldTimeSecLow = %heldTime; %dtStats.heldTimeSecLow = %heldTime;
} }
else else
%player.client.dtStats.heldTimeSecLow = %heldTime; %dtStats.heldTimeSecLow = %heldTime;
} }
} }
} }
@ -2554,15 +2582,29 @@ package dtStatsGame{
function SCtFGame::flagCap(%game, %player){ function SCtFGame::flagCap(%game, %player){
if($dtStats::Enable){ if($dtStats::Enable){
%flag = %player.holdingFlag; %flag = %player.holdingFlag;
%dtStats = %player.client.dtStats;
%time = ((getSimTime() - $missionStartTime)/1000)/60;
if(%clTeam == 1){
if(!%dtStats.teamOneCapTimes)
%dtStats.teamOneCapTimes = cropFloat(%time,1);
else
%dtStats.teamOneCapTimes = %dtStats.teamOneCapTimes @ "," @ cropFloat(%time,1);
}
else{
if(!%dtStats.teamTwoCapTimes)
%dtStats.teamTwoCapTimes = cropFloat(%time,1);
else
%dtStats.teamTwoCapTimes = %dtStats.teamTwoCapTimes @ "," @ cropFloat(%time,1);
}
if(%game.dtTotalFlagTime[%flag]){ if(%game.dtTotalFlagTime[%flag]){
%heldTime = (getSimTime() - %game.dtTotalFlagTime[%flag])/1000; %heldTime = (getSimTime() - %game.dtTotalFlagTime[%flag])/1000;
if(%heldTime < %player.client.dtStats.heldTimeSec || !%player.client.dtStats.heldTimeSec){ if(%heldTime < %dtStats.heldTimeSec || !%dtStats.heldTimeSec){
if($TeamRank[2,"count"] > 5 && $TeamRank[1,"count"] > 5){ if($TeamRank[2,"count"] > 5 && $TeamRank[1,"count"] > 5){
%player.client.dtStats.heldTimeSec = %heldTime; %dtStats.heldTimeSec = %heldTime;
%player.client.dtStats.heldTimeSecLow = %heldTime; %dtStats.heldTimeSecLow = %heldTime;
} }
else else
%player.client.dtStats.heldTimeSecLow = %heldTime; %dtStats.heldTimeSecLow = %heldTime;
} }
} }
} }
@ -3946,7 +3988,7 @@ function dtStatsMissionDropReady(%game, %client){ // called when client has fini
else else
%dtStats = %client.dtStats; %dtStats = %client.dtStats;
%dtStats.joinPCT = %game.getGamePct(); %dtStats.joinPCT = (isGameRun() == 1) ? %game.getGamePct() : 0;
updateTeamTime(%dtStats, -1); updateTeamTime(%dtStats, -1);
%dtStats.team = %client.team;// should be 0 %dtStats.team = %client.team;// should be 0
if(isObject(%dtStats) && %dtStats.gameData[%game.class] != 1){ // game type change if(isObject(%dtStats) && %dtStats.gameData[%game.class] != 1){ // game type change
@ -3966,73 +4008,75 @@ function dtStatsClientLeaveGame(%client){
if(%client.score != 0) if(%client.score != 0)
$dtServer::mapDisconnectsScore[cleanMapName($CurrentMission),Game.class]++; $dtServer::mapDisconnectsScore[cleanMapName($CurrentMission),Game.class]++;
} }
//if($HostGamePlayerCount - $HostGameBotCount == 0)
if(isObject(%client.dtStats)){ if(isObject(%client.dtStats)){
%client.dtStats.clientLeft = 1; %client.dtStats.clientLeft = 1;
%client.dtStats.leftTime = getSimTime(); %client.dtStats.leftTime = getSimTime();
%client.dtStats.leftID = $dtStats::leftID; %client.dtStats.leftID = $dtStats::leftID;
updateTeamTime(%client.dtStats, %dtStats.team); %client.dtStats.leftPCT = (isGameRun() == 1) ? %game.getGamePct() : 0;
if(isObject(Game) && isGameRun() && %client.score != 0) if(isObject(Game) && isGameRun() && %client.score != 0)
bakGameStats(%client,Game.class);//back up there current game in case they lost connection bakGameStats(%client,Game.class);//back up there current game in case they lost connection
} }
} }
function dtStatsGameOver( %game ){ function dtStatsGameOver( %game ){
if($dtStats::debugEchos){error("dtStatsGameOver");}
$dtStats::serverHang = $dtStats::hostHang = 0; $dtStats::serverHang = $dtStats::hostHang = 0;
$dtStats::LastMissionDN = $MissionDisplayName; $dtStats::LastMissionDN = $MissionDisplayName;
$dtStats::LastMissionCM = $CurrentMission; $dtStats::LastMissionCM = $CurrentMission;
$dtStats::LastGameType = %game.class; $dtStats::LastGameType = %game.class;
$dtStats::statsSave = 1; if(%game.getGamePct() > 90){
if(%game.getGamePct() > 50){
$dtServer::playCount[cleanMapName($CurrentMission),%game.class]++; $dtServer::playCount[cleanMapName($CurrentMission),%game.class]++;
$dtServer::lastPlay[cleanMapName($CurrentMission),%game.class] = getDayNum() TAB getYear() TAB formattimestring("mm/dd/yy hh:nn:a"); $dtServer::lastPlay[cleanMapName($CurrentMission),%game.class] = getDayNum() TAB getYear() TAB formattimestring("mm/dd/yy hh:nn:a");
} }
else else
$dtServer::skipCount[cleanMapName($CurrentMission),%game.class]++; $dtServer::skipCount[cleanMapName($CurrentMission),%game.class]++;
if(!$dtStats::statsSave){//in case of admin skip map and it has not finished saving the old map
statsGroup.firstKill = 0; $dtStats::statsSave = 1;
if($dtStats::debugEchos){error("dtStatsGameOver");} statsGroup.firstKill = 0;
if(%game.class $= "CTFGame" || %game.class $= "SCtFGame" || %game.class $= "ArenaGame"){ if($dtStats::debugEchos){error("dtStatsGameOver2");}
statsGroup.team[1] = $teamScore[1]; if(%game.class $= "CTFGame" || %game.class $= "SCtFGame" || %game.class $= "ArenaGame"){
statsGroup.team[2] = $teamScore[2]; statsGroup.team[1] = $teamScore[1];
} statsGroup.team[2] = $teamScore[2];
%timeNext =0; }
%time = 2000; %timeNext =0;
for (%i = 0; %i < statsGroup.getCount(); %i++){// see if we have any old clients data %time = 2000;
%dtStats = statsGroup.getObject(%i); for (%i = 0; %i < statsGroup.getCount(); %i++){// see if we have any old clients data
if(%dtStats.clientLeft || !isObject(%dtStats.client)){ // find any that left during the match and %dtStats = statsGroup.getObject(%i);
%dtStats.markForDelete = 1; if(%dtStats.clientLeft || !isObject(%dtStats.client)){ // find any that left during the match and
%game.postGameStats(%dtStats); %dtStats.markForDelete = 1;
%time += $dtStats::slowSaveTime; // this will chain them %game.postGameStats(%dtStats);// note bakGame was called when they left
schedule(%time ,0,"incGameStats",%dtStats,%game.class); %time += $dtStats::slowSaveTime;
if($dtStats::mapStats){ schedule(%time ,0,"incGameStats",%dtStats,%game.class);
%time += $dtStats::slowSaveTime; // this will chain them if($dtStats::mapStats){
schedule(%time ,0,"saveMapStats",%dtStats,%game.class); %time += $dtStats::slowSaveTime;
schedule(%time ,0,"saveMapStats",%dtStats,%game.class);
}
%time += $dtStats::slowSaveTime;
schedule(%time ,0,"saveGameTotalStats",%dtStats,%game.class);
} }
%time += $dtStats::slowSaveTime; // this will chain them else if(isObject(%dtStats.client)){// make sure client is still a thing
schedule(%time ,0,"saveGameTotalStats",%dtStats,%game.class); %client = %dtStats.client;
} %client.viewMenu = %client.viewClient = %client.viewStats = 0;//reset hud
else if(isObject(%dtStats.client)){// make sure client is still a thing %client.lastPage = 1; %client.lgame = %game;
%client = %dtStats.client; bakGameStats(%client,%game.class);// copy over game type values before they reset
%client.viewMenu = %client.viewClient = %client.viewStats = 0;//reset hud %game.postGameStats(%dtStats);
%client.lastPage = 1; %client.lgame = %game;
bakGameStats(%client,%game.class);// copy over game type values before they reset
%game.postGameStats(%dtStats);
%time += $dtStats::slowSaveTime; // this will chain them
schedule(%time ,0,"incGameStats",%dtStats,%game.class); //resetDtStats after incGame
if($dtStats::mapStats){
%time += $dtStats::slowSaveTime; // this will chain them %time += $dtStats::slowSaveTime; // this will chain them
schedule(%time ,0,"saveMapStats",%dtStats,%game.class); schedule(%time ,0,"incGameStats",%dtStats,%game.class); //resetDtStats after incGame
if($dtStats::mapStats){
%time += $dtStats::slowSaveTime; // this will chain them
schedule(%time ,0,"saveMapStats",%dtStats,%game.class);
}
%time += $dtStats::slowSaveTime;
schedule(%time,0,"saveGameTotalStats",%dtStats,%game.class); //
}
else{
error("Logic issue in dtStatsGameOver" SPC %dtStats SPC %client SPC %game.class);
%dtStats.delete();
} }
%time += $dtStats::slowSaveTime;
schedule(%time,0,"saveGameTotalStats",%dtStats,%game.class); //
}
else{
error("Logic issue in dtStatsGameOver" SPC %dtStats SPC %client SPC %game.class);
%dtStats.delete();
} }
%time += $dtStats::slowSaveTime;
schedule(%time,0,"dtSaveDone");
} }
%time += $dtStats::slowSaveTime;
schedule(%time,0,"dtSaveDone");
} }
function dtSaveDone(){ function dtSaveDone(){
$dtStats::statsSave = 0; $dtStats::statsSave = 0;
@ -4043,24 +4087,27 @@ function dtSaveDone(){
// Supporting Functions // // Supporting Functions //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
function DefaultGame::postGameStats(%game,%dtStats){ //stats to add up at the end of the match function DefaultGame::postGameStats(%game,%dtStats){ //stats to add up at the end of the match
if($dtStats::debugEchos){error("postGameStats GUID = " SPC %dtStats.guid);}
if(!isObject(%dtStats)) if(!isObject(%dtStats))
return; return;
armorTimer(%dtStats, 0, 1);
%dtStats.null = getRandom(1,100); %dtStats.null = getRandom(1,100);
%dtStats.kdr = %dtStats.deaths ? (%dtStats.kills/%dtStats.deaths) : %dtStats.kills; %dtStats.kdr = %dtStats.deaths ? (%dtStats.kills/%dtStats.deaths) : %dtStats.kills;
if(statsGroup.lastKill == %dtStats)
%dtStats.lastKill = 1;
%dtStats.dtTeam = %dtStats.lastTeam;// this may need to be lastteam %dtStats.lastKill = (statsGroup.lastKill == %dtStats);
if(%dtStats.clientLeft)
%dtStats.totalTime = ((%dtStats.leftTime - %dtStats.joinTime)/1000)/60;
else
%dtStats.totalTime = ((getSimTime() - %dtStats.joinTime)/1000)/60;//convert it to min
%dtStats.matchRunTime =((getSimTime() - $missionStartTime)/60)/1000;
updateTeamTime(%dtStats,%dtStats.team); %dtStats.totalTime = (%dtStats.clientLeft == 1) ? ((%dtStats.leftTime - %dtStats.joinTime)/1000)/60 : ((getSimTime() - %dtStats.joinTime)/1000)/60;
%dtStats.gamePCT = mFloor(%game.getGamePct() - %dtStats.joinPCT); %dtStats.clientQuit = %dtStats.clientLeft == 1;
%dtStats.matchRunTime =((getSimTime() - $missionStartTime)/1000)/60;
%dtStats.startPCT = %dtStats.joinPCT;
%dtStats.endPCT = (%dtStats.clientLeft == 1) ? %dtStats.leftPCT : %game.getGamePct();
%dtStats.gamePCT = mFloor(%dtStats.endPCT - %dtStats.startPCT);
%dtStats.mapSkip = (%game.getGamePct() < 99);
//error(%dtStats.endPCT SPC %dtStats.startPCT SPC %dtStats.gamePCT SPC %dtStats.mapSkip);
%dtStats.totalMA = %dtStats.discMA + %dtStats.totalMA = %dtStats.discMA +
%dtStats.grenadeMA + %dtStats.grenadeMA +
@ -4073,7 +4120,7 @@ function DefaultGame::postGameStats(%game,%dtStats){ //stats to add up at the en
%dtStats.mineMA; %dtStats.mineMA;
%dtStats.EVKills = %dtStats.explosionKills + %dtStats.EVKills = %dtStats.explosionKills +
%dtStats.groundKills + %dtStats.groundKills +
%dtStats.outOfBoundKills + %dtStats.outOfBoundKills +
%dtStats.lavaKills + %dtStats.lavaKills +
@ -4082,7 +4129,7 @@ function DefaultGame::postGameStats(%game,%dtStats){ //stats to add up at the en
%dtStats.forceFieldPowerUpKills + %dtStats.forceFieldPowerUpKills +
%dtStats.nexusCampingKills; %dtStats.nexusCampingKills;
%dtStats.EVDeaths = %dtStats.explosionDeaths + %dtStats.EVDeaths = %dtStats.explosionDeaths +
%dtStats.groundDeaths + %dtStats.groundDeaths +
%dtStats.outOfBoundDeaths + %dtStats.outOfBoundDeaths +
%dtStats.lavaDeaths + %dtStats.lavaDeaths +
@ -4092,18 +4139,18 @@ function DefaultGame::postGameStats(%game,%dtStats){ //stats to add up at the en
%dtStats.nexusCampingDeaths; %dtStats.nexusCampingDeaths;
%dtStats.totalWepDmg = %dtStats.cgDmg + %dtStats.totalWepDmg = %dtStats.cgDmg +
%dtStats.laserDmg + %dtStats.laserDmg +
%dtStats.blasterDmg + %dtStats.blasterDmg +
%dtStats.elfDmg + %dtStats.elfDmg +
%dtStats.discDmg + %dtStats.discDmg +
%dtStats.grenadeDmg + %dtStats.grenadeDmg +
%dtStats.hGrenadeDmg + %dtStats.hGrenadeDmg +
%dtStats.mortarDmg + %dtStats.mortarDmg +
%dtStats.missileDmg + %dtStats.missileDmg +
%dtStats.plasmaDmg + %dtStats.plasmaDmg +
%dtStats.shockDmg + %dtStats.shockDmg +
%dtStats.mineDmg + %dtStats.mineDmg +
%dtStats.SatchelDmg; %dtStats.SatchelDmg;
if(%dtStats.cgShotsFired < 100) if(%dtStats.cgShotsFired < 100)
@ -4149,9 +4196,9 @@ function DefaultGame::postGameStats(%game,%dtStats){ //stats to add up at the en
if(%game.class $= "CTFGame" || %game.class $= "SCtFGame"){ if(%game.class $= "CTFGame" || %game.class $= "SCtFGame"){
%dtStats.teamScore = $TeamScore[%dtStats.team]; %dtStats.teamScore = $TeamScore[%dtStats.dtTeam];
%dtStats.destruction = %dtStats.genDestroys + %dtStats.destruction = %dtStats.genDestroys +
%dtStats.solarDestroys + %dtStats.solarDestroys +
%dtStats.sensorDestroys + %dtStats.sensorDestroys +
%dtStats.turretDestroys + %dtStats.turretDestroys +
@ -4164,7 +4211,7 @@ function DefaultGame::postGameStats(%game,%dtStats){ //stats to add up at the en
%dtStats.depStationDestroys + %dtStats.depStationDestroys +
%dtStats.mpbtstationDestroys; %dtStats.mpbtstationDestroys;
%dtStats.repairs = %dtStats.genRepairs + %dtStats.repairs = %dtStats.genRepairs +
%dtStats.SensorRepairs + %dtStats.SensorRepairs +
%dtStats.TurretRepairs + %dtStats.TurretRepairs +
%dtStats.StationRepairs + %dtStats.StationRepairs +
@ -4176,20 +4223,17 @@ function DefaultGame::postGameStats(%game,%dtStats){ //stats to add up at the en
%dtStats.depInvRepairs + %dtStats.depInvRepairs +
%dtStats.depTurretRepairs; %dtStats.depTurretRepairs;
if(%dtStats.flagGrabs > 0) %dtStats.capEfficiency = (%dtStats.flagGrabs > 0) ? (%dtStats.flagCaps / %dtStats.flagGrabs) : 0;
%dtStats.capEfficiency = %dtStats.flagCaps / %dtStats.flagGrabs;
else
%dtStats.capEfficiency = 0;
if(statsGroup.team[1] == statsGroup.team[2]){ if(statsGroup.team[1] == statsGroup.team[2]){
%dtStats.winCount = 0; %dtStats.winCount = 0;
%dtStats.lossCount = 0; %dtStats.lossCount = 0;
} }
else if(statsGroup.team[1] > statsGroup.team[2] && %dtStats.lastTeam == 1) else if(statsGroup.team[1] > statsGroup.team[2] && %dtStats.dtTeam == 1)
%dtStats.winCount = 1; %dtStats.winCount = 1;
else if(statsGroup.team[2] > statsGroup.team[1] && %dtStats.lastTeam == 2) else if(statsGroup.team[2] > statsGroup.team[1] && %dtStats.dtTeam == 2)
%dtStats.winCount = 1; %dtStats.winCount = 1;
else if(%dtStats.lastTeam > 0) else if(%dtStats.dtTeam > 0)
%dtStats.lossCount = 1; %dtStats.lossCount = 1;
%winCount = getField(%dtStats.gameStats["winCountTG","t",%game.class],5) + %dtStats.winCount; %winCount = getField(%dtStats.gameStats["winCountTG","t",%game.class],5) + %dtStats.winCount;
@ -4201,7 +4245,7 @@ function DefaultGame::postGameStats(%game,%dtStats){ //stats to add up at the en
else if(%game.class $= "LakRabbitGame") else if(%game.class $= "LakRabbitGame")
%dtStats.flagTimeMin = (%dtStats.flagTimeMS / 1000)/60; %dtStats.flagTimeMin = (%dtStats.flagTimeMS / 1000)/60;
else if(%game.class $= "ArenaGame") else if(%game.class $= "ArenaGame")
%dtStats.teamScore = $TeamScore[%dtStats.lastTeam]; %dtStats.teamScore = $TeamScore[%dtStats.dtTeam];
} }
function isGameRun(){// function isGameRun(){//
@ -4209,120 +4253,109 @@ function isGameRun(){//
} }
function DefaultGame::getGamePct(%game){ function DefaultGame::getGamePct(%game){
if(isGameRun()){ %curTimeLeftMS = ((getSimTime() - $missionStartTime)/1000)/60;
%curTimeLeftMS = mAbs((($missionStartTime - getSimTime())/60)/1000); %timePct = (%curTimeLeftMS / $Host::TimeLimit) * 100;
%timePct = (%curTimeLeftMS / $Host::TimeLimit) * 100; %timePct = (%timePct > 100) ? 100 : %timePct;
return %timePct; return %timePct;
}
return 0;
} }
function ArenaGame::getGamePct(%game){ function ArenaGame::getGamePct(%game){
if(isGameRun()){ if(%game.roundLimit != 0){
// Verify that there is a roundlimit and that the team has met it if( $TeamScore[1] >= $TeamScore[2]){
if(%game.roundLimit != 0){ %pct = ($TeamScore[1] / %game.roundLimit) * 100;
if( $TeamScore[1] >= $TeamScore[2]){ %pct = (%pct > 100) ? 100 : %pct;
return ($TeamScore[1] / %game.roundLimit) * 100; return %pct;
}
else if( $TeamScore[1] <= $TeamScore[2]){
return ($TeamScore[2] / %game.roundLimit) * 100;
}
} }
else if( $TeamScore[1] <= $TeamScore[2]){
%pct = ($TeamScore[2] / %game.roundLimit) * 100;
%pct = (%pct > 100) ? 100 : %pct;
return %pct;
}
} }
return 0; return 0;
} }
function CTFGame::getGamePct(%game){ function CTFGame::getGamePct(%game){
if(isGameRun()){ %curTimeLeftMS = ((getSimTime() - $missionStartTime)/1000)/60;
%curTimeLeftMS = mAbs((($missionStartTime - getSimTime())/60)/1000);
%timePct = (%curTimeLeftMS / $Host::TimeLimit) * 100; %timePct = (%curTimeLeftMS / $Host::TimeLimit) * 100;
%timePct = (%timePct > 100) ? 100 : %timePct;
%scoreLimit = MissionGroup.CTF_scoreLimit * %game.SCORE_PER_TEAM_FLAG_CAP; %scoreLimit = MissionGroup.CTF_scoreLimit * %game.SCORE_PER_TEAM_FLAG_CAP;
if(%scoreLimit $= "") if(%scoreLimit $= "")
%scoreLimit = 5 * %game.SCORE_PER_TEAM_FLAG_CAP; %scoreLimit = 5 * %game.SCORE_PER_TEAM_FLAG_CAP;
if($TeamScore[1] > $TeamScore[2]) if($TeamScore[1] > $TeamScore[2])
%scorePct = ($TeamScore[1] / %scoreLimit) * 100; %pct = ($TeamScore[1] / %scoreLimit) * 100;
else else
%scorePct = ($TeamScore[2] / %scoreLimit) * 100; %pct = ($TeamScore[2] / %scoreLimit) * 100;
%scorePct = (%pct > 100) ? 100 : %pct;
if(%scorePct > %timePct) if(%scorePct > %timePct)
return %scorePct; return %scorePct;
else else
return %timePct; return %timePct;
}
return 0;
} }
function LakRabbitGame::getGamePct(%game){ function LakRabbitGame::getGamePct(%game){
if(isGameRun()){ %curTimeLeftMS = ((getSimTime() - $missionStartTime)/1000)/60;
%curTimeLeftMS = mAbs((($missionStartTime - getSimTime())/60)/1000); %timePct = (%curTimeLeftMS / $Host::TimeLimit) * 100;
%timePct = (%curTimeLeftMS / $Host::TimeLimit) * 100; %timePct = (%timePct > 100) ? 100 : %timePct;
%scoreLimit = MissionGroup.Rabbit_scoreLimit;
%scoreLimit = MissionGroup.Rabbit_scoreLimit; if(%scoreLimit $= "")
if(%scoreLimit $= "") %scoreLimit = 2000;
%scoreLimit = 2000; %lScore = 0;
for (%i = 0; %i < ClientGroup.getCount(); %i++){
for (%i = 0; %i < ClientGroup.getCount(); %i++){ %client = ClientGroup.getObject(%i);
%client = ClientGroup.getObject(%i); if(%lScore < %client.score){
if(%lScore < %client.score){ %lScore = %client.score;
%lScore = %client.score;
}
} }
%scorePct = (%lScore / %scoreLimit) * 100;
if(%scorePct > %timePct)
return %scorePct;
else
return %timePct;
} }
return 0; %pct = (%lScore / %scoreLimit) * 100;
%scorePct = (%pct > 100) ? 100 : %pct;
if(%scorePct > %timePct)
return %scorePct;
else
return %timePct;
} }
function DMGame::getGamePct(%game){ function DMGame::getGamePct(%game){
if(isGameRun()){ %curTimeLeftMS = ((getSimTime() - $missionStartTime)/1000)/60;
%curTimeLeftMS = mAbs((($missionStartTime - getSimTime())/60)/1000); %timePct = (%curTimeLeftMS / $Host::TimeLimit) * 100;
%timePct = (%curTimeLeftMS / $Host::TimeLimit) * 100; %timePct = (%timePct > 100) ? 100 : %timePct;
%scoreLimit = MissionGroup.DM_scoreLimit;
if(%scoreLimit $= "")
%scoreLimit = 25;
%scoreLimit = MissionGroup.DM_scoreLimit; for (%i = 0; %i < ClientGroup.getCount(); %i++){
if(%scoreLimit $= "") %client = ClientGroup.getObject(%i);
%scoreLimit = 25; if(%lScore < %client.score){
%lScore = %client.score;
for (%i = 0; %i < ClientGroup.getCount(); %i++){
%client = ClientGroup.getObject(%i);
if(%lScore < %client.score){
%lScore = %client.score;
}
} }
%scorePct = (%lScore / %scoreLimit) * 100;
if(%scorePct > %timePct)
return %scorePct;
else
return %timePct;
} }
return 0; %pct = (%lScore / %scoreLimit) * 100;
%scorePct = (%pct > 100) ? 100 : %pct;
if(%scorePct > %timePct)
return %scorePct;
else
return %timePct;
} }
function SCtFGame::getGamePct(%game){ function SCtFGame::getGamePct(%game){
if(isGameRun()){ %curTimeLeftMS = ((getSimTime() - $missionStartTime)/1000)/60;
%curTimeLeftMS = mAbs((($missionStartTime - getSimTime())/60)/1000); %timePct = (%curTimeLeftMS / $Host::TimeLimit) * 100;
%timePct = (%curTimeLeftMS / $Host::TimeLimit) * 100; %timePct = (%timePct > 100) ? 100 : %timePct;
%scoreLimit = MissionGroup.CTF_scoreLimit * %game.SCORE_PER_TEAM_FLAG_CAP;
if(%scoreLimit $= "")
%scoreLimit = 5 * %game.SCORE_PER_TEAM_FLAG_CAP;
%scoreLimit = MissionGroup.CTF_scoreLimit * %game.SCORE_PER_TEAM_FLAG_CAP; if($TeamScore[1] > $TeamScore[2])
if(%scoreLimit $= "") %pct = ($TeamScore[1] / %scoreLimit) * 100;
%scoreLimit = 5 * %game.SCORE_PER_TEAM_FLAG_CAP; else
%pct = ($TeamScore[2] / %scoreLimit) * 100;
if($TeamScore[1] > $TeamScore[2]) %scorePct = (%pct > 100) ? 100 : %pct;
%scorePct = ($TeamScore[1] / %scoreLimit) * 100; if(%scorePct > %timePct)
else return %scorePct;
%scorePct = ($TeamScore[2] / %scoreLimit) * 100; else
return %timePct;
if(%scorePct > %timePct)
return %scorePct;
else
return %timePct;
}
} }
function msToMinSec(%time) function msToMinSec(%time)
{ {
@ -5126,10 +5159,9 @@ function hasValue(%val){//make sure we have at least something in the field spot
function bakGameStats(%client,%game) {//back up clients current stats in case they come back function bakGameStats(%client,%game) {//back up clients current stats in case they come back
if($dtStats::debugEchos){error("bakGameStats GUID = " SPC %client.guid);} if($dtStats::debugEchos){error("bakGameStats GUID = " SPC %client.guid);}
%dtStats = %client.dtStats; %dtStats = %client.dtStats;
%dtStats.lastTeam = (%client.team == 0) ? %client.lastTeam : %client.team;// in case we jump to observer at the end of the game %dtStats.dtTeam = %client.team;
if(!%dtStats.lastTeam)// does not always get set updateTeamTime(%client.dtStats, %dtStats.team);
%dtStats.lastTeam = 0; armorTimer(%dtStats, 0, 1);
for(%v = 0; %v < $dtStats::varTypeCount; %v++){ for(%v = 0; %v < $dtStats::varTypeCount; %v++){
%varType = $dtStats::varType[%v]; %varType = $dtStats::varType[%v];
for(%i = 1; %i <= $dtStats::FCG[%game,%varType]; %i++){ for(%i = 1; %i <= $dtStats::FCG[%game,%varType]; %i++){
@ -12926,3 +12958,12 @@ function testVarsRandomAll(%max){
// Misc Stat fixes // Misc Stat fixes
// Speed up file delete time // Speed up file delete time
// Removed loadslow in favor for loadafter, less edge cases // Removed loadslow in favor for loadafter, less edge cases
//
// 9.0
// Misc Stat Fixes
// Reverted team changes and removed some of the inconsistencies with team tracking
// Added flag capture times
// Capped gamepct do to timeing/score it can go over 100
// Added startPCt and endPct for game progress info
// Added clientQuit to make filtering easier
// Some code cleanup