Quantcast UnitPower returns an integer - WoWInterface
Thread Tools Display Modes
07-08-17, 09:18 PM   #1
Modinstaller
A Defias Bandit
Join Date: Jul 2017
Posts: 2
UnitPower returns an integer

Even if it isn't really one.

Making a weakaura : I'm trying to track my astral power, and more importantly predict what it's going to be after my next cast. Lunar Strike gives 12 ap, 15 ap with Blessing of Elune (*1.25), 22.5 with BoE + Celestial Alignment (*1.25 *1.5).

So, even if my ap is in reality, say, 17.5, the game will only return me 17, and my prediction will be 39 (or 39.5) for my next BoE+CA buffed LS instead of 40. This is unwanted, since knowing whether I'll be at 39 or 40 is critical to predict if I'm going to be able to use Starsurge or not.

Right now, the only two choices I see to solve this are either entirely rewrite the AP calculation function to try and get an accurate float AP amount ... or count the number of times I've cast CA buffed LS and alternate between adding 22 and 23 ap to my current amount (and I'll also have to account for the fact that .5 ap can disappear if I cap out).
Obviously the second solution is the easiest (since there is only one source for gaining .5 ap - CA buffed LS - and one source for losing it - capping out -). But neither this one nor the first are entertaining to me.

Since I'm a complete novice at both programming and using WoW's API, I was hoping someone might have a magical solution for me that might save some hassle.

Thanks for taking the time to help
  Reply With Quote
07-09-17, 01:53 AM   #2
lightspark
A Frostmaul Preserver
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 294
Use UnitPower's 3 arg to get unmodified values.

Lua Code:
  1. local mod = UnitPowerDisplayMod(8) -- returns 10
  2. local cur_mod = UnitPower("player", 8) -- let's say it returns 15
  3. local cur_unmod = UnitPower("player", 8, true) -- will return 150

You can divide unmodified value by modifier later, when you need to do so.
__________________
  Reply With Quote
07-09-17, 08:09 AM   #3
Modinstaller
A Defias Bandit
Join Date: Jul 2017
Posts: 2
Thanks, that worked perfectly !

I've ran into another problem : at first I was just checking whether I was casting or not (at every frame). This worked fine but not only did I have a small problem with buffs falling off in the middle of a cast, I also thought I might optimize it by checking for combat log events. Now, it works fine, except when I start casting something and interrupt it in the following split second.
If I do that, the game sends me a SPELL_CAST_START, but no following SPELL_CAST_SUCCESS or SPELL_CAST_FAILED, so I'm still thinking I'm casting.

Now the only way I can figure out how to fix that is revert to my first implementation : check if I'm casting every frame.
Is that the only choice I have ?

Thanks for the help.

Edit : I didn't try looking for SPELL_CAST_INTERRUPTED, maybe that's what I was missing.

Last edited by Modinstaller : 07-09-17 at 08:57 AM.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » UnitPower returns an integer

Thread Tools
Display Modes

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