ClearToEngage

Check if clear to engage (no friendlies in area)

Usage: Used in 17 task(s)

Lua Implementation

-- Clear To Engage
function evaluate(params)
    local target = params.target
    local safetyRadius = params.safety_radius or 100

    if not target then
        return false
    end

    -- Check for friendlies near target
    local contacts = this:getContactList()
    for _, contact in ipairs(contacts) do
        if contact:isValid() and contact:getForceType() == this:getForceType() then
            local distance = spatialUtil.distance(
                contact:getLocation3D(),
                target:getLocation3D()
            )
            if distance < safetyRadius then
                return false
            end
        end
    end

    return true
end