PtitSerpent

HORUS lift-off script

Feb 7th, 2025
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | Gaming | 0 0
  1. CLEARSCREEN.
  2. SET esc_char TO char(10).
  3.  
  4. PRINT "-----------------------------------------".
  5. PRINT "-----------------------------------------".
  6. PRINT "-----------| HORUS |-----------".
  7. PRINT "-----------------------------------------".
  8. PRINT "-----------------------------------------".
  9. PRINT esc_char.
  10.  
  11. PRINT "Initiate the lift-off script...".
  12. SET th TO 1.
  13. SET h_dir TO 90.
  14. SET h_pitch TO 90.
  15. SET h_roll TO -90.
  16. LOCK THROTTLE TO th.
  17. LOCK STEERING TO HEADING(h_dir,h_pitch,h_roll).
  18. SAS OFF.
  19. RCS OFF.
  20. GEAR OFF.
  21.  
  22. WAIT 1.
  23. PRINT "Lift-off in:".
  24. printCountdown(5).
  25. STAGE.
  26. PRINT "Lift-off!".
  27. PRINT esc_char.
  28.  
  29. WAIT UNTIL ship:velocity:surface:mag >= 100.
  30. PRINT "Heading to 68°...".
  31. SET h_pitch TO 68.
  32.  
  33. WAIT UNTIL ship:velocity:surface:mag >= 170.
  34. PRINT "SAS prograde heading".
  35. sasToPrograde().
  36.  
  37. WAIT UNTIL ship:obt:apoapsis >= 81500.
  38. PRINT "Engines shutdown".
  39. SET th TO 0.
  40. UNLOCK THROTTLE.
  41.  
  42. WAIT 15.
  43. PRINT "Staging".
  44. BRAKES ON.
  45. STAGE.
  46. BRAKES OFF.
  47. RCS ON.
  48. WAIT 5.
  49. SET launcherCraft TO getNearCraft().
  50. SET ship:name TO "[Ship] HORUS".
  51.  
  52. WAIT UNTIL eta:apoapsis <= 25.
  53. PRINT "Circularization started".
  54. SAS OFF.
  55. STAGE.
  56. circularize().
  57. PRINT "Circularization ended".
  58. sasToPrograde().
  59. RCS OFF.
  60. AG1 ON.
  61. PANELS ON.
  62. WAIT 3.
  63. PRINT "Vessel switch in 2s for manual landing".
  64. WAIT 2.
  65. SET KUniverse:ACTIVEVESSEL TO launcherCraft.
  66.  
  67.  
  68. function circularize {
  69. SET th TO 0.
  70. LOCK THROTTLE TO th.
  71. SET dV to ship:facing:vector:normalized.
  72. LOCK STEERING TO LOOKDIRUP(dV, ship:facing:topvector).
  73. LOCAL timeout IS time:seconds + 9000.
  74. WHEN dV:mag < 0.05 THEN SET timeout TO time:seconds + 3.
  75. UNTIL dV:mag < 0.02 or time:seconds > timeout {
  76. SET posVec TO ship:position - body:position.
  77. SET vecNormal TO vcrs(posVec,velocity:orbit).
  78. SET vecHorizontal TO -1 * vcrs(ship:position-body:position, vecNormal).
  79. SET vecHorizontal:mag TO sqrt(body:MU/(body:Radius + altitude)). //this is the desired velocity vector to obtain circular orbit at current altitude
  80. SET dV TO vecHorizontal - velocity:orbit. //deltaV as a vector
  81. //throttle control
  82. IF vang(ship:facing:vector,dV) > 1 {
  83. SET th TO 0.
  84. } ELSE {
  85. SET th TO max(0,min(1,dV:mag/10)).
  86. }
  87. WAIT 0.
  88. }
  89. }
  90.  
  91. function sasToPrograde {
  92. UNLOCK STEERING.
  93. SAS ON.
  94. WAIT 0.1.
  95. SET SASMODE to "PROGRADE".
  96. }
  97.  
  98. function printCountdown {
  99. parameter numberOfSeconds.
  100. FROM {LOCAL countdown IS numberOfSeconds.} UNTIL countdown = 0 STEP {SET countdown TO countdown - 1.} DO {
  101. PRINT countdown.
  102. WAIT 1.
  103. }
  104. }
  105.  
  106. function getNearCraft {
  107. LOCAL allCrafts IS LIST().
  108. LIST TARGETS IN allCrafts.
  109. FOR craft IN allCrafts {
  110. LOCAL dist IS (craft:POSITION - ship:POSITION):MAG.
  111. IF dist < 500 AND craft:name <> ship:name {
  112. RETURN craft.
  113. }
  114. }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment