Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

Commit

Permalink
All the plugin stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonBlade committed Sep 27, 2020
1 parent 912f33c commit 76790f5
Show file tree
Hide file tree
Showing 8 changed files with 304 additions and 1 deletion.
25 changes: 25 additions & 0 deletions HeelsPlugin.sln
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions HeelsPlugin/Configuration.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
69 changes: 69 additions & 0 deletions HeelsPlugin/HeelsPlugin.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{13C812E9-0D42-4B95-8646-40EEBF30636F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>HeelsPlugin</RootNamespace>
<AssemblyName>HeelsPlugin</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="Dalamud">
<HintPath>C:\Users\LeonBlade\AppData\Roaming\XIVLauncher\addon\Hooks\Dalamud.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ImGui.NET">
<HintPath>C:\Users\LeonBlade\AppData\Roaming\XIVLauncher\addon\Hooks\ImGui.NET.dll</HintPath>
</Reference>
<Reference Include="ImGuiScene">
<HintPath>C:\Users\LeonBlade\AppData\Roaming\XIVLauncher\addon\Hooks\ImGuiScene.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration.cs" />
<Compile Include="PluginMemory.cs" />
<Compile Include="Plugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="HeelsPlugin.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
11 changes: 11 additions & 0 deletions HeelsPlugin/HeelsPlugin.json
Original file line number Diff line number Diff line change
@@ -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
}
52 changes: 52 additions & 0 deletions HeelsPlugin/Plugin.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
}
65 changes: 65 additions & 0 deletions HeelsPlugin/PluginMemory.cs
Original file line number Diff line number Diff line change
@@ -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<PlayerMovementDelegate> 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<PlayerMovementDelegate>(
playerMovementFunc,
new PlayerMovementDelegate(PlayerMovementHook)
);

this.playerMovementHook.Enable();
}

/// <summary>
/// Dispose for the memory functions.
/// </summary>
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);
}
}
}
35 changes: 35 additions & 0 deletions HeelsPlugin/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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")]
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 76790f5

Please sign in to comment.