Want more features on Pastebin? Sign Up, it's FREE!
Guest

Flag Lock InstantStatusFunction

By: mikeyy on Jul 25th, 2011  |  syntax: Lua  |  size: 0.85 KB  |  views: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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,
clone this paste RAW Paste Data