Minion Beta! - Help us test our new AddOn updater. Get it now!
Download
(2 Kb)
Download
Updated: 10-14-14 06:56 PM
Pictures
File Info
Compatibility:
Warlords of Draenor Pre-Patch (6.0.2)
Siege of Orgrimmar (5.4)
Escalation (5.3)
Thunder Isle (5.2)
Updated:10-14-14 06:56 PM
Created:02-03-10 08:23 PM
Downloads:12,775
Favorites:65
MD5:
6.0.2
TargetPercent  Updated this week!  Popular! (More than 5000 hits)
Version: r55
by: funkydude [More]
Adds a health percentage to the Blizzard target, focus & boss frames.
Movable with ALT-drag if you dislike the default positions.
Post A Reply Comment Options
Unread 05-29-13, 12:14 PM  
spiralofhope
A Deviate Faerie Dragon
 
spiralofhope's Avatar

Forum posts: 11
File comments: 207
Uploads: 0
I didn't like showing anything when the unit has maximum health.

So I changed healthUpdate:

Lua Code:
  1. local healthUpdate = function(frame, _, unit)
  2.     unit = unit or frame.unit
  3.     local hp = UnitHealth(unit)
  4.     local maxhp = UnitHealthMax(unit)
  5.     if hp == maxhp then
  6.         addon[unit]:SetText("")
  7.     elseif hp > 0 then
  8.         hp = hp / UnitHealthMax(unit) * 100
  9.         addon[unit]:SetFormattedText("%.1f%%", hp)
  10.     else
  11.         addon[unit]:SetText("0%")
  12.     end
  13. end
__________________
spiralofhope.com
spiralofhope is offline Report comment to moderator  
Reply With Quote
Unread 01-01-12, 04: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 04:25 AM.
BadWarlock is offline Report comment to moderator  
Reply With Quote
Unread 07-07-11, 05:07 AM  
Pixol
A Deviate Faerie Dragon
AddOn Author - Click to view AddOns

Forum posts: 13
File comments: 62
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
Unread 02-01-11, 04: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
Unread 02-01-11, 10: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
Unread 01-30-11, 09:51 PM  
funkydude
A Deviate Faerie Dragon
 
funkydude's Avatar
AddOn Author - Click to view AddOns

Forum posts: 13
File comments: 412
Uploads: 35
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
Unread 01-30-11, 09:45 PM  
Jexx
A Deviate Faerie Dragon

Forum posts: 10
File comments: 114
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
Unread 01-30-11, 08:12 PM  
funkydude
A Deviate Faerie Dragon
 
funkydude's Avatar
AddOn Author - Click to view AddOns

Forum posts: 13
File comments: 412
Uploads: 35
Well you can now ALT-drag to move it
funkydude is offline Report comment to moderator  
Reply With Quote
Unread 01-26-11, 10:19 AM  
Spike`
A Defias Bandit
AddOn Author - Click to view AddOns

Forum posts: 3
File comments: 35
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
Unread 01-25-11, 06:39 PM  
funkydude
A Deviate Faerie Dragon
 
funkydude's Avatar
AddOn Author - Click to view AddOns

Forum posts: 13
File comments: 412
Uploads: 35
Re: Bug

Fixed, thanks.
funkydude is offline Report comment to moderator  
Reply With Quote
Unread 01-25-11, 10: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
Unread 01-23-11, 10:31 AM  
funkydude
A Deviate Faerie Dragon
 
funkydude's Avatar
AddOn Author - Click to view AddOns

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

Forum posts: 352
File comments: 217
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
Unread 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
Unread 07-06-10, 12:10 AM  
Squiddy0
A Defias Bandit
 
Squiddy0's Avatar
AddOn Author - Click to view AddOns

Forum posts: 3
File comments: 115
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
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.