Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @clobberbuiltins on.
- on ag10 {
- abort().
- }
- clearscreen.
- settings().
- flight().
- run apollomuninj.
- run apollomuncirc.
- run apollokerbburn.
- run apolloreturn.
- function printingonlaunch {
- clearscreen.
- print "Left " + t + " Seconds".
- print "Status: " + status1.
- wait 0.1.
- }
- function printing {
- clearscreen.
- set t to time:seconds - now1.
- print "T+: " + t.
- print "Status: " + status1.
- wait 0.1.
- }
- function settings {
- set TargetPe to 97000.
- set TargetAp to 97500.
- set Azimuth to 90.
- set radaroffset to ship:altitude.
- lock altit to ship:altitude - radaroffset.
- set startsteer to lookDirUp(up:forevector, ship:facing:topvector).
- set PitchKickAlt to 250.
- set sec to 50.
- set min to 28.
- set hour to 4.
- set clock to "04:28:50".
- set status1 to "Waiting for launch window".
- print "Running hardware...".
- wait 5.
- set n to time:seconds + ((hour-time:hour)*60+min-time:minute)*60+(sec-time:second).
- lock t to (n - time:seconds)+10.
- lock rclock to time:clock.
- until rclock >= clock and rclock <= clock {
- printingonlaunch().
- }
- }
- function flight {
- //Liftoff
- ag1 on.
- print "T-10".
- wait 0.
- sas off.
- wait 1.
- print "T-9".
- stage.
- lock throttle to 0.05.
- wait 1.
- print "T-8".
- set now to time:seconds.
- lock ti to time:seconds - now.
- lock throttle to min(1, 0.05+ti/6).
- print "Ignition!".
- print "T-7".
- wait 1.
- print "T-6".
- wait 1.
- print "T-5".
- wait 1.
- print "T-4".
- wait 1.
- print "T-3".
- wait 1.
- print "T-2".
- print "Full throttle".
- wait 1.
- print "T-1".
- wait 1.
- print "T-0".
- stage.
- set now1 to time:seconds.
- lock steering to startsteer.
- until ship:verticalspeed > 1 {
- printing().
- }
- set status1 to "Liftoff".
- until altit > PitchKickAlt - 50 {
- printing().
- }
- lock steering to heading(Azimuth, 90).
- until altit > PitchKickAlt {
- printing().
- }
- set status1 to "Pitching and ascending".
- lock gravityturn to 90-((ship:apoapsis/TargetPe)*90).
- lock steering to heading(Azimuth, gravityturn).
- set oldq to ship:q.
- wait 0.1.
- set newq to ship:q.
- until newq < oldq {
- set oldq to ship:q.
- wait 0.1.
- set newq to ship:q.
- printing().
- }
- set status1 to "Max-Q passed".
- until stage:deltav:duration < 10 {
- printing().
- }
- set status1 to "First Stage Center Engine Cutoff".
- ship:partstagged("FCE")[0]:shutdown.
- until stage:deltav:duration < 2 {
- printing().
- }
- set status1 to "First Stage Engines Cutoff".
- set now to time:seconds.
- lock ti to time:seconds - now.
- set thr to throttle.
- lock throttle to max(0.05, thr-ti/2).
- rcs on.
- wait 2.
- stage.
- set status1 to "Stage Separation".
- set ship:control:fore to 1.
- wait 1.
- lock throttle to 0.05.
- wait 2.
- set status1 to "Second Stage Ignition".
- set now to time:seconds.
- lock ti to time:seconds - now.
- lock throttle to min(1, ti/1).
- set ship:control:fore to 0.
- wait 10.
- stage.
- wait 5.
- stage.
- set status1 to "Launch Escape System Jettison".
- wait 3.
- set status1 to "Ascending algorithm is completing".
- set thr to 1.
- lock throttle to thr.
- set pitch to 35.
- lock steering to heading(Azimuth, pitch).
- set targeteta1 to 90.
- set pid1 to pidloop(0.25,0.02,0.02, 0.05,1).
- set pid1:setpoint to targeteta1.
- set pid2 to pidloop(0.12,0.05,0.03, -25,45).
- set pid2:setpoint to TargetPe*1.06.
- until ship:apoapsis > TargetPe*1.05 {
- set thr to pid1:update(time:seconds,eta:apoapsis).
- set pitch to pid2:update(time:seconds,ship:apoapsis).
- printing().
- wait 0.01.
- }
- set targeteta2 to 15.
- set pid1:setpoint to targeteta2.
- until ship:apoapsis >= TargetAp and ship:periapsis >= TargetPe*0.98 {
- set thr to pid1:update(time:seconds,eta:apoapsis).
- set pitch to pid2:update(time:seconds,ship:apoapsis).
- set targeteta2 to (((TargetPe-ship:periapsis)/targeteta1)/targeteta1).
- set pid1:setpoint to targeteta2.
- set pid2:setpoint to TargetPe*1.06.
- printing().
- if ship:verticalspeed < 5 {
- printing().
- set pid1 to pidloop(0.01,0.001,0.001, 0.25,1).
- set pid2 to pidloop(2,0.3,0.01, -10,30).
- set pid1:setpoint to 5.
- set pid2:setpoint to 5.
- set pitch to pid2:update(time:seconds, ship:verticalspeed).
- set thr to pid1:update(time:seconds,ship:verticalspeed).
- when stage:deltav:current < 100 then {
- set now to time:seconds.
- lock ti to time:seconds - now.
- set thr to throttle.
- lock throttle to max(0.03, thr-ti/2).
- set status1 to "Second Stage Engines Cutoff".
- wait 2.
- stage.
- set status1 to "Stage Separation".
- wait 1.
- lock throttle to 0.03.
- wait 2.
- set status1 to "Third Stage Engine Ignition".
- set now to time:seconds.
- lock ti to time:seconds - now.
- lock throttle to min(1, ti/1).
- }
- printing().
- }
- }
- lock throttle to 0.
- set status1 to "Third Stage Engine Cutoff, orbit reached".
- }
- function abort {
- if ship:status = "Prelaunch" {
- set now1 to time:seconds.
- lock t to time:second - now1.
- lock steering to loodirup(up:vector,ship:facing:starvector).
- wait 0.2.
- }
- lock steering to srfprograde.
- set status1 to "Launch Escape System Activated".
- until stage:deltav:current < 1 {
- printing().
- }
- stage.
- set status1 to "Launch Escape System Separation".
- until altit < ship:apoapsis {
- printing().
- }
- set status1 to "Apoapsis reached, descending back to Kerbin".
- return1().
- }
- function return1 {
- lock steering to srfretrograde.
- until altit < 3750 {
- printing().
- }
- stage.
- wait 1.
- stage.
- set status1 to "Heat Shield Separation and Drogue Chutes Deploy".
- until altit < 1750 {
- printing().
- }
- ag8 on.
- stage.
- set status1 to "Main Chutes Deploy".
- until ship:status = "Landed" or ship:status = "Splashed" or ship:status = "Crashed" {
- printing().
- }
- print "Touchdown".
- set status to "Touchdown".
- }
Advertisement
Add Comment
Please, Sign In to add comment