Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.05 KB | None | 0 0
  1. local myTeamID = Spring.GetMyAllyTeamID()
  2. function widget:GameFrame(frameNum)
  3.     if frameNum%30==0 then --once in a second
  4.     local allUnits = Spring.GetAllUnits()
  5.     local ravens = {}
  6.     local hacksaws = {}
  7.         for i=1, #allUnits do
  8.         local unitID = allUnits[i]
  9.         unitDefID = Spring.GetUnitDefID(unitID)
  10.             if unitDefID == 80 and (Spring.GetUnitAllyTeam(unitID)~=myTeamID) then
  11.                 table.insert(ravens,unitID)
  12.             elseif unitDefID == 332 and (Spring.GetUnitAllyTeam(unitID)==myTeamID) then
  13.                 table.insert(hacksaws, unitID)
  14.             end
  15.         end
  16.         for i=1, #ravens do
  17.         local unitID1 = ravens[i]
  18.         local x,y,z = Spring.GetUnitPosition(unitID1)
  19.         --Spring.MarkerAddPoint(x,y,z, "enemy bomber")
  20.         end
  21.         for i=1, #hacksaws do
  22.         local unitID2 = hacksaws[i]
  23.         local x,y,z = Spring.GetUnitPosition(unitID2)
  24.         --Spring.MarkerAddPoint(x,y,z, "my hacksaws")
  25.         end
  26.         for i=1, #ravens do
  27.         --Spring.GiveOrderToUnit(hacksaws[i%#hacksaws + 1], CMD.INSERT,  {-1,CMD.ATTACK,CMD.OPT_SHIFT,ravens[i]}, {})
  28.         Spring.SetUnitTarget(hacksaws[i%#hacksaws + 1], ravens[i])
  29.         end
  30.     end
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement