TargetInEnvelope

Check if target is in weapon engagement envelope

Usage: Used in 9 task(s)

Lua Implementation

-- Target In Envelope
function evaluate(params)
    local target = params.target
    local weaponSystem = this:getSystem(params.weapon_system)

    if not target or not target:isValid() or not weaponSystem then
        return false
    end

    local distance = spatialUtil.distance(this:getLocation3D(), target:getLocation3D())
    local minRange = weaponSystem:getMinRange()
    local maxRange = weaponSystem:getMaxRange()

    return distance >= minRange and distance <= maxRange
end