SHOW:
|
|
- or go back to the newest paste.
| 1 | local component = require("component")
| |
| 2 | local event = require("event")
| |
| 3 | local serialization= require("serialization")
| |
| 4 | local computer= require("computer")
| |
| 5 | local thread= require("thread")
| |
| 6 | - | local term= require("term")
|
| 6 | + | |
| 7 | local Tn = component.navigation | |
| 8 | - | --local Tn = component.navigation |
| 8 | + | local Tr = component.radar |
| 9 | - | --local Tr = component.radar |
| 9 | + | |
| 10 | local SoldiersChannel = 2413 | |
| 11 | - | local QueensResponseChannel = 2402 |
| 11 | + | |
| 12 | - | local PawnsChannel = 2413 |
| 12 | + | |
| 13 | - | local PawnsResponseChannel = 2403 |
| 13 | + | |
| 14 | --local q_firmware = require("queen_firmware")
| |
| 15 | - | local drone_is_queen = true |
| 15 | + | --local flightform = require("flight_formation")
|
| 16 | ||
| 17 | modem.open(QueensChannel) | |
| 18 | ||
| 19 | - | local q_firmware = require("queen_firmware")
|
| 19 | + | --q_firmware.broadcastFirmWare(QueensChannel) |
| 20 | - | local flightform = require("flight_formation")
|
| 20 | + | function Q_FIRMWARE() |
| 21 | - | local radar_targeting = require("radar_targeting")
|
| 21 | + | modem.broadcast(QueensChannel, |
| 22 | - | local GPS = require("GPS")
|
| 22 | + | [[ |
| 23 | - | local GPS_TRG = require("GPS_TRG")
|
| 23 | + | Qr= component.proxy(component.list('radar')())
|
| 24 | - | local p_firmware = require("pawn_firmware")
|
| 24 | + | Qn= component.proxy(component.list('navigation')())
|
| 25 | - | local formation_generator = require("formation_generator")
|
| 25 | + | Qd= component.proxy(component.list('drone')())
|
| 26 | Qm= component.proxy(component.list('modem')())
| |
| 27 | - | modem.open(QueensResponseChannel) |
| 27 | + | QueensChannel = 2412 |
| 28 | - | modem.open(PawnsResponseChannel) |
| 28 | + | Qm.open(QueensChannel) |
| 29 | ]] | |
| 30 | ) | |
| 31 | ||
| 32 | modem.broadcast(QueensChannel, | |
| 33 | [[ | |
| 34 | - | --form1 = {{13,2,-2},{-13,2,-2},{0,2,13}} --bad y gps value
|
| 34 | + | function sleep(timeout) |
| 35 | - | --form1 = {{3,8,-2},{-3,14,-2},{0,20,3}} -- bad xz gps values
|
| 35 | + | checkArg(1, timeout, 'number', 'nil') |
| 36 | - | --form1 = {{10,8,-10},{-10,14,0},{5,20,10}}
|
| 36 | + | local deadline = computer.uptime() + (timeout or 0) |
| 37 | - | --form1 = {{0,0,0},{5,5,0},{0,10,10},{-15,15,0},{0,20,-20}}
|
| 37 | + | repeat |
| 38 | - | --form1 = {{0,0,0},{2,2,0},{0,4,4},{-8,8,0},{0,10,-10},{12,12,0},{0,14,14},{-16,16,0}}--golden ratio Spiral
|
| 38 | + | computer.pullSignal(deadline - computer.uptime()) |
| 39 | - | actualSatForm = {{0,25,-3},{0,25,3},{3,22,0},{-3,22,0}}-- ComputerCraft Heresy --(Tetrahedron) -- it's actually good for xz coordinates
|
| 39 | + | until computer.uptime() >= deadline |
| 40 | - | --satff={}
|
| 40 | + | |
| 41 | - | --compensatedSatForm = {{0,25,-2},{0,25,3},{2,22,0},{-3,22,0}}
|
| 41 | + | |
| 42 | - | --form1 = {{0,35,-3},{0,30,3},{3,20,0},{-3,25,0}}
|
| 42 | + | ) |
| 43 | - | --form1 = {{0,35,-5},{0,30,2},{5,20,0},{-2,25,0}}
|
| 43 | + | |
| 44 | - | --form2 = {{-2,10,2},{2,15,2},{0,2,0}}
|
| 44 | + | modem.broadcast(QueensChannel, |
| 45 | - | --form3 = {{-2,20,-2},{2,25,-2}}
|
| 45 | + | [[ |
| 46 | - | --form2 = {{-10,10,10},{10,12,10},{0,5,0}}
|
| 46 | + | function getPlayerCoord(e_name) |
| 47 | - | --form3 = {{-10,14,-10},{10,16,-10}}
|
| 47 | + | checkArg(1,e_name,'string','nil') |
| 48 | - | form2 = {{3,0,0},{0,3,0},{0,0,3},{3,0,3},{-3,0,-3}}
|
| 48 | + | for k,v in ipairs(Qr.getPlayers()) do |
| 49 | - | form3 = {{-3,0,0},{0,-3,0},{0,0,-3},{3,3,3},{-3,-3,-3}}
|
| 49 | + | if v.name == e_name then |
| 50 | return {v.x,v.y,v.z},v.distance
| |
| 51 | - | --*************-- |
| 51 | + | end |
| 52 | - | --[[ |
| 52 | + | |
| 53 | - | The radar has an inaccuracy where it recognises two blocks as zeroes in each axis. |
| 53 | + | return {0,0,0},0
|
| 54 | - | Drones positioned in coordinates with positive axis components around a target player are actually a block extra away from the origin |
| 54 | + | |
| 55 | - | the given formation array is thus compensated in the formUP function from the flight_formation library |
| 55 | + | |
| 56 | ) | |
| 57 | - | --*************-- |
| 57 | + | modem.broadcast(QueensChannel, |
| 58 | [[ | |
| 59 | - | fbook={actualSatForm,form2,form3}
|
| 59 | + | function move(x,y,z) |
| 60 | checkArg(1,x,'number','nil') | |
| 61 | checkArg(1,y,'number','nil') | |
| 62 | checkArg(1,z,'number','nil') | |
| 63 | - | print("Bingus30")
|
| 63 | + | if x and y and z then |
| 64 | - | function printSwarmStats() |
| 64 | + | Qd.setLightColor(0x00FFAF) |
| 65 | - | term.clear() |
| 65 | + | Qd.move(x,y,z) |
| 66 | - | print("QUEENS:")
|
| 66 | + | |
| 67 | - | flightform.printDronePool(drone_is_queen) |
| 67 | + | |
| 68 | - | flightform.printFFAssignment(ffbook) |
| 68 | + | |
| 69 | ) | |
| 70 | modem.broadcast(QueensChannel, | |
| 71 | [[ | |
| 72 | function sub_vec(A,B) return {A[1]-B[1],A[2]-B[2],A[3]-B[3]} end
| |
| 73 | - | --local trgChannel = 3 |
| 73 | + | function math.trunc(v) |
| 74 | local t = math.modf(v) | |
| 75 | return t | |
| 76 | - | --trgPortBook = {}--{[trgport]="target"} multiple to fixed single relationship
|
| 76 | + | |
| 77 | - | trgPortBook = {[3]="Bingus",[4]="Floppa",[5]="FloppaMi",[7]="FloppaNi"}
|
| 77 | + | function vec_trunc(A) |
| 78 | if A then | |
| 79 | - | Pawnffbook = {}
|
| 79 | + | return {math.trunc(A[1]),math.trunc(A[2]),math.trunc(A[3])}
|
| 80 | - | Pawnffbook[1] = {}
|
| 80 | + | |
| 81 | - | Pawnffbook[2] = {}
|
| 81 | + | return nil |
| 82 | - | Pawnffbook[3] = {}
|
| 82 | + | |
| 83 | - | Pawnffbook[4] = {}
|
| 83 | + | function navMoveToPlayer(e_name) |
| 84 | - | Pawnffbook[5] = {}
|
| 84 | + | checkArg(1,e_name,"string","nil") |
| 85 | - | Pawnffbook[6] = {}
|
| 85 | + | local trgPos = {Qn.getPosition()},stp
|
| 86 | - | dynamicTriangle = {{3,2,-2},{-3,2,-2},{0,2,3}}
|
| 86 | + | |
| 87 | - | --staticTriangle = {{3,2,-2},{-3,2,-2},{0,2,3}}
|
| 87 | + | if not trgPos[1] then Qd.setLightColor(0xFF0000) return "Out Of\nRange" end |
| 88 | - | --staticTriangle = formation_generator.TriangleFormation("Y:spanX",4,8,2,{x=0,y=2,z=0})
|
| 88 | + | |
| 89 | - | staticTriangle = formation_generator.TriangleFormation("Y:spanX",8,10,2,{x=0,y=2,z=0})
|
| 89 | + | trgPos = vec_trunc(trgPos) |
| 90 | - | staticTriangle = formation_generator.rotateFormation("X",math.pi/4,staticTriangle)
|
| 90 | + | local mv = {0,0,0}
|
| 91 | - | --staticOrbitTriangle = {{3,2,-2},{-3,2,-2},{0,2,3}}
|
| 91 | + | local mapRange = Qn.getRange() |
| 92 | - | --staticOrbitSquare = {{1,1,0},{-1,1,0},{0,1,1},{0,1,-1}}
|
| 92 | + | |
| 93 | - | staticOrbitSquare = formation_generator.hollowSquareFormation("Z",5,5,7,{x=-2,y=0,z=0})
|
| 93 | + | repeat |
| 94 | - | dynamicOrbitSquareMe = {{1,3,0},{-1,3,0},{0,3,1},{0,3,-1}}
|
| 94 | + | local v = getPlayerCoord(e_name) |
| 95 | - | dynamicTriangleMe = {{3,4,-2},{-3,4,-2},{0,4,3}}
|
| 95 | + | v = vec_trunc(v) |
| 96 | - | --Pawnform1 = {{0,2,0}}
|
| 96 | + | local Qnpos = {Qn.getPosition()}
|
| 97 | - | Pawnfbook = {dynamicTriangle,staticTriangle,staticOrbitSquare,dynamicOrbitSquareMe,dynamicTriangleMe}
|
| 97 | + | if Qnpos[1] then |
| 98 | - | Pawndynamic_fbook = Pawnfbook |
| 98 | + | Qnpos = vec_trunc(Qnpos) |
| 99 | local Qpn = {Qnpos[1] + v[1], Qnpos[2] + v[2] + 2, Qnpos[3] + v[3]}
| |
| 100 | - | ring = formation_generator.circleFormation("Y",10,{x=0,y=0,z=7})
|
| 100 | + | mv = sub_vec(Qpn,trgPos) |
| 101 | - | ring2 = formation_generator.circleFormation("Y",10,{x=0,y=0,z=7})
|
| 101 | + | if math.abs(Qpn[1]) < mapRange-5 and math.abs(Qpn[3]) < mapRange-5 then |
| 102 | - | hollow_square = formation_generator.hollowSquareFormation("Y",3,3,7,{x=-1,y=0,z=-1})
|
| 102 | + | Qd.move(mv[1],mv[2],mv[3]) |
| 103 | - | triangle = formation_generator.TriangleFormation("Y:spanX",2,4,2,{x=0,y=2,z=0})
|
| 103 | + | trgPos = Qpn |
| 104 | - | rotated_hsqr = formation_generator.rotateFormation("Z",math.pi/4,hollow_square)
|
| 104 | + | end |
| 105 | else | |
| 106 | - | dynamicTriangle = formation_generator.TriangleFormation("X:spanZ",1,2,3,{x=-1,y=1,z=0})
|
| 106 | + | Qd.setLightColor(0xFF0000) |
| 107 | - | dynamicTriangle2 = formation_generator.TriangleFormation("X:spanZ",1,2,3,{x=-1,y=-1,z=0})
|
| 107 | + | Qd.setStatusText("Out Of\nRange")
|
| 108 | - | for k,v in ipairs(dynamicTriangle2) do |
| 108 | + | Qd.move(-mv[1],-mv[2],-mv[3]) |
| 109 | - | table.insert(dynamicTriangle,v) |
| 109 | + | |
| 110 | - | end |
| 110 | + | stp = select(6,computer.pullSignal(0.5)) |
| 111 | until stp == "stop" | |
| 112 | - | --numbering must be the same with ffbook, can't regen otherwise: |
| 112 | + | return Qd.name() |
| 113 | - | PawnGeneratedFormBook = {{},{},{},ring,ring2,dynamicTriangle,hollow_square,triangle,rotated_hsqr}
|
| 113 | + | |
| 114 | - | dynamicPawnPyramidBook = PawnGeneratedFormBook |
| 114 | + | |
| 115 | ) | |
| 116 | - | --[[ |
| 116 | + | modem.broadcast(QueensChannel, |
| 117 | - | For Floppa: |
| 117 | + | [[ |
| 118 | - | Pawnffbook[1] = Pawndynamic_fbook[1] = dynamicTriangle |
| 118 | + | function navSwarmPlayer(e_name) |
| 119 | - | Static: |
| 119 | + | checkArg(1,e_name,"string","nil") |
| 120 | - | Pawnffbook[2] = Pawndynamic_fbook[2] = staticTriangle |
| 120 | + | local trgPos = {Qn.getPosition()},stp
|
| 121 | - | Pawnffbook[3] = Pawndynamic_fbook[3] = staticOrbitSquare |
| 121 | + | |
| 122 | - | Follow Me: |
| 122 | + | if not trgPos[1] then Qd.setLightColor(0xFF0000) return "Out Of\nRange" end |
| 123 | - | Pawnffbook[4] = PawnGeneratedFormBook[4] = ring |
| 123 | + | |
| 124 | - | Pawnffbook[5] = PawnGeneratedFormBook[5] = ring2 |
| 124 | + | trgPos = vec_trunc(trgPos) |
| 125 | - | Pawnffbook[6] = PawnGeneratedFormBook[6] = dynamicTriangle |
| 125 | + | local mv = {0,0,0}
|
| 126 | local mapRange = Qn.getRange() | |
| 127 | - | trgPortBookME = {[11]="ph0",[12]="ph0",[13]="ph0"}
|
| 127 | + | |
| 128 | - | StaticFormationtrgPortBook = {[8]="team1",[10]="team2"}
|
| 128 | + | repeat |
| 129 | local v = getPlayerCoord(e_name) | |
| 130 | - | function printSwarmStatsPawn() |
| 130 | + | v = vec_trunc(v) |
| 131 | - | term.clear() |
| 131 | + | local Qnpos = {Qn.getPosition()}
|
| 132 | - | print("PAWNS:")
|
| 132 | + | if Qnpos[1] then |
| 133 | - | flightform.printDronePool(false) |
| 133 | + | Qnpos = vec_trunc(Qnpos) |
| 134 | - | flightform.printFFAssignment(Pawnffbook) |
| 134 | + | local Qpn = {Qnpos[1] + v[1] +math.random(-3,3), Qnpos[2] + v[2] +math.random(-3,3), Qnpos[3] + v[3]+math.random(-3,3)}
|
| 135 | mv = sub_vec(Qpn,trgPos) | |
| 136 | if math.abs(Qpn[1]) < mapRange-5 and math.abs(Qpn[3]) < mapRange-5 then | |
| 137 | Qd.move(mv[1],mv[2],mv[3]) | |
| 138 | trgPos = Qpn | |
| 139 | end | |
| 140 | - | |
| 140 | + | else |
| 141 | - | -- QUEEN Commands |
| 141 | + | Qd.setLightColor(0xFF0000) |
| 142 | Qd.setStatusText("Out Of\nRange")
| |
| 143 | - | q_firmware.broadcastFirmWare(QueensChannel) |
| 143 | + | Qd.move(-mv[1],-mv[2],-mv[3]) |
| 144 | end | |
| 145 | stp = select(6,computer.pullSignal(0.5)) | |
| 146 | until stp == "stop" | |
| 147 | return Qd.name() | |
| 148 | end | |
| 149 | ]] | |
| 150 | ) | |
| 151 | modem.broadcast(QueensChannel, | |
| 152 | [[ | |
| 153 | local cc = 1 | |
| 154 | isFree = true | |
| 155 | function replyInv(add) | |
| 156 | if isFree then | |
| 157 | Qd.setLightColor(0xFF00BB) | |
| 158 | Qm.send(add,QueensChannel,"pkme") | |
| 159 | --Qd.setStatusText(tostring(cc)) | |
| 160 | - | flightform.populatePool(QueensChannel,drone_is_queen) |
| 160 | + | cc=cc+1 |
| 161 | end | |
| 162 | - | printSwarmStats() |
| 162 | + | |
| 163 | ]] | |
| 164 | ) | |
| 165 | modem.broadcast(QueensChannel, | |
| 166 | - | flightform.refreshFFT(ffbook,dynamic_fbook,QueensChannel,drone_is_queen) |
| 166 | + | [[ |
| 167 | - | flightform.formFF(ffbook[1],dynamic_fbook[1],QueensChannel,drone_is_queen) |
| 167 | + | acts = {
|
| 168 | - | flightform.QformUP("ph0",ffbook[1],QueensChannel)
|
| 168 | + | ["go"] = function(r_add,tag,x,y,z) Qd.setLightColor(0x00FF00) Qd.setStatusText(navMoveToPlayer(tag)) end, |
| 169 | - | printSwarmStats() |
| 169 | + | ["bzz"] = function(r_add,tag,x,y,z) Qd.setLightColor(0x0000FF) Qd.setStatusText(navSwarmPlayer(tag)) end, |
| 170 | ["move"] = function(r_add,tag,x,y,z) move(x,y,z) end, | |
| 171 | ["inv"] = function(r_add,tag,x,y,z) replyInv(r_add) end, | |
| 172 | - | flightform.refreshFFT(ffbook,dynamic_fbook,QueensChannel,drone_is_queen) |
| 172 | + | ["commit"] = function(r_add,tag,x,y,z) Qd.setLightColor(0xFF1F00) isFree = false Qd.setStatusText("cmt "..tostring(isFree)) end,
|
| 173 | - | flightform.formFF(ffbook[2],dynamic_fbook[2],QueensChannel,drone_is_queen) |
| 173 | + | ["uncommit"] = function(r_add,tag,x,y,z) isFree = true end, |
| 174 | - | flightform.formFF(ffbook[3],dynamic_fbook[3],QueensChannel,drone_is_queen) |
| 174 | + | ["uok"] = function(r_add,tag,x,y,z) Qd.setLightColor(0x77FF77) isFree = true Qm.send(r_add,QueensChannel,"actv") end, |
| 175 | - | flightform.QformUP("ph0",ffbook[2],QueensChannel)
|
| 175 | + | ["formup"] = function(r_add,tag,x,y,z) Qd.setLightColor(0x0011FF) Qd.setStatusText(navMoveToPlayerWOffset(tag,x,y,z)) end, |
| 176 | - | flightform.QformUP("ph0",ffbook[3],QueensChannel)
|
| 176 | + | ["HUSH"] = function(r_add,tag,x,y,z) computer.shutdown() end |
| 177 | - | printSwarmStats() |
| 177 | + | } |
| 178 | ]] | |
| 179 | ) | |
| 180 | modem.broadcast(QueensChannel, | |
| 181 | - | flightform.breakFormation(ffbook[i],dynamic_fbook[i],QueensChannel,drone_is_queen) |
| 181 | + | [[ |
| 182 | gpsChannel = 2 | |
| 183 | - | printSwarmStats() |
| 183 | + | trgChannel = 2472 |
| 184 | function QgpsBroadcast() | |
| 185 | Qm.broadcast(gpsChannel,"Qgps") | |
| 186 | - | flightform.refreshFFT(ffbook,dynamic_fbook,QueensChannel,drone_is_queen) |
| 186 | + | |
| 187 | - | printSwarmStats() |
| 187 | + | |
| 188 | ) | |
| 189 | - | elseif(cmd == "PRINTQ") then --printGroup |
| 189 | + | modem.broadcast(QueensChannel, |
| 190 | - | printSwarmStats() |
| 190 | + | [[ |
| 191 | function navMoveToPlayerWOffset(e_name,xo,yo,zo) | |
| 192 | checkArg(1,e_name,"string","nil") | |
| 193 | local trgPos = {Qn.getPosition()}
| |
| 194 | if not trgPos[1] then Qd.setLightColor(0xFF0000) return "Out Of\nRange" end | |
| 195 | trgPos = vec_trunc(trgPos) | |
| 196 | - | elseif(cmd == "HUSH") then |
| 196 | + | local mv = {0,0,0}
|
| 197 | - | modem.broadcast(QueensChannel,"HUSH") |
| 197 | + | local stp = "bingus" |
| 198 | local mapRange = Qn.getRange() | |
| 199 | - | |
| 199 | + | repeat |
| 200 | - | elseif(cmd == "GPS") then -- activate QUEEN satellite GPS broadcasting |
| 200 | + | local v = getPlayerCoord(e_name) |
| 201 | - | for addr,c in pairs(ffbook[1]) do |
| 201 | + | v = vec_trunc(v) |
| 202 | - | print(addr,c) |
| 202 | + | Qm.broadcast(gpsChannel,"gps",-v[1],-v[2],-v[3]) |
| 203 | - | modem.send(addr,QueensChannel,"setgpspos",_,c[1],c[2],c[3]) |
| 203 | + | local Qnpos = {Qn.getPosition()}
|
| 204 | if Qnpos[1] then | |
| 205 | - | modem.broadcast(QueensChannel,"startgps") |
| 205 | + | Qnpos = vec_trunc(Qnpos) |
| 206 | local Qpn = {Qnpos[1] + v[1] + xo, Qnpos[2] + v[2] + yo, Qnpos[3] + v[3] + zo}
| |
| 207 | mv = sub_vec(Qpn,trgPos) | |
| 208 | - | |
| 208 | + | if math.abs(Qpn[1]) < mapRange-5 and math.abs(Qpn[3]) < mapRange-5 then |
| 209 | - | --PAWN Commands |
| 209 | + | Qd.move(mv[1],mv[2],mv[3]) |
| 210 | - | |
| 210 | + | trgPos = Qpn |
| 211 | - | |
| 211 | + | end |
| 212 | - | elseif(cmd == "K") then -- terminate GPS targeting thread |
| 212 | + | else |
| 213 | - | GPS_TRG.killGPSTRGThread(gpsChannel) |
| 213 | + | Qd.setLightColor(0xFF0000) |
| 214 | Qd.setStatusText("Out Of\nRange")
| |
| 215 | Qd.move(-mv[1],-mv[2],-mv[3]) | |
| 216 | - | elseif(cmd == "A") then -- form triangle on Floppa with PAWNS |
| 216 | + | |
| 217 | - | local targetingChannel = 4 |
| 217 | + | stp = select(6,computer.pullSignal(0.5)) |
| 218 | - | --flightform.refreshFFT(Pawnffbook,Pawndynamic_fbook,PawnsChannel,false)-- use RPE |
| 218 | + | until stp == "stop" |
| 219 | - | flightform.formFF(Pawnffbook[1],Pawndynamic_fbook[1],PawnsChannel,false) |
| 219 | + | return Qd.name() |
| 220 | - | flightform.PformUP(targetingChannel,Pawnffbook[1],PawnsChannel) |
| 220 | + | |
| 221 | - | printSwarmStatsPawn() |
| 221 | + | |
| 222 | ) | |
| 223 | - | |
| 223 | + | modem.broadcast(QueensChannel, |
| 224 | - | elseif(cmd == "TRG") then -- start entity (Floppa) targeting broadcast |
| 224 | + | [[ |
| 225 | - | local targetingChannel = 4 |
| 225 | + | Qd.setAcceleration(100) |
| 226 | - | GPS_TRG.updateGPSTRGsPRINT(trgPortBook,gpsChannel,{[targetingChannel]=0},{[targetingChannel]="Y"},{[targetingChannel]=0})
|
| 226 | + | local cmd,tag,x,y,z |
| 227 | Qd.setLightColor(0xFFAF00) | |
| 228 | - | |
| 228 | + | |
| 229 | - | elseif(cmd == "SFP") then -- Static Formation PAWNS |
| 229 | + | _,_,r_add,_,_,cmd,tag,x,y,z = computer.pullSignal(0.5) |
| 230 | - | local targetingChannel = 8 |
| 230 | + | if Qd.name():match("^Q%d+$") then
|
| 231 | - | --modem.broadcast(targetingChannel,"stop") |
| 231 | + | if acts[cmd] then |
| 232 | - | --flightform.refreshFFT(Pawnffbook,Pawndynamic_fbook,PawnsChannel,false)-- use RPE |
| 232 | + | acts[cmd](r_add,tag,x,y,z) |
| 233 | - | flightform.formFF(Pawnffbook[2],Pawndynamic_fbook[2],PawnsChannel,false) |
| 233 | + | |
| 234 | - | flightform.PformUP(targetingChannel,Pawnffbook[2],PawnsChannel) |
| 234 | + | |
| 235 | - | --flightform.POrbit(targetingChannel,Pawnffbook[2],PawnsChannel) |
| 235 | + | --Qd.setLightColor(0xFFAF00) |
| 236 | --Qd.setLightColor(0x77FF77) | |
| 237 | - | |
| 237 | + | |
| 238 | - | elseif(cmd == "USFP") then -- Update Static Formation PAWNS |
| 238 | + | |
| 239 | - | local targetingChannel = 8 |
| 239 | + | ) |
| 240 | - | modem.broadcast(targetingChannel,"color",0xBC18FB) |
| 240 | + | |
| 241 | - | GPS_TRG.updateStaticGPS(targetingChannel,gpsChannel,{[targetingChannel]=0},{[targetingChannel]="Y"},{[targetingChannel]=0})
|
| 241 | + | modem.open(SoldiersChannel) |
| 242 | modem.broadcast(SoldiersChannel,"Sr= component.proxy(component.list('radar')())")
| |
| 243 | modem.broadcast(SoldiersChannel,"Sn= component.proxy(component.list('navigation')())")
| |
| 244 | - | elseif(cmd == "SRFP") then -- Static Rotating Formation PAWNS |
| 244 | + | modem.broadcast(SoldiersChannel,"Sd= component.proxy(component.list('drone')())")
|
| 245 | - | local targetingChannel = 10 |
| 245 | + | modem.broadcast(SoldiersChannel,"function sleep(timeout) checkArg(1, timeout, 'number', 'nil') local deadline = computer.uptime() + (timeout or 0) repeat computer.pullSignal(deadline - computer.uptime()) until computer.uptime() >= deadline end") |
| 246 | - | --modem.broadcast(targetingChannel,"stop") |
| 246 | + | |
| 247 | - | --flightform.refreshFFT(Pawnffbook,Pawndynamic_fbook,PawnsChannel,false)-- use RPE |
| 247 | + | |
| 248 | - | flightform.formFF(Pawnffbook[3],Pawndynamic_fbook[3],PawnsChannel,false) |
| 248 | + | |
| 249 | - | flightform.POrbit(targetingChannel,Pawnffbook[3],PawnsChannel) |
| 249 | + | |
| 250 | - | os.sleep(0.5) |
| 250 | + | |
| 251 | - | |
| 251 | + | |
| 252 | - | elseif(cmd == "USRFP") then -- Update Static Rotating Formation PAWNS |
| 252 | + | form1 = {{3,2,-2},{-3,2,-2},{0,2,3}}
|
| 253 | - | local targetingChannel = 10 |
| 253 | + | form2 = {{-2,2,2},{2,2,2}}
|
| 254 | - | local rotationAngleInterval = math.pi/8 |
| 254 | + | form3 = {{-2,2,-2},{2,2,-2}}
|
| 255 | - | local tiltAngle = math.pi/4 |
| 255 | + | fbook={form1,form2,form3}
|
| 256 | - | modem.broadcast(targetingChannel,"color",0xF78E1E) |
| 256 | + | |
| 257 | - | GPS_TRG.updateStaticGPS(targetingChannel,gpsChannel,{[targetingChannel]=rotationAngleInterval},{[targetingChannel]="X"},{[targetingChannel]=tiltAngle})
|
| 257 | + | |
| 258 | - | os.sleep(0.5) |
| 258 | + | pool={}
|
| 259 | - | |
| 259 | + | |
| 260 | - | elseif(cmd == "RM") then -- Rotating on Me |
| 260 | + | function clearPool() |
| 261 | - | local targetingChannel1 = 11 |
| 261 | + | |
| 262 | - | local targetingChannel2 = 12 |
| 262 | + | |
| 263 | - | local targetingChannel3 = 13 |
| 263 | + | |
| 264 | - | --modem.broadcast(targetingChannel1,"stop") |
| 264 | + | msg_reaction = {
|
| 265 | - | --modem.broadcast(targetingChannel2,"stop") |
| 265 | + | } |
| 266 | - | --modem.broadcast(targetingChannel3,"stop") |
| 266 | + | |
| 267 | - | |
| 267 | + | function msg_handler(evt,l_add,r_add,port,dist,msg,...) |
| 268 | - | --flightform.refreshFFT(Pawnffbook,dynamicPawnPyramidBook,PawnsChannel,false) -- use RPM |
| 268 | + | |
| 269 | - | |
| 269 | + | |
| 270 | - | --[[ |
| 270 | + | |
| 271 | - | flightform.formFF(Pawnffbook[4],Pawndynamic_fbook[4],PawnsChannel,false) |
| 271 | + | function openFlighFormComms() |
| 272 | - | flightform.POrbit(targetingChannel,Pawnffbook[4],PawnsChannel) |
| 272 | + | |
| 273 | - | |
| 273 | + | function closeFlighFormComms() --**********************-- |
| 274 | - | flightform.formFF(Pawnffbook[5],Pawndynamic_fbook[5],PawnsChannel,false) |
| 274 | + | |
| 275 | - | flightform.PformUP(targetingChannel,Pawnffbook[5],PawnsChannel) |
| 275 | + | |
| 276 | - | ]] |
| 276 | + | function populatePool(port) --**********************-- |
| 277 | - | ----flightform.formFF(Pawnffbook[4],dynamicPawnPyramidBook[2],PawnsChannel,false) |
| 277 | + | |
| 278 | - | flightform.formFF(Pawnffbook[4],dynamicPawnPyramidBook[4],PawnsChannel,false) |
| 278 | + | |
| 279 | - | flightform.formFF(Pawnffbook[5],dynamicPawnPyramidBook[5],PawnsChannel,false) |
| 279 | + | function refreshPool(port) |
| 280 | - | flightform.formFF(Pawnffbook[6],dynamicPawnPyramidBook[6],PawnsChannel,false) |
| 280 | + | |
| 281 | - | --flightform.formFF(Pawnffbook[5],dynamicPawnPyramidBook[2],PawnsChannel,false) |
| 281 | + | |
| 282 | - | --flightform.formFF(Pawnffbook[5],dynamicPawnPyramidBook[3],PawnsChannel,false) |
| 282 | + | function add2Pool(addr) |
| 283 | - | --flightform.formFF(Pawnffbook[5],dynamicPawnPyramidBook[4],PawnsChannel,false) |
| 283 | + | |
| 284 | - | --flightform.PformUP(targetingChannel2,Pawnffbook[4],PawnsChannel) |
| 284 | + | |
| 285 | - | flightform.POrbit(targetingChannel1,Pawnffbook[4],PawnsChannel) |
| 285 | + | function setAsActive(addr) |
| 286 | - | flightform.POrbit(targetingChannel2,Pawnffbook[5],PawnsChannel) |
| 286 | + | |
| 287 | - | flightform.POrbit(targetingChannel3,Pawnffbook[6],PawnsChannel) |
| 287 | + | |
| 288 | function add2FF(ff,f,addr,port) | |
| 289 | - | |
| 289 | + | |
| 290 | - | os.sleep(0.5) |
| 290 | + | |
| 291 | - | elseif(cmd == "URM") then -- Update Static Formation PAWNS |
| 291 | + | function populateFF(ff,f,port) |
| 292 | - | local targetingChannel1 = 11 |
| 292 | + | |
| 293 | - | local targetingChannel2 = 12 |
| 293 | + | |
| 294 | - | local targetingChannel3 = 13 |
| 294 | + | function pruneFF(ff,f,port) |
| 295 | - | --modem.broadcast(targetingChannel,"color",tonumber(0xFF8800)) |
| 295 | + | |
| 296 | - | --for addr,c in pairs(Pawnffbook[5]) do modem.send(addr,targetingChannel1,"color",0x8800FF) end |
| 296 | + | |
| 297 | - | --for addr,c in pairs(Pawnffbook[4]) do modem.send(addr,targetingChannel2,"color",0xFF8800) end |
| 297 | + | function refreshFF(ff,f,port) --**********************-- |
| 298 | - | --local rotationAngleInterval = math.pi/8 -- for squares |
| 298 | + | |
| 299 | - | --modem.broadcast(targetingChannel1,"color",0x8800FF) |
| 299 | + | |
| 300 | - | --modem.broadcast(targetingChannel2,"color",0xFF8800) |
| 300 | + | function formFF(ff,f,port) --**********************-- |
| 301 | - | modem.broadcast(targetingChannel1,"color",0xBC18FB) |
| 301 | + | |
| 302 | - | modem.broadcast(targetingChannel2,"color",0x28DDEF) |
| 302 | + | function formUP(e_name,ff,f,port) --**********************-- |
| 303 | - | modem.broadcast(targetingChannel3,"color",0x00FF00) |
| 303 | + | |
| 304 | - | local rotationAngleInterval1 = math.pi/4 |
| 304 | + | |
| 305 | - | local tiltAngle1 = math.pi/4 |
| 305 | + | function breakFormation(ff,f,port) --**********************-- |
| 306 | - | local rotationAngleInterval2 = -math.pi/4 |
| 306 | + | |
| 307 | - | local tiltAngle2 = -math.pi/4 |
| 307 | + | |
| 308 | - | --local axisTable = {[targetingChannel1] = "Z",[targetingChannel2] = "Z"}
|
| 308 | + | function printDronePool() --**********************-- |
| 309 | - | local axisTable = {[targetingChannel1] = "X",[targetingChannel2] = "X",[targetingChannel3]="Y"}
|
| 309 | + | |
| 310 | - | local tiltAngleTable = {[targetingChannel1] = tiltAngle1,[targetingChannel2] = tiltAngle2,[targetingChannel3]=0}
|
| 310 | + | function printFFAssignment(ffb) --**********************-- |
| 311 | - | local rotAngIntTable = {[targetingChannel1] = rotationAngleInterval1,[targetingChannel2] = rotationAngleInterval2,[targetingChannel3]=0}
|
| 311 | + | |
| 312 | - | GPS_TRG.updateGPSTRGsPRINT(trgPortBookME,gpsChannel,rotAngIntTable,axisTable,tiltAngleTable) |
| 312 | + | |
| 313 | - | --GPS_TRG.updateGPSTRGsPRINT(trgPortBookME,gpsChannel,rotationAngleInterval,"Z") |
| 313 | + | |
| 314 | - | --GPS_TRG.updateGPSTRGsPRINT(trgPortBookME,gpsChannel,rotationAngleInterval,"X") |
| 314 | + | print("Bingus28")
|
| 315 | ||
| 316 | - | elseif(cmd == "URMREV") then -- Update Static Formation PAWNS Reverse |
| 316 | + | |
| 317 | - | --[[local targetingChannel = 11 |
| 317 | + | |
| 318 | - | --modem.broadcast(targetingChannel,"color",tonumber(0x8800FF)) |
| 318 | + | local trgChannel = 2472 |
| 319 | - | for addr,c in pairs(Pawnffbook[5]) do modem.send(addr,targetingChannel,"color",0xFF8800) end |
| 319 | + | |
| 320 | - | --for addr,c in pairs(Pawnffbook[4]) do modem.send(addr,targetingChannel,"color",0x8800FF) end |
| 320 | + | |
| 321 | - | --local rotationAngleInterval = -math.pi/8 |
| 321 | + | function gpsBroadcast(gps_port) |
| 322 | - | local rotationAngleInterval = -math.pi/4 -- for circles |
| 322 | + | while true do |
| 323 | - | local tiltAngle = -math.pi/4 -- for circles |
| 323 | + | modem.broadcast(gps_port,"gps",0,0,0) |
| 324 | - | GPS_TRG.updateGPSTRGsPRINT(trgPortBookME,gpsChannel,rotationAngleInterval,"Z",tiltAngle) |
| 324 | + | --print("broadcasting..")
|
| 325 | - | --GPS_TRG.updateGPSTRGsPRINT(trgPortBookME,gpsChannel,rotationAngleInterval,"X",tiltAngle) |
| 325 | + | os.sleep() |
| 326 | - | --GPS_TRG.updateGPSTRGsPRINT(trgPortBookME,gpsChannel,rotationAngleInterval,"Z") |
| 326 | + | |
| 327 | - | --GPS_TRG.updateGPSTRGsPRINT(trgPortBookME,gpsChannel,rotationAngleInterval,"X")]] |
| 327 | + | |
| 328 | - | local targetingChannel1 = 11 |
| 328 | + | |
| 329 | - | local targetingChannel2 = 12 |
| 329 | + | local gpsThread |
| 330 | - | local targetingChannel3 = 13 |
| 330 | + | local sat_mode = false |
| 331 | - | modem.broadcast(targetingChannel1,"color",0xFF9945) |
| 331 | + | function toggleGPSBroadCast(channel) --**********************-- |
| 332 | - | modem.broadcast(targetingChannel2,"color",0x1CF6C5) |
| 332 | + | sat_mode = not sat_mode |
| 333 | - | modem.broadcast(targetingChannel3,"color",0xFFD700) |
| 333 | + | print("sat_mode: "..tostring(sat_mode))
|
| 334 | - | local rotationAngleInterval1 = -math.pi/4 |
| 334 | + | if sat_mode then |
| 335 | - | local tiltAngle1 = -math.pi/4 |
| 335 | + | print("creating GPS Thread..")
|
| 336 | - | local rotationAngleInterval2 = math.pi/4 |
| 336 | + | gpsThread = thread.create(function(port) gpsBroadcast(port) end,channel) |
| 337 | - | local tiltAngle2 = math.pi/4 |
| 337 | + | |
| 338 | - | --local axisTable = {[targetingChannel1] = "X",[targetingChannel2] = "X"}
|
| 338 | + | gpsThread:kill() |
| 339 | - | --local tiltAngleTable = {[targetingChannel1] = tiltAngle1,[targetingChannel2] = tiltAngle2}
|
| 339 | + | |
| 340 | - | --local rotAngIntTable = {[targetingChannel1] = rotationAngleInterval1,[targetingChannel2] = rotationAngleInterval2}
|
| 340 | + | |
| 341 | - | local axisTable = {[targetingChannel1] = "X",[targetingChannel2] = "X",[targetingChannel3]="X"}
|
| 341 | + | |
| 342 | - | local tiltAngleTable = {[targetingChannel1] = tiltAngle1,[targetingChannel2] = tiltAngle2,[targetingChannel3]= math.pi/2}
|
| 342 | + | function getPlayerCoord(e_name) |
| 343 | - | local rotAngIntTable = {[targetingChannel1] = rotationAngleInterval1,[targetingChannel2] = rotationAngleInterval2,[targetingChannel3]=0}
|
| 343 | + | checkArg(1,e_name,'string','nil') |
| 344 | - | GPS_TRG.updateGPSTRGsPRINT(trgPortBookME,gpsChannel,rotAngIntTable,axisTable,tiltAngleTable) |
| 344 | + | for k,v in ipairs(Tr.getPlayers()) do |
| 345 | - | os.sleep(0.5) |
| 345 | + | if v.name == e_name then |
| 346 | - | |
| 346 | + | return {v.x,v.y,v.z},v.distance
|
| 347 | - | elseif(cmd == "GP") then -- recall PAWNS |
| 347 | + | end |
| 348 | - | modem.broadcast(PawnsChannel,"stop") |
| 348 | + | |
| 349 | - | GPS_TRG.GPSRecall(trgPortBook,gpsChannel,PawnsChannel) |
| 349 | + | return {0,0,0},0
|
| 350 | end | |
| 351 | - | |
| 351 | + | |
| 352 | - | elseif(cmd == "FP") then |
| 352 | + | function trgBroadcast(e_name) |
| 353 | - | p_firmware.broadcastFirmWare(PawnsChannel) |
| 353 | + | while true do |
| 354 | local player_co = getPlayerCoord(e_name) | |
| 355 | - | elseif(cmd == "EP") then |
| 355 | + | player_co = s_utils.vec_trunc(player_co) |
| 356 | - | for i = 1,#Pawnffbook do |
| 356 | + | modem.broadcast(trgChannel,"trg",player_co[1],player_co[2],player_co[3]) |
| 357 | - | flightform.breakFormation(Pawnffbook[i],Pawndynamic_fbook[i],PawnsChannel,false) |
| 357 | + | --print("broadcasting target..")
|
| 358 | os.sleep() | |
| 359 | - | printSwarmStatsPawn() |
| 359 | + | |
| 360 | end | |
| 361 | - | elseif(cmd == "RPE") then --refresh PAWN Entity Formation |
| 361 | + | local trgThread |
| 362 | - | flightform.refreshFFT(Pawnffbook,Pawndynamic_fbook,PawnsChannel,false) |
| 362 | + | local send_trg = false |
| 363 | - | printSwarmStatsPawn() |
| 363 | + | function toggleTargetBroadCast(target) --**********************-- |
| 364 | - | os.sleep(0.5) |
| 364 | + | send_trg = not send_trg |
| 365 | - | elseif(cmd == "RPM") then --refresh PAWN ME Formation |
| 365 | + | print("send_trg: "..tostring(send_trg))
|
| 366 | - | flightform.refreshFFT(Pawnffbook,dynamicPawnPyramidBook,PawnsChannel,false) |
| 366 | + | if send_trg then |
| 367 | - | printSwarmStatsPawn() |
| 367 | + | print("creating TRG Thread..")
|
| 368 | - | os.sleep(0.5) |
| 368 | + | trgThread = thread.create(function(t) trgBroadcast(t) end,target) |
| 369 | - | elseif(cmd == "PRINTP") then |
| 369 | + | |
| 370 | - | printSwarmStatsPawn() |
| 370 | + | trgThread:kill() |
| 371 | end | |
| 372 | - | elseif(cmd == "SP") then |
| 372 | + | |
| 373 | - | modem.broadcast(PawnsChannel,"stop") |
| 373 | + | |
| 374 | - | os.sleep(0.5) |
| 374 | + | |
| 375 | - | elseif(cmd == "HUSHP") then |
| 375 | + | |
| 376 | - | modem.broadcast(PawnsChannel,"HUSH") |
| 376 | + | |
| 377 | - | os.sleep(0.5) |
| 377 | + | |
| 378 | - | |
| 378 | + | |
| 379 | - | elseif(cmd == "WRU") then |
| 379 | + | print("Broadcasting Queen FIRMWARE")
|
| 380 | - | modem.broadcast(PawnsChannel,"wru") |
| 380 | + | Q_FIRMWARE() |
| 381 | - | modem.close(gpsChannel) |
| 381 | + | |
| 382 | - | local _,_,r_addr,_,_,msg,x,y,z = event.pull("modem_message")
|
| 382 | + | |
| 383 | - | if msg == "here" then |
| 383 | + | |
| 384 | - | print("r_addr: ",r_addr,"c: ",x,y,z)
|
| 384 | + | |
| 385 | os.sleep(0.5) | |
| 386 | - | os.sleep(0.5) |
| 386 | + | |
| 387 | modem.broadcast(QueensChannel,"stop") | |
| 388 | - | |
| 388 | + | |
| 389 | os.sleep(0.5) | |
| 390 | - | flightform.closeFlighFormComms() |
| 390 | + | |
| 391 | - | GPS_TRG.killGPSTRGThread(gpsChannel) |
| 391 | + | |
| 392 | modem.broadcast(QueensChannel,"move","",0,3,0) | |
| 393 | os.sleep(0.5) | |
| 394 | elseif(cmd == "P") then --refreshFormation | |
| 395 | populatePool(QueensChannel) | |
| 396 | os.sleep(0.5) | |
| 397 | elseif(cmd == "T") then | |
| 398 | formFF(ffbook[1],dynamic_fbook[1],QueensChannel) | |
| 399 | formUP("ph0",ffbook[1],dynamic_fbook[1],QueensChannel)
| |
| 400 | os.sleep(0.5) | |
| 401 | elseif(cmd == "Q") then | |
| 402 | formFF(ffbook[2],dynamic_fbook[2],QueensChannel) | |
| 403 | formFF(ffbook[3],dynamic_fbook[3],QueensChannel) | |
| 404 | formUP("ph0",ffbook[2],dynamic_fbook[2],QueensChannel)
| |
| 405 | formUP("ph0",ffbook[3],dynamic_fbook[3],QueensChannel)
| |
| 406 | os.sleep(0.5) | |
| 407 | elseif(cmd == "E") then | |
| 408 | for i = 1,#ffbook do | |
| 409 | breakFormation(ffbook[i],dynamic_fbook[i],QueensChannel) | |
| 410 | end | |
| 411 | os.sleep(0.5) | |
| 412 | elseif(cmd == "R") then --refreshFormation | |
| 413 | for i = 1,#ffbook do | |
| 414 | refreshFF(ffbook[i],dynamic_fbook[i],QueensChannel) | |
| 415 | end | |
| 416 | os.sleep(0.5) | |
| 417 | elseif(cmd == "PRINT") then --printGroup | |
| 418 | printDronePool() | |
| 419 | printFFAssignment(ffbook) | |
| 420 | os.sleep(0.5) | |
| 421 | elseif(cmd == "GPS") then | |
| 422 | toggleGPSBroadCast(gpsChannel) | |
| 423 | os.sleep(0.5) | |
| 424 | elseif(cmd == "TRG") then | |
| 425 | toggleTargetBroadCast("ph0")
| |
| 426 | os.sleep(0.5) | |
| 427 | elseif(cmd == "EXIT") then | |
| 428 | for i = 1,#ffbook do | |
| 429 | breakFormation(ffbook[i],dynamic_fbook[i],QueensChannel) | |
| 430 | end | |
| 431 | closeFlighFormComms() | |
| 432 | clearPool() | |
| 433 | os.exit() | |
| 434 | elseif(cmd == "S") then | |
| 435 | modem.broadcast(QueensChannel,"stop") | |
| 436 | event.ignore("modem_message",msg_handler)
| |
| 437 | os.sleep(0.5) | |
| 438 | else | |
| 439 | modem.broadcast(QueensChannel,cmd) | |
| 440 | end | |
| 441 | end | |
| 442 |