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)