Skip to content

Commit

Permalink
Fix Space Engines Safety ratings being 0 and simultaneously unable to…
Browse files Browse the repository at this point in the history
… fail. Fix Divide by 0 in VAB
  • Loading branch information
severedsolo committed Feb 1, 2019
1 parent 6929a43 commit 6f23a66
Show file tree
Hide file tree
Showing 5 changed files with 5,658 additions and 4,113 deletions.
4 changes: 2 additions & 2 deletions OhScrap/BaseFailureModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void Start()

private void OnLaunch(EventReport data)
{
if (FlightGlobals.ActiveVessel.speed > 8 || isSRB) return;
if (FlightGlobals.ActiveVessel.speed > 8) return;
ActivateFailures();
}

Expand Down Expand Up @@ -122,7 +122,7 @@ private void ActivateFailures()
launched = true;
Initialise();
UPFMUtils.instance.testedParts.Add(SYP.ID);
if (HighLogic.LoadedScene == GameScenes.FLIGHT && FailureAllowed() && isSRB && UPFMUtils.instance._randomiser.NextDouble() < chanceOfFailure) InvokeRepeating("FailPart", 0.01f, 0.01f);
if (HighLogic.LoadedScene == GameScenes.FLIGHT && isSRB && FailureAllowed() && UPFMUtils.instance._randomiser.NextDouble() < chanceOfFailure) InvokeRepeating("FailPart", 0.01f, 0.01f);
}

// This is where we "initialise" the failure module and get everything ready
Expand Down
4 changes: 2 additions & 2 deletions OhScrap/EngineFailureModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class EngineFailureModule : BaseFailureModule
[KSPField(isPersistant = true, guiActive = false)]
float originalThrust;
[KSPField(isPersistant = true, guiActive = false)]
int spaceEngineExpectedLifetime;
int spaceEngineExpectedLifetime = 3;
[KSPField(isPersistant = true, guiActive = false)]
float spaceEngineBaseChanceOfFailure;
float spaceEngineBaseChanceOfFailure = 0.1f;


protected override void Overrides()
Expand Down
2 changes: 1 addition & 1 deletion OhScrap/UPFMUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ private void onEditorShipModified(ShipConstruct shipConstruct)
vesselSafetyRating += bfm.safetyRating;
bfmCount++;
}
vesselSafetyRating = vesselSafetyRating / bfmCount;
}
vesselSafetyRating = vesselSafetyRating / bfmCount;
}
//This is mostly for use in the flight scene, will only run once assuming everything goes ok.
void Update()
Expand Down
Loading

0 comments on commit 6f23a66

Please sign in to comment.