Skip to content

Commit

Permalink
fix injury calcs to not increase if "get injury cost" is < original cost
Browse files Browse the repository at this point in the history
  • Loading branch information
ajkroeg committed May 22, 2022
1 parent 7d999fc commit 95cace2
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions Patches/InjuryPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using Harmony;
using BattleTech;
using TisButAScratch.Framework;
Expand Down Expand Up @@ -516,7 +517,21 @@ public static bool Prefix(Contract __instance)
}
}

[HarmonyPatch(typeof(SimGameState), "RefreshInjuries")]
public static class SimGameState_RefreshInjuries
{
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> codes = instructions.ToList();

// only update injury cost of new cost is greater than old cost
int index = codes.FindIndex(c => c == codes.First(x => x.opcode == OpCodes.Beq));

codes[index].opcode = OpCodes.Bge;

return codes.AsEnumerable();
}
}

[HarmonyPatch(typeof(SimGameState))]
[HarmonyPatch("GetInjuryCost", typeof(Pilot))]
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.2")]
[assembly: AssemblyFileVersion("1.0.4.2")]
[assembly: AssemblyVersion("1.0.4.3")]
[assembly: AssemblyFileVersion("1.0.4.3")]
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 95cace2

Please sign in to comment.