InstantStatusFunction = function(unit, action)
local aiBrain = unit:GetAIBrain()
local flags = aiBrain:GetUnitsAroundPoint( categories.FLAG, unit.Position, 32, 'Ally' )
if table.empty(flags) then
return false
else
--Mithy: Check for existing locks
local numflags, numlocked = table.getn(flags), 0
for k, v in flags do
if not v.CanBeCaptured or v.BeingLocked then
numlocked = numlocked + 1
end
end
if numlocked == numflags then
return false
end
end
if aiBrain:GetThreatAtPosition(flags[1].Position, 1, 'Hero', 'Enemy' ) <= 0 then
return false
end
return AIAbility.DefaultStatusFunction(unit, action)
end,