Deserter

Marauder v2

Feb 28th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. clearscreen.
  2.  
  3. print " ".
  4. print " ".
  5.  
  6. if body:atm:oxygen = true {
  7. print " Begin Marauder launch sequence...".
  8. } else {
  9. print " ERROR!".
  10. wait 0.5.
  11. print " No oxygen detected".
  12. wait 0.5.
  13. print " Aborting launch".
  14. set x to 1/0.
  15. }
  16.  
  17. set terminal:height to 30.
  18. set terminal:width to 40.
  19. set apo_PID to PIDLoop(0.25, 0.02, 0.005, 0, 1).
  20. set apo_PID:setpoint to 60.
  21. set tgtThrot to 1.
  22. set tgtVel to sqrt(body:mu / (body:radius + body:atm:height)) * 0.9.
  23.  
  24. lock tgtApo to body:atm:height * 1.03 * (1 + ship:q).
  25. lock tgtETA to (body:atm:height * 0.01) * orbit:eccentricity.
  26. lock nucAlt to tgtApo * 0.33.
  27. lock rapAlt to tgtApo * 0.4.
  28.  
  29. function vel_bearing {
  30. local trig_x is vdot(heading(90, 0):vector, facing:vector).
  31. local trig_y is vdot(heading(0, 0):vector, facing:vector).
  32. return mod(arctan2(trig_x, trig_y) + 360, 360).
  33. }
  34.  
  35. function flightText {
  36. print round(altitude) + "m " at(13,4).
  37. print round(apoapsis) + "m " at(13,5).
  38. print round(tgtApo) + "m " at(13,6).
  39. print round(periapsis) + "m " at(13,7).
  40. print round(eta:apoapsis,2) + " " at(13,9).
  41. print round(tgtETA,2) + " " at(13,10).
  42. print round(tgtThrot,2) + " " at(13,12).
  43. print round(ship:availablethrust,2) + "kN " at(13,13).
  44. print round(vel_bearing(),2) + " " at(13,15).
  45. print round(ship:q,4) + " " at(13,16).
  46. print round(body:atm:altitudepressure(altitude),4) + " " at(13,17).
  47. }
  48.  
  49. print "----------------------------------------".
  50. print " ALT: True:".
  51. print " APO: NOW:".
  52. print " APO: TRGT:".
  53. print " Periapsis:".
  54. print " ".
  55. print " ETA: NOW:".
  56. print " ETA: TRGT:".
  57. print " ".
  58. print " Throttle:".
  59. print " Thrust:".
  60. print " ".
  61. print " Bearing:".
  62. print " Pressure:".
  63. print " Atmosphere:".
  64. print "----------------------------------------".
  65. print " STATE".
  66. print "NEXT AT" at(20,19).
  67.  
  68. wait 1.
  69.  
  70. stage.
  71.  
  72. sas off.
  73. brakes off.
  74. print " Launch".
  75. print "Airspeed: 50m/s" at(20,20).
  76. lock throttle to tgtThrot.
  77.  
  78. wait until airspeed > 50.
  79. print " Take-off".
  80. print "Altitude: 20m" at(20,21).
  81. lock steering to heading(90,10).
  82.  
  83. wait until alt:radar > 20.
  84. print " Flight".
  85. print "Altitude:" at(20,22).
  86. lock steering to heading(90,15).
  87. gear off.
  88.  
  89. until altitude > nucalt {
  90. flightText().
  91. print round(nucAlt) + "m" at(31,22).
  92. }
  93.  
  94. print " Nuclear stage".
  95. print "Altitude:" at(20,23).
  96. lock tgtThrot to 1 - ship:q.
  97. toggle ag4.
  98.  
  99. until altitude > rapAlt {
  100. flightText().
  101. print round(rapAlt) + "m" at(31,23).
  102. }
  103.  
  104. print " Closed cycle".
  105. print "Airspeed: " + round(tgtVel) + "m/s" at(20,24).
  106. toggle ag3.
  107.  
  108. until velocity:orbit:mag > tgtVel { flightText(). }
  109.  
  110. toggle ag5.
  111. print " RAPIER shutdown".
  112. print "Apoapsis:" at(20,25).
  113.  
  114. until apoapsis > tgtApo {
  115. flightText().
  116. print round(tgtApo) + "m" at(31,25).
  117. }
  118.  
  119. print " Burn complete".
  120. print "Altitude: " + body:atm:height + "m" at(20,26).
  121. lock steering to prograde.
  122.  
  123. until altitude > body:atm:height {
  124. flightText().
  125. set apo_PID:setpoint to tgtETA.
  126. set tgtThrot to apo_PID:update(time:seconds, eta:apoapsis).
  127. }
  128.  
  129. print " Circularization".
  130. print "Periapsis:" at(20,27).
  131. lock steering to vxcl(up:vector, prograde:vector).
  132. toggle ag10.
  133.  
  134. until periapsis > altitude * 0.99 {
  135. flightText().
  136. print round(altitude * 0.99) + "m" at(31,27).
  137. set apo_PID:setpoint to tgtETA.
  138. set tgtThrot to apo_PID:update(time:seconds, eta:apoapsis).
  139. }
  140.  
  141. flightText().
  142. print " Orbit - manual controls".
  143. set ship:control:pilotmainthrottle to 0.
  144. lock throttle to 0.
  145. unlock all.
  146. sas on.
Add Comment
Please, Sign In to add comment