WoW:API UnitHealthMax: Difference between revisions

mNo edit summary
m (Move page script moved page API UnitHealthMax to API UnitHealthMax without leaving a redirect)
 
(6 intermediate revisions by 6 users not shown)
Line 1: Line 1:
<center>'''UnitHealthMax''' ''-Documentation by [[User:Danboo|danboo]]-''</center>
{{wowapi}} __NOTOC__
 
Returns the maximum health of the specified unit.
Returns the maximal health of the specified unit, in percentage, for:
 
*target
*mouseover
 
Otherwise in points.


  local max_health = UnitHealthMax(unit);
  local max_health = UnitHealthMax(unit);


----
==Parameters==
;''Arguments''
:;unit : [[UnitId]] -  the unit whose max health to query.
 
:(String unit)
 
:;arg1 : the unit's max health to query
 
----
;''Returns''
 
:max_health
:;max_health : the maximum health of the specified unit
 
----
;''Example''
local max_health = UnitHealthMax("player");
local max_health2 = UnitHealthMax("target");
ChatFrame1:AddMessage('player max health: ' .. max_health);
ChatFrame1:AddMessage('target max health: ' .. max_health2 .. "%");
 
;''Result''
Prints the player's maximum health to the chat frame as
'player max health: 900' and 'target max health: 100%'
 
----
;''Description''


: Returns the maximum health of the specified unit. The health is returned in real points only if the unit is in the player's party. Otherwise, a percentage is returned (which will always be 100 in this case). (Note, that the player, the player's pet, and any party member pets are considered to be in the party.)
==Returns==
:;max_health : Integer - the maximum health of the specified unit, returns 0 if the specified unit does not exist (eg. "target" given but there is no target)


----
==Example==
{{Template:WoW API}}
Print the maximum health of ''player'' and ''target'' units to the chat window:
[[Category:API Functions|UnitHealthMax]]
ChatFrame1:AddMessage('Player max health: ' .. UnitHealthMax("player") .. " HP");
[[Category:API Unit Functions|UnitHealthMax]]
ChatFrame1:AddMessage('Target max health: ' .. UnitHealthMax("target") .. " HP");

Latest revision as of 04:47, 15 August 2023

WoW API < UnitHealthMax

Returns the maximum health of the specified unit.

local max_health = UnitHealthMax(unit);

Parameters

unit
UnitId - the unit whose max health to query.

Returns

max_health
Integer - the maximum health of the specified unit, returns 0 if the specified unit does not exist (eg. "target" given but there is no target)

Example

Print the maximum health of player and target units to the chat window:

ChatFrame1:AddMessage('Player max health: ' .. UnitHealthMax("player") .. " HP");
ChatFrame1:AddMessage('Target max health: ' .. UnitHealthMax("target") .. " HP");