kEnergy

kEnergy is an energy ticker which maintains a running average and standard
deviation to ensure that the tick interval matches when your energy is really
coming in. Unfortunately, energy ticks do not occur at precise 2 second
intervals, nor do they always come in increments of exactly 20 energy, so a
more adaptive solution was sought. By maintaining the average and throwing
out outlying tick offsets, this addon is able to be more accurate than most
(if not all) other energy tickers out there, particularly in environments with
high network latency.

Most aspects of its display can be configured, including color, texture, size,
font size, and bar text (energy, combo points, or both).

Please report any bugs you find to me, as I cannot fix problems which I'm not
aware of! Note that if you run into a problem with the tick offset being
too high (bar ticking too slow):
- Reset the tickoffset (/ke tickoffset 0)
- Enable debugging (/ke debug)
- Fight until the problem is reproduced (assuming it is indeed reproducable)
- Reload your UI or logout.
- Send me the kEnergy.lua from your SavedVariables, as debug mode enabled a
full log of your energy activity over time, so the problem can be isolated.
Be warned, do not keep /ke debug enabled in critical environments, as it is
consuming small amounts of ram (new entry in the energy log) for each energy
gain/loss.

Release ChangeLog:

0.9:
* Make use of the LoadManagers field in the .toc. Only supports ForkliftGnome
as a LoadManager for now.
* Add transparent texture for those only wanting to display the spark, courtesy evl.
* Drop the Metrognome library in favor of AceEvent, and drop SurfaceLib in
favor of SharedMediaLib, courtesy Ammo.
* Respond to talents being trained, for talents that affect energy cost of
abilities, rather than only doing it at load time.
* Predict shiv's energy cost in the energy tracking (special due to the cost
being based on offhand weapon speed).
* Fix debuglevel option to be hidden when debugging is enabled, and to step by 1.

0.8:
* Fix the 'Reset bar position.' option.
* Updated deDE translation, courtesy Viperb0y.
* Standby fixup: Hide the bartext on disable, and reset self.barticking
on enable when we reset the rest of the state.
* Add bartext info to readme and clean up relnotes.
* Locking fixups:
* Method modified to behave more sensibly, fixing the unlock to no longer show
a spark on the bar, and to make bartext never, ever show up before the bar
does.
* Ensure that the code properly handles being locked/unlocked at all times (now
properly handles receiving energy ticks while unlocked).
* Ensure that our knowledge of the tick isn't lost when locking/unlocking.
Previously, if you locked and unlocked, you'd have to go cause an
energy tick for the bar to start ticking again.

0.7:
* By request, add options to display energy / combo points as text on the
bar, and appearance options for that text.
* Kill legacy Combat Potency handling from pre 2.0.3 wow versions.
* Handle 'Shadowmeld' handling for the display when in stealth option.
* Bump Interface # in .toc.
* Add deDE translation, courtesy trh_.
* Fix the missing self.tickamount variable for druids.
* Fix bug which could result in a tickoffset which is too large, if high
latency was encountered during the initial world entry.
* Fix issue reported by Guillotine where the bar never came back after leaving
cat form.
* Work around a Blizzard annoyance - apparently, when shifting into cat form,
you can receive a UNIT_ENERGY event before getting the PLAYER_AURAS_CHANGED
which tells us we're now in cat form.
* Substantial rework of the way our ticks were being simulated and how that
interacted with real energy ticks. There is no longer a small period of
time between one timer bar completing and the next one starting. It now
starts the next one immediately, and adjusts the end time of that next one
when the expected energy event arrives.
* General cleanup and enhancements to the code.

0.61:
* Add the missing debug level localization.. oops.

0.6:
* Add option to fill the bar rather than emptying it.
* Fix handling of adrenaline rush.
* Fix the bug resulting in one extra bar tick upon reaching max energy (it should stop immediately now).
* Fix 'standby'.
* Store spell costs by name -and- rank.
* Ensure that energy ticks from units other than 'player' (i.e. party members) don't throw off our ticking.
* Maintain spell cost state using _SENT to ensure that multiple _SUCCEEDED spellcast events from a single cast don't throw off our energy predictions (was mainly an issue with mutilate).
* Set the player's max energy correctly for druids upon entering cat form, as the UNIT_MAXENERGY event is not fired upon shapeshifting.

* Maintain an energy activity log in saved vars (wiped on each ui load) when debugging is enabled, so when a problem is encountered, the user can enable debugging and send me the log.
* Fix ordering of our options.
* Add option to set the debug level (a level of 2 shows the energy log in the chat frame).
* SurfaceLib support: kill Surface_Registered handling, as it's unnecessary now, and add handling of Surface_SetGlobal.

0.5:
* Switch the prints to debug output, so will not spam by default anymore.
* Fixed handling of Combat Potency on live servers.
* Properly reset the tick cycle on player death.
* Alter the logic in self:tick() to fix some bar stutter.
* Rename a variable to avoid stepping on the toes of AceOO/AceConsole, which was resulting in the "standby" and profile options missing from our configuration menu / chat.
* Properly reset the tick cycle upon losing the Cat Form buff -- should fix the tick times getting screwed up on shapeshifts (thanks for the bug report folks, I don't have a druid that I play regularly).

0.4
* Added right click menu for configuration while unlocked.
* Added option to reset bar position to default.
* Completely reworked the averaging code -- we now maintain a running average (mean) and running standard deviation, and throw away outliers (bad values which will screw up the average).
* Added handling of a few circumstances which it was unable to deal with in the past: it more intelligently handles the final tick in a sequence of ticks, it tracks user energy usage to ensure that a 20 energy gain from a 2 charge Arcane Torrent is not misinterpreted as an energy tick, etc.
* Added an option to manually set the tick offset value (can easily reset it back to 0).
* Had druid functionality tested and confirmed happy.

0.3
* Add option for when to show the bar.
* Add more bar textures.
* Show only when in cat form for druids.
* Use a weighted average for the tick time to attempt to compensate for latency.

0.2
* Updated to no longer rely upon SupplyAndDemand for loading (no longer a LoadOnDemad addon) to avoid confusion.

After i give it a try, i found something that i dont like - the energy bar dissappear for a moment when u attack someone and then appear again, and options for when bar is shown are not enough, for example i want to see my bar when i am targeting enemy player or npc no matter in combat or not or in stealth or not. its not great when i gauge someone to re'stealth and my bar disappear when i am out of combat when i stealth it appears and when i attack it disappear again and show after a moment. this combination is really bad , and yes i dont want to see it always.

Originally posted by Critty I seem to be having an issue with KEnergy. Every time I try to unlock KEnergy, the bar disappears. I've turned off all add-ons but KEnergy and I still can't manage to move the bar. Any idea's? Right now I can use Energywatch but it really doesn't add much in the way of customizing the look of the bar.

That's.... really strange. I can't reproduce that, and haven't heard of it before, but I'll see if I can peruse the code and think of the codepath you could be hitting to cause it, and get back to you.

I seem to be having an issue with KEnergy. Every time I try to unlock KEnergy, the bar disappears. I've turned off all add-ons but KEnergy and I still can't manage to move the bar. Any idea's? Right now I can use Energywatch but it really doesn't add much in the way of customizing the look of the bar.

Originally posted by Knifed the bar needs to have a border or outline so you can see where the end of the tick is...
i used bar fill instead of bar drain and i can't see where the end of the tick is so i can't really tell precisely when the tick is coming...

or at least have a right edge outline so u can see where the end of the bar is...

Good idea, I'll add border options for the next release. Honestly, I was hoping to not have to mess with this anymore, it was just -working-, but what the heck, a few small easy to add features that don't deviate from the goal won't hurt anybody

the bar needs to have a border or outline so you can see where the end of the tick is...
i used bar fill instead of bar drain and i can't see where the end of the tick is so i can't really tell precisely when the tick is coming...

or at least have a right edge outline so u can see where the end of the bar is...

Originally posted by Tarmin I do have a feature request, though: I think it would be nice if kEnergy had an option that would show the bar when stealthed and when in combat (and of course when my energy is less than the maximum). At the moment the bar will be hidden when I am in combat but my energy is full.

You've convinced me I've just implemented it in current kEnergy svn (though not the 0.9 release, as it hasn't been tested it). Give it a shot, if you would.

Originally posted by deluXE I just installed the addon, but it doesn't seem to be working at all: no bar on screen and the slash commands don't do a thing.

I'll assume that you're 1) using svn kEnergy and 2) using SupplyAndDemand. I had attempted to make use of LoadManagers with S&D as the load manager, but apparently S&D wasn't loading it properly when it was the load manager. Try the latest release/commits.