Thread Tools Display Modes
09-16-19, 05:35 AM   #1
SnaBe
A Kobold Labourer
 
SnaBe's Avatar
Join Date: Sep 2019
Posts: 1
Exclamation Getting spellId from CombatLogGetCurrentEventInfo in WoW Classic

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:
  1. 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:
  1. local spells = {
  2.     SPELL_AURA_APPLIED = {
  3.         [19742] = 300, -- Rank 1 Blessing of Wisdom
  4.         [19850] = 300, -- Rank 2 Blessing of Wisdom
  5.         [19852] = 300, -- Rank 3 Blessing of Wisdom
  6.         [19853] = 300, -- Rank 4 Blessing of Wisdom
  7.         [19854] = 300, -- Rank 5 Blessing of Wisdom
  8.         [25290] = 300, -- Rank 6 Blessing of Wisdom
  9.         [19740] = 300, -- Rank 1 Blessing of Might
  10.         [19834] = 300, -- Rank 2 Blessing of Might
  11.         [19835] = 300, -- Rank 3 Blessing of Might
  12.         [19836] = 300, -- Rank 4 Blessing of Might
  13.         [19837] = 300, -- Rank 5 Blessing of Might
  14.         [19838] = 300, -- Rank 6 Blessing of Might  
  15.         [25291] = 300, -- Rank 7 Blessing of Might  
  16.     },
  17. }
  18.  
  19. local function eventHandler(self, event, ...)
  20.     if event == 'COMBAT_LOG_EVENT_UNFILTERED' then
  21.         local timestamp, eventType, _, sourceGUID, sourceName, _, _, destGUID, destName, _, _, spellId, spellName, spellSchool = CombatLogGetCurrentEventInfo()
  22.         -- Debug the combat log event
  23.         print('Player ' .. sourceName .. ' casted ' .. spellName .. ' (id: ' .. spellId .. ', school: ' .. spellSchool .. ') on ' .. destName .. ' triggered by ' .. eventType)
  24.        
  25.         if spells[eventType] and spells[eventType][spellId] and sourceGUID == UnitGUID('player') then
  26.             print('Success!')
  27.             -- Handle Aura buff
  28.         end
  29.     end
  30. end
  31.  
  32. local eventFrame = CreateFrame('Frame')
  33.  
  34. eventFrame:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
  35.  
  36. 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

Last edited by SnaBe : 09-16-19 at 07:23 AM. Reason: Correction
  Reply With Quote
09-16-19, 05:58 AM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Without looking at your code, I can personally tell you that classic's combat event is either currently bugged or specifically not showing spell IDs at all. I've had a personal code snippit for quite some time that emotes when I interrupt and links the interrupted spell. I thought it was just GetSpellLink not working (which currently doesn't link anyways) but the argument in the interrupt payload that gives the interrupted spell ID is 0, along with the casted spell ID also being 0.

You're going to have to match spell names and localize if it's for a public addon.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Getting spellId from CombatLogGetCurrentEventInfo in WoW Classic

Thread Tools
Display Modes

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