So, I played with it, and got it to work by wrapping your "return true" condition with a condition to check for range.
I didn't touch the untrigger function as it seemed to work without touching it. Maybe you want to, I don't know.
Do take note, that the IsSpellInRange() is currently checking for the hunter's interrupt Muzzle, you'll have to change that to whatever.
Code:
function ()
if not UnitExists("target") or not UnitIsEnemy("player", "target") then return false end
local name, _, _, _, _, endTime, _, _, noInterrupt = UnitCastingInfo("target")
local start, duration = GetSpellCooldown(57994)
if IsSpellInRange("Muzzle", "target") == 1 then
if name and not noInterrupt and ( start == 0 or start + duration < endTime / 1000 ) then
return true
end
name, _, _, _, _, endTime, _, noInterrupt = UnitChannelInfo("target")
if name and not noInterrupt and ( start == 0 or start + duration < endTime / 1000 ) then
return true
end
end
return false
end