Advertisement
Guest User

Untitled

a guest
Feb 28th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.35 KB | None | 0 0
  1. function widget:GetInfo()
  2.     return {
  3.         name      = "DecloackArea v1.0",
  4.         desc      = "Display deacloack area around cloacked units",
  5.         author    = "banana_Ai",
  6.         date      = "28 Feb 2016",
  7.         license   = "GNU GPL v2",
  8.         layer     = 0,
  9.         enabled   = true,  --  loaded by default?
  10.     }
  11. end
  12.  
  13. local Chili
  14. options_path = 'Settings/Interface/Decloak Ranges'
  15. options={
  16.     onlyforcloacked={
  17.         name = 'Draw for only cloacked units',
  18.         type = 'bool',
  19.         value = false,
  20.     },
  21.     onlyforselected={
  22.         name = 'Draw for only selected units',
  23.         type = 'bool',
  24.         value = false,
  25.     }
  26. }
  27.  
  28. options_order = {
  29.     'onlyforcloacked',
  30.     'onlyforselected'
  31. }
  32.  
  33. local localTeamID=Spring.GetLocalTeamID()
  34.  
  35. local function DrawDecloackArea(unitID,def)
  36.     local r=def.decloakDistance
  37.     local x,_,z=Spring.GetUnitPosition(unitID)
  38.     gl.Color(0,1,0,0.2)
  39.     gl.Utilities.DrawGroundCircle(x,z,r)
  40. end
  41.  
  42. function widget:DrawWorldPreUnit()
  43.     local units
  44.     if options.onlyforselected.value then
  45.         units=Spring.GetSelectedUnits()
  46.     else
  47.         units=Spring.GetTeamUnits(localTeamID)
  48.     end
  49.    
  50.     for _,unitID in ipairs(units) do
  51.         local defID=Spring.GetUnitDefID(unitID)
  52.         local def=UnitDefs[defID]
  53.        
  54.         if Spring.GetUnitIsCloaked(unitID) or
  55.                 (def.canCloak and not options.onlyforcloacked.value) then
  56.             DrawDecloackArea(unitID,def)
  57.         end
  58.     end
  59. end
  60.  
  61. VFS.Include("LuaRules/Utilities/glVolumes.lua")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement