mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-31 21:03:43 +01:00
Add 'Oops, Maybe Lalafells!'
This commit is contained in:
parent
c60bb99e77
commit
29da285091
3 changed files with 86 additions and 3 deletions
|
|
@ -77,8 +77,8 @@ internal class FoolsManager : IDisposable, IServiceType
|
||||||
{
|
{
|
||||||
new("Pixel Imperfect", "PixelImperfectPlugin", "Whoops... we messed up the math on that one.", "Halpo",
|
new("Pixel Imperfect", "PixelImperfectPlugin", "Whoops... we messed up the math on that one.", "Halpo",
|
||||||
typeof(PixelImperfectPlugin)),
|
typeof(PixelImperfectPlugin)),
|
||||||
new("DailyLifeDuty", "DailyLifeDutyPlugin", "Easily Track Daily and Weekly tasks... in real life",
|
new("DailyLifeDuty", "DailyLifeDutyPlugin", "Easily Track Daily and Weekly tasks... in real life", "MidoriKami", typeof(DailyLifeDutyPlugin)),
|
||||||
"MidoriKami", typeof(DailyLifeDutyPlugin)),
|
new("Oops, Maybe Lalafells!", "OopsMaybeLalafellsPlugin", "Turn everyone into Lalafells? Maybe. We haven't quite tested it yet.", "Chrip", typeof(OopsMaybeLalafells))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
83
Dalamud/Fools/Plugins/OopsMaybeLalafellsPlugin.cs
Normal file
83
Dalamud/Fools/Plugins/OopsMaybeLalafellsPlugin.cs
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
using Dalamud.Game;
|
||||||
|
using Dalamud.Game.ClientState.Objects;
|
||||||
|
using Dalamud.Game.ClientState.Objects.Enums;
|
||||||
|
using Dalamud.Hooking;
|
||||||
|
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.Game.Object;
|
||||||
|
|
||||||
|
namespace Dalamud.Fools.Plugins;
|
||||||
|
|
||||||
|
public class OopsMaybeLalafells : IFoolsPlugin
|
||||||
|
{
|
||||||
|
// Plugin
|
||||||
|
|
||||||
|
public OopsMaybeLalafells()
|
||||||
|
{
|
||||||
|
var scanner = Service<SigScanner>.Get();
|
||||||
|
var addr = scanner.ScanText(SetupCharacterSig);
|
||||||
|
SetupCharacterHook = Hook<SetupCharacterDelegate>.FromAddress(addr, SetupCharacterDetour);
|
||||||
|
SetupCharacterHook.Enable();
|
||||||
|
RedrawAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
SetupCharacterHook.Disable();
|
||||||
|
SetupCharacterHook.Dispose();
|
||||||
|
RedrawAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe void RedrawAll()
|
||||||
|
{
|
||||||
|
Service<Framework>.Get().RunOnFrameworkThread(() => {
|
||||||
|
var objects = Service<ObjectTable>.Get();
|
||||||
|
foreach (var obj in objects)
|
||||||
|
{
|
||||||
|
if (obj.ObjectIndex > 241) break;
|
||||||
|
|
||||||
|
var csObject = (GameObject*)obj.Address;
|
||||||
|
if (csObject == null) continue;
|
||||||
|
|
||||||
|
csObject->DisableDraw();
|
||||||
|
csObject->EnableDraw();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// The Lalafellinator
|
||||||
|
|
||||||
|
private readonly Random Rng = new();
|
||||||
|
|
||||||
|
private readonly List<ushort> ReplaceIDs = new() { 84, 85, 86, 87, 88, 89, 90, 91, 257, 258, 581, 597, 744 };
|
||||||
|
|
||||||
|
private const string SetupCharacterSig = "E8 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ?? 48 8B D7 E8 ?? ?? ?? ?? 48 8B CF E8 ?? ?? ?? ?? 48 8B C7";
|
||||||
|
|
||||||
|
private delegate char SetupCharacterDelegate(nint a1, nint a2);
|
||||||
|
private Hook<SetupCharacterDelegate> SetupCharacterHook = null!;
|
||||||
|
|
||||||
|
private unsafe char SetupCharacterDetour(nint a1, nint a2)
|
||||||
|
{
|
||||||
|
// Roll the dice
|
||||||
|
if (Rng.Next(0, 4) == 0)
|
||||||
|
{
|
||||||
|
var customize = (byte*)a2;
|
||||||
|
customize[(int)CustomizeIndex.Race] = 3;
|
||||||
|
|
||||||
|
var face = customize + (int)CustomizeIndex.FaceType;
|
||||||
|
*face = (byte)(1 + ((*face - 1) % 4));
|
||||||
|
|
||||||
|
var equipTar = (ushort)(customize[(int)CustomizeIndex.Gender] == 0 ? 92 : 93);
|
||||||
|
for (var i = 1; i < 5; i++)
|
||||||
|
{
|
||||||
|
var equip = (ushort*)(a2 + 28 + (i * 4));
|
||||||
|
if (ReplaceIDs.Contains(*equip))
|
||||||
|
*equip = equipTar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return SetupCharacterHook.Original(a1, a2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 74345c97468f310d555929f4e40c844556bc64e7
|
Subproject commit 9e97396f98c20eff17a71aacb24296efcaa04808
|
||||||
Loading…
Add table
Add a link
Reference in a new issue