Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if UnitClass("player") == "Warrior" then
- local function PlayInterruptSound()
- if WHUD_VARS["Interrupt Sound"].enabled then
- PlaySoundFile("Interface\\AddOns\\Lulleh_WarriorHUD\\sounds\\IM.ogg", "Master")
- end
- end
- local _G = getfenv(0)
- local WHUD_GLOWING = {}
- local Glow, Glow_Table, Glow_Spell, HasGlow
- local frames = {} local framecount = 0
- local flag = false
- local AntTexCoords = {
- {0.0078125, 0.1796875, 0.00390625, 0.17578125}, {0.1953125, 0.3671875, 0.00390625, 0.17578125}, {0.3828125, 0.5546875, 0.00390625, 0.17578125}, {0.5703125, 0.7421875, 0.00390625, 0.17578125}, {0.7578125, 0.9296875, 0.00390625, 0.17578125},
- {0.0078125, 0.1796875, 0.19140625, 0.36328125}, {0.1953125, 0.3671875, 0.19140625, 0.36328125}, {0.3828125, 0.5546875, 0.19140625, 0.36328125}, {0.5703125, 0.7421875, 0.19140625, 0.36328125}, {0.7578125, 0.9296875, 0.19140625, 0.36328125},
- {0.0078125, 0.1796875, 0.37890625, 0.55078125}, {0.1953125, 0.3671875, 0.37890625, 0.55078125}, {0.3828125, 0.5546875, 0.37890625, 0.55078125}, {0.5703125, 0.7421875, 0.37890625, 0.55078125}, {0.7578125, 0.9296875, 0.37890625, 0.55078125},
- {0.0078125, 0.1796875, 0.56640625, 0.73828125}, {0.1953125, 0.3671875, 0.56640625, 0.73828125}, {0.3828125, 0.5546875, 0.56640625, 0.73828125}, {0.5703125, 0.7421875, 0.56640625, 0.73828125}, {0.7578125, 0.9296875, 0.56640625, 0.73828125},
- {0.0078125, 0.1796875, 0.75390625, 0.92578125}, {0.1953125, 0.3671875, 0.75390625, 0.92578125}, {0.3828125, 0.5546875, 0.75390625, 0.92578125}, {0.5703125, 0.7421875, 0.75390625, 0.92578125}, {0.7578125, 0.9296875, 0.75390625, 0.92578125},
- }
- function WHUD_Glow_Init()
- WHUD_RegisterEvent("COMBAT_TEXT_UPDATE")
- WHUD_RegisterEvent("PLAYER_TARGET_CHANGED")
- WHUD_RegisterEvent("PLAYER_AURAS_CHANGED")
- WHUD_RegisterEvent("UNIT_RAGE")
- WHUD_RegisterEvent("PLAYER_DEAD")
- WHUD_RegisterEvent("UPDATE_BONUS_ACTIONBAR")
- end
- SLASH_WHDEBUG1 = "/whdebug";
- SlashCmdList["WHDEBUG"] = function(msg)
- DEFAULT_CHAT_FRAME:AddMessage("DEBUGGING:")
- for x=1,table.getn(WHUD_GLOWING) do
- DEFAULT_CHAT_FRAME:AddMessage(WHUD_GLOWING[x])
- end
- end
- function Glow_Spell(name,show)
- if name == "" then return end
- local glowing = false
- for x=1,table.getn(WHUD_GLOWING) do
- if show then
- if WHUD_GLOWING[x] == name then
- return -- it is already glowing
- end
- else
- if WHUD_GLOWING[x] == name then
- glowing = true
- end
- if x == table.getn(WHUD_GLOWING) then
- if not glowing then
- return -- it is already hidden
- end
- end
- end
- end
- if show then
- for i=1,120 do -- checking the ActionSlot IDs
- if GetActionTexture(i) then
- if WHUD_SPELLINFO[name][1] ~= 1 and
- GetActionTexture(i) == GetSpellTexture(WHUD_SPELLINFO[name][1],"BOOKTYPE_SPELL") then
- local number = i
- local display = true
- local frameName = ""
- -- Blizzards default ActionBars/Bartender3/Bartender4/ElvUI actionbars
- local bar = ""
- if i > 24 and i < 37 then
- bar = "MultiBarRightButton"
- number = i - 24
- elseif i > 36 and i < 49 then
- bar = "MultiBarLeftButton"
- number = i - 36
- elseif i > 48 and i < 61 then
- bar = "MultiBarBottomRightButton"
- number = i - 48
- elseif i > 60 and i < 73 then
- bar = "MultiBarBottomLeftButton"
- number = i - 60
- elseif i > 72 and i < 85 then
- bar = "BonusActionButton"
- number = i - 72
- --local _,_, active = GetShapeshiftFormInfo(1)
- --if not active then display = false end
- elseif i > 84 and i < 97 then
- bar = "BonusActionButton"
- number = i - 84
- --local _,_, active = GetShapeshiftFormInfo(2)
- --if not active then display = false end
- elseif i > 96 and i < 108 then
- bar = "BonusActionButton"
- number = i - 96
- --local _,_, active = GetShapeshiftFormInfo(3)
- --if not active then display = false end
- end
- if bar ~= "" then frameName = bar..number; end
- if AddonIsActive("DiscordActionBars") then
- if i > 72 and i < 85 then -- battle stance
- number = i - 72
- --local _,_, active = GetShapeshiftFormInfo(1)
- -- f not active then display = false end
- elseif i > 84 and i < 97 then -- defensive stance
- number = i - 84
- --local _,_, active = GetShapeshiftFormInfo(2)
- --if not active then display = false end
- elseif i > 96 and i < 108 then -- berserker stance
- number = i - 96
- --local _,_, active = GetShapeshiftFormInfo(3)
- --if not active then display = false end
- end
- frameName = "DAB_ActionButton_"..number;
- end
- if AddonIsActive("Bongos") then
- if i > 72 and i < 85 then
- number = i - 72
- --local _,_, active = GetShapeshiftFormInfo(1)
- --if not active then display = false end
- elseif i > 84 and i < 97 then
- number = i - 84
- --local _,_, active = GetShapeshiftFormInfo(2)
- --if not active then display = false end
- elseif i > 96 and i < 108 then
- number = i - 96
- --local _,_, active = GetShapeshiftFormInfo(3)
- --if not active then display = false end
- end
- frameName = "BActionButton"..number;
- end
- if AddonIsActive("ElvUI") then
- local bar = ""
- if i > 0 and i < 13 then
- bar = "ElvUI_Bar1Button"
- number = i
- elseif i > 12 and i < 25 then
- bar = "ElvUI_Bar6Button"
- number = i - 12
- elseif i > 24 and i < 30 then
- bar = "ElvUI_Bar5Button"
- number = i - 24
- elseif i > 36 and i < 49 then
- bar = "ElvUI_Bar4Button"
- number = i - 36
- elseif i > 48 and i < 61 then
- bar = "ElvUI_Bar2Button"
- number = i - 48
- elseif i > 60 and i < 67 then
- bar = "ElvUI_Bar3Button"
- number = i - 60
- elseif i > 72 and i < 85 then
- bar = "ElvUI_Bar7Button"
- number = i - 72
- elseif i > 84 and i < 97 then
- bar = "ElvUI_Bar8Button"
- number = i - 84
- elseif i > 96 and i < 109 then
- bar = "ElvUI_Bar9Button"
- number = i - 96
- elseif i > 108 and i < 121 then
- bar = "ElvUI_Bar10Button"
- number = i - 108
- end
- display = true
- if bar ~= "" then frameName = bar..number; end
- end
- if AddonIsActive("Bartender3") then
- local bar = ""
- if UnitClass("player") == "Warrior" then
- if i > 12 and i < 73 then
- number = i
- elseif i > 72 and i < 85 then
- number = i - 72
- --local _,_, active = GetShapeshiftFormInfo(1)
- --if not active then display = false end
- elseif i > 84 and i < 97 then
- number = i - 84
- --local _,_, active = GetShapeshiftFormInfo(2)
- --if not active then display = false end
- elseif i > 96 and i < 109 then
- number = i - 96
- --local _,_, active = GetShapeshiftFormInfo(3)
- --if not active then display = false end
- elseif i > 108 and i < 121 then
- number = i
- end
- end
- if UnitClass("player") == "Druid" then
- -- TODO
- end
- if i > 12 and i < 121 and UnitClass("player") ~= "Warrior" and UnitClass("player") ~= "Druid" then
- number = i
- end
- frameName = "BT3Button"..number
- end
- if AddonIsActive("Bartender4") then
- local bar = ""
- if UnitClass("player") == "Warrior" then
- if i > 12 and i < 73 then
- number = i
- elseif i > 72 and i < 85 then
- number = i - 72
- --local _,_, active = GetShapeshiftFormInfo(1)
- --if not active then display = false end
- elseif i > 84 and i < 97 then
- number = i - 84
- --local _,_, active = GetShapeshiftFormInfo(2)
- --if not active then display = false end
- elseif i > 96 and i < 109 then
- number = i - 96
- --local _,_, active = GetShapeshiftFormInfo(3)
- --if not active then display = false end
- elseif i > 108 and i < 121 then
- number = i
- end
- end
- if UnitClass("player") == "Druid" then
- -- TODO
- end
- if i > 12 and i < 121 and UnitClass("player") ~= "Warrior" and UnitClass("player") ~= "Druid" then
- number = i
- end
- frameName = "BT4Button"..number.."Secure"
- end
- if frameName ~= "" then
- if _G[frameName]:IsVisible() and display then
- Glow(frameName,show)
- Glow_Table(name,show,frameName)
- end
- end
- end
- end
- end
- else
- if WHUD_GLOWING[name] ~= nil then
- for i=1,table.getn(WHUD_GLOWING[name]) do
- if WHUD_GLOWING[name][i] ~= "" then
- if _G[WHUD_GLOWING[name][i]]:IsVisible() then
- Glow(WHUD_GLOWING[name][i],false)
- Glow_Table(name,false,WHUD_GLOWING[name][i])
- end
- end
- end
- end
- end
- end
- function Glow_Table(name,add,button)
- if add then
- if WHUD_GLOWING[name] == nil then
- WHUD_GLOWING[name] = {button}
- else
- local already = false
- for i=1,table.getn(WHUD_GLOWING[name]) do
- if WHUD_GLOWING[name][i] == button then already = true end
- end
- if not already then
- for i=1,table.getn(WHUD_GLOWING[name]) do
- if WHUD_GLOWING[name][i] == "" then
- WHUD_GLOWING[name][i] = button
- return
- end
- end
- WHUD_GLOWING[name][table.getn(WHUD_GLOWING[name])+1] = button
- end
- end
- else
- if WHUD_GLOWING[name] ~= nil then
- for i=1,table.getn(WHUD_GLOWING[name]) do
- if WHUD_GLOWING[name][i] == button then
- WHUD_GLOWING[name][i] = ""
- end
- end
- end
- end
- end
- function Glow(button,show)
- button = _G[button]
- if show then
- -- Credits to Numielle @ Feenix(wow-one.com/forum) for this code
- if not button.overlay then
- button.overlay = GetOverlay(button)
- button.overlay:SetParent(button);
- if AddonIsActive("DiscordActionBars") then
- button.overlay:SetWidth(button:GetWidth()*1.2)
- button.overlay:SetHeight(button:GetHeight()*1.2)
- button.overlay:SetPoint("CENTER",button,0,1)
- else
- button.overlay:SetWidth(button:GetWidth()*1.1)
- button.overlay:SetHeight(button:GetHeight()*1.1)
- button.overlay:SetPoint("CENTER",button)
- end
- button.overlay.index = 1
- button.overlay.lastUpdated = 0
- button.overlay:Show()
- button.overlay:SetScript("OnUpdate", function()
- button.overlay.lastUpdated = button.overlay.lastUpdated + arg1 -- elapsed
- if (button.overlay.lastUpdated > 0.0175) then
- if button.overlay.index == 22 then button.overlay.index = 1
- else button.overlay.index = button.overlay.index + 1 end
- button.overlay.glow:SetTexCoord(AntTexCoords[button.overlay.index][1], AntTexCoords[button.overlay.index][2], AntTexCoords[button.overlay.index][3], AntTexCoords[button.overlay.index][4]);
- button.overlay.lastUpdated = 0;
- end
- end);
- end
- else
- if button.overlay then
- local overlay = button.overlay -- use temporary reference to reset overlay BEFORE putting it back in the pool
- button.overlay:SetScript("OnUpdate", nil);
- button.overlay:Hide();
- button.overlay:SetParent(UIParent);
- button.overlay = nil;
- tinsert(frames, overlay) -- put the frame into the pool to reuse it in the future
- end
- end
- end
- local function GetBuffExpire(unitTarget, buff)
- local n = 1
- local name,_,_,_,_,expire = UnitBuff(unitTarget, n)
- while name do
- if name == buff then
- if expire ~= nil then
- return expire
- end
- end
- n = n + 1
- name,_,_,_,_,expire = UnitBuff(unitTarget, n)
- end
- return -1
- end
- local pummelGlowFlag = false
- function WHUD_Glow_OnUpdate() -- the Glow OnUpdate will hide it again
- for i=1,table.getn(WHUD_SPELLS) do
- local name = WHUD_SPELLS[i]
- if WHUD_VARS.Glow["Execute"] and name == "Execute" then
- if UnitExists("target") then
- local ap = 2755.5
- local playerAP = 0
- if not WHUD_VARS.Alerts["Impexecute"] and WHUD_VARS.Alerts["4T6"] then ap = 2895.5 end
- if WHUD_VARS.Alerts["Impexecute"] and not WHUD_VARS.Alerts["4T6"] then ap = 2988.8 end
- if WHUD_VARS.Alerts["Impexecute"] and WHUD_VARS.Alerts["4T6"] then ap = 3128.8 end
- local base, posBuff, negBuff = UnitAttackPower("player")
- playerAP = base + posBuff + negBuff
- local HPperc = math.floor((UnitHealth("target")/UnitHealthMax("target")) * 100)
- if playerAP >= ap then
- if HPperc > 19 or UnitIsDeadOrGhost("target") or not UnitCanAttack("player","target") then
- Glow_Spell("Execute",false)
- Glow_Spell("Bloodthirst",false)
- else
- Glow_Spell("Execute",false)
- Glow_Spell("Bloodthirst",true)
- end
- elseif playerAP < ap then
- if HPperc > 19 or UnitIsDeadOrGhost("target") or not UnitCanAttack("player","target") then
- Glow_Spell("Execute",false)
- Glow_Spell("Bloodthirst",false)
- else
- Glow_Spell("Execute",true)
- Glow_Spell("Bloodthirst",false)
- end
- end
- else
- Glow_Spell("Execute",false)
- Glow_Spell("Bloodthirst",false)
- end
- end
- if WHUD_VARS.Glow["Overpower"] then
- if name == "Overpower" then
- --local _,_, active = GetShapeshiftFormInfo(1)
- if not IsUsableSpell("Overpower") then
- Glow_Spell("Overpower",false)
- end
- elseif IsUsableSpell("Overpower") then Glow_Spell("Overpower",true) end
- end
- if WHUD_VARS.Glow["Revenge"] then
- if name == "Revenge" then
- local _,_, active = GetShapeshiftFormInfo(2)
- if not active or not IsUsableSpell("Revenge") then
- Glow_Spell("Revenge",false)
- end
- elseif IsUsableSpell("Revenge") and GetShapeshiftForm() == 2 then Glow_Spell("Revenge",true) end
- end
- if name == "Battle Shout" then
- local doneGlow = false
- if WHUD_VARS.Glow["Battleshout"] then
- if GetBuffExpire("player", name) > 10 then
- doneGlow = true
- Glow_Spell(name, false)
- else
- doneGlow = true
- Glow_Spell(name, true)
- end
- end
- if doneGlow == false then
- Glow_Spell(name, false)
- end
- end
- if name == "Commanding Shout" then
- local doneGlow = false
- if WHUD_VARS.Glow["Commanding"] then
- if GetBuffExpire("player", name) > 10 then
- doneGlow = true
- Glow_Spell(name, false)
- else
- doneGlow = true
- Glow_Spell(name, true)
- end
- end
- if doneGlow == false then
- Glow_Spell(name, false)
- end
- end
- if WHUD_VARS.Glow["Rampage"] and name == "Rampage" then
- local active = false
- if GetBuffExpire("player", name) > 6 then
- active = true
- end
- if not active and UnitAffectingCombat("player") then Glow_Spell("Rampage", true) else Glow_Spell("Rampage", false) end
- end
- if WHUD_VARS.Glow["Pummel"] and name == "Pummel" then
- -- Check if the unit exists and is attackable
- local doGlow = false
- if UnitExists("target") and UnitCanAttack("player","target") then
- -- Check if the unit is casting a spell
- local spellName,_,_,_,_,endTime = UnitCastingInfo("target")
- if spellName ~= nil and endTime ~= nil then
- if tContains(blacklistedInterruptableSpells, spellName) == nil then
- -- Check if the endtime of the spell is less than our current cooldown on our interrupt
- local spellTimeLeft = (endTime / 1000.0) - GetTime()
- local interruptSpellCastAtTime,interruptSpellMaximumCooldown,_ = GetSpellCooldown("Pummel")
- if endTime ~= nil and interruptSpellCastAtTime ~= nil then
- local currentCooldown = interruptSpellMaximumCooldown - (GetTime() - interruptSpellCastAtTime)
- if currentCooldown < spellTimeLeft then
- -- Glow the interrupt spell
- doGlow = true
- Glow_Spell("Pummel", true)
- if pummelGlowFlag == false then
- PlayInterruptSound()
- pummelGlowFlag = true
- end
- end
- end
- end
- end
- end
- -- Check if we did not set the glow
- if doGlow == false then
- -- Remove glow from the interrupt spell
- pummelGlowFlag = false
- Glow_Spell("Pummel", false)
- end
- end
- if WHUD_VARS.Glow["Bash"] and name == "Shield Bash" then
- if UnitExists("target") and GetShapeshiftForm() == 2 then
- local name,_,_,_,_,endTime = UnitCastingInfo("target")
- local cd = 0
- local finish = 0
- _,cd,_ = GetSpellCooldown("Shield Bash")
- if endTime ~= nil then finish = endTime/1000 - GetTime() end
- if name ~= nil and cd < finish and UnitCanAttack("player","target") then canInterrupt = true else canInterrupt = false end
- if not flag and canInterrupt then PlayInterruptSound() flag = true end
- if name == nil then flag = false end
- if canInterrupt and not UnitIsDeadOrGhost("target") and UnitCanAttack("player","target") and GetShapeshiftForm() == 2 then
- Glow_Spell("Shield Bash", true)
- elseif not canInterrupt or UnitIsDeadOrGhost("target") or not UnitCanAttack("player","target") or not GetShapeshiftForm() == 2 then
- Glow_Spell("Shield Bash", false)
- end
- else
- Glow_Spell("Shield Bash", false)
- end
- end
- if WHUD_VARS.Glow["Heroicstrike"] and name == "Heroic Strike" then
- if UnitExists("target") then
- if UnitMana("player") < WHUD_VARS.Ragebar["threshold"] or UnitIsDeadOrGhost("target") or not UnitCanAttack("player","target") then
- Glow_Spell("Heroic Strike", false)
- elseif UnitMana("player") >= WHUD_VARS.Ragebar["threshold"] and not UnitIsDeadOrGhost("target") and UnitCanAttack("player","target") then
- Glow_Spell("Heroic Strike", true)
- end
- else
- Glow_Spell("Heroic Strike", false)
- end
- end
- end
- end
- function WHUD_Glow_OnEvent(event,arg1,arg2,arg3)
- if event == "UPDATE_BONUS_ACTIONBAR" then
- for i=1,table.getn(WHUD_IMPORTANTSPELLS)+5 do
- local name = WHUD_IMPORTANTSPELLS[i]
- if i == table.getn(WHUD_IMPORTANTSPELLS)+1 then name = "Overpower"
- elseif i == table.getn(WHUD_IMPORTANTSPELLS)+2 then name = "Revenge"
- elseif i == table.getn(WHUD_IMPORTANTSPELLS)+3 then name = "Pummel"
- elseif i == table.getn(WHUD_IMPORTANTSPELLS)+4 then name = "Shield Bash"
- elseif i == table.getn(WHUD_IMPORTANTSPELLS)+5 then name = "Execute" end
- if WHUD_GLOWING[name] ~= nil then
- Glow_Spell(name,false)
- Glow_Spell(name,true)
- end
- end
- elseif event == "PLAYER_DEAD" then
- for i=1,table.getn(WHUD_GLOWING) do
- Glow_Spell(WHUD_GLOWING[i],false)
- end
- end
- end
- function HasGlow(button)
- for i=1,table.getn(WHUD_SPELLS) do
- if WHUD_GLOWING[WHUD_SPELLS[i]] then
- for j=1,table.getn(WHUD_GLOWING[WHUD_SPELLS[i]]) do
- if WHUD_GLOWING[WHUD_SPELLS[i]][j] == button then
- return WHUD_SPELLS[i]
- end
- end
- end
- end
- return nil
- end
- function IsBuffed(unit, spell)
- for i=0,16 do
- local name = UnitBuff(unit, i)
- if name == spell then
- return true
- end
- end
- return false
- end
- function IsDebuffed(unit, spell)
- for i=0,16 do
- local name = UnitDebuff(unit, i)
- if name == spell then
- return true
- end
- end
- return false
- end
- function GetOverlay()
- -- Credits to Numielle @ Feenix(wow-one.com/forum) for this code
- local overlay = tremove(frames)
- if ( not overlay ) then
- framecount = framecount + 1
- overlay = CreateFrame("Frame", "ActionButtonOverlay"..framecount)
- overlay:SetFrameStrata("TOOLTIP")
- overlay.background = overlay:CreateTexture(nil, "BACKGROUND")
- overlay.background:SetTexture("Interface\\AddOns\\Lulleh_WarriorHUD\\textures\\IconAlert")
- overlay.background:SetTexCoord(0.0546875, 0.4609375, 0.30078125, 0.50390625)
- overlay.background:SetAllPoints(overlay)
- overlay.glow = overlay:CreateTexture(nil, "MEDIUM")
- overlay.glow:SetTexture("Interface\\AddOns\\Lulleh_WarriorHUD\\textures\\IconAlertAnts")
- overlay.glow:SetTexCoord(AntTexCoords[1][1], AntTexCoords[1][2], AntTexCoords[1][3], AntTexCoords[1][4])
- overlay.glow:SetAllPoints(overlay)
- end
- return overlay
- end
- end
Add Comment
Please, Sign In to add comment