Module enemies
These functions return a table of enemies for the provided parameters.
Enemies functions are the profile API table `enemies` (br.api.profile.enemies); profiles use it by name.
After defining enemies you would place the below functions in the main profile loop to populate and update the enemy tables.
Once done you can use variables such as these examples, you can also get count of enemies but just added a `#` in front of the variable name:
* `enemies.yards8` - Returns all enemies around player in 8yrds, generated by function enemies.get(8)
* `enemies.yards8t` - Returns all enemies around target in 8yrds, generated by function enemies.get(8,"target")
* `enemies.yards8tnc` - Returns all units around target in 8yrds, generated by function enemies.get(8,"target",true)
* `enemies.yards8tncf` - Returns all units the target is facing in 8yrds, generated by function enemies.get(8,"target",true,true)
For enemies in a cone it is the same as above but you use the `c` tag instead of `t`. Ex function: enemies.cone.get(8, 90) (range, angle)
For enemies in a rectangle it is the same as above but you use the `r` tag instead of `t`. Ex function: enemies.rect.get(8, 5) (range, width)
Functions
| any (list, check) | True when any unit in a list passes a check. |
| enemies.cone.get (range, angle, checkNoCombat) | The enemies in the player's frontal cone, by the server's rule (see getEnemiesInCone) |
| count (list, check) | How many units in a list pass a check. |
| first (list, check) | The first unit in a list that passes a check, to cast on it; nil when none does. |
| get (range, unit, checkNoCombat, facing) | Returns a table of all enemies around unit for given range, combat situation, and facing |
| enemies.rect.get (range, width, checkNoCombat) | The enemies in the player's frontal rectangle (a line spell), by the server's rule (see getEnemiesInRect) |
Functions
- any (list, check)
-
True when any unit in a list passes a check. Instead of looping in the profile, write the
check once (a function of one unit) and pass it with the list.
Parameters:
- list table A list of units, such as enemies.yards10
- check function Returns true for a unit that counts, as check(thisUnit)
Returns:
-
boolean
Usage:
if enemies.any(enemies.yards10, function(thisUnit) return debuff.demoralizingRoar.refresh(thisUnit) end) then
- enemies.cone.get (range, angle, checkNoCombat)
-
The enemies in the player's frontal cone, by the server's rule (see getEnemiesInCone)
Parameters:
- range number How far the cone reaches, in yards
- angle number The cone's full angle, in degrees (the spell's ConeDegrees)
- checkNoCombat boolean Count units not in combat too
Returns:
-
table
The units, the same table as enemies.yards
c - number How many
- count (list, check)
-
How many units in a list pass a check.
Parameters:
- list table A list of units, such as enemies.yards8
- check function Returns true for a unit that counts, as check(thisUnit)
Returns:
-
number
Usage:
if enemies.count(enemies.yards8, function(thisUnit) return unit.ttd(thisUnit) > 10 end) >= 3 then
- first (list, check)
-
The first unit in a list that passes a check, to cast on it; nil when none does.
Parameters:
- list table A list of units, such as enemies.yards5
- check function Returns true for a unit that counts, as check(thisUnit)
Returns:
-
The unit, or nil
Usage:
local thisUnit = enemies.first(enemies.yards5, needsLacerate) if thisUnit and cast.able.lacerate(thisUnit) then cast.lacerate(thisUnit) end
- get (range, unit, checkNoCombat, facing)
-
Returns a table of all enemies around unit for given range, combat situation, and facing
Parameters:
- range number The range to check for enemies
- unit string The unit to check for enemies around
- checkNoCombat boolean Check for enemies even if not in combat
- facing boolean Check if enemies are facing unit
Returns:
- table
- number How many
- enemies.rect.get (range, width, checkNoCombat)
-
The enemies in the player's frontal rectangle (a line spell), by the server's rule (see
getEnemiesInRect)
Parameters:
- range number How far the rectangle reaches, in yards
- width number Its full width, in yards (the spell's Width)
- checkNoCombat boolean Count units not in combat too
Returns:
-
table
The units, the same table as enemies.yards
r - number How many