Hello fellow developers!
I've been working on an addon for WoW Classic and currently hit a little bump.
I'm using the
COMBAT_LOG_EVENT_UNFILTERED event to get information regarding spells being cast by certain players, their target and so on. I researched that the API requires you to use the
CombatLogGetCurrentEventInfo() method to retrieve the event info like so:
Lua Code:
local timestamp, eventType, _, sourceGUID, sourceName, _, _, destGUID, destName, _, _, spellId, spellName, spellSchool = CombatLogGetCurrentEventInfo()
But in Classic I don't get the spellId (Correction: I do get a spellId but it's always 0). However, I get every other combat log detail. The code works like intended on the retail version of WoW (See the full code below), but not in the Classic release. I know theres been changes to the WoW API to restrict certain methods and functionality. However, I've been unable to find any documentation regarding changing how the
COMBAT_LOG_EVENT_UNFILTERED event and
CombatLogGetCurrentEventInfo method functions. So I must be doing something wrong regarding how the API works with Classic? (Compared to retail)
Here's the full code:
Lua Code:
local spells = {
SPELL_AURA_APPLIED = {
[19742] = 300, -- Rank 1 Blessing of Wisdom
[19850] = 300, -- Rank 2 Blessing of Wisdom
[19852] = 300, -- Rank 3 Blessing of Wisdom
[19853] = 300, -- Rank 4 Blessing of Wisdom
[19854] = 300, -- Rank 5 Blessing of Wisdom
[25290] = 300, -- Rank 6 Blessing of Wisdom
[19740] = 300, -- Rank 1 Blessing of Might
[19834] = 300, -- Rank 2 Blessing of Might
[19835] = 300, -- Rank 3 Blessing of Might
[19836] = 300, -- Rank 4 Blessing of Might
[19837] = 300, -- Rank 5 Blessing of Might
[19838] = 300, -- Rank 6 Blessing of Might
[25291] = 300, -- Rank 7 Blessing of Might
},
}
local function eventHandler(self, event, ...)
if event == 'COMBAT_LOG_EVENT_UNFILTERED' then
local timestamp, eventType, _, sourceGUID, sourceName, _, _, destGUID, destName, _, _, spellId, spellName, spellSchool = CombatLogGetCurrentEventInfo()
-- Debug the combat log event
print('Player ' .. sourceName .. ' casted ' .. spellName .. ' (id: ' .. spellId .. ', school: ' .. spellSchool .. ') on ' .. destName .. ' triggered by ' .. eventType)
if spells[eventType] and spells[eventType][spellId] and sourceGUID == UnitGUID('player') then
print('Success!')
-- Handle Aura buff
end
end
end
local eventFrame = CreateFrame('Frame')
eventFrame:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
eventFrame:SetScript('OnEvent', eventHandler)
So if anyone could help me out with my mistakes or point me in the direction of some useful documentation or examples, I would be really grateful!
- SnaBe