tirem / HXUI

A set of UI elements for Ashita v4
GNU General Public License v3.0
47 stars 17 forks source link

Display duration of (de)buffs on target bar? #50

Open ConteAlmaviva opened 7 months ago

ConteAlmaviva commented 7 months ago

If your current target is an enemy, the target bar of HXUI will show all the buff/debuff icons that it is aware of currently active on that enemy. It looks like in debuffhandler.lua, it does also keep track of the default expiration time of each buff, storing it in a table debuffs[target.Id][debuffId] = expiry where expiry is the time at the (de)buff's application plus the duration of the debuff assuming no resist and doesn't take into account any added duration from gear/merits/job points, etc. Would it be possible to draw this number on screen underneath the debuff to show estimated time remaining? (e.g. in the screenshot below it could show a 30 second countdown under the Dia icon, 22s under Slow, etc.)

image

ConteAlmaviva commented 7 months ago

FWIW, I took a stab at this and it seems to work relatively OK.

image

I'm sure there's a better way to do it than I've done here. I modified debuffHandler to return an additional table in the GetActiveDebuffs function--as initially written it returns a table of all the debuff IDs (the keys of the debuffHandler.enemies[serverId] table). I added an additional statement to gather the values stored alongside those IDs (the time remaining on each debuff based on non-resisted duration of the debuff as far as I can tell) and return a second table with those values back to targetBar. I then pass that second table to the DrawStatusIcons function in helpers.lua, and when it's drawing each icon I have it draw a text object underneath the icon with the corresponding time remaining value out of the second table. There's also some logic in targetbar.lua to go through and delete the text objects if you have a different target (or no target) selected. Done some initial testing and it seems to do fine keeping track of multiple enemies, etc. Forked here: https://github.com/ConteAlmaviva/HXUI/