Code! initial release, zappin' on damage
This commit is contained in:
parent
91097fa602
commit
2d7b981cb9
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
.vs/
|
||||||
|
obj/
|
||||||
|
bin/
|
||||||
|
.idea/
|
||||||
|
*.user
|
||||||
|
.editorconfig
|
29
DalamudShock.sln
Normal file
29
DalamudShock.sln
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
|
||||||
|
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}") = "DalamudShock", "DalamudShock\DalamudShock.csproj", "{13C812E9-0D42-4B95-8646-40EEBF30636F}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|x64.Build.0 = Release|x64
|
||||||
|
{4FEC9558-EB25-419F-B86E-51B8CFDA32B7}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{4FEC9558-EB25-419F-B86E-51B8CFDA32B7}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{4FEC9558-EB25-419F-B86E-51B8CFDA32B7}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{4FEC9558-EB25-419F-B86E-51B8CFDA32B7}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {B17E85B1-5F60-4440-9F9A-3DDE877E8CDF}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
22
DalamudShock/Configuration.cs
Normal file
22
DalamudShock/Configuration.cs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
using Dalamud.Configuration;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace DalamudShock
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class Configuration : IPluginConfiguration
|
||||||
|
{
|
||||||
|
public int Version { get; set; }
|
||||||
|
|
||||||
|
public string openshockApiKey { get; set; } = string.Empty;
|
||||||
|
public string OpenshockShockerID { get; set; } = string.Empty;
|
||||||
|
public int MaxValue { get; set; } = 100;
|
||||||
|
|
||||||
|
public bool IsConfigWindowMovable { get; set; } = true;
|
||||||
|
|
||||||
|
public void Save()
|
||||||
|
{
|
||||||
|
Plugin.PluginInterface.SavePluginConfig(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
DalamudShock/Dalamud.Plugin.Bootstrap.targets
Normal file
11
DalamudShock/Dalamud.Plugin.Bootstrap.targets
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<DalamudLibPath Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
|
||||||
|
<DalamudLibPath Condition="$([MSBuild]::IsOSPlatform('Linux'))">$(HOME)/.xlcore/dalamud/Hooks/dev/</DalamudLibPath>
|
||||||
|
<DalamudLibPath Condition="$([MSBuild]::IsOSPlatform('OSX'))">$(HOME)/Library/Application Support/XIV on Mac/dalamud/Hooks/dev/</DalamudLibPath>
|
||||||
|
<DalamudLibPath Condition="$(DALAMUD_HOME) != ''">$(DALAMUD_HOME)/</DalamudLibPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Import Project="$(DalamudLibPath)/targets/Dalamud.Plugin.targets"/>
|
||||||
|
</Project>
|
12
DalamudShock/DalamudShock.csproj
Normal file
12
DalamudShock/DalamudShock.csproj
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<Import Project="Dalamud.Plugin.Bootstrap.targets"/>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<Version>0.0.0.2</Version>
|
||||||
|
<Description>A shockingly powerful experience.</Description>
|
||||||
|
<PackageProjectUrl>https://git.mercurio.moe/Mercury/DalamudShock</PackageProjectUrl>
|
||||||
|
<PackageLicenseExpression>AGPL-3.0-or-later</PackageLicenseExpression>
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
12
DalamudShock/DalamudShock.json
Normal file
12
DalamudShock/DalamudShock.json
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"Author": "Arael",
|
||||||
|
"Name": "DalamudShock",
|
||||||
|
"Punchline": "zap zap bitch. [openshock only]",
|
||||||
|
"Description": ":3",
|
||||||
|
"ApplicableVersion": "any",
|
||||||
|
"Tags": [
|
||||||
|
"meow",
|
||||||
|
"silly",
|
||||||
|
":3"
|
||||||
|
]
|
||||||
|
}
|
149
DalamudShock/Plugin.cs
Normal file
149
DalamudShock/Plugin.cs
Normal file
|
@ -0,0 +1,149 @@
|
||||||
|
using Dalamud.Game.Command;
|
||||||
|
using Dalamud.IoC;
|
||||||
|
using Dalamud.Plugin;
|
||||||
|
using System;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Dalamud.Interface.Windowing;
|
||||||
|
using Dalamud.Plugin.Services;
|
||||||
|
using DalamudShock.Windows;
|
||||||
|
// ReSharper disable RedundantAnonymousTypePropertyName
|
||||||
|
|
||||||
|
|
||||||
|
namespace DalamudShock
|
||||||
|
{
|
||||||
|
public sealed class Plugin : IDalamudPlugin
|
||||||
|
{
|
||||||
|
[PluginService] internal static IDalamudPluginInterface PluginInterface { get; private set; } = null!;
|
||||||
|
[PluginService] internal static IClientState ClientState { get; private set; } = null!;
|
||||||
|
[PluginService] internal static IFramework Framework { get; private set; } = null!;
|
||||||
|
[PluginService] internal static ICommandManager CommandManager { get; private set; } = null!;
|
||||||
|
[PluginService] internal static IPluginLog PluginLog { get; private set; } = null!;
|
||||||
|
|
||||||
|
|
||||||
|
private const string CommandName = "/zap";
|
||||||
|
public Configuration Configuration { get; init; }
|
||||||
|
public readonly WindowSystem WindowSystem = new("DalamudShock");
|
||||||
|
private ConfigWindow ConfigWindow { get; init; }
|
||||||
|
private MainWindow MainWindow { get; init; }
|
||||||
|
|
||||||
|
private uint lastHealth;
|
||||||
|
private DateTime lastShockTime = DateTime.MinValue;
|
||||||
|
|
||||||
|
public Plugin()
|
||||||
|
{
|
||||||
|
Configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
|
||||||
|
|
||||||
|
ConfigWindow = new ConfigWindow(this);
|
||||||
|
MainWindow = new MainWindow(this);
|
||||||
|
|
||||||
|
WindowSystem.AddWindow(ConfigWindow);
|
||||||
|
WindowSystem.AddWindow(MainWindow);
|
||||||
|
|
||||||
|
CommandManager.AddHandler(CommandName, new CommandInfo(OnCommand)
|
||||||
|
{
|
||||||
|
HelpMessage = "A shockingly empty description :3"
|
||||||
|
});
|
||||||
|
|
||||||
|
PluginInterface.UiBuilder.Draw += DrawUI;
|
||||||
|
PluginInterface.UiBuilder.OpenConfigUi += ToggleConfigUI;
|
||||||
|
PluginInterface.UiBuilder.OpenMainUi += ToggleMainUI;
|
||||||
|
|
||||||
|
Framework.Update += OnFrameworkUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Framework.Update -= OnFrameworkUpdate;
|
||||||
|
WindowSystem.RemoveAllWindows();
|
||||||
|
ConfigWindow.Dispose();
|
||||||
|
MainWindow.Dispose();
|
||||||
|
CommandManager.RemoveHandler(CommandName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnCommand(string command, string args)
|
||||||
|
{
|
||||||
|
ToggleMainUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawUI() => WindowSystem.Draw();
|
||||||
|
|
||||||
|
public void ToggleConfigUI() => ConfigWindow.Toggle();
|
||||||
|
public void ToggleMainUI() => MainWindow.Toggle();
|
||||||
|
|
||||||
|
private void OnFrameworkUpdate(IFramework framework)
|
||||||
|
{
|
||||||
|
var player = ClientState.LocalPlayer;
|
||||||
|
|
||||||
|
if (player == null) return;
|
||||||
|
var currentHealth = player.CurrentHp;
|
||||||
|
|
||||||
|
if (currentHealth == lastHealth) return;
|
||||||
|
lastHealth = currentHealth;
|
||||||
|
|
||||||
|
if (currentHealth < player.MaxHp * 0.5)
|
||||||
|
{
|
||||||
|
if ((DateTime.Now - lastShockTime).TotalSeconds >= 15)
|
||||||
|
{
|
||||||
|
PluginLog.Information($"Player health changed to {currentHealth}, time conditions met. sending API request");
|
||||||
|
lastShockTime = DateTime.Now;
|
||||||
|
SendShockApiRequest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void SendShockApiRequest()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(Configuration.openshockApiKey) || string.IsNullOrEmpty(Configuration.OpenshockShockerID))
|
||||||
|
{
|
||||||
|
PluginLog.Error("OpenShock API Key or Shocker ID is not configured.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var random = new Random();
|
||||||
|
int intensity = random.Next(0, Configuration.MaxValue);
|
||||||
|
int duration = random.Next(1000, 25000);
|
||||||
|
|
||||||
|
var requestData = new[]
|
||||||
|
{
|
||||||
|
new
|
||||||
|
{
|
||||||
|
id = Configuration.OpenshockShockerID,
|
||||||
|
type = "shock",
|
||||||
|
intensity = intensity,
|
||||||
|
duration = duration
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var jsonContent = JsonConvert.SerializeObject(requestData);
|
||||||
|
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
|
using var client = new HttpClient();
|
||||||
|
client.DefaultRequestHeaders.Add("OpenShockToken", Configuration.openshockApiKey);
|
||||||
|
client.DefaultRequestHeaders.Add("User-Agent", "FFXIV:DalamudShock/0.2");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var response = await client.PostAsync("https://api.shocklink.net/1/shockers/control", content);
|
||||||
|
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
PluginLog.Information("Shock sent successfully with intensity {0} and duration {1} ms.", intensity, duration);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var responseBody = await response.Content.ReadAsStringAsync();
|
||||||
|
PluginLog.Error($"Shock API request failed: {responseBody}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
PluginLog.Error($"Error occurred while sending shock: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
57
DalamudShock/Windows/ConfigWindow.cs
Normal file
57
DalamudShock/Windows/ConfigWindow.cs
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
using System;
|
||||||
|
using System.Numerics;
|
||||||
|
using Dalamud.Interface.Windowing;
|
||||||
|
using ImGuiNET;
|
||||||
|
|
||||||
|
namespace DalamudShock.Windows
|
||||||
|
{
|
||||||
|
public class ConfigWindow : Window, IDisposable
|
||||||
|
{
|
||||||
|
private Configuration Configuration;
|
||||||
|
public ConfigWindow(Plugin plugin) : base("DalamudShock Config###With a constant ID")
|
||||||
|
{
|
||||||
|
Flags = ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar |
|
||||||
|
ImGuiWindowFlags.NoScrollWithMouse;
|
||||||
|
Size = new Vector2(400, 200);
|
||||||
|
SizeCondition = ImGuiCond.Always;
|
||||||
|
Configuration = plugin.Configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose() { }
|
||||||
|
|
||||||
|
public override void PreDraw()
|
||||||
|
{
|
||||||
|
if (Configuration.IsConfigWindowMovable)
|
||||||
|
{
|
||||||
|
Flags &= ~ImGuiWindowFlags.NoMove;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Flags |= ImGuiWindowFlags.NoMove;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Draw()
|
||||||
|
{
|
||||||
|
var apiKey = Configuration.openshockApiKey;
|
||||||
|
if (ImGui.InputText("OpenShock API Key", ref apiKey, 100))
|
||||||
|
{
|
||||||
|
Configuration.openshockApiKey = apiKey;
|
||||||
|
Configuration.Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
var shockerID = Configuration.OpenshockShockerID;
|
||||||
|
if (ImGui.InputText("OpenShock Shocker ID", ref shockerID, 100))
|
||||||
|
{
|
||||||
|
Configuration.OpenshockShockerID = shockerID;
|
||||||
|
Configuration.Save();
|
||||||
|
}
|
||||||
|
var maxShock = Configuration.MaxValue;
|
||||||
|
if (ImGui.SliderInt("Intensity cap", ref maxShock, 0, 100))
|
||||||
|
{
|
||||||
|
Configuration.MaxValue = maxShock;
|
||||||
|
Configuration.Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
DalamudShock/Windows/MainWindow.cs
Normal file
36
DalamudShock/Windows/MainWindow.cs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
using System;
|
||||||
|
using System.Numerics;
|
||||||
|
using Dalamud.Interface.Windowing;
|
||||||
|
using ImGuiNET;
|
||||||
|
|
||||||
|
namespace DalamudShock.Windows;
|
||||||
|
|
||||||
|
public class MainWindow : Window, IDisposable
|
||||||
|
{
|
||||||
|
private Plugin Plugin;
|
||||||
|
|
||||||
|
public MainWindow(Plugin plugin)
|
||||||
|
: base("This window has no reason to exist##With a hidden ID", ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse)
|
||||||
|
{
|
||||||
|
SizeConstraints = new WindowSizeConstraints
|
||||||
|
{
|
||||||
|
MinimumSize = new Vector2(375, 330),
|
||||||
|
MaximumSize = new Vector2(float.MaxValue, float.MaxValue)
|
||||||
|
};
|
||||||
|
|
||||||
|
Plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose() { }
|
||||||
|
|
||||||
|
public override void Draw()
|
||||||
|
{
|
||||||
|
if (ImGui.Button("Show Settings"))
|
||||||
|
{
|
||||||
|
Plugin.ToggleConfigUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.Spacing();
|
||||||
|
ImGui.Text("We aren't beating the bottom allegations with this one");
|
||||||
|
}
|
||||||
|
}
|
13
DalamudShock/packages.lock.json
Normal file
13
DalamudShock/packages.lock.json
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"dependencies": {
|
||||||
|
"net8.0-windows7.0": {
|
||||||
|
"DalamudPackager": {
|
||||||
|
"type": "Direct",
|
||||||
|
"requested": "[2.1.13, )",
|
||||||
|
"resolved": "2.1.13",
|
||||||
|
"contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
13
README.md
13
README.md
|
@ -1,3 +1,12 @@
|
||||||
# DalamudShock
|
it zaps.
|
||||||
|
|
||||||
A shockingly powerful plugin :3
|
you take damange and it zaps, couldn't get any more shrimple than this.
|
||||||
|
|
||||||
|
Requires whatever final version of Dalamud, FF14, XIVLauncher, all that shiz
|
||||||
|
grab your(or your friend's) api key for Openshock over [here](https://openshock.app/#/dashboard/tokens)
|
||||||
|
and your shocker id from [shockers](https://openshock.app/#/dashboard/shockers/own)>more>edit.
|
||||||
|
|
||||||
|
Current zapping conditions are if health drops below 50%, but i plan on adding stuff for:
|
||||||
|
- forgetful tanks that don't turn on their stance in dungeons
|
||||||
|
- zap on vulnerability stack, just learn the mechanics man
|
||||||
|
- manual shocking, if you just want to feeel pain
|
Loading…
Reference in a new issue