Thread Tools Display Modes
02-28-14, 04:04 AM   #1
Pyrates
A Cliff Giant
 
Pyrates's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 77
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!
__________________
" ... and the Vogon will do things to you that you wish you'd never been born, or, if you're a clearer minded thinker, that the Vogon had never been born."
  Reply With Quote
02-28-14, 02:42 PM   #2
Tim
A Rage Talon Dragon Guard
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 309
Change
Code:
oUF.Tags.Events["enhdead"] = "UNIT_CONNECTION".." PLAYER_UNGHOST".." PLAYER_DEAD".." PLAYER_ALIVE"
to
Code:
oUF.Tags.Events["enhdead"] = "UNIT_HEALTH"
__________________
AddOns: Tim @ WoWInterface
Battle Tag: Mysterio#11164
Current PC Setup: PCPartPicker List
  Reply With Quote
02-28-14, 04:09 PM   #3
Pyrates
A Cliff Giant
 
Pyrates's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 77
Thanks for trying to help, but I'll just quote myself:

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.
__________________
" ... and the Vogon will do things to you that you wish you'd never been born, or, if you're a clearer minded thinker, that the Vogon had never been born."
  Reply With Quote
02-28-14, 04:58 PM   #4
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
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

Last edited by p3lim : 03-01-14 at 02:57 AM.
  Reply With Quote
02-28-14, 07:32 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by p3lim View Post
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
Originally Posted by Pyrates View Post
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.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
03-01-14, 02:56 AM   #6
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by Phanx View Post
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.
  Reply With Quote
03-01-14, 12:45 PM   #7
Pyrates
A Cliff Giant
 
Pyrates's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 77
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!
__________________
" ... and the Vogon will do things to you that you wish you'd never been born, or, if you're a clearer minded thinker, that the Vogon had never been born."
  Reply With Quote
03-02-14, 06:47 AM   #8
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
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.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Events for Ghost, Dead, Offline

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