portablejim

ssto-r100-deorbit.ks

Mar 3rd, 2021 (edited)
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if ship:partstaggedpattern("booster"):length > 0 {
  2. print "Preparing for deorbit:".
  3. print " * point retrograde".
  4. print " * move remaining fuel to the other end of the rocket.".
  5. lock steering to lookDirUp(retrograde:forevector, sun:position).
  6. set steeringmanager:maxstoppingtime to 5.
  7. set transferFuel to transferall("LiquidFuel", ship:partstagged("toptank"), ship:partstagged("bottomtank")). set transferFuel:active to true.
  8. set transferOx to transferall("Oxidizer", ship:partstagged("toptank"), ship:partstagged("bottomtank")). set transferOx:active to true.
  9.  
  10. when transferFuel:status = "Finished" then {
  11. print "Deorbit prep completed. Warping close to deorbit point.".
  12. when geoposition:lng > 140 then set warp to 1.
  13. when geoposition:lng > 150 then set warp to 0.
  14. set warp to 3.
  15. }
  16.  
  17. when geoposition:lng > 161.5 then {
  18. print "Deorbit burn".
  19. lock throttle to 1.
  20. when periapsis < 30_000 then {
  21. lock throttle to 0.25.
  22. when periapsis < 25_000 then {
  23. lock throttle to 0.
  24. print "Deorbit burn completed. Preparing for reentry.".
  25. lock steering to lookDirUp(srfretrograde:forevector, sun:position).
  26. brakes on.
  27.  
  28. wait 5.
  29.  
  30. print "Warping to atmosphere.".
  31. set warp to 2.
  32. when altitude < (body:atm:height + 400) then {
  33. print "Warping to thicker parts of the atmosphere.".
  34. set warp to 0.
  35. set warpmode to "physics".
  36. set warp to 3.
  37. when altitude < 25000 then
  38. {
  39. print "Now in real time".
  40. set warp to 0.
  41. }
  42. }
  43.  
  44.  
  45. when geoposition:lng > -49.0 and geoposition:lng < -45 then {
  46. print "Near KSC".
  47. if airspeed > 380 {
  48. print "Still too fast, slowing down.".
  49. when airspeed < 385 then {
  50. lock throttle to 0.
  51. }
  52. lock throttle to 1.
  53. }
  54.  
  55. }
  56. when geoposition:lng > -48.4 and geoposition:lng < -45 then {
  57. if geoposition:lng > -48.4 and geoposition:lng < -45 {
  58. print "Over KSC".
  59. } else {
  60. print "Lithobraking imminent... slowing down".
  61. }
  62. stage.
  63. when airspeed < 150 then {
  64. lock steering to lookDirUp( up:forevector, ship:facing:topvector).
  65. gear on.
  66. }
  67. }
  68. }
  69. }
  70. }
  71. } else {
  72. print "Something is not right. I am not a booster.".
  73. }
Add Comment
Please, Sign In to add comment