Skip to content

Commit df87bd2

Browse files
committed
armoury thing and onemote
1 parent 2e9dbbb commit df87bd2

File tree

5 files changed

+47
-6
lines changed

5 files changed

+47
-6
lines changed

SomethingNeedDoing/Core/Enums.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public enum TriggerEvent
7171
OnDutyStarted,
7272
OnDutyWiped,
7373
OnDutyCompleted,
74+
OnEmote,
7475
}
7576

7677
/// <summary>

SomethingNeedDoing/LuaMacro/Modules/InventoryModule.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,25 @@ public InventoryItemWrapper(uint itemId)
181181
[LuaDocs] public InventoryType Container => Item->Container;
182182
[LuaDocs] public int Slot => Item->Slot;
183183

184+
[LuaDocs]
185+
[Changelog("13.55")]
186+
public InventoryType ArmouryContainer => GetRow<Sheets.Item>(ItemId)?.EquipSlotCategory.Value switch
187+
{
188+
{ MainHand: 1 } => InventoryType.ArmoryMainHand,
189+
{ OffHand: 1 } => InventoryType.ArmoryOffHand,
190+
{ Head: 1 } => InventoryType.ArmoryHead,
191+
{ Body: 1 } => InventoryType.ArmoryBody,
192+
{ Gloves: 1 } => InventoryType.ArmoryHands,
193+
{ Legs: 1 } => InventoryType.ArmoryLegs,
194+
{ Feet: 1 } => InventoryType.ArmoryFeets,
195+
{ Ears: 1 } => InventoryType.ArmoryEar,
196+
{ Neck: 1 } => InventoryType.ArmoryNeck,
197+
{ Wrists: 1 } => InventoryType.ArmoryWrist,
198+
{ FingerL: 1 } => InventoryType.ArmoryRings,
199+
{ FingerR: 1 } => InventoryType.ArmoryRings,
200+
_ => InventoryType.Invalid
201+
};
202+
184203
[LuaDocs] public void Use() => Game.UseItem(ItemId, IsHighQuality);
185204

186205
[LuaDocs]

SomethingNeedDoing/Managers/MacroScheduler.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
using Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
44
using Dalamud.Game.Text;
55
using Dalamud.Game.Text.SeStringHandling;
6+
using Dalamud.Hooking;
67
using Dalamud.Plugin.Services;
8+
using Dalamud.Utility.Signatures;
9+
using ECommons;
10+
using FFXIVClientStructs.FFXIV.Client.Game.Object;
711
using NLua;
812
using SomethingNeedDoing.Core.Events;
913
using SomethingNeedDoing.Core.Interfaces;
@@ -43,8 +47,15 @@ public class MacroScheduler : IMacroScheduler, IDisposable
4347
/// </summary>
4448
public event EventHandler<MacroErrorEventArgs>? MacroError;
4549

50+
private unsafe delegate long OnEmoteFuncDelegate(IntPtr a1, GameObject* source, ushort emoteId, GameObjectId targetId, long a5);
51+
[Signature("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 56 48 83 EC 30 4C 8B 74 24 ?? 48 8B D9", DetourName = nameof(OnEmoteFuncDetour))]
52+
private readonly Hook<OnEmoteFuncDelegate> OnEmoteFuncHook = null!;
53+
4654
public MacroScheduler(NativeMacroEngine nativeEngine, NLuaMacroEngine luaEngine, TriggerEventManager triggerEventManager, MacroHierarchyManager hierarchyManager, IEnumerable<IDisableable> disableablePlugins)
4755
{
56+
Svc.Hook.InitializeFromAttributes(this);
57+
OnEmoteFuncHook?.Enable();
58+
4859
_nativeEngine = nativeEngine;
4960
_luaEngine = luaEngine;
5061
_triggerEventManager = triggerEventManager;
@@ -797,6 +808,14 @@ private void OnDutyCompleted(object? sender, ushort e)
797808
_ = _triggerEventManager.RaiseTriggerEvent(TriggerEvent.OnDutyCompleted);
798809
}
799810

811+
private unsafe long OnEmoteFuncDetour(IntPtr a1, GameObject* source, ushort emoteId, GameObjectId targetId, long a5)
812+
{
813+
FrameworkLogger.Verbose($"Emote performed: Source={source->NameString}, EmoteId={emoteId}, TargetId={targetId.Id}, a5={a5}");
814+
var eventData = new Dictionary<string, object> { { "SourceId", source->EntityId }, { "SourceName", source->NameString }, { "EmoteId", emoteId }, { "TargetId", targetId } };
815+
_ = _triggerEventManager.RaiseTriggerEvent(TriggerEvent.OnEmote, eventData);
816+
return OnEmoteFuncHook!.Original(a1, source, emoteId, targetId, a5);
817+
}
818+
800819
private void CheckCharacterPostProcess(IMacro macro)
801820
{
802821
if (C.ARCharacterPostProcessExcludedCharacters.Any(x => x == Svc.ClientState.LocalContentId))
@@ -933,6 +952,7 @@ public void Dispose()
933952
_addonEvents.Clear();
934953

935954
_triggerEventManager.Dispose();
955+
OnEmoteFuncHook?.Dispose();
936956
}
937957

938958
/// <inheritdoc/>

SomethingNeedDoing/SomethingNeedDoing.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<Version>0.0.0.0</Version>
55
<LangVersion>preview</LangVersion>
6+
<Platforms>x64;ARM32</Platforms>
67
</PropertyGroup>
78

89
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'">

SomethingNeedDoing/SomethingNeedDoing.sln

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SomethingNeedDoing", "Somet
66
EndProject
77
Global
88
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9-
Debug|Any CPU = Debug|Any CPU
10-
Release|Any CPU = Release|Any CPU
9+
Debug|x64 = Debug|x64
10+
Release|x64 = Release|x64
1111
EndGlobalSection
1212
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13-
{70FB72AD-8823-5E66-89E8-BBC2BCFDCAC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14-
{70FB72AD-8823-5E66-89E8-BBC2BCFDCAC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
15-
{70FB72AD-8823-5E66-89E8-BBC2BCFDCAC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
16-
{70FB72AD-8823-5E66-89E8-BBC2BCFDCAC9}.Release|Any CPU.Build.0 = Release|Any CPU
13+
{70FB72AD-8823-5E66-89E8-BBC2BCFDCAC9}.Debug|x64.ActiveCfg = Debug|x64
14+
{70FB72AD-8823-5E66-89E8-BBC2BCFDCAC9}.Debug|x64.Build.0 = Debug|x64
15+
{70FB72AD-8823-5E66-89E8-BBC2BCFDCAC9}.Release|x64.ActiveCfg = Release|x64
16+
{70FB72AD-8823-5E66-89E8-BBC2BCFDCAC9}.Release|x64.Build.0 = Release|x64
1717
EndGlobalSection
1818
GlobalSection(SolutionProperties) = preSolution
1919
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)