API UnitSpellHaste

From Wowpedia
Jump to: navigation, search

Returns the current spell haste percentage for a unit.

spellHastePercent = UnitSpellHaste("unit" or "name")

Arguments

unit
String (unitId) - unit to query, e.g. "player", "target".
name
String - Name of unit to query.

Returns

spellHastePercent 
Number - The spell haste percent for the queried unit (e.g. 37.650131225586). Will return 0 if no valid unitId is provided.

Example

The following snippet prints the current spell haste percentage modifier for the targeted unit:

local spellHastePercent = UnitSpellHaste("target")
print(format("Current spell haste percent: %s", spellHastePercent))

You can use this function to get the non-modified cast time of a spell:

local spellId = 2060 --Greater Heal
local castTimeWithHaste = select(7,GetSpellInfo(spellId))
local spellHasteModifier = 1-UnitSpellHaste("player")/100
local castTimeWithoutHaste = floor(castTimeWithHaste/spellHasteModifier/100)/10
print(castTimeWithoutHaste)

This should print 2.5 for [Greater Heal].

See also