-
Posted by gates on Thu, 23 Jan 2014 07:15:22
I've been working on an addon to track when a Unit will fall out of combat in PvP. An Icon is shown when each Unit is in combat and a Cooldown frame overlay to represent the time remaining before the Unit exits combat. I am having trouble with Lag and Accuracy also some Lua Errors with few spells eg.(Shadow Word: Death).
`--[[Addon to Track combat of any unit in PvP Gates - Axium-WoW.com]] -- LoadAddOn("Blizzard_ArenaUI")
local function cooldownFrame(f, unitFrameType, unitNum, cd, x, y, size)
if unitNum ~= nil then f:SetPoint("LEFT", unitFrameType..unitNum, "RIGHT", x, y) elseif unitNum == nil then f:SetPoint("LEFT", unitFrameType, "RIGHT", x, y) end f:SetSize(size,size) f.c = CreateFrame("Cooldown", cd) f.c:SetAllPoints(f) f.t = f:CreateTexture(nil, "Border") f.t:SetAllPoints() f.t:SetTexture("Interface\\Icons\\ABILITY_DUALWIELD") f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end
local function timer(f, cd)
f:Show(); CooldownFrame_SetTimer( cd, GetTime(), 5, 1)
end
--spells that do not effect combat
local noCombatSpell = {
[5171] = true, -- Slice and Dice (R1) [6774] = true, -- Slice and Dice (R2) [52610] = true, -- Savage Roar [44055] = true, -- Tremendous Fortitude (+1750 HP) [55915] = true, -- Tremendous Fortitude (+3385 HP) [55917] = true, -- Tremendous Fortitude (+4355 HP) [67596] = true, -- Tremendous Fortitude (+4608 HP) [54181] = true, -- Fel Synergy
};
local noCombatEventType = {
[48300] = true, -- Devouring Plague
};
local eventRegistered = {
["SWING_DAMAGE"] = true, --someone got damaged by meele ["SWING_MISSED"] = true, --someone missed, resisted, absorbed, etc. damage by meele ["RANGE_DAMAGE"] = true, --someone got damaged by range ["RANGE_MISSED"] = true, --someone missed, resisted, absorbed, etc. damage by range ["SPELL_DAMAGE"] = true, --someone got damaged by caster ["SPELL_MISSED"] = true, --someone missed, resisted, absorbed, etc. damage by caster ["SPELL_HEAL"] = true, --someone got healed by caster ["SPELL_CAST_SUCCESS"] = true, --some got affected by instant spell like Counterspell ["SPELL_AURA_APPLIED"] = true, --someone got buffed/debuffed by caster ["SPELL_AURA_DISPELLED"] = true, --someones buff/debuff got dispelled by caster ["SPELL_AURA_STOLEN"] = true, --someones buff got stolen by caster ["SPELL_AURA_REFRESH"] = true, ["SPELL_DISPEL_FAILED"] = true, --caster failed to dispel buff/debuff ["SPELL_PERIODIC_DISPEL_FAILED"] = true, --caster failed to dispel dot/hot
};
for i = 1, 5 do
_G["AT"..i] = CreateFrame("Frame"); cooldownFrame(_G["AT"..i], "ArenaEnemyFrame", i, "cda"..i, 30, 0, 28); _G["AT"..i]:SetScript("OnUpdate", function(self) if UnitAffectingCombat("arena"..i) or UnitAffectingCombat("arenapet"..i) then self:SetAlpha(1); self.c:SetAlpha(1); else self:SetAlpha(0); self.c:SetAlpha(0); end end) _G["AT"..i]:SetScript("OnEvent", function(_,_,_, eventType,_, sourceName,_,_, destName,_, spellId, ...) if not(sourceName == UnitName("arena"..i) or destName == UnitName("arenapet"..i) or destName == UnitName("arena"..i) or destName == UnitName("arenapet"..i)) then return; end if eventType == ("SPELL_DAMAGE") or eventType == ("SPELL_HEAL")and spellId ~= nil and noCombatEventType[spellId] then return; end if not eventRegistered[eventType] then return; end if sourceName == destName then return; end --if UnitCanAssist(sourceName, destName) == true and not UnitAffectingCombat(destName) then -- return; -- end if destName == (UnitName("arena"..i) or UnitName("arenapet"..i)) and UnitCanAssist(sourceName, destName) then return; end if spellId ~= nil and noCombatSpell[spellId] then return; end timer(_G["AT"..i], _G["cda"..i]) end)
end
for i = 1, 4 do
_G["PT"..i] = CreateFrame("Frame"); cooldownFrame(_G["PT"..i], "PartyMemberFrame", i, "cdp"..i, 0, 0, 25); _G["PT"..i]:SetScript("OnUpdate", function(self) if UnitAffectingCombat("party"..i) or UnitAffectingCombat("party"..i) then self:SetAlpha(1); self.c:SetAlpha(1); else self:SetAlpha(0); self.c:SetAlpha(0); end end) _G["PT"..i]:SetScript("OnEvent", function(_,_,_, eventType,_, sourceName,_,_, destName,_, spellId, ...) if sourceName == UnitName("party"..i) or destName == UnitName("partypet"..i) or destName == UnitName("party"..i) or destName == UnitName("partypet"..i) then if eventType == ("SPELL_DAMAGE") and spellId ~= nil and noCombatEventType[spellId] then return; end if not eventRegistered[eventType] then return; end if sourceName == destName then return; end --if UnitCanAssist(sourceName, destName) == true and not UnitAffectingCombat(destName) then -- return; -- end if destName == (UnitName("party"..i) or UnitName("partypet"..i)) and UnitCanAssist(sourceName, destName) == true then return; end if spellId ~= nil and noCombatSpell[spellId] then return; end timer(_G["PT"..i], _G["cdp"..i]) end end)
end
local T = CreateFrame("Frame"); cooldownFrame(T, "TargetFrame", _, "cdt", 0, 0, 25);
T:SetScript("OnUpdate", function(self)
if UnitAffectingCombat("target") then self:SetAlpha(1); self.c:SetAlpha(1); else self:SetAlpha(0); self.c:SetAlpha(0); end
end)
T:SetScript("OnEvent", function(,,, eventType,, sourceName,,, destName,_, spellId, ...)
if sourceName == UnitName("target") or destName == UnitName("target") then if eventType == ("SPELL_DAMAGE") and spellId ~= nil and noCombatEventType[spellId] then return; end if not eventRegistered[eventType] then return; end if sourceName == destName then return; end -- if UnitCanAssist(sourceName, destName) == true and not UnitAffectingCombat(destName) then -- return; -- end if destName == UnitName("target") and UnitCanAssist(sourceName, destName) then return; end if spellId ~= nil and noCombatSpell[spellId] then return; end timer(T, cdt) end
end)
local P = CreateFrame("Frame"); cooldownFrame(P, "PlayerFrame", _, "cdme", 50, 0, 25);
P:SetScript("OnUpdate", function(self)
if UnitAffectingCombat("player") or UnitAffectingCombat("pet") then self:SetAlpha(1); self.c:SetAlpha(1); else self:SetAlpha(0); self.c:SetAlpha(0); end
end)
P:SetScript("OnEvent", function(,,, eventType,, sourceName,,, destName,_, spellId, ...)
if sourceName == UnitName("player") or sourceName == UnitName("pet") or destName == UnitName("player") or destName == UnitName("pet") then if eventType == ("SPELL_DAMAGE") and spellId ~= nil and noCombatEventType[spellId] then return; end if not eventRegistered[eventType] then return; end if sourceName == destName then return; end -- if UnitCanAssist(sourceName, destName) == true and not UnitAffectingCombat(destName) then -- return; -- end if destName == UnitName("player") and UnitCanAssist(sourceName, destName) then return; end if spellId ~= nil and noCombatSpell[spellId] then return; end timer(P, cdme) end
end)
local F = CreateFrame("Frame"); cooldownFrame(F, "FocusFrame", _, "cdf", 0, 0, 25);
F:SetScript("OnUpdate", function(self)
if UnitAffectingCombat("focus") then self:SetAlpha(1); self.c:SetAlpha(1); else self:SetAlpha(0); self.c:SetAlpha(0); end
end)
F:SetScript("OnEvent", function(,,, eventType,, sourceName,,, destName,_, spellId, ...)
if sourceName == UnitName("focus") or destName == UnitName("focus") then if eventType == ("SPELL_DAMAGE") and spellId ~= nil and noCombatEventType[spellId] then return; end if not eventRegistered[eventType] then return; end if sourceName == destName then return; end -- if UnitCanAssist(sourceName, destName) == true and not UnitAffectingCombat(destName) then -- return; -- end if destName == UnitName("focus") and UnitCanAssist(sourceName, destName) then return; end if spellId ~= nil and noCombatSpell[spellId] then return; end timer(F, cdf) end
end)`