Update regiments

This commit is contained in:
2024-07-23 22:19:44 +02:00
parent 0dc6ac592e
commit 0c92e0e1b7
4 changed files with 247 additions and 247 deletions

View File

@@ -1,167 +1,167 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection.Emit; using System.Reflection.Emit;
using birdseye; using birdseye;
using birdseye.Regiments; using birdseye.Regiments;
using birdseye.Regiments.Commanders; using birdseye.Regiments.Commanders;
using birdseye.Regiments.GameModes; using birdseye.Regiments.GameModes;
using birdseye.Regiments.Menu.GUI; using birdseye.Regiments.Menu.GUI;
using birdseye.Regiments.Platoons; using birdseye.Regiments.Platoons;
using birdseye.Regiments.Platoons.Modules; using birdseye.Regiments.Platoons.Modules;
using birdseye.Regiments.Units.WeaponSystems; using birdseye.Regiments.Units.WeaponSystems;
using birdseye.Regiments.Zones; using birdseye.Regiments.Zones;
using HarmonyLib; using HarmonyLib;
using UnityEngine; using UnityEngine;
// Patch maxSupPoints in PlatoonSupplyModule // Patch maxSupPoints in PlatoonSupplyModule
// Patch Operational Authority point gain // Patch Operational Authority point gain
namespace Regiments { namespace Regiments {
[HarmonyPatch] [HarmonyPatch]
public class Patches { public class Patches {
private static float baseHqValue = 0; private static float baseHqValue = 0;
private static float baseSupplyValue = 0; private static float baseSupplyValue = 0;
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(SupplyPointsController), "AddSPs")] [HarmonyPatch(typeof(SupplyPointsController), "AddSPs")]
static void SpMultiplier(ref float value) { static void SpMultiplier(ref float value) {
if (value == 0) { if (value == 0) {
return; return;
} }
float multiplier = Main.SPMultiplier.Value; float multiplier = Main.SPMultiplier.Value;
// Console.WriteLine("Multiplying SP {0} by {1}", value, multiplier); // Console.WriteLine("Multiplying SP {0} by {1}", value, multiplier);
value *= multiplier; value *= multiplier;
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(TacAidPointsController), "AddTP")] [HarmonyPatch(typeof(TacAidPointsController), "AddTP")]
static void TpMultiplier(ref float val) { static void TpMultiplier(ref float val) {
if (val == 0) { if (val == 0) {
return; return;
} }
float multiplier = Main.TPMultiplier.Value; float multiplier = Main.TPMultiplier.Value;
// Console.WriteLine("Multiplying TP {0} by {1}", val, multiplier); // Console.WriteLine("Multiplying TP {0} by {1}", val, multiplier);
val *= multiplier; val *= multiplier;
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(MapZoneFactory), "MakeRefitZone")] [HarmonyPatch(typeof(MapZoneFactory), "MakeRefitZone")]
static void SupplyAoeMultiplier(ref eSides side, ref Vector3 position, ref float size) { static void SupplyAoeMultiplier(ref eSides side, ref Vector3 position, ref float size) {
float multiplier = Main.SupplyAOEMultiplier.Value; float multiplier = Main.SupplyAOEMultiplier.Value;
Console.WriteLine("Multiplying supply aoe {0} by {1}", size, multiplier); Console.WriteLine("Multiplying supply aoe {0} by {1}", size, multiplier);
size *= multiplier; size *= multiplier;
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(PlatoonHQVisuals), "Start")] [HarmonyPatch(typeof(PlatoonHQVisuals), "Start")]
static void HqAoeMultiplier(PlatoonHQVisuals __instance) { static void HqAoeMultiplier(PlatoonHQVisuals __instance) {
Console.WriteLine("Patching HQ radius - base range {0}", baseHqValue); Console.WriteLine("Patching HQ radius - base range {0}", baseHqValue);
if (baseHqValue == 0) { if (baseHqValue == 0) {
baseHqValue = __instance.platoon.parameters.HQRadius; baseHqValue = __instance.platoon.parameters.HQRadius;
Console.WriteLine("Base range is 0, assigning new: {0}", baseHqValue); Console.WriteLine("Base range is 0, assigning new: {0}", baseHqValue);
} }
__instance.platoon.parameters.HQRadius = baseHqValue * Main.HQAOEMultiplier.Value; __instance.platoon.parameters.HQRadius = baseHqValue * Main.HQAOEMultiplier.Value;
Console.WriteLine("HQ radius patched to: {0}", __instance.platoon.parameters.HQRadius); Console.WriteLine("HQ radius patched to: {0}", __instance.platoon.parameters.HQRadius);
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(PlatoonSupplyModule), "Start")] [HarmonyPatch(typeof(PlatoonSupplyModule), "Start")]
static void SupplyAoeMultiplier(PlatoonSupplyModule __instance) { static void SupplyAoeMultiplier(PlatoonSupplyModule __instance) {
Console.WriteLine("Patching supply amount - base amount {0}", baseSupplyValue); Console.WriteLine("Patching supply amount - base amount {0}", baseSupplyValue);
if (baseSupplyValue == 0) { if (baseSupplyValue == 0) {
baseSupplyValue = __instance.platoon.parameters.supplyPointsPerUnit; baseSupplyValue = __instance.platoon.parameters.supplyPointsPerUnit;
Console.WriteLine("Base amount is 0, assigning new: {0}", baseSupplyValue); Console.WriteLine("Base amount is 0, assigning new: {0}", baseSupplyValue);
} }
__instance.platoon.parameters.supplyPointsPerUnit = __instance.platoon.parameters.supplyPointsPerUnit =
(int)(baseSupplyValue * Main.SupplyAmountMultiplier.Value); (int)(baseSupplyValue * Main.SupplyAmountMultiplier.Value);
Console.WriteLine("Supply amount patched to: {0}", __instance.platoon.parameters.supplyPointsPerUnit); Console.WriteLine("Supply amount patched to: {0}", __instance.platoon.parameters.supplyPointsPerUnit);
} }
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(WeaponAttackBase), "GetReloadInterval")] [HarmonyPatch(typeof(WeaponAttackBase), "GetReloadInterval")]
static void FireRateMultiplier(ref float __result) { static void FireRateMultiplier(ref float __result) {
Console.WriteLine("Patching fire rate"); Console.WriteLine("Patching fire rate");
__result *= Main.FireRateMultiplier.Value; __result *= Main.FireRateMultiplier.Value;
Console.WriteLine("Fire rate patched to: {0}", __result); Console.WriteLine("Fire rate patched to: {0}", __result);
} }
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(WeaponAttackBase), "GetAimInterval")] [HarmonyPatch(typeof(WeaponAttackBase), "GetAimInterval")]
static void AimingIntervalMultiplier(ref float __result) { static void AimingIntervalMultiplier(ref float __result) {
Console.WriteLine("Patching aim interval - base amount {0}", baseSupplyValue); Console.WriteLine("Patching aim interval - base amount {0}", baseSupplyValue);
__result *= Main.AimIntervalMultiplier.Value; __result *= Main.AimIntervalMultiplier.Value;
Console.WriteLine("Aim interval patched to: {0}", __result); Console.WriteLine("Aim interval patched to: {0}", __result);
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(TimerManager), "GetPersistentTimer")] [HarmonyPatch(typeof(TimerManager), "GetPersistentTimer")]
static void Transpiler(ref float interval, ref string hint) { static void Transpiler(ref float interval, ref string hint) {
if (hint == "burst") { if (hint == "burst") {
Console.WriteLine("Patching burst interval from: {0}", interval); Console.WriteLine("Patching burst interval from: {0}", interval);
interval *= Main.FireRateMultiplier.Value; interval *= Main.FireRateMultiplier.Value;
Console.WriteLine("Burst interval patched to: {0}", interval); Console.WriteLine("Burst interval patched to: {0}", interval);
} }
} }
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(RefitZone), "OnRefitStep")] [HarmonyPatch(typeof(RefitZone), "OnRefitStep")]
static void SupplyRateMultiplier(ref float hpVal, ref float ammoVal) { static void SupplyRateMultiplier(ref float hpVal, ref float ammoVal) {
Console.WriteLine("Patching refit step from: {0} {1}", hpVal, ammoVal); Console.WriteLine("Patching refit step from: {0} {1}", hpVal, ammoVal);
hpVal *= Main.SupplyRateMultiplier.Value; hpVal *= Main.SupplyRateMultiplier.Value;
ammoVal *= Main.SupplyRateMultiplier.Value; ammoVal *= Main.SupplyRateMultiplier.Value;
Console.WriteLine("Patching refit step to: {0} {1}", hpVal, ammoVal); Console.WriteLine("Patching refit step to: {0} {1}", hpVal, ammoVal);
} }
// [HarmonyPatch(typeof(AdvancedRulesData), "Validate")] // [HarmonyPatch(typeof(AdvancedRulesData), "Validate")]
// static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { // static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) {
// var codes = new List<CodeInstruction>(instructions); // var codes = new List<CodeInstruction>(instructions);
// //
// foreach (var code in codes) { // foreach (var code in codes) {
// if (code.opcode == OpCodes.Ldc_R4) { // if (code.opcode == OpCodes.Ldc_R4) {
// Console.WriteLine("Changing " + code); // Console.WriteLine("Changing " + code);
// code.operand = (float)code.operand * 2; // code.operand = (float)code.operand * 2;
// Console.WriteLine("Changed " + code); // Console.WriteLine("Changed " + code);
// } // }
// } // }
// //
// return codes.AsEnumerable(); // return codes.AsEnumerable();
// } // }
// [HarmonyPatch(typeof(AdvancedRulesData), "IsWithinLimits")] // [HarmonyPatch(typeof(AdvancedRulesData), "IsWithinLimits")]
// static IEnumerable<CodeInstruction> Transpiler2(IEnumerable<CodeInstruction> instructions) { // static IEnumerable<CodeInstruction> Transpiler2(IEnumerable<CodeInstruction> instructions) {
// var codes = new List<CodeInstruction>(instructions); // var codes = new List<CodeInstruction>(instructions);
// //
// foreach (var code in codes) { // foreach (var code in codes) {
// if (code.opcode == OpCodes.Ldc_R4) { // if (code.opcode == OpCodes.Ldc_R4) {
// Console.WriteLine("Changing " + code); // Console.WriteLine("Changing " + code);
// code.operand = (float)code.operand * 2; // code.operand = (float)code.operand * 2;
// Console.WriteLine("Changed " + code); // Console.WriteLine("Changed " + code);
// } // }
// } // }
// //
// return codes.AsEnumerable(); // return codes.AsEnumerable();
// } // }
// private static float baseAccuracy; // private static float baseAccuracy;
// //
// [HarmonyPostfix] // [HarmonyPostfix]
// [HarmonyPatch(typeof(SkirmishAdvancedRules), "Update")] // [HarmonyPatch(typeof(SkirmishAdvancedRules), "Update")]
// static void AccuracyPatch(SkirmishAdvancedRules __instance) { // static void AccuracyPatch(SkirmishAdvancedRules __instance) {
// var accMod = Traverse.Create(__instance).Field("currentARD").Field("accuracyModifier"); // var accMod = Traverse.Create(__instance).Field("currentARD").Field("accuracyModifier");
// if (baseAccuracy == 0) { // if (baseAccuracy == 0) {
// baseAccuracy = (float)accMod.GetValue(); // baseAccuracy = (float)accMod.GetValue();
// Console.WriteLine("Base accuracy set to {0}", baseAccuracy); // Console.WriteLine("Base accuracy set to {0}", baseAccuracy);
// } // }
// //
// accMod.SetValue(baseAccuracy * 4f); // accMod.SetValue(baseAccuracy * 4f);
// Console.WriteLine("Accuracy now: {0}", accMod.GetValue()); // Console.WriteLine("Accuracy now: {0}", accMod.GetValue());
// } // }
} }
} }

View File

@@ -1,76 +1,76 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DA9D274E-486F-4F82-84FF-CD9388CB0B09}</ProjectGuid> <ProjectGuid>{DA9D274E-486F-4F82-84FF-CD9388CB0B09}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Regiments</RootNamespace> <RootNamespace>Regiments</RootNamespace>
<AssemblyName>Regiments</AssemblyName> <AssemblyName>Regiments</AssemblyName>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="0Harmony"> <Reference Include="0Harmony">
<HintPath>libs\0Harmony.dll</HintPath> <HintPath>C:\Program Files (x86)\Steam\steamapps\common\Regiments\BepInEx\core\0Harmony.dll</HintPath>
</Reference> </Reference>
<Reference Include="Assembly-CSharp"> <Reference Include="Assembly-CSharp">
<HintPath>libs\Assembly-CSharp.dll</HintPath> <HintPath>C:\Program Files (x86)\Steam\steamapps\common\Regiments\Regiments_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference> </Reference>
<Reference Include="BepInEx"> <Reference Include="BepInEx">
<HintPath>libs\BepInEx.dll</HintPath> <HintPath>C:\Program Files (x86)\Steam\steamapps\common\Regiments\BepInEx\core\BepInEx.dll</HintPath>
</Reference> </Reference>
<Reference Include="ConfigurationManager"> <Reference Include="ConfigurationManager">
<HintPath>libs\ConfigurationManager.dll</HintPath> <HintPath>C:\Program Files (x86)\Steam\steamapps\common\Regiments\BepInEx\plugins\ConfigurationManager\ConfigurationManager.dll</HintPath>
</Reference> </Reference>
<Reference Include="MainAssembly"> <Reference Include="MainAssembly">
<HintPath>libs\MainAssembly.dll</HintPath> <HintPath>C:\Program Files (x86)\Steam\steamapps\common\Regiments\Regiments_Data\Managed\MainAssembly.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="UnityEngine"> <Reference Include="UnityEngine">
<HintPath>libs\UnityEngine.dll</HintPath> <HintPath>C:\Program Files (x86)\Steam\steamapps\common\Regiments\Regiments_Data\Managed\UnityEngine.dll</HintPath>
</Reference> </Reference>
<Reference Include="UnityEngine.CoreModule"> <Reference Include="UnityEngine.CoreModule">
<HintPath>libs\UnityEngine.CoreModule.dll</HintPath> <HintPath>C:\Program Files (x86)\Steam\steamapps\common\Regiments\Regiments_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Class1.cs" /> <Compile Include="Class1.cs" />
<Compile Include="Patches.cs" /> <Compile Include="Patches.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Transpiler.cs" /> <Compile Include="Transpiler.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">
</Target> </Target>
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>

View File

@@ -1,4 +1,4 @@
// <autogenerated /> // <autogenerated />
using System; using System;
using System.Reflection; using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")] [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]