PHP код:
local _G = _G
local tostring = tostring
local WorldFrame = WorldFrame
local select = select
local UnitExists = UnitExists
local UnitGUID = UnitGUID
local UnitName = UnitName
local pairs = pairs
local table_insert = table.insert
local GetMouseFocus = GetMouseFocus
local GetNumRaidMembers = GetNumRaidMembers
local GetNumPartyMembers = GetNumPartyMembers
local UnitIsUnit = UnitIsUnit
local GetRaidTargetIndex = GetRaidTargetIndex
local print = print
local table_getn = table.getn
local _ --localized underscore so FindGlobals
local IsAddOnLoaded = IsAddOnLoaded
local unpack = unpack
local math_floor = math.floor
local tonumber = tonumber
local UnitHealth = UnitHealth
local UnitHealthMax = UnitHealthMax
local UnitClass = UnitClass
local UnitInRange = UnitInRange
local UnitCastingInfo = UnitCastingInfo
local UnitChannelInfo = UnitChannelInfo
local FAuras = {
[118] = true, --Polymorph
[51514] = true, --Hex
[710] = true, --Banish
[6358] = true, --Seduction
[6770] = true, --Sap
[605] = true, --Mind Control
[33786] = true, --Cyclone
[5782] = true, --Fear
[5484] = true, --Howl of Terror
[6789] = true, --Death Coil
[45438] = true, --Ice Block
[642] = true, --Divine Shield
[8122] = true, --Psychic Scream
[339] = true, --Entangling Roots
[23335] = true, -- Silverwing Flag (alliance WSG flag)
[23333] = true, -- Warsong Flag (horde WSG flag)
[34976] = true, -- Netherstorm Flag (EotS flag)
[2094] = true, --Blind
[33206] = true, --Pain Suppression (priest)
[29166] = true, --Innervate (druid)
[47585] = true, --Dispersion (priest)
[19386] = true, --Wyvern Sting (hunter)
[15487] = true, --Silence (priest)
[10060] = true, --Power Infusion (priest)
[2825] = true, --Bloodlust
[5246] = true, --Intimidating Shout (warrior)
[31224] = true, --Cloak of Shadows (rogue)
[498] = true, --Divine Protection
[47476] = true, --Strangulate (warlock)
[31884] = true, --Avenging Wrath (pally)
[37587] = true, --Bestial Wrath (hunter)
[12472] = true, --Icy Veins (mage)
[49039] = true, --Lichborne (DK)
[48792] = true, --Icebound Fortitude (DK)
[5277] = true, --Evasion (rogue)
[53563] = true, --Beacon of Light (pally)
[22812] = true, --Barkskin (druid)
[67867] = true, --Trampled (ToC arena spell when you run over someone)
[1499] = true, --Freezing Trap
[2637] = true, --Hibernate
[64044] = true, --Psychic Horror
[19503] = true, --Scatter Shot (hunter)
[34490] = true, --Silencing Shot (hunter)
[10278] = true, --Hand of Protection (pally)
[10326] = true, --Turn Evil (pally)
[44572] = true, --Deep Freeze (mage)
[20066] = true, --Repentance (pally)
[46968] = true, --Shockwave (warrior)
[46924] = true, --Bladestorm (warrior)
[16689] = true, --Nature's Grasp (Druid)
[53601] = true, --блядощит пеладина
[56222] = false,
[49284] = true,
[26669] = true,
[51724] = true
}
local UI, M = select(2, ...):unpack()
local NP = UI:NewModule("NamePlates")
local scanDelay = 1
local updateDelay = 1
NP.nameplates = {}
NP.GUIDs = {}
NP.names = {}
NP.onShowHooks = {}
NP.onHideHooks = {}
NP.onUpdateHooks = {}
NP.healthOnValueChangedHooks = {}
NP.plateGUIDs = {}
NP.isOnScreen = {}
NP.isOnUpdating = {}
NP.realPlate = {}
NP.fakePlate = {}
NP.combatStatus = {}
local function IsNamePlateFrame(frame)
if frame:GetName() then return false end
if frame:GetID() ~= 0 then return false end
if frame:GetObjectType() ~= "Frame" then return false end
if frame:GetNumChildren() == 0 then return false end
if frame:GetNumRegions() == 0 then return false end
return true
end
local function RemoveHexColor(inputString)
local find = inputString:find("|c")
if find then
inputString = inputString:sub(find+10)
end
inputString = inputString:gsub("|r", "")
return inputString
end
function NP:GetName(frame)
local frame = self.realPlate[frame] or frame
local nameRegion = frame.nameTextRegion or self:GetNameRegion(frame)
if nameRegion and nameRegion.GetText then
return RemoveHexColor( nameRegion:GetText() )
end
return nil
end
function NP:GetHightlightRegion(frame)
local hl = select(6, frame:GetRegions())
return hl
end
function NP:GetNameRegion(frame)
local nr = select(7, frame:GetRegions())
return nr
end
function NP:GetReaction(frame)
local frame = self.realPlate[frame] or frame
local r,g,b = GetHealthBarColor(frame)
if r then
return reactionByColor(r, g, b )
end
return nil
end
function NP:GetHealthBar(frame)
return select(1, frame:GetChildren())
end
function NP:GetCastBar(frame)
return select(2, frame:GetChildren())
end
function NP:IsMouseover(frame)
local frame = self.realPlate[frame] or frame
local region = frame.highlightRegion or self:GetHightlightRegion(frame)
if region and region.IsShown then
return region:IsShown() and true or false
end
return nil
end
local function FoundPlateGUID(frame, GUID, unitID)
NP.plateGUIDs[frame] = GUID
NP.GUIDs[GUID] = frame
NP:FoundGUID(NP.fakePlate[frame] or frame, GUID, unitID)
end
local function GetMouseoverGUID(frame)
local unitID = "mouseover"
if UnitExists(unitID) then
FoundPlateGUID(frame, UnitGUID(unitID), unitID)
end
end
local function HideMouseoverRegion(frame)
local region = frame.highlightRegion or NP:GetHightlightRegion(frame)
if region and region.Hide then
region:Hide()
end
end
local function UpdateNameplateInfo(frame)
if NP:IsMouseover(frame) and not UnitExists("mouseover") then
HideMouseoverRegion(frame)
end
if not NP.plateGUIDs[frame] then
if NP:IsMouseover(frame) then
GetMouseoverGUID(frame)
end
end
frame.lnpLastUpdate = 0
end
local function combatByColor(r, g, b, a)
return (r > .5 and g < .5)
end
function NP:IsInCombat(frame)
local frame = self.realPlate[frame] or frame
local region = frame.nameTextRegion or self:GetNameRegion(frame)
if region and region.GetTextColor then
return combatByColor( region:GetTextColor() ) and true or false
end
return nil
end
local function CheckUnitIDForMatchingHP(unitID, frameName, current, max)
local targetID = unitID.."target"
if UnitName(targetID) == frameName then
local health = UnitHealth(targetID)
local maxHealth = UnitHealthMax(targetID)
if health == current and maxHealth == max then
return true
end
end
return false
end
function NP:NewNameplateCheckHP(frame)
local bar = frame.healthBar or self:GetHealthBar(frame)
if bar and bar.GetValue then
local _, max = bar:GetMinMaxValues()
local current = bar:GetValue()
NP.prevHealth[frame] = current
if current > 0 and current ~= max then
local group, num = "", 0
if GetNumRaidMembers() > 1 then
group, num = "raid", GetNumRaidMembers()
elseif GetNumPartyMembers() > 0 then
group, num = "party", GetNumPartyMembers()
else
return
end
local possibleUnits = {}
local frameName = self:GetName(frame)
local unitID, targetID, targetIndex
for i = 1, num do
unitID = group..i;
if CheckUnitIDForMatchingHP(unitID, frameName, current, max) then
table_insert(possibleUnits, #possibleUnits+1, unitID.."target")
end
if UnitExists(unitID.."pet") then
if CheckUnitIDForMatchingHP(unitID.."pet", frameName, current, max) then
table_insert(possibleUnits, #possibleUnits+1, unitID.."pettarget")
end
end
end
if #possibleUnits == 1 then
FoundPlateGUID(frame, UnitGUID(possibleUnits[1]), possibleUnits[1])
return true
end
end
end
end
NP.prevHealth = {}
function NP.OnNameplateShow(frame, ...)
NP:SetupNameplate(frame)
NP:NewNameplateCheckHP(frame)
end
local function ourOnShow(...) return NP.OnNameplateShow(...) end
local function RecycleNameplate(frame)
NP:RecycleNameplate(NP.fakePlate[frame] or frame)
if NP.plateGUIDs[frame] then
NP.GUIDs[NP.plateGUIDs[frame]] = false
end
local plateName = NP:GetName(frame)
if plateName and NP.names[plateName] then
NP.names[plateName] = false
end
NP.plateGUIDs[frame] = false
local fake = NP.fakePlate[frame]
if fake then
NP.realPlate[fake] = false
end
NP.fakePlate[frame] = false
end
function NP.OnNameplateHide(frame, ...)
NP.isOnScreen[frame] = false
NP.isOnUpdating[frame] = false
NP.combatStatus[frame] = false
RecycleNameplate(frame)
end
local function ourOnHide(...) return NP.OnNameplateHide(...) end
function NP.OnNameplateUpdate(frame, elapsed, ...)
NP.isOnUpdating[frame] = true
if frame.lnpCheckForTarget then
frame.lnpCheckForTarget = false
if not NP.plateGUIDs[frame] and frame:IsShown() and ((frame:GetAlpha() == 1) and UnitExists("target")) then
FoundPlateGUID(frame, UnitGUID("target"), "target")
end
end
frame.lnpLastUpdate = (frame.lnpLastUpdate or 0) + elapsed
if frame.lnpLastUpdate > updateDelay then
UpdateNameplateInfo(frame)
NP:NameplateOnUpdate(frame)
local inCombat = NP:IsInCombat(frame)
if NP.combatStatus[frame] ~= inCombat then
NP.combatStatus[frame] = inCombat
NP:CombatChange(NP.fakePlate[frame] or frame, inCombat)
end
end
end
local function ourOnUpdate(...) return NP.OnNameplateUpdate(...) end
function NP.healthOnValueChanged(frame, ...)
local plate = frame:GetParent()
local currentHP = ...
local min, max = frame:GetMinMaxValues()
if plate and NP.isOnScreen[plate] and (not NP.prevHealth[plate] or NP.prevHealth[plate] ~= currentHP) then
NP:HealthChange(plate, min, max, currentHP)
local plateName = NP:GetName(plate)
if not NP.plateGUIDs[plate] then
NP:NewNameplateCheckHP(plate)
end
end
end
local function ourHealthOnValueChanged(...) return NP.healthOnValueChanged(...) end
function NP:HookNameplate(frame)
if frame:HasScript("OnHide") and not self.onHideHooks[frame] then
self.onHideHooks[frame] = true
frame:HookScript("OnHide", ourOnHide)
end
if frame:HasScript("OnShow") and not self.onShowHooks[frame] then
self.onShowHooks[frame] = true
frame:HookScript("OnShow", ourOnShow)
end
if frame:HasScript("OnUpdate") and not self.onUpdateHooks[frame] then
self.onUpdateHooks[frame] = true
frame:HookScript("OnUpdate", ourOnUpdate)
end
local healthBar = frame.healthBar
if healthBar and not self.healthOnValueChangedHooks[frame] then
self.healthOnValueChangedHooks[frame] = true
healthBar:HookScript("OnValueChanged", ourHealthOnValueChanged)
end
end
function NP:SaveFrameRegions(frame)
local glowRegion, overlayRegion, castbarOverlay, shieldedRegion, spellIconRegion, highlightRegion, nameTextRegion, levelTextRegion, bossIconRegion, raidIconRegion, stateIconRegion = frame:GetRegions()
frame.glowRegion = glowRegion
frame.overlayRegion = overlayRegion
frame.castbarOverlay = castbarOverlay
frame.shieldedRegion = shieldedRegion
frame.spellIconRegion = spellIconRegion
frame.highlightRegion = highlightRegion
frame.nameTextRegion = nameTextRegion
frame.levelTextRegion = levelTextRegion
frame.bossIconRegion = bossIconRegion
frame.raidIconRegion = raidIconRegion
frame.stateIconRegion = stateIconRegion
end
function NP:SaveFrameBars(frame)
frame.healthBar = self:GetHealthBar(frame)
frame.castBar = self:GetCastBar(frame)
end
function NP:NameplateFirstLoad(frame)
NP:SaveFrameRegions(frame)
NP:SaveFrameBars(frame)
self:HookNameplate(frame)
if self.combatStatus[frame] == nil then
self.combatStatus[frame] = false
end
end
function NP:SetupNameplate(frame)
self.isOnScreen[frame] = true
local plateName = self:GetName(frame)
self.nameplates[frame] = plateName
self.names[plateName] = frame
self:NewNameplate(self.fakePlate[frame] or frame)
frame.lnpCheckForTarget = true
UpdateNameplateInfo(frame)
end
local function ScanWorldFrameChildren(n, ...)
for i = 1, n do
local frame = select(i, ...)
if frame:IsShown() and IsNamePlateFrame(frame) then
if not NP.nameplates[frame] then
NP:NameplateFirstLoad(frame)
NP:SetupNameplate(frame)
end
end
end
end
local lastChildren = 0
local function FindNameplates()
local curChildren = WorldFrame:GetNumChildren()
if curChildren ~= lastChildren then
lastChildren = curChildren
ScanWorldFrameChildren(curChildren, WorldFrame:GetChildren())
end
end
function NP:IsTarget(frame)
local frame = self.realPlate[frame] or frame
return frame:IsShown() and frame:GetAlpha() == 1 and UnitExists("target") or false
end
local function CheckForTargetGUID()
local unitID = "target"
local GUID
for frame in pairs(NP.nameplates) do
if NP:IsTarget(frame) then
NP.targeted = frame
if not NP.plateGUIDs[frame] then
FoundPlateGUID(frame, UnitGUID(unitID), unitID)
end
NP:TargetNameplate(NP.fakePlate[frame] or frame)
return
end
end
end
local function OnUpdate(frame, elapsed)
if frame.checkTarget then
frame.checkTarget = false
CheckForTargetGUID()
end
FindNameplates()
frame.lastUpdate = frame.lastUpdate + elapsed
if frame.lastUpdate >= scanDelay then
frame.lastUpdate = 0
for frame, value in pairs(NP.isOnScreen) do
if (value == true and not frame:IsShown()) then --OnHide fail
print("OnHide fail", frame, value, frame:IsShown())
NP.onHideHooks[frame] = false
NP.isOnScreen[frame] = false
NP:HookNameplate(frame)
NP.OnNameplateHide(frame)
elseif (value == false and frame:IsShown()) then --OnShow fail
print("OnShow fail", frame, value, frame:IsShown())
NP.onShowHooks[frame] = false
NP.isOnScreen[frame] = false
NP:HookNameplate(frame)
NP:SetupNameplate(frame, true)
end
end
for frame, value in pairs(NP.isOnUpdating) do
if value == false and frame:IsShown() then
print("OnUpdate fail?")
NP.onUpdateHooks[frame] = false
NP:HookNameplate(frame)
end
end
end
end
local function OnEvent(frame, event, ...)
if event == "UPDATE_MOUSEOVER_UNIT" then
if GetMouseFocus():GetName() == "WorldFrame" then
local i = 0
local mouseoverPlate
for frame in pairs(NP.nameplates) do
if frame:IsShown() and NP:IsMouseover(frame) then
i = i + 1
mouseoverPlate = frame
end
end
if i == 1 then
if not NP.plateGUIDs[mouseoverPlate] then
GetMouseoverGUID(mouseoverPlate)
end
NP:MouseoverNameplate(NP.fakePlate[mouseoverPlate] or mouseoverPlate)
elseif i > 1 then
debugPrint(i.." mouseover frames")
end
end
elseif event == "PLAYER_TARGET_CHANGED" then
if UnitExists("target") then
frame.checkTarget = true
else
NP.targeted = nil
end
elseif event == "UNIT_TARGET" then
local unitID = ...
local targetID = unitID.."target"
if UnitExists(targetID) and not UnitIsUnit("player", unitID) and UnitInRange(unitID) then
local targetGUID = UnitGUID(targetID)
local iconNum = GetRaidTargetIndex(targetID)
if iconNum and iconNum > 0 then
local foundPlate = FindPlateWithRaidIcon(iconNum)
if foundPlate and not NP.plateGUIDs[foundPlate] then
FoundPlateGUID(foundPlate, targetGUID, targetID)
end
end
if NP.GUIDs[targetGUID] and NP.GUIDs[targetGUID]:IsShown() then
return
end
local health = UnitHealth(targetID)
local maxHealth = UnitHealthMax(targetID)
if health > 0 and health ~= maxHealth then
local foundPlate = NP:GetNameplateByHealth(health, maxHealth)
if foundPlate and not NP.plateGUIDs[foundPlate] then
local name = UnitName(targetID)
if name == NP:GetName(foundPlate) then
FoundPlateGUID(foundPlate, targetGUID, targetID)
end
end
end
end
elseif event == "UNIT_AURA" and arg1~="player" then
NP:UnitAura(arg1)
else
if ... ~= "player" then
NP:UnitCasting(event, arg1)
end
end
end
function NP:GetNameplateByHealth(current, max)
local possibleFrames = {}
local bar, barMax, barCurrent
for frame in pairs(self.nameplates) do
if frame:IsShown() then
bar = frame.healthBar or self:GetHealthBar(frame)
if bar and bar.GetMinMaxValues then
_, barMax = bar:GetMinMaxValues()
if barMax == max then
if bar:GetValue() == current then
table_insert(possibleFrames, #possibleFrames+1, frame)
end
end
end
end
end
if #possibleFrames == 1 then
return possibleFrames[1]
end
return nil
end
function NP:GetTargetNameplate()
if self.targeted and self.targeted:IsShown() then
return self.fakePlate[self.targeted] or self.targeted
end
end
function NP:GetNameplateByGUID(GUID)
if self.GUIDs[GUID] and self.GUIDs[GUID]:IsShown() then
return self.fakePlate[self.GUIDs[GUID]] or self.GUIDs[GUID]
end
end
function NP:GetNameplateByName(name)
if self.names[name] and self.names[name]:IsShown() then
return self.fakePlate[self.names[name]] or self.names[name]
end
end
function NP:GetNameplateByUnit(unitID)
if UnitIsUnit(unitID, "target") then
return self:GetTargetNameplate()
end
local GUID = UnitGUID(unitID)
if self.GUIDs[GUID] and self.GUIDs[GUID]:IsShown() then
return self.fakePlate[self.GUIDs[GUID]] or self.GUIDs[GUID]
end
local health = UnitHealth(unitID)
local maxHealth = UnitHealthMax(unitID)
local frame = self:GetNameplateByHealth(health, maxHealth)
local name = UnitName(unitID)
if frame then
if name == self:GetName(frame) then
return self.fakePlate[frame] or frame
end
end
if self.names[GUID] and self.names[GUID]:IsShown() then
return self.fakePlate[self.names[GUID]] or self.names[GUID]
end
end
local floor = math.floor
local tinsert = table.insert
local function createAuraIcon(icons, index)
local button = CreateFrame("frame", nil, icons)
button:SetWidth(icons.size or 16)
button:SetHeight(icons.size or 16)
local icon = button:CreateTexture(nil, "BORDER")
icon:SetAllPoints(button)
icon:SetTexCoord(.08, .92, .08, .92)
local timer = button:CreateFontString(nil, "OVERLAY", "NumberFontNormal")
timer:SetPoint("BOTTOM", button, "BOTTOM", 0, -6)
local count = button:CreateFontString(nil, "OVERLAY")
count:SetFontObject(NumberFontNormal)
count:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -1, 0)
tinsert(icons.frames, button)
button.parent = icons
button.icon = icon
button.count = count
button.timer = timer
return button
end
local function customFilter(icons, unit, icon, name, rank, texture, count, dtype, duration, timeLeft, caster)
local isPlayer
if(caster == 'player' or caster == 'vehicle') then
isPlayer = true
end
if((icons.onlyShowPlayer and isPlayer) or (not icons.onlyShowPlayer and name)) then
icon.isPlayer = isPlayer
icon.owner = caster
return true
end
end
local function in_array(e, t)
if ( t[e] ) then
return true
end
return false
end
local function FilterBlacklist(spellID, list)
if ( in_array(spellID, list) ) then
return false
end
return true
end
local function FilterWhitelist(spellID, list)
if ( in_array(spellID, list) ) then
return true
end
return false
end
local function Filter(icons, caster, spellID)
if icons.type=="auras" then
return FilterWhitelist(spellID, FAuras)
elseif icons.type=="debuffs" then
if caster then
if caster=="player" or caster=="pet" or caster==caster:match("party%d") or caster==caster:match("partypet%d") then
return FilterBlacklist(spellID, FAuras)
else
return false
end
end
end
end
local function SetPosition(icons, x)
if(icons and x > 0) then
local col, row, gap = 0, 0, icons.gap
local sizex = (icons.size or 16) + (icons['spacing-x'] or icons.spacing or 0)
local sizey = (icons.size or 16) + (icons['spacing-y'] or icons.spacing or 0)
local anchor = icons.initialAnchor or "BOTTOMLEFT"
local growthx = (icons["growth-x"] == "LEFT" and -1) or 1
local growthy = (icons["growth-y"] == "DOWN" and -1) or 1
local cols = floor(icons:GetWidth() / sizex + .5)
local rows = floor(icons:GetHeight() / sizey + .5)
for i = 1, #icons.frames do
local button = icons.frames[i]
if(button and button:IsShown()) then
if(gap and button.debuff) then
if(col > 0) then
col = col + 1
end
gap = false
end
if(col >= cols) then
col = 0
row = row + 1
end
button:ClearAllPoints()
button:SetPoint(anchor, icons, anchor, col * sizex * growthx, row * sizey * growthy)
col = col + 1
elseif(not button) then
break
end
end
end
end
local function UpdateIcons(unit, icons, index, offset, filter, isDebuff, visible)
if not unit then return; end
local name, rank, texture, count, dtype, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID = UnitAura(unit, index, filter)
if(name) then
local n = visible + offset + 1
local icon = icons.frames[n]
if(not icon) then
icon = createAuraIcon(icons)
end
local show = Filter(icons, caster, spellID)
if(show) then
icon.icon:SetTexture(texture)
icon.count:SetText((count > 1 and count))
icon.filter = filter
icon.isDebuff = isDebuff
icon:SetID(index)
icon:Show()
icon.duration = timeLeft - GetTime()
icon:SetScript("OnUpdate", function(self, elaps)
self.duration = self.duration - elaps
if self.duration <= 0 then
self:Hide()
SetPosition(icons, icons.num)
else
self.timer:SetFormattedText("%.1f", self.duration)
end
end)
icon:SetScript("OnHide", function(self)
self.duration = 0
end)
return 1
else
return 0
end
end
end
local function filterIcons(unit, icons, filter, limit, isDebuff, offset, dontHide)
if(not offset) then offset = 0 end
local index = 1
local visible = 0
while(visible < limit) do
local result = UpdateIcons(unit, icons, index, offset, filter, isDebuff, visible)
if(not result) then
break
elseif(result == 1) then
visible = visible + 1
end
index = index + 1
end
if(not dontHide) then
for i = visible + offset + 1, #icons.frames do
icons.frames[i]:Hide()
end
end
return visible
end
local function UpdateAuras(self, unit)
if not self then return end
local auras = self.Auras
if(auras) then
local numBuffs = auras.numBuffs or 32
local numDebuffs = auras.numDebuffs or 40
local max = numBuffs + numDebuffs
local visibleBuffs = filterIcons(unit, auras, auras.buffFilter or auras.filter or 'HELPFUL', numBuffs, nil, 0, true)
auras.visibleBuffs = visibleBuffs
auras.visibleDebuffs = filterIcons(unit, auras, auras.debuffFilter or auras.filter or 'HARMFUL', numDebuffs, true, visibleBuffs)
auras.visibleAuras = auras.visibleBuffs + auras.visibleDebuffs
SetPosition(auras, max)
end
local debuffs = self.Debuffs
if(debuffs) then
local numDebuffs = debuffs.num or 40
debuffs.visibleDebuffs = filterIcons(unit, debuffs, debuffs.filter or 'HARMFUL', numDebuffs, true)
SetPosition(debuffs, numDebuffs)
end
end
local update_units = {"party1", "party2", "party3", "party4",
"arena1", "arena2", "arena3", "arenapet1", "arenapet2", "arenapet3",
"partypet1", "partypet2", "partypet3", "partypet4"}
function NP:NewNameplate(frame)
self:StylePlate(frame)
for _, unit in pairs(update_units) do
if UnitCastingInfo(unit) then
self:UnitCasting("UNIT_SPELLCAST_START", unit)
elseif UnitChannelInfo(unit) then
self:UnitCasting("UNIT_SPELLCAST_CHANNEL_START", unit)
end
end
if not frame.Debuffs then
local debuffs = CreateFrame("Frame", nil, frame)
debuffs.frames = {}
debuffs.size = 26
debuffs.spacing = 2
debuffs:SetPoint("BOTTOM", frame, "TOP", 0, 0)
debuffs["growth-x"] = "RIGHT"
debuffs["growth-y"] = "UP"
debuffs.initialAnchor = "BOTTOMLEFT"
debuffs:SetWidth(frame:GetWidth())
debuffs:SetHeight(debuffs.size*2+debuffs.spacing)
debuffs.num = 24
debuffs.type = "debuffs"
frame.Debuffs = debuffs
end
if not frame.Auras then
local auras = CreateFrame("Frame", nil, frame)
auras.frames = {}
auras.size = 32
auras.spacing = 2
auras:SetPoint("BOTTOM", debuffs, "TOP", 0, 6)
auras["growth-x"] = "RIGHT"
auras["growth-y"] = "UP"
auras.initialAnchor = "BOTTOMLEFT"
auras:SetWidth(frame:GetWidth())
auras:SetHeight(auras.size*2+auras.spacing)
auras.num = 24
auras.type = "auras"
frame.Auras = auras
end
end
function NP:NameplateOnUpdate(frame)
self:UpdateStatusbarColor(frame)
end
function NP:TargetNameplate(frame)
UpdateAuras(frame, "target")
if UnitCastingInfo("target") then
self:UnitCasting("UNIT_SPELLCAST_START", "target", frame)
elseif UnitChannelInfo(unit) then
self:UnitCasting("UNIT_SPELLCAST_CHANNEL_START", "target", frame)
end
end
function NP:MouseoverNameplate(frame)
UpdateAuras(frame, "mouseover")
if UnitCastingInfo("mouseover") then
self:UnitCasting("UNIT_SPELLCAST_START", "mouseover", frame)
elseif UnitChannelInfo(unit) then
self:UnitCasting("UNIT_SPELLCAST_CHANNEL_START", "mouseover", frame)
end
end
function NP:HealthChange(frame, min, max, cur)
self:UpdateHealthBarValue(frame, min, max, cur)
end
function NP:FoundGUID(frame, guid, unit)
UpdateAuras(frame, unit)
if UnitCastingInfo(unit) then
self:UnitCasting("UNIT_SPELLCAST_START", unit, frame)
elseif UnitChannelInfo(unit) then
self:UnitCasting("UNIT_SPELLCAST_CHANNEL_START", unit, frame)
end
end
function NP:RecycleNameplate(frame)
if frame.Debuffs and #frame.Debuffs.frames > 0 then
for _, icon in pairs(frame.Debuffs.frames) do
icon.duration = 0
end
end
if frame.Auras and #frame.Auras.frames > 0 then
for _, icon in pairs(frame.Auras.frames) do
icon.duration = 0
end
end
frame.health:Hide()
frame.cast:Hide()
end
function NP:CombatChange(frame, inCombat)
self:UpdateNameText(frame, inCombat)
end
function NP:UnitAura(unit)
local frame
local GUID = UnitGUID(unit)
frame = self:GetNameplateByGUID(GUID)
if frame then
UpdateAuras(frame, unit)
else
frame = self:GetNameplateByUnit(unit)
UpdateAuras(frame, unit)
end
end
function NP:Init()
self.lastUpdate = 0
self.lastHPCheck = 0
self.checkTarget = false
self:SetScript("OnUpdate", OnUpdate)
self:SetScript("OnEvent", OnEvent)
self:RegisterEvent('UPDATE_MOUSEOVER_UNIT')
self:RegisterEvent('PLAYER_TARGET_CHANGED')
self:RegisterEvent('UNIT_TARGET')
self:RegisterEvent('RAID_TARGET_UPDATE')
self:RegisterEvent('UNIT_AURA')
self:RegisterEvent("UNIT_SPELLCAST_START")
self:RegisterEvent("UNIT_SPELLCAST_FAILED")
self:RegisterEvent("UNIT_SPELLCAST_STOP")
self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED")
self:RegisterEvent("UNIT_SPELLCAST_DELAYED")
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE")
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP")
end
шкурка не влезла , превышен лимит в 35 000 букв , нужно ждать 20 минут что бы следующий пост был как новый , а не updated.