A Deviate Faerie Dragon
Join Date: Jun 2009
Posts: 11
|
Target buff timers
What do i need to change here to make the buff timers for target stay and not disappear when i change targets? In addition it would be nice that if i change back to the original target the buff expiration time left is refreshed.
local function OnEvent(self, event, ...)
local unit = ...;
if ( ( unit == "target" or unit == "player" ) or event == "PLAYER_TARGET_CHANGED" or event == "PLAYER_ENTERING_WORLD" or event == "SPELL_UPDATE_COOLDOWN" ) then
local data, name, rank, icon, count, debuffType, duration, expirationTime, caster, isStealable, start, enabled, slotLink;
local id = self.Id;
for i=1, #spells[class][id], 1 do
data = spells[class][id][i];
if ( data.filter == "BUFF" ) then
name, rank, icon, count, debuffType, duration, expirationTime, caster, isStealable = UnitBuff(data.unitId, data.spellName);
elseif ( data.filter == "DEBUFF" ) then
name, rank, icon, count, debuffType, duration, expirationTime, caster, isStealable = UnitDebuff(data.unitId, data.spellName);
else
if ( type(data.spellName) == "string" ) then
start, duration, enabled = GetSpellCooldown(data.spellName);
icon = GetSpellTexture(data.spellName);
else
slotLink = GetInventoryItemLink("player", data.spellName);
if ( slotLink ) then
name, _, _, _, _, _, _, _, _, icon = GetItemInfo(slotLink);
if ( not data.displayName ) then
data.displayName = name;
end
start, duration, enabled = GetInventoryItemCooldown("player", data.spellName);
end
end
count = 0;
caster = "all";
end
if ( not active[id] ) then
active[id] = {};
end
for index, value in ipairs(active[id]) do
if ( data.spellName == value.data.spellName ) then
tremove(active[id], index);
break;
end
end
if ( ( name and ( caster == data.caster or data.caster == "all" ) ) or ( ( enabled or 0 ) > 0 and ( duration or 0 ) > 1.5 ) ) then
table.insert(active[id], { data = data, icon = icon, count = count, duration = duration, expirationTime = expirationTime or start });
end
end
Update(self);
end
end
|