//-126 function DeOrbit{ parameter burnLng, deltaV. lock pos to SHIP:geoposition. lock curLng to pos:lng. DECLARE LOCAL tgtLng IS burnLng - 5. if curLng > burnLng or curLng < tgtLng { SET WARPMODE TO "RAILS". SET WARP TO 3. print "warping to " + tgtLng. WAIT UNTIL curLng > tgtLng and curLng < burnLng. SET WARP TO 0. print "arived at dst " + tgtLng. print "burn at " + burnLng. } print "currently at" + curLng. BRAKES ON. RCS ON. LOCK steering to retrograde. wait until curLng >= burnLng. } function CalculateBurnDuration{ parameter dv. declare local isp is GetIsp(). declare local finalMass is mass * exp(-dv / (isp * constant:g0)). declare local twr is ship:maxThrust / (((mass + finalMass)/2) * constant:g0). local t is dv / (twr * constant.g0). return t. } function GetIsp{ LIST ENGINES IN allEngines. declare local totalThrust is ship:maxThrust. local sum is 0. local weights is 0. for eng in allEngines{ if eng:IGNITION and not eng:flameout{ local w is eng:AVAILABLETHRUST / totalThrust. local ispW is eng:isp * w. set sum to sum + ispW. set weights to weights + w. } } return sum / weights. } // DeOrbit(-126, 250). print CalculateBurnDuration(250).