Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CLEARSCREEN.
- SET esc_char TO char(10).
- PRINT "-----------------------------------------".
- PRINT "-----------------------------------------".
- PRINT "-----------| HORUS |-----------".
- PRINT "-----------------------------------------".
- PRINT "-----------------------------------------".
- PRINT esc_char.
- PRINT "Initiate the lift-off script...".
- SET th TO 1.
- SET h_dir TO 90.
- SET h_pitch TO 90.
- SET h_roll TO -90.
- LOCK THROTTLE TO th.
- LOCK STEERING TO HEADING(h_dir,h_pitch,h_roll).
- SAS OFF.
- RCS OFF.
- GEAR OFF.
- WAIT 1.
- PRINT "Lift-off in:".
- printCountdown(5).
- STAGE.
- PRINT "Lift-off!".
- PRINT esc_char.
- WAIT UNTIL ship:velocity:surface:mag >= 100.
- PRINT "Heading to 68°...".
- SET h_pitch TO 68.
- WAIT UNTIL ship:velocity:surface:mag >= 170.
- PRINT "SAS prograde heading".
- sasToPrograde().
- WAIT UNTIL ship:obt:apoapsis >= 81500.
- PRINT "Engines shutdown".
- SET th TO 0.
- UNLOCK THROTTLE.
- WAIT 15.
- PRINT "Staging".
- BRAKES ON.
- STAGE.
- BRAKES OFF.
- RCS ON.
- WAIT 5.
- SET launcherCraft TO getNearCraft().
- SET ship:name TO "[Ship] HORUS".
- WAIT UNTIL eta:apoapsis <= 25.
- PRINT "Circularization started".
- SAS OFF.
- STAGE.
- circularize().
- PRINT "Circularization ended".
- sasToPrograde().
- RCS OFF.
- AG1 ON.
- PANELS ON.
- WAIT 3.
- PRINT "Vessel switch in 2s for manual landing".
- WAIT 2.
- SET KUniverse:ACTIVEVESSEL TO launcherCraft.
- function circularize {
- SET th TO 0.
- LOCK THROTTLE TO th.
- SET dV to ship:facing:vector:normalized.
- LOCK STEERING TO LOOKDIRUP(dV, ship:facing:topvector).
- LOCAL timeout IS time:seconds + 9000.
- WHEN dV:mag < 0.05 THEN SET timeout TO time:seconds + 3.
- UNTIL dV:mag < 0.02 or time:seconds > timeout {
- SET posVec TO ship:position - body:position.
- SET vecNormal TO vcrs(posVec,velocity:orbit).
- SET vecHorizontal TO -1 * vcrs(ship:position-body:position, vecNormal).
- SET vecHorizontal:mag TO sqrt(body:MU/(body:Radius + altitude)). //this is the desired velocity vector to obtain circular orbit at current altitude
- SET dV TO vecHorizontal - velocity:orbit. //deltaV as a vector
- //throttle control
- IF vang(ship:facing:vector,dV) > 1 {
- SET th TO 0.
- } ELSE {
- SET th TO max(0,min(1,dV:mag/10)).
- }
- WAIT 0.
- }
- }
- function sasToPrograde {
- UNLOCK STEERING.
- SAS ON.
- WAIT 0.1.
- SET SASMODE to "PROGRADE".
- }
- function printCountdown {
- parameter numberOfSeconds.
- FROM {LOCAL countdown IS numberOfSeconds.} UNTIL countdown = 0 STEP {SET countdown TO countdown - 1.} DO {
- PRINT countdown.
- WAIT 1.
- }
- }
- function getNearCraft {
- LOCAL allCrafts IS LIST().
- LIST TARGETS IN allCrafts.
- FOR craft IN allCrafts {
- LOCAL dist IS (craft:POSITION - ship:POSITION):MAG.
- IF dist < 500 AND craft:name <> ship:name {
- RETURN craft.
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment