Thread Tools Display Modes
05-01-23, 09:47 AM   #1
maciekish
A Murloc Raider
Join Date: May 2023
Posts: 4
COMBAT_LOG_EVENT_UNFILTERED Event Args empty

Hi, I'm trying to reimplement Critline for WOTLK Classic (3.4.1) but the event args are empty. When i hit something i just see the text "Event Args:". Any ideas please? Never made an addon before but worked with objc & Swift.

Even if i try to get the sourceGUID specifically, it prints nil.

Code:
f:SetScript("OnEvent", function(self, event, arg1, arg2, arg3, arg4, ...)
  print("Event Args:", arg4)
Code:
-- Define a table to hold the highest hits data.
CritlineClassicData = CritlineClassicData or {}

-- Modify the OnTooltipSetSpell() function to add the highest hits data to the spell tooltip.
local function OnTooltipSetSpell(tooltip, ...)
  local spellName, spellRank, spellID = tooltip:GetSpell()
  if CritlineClassicData[spellName] then
    tooltip:AddLine("Highest Crit: " .. CritlineClassicData[spellName].highestCrit)
    tooltip:AddLine("Highest Normal: " .. CritlineClassicData[spellName].highestNormal)
    print("Tooltip data added for " .. spellName)
  end
end

-- 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, ...)
  print("Event Args:", ...)

  -- Get information about the combat event.
  local timestamp, eventType, _, sourceGUID, _, _, _, destGUID, _, _, _, spellID, _, _, amount, overkill, _, _, _, _, critical = ...

  -- Check if the event is a player hit and update the highest hits data if needed.
  if sourceGUID == UnitGUID("player") and destGUID ~= UnitGUID("player") and (eventType == "SPELL_DAMAGE" or eventType == "SWING_DAMAGE" or eventType == "RANGE_DAMAGE") and amount > 0 then
    local spellName, _, spellIcon = GetSpellInfo(spellID)
    if spellName then
      CritlineClassicData[spellName] = CritlineClassicData[spellName] or {
        highestCrit = 0,
        highestNormal = 0,
        spellIcon = spellIcon,
      }
      if critical then
        if amount > CritlineClassicData[spellName].highestCrit then
          CritlineClassicData[spellName].highestCrit = amount
          print("New highest crit hit for " .. spellName .. ": " .. CritlineClassicData[spellName].highestCrit)
        end
      else
        if amount > CritlineClassicData[spellName].highestNormal then
          CritlineClassicData[spellName].highestNormal = amount
          print("New highest normal hit for " .. spellName .. ": " .. CritlineClassicData[spellName].highestNormal)
        end
      end
    end
  end
end)

-- Register an event that fires when the addon is loaded.
local function OnLoad(self, event, ...)
  print("Critline Classic Loaded!")
  
  -- Print the highest hits data to the chat frame.
  for spellName, spellData in pairs(CritlineClassicData) do
    print(spellName .. " highest crit hit: " .. spellData.highestCrit)
    print(spellName .. " highest normal hit: " .. spellData.highestNormal)
  end
  
  -- Add the highest hits data to the spell button tooltip.
  GameTooltip:HookScript("OnTooltipSetSpell", OnTooltipSetSpell)
end
local frame = CreateFrame("FRAME")
frame:RegisterEvent("ADDON_LOADED")
frame:SetScript("OnEvent", OnLoad)

-- Register an event that fires when the player logs out or exits the game.
local function OnSave(self, event, ...)
  -- Save the highest hits data to the saved variables for the addon.
  _G["CritlineClassicData"] = CritlineClassicData
end
local frame = CreateFrame("FRAME")
frame:RegisterEvent("PLAYER_LOGOUT")
frame:SetScript("OnEvent", OnSave)
  Reply With Quote
05-01-23, 11:22 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
Rather than receiving the payload directly for the event you now have to call CombatLogGetCurrentEventInfo()

For Combat Event Info
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
05-01-23, 12:30 PM   #3
maciekish
A Murloc Raider
Join Date: May 2023
Posts: 4
Originally Posted by Fizzlemizz View Post
Rather than receiving the payload directly for the event you now have to call CombatLogGetCurrentEventInfo()

For Combat Event Info
That did the trick, thank you!
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » COMBAT_LOG_EVENT_UNFILTERED Event Args empty


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off