diff --git a/Dalamud/Game/ClientState/Actors/Types/Actor.cs b/Dalamud/Game/ClientState/Actors/Types/Actor.cs index 275a5cd39..2289a8b30 100644 --- a/Dalamud/Game/ClientState/Actors/Types/Actor.cs +++ b/Dalamud/Game/ClientState/Actors/Types/Actor.cs @@ -49,5 +49,15 @@ namespace Dalamud.Game.ClientState.Actors.Types { /// possible values. /// public ObjectKind ObjectKind => this.actorStruct.ObjectKind; + + /// + /// The X distance from the local player in yalms. + /// + public byte YalmDistanceX => this.actorStruct.YalmDistanceFromPlayerX; + + /// + /// The Y distance from the local player in yalms. + /// + public byte YalmDistanceY => this.actorStruct.YalmDistanceFromPlayerY; } } diff --git a/Dalamud/Game/ClientState/Structs/Actor.cs b/Dalamud/Game/ClientState/Structs/Actor.cs index 68090891b..934ba630f 100644 --- a/Dalamud/Game/ClientState/Structs/Actor.cs +++ b/Dalamud/Game/ClientState/Structs/Actor.cs @@ -20,9 +20,9 @@ namespace Dalamud.Game.ClientState.Structs [FieldOffset(140)] public ObjectKind ObjectKind; [FieldOffset(141)] public byte SubKind; [FieldOffset(142)] public bool IsFriendly; - [FieldOffset(144)] public byte YalmDistanceFromPlayer1; // Demo says one of these is x distance + [FieldOffset(144)] public byte YalmDistanceFromPlayerX; // Demo says one of these is x distance [FieldOffset(145)] public byte PlayerTargetStatus; // This is some kind of enum - [FieldOffset(146)] public byte YalmDistanceFromPlayer2; // and the other is z distance + [FieldOffset(146)] public byte YalmDistanceFromPlayerY; // and the other is z distance [FieldOffset(160)] public Position3 Position; [FieldOffset(0x17F8)] public int TargetActorId; // This field can't be correctly aligned, so we have to cut it manually. diff --git a/Dalamud/Interface/DalamudDataWindow.cs b/Dalamud/Interface/DalamudDataWindow.cs index d55476f2b..59284f113 100644 --- a/Dalamud/Interface/DalamudDataWindow.cs +++ b/Dalamud/Interface/DalamudDataWindow.cs @@ -1,3 +1,4 @@ +using System; using System.Linq; using System.Numerics; using Dalamud.Game.Chat; @@ -18,6 +19,7 @@ namespace Dalamud.Interface private int currentKind; private bool drawActors = false; + private float maxActorDrawDistance = 20; public DalamudDataWindow(Dalamud dalamud) { this.dalamud = dalamud; @@ -87,6 +89,7 @@ namespace Dalamud.Interface stateString += $"TerritoryType: {this.dalamud.ClientState.TerritoryType}\n\n"; ImGui.Checkbox("Draw actors on screen", ref this.drawActors); + ImGui.SliderFloat("Draw Distance", ref this.maxActorDrawDistance, 2f, 40f); for (var i = 0; i < this.dalamud.ClientState.Actors.Length; i++) { var actor = this.dalamud.ClientState.Actors[i]; @@ -95,7 +98,7 @@ namespace Dalamud.Interface continue; stateString += - $"{actor.Address.ToInt64():X}:{actor.ActorId:X}[{i}] - {actor.ObjectKind} - {actor.Name} - {actor.Position.X} {actor.Position.Y} {actor.Position.Z}\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}\n"; if (actor is Npc npc) stateString += $" DataId: {npc.DataId} NameId:{npc.NameId}\n"; @@ -111,7 +114,11 @@ namespace Dalamud.Interface if (this.drawActors && this.dalamud.Framework.Gui.WorldToScreen(actor.Position, out var screenCoords)) { ImGui.PushID("ActorWindow" + i); ImGui.SetNextWindowPos(new Vector2(screenCoords.X, screenCoords.Y)); - ImGui.SetNextWindowBgAlpha(0.35f); + + if (actor.YalmDistanceX > this.maxActorDrawDistance) + continue; + + ImGui.SetNextWindowBgAlpha(Math.Max(1f - (actor.YalmDistanceX / this.maxActorDrawDistance), 0.2f)); if (ImGui.Begin("Actor" + i, ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoMouseInputs |