Skip to content

Commit

Permalink
Update for patch 6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
chirpxiv committed Jan 11, 2023
1 parent b84f74f commit 0ef3ac7
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Ktisis/History/ActorBone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public unsafe override void Update(bool undo) {
}

var bone = model->Skeleton->GetBone(historyBone!.Partial, historyBone.Index);
var boneName = bone.HkaBone.Name.String;
var boneName = bone.HkaBone.Name.String ?? "";
var boneTransform = bone.AccessModelSpace(PropagateOrNot.DontPropagate);

// Write our updated matrix to memory.
Expand Down
2 changes: 1 addition & 1 deletion Ktisis/Interface/Input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,6 @@ private static void ReadPurposesStates() {
return (purpose: p, state);
}).ToDictionary(kp => kp.purpose, kp => kp.state);
}
private unsafe static bool IsChatInputActive() => ((UIModule*)Services.GameGui.GetUIModule())->GetRaptureAtkModule()->AtkModule.IsTextInputActive() == 1;
private unsafe static bool IsChatInputActive() => ((UIModule*)Services.GameGui.GetUIModule())->GetRaptureAtkModule()->AtkModule.IsTextInputActive();
}
}
2 changes: 1 addition & 1 deletion Ktisis/Interface/Windows/ConfigGui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public static unsafe void DrawBonesOffset(Configuration cfg) {
cfg.CustomBoneOffset.Add(targetBodyType,new());

if (GuiHelpers.DragFloat3FillWidth($"##currentTargetOffset", false, null, ref targetBoneOffset, .00001f, "%.5f"))
cfg.CustomBoneOffset[targetBodyType][bone.HkaBone.Name.String] = targetBoneOffset;
cfg.CustomBoneOffset[targetBodyType][bone.HkaBone.Name.String!] = targetBoneOffset;
} else {
ImGuiComponents.HelpMarker("Select a Bone to start adjusting its position.");
}
Expand Down
2 changes: 1 addition & 1 deletion Ktisis/Interface/Windows/Workspace/EditGaze.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
using Dalamud.Interface;
using Dalamud.Interface.Components;

using Ktisis.Util;
using Ktisis.Overlay;
using Ktisis.Structs.Actor;
using Ktisis.Structs.Extensions;
using Ktisis.Util;

namespace Ktisis.Interface.Windows.Workspace {
public static class EditGaze {
Expand Down
2 changes: 1 addition & 1 deletion Ktisis/Interop/Hooks/ActorHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal static class ActorHooks {
internal static Hook<ControlGazeDelegate> ControlGazeHook = null!;

internal unsafe static IntPtr ControlGaze(IntPtr a1) {
var actor = (Actor*)(a1 - 0xC10);
var actor = (Actor*)(a1 - 0xC30);
EditGaze.Apply(actor);
return ControlGazeHook.Original(a1);
}
Expand Down
4 changes: 2 additions & 2 deletions Ktisis/Interop/Methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal class Methods {
// Change actor equipment
// a1 = Actor + 0x6D0, a2 = EquipIndex, a3 = EquipItem

internal delegate IntPtr ChangeEquipDelegate(IntPtr writeTo, EquipIndex index, ItemEquip item);
internal delegate void ChangeEquipDelegate(IntPtr writeTo, EquipIndex index, ItemEquip item);
internal static ChangeEquipDelegate? ActorChangeEquip;

internal delegate void ChangeWeaponDelegate(IntPtr writeTo, int slot, WeaponEquip weapon, byte a4, byte a5, byte a6, byte a7); // a4-a7 is always 0,1,0,0.
Expand All @@ -34,7 +34,7 @@ private static TDelegate Retrieve<TDelegate>(string sig)

internal static void Init() {
ActorLookAt = Retrieve<LookAtDelegate>("40 53 55 57 41 56 41 57 48 83 EC 70");
ActorChangeEquip = Retrieve<ChangeEquipDelegate>("E8 ?? ?? ?? ?? 41 B5 01 FF C3");
ActorChangeEquip = Retrieve<ChangeEquipDelegate>("E8 ?? ?? ?? ?? 41 B5 01 FF C6");
ActorChangeWeapon = Retrieve<ChangeWeaponDelegate>("E8 ?? ?? ?? ?? 80 7F 25 00");
GetMatrix = Retrieve<GetMatrixDelegate>("E8 ?? ?? ?? ?? 48 8D 4C 24 ?? 48 89 4c 24 ?? 4C 8D 4D ?? 4C 8D 44 24 ??");
}
Expand Down
1 change: 1 addition & 0 deletions Ktisis/Ktisis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Ktisis.History;
using Ktisis.Events;
using Ktisis.Overlay;
using Dalamud.Logging;

namespace Ktisis {
public sealed class Ktisis : IDalamudPlugin {
Expand Down
3 changes: 1 addition & 2 deletions Ktisis/Overlay/Skeleton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using ImGuiNET;
using ImGuizmoNET;

using Ktisis.Interface.Components.Toolbar;
using Ktisis.Interface.Windows.Toolbar;
using Ktisis.Interface.Windows.Workspace;
using Ktisis.Structs;
Expand Down Expand Up @@ -76,7 +75,7 @@ public unsafe static void Draw() {
var skeleton = pose->Skeleton;
for (var i = 1; i < skeleton->Bones.Length; i++) {
var bone = model->Skeleton->GetBone(p, i);
var boneName = bone.HkaBone.Name.String;
var boneName = bone.HkaBone.Name.String ?? "";
var parentId = bone.ParentId;

var uniqueName = bone.UniqueName;
Expand Down
2 changes: 1 addition & 1 deletion Ktisis/Services.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal class Services {

internal static Interop.Hooks.AddonManager AddonManager = null!;
internal unsafe static TargetSystem* Targets = TargetSystem.Instance();
internal unsafe static CameraManager* Camera = CameraManager.Instance();
internal unsafe static CameraManager* Camera = CameraManager.Instance;

public static void Init(DalamudPluginInterface dalamud) {
dalamud.Create<Services>();
Expand Down
14 changes: 3 additions & 11 deletions Ktisis/Structs/Actor/Actor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,16 @@ public struct Actor {

[FieldOffset(0x88)] public byte ObjectID;

[FieldOffset(0xF0)] public unsafe ActorModel* Model;
[FieldOffset(0x104)] public RenderMode RenderMode;
[FieldOffset(0x100)] public unsafe ActorModel* Model;
[FieldOffset(0x114)] public RenderMode RenderMode;
[FieldOffset(0x1B4)] public uint ModelId;

[FieldOffset(0x6E0)] public Weapon MainHand;
[FieldOffset(0x748)] public Weapon OffHand;
[FieldOffset(0x818)] public Equipment Equipment;
[FieldOffset(0x840)] public Customize Customize;

[FieldOffset(0xC20)] public ActorGaze Gaze;

[FieldOffset(0x1A68)] public byte TargetObjectID;
[FieldOffset(0x1A6C)] public byte TargetMode;
[FieldOffset(0xC40)] public ActorGaze Gaze; // Update in ActorHooks.cs as well

public unsafe string? Name => Marshal.PtrToStringAnsi((IntPtr)GameObject.GetName());

Expand All @@ -40,11 +37,6 @@ public unsafe IntPtr GetAddress() {

// Targeting

public unsafe void TargetActor(Actor* actor) {
TargetObjectID = actor->ObjectID;
TargetMode = 2;
}

public unsafe void LookAt(Gaze* tar, GazeControl bodyPart) {
if (Methods.ActorLookAt == null) return;
fixed (ActorGaze* gaze = &Gaze) {
Expand Down
2 changes: 1 addition & 1 deletion Ktisis/Structs/Actor/ActorGaze.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ public enum GazeMode : uint {

_KtisisFollowCam_ = 9
}
}
}
6 changes: 3 additions & 3 deletions Ktisis/Structs/Bones/Bone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public unsafe hkQsTransformf Transform {
set => Pose->ModelPose.Data[Index] = value;
}

public string LocaleName => Locale.GetBoneName(HkaBone.Name.String);
public string LocaleName => Locale.GetBoneName(HkaBone.Name.String ?? "Unknown");

public string UniqueId => $"{Partial}_{Index}";
public string UniqueName => $"{LocaleName}##{UniqueId}";
Expand Down Expand Up @@ -87,7 +87,7 @@ public List<Bone> GetDescendants(bool includePartials = true, bool usePartialRoo
}

public unsafe Bone? GetMirrorSibling() {
var name = HkaBone.Name.String;
var name = HkaBone.Name.String ?? "";
var prefix = name[..^2];

for (var p = 0; p < Skeleton->PartialSkeletonCount; p++) {
Expand All @@ -99,7 +99,7 @@ public List<Bone> GetDescendants(bool includePartials = true, bool usePartialRoo
for (var i = 1; i < poseSkeleton->Bones.Length; i++) {
var potentialBone = new Bone(Skeleton, p, i);
if (potentialBone == null) continue;
var pBName = potentialBone.HkaBone.Name.String;
var pBName = potentialBone.HkaBone.Name.String ?? "";
if (pBName[..^2] == prefix && pBName != name)
return potentialBone;
}
Expand Down
2 changes: 1 addition & 1 deletion Ktisis/Structs/Bones/CustomOffset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public unsafe static Vector3 GetBoneOffset(Bone bone) {

if (!Ktisis.Configuration.CustomBoneOffset.TryGetValue(GetRaceGenderFromActor(target), out var bonesOffsets))
return new();
if (!bonesOffsets.TryGetValue(bone.HkaBone.Name.String, out Vector3 offset))
if (!bonesOffsets.TryGetValue(bone.HkaBone.Name.String!, out Vector3 offset))
return new();
return offset;
}
Expand Down
4 changes: 2 additions & 2 deletions Ktisis/Structs/Poses/PoseContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public unsafe void Store(Skeleton* modelSkeleton) {
continue; // this would be a mess, unsupported by anam poses anyway

var bone = modelSkeleton->GetBone(p, i);
var name = bone.HkaBone.Name.String;
var name = bone.HkaBone.Name.String!;

var model = bone.AccessModelSpace();
this[name] = Transform.FromHavok(*model);
Expand All @@ -50,7 +50,7 @@ public unsafe void ApplyToPartial(Skeleton* modelSkeleton, int p, PoseTransforms
var skeleton = pose->Skeleton;
for (var i = 0; i < skeleton->Bones.Length; i++) {
var bone = modelSkeleton->GetBone(p, i);
var name = bone.HkaBone.Name.String;
var name = bone.HkaBone.Name.String ?? "";

if (TryGetValue(name, out var val)) {
var model = bone.AccessModelSpace();
Expand Down

0 comments on commit 0ef3ac7

Please sign in to comment.