diff --git a/MechJeb2/MechJebModuleStagingController.cs b/MechJeb2/MechJebModuleStagingController.cs index b4a72dce6..a876793cf 100644 --- a/MechJeb2/MechJebModuleStagingController.cs +++ b/MechJeb2/MechJebModuleStagingController.cs @@ -268,8 +268,8 @@ public override void OnUpdate() HasFairing(vessel.currentStage - 1)) return; - //only release launch clamps if we're at nearly full thrust - if (vesselState.thrustCurrent / vesselState.thrustAvailable < clampAutoStageThrustPct && + //only release launch clamps if we're at nearly full thrust and no failed engines + if ((vesselState.thrustCurrent / vesselState.thrustAvailable < clampAutoStageThrustPct || AnyFailedEngines(allModuleEngines)) && InverseStageReleasesClamps(vessel.currentStage - 1)) return; } @@ -358,6 +358,18 @@ public bool InverseStageHasEngines(int inverseStage) return result; } + public bool AnyFailedEngines(List allEngines) + { + foreach (ModuleEngines engine in allEngines) + { + Part p = engine.part; + if (p.inverseStage >= vessel.currentStage && !p.IsDecoupledInStage(vessel.currentStage - 1) && engine.isEnabled && !engine.EngineIgnited && engine.allowShutdown) + return true; + } + + return false; + } + public void UpdateActiveModuleEngines(List allEngines) { activeModuleEngines.Clear();