Skip to content

is_melee

The is_melee function checks if a specified unit is within melee range of the player. This function is useful for determining whether a unit is close enough to be attacked with melee abilities.

Parameters

  • unit (string, optional): The unit identifier (such as "target", "focus", etc.) to check. Defaults to "target" if not specified.

Returns

  • is_in_melee_range (boolean): Returns true if the unit is within melee range of the player, otherwise returns false.

Example Usage in Lua

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

local api = ...

-- Function to check if a unit is within melee range and print the result
function CheckMeleeRange(unit)
    local is_in_melee_range = api.is_melee(unit)
    if is_in_melee_range then
        print("The unit '" .. unit .. "' is within melee range of the player.")
    else
        print("The unit '" .. unit .. "' is not within melee range of the player.")
    end
end

-- Example usage: Check if the target is within melee range of the player
CheckMeleeRange("target")