diff --git a/src/RynthCore.Engine/Compatibility/PowerbarHooks.cs b/src/RynthCore.Engine/Compatibility/PowerbarHooks.cs
new file mode 100644
index 0000000..4cb7a40
--- /dev/null
+++ b/src/RynthCore.Engine/Compatibility/PowerbarHooks.cs
@@ -0,0 +1,224 @@
+// ============================================================================
+// RynthCore.Engine - Compatibility/PowerbarHooks.cs
+//
+// Hooks gmPowerbarUI's RecvNotice_* trio so that, when SuppressOriginalDraw
+// is set, the vanilla attack/magic power bar never appears on screen. The
+// bar is ENTIRELY initialized via these notices — BeginPowerbar shows it,
+// SetPowerbarLevel updates it, FinishPowerbar hides it. By no-opping all
+// three, the bar stays invisible.
+//
+// VA derivation (map offset + 0x00401000 = live VA — same as RadarHooks):
+// 000DA390 gmPowerbarUI::RecvNotice_BeginPowerbar(PowerBarMode) → 0x004DB390
+// 000DA1B0 gmPowerbarUI::RecvNotice_SetPowerbarLevel(PowerBarMode,float)→ 0x004DB1B0
+// 000DA1E0 gmPowerbarUI::RecvNotice_FinishPowerbar(PowerBarMode) → 0x004DB1E0
+// ============================================================================
+
+using System;
+using System.Runtime.InteropServices;
+using System.Threading;
+using RynthCore.Engine.Hooking;
+
+namespace RynthCore.Engine.Compatibility;
+
+internal static class PowerbarHooks
+{
+ private const int GmPowerbarUIBeginVa = 0x004DB390;
+ private const int GmPowerbarUILevelVa = 0x004DB1B0;
+ private const int GmPowerbarUIFinishVa = 0x004DB1E0;
+
+ // ClientCombatSystem direct hide. Map: 0016A5F0 + 0x00401000 = 0x0056B5F0.
+ // Thiscall void HidePowerBar() — call on the CCS singleton via the global
+ // pointer that ClientCombatHooks already locates at 0x0087166C.
+ private const int ClientCombatSystemHidePowerBarVa = 0x0056B5F0;
+ private const int CombatSystemPtrVa = 0x0087166C;
+
+ [UnmanagedFunctionPointer(CallingConvention.ThisCall)]
+ private delegate void HidePowerBarDelegate(IntPtr thisPtr);
+
+ private static IntPtr _gmPowerbarUIInstance;
+
+ [UnmanagedFunctionPointer(CallingConvention.ThisCall)]
+ private delegate void NoticeBeginDelegate(IntPtr thisPtr, int powerBarMode);
+
+ [UnmanagedFunctionPointer(CallingConvention.ThisCall)]
+ private delegate void NoticeLevelDelegate(IntPtr thisPtr, int powerBarMode, float level);
+
+ [UnmanagedFunctionPointer(CallingConvention.ThisCall)]
+ private delegate void NoticeFinishDelegate(IntPtr thisPtr, int powerBarMode);
+
+ private static NoticeBeginDelegate? _originalBegin;
+ private static NoticeBeginDelegate? _beginDetour;
+ private static NoticeLevelDelegate? _originalLevel;
+ private static NoticeLevelDelegate? _levelDetour;
+ private static NoticeFinishDelegate? _originalFinish;
+ private static NoticeFinishDelegate? _finishDetour;
+
+ private static bool _hookInstalled;
+ private static string _statusMessage = "Not initialized.";
+
+ public static bool IsInstalled => _hookInstalled;
+ public static string StatusMessage => _statusMessage;
+
+ ///
+ /// When true, the detours skip the original gmPowerbarUI notices, so the
+ /// retail attack/magic power bar never appears. A plugin can render its
+ /// own equivalent (or just leave it hidden).
+ ///
+ public static bool SuppressOriginalDraw;
+
+ public static void Initialize()
+ {
+ if (_hookInstalled)
+ return;
+
+ if (!AcClientModule.TryReadTextSection(out AcClientTextSection textSection))
+ {
+ _statusMessage = "acclient.exe not available.";
+ return;
+ }
+
+ bool beginOk = TryInstallBeginHook(textSection);
+ bool levelOk = TryInstallLevelHook(textSection);
+ bool finishOk = TryInstallFinishHook(textSection);
+
+ if (beginOk && levelOk && finishOk)
+ {
+ _hookInstalled = true;
+ _statusMessage = "Hooked gmPowerbarUI::RecvNotice_(Begin/Level/Finish).";
+ RynthLog.Compat($"Compat: powerbar hooks ready (Begin=0x{GmPowerbarUIBeginVa:X8}, Level=0x{GmPowerbarUILevelVa:X8}, Finish=0x{GmPowerbarUIFinishVa:X8}).");
+ }
+ else
+ {
+ _statusMessage = $"Partial install — Begin={beginOk}, Level={levelOk}, Finish={finishOk}.";
+ RynthLog.Compat($"Compat: powerbar hook {_statusMessage}");
+ }
+ }
+
+ private static bool TryInstallBeginHook(AcClientTextSection textSection)
+ {
+ int funcOff = GmPowerbarUIBeginVa - textSection.TextBaseVa;
+ if (!IsValidPrologue(textSection, funcOff, "Begin", GmPowerbarUIBeginVa))
+ return false;
+
+ try
+ {
+ IntPtr targetAddress = new IntPtr(textSection.TextBaseVa + funcOff);
+ _beginDetour = BeginDetour;
+ IntPtr detourPtr = Marshal.GetFunctionPointerForDelegate(_beginDetour);
+ _originalBegin = Marshal.GetDelegateForFunctionPointer(
+ MinHook.HookCreate(targetAddress, detourPtr));
+ Thread.MemoryBarrier();
+ MinHook.Enable(targetAddress);
+ return true;
+ }
+ catch (Exception ex)
+ {
+ RynthLog.Compat($"Compat: Powerbar Begin hook failed - {ex.Message}");
+ return false;
+ }
+ }
+
+ private static bool TryInstallLevelHook(AcClientTextSection textSection)
+ {
+ int funcOff = GmPowerbarUILevelVa - textSection.TextBaseVa;
+ if (!IsValidPrologue(textSection, funcOff, "Level", GmPowerbarUILevelVa))
+ return false;
+
+ try
+ {
+ IntPtr targetAddress = new IntPtr(textSection.TextBaseVa + funcOff);
+ _levelDetour = LevelDetour;
+ IntPtr detourPtr = Marshal.GetFunctionPointerForDelegate(_levelDetour);
+ _originalLevel = Marshal.GetDelegateForFunctionPointer(
+ MinHook.HookCreate(targetAddress, detourPtr));
+ Thread.MemoryBarrier();
+ MinHook.Enable(targetAddress);
+ return true;
+ }
+ catch (Exception ex)
+ {
+ RynthLog.Compat($"Compat: Powerbar Level hook failed - {ex.Message}");
+ return false;
+ }
+ }
+
+ private static bool TryInstallFinishHook(AcClientTextSection textSection)
+ {
+ int funcOff = GmPowerbarUIFinishVa - textSection.TextBaseVa;
+ if (!IsValidPrologue(textSection, funcOff, "Finish", GmPowerbarUIFinishVa))
+ return false;
+
+ try
+ {
+ IntPtr targetAddress = new IntPtr(textSection.TextBaseVa + funcOff);
+ _finishDetour = FinishDetour;
+ IntPtr detourPtr = Marshal.GetFunctionPointerForDelegate(_finishDetour);
+ _originalFinish = Marshal.GetDelegateForFunctionPointer(
+ MinHook.HookCreate(targetAddress, detourPtr));
+ Thread.MemoryBarrier();
+ MinHook.Enable(targetAddress);
+ return true;
+ }
+ catch (Exception ex)
+ {
+ RynthLog.Compat($"Compat: Powerbar Finish hook failed - {ex.Message}");
+ return false;
+ }
+ }
+
+ private static bool IsValidPrologue(AcClientTextSection textSection, int funcOff, string label, int va)
+ {
+ if (funcOff < 0 || funcOff >= textSection.Bytes.Length)
+ {
+ RynthLog.Compat($"Compat: Powerbar {label} VA out of range @ 0x{va:X8}.");
+ return false;
+ }
+
+ byte firstByte = textSection.Bytes[funcOff];
+ if (firstByte is 0x00 or 0xCC or 0xC3)
+ {
+ RynthLog.Compat($"Compat: Powerbar {label} looks invalid @ 0x{va:X8} (opcode 0x{firstByte:X2}).");
+ return false;
+ }
+ return true;
+ }
+
+ // Per-call diagnostic — emits the first ~5 fires of each detour so we
+ // can confirm the hook is actually reached when the user expects the bar.
+ private static int _beginFires, _levelFires, _finishFires;
+
+ private static void BeginDetour(IntPtr thisPtr, int powerBarMode)
+ {
+ if (thisPtr != IntPtr.Zero) _gmPowerbarUIInstance = thisPtr;
+ if (++_beginFires <= 5)
+ RynthLog.Compat($"Powerbar Begin fired #{_beginFires} (mode={powerBarMode}, suppress={SuppressOriginalDraw})");
+ if (SuppressOriginalDraw)
+ return;
+ _originalBegin!(thisPtr, powerBarMode);
+ }
+
+ private static void LevelDetour(IntPtr thisPtr, int powerBarMode, float level)
+ {
+ if (thisPtr != IntPtr.Zero) _gmPowerbarUIInstance = thisPtr;
+ if (++_levelFires <= 5)
+ RynthLog.Compat($"Powerbar Level fired #{_levelFires} (mode={powerBarMode}, level={level:F2}, suppress={SuppressOriginalDraw})");
+ if (SuppressOriginalDraw)
+ return;
+ _originalLevel!(thisPtr, powerBarMode, level);
+ }
+
+ private static void FinishDetour(IntPtr thisPtr, int powerBarMode)
+ {
+ if (thisPtr != IntPtr.Zero) _gmPowerbarUIInstance = thisPtr;
+ if (++_finishFires <= 5)
+ RynthLog.Compat($"Powerbar Finish fired #{_finishFires} (mode={powerBarMode}, suppress={SuppressOriginalDraw})");
+ if (SuppressOriginalDraw)
+ return;
+ _originalFinish!(thisPtr, powerBarMode);
+ }
+
+ // Per-frame SetVisible(false) on the captured pointer was crashing
+ // (0xC0000005 null-deref) — the instance grabbed from LevelDetour isn't
+ // safe to invoke UIElement::SetVisible on. Suppression is currently a
+ // no-op of the notices only; we'll need a different hide strategy later.
+}
diff --git a/src/RynthCore.Engine/EntryPoint.cs b/src/RynthCore.Engine/EntryPoint.cs
index ea332dc..70bfd64 100644
--- a/src/RynthCore.Engine/EntryPoint.cs
+++ b/src/RynthCore.Engine/EntryPoint.cs
@@ -275,6 +275,7 @@ public static class EntryPoint
RunInitStep("salvage hooks", SalvageHooks.Initialize);
RunInitStep("radar hooks", RadarHooks.Initialize);
RunInitStep("chat hooks", ChatHooks.Initialize);
+ RunInitStep("powerbar hooks", PowerbarHooks.Initialize);
RunInitStep("do-motion hooks", DoMotionHooks.Initialize);
RunInitStep("smartbox-setstate hooks", SmartBoxSetStateHooks.Initialize);
RunInitStep("appraisal hooks", AppraisalHooks.Initialize);
diff --git a/src/RynthCore.Engine/ImGui/ImGuiController.cs b/src/RynthCore.Engine/ImGui/ImGuiController.cs
index 849b7ff..837a3f6 100644
--- a/src/RynthCore.Engine/ImGui/ImGuiController.cs
+++ b/src/RynthCore.Engine/ImGui/ImGuiController.cs
@@ -83,6 +83,23 @@ internal static class ImGuiController
ImGuiNET.ImGui.SetCurrentContext(_context);
ImGuiIOPtr io = ImGuiNET.ImGui.GetIO();
+ // Pin imgui.ini to a stable absolute path so window positions/sizes
+ // persist across plugin reloads (RL) and AC restarts. The default
+ // ImGui behavior writes to the working directory which can differ
+ // between launches. Allocated once, kept alive for the process lifetime.
+ try
+ {
+ const string iniPath = @"C:\Games\RynthSuite\RynthAi\imgui.ini";
+ System.IO.Directory.CreateDirectory(@"C:\Games\RynthSuite\RynthAi");
+ IntPtr iniPtr = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(iniPath);
+ unsafe { io.NativePtr->IniFilename = (byte*)iniPtr; }
+ RynthLog.Render($"ImGuiController: imgui.ini pinned to {iniPath}");
+ }
+ catch (Exception ex)
+ {
+ RynthLog.Render($"ImGuiController: failed to pin imgui.ini path - {ex.Message}");
+ }
+
io.ConfigFlags |= ImGuiConfigFlags.DockingEnable;
io.ConfigFlags |= ImGuiConfigFlags.ViewportsEnable;
// Popped-out plugin windows use WS_EX_TOOLWINDOW so they don't show
diff --git a/src/RynthCore.Engine/Plugins/PluginContract.cs b/src/RynthCore.Engine/Plugins/PluginContract.cs
index 5e45d76..8c2f364 100644
--- a/src/RynthCore.Engine/Plugins/PluginContract.cs
+++ b/src/RynthCore.Engine/Plugins/PluginContract.cs
@@ -497,6 +497,12 @@ internal struct RynthCoreAPI
/// gmMainChatUI each frame, hiding the retail chatbox entirely.
/// Requires API v55+.
public IntPtr SetChatSuppressedFn;
+
+ /// Function pointer: void SetPowerbarSuppressed(int enabled)
+ /// When enabled=1, the engine no-ops gmPowerbarUI's RecvNotice_(Begin/
+ /// Level/Finish), so the retail attack/magic power bar never renders.
+ /// Requires API v56+.
+ public IntPtr SetPowerbarSuppressedFn;
}
@@ -504,7 +510,7 @@ internal struct RynthCoreAPI
/// Current API version. Bump when adding fields to RynthCoreAPI.
internal static class PluginContractVersion
{
- public const uint Current = 55;
+ public const uint Current = 56;
}
internal static class ClientActionHookFlags
@@ -907,5 +913,8 @@ internal unsafe delegate int GetRadarRectCallbackDelegate(int* x0, int* y0, int*
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void SetRadarSuppressedCallbackDelegate(int enabled);
+[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+internal delegate void SetPowerbarSuppressedCallbackDelegate(int enabled);
+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void SetChatSuppressedCallbackDelegate(int enabled);
diff --git a/src/RynthCore.Engine/Plugins/PluginManager.cs b/src/RynthCore.Engine/Plugins/PluginManager.cs
index 75b4894..b7dfe5a 100644
--- a/src/RynthCore.Engine/Plugins/PluginManager.cs
+++ b/src/RynthCore.Engine/Plugins/PluginManager.cs
@@ -119,6 +119,7 @@ internal static class PluginManager
private static GetRadarRectCallbackDelegate? _getRadarRectCallback;
private static SetRadarSuppressedCallbackDelegate? _setRadarSuppressedCallback;
private static SetChatSuppressedCallbackDelegate? _setChatSuppressedCallback;
+ private static SetPowerbarSuppressedCallbackDelegate? _setPowerbarSuppressedCallback;
private static SetMotionCallbackDelegate? _setMotionCallback;
private static StopCompletelyCallbackDelegate? _stopCompletelyCallback;
private static TurnToHeadingCallbackDelegate? _turnToHeadingCallback;
@@ -1683,6 +1684,7 @@ internal static class PluginManager
_getRadarRectCallback ??= GetRadarRect;
_setRadarSuppressedCallback ??= SetRadarSuppressed;
_setChatSuppressedCallback ??= SetChatSuppressed;
+ _setPowerbarSuppressedCallback ??= SetPowerbarSuppressed;
_setMotionCallback ??= SetMotion;
_stopCompletelyCallback ??= StopCompletely;
_turnToHeadingCallback ??= TurnToHeading;
@@ -1857,6 +1859,7 @@ internal static class PluginManager
_api.GetRadarRectFn = Marshal.GetFunctionPointerForDelegate(_getRadarRectCallback);
_api.SetRadarSuppressedFn = Marshal.GetFunctionPointerForDelegate(_setRadarSuppressedCallback);
_api.SetChatSuppressedFn = Marshal.GetFunctionPointerForDelegate(_setChatSuppressedCallback);
+ _api.SetPowerbarSuppressedFn = Marshal.GetFunctionPointerForDelegate(_setPowerbarSuppressedCallback);
}
private static void ProbeClientHooks()
@@ -2238,6 +2241,15 @@ internal static class PluginManager
ChatHooks.SuppressOriginalChat = enabled != 0;
}
+ private static void SetPowerbarSuppressed(int enabled)
+ {
+ bool was = PowerbarHooks.SuppressOriginalDraw;
+ bool now = enabled != 0;
+ PowerbarHooks.SuppressOriginalDraw = now;
+ if (was != now)
+ RynthLog.Compat($"Compat: powerbar suppress -> {now}");
+ }
+
private static int SetMotion(uint motion, int enabled)
{
return ToAbiBool(ClientActionHooks.SetMotion(motion, enabled != 0));
diff --git a/src/RynthCore.PluginSdk/RynthCoreApiNative.cs b/src/RynthCore.PluginSdk/RynthCoreApiNative.cs
index b7cf770..051f975 100644
--- a/src/RynthCore.PluginSdk/RynthCoreApiNative.cs
+++ b/src/RynthCore.PluginSdk/RynthCoreApiNative.cs
@@ -106,4 +106,5 @@ public struct RynthCoreApiNative
public IntPtr GetRadarRectFn;
public IntPtr SetRadarSuppressedFn;
public IntPtr SetChatSuppressedFn;
+ public IntPtr SetPowerbarSuppressedFn;
}
diff --git a/src/RynthCore.PluginSdk/RynthCoreHost.cs b/src/RynthCore.PluginSdk/RynthCoreHost.cs
index c0298e9..8d8b0d2 100644
--- a/src/RynthCore.PluginSdk/RynthCoreHost.cs
+++ b/src/RynthCore.PluginSdk/RynthCoreHost.cs
@@ -104,8 +104,9 @@ public readonly unsafe struct RynthCoreHost
public bool HasDoJump => _api.Version >= 51 && _api.DoJumpFn != IntPtr.Zero;
public bool HasLaunchJumpWithMotion => _api.Version >= 52 && _api.LaunchJumpWithMotionFn != IntPtr.Zero;
public bool HasGetRadarRect => _api.Version >= 53 && _api.GetRadarRectFn != IntPtr.Zero;
- public bool HasSetRadarSuppressed => _api.Version >= 54 && _api.SetRadarSuppressedFn != IntPtr.Zero;
- public bool HasSetChatSuppressed => _api.Version >= 55 && _api.SetChatSuppressedFn != IntPtr.Zero;
+ public bool HasSetRadarSuppressed => _api.Version >= 54 && _api.SetRadarSuppressedFn != IntPtr.Zero;
+ public bool HasSetChatSuppressed => _api.Version >= 55 && _api.SetChatSuppressedFn != IntPtr.Zero;
+ public bool HasSetPowerbarSuppressed => _api.Version >= 56 && _api.SetPowerbarSuppressedFn != IntPtr.Zero;
// ─── Methods ────────────────────────────────────────────────────────────
@@ -301,6 +302,14 @@ public readonly unsafe struct RynthCoreHost
/// UIElement::SetVisible(false). Re-asserted every frame so the game can't
/// sneak it back on.
///
+ public void SetPowerbarSuppressed(bool enabled)
+ {
+ if (_api.SetPowerbarSuppressedFn == IntPtr.Zero)
+ return;
+
+ ((delegate* unmanaged[Cdecl])_api.SetPowerbarSuppressedFn)(enabled ? 1 : 0);
+ }
+
public void SetChatSuppressed(bool enabled)
{
if (_api.SetChatSuppressedFn == IntPtr.Zero)