diff --git a/ElvUI_SLE/libs/load_libs.xml b/ElvUI_SLE/libs/load_libs.xml index c42ea66..7a138b7 100644 --- a/ElvUI_SLE/libs/load_libs.xml +++ b/ElvUI_SLE/libs/load_libs.xml @@ -1 +1 @@ -<Ui xmlns="http://www.blizzard.com/wow/ui/"> <Script file="oUF_NecroStrike\oUF_NecroStrike.lua"/> </Ui> \ No newline at end of file +<Ui xmlns="http://www.blizzard.com/wow/ui/"> <Script file="oUF_NecroStrike\oUF_NecroStrike.lua"/> <Script file="oUF_Vengeance\oUF_Vengeance.lua"/> </Ui> \ No newline at end of file diff --git a/ElvUI_SLE/libs/oUF_Vengeance/oUF_Vengeance.lua b/ElvUI_SLE/libs/oUF_Vengeance/oUF_Vengeance.lua new file mode 100644 index 0000000..306f4a0 --- /dev/null +++ b/ElvUI_SLE/libs/oUF_Vengeance/oUF_Vengeance.lua @@ -0,0 +1,181 @@ +--[[ + Project.: oUF_Vengeance + File....: oUF_Vengeance.lua + Version.: 40200.5 + Rev Date: 06/28/2011 + Authors.: Shandrela [EU-Baelgun] <Bloodmoon> +]] + +--[[ + Elements handled: + .Vengeance [frame] + .Vengeance.Text [fontstring] + + Code Example: + .Vengeance = CreateFrame("StatusBar", nil, self) + .Vengeance:SetWidth(400) + .Vengeance:SetHeight(20) + .Vengeance:SetPoint("BOTTOM", UIParent, "BOTTOM", 0, 100) + .Vengeance:SetStatusBarTexture(normTex) + .Vengeance:SetStatusBarColor(1,0,0) + + Functions that can be overridden from within a layout: + - :OverrideText(value) + + Possible OverrideText function: + + local VengOverrideText(bar, value) + local text = bar.Text + + text:SetText(value) + end + ... + self.Vengeance.OverrideText = VengOverrideText + + others: + self.Vengeance.showInfight [boolean] + if true, the Vengeance bar will be shown infight, even if you haven't got stacks of Vengeance +--]] +local _, ns = ... +--local oUF = oUF or ns.oUF +local oUF = ElvUF or oUF + +local _, class = UnitClass("player") +local vengeance = GetSpellInfo(93098) + +local UnitAura = UnitAura +local InCombatLockdown = InCombatLockdown + +local tooltip = CreateFrame("GameTooltip", "VengeanceTooltip", UIParent, "GameTooltipTemplate") +local tooltiptext = _G[tooltip:GetName().."TextLeft2"] + +tooltip:SetOwner(UIParent, "ANCHOR_NONE") +tooltiptext:SetText("") + +local function valueChanged(self, event, unit) + if unit ~= "player" then return end + local bar = self.Vengeance + + if not bar.isTank then + bar:Hide() + return + end + + local name = UnitAura("player", vengeance, nil, "PLAYER|HELPFUL") + + if name then + tooltip:ClearLines() + tooltip:SetUnitBuff("player", name) + local value = (tooltiptext:GetText() and tonumber(string.match(tostring(tooltiptext:GetText()), "%d+"))) or -1 + + if value > 0 then + if value > bar.max then value = bar.max end + if value == bar.value then return end + + bar:SetMinMaxValues(0, bar.max) + bar:SetValue(value) + bar.value = value + bar:Show() + + if bar.Text then + if bar.OverrideText then + bar:OverrideText(value) + else + bar.Text:SetText(value) + end + end + end + elseif bar.showInfight and InCombatLockdown() then + bar:Show() + bar:SetMinMaxValues(0, 1) + bar:SetValue(0) + bar.value = 0 + else + bar:Hide() + bar.value = 0 + end +end + +local function maxChanged(self, event, unit) + if unit ~= "player" then return end + local bar = self.Vengeance + + if not bar.isTank then + bar:Hide() + return + end + + local health = UnitHealthMax("player") + local _, stamina = UnitStat("player", 3) + + if not health or not stamina then return end + + bar.max = 0.1 * (health - 15 * stamina) + stamina + bar:SetMinMaxValues(0, bar.max) + + valueChanged(self, event, unit) +end + +local function isTank(self, event) + local masteryIndex = GetPrimaryTalentTree() + local bar = self.Vengeance + + if masteryIndex then + if class == "DRUID" and masteryIndex == 2 then + bar.isTank = true + elseif (class == "DEATH KNIGHT" or class == "DEATHKNIGHT") and masteryIndex == 1 then + bar.isTank = true + elseif class == "PALADIN" and masteryIndex == 2 then + print("Checked") + bar.isTank = true + elseif class == "WARRIOR" and masteryIndex == 3 then + bar.isTank = true + else + bar.isTank = false + bar:Hide() + end + else + bar.isTank = false + bar:Hide() + end + print("IsTank") + + maxChanged(self, event, "player") +end + +local function Enable(self, unit) + local bar = self.Vengeance + + if bar and unit == "player" then + bar.max = 0 + bar.value = 0 + + self:RegisterEvent("UNIT_AURA", valueChanged) + + self:RegisterEvent("UNIT_MAXHEALTH", maxChanged) + self:RegisterEvent("UNIT_LEVEL", maxChanged) + + self:RegisterEvent("PLAYER_REGEN_DISABLED", isTank) + + bar:Hide() + + return true + end +end + +local function Disable(self) + local bar = self.Vengeance + + if bar then + self:UnregisterEvent("UNIT_AURA", valueChanged) + + self:UnregisterEvent("UNIT_MAXHEALTH", maxChanged) + self:UnregisterEvent("UNIT_LEVEL", maxChanged) + + self:UnregisterEvent("PLAYER_REGEN_DISABLED", isTank) + end +end + +oUF:AddElement("Vengeance", nil, Enable, Disable) + +for i, frame in ipairs(oUF.objects) do Enable(frame) end \ No newline at end of file diff --git a/ElvUI_SLE/libs/oUF_Vengeance/oUF_Vengeance.toc b/ElvUI_SLE/libs/oUF_Vengeance/oUF_Vengeance.toc new file mode 100644 index 0000000..24e0937 --- /dev/null +++ b/ElvUI_SLE/libs/oUF_Vengeance/oUF_Vengeance.toc @@ -0,0 +1,8 @@ +## Interface: 40200 +## Author: Shandrela [EU-Baelgun] <Bloodmoon> +## Version: 40200.5 +## Title: oUF Vengeance +## Notes: Vengeance plug-in for oUF +## RequiredDeps: oUF + +oUF_Vengeance.lua \ No newline at end of file diff --git a/ElvUI_SLE/modules/load_modules.xml b/ElvUI_SLE/modules/load_modules.xml index 8afe6be..d74f08d 100644 --- a/ElvUI_SLE/modules/load_modules.xml +++ b/ElvUI_SLE/modules/load_modules.xml @@ -12,4 +12,5 @@ <Include file='skins\load_skins.xml'/> <Include file='uibuttons\load_uibuttons.xml'/> <Include file='unitframes\load_unitframes.xml'/> + <Include file='vengeance\load_vengeance.xml'/> </Ui> \ No newline at end of file diff --git a/ElvUI_SLE/modules/vengeance/load_vengeance.xml b/ElvUI_SLE/modules/vengeance/load_vengeance.xml new file mode 100644 index 0000000..e10f79c --- /dev/null +++ b/ElvUI_SLE/modules/vengeance/load_vengeance.xml @@ -0,0 +1,4 @@ +<Ui xmlns="http://www.blizzard.com/wow/ui/"> + <Script file='vengeance.lua'/> + <Script file='options.lua'/> +</Ui> \ No newline at end of file diff --git a/ElvUI_SLE/modules/vengeance/options.lua b/ElvUI_SLE/modules/vengeance/options.lua new file mode 100644 index 0000000..884b9c1 --- /dev/null +++ b/ElvUI_SLE/modules/vengeance/options.lua @@ -0,0 +1 @@ +local E, L, V, P, G = unpack(ElvUI); --Inport: Engine, Locales, ProfileDB, GlobalDB diff --git a/ElvUI_SLE/modules/vengeance/vengeance.lua b/ElvUI_SLE/modules/vengeance/vengeance.lua new file mode 100644 index 0000000..56f5290 --- /dev/null +++ b/ElvUI_SLE/modules/vengeance/vengeance.lua @@ -0,0 +1,139 @@ +local E, L, V, P, G = unpack(ElvUI); --Engine +local VG = E:NewModule('Vengeance', 'AceHook-3.0', 'AceEvent-3.0'); +local UF = E:GetModule('UnitFrames'); +print("Vengeance loaded") + +local Vbar +local Vstam +local VaddHP +local Vmax +local V_ScanTip = CreateFrame("GameTooltip","VengeanceModuleScanTip",nil,"GameTooltipTemplate") +V_ScanTip:SetOwner(UIParent, "ANCHOR_NONE") + +local function getTooltipText(...) --This stuff is for knowing how much bonus AP we actually have. It's called from aura event function + local text = "" + for i=1,select("#",...) do + local rgn = select(i,...) + if rgn and rgn:GetObjectType() == "FontString" then + text = text .. (rgn:GetText() or "") + end + end + return text == "" and "0" or text +end + +function VG:CreateBar() + Vbar = ElvUF_Player.Vengeance --This is actually from the plugin. idk how to put other functionings from there to the code O_o + Vbar = CreateFrame("StatusBar", nil, ElvUF_Player) + Vbar:CreateBackdrop("Default") + Vbar:Point("TOPLEFT", ElvUF_Player.Power, "BOTTOMLEFT", 0, -4) --2 lines for determining positioning and size + Vbar:Point("BOTTOMRIGHT", ElvUF_Player.Power, "BOTTOMRIGHT", 0, -12) --The bar is docked under power bar for now + Vbar:SetStatusBarTexture(E["media"].normTex) + --Vbar:SetStatusBarColor(1,0,0) --No need atm + + Vbar.value = Vbar:CreateFontString(nil, 'OVERLAY') + Vbar.value:FontTemplate(nil, 10) --Font temeplate. will need to change that to use UF font and size + Vbar.value:SetParent(Vbar) + + Vbar.value:Point("CENTER", Vbar, "CENTER", 0, 0) --May need to change that to be at the keft side instead of center + + --Setting text on initial load as i didn't add a function for player_entering_world event + V_ScanTip:ClearLines() + V_ScanTip:SetUnitBuff("player", GetSpellInfo(93098) or GetSpellInfo(76691)) + local tipText = getTooltipText(V_ScanTip:GetRegions()) + local vengval,percentmax,downtime + vengval = tonumber(string.match(tipText,"%d+")) + percentmax = (vengval/Vmax)*100 + Vbar:SetMinMaxValues(0,Vmax) + Vbar:SetValue(vengval) + Vbar.value:SetText(string.format("%s/%s (%.2f%%)",vengval,Vmax,percentmax)) +end + +function VG:setBaseHPadd() --For knowing base HP bonus to AP + local baseHP + local level = UnitLevel("player"); + + local stat, effectiveStat, posBuff, negBuff = UnitStat("player", 3); + local baseStam = min(20, effectiveStat); + local moreStam = effectiveStat - baseStam; + local healthPerStam = UnitHPPerStamina("player") + local hpFromStam = (baseStam + (moreStam*healthPerStam))*GetUnitMaxHealthModifier("player") + baseHP = UnitHealthMax("player") - hpFromStam + + if baseHP then + VaddHP = floor(baseHP/10) + else + DEFAULT_CHAT_FRAME:AddMessage("ERROR - Unable to calculate baseHP") + end +end + +function VG:SetMax() --For knowing our current maximum AP bonus + Vstam = UnitStat("player", 3); + print("Stamina: "..Vstam) + Vmax = VaddHP + Vstam + print("Maximun Vengeance: "..Vmax) +end + +function VG:UNIT_AURA(...) --Updating on aura event. Setting the values and colors when we gain or loose vengeance bonuses. + local event, unit = ...; + if unit == "player" then + local n,_,_,_,_,_,_,_,_,_,id = UnitAura("player", (GetSpellInfo(93098) or GetSpellInfo(76691))); + if n then + V_ScanTip:ClearLines() + V_ScanTip:SetUnitBuff("player",n) + local tipText = getTooltipText(V_ScanTip:GetRegions()) + local vengval,percentmax,downtime + vengval = tonumber(string.match(tipText,"%d+")) + percentmax = (vengval/Vmax)*100 + print("Percent of vengeance:"..percentmax) + Vbar:SetMinMaxValues(0,Vmax) + Vbar:SetValue(vengval) + Vbar.value:SetText(string.format("%s/%s (%.2f%%)",vengval,Vmax,percentmax)) + if (percentmax <= 25) then + Vbar:SetStatusBarColor(1, 75 / 255, 75 / 255, 0.5, .8) + elseif (percentmax > 25 and percentmax < 60) then + Vbar:SetStatusBarColor(1, 180 / 255, 0, .8) + else + Vbar:SetStatusBarColor(30 / 255, 1, 30 / 255, .8) + end + else + VG:SetMax() + Vbar:SetMinMaxValues(0,Vmax) + Vbar:SetValue(0) + Vbar.value:SetText("0/"..Vmax.." (0.00%)") + end + end +end + +function VG:UNIT_STATS(...) --Updating when our stats are changed + local event, unit = ...; + if unit == "player" then + VG:SetMax() + Vbar:SetMinMaxValues(0,Vmax) + local vengval = Vbar:GetValue() + if vengval and (vengval > 0) then + local percentmax = min(((vengval/Vmax)*100),100) + Vbar.value:SetText(string.format("%s/%s (%.2f%%)",vengval,Vgmax,percentmax)) + else + Vbar.value:SetText("0/"..Vmax.." (0.00%)") + end + end +end + +function VG:Initialize() + VG:setBaseHPadd() + VG:SetMax() + VG:CreateBar() + + --Commented lines are for more events that can influence the bonus + --self:RegisterEvent("ADDON_LOADED") + --self:RegisterEvent("PLAYER_LOGIN") + --self:RegisterEvent("PLAYER_DEAD") + --self:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED") + self:RegisterEvent("UNIT_AURA") + self:RegisterEvent("UNIT_STATS") + --self:RegisterEvent("UNIT_LEVEL") + --self:RegisterEvent("PLAYER_REGEN_ENABLED") + --self:RegisterEvent("PLAYER_REGEN_DISABLED") +end + +E:RegisterModule(VG:GetName()) \ No newline at end of file