HostilesPresent

Check if hostile forces are present in area

Usage: Used in 7 task(s)

Lua Implementation

-- Hostiles Present
function evaluate(params)
    local searchRadius = params.search_radius or 500
    local myLoc = this:getLocation3D()
    local contacts = this:getContactList()

    for _, contact in ipairs(contacts) do
        if contact:isValid() and IsHostile{target = contact} then
            local distance = spatialUtil.distance(myLoc, contact:getLocation3D())
            if distance <= searchRadius then
                return true
            end
        end
    end

    return false
end