From 80173da3b0d655a94616c4b0823bab1e8a6c0d76 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Tue, 10 Dec 2024 11:30:57 +0100 Subject: [PATCH] Implement reverse engineer chance multiplier --- Projects/CykaOfQud/Class1.cs | 4 ++++ Projects/CykaOfQud/Patches.cs | 32 ++++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Projects/CykaOfQud/Class1.cs b/Projects/CykaOfQud/Class1.cs index ded81ca..13d8534 100644 --- a/Projects/CykaOfQud/Class1.cs +++ b/Projects/CykaOfQud/Class1.cs @@ -23,6 +23,8 @@ namespace CykaOfQud { public static ConfigEntry attributeBonusPerLevelMultiplier; public static ConfigEntry disassemblyBonusMultiplier; + public static ConfigEntry reverseEngineerChanceMultiplier; + public static ConfigEntry debugMode; public void Awake() { @@ -39,6 +41,8 @@ namespace CykaOfQud { new ConfigDescription("Attribute Bonus Per Level Multiplier")); disassemblyBonusMultiplier = Config.Bind("General", "Disassembly Bonus Multiplier", 1f, new ConfigDescription("Disassembly Bonus Multiplier")); + reverseEngineerChanceMultiplier = Config.Bind("General", "Reverse Engineer Chance Multiplier", 1f, + new ConfigDescription("Reverse Engineer Chance Multiplier")); debugMode = Config.Bind("General", "Debug Mode", false, new ConfigDescription("Debug Mode")); diff --git a/Projects/CykaOfQud/Patches.cs b/Projects/CykaOfQud/Patches.cs index db65189..26c78db 100644 --- a/Projects/CykaOfQud/Patches.cs +++ b/Projects/CykaOfQud/Patches.cs @@ -84,24 +84,40 @@ namespace CykaOfIndustry { if (Main.debugMode.Value) Console.WriteLine("CykaOfQud: AddBits: Old {0}", Bits); - StringBuilder output = new StringBuilder(); + StringBuilder output = new StringBuilder(); foreach (char c in Bits) { output.Append(new string(c, (int)Math.Ceiling(Main.disassemblyBonusMultiplier.Value))); } + Bits = output.ToString(); if (Main.debugMode.Value) Console.WriteLine("CykaOfQud: AddBits: New {0}", Bits); } - [HarmonyPrefix] - [HarmonyPatch(typeof(XRL.World.Parts.BitLocker), "AddAllBits")] - static void addAllBits(ref int num) { + [HarmonyPostfix] + [HarmonyPatch(typeof(GetTinkeringBonusEvent), nameof(GetTinkeringBonusEvent.GetFor), + new Type[] { + typeof(GameObject), typeof(GameObject), typeof(string), typeof(int), typeof(int), typeof(int), + typeof(bool), typeof(bool), typeof(bool), typeof(bool) + }, + new ArgumentType[] { + ArgumentType.Normal, ArgumentType.Normal, ArgumentType.Normal, ArgumentType.Normal, ArgumentType.Normal, + ArgumentType.Out, ArgumentType.Out, ArgumentType.Out, ArgumentType.Normal, ArgumentType.Normal + })] + static void reverseEngineerChanceMultiplier(GameObject Actor, GameObject Item, string Type, int BaseRating, + int Bonus, ref int SecondaryBonus, ref bool Interrupt, ref bool PsychometryApplied, bool Interruptable, + bool ForSifrah, ref int __result) { if (Main.debugMode.Value) - Console.WriteLine("CykaOfQud: AddAllBits: Old {0}", num); - num = (int)(num * Main.disassemblyBonusMultiplier.Value); + Console.WriteLine( + "CykaOfQud: GetFor: Actor {0} Item {1} Type {2} BaseRating {3} Bonus {4} SecondaryBonus {5} Interrupt {6} PsychometryApplied {7} Interruptable {8} ForSifrah {9} Result {10}", + Actor.ID, Item.ID, Type, BaseRating, Bonus, SecondaryBonus, Interrupt, PsychometryApplied, + Interruptable, ForSifrah, __result); + __result = (int)(__result * Main.reverseEngineerChanceMultiplier.Value); + if (__result > 100) + __result = 100; if (Main.debugMode.Value) - Console.WriteLine("CykaOfQud: AddAllBits: New {0}", num); + Console.WriteLine("CykaOfQud: GetFor: New Result {0}", __result); } } -} +} \ No newline at end of file