feat: add Customize to Chara

This commit is contained in:
goat 2020-04-30 14:10:02 +02:00
parent 0800cc4e91
commit 520cd4bddc
6 changed files with 172 additions and 119 deletions

View file

@ -1,41 +1,46 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Label="Target"> <PropertyGroup Label="Target">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<TargetFramework>net48</TargetFramework> <TargetFramework>net48</TargetFramework>
<LangVersion>8.0</LangVersion> <LangVersion>8.0</LangVersion>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Label="Build"> <PropertyGroup Label="Build">
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<OutputPath>$(SolutionDir)/bin</OutputPath> <OutputPath>$(SolutionDir)/bin</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>Portable</DebugType> <DebugType>Portable</DebugType>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Label="Feature"> <PropertyGroup Label="Feature">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyVersion>4.9.3.0</AssemblyVersion> <AssemblyVersion>4.9.3.0</AssemblyVersion>
<FileVersion>4.9.3.0</FileVersion> <FileVersion>4.9.3.0</FileVersion>
<Description>XIVLauncher addon injection</Description> <Description>XIVLauncher addon injection</Description>
<Version>4.9.3.0</Version> <Version>4.9.3.0</Version>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile></DocumentationFile> <DocumentationFile></DocumentationFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup Condition="'$(Configuration)'=='Release'">
<GeneratePackageOnBuild>false</GeneratePackageOnBuild> <AppOutputBase>$(MSBuildProjectDirectory)\</AppOutputBase>
<PackageIcon></PackageIcon> <PathMap>$(AppOutputBase)=C:\goatsoft\companysecrets\injector\</PathMap>
<PackageIconUrl /> <Deterministic>true</Deterministic>
<ApplicationIcon>dalamud.ico</ApplicationIcon> </PropertyGroup>
</PropertyGroup> <PropertyGroup>
<ItemGroup> <GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PackageReference Include="EasyHook" Version="2.7.6270" /> <PackageIcon></PackageIcon>
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" /> <PackageIconUrl />
</ItemGroup> <ApplicationIcon>dalamud.ico</ApplicationIcon>
<ItemGroup> </PropertyGroup>
<ProjectReference Include="..\Dalamud\Dalamud.csproj" /> <ItemGroup>
</ItemGroup> <PackageReference Include="EasyHook" Version="2.7.6270" />
<ItemGroup> <PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<Reference Include="System.Windows.Forms" /> </ItemGroup>
</ItemGroup> <ItemGroup>
<ProjectReference Include="..\Dalamud\Dalamud.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Windows.Forms" />
</ItemGroup>
</Project> </Project>

View file

@ -1,79 +1,73 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Label="Target"> <PropertyGroup Label="Target">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<TargetFramework>net472</TargetFramework> <TargetFramework>net472</TargetFramework>
<LangVersion>8.0</LangVersion> <LangVersion>8.0</LangVersion>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Label="Build"> <PropertyGroup Label="Build">
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<OutputPath></OutputPath> <OutputPath></OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>Portable</DebugType> <DebugType>Portable</DebugType>
</PropertyGroup> <DocumentationFile>$(SolutionDir)\bin\Dalamud.xml</DocumentationFile>
<PropertyGroup Label="Feature"> </PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <PropertyGroup Label="Feature">
<AssemblyVersion>4.9.3.0</AssemblyVersion> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Version>4.9.3.0</Version> <AssemblyVersion>4.9.3.0</AssemblyVersion>
<FileVersion>4.9.3.0</FileVersion> <Version>4.9.3.0</Version>
</PropertyGroup> <FileVersion>4.9.3.0</FileVersion>
<ItemGroup Label="Resources"> </PropertyGroup>
<None Include="$(SolutionDir)/Resources/**/*" CopyToOutputDirectory="PreserveNewest" Visible="false" /> <ItemGroup Label="Resources">
</ItemGroup> <None Include="$(SolutionDir)/Resources/**/*" CopyToOutputDirectory="PreserveNewest" Visible="false" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> </ItemGroup>
<DocumentationFile>$(SolutionDir)\bin\Dalamud.xml</DocumentationFile> <PropertyGroup Condition="'$(Configuration)'=='Release'">
</PropertyGroup> <AppOutputBase>$(MSBuildProjectDirectory)\</AppOutputBase>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PathMap>$(AppOutputBase)=C:\goatsoft\companysecrets\dalamud\</PathMap>
<DocumentationFile>$(SolutionDir)\bin\Dalamud.xml</DocumentationFile> <Deterministic>true</Deterministic>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> <PropertyGroup>
<DocumentationFile>$(SolutionDir)\bin\Dalamud.xml</DocumentationFile> <GeneratePackageOnBuild>false</GeneratePackageOnBuild>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemGroup>
<DocumentationFile>$(SolutionDir)bin\Dalamud.xml</DocumentationFile> <Compile Remove="Resources\**" />
</PropertyGroup> <EmbeddedResource Remove="Resources\**" />
<PropertyGroup> <None Remove="Resources\**" />
<GeneratePackageOnBuild>false</GeneratePackageOnBuild> </ItemGroup>
</PropertyGroup> <ItemGroup>
<ItemGroup> <PackageReference Include="CheapLoc" Version="1.1.3" />
<Compile Remove="Resources\**" /> <PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<EmbeddedResource Remove="Resources\**" /> <PackageReference Include="Lumina" Version="1.1.1" />
<None Remove="Resources\**" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
</ItemGroup> <PackageReference Include="PropertyChanged.Fody" Version="2.6.1" />
<ItemGroup> <PackageReference Include="Serilog" Version="2.6.0" />
<PackageReference Include="CheapLoc" Version="1.1.3" /> <PackageReference Include="Serilog.Sinks.Async" Version="1.1.0" />
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" /> <PackageReference Include="Serilog.Sinks.File" Version="4.0.0" />
<PackageReference Include="Lumina" Version="1.1.1" /> <PackageReference Include="EasyHook" Version="2.7.6270" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" /> <PackageReference Include="SharpDX.Desktop" Version="4.2.0" />
<PackageReference Include="PropertyChanged.Fody" Version="2.6.1" /> </ItemGroup>
<PackageReference Include="Serilog" Version="2.6.0" /> <ItemGroup>
<PackageReference Include="Serilog.Sinks.Async" Version="1.1.0" /> <Reference Include="System.Net.Http" />
<PackageReference Include="Serilog.Sinks.File" Version="4.0.0" /> </ItemGroup>
<PackageReference Include="EasyHook" Version="2.7.6270" /> <ItemGroup>
<PackageReference Include="SharpDX.Desktop" Version="4.2.0" /> <Compile Update="Properties\Resources.Designer.cs">
</ItemGroup> <DesignTime>True</DesignTime>
<ItemGroup> <AutoGen>True</AutoGen>
<Reference Include="System.Net.Http" /> <DependentUpon>Resources.resx</DependentUpon>
</ItemGroup> </Compile>
<ItemGroup> </ItemGroup>
<Compile Update="Properties\Resources.Designer.cs"> <ItemGroup>
<DesignTime>True</DesignTime> <EmbeddedResource Update="Properties\Resources.resx">
<AutoGen>True</AutoGen> <Generator>ResXFileCodeGenerator</Generator>
<DependentUpon>Resources.resx</DependentUpon> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</Compile> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx"> <ProjectReference Include="..\lib\Discord.Net\src\Discord.Net.Rest\Discord.Net.Rest.csproj" />
<Generator>ResXFileCodeGenerator</Generator> <ProjectReference Include="..\lib\Discord.Net\src\Discord.Net.WebSocket\Discord.Net.WebSocket.csproj" />
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <ProjectReference Include="..\lib\ImGuiScene\deps\ImGui.NET\src\ImGui.NET-472\ImGui.NET-472.csproj" />
</EmbeddedResource> <ProjectReference Include="..\lib\ImGuiScene\deps\SDL2-CS\SDL2-CS.csproj" />
</ItemGroup> <ProjectReference Include="..\lib\ImGuiScene\ImGuiScene\ImGuiScene.csproj" />
<ItemGroup> </ItemGroup>
<ProjectReference Include="..\lib\Discord.Net\src\Discord.Net.Rest\Discord.Net.Rest.csproj" />
<ProjectReference Include="..\lib\Discord.Net\src\Discord.Net.WebSocket\Discord.Net.WebSocket.csproj" />
<ProjectReference Include="..\lib\ImGuiScene\deps\ImGui.NET\src\ImGui.NET-472\ImGui.NET-472.csproj" />
<ProjectReference Include="..\lib\ImGuiScene\deps\SDL2-CS\SDL2-CS.csproj" />
<ProjectReference Include="..\lib\ImGuiScene\ImGuiScene\ImGuiScene.csproj" />
</ItemGroup>
</Project> </Project>

View file

@ -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
{
/// <summary>
/// This enum describes the indices of the Customize array.
/// </summary>
// 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,
}
}

View file

@ -43,5 +43,10 @@ namespace Dalamud.Game.ClientState.Actors.Types {
/// The maximum MP of this Chara. /// The maximum MP of this Chara.
/// </summary> /// </summary>
public int MaxMp => this.actorStruct.MaxMp; public int MaxMp => this.actorStruct.MaxMp;
/// <summary>
/// Byte array describing the visual appearance of this Chara. Indexed by <see cref="CustomizeIndex"/>.
/// </summary>
public byte[] Customize => this.actorStruct.Customize;
} }
} }

View file

@ -13,7 +13,9 @@ namespace Dalamud.Game.ClientState.Structs
/// </summary> /// </summary>
[StructLayout(LayoutKind.Explicit)] [StructLayout(LayoutKind.Explicit)]
public struct Actor { 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(116)] public int ActorId;
[FieldOffset(128)] public int DataId; [FieldOffset(128)] public int DataId;
[FieldOffset(132)] public int OwnerId; [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(145)] public byte PlayerTargetStatus; // This is some kind of enum
[FieldOffset(146)] public byte YalmDistanceFromPlayerY; // and the other is z distance [FieldOffset(146)] public byte YalmDistanceFromPlayerY; // and the other is z distance
[FieldOffset(160)] public Position3 Position; [FieldOffset(160)] public Position3 Position;
[FieldOffset(0x17B8)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 28)] public byte[] Customize;
[FieldOffset(0x17F8)] public int TargetActorId; [FieldOffset(0x17F8)] public int TargetActorId;
// This field can't be correctly aligned, so we have to cut it manually. // 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(0x1868)] public int NameId;
[FieldOffset(0x1884)] public byte CurrentWorld; [FieldOffset(0x1884)] public byte CurrentWorld;
[FieldOffset(0x1886)] public byte HomeWorld; [FieldOffset(0x1886)] public byte HomeWorld;

View file

@ -105,7 +105,7 @@ namespace Dalamud.Interface
if (actor is Chara chara) if (actor is Chara chara)
stateString += 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) if (actor is PlayerCharacter pc)
stateString += stateString +=