Unit Methods
This document outlines all available methods for the Unit class in the Aurora Framework.
Position & Movement Methods
behind(target)
behind(target: Unit) -> boolean
Check if unit is behind target
infront(target)
infront(target: Unit) -> boolean
Check if unit is in front of target
melee(target)
melee(target: Unit) -> boolean
Check if unit is in melee range of target
distanceto(target)
distanceto(target: Unit | {x: number, y: number, z: number}) -> number
Get distance to target. The target can be either:
- A Unit object
- A position table with x, y, z coordinates
Returns the distance in yards.
distancetoliteral(target)
distancetoliteral(target: Unit) -> number
Get literal distance to target (ignoring combat reach)
futureposition(timeframe)
futureposition(time: Number) -> Array: number
movingtoward(target, options)
movingtoward(target: Unit, options?: number | {angle?: number, duration?: number}) -> boolean
Check if unit is moving toward the specified target.
Parameters:
target
: The target unit to check movement towardoptions
: Can be either:- A number representing the angle threshold in degrees (default: 30)
- A table with optional properties:
angle
: Angle threshold in degrees (default: 30)duration
: Minimum duration in seconds the unit must be moving toward target (default: 0)
Returns: true
if the unit is moving toward the target within the specified angle threshold and duration, false
otherwise.
-- Simple check with default 30-degree threshold
if player.movingtoward(target) then
-- Player is moving toward target
end
-- Check with custom angle threshold
if player.movingtoward(target, 45) then
-- Player is moving toward target within 45 degrees
end
-- Check with angle and duration requirements
if player.movingtoward(target, {angle = 20, duration = 1.5}) then
-- Player has been moving toward target for at least 1.5 seconds within 20 degrees
end
movingawayfrom(target, options)
movingawayfrom(target: Unit, options?: number | {angle?: number, duration?: number}) -> boolean
Check if unit is moving away from the specified target.
Parameters:
target
: The target unit to check movement away fromoptions
: Can be either:- A number representing the angle threshold in degrees (default: 30)
- A table with optional properties:
angle
: Angle threshold in degrees (default: 30)duration
: Minimum duration in seconds the unit must be moving away from target (default: 0)
Returns: true
if the unit is moving away from the target within the specified angle threshold and duration, false
otherwise.
-- Simple check with default 30-degree threshold
if player.movingawayfrom(target) then
-- Player is moving away from target
end
-- Check with custom angle threshold
if player.movingawayfrom(target, 45) then
-- Player is moving away from target within 45 degrees
end
-- Check with angle and duration requirements
if player.movingawayfrom(target, {angle = 20, duration = 1.5}) then
-- Player has been moving away from target for at least 1.5 seconds within 20 degrees
end
predictposition(elapsed)
predictposition(elapsed: number) -> Vector3 | false
Predict the unit's position after a given elapsed time (in seconds). Returns a Vector3 of the predicted position, or false if prediction is not possible.
-- Predict where the player will be in 2 seconds
local futurePos = player.predictposition(2)
if futurePos then
-- Use predicted position for targeting or movement
end
Combat Methods
inarcof(target, size , arc , rotation)
inarcof(target: Unit, size: number, arc: number, rotation: number) -> boolean
Check if unit is within a specific arc of target
enemiesaround(radius)
enemiesaround(radius: number) -> number
Count enemies within radius
haslos(target)
haslos(target: Unit | {x: number, y: number, z: number}) -> boolean
Check line of sight to target
predictlos(target, timeframe)
predictlos(target: Unit, timeframe?: number) -> boolean
Predict line of sight to target at a future position. This method calculates the predicted positions of both units after the specified timeframe and checks if there will be line of sight between them.
Parameters:
target
: The target unit to check predicted line of sight totimeframe
: Time in seconds to predict ahead (default: 1)
Returns: true
if there will be line of sight to the target at the predicted positions, false
otherwise.
The method:
- Predicts both units' positions at the future timeframe
- Checks for LOS override settings in Aurora.Enums.OMLists.LosOverride
- Uses TraceLine to verify line of sight between predicted positions
- Accounts for unit height in the calculation
-- Check if we'll have line of sight to target in 2 seconds
if player.predictlos(target, 2) then
-- Pre-cast spell that will land when we have LOS
end
-- Check predicted LOS with default 1 second timeframe
if unit.predictlos(enemy) then
-- Target will be in line of sight soon
end
Unit Interaction Methods
settarget(target)
settarget(target: Unit|nil) -> boolean
Set unit's target
isunit(target)
isunit(target: Unit) -> boolean
Check if unit is the same as target
interact()
interact() -> boolean
Interact with the unit
Position & Movement
local target = Aurora.UnitManager:Get("target")
local player = Aurora.UnitManager:Get("player")
-- Check if player is behind target
if player.behind(target) then
-- Use backstab ability
end
-- Check distance and line of sight
if target.distanceto(player) < 30 and target.haslos(player) then
-- Cast ranged ability
end
Combat & Targeting
local player = Aurora.UnitManager:Get("player")
-- Count nearby enemies
local enemyCount = player.enemiesaround(8)
if enemyCount >= 3 then
-- Use AoE ability
end
-- Set target and interact
local enemy = Aurora.UnitManager:Get("target")
if enemy.exists and player.settarget(enemy) then
player.interact()
end
Best Practices
- Always check unit existence before calling methods
- Use appropriate range checks before attempting interactions
- Consider line of sight for ranged abilities
- Cache frequently accessed values for better performance
- Don't assume target existence
- Check range before melee abilities
- Verify line of sight for ranged abilities
- Consider unit type restrictions for certain interactions
Notes
All methods can be called using either:
- Colon syntax:
unit:method(args)
- Dot syntax with self:
unit.method(unit, args)
- Most methods return
false
ornil
on failure - Check return values for critical operations
- Some methods may return multiple values