Thread Tools Display Modes
10-28-09, 10:43 PM   #1
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
dynamical changing of frames for PvP (... or PvE)

I got a request from someone who wants to have a debuff filter removed for PvP/arena. Which made me ask myself if there is a way to "dynamically" change the filter (and maybe other things, too) based on the zone the player is in.

Which would be in this case PvP/BG zone OR else.


I checked Skada (because I remembered it has an option to hide in PvP) and it has the following function(s):

Code:
local wasininstance
local wasinpvp

-- Are we in a PVP zone?
local function is_in_pvp()
	return select(2,IsInInstance()) == "pvp" or select(2,IsInInstance()) == "arena"
end

-- Fired on entering a zone.
function Skada:PLAYER_ENTERING_WORLD()
	-- Check if we are entering an instance.
	local inInstance, instanceType = IsInInstance()
	local isininstance = inInstance and (instanceType == "party" or instanceType == "raid")
	local isinpvp = is_in_pvp()

	-- If we are entering an instance, and we were not previously in an instance, and we got this event before... and we have some data...
	if isininstance and wasininstance ~= nil and not wasininstance and self.db.profile.reset.instance ~= 1 and total ~= nil then
		if self.db.profile.reset.instance == 3 then
			ask_for_reset()
		else
			self:Reset()
		end
	end

	-- Hide in PvP. Hide if entering a PvP instance, show if we are leaving one.
	if self.db.profile.hidepvp then
		if is_in_pvp() then
			Skada:SetActive(false)
		elseif wasinpvp then
			Skada:SetActive(true)
		end
	end

	-- Save a flag marking our previous (current) instance status.
	if isininstance then
		wasininstance = true
	else
		wasininstance = false
	end
	
	-- Save a flag marking out previous (current) pvp status.
	if isinpvp then
		wasinpvp = true
	else
		wasinpvp = false
	end

	-- Mark our last party status. This is done so that the flag is set to correct value on relog/reloadui.
	wasinparty = (GetNumPartyMembers() > 0 or GetNumRaidMembers() > 0)

	-- Check for pets.
	self:CheckPets()
end
Now, skada also checks if You are in a group or not, which is irrelevant (in our case, skada does this, because it also has an option to hide itself when solo).

Is it possible to adapt this for oUF? Is there an easier way to do code this? What's the best event to update the function (something like "onZoneChange" maybe)?
  Reply With Quote
10-29-09, 11:56 AM   #2
wurmfood
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 122
After detecting if the user is in an arena, you should be able to change the aura filter on the target. For example:

--detect code
oUF_something_target.Auras.buffFilter = "HELPFUL"
oUF_something_target.Auras.debuffFilter = "HARMFUL"
else
oUF_something_target.Auras.buffFilter = "HELPFUL|PLAYER"
oUF_something_target.Auras.debuffFilter = "HARMFUL|PLAYER"

Instead of using the zone changed event (which would work), I'd probably go with PLAYER_ENTERING_WORLD. This definitely fires when you enter an arena and fires less often than the zone change.
  Reply With Quote
10-30-09, 08:59 AM   #3
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
I would recommend that you inject it into object.__elements instead of using :RegisterEvent for PEW. Also, if you are going to Hide/Show frames then you need to: a) Watch out of combat b) Create a state-drive to do it for you.
__________________
「貴方は1人じゃないよ」
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » dynamical changing of frames for PvP (... or PvE)


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