Add radar rect API, jump primitives, account profile tweaks
- Hook gmRadarUI::DrawObjects to capture the UI singleton; expose host.TryGetRadarRect via UIElement::GetSurfaceBox (API v53). - Plumb CommenceJump/DoJump/LaunchJumpWithMotion through ClientActionHooks and PlayerPhysicsHooks. - Account profile dialog + LaunchAccountProfile adjustments. - Viewport platform backend tweak.
This commit is contained in:
parent
27d6e530e0
commit
2c3d2410a8
13 changed files with 540 additions and 15 deletions
|
|
@ -136,6 +136,21 @@ internal static class ClientActionHooks
|
|||
return CommandInterpreterHooks.TapJump();
|
||||
}
|
||||
|
||||
public static bool CommenceJump()
|
||||
{
|
||||
return CommandInterpreterHooks.CommenceJump();
|
||||
}
|
||||
|
||||
public static bool DoJump(bool autonomous)
|
||||
{
|
||||
return CommandInterpreterHooks.DoJump(autonomous);
|
||||
}
|
||||
|
||||
public static bool LaunchJumpWithMotion(bool shift, bool holdW, bool holdX, bool holdZ, bool holdC)
|
||||
{
|
||||
return PlayerPhysicsHooks.LaunchJumpWithMotion(shift, holdW, holdX, holdZ, holdC);
|
||||
}
|
||||
|
||||
public static bool SetMotion(uint motion, bool enabled)
|
||||
{
|
||||
return CommandInterpreterHooks.SetMotion(motion, enabled);
|
||||
|
|
|
|||
|
|
@ -244,6 +244,38 @@ internal static class CommandInterpreterHooks
|
|||
}
|
||||
}
|
||||
|
||||
public static bool CommenceJump()
|
||||
{
|
||||
if (!TryBindDelegates())
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
_commenceJump!(_boundCmdInterp);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool DoJump(bool autonomous)
|
||||
{
|
||||
if (!TryBindDelegates())
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
_doJump!(_boundCmdInterp, autonomous ? 1 : 0);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool TryBindDelegates()
|
||||
{
|
||||
IntPtr selectedStaticAddr = IntPtr.Zero;
|
||||
|
|
|
|||
|
|
@ -17,15 +17,43 @@ internal static class PlayerPhysicsHooks
|
|||
private const int ReferencePhysicsGetHeading = 0x00512010;
|
||||
private const int ReferencePhysicsSetHeading = 0x00514C60;
|
||||
|
||||
// CPhysicsObj::m_pMovementManager lives at +0xC4 (same offset UB's Jumper uses).
|
||||
// The CMotionInterp pointer is the first field of MovementManager.
|
||||
private const int MovementManagerOffset = 0xC4;
|
||||
|
||||
// CMotionInterp::get_max_speed — Chorizite RVA 0x001278C0, our client is +0x1000
|
||||
// from Chorizite (confirmed via set_heading/get_heading/CommenceJump addresses).
|
||||
private const int ReferenceGetMaxSpeed = 0x005288C0;
|
||||
|
||||
// Fields in CMotionInterp holding the "current motion command" for each
|
||||
// channel. Writing these right before DoJump tells the physics simulation
|
||||
// to launch the jump with that velocity baked in.
|
||||
private const int CMotionForwardIdOffset = 76; // 0x4C
|
||||
private const int CMotionForwardSpeedOffset = 80; // 0x50
|
||||
private const int CMotionStrafeIdOffset = 84; // 0x54
|
||||
private const int CMotionStrafeSpeedOffset = 88; // 0x58
|
||||
private const int CMotionTurnOffset = 92; // 0x5C
|
||||
|
||||
// Raw motion-command IDs the physics simulation reads from CMotionInterp.
|
||||
// Sourced from UB's UBHelper.Jumper — these are *not* the SetMotion IDs.
|
||||
private const int MotionIdForward = 0x44000007;
|
||||
private const int MotionIdBackward = 0x45000005;
|
||||
private const int MotionIdIdle = 0x41000003;
|
||||
private const int MotionIdSidestep = 0x6500000F;
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
|
||||
private delegate float PhysicsGetHeadingDelegate(IntPtr physicsObjPtr);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
|
||||
private delegate void PhysicsSetHeadingDelegate(IntPtr physicsObjPtr, float headingDegrees, int sendEvent);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
|
||||
private delegate double GetMaxSpeedDelegate(IntPtr cmotionInterpPtr);
|
||||
|
||||
private static string _statusMessage = "Not probed yet.";
|
||||
private static PhysicsGetHeadingDelegate? _getHeading;
|
||||
private static PhysicsSetHeadingDelegate? _setHeading;
|
||||
private static GetMaxSpeedDelegate? _getMaxSpeed;
|
||||
|
||||
public static bool IsInitialized { get; private set; }
|
||||
public static bool HasGetHeading => _getHeading != null;
|
||||
|
|
@ -185,6 +213,137 @@ internal static class PlayerPhysicsHooks
|
|||
}
|
||||
}
|
||||
|
||||
public static bool HasLaunchJumpWithMotion => SmartBoxLocator.IsPointerInModule(new(ReferenceGetMaxSpeed));
|
||||
|
||||
/// <summary>
|
||||
/// Writes motion-vector fields directly into CMotionInterp, calls DoJump(1),
|
||||
/// then clears them back out. Mirrors UB's UBHelper.Jumper algorithm, minus
|
||||
/// the power-bar hook (the plugin drives timing with a ms delay).
|
||||
///
|
||||
/// This is the only reliable way to jump *with forward/back/strafe momentum*
|
||||
/// in AC — SetMotion routes through the command interpreter, which doesn't
|
||||
/// bake velocity into the physics simulation in time for DoJump.
|
||||
/// </summary>
|
||||
public static bool LaunchJumpWithMotion(bool shift, bool holdW, bool holdX, bool holdZ, bool holdC)
|
||||
{
|
||||
if (!TryGetCMotionInterp(out IntPtr cmi))
|
||||
{
|
||||
RynthLog.Compat("LaunchJumpWithMotion: CMotionInterp unavailable");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!TryGetMaxSpeed(cmi, out double maxSpeed))
|
||||
{
|
||||
RynthLog.Compat("LaunchJumpWithMotion: get_max_speed failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
double num = maxSpeed / 4.0;
|
||||
|
||||
IntPtr pForwardId = cmi + CMotionForwardIdOffset;
|
||||
IntPtr pForwardSpeed = cmi + CMotionForwardSpeedOffset;
|
||||
IntPtr pStrafeId = cmi + CMotionStrafeIdOffset;
|
||||
IntPtr pStrafeSpeed = cmi + CMotionStrafeSpeedOffset;
|
||||
IntPtr pTurn = cmi + CMotionTurnOffset;
|
||||
|
||||
try
|
||||
{
|
||||
// Forward/back channel
|
||||
if (holdW || holdX)
|
||||
{
|
||||
if (holdW)
|
||||
{
|
||||
Marshal.WriteInt32(pForwardId, MotionIdForward);
|
||||
WriteFloat(pForwardSpeed, shift ? 1f : (float)num);
|
||||
}
|
||||
else
|
||||
{
|
||||
Marshal.WriteInt32(pForwardId, MotionIdBackward);
|
||||
WriteFloat(pForwardSpeed, shift ? -1f : (float)(-0.65 * num));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Marshal.WriteInt32(pForwardId, MotionIdIdle);
|
||||
}
|
||||
|
||||
// Strafe channel
|
||||
if (holdZ || holdC)
|
||||
{
|
||||
Marshal.WriteInt32(pStrafeId, MotionIdSidestep);
|
||||
double s = num * 1.248;
|
||||
if (shift) s *= 0.5;
|
||||
if (s > 3.0) s = 3.0;
|
||||
WriteFloat(pStrafeSpeed, holdC ? (float)s : (float)(-s));
|
||||
}
|
||||
else
|
||||
{
|
||||
Marshal.WriteInt32(pStrafeId, 0);
|
||||
}
|
||||
|
||||
Marshal.WriteInt32(pTurn, 0);
|
||||
|
||||
bool jumped = CommandInterpreterHooks.DoJump(true);
|
||||
|
||||
// Clear immediately so the character doesn't keep walking on landing.
|
||||
if (holdZ || holdC) Marshal.WriteInt32(pStrafeId, 0);
|
||||
if (holdW || holdX) Marshal.WriteInt32(pForwardId, MotionIdIdle);
|
||||
|
||||
return jumped;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RynthLog.Compat($"LaunchJumpWithMotion: write failed: {ex.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool TryGetCMotionInterp(out IntPtr cmotionInterp)
|
||||
{
|
||||
cmotionInterp = IntPtr.Zero;
|
||||
|
||||
if (!SmartBoxLocator.TryGetPlayer(out IntPtr player, out _, out string failure))
|
||||
{
|
||||
_statusMessage = failure;
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
IntPtr movementManager = Marshal.ReadIntPtr(player + MovementManagerOffset);
|
||||
if (movementManager == IntPtr.Zero) return false;
|
||||
cmotionInterp = Marshal.ReadIntPtr(movementManager);
|
||||
return cmotionInterp != IntPtr.Zero;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool TryGetMaxSpeed(IntPtr cmotionInterp, out double maxSpeed)
|
||||
{
|
||||
maxSpeed = 0;
|
||||
|
||||
if (_getMaxSpeed == null)
|
||||
{
|
||||
IntPtr ptr = new(ReferenceGetMaxSpeed);
|
||||
if (!SmartBoxLocator.IsPointerInModule(ptr))
|
||||
return false;
|
||||
_getMaxSpeed = Marshal.GetDelegateForFunctionPointer<GetMaxSpeedDelegate>(ptr);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
maxSpeed = _getMaxSpeed(cmotionInterp);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteFloat(IntPtr address, float value)
|
||||
{
|
||||
Marshal.WriteInt32(address, BitConverter.SingleToInt32Bits(value));
|
||||
|
|
|
|||
135
src/RynthCore.Engine/Compatibility/RadarHooks.cs
Normal file
135
src/RynthCore.Engine/Compatibility/RadarHooks.cs
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - Compatibility/RadarHooks.cs
|
||||
//
|
||||
// Hooks gmRadarUI::DrawObjects to capture the singleton 'this' pointer.
|
||||
// Exposes TryGetRadarRect, which asks UIElement::GetSurfaceBox for the
|
||||
// radar element's current screen rect (used to overlay dungeon walls on
|
||||
// the retail radar).
|
||||
//
|
||||
// VA derivation (map offset + 0x00401000 = live VA):
|
||||
// 000D8FE0 gmRadarUI::DrawObjects(UISurface*) → 0x004D9FE0
|
||||
// 00061220 UIElement::GetSurfaceBox(Box2D*) → 0x00462220
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using RynthCore.Engine.Hooking;
|
||||
|
||||
namespace RynthCore.Engine.Compatibility;
|
||||
|
||||
internal static class RadarHooks
|
||||
{
|
||||
private const int GmRadarUIDrawObjectsVa = 0x004D9FE0;
|
||||
private const int UIElementGetSurfaceBoxVa = 0x00462220;
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
|
||||
private delegate void GmRadarUIDrawObjectsDelegate(IntPtr thisPtr, IntPtr uiSurface);
|
||||
|
||||
private static GmRadarUIDrawObjectsDelegate? _originalDrawObjects;
|
||||
private static GmRadarUIDrawObjectsDelegate? _drawObjectsDetour; // held alive to prevent GC
|
||||
private static IntPtr _gmRadarUIInstance;
|
||||
private static bool _hookInstalled;
|
||||
private static string _statusMessage = "Not initialized.";
|
||||
|
||||
public static bool IsInstalled => _hookInstalled;
|
||||
public static string StatusMessage => _statusMessage;
|
||||
|
||||
/// <summary>
|
||||
/// The captured gmRadarUI singleton. Zero until the radar has rendered at
|
||||
/// least once this session (usually within the first frame after login).
|
||||
/// </summary>
|
||||
public static IntPtr GmRadarUIInstance => _gmRadarUIInstance;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if (_hookInstalled)
|
||||
return;
|
||||
|
||||
if (!AcClientModule.TryReadTextSection(out AcClientTextSection textSection))
|
||||
{
|
||||
_statusMessage = "acclient.exe not available.";
|
||||
return;
|
||||
}
|
||||
|
||||
int funcOff = GmRadarUIDrawObjectsVa - textSection.TextBaseVa;
|
||||
if (funcOff < 0 || funcOff >= textSection.Bytes.Length)
|
||||
{
|
||||
_statusMessage = $"gmRadarUI::DrawObjects VA out of range @ 0x{GmRadarUIDrawObjectsVa:X8}.";
|
||||
RynthLog.Compat($"Compat: radar hook failed - {_statusMessage}");
|
||||
return;
|
||||
}
|
||||
|
||||
byte firstByte = textSection.Bytes[funcOff];
|
||||
if (firstByte is 0x00 or 0xCC or 0xC3)
|
||||
{
|
||||
_statusMessage = $"gmRadarUI::DrawObjects looks invalid @ 0x{GmRadarUIDrawObjectsVa:X8} (opcode 0x{firstByte:X2}).";
|
||||
RynthLog.Compat($"Compat: radar hook failed - {_statusMessage}");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
IntPtr targetAddress = new IntPtr(textSection.TextBaseVa + funcOff);
|
||||
_drawObjectsDetour = DrawObjectsDetour;
|
||||
IntPtr detourPtr = Marshal.GetFunctionPointerForDelegate(_drawObjectsDetour);
|
||||
_originalDrawObjects = Marshal.GetDelegateForFunctionPointer<GmRadarUIDrawObjectsDelegate>(
|
||||
MinHook.HookCreate(targetAddress, detourPtr));
|
||||
Thread.MemoryBarrier();
|
||||
MinHook.Enable(targetAddress);
|
||||
|
||||
_hookInstalled = true;
|
||||
_statusMessage = $"Hooked gmRadarUI::DrawObjects @ 0x{targetAddress.ToInt32():X8}.";
|
||||
RynthLog.Verbose($"Compat: radar hook ready @ 0x{targetAddress.ToInt32():X8}, firstByte=0x{firstByte:X2}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_statusMessage = ex.Message;
|
||||
RynthLog.Compat($"Compat: radar hook failed - {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawObjectsDetour(IntPtr thisPtr, IntPtr uiSurface)
|
||||
{
|
||||
if (thisPtr != IntPtr.Zero)
|
||||
_gmRadarUIInstance = thisPtr;
|
||||
|
||||
_originalDrawObjects!(thisPtr, uiSurface);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the retail radar element's current screen rect (x0,y0,x1,y1 in
|
||||
/// pixels, exclusive on x1/y1). Calls UIElement::GetSurfaceBox on the
|
||||
/// captured singleton. Returns false until the radar has rendered at least
|
||||
/// once, or if the rect looks invalid.
|
||||
/// </summary>
|
||||
public static unsafe bool TryGetRadarRect(out int x0, out int y0, out int x1, out int y1)
|
||||
{
|
||||
x0 = y0 = x1 = y1 = 0;
|
||||
IntPtr inst = _gmRadarUIInstance;
|
||||
if (inst == IntPtr.Zero)
|
||||
return false;
|
||||
|
||||
// Box2D is four int32s laid out (x0, y0, x1, y1). GetSurfaceBox follows
|
||||
// MSVC's "return struct by value" ABI: caller passes the output slot as
|
||||
// the first stack argument; the callee fills it and returns the same ptr.
|
||||
int* box = stackalloc int[4];
|
||||
box[0] = box[1] = box[2] = box[3] = 0;
|
||||
|
||||
try
|
||||
{
|
||||
((delegate* unmanaged[Thiscall]<IntPtr, int*, int*>)UIElementGetSurfaceBoxVa)(inst, box);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int bx0 = box[0], by0 = box[1], bx1 = box[2], by1 = box[3];
|
||||
if (bx1 <= bx0 || by1 <= by0 || bx1 > 10000 || by1 > 10000 || bx0 < -1000 || by0 < -1000)
|
||||
return false;
|
||||
|
||||
x0 = bx0; y0 = by0; x1 = bx1; y1 = by1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -273,6 +273,7 @@ public static class EntryPoint
|
|||
RunInitStep("combat-mode hooks", CombatModeHooks.Initialize);
|
||||
RunInitStep("teleport-state hooks", TeleportStateHooks.Initialize);
|
||||
RunInitStep("salvage hooks", SalvageHooks.Initialize);
|
||||
RunInitStep("radar hooks", RadarHooks.Initialize);
|
||||
RunInitStep("do-motion hooks", DoMotionHooks.Initialize);
|
||||
RunInitStep("smartbox-setstate hooks", SmartBoxSetStateHooks.Initialize);
|
||||
RunInitStep("appraisal hooks", AppraisalHooks.Initialize);
|
||||
|
|
|
|||
|
|
@ -470,14 +470,15 @@ internal static unsafe class ViewportPlatformBackend
|
|||
{
|
||||
uint flags = unchecked((uint)vp->Flags);
|
||||
bool noDecoration = (flags & (uint)ImGuiViewportFlags.NoDecoration) != 0;
|
||||
bool noTaskbarIcon = (flags & (uint)ImGuiViewportFlags.NoTaskBarIcon) != 0;
|
||||
bool topMost = (flags & (uint)ImGuiViewportFlags.TopMost) != 0;
|
||||
|
||||
uint dwStyle = noDecoration
|
||||
? WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS
|
||||
: WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
|
||||
|
||||
uint dwExStyle = noTaskbarIcon ? WS_EX_TOOLWINDOW : WS_EX_APPWINDOW;
|
||||
// Always use WS_EX_TOOLWINDOW so tear-off viewports don't clutter the taskbar / Alt-Tab
|
||||
// list when users run many clients. Owned by _mainHwnd so it still closes with the game.
|
||||
uint dwExStyle = WS_EX_TOOLWINDOW;
|
||||
if (topMost) dwExStyle |= WS_EX_TOPMOST;
|
||||
dwExStyle |= WS_EX_NOACTIVATE;
|
||||
|
||||
|
|
@ -746,7 +747,16 @@ internal static unsafe class ViewportPlatformBackend
|
|||
break;
|
||||
|
||||
case WM_MOUSEACTIVATE:
|
||||
return new IntPtr(MA_NOACTIVATE);
|
||||
{
|
||||
// If AC is the foreground app, don't steal its focus — just process the click.
|
||||
// If the user is tabbed out (some other app is foreground), allow Windows to
|
||||
// activate this viewport so the click actually brings it to the front.
|
||||
IntPtr fg = GetForegroundWindow();
|
||||
IntPtr game = Win32Backend.GameHwnd;
|
||||
if (game != IntPtr.Zero && fg == game)
|
||||
return new IntPtr(MA_NOACTIVATE);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_NCHITTEST:
|
||||
{
|
||||
|
|
|
|||
|
|
@ -461,6 +461,30 @@ internal struct RynthCoreAPI
|
|||
/// Returns total subpalette count, or -1 if no data was captured for this object.
|
||||
/// subIds[i] is the palette DID; offsets[i] is the range-start offset (used as slot index).</summary>
|
||||
public IntPtr GetObjectPalettesFn;
|
||||
|
||||
/// <summary>Function pointer: int CommenceJump()
|
||||
/// Calls ClientCombatSystem::CommenceJump (spacebar key-down). Starts the
|
||||
/// power-bar charge cycle. Pair with DoJump(autonomous) to release.</summary>
|
||||
public IntPtr CommenceJumpFn;
|
||||
|
||||
/// <summary>Function pointer: int DoJump(int autonomous)
|
||||
/// Calls ClientCombatSystem::DoJump (spacebar key-up). Releases a jump
|
||||
/// at the current power-bar level. Pass autonomous=1 for the normal
|
||||
/// player-driven jump (matches keyboard behavior).</summary>
|
||||
public IntPtr DoJumpFn;
|
||||
|
||||
/// <summary>Function pointer: int LaunchJumpWithMotion(int shift, int w, int x, int z, int c)
|
||||
/// Writes motion vector directly into CMotionInterp, calls DoJump(1), then
|
||||
/// clears the motion. This is the only way to jump with forward/back/strafe
|
||||
/// momentum — SetMotion does not bake velocity into the physics sim in time
|
||||
/// for DoJump. Mirrors UB's UBHelper.Jumper algorithm.</summary>
|
||||
public IntPtr LaunchJumpWithMotionFn;
|
||||
|
||||
/// <summary>Function pointer: int GetRadarRect(int* x0, int* y0, int* x1, int* y1)
|
||||
/// Returns the retail gmRadarUI element's current screen rect in pixels
|
||||
/// (x0,y0 top-left, x1,y1 bottom-right exclusive). Returns 1 on success, 0
|
||||
/// if the radar has not rendered yet this session. Requires API v53+.</summary>
|
||||
public IntPtr GetRadarRectFn;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -468,7 +492,7 @@ internal struct RynthCoreAPI
|
|||
/// <summary>Current API version. Bump when adding fields to RynthCoreAPI.</summary>
|
||||
internal static class PluginContractVersion
|
||||
{
|
||||
public const uint Current = 50;
|
||||
public const uint Current = 53;
|
||||
}
|
||||
|
||||
internal static class ClientActionHookFlags
|
||||
|
|
@ -625,6 +649,15 @@ internal delegate int SetAutoRunCallbackDelegate(int enabled);
|
|||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal delegate int TapJumpCallbackDelegate();
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal delegate int CommenceJumpCallbackDelegate();
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal delegate int DoJumpCallbackDelegate(int autonomous);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal delegate int LaunchJumpWithMotionCallbackDelegate(int shift, int w, int x, int z, int c);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal delegate int SetMotionCallbackDelegate(uint motion, int enabled);
|
||||
|
||||
|
|
@ -855,3 +888,6 @@ internal delegate void ForceResetBusyCountCallbackDelegate();
|
|||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal unsafe delegate int GetObjectPalettesCallbackDelegate(uint objectId, uint* subIds, uint* offsets, int maxCount);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal unsafe delegate int GetRadarRectCallbackDelegate(int* x0, int* y0, int* x1, int* y1);
|
||||
|
|
|
|||
|
|
@ -113,6 +113,10 @@ internal static class PluginManager
|
|||
private static SetAutonomyLevelCallbackDelegate? _setAutonomyLevelCallback;
|
||||
private static SetAutoRunCallbackDelegate? _setAutoRunCallback;
|
||||
private static TapJumpCallbackDelegate? _tapJumpCallback;
|
||||
private static CommenceJumpCallbackDelegate? _commenceJumpCallback;
|
||||
private static DoJumpCallbackDelegate? _doJumpCallback;
|
||||
private static LaunchJumpWithMotionCallbackDelegate? _launchJumpWithMotionCallback;
|
||||
private static GetRadarRectCallbackDelegate? _getRadarRectCallback;
|
||||
private static SetMotionCallbackDelegate? _setMotionCallback;
|
||||
private static StopCompletelyCallbackDelegate? _stopCompletelyCallback;
|
||||
private static TurnToHeadingCallbackDelegate? _turnToHeadingCallback;
|
||||
|
|
@ -1671,6 +1675,10 @@ internal static class PluginManager
|
|||
_setAutonomyLevelCallback ??= SetAutonomyLevel;
|
||||
_setAutoRunCallback ??= SetAutoRun;
|
||||
_tapJumpCallback ??= TapJump;
|
||||
_commenceJumpCallback ??= CommenceJump;
|
||||
_doJumpCallback ??= DoJump;
|
||||
_launchJumpWithMotionCallback ??= LaunchJumpWithMotion;
|
||||
_getRadarRectCallback ??= GetRadarRect;
|
||||
_setMotionCallback ??= SetMotion;
|
||||
_stopCompletelyCallback ??= StopCompletely;
|
||||
_turnToHeadingCallback ??= TurnToHeading;
|
||||
|
|
@ -1839,6 +1847,10 @@ internal static class PluginManager
|
|||
_api.ForceResetBusyCountFn = Marshal.GetFunctionPointerForDelegate(_forceResetBusyCountCallback);
|
||||
_getObjectPalettesCallback ??= GetObjectPalettesAction;
|
||||
_api.GetObjectPalettesFn = Marshal.GetFunctionPointerForDelegate(_getObjectPalettesCallback);
|
||||
_api.CommenceJumpFn = Marshal.GetFunctionPointerForDelegate(_commenceJumpCallback);
|
||||
_api.DoJumpFn = Marshal.GetFunctionPointerForDelegate(_doJumpCallback);
|
||||
_api.LaunchJumpWithMotionFn = Marshal.GetFunctionPointerForDelegate(_launchJumpWithMotionCallback);
|
||||
_api.GetRadarRectFn = Marshal.GetFunctionPointerForDelegate(_getRadarRectCallback);
|
||||
}
|
||||
|
||||
private static void ProbeClientHooks()
|
||||
|
|
@ -2183,6 +2195,33 @@ internal static class PluginManager
|
|||
return ToAbiBool(ClientActionHooks.TapJump());
|
||||
}
|
||||
|
||||
private static int CommenceJump()
|
||||
{
|
||||
return ToAbiBool(ClientActionHooks.CommenceJump());
|
||||
}
|
||||
|
||||
private static int DoJump(int autonomous)
|
||||
{
|
||||
return ToAbiBool(ClientActionHooks.DoJump(autonomous != 0));
|
||||
}
|
||||
|
||||
private static int LaunchJumpWithMotion(int shift, int w, int x, int z, int c)
|
||||
{
|
||||
return ToAbiBool(ClientActionHooks.LaunchJumpWithMotion(shift != 0, w != 0, x != 0, z != 0, c != 0));
|
||||
}
|
||||
|
||||
private static unsafe int GetRadarRect(int* x0, int* y0, int* x1, int* y1)
|
||||
{
|
||||
if (x0 == null || y0 == null || x1 == null || y1 == null)
|
||||
return 0;
|
||||
|
||||
if (!RadarHooks.TryGetRadarRect(out int rx0, out int ry0, out int rx1, out int ry1))
|
||||
return 0;
|
||||
|
||||
*x0 = rx0; *y0 = ry0; *x1 = rx1; *y1 = ry1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int SetMotion(uint motion, int enabled)
|
||||
{
|
||||
return ToAbiBool(ClientActionHooks.SetMotion(motion, enabled != 0));
|
||||
|
|
|
|||
Loading…
Reference in a new issue