Module units
These functions find units: the "best" unit for a range and AOE/facing, the group members, the dead to loot.
Units functions are the profile API table `units` (br.api.profile.units); profiles use it by name.
Functions
| buffUnit (thisOption, needsBuff[, range=40]) | Gets the unit to buff from a "cast on" dropdown option (choices = "CastOn": You, You + Target, You + Mouseover, You + Focus, You + Group). |
| castOn (thisOption, needs, able[, opts]) | The unit a "cast on" dropdown option (choices = "CastOn") puts a helpful spell on now, or nil: you first, then the option's target, mouseover or focus, or for You + Group each member (lowest health first). |
| get (range) | Gets the "best" unit within a specified range in front or around the player. |
| picking () | True when BR may pick enemies other than your target right now (Targeting Mode isn't Off, and you're in combat or "Targeting Only In Combat" is off): what units.get's picks follow |
| groupStable (seconds) | True when the group hasn't changed (members joining or leaving) for that many seconds |
| healAround (thisUnit, radius, health, count) | The group members within radius yards of a unit at or below health percent, lowest first, at most count of them (each with .hp, .guid, .name, position) |
| lootable () | The dead units the player can loot |
| lootCount () | How many dead units are waiting to be looted |
| setTargetWeight (fn) | Sets the profile's own target weight for dynamic targeting: fn(unit) returns a number added to the unit's score (higher = more priority), or nil to leave it. |
Functions
- buffUnit (thisOption, needsBuff[, range=40])
-
Gets the unit to buff from a "cast on" dropdown option (choices = "CastOn": You, You + Target,
You + Mouseover, You + Focus, You + Group). Older form of units.castOn: range by distance, no cast check.
Parameters:
- thisOption string - Name of the dropdown option.
- needsBuff - function(unit) returning true if that unit needs the buff.
- range number - Maximum range for others. (default 40)
Returns:
-
string - Unit token: you, else the first friendly player the option allows that needs it, else "player".
- castOn (thisOption, needs, able[, opts])
-
The unit a "cast on" dropdown option (choices = "CastOn") puts a helpful spell on now, or nil: you first,
then the option's target, mouseover or focus, or for You + Group each member (lowest health first). Each one
must be a friendly player you can help (alive, online, not charmed), want it (needs) and be castable (able,
usually cast.able.
, which judges range and sight); one that fails is passed over for the next. Parameters:
- thisOption string - Name of the dropdown option.
- needs - function(unit) returning true if that unit wants the spell (nil: anyone).
- able - function(unit) returning true if the spell can go on that unit now (nil: no check).
- opts - { self = false: leave yourself out; others = false: only yourself (a key not held); roles = { "TANK", ... }: group members in these roles first; dead = true: dead players to resurrect instead of living ones }. (optional)
Returns:
-
string|nil - Unit token, or nil when nobody qualifies.
Usage:
local thisUnit = units.castOn("Thorns", buff.thorns.refresh, cast.able.thorns, { roles = { "TANK" } })
- get (range)
-
Gets the "best" unit within a specified range in front or around the player.
Call once per profile rotation and use the variable it creates in units
IE: units.get(5,false) makes units.dyn5, units.get(8,true) makes units.dyn8AOE
Parameters:
- range number - Distance in yards to look for the "best" unit
- picking ()
-
True when BR may pick enemies other than your target right now (Targeting Mode isn't Off, and you're in
combat or "Targeting Only In Combat" is off): what units.get's picks follow
Returns:
-
boolean
- groupStable (seconds)
-
True when the group hasn't changed (members joining or leaving) for that many seconds
Parameters:
- seconds number
Returns:
-
boolean
- healAround (thisUnit, radius, health, count)
-
The group members within radius yards of a unit at or below health percent, lowest first, at
most count of them (each with .hp, .guid, .name, position)
Parameters:
- thisUnit string The centre
- radius number Yards
- health number Health percent
- count number The most members to return
Returns:
-
table
- lootable ()
-
The dead units the player can loot
Returns:
-
table
- lootCount ()
-
How many dead units are waiting to be looted
Returns:
-
number
- setTargetWeight (fn)
-
Sets the profile's own target weight for dynamic targeting: fn(unit) returns a number added to
the unit's score (higher = more priority), or nil to leave it. Cleared whenever the profile is built.
Parameters:
- fn function(unit) or nil
Usage:
-- Example: Feral druid prioritizing Rip refresh units.setTargetWeight(function(thisUnit) if debuff.rip.exists(thisUnit) and debuff.rip.remains(thisUnit) < 5 then return 80 -- High priority to refresh expiring Rip end end)