From 8e5ed60c7994f1ef091048572fec5ccd36578374 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 5 May 2023 16:17:53 +0200 Subject: [PATCH] Add hook for dismount sounds..? --- .../PathResolving/AnimationHookService.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Penumbra/Interop/PathResolving/AnimationHookService.cs b/Penumbra/Interop/PathResolving/AnimationHookService.cs index 2add5771..b9250502 100644 --- a/Penumbra/Interop/PathResolving/AnimationHookService.cs +++ b/Penumbra/Interop/PathResolving/AnimationHookService.cs @@ -47,6 +47,7 @@ public unsafe class AnimationHookService : IDisposable _scheduleClipUpdateHook.Enable(); _unkMountAnimationHook.Enable(); _unkParasolAnimationHook.Enable(); + _dismountHook.Enable(); } public bool HandleFiles(ResourceType type, Utf8GamePath _, out ResolveData resolveData) @@ -103,6 +104,7 @@ public unsafe class AnimationHookService : IDisposable _scheduleClipUpdateHook.Dispose(); _unkMountAnimationHook.Dispose(); _unkParasolAnimationHook.Dispose(); + _dismountHook.Dispose(); } /// Characters load some of their voice lines or whatever with this function. @@ -333,4 +335,30 @@ public unsafe class AnimationHookService : IDisposable _unkParasolAnimationHook!.Original(drawObject, unk1); _animationLoadData.Value = last; } + + [Signature("E8 ?? ?? ?? ?? F6 43 ?? ?? 74 ?? 48 8B CB", DetourName = nameof(DismountDetour))] + private readonly Hook _dismountHook = null; + + private delegate void DismountDelegate(nint a1, nint a2); + + private void DismountDetour(nint a1, nint a2) + { + if (a1 == nint.Zero) + { + _dismountHook!.Original(a1, a2); + return; + } + + var gameObject = *(GameObject**)(a1 + 8); + if (gameObject == null) + { + _dismountHook!.Original(a1, a2); + return; + } + + var last = _animationLoadData.Value; + _animationLoadData.Value = _collectionResolver.IdentifyCollection(gameObject, true); + _dismountHook!.Original(a1, a2); + _animationLoadData.Value = last; + } }