ArcHUD3 Classic

ArcHUD3 Classic

30.3k Downloads

Suggestion: Demon Hunter Soul Fragments Bar #96

nyyr opened this issue ยท 1 comments

commented

Garrett128 created this issue Sep 14, 2017

Hi,

As asked to do on the archud 3 curse comments page, i am writing this to create a ticket about the demon hunter bar i have been using.

Basically it is a buff bar, as demon hunter's secondary resource, Soul Fragments, is beeing kept track of within a buff.

What i did, if i remember correctly, is use the code for the custom buff bar code as template and tracked this bar's charges :

local _, _, _, count = UnitAura(self.unit, "Soul Fragments")

This gave me the number for the buff bar and for the OnEvent function i simply used the UnitAura event :

self:RegisterEvent("UNIT_AURA", "UpdatePower", self.unit);

Anyways, since it is not that long i can post the code here :

local module = ArcHUD:NewModule("SoulFragments")
local _, _, rev = string.find("$Rev: 109 $", "([0-9]+)")
module.version = "1.0 (r" .. rev .. ")"

module.unit = "player"
module.noAutoAlpha = nil

module.defaults = {
profile = {
Enabled = true,
Outline = true,
Flash = false,
Side = 2,
Level = 1,
ShowSeparators = true,
Color = {r = 0.3, g = 0.3, b = 1},
RingVisibility = 2, -- always fade out when out of combat, regardless of ring status
}
}
module.options = {
attach = true,
hasseparators = true,
}
module.localized = true

function module:Initialize()
-- Setup the frame we need
self.f = self:CreateRing(true, ArcHUDFrame)
self.f:SetAlpha(0)

self:CreateStandardModuleOptions(55)

end

function module:OnModuleUpdate()
self:UpdateColor()
end

function module:OnModuleEnable()
local _, class = UnitClass("player")
if (class ~= "DEMONHUNTER") then return end

local showBar = false;

self.f.dirty = true
self.f.fadeIn = 0.25

self:UpdateColor()

-- Register the UNIT_AURA event we need for detecting the buff
self:RegisterEvent("UNIT_AURA", "UpdatePower", self.unit);

-- Show the bar
showBar = true;
self.f:SetShown(showBar);

-- Activate ring timers
self:StartRingTimers()

end

function module:UpdatePowerRing()
local maxPower = 5
local num = 0

local _, _, _, count = UnitAura(self.unit, "Soul Fragments")
if count then 
	num = count
else 
	num = 0
end

self.f:SetMax(maxPower)
self.f:SetValue(num)

--self:Debug(1, "UpdatePowerRing(): %d/%d", num, maxPower)

if (num < maxPower and num >= 0) then
	self.f:StopPulse()
	self.f:UpdateColor(self.db.profile.Color)
else
	if (self.Flash) then
		self.f:StartPulse()
	else
		self.f:StopPulse()
	end
end

end

function module:UpdatePower(event, arg1, arg2)
if (event == "UNIT_POWER_FREQUENT") then
if (arg1 == self.unit and (arg2 == "ARCANE_CHARGES")) then
self:UpdatePowerRing()
end
elseif (event == "PLAYER_TALENT_UPDATE") then
self:CheckSpecialization()
self:UpdatePowerRing()
else
self:UpdatePowerRing()
end
end

There are forcefully still some references to be worked out but this should speed things up should you decide to implement it.

Cheers and thanks for this great addon,

Garrett

commented

Since this is a buff, this can be realized with the custom buff arc configuration. Thus, I'm currently not inclined to add this as a default arc.

If there should be a "huge" demand (or if it doesn't work with the custom buff arc), please reopen this ticket.

Anyway, thanks for the suggestion!