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 = ... 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 ? |
For paladin, compare the new amount of combo points to the previous amount. Only beep if the new amount is greater.
|
As Haleth suggested the same can be done for warlocks with a slight adjustment. The only difference being that Warlock resources (possibly with the exception of Soul Shards) are generated fractionally. It takes 10 Ember Bits to fill a Burning Ember and 1000 Demonic Fury to fill the bar (I've no idea about Soul Shards as I've never played Affliction).
Dividing by 10 on Burning Ember power will tell you how many Burning Embers you have. I don't know how you'd want to handle Demonic Fury as that's not really a combo point system (perhaps every 250?). Although you asked for improvements I'm not sure you meant efficiency/superfluous code issues. There are a few but they could just be individual to me.. e.g. using RegisterEvent() instead of RegisterUnitEvent(), registering events for classes that don't need them, UnitMaxPower() variants on each UNIT_POWER even though most of them are constant (and those that aren't fire an event for it), etc. |
Quote:
|
I didn't realise you wanted a solution and not a hint (which is a good thing as I meant divide by 10 not modulo by it).
With changing as little as possible: Lua Code:
|
There we go, i wasn't resetting "numPrevious"...
Now let's try. |
It seems UnitPower("player", SPELL_POWER_BURNING_EMBERS) returns a count of only full embers not total ember bits. Updated code.
|
Well, so far i've tried paladins and all 3 warlock specs and those work great, thank you !
|
In the interests of reducing code duplication, and reducing the number of function calls and global lookups (checking the class and spec on every power update is quite wasteful) I would rewrite that like so:
Lua Code:
Also you may want to upvalue UnitPower, UnitPowerMax, and math.floor to speed things up. |
Phanx, i only copy pasted but yours doesn't seems to work :( as in, no error but doesn't do a thing.
Edit: That's because you use "SPELL_POWER_HOLY_POWER" which returns 9 instead of "HOLY_POWER" Hmm, even like that, there are other issues. |
Fixed the power types, but unless you can be more specific than "it has issues" there's not much I can do (other than leveling each class to the appropriate level to get the secondary resource and testing it myself, which I'm certainly not going to do)....
|
Oh no don't worry i understand, unfortunately i can't be more specific right now, i don't have a warlock and i have to log a friend's account but i can't now because he's playing it.
I'll get back to you with more details as soon as i can log it in. Only one thing i can see right now is, you're only defining the warlock spec on "PLAYER_SPECIALIZATION_CHANGED" and not on PEW but as i said i can't test anything. |
PLAYER_SPEC should fire shortly after login; there shouldn't be any reason to listen to PEW.
|
Quote:
|
Actually I just checked; PLAYER_SPEC only fires on login, not on reload (though on reload the spec is available immediately). So, I'd just register PLAYER_LOGIN for warlocks too. I've updated the code in my previous post again.
|
Well, something is wrong, at least on the paladin, the beeps come randomly, sometimes they do, sometimes they don't and i can't find any pattern. Also, it beeps when i use the holy power points which it shouldn't since it's a decrease and not an increase.
That's what i've noticed after a quick test. |
Just a note for warlock:
Those magic 10 are contained in the global MAX_POWER_PER_EMBER. Code:
UnitPower("player", SPELL_POWER_BURNING_EMBERS) Code:
math.floor(UnitPower("player", SPELL_POWER_BURNING_EMBERS, true) / MAX_POWER_PER_EMBER) |
Phanx, i believe i have it working for everyone with your version, let me know what you think:
Code:
local _, caelUI = ... |
First and foremost, stop doing this:
Code:
for _, event in next, { Code:
caelUI.powersound:RegisterUnitEvent("UNIT_COMBO_POINTS", "player") (1) Rather than POWER_TYPE and SPELL_POWER_TYPE, I'd use variable names that more clearly identified what they are, such as POWER_TYPE_NAME and POWER_TYPE_ID. (2) Mixing upvalues and local variables like this seems sloppy: Code:
local floor, numPrevious = math.floor, 0 Code:
local floor, UnitPower, UnitPowerMax = math.floor, UnitPower, UnitPowerMax Lua Code:
|
You also don't have a local reference to MAX_COMBO_POINTS. You don't check for vehicle combo points either (there was a daily rep quest back in WotLK that used that, maybe there are others too). You could also set MAX_POWER to 4 for warlocks as long you are not using this for demonology and spare a function call in that case.
|
All times are GMT -6. The time now is 08:17 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI