Module unit.Main
Main unit api.
Functions
Functions
- Unit:GUID ()
-
Returns:
-
string The GUID of the unit.
- Unit:ClassID ()
-
Returns:
-
number The class ID of the unit.
- Unit:ClassName ()
-
Returns:
-
string The class name of the unit.
- Unit:NpcID ()
-
Returns:
-
number The NPC ID, or 0 if not an NPC or the ID cannot be determined.
- Unit:IsNpc ()
-
Returns:
-
boolean True if the unit is an NPC, false otherwise.
- Unit:Exists ()
-
Returns:
-
boolean True if the unit exists and is visible, false otherwise.
- Unit:Name ()
-
Returns:
-
string The name of the unit.
- Unit:Hostile ()
-
Returns:
-
boolean True if the unit is hostile, false otherwise.
- Unit:IsValidEnemy (range)
-
Parameters:
- range number|nil The maximum range to consider the unit a valid enemy. Defaults to 40.
Returns:
-
boolean True if the unit is a valid enemy, false otherwise.
- Unit:IsValidFriend (range)
-
Parameters:
- range number|nil The maximum range to consider the unit a valid friend. Defaults to 40.
Returns:
-
boolean True if the unit is a valid friend, false otherwise.
- Unit:Level ()
-
Returns:
-
number The level of the unit.
- Unit:Class ()
-
Returns:
-
string, string, number The localized class name, class token, and class ID.
- Unit:IsInBossList (id)
-
Parameters:
- id number|nil An optional NPC ID to check against. If nil, uses the unit's own NpcID.
Returns:
-
boolean True if the unit is in the boss list, false otherwise.
- Unit:IsBoss ()
-
Returns:
-
boolean True if the unit is a boss, false otherwise.
- Unit:IsDummy ()
-
Returns:
-
boolean True if the unit is a dummy, false otherwise.
- Unit:IsAPlayer ()
-
Returns:
-
boolean True if the unit is a player, false otherwise.
- Unit:Health ()
-
Returns:
-
number The current health of the unit.
- Unit:MaxHealth ()
-
Returns:
-
number The maximum health of the unit.
- Unit:HP ()
-
Returns:
-
number The health percentage (0-100), or 0 if health/max health is invalid.
- Unit:IsDeadOrGhost ()
-
Returns:
-
boolean True if the unit is dead or a ghost, false otherwise.
- Unit:IsInCombat ()
-
Returns:
-
boolean True if the unit is in combat, false otherwise.
- Unit:IsUnit (other)
-
Parameters:
- other table The other unit object (e.g., {id = "target"}).
Returns:
-
boolean True if the units are the same, false otherwise.
- Unit:Classification ()
-
Returns:
-
string The unit's classification, or an empty string if none.
- Unit:GroupRole ()
-
Returns:
-
string|nil The group role, or nil if not assigned a role.
- Unit:IsTank ()
-
Returns:
-
boolean True if the unit is a tank, false otherwise.
- Unit:IsDPS ()
-
Returns:
-
boolean True if the unit is a DPS, false otherwise.
- Unit:IsHealer ()
-
Returns:
-
boolean True if the unit is a healer, false otherwise.
- Unit:IsTanking (other)
-
Parameters:
- other table The other unit object being tanked.
Returns:
-
boolean True if the unit is tanking the other unit, false otherwise.
- Unit:IsTankingAoE ()
-
Returns:
-
boolean True if the unit is tanking AoE, false otherwise.
- Unit:IsMoving ()
-
Returns:
-
boolean True if the unit is moving, false otherwise.
- Unit:IsInRange (self, range)
-
Checks if the unit is within a specified range.
Parameters:
- self Unit The unit object.
- range number The maximum range to check against.
Returns:
-
boolean True if the unit is within the specified range, false otherwise.
- Unit:Range (self)
-
Retrieves the maximum range at which the unit can be interacted with.
Parameters:
- self Unit The unit object.
Returns:
-
number The maximum interaction range of the unit, or 0 if not available.
- Unit:IsSpellInRange (self, spell)
-
Checks if a specific spell is in range for the unit.
Parameters:
- self Unit The unit object.
- spell table A table containing the spell information (e.g., spell.id or spell.name).
Returns:
-
boolean True if the spell is in range for the unit, false otherwise.
- Unit:IsItemInRange (self, item)
-
Checks if a specific item is in range for the unit.
Parameters:
- self Unit The unit object.
- item table A table containing the item information (e.g., item.id).
Returns:
-
boolean True if the item is in range for the unit, false otherwise.
- Unit:TargetUnit ()
-
Returns:
-
table A Unit object representing the targeted unit.
- Unit:PowerType ()
-
Returns:
-
string The power type.
- Unit:PowerMax ()
-
Returns:
-
number The maximum power.
- Unit:Power ()
-
Returns:
-
number The current power.
- Unit:PowerRegen ()
-
Returns:
-
number The power regeneration per second.
- Unit:PowerPercentage ()
-
Returns:
-
number The power percentage (0-100).
- Unit:PowerDeficit ()
-
Returns:
-
number The power deficit.
- Unit:PowerDeficitPercentage ()
-
Returns:
-
number The power deficit percentage (0-100).
- Unit:PowerRegenPercentage ()
-
Returns:
-
number The power regeneration percentage.
- Unit:PowerTimeToMax ()
-
Returns:
-
number The time to max power, or -1 if no regeneration.
- Unit:PowerTimeToX (amount, offset)
-
Parameters:
- amount number The target power amount.
- offset number|nil An optional offset for regeneration calculation.
Returns:
-
number The time to reach the amount, or -1 if no regeneration or already at/above amount.
- Unit:PowerTimeToXPercentage (amount)
-
Parameters:
- amount number The target power percentage (0-100).
Returns:
-
number The time to reach the percentage, or -1 if no regeneration or already at/above percentage.
- Unit:IsHealable ()
-
Returns:
-
boolean True if the unit is healable, false otherwise.
- Unit:HealAbsorb ()
-
Returns:
-
number The total heal absorb amount, or 0 if none.
- Unit:GetKeybindAction ()
-
Returns:
-
table|nil The keybind action object, or nil if not set.
- Unit:GetKeybind ()
-
Returns:
-
string|nil The keybind string, or nil if no action or keybind.
- Unit:GetKeycodes ()
-
Returns:
-
table A table of keycodes, or an empty table if no action.