Thread Tools Display Modes
Prev Previous Post   Next Post Next
02-19-14, 05:32 AM   #1
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
Misc issues with an addon

Hi, so i've had this little addon issuing a sound for each combo point and then another sound to warn me when i reached 5 (some people use bars on their screen for that, i prefer sounds) but then i decided i wanted to level a paladin and thought, why not make this work for each classes that this kind of "points".

So i came up with this:

Code:
local _, caelUI = ...

caelUI.powersound = caelUI.createModule("PowerSound")

local num, numMax, power, spec

local powers = {
	["MONK"]		=	"CHI",
	["PALADIN"]	=	"HOLY_POWER",
	["PRIEST"]	=	"SHADOW_ORBS",
	["WARLOCK"] = {
		[1]		=	"SOUL_SHARDS",
		[2]		=	"DEMONIC_FURY",
		[3]		=	"BURNING_EMBERS",
	}
}

caelUI.powersound:SetScript("OnEvent", function(self, event, unit, powerType)
	if unit ~= "player" then return end

	if event == "UNIT_COMBO_POINTS" then
		num = GetComboPoints("player", "target")
		numMax = MAX_COMBO_POINTS

		if num ~= 0 and num ~= numMax then
			PlaySoundFile(caelMedia.files.soundCombo, "Master")
		elseif num == numMax then
			PlaySoundFile(caelMedia.files.soundComboMax, "Master")
		end
	end

	if event == "UNIT_POWER" then
		spec = GetSpecialization()

		if powerType ~= powers[caelUI.playerClass] and powerType ~= powers[caelUI.playerClass][spec] then return end

		if caelUI.playerClass == "MONK" then
			num = UnitPower("player", SPELL_POWER_CHI)
			numMax = UnitPowerMax("player", SPELL_POWER_CHI)
		elseif caelUI.playerClass == "PALADIN" then
			num = UnitPower("player", SPELL_POWER_HOLY_POWER)
			numMax = UnitPowerMax("player", SPELL_POWER_HOLY_POWER)
		elseif caelUI.playerClass == "PRIEST" then
			num = UnitPower("player", SPELL_POWER_SHADOW_ORBS)
			numMax = PRIEST_BAR_NUM_ORBS -- UnitPowerMax("player", SPELL_POWER_SHADOW_ORBS)
--[[
		elseif caelUI.playerClass == "WARLOCK" then
			if spec then
				if spec == SPEC_WARLOCK_AFFLICTION then
					num = UnitPower("player", SPELL_POWER_SOUL_SHARDS)
					numMax = UnitPowerMax("player", SPELL_POWER_SOUL_SHARDS)
				elseif spec == SPEC_WARLOCK_DEMONOLOGY then
					num = UnitPower("player", SPELL_POWER_DEMONIC_FURY)
					numMax = UnitPowerMax("player", SPELL_POWER_DEMONIC_FURY)
				elseif spec == SPEC_WARLOCK_DESTRUCTION then
					num = UnitPower("player", SPELL_POWER_BURNING_EMBERS)
					numMax = UnitPowerMax("player", SPELL_POWER_BURNING_EMBERS)
				end
			end
--]]
		end

		if num ~= 0 and num ~= numMax then
			PlaySoundFile(caelMedia.files.soundCombo, "Master")
		elseif num == numMax then
			PlaySoundFile(caelMedia.files.soundComboMax, "Master")
		end
	end
end)

for _, event in next, {
	"UNIT_COMBO_POINTS",
	"UNIT_POWER",
} do
	caelUI.powersound:RegisterEvent(event)
end
Obviously, for combo points it works perfectly, but for other classes not so much.

The issues (that i need help with) are the following:

Paladin: Over time, the Holy power decreases and the problem is that each time i loose one point, it beeps, it shouldn't.
Warlock: This one is the worst, different power source for each spec, the power does decrease over time, burning embers seems to beep for every spell i cast, not just when i gain one ember, in fewer words, warlocks are a mess.

Anyone would have any idea how i could improve this little addon ?
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Misc issues with an addon


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off