Advertisement
Guest User

Untitled

a guest
Apr 30th, 2016
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.81 KB | None | 0 0
  1. CLEARSCREEN.
  2. lights off.
  3.  
  4. SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0.
  5.  
  6. PRINT "Countdown: -T 5 Sec".
  7.  
  8. WAIT 4.
  9.  
  10. FROM {local countdown is 10.} UNTIL countdown = 0 STEP {SET countdown to countdown - 1.} DO {
  11.  
  12. PRINT "..." + countdown.
  13.  
  14. WAIT 1.
  15.  
  16. CLEARSCREEN.
  17.  
  18. }
  19.  
  20. LOCK THROTTLE TO 0.5.
  21.  
  22. STAGE.
  23.  
  24. WAIT 1.
  25.  
  26. STAGE.
  27.  
  28. PRINT "LIFT OFF!".
  29.  
  30. lock steering to lookdirup(heading(90,85):vector, ship:facing:topvector).
  31.  
  32. WAIT UNTIL SHIP:ALTITUDE > 3000.
  33.  
  34. PRINT "Steering".
  35.  
  36. lock steering to lookdirup(heading(90,80):vector, ship:facing:topvector).
  37.  
  38. WAIT UNTIL SHIP:ALTITUDE > 4000.
  39.  
  40. PRINT "Steering".
  41.  
  42. lock steering to lookdirup(heading(90,75):vector, ship:facing:topvector).
  43.  
  44. WAIT UNTIL SHIP:ALTITUDE > 5000.
  45.  
  46. PRINT "Steering".
  47.  
  48. lock steering to lookdirup(heading(90,70):vector, ship:facing:topvector).
  49.  
  50. WAIT UNTIL SHIP:ALTITUDE > 6000.
  51.  
  52. PRINT "Steering".
  53.  
  54. lock steering to lookdirup(heading(90,65):vector, ship:facing:topvector).
  55.  
  56. WAIT 3.
  57.  
  58. PRINT "Waiting boosters flameout...".
  59.  
  60. WAIT UNTIL STAGE:SOLIDFUEL < 0.1.
  61.  
  62. lock steering to lookdirup(heading(90,45):vector, ship:facing:topvector).
  63.  
  64. STAGE.
  65.  
  66. PRINT "Boosters Ejected".
  67.  
  68. RCS ON.
  69.  
  70. PRINT "RCS ON".
  71.  
  72. LOCK THROTTLE TO 0.6.
  73.  
  74. PRINT "Accelerating".
  75.  
  76. WAIT 5.
  77.  
  78. LOCK THROTTLE TO 0.7.
  79.  
  80. PRINT "Accelerating".
  81.  
  82. WAIT 5.
  83.  
  84. LOCK THROTTLE TO 0.8.
  85.  
  86. PRINT "Accelerating".
  87.  
  88. WAIT UNTIL SHIP:ALTITUDE > 30000.
  89.  
  90. lock steering to lookdirup(heading(90,40):vector, ship:facing:topvector).
  91.  
  92. PRINT "Steering".
  93.  
  94. WAIT UNTIL SHIP:ALTITUDE > 32500.
  95.  
  96. lock steering to lookdirup(heading(90,35):vector, ship:facing:topvector).
  97.  
  98. PRINT "Steering".
  99.  
  100. WAIT UNTIL SHIP:ALTITUDE > 35000.
  101.  
  102. lock steering to lookdirup(heading(90,35):vector, ship:facing:topvector).
  103.  
  104. PRINT "Steering".
  105.  
  106. WAIT UNTIL SHIP:ALTITUDE > 37500.
  107.  
  108. lock steering to lookdirup(heading(90,30):vector, ship:facing:topvector).
  109.  
  110. PRINT "Steering a little more...".
  111.  
  112. WAIT UNTIL SHIP:ALTITUDE > 40000.
  113.  
  114. lock steering to lookdirup(heading(90,27):vector, ship:facing:topvector).
  115.  
  116. PRINT "End of turn".
  117.  
  118. WAIT UNTIL SHIP:ALTITUDE > 42500.
  119.  
  120. lock steering to lookdirup(heading(90,25):vector, ship:facing:topvector).
  121.  
  122. PRINT "End of turn".
  123.  
  124. PRINT "Waiting apoapsis...".
  125.  
  126. WAIT UNTIL SHIP:APOAPSIS > 100000.5.
  127.  
  128. LOCK THROTTLE TO 0.0.
  129.  
  130. PRINT "100km Apoapsis reached".
  131.  
  132. WAIT 3.
  133.  
  134. lock steering to prograde.
  135.  
  136. PRINT "Steering to prograde".
  137.  
  138. WAIT 14.
  139.  
  140. PRINT "Ejecting external fueltank".
  141.  
  142. STAGE.
  143.  
  144. // something to turn off main engines
  145.  
  146. // WAIT UNTIL SHIP:ALTITUDE > 70000.
  147.  
  148. PRINT "Calculating maneuver node".
  149.  
  150. declare parameter alt.
  151.  
  152. // create apoapsis maneuver node
  153.  
  154. print "T+" + round(missiontime) + " Apoapsis maneuver, orbiting " + body:name.
  155.  
  156. print "T+" + round(missiontime) + " Apoapsis: " + round(apoapsis/1000) + "km".
  157.  
  158. print "T+" + round(missiontime) + " Periapsis: " + round(periapsis/1000) + "km -> " + round(alt/1000) + "km".
  159.  
  160. // present orbit properties
  161.  
  162. set vom to velocity:orbit:mag. // actual velocity
  163.  
  164. set r to rb + altitude. // actual distance to body
  165.  
  166. set ra to rb + apoapsis. // radius in apoapsis
  167.  
  168. set va to sqrt( vom^2 + 2*mu*(1/ra - 1/r) ). // velocity in apoapsis
  169.  
  170. set a to (periapsis + 2*rb + apoapsis)/2. // semi major axis present orbit
  171.  
  172. // future orbit properties
  173.  
  174. set r2 to rb + apoapsis. // distance after burn at apoapsis
  175.  
  176. set a2 to (alt + 2*rb + apoapsis)/2. // semi major axis target orbit
  177.  
  178. set v2 to sqrt( vom^2 + (mu * (2/r2 - 2/r + 1/a - 1/a2 ) ) ).
  179.  
  180. // setup node
  181.  
  182. set deltav to v2 - va.
  183.  
  184. print "T+" + round(missiontime) + " Apoapsis burn: " + round(va) + ", dv:" + round(deltav) + " -> " + round(v2) + "m/s".
  185.  
  186. set nd to node(time:seconds + eta:apoapsis, 0, 0, deltav).
  187.  
  188. add nd.
  189.  
  190. print "T+" + round(missiontime) + " Node created.".
  191.  
  192. WAIT 4.
  193.  
  194. PRINT "Node Confirmed".
  195.  
  196. WAIT 5.
  197.  
  198. PRINT "Prepairing to burn".
  199.  
  200. set nd to nextnode(x).
  201.  
  202. print "Node in: " + round(nd:eta) + ", DeltaV: " + round(nd:deltav:mag).
  203.  
  204. set max_acc to ship:maxthrust/ship:mass.
  205.  
  206. set burn_duration to nd:deltav:mag/max_acc.
  207.  
  208. print "Crude Estimated burn duration: " + round(burn_duration) + "s".
  209.  
  210. wait until node:eta <= (burn_duration/2 + 60).
  211.  
  212. set np to nd:deltav.
  213.  
  214. lock steering to np.
  215.  
  216. wait until abs(np:pitch - facing:pitch) < 0.15 and abs(np:yaw - facing:yaw) < 0.15.
  217.  
  218. wait until node:eta <= (burn_duration/2).
  219.  
  220. set tset to 0.
  221.  
  222. lock throttle to tset.
  223.  
  224. set done to False.
  225.  
  226. set dv0 to nd:deltav.
  227.  
  228. until done
  229.  
  230. {
  231.  
  232. set max_acc to ship:maxthrust/ship:mass.
  233.  
  234. set tset to min(nd:deltav:mag/max_acc, 1).
  235.  
  236. if vdot(dv0, nd:deltav) < 0
  237.  
  238. {
  239.  
  240. print "End burn, remain dv " + round(nd:deltav:mag,1) + "m/s, vdot: " + round(vdot(dv0, nd:deltav),1).
  241.  
  242. lock throttle to 0.
  243.  
  244. break.
  245.  
  246. }
  247.  
  248.  
  249.  
  250. //we have very little left to burn, less then 0.1m/s
  251.  
  252. if nd:deltav:mag < 0.1
  253.  
  254. {
  255.  
  256. print "Finalizing burn, remain dv " + round(nd:deltav:mag,1) + "m/s, vdot: " + round(vdot(dv0, nd:deltav),1).
  257.  
  258. //we burn slowly until our node vector starts to drift significantly from initial vector
  259.  
  260. //this usually means we are on point
  261.  
  262. wait until vdot(dv0, nd:deltav) < 0.5.
  263.  
  264.  
  265.  
  266. lock throttle to 0.
  267.  
  268. print "End burn, remain dv " + round(nd:deltav:mag,1) + "m/s, vdot: " + round(vdot(dv0, nd:deltav),1).
  269.  
  270. set done to True.
  271.  
  272. }
  273.  
  274. }
  275.  
  276. unlock steering.
  277.  
  278. unlock throttle.
  279.  
  280. wait 1.
  281.  
  282.  
  283.  
  284. //we no longer need the maneuver node
  285.  
  286. remove nd.
  287.  
  288.  
  289.  
  290. //set throttle to 0 just in case.
  291.  
  292. SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0.
  293.  
  294. lock steering to prograde.
  295.  
  296. LOCK THROTTLE TO 0.0.
  297.  
  298.  
  299.  
  300. PRINT "Welcome to orbit".
  301.  
  302. WAIT 4.
  303.  
  304. PRINT "Lights on, debloying solar panels".
  305.  
  306. panels on.
  307.  
  308. lights on.
  309.  
  310. WAIT 4.
  311.  
  312. PRINT "You may open cargo bay now".
  313.  
  314. unlock steering.
  315.  
  316. WAIT 4.
  317.  
  318. Print "Full control return".
  319.  
  320. SAS ON.
  321.  
  322. print "Good bye!".
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement