View Single Post
07-28-23, 10:21 AM   #4
Infinite-Loop-Alchemist
A Murloc Raider
 
Infinite-Loop-Alchemist's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2023
Posts: 7
Originally Posted by Fizzlemizz View Post
You have critical as return 18 from CombatLogGetCurrentEventInfo() which would work for SWING_DAMAGE. WoWPedia says it should be 21 for SPELL_DAMAGE.

There's a side by side comparison table of return for SWING_DAMAGE and SPELL_DAMAGE on that page.
Am I doing this right?
Code:
-- Register an event that fires when the player hits an enemy.
local f = CreateFrame("FRAME")
f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
f:SetScript("OnEvent", function(self, event)

  -- Get information about the combat event.
  local eventInfo = {CombatLogGetCurrentEventInfo()}

  local timestamp, eventType, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = unpack(eventInfo, 1, 11)
  local spellID, spellName, spellSchool, amount, overhealing, absorbed, critical

  if eventType == "SWING_DAMAGE" then
    spellName = "Auto Attack"
    spellID = 6603 -- or specify the path to a melee icon, if you have one
    amount, _, _, _, _, _, critical = unpack(eventInfo, 12, 18)
  else
    spellID, spellName, spellSchool = unpack(eventInfo, 12, 14)
    amount, overhealing, absorbed, critical = unpack(eventInfo, 15, 21)
  end

  if sourceGUID == UnitGUID("player") and destGUID ~= UnitGUID("player") and amount > 0 then
    if spellName then
      CritMaticData[spellName] = CritMaticData[spellName] or {
        highestCrit = 0,
        highestNormal = 0,
        highestHeal = 0,
        highestHealCrit = 0,
        spellIcon = GetSpellTexture(spellID)
      }

      print(CombatLogGetCurrentEventInfo())

      if critical then
        if eventType == "SPELL_HEAL" or eventType == "SPELL_PERIODIC_HEAL" then
          if amount > CritMaticData[spellName].highestHealCrit then
            if spellName == "Auto Attack" then
              return
            end
            CritMaticData[spellName].highestHealCrit = amount
            PlaySound(888, "SFX")
            CritMatic.ShowNewHealCritMessage(spellName, amount)
            print("New highest crit heal for " .. spellName .. ": " .. CritMaticData[spellName].highestHealCrit)
          end
        else
          if amount > CritMaticData[spellName].highestCrit then
            if spellName == "Auto Attack" then
              return
            end
            CritMaticData[spellName].highestCrit = amount
            PlaySound(888, "SFX")
            CritMatic.ShowNewCritMessage(spellName, amount)
            print("New highest crit hit for " .. spellName .. ": " .. CritMaticData[spellName].highestCrit)
          end
        end
      elseif not critical then
        if eventType == "SPELL_HEAL" or eventType == "SPELL_PERIODIC_HEAL" then
          if amount > CritMaticData[spellName].highestHeal then
            if spellName == "Auto Attack" then
              return
            end
            CritMaticData[spellName].highestHeal = amount
            PlaySound(10049, "SFX")
            CritMatic.ShowNewHealMessage(spellName, amount)
            print("New highest normal heal for " .. spellName .. ": " .. CritMaticData[spellName].highestHeal)
          end
        else
          if amount > CritMaticData[spellName].highestNormal then
            if spellName == "Auto Attack" then
              return
            end
            CritMaticData[spellName].highestNormal = amount
            PlaySound(10049, "SFX")
            CritMatic.ShowNewNormalMessage(spellName, amount)
            print("New highest normal hit for " .. spellName .. ": " .. CritMaticData[spellName].highestNormal)
          end
        end
      end
    end
  end
heals crits work and heal normals work but spell normals work but not crits.
  Reply With Quote