Advertisement
mikeyy

Flag Lock InstantStatusFunction

Jul 25th, 2011
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1.     InstantStatusFunction = function(unit, action)
  2.         local aiBrain = unit:GetAIBrain()
  3.  
  4.         local flags = aiBrain:GetUnitsAroundPoint( categories.FLAG, unit.Position, 32, 'Ally' )
  5.         if table.empty(flags) then
  6.             return false
  7.         else
  8.             --Mithy: Check for existing locks
  9.             local numflags, numlocked = table.getn(flags), 0
  10.             for k, v in flags do
  11.                 if not v.CanBeCaptured or v.BeingLocked then
  12.                     numlocked = numlocked + 1
  13.                 end
  14.             end
  15.             if numlocked == numflags then
  16.                 return false
  17.             end
  18.         end
  19.  
  20.         if aiBrain:GetThreatAtPosition(flags[1].Position, 1, 'Hero', 'Enemy' ) <= 0 then
  21.             return false
  22.         end
  23.  
  24.         return AIAbility.DefaultStatusFunction(unit, action)
  25.     end,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement