From a7c5d513d4438a7d6024c35d7f9d917e01c9602d Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 13 Aug 2024 15:27:32 +0200 Subject: [PATCH] Maybe fix weapon hidden state when leaving gpose or changing zones. --- Glamourer/Interop/MetaService.cs | 2 ++ Glamourer/Interop/ScalingService.cs | 2 +- Glamourer/State/StateApplier.cs | 9 +++++++-- Glamourer/State/StateEditor.cs | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Glamourer/Interop/MetaService.cs b/Glamourer/Interop/MetaService.cs index 1dc4c1a..1c79cec 100644 --- a/Glamourer/Interop/MetaService.cs +++ b/Glamourer/Interop/MetaService.cs @@ -61,7 +61,9 @@ public unsafe class MetaService : IDisposable if (!actor.IsCharacter) return; + var old = actor.AsCharacter->DrawData.IsWeaponHidden; _hideWeaponsHook.Original(&actor.AsCharacter->DrawData, (byte)(value ? 0 : 1)); + actor.AsCharacter->DrawData.IsWeaponHidden = old; } private void HideHatDetour(DrawDataContainer* drawData, uint id, byte value) diff --git a/Glamourer/Interop/ScalingService.cs b/Glamourer/Interop/ScalingService.cs index 16b9a37..c2eb32f 100644 --- a/Glamourer/Interop/ScalingService.cs +++ b/Glamourer/Interop/ScalingService.cs @@ -59,7 +59,7 @@ public unsafe class ScalingService : IDisposable private void SetupOrnamentDetour(Ornament* ornament, uint* unk1, float* unk2) { - var character = ornament->Character.GetParentCharacter(); + var character = ornament->GetParentCharacter(); if (character == null) { _setupOrnamentHook.Original(ornament, unk1, unk2); diff --git a/Glamourer/State/StateApplier.cs b/Glamourer/State/StateApplier.cs index d6d5bde..ed6f907 100644 --- a/Glamourer/State/StateApplier.cs +++ b/Glamourer/State/StateApplier.cs @@ -247,8 +247,13 @@ public class StateApplier( } case MetaIndex.WeaponState: { - foreach (var actor in data.Objects.Where(a => a.IsCharacter)) - _metaService.SetWeaponState(actor, value); + // Only apply to the GPose character because otherwise we get some weird incompatibility when leaving GPose. + if (_objects.IsInGPose) + foreach (var actor in data.Objects.Where(a => a.IsGPoseOrCutscene)) + _metaService.SetWeaponState(actor, value); + else + foreach (var actor in data.Objects.Where(a => a.IsCharacter)) + _metaService.SetWeaponState(actor, value); return; } case MetaIndex.VisorState: diff --git a/Glamourer/State/StateEditor.cs b/Glamourer/State/StateEditor.cs index 50479b2..c7867e1 100644 --- a/Glamourer/State/StateEditor.cs +++ b/Glamourer/State/StateEditor.cs @@ -251,7 +251,7 @@ public class StateEditor( var actors = Applier.ChangeMetaState(state, index, settings.Source.RequiresChange()); Glamourer.Log.Verbose( - $"Set Head Gear Visibility in state {state.Identifier.Incognito(null)} from {old} to {value}. [Affecting {actors.ToLazyString("nothing")}.]"); + $"Set {index.ToName()} in state {state.Identifier.Incognito(null)} from {old} to {value}. [Affecting {actors.ToLazyString("nothing")}.]"); StateChanged.Invoke(StateChangeType.Other, settings.Source, state, actors, new MetaTransaction(index, old, value)); }