View Single Post
06-28-16, 01:13 AM   #7
whatisxml
A Murloc Raider
 
whatisxml's Avatar
Join Date: Jun 2016
Posts: 9
Originally Posted by Resike View Post
Find the frame, hook it's SetAlpha and override it.
It was a little bit more difficult than that. I have a solution but not an answer, if that makes sense.

For instance, let's say you have the player name plate.

Code:
local namePlate=C_NamePlate.GetNamePlateForUnit("player")
During combat namePlate:GetAlpha() == 0.75. When you leave combat this value goes down to about 0.375 for a second and then down to nearly 0. Then the NAME_PLATE_UNIT_REMOVED event fires which causes namePlate:Hide() and also destroys all the namePlate's and namePlate.UnitFrame's metadata, breaking its link to the player so it can be reused for other units' name plates. If this happens, you can't get it back. It's gone until the next magic event resummons it.

A few notes on this: destroying its SetAlpha method with namePlate["SetAlpha"]=function()end doesn't prevent the namePlate from fading out or fading back in. I thought maybe just its children were fading but all its children's alphas are at 1.0 the whole time. So something else is driving its fading. The only other way to make it fade is by running WorldFrame:SetAlpha. But again, destroying WorldFrame["SetAlpha"]=function()end doesn't prevent it from fading.

Could there be some hidden frame used to fade it? There's nothing obvious showing up in fstack.

At any rate, here is the temporary solution for the problem:

Code:
local tempFun=NamePlateDriverFrame:GetScript("OnEvent");
local function newOnEvent(self,event,...)
	if event=="NAME_PLATE_UNIT_REMOVED" and UnitIsPlayer(...) then 
		-- do nothing
	else
		tempFun(self,event,...);
	end
end 
NamePlateDriverFrame:SetScript("OnEvent",newOnEvent);
or if you prefer a macro like I've been using (because I have no idea what I'm doing)

Code:
/run local f=NamePlateDriverFrame;gn=f:GetScript("OnEvent");function fn(s,e,...)if e=="NAME_PLATE_UNIT_REMOVED" and UnitIsPlayer(...)then else gn(s,e,...)end end f:SetScript("OnEvent",fn)
This just prevents the NAME_PLATE_UNIT_REMOVED event script from firing if it's the player's name plate that's removed. Now if you turn off all other nameplates so that yours is the only and let's say it's NamePlate1. You can now make it reappear after it fades by simply running the following snippet:

Code:
/run NamePlate1:Show(); NamePlate1:SetAlpha(0.75);
Unfortunately the name plate is no longer reserved for the player at this point so if another unit on your screen needs a nameplate, it will steal your NamePlate1. I don't think we have access to the code where NamePlates are actually assigned to units so it doesn't seem possible to create a new NamePlate reserved for "player".

And as for the source of the alpha fading, who knows?