PHP код:
local function GetAuras()
return {
--Spell Name Priority (higher = more priority)
--crowd control
[GetSpellInfo(33786)] = 3, --Cyclone
[GetSpellInfo(18658)] = 3, --Hibernate
[GetSpellInfo(6770)] = 3, --Sap
[GetSpellInfo(2094)] = 3, --Blind
[GetSpellInfo(5782)] = 3, --Fear
[GetSpellInfo(47860)] = 3, --Death Coil Warlock
[GetSpellInfo(6358)] = 3, --Seduction
[GetSpellInfo(5484)] = 3, --Howl of Terror
[GetSpellInfo(5246)] = 3, --Intimidating Shout
[GetSpellInfo(8122)] = 3, --Psychic Scream
[GetSpellInfo(12826)] = 3, --Polymorph
[GetSpellInfo(28272)] = 3, --Polymorph pig
[GetSpellInfo(28271)] = 3, --Polymorph turtle
[GetSpellInfo(61305)] = 3, --Polymorph black cat
[GetSpellInfo(61025)] = 3, --Polymorph serpent
[GetSpellInfo(51514)] = 3, --Hex
--Stuns and incapacitates
[GetSpellInfo(8983)] = 3, --Bash
[GetSpellInfo(1833)] = 3, --Cheap Shot
[GetSpellInfo(8643)] = 3, --Kidney Shot
[GetSpellInfo(1776)] = 3, --Gouge
[GetSpellInfo(44572)] = 3, --Deep Freeze
[GetSpellInfo(49012)] = 3, --Wyvern Sting
[GetSpellInfo(19503)] = 3, --Scatter Shot
[GetSpellInfo(49803)] = 3, --Pounce
[GetSpellInfo(49802)] = 3, --Maim
[GetSpellInfo(10308)] = 3, --Hammer of Justice
[GetSpellInfo(20066)] = 3, --Repentance
[GetSpellInfo(46968)] = 3, --Shockwave
[GetSpellInfo(49203)] = 3, --Hungering Cold
[GetSpellInfo(47481)] = 3, --Gnaw (dk pet stun)
[GetSpellInfo(7922)] = 3, --charge
[GetSpellInfo(20253)] = 3, --charge
--Silences
[GetSpellInfo(18469)] = 1, --Improved Counterspell
[GetSpellInfo(15487)] = 1, --Silence
[GetSpellInfo(34490)] = 1, --Silencing Shot
[GetSpellInfo(18425)] = 1, --Improved Kick
[GetSpellInfo(49916)] = 1, --Strangulate
--Disarms
[GetSpellInfo(676)] = 1, --Disarm
[GetSpellInfo(51722)] = 1, --Dismantle
[GetSpellInfo(53359)] = 1, --Chimera Shot - Scorpid
--Buffs
[GetSpellInfo(1022)] = 1, --Blessing of Protection
[GetSpellInfo(10278)] = 1, --Hand of Protection
[GetSpellInfo(1044)] = 1, --Blessing of Freedom
[GetSpellInfo(2825)] = 1, --Bloodlust
[GetSpellInfo(32182)] = 1, --Heroism
[GetSpellInfo(33206)] = 1, --Pain Suppression
[GetSpellInfo(29166)] = 1, --Innervate
[GetSpellInfo(18708)] = 1, --Fel Domination
[GetSpellInfo(54428)] = 1, --Divine Plea
[GetSpellInfo(31821)] = 1, --Aura mastery
--immunities
[GetSpellInfo(34692)] = 2, --The Beast Within
[GetSpellInfo(45438)] = 2, --Ice Block
[GetSpellInfo(642)] = 2, --Divine Shield
}
end
local function Update(object, event, unit)
if object.unit ~= unit then return end
local auraList = GetAuras()
local priority = 0
local auraName, auraIcon, auraExpTime
local index = 1
--Buffs
while ( true ) do
local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable = UnitAura(unit, index, "HELPFUL")
if ( not name ) then break end
if ( auraList[name] and auraList[name] >= priority ) then
priority = auraList[name]
auraName = name
auraIcon = icon
auraExpTime = expirationTime
end
index = index+1
end
index = 1
--Debuffs
while ( true ) do
local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable = UnitAura(unit, index, "HARMFUL")
if ( not name ) then break end
if ( auraList[name] and auraList[name] >= priority ) then
priority = auraList[name]
auraName = name
auraIcon = icon
auraExpTime = expirationTime
end
index = index+1
end
if ( auraName ) then -- If an aura is found, display it and set the time left!
object.AuraTracker.icon:SetTexture(auraIcon)
object.AuraTracker.timeleft = (auraExpTime-GetTime())
object.AuraTracker.active = true
elseif ( not auraName ) then
object.AuraTracker.icon:SetTexture("")
object.AuraTracker.text:SetText("")
object.AuraTracker.active = false
end
end
local function Enable(object)
if not object.AuraTracker then return end
object:RegisterEvent("UNIT_AURA", Update)
return true
end
local function Disable(object)
if object.AuraTracker then
object:UnregisterEvent("UNIT_AURA", Update)
end
end
Это использовать для встраивания в нужно место:
PHP код:
--// Функция для обновления
local function updateAuraTrackerTime(self, elapsed)
if (self.active) then
self.timeleft = self.timeleft - elapsed
if (self.timeleft <= 5) then
self.text:SetTextColor(1, 0, 0) -- red
else
self.text:SetTextColor(1, 1, 1) -- white
end
if (self.timeleft <= 0) then
self.icon:SetTexture("")
self.text:SetText("")
end
self.text:SetFormattedText("%.1f", self.timeleft)
end
end
--// Сам Aura Tracker , как можно было понять из local function Update(object, event, unit) - для каждого нужно юника создаем отдельные фреймы.
AuraTracker = CreateFrame("Frame", nil, UIParent)
AuraTracker:SetWidth(40)
AuraTracker:SetHeight(40)
AuraTracker:SetPoint("CENTER", UIParent, "CENTER", 0,0)
AuraTracker:SetFrameStrata("HIGH")
AuraTracker.icon = self.AuraTracker:CreateTexture(nil, "ARTWORK")
AuraTracker.icon:SetWidth(41)
AuraTracker.icon:SetHeight(41)
AuraTracker.icon:SetPoint("CENTER", UIParent, "CENTER")
AuraTracker.icon:SetTexCoord(0.07,0.93,0.07,0.93)
AuraTracker.text = AuraTracker:CreateFontString(nil, 'OVERLAY', 'NumberFontNormal')
AuraTracker.text:SetPoint('CENTER', AuraTracker, 0, 0)
AuraTracker:SetScript("OnUpdate", updateAuraTrackerTime)