diff --git a/Projects/NightRaider/Class1.cs b/Projects/NightRaider/Class1.cs index 270ad01..92e9d93 100644 --- a/Projects/NightRaider/Class1.cs +++ b/Projects/NightRaider/Class1.cs @@ -14,6 +14,7 @@ namespace CykaRaider { public static ConfigEntry lootTimeAdder; public static ConfigEntry maxStackMultiplier; public static ConfigEntry autoLoot; + public static ConfigEntry upgradePriceMultiplier; public static ConfigEntry debugMode; @@ -22,6 +23,7 @@ namespace CykaRaider { lootTimeAdder = Config.Bind("General", "Loot Time Adder", 0, new ConfigDescription("Loot Time Adder")); maxStackMultiplier = Config.Bind("General", "Max Stack Multiplier", 1f, new ConfigDescription("Max Stack Multiplier")); autoLoot = Config.Bind("General", "Auto Loot", false, new ConfigDescription("Auto Loot")); + upgradePriceMultiplier = Config.Bind("General", "Upgrade Price Multiplier", 1f, new ConfigDescription("Upgrade Price Multiplier")); Logger.LogInfo("Cyka mod loaded"); HarmonyFileLog.Enabled = true; diff --git a/Projects/NightRaider/Patches.cs b/Projects/NightRaider/Patches.cs index 4b93ca2..fb15108 100644 --- a/Projects/NightRaider/Patches.cs +++ b/Projects/NightRaider/Patches.cs @@ -1,5 +1,7 @@ -using System; -using HarmonyLib; +using System; + using System.Collections.Generic; + using System.Reflection.Emit; + using HarmonyLib; using UnityEngine.UI; namespace CykaRaider @@ -52,6 +54,44 @@ namespace CykaRaider Console.WriteLine("CykaRaider: autoLoot: Bag closed"); } } + + [HarmonyPatch(typeof(NPCControl), "UpgradeSkill")] + public static class upgradePriceMultiplier { + static IEnumerable Transpiler(IEnumerable instructions) { + if (Main.debugMode.Value) + Console.WriteLine("CykaRaider: upgradePriceMultiplier: Transpiler"); + var codes = new List(instructions); + for (int i = 0; i < codes.Count; i++) { + if (codes[i].opcode == OpCodes.Ldc_I4 && ((int)codes[i].operand == 125000 || (int)codes[i].operand == -125000)) { + if (Main.debugMode.Value) + Console.WriteLine("CykaRaider: upgradePriceMultiplier: Old price {0}", codes[i].operand); + codes[i].operand = (int)((float)codes[i].operand * Main.upgradePriceMultiplier.Value); + if (Main.debugMode.Value) + Console.WriteLine("CykaRaider: upgradePriceMultiplier: New price {0}", codes[i].operand); + } + } + return codes; + } + } + + [HarmonyPatch(typeof(NPCControl), "RefreshSkill")] + public static class refreshSkillPriceMultiplier { + static IEnumerable Transpiler(IEnumerable instructions) { + if (Main.debugMode.Value) + Console.WriteLine("CykaRaider: refreshSkillPriceMultiplier: Transpiler"); + var codes = new List(instructions); + for (int i = 0; i < codes.Count; i++) { + if (codes[i].opcode == OpCodes.Ldc_I4 && ((int)codes[i].operand == 125000 || (int)codes[i].operand == -125000)) { + if (Main.debugMode.Value) + Console.WriteLine("CykaRaider: refreshSkillPriceMultiplier: Old price {0}", codes[i].operand); + codes[i].operand = (int)((float)codes[i].operand * Main.upgradePriceMultiplier.Value); + if (Main.debugMode.Value) + Console.WriteLine("CykaRaider: refreshSkillPriceMultiplier: New price {0}", codes[i].operand); + } + } + return codes; + } + } // [HarmonyPrefix] // [HarmonyPatch(typeof(XRL.World.Parts.Experience), "HandleEvent")] // static void xpMultiplier(ref AwardedXPEvent E) {