View Single Post
04-29-16, 11:23 PM   #30
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by galvin View Post
Didn't even think to do this instead.
Blizzard uses UnitCastingInfo() in their code with cast bars. Unless I'm missing something.

So just do SpellID = select(10, UnitCastingInfo(Unit)) or
_, _, _, _, _, _, _, _, _, SpellID = UnitCastingInfo(Unit)

This should produce zero garbage.

I tested it and gave back the spell id at the start and end of a cast.

This works on a UNIT_SPELLCAST_SUCCEEDED event. Not sure if lag would cause UnitCastingInfo() to return no info.

EDIT: Not reilable on a UNIT_SPELLCAST_SUCCEEDED sometimes UnitCastingInfo() for spellID returns nil.

Could do this not sure if it uses less memory or not

Code:
-- Set events for UNIT_SPELLCAST_START and SUCCEEDED here.

function SpellCasting(Event, Unit, Name, Rank, CastID)
  if Event == 'UNIT_SPELLCAST_START' then
    local _, _, _, _, _, _, _, _, _, SpellID = UnitCastingInfo(Unit)
    LastSpell[CastID] = SpellID
  else
    SpellID = LastSpell[CastID]
  end

  print('>>', Event, SpellID)
end
There are a lot of other cast related event types, when castinginfo return nil, or just simply not reliable. Thats when you need to get access fro the spellid and the lineid from the event itself.

The main issue i see is that every player runs with a long macros filled with multiple spells and spam them while in combat:

/cast Avatar
/cast Bloodbath
/cast Bladestorm

Only one will trigger a spell every other line will generate a "UNIT_SPELLCAST_FAILED" event, any you need to listen this event for your castbar, and thats where the parsing the string six billion times uncessessary will be so bad. When a 40 man raid (and their pets) spamming their 255 long macros filled with their spellbook.

And the "UNIT_SPELLCAST_FAILED" is just one example from the many cast related spells.

Last edited by Resike : 04-29-16 at 11:25 PM.