From f1b51708b406ad46b2a6262be135c16266ac5d28 Mon Sep 17 00:00:00 2001 From: meli <57847713+ff-meli@users.noreply.github.com> Date: Thu, 30 Apr 2020 16:50:34 -0700 Subject: [PATCH 1/5] Update ActorTable offsets for hp/mp, add ui (display-only.. probably) status effects --- Dalamud/Game/ClientState/Actors/Types/Chara.cs | 2 +- Dalamud/Game/ClientState/Structs/Actor.cs | 12 ++++++++---- .../Game/ClientState/Structs/StatusEffect.cs | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 Dalamud/Game/ClientState/Structs/StatusEffect.cs diff --git a/Dalamud/Game/ClientState/Actors/Types/Chara.cs b/Dalamud/Game/ClientState/Actors/Types/Chara.cs index 06b0657f9..467ad087a 100644 --- a/Dalamud/Game/ClientState/Actors/Types/Chara.cs +++ b/Dalamud/Game/ClientState/Actors/Types/Chara.cs @@ -42,7 +42,7 @@ namespace Dalamud.Game.ClientState.Actors.Types { /// /// The maximum MP of this Chara. /// - public int MaxMp => this.actorStruct.MaxMp; + public int MaxMp => 10000; // Currently hardcoded because the value in actorStruct is very questionable. /// /// Byte array describing the visual appearance of this Chara. Indexed by . diff --git a/Dalamud/Game/ClientState/Structs/Actor.cs b/Dalamud/Game/ClientState/Structs/Actor.cs index 89308a2f2..745eb7e76 100644 --- a/Dalamud/Game/ClientState/Structs/Actor.cs +++ b/Dalamud/Game/ClientState/Structs/Actor.cs @@ -38,12 +38,16 @@ namespace Dalamud.Game.ClientState.Structs [FieldOffset(0x1868)] public int NameId; [FieldOffset(0x1884)] public byte CurrentWorld; [FieldOffset(0x1886)] public byte HomeWorld; - [FieldOffset(6328)] public int CurrentHp; - [FieldOffset(6332)] public int MaxHp; - [FieldOffset(6336)] public int CurrentMp; - [FieldOffset(6340)] public int MaxMp; + [FieldOffset(0x1898)] public int CurrentHp; + [FieldOffset(0x189C)] public int MaxHp; + [FieldOffset(0x18A0)] public int CurrentMp; + // This value is weird. It seems to change semi-randomly between 0 and 10k, definitely + // in response to mp-using events, but it doesn't often have a value and the changing seems + // somewhat arbitrary. + [FieldOffset(0x18AA)] public int MaxMp; [FieldOffset(6358)] public byte ClassJob; [FieldOffset(6360)] public byte Level; + [FieldOffset(0x1958)][MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] public StatusEffect[] UIStatusEffects; } } diff --git a/Dalamud/Game/ClientState/Structs/StatusEffect.cs b/Dalamud/Game/ClientState/Structs/StatusEffect.cs new file mode 100644 index 000000000..584c5c48d --- /dev/null +++ b/Dalamud/Game/ClientState/Structs/StatusEffect.cs @@ -0,0 +1,18 @@ +using System; +using System.Runtime.InteropServices; + +namespace Dalamud.Game.ClientState.Structs +{ + /// + /// Native memory representation of a FFXIV status effect. + /// + [StructLayout(LayoutKind.Sequential)] + public struct StatusEffect + { + public short EffectId; + public byte StackCount; + public byte Param; + public float Duration; + public int OwnerId; + } +} From 2e39dd07e334f0bba71c4194bbb88d9b394bf183 Mon Sep 17 00:00:00 2001 From: meli <57847713+ff-meli@users.noreply.github.com> Date: Thu, 30 Apr 2020 18:34:42 -0700 Subject: [PATCH 2/5] Add actor rotation --- Dalamud/Game/ClientState/Actors/Types/Actor.cs | 6 ++++++ Dalamud/Game/ClientState/Structs/Actor.cs | 1 + Dalamud/Interface/DalamudDataWindow.cs | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Dalamud/Game/ClientState/Actors/Types/Actor.cs b/Dalamud/Game/ClientState/Actors/Types/Actor.cs index 2289a8b30..caed4962d 100644 --- a/Dalamud/Game/ClientState/Actors/Types/Actor.cs +++ b/Dalamud/Game/ClientState/Actors/Types/Actor.cs @@ -34,6 +34,12 @@ namespace Dalamud.Game.ClientState.Actors.Types { /// public Position3 Position => this.actorStruct.Position; + /// + /// Rotation of this .
+ /// This ranges from -pi to pi radians. + ///
+ public float Rotation => this.actorStruct.Rotation; + /// /// Displayname of this Actor. /// diff --git a/Dalamud/Game/ClientState/Structs/Actor.cs b/Dalamud/Game/ClientState/Structs/Actor.cs index 745eb7e76..b8cf25680 100644 --- a/Dalamud/Game/ClientState/Structs/Actor.cs +++ b/Dalamud/Game/ClientState/Structs/Actor.cs @@ -26,6 +26,7 @@ namespace Dalamud.Game.ClientState.Structs [FieldOffset(145)] public byte PlayerTargetStatus; // This is some kind of enum [FieldOffset(146)] public byte YalmDistanceFromPlayerY; // and the other is z distance [FieldOffset(160)] public Position3 Position; + [FieldOffset(176)] public float Rotation; // Rotation around the vertical axis (yaw), from -pi to pi radians [FieldOffset(0x17B8)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 28)] public byte[] Customize; diff --git a/Dalamud/Interface/DalamudDataWindow.cs b/Dalamud/Interface/DalamudDataWindow.cs index 8b8828676..aefbe4e0b 100644 --- a/Dalamud/Interface/DalamudDataWindow.cs +++ b/Dalamud/Interface/DalamudDataWindow.cs @@ -98,7 +98,7 @@ namespace Dalamud.Interface continue; stateString += - $"{actor.Address.ToInt64():X}:{actor.ActorId:X}[{i}] - {actor.ObjectKind} - {actor.Name} - X{actor.Position.X} Y{actor.Position.Y} Z{actor.Position.Z} D{actor.YalmDistanceX}\n"; + $"{actor.Address.ToInt64():X}:{actor.ActorId:X}[{i}] - {actor.ObjectKind} - {actor.Name} - X{actor.Position.X} Y{actor.Position.Y} Z{actor.Position.Z} D{actor.YalmDistanceX} R{actor.Rotation}\n"; if (actor is Npc npc) stateString += $" DataId: {npc.DataId} NameId:{npc.NameId}\n"; From eafe992f4a0d7fc8a173f201926b08cb2475c6e8 Mon Sep 17 00:00:00 2001 From: Cara Date: Sun, 3 May 2020 23:39:37 +0930 Subject: [PATCH 3/5] Avoid crashing when clicking Choose with no item selected Also "Disabled" (darkened) the choose button if no item is selected. --- Dalamud/Interface/ItemSearchWindow.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Dalamud/Interface/ItemSearchWindow.cs b/Dalamud/Interface/ItemSearchWindow.cs index ba7512088..88b89fdf0 100644 --- a/Dalamud/Interface/ItemSearchWindow.cs +++ b/Dalamud/Interface/ItemSearchWindow.cs @@ -186,15 +186,23 @@ namespace Dalamud.Interface ImGui.EndChild(); - if (ImGui.Button(Loc.Localize("Choose", "Choose"))) { - OnItemChosen?.Invoke(this, this.searchTask.Result[this.selectedItemIndex]); + // Darken choose button if it shouldn't be clickable + ImGui.PushStyleVar(ImGuiStyleVar.Alpha, this.selectedItemIndex < 0 ? 0.25f : 1); - if (this.closeOnChoose) { - this.selectedItemTex?.Dispose(); - isOpen = false; + if (ImGui.Button(Loc.Localize("Choose", "Choose"))) { + try { + OnItemChosen?.Invoke(this, this.searchTask.Result[this.selectedItemIndex]); + if (this.closeOnChoose) { + this.selectedItemTex?.Dispose(); + isOpen = false; + } + } catch (Exception ex) { + Log.Error($"Exception in Choose: {ex.Message}"); } } + ImGui.PopStyleVar(); + if (!this.closeOnChoose) { ImGui.SameLine(); if (ImGui.Button(Loc.Localize("Close", "Close"))) From b2f9aebf1f9b896c707a164f7a0681ef06224abc Mon Sep 17 00:00:00 2001 From: Cara Date: Sun, 3 May 2020 23:54:53 +0930 Subject: [PATCH 4/5] Allow xlitem searching from command --- Dalamud/Dalamud.cs | 2 +- Dalamud/Interface/ItemSearchWindow.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dalamud/Dalamud.cs b/Dalamud/Dalamud.cs index cb35b6fc7..3d39a07ab 100644 --- a/Dalamud/Dalamud.cs +++ b/Dalamud/Dalamud.cs @@ -559,7 +559,7 @@ namespace Dalamud { private bool isImguiDrawItemSearchWindow; private void OnItemLinkCommand(string command, string arguments) { - this.itemSearchCommandWindow = new ItemSearchWindow(this.Data, new UiBuilder(this.InterfaceManager, "ItemSearcher"), false); + this.itemSearchCommandWindow = new ItemSearchWindow(this.Data, new UiBuilder(this.InterfaceManager, "ItemSearcher"), false, arguments); this.itemSearchCommandWindow.OnItemChosen += (sender, item) => { var hexData = new byte[] { 0x02, 0x13, 0x06, 0xFE, 0xFF, 0xF3, 0xF3, 0xF3, 0x03, 0x02, 0x27, 0x07, 0x03, 0xF2, 0x3A, 0x2F, diff --git a/Dalamud/Interface/ItemSearchWindow.cs b/Dalamud/Interface/ItemSearchWindow.cs index ba7512088..fd16f7f06 100644 --- a/Dalamud/Interface/ItemSearchWindow.cs +++ b/Dalamud/Interface/ItemSearchWindow.cs @@ -41,11 +41,11 @@ namespace Dalamud.Interface public event EventHandler OnItemChosen; - public ItemSearchWindow(DataManager data, UiBuilder builder, bool closeOnChoose = true) { + public ItemSearchWindow(DataManager data, UiBuilder builder, bool closeOnChoose = true, string searchText = "") { this.data = data; this.builder = builder; this.closeOnChoose = closeOnChoose; - + this.searchText = searchText; while (!data.IsDataReady) Thread.Sleep(1); From 6187e3b4d6b61ec130408c4c8c2ebecff5b754fa Mon Sep 17 00:00:00 2001 From: Cara Date: Sun, 3 May 2020 23:57:00 +0930 Subject: [PATCH 5/5] Update ItemSearchWindow.cs --- Dalamud/Interface/ItemSearchWindow.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Dalamud/Interface/ItemSearchWindow.cs b/Dalamud/Interface/ItemSearchWindow.cs index fd16f7f06..8926a311b 100644 --- a/Dalamud/Interface/ItemSearchWindow.cs +++ b/Dalamud/Interface/ItemSearchWindow.cs @@ -46,6 +46,7 @@ namespace Dalamud.Interface this.builder = builder; this.closeOnChoose = closeOnChoose; this.searchText = searchText; + while (!data.IsDataReady) Thread.Sleep(1);