Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[Skynet Nuclear ABM Defense Program BY: Andrew2060]]--
- --[[ABM Server, use with http://pastebin.com/aNsduCem]]--
- --[[Settings]]--
- local waitDelay = 2
- local countersPerMissile = 1
- local missileDelay = 3
- --[[Initialization]]--
- local silos, curSilo = {}, 1
- local retalSilos = {}
- peripheral.find("modem", rednet.open)
- term.setBackgroundColor(colors.blue)
- --Set your base coordinates here to determine distance
- local homeX = 578
- local homeY = 56
- local homeZ = -494
- local function red()
- term.setBackgroundColor(colors.red)
- print(" ")
- term.setBackgroundColor(colors.blue)
- end
- rednet.broadcast("ABM1")
- rednet.broadcast("Retaliate")
- repeat
- local id, msg = rednet.receive(waitDelay)
- if msg == "ABM" then table.insert(silos, id)
- elseif msg == "RetaliationCheck" then table.insert(retalSilos, id) end
- until not id
- --[[Main Programs]]--
- while true do
- if not redstone.getInput("back") then
- term.clear()
- term.setCursorPos(1, 1)
- red()
- print(" SKYNET DEFENSE SYSTEMS ACTIVATED ")
- red()
- print(" ANTI-BALLISTIC MISSILE SHIELD ONLINE ")
- red()
- red()
- print(" [STANDBY ABM Silos] ")
- for k, v in ipairs(silos) do print(" silo #" .. k .. " id = "..v) end
- red()
- repeat os.pullEvent("redstone") until redstone.getInput("back")
- end
- term.clear()
- term.setCursorPos(1, 1)
- term.setTextColor(colors.red)
- print("Incoming Missiles:")
- print("Firing CounterMeasures\n")
- maptab = peripheral.call("back","getEntities")
- maptxt = textutils.serialize(maptab)
- if maptxt ~= "{}" then
- allDat = 0
- for num in pairs(maptab) do
- allDat = allDat+1
- end
- targets = allDat/3
- for i=0,targets-1 do
- local msg = {["x"] = math.floor(maptab["x_"..i]), ["y"] = math.floor(maptab["y_"..i]), ["z"] = math.floor(maptab["z_"..i])}
- local x2 = math.floor(tonumber(maptab["x_"..i])/1)
- local y2 = math.floor(tonumber(maptab["y_"..i])/1)
- local z2 = math.floor(tonumber(maptab["z_"..i])/1)
- local msg2 = {x2, y2, z2}
- local distance = math.sqrt((x2-homeX)^2 + (y2-homeY)^2 + (z2-homeZ)^2)
- print("Incoming Missile")
- print(" X:" .. msg.x .. " Y:" .. msg.y .. " Z:" .. msg.z.. " Distance: "..distance)
- print("Launching " .. countersPerMissile .. " ABM Missile CounterMeasures...\n")
- term.setBackgroundColor(colors.blue)
- if distance < 1000 then
- for i = 1, countersPerMissile do
- rednet.send(silos[curSilo], msg)
- rednet.send(retalSilos, msg2)
- curSilo = (curSilo == #silos) and 1 or (curSilo + 1)
- sleep(0)
- sleep(missileDelay)
- end
- sleep(0)
- end
- sleep(0)
- end
- sleep(1)
- end
- rednet.send(5, msg2)
- sleep(1)
- end
Add Comment
Please, Sign In to add comment