Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function(event,time,type,_,sourceGUID,sourcename,_,_,destGUID,destname,_,_,spellid,spellname,_,_,_,_,_,_,_,spellcritical,_,_,_,spellmultistrike)
- local CurrentTime = GetTime();
- WA_SA_NUM_UNITS = WA_SA_NUM_UNITS or 0;
- WA_SA_TOTAL = WA_SA_TOTAL or 0;
- -- Stats buffer
- WA_SA_STATS = WA_SA_STATS or {};
- WA_SA_DEAD = WA_SA_DEAD or {};
- WA_LAST_CONTINUITY_CHECK = WA_LAST_CONTINUITY_CHECK or GetTime();
- WA_SA_Cleanup = WA_SA_Cleanup or function(guid)
- if WA_SA_STATS[guid] then
- WA_SA_TOTAL = WA_SA_TOTAL - WA_SA_STATS[guid].Count;
- if WA_SA_TOTAL < 0 then
- WA_SA_TOTAL = 0;
- end
- WA_SA_STATS[guid].Count = nil;
- WA_SA_STATS[guid].LastUpdate = nil;
- WA_SA_STATS[guid] = nil;
- WA_SA_NUM_UNITS = WA_SA_NUM_UNITS - 1;
- if WA_SA_NUM_UNITS < 0 then
- WA_SA_NUM_UNITS = 0;
- end
- end
- end
- if event == "COMBAT_LOG_EVENT_UNFILTERED" and sourceGUID == UnitGUID("player") then
- if spellid == 147193 and type == "SPELL_CAST_SUCCESS" then -- Shadowy Apparition Spawned
- if not WA_SA_STATS[destGUID] or WA_SA_STATS[destGUID] == nil then
- WA_SA_STATS[destGUID] = {};
- WA_SA_STATS[destGUID].Count = 0;
- WA_SA_NUM_UNITS = WA_SA_NUM_UNITS + 1;
- end
- WA_SA_TOTAL = WA_SA_TOTAL + 1;
- WA_SA_STATS[destGUID].Count = WA_SA_STATS[destGUID].Count + 1;
- WA_SA_STATS[destGUID].LastUpdate = CurrentTime;
- elseif spellid == 148859 and type == "SPELL_DAMAGE" then --Auspicious Spirit Hit
- WA_SA_TOTAL = WA_SA_TOTAL - 1;
- if WA_SA_STATS[destGUID] and WA_SA_STATS[destGUID].Count > 0 then
- WA_SA_STATS[destGUID].Count = WA_SA_STATS[destGUID].Count - 1;
- WA_SA_STATS[destGUID].LastUpdate = CurrentTime;
- if WA_SA_STATS[destGUID].Count <= 0 then
- WA_SA_Cleanup(destGUID);
- end
- end
- end
- end
- if WA_SA_TOTAL < 0 then
- WA_SA_TOTAL = 0;
- end
- for guid,count in pairs(WA_SA_STATS) do
- if (CurrentTime - WA_SA_STATS[guid].LastUpdate) > 10 then
- --If we haven't had a new SA spawn in 10sec, that means all SAs that are out have hit the target (usually), or, the target disappeared.
- WA_SA_Cleanup(guid);
- end
- end
- if event == "COMBAT_LOG_EVENT_UNFILTERED" and (type == "UNIT_DIED" or type == "UNIT_DESTROYED" or type == "SPELL_INSTAKILL") then -- Unit Died, remove them from the target list.
- WA_SA_Cleanup(destGUID);
- end
- if UnitIsDeadOrGhost("player") or not UnitAffectingCombat("player") or event == "PLAYER_REGEN_ENABLED" then -- We died, or, exited combat, go ahead and purge the list
- for guid,count in pairs(WA_SA_STATS) do
- WA_SA_Cleanup(guid);
- end
- WA_SA_STATS = {};
- WA_SA_NUM_UNITS = 0;
- WA_SA_TOTAL = 0;
- end
- if CurrentTime - WA_LAST_CONTINUITY_CHECK > 10 then --Force check of unit count every 10sec
- local newUnits = 0;
- for guid,count in pairs(WA_SA_STATS) do
- newUnits = newUnits + 1;
- end
- WA_SA_NUM_UNITS = newUnits;
- WA_LAST_CONTINUITY_CHECK = CurrentTime;
- end
- if WA_SA_NUM_UNITS > 0 then
- local totalSAs = 0;
- for guid,count in pairs(WA_SA_STATS) do
- if WA_SA_STATS[guid].Count <= 0 or (UnitIsDeadOrGhost(guid)) then
- WA_SA_DEAD[guid] = true;
- else
- totalSAs = totalSAs + WA_SA_STATS[guid].Count;
- end
- end
- if totalSAs > 0 and WA_SA_TOTAL > 0 then
- return true;
- end
- end
- return false;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement