Thread Tools Display Modes
02-10-11, 10:39 PM   #1
silentstone7
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Dec 2010
Posts: 14
Custom Unitframe

I'm working on an Addon to monitor CC on a target. Basically what I'm trying to create is a second "Focus".
I want to make a unit frame where you can set and clear a unitID to keep track of an enemy's health and debuffs. I'm running into trouble trying to create the unitframe. I've found plenty of code samples online for creating a unit frame for yourself/party/raid or target. How do you create a unitframe for a stored unit ID value?
Any code samples here are much appreciated!

Here's what I have so far... I just have the frames drawn, and I'm not sure how to update them with actual health values.

Code:
local CCHB_unitHealth = CreateFrame("Frame", "CCHB_unitHealth", CCHB_mainframe)
CCHB_unitHealth:SetBackdrop(defaultBackdrop)
CCHB_unitHealth:SetBackdropColor(0,0,0,0)
CCHB_unitHealth:SetMovable(false)
CCHB_unitHealth:SetSize(200,25)
CCHB_unitHealth:SetPoint("LEFT", CCHB_mainframe, "LEFT", 25, -10)

local CCHB_unitHealthSB = CreateFrame("StatusBar", "CCHB_unitHealthSB", UIParent, "SecureUnitButtonTemplate")
CCHB_unitHealthSB:SetPoint("CENTER", CCHB_unitHealth, "CENTER", 0, 0)
CCHB_unitHealthSB:SetWidth(195)
CCHB_unitHealthSB:SetHeight(20)
CCHB_unitHealthSB:SetStatusBarTexture("Interface\\TARGETINGFRAME\\UI-StatusBar")
CCHB_unitHealthSB:GetStatusBarTexture():SetHorizTile(false)
CCHB_unitHealthSB:GetStatusBarTexture():SetVertTile(false)
CCHB_unitHealthSB:SetStatusBarColor(0, 0.65, 0)
CCHB_unitHealthSB:SetMinMaxValues(0, 100)

local CCHB_unitName = CCHB_unitHealth:CreateFontString("CCHB_unitName", "OVERLAY")
CCHB_unitName:SetPoint("CENTER", CCHB_unitHealth, "CENTER")
CCHB_unitName:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
CCHB_unitName:SetJustifyH("CENTER")
CCHB_unitName:SetShadowOffset(1, -1)
CCHB_unitName:SetTextColor(1, 1, 1)
CCHB_unitName:SetText("No Target")
  Reply With Quote
02-11-11, 12:59 AM   #2
Akkorian
A Flamescale Wyrmkin
 
Akkorian's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 111
It’s not possible to create custom unit tokens, like “target” or “focus”. You can only use the ones Blizzard provides. It’s also not possible to create a real unit frame that tracks a unit without a valid Blizzard unit token.

You could create a fake unit frame, but it wouldn’t be able to do normal unit frame things like target the unit when clicked, unless you set it up outside of combat as a secure action button that ran a “/target Name Of Mob” macro when clicked. It also couldn’t update to track the unit’s health or mana, or to track the real duration of your CC debuff on the unit. It could only update if you targeted or moused over the unit, which would temporarily give it a valid unit token like “target” or ”mouseover”. You could watch the combat log and turn the frame red if the CC broke early, but that would be about it.
__________________
“Be humble, for you are made of earth. Be noble, for you are made of stars.”
  Reply With Quote
02-11-11, 01:11 AM   #3
silentstone7
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Dec 2010
Posts: 14
Originally Posted by Akkorian View Post
It’s not possible to create custom unit tokens, like “target” or “focus”. You can only use the ones Blizzard provides. It’s also not possible to create a real unit frame that tracks a unit without a valid Blizzard unit token.

You could create a fake unit frame, but it wouldn’t be able to do normal unit frame things like target the unit when clicked, unless you set it up outside of combat as a secure action button that ran a “/target Name Of Mob” macro when clicked. It also couldn’t update to track the unit’s health or mana, or to track the real duration of your CC debuff on the unit. It could only update if you targeted or moused over the unit, which would temporarily give it a valid unit token like “target” or ”mouseover”. You could watch the combat log and turn the frame red if the CC broke early, but that would be about it.
Well crap. I'm used to having my target be the mob to DPS and my focus being the tank to misdirect to. Keeping track of a CC target just sucks as is. So there's no way to keep tabs on the remainder of CC on a mob other than to make them your target or your focus?
  Reply With Quote
02-11-11, 01:22 AM   #4
Akkorian
A Flamescale Wyrmkin
 
Akkorian's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 111
Not really. Like I said, the closest you could get would be watching the combat log and warning you if the CC broke early.

If you’re using a macro to misdirect to your focus, you could change the macro to:

Code:
/cast [target=Tankname] [] Misdirection
You’d have to remember to update it with the tank’s name, though.

Or, if you raid sets the tank as the main tank in the raid window:

Code:
/cast [target=maintank1] [] Misdirection
That wouldn’t work if they set multiple tanks, though, because there’s no way to tell which maintankN unit token resolves to which named unit in a macro.
__________________
“Be humble, for you are made of earth. Be noble, for you are made of stars.”
  Reply With Quote
02-11-11, 07:26 AM   #5
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
If I may, I recommend installing http://www.wowinterface.com/download...Misdirect.html and http://www.wowinterface.com/download...trolFreak.html .
  Reply With Quote
02-11-11, 05:50 PM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
I was working on a project long ago that parsed combat log events for the application and fading of spell effects originating from the player. It featured a tooltip scanner that would grab a duration from the tooltip and an override system for spells that either had incorrect tooltips or didn't display their duration. Most spells worked without need for override entries and it had support for durations based off combo points and modifications from glyphs.

I stopped development when Cataclysm launched, I didn't feel like putting in the time needed to update the override data.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Custom Unitframe


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