Stage 1: walk while healing legs, for SPT 4.0.13

Ground-up reimplementation of yox92/SmartAction targeting SPT 4.0.13 /
EFT 0.16.9.0.40087. Only the walk-while-healing feature is implemented;
see NOTES.md for status and the deferred sprint work.

Design departures from upstream:

- CanWalk is a guarded postfix, not a transpiler. Upstream rewrote the
  method body, which affects every MovementContext in the raid including
  bots, and is hard-incompatible with the three other mods already
  patching MovementContext in a typical load order (SAIN, ORBIT,
  maschine-DualSideDoorBreach). A postfix that only flips false -> true
  for IsYourPlayer is inert for other entities by construction.

- The postfix re-tests ObstacleCollisionFacade_1.CanMove() before
  lifting. Upstream's transpiler dropped that check along with the
  HealingLegs check, silently disabling obstacle blocking.

- Targets resolve by name via AccessTools.PropertyGetter + nameof rather
  than by GClass number, so they survive EFT version bumps.

Verified in-game against 78 loaded plugins: both patches attach, the
guard rejected 985 non-local MovementContext calls with zero leaks, and
_player was never null across ~4000 guard calls.

CanSprintPatch is parked in deferred/ rather than deleted:
MovementContext.CanSprint does not gate sprinting (EnableSprint calls
Physical.Sprint unconditionally), and forcing it true makes EnableSprint
run ForceStopInteractions()/RemoveLeftHandItem() mid-heal. Details and
the 3.11 -> 4.0.13 rename table are in NOTES.md.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
funman300
2026-07-28 18:45:42 -07:00
commit 8de369869f
9 changed files with 515 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using SmartAction.Patch;
namespace SmartAction;
[BepInPlugin(PluginGuid, PluginName, PluginVersion)]
[BepInDependency("com.SPT.core", "4.0.0")]
public class Plugin : BaseUnityPlugin
{
public const string PluginGuid = "com.yox92.smartaction";
public const string PluginName = "SmartAction";
public const string PluginVersion = "2.0.0";
internal static ManualLogSource Log { get; private set; }
private ConfigEntry<bool> _diagnostics;
private void Awake()
{
Log = Logger;
_diagnostics = Config.Bind(
"Debug",
"Diagnostics",
true,
"Log patch and guard activity. Counters are cheap, but this writes a summary line "
+ "every 30s while in raid. Turn off once the behaviour is trusted.");
Diagnostics.Enabled = _diagnostics.Value;
_diagnostics.SettingChanged += (_, _) => Diagnostics.Enabled = _diagnostics.Value;
// Stage 1 is walk-only. CanSprintPatch is deferred to Stage 2/3 — see NOTES.md:
// MovementContext.CanSprint does not gate sprinting, and patching it caused
// EnableSprint() to call ForceStopInteractions()/RemoveLeftHandItem() mid-heal.
new CanWalkPatch().Enable();
Log.LogInfo($"{PluginName} {PluginVersion} loaded (walk-while-healing active, "
+ $"diagnostics {(Diagnostics.Enabled ? "ON" : "off")}).");
}
}