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

View File

@@ -1,76 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<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')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DA9D274E-486F-4F82-84FF-CD9388CB0B09}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Regiments</RootNamespace>
<AssemblyName>Regiments</AssemblyName>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>libs\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>libs\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="BepInEx">
<HintPath>libs\BepInEx.dll</HintPath>
</Reference>
<Reference Include="ConfigurationManager">
<HintPath>libs\ConfigurationManager.dll</HintPath>
</Reference>
<Reference Include="MainAssembly">
<HintPath>libs\MainAssembly.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>libs\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>libs\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Patches.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Transpiler.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
<?xml version="1.0" encoding="utf-8"?>
<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')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DA9D274E-486F-4F82-84FF-CD9388CB0B09}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Regiments</RootNamespace>
<AssemblyName>Regiments</AssemblyName>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Regiments\BepInEx\core\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Regiments\Regiments_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="BepInEx">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Regiments\BepInEx\core\BepInEx.dll</HintPath>
</Reference>
<Reference Include="ConfigurationManager">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Regiments\BepInEx\plugins\ConfigurationManager\ConfigurationManager.dll</HintPath>
</Reference>
<Reference Include="MainAssembly">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Regiments\Regiments_Data\Managed\MainAssembly.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Regiments\Regiments_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Regiments\Regiments_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Patches.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Transpiler.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

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