Skip to content

enemies

The enemies function retrieves a list of enemy units within a specified distance from the player. This function is useful for identifying and targeting enemies in the vicinity of the player.

Parameters

  • distance (number, optional): The maximum distance within which to search for enemy units. Defaults to 40 if not specified.

Returns

  • units (table): A table containing the identifiers of the enemy units found within the specified distance.

Example Usage in Lua

Here is an example of how to use the enemies function in Lua:

local api = ...

-- Function to print the list of enemy units within a specified distance from the player
function PrintEnemies(distance)
    local enemies = api.enemies(distance)
    print("Enemies within distance " .. distance .. ":")
    for _, enemy in ipairs(enemies) do
        print(enemy)
    end
end

-- Example usage: Print the list of enemy units within a distance of 40 from the player
PrintEnemies(40)