Skip to content

Commit

Permalink
init and use IncapacitatedDeathChance and LethalDeathChance company s…
Browse files Browse the repository at this point in the history
…tats for FinalizeKilledMechwarriors
  • Loading branch information
ajkroeg committed May 29, 2022
1 parent 95cace2 commit 59aaf23
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 5 deletions.
12 changes: 9 additions & 3 deletions Patches/InjuryPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,16 @@ public static bool Prefix(Contract __instance)

else
{

float num = pilot.LethalInjuries
? sim.Constants.Pilot.LethalDeathChance
var lethalDeathChance = sim.CompanyStats.ContainsStatistic("LethalDeathChance")
? sim.CompanyStats.GetValue<float>("LethalDeathChance")
: sim.Constants.Pilot.LethalDeathChance;
var incapacitatedDeathChance = sim.CompanyStats.ContainsStatistic("IncapacitatedDeathChance")
? sim.CompanyStats.GetValue<float>("IncapacitatedDeathChance")
: sim.Constants.Pilot.IncapacitatedDeathChance;

float num = pilot.LethalInjuries
? lethalDeathChance
: incapacitatedDeathChance;
num = Mathf.Max(0f, num - sim.Constants.Pilot.GutsDeathReduction * (float) pilot.Guts);
float num2 = sim.NetworkRandom.Float();
string s = string.Format(
Expand Down
19 changes: 19 additions & 0 deletions Patches/SaveAndStatePatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ public static void Postfix(SGCharacterCreationCareerBackgroundSelectionPanel __i
ModInit.modLog?.Info?.Write($"{p.Callsign} missing, added to pilotInjuriesMap with iGUID {pKey}");
}
}

//init deathchance stats for hospital upgrades:
if (!sim.CompanyStats.ContainsStatistic("LethalDeathChance"))
{
sim.CompanyStats.AddStatistic("LethalDeathChance", sim.Constants.Pilot.LethalDeathChance);
}
if (!sim.CompanyStats.ContainsStatistic("IncapacitatedDeathChance"))
{
sim.CompanyStats.AddStatistic("IncapacitatedDeathChance", sim.Constants.Pilot.IncapacitatedDeathChance);
}
}
}

Expand Down Expand Up @@ -348,6 +358,15 @@ public static void Postfix(SimGameState __instance)
ModInit.modLog?.Info?.Write(
$"Pilot with pilotID {key} not in roster, removing from pilotInjuriesMap");
}

if (!sim.CompanyStats.ContainsStatistic("LethalDeathChance"))
{
sim.CompanyStats.AddStatistic("LethalDeathChance", sim.Constants.Pilot.LethalDeathChance);
}
if (!sim.CompanyStats.ContainsStatistic("IncapacitatedDeathChance"))
{
sim.CompanyStats.AddStatistic("IncapacitatedDeathChance", sim.Constants.Pilot.IncapacitatedDeathChance);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.4.3")]
[assembly: AssemblyFileVersion("1.0.4.3")]
[assembly: AssemblyVersion("1.0.4.4")]
[assembly: AssemblyFileVersion("1.0.4.4")]
Binary file modified bin/Debug/TisButAScratch.dll
Binary file not shown.
Binary file modified bin/Debug/TisButAScratch.pdb
Binary file not shown.
Binary file modified obj/Debug/TisButAScratch.dll
Binary file not shown.
Binary file modified obj/Debug/TisButAScratch.pdb
Binary file not shown.

0 comments on commit 59aaf23

Please sign in to comment.