Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clearscreen.
- settings().
- boostback().
- entry().
- landing().
- function settings {
- unlock all.
- set ship:control:pilotmainthrottle to 0.
- set errorScalling to 1.
- set landingZone to latlng(-6.1, -83.5).
- set altit to ship:altitude - 37.
- set lngoff to (landingZone:lng - addons:tr:impactpos:lng)*10472.
- set latoff to (landingZone:lat - addons:tr:impactpos:lat)*10472.
- set tlng to 500.
- set fte to ship:partstagged("fte")[0].
- set bt to ship:partsdubbed("bts")[0].
- set rb1 to bt:resources.
- set rb2 to rb1[0].
- set rb3 to rb1[1].
- set rb2:enabled to false.
- set rb3:enabled to false.
- set engList to list().
- set i to -1.
- until i >= 32 {
- set i to i + 1.
- engList:add(ship:partstagged("Vector" + i)[0]).
- }
- sas off.
- rcs on.
- }
- function boostbackvars {
- set deg to max(3.4, (min(35, abs(latoff/1000)))*2).
- set sign to abs(latoff)/latoff.
- set degf to deg*sign.
- }
- function boostback {
- when min(35, abs(latoff/1000))*2 = 0 then {
- set sign to 0.
- set degf to 0.
- }
- set n to time:seconds.
- set t to time:seconds - n.
- set sstatus to "Boostback burn starting, T+ " + round(t,1) + " Seconds".
- boostbackvars().
- set steeringManager:maxstoppingtime to 0.35.
- set steeringManager:yawts to 0.5.
- set steeringManager:pitchts to 0.5.
- lock steering to heading(270+degf, 0).
- lock throttle to 0.4.
- set now1 to time:seconds.
- lock ti to time:seconds - now1.
- until ti > 2 {
- printing().
- boostbackvars().
- }
- set ship:partstagged("Vector0")[0]:thrustlimit to 100.
- set ship:partstagged("Vector1")[0]:thrustlimit to 100.
- set ship:partstagged("Vector2")[0]:thrustlimit to 100.
- ship:partstagged("Vector6")[0]:activate.
- ship:partstagged("Vector11")[0]:activate.
- until ti > 2.2 {
- printing().
- boostbackvars().
- }
- ship:partstagged("Vector7")[0]:activate.
- ship:partstagged("Vector12")[0]:activate.
- until ti > 2.6 {
- printing().
- boostbackvars().
- }
- ship:partstagged("Vector4")[0]:activate.
- ship:partstagged("Vector9")[0]:activate.
- until ti > 2.8 {
- printing().
- boostbackvars().
- }
- ship:partstagged("Vector3")[0]:activate.
- ship:partstagged("Vector8")[0]:activate.
- until ti > 3.2 {
- printing().
- boostbackvars().
- }
- ship:partstagged("Vector5")[0]:activate.
- ship:partstagged("Vector10")[0]:activate.
- until ti > 6 {
- printing().
- boostbackvars().
- }
- lock throttle to 1.
- set sstatus to "Superheavy boostback burn has started, T+ " + round(t,1) + " Seconds".
- until altit > 50700 {
- printing().
- boostbackvars().
- }
- ship:partstagged("Vector9")[0]:shutdown.
- set now1 to time:seconds.
- lock ti to time:seconds - now1.
- until ti > 0.5 {
- printing().
- boostbackvars().
- }
- ship:partstagged("Vector10")[0]:shutdown.
- until ti > 0.7 {
- printing().
- boostbackvars().
- }
- ship:partstagged("Vector8")[0]:shutdown.
- until ti > 1.1 {
- printing().
- boostbackvars().
- }
- ship:partstagged("Vector11")[0]:shutdown.
- until ti > 1.5 {
- printing().
- boostbackvars().
- }
- ship:partstagged("Vector7")[0]:shutdown.
- until ti > 1.9 {
- printing().
- boostbackvars().
- }
- ship:partstagged("Vector12")[0]:shutdown.
- until ti > 4 {
- printing().
- boostbackvars().
- }
- ship:partstagged("Vector3")[0]:shutdown.
- ship:partstagged("Vector4")[0]:shutdown.
- ship:partstagged("Vector5")[0]:shutdown.
- ship:partstagged("Vector6")[0]:shutdown.
- set sstatus to "Boostback burn is ending".
- until ti > 8 {
- printing().
- boostbackvars().
- }
- set sstatus to "Boostback burn shutdown, T+ " + round(t,1) + " Seconds".
- lock throttle to 0.
- wait 2.
- toggle brakes.
- unlock steering.
- unlock throttle.
- ship:partstagged("Vector3")[0]:activate.
- ship:partstagged("Vector4")[0]:activate.
- ship:partstagged("Vector5")[0]:activate.
- ship:partstagged("Vector6")[0]:activate.
- ship:partstagged("Vector7")[0]:activate.
- ship:partstagged("Vector8")[0]:activate.
- ship:partstagged("Vector9")[0]:activate.
- ship:partstagged("Vector10")[0]:activate.
- ship:partstagged("Vector11")[0]:activate.
- ship:partstagged("Vector12")[0]:activate.
- fte:getmodule("ModuleResourceDrain"):doaction("слить",true).
- ag6 off.
- rcs on.
- set sstatus to "Coast, grid fins are enabled, draining fuel T+ " + round(t,1) + " Seconds".
- }
- function entry {
- when ship:verticalspeed <= 0 then {
- set sstatus to "Superheavy has reached apoapsis, T+ " + round(t,1) + " Seconds".
- }
- when ship:liquidfuel < 500 then {
- fte:getmodule("ModuleResourceDrain"):doaction("остановить слив",true).
- print "Fuel is drained, activating landing tank".
- ag6 on.
- set rb2:enabled to true.
- set rb3:enabled to true.
- wait 2.
- }
- set steeringManager:maxstoppingtime to 0.04.
- lock steering to heading(270,90).
- until vang(up:vector, ship:facing:vector) < 3 and ship:verticalspeed < -20 {
- printing().
- }
- set sstatus to "Superheavy has reached apoapsis, orienting retrograde, T+ " + round(t,1) + " Seconds".
- lock steering to srfretrograde.
- until altit < 25000 {
- printing().
- }
- set sstatus to "Controlled descent, T+ " + round(t,1) + " Seconds".
- set steeringManager:maxstoppingtime to 5.
- set steeringManager:yawts to 1.
- set steeringManager:pitchts to 1.
- set aoa to 60.
- lock steering to Steer().
- when lngoff < 200 and lngoff > -200 and latoff < 200 and latoff > -200 and altitude > 3000 then {
- set aoa to 25.
- }
- until myvel:mag < 220 {
- printing().
- }
- set sstatus to "Superheavy is transonic, getting ready for landing burn, T+ " + round(t,1) + " Seconds".
- set engnum to 13.
- until altit < 3500 {
- printing().
- lbcalc(engnum).
- }
- set sstatus to "Controlled descend, getting ready for landing burn, T+ " + round(t,1) + " Seconds".
- }
- function landing {
- until altit < lbcalc(engnum)+350 and altit < 2000 {
- printing().
- lbcalc(engnum).
- }
- lock aoa to -5.
- ship:partstagged("Vector0")[0]:shutdown.
- ship:partstagged("Vector1")[0]:shutdown.
- ship:partstagged("Vector2")[0]:activate.
- ship:partstagged("Vector3")[0]:shutdown.
- ship:partstagged("Vector3")[0]:shutdown.
- ship:partstagged("Vector4")[0]:shutdown.
- ship:partstagged("Vector5")[0]:shutdown.
- ship:partstagged("Vector6")[0]:shutdown.
- ship:partstagged("Vector7")[0]:shutdown.
- ship:partstagged("Vector8")[0]:shutdown.
- ship:partstagged("Vector9")[0]:shutdown.
- ship:partstagged("Vector10")[0]:shutdown.
- ship:partstagged("Vector11")[0]:shutdown.
- ship:partstagged("Vector12")[0]:shutdown.
- wait 0.01.
- lock throttle to 1.
- print "Superheavy Landing Burn has started.".
- set now1 to time:seconds.
- lock ti1 to time:seconds - now1.
- until ti1 > 0.8 {
- printing().
- }
- ship:partstagged("Vector5")[0]:activate.
- ship:partstagged("Vector3")[0]:activate.
- until ti1 > 1.5 {
- printing().
- }
- ship:partstagged("Vector3")[0]:shutdown.
- until ti1 > 3.7 {
- printing().
- }
- ship:partstagged("Vector5")[0]:shutdown.
- set engnum to 3.
- until altit < lbcalc(engnum) {
- printing().
- lbcalc(engnum).
- }
- lock throttle to Thr.
- until altit < 100 {
- printing().
- thrustcalc().
- }
- set sstatus to "Landing burn, orienting retrograde, T+ " + round(t,1) + " Seconds".
- lock steering to lookdirup(-ship:velocity:surface,ship:facing:topvector).
- until vang(up:vector, -ship:velocity:surface)<2 {
- printing().
- thrustcalc().
- }
- set sstatus to "Landing burn, orienting up, T+ " + round(t,1) + " Seconds".
- lock steering to lookdirup(up:vector,ship:facing:topvector).
- until ship:verticalspeed > -1 and ImpactTime < 0.1 {
- printing().
- thrustcalc().
- }
- set sstatus to "Touchdown, T+ " + round(t,1) + " Seconds".
- set now1 to time:seconds.
- lock ti1 to time:seconds-now1.
- lock throttle to max(0.05, 0.5-ti1).
- print "Lngoff(M): " + lngoff.
- print "Latoff(M): " + latoff.
- until ship:status = "Landed" or ship:status = "Splashed" {
- printing().
- thrustcalc().
- }
- set t to t.
- unlock steering.
- set sstatus to "Landing confirmed, T+ " + round(t,1) + " Seconds".
- print sstatus.
- lock throttle to 0.05.
- wait 1.
- lock throttle to 0.
- print "Superheavy, landing confirmed, getting ready for post landing procedures, T+ " + round(t,1) + " Seconds".
- set now1 to time:seconds.
- lock ti to time:seconds - now1.
- until ti > 20 {
- printing().
- }
- set sstatus to "Shutting down all systems, unlocking controls, T+ " + round(t,1) + " Seconds".
- print sstatus.
- unlock steering.
- unlock throttle.
- sas off.
- rcs off.
- toggle brakes.
- }
- function abortofscript {
- clearscreen.
- print "Program aborted".
- wait 2.
- print 3/0.
- }
- function printing {
- clearscreen.
- set t to time:seconds - n.
- set myvel to ship:velocity:surface.
- set altit to ship:altitude - 37.
- set lngoff to (landingZone:lng - getImpact:lng)*10472.
- set latoff to (landingZone:lat - getImpact:lat)*10472.
- print "Welcome to Superheavy Landing Software V1.".
- print "Status: " + sstatus.
- print "T+ since start of script to landing: " + round(t,1) + " Seconds".
- print "Latoff(M): " + latoff.
- print "Lngoff(M): " + lngoff.
- if altit < 3000 and myvel:mag < 219 {
- print "Landing burn altitude: " + LBCalc(engnum) + " Meters".
- }
- print "Press 10 to abort current program".
- }
- function LBCalc {
- parameter engnum.
- set grav to constant:g * body:mass / body:radius^2.
- set maxAccel to (engnum*ship:partstagged("Vector0")[0]:maxthrust / ship:mass) - grav.
- set LBAlt to ship:verticalspeed^2 / (2 * maxAccel).
- return LBAlt.
- }
- function thrustcalc {
- set Thr to LBcalc(engnum) / altit.
- return Thr.
- }
- function errorVector {
- return getImpact():position - landingZone:position.
- }
- function Steer {
- local errorVector is errorVector().
- local velVector is -ship:velocity:surface.
- local result is velVector + errorVector*errorScalling.
- if vang(result, velVector) > aoa
- {
- set result to velVector:normalized + tan(aoa)*errorVector:normalized.
- }
- return lookdirup(result, ship:facing:topvector).
- }
- function getImpact {
- if addons:tr:hasimpact {
- return addons:tr:impactpos.
- } else {
- return ship:geoposition.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement