Add 'Good Vibes'

This commit is contained in:
chirp 2023-03-21 06:55:45 +00:00
parent 210afc4f09
commit 382a1c0c96
2 changed files with 56 additions and 1 deletions

View file

@ -95,7 +95,7 @@ internal class FoolsManager : IDisposable, IServiceType
Name = "Oops, Maybe Lalafells!",
InternalName = "OopsMaybeLalafellsPlugin",
Description = "Turn everyone into Lalafells? Maybe. We haven't quite tested it yet.",
Author = "Chrip",
Author = "Chirpopo Chirpo",
RealAuthor = "Chirp",
Type = typeof(OopsMaybeLalafells),
},
@ -126,6 +126,15 @@ internal class FoolsManager : IDisposable, IServiceType
RealAuthor = "NotNite",
Type = typeof(YesSolicitingPlugin),
},
new()
{
Name = "Good Vibes",
InternalName = "GoodVibesPlugin",
Description = "Shake things up with this vibe plugin!",
Author = "C h i r p",
RealAuthor = "Chirp",
Type = typeof(GoodVibesPlugin),
},
};
}

View file

@ -0,0 +1,46 @@
using System;
using System.Numerics;
using Dalamud.Game;
using Dalamud.Hooking;
namespace Dalamud.Fools.Plugins
{
public class GoodVibesPlugin : IFoolsPlugin
{
// Plugin
public GoodVibesPlugin()
{
var addr = Service<SigScanner>.Get().ScanText("48 83 EC 08 8B 02");
OffsetModelHook = Hook<OffsetModelDelegate>.FromAddress(addr, OffsetModelDetour);
OffsetModelHook.Enable();
}
public void Dispose()
{
OffsetModelHook.Disable();
OffsetModelHook.Dispose();
}
// brrrrrrrr
private readonly Random Rng = new();
private Vector3 GenRandVec()
{
var Pos = new float[3];
for (var i = 0; i < 3; i++)
Pos[i] = Rng.Next(-5, 5) / 1000f;
return new Vector3(Pos);
}
private delegate nint OffsetModelDelegate(nint a1, nint a2);
private Hook<OffsetModelDelegate> OffsetModelHook = null!;
private unsafe nint OffsetModelDetour(nint a1, nint a2)
{
*(Vector3*)a2 += GenRandVec();
return OffsetModelHook.Original(a1, a2);
}
}
}