Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function info {
- parameter message.
- print char(7).
- set logmessage to round(missionTime,1):tostring():padleft(5) + ": " + message.
- print logmessage.
- }
- for i in range(terminal:height-3) Print "":padright(terminal:width).
- //Variables
- set x to 90.
- lock p to choose 0 if airspeed < takeoffspeed else min(60,max(0,groundspeed/5)).
- set takeoffspeed to 125.
- set targetOrbitAltitude to body:atm:height + 1e4.
- lock angletarget to 0.
- set shipbounds to ship:bounds.
- set runwayaltradar to 4.
- lock vlimit to max(0,(-verticalspeed + (runwayaltradar-shipbounds:bottomaltradar))*100).
- set vlimitcopy to vlimit.
- set anglecopy to angletarget.
- lock aoa to vang(srfprograde:vector, ship:facing:vector).
- set maxCircEta to 50.
- set chaseSpeed to 350.
- set turboSpeed to 300.
- set autoVectoring to true.
- set minheight to 0.
- circularizing off.
- //Triggers
- when shipbounds:bottomaltradar > 0.5 and abs(steeringmanager:angleerror) < 5 then {
- info("engage dynamic servo").
- gear off.
- lock angletarget to max(0, min(90,100 - ((-verticalspeed + (runwayaltradar-shipbounds:bottomaltradar)/1.5)*100))).
- }
- when shipbounds:bottomaltradar > 1 and ship:verticalspeed < 1 then {
- info("Capture starting height").
- set minheight to shipbounds:bottomaltradar.
- }
- when true then {
- if(shipbounds:bottomaltradar < minheight) set minheight to shipbounds:bottomaltradar.
- set vlimitcopy to vlimit.
- set anglecopy to angletarget.
- ThrustLimit(vectors, vlimitcopy).
- SetAngle(anglecopy).
- return autoVectoring.
- }
- when airspeed > takeoffspeed then {
- info("Vector Power Climb").
- lock vlimit to 100.
- lock p to 60.
- }
- when apoapsis > 1000 then {
- info("will clear mountain, locking to surface prograde").
- lock p to max(10,vang(srfprograde:vector,heading(90,0):vector)).
- }
- when airspeed > turboSpeed then {
- info("Resume Airbreathing Flight").
- shutoff(vectors).
- set vlimit to 100.
- set angletarget to 90.
- autoVectoring off.
- }
- when altitude > 14000 then {
- info("engage nukes").
- startup(nukes).
- lock p to 15.
- }
- when altitude > 20000 then {
- info("push to orbit").
- lock p to min(35,airspeed/50).
- startup(vectors).
- ThrustLimit(vectors, 100).
- }
- when apoapsis >= targetOrbitAltitude-5e3 then {
- info("locking to surface prograde").
- lock p to vang(srfprograde:vector,heading(90,0):vector).
- }
- when ship:oxidizer < 3750 then {
- info("preserve landing fuel").
- shutoff(vectors).
- }
- when apoapsis >= targetOrbitAltitude then {
- info("warping to space").
- shutoff(turbos).
- lock throttle to 0.
- set warpmode to "physics".
- set warp to 3.
- }
- when (altitude >= body:atm:height and (periapsis > body:atm:height or ship:verticalspeed > 0)) then {
- steeringManager:resettodefault().
- set warp to 0.
- wait until kuniverse:timewarp:issettled.
- set warpmode to "rails".
- info("adjusting apoapsis").
- lock throttle to 1.
- }
- when apoapsis >= targetOrbitAltitude and (altitude >= body:atm:height and (periapsis > body:atm:height or ship:verticalspeed > 0)) then {
- info("prep for circularization").
- set warp to 0.
- lock throttle to 0.
- shutoff(turbos).
- shutoff(vectors).
- startup(nukes).
- lock throttle to periapsis < body:atm:height.
- lock p to max(0,min(60,-verticalspeed)).
- }
- when eta:apoapsis < maxCircEta and altitude > body:atm:height and apoapsis > targetOrbitAltitude then {
- info("Final circularization").
- rcs on.
- set circularizing to true.
- lock desiredVel to vxcl(up:vector,velocity:orbit):normalized * sqrt(body:MU/(body:Radius + altitude)).
- lock dV to desiredVel - velocity:orbit.
- lock steering to lookdirup(dV, ship:facing:topvector).
- }
- when circularizing then {
- if vang(facing:vector,dV) > 10 {
- lock throttle to 0.
- } else {
- lock throttle to dv:mag / 2.
- }
- if dv:mag > 0.3 {
- return true.
- } else {
- info("circularize complete").
- lock throttle to 0.
- set circularizing to false.
- rcs off.
- info("Final Stats: ").
- info("apoapsis " + apoapsis).
- info("periapsis " + periapsis).
- info("liquidfuel " + ship:liquidfuel).
- info("oxidizer" + ship:oxidizer).
- }
- return circularizing.
- }
- //Settings
- set steeringmanager:rollcontrolanglerange to 180.
- //Flight
- bays off.
- brakes off.
- startup(vectors).
- startup(turbos).
- lock steering to heading(x,p).
- lock throttle to targetOrbitAltitude-apoapsis.
- info("non-blocking").
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement