PanicModeCombatAnalyzer = PanicModeCombatAnalyzer or {} PanicModeCombatAnalyzer.name = 'PanicModeCombatAnalyzer' PanicModeCombatAnalyzer.version = '1.0.1' PanicModeCombatAnalyzer.versionDB = 1 PanicModeCombatAnalyzer.loaded = false PanicModeCombatAnalyzer.author = 'silentgecko, deevilius' PanicModeCombatAnalyzer.savedVarsName = 'PMCAVars' PanicModeCombatAnalyzer.variables = { fights = {} } PanicModeCombatAnalyzer.tempVars = { lastSave = 0, inFight = false, lastDps = 0, lastDpsCount = 0, } -- grab ftc from global FTC = _G['FTC'] ---------Passing saved variables to the labels at initialize------- function PanicModeCombatAnalyzer.Initialize(event, addonName) local self = PanicModeCombatAnalyzer if addonName ~= self.name then return end EVENT_MANAGER:UnregisterForEvent(self.name, EVENT_ADD_ON_LOADED) self.savedVariables = ZO_SavedVars:New(self.savedVarsName, self.versionDB, nil, self.variables) EVENT_MANAGER:RegisterForEvent(self.name, EVENT_PLAYER_COMBAT_STATE, self.OnPlayerCombatState) end function PanicModeCombatAnalyzer.OnPlayerCombatState(event, inCombat) PanicModeCombatAnalyzer.tempVars.inFight = inCombat end --[[ * Overwrite from origin FTC * Update the mini DPS meter * -------------------------------- * Called by FTC.Stats:Initialize() * -------------------------------- ]]-- function FTC.Stats:Update() local self = PanicModeCombatAnalyzer -- Bail out if there is no damage to report if ( FTC.Stats.damage == 0 and FTC.Stats.healing == 0 ) then return end -- Retrieve data local mini = _G["FTC_MiniMeter"] -- Compute the fight time local time = ( FTC.Stats.endTime - FTC.Stats.startTime ) / 1000 -- Determine the correct time label local dtime = (( not IsUnitInCombat('player') ) or ((( GetGameTimeMilliseconds() - FTC.Stats.endTime ) / 1000 ) >= FTC.Vars.DamageTimeout )) and time or ( GetGameTimeMilliseconds() - FTC.Stats.startTime ) / 1000 local secs = ZO_FormatTime( dtime , SI_TIME_FORMAT_TIMESTAMP) -- Compute player statistics local dps = FTC.DisplayNumber( FTC.Stats.damage / math.max(time,1) ) local hps = FTC.DisplayNumber( FTC.Stats.healing / math.max(time,1) ) -- added saving vars local lastSave = self.tempVars.lastSave local currentTime = GetGameTimeMilliseconds() local timeStamp = GetTimeStamp() local lastSaveDiff = currentTime - lastSave local currenTarget = GetUnitName('reticleover') local dpsForSaving = (FTC.Stats.damage / math.max(time,1)) if self.tempVars.lastDps == dpsForSaving then self.tempVars.lastDpsCount = self.tempVars.lastDpsCount+1 else self.tempVars.lastDpsCount = 0 end self.tempVars.lastDps = dpsForSaving -- only save if we don't get three times the same amount of dps, and lastSavediff is more than one second ago and we're in fight if self.tempVars.lastDpsCount <= 2 and lastSaveDiff >= 1000 and self.tempVars.inFight then self.tempVars.lastSave = currentTime self.savedVariables.fights[currenTarget] = { time = timeStamp, dps = dpsForSaving } self.debug('saved dps', dps) end -- Update the labels mini.damage.label:SetText( dps ) mini.healing.label:SetText( hps ) mini.time.label:SetText( secs ) end -- debug func function PanicModeCombatAnalyzer.debug(message, data) d('PM CA Debug:') d(message, data) end ---------Events------- EVENT_MANAGER:RegisterForEvent(PanicModeCombatAnalyzer.name, EVENT_ADD_ON_LOADED, PanicModeCombatAnalyzer.Initialize)