Hi all,
Yeah... it's me again
For this time, I am trying to make an addon that tracks player's spell usage and here is what I have got so far.
Lua Code:
local SkillFlow = CreateFrame("Frame");
SkillFlow:RegisterEvent("PLAYER_REGEN_ENABLED");
SkillFlow:RegisterEvent("PLAYER_REGEN_DISABLED");
SkillFlow:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
SkillFlow.regenEnabled = true;
SkillFlow.queue = {};
SkillFlow.queueSize = 10;
function SkillFlow:PLAYER_REGEN_ENABLED()
self.regenEnabled = true;
end
function SkillFlow:PLAYER_REGEN_DISABLED()
self.regenEnabled = false;
end
function SkillFlow:OnEvent(event, ...)
self[event](self, event, ...);
end
function SkillFlow:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
local _, subEvent, _, sourceGUID, _, _, _, _, _, _, _ = ...;
if sourceGUID == UnitGUID("player") then
if subEvent == "SPELL_CAST_SUCCESS" and not self.regenEnabled then
local spellName = select(13, ...);
if #self.queue < self.queueSize then
table.insert(self.queue, spellName);
else
for i = 1, #self.queue - 1 do
self.queue[i] = self.queue[i + 1];
end
self.queue[self.queueSize] = spellName;
end
-- DUBUGGING ----------------------------------------
print("\n======== Skill Flow ========");
for i = 1, #self.queue do
print(string.format("%d: %s", i, self.queue[i]));
end
print("============================");
-----------------------------------------------------
end
end
end
SkillFlow:SetScript("OnEvent", SkillFlow.OnEvent);
There are basically two main problems that I am concerned:
1. The first spell fired before the combat won't be tracked and I know that is because of this line:
Code:
if type == "SPELL_CAST_SUCCESS" and not self.regenEnabled then
However, if I get rid of
not self.regenEnabled, it even tracks for spell-casts done during non-combat situation.
2. Also tracks for spells fired via ExtraActionButton and so on. Since I am expecting to track player's spell only, I would like these kind of spells to be ignored.
In my personal opinion, COMBAT_LOG_EVENT (not COMBAT_LOG_EVENT_UNFILTERED) would do some job here, but I can't find further references regarding this.
(COMBAT_LOG_EVENT info page on wowwiki doesn't seem to cover this as well
)
Any suggestions, please?
Thank you!