Blizzard frames that are hidden out-of-combat

I'm looking for something that will allow the default blizzard player and target frames (or frames from an addon that look exactly like the blizzard frames) to be hidden outside of combat?

Shadowed unit frames and pitbull unit frames change how they look which is not what I'm after.
1 Like
I've gone ahead and wrote and tested a script that does what you want.

local f = CreateFrame("Frame")
local inCombat = false --need own variable becuase of event timings
f:RegisterEvent("PLAYER_REGEN_DISABLED") -- entered combat
f:RegisterEvent("PLAYER_REGEN_ENABLED") -- left combat
f:SetScript("OnEvent", function(self, event, ...) -- hides/shows frames when leaving/entering combat
if event =="PLAYER_REGEN_DISABLED" then
inCombat = true
PlayerFrame:Show()
TargetFrame:Show()
TargetFrameToT:Show()
else
inCombat = false
PlayerFrame:Hide()
TargetFrame:Hide()
TargetFrameToT:Hide()
end
end)
PlayerFrame:Hide() -- hides frames when client has loaded
TargetFrame:Hide()
TargetFrameToT:Hide()
--Make sure frames stay hidden while out of combat
PlayerFrame:SetScript("OnShow",
function()
if (inCombat == false) then
PlayerFrame:Hide()
end
end)
TargetFrame:SetScript("OnShow",
function()
if (inCombat == false) then
TargetFrame:Hide()
end
end)
TargetFrameToT:SetScript("OnShow",
function()
if (inCombat == false) then
TargetFrameToT:Hide()
end
end)


This will hide blizzard's player, target, and target of target frames while out of combat and show them while in combat.

use https://addon.bool.no to turn this script into an addon and put it into your WoW client folder.

Lastly, if you use custom frames from an addon (since you mentioned frames that look exactly like blizzard's), you should use the /fstack command in-game to find out their names. You can use those names in above script.

Let me know if it works, and if it's what you were looking for! :)
4 Likes
Hello i am currently using that addon, i know nothing about code, could you write a version which hides the frames only when im not targeting anything, when i target something they will show?
1 Like
Hi Thedarkvoid,

Next time, please make a separate thread for requests. If i didn't recognize the title, i wouldn't have looked in here because it had already received replies and thus wouldn't have seen your request. ;)

Here's the code which does what you want.
local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_TARGET_CHANGED") -- Run code when player's target changed
f:SetScript("OnEvent", function(self, event, ...)
if(UnitName("target") == nil or UnitName("target") == UnitName("player")) then --if player has no target
PlayerFrame:Hide()
TargetFrame:Hide()
TargetFrameToT:Hide()
else --if player has target
PlayerFrame:Show()
TargetFrame:Show()
TargetFrameToT:Show()
end
end)
PlayerFrame:Hide() --hide frames when client loads
TargetFrame:Hide()
TargetFrameToT:Hide()
--Make sure frames stay hidden when there's no target
PlayerFrame:SetScript("OnShow",
function()
if (UnitName("target") == nil or UnitName("target") == UnitName("player")) then
PlayerFrame:Hide()
end
end)
TargetFrame:SetScript("OnShow",
function()
if (UnitName("target") == nil or UnitName("target") == UnitName("player")) then
TargetFrame:Hide()
end
end)
TargetFrameToT:SetScript("OnShow",
function()
if (UnitName("target") == nil or UnitName("target") == UnitName("player")) then
TargetFrameToT:Hide()
end
end)


This will Hide the player, target, and target of target frames while you don't have anything targeted and show them when you do.

I've also built in a little extra, if you target yourself (by clicking on your own portrait for example), the script will treat that as a request to hide the frames. This feature might be especially useful to "untarget" players and npcs while in cities.

as with the above script, use https://addon.bool.no to turn it into an addon. Then install that addon into your WoW/Interface/Addons folder.
3 Likes
First of all, thanks for doing this.

Second, the last code your wrote here has some issues, if you get in combat by aggroing a mob without targeting, the player frame will not show.

A request: Can you add fade animation?
1 Like
Hi Zladarus,

Thank you for pointing out this bug. The cause is that the PlayerFrame can't be toggled visible/invisible while you're in combat. I've now fixed this issue by using a different technique to hide the frames.

I've also put in a fade animation, as you requested. :)
-- This file is loaded from "Combat Addon.toc"

local f = CreateFrame("Frame")
local f2 = CreateFrame("Frame");
local f3 = CreateFrame("Frame");
f:RegisterEvent("PLAYER_TARGET_CHANGED") -- Run code when player's target changed
f2:RegisterEvent("PLAYER_REGEN_DISABLED") --player entered combat
f3:RegisterEvent("PLAYER_REGEN_ENABLED")--player left combat

f:SetScript("OnEvent", function(self, event, ...) --target changed event
if (DropDownList1Button2ExpandArrow:GetRight() == nil) then --init mouse menu
PlayerFrame:Click("RightButton");
DropDownList1Button16:Click();
DropDownList1:SetScript("OnShow", --keep mouse menu hidden when player frame is hidden
function()
if(PlayerFrame:GetAlpha() == 0) then
DropDownList1:Hide();
end
end)
end
if(UnitName("target") == nil or UnitName("target") == UnitName("player")) then --if player has no target
fadeOut(PlayerFrame)
fadeOut(TargetFrame)
fadeOut(TargetFrameToT)
else --if player has target
fadeIn(PlayerFrame)
fadeIn(TargetFrame)
fadeIn(TargetFrameToT)
end
end)

f2:SetScript("OnEvent", function(self, event, ...)
fadeIn(PlayerFrame)
end)

f3:SetScript("OnEvent", function(self, event, ...)
if(UnitName("target") == nil or UnitName("target") == UnitName("player")) then
fadeOut(PlayerFrame)
end
end)

PlayerFrame:SetAlpha(0) --hide frames when client loads
TargetFrame:SetAlpha(0)
TargetFrameToT:SetAlpha(0)
DropDownList1:Hide();

function fadeIn(frame)
local ticker = C_Timer.NewTicker(0.01, function()
frame:SetAlpha(frame:GetAlpha()+0.09)
end, 50)
end

function fadeOut(frame)
local ticker = C_Timer.NewTicker(0.01, function()
frame:SetAlpha(frame:GetAlpha()-0.09)
end, 50)
end
As with the other code snippets, go to https://addon.bool.no to turn this script into an addon and then put it into your WoW\Interface\Addons folder.

If you would like to change the speed of the fade animation, the best way to go about this is to remain in-game, go to WoW\Interface\Addons\<Your Addon Name>\ folder, and edit the code.lua file with a text editor (i recommend using notepad++).

On the bottom of the code.lua file, lines 49 and 55, you'll find a line like this frame:SetAlpha(frame:GetAlpha()+0.09) Just change the 0.09 to adjust the speed. The bigger this number, the faster the animation goes.

Once you adjusted that number, save the script and then do a /reload in-game. The changes will immediately be put into effect so you can test whether you like the new speed. :)
4 Likes
Hi Grimmj, thank you for the insight on this. I also was looking for this. is there any way that character frame will become visible at mouse over or right click?
Thank you!
1 Like
Here you go. :)

local animationTimeSeconds = 0.15 --amount of seconds it takes to make a frame visible/invisible.

local f = CreateFrame("Frame")
local f2 = CreateFrame("Frame");
local f3 = CreateFrame("Frame");
f:RegisterEvent("PLAYER_TARGET_CHANGED") -- Run code when player's target changed
f2:RegisterEvent("PLAYER_REGEN_DISABLED") --player entered combat
f3:RegisterEvent("PLAYER_REGEN_ENABLED")--player left combat
local override = false;
local animating = false;

local main = function(self, event, ...) --target changed event
if (DropDownList1Button2ExpandArrow:GetRight() == nil) then --init mouse menu
PlayerFrame:Click("RightButton");
DropDownList1Button16:Click();
DropDownList1:SetScript("OnShow", --keep mouse menu hidden when player frame is hidden
function()
if(PlayerFrame:GetAlpha() == 0) then
DropDownList1:Hide();
end
end)
end
if(UnitName("target") == nil or UnitName("target") == UnitName("player")) then --if player has no target
fadeOut(TargetFrame)
fadeOut(TargetFrameToT)
if (not override) then
fadeOut(PlayerFrame)
end
else --if player has target
fadeIn(PlayerFrame)
fadeIn(TargetFrame)
fadeIn(TargetFrameToT)
end
end

f:SetScript("OnEvent", main)

C_Timer.NewTicker(0.25, function()
if (PlayerFrame:IsMouseOver()) then
override = true;
fadeIn(PlayerFrame);
else
override = false;
if (UnitName("target") == nil or UnitName("target") == UnitName("player")) then
fadeOut(PlayerFrame);
end
end
end)


f2:SetScript("OnEvent", function(self, event, ...)
fadeIn(PlayerFrame)
end)

f3:SetScript("OnEvent", function(self, event, ...)
if(not override and (UnitName("target") == nil or UnitName("target") == UnitName("player"))) then
fadeOut(PlayerFrame)
end
end)

PlayerFrame:SetAlpha(0) --hide frames when client loads
TargetFrame:SetAlpha(0)
TargetFrameToT:SetAlpha(0)
DropDownList1:Hide();

function fadeIn(frame)
if (frame:GetAlpha() < 1 and not animating) then
animating = true;
local ticker = C_Timer.NewTicker(animationTimeSeconds / 10, function()
frame:SetAlpha(frame:GetAlpha()+0.1)
end, 10)
animating = false;
end
end

function fadeOut(frame)
if (frame:GetAlpha() > 0 and not animating) then
animating = true;
local ticker = C_Timer.NewTicker(animationTimeSeconds / 10, function()
frame:SetAlpha(frame:GetAlpha()-0.1)
end, 10)
animating = false;
end
end


note that i've moved the animation speed, or rather the amount of time it takes to complete a fade animation, to the top of the script.
5 Likes

This is exactly what I’ve been looking for, thank you so much!

Hey, Grimmj! I want you to know that I’m using your code snip to this day. The minimalistic HUD helps me get immersed and be relaxed and engaged with the game without the need for bulky addons that do a ton of stuff I need. Just this one feature. Back then, this had also inspired me to start learning LUA. Thank you for writing it up!

Hey!

I know this is a pretty old thread. But this add-on is an awesome one, just what I was looking for. Maybe you will stumble upon my request in the future though so I’ll ask it:

-Could you extend the features into the:
~Chat
~Actionbars
~Buttons on the bottom right
~Quest objectives

Essentially only leaving the map visible all the time. That would be hell of a great. Thank you for the stuff you already created anyway.

Oh, a bug I stumbled upon: If the players ui in faded mode, so not targeting anything, the menus with dropping down lists don’t shop up as: menus in the settings menu, or the tracking thing near the map, with which you can choose which icon’s should the map show for you, etc.

<3