Skip to content

Commit

Permalink
Fix infinite reliability on high gen parts
Browse files Browse the repository at this point in the history
  • Loading branch information
severedsolo committed Nov 19, 2018
1 parent 9d125c6 commit bd7bdc3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
5 changes: 4 additions & 1 deletion OhScrap/BaseFailureModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public void Initialise()
if (SYP.TimesRecovered == 0 || !UPFMUtils.instance.testedParts.Contains(SYP.ID)) chanceOfFailure = CalculateInitialFailureRate();
else chanceOfFailure = CalculateInitialFailureRate() * (SYP.TimesRecovered / (float)expectedLifetime);
if (chanceOfFailure < UPFMUtils.instance.minimumFailureChance) chanceOfFailure = UPFMUtils.instance.minimumFailureChance;
if (SYP.TimesRecovered > expectedLifetime) chanceOfFailure += 1 - (expectedLifetime / SYP.TimesRecovered);
//if the part has already failed turn the repair and highlight events on.
if (hasFailed)
{
Expand Down Expand Up @@ -154,7 +155,9 @@ public void Initialise()

private float CalculateInitialFailureRate()
{
return baseChanceOfFailure - (OhScrap.generation * (baseChanceOfFailure / 10));
int generation = OhScrap.generation;
if (generation > 10) generation = 10;
return baseChanceOfFailure+0.01f - (generation * (baseChanceOfFailure / 10));
}

//These methods all are overriden by the failure modules
Expand Down
10 changes: 5 additions & 5 deletions OhScrap/OhScrap.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Assembly-CSharp">
<HintPath>..\..\Kerbal Space Program\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\..\Kerbal Space Program\KSP_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
<HintPath>..\..\Kerbal Space Program\KSP_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\..\Kerbal Space Program\KSP_Data\Managed\UnityEngine.UI.dll</HintPath>
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
</Reference>
<Reference Include="ScrapYard">
<HintPath>..\..\Kerbal Space Program\GameData\ScrapYard\ScrapYard.dll</HintPath>
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program - ModDev\GameData\ScrapYard\ScrapYard.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
34 changes: 17 additions & 17 deletions OhScrap/obj/Release/OhScrap.csproj.FileListAbsolute.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,6 @@ C:/Users/evilp/source/repos/OhScrap/OhScrap/bin/Release/TDx.TDxInput.dll
C:/Users/evilp/source/repos/OhScrap/OhScrap/bin/Release/RedShellSDK.dll
C:/Users/evilp/source/repos/OhScrap/OhScrap/obj/Release/OhScrap.csproj.CopyComplete
C:/Users/evilp/source/repos/OhScrap/OhScrap/obj/Release/OhScrap.csprojAssemblyReference.cache
D:/OneDrive/Documents/Github/OhScrap/OhScrap/bin/Release/OhScrap.dll
D:/OneDrive/Documents/Github/OhScrap/OhScrap/bin/Release/OhScrap.pdb
D:/OneDrive/Documents/Github/OhScrap/OhScrap/bin/Release/Assembly-CSharp-firstpass.dll
D:/OneDrive/Documents/Github/OhScrap/OhScrap/bin/Release/Assembly-CSharp.dll
D:/OneDrive/Documents/Github/OhScrap/OhScrap/bin/Release/ScrapYard.dll
D:/OneDrive/Documents/Github/OhScrap/OhScrap/bin/Release/UnityEngine.dll
D:/OneDrive/Documents/Github/OhScrap/OhScrap/bin/Release/UnityEngine.UI.dll
D:/OneDrive/Documents/Github/OhScrap/OhScrap/bin/Release/KSPTrackIR.dll
D:/OneDrive/Documents/Github/OhScrap/OhScrap/bin/Release/KSPAssets.dll
D:/OneDrive/Documents/Github/OhScrap/OhScrap/bin/Release/Mono.Cecil.dll
D:/OneDrive/Documents/Github/OhScrap/OhScrap/bin/Release/Ionic.Zip.dll
D:/OneDrive/Documents/Github/OhScrap/OhScrap/bin/Release/TDx.TDxInput.dll
D:/OneDrive/Documents/Github/OhScrap/OhScrap/obj/Release/OhScrap.csprojAssemblyReference.cache
D:/OneDrive/Documents/Github/OhScrap/OhScrap/obj/Release/OhScrap.csproj.CoreCompileInputs.cache
D:/OneDrive/Documents/Github/OhScrap/OhScrap/obj/Release/OhScrap.csproj.CopyComplete
D:/OneDrive/Documents/Github/OhScrap/OhScrap/obj/Release/OhScrap.dll
D:/OneDrive/Documents/Github/OhScrap/OhScrap/obj/Release/OhScrap.pdb
/home/martin/.steam/steam/steamapps/common/OhScrap-master/OhScrap/bin/Release/OhScrap.dll
/home/martin/.steam/steam/steamapps/common/OhScrap-master/OhScrap/bin/Release/OhScrap.pdb
/home/martin/.steam/steam/steamapps/common/OhScrap-master/OhScrap/bin/Release/Assembly-CSharp-firstpass.dll
Expand All @@ -50,3 +33,20 @@ D:/OneDrive/Documents/Github/OhScrap/OhScrap/obj/Release/OhScrap.pdb
/home/martin/.steam/steam/steamapps/common/OhScrap-master/OhScrap/obj/Release/OhScrap.dll
/home/martin/.steam/steam/steamapps/common/OhScrap-master/OhScrap/obj/Release/OhScrap.pdb
/home/martin/.steam/steam/steamapps/common/OhScrap-master/OhScrap/obj/Release/OhScrap.csprojAssemblyReference.cache
D:\OneDrive\Documents\Github\OhScrap\OhScrap\obj\Release\OhScrap.csprojAssemblyReference.cache
D:\OneDrive\Documents\Github\OhScrap\OhScrap\obj\Release\OhScrap.csproj.CoreCompileInputs.cache
D:\OneDrive\Documents\Github\OhScrap\OhScrap\bin\Release\OhScrap.dll
D:\OneDrive\Documents\Github\OhScrap\OhScrap\bin\Release\OhScrap.pdb
D:\OneDrive\Documents\Github\OhScrap\OhScrap\bin\Release\Assembly-CSharp-firstpass.dll
D:\OneDrive\Documents\Github\OhScrap\OhScrap\bin\Release\Assembly-CSharp.dll
D:\OneDrive\Documents\Github\OhScrap\OhScrap\bin\Release\ScrapYard.dll
D:\OneDrive\Documents\Github\OhScrap\OhScrap\bin\Release\UnityEngine.dll
D:\OneDrive\Documents\Github\OhScrap\OhScrap\bin\Release\UnityEngine.UI.dll
D:\OneDrive\Documents\Github\OhScrap\OhScrap\bin\Release\KSPTrackIR.dll
D:\OneDrive\Documents\Github\OhScrap\OhScrap\bin\Release\KSPAssets.dll
D:\OneDrive\Documents\Github\OhScrap\OhScrap\bin\Release\Mono.Cecil.dll
D:\OneDrive\Documents\Github\OhScrap\OhScrap\bin\Release\Ionic.Zip.dll
D:\OneDrive\Documents\Github\OhScrap\OhScrap\bin\Release\TDx.TDxInput.dll
D:\OneDrive\Documents\Github\OhScrap\OhScrap\obj\Release\OhScrap.csproj.CopyComplete
D:\OneDrive\Documents\Github\OhScrap\OhScrap\obj\Release\OhScrap.dll
D:\OneDrive\Documents\Github\OhScrap\OhScrap\obj\Release\OhScrap.pdb

0 comments on commit bd7bdc3

Please sign in to comment.