Created
June 12, 2023 19:51
-
-
Save snightshade/f9a3bee74784e64eb3fd3650e41b605f to your computer and use it in GitHub Desktop.
we love casting spells
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
using Dalamud.Hooking; | |
using FFXIVClientStructs.FFXIV.Client.Game.Character; | |
using Lumina.Excel; | |
using Stellaron.Impl; | |
using Stellaron.Util; | |
using Stellaron.Util.Audio; | |
using Action = Lumina.Excel.GeneratedSheets.Action; | |
namespace Stellaron.Modules.Funny; | |
// thank you jules notnite for most of this | |
[Module("Shadow Wizard Money Gang", ModuleCategory.Funny, "We love casting spells.")] | |
public unsafe class ShadowWizardMoneyGangModule : IModule | |
{ | |
private CachedSound swmg; | |
private delegate void DOnActionUsed( | |
uint source, | |
Character* character, | |
IntPtr position, | |
IntPtr fxHeader, | |
IntPtr fxArray, | |
IntPtr fxTrail); | |
private Hook<DOnActionUsed> actionUsedHook; | |
private ExcelSheet<Action> action; | |
public ShadowWizardMoneyGangModule() | |
{ | |
swmg = AudioHelper.Instance.CacheFromData("swmg.wav"); | |
// https://github.com/Tischel/ActionTimeline/blob/master/ActionTimeline/Helpers/TimelineManager.cs#L86 | |
var actUsedSig = Service.SigScanner.ScanText( | |
"40 55 53 57 41 54 41 55 41 56 41 57 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 45 70"); | |
actionUsedHook = Hook<DOnActionUsed>.FromAddress(actUsedSig, OnActionUsedDetour, false); | |
action = Service.DataManager.GetExcelSheet<Action>()!; | |
} | |
private void OnActionUsedDetour( | |
uint source, | |
Character* character, | |
IntPtr position, | |
IntPtr fxHeader, | |
IntPtr fxArray, | |
IntPtr fxTrail) | |
{ | |
actionUsedHook.Original(source, character, position, fxHeader, fxArray, fxTrail); | |
var row = action.GetRow((uint)Marshal.ReadInt32(fxHeader, 8)); | |
if (row == null) | |
return; | |
if (row.ActionCategory.Row != 9u) // limit break | |
return; | |
AudioHelper.Instance.PlayOneshot(swmg); | |
} | |
public void OnEnable() | |
{ | |
actionUsedHook.Enable(); | |
} | |
public void OnDisable() | |
{ | |
actionUsedHook.Disable(); | |
} | |
public void DrawUi() | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment