Advertisement
dekyos

SSTO_kOS

Dec 27th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.51 KB | None | 0 0
  1. parameter orbitHeight is 80000, nosekicker is false.
  2. function updateReadouts{
  3.     print "Step: "+step+"          " AT(0,0).
  4.     print "Target Orbit "+orbitHeight/1000+"km          " AT(0,2).
  5.     print "Steering Direction = "+round(steeringDir,3)+"          " AT(0,3).
  6.     print "Pitch = "+round(shipPitch,3)+"          " AT(0,4).
  7.  
  8.     print genoutputmessage+"                           " AT(0,6).
  9. }
  10.  
  11. //RUN functions.ks.
  12.  
  13. CLEARSCREEN.
  14. BRAKES ON.
  15.  
  16. if(DEFINED step){
  17.  
  18. }else{
  19.     SET step to "Launch".
  20.  
  21. SET looping to TRUE.
  22. SET thrott to 0.
  23. SET steeringDir to 90.
  24. SET shipPitch to 0.7.
  25. SET genoutputmessage TO "".
  26.  
  27. LOCK THROTTLE to thrott.
  28. LOCK STEERING TO HEADING(steeringDir, shipPitch).
  29.  
  30. WHEN ALT:RADAR>25 THEN {
  31.     SET step TO "Retracting Landing Gear.".
  32.     GEAR OFF.
  33.     WAIT 4.
  34.     SET step TO "Ascent".
  35.     RETURN FALSE.
  36. }
  37.  
  38. WHEN SHIP:ALTITUDE>6500 THEN {
  39.     SET shipPitch to 15.
  40.     RETURN FALSE.
  41. }
  42.  
  43. WHEN SHIP:ALTITUDE>21000 THEN {
  44.     AG1 ON.
  45.     SET step TO "Closed Cycle Ascent.".
  46.     RETURN FALSE.
  47. }
  48.  
  49. WHEN ORBIT:APOAPSIS>50000 THEN {
  50.     LOCK STEERING TO SHIP:PROGRADE:VECTOR.
  51.     AG9 ON.
  52.     IF ORBIT:APOAPSIS>orbitHeight+250{
  53.         SET thrott to 0.
  54.         SET step TO "Coasting.".
  55.         RETURN FALSE.  
  56.     }
  57.     RETURN TRUE.
  58. }
  59.  
  60. UNTIL looping = false {
  61.     updateReadouts().
  62.  
  63.     if(step="Launch"){
  64.         STAGE.
  65.         BRAKES OFF.
  66.         SAS OFF.
  67.         RCS OFF.
  68.         SET thrott TO 1.
  69.         SET step TO "Takeoff".
  70.         }
  71.     if(step="Takeoff"){
  72.         if SHIP:GROUNDSPEED+VERTICALSPEED>125{
  73.             if(nosekicker="true"){
  74.                 SET noseEngines TO SHIP:PARTSTAGGED("noselifters").
  75.                 FOR item IN noseEngines{
  76.                     item:Activate().
  77.                 }
  78.            
  79.             }
  80.             SET shipPitch to 10.
  81.             WAIT 5.
  82.             if(nosekicker="true"){
  83.                 FOR item IN noseEngines{
  84.                     item:Shutdown().
  85.                 }}
  86.             SET adjustment TO false.
  87.             SET step TO "Ascent".
  88.         }}
  89.     if(step="Coasting."){
  90.         if SHIP:ALTITUDE>69999{
  91.             LOCK STEERING TO HEADING(steeringDir, shipPitch).
  92.             SET shipPitch to 0.
  93.             AG2 ON.
  94.             AG3 ON.
  95.         }
  96.         SET shipPitch to 0.
  97.         if(eta:apoapsis<3){
  98.             SET thrott to 1.
  99.             SET shipPitch to 0.
  100.             SET targetAP to SHIP:APOAPSIS+150.
  101.             SET step TO "Circularization.".
  102.         }}
  103.     if(step="Circularization."){
  104.         if(SHIP:PERIAPSIS>20000){
  105.             SET thrott to 0.5.
  106.         }else{
  107.             SET thrott to 1.
  108.         }
  109.         if(eta:apoapsis>500){
  110.             SET shipPitch to 6.
  111.         }else{
  112.             SET shipPitch to -1.
  113.         }
  114.         if(targetAP < SHIP:APOAPSIS){
  115.             SET thrott to 0.
  116.             SET step TO "end".
  117.         }}
  118.     if(step="end"){
  119.         SET thrott TO 0.
  120.         SET looping TO false.
  121.         UNLOCK STEERING.
  122.         CLEARSCREEN.
  123.         Print "Orbit complete. Exiting Program.".
  124.     }}
  125.            
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement