Advertisement
sumguytwitches

Shoot the ring

Mar 8th, 2024 (edited)
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1.  
  2.  
  3. {
  4.  
  5. global function closest {
  6. parameter sgt is time:seconds.
  7. parameter sgstep to 1.
  8. set sgmindist to 9e9.
  9. lock sgdist to (positionat(ship, sgt) - positionat(target, sgt)):mag.
  10. until sgt - time:seconds > orbit:period {
  11. if sgdist < sgmindist {
  12. set sgmindist to sgdist.
  13. set sgmint to sgt.
  14. }
  15. set sgt to sgt + sgstep.
  16. }
  17. print sgmint. print sgmindist.
  18. return sgmint.
  19. }
  20.  
  21. set rt to closest().
  22. set st to (positionat(target, rt) - positionat(ship, rt)).
  23. lock steering to st. wait 0.
  24. wait until abs(steeringmanager:angleerror) < 1.
  25. print "steering adjusted".
  26. lock dist to (positionat(ship, rt) - positionat(target, rt)):mag.
  27. until dist > 5000 { set rt to rt - 1.}
  28.  
  29. when target:loaded then {
  30. set portacontrol to target:partsdubbedpattern("porta")[0].
  31. lock tgt to portacontrol:position + portacontrol:facing:vector*12.5.
  32. lock steering to tgt.
  33. lock relvel to ship:velocity:orbit - target:velocity:orbit.
  34. lock tarVel to tgt:normalized * relvel:mag.
  35. lock errvel to tarvel-relvel.
  36. rcs on.
  37. set adjust to true.
  38. when adjust then {
  39. set ship:control:translation to errvel * ship:facing:inverse.
  40. return adjust.
  41. }
  42. when not adjust then {
  43. set ship:Control:translation to v(0,0,0).
  44. set ship:Control:neutralize to true.
  45. }
  46. on body adjust off.
  47. set m to target:modulesnamed("wbijumpgate")[0].
  48. set m:destination to vessel("marauder plus").
  49. }
  50.  
  51. set warp to 1.
  52. when kuniverse:timewarp:issettled then warpto(rt).
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66. //camera
  67. mapview off.
  68. set cam to addons:camera:flightcamera.
  69. set cam:mode to "orbital".
  70. wait 1.
  71. set cx to 0.
  72. set cy to -25.
  73. Set cz to 0.
  74. set cd to cam:distance.
  75. on time:seconds {
  76. set cam:position to (-target:position:normalized*cd)*r(cx,cy,cz).
  77. return target:distance > 200.
  78. }
  79.  
  80. }
  81.  
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement