Ralgathor / LibClassicSwingTimerAPI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LibClassicSwingTimerAPI

There is no relevant WOW API to have an easily accessible state of the swing timer. This library fires custom EVENTS that can be used in other ADDONs to produce swing timer information.

Usage example:

Use in Addon

local SwingTimerLib = LibStub("LibClassicSwingTimerAPI", true)
if not SwingTimerLib then return end

local f = CreateFrame("Frame", nil)

local UnitSwingTimerInfo = function(unitId, hand)
    return SwingTimerLib:UnitSwingTimerInfo(unitId, hand)
end

local SwingTimerEventHandler = function(event, ...)
    return f[event](f, event, ...)
end

SwingTimerLib.RegisterCallback(f, "UNIT_SWING_TIMER_INFO_INITIALIZED", SwingTimerEventHandler)
SwingTimerLib.RegisterCallback(f, "UNIT_SWING_TIMER_START", SwingTimerEventHandler)
SwingTimerLib.RegisterCallback(f, "UNIT_SWING_TIMER_UPDATE", SwingTimerEventHandler)
SwingTimerLib.RegisterCallback(f, "UNIT_SWING_TIMER_CLIPPED", SwingTimerEventHandler)
SwingTimerLib.RegisterCallback(f, "UNIT_SWING_TIMER_PAUSED", SwingTimerEventHandler)
SwingTimerLib.RegisterCallback(f, "UNIT_SWING_TIMER_STOP", SwingTimerEventHandler)
SwingTimerLib.RegisterCallback(f, "UNIT_SWING_TIMER_DELTA", SwingTimerEventHandler)

Use in WeakAuras

The LibClassicSwingTimerAPI fire the events as WeakAuras custom events that can be use on Custom Triggers. The following auras export strings are examples on how to use the lib in WeakAuras.

Main hand aura
!WA:2!9zv3UTTnu4AyGUnHMIwxScKHTbnJTIwSK08t)ddiOWkXU2dj2UYknTBTqHsKYITYKeuuoX5IHTGHHEDUB3Sl8JGXEak6tGqWW21lpc5jyKuQo)6jaBrE4HN)pFhvOwPELGLGV9UdJza(B2edfHF6qSpL0HMW9rF(L470kiigjQ)yZlPF4dYj8UNUu3FwsyeG4hs5TPyIWBLQnDQAFGwA2ubqGPKcSRFQ9RtHiRkB406ipG)B6YPje4k0ik)7luOq7IZp393tWXD7I4X)XT45l)Bl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EP4N0Vexxks2aC7vZUE922GOKqqrxXn0hhyqXePZrHpkddNSZkvJc6Sud0l2EsmflWoQQ24gDSB(6oTDQ2AS30zUgtWen(uSZy0zm3xRuAY8pUYdR8Zl)0LdCF6k(U(RuAV)y7))p

API EVENTS

UNIT_SWING_TIMER_INFO_INITIALIZED

Fired after the initialization of swing information for the unit. The UnitSwingTimerInfo method is only usable after this event.

Property Description
unitId string - type of the unit ("player" or "target")

UNIT_SWING_TIMER_START

Fired when a weapon or ranged swing starts.

Property Description
unitId string - type of the unit ("player" or "target")
speed number - weapon speed
expirationTime number - end of swing relative to GetTime()
hand string - the hand that start to swing ("mainhand", "offhand" or "ranged")

UNIT_SWING_TIMER_UPDATE

Fired when weapon speed changes.

Property Description
unitId string - type of the unit ("player" or "target")
speed number - weapon speed
expirationTime number - end of swing relative to GetTime()
hand string - the hand speed that update ("mainhand" or "offhand")

UNIT_SWING_TIMER_CLIPPED

Fired if a weapon swing is clipped by a spell cast.

Property Description
unitId string - type of the unit ("player" or "target")
hand string - The hand that is clipped "mainhand" or "offhand"

UNIT_SWING_TIMER_PAUSED

Fired if a weapon swing is paused by a spell cast.

Property Description
unitId string - type of the unit ("player" or "target")
hand string - The hand that is paused "mainhand" or "offhand"

UNIT_SWING_TIMER_STOP

Fired when a weapon or ranged swing ends.

Property Description
unitId string - type of the unit ("player" or "target")
hand string - the hand that end a swing ("mainhand", "offhand" or "ranged")

UNIT_SWING_TIMER_DELTA

Fired when delta calculation between MH and OH update

Property Description
unitId string - type of the unit ("player" or "target")
swingDelta number - Delta in seconds between MH and OH.

API METHODS

UnitSwingTimerInfo(unitId, hand)

Returns the hand's current swing state for the given unit type. Can only be used after the UNIT_SWING_TIMER_INFO_INITIALIZED event.

speed, expirationTime, lastSwing = UnitSwingTimerInfo(unitId, hand)
  • Arguments
    • unitId
      • string - type of the unit ("player" or "target")
    • hand
      • string - The hand to get information for ("mainhand", "offhand" or "ranged")
  • Returns
    • speed
      • number - weapon speed
    • expirationTime
      • number - end of swing relative to GetTime()
    • lastSwing
      • number - last swing relative to GetTime()

API EVENTS Backward compatibility

Maintain backward compatibility. The following events are still fired only for the player.

SWING_TIMER_INFO_INITIALIZED

Fired after the initialization of the swing information for the player. The SwingTimerInfo method is only usable after this event.

SWING_TIMER_START

Fired when a weapon or ranged swing starts.

Property Description
speed number - weapon speed
expirationTime number - end of swing relative to GetTime()
hand string - the hand that start to swing ("mainhand", "offhand" or "ranged")

SWING_TIMER_UPDATE

Fired when weapon speed changes.

Property Description
speed number - weapon speed
expirationTime number - end of swing relative to GetTime()
hand string - the hand speed that update ("mainhand" or "offhand")

SWING_TIMER_CLIPPED

Fired if a weapon swing is clipped by a spell cast.

Property Description
hand string - The hand that is clipped "mainhand" or "offhand"

SWING_TIMER_PAUSED

Fired if a weapon swing is paused by a spell cast.

Property Description
hand string - The hand that is paused "mainhand" or "offhand"

SWING_TIMER_STOP

Fired when a weapon or ranged swing ends.

Property Description
hand string - the hand that end a swing ("mainhand", "offhand" or "ranged")

SWING_TIMER_DELTA

Fired when delta calculation between MH and OH update

Property Description
swingDelta number - Delta in seconds between MH and OH.

API METHODS Backward compatibility

API method SwingTimerInfo(hand)

Returns the hand's current swing state for the player. Can only be used after the SWING_TIMER_INFO_INITIALIZED event.

speed, expirationTime, lastSwing = SwingTimerInfo(hand)
  • Arguments
    • hand
      • string - The hand to get information for ("mainhand", "offhand" or "ranged")
  • Returns
    • speed
      • number - weapon speed
    • expirationTime
      • number - end of swing relative to GetTime()
    • lastSwing
      • number - last swing relative to GetTime()

About

License:GNU General Public License v3.0


Languages

Language:Lua 100.0%