WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Getting spellId from CombatLogGetCurrentEventInfo in WoW Classic (https://www.wowinterface.com/forums/showthread.php?t=57499)

SnaBe 09-16-19 05:35 AM

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

Kanegasi 09-16-19 05:58 AM

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.


All times are GMT -6. The time now is 06:39 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI