Advertisement
Guest User

tr

a guest
Nov 23rd, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.26 KB | None | 0 0
  1. local function func()
  2.     local com                   = require("component")
  3.     local event                 = require("event")
  4.     local gpu                   = com.gpu
  5.     local turret                = com.os_energyturret
  6.     local radar                 = com.openperipheral_sensor
  7.     local autors                = {"qwertyMAN"}
  8.     local version               = "0.9.1"
  9.  
  10.     -- Настройки
  11.     local firePleayers          = true
  12.     local fireMobs              = true
  13.     local Black_Player_List     = {}
  14.     local White_Player_List     = {"GanGsSstA"; "Tequila1337"; "ideeted"}
  15.     -- относительные координаты пушки от сканера
  16.     local correct = {
  17.         x = 0,
  18.         y = 1,
  19.         z = -1
  20.     }
  21.  
  22.     local function pointer(x,y,z)
  23.         local distXY = math.sqrt(x^2+z^2)
  24.         local distDY = math.sqrt(y^2+distXY^2)
  25.         local outX = math.deg(math.acos(x/distXY))+90
  26.         local outY = 90-math.deg(math.acos(y/distDY))
  27.         if z<0 then
  28.             outX = (180-outX)%360
  29.         end
  30.         return outX,outY
  31.     end    
  32.                    
  33.     while true do
  34.         os.sleep(0)
  35.         local target = false
  36.         local fire = true
  37.         local scan=radar.getPlayers()
  38.         if firePleayers and #scan>0 then
  39.             if #White_Player_List>0 then
  40.                 for i=1, #autors do
  41.                     White_Player_List[#White_Player_List+1] = autors[i]
  42.                 end
  43.                 for i=1, #scan do
  44.                     local swich = true
  45.                     for j=1, #White_Player_List do
  46.                         if scan[i].name==White_Player_List[j] or not scan[i].name then
  47.                             swich = false
  48.                         end
  49.                     end
  50.                     if swich then
  51.                         target = scan[i].name
  52.                         break
  53.                     end
  54.                 end
  55.             elseif #Black_Player_List>0 then
  56.                 for i=#Black_Player_List, 1, -1 do
  57.                     for j=1, #autors do
  58.                         if Black_Player_List[i] == autors[j] then
  59.                             table.remove(Black_Player_List,i)
  60.                         end
  61.                     end
  62.                 end
  63.                 for i=1, #scan do
  64.                     local swich = false
  65.                     for j=1, #Black_Player_List do
  66.                         if scan[i].name==Black_Player_List[j] then
  67.                             swich = true
  68.                         end
  69.                     end
  70.                     if swich then
  71.                         target = scan[i].name
  72.                         break
  73.                     end
  74.                 end
  75.             else
  76.                 if #autors>0 then
  77.                     for i=1, #autors do
  78.                         White_Player_List[#White_Player_List+1] = autors[i]
  79.                     end
  80.                 else
  81.                     target = scan[1].name
  82.                 end
  83.             end
  84.             if target and radar.getPlayerByName(target) then
  85.                 target=radar.getPlayerByName(target).all()
  86.                 local x,y,z = target.position.x-0.5-correct.x, target.position.y+0.3-correct.y, target.position.z-0.5-correct.z
  87.                 local vx,vy = pointer(x,y,z)
  88.                 turret.moveTo(vx,vy)
  89.                 if turret.isOnTarget() then
  90.                     turret.fire()
  91.                 end
  92.                 fire = false
  93.             end
  94.         end
  95.         target = false
  96.         if fireMobs and fire then
  97.             local scan=radar.getMobIds()
  98.             if #scan>0 then
  99.                 for i=1, #scan do
  100.                     local mob
  101.                     if radar.getMobData(scan[i]).basic() then
  102.                         mob = radar.getMobData(scan[i]).basic()
  103.                         target = mob
  104.                     end
  105.                 end
  106.                 if target then
  107.                     local x,y,z = target.position.x-0.5-correct.x, target.position.y-0.5-correct.y, target.position.z-0.5-correct.z
  108.                     local vx,vy = pointer(x,y,z)
  109.                     turret.moveTo(vx,vy)
  110.                     if turret.isOnTarget() then
  111.                         turret.fire()
  112.                     end
  113.                 end
  114.             end
  115.         end
  116.     end
  117. end
  118. -- мегакостыль
  119. while true do
  120.     local oop = pcall(func)
  121.     print(oop)
  122. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement