# C_SwingTimer: World of Warcraft Forever API

Forever 1.60.1 (70959), Interface 16001, Lua 5.1, from Blizzard's own API documentation. Page: https://wowaddons.gg/forever-api/C_SwingTimer

## Functions

### C_SwingTimer.EnableRangeCheck

```lua
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:
- `swingType`: PlayerSwingType
- `enable`: bool. True if changes in range for the swing type should dispatch PlayerSwingRangeUpdate. False if the swing type no longer needs the event.

### C_SwingTimer.IsTargetWithinSwingRange

```lua
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:
- `swingType`: PlayerSwingType

Returns:
- `isInRange`: bool, may be nil. Nil 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

Payload, after the event's name:
- `swingDuration`: number
- `swingType`: PlayerSwingType

### PLAYER_SWING_RANGE_UPDATE

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

Payload, after the event's name:
- `swingType`: PlayerSwingType
- `isInRange`: bool. Whether the current target is within auto attack range. Should not be used if the 'checksRange' parameter is false.
- `checksRange`: bool. Can be false if a range check was not made for any reason, for example there is not a current target.

## Tables

### Enum.PlayerSwingType (enumeration)

- `MainHand` = 0
- `OffHand` = 1
- `Ranged` = 2

---
Make an addon with your 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."
