ecco7777

CC Plethora Stuff

Jun 19th, 2021 (edited)
839
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.12 KB | None | 0 0
  1. mode="shoot"
  2. ni=peripheral.wrap("back")
  3.  
  4. function getAngle(x,y)
  5.     return (180/math.pi)*math.atan(y,x)
  6. end
  7.  
  8. function getDistance(block)
  9.     vec=vector.new(block.x,block.y,block.z)
  10.     return vec.length(vec)
  11. end
  12.  
  13. function swing()
  14.     while true do
  15.         ni.swing()
  16.     end
  17. end
  18.  
  19. function use()
  20.     while true do
  21.         ni.use()
  22.     end
  23. end
  24.  
  25. function moveTo(x,y,z,power)
  26.     pitch = -math.atan2(y, math.sqrt(x * x + z * z))
  27.     yaw = math.atan2(-x, z)
  28.     ni.launch(math.deg(yaw),math.deg(pitch),power)
  29. end
  30.  
  31. function moveToBlock(filter,meta)
  32.     while true do
  33.         blocks={}
  34.         ni.canvas3d().clear()
  35.         c3d=ni.canvas3d().create()
  36.         --c3d.recenter()
  37.         for _, block in pairs(ni.scan()) do
  38.             if string.find(block.name,filter) and block.metadata==meta then
  39.                 table.insert(blocks,block)
  40.             end
  41.  
  42.         end
  43.         table.sort(blocks,function(a,b) return getDistance(a)<getDistance(b) end)
  44.         if #blocks>0 then
  45.             block=blocks[1]
  46.             msg=(("The block at %d, %d, %d is %s"):format(block.x, block.y, block.z, block.name))
  47.             ni.tell(msg)
  48.             pitch = -math.atan2(block.y, math.sqrt(block.x * block.x + block.z * block.z))
  49.             yaw = math.atan2(-block.x, block.z)
  50.             ni.fire(math.deg(yaw),math.deg(pitch),5)
  51.             c3d.addLine({x=0,y=0,z=0},{block.x, block.y, block.z})
  52.             --moveTo(block.x,block.y,block.z)
  53.             print(msg)
  54.         end
  55.         sleep(0.5)
  56.     end
  57. end
  58.  
  59. function follow(mobFilter)
  60.     while true do
  61.         mobs=ni.sense()
  62.         mobs=filterArray(mobs,mobFilter)
  63.         table.sort(mobs,function(a,b) return getDistance(a)<getDistance(b) end)
  64.         if #mobs>1 then
  65.             mob=mobs[2]
  66.             if getDistance(mob)<16 and getDistance(mob)>2 then
  67.                 msg=(("The mob at %d, %d, %d is %s"):format(mob.x, mob.y, mob.z, mob.name))
  68.                 pitch = -math.atan2(mob.y, math.sqrt(mob.x * mob.x + mob.z * mob.z))
  69.                 yaw = math.atan2(-mob.x, mob.z)
  70.                 ni.look(math.deg(yaw),math.deg(pitch))
  71.                 moveTo(mob.x,mob.y,mob.z,0.5)
  72.                 print(msg)
  73.             end
  74.         end
  75.         sleep(0.1)
  76.     end
  77. end
  78.  
  79. function followSwing(mobfilter)
  80.     while true do
  81.         mobs=ni.sense()
  82.         mobs=filterArray(mobs,mobFilter)
  83.         table.sort(mobs,function(a,b) return getDistance(a)<getDistance(b) end)
  84.         if #mobs>1 then
  85.             mob=mobs[2]
  86.             if getDistance(mob)<2 and getDistance(mob)>1 then
  87.                 msg=(("The mob at %d, %d, %d is %s"):format(mob.x, mob.y, mob.z, mob.name))
  88.                 pitch = -math.atan2(mob.y, math.sqrt(mob.x * mob.x + mob.z * mob.z))
  89.                 yaw = math.atan2(-mob.x, mob.z)
  90.                 ni.look(math.deg(yaw),math.deg(pitch))
  91.                 moveTo(mob.x,mob.y,mob.z,0.5)
  92.                 print(msg)
  93.             else
  94.                 for is=1,10 do
  95.                     ni.swing()
  96.                 end
  97.             end
  98.         end
  99.         sleep(0.1)
  100.     end
  101. end
  102.  
  103. function filterArray(iArray,iFilter)
  104.     oArray={}
  105.     for iA=1, #iArray do
  106.         if string.find(iFilter,iArray[iA].name)==nil then
  107.             table.insert(oArray,iArray[iA])
  108.         end
  109.     end
  110.     return oArray
  111. end
  112.  
  113. mobFilter="ecco7777ItemAlphaCyclesplethora:laserxp_orb_bigxp_orb_smallspiritArrow"
  114. function autoKill(filter)
  115.     while true do
  116.         mobs=ni.sense()
  117.         ni.canvas3d().clear()
  118.         c3d=ni.canvas3d().create()
  119.         --c3d.recenter()
  120.         mobs=filterArray(mobs,mobFilter)
  121.         table.sort(mobs,function(a,b) return getDistance(a)<getDistance(b) end)
  122.         if #mobs>0 then
  123.             mob=mobs[1]
  124.             msg=(("The mob at %d, %d, %d is %s"):format(mob.x, mob.y, mob.z, mob.name))
  125.             ni.tell(msg)
  126.             pitch = -math.atan2(mob.y, math.sqrt(mob.x * mob.x + mob.z * mob.z))
  127.             yaw = math.atan2(-mob.x, mob.z)
  128.             ni.fire(math.deg(yaw),math.deg(pitch),5)
  129.             c3d.addLine({x=0,y=0,z=0},{mob.x, mob.y, mob.z})
  130.             --moveTo(mob.x,mob.y,mob.z)
  131.             print(msg)
  132.         end
  133.         sleep(0.1)
  134.     end
  135. end
  136.  
  137. function autoSwing(filter)
  138.     while true do
  139.         mobs=ni.sense()
  140.         ni.canvas3d().clear()
  141.         c3d=ni.canvas3d().create()
  142.         --c3d.recenter()
  143.         mobs=filterArray(mobs,mobFilter)
  144.         table.sort(mobs,function(a,b) return getDistance(a)<getDistance(b) end)
  145.         if #mobs>1 then
  146.             mob=mobs[1]
  147.             if getDistance(mob)<4 then
  148.                 msg=(("The mob at %d, %d, %d is %s"):format(mob.x, mob.y, mob.z, mob.name))
  149.                 ni.tell(msg)
  150.                 pitch = -math.atan2(mob.y, math.sqrt(mob.x * mob.x + mob.z * mob.z))
  151.                 yaw = math.atan2(-mob.x, mob.z)
  152.                 ni.look(math.deg(yaw),math.deg(pitch))
  153.                 ni.swing()
  154.                 c3d.addLine({x=0,y=0,z=0},{mob.x, mob.y, mob.z})
  155.                 --moveTo(mob.x,mob.y,mob.z)
  156.                 print(msg)
  157.             end
  158.         end
  159.         sleep(0.1)
  160.     end
  161. end
  162.  
  163. function fire()
  164. while true do
  165.     meta=ni.getMetaOwner()
  166.     ni.fire(meta.yaw,meta.pitch,4)
  167. end
  168. end
  169.  
  170. function split (inputstr, sep)
  171.     if sep == nil then
  172.             sep = "%s"
  173.     end
  174.     local t={}
  175.     for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  176.             table.insert(t, str)
  177.     end
  178.     return t
  179. end
  180.  
  181. function loadFile(filename)
  182.     fp=fs.open(filename,"r")
  183.     lines={}
  184.     i=1
  185.     lines[i]=fp.readLine()
  186.     while lines[i]~=nil do
  187.         i=i+1
  188.         lines[i]=fp.readLine()
  189.     end
  190.     return lines
  191. end
  192.  
  193. function compileObj(lines)
  194. v = {}
  195. vt = {}
  196. vn = {}
  197. f = {}
  198. l = {}
  199. print(#lines)
  200.     for i=5, #lines do
  201.         if string.sub(lines[i],1,2)=="v " then
  202.             table.insert(v,split(lines[i]))
  203.         end
  204.         if string.sub(lines[i],1,2)=="vt" then
  205.             table.insert(vt,split(lines[i]))
  206.         end
  207.         if string.sub(lines[i],1,2)=="vn" then
  208.             table.insert(vn,split(lines[i]))
  209.         end
  210.         if string.sub(lines[i],1,2)=="f " then
  211.             table.insert(f,split(lines[i]))
  212.         end
  213.         if string.sub(lines[i],1,2)=="l " then
  214.             table.insert(l,split(lines[i]))
  215.         end
  216.     end
  217. end
  218.  
  219. function showModel()
  220.     compileObj(loadFile("model"))
  221.     br=10
  222.     line=1
  223.     ni.canvas3d().clear()
  224.     c3d=ni.canvas3d().create()
  225.         for mi=1, 5000 do
  226.             i=math.random(1,#v)
  227.             i2=math.random(1,#v)
  228.             c3d.addLine({x=v[i][2]*br,y=v[i][3]*br,z=v[i][4]*br},{x=v[i][2]*br,y=v[i][3]*br+0.1,z=v[i][4]*br})
  229.         end
  230. end
  231.  
  232. function displayImage()
  233.     l=2
  234.     br=1
  235.     xOff=0
  236.     yOff=0
  237.     --shell.run(file)
  238.     os.loadAPI("bild")
  239.     color=bild.color
  240.     ni.canvas().clear()
  241.     cvs=ni.canvas()
  242.     --fp=fs.open(file,"r")
  243.     xMax=#color
  244.     yMax=#color[1]
  245.     for y=1,xMax do
  246.         for x=1,yMax do
  247.             pixel=cvs.addRectangle(y*l+xOff,xMax*l-x*l+yOff,l,l)
  248.             pixel.setColor(color[x][y])
  249.             pixel.setAlpha(br*0xff)
  250.         end
  251.     end
  252. end
  253.  
  254. function debug()
  255.     autoSwing(mobFilter)
  256. end
  257.  
  258. function keyevent()
  259.     while true do
  260.         e,val=os.pullEvent()
  261.         if e=="key" then
  262.             if val==57 then
  263.                 debug()
  264.             end
  265.         end
  266.     end
  267. end
  268.  
  269. function main()
  270.     if mode=="" then
  271.        
  272.     end
  273.     if mode=="followSwing" then
  274.         mobFilter="ItemAlphaCyclesplethora:laserxp_orb_bigxp_orb_smallspiritArrowThrownPotionbotania:magicMissilebotania:magicLandmine"
  275.         followSwing(mobFilter)
  276.     end
  277.     if mode=="model" then
  278.         showModel()
  279.     end
  280.     if mode=="laserkill" then
  281.         autokill()
  282.     end
  283.     if mode=="shoot" then
  284.         fire()
  285.     end
  286.     if mode=="autoSwing" then
  287.         mobFilter="ecco7777ItemAlphaCyclesplethora:laserxp_orb_bigxp_orb_smallspiritArrowThrownPotionbotania:magicMissilebotania:magicLandmine"
  288.         autoSwing(mobFilter)
  289.     end
  290.     if mode=="follow" then
  291.         filter="ItemAlphaCyclesplethora:laserxp_orb_bigxp_orb_smallspiritArrowThrownPotionbotania:magicMissilebotania:magicLandmine"
  292.         follow(filter)
  293.     end
  294.  
  295. end
  296.  
  297. main()
Add Comment
Please, Sign In to add comment