The the unfiltered combatlog event, I'm looking for the SPELL_DAMAGE event and SPELL_ENERGIZE event. Problem is sometimes the damage event happens before the energize event or vice versa. Problem is I need to get the damage event first then energize second. I have no idea how to work around this problem.
Is there something I can do to force events to happen in the correct order?
This is the basic concept (dry coded), you could implement it a million different ways depending on the needs:
local _cache = {}
local function cleu_handler(...)
if event == SPELL_DAMAGE or event == SPELL_ENERGIZE then
local cache = _cache[sourceName]
if cache then
if cache == SPELL_DAMAGE and event == SPELL_ENERGIZE then
--SPELL_ENERGIZE after SPELL_DAMAGE
_cache[sourceName] = nil
elseif cache == SPELL_ENERGIZE and event == SPELL_DAMAGE then
--SPELL_DAMAGE after SPELL_ENERGIZE
_cache[sourceName] = nil
else
--you probably got two of the same event in a row
end
else
_cache[sourceName] = event
end
else
--some other event, may need to remove cache depending on logic
_cache[sourceName] = nil
end
end
The logic regarding when to clear the last cache value, or for how long to keep it is entirely dependent on what you're trying to accomplish and how the events come in.
Is there something I can do to force events to happen in the correct order?
Nope.
Take a look at this thread though, different problem, but same technique can be employed:
http://forums.wowace.com/showthread.php?t=19559
This is the basic concept (dry coded), you could implement it a million different ways depending on the needs:
The logic regarding when to clear the last cache value, or for how long to keep it is entirely dependent on what you're trying to accomplish and how the events come in.