API UnitCastingInfo

From Wowpedia
Jump to: navigation, search

Returns information about the spell currently being cast by the specified unit.

name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo("unit")

Arguments

unit 
String - The unit to query (e.g. "player", "party2", "pet", "target" etc.)

Returns

name 
String - The name of the spell, or nil if no spell is being cast.
text 
String - The name to be displayed.
texture 
String - The texture path associated with the spell icon.
startTimeMS 
Number - Specifies when casting began in milliseconds (corresponds to GetTime()*1000).
endTimeMS 
Number - Specifies when casting will end in milliseconds (corresponds to GetTime()*1000).
isTradeSkill 
Boolean - Specifies if the cast is a tradeskill
castID 
String - GUID-like string (an example is 3-3890-1159-21205-8936-00014B7E7F) where the second to last value is the spellID. The other values are as yet unknown.
notInterruptible 
Boolean - if true, indicates that this cast cannot be interrupted with abilities like [Kick] or [Shield Bash]. In default UI those spells have shield frame around their icons on enemy cast bars.
spellId 
Integer - The spell's unique identifier. (Added in 7.2.5)

Example

The following snippet prints the amount of time remaining before the player's current spell finishes casting.

local spell, _, _, _, endTime = UnitCastingInfo("player")
if spell then 
 local finish = endTimeMS/1000 - GetTime()
 print(spell .. ' will be finished casting in ' .. finish .. ' seconds.')
end

Details

  • For channeled spells, displayName is "Channeling". So far displayName is observed to be the same as name in any other contexts.
  • This function may not return anything when the target is channeling spell post it warm-up period, you should use UnitChannelInfo in that case. It takes the same arguments and returns similar values specific to channeling spells.
  • The castID has changed (7.2.5?) from the previous ("Number - Counts the spellcast(s) since the game has loaded") and is now GUID-like string. An example is "3-3890-1159-21205-8936-00014B7E7F". The second to last value is the spell ID but the others need to be identified.

Patch changes

  • Battle for Azeroth Patch 8.0.1 (2018-07-17): Removed the second parameter, "nameSubtext". Second parameter is now "text" (former third parameter).

See also