Download
(2 Kb)
Download
Updated: 11-29-11 12:11 PM
Pictures
File Info
Tested:Hour of Twilight 4.3
Updated:11-29-11 12:11 PM
Created:02-03-10 07:23 PM
Downloads:8,911
Favorites:48
MD5:
This AddOn is 4.3 compatible
TargetPercent  Popular! (More than 5000 hits)
Version: v2.00
by: funkydude [More]
Adds a health percentage to the Blizzard target, focus & boss frames.
Movable with ALT-drag if you dislike the default positions.
v2.00: re-write, more accurate and more efficient

v1.75: bump toc, increase frame width slightly

v1.71: toc bump

v1.70: You can now ALT-drag to move the health percentages.

v1.55: Various bugfixes

v1.50: Now supports percentage on the boss target frames

v1.32: toc update

v1.31: Remove debug spamming "update" in chat /smackself

v1.3: add percentage to focus frame also.

v1.2: Now shows a decimal place, bugfix to show 0% health when targeting a dead target after targeting a live target.

v1.1: Use the Blizzard Unit Frame font object for consistency.

v1.0: Release
Post A Reply Comment Options
Old 01-01-12, 03:23 AM  
BadWarlock
A Kobold Labourer

Forum posts: 0
File comments: 7
Uploads: 0
Hello! tell me how to add here the ability to change color and size text?
Last edited by BadWarlock : 01-01-12 at 03:25 AM.
BadWarlock is offline Report comment to moderator  
Reply With Quote
Old 07-07-11, 05:07 AM  
Pixol
A Deviate Faerie Dragon
AddOn Author - Click to view AddOns

Forum posts: 13
File comments: 61
Uploads: 8
Thanks I modified your code a bit to show current truncated (divided by 1000 with a "k") hp and mana values for target. This helps me see how much hp a tank has or if they're ret or holy, etc. I like to display the percent on the hp bar itself as the other option blizzard offers tends to block out the entire health bar.


TargetPercent.lua
Code:
local registerOnShow = function(frame) frame:RegisterEvent("UNIT_HEALTH") end
local unregisterOnHide = function(frame) frame:UnregisterEvent("UNIT_HEALTH") end

local startDrag = function(frame) if IsAltKeyDown() then frame:StartMoving() end end
local stopDrag = function(frame) frame:StopMovingOrSizing() end

local healthUpdate = function(frame, _, unit)
	if not unit or unit == frame.target then
		local hp = UnitHealth(frame.target)
		if hp > 0 then
			--hp = hp / UnitHealthMax(frame.target) * 100
			--frame.text:SetFormattedText("%.1f%%", hp)
			frame.text:SetFormattedText("%.1fk", hp/1000)
		else
			--frame.text:SetText("0%")
			frame.text:SetText("0.0k")
		end
	end
end

local manaUpdate = function(frame, _, unit)
	if not unit or unit == frame.target then
		local mp = UnitPower(frame.target)
		local mp_type = UnitPowerType(frame.target)
		if mp_type == 0 then
      if mp > 0 then
        --hp = hp / UnitHealthMax(frame.target) * 100
        --frame.text:SetFormattedText("%.1f%%", hp)
        frame.text:SetFormattedText("%.1fk", mp/1000)
      else
        --frame.text:SetText("0%")
        frame.text:SetText("0.0k")
      end
    else
      frame.text:SetText("")
    end
	end
end

local t_hpFrame = CreateFrame("Frame", "TargetPercent", TargetFrameHealthBar)
t_hpFrame:SetPoint("LEFT", TargetFrameHealthBar, "LEFT", -54, 0)
t_hpFrame:SetWidth(50)
t_hpFrame:SetHeight(20)
t_hpFrame.text = t_hpFrame:CreateFontString("TargetPercentText", "OVERLAY")
t_hpFrame.text:SetAllPoints(t_hpFrame)
t_hpFrame.text:SetFontObject(TextStatusBarText)
t_hpFrame.text:SetJustifyH("RIGHT")
t_hpFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
t_hpFrame:SetScript("OnShow", registerOnShow)
t_hpFrame:SetScript("OnHide", unregisterOnHide)
t_hpFrame:EnableMouse(false)
t_hpFrame:RegisterForDrag("LeftButton")
t_hpFrame:SetClampedToScreen(true)
t_hpFrame:SetMovable(true)
t_hpFrame:SetScript("OnDragStart", startDrag)
t_hpFrame:SetScript("OnDragStop", stopDrag)
t_hpFrame:SetScript("OnEvent", healthUpdate)
t_hpFrame.target = "target"

local t_mpFrame = CreateFrame("Frame", "TargetPercent", TargetFrameManaBar)
t_mpFrame:SetPoint("LEFT", TargetFrameManaBar, "LEFT", -54, 0)
t_mpFrame:SetWidth(50)
t_mpFrame:SetHeight(20)
t_mpFrame.text = t_mpFrame:CreateFontString("TargetPercentText", "OVERLAY")
t_mpFrame.text:SetAllPoints(t_mpFrame)
t_mpFrame.text:SetFontObject(TextStatusBarText)
t_mpFrame.text:SetJustifyH("RIGHT")
t_mpFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
t_mpFrame:SetScript("OnShow", registerOnShow)
t_mpFrame:SetScript("OnHide", unregisterOnHide)
t_mpFrame:EnableMouse(false)
t_mpFrame:RegisterForDrag("LeftButton")
t_mpFrame:SetClampedToScreen(true)
t_mpFrame:SetMovable(true)
t_mpFrame:SetScript("OnDragStart", startDrag)
t_mpFrame:SetScript("OnDragStop", stopDrag)
t_mpFrame:SetScript("OnEvent", manaUpdate)
t_mpFrame.target = "target"
Last edited by Pixol : 07-07-11 at 05:09 AM.
Pixol is offline Report comment to moderator  
Reply With Quote
Old 02-01-11, 03:33 PM  
paterbrown
A Kobold Labourer

Forum posts: 0
File comments: 21
Uploads: 0
Good Addon. The name indeed is TargetPercent but percent display to the playerframe would be useful. Maybe you can add this option?
paterbrown is offline Report comment to moderator  
Reply With Quote
Old 02-01-11, 09:52 AM  
penpen002
A Defias Bandit
 
penpen002's Avatar

Forum posts: 2
File comments: 29
Uploads: 0
This is just the add on I am looking for. Love you
penpen002 is offline Report comment to moderator  
Reply With Quote
Old 01-30-11, 08:51 PM  
funkydude
A Deviate Faerie Dragon
 
funkydude's Avatar
AddOn Author - Click to view AddOns

Forum posts: 10
File comments: 341
Uploads: 27
Not sure of the point, most UF mods will allow you to show absolute health and percentage health side by side.

Originally posted by Jexx
Anyway to have this frame show up on custom unit frames, particularly Shadowed Unit Frames?
funkydude is offline Report comment to moderator  
Reply With Quote
Old 01-30-11, 08:45 PM  
Jexx
A Deviate Faerie Dragon

Forum posts: 10
File comments: 122
Uploads: 0
Anyway to have this frame show up on custom unit frames, particularly Shadowed Unit Frames?
Jexx is offline Report comment to moderator  
Reply With Quote
Old 01-30-11, 07:12 PM  
funkydude
A Deviate Faerie Dragon
 
funkydude's Avatar
AddOn Author - Click to view AddOns

Forum posts: 10
File comments: 341
Uploads: 27
Well you can now ALT-drag to move it
funkydude is offline Report comment to moderator  
Reply With Quote
Old 01-26-11, 09:19 AM  
Spike`
A Kobold Labourer
AddOn Author - Click to view AddOns

Forum posts: 1
File comments: 30
Uploads: 1
does it take in account Onyxia bossframe on Nepharian fight?

she has left of their bossframe a energy bar, your % will be hidden by it
Spike` is offline Report comment to moderator  
Reply With Quote
Old 01-25-11, 05:39 PM  
funkydude
A Deviate Faerie Dragon
 
funkydude's Avatar
AddOn Author - Click to view AddOns

Forum posts: 10
File comments: 341
Uploads: 27
Re: Bug

Fixed, thanks.
funkydude is offline Report comment to moderator  
Reply With Quote
Old 01-25-11, 09:23 AM  
bimmy
A Kobold Labourer

Forum posts: 0
File comments: 8
Uploads: 0
Bug

I made a ticket about this on wowace: the TargetPercent display doesn't update on target switch. It will only update a newly selected target's HP when the target's HP changes.

Example: I can have 4.1% as the last displayed HP on a monster I just killed and select a new monster and it will display 4.1% until I damage it.
bimmy is offline Report comment to moderator  
Reply With Quote
Old 01-23-11, 09:31 AM  
funkydude
A Deviate Faerie Dragon
 
funkydude's Avatar
AddOn Author - Click to view AddOns

Forum posts: 10
File comments: 341
Uploads: 27
v1.50 Now supports percentage on the boss target frames
funkydude is offline Report comment to moderator  
Reply With Quote
Old 10-20-10, 07:50 PM  
tralkar
An Onyxian Warder
 
tralkar's Avatar

Forum posts: 352
File comments: 202
Uploads: 0
Being blind myself, anyway of making the font bigger?

* ok took me some time lol but i found a way to make the text a little bigger. yeah there might be other ways but this one works for me..
Change this= t_hpFrame.text:SetFontObject(TextStatusBarText)


To this= t_hpFrame.text:SetFontObject("NumberFontNormallarge")
Last edited by tralkar : 10-24-10 at 09:50 PM.
tralkar is offline Report comment to moderator  
Reply With Quote
Old 10-09-10, 03:29 AM  
fatalerror
A Kobold Labourer

Forum posts: 1
File comments: 5
Uploads: 0
Originally posted by Squiddy0
So I really enjoy this addon but I can't figure how to remove the decimal ., for:

100.0%

the .0% isn't necessary, I've tried many variations on:
Code:
local hp = UnitHealth("target")
		if hp > 0 then
			hp = hp / 

UnitHealthMax("target") * 100
			
frame.text:SetFormattedText("%.1f%%", hp)
		else
			frame.text:SetText("0%")
		end
but not having much luck, so the 100.0% stays for now, I just get errors for trying to remove it; not being LUA savy, I'm probably going at it wrong too.
just change the %.1f%% to %.0f%% ,should work.
fatalerror is offline Report comment to moderator  
Reply With Quote
Old 07-06-10, 12:10 AM  
Squiddy0
A Murloc Raider
 
Squiddy0's Avatar
AddOn Author - Click to view AddOns

Forum posts: 3
File comments: 106
Uploads: 3
So I really enjoy this addon but I can't figure how to remove the decimal ., for:

100.0%

the .0% isn't necessary, I've tried many variations on:
Code:
local hp = UnitHealth("target")
		if hp > 0 then
			hp = hp / 

UnitHealthMax("target") * 100
			
frame.text:SetFormattedText("%.1f%%", hp)
		else
			frame.text:SetText("0%")
		end
but not having much luck, so the 100.0% stays for now, I just get errors for trying to remove it; not being LUA savy, I'm probably going at it wrong too.
Last edited by Squiddy0 : 07-06-10 at 12:13 AM.
Squiddy0 is offline Report comment to moderator  
Reply With Quote
Old 06-08-10, 03:51 PM  
guin
A Kobold Labourer
 
guin's Avatar

Forum posts: 0
File comments: 13
Uploads: 0
Just what i was looking for a simple add-on that do just this. Going to try this right away.

Thx funkydude
guin is offline Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump:

Support AddOn Development!

You have just downloaded by the author . If you like this AddOn why not consider supporting the author? This author has set up a donation account. Donations ensure that authors can continue to develop useful tools for everyone.