From c1c7c1f6a9d69d7352c7b0ff129160b3388dd984 Mon Sep 17 00:00:00 2001 From: Sean Petrie Date: Mon, 18 Nov 2024 23:34:23 -0600 Subject: [PATCH] Experemental selection fixes --- CHANGELOG.md | 4 +++ Repository.json | 2 +- .../Bugfixes/General/SelectionHitboxFix.cs | 36 +++++++++++++++++++ TabletopTweaks-Base/Config/Fixes.json | 5 +++ TabletopTweaks-Base/Info.json | 4 +-- .../TabletopTweaks-Base.csproj | 1 + 6 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 TabletopTweaks-Base/Bugfixes/General/SelectionHitboxFix.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index e43bf819..36fdb962 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# Version 2.6.12 +* Fixes + * Experimental fix for selection sizes growing far too much as unit size increases. + # Version 2.6.11 * Fixes * Fix for infinite stacking of weapon enchantments though means such as the Holy Symbol Of Iomedae. diff --git a/Repository.json b/Repository.json index 2d79ae17..c472abdf 100644 --- a/Repository.json +++ b/Repository.json @@ -2,7 +2,7 @@ "Releases": [ { "Id": "TabletopTweaks-Base", - "Version": "2.6.11" + "Version": "2.6.12" } ] } \ No newline at end of file diff --git a/TabletopTweaks-Base/Bugfixes/General/SelectionHitboxFix.cs b/TabletopTweaks-Base/Bugfixes/General/SelectionHitboxFix.cs new file mode 100644 index 00000000..a95cba53 --- /dev/null +++ b/TabletopTweaks-Base/Bugfixes/General/SelectionHitboxFix.cs @@ -0,0 +1,36 @@ +using HarmonyLib; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection.Emit; +using System.Reflection; +using Kingmaker.View; +using static TabletopTweaks.Base.Main; + +namespace TabletopTweaks.Base.Bugfixes.General { + internal class SelectionHitboxFix { + [HarmonyPatch(typeof(UnitEntityView), nameof(UnitEntityView.SetupSelectionColliders), new Type[] { typeof(bool) })] + static class Arcanist_ActionBarSpellbookHelper_Patch { + static readonly FieldInfo UnitEntityView_m_Corpulence = AccessTools.Field(typeof(UnitEntityView), "m_Corpulence"); + static readonly MethodInfo UnitEntityView_Corpulence = AccessTools.PropertyGetter(typeof(UnitEntityView), "Corpulence"); + //Prevent Collision radius from scaling with size adjusted corpulance + static IEnumerable Transpiler(IEnumerable instructions) { + if (TTTContext.Fixes.BaseFixes.IsDisabled("SelectionHitboxFix")) { return instructions; } + var codes = new List(instructions); + int target = FindInsertionTarget(codes); + codes[target] = new CodeInstruction(OpCodes.Ldfld, UnitEntityView_m_Corpulence); + return codes.AsEnumerable(); + } + private static int FindInsertionTarget(List codes) { + for (int i = 0; i < codes.Count; i++) { + if (codes[i].opcode == OpCodes.Call && codes[i].Calls(UnitEntityView_Corpulence)) { + return i ; + } + } + + TTTContext.Logger.Log("SelectionHitboxFix: COULD NOT FIND TARGET"); + return -1; + } + } + } +} diff --git a/TabletopTweaks-Base/Config/Fixes.json b/TabletopTweaks-Base/Config/Fixes.json index bd45c7b0..dd33c9fe 100644 --- a/TabletopTweaks-Base/Config/Fixes.json +++ b/TabletopTweaks-Base/Config/Fixes.json @@ -193,6 +193,11 @@ "Homebrew": false, "Description": "Fixes the combat log breakdowns of saving throws to include the bonus granted from base stats." }, + "SelectionHitboxFix": { + "Enabled": true, + "Homebrew": false, + "Description": "Changes how selection boxes scale with size modifiers to prevent them from being massive." + }, "SelectiveMetamagicNonInstantaneous": { "Enabled": true, "Homebrew": false, diff --git a/TabletopTweaks-Base/Info.json b/TabletopTweaks-Base/Info.json index 68a20dd6..18847fb6 100644 --- a/TabletopTweaks-Base/Info.json +++ b/TabletopTweaks-Base/Info.json @@ -8,7 +8,7 @@ "Id": "TabletopTweaks-Base", "ManagerVersion": "0.23.0", "Repository": "https://raw.githubusercontent.com/Vek17/TabletopTweaks-Base/master/Repository.json", - "Requirements": [ "TabletopTweaks-Core-0.7.9" ], + "Requirements": [ "TabletopTweaks-Core-0.7.10" ], "LoadAfter": [ "TabletopTweaks-Core" ], - "Version": "2.6.11" + "Version": "2.6.12" } \ No newline at end of file diff --git a/TabletopTweaks-Base/TabletopTweaks-Base.csproj b/TabletopTweaks-Base/TabletopTweaks-Base.csproj index 1b180872..abcc34fb 100644 --- a/TabletopTweaks-Base/TabletopTweaks-Base.csproj +++ b/TabletopTweaks-Base/TabletopTweaks-Base.csproj @@ -218,6 +218,7 @@ +