protected override void FailPart() { chute = part.FindModuleImplementing <ModuleParachute>(); if (chute == null) { return; } if (chute.vessel != FlightGlobals.ActiveVessel) { return; } if (chute.deploymentState == ModuleParachute.deploymentStates.SEMIDEPLOYED || chute.deploymentState == ModuleParachute.deploymentStates.DEPLOYED) { chute.CutParachute(); } if (UPFM.highlight) { UPFM.SetFailedHighlight(); } if (message) { return; } message = true; postMessage = true; ScreenMessages.PostScreenMessage("Parachute Failure!"); Debug.Log("[UPFM]: " + SYP.ID + " parachute has failed"); }
protected override void FailPart() { rcs = part.FindModuleImplementing <ModuleRCS>(); if (rcs == null) { return; } if (rcs.vessel != FlightGlobals.ActiveVessel) { return; } rcs.rcsEnabled = false; if (UPFM.highlight) { UPFM.SetFailedHighlight(); } if (message) { return; } message = true; postMessage = true; ScreenMessages.PostScreenMessage("RCS Failure!"); Debug.Log("[UPFM]: " + SYP.ID + " RCS has failed"); }
protected override void FailPart() { if (leaking == null) { if (leakingName != "None") { leaking = part.Resources[leakingName]; failureType = leaking.resourceName + " leak"; return; } List <PartResource> potentialLeakCache = part.Resources.ToList(); List <PartResource> potentialLeaks = part.Resources.ToList(); if (potentialLeaks.Count == 0) { return; } ConfigNode[] blackListNode = GameDatabase.Instance.GetConfigNodes("OHSCRAP_RESOURCE_BLACKLIST"); if (blackListNode.Count() > 0) { for (int i = 0; i < blackListNode.Count(); i++) { ConfigNode node = blackListNode.ElementAt(i); #if DEBUG Debug.Log("[UPFM]: Checking " + node.GetValue("name") + " for blacklist"); #endif for (int p = 0; p < potentialLeakCache.Count(); p++) { PartResource pr = potentialLeakCache.ElementAt(p); if (pr.resourceName == node.GetValue("name")) { potentialLeaks.Remove(pr); } } } if (potentialLeaks.Count == 0) { leaking = null; leakingName = "None"; hasFailed = false; willFail = false; postMessage = false; Debug.Log("[UPFM]: " + SYP.ID + "has no resources that could fail. Failure aborted"); return; } } leaking = potentialLeaks.ElementAt(Randomiser.instance.RandomInteger(0, potentialLeaks.Count())); leakingName = leaking.resourceName; Debug.Log("[UPFM]: " + leaking.resourceName + " started leaking from " + SYP.ID); ScreenMessages.PostScreenMessage("A tank of " + leaking.resourceName + " started to leak!"); failureType = leaking.resourceName + " leak"; } leaking.amount = leaking.amount * 0.999f; if (UPFM.highlight) { UPFM.SetFailedHighlight(); } }
protected override void FailPart() { panel = part.FindModuleImplementing <ModuleDeployableSolarPanel>(); if (panel == null) { return; } if (!panel.isTracking) { return; } if (!postMessage && !trackingSet) { if (Randomiser.instance.NextDouble() < 0.5) { trackingFailure = true; } else { trackingFailure = false; } trackingSet = true; } if (panel.isTracking && panel.retractable && panel.deployState == ModuleDeployablePart.DeployState.EXTENDED && !trackingFailure) { panel.retractable = false; originallyRetractable = true; if (!postMessage) { failureType = "retraction error"; ScreenMessages.PostScreenMessage(part.name + " retraction mechanism jammed"); Debug.Log("[UPFM]: " + SYP.ID + " retraction mechanism has jammed"); postMessage = true; } if (UPFM.highlight) { UPFM.SetFailedHighlight(); } } else if (panel.isTracking && panel.deployState == ModuleDeployablePart.DeployState.EXTENDED && !originallyRetractable) { panel.isTracking = false; if (!postMessage) { failureType = "sun tracking error"; ScreenMessages.PostScreenMessage(part.name + " sun tracking mechanism jammed"); Debug.Log("[UPFM]: " + SYP.ID + " sun tracking mechanism has jammed"); postMessage = true; } if (UPFM.highlight) { UPFM.SetFailedHighlight(); } } }
protected override void FailPart() { battery = part.Resources["ElectricCharge"]; battery.amount = 0; battery.flowState = false; if (UPFM.highlight) { UPFM.SetFailedHighlight(); } if (message) { return; } ScreenMessages.PostScreenMessage("Battery short circuited!"); Debug.Log("[UPFM]: " + SYP.ID + " has suffered a short circuit failure"); message = true; }
protected override void FailPart() { rw = part.FindModuleImplementing <ModuleReactionWheel>(); rw.isEnabled = false; rw.wheelState = ModuleReactionWheel.WheelState.Broken; if (UPFM.highlight) { UPFM.SetFailedHighlight(); } if (message) { return; } message = true; if (rw.wheelState != ModuleReactionWheel.WheelState.Broken) { Debug.Log("[UPFM]: " + SYP.ID + "'s reaction wheels have failed"); } ScreenMessages.PostScreenMessage("A reaction wheel has failed"); }
protected override void FailPart() { if (part.vessel.atmDensity == 0) { return; } controlSurface = part.FindModuleImplementing <ModuleControlSurface>(); controlSurface.ignorePitch = true; controlSurface.ignoreRoll = true; controlSurface.ignoreYaw = true; if (UPFM.highlight) { UPFM.SetFailedHighlight(); } if (message) { return; } ScreenMessages.PostScreenMessage("Control Surface Failure!"); Debug.Log("[UPFM]: " + SYP.ID + " has suffered a control surface failure"); message = true; }
protected override void FailPart() { if (part.Resources.Contains("SolidFuel")) { return; } engine = part.FindModuleImplementing <ModuleEngines>(); if (engine == null) { engineFX = part.FindModuleImplementing <ModuleEnginesFX>(); } gimbal = part.FindModuleImplementing <ModuleGimbal>(); if (engine != null) { if (engine.currentThrottle == 0) { fuelLineCounter = 10; return; } } else { if (engine.currentThrottle == 0) { fuelLineCounter = 10; return; } } if (UPFM.highlight) { UPFM.SetFailedHighlight(); } if (failureType == "none") { int i = Randomiser.instance.RandomInteger(1, 5); switch (i) { case 1: failureType = "Fuel Flow Failure"; Debug.Log("[UPFM]: attempted to perform Fuel Flow Failure on " + SYP.ID); break; case 2: failureType = "Fuel Line Leak"; Debug.Log("[UPFM]: attempted to perform Fuel Line Leak on " + SYP.ID); InvokeRepeating("LeakFuel", 2.0f, 2.0f); break; case 3: failureType = "Underthrust"; Debug.Log("[UPFM]: attempted to perform Underthrust on " + SYP.ID); break; case 4: if (gimbal == null) { return; } failureType = "Gimbal Failure"; Debug.Log("[UPFM]: attempted to lock gimbal on" + SYP.ID); break; default: failureType = "none"; Debug.Log("[UPFM]: " + SYP.ID + " decided not to fail after all"); break; } ScreenMessages.PostScreenMessage(failureType + " detected on " + part.name); postMessage = true; return; } switch (failureType) { case "Fuel Flow Failure": engine.Shutdown(); break; case "Fuel Line Leak": if (timeBetweenFailureEvents > Planetarium.GetUniversalTime()) { break; } if (fuelLineCounter < 0) { part.explode(); } else { fuelLineCounter--; } timeBetweenFailureEvents = Planetarium.GetUniversalTime() + 10; break; case "Underthrust": if (timeBetweenFailureEvents <= Planetarium.GetUniversalTime()) { if (engine != null) { engine.thrustPercentage = engine.thrustPercentage * 0.9f; } else { engineFX.thrustPercentage = engine.thrustPercentage * 0.9f; } timeBetweenFailureEvents = Planetarium.GetUniversalTime() + Randomiser.instance.RandomInteger(10, 30); if (engine != null) { staticThrust = engine.thrustPercentage; } else { staticThrust = engineFX.thrustPercentage; } } if (engine != null) { engine.thrustPercentage = staticThrust; } else { engineFX.thrustPercentage = staticThrust; } break; case "Gimbal Failure": gimbal.gimbalLock = true; break; default: return; } }