WoW:API GetPetHappiness: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
m (Move page script moved page API GetPetHappiness to API GetPetHappiness without leaving a redirect)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{wowapi}}
Returns the pet's happiness, damage percentage, and loyalty gain rate.
Returns the pet's happiness, damage percentage, and loyalty gain rate.


  happiness, damagePercentage, loyaltyRate = GetPetHappiness();
  happiness, damagePercentage, loyaltyRate = GetPetHappiness()
 
== Parameters ==
=== Arguments ===
:none


----
=== Returns ===
:happiness, damagePercentage, loyaltyRate


; ''Returns:''<br>
:;happiness : Number - the numerical happiness value of the pet (1 = unhappy, 2 = content, 3 = happy)
:'''happiness''' (integer) - the numerical happiness value of the pet (1 = unhappy, 2 = content, 3 = happy)
:;damagePercentage : Number - damage modifier, happiness affects this (unhappy = 75%, content = 100%, happy = 125%)  
:'''damagePercentage''' (integer) - damage modifier, happiness affects this (unhappy = 75%, content = 100%, happy = 125%)
:;loyaltyRate : Number - the rate at which your pet is currently gaining loyalty (< 0, losing loyalty, > 0, gaining loyalty)
:'''loyaltyRate''' (integer) - the rate at which your pet is currently gaining happiness (< 0, losing loyalty, > 0, gaining loyalty)


{{template:WoW API}}
== Example ==
happiness, damagePercentage, loyaltyRate = GetPetHappiness()
if not happiness then
DEFAULT_CHAT_FRAME:AddMessage("No Pet")
else
local happy = ({"Unhappy", "Content", "Happy"})[happiness]
local loyalty = loyaltyRate > 0 and "gaining" or "losing"
DEFAULT_CHAT_FRAME:AddMessage("Pet is " .. happy)
DEFAULT_CHAT_FRAME:AddMessage("Pet is doing " .. damagePercentage .. "% damage")
DEFAULT_CHAT_FRAME:AddMessage("Pet is " .. loyalty .. " loyalty")
end

Latest revision as of 04:46, 15 August 2023

WoW API < GetPetHappiness

Returns the pet's happiness, damage percentage, and loyalty gain rate.

happiness, damagePercentage, loyaltyRate = GetPetHappiness()

Parameters[edit]

Arguments[edit]

none

Returns[edit]

happiness, damagePercentage, loyaltyRate
happiness
Number - the numerical happiness value of the pet (1 = unhappy, 2 = content, 3 = happy)
damagePercentage
Number - damage modifier, happiness affects this (unhappy = 75%, content = 100%, happy = 125%)
loyaltyRate
Number - the rate at which your pet is currently gaining loyalty (< 0, losing loyalty, > 0, gaining loyalty)

Example[edit]

happiness, damagePercentage, loyaltyRate = GetPetHappiness()
if not happiness then
	DEFAULT_CHAT_FRAME:AddMessage("No Pet")
else
	local happy = ({"Unhappy", "Content", "Happy"})[happiness]
	local loyalty = loyaltyRate > 0 and "gaining" or "losing"
	DEFAULT_CHAT_FRAME:AddMessage("Pet is " .. happy)
	DEFAULT_CHAT_FRAME:AddMessage("Pet is doing " .. damagePercentage .. "% damage")
	DEFAULT_CHAT_FRAME:AddMessage("Pet is " .. loyalty .. " loyalty")
end