diff --git a/SomethingNeedDoing/Interface/HelpWindow.cs b/SomethingNeedDoing/Interface/HelpWindow.cs index e2102013..a6f3eb9d 100644 --- a/SomethingNeedDoing/Interface/HelpWindow.cs +++ b/SomethingNeedDoing/Interface/HelpWindow.cs @@ -321,6 +321,10 @@ static void DisplayChangelog(string date, string changes, bool separator = true) ImGui.PushFont(UiBuilder.MonoFont); + DisplayChangelog( + "2023-12-12", + "- Updated the GetRaw coordinate functions to take in an object name or party member position.\n"); + DisplayChangelog( "2023-12-12", "- Added IsQuestAccepted()\n" + @@ -951,9 +955,10 @@ uint GetGil() uint GetClassJobId() -float GetPlayerRawXPos() -float GetPlayerRawYPos() -float GetPlayerRawZPos() +// if you pass an invalid name or party position it will return -1 +float GetPlayerRawXPos(string character = "") +float GetPlayerRawYPos(string character = "") +float GetPlayerRawZPos(string character = "") float GetDistanceToPoint(float x, float y, float z)) int GetLevel(uint ExpArrayIndex = -1) diff --git a/SomethingNeedDoing/Misc/CommandInterface.cs b/SomethingNeedDoing/Misc/CommandInterface.cs index c1fb6e68..1f577aaa 100644 --- a/SomethingNeedDoing/Misc/CommandInterface.cs +++ b/SomethingNeedDoing/Misc/CommandInterface.cs @@ -5,12 +5,11 @@ using System.Runtime.InteropServices; using System.Text.RegularExpressions; using Dalamud.Game.ClientState.Conditions; -using Dalamud.Logging; using ECommons; using ECommons.DalamudServices; using FFXIVClientStructs.FFXIV.Client.Game; +using FFXIVClientStructs.FFXIV.Client.Game.Object; using FFXIVClientStructs.FFXIV.Client.Game.UI; -using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel; using FFXIVClientStructs.FFXIV.Client.System.Framework; using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Client.UI.Agent; @@ -19,7 +18,6 @@ using Lumina.Excel.GeneratedSheets; using Lumina.Text; using SomethingNeedDoing.Exceptions; -using SomethingNeedDoing.Interface; using SomethingNeedDoing.IPC; namespace SomethingNeedDoing.Misc; @@ -546,9 +544,60 @@ private unsafe (uint Progress, uint Quality) GetActionResult(uint id) public uint GetClassJobId() => Svc.ClientState.LocalPlayer!.ClassJob.Id; - public float GetPlayerRawXPos() => Svc.ClientState.LocalPlayer!.Position.X; - public float GetPlayerRawYPos() => Svc.ClientState.LocalPlayer!.Position.Y; - public float GetPlayerRawZPos() => Svc.ClientState.LocalPlayer!.Position.Z; + private static readonly unsafe IntPtr pronounModule = (IntPtr)Framework.Instance()->GetUiModule()->GetPronounModule(); + private static readonly unsafe delegate* unmanaged getGameObjectFromPronounID = (delegate* unmanaged)Service.SigScanner.ScanText("E8 ?? ?? ?? ?? 48 8B D8 48 85 C0 0F 85 ?? ?? ?? ?? 8D 4F DD"); + public static unsafe GameObject* GetGameObjectFromPronounID(uint id) => getGameObjectFromPronounID(pronounModule, id); + + public float GetPlayerRawXPos(string character = "") + { + if (!character.IsNullOrEmpty()) + { + unsafe + { + if (int.TryParse(character, out var p)) + { + var go = GetGameObjectFromPronounID((uint)(p + 42)); + return go != null ? go->Position.X : -1; + } + else return Svc.Objects.Where(x => x.IsTargetable).FirstOrDefault(x => x.Name.ToString().Equals(character))?.Position.X ?? -1; + } + } + return Svc.ClientState.LocalPlayer!.Position.X; + } + + public float GetPlayerRawYPos(string character = "") + { + if (!character.IsNullOrEmpty()) + { + unsafe + { + if (int.TryParse(character, out var p)) + { + var go = GetGameObjectFromPronounID((uint)(p + 42)); + return go != null ? go->Position.Y : -1; + } + else return Svc.Objects.Where(x => x.IsTargetable).FirstOrDefault(x => x.Name.ToString().Equals(character))?.Position.Y ?? -1; + } + } + return Svc.ClientState.LocalPlayer!.Position.Y; + } + + public float GetPlayerRawZPos(string character = "") + { + if (!character.IsNullOrEmpty()) + { + unsafe + { + if (int.TryParse(character, out var p)) + { + var go = GetGameObjectFromPronounID((uint)(p + 42)); + return go != null ? go->Position.Z : -1; + } + else return Svc.Objects.Where(x => x.IsTargetable).FirstOrDefault(x => x.Name.ToString().Equals(character))?.Position.Z ?? -1; + } + } + return Svc.ClientState.LocalPlayer!.Position.Z; + } public float GetDistanceToPoint(float x, float y, float z) => Vector3.Distance(Svc.ClientState.LocalPlayer!.Position, new Vector3(x, y, z));