From 76790f5d0ab5a9acfd605d1c47da5bd85cd1b2ad Mon Sep 17 00:00:00 2001 From: James Stine Date: Sat, 26 Sep 2020 21:31:24 -0400 Subject: [PATCH] All the plugin stuff --- HeelsPlugin.sln | 25 ++++++++++ HeelsPlugin/Configuration.cs | 25 ++++++++++ HeelsPlugin/HeelsPlugin.csproj | 69 ++++++++++++++++++++++++++ HeelsPlugin/HeelsPlugin.json | 11 ++++ HeelsPlugin/Plugin.cs | 52 +++++++++++++++++++ HeelsPlugin/PluginMemory.cs | 65 ++++++++++++++++++++++++ HeelsPlugin/Properties/AssemblyInfo.cs | 35 +++++++++++++ README.md | 23 ++++++++- 8 files changed, 304 insertions(+), 1 deletion(-) create mode 100644 HeelsPlugin.sln create mode 100644 HeelsPlugin/Configuration.cs create mode 100644 HeelsPlugin/HeelsPlugin.csproj create mode 100644 HeelsPlugin/HeelsPlugin.json create mode 100644 HeelsPlugin/Plugin.cs create mode 100644 HeelsPlugin/PluginMemory.cs create mode 100644 HeelsPlugin/Properties/AssemblyInfo.cs diff --git a/HeelsPlugin.sln b/HeelsPlugin.sln new file mode 100644 index 0000000..76581b2 --- /dev/null +++ b/HeelsPlugin.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeelsPlugin", "HeelsPlugin\HeelsPlugin.csproj", "{13C812E9-0D42-4B95-8646-40EEBF30636F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B17E85B1-5F60-4440-9F9A-3DDE877E8CDF} + EndGlobalSection +EndGlobal diff --git a/HeelsPlugin/Configuration.cs b/HeelsPlugin/Configuration.cs new file mode 100644 index 0000000..bac1b89 --- /dev/null +++ b/HeelsPlugin/Configuration.cs @@ -0,0 +1,25 @@ +using Dalamud.Configuration; +using Dalamud.Plugin; +using System; + +namespace HeelsPlugin +{ + [Serializable] + public class Configuration : IPluginConfiguration + { + public int Version { get; set; } = 0; + + [NonSerialized] + private DalamudPluginInterface pluginInterface; + + public void Initialize(DalamudPluginInterface pluginInterface) + { + this.pluginInterface = pluginInterface; + } + + public void Save() + { + this.pluginInterface.SavePluginConfig(this); + } + } +} diff --git a/HeelsPlugin/HeelsPlugin.csproj b/HeelsPlugin/HeelsPlugin.csproj new file mode 100644 index 0000000..cf43036 --- /dev/null +++ b/HeelsPlugin/HeelsPlugin.csproj @@ -0,0 +1,69 @@ + + + + + Debug + AnyCPU + {13C812E9-0D42-4B95-8646-40EEBF30636F} + Library + Properties + HeelsPlugin + HeelsPlugin + v4.7.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + true + + + + C:\Users\LeonBlade\AppData\Roaming\XIVLauncher\addon\Hooks\Dalamud.dll + False + + + C:\Users\LeonBlade\AppData\Roaming\XIVLauncher\addon\Hooks\ImGui.NET.dll + + + C:\Users\LeonBlade\AppData\Roaming\XIVLauncher\addon\Hooks\ImGuiScene.dll + False + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + \ No newline at end of file diff --git a/HeelsPlugin/HeelsPlugin.json b/HeelsPlugin/HeelsPlugin.json new file mode 100644 index 0000000..0d9f487 --- /dev/null +++ b/HeelsPlugin/HeelsPlugin.json @@ -0,0 +1,11 @@ +{ + "Author": "LeonBlade", + "Name": "Heels Plugin", + "Description": "Offsets your character off the ground for when wearing heels.", + "InternalName": "heels", + "AssemblyVersion": "1.0.0.0", + "RepoUrl": "https://github.com/LeonBlade/HeelsPlugin", + "ApplicableVersion": "any", + "Tags": ["offset", "leonblade", "heels"], + "DalamudApiLevel": 1 +} diff --git a/HeelsPlugin/Plugin.cs b/HeelsPlugin/Plugin.cs new file mode 100644 index 0000000..813c8b4 --- /dev/null +++ b/HeelsPlugin/Plugin.cs @@ -0,0 +1,52 @@ +using Dalamud.Game.Command; +using Dalamud.Plugin; + +namespace HeelsPlugin +{ + public class Plugin : IDalamudPlugin + { + public string Name => "Heels Plugin"; + + private const string commandName = "/xlheels"; + + private DalamudPluginInterface pi; + private Configuration configuration; + private PluginMemory memory; + + public void Initialize(DalamudPluginInterface pluginInterface) + { + this.pi = pluginInterface; + + this.configuration = this.pi.GetPluginConfig() as Configuration ?? new Configuration(); + this.configuration.Initialize(this.pi); + + this.memory = new PluginMemory(this.pi); + + this.pi.CommandManager.AddHandler(commandName, new CommandInfo(OnCommand) + { + HelpMessage = "Specify a float value to offset your character from the ground. Use 0 or off to disable." + }); + } + + public void Dispose() + { + // Dispose for stuff in Plugin Memory class. + this.memory.Dispose(); + + this.pi.CommandManager.RemoveHandler(commandName); + this.pi.Dispose(); + } + + private void OnCommand(string command, string args) + { + var argArr = args.Split(' '); + if (argArr.Length > 0) + { + if (argArr[0].ToLower() == "off") + this.memory.offset = 0; + else if (float.TryParse(argArr[0], out float offset)) + this.memory.offset = offset; + } + } + } +} diff --git a/HeelsPlugin/PluginMemory.cs b/HeelsPlugin/PluginMemory.cs new file mode 100644 index 0000000..3d639bd --- /dev/null +++ b/HeelsPlugin/PluginMemory.cs @@ -0,0 +1,65 @@ +using Dalamud.Hooking; +using Dalamud.Plugin; +using System; +using System.Runtime.InteropServices; + +namespace HeelsPlugin +{ + public class PluginMemory + { + private readonly DalamudPluginInterface pi; + + public float offset = 0; + + public IntPtr playerMovementFunc; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate void PlayerMovementDelegate(IntPtr player, float x, float y, float z); + private readonly Hook playerMovementHook; + + public PluginMemory(DalamudPluginInterface pluginInterface) + { + this.pi = pluginInterface; + + this.playerMovementFunc = this.pi.TargetModuleScanner.ScanText("40 53 48 83 EC 20 F3 0F 11 89 A0"); + this.playerMovementHook = new Hook( + playerMovementFunc, + new PlayerMovementDelegate(PlayerMovementHook) + ); + + this.playerMovementHook.Enable(); + } + + /// + /// Dispose for the memory functions. + /// + public void Dispose() + { + try + { + // Kill the hook assuming it's not already dead. + if (this.playerMovementHook != null) + { + this.playerMovementHook?.Disable(); + this.playerMovementHook?.Dispose(); + } + } + catch (Exception ex) + { + PluginLog.LogError(ex, "Error while calling PluginMemory.Dispose()"); + } + } + + private void PlayerMovementHook(IntPtr player, float x, float y, float z) + { + try + { + if (this.pi.ClientState.Actors.Length > 0 && this.pi.ClientState.Actors[0].Address == player) + y += offset; + } + catch { } + + // Call the original function. + this.playerMovementHook.Original(player, x, y, z); + } + } +} diff --git a/HeelsPlugin/Properties/AssemblyInfo.cs b/HeelsPlugin/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..459e6d9 --- /dev/null +++ b/HeelsPlugin/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("HeelsPlugin")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("HeelsPlugin")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("13c812e9-0d42-4b95-8646-40eebf30636f")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/README.md b/README.md index f098989..410e985 100644 --- a/README.md +++ b/README.md @@ -1 +1,22 @@ -BDTHPlugin +# Heels Plugin +This is a plugin to be used with the [FFXIVQuickLauncher](https://github.com/goatcorp/FFXIVQuickLauncher). + +## Installing +A prebuilt plugin can be found on the releases page. Download and unzip the contents of the release. Place the HeelsPlugin +folder in this path `%appdata%\XIVLauncher\installedPlugins`. + +## Usage +To use the plugin, you must have launched the game via FFXIVQuickLauncher. +Then, all you need to do is type `/xlheels` in the in game chat followed by an offset. For example, you might type +`/xlheels 0.11` and this will offset your character 0.11 units off of the ground. In order for the offset to take effect, +you simply need to take a step forward. + +If you wish to disable the effect, simply type `/xlheels 0` or `/xlheels off` in the chat to disable the offset. + +## Notes +Due to the nature of this plugin and how it works, you will float off of the ground even while sitting. This plugin also +hasn't been tested extensively, so there may be some issues. Please contact me if you run into any major problems. + +## Donations +**Ko-Fi:** https://ko-fi.com/LeonBlade +**Patreon:** https://patreon.com/LeonBlade \ No newline at end of file