WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Events for Ghost, Dead, Offline (https://www.wowinterface.com/forums/showthread.php?t=49012)

Pyrates 02-28-14 04:04 AM

Events for Ghost, Dead, Offline
 
Hey, I have the following tag:

Code:

oUF.Tags.Events["enhdead"] = "UNIT_CONNECTION".." PLAYER_UNGHOST".." PLAYER_DEAD".." PLAYER_ALIVE"
oUF.Tags.Methods["enhdead"] = function(u)

        if(UnitIsDead(u)) then
                return 'Dead'
        elseif(UnitIsGhost(u)) then
                return 'Ghost'
        elseif(not UnitIsConnected(u)) then
                return 'Off'
        end
               
end

Seems simple enough. Only, the events never seem to fire... at least the player events, I did not test for unit_connection. If I add "UNIT_HEALTH", everything works as expected, so the tag is ok, the string is there... But this seems wasteful. Does anyone know what's up here or has a better idea? I really want death/ghost/offline in my frames :) Thanks for any help!

Tim 02-28-14 02:42 PM

Change
Code:

oUF.Tags.Events["enhdead"] = "UNIT_CONNECTION".." PLAYER_UNGHOST".." PLAYER_DEAD".." PLAYER_ALIVE"
to
Code:

oUF.Tags.Events["enhdead"] = "UNIT_HEALTH"

Pyrates 02-28-14 04:09 PM

Thanks for trying to help, but I'll just quote myself:

Quote:

If I add "UNIT_HEALTH", everything works as expected, so the tag is ok, the string is there... But this seems wasteful.
So I know how to work around it alright, I'm just not happy about that solution.

p3lim 02-28-14 04:58 PM

All of the (if not, atleast a lot of the) PLAYER_* events are something we like to call "unitless events", basically the first argument is not the unit affected, in this case, the first argument would be "player".

The way oUF handles these events is you have to register them in a special way, like so:
Code:

oUF.Tags.SharedEvents['PLAYER_UNGHOST'] = true
oUF.Tags.SharedEvents['PLAYER_DEAD'] = true
oUF.Tags.SharedEvents['PLAYER_ALIVE'] = true

oUF.Tags.Events['enhdead'] = 'UNIT_CONNECTION PLAYER_UNGHOST PLAYER_DEAD PLAYER_ALIVE'
oUF.Tags.Methods['enhdead'] = function(u)
        if(UnitIsDead(u)) then
                return 'Dead'
        elseif(UnitIsGhost(u)) then
                return 'Ghost'
        elseif(not UnitIsConnected(u)) then
                return 'Off'
        end       
end


Phanx 02-28-14 07:32 PM

Quote:

Originally Posted by p3lim (Post 291195)
I wish you could apply them specifically to a tag instead of applying them globally, but there isn't a way without hacking on the element.

I'm not really sure what you mean by this. Adding events to the SharedEvents table doesn't do anything other than tell oUF to go ahead and process the event anyway if arg1 doesn't match the value of the unit key on the frame:

Code:

if(fontstring:IsVisible() and (unitlessEvents[event] or fontstring.parent.unit == unit)) then
Quote:

Originally Posted by Pyrates (Post 291193)
So I know how to work around it alright, I'm just not happy about that solution.

Well, regardless of how happy or unhappy you are about it, that's the only solution. The PLAYER_* events only fire for the player unit -- your own character. If you want to show Dead/Offline/Ghost on other units' frames, you must use the UNIT_* events. UNIT_HEALTH will tell you when someone becomes dead or alive. UNIT_CONNECTION will tell you when someone goes offline or comes back online. If you want to track Ghost separately from Dead, you'll also need to listen to UNIT_AURA and look for UnitBuff(unit, GHOST) where GHOST is the result of GetSpellInfo(8326) or, if you don't care about non-English players, just UnitBuff(unit, "Ghost").

Your layout is presumably already responding to UNIT_HEALTH and UNIT_AURA to update things like health bars and buff icons, so having it additionally update your Dead/Offline/Ghost text on those events is really not adding any significant overhead.

p3lim 03-01-14 02:56 AM

Quote:

Originally Posted by Phanx (Post 291196)
I'm not really sure what you mean by this. Adding events to the SharedEvents table doesn't do anything other than tell oUF to go ahead and process the event anyway if arg1 doesn't match the value of the unit key on the frame

You're right, I read the code as if it iterated over all tags once the event fired.

Pyrates 03-01-14 12:45 PM

Aww crud, I kinda forgot that PLAYER* probably doesn't fire for raid units... Still, UNIT_HEALTH does feel like the wrong event, it fires quite a bit and this is not really neede for dead etc. I'm not sure UNIT_HEALTH is used anywhere else, health uses UNIT_HEALTH_FREQUENT nowadays, doesn't it? On the other hand, it fires for becoming ghost as well, so no need for UNIT_AURA :)

Thanks for all your help!

Rainrider 03-02-14 06:47 AM

You don't need to watch for UNIT_AURA to get the ghost status. UNIT_HEALTH suffices because dead and ghosted players have different health (yes, this is strange).

UNIT_HEALTH_FREQUENT (UHF) is just the same as UNIT_HEALTH (UH) but fires a lot more frequently. I personally find the lags of UH hardly noticeable and as I don't play a healer I'm not that interested in health status, thus I use UH for my raid frames. The only place currently where you have to use UHF is boss frames, because there seems to be a bug there which causes only the targeted boss' health to update if you use UH.


All times are GMT -6. The time now is 09:12 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI