WowAddons

World of Warcraft Forever API · C_SwingTimer.md, for your AI

C_SwingTimer

2 functions, 2 events, 1 tables, as Blizzard documents them for Forever 1.60.1 (70959).

Making an addon with an AI? Tell it: Read https://wowaddons.gg/agents.md, then make me a World of Warcraft Forever addon that …, try it with me in the game, and publish it. It checks every call against this API before you try it in the game, then publishes it here. How it works.

Functions

C_SwingTimer.EnableRangeCheck

C_SwingTimer.EnableRangeCheck(swingType, enable)

Used in conjunction with PlayerSwingRangeUpdate to inform the UI when the current target goes in or out of auto attack range.

Arguments

swingTypePlayerSwingType
enableboolTrue if changes in range for the swing type should dispatch PlayerSwingRangeUpdate. False if the swing type no longer needs the event.

C_SwingTimer.IsTargetWithinSwingRange

isInRange = C_SwingTimer.IsTargetWithinSwingRange(swingType)

Whether the current target is within range of the player's auto attack for the given swing type. Auto attacks only ever apply to the current target, so no other unit can be queried.

Arguments

swingTypePlayerSwingType

Returns

isInRangebool may be nilNil when no range check could be made, for example there is no target, the target cannot be attacked, or no weapon is equipped for the swing type. Nil must not be treated as out of range.

Events

PLAYER_SWING

swingDurationnumber
swingTypePlayerSwingType

PLAYER_SWING_RANGE_UPDATE

Only signaled for swing types that have an active range check. See C_SwingTimer.EnableRangeCheck.

swingTypePlayerSwingType
isInRangeboolWhether the current target is within auto attack range. Should not be used if the 'checksRange' parameter is false.
checksRangeboolCan be false if a range check was not made for any reason, for example there is not a current target.

Tables

Enum.PlayerSwingType enumeration

MainHand0
OffHand1
Ranged2

It takes WowAddons

Free, for Windows, macOS and Linux: it puts the addon in your game in one click and keeps it up to date. Open it once, then press Install again.

WowAddons runs on your computer: open wowaddons.gg there.

Download for Windows