Files
kOS/beegSana.ks
T

69 lines
1.7 KiB
Plaintext

run "defaults".
run "library/lib_orbits".
run "library/lib_vessel_utils".
run "poweredLanding".
declare function Reentry{
print "Re-entry.".
lock steering to heading(90, 70, 0).
ag1 on.
wait until altitude < 20000.
rcs off.
wait until (groundSpeed < 500 and altitude < 10000).
print "Flipping.".
rcs on.
lock steering to srfRetrograde.
}
declare function DeorbitBurn{
if periapsis < 0
{
return.
}
set kscPad to location_constants:kerbin:launchpad.
// wait until ag10.
sas off.
rcs on.
CreateDeorbit(kscPad, -300, 0, 0).
lock steering to nextNode:burnvector.
local lock align to vDot(ship:facing:vector, nextNode:burnvector).
wait until align > 0.95.
unlock steering.
sas on.
set sasMode to "MANEUVER".
wait 0.001.
warpTo(time:seconds + nextNode:eta - 15).
sas off.
local dur to CalculateBurnDuration(nextNode:burnvector:mag, GetIsp(), ship:mass, GetMaxMassFlow() * 1000).
print "duration " + dur.
lock steering to nextNode:burnvector.
wait until nextNode:eta < 1.
local end to time:seconds + dur.
lock throttle to 1.
wait until end <= time:seconds.
lock throttle to 0.
unlock throttle.
unlock steering.
remove nextNode.
}
DeorbitBurn().
wait until (altitude > 70000 and periapsis > 70000) or (verticalSpeed < -100 and periapsis < 0).
wait until (periapsis < 0 and throttle = 0).
print "Prep for re-entry".
print "Dont forget to Turn of MechJob Q Limit".
// set mj to addons:mj.
// set asc to mj:ascent.
// set asc:limitqaenabled to false.
CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Open Terminal").
lock steering to heading(90, 60, 0).
wait until (altitude < 70000).
Reentry().
brakes on.
Descent(200, 20).
Landing(0, -20).