Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CHC = {}
- local isDebug = true
- local rawChainHealData = {
- totalCasts = 0,
- history = {
- targets = 0,
- multistrikes = 0,
- data = {
- }
- }
- }
- -- Utility functions
- local print = function (msg)
- if isDebug == true then
- DEFAULT_CHAT_FRAME:AddMessage(msg)
- end
- end
- -- Register Frame
- function CHC:registerFrame()
- local CHCatcher_EventFrame = CreateFrame("Frame")
- CHC:setEventHandlers(CHCatcher_EventFrame)
- end
- -- Register Events
- function CHC:setEventHandlers(Catcher)
- print("EventListener activated")
- Catcher:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
- Catcher:RegisterEvent("COMBAT_LOG_EVENT")
- CHC:handleEvents(Catcher)
- end
- function CHC:handleEvents(Catcher)
- Catcher:SetScript("OnEvent", function(self, event, ...)
- if event == "UNIT_SPELLCAST_SUCCEEDED" then
- CHC:spellCast_Succeeded(...)
- elseif event == "COMBAT_LOG_EVENT" then
- CHC:filterTheCombatLog(...)
- end
- end)
- end
- function CHC:spellCast_Succeeded(...)
- local unitID, spell, rank, lineID, spellID = select(1, ...)
- -- Only do stuff on chain heal casts that succeed
- if spellId == 1064 or spell == "Chain Heal" then
- print("Finished casting " .. spell)
- end
- end
- function CHC:filterTheCombatLog(...)
- local type = select(2, ...)
- -- Check if combat log event is a heal
- if type == "SPELL_HEAL" then
- local spellId, spellName, spellSchool = select(12, ...)
- -- If the heal event matches chain heal and all that.
- if spellId == 1064 or spellName == "Chain Heal" then
- -- Check if the heal was a multistrike
- -- Save those separately
- if select(19, ...) == true then
- rawChainHealData.history.multistrikes = rawChainHealData.history.multistrikes + 1
- print("Multistrike #" .. rawChainHealData.history.multistrikes)
- else
- rawChainHealData.history.targets = rawChainHealData.history.targets + 1
- print("Hit #" .. rawChainHealData.history.targets .. " at " .. select(1, ...))
- end
- -- Save some of the data for later use.
- local spellData = {
- timestamp = select(1, ...),
- target = select(9, ...),
- source = select(5, ...),
- amount = select(15, ...),
- overhealing = select(16, ...),
- multistrike = select(19, ...)
- }
- table.insert(rawChainHealData.history.data, spellData)
- end
- end
- end
- CHC:registerFrame()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement