From 520cd4bddc5cd1d334f31941be2d35d9b007eb7e Mon Sep 17 00:00:00 2001 From: goat <16760685+goaaats@users.noreply.github.com> Date: Thu, 30 Apr 2020 14:10:02 +0200 Subject: [PATCH] feat: add Customize to Chara --- Dalamud.Injector/Dalamud.Injector.csproj | 83 +++++----- Dalamud/Dalamud.csproj | 148 +++++++++--------- .../Game/ClientState/Actors/CustomizeIndex.cs | 41 +++++ .../Game/ClientState/Actors/Types/Chara.cs | 5 + Dalamud/Game/ClientState/Structs/Actor.cs | 12 +- Dalamud/Interface/DalamudDataWindow.cs | 2 +- 6 files changed, 172 insertions(+), 119 deletions(-) create mode 100644 Dalamud/Game/ClientState/Actors/CustomizeIndex.cs diff --git a/Dalamud.Injector/Dalamud.Injector.csproj b/Dalamud.Injector/Dalamud.Injector.csproj index 2f5adf457..cf79dd174 100644 --- a/Dalamud.Injector/Dalamud.Injector.csproj +++ b/Dalamud.Injector/Dalamud.Injector.csproj @@ -1,41 +1,46 @@ - - AnyCPU - net48 - 8.0 - AnyCPU;x64 - - - Exe - $(SolutionDir)/bin - false - true - Portable - - - true - 4.9.3.0 - 4.9.3.0 - XIVLauncher addon injection - 4.9.3.0 - - - - - - false - - - dalamud.ico - - - - - - - - - - - + + AnyCPU + net48 + 8.0 + AnyCPU;x64 + + + Exe + $(SolutionDir)/bin + false + true + Portable + + + true + 4.9.3.0 + 4.9.3.0 + XIVLauncher addon injection + 4.9.3.0 + + + + + + $(MSBuildProjectDirectory)\ + $(AppOutputBase)=C:\goatsoft\companysecrets\injector\ + true + + + false + + + dalamud.ico + + + + + + + + + + + diff --git a/Dalamud/Dalamud.csproj b/Dalamud/Dalamud.csproj index ead306bc1..e8fd28ddf 100644 --- a/Dalamud/Dalamud.csproj +++ b/Dalamud/Dalamud.csproj @@ -1,79 +1,73 @@ - - AnyCPU - net472 - 8.0 - AnyCPU;x64 - - - Library - - false - true - Portable - - - true - 4.9.3.0 - 4.9.3.0 - 4.9.3.0 - - - - - - $(SolutionDir)\bin\Dalamud.xml - - - $(SolutionDir)\bin\Dalamud.xml - - - $(SolutionDir)\bin\Dalamud.xml - - - $(SolutionDir)bin\Dalamud.xml - - - false - - - - - - - - - - - - - - - - - - - - - - - - True - True - Resources.resx - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - - - - - - + + AnyCPU + net472 + 8.0 + AnyCPU;x64 + + + Library + + false + true + Portable + $(SolutionDir)\bin\Dalamud.xml + + + true + 4.9.3.0 + 4.9.3.0 + 4.9.3.0 + + + + + + $(MSBuildProjectDirectory)\ + $(AppOutputBase)=C:\goatsoft\companysecrets\dalamud\ + true + + + false + + + + + + + + + + + + + + + + + + + + + + + + True + True + Resources.resx + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + + + + + diff --git a/Dalamud/Game/ClientState/Actors/CustomizeIndex.cs b/Dalamud/Game/ClientState/Actors/CustomizeIndex.cs new file mode 100644 index 000000000..93553f0b7 --- /dev/null +++ b/Dalamud/Game/ClientState/Actors/CustomizeIndex.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Dalamud.Game.ClientState.Actors +{ + /// + /// This enum describes the indices of the Customize array. + /// + // TODO: This may need some rework since it may not be entirely accurate (stolen from Sapphire) + public enum CustomizeIndex { + Race = 0x00, + Gender = 0x01, + Tribe = 0x04, + Height = 0x03, + ModelType = 0x02, // Au Ra: changes horns/tails, everything else: seems to drastically change appearance (flip between two sets, odd/even numbers). sometimes retains hairstyle and other features + FaceType = 0x05, + HairStyle = 0x06, + HasHighlights = 0x07, // negative to enable, positive to disable + SkinColor = 0x08, + EyeColor = 0x09, // color of character's right eye + HairColor = 0x0A, // main color + HairColor2 = 0x0B, // highlights color + FaceFeatures = 0x0C, // seems to be a toggle, (-odd and +even for large face covering), opposite for small + FaceFeaturesColor = 0x0D, + Eyebrows = 0x0E, + EyeColor2 = 0x0F, // color of character's left eye + EyeShape = 0x10, + NoseShape = 0x11, + JawShape = 0x12, + LipStyle = 0x13, // lip colour depth and shape (negative values around -120 darker/more noticeable, positive no colour) + LipColor = 0x14, + RaceFeatureSize = 0x15, + RaceFeatureType = 0x16, // negative or out of range tail shapes for race result in no tail (e.g. Au Ra has max of 4 tail shapes), incorrect value can crash client + BustSize = 0x17, // char creator allows up to max of 100, i set to 127 cause who wouldnt but no visible difference + Facepaint = 0x18, + FacepaintColor = 0x19, + } +} diff --git a/Dalamud/Game/ClientState/Actors/Types/Chara.cs b/Dalamud/Game/ClientState/Actors/Types/Chara.cs index 45471e719..06b0657f9 100644 --- a/Dalamud/Game/ClientState/Actors/Types/Chara.cs +++ b/Dalamud/Game/ClientState/Actors/Types/Chara.cs @@ -43,5 +43,10 @@ namespace Dalamud.Game.ClientState.Actors.Types { /// The maximum MP of this Chara. /// public int MaxMp => this.actorStruct.MaxMp; + + /// + /// Byte array describing the visual appearance of this Chara. Indexed by . + /// + public byte[] Customize => this.actorStruct.Customize; } } diff --git a/Dalamud/Game/ClientState/Structs/Actor.cs b/Dalamud/Game/ClientState/Structs/Actor.cs index 934ba630f..89308a2f2 100644 --- a/Dalamud/Game/ClientState/Structs/Actor.cs +++ b/Dalamud/Game/ClientState/Structs/Actor.cs @@ -13,7 +13,9 @@ namespace Dalamud.Game.ClientState.Structs /// [StructLayout(LayoutKind.Explicit)] public struct Actor { - [FieldOffset(0x30)] [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 30)] public string Name; + [FieldOffset(0x30)] [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 30)] + public string Name; + [FieldOffset(116)] public int ActorId; [FieldOffset(128)] public int DataId; [FieldOffset(132)] public int OwnerId; @@ -24,9 +26,15 @@ 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(0x17B8)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 28)] public byte[] Customize; + [FieldOffset(0x17F8)] public int TargetActorId; + // This field can't be correctly aligned, so we have to cut it manually. - [FieldOffset(0x17d0)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)] public byte[] CompanyTag; + [FieldOffset(0x17d0)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)] + public byte[] CompanyTag; + [FieldOffset(0x1868)] public int NameId; [FieldOffset(0x1884)] public byte CurrentWorld; [FieldOffset(0x1886)] public byte HomeWorld; diff --git a/Dalamud/Interface/DalamudDataWindow.cs b/Dalamud/Interface/DalamudDataWindow.cs index 59284f113..8b8828676 100644 --- a/Dalamud/Interface/DalamudDataWindow.cs +++ b/Dalamud/Interface/DalamudDataWindow.cs @@ -105,7 +105,7 @@ namespace Dalamud.Interface if (actor is Chara chara) stateString += - $" Level: {chara.Level} ClassJob: {chara.ClassJob.GameData.Name} CHP: {chara.CurrentHp} MHP: {chara.MaxHp} CMP: {chara.CurrentMp} MMP: {chara.MaxMp}\n"; + $" Level: {chara.Level} ClassJob: {chara.ClassJob.GameData.Name} CHP: {chara.CurrentHp} MHP: {chara.MaxHp} CMP: {chara.CurrentMp} MMP: {chara.MaxMp}\n Customize: {BitConverter.ToString(chara.Customize).Replace("-", " ")}\n"; if (actor is PlayerCharacter pc) stateString +=