From 983aaa68e6def7b3da6103322b97c4b9c5b58c1b Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Tue, 31 Dec 2024 13:46:32 +0100 Subject: [PATCH] Add night rider --- Projects/NightRaider/.vscode/settings.json | 3 + Projects/NightRaider/Class1.cs | 35 ++++ Projects/NightRaider/CykaRaider.csproj | 60 +++++++ Projects/NightRaider/CykaRaider.sln | 16 ++ .../CykaRaider.sln.DotSettings.user | 7 + .../NightRaider.sln.DotSettings.user | 7 + Projects/NightRaider/Patches.cs | 152 ++++++++++++++++++ .../NightRaider/Properties/AssemblyInfo.cs | 35 ++++ Projects/NightRaider/sync | 1 + 9 files changed, 316 insertions(+) create mode 100644 Projects/NightRaider/.vscode/settings.json create mode 100644 Projects/NightRaider/Class1.cs create mode 100644 Projects/NightRaider/CykaRaider.csproj create mode 100644 Projects/NightRaider/CykaRaider.sln create mode 100644 Projects/NightRaider/CykaRaider.sln.DotSettings.user create mode 100644 Projects/NightRaider/NightRaider.sln.DotSettings.user create mode 100644 Projects/NightRaider/Patches.cs create mode 100644 Projects/NightRaider/Properties/AssemblyInfo.cs create mode 100644 Projects/NightRaider/sync diff --git a/Projects/NightRaider/.vscode/settings.json b/Projects/NightRaider/.vscode/settings.json new file mode 100644 index 0000000..4ce0372 --- /dev/null +++ b/Projects/NightRaider/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "dotnet.preferCSharpExtension": true +} \ No newline at end of file diff --git a/Projects/NightRaider/Class1.cs b/Projects/NightRaider/Class1.cs new file mode 100644 index 0000000..90f1a20 --- /dev/null +++ b/Projects/NightRaider/Class1.cs @@ -0,0 +1,35 @@ +using System.Linq; +using BepInEx; +using BepInEx.Configuration; +using HarmonyLib; +using HarmonyLib.Tools; + +namespace CykaRaider { + [BepInPlugin(pluginGuid, pluginName, pluginVersion)] + public class Main : BaseUnityPlugin { + private const string pluginGuid = "CykaRaider"; + private const string pluginName = "CykaRaider"; + private const string pluginVersion = "1.0.0"; + + public static ConfigEntry lootTimeAdder; + public static ConfigEntry maxStackMultiplier; + + public static ConfigEntry debugMode; + + public void Awake() { + debugMode = Config.Bind("General", "Debug Mode", false, new ConfigDescription("Debug Mode")); + 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")); + + Logger.LogInfo("Cyka mod loaded"); + HarmonyFileLog.Enabled = true; + Harmony harmony = new Harmony(pluginGuid); + harmony.PatchAll(); + var originalMethods = harmony.GetPatchedMethods(); + Logger.LogInfo("Patched " + originalMethods.Count() + " methods"); + foreach (var method in originalMethods) { + Logger.LogInfo("Patched " + method.Name); + } + } + } +} diff --git a/Projects/NightRaider/CykaRaider.csproj b/Projects/NightRaider/CykaRaider.csproj new file mode 100644 index 0000000..dc7aff3 --- /dev/null +++ b/Projects/NightRaider/CykaRaider.csproj @@ -0,0 +1,60 @@ + + + + + C:/Games/NightRaider + $(GAME_DIR)/NightRaider_Data/Managed + $(GAME_DIR)/BepInEx + Debug + AnyCPU + {EE5EFB7F-A4DC-44F0-967B-F71ECA2D46AE} + Library + Properties + CykaRaider + CykaRaider + v4.8 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + $(GAME_BEPINEX)/core/0Harmony.dll + + + $(GAME_BEPINEX)/core/BepInEx.dll + + + $(GAME_MANAGED)/UnityEngine.dll + + + $(GAME_MANAGED)/UnityEngine.CoreModule.dll + + + $(GAME_MANAGED)/Assembly-CSharp.dll + + + + \ No newline at end of file diff --git a/Projects/NightRaider/CykaRaider.sln b/Projects/NightRaider/CykaRaider.sln new file mode 100644 index 0000000..ad37320 --- /dev/null +++ b/Projects/NightRaider/CykaRaider.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CykaRaider", "CykaRaider.csproj", "{EE5EFB7F-A4DC-44F0-967B-F71ECA2D46AE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EE5EFB7F-A4DC-44F0-967B-F71ECA2D46AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EE5EFB7F-A4DC-44F0-967B-F71ECA2D46AE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EE5EFB7F-A4DC-44F0-967B-F71ECA2D46AE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EE5EFB7F-A4DC-44F0-967B-F71ECA2D46AE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Projects/NightRaider/CykaRaider.sln.DotSettings.user b/Projects/NightRaider/CykaRaider.sln.DotSettings.user new file mode 100644 index 0000000..915d738 --- /dev/null +++ b/Projects/NightRaider/CykaRaider.sln.DotSettings.user @@ -0,0 +1,7 @@ + + False + C:\Users\Administrator\scoop\apps\dotnet-sdk\current\dotnet.exe + 16 + C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe + 1048576 + True \ No newline at end of file diff --git a/Projects/NightRaider/NightRaider.sln.DotSettings.user b/Projects/NightRaider/NightRaider.sln.DotSettings.user new file mode 100644 index 0000000..915d738 --- /dev/null +++ b/Projects/NightRaider/NightRaider.sln.DotSettings.user @@ -0,0 +1,7 @@ + + False + C:\Users\Administrator\scoop\apps\dotnet-sdk\current\dotnet.exe + 16 + C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe + 1048576 + True \ No newline at end of file diff --git a/Projects/NightRaider/Patches.cs b/Projects/NightRaider/Patches.cs new file mode 100644 index 0000000..a4379c1 --- /dev/null +++ b/Projects/NightRaider/Patches.cs @@ -0,0 +1,152 @@ +using System; +using HarmonyLib; + +namespace CykaRaider +{ + [HarmonyPatch] + public class Patches + { + [HarmonyPostfix] + [HarmonyPatch(typeof(GameManager), "FixedUpdate")] + static void lootTimeAdder(GameManager __instance) { + var trav = Traverse.Create(__instance); + var lootTime = trav.Field("lootTime").GetValue(); + if (lootTime > 0) { + if (Main.debugMode.Value) + Console.WriteLine("CykaRaider: FixedUpdate: Old lootTime {0}", lootTime); + lootTime += Main.lootTimeAdder.Value; + if (Main.debugMode.Value) + Console.WriteLine("CykaRaider: FixedUpdate: New lootTime {0}", lootTime); + trav.Field("lootTime").SetValue(lootTime); + } + } + + [HarmonyPostfix] + [HarmonyPatch(typeof(DataHub), "GetFixedData")] + static void xpMultiplier(DataHub __instance) { + for (int i = 0; i < __instance.itemDataDic.Count; i++) { + var itemData = __instance.itemDataDic[i]; + if (itemData.maxStack > 0) { + if (Main.debugMode.Value) + Console.WriteLine("CykaRaider: GetFixedData: Old maxStack {0}", itemData.maxStack); + itemData.maxStack = (int)(itemData.maxStack * Main.maxStackMultiplier.Value); + if (Main.debugMode.Value) + Console.WriteLine("CykaRaider: GetFixedData: New maxStack {0}", itemData.maxStack); + } + } + } + // [HarmonyPrefix] + // [HarmonyPatch(typeof(XRL.World.Parts.Experience), "HandleEvent")] + // static void xpMultiplier(ref AwardedXPEvent E) { + // if (Main.debugMode.Value) + // Console.WriteLine("CykaRaider: AwardedXPEvent: Old XP {0}", E.Amount); + // E.Amount = (int)(E.Amount * Main.xpMultiplier.Value); + // if (Main.debugMode.Value) + // Console.WriteLine("CykaRaider: AwardedXPEvent: New XP {0}", E.Amount); + // } + // + // [HarmonyPrefix] + // [HarmonyPatch(typeof(XRL.World.Parts.Leveler), "AddHitpoints")] + // static void hitpointsPerLevelMultiplier(StringBuilder sb, ref int HPGain) { + // if (Main.debugMode.Value) + // Console.WriteLine("CykaRaider: AddHitpoints: Old HP for level {0}", HPGain); + // if (HPGain == 0) + // HPGain = 1; + // HPGain = (int)(HPGain * Main.hitpointsPerLevelMultiplier.Value); + // if (Main.debugMode.Value) + // Console.WriteLine("CykaRaider: AddHitpoints: New HP for level {0}", HPGain); + // } + // + // [HarmonyPrefix] + // [HarmonyPatch(typeof(XRL.World.Parts.Leveler), "AddSkillPoints")] + // static void skillPointsPerLevelMultiplier(StringBuilder sb, ref int SPGain) { + // if (Main.debugMode.Value) + // Console.WriteLine("CykaRaider: AddSkillPoints: Old SP for level {0}", SPGain); + // if (SPGain == 0) + // SPGain = 1; + // SPGain = (int)(SPGain * Main.skillPointsPerLevelMultiplier.Value); + // if (Main.debugMode.Value) + // Console.WriteLine("CykaRaider: AddSkillPoints: New SP for level {0}", SPGain); + // } + // + // [HarmonyPrefix] + // [HarmonyPatch(typeof(XRL.World.Parts.Leveler), "AddMutationPoints")] + // static void mutationPointsPerLevelMultiplier(StringBuilder sb, ref int MPGain) { + // if (Main.debugMode.Value) + // Console.WriteLine("CykaRaider: AddMutationPoints: Old MP for level {0}", MPGain); + // if (MPGain == 0) + // MPGain = 1; + // MPGain = (int)(MPGain * Main.mutationPointsPerLevelMultiplier.Value); + // if (Main.debugMode.Value) + // Console.WriteLine("CykaRaider: AddMutationPoints: New MP for level {0}", MPGain); + // } + // + // [HarmonyPrefix] + // [HarmonyPatch(typeof(XRL.World.Parts.Leveler), "AddAttributePoints")] + // static void attributePointsPerLevelMultiplier(StringBuilder sb, ref int APGain) { + // if (Main.debugMode.Value) + // Console.WriteLine("CykaRaider: AddAttributePoints: Old AP for level {0}", APGain); + // if (APGain == 0) + // APGain = 1; + // APGain = (int)(APGain * Main.attributePointsPerLevelMultiplier.Value); + // if (Main.debugMode.Value) + // Console.WriteLine("CykaRaider: AddAttributePoints: New AP for level {0}", APGain); + // } + // + // [HarmonyPrefix] + // [HarmonyPatch(typeof(XRL.World.Parts.Leveler), "AddAttributeBonus")] + // static void attributeBonusPerLevelMultiplier(StringBuilder sb, ref int ABGain) { + // if (Main.debugMode.Value) + // Console.WriteLine("CykaRaider: AddAttributeBonus: Old AB for level {0}", ABGain); + // ABGain = (int)(ABGain * Main.attributeBonusPerLevelMultiplier.Value); + // if (ABGain == 0) + // ABGain = 2; + // if (Main.debugMode.Value) + // Console.WriteLine("CykaRaider: AddAttributeBonus: New AB for level {0}", ABGain); + // } + // + // [HarmonyPrefix] + // [HarmonyPatch(typeof(XRL.World.Parts.BitLocker), "AddBits")] + // static void disassemblyBonusMultiplier(ref string Bits) { + // if (Main.debugMode.Value) + // Console.WriteLine("CykaRaider: AddBits: Old {0}", Bits); + // + // 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("CykaRaider: AddBits: New {0}", Bits); + // } + // + // [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( + // "CykaRaider: 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); + // __result += Main.reverseEngineerChanceAdditional.Value; + // if (__result > 100) + // __result = 100; + // if (Main.debugMode.Value) + // Console.WriteLine("CykaRaider: GetFor: New Result {0}", __result); + // } + // } + } +} diff --git a/Projects/NightRaider/Properties/AssemblyInfo.cs b/Projects/NightRaider/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1cea293 --- /dev/null +++ b/Projects/NightRaider/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Regiments")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Regiments")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("DA9D274E-486F-4F82-84FF-CD9388CB0B09")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// 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.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/Projects/NightRaider/sync b/Projects/NightRaider/sync new file mode 100644 index 0000000..5eed2b3 --- /dev/null +++ b/Projects/NightRaider/sync @@ -0,0 +1 @@ +bin/Release/CykaRaider.dll,"C:/Games/NightRaider/BepInEx/plugins/CykaRaider.dll" \ No newline at end of file