Compare commits

..

No commits in common. "d44ed775df42f8ce4ff9074843e6d32825837085" and "82e456be709f97a8262051fa8934057f740c59b3" have entirely different histories.

View File

@ -108,8 +108,6 @@ function Launch {
// serves the specific needs of launch. // serves the specific needs of launch.
// It also makes automated launches possible before maneuver nodes are unlocked. // It also makes automated launches possible before maneuver nodes are unlocked.
// //
// TODO: Refactor code reuse between this function and ExecNode().
//
// prerequisites: // prerequisites:
// * Vessel is still behind the Apoapsis // * Vessel is still behind the Apoapsis
// * Apoapsis is at the target height // * Apoapsis is at the target height
@ -118,7 +116,7 @@ function insertionBurn {
// vector is prograde but only on the horizonal plane // vector is prograde but only on the horizonal plane
print "Adjusting heading.". print "Adjusting heading.".
local lock horizon is Vxcl(SHIP:UP:FOREVECTOR, SHIP:PROGRADE:FOREVECTOR). local horizon is Vxcl(SHIP:UP:FOREVECTOR, SHIP:PROGRADE:FOREVECTOR).
lock STEERING to LookDirUp(horizon, SHIP:FACING:TOPVECTOR). lock STEERING to LookDirUp(horizon, SHIP:FACING:TOPVECTOR).
// calculate the deltaV to get us to the target velocity, for calculating burn start time. // calculate the deltaV to get us to the target velocity, for calculating burn start time.
@ -126,25 +124,18 @@ function insertionBurn {
local Vc is sqrt(SHIP:BODY:MU/(PositionAt(SHIP, t) - SHIP:BODY:POSITION):MAG). local Vc is sqrt(SHIP:BODY:MU/(PositionAt(SHIP, t) - SHIP:BODY:POSITION):MAG).
local dV is Vc - VelocityAt(SHIP, t):ORBIT:MAG. local dV is Vc - VelocityAt(SHIP, t):ORBIT:MAG.
if WillStage(dV) {
when FlameOut() then {
print "Flameout detected. Staging.".
stage.
}
}
// calculate the total burn time (Tb) and the burn start time (Ts) // calculate the total burn time (Tb) and the burn start time (Ts)
local Tb is BurnTime(dV). local Tb is BurnTime(dV).
local Ts is TIME + SHIP:OBT:ETA:APOAPSIS - BurnTime(dV / 2). local Ts is TIME + SHIP:OBT:ETA:APOAPSIS - BurnTime(dV / 2).
// warp to the burn point // warp to the burn point
print "Waiting for burn window.". print "Waiting for burn window.".
wait until (VAng(SHIP:FACING:FOREVECTOR, STEERINGMANAGER:TARGET:FOREVECTOR) <= 0.5) OR (TIME > Ts). wait until (VAng(SHIP:FACING:FOREVECTOR, STEERINGMANAGER:TARGET:FOREVECTOR) <= 1) OR (TIME >= Ts).
if TIME < Ts - 2 { if TIME > Ts - 2 {
KUNIVERSE:TIMEWARP:WarpTo(Ts:SECONDS - 2). KUNIVERSE:TIMEWARP:WarpTo(Ts - 2).
} }
wait until SHIP:UNPACKED. wait until SHIP:UNPACKED.
wait until TIME > Ts. wait until TIME >= Ts.
// burn until periapsis is clear // burn until periapsis is clear
print "Circularizing orbit.". print "Circularizing orbit.".