Module Unit
Unit API for BadRotations
Usage:
local unit = br.player.unit
Functions
unit.aberration (thisUnit) | Check if a unit is an Aberration |
unit.beast (thisUnit) | Check if a unit is a Beast |
unit.canAttack (thisUnit, playerUnit) | Check if a unit can be attacked |
unit.cancelForm () | Cancel current shapeshift form |
unit.casting (thisUnit, spellID) | Check if a unit is casting or channeling a spell |
unit.combatTime () | Get combat time |
unit.ooCombatTime () | Get time out of combat |
unit.charmed (thisUnit) | Check if a unit is charmed |
unit.clearTarget () | Clear current target |
unit.deadOrGhost (thisUnit) | Check if a unit is dead or ghost |
unit.demon (thisUnit) | Check if a unit is a Demon |
unit.distance (thisUnit, otherUnit) | Get distance between units |
unit.dualWielding () | Check if player is dual wielding weapons |
unit.enemy (thisUnit, playerUnit) | Check if a unit is an enemy |
unit.exists (thisUnit) | Check if a unit exists |
unit.facing (thisUnit, otherUnit, degrees) | Check if a unit is facing another unit |
unit.falling () | Check if a unit is falling |
unit.fallTime () | Get time the player has been falling |
unit.flying () | Check if player is flying |
unit.form () | Get current shapeshift form |
unit.formCount () | Get number of available shapeshift forms |
unit.friend (thisUnit, playerUnit) | Check if a unit is friendly to another unit |
unit.gcd (max) | Get global cooldown duration |
unit.guid (thisUnit) | Get unit's GUID (Globally Unique Identifier) |
unit.health (thisUnit) | Get unit's current health |
unit.healthMax (thisUnit) | Get unit's maximum health |
unit.hp (thisUnit) | Get unit's health percentage |
unit.humanoid (thisUnit) | Check if a unit is a Humanoid |
unit.id (thisUnit) | Get unit's ID |
unit.inCombat (thisUnit) | Check if a unit is in combat |
unit.instance (thisInstance) | Check instance type or if in a specific instance type |
unit.interruptable (thisUnit, castPercent) | Check if a unit's cast can be interrupted |
unit.isBoss (thisUnit) | Check if a unit is a boss |
unit.isCasting (thisUnit) | Check if a unit is casting |
unit.isDummy (thisUnit) | Check if a unit is a training dummy |
unit.isExplosive (thisUnit) | Check if a unit is an explosive orb (M+ affix) |
unit.isTanking (thisUnit) | Check if a unit is tanking |
unit.isTankInRange () | Check if a tank is in range |
unit.isUnit (thisUnit, otherUnit) | Check if two units are the same |
unit.level (thisUnit) | Get unit's level |
unit.lowest (range) | Get the lowest health friendly unit in range |
unit.mounted () | Check if player is mounted |
unit.moving (thisUnit) | Check if a unit is moving |
unit.movingTime () | Get time a unit has been moving |
unit.name (thisUnit) | Get unit's name |
unit.player (thisUnit) | Check if a unit is a player |
unit.outdoors () | Check if player is outdoors |
unit.race (thisUnit) | Get unit's race |
unit.reaction (thisUnit, playerUnit) | Get unit's reaction level towards another unit |
unit.resting () | Check if player is resting |
unit.role (thisUnit) | Get unit's assigned role in group |
unit.solo () | Check if player is solo (no group) |
unit.spellHaste () | Get player's spell haste percentage |
unit.standingTime () | Get time a unit has been standing still |
unit.startAttack () | Start auto-attack |
unit.stopAttack () | Stop auto-attack |
unit.swimming () | Check if player is swimming |
unit.taxi (thisUnit) | Check if a unit is on a taxi |
unit.threat (thisUnit) | Check if a unit has threat |
unit.ttd (thisUnit, percent) | Estimate time until unit dies |
unit.ttdGroup (range, percent) | Get combined time to death for all enemies in range |
unit.undead (thisUnit) | Check if a unit is Undead |
unit.valid (thisUnit) | Check if a unit is valid for targeting |
unit.weaponImbue.exists (imbueId, offHand) | Check if a weapon imbue exists |
unit.weaponImbue.remain (imbueId, offHand) | Get weapon imbue remaining time |
unit.weaponImbue.charges (imbueId, offHand) | Get weapon imbue charges |
Functions
- unit.aberration (thisUnit)
-
Check if a unit is an Aberration
Parameters:
- thisUnit The unit to check, defaults to "target" if nil
Returns:
-
boolean True if the unit is an Aberration
- unit.beast (thisUnit)
-
Check if a unit is a Beast
Parameters:
- thisUnit The unit to check, defaults to "target" if nil
Returns:
-
boolean True if the unit is a Beast
- unit.canAttack (thisUnit, playerUnit)
-
Check if a unit can be attacked
Parameters:
- thisUnit The unit to check
- playerUnit The attacking unit, defaults to "player" if nil
Returns:
-
boolean True if playerUnit can attack thisUnit
- unit.cancelForm ()
-
Cancel current shapeshift form
Returns:
-
nil
- unit.casting (thisUnit, spellID)
-
Check if a unit is casting or channeling a spell
Parameters:
- thisUnit The unit to check, defaults to "player" if nil
- spellID Optional spellID to check for
Returns:
-
boolean True if the unit is casting, or casting the specific spell if spellID provided
- unit.combatTime ()
-
Get combat time
Returns:
-
number Time in combat in seconds
- unit.ooCombatTime ()
-
Get time out of combat
Returns:
-
number Time out of combat in seconds
- unit.charmed (thisUnit)
-
Check if a unit is charmed
Parameters:
- thisUnit The unit to check
Returns:
-
boolean True if the unit is charmed
- unit.clearTarget ()
-
Clear current target
Returns:
-
nil
- unit.deadOrGhost (thisUnit)
-
Check if a unit is dead or ghost
Parameters:
- thisUnit The unit to check
Returns:
-
boolean True if the unit is dead or a ghost
- unit.demon (thisUnit)
-
Check if a unit is a Demon
Parameters:
- thisUnit The unit to check, defaults to "target" if nil
Returns:
-
boolean True if the unit is a Demon
- unit.distance (thisUnit, otherUnit)
-
Get distance between units
Parameters:
- thisUnit First unit
- otherUnit Second unit (if nil, first unit is assumed to be the target and player is used)
Returns:
-
number Distance between units in yards
- unit.dualWielding ()
-
Check if player is dual wielding weapons
Returns:
-
boolean True if player is dual wielding
- unit.enemy (thisUnit, playerUnit)
-
Check if a unit is an enemy
Parameters:
- thisUnit The unit to check
- playerUnit The reference unit, defaults to "player" if nil
Returns:
-
boolean True if thisUnit is an enemy to playerUnit
- unit.exists (thisUnit)
-
Check if a unit exists
Parameters:
- thisUnit The unit to check
Returns:
-
boolean True if the unit exists
- unit.facing (thisUnit, otherUnit, degrees)
-
Check if a unit is facing another unit
Parameters:
- thisUnit The unit to check facing from, defaults to "player" if only one parameter provided
- otherUnit The unit to check facing towards
- degrees Optional angle in degrees to consider "facing", defaults to normal game value
Returns:
-
boolean True if thisUnit is facing otherUnit within the specified degrees
- unit.falling ()
-
Check if a unit is falling
Returns:
-
boolean True if player is falling
- unit.fallTime ()
-
Get time the player has been falling
Returns:
-
number Time in seconds player has been falling
- unit.flying ()
-
Check if player is flying
Returns:
-
boolean True if player is flying
- unit.form ()
-
Get current shapeshift form
Returns:
-
number Current shapeshift form ID
- unit.formCount ()
-
Get number of available shapeshift forms
Returns:
-
number Count of available shapeshift forms
- unit.friend (thisUnit, playerUnit)
-
Check if a unit is friendly to another unit
Parameters:
- thisUnit The unit to check
- playerUnit The reference unit, defaults to "player" if nil
Returns:
-
boolean True if thisUnit is friendly to playerUnit
- unit.gcd (max)
-
Get global cooldown duration
Parameters:
- max Optional boolean to return maximum possible GCD instead of current
Returns:
-
number Global cooldown in seconds
- unit.guid (thisUnit)
-
Get unit's GUID (Globally Unique Identifier)
Parameters:
- thisUnit The unit to get GUID for
Returns:
-
string Unit's GUID
- unit.health (thisUnit)
-
Get unit's current health
Parameters:
- thisUnit The unit to check, defaults to "player" if nil
Returns:
-
number Current health of the unit
- unit.healthMax (thisUnit)
-
Get unit's maximum health
Parameters:
- thisUnit The unit to check, defaults to "player" if nil
Returns:
-
number Maximum health of the unit
- unit.hp (thisUnit)
-
Get unit's health percentage
Parameters:
- thisUnit The unit to check, defaults to "player" if nil
Returns:
-
number Health percentage of the unit (0-100)
- unit.humanoid (thisUnit)
-
Check if a unit is a Humanoid
Parameters:
- thisUnit The unit to check, defaults to "target" if nil
Returns:
-
boolean True if the unit is a Humanoid
- unit.id (thisUnit)
-
Get unit's ID
Parameters:
- thisUnit The unit to get ID for
Returns:
-
number Unit's ID
- unit.inCombat (thisUnit)
-
Check if a unit is in combat
Parameters:
- thisUnit The unit to check, defaults to "player" if nil
Returns:
-
boolean True if the unit is in combat or special conditions are met
- unit.instance (thisInstance)
-
Check instance type or if in a specific instance type
Parameters:
- thisInstance Optional specific instance type to check for
Returns:
-
string|boolean Returns instance type if no parameter, or boolean if matching specific instance
- unit.interruptable (thisUnit, castPercent)
-
Check if a unit's cast can be interrupted
Parameters:
- thisUnit The unit to check, defaults to "target" if nil
- castPercent Optional cast percentage threshold
Returns:
-
boolean True if the unit's cast can be interrupted
- unit.isBoss (thisUnit)
-
Check if a unit is a boss
Parameters:
- thisUnit The unit to check, defaults to "target" if nil
Returns:
-
boolean True if the unit is a boss
- unit.isCasting (thisUnit)
-
Check if a unit is casting
Parameters:
- thisUnit The unit to check, defaults to "player" if nil
Returns:
-
boolean True if the unit is casting
- unit.isDummy (thisUnit)
-
Check if a unit is a training dummy
Parameters:
- thisUnit The unit to check
Returns:
-
boolean True if the unit is a training dummy
- unit.isExplosive (thisUnit)
-
Check if a unit is an explosive orb (M+ affix)
Parameters:
- thisUnit The unit to check
Returns:
-
boolean True if the unit is an explosive orb
- unit.isTanking (thisUnit)
-
Check if a unit is tanking
Parameters:
- thisUnit The unit to check, defaults to "player" if nil
Returns:
-
boolean True if the unit is tanking
- unit.isTankInRange ()
-
Check if a tank is in range
Returns:
-
boolean True if a tank is in range
- unit.isUnit (thisUnit, otherUnit)
-
Check if two units are the same
Parameters:
- thisUnit First unit to compare
- otherUnit Second unit to compare
Returns:
-
boolean True if both units are the same
- unit.level (thisUnit)
-
Get unit's level
Parameters:
- thisUnit The unit to check, defaults to "player" if nil
Returns:
-
number The level of the unit
- unit.lowest (range)
-
Get the lowest health friendly unit in range
Parameters:
- range The range to check for units, defaults to 5 if nil
Returns:
-
unit The friendly unit with lowest health in range
- unit.mounted ()
-
Check if player is mounted
Returns:
-
boolean True if player is mounted
- unit.moving (thisUnit)
-
Check if a unit is moving
Parameters:
- thisUnit The unit to check, defaults to "player" if nil
Returns:
-
boolean True if the unit is moving
- unit.movingTime ()
-
Get time a unit has been moving
Returns:
-
number Time in seconds the unit has been moving
- unit.name (thisUnit)
-
Get unit's name
Parameters:
- thisUnit The unit to get name of
Returns:
-
string The name of the unit
- unit.player (thisUnit)
-
Check if a unit is a player
Parameters:
- thisUnit The unit to check
Returns:
-
boolean True if the unit is a player
- unit.outdoors ()
-
Check if player is outdoors
Returns:
-
boolean True if player is outdoors
- unit.race (thisUnit)
-
Get unit's race
Parameters:
- thisUnit The unit to check, defaults to "player" if nil
Returns:
-
string The race of the unit
- unit.reaction (thisUnit, playerUnit)
-
Get unit's reaction level towards another unit
Parameters:
- thisUnit The unit to check reaction of
- playerUnit The reference unit, defaults to "player" if nil
Returns:
-
number Reaction level (1-hostile to 8-friendly)
- unit.resting ()
-
Check if player is resting
Returns:
-
boolean True if player is resting
- unit.role (thisUnit)
-
Get unit's assigned role in group
Parameters:
- thisUnit The unit to check, defaults to "target" if nil
Returns:
-
string The role assigned to the unit ("TANK", "HEALER", "DAMAGER", "NONE")
- unit.solo ()
-
Check if player is solo (no group)
Returns:
-
boolean True if player is solo
- unit.spellHaste ()
-
Get player's spell haste percentage
Returns:
-
number Spell haste percentage
- unit.standingTime ()
-
Get time a unit has been standing still
Returns:
-
number Time in seconds the unit has been standing still
- unit.startAttack ()
-
Start auto-attack
Returns:
-
nil
- unit.stopAttack ()
-
Stop auto-attack
Returns:
-
nil
- unit.swimming ()
-
Check if player is swimming
Returns:
-
boolean True if player is swimming
- unit.taxi (thisUnit)
-
Check if a unit is on a taxi
Parameters:
- thisUnit The unit to check, defaults to "player" if nil
Returns:
-
boolean True if the unit is on a taxi
- unit.threat (thisUnit)
-
Check if a unit has threat
Parameters:
- thisUnit The unit to check, defaults to "target" if nil
Returns:
-
boolean True if the unit has threat
- unit.ttd (thisUnit, percent)
-
Estimate time until unit dies
Parameters:
- thisUnit The unit to check, defaults to "target" if nil
- percent Optional health percentage to calculate time to
Returns:
-
number Estimated time until death in seconds
- unit.ttdGroup (range, percent)
-
Get combined time to death for all enemies in range
Parameters:
- range Range to check for enemies, defaults to 5 yards if nil
- percent Optional health percentage to calculate time to
Returns:
-
number Combined estimated time until death for all enemies in range
- unit.undead (thisUnit)
-
Check if a unit is Undead
Parameters:
- thisUnit The unit to check
Returns:
-
boolean True if the unit is Undead
- unit.valid (thisUnit)
-
Check if a unit is valid for targeting
Parameters:
- thisUnit The unit to check
Returns:
-
boolean True if the unit is valid
- unit.weaponImbue.exists (imbueId, offHand)
-
Check if a weapon imbue exists
Parameters:
- imbueId The ID of the imbue to check for
- offHand Boolean whether to check offhand (true) or main hand (false, default)
Returns:
-
boolean True if the imbue exists on the specified weapon
- unit.weaponImbue.remain (imbueId, offHand)
-
Get weapon imbue remaining time
Parameters:
- imbueId The ID of the imbue to check
- offHand Boolean whether to check offhand (true) or main hand (false, default)
Returns:
-
number Time remaining on the weapon imbue in seconds
- unit.weaponImbue.charges (imbueId, offHand)
-
Get weapon imbue charges
Parameters:
- imbueId The ID of the imbue to check
- offHand Boolean whether to check offhand (true) or main hand (false, default)
Returns:
-
number Number of charges remaining on the weapon imbue