Thread Tools Display Modes
05-05-10, 06:33 PM   #1
upyursh
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 32
Best Way to get a Bosses Health

So I know the boss name but I want to get its health. Is this the best way? Is their limitations to doing it this way?

Code:
      bossname = "Ya Mumma"
      bossmax = UnitHealthMax(bossname)
      bosscurrent = UnitHealth(bossname)
      bossPerc =  bosscurrent / bossmax
Do I need to boss targetted etc?

Upy
  Reply With Quote
05-05-10, 07:55 PM   #2
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,362
You need a valid UnitID.
Those won't work at all.

Edit: To make my comment a bit more useful.

You do need the boss targeted, mouseover-ed, or in case the default client shows bossframes get it from 'bossx' unitid.

If you want to save the HP you got back you probably need to store boss name or guid alongside the current raid difficulty/size.

Keep in mind that some bosses change hitpoints "dynamically" when hardmodes are activated.
(fx heartbreaker on XT-002 or Flame Leviathan with towers up)

Do you need persistent records of boss hp for some reason?

Last edited by Dridzt : 05-05-10 at 08:01 PM.
  Reply With Quote
05-05-10, 08:30 PM   #3
upyursh
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 32
ill try changing to boss1 (this is for Sind)

I am checking for Phase 3, once she's below 35% then i set a flag to Phase3 and then dont need health any longer really

Hmm actually I need to reset that flag at some point, hmmm

Upy
  Reply With Quote
05-10-10, 05:50 PM   #4
upyursh
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 32
So using boss1 didnt work for Sindy, I dont know why
I ended up using focus instead

Any ideas why UnitHealth("boss1") would return 0 during the encounter?

Is UnitHealth("Sindragosa") a better way of doing it?

Upy
  Reply With Quote
05-10-10, 06:11 PM   #5
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,968
It is case sensitive .. try "Boss1".

Edit: My apologies .. "Boss1TargetFrame" is the frame you see when fighting them. "boss1" is the internal unitID for that boss. Had to dig through unitframe.lua and xml for that.

Edit2: Rofl .. actually it was targetframe.lua. The BossFrames aren't located anywhere in Unitframe.lua/xml so perhaps that is why UnitHealth isn't working as planned ? But then you can use UnitHealth("target"). Ah thats why. "target" is a part of the unitframe system.

You might have to use "target" instead and keep her targetted.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818

Last edited by Xrystal : 05-10-10 at 06:22 PM.
  Reply With Quote
05-10-10, 06:15 PM   #6
upyursh
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 32
lol ok ill try that next time we face her

good news is my addon seemed to help organise people enough to get our first kill
  Reply With Quote
05-10-10, 06:23 PM   #7
upyursh
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 32
Originally Posted by Xrystal View Post
It is case sensitive .. try "Boss1".

Edit: My apologies .. "Boss1TargetFrame" is the frame you see when fighting them. "boss1" is the internal unitID for that boss. Had to dig through unitframe.lua and xml for that.
Hmm its ok, I dont know why it wasnt working then, it just never found her :/

Ill create some debugging in the addon to try find the UnitID through a number of ways and see which one works. I'd rather not have to rely on a target or focus

Upy
  Reply With Quote
05-10-10, 06:24 PM   #8
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,968
Rofl... thought my last edit would get there before you saw it darn it ..
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
05-10-10, 06:25 PM   #9
upyursh
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 32
haha im hitting refresh every 15 secs :P
  Reply With Quote
05-11-10, 01:49 AM   #10
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
Originally Posted by Xrystal View Post
It is case sensitive .. try "Boss1".

Edit: My apologies .. "Boss1TargetFrame" is the frame you see when fighting them. "boss1" is the internal unitID for that boss. Had to dig through unitframe.lua and xml for that.
Every string-based token I can think of (unitIDs, widgets) is case-insensitive.

And the bossN unitIDs are only valid when the default unit frames show boss targets, which is limited to static multi-target boss encounters in Icecrown Citadel. Gunship, Council, Valithria (?) are the only ones I believe use this feature.
  Reply With Quote
05-11-10, 02:48 AM   #11
upyursh
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 32
Thanks Waverian, makes sense why it wouldnt find her then I'll find an alternate method to check boss health than using boss1 for unitid then
  Reply With Quote
05-11-10, 05:01 AM   #12
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
Edit: I just decided to actually read more of the thread. If all you want to do is detect when Sindragosa hits P3, then you can just use one of the spell cast events (whether standalone or combat_log_event_unfiltered), and as soon as Mystic Buffet is cast for the first time, you know you've entered P3.

Wowwiki also claims she has a chat yell for entering P3 (http://www.wowwiki.com/Sindragosa_%28tactics%29) but that would require localization for non-English clients, so spell cast would probably be easiest and most versatile.


Originally Posted by upyursh View Post
Thanks Waverian, makes sense why it wouldnt find her then I'll find an alternate method to check boss health than using boss1 for unitid then
You can use raid target scanning.

Example:

Code:
-- For localization. You can also use npc ids which I don't know how to use.
-- I believe DXE using the ids if you're looking for an example
local SINDRAGOSA = "Sindragosa"

local ScanForUnit = function(name)
	if UnitName'target' == name then
		return 'target'
	elseif UnitName'focus' == name then
		return 'focus'
	elseif UnitName'pettarget' == name then
		return 'pettarget'
	else
		for i = 1, GetNumRaidMembers() do
			local unit = ('raid%dtarget'):format(i)
			if UnitName(unit) == name then return unit end
		end
	end
end

-- Use like this:
local unit = ScanForUnit(SINDRAGOSA)
print(UnitHealth(unit))

Last edited by Waverian : 05-11-10 at 05:11 AM.
  Reply With Quote
05-11-10, 07:27 AM   #13
upyursh
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 32
I am already monitoring combat log so I will use that to identify if she's around and then get her health etc, that should do the trick.

Thanks for the code btw I will store that
  Reply With Quote
05-11-10, 08:38 AM   #14
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,968
Originally Posted by Waverian View Post
Every string-based token I can think of (unitIDs, widgets) is case-insensitive.

And the bossN unitIDs are only valid when the default unit frames show boss targets, which is limited to static multi-target boss encounters in Icecrown Citadel. Gunship, Council, Valithria (?) are the only ones I believe use this feature.
Ah, learn something new every day rofl.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Best Way to get a Bosses Health


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