Skip to content

Commit

Permalink
Experemental selection fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vek17 committed Nov 19, 2024
1 parent 59937c5 commit c1c7c1f
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Repository.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Releases": [
{
"Id": "TabletopTweaks-Base",
"Version": "2.6.11"
"Version": "2.6.12"
}
]
}
36 changes: 36 additions & 0 deletions TabletopTweaks-Base/Bugfixes/General/SelectionHitboxFix.cs
Original file line number Diff line number Diff line change
@@ -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<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) {
if (TTTContext.Fixes.BaseFixes.IsDisabled("SelectionHitboxFix")) { return instructions; }
var codes = new List<CodeInstruction>(instructions);
int target = FindInsertionTarget(codes);
codes[target] = new CodeInstruction(OpCodes.Ldfld, UnitEntityView_m_Corpulence);
return codes.AsEnumerable();
}
private static int FindInsertionTarget(List<CodeInstruction> 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;
}
}
}
}
5 changes: 5 additions & 0 deletions TabletopTweaks-Base/Config/Fixes.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions TabletopTweaks-Base/Info.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
1 change: 1 addition & 0 deletions TabletopTweaks-Base/TabletopTweaks-Base.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
<Compile Include="Bugfixes\General\DynamicItemNames.cs" />
<Compile Include="Bugfixes\General\FeatSelections.cs" />
<Compile Include="Bugfixes\General\MountedCombatFixes.cs" />
<Compile Include="Bugfixes\General\SelectionHitboxFix.cs" />
<Compile Include="Bugfixes\General\ShadowMagicFix.cs" />
<Compile Include="Bugfixes\General\SizeModifiers.cs" />
<Compile Include="Bugfixes\General\SizeShiftLimits.cs" />
Expand Down

0 comments on commit c1c7c1f

Please sign in to comment.