Thread Tools Display Modes
03-09-11, 02:19 PM   #1
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 540
KG Panels + Coloring

Posted from Below and from PM's
(Big thanks to Nib!)

Normal Threat:

-- OnLoad
Code:
self:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE")
-- OnEvent
Code:
-- Replace unit with "party1" to "party4" for party members. Or ("target", "targettarget") for seeing threat on your target.
local status = UnitThreatSituation(unit)
local color = status and {GetThreatStatusColor(status)} or {0,0,0}
self:SetBackdropBorderColor(unpack(color))
--------------------------------

Personal Colors: (also with extra quirks that doesn't show threat unless you're in group/have pet and won't show in BGs)

-- OnLoad
Code:
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("PARTY_MEMBERS_CHANGED")
self:RegisterEvent("UNIT_PET")
self:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE")
-- On Event
Code:
--- {R, G, B, A}  - Set A to 0 to hide the panel.
local ThreatStatusColors = {
	[0] = {0, 0, 0, 0},		-- not tanking, lower threat than tank. 
	[1] = {0, 0, 0, 1},		-- not tanking, higher threat than tank. 
	[2] = {0, 0, 0, 1},		-- insecurely tanking, another unit have higher threat but not tanking. 
	[3] = {0, 0, 0, 1},		-- securely tanking, highest threat 
}

local color
local status = UnitThreatSituation(unit)
local _, InstType = IsInInstance()
if ( (status ~= nil) and (UnitExists("pet") or (GetRealNumPartyMembers() > 0) or (GetRealNumRaidMembers() > 1)) and not (InstType == "pvp" or InstType == "arena") ) then
	color = ThreatStatusColors[status]
else
	color = {0,0,0,0}	-- Hide
end
self:SetBackdropBorderColor(unpack(color))
---------------------------
Same as above, but default ThreatColors:

-- OnLoad
Code:
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("PARTY_MEMBERS_CHANGED")
self:RegisterEvent("UNIT_PET")
self:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE")
-- OnEvent
Code:
local color, status
local _, InstType = IsInInstance()
if ( (UnitExists("pet") or (GetRealNumPartyMembers() > 0) or (GetRealNumRaidMembers() > 1)) and not (InstType == "pvp" or InstType == "arena") ) then
	status = UnitThreatSituation(unit)
	color = status and {GetThreatStatusColor(status)} or {0,0,0,0}	-- Threat colors
else
	color = {0,0,0,0}	-- Hide
end

Last edited by Lily.Petal : 04-30-11 at 05:16 PM.
  Reply With Quote
03-09-11, 02:29 PM   #2
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Originally Posted by Lily.Petal View Post
Is there anyway I can change the background color of a frame to show if that party member has aggro or not?

I can't seem to find any leads :<
-- OnLoad
Code:
self:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE")
or

-- OnEvent
Code:
-- Replace unit with "party1" to "party4" for party members. Or ("target", "targettarget") for seeing threat on your target.
local status = UnitThreatSituation(unit, "target")
local r, g, b = GetThreatStatusColor(status)
self.bg:SetVertexColor(r, g, b)
UnitThreatSituation API

Hmm, may need a "UNIT_TARGET" event registered in OnLoad.

Last edited by Nibelheim : 03-09-11 at 02:35 PM.
  Reply With Quote
03-09-11, 02:42 PM   #3
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 540
The code works.. but the only problem is that I want the border to change colors, not the BG >< Any fix you may think up?

And thank you very much for the previous code~
  Reply With Quote
03-09-11, 02:45 PM   #4
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Originally Posted by Lily.Petal View Post
The code works.. but the only problem is that I want the border to change colors, not the BG >< Any fix you may think up?

And thank you very much for the previous code~
self:SetBackdropBorderColor(r,g,b) should work.
  Reply With Quote
03-09-11, 02:50 PM   #5
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Come to think of it, are you wanting to see the threat of party members on your target, or just whether or not they have agro?

If it's the latter, just remove the second argument from the UnitThreatSituation line. So like this:

Code:
local status = UnitThreatSituation(unit)

Last edited by Nibelheim : 03-09-11 at 02:52 PM.
  Reply With Quote
03-09-11, 05:38 PM   #6
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 540
Originally Posted by Nibelheim View Post
Come to think of it, are you wanting to see the threat of party members on your target, or just whether or not they have agro?

If it's the latter, just remove the second argument from the UnitThreatSituation line. So like this:

Code:
local status = UnitThreatSituation(unit)
Works great, only one problem now, it changes my border after combat to white, instead of back to black ><

1st : Before combat and script change
2nd : In combat after script change
3rd : After combat with script
Attached Thumbnails
Click image for larger version

Name:	Untitled.png
Views:	1024
Size:	98.4 KB
ID:	5835  Click image for larger version

Name:	Untitled2.png
Views:	959
Size:	65.7 KB
ID:	5836  Click image for larger version

Name:	Untitled3.png
Views:	892
Size:	26.1 KB
ID:	5837  

Last edited by Lily.Petal : 03-09-11 at 05:57 PM.
  Reply With Quote
03-09-11, 05:52 PM   #7
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Originally Posted by Lily.Petal View Post
Works great, only one problem now, it changes my background after combat to white, instead of back to black ><

Try changing the color lines to:

Code:
local color = status and {GetThreatStatusColor(status)} or {0,0,0}
self:SetBackdropBorderColor(unpack(color))
The {0,0,0} is what you want the default color to be.

Last edited by Nibelheim : 03-09-11 at 05:56 PM.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » KG Panels + Coloring


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