diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..645ca620 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,49 @@ +name: Build & Publish to Dynamis + +on: + push: + tags: + - 'v*.*.*.*' + +jobs: + Build: + runs-on: ubuntu-latest + env: + DALAMUD_HOME: /tmp/dalamud + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + submodules: true + + - name: Get Tag Name + run: echo "tag=$(echo ${{ github.ref }} | sed 's/refs\/tags\/v//')" >> $GITHUB_ENV + + - name: Set up .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.0.x + + - name: Download Dalamud Latest + run: | + wget https://goatcorp.github.io/dalamud-distrib/latest.zip -O ${{ env.DALAMUD_HOME }}.zip + unzip ${{ env.DALAMUD_HOME }}.zip -d ${{ env.DALAMUD_HOME }} + + - name: Restore Project + run: dotnet restore + + - name: Build Project + run: dotnet build --configuration Release SomethingNeedDoing/SomethingNeedDoing.csproj -p:AssemblyVersion=${{ env.tag }} + + - name: Publish Version + uses: PunishXIV/dynamis-action@v1 + id: dynamis + with: + plugin_id: 28 + internal_name: 'SomethingNeedDoing' + version_number: ${{ env.tag }} + path: 'SomethingNeedDoing/bin/Release/SomethingNeedDoing/latest.zip' + type: 'latest' + dalamud_version: '9' + env: + PUBLISHER_KEY: ${{ secrets.PUBLISHER_KEY }} diff --git a/SomethingNeedDoing/Interface/HelpWindow.cs b/SomethingNeedDoing/Interface/HelpWindow.cs index c254dc71..f7381dd3 100644 --- a/SomethingNeedDoing/Interface/HelpWindow.cs +++ b/SomethingNeedDoing/Interface/HelpWindow.cs @@ -2,12 +2,15 @@ using System.Collections.Generic; using System.Linq; using System.Numerics; +using System.Reflection.Emit; using System.Threading.Tasks; - +using System.Xml.Linq; +using Dalamud.Game.ClientState.Conditions; using Dalamud.Game.ClientState.Keys; using Dalamud.Game.Text; using Dalamud.Interface; using Dalamud.Interface.Colors; +using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Windowing; using ImGuiNET; @@ -255,6 +258,7 @@ public override void Draw() ("CLI", this.DrawCli), ("Clicks", this.DrawClicks), ("Sends", this.DrawVirtualKeys), + ("Conditions", this.DrawAllConditions), }; foreach (var (title, dele) in tabs) @@ -292,6 +296,20 @@ static void DisplayChangelog(string date, string changes, bool separator = true) ImGui.PushFont(UiBuilder.MonoFont); + DisplayChangelog( + "2023-11-05", + "- Added LeaveDuty().\n"); + + DisplayChangelog( + "2023-11-04", + "- Added GetProgressIncrease(uint actionID). Returns numerical amount of progress increase a given action will cause.\n" + + "- Added GetQualityIncrease(uint actionID). Returns numerical amount of quality increase a given action will cause.\n"); + + DisplayChangelog( + "2023-10-24", + "- Changed GetCharacterCondition() to take in an int instead of a string.\n" + + "- Added a list of conditions to the help menu.\n"); + DisplayChangelog( "2023-10-21", "- Added an optional bool to pass to GetCharacterName to return the world name in addition.\n"); @@ -847,4 +865,24 @@ private void DrawVirtualKeys() ImGui.PopFont(); } + + private void DrawAllConditions() + { + using var font = ImRaii.PushFont(UiBuilder.MonoFont); + + ImGui.TextWrapped("Active conditions will highlight green."); + ImGui.Separator(); + + foreach (ConditionFlag flag in Enum.GetValues(typeof(ConditionFlag))) + { + var isActive = Service.Condition[flag]; + if (isActive) + ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.HealerGreen); + + ImGui.Text($"ID: {(int)flag} Enum: {flag}"); + + if (isActive) + ImGui.PopStyleColor(); + } + } } diff --git a/SomethingNeedDoing/Misc/CommandInterface.cs b/SomethingNeedDoing/Misc/CommandInterface.cs index 69dd35c6..59505aeb 100644 --- a/SomethingNeedDoing/Misc/CommandInterface.cs +++ b/SomethingNeedDoing/Misc/CommandInterface.cs @@ -8,6 +8,7 @@ using FFXIVClientStructs.FFXIV.Client.Game.UI; using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel; using FFXIVClientStructs.FFXIV.Client.UI; +using FFXIVClientStructs.FFXIV.Client.UI.Agent; using FFXIVClientStructs.FFXIV.Component.GUI; using Lumina.Excel.GeneratedSheets; using SomethingNeedDoing.Exceptions; @@ -21,6 +22,10 @@ namespace SomethingNeedDoing.Misc; /// public class CommandInterface : ICommandInterface { + private readonly AbandonDuty abandonDuty = Marshal.GetDelegateForFunctionPointer(Service.SigScanner.ScanText("E8 ?? ?? ?? ?? 48 8B 43 28 B1 01")); + + private delegate void AbandonDuty(bool a1); + /// /// Gets the static instance. /// @@ -429,12 +434,9 @@ public unsafe string GetSelectIconStringText(int index) } /// - public bool GetCharacterCondition(string flagName, bool hasCondition = true) + public bool GetCharacterCondition(int flagID, bool hasCondition = true) { - if (Enum.TryParse(typeof(ConditionFlag), flagName, ignoreCase: true, out var enumValue)) - return hasCondition ? Service.Condition[(ConditionFlag)enumValue] : !Service.Condition[(ConditionFlag)enumValue]; - else - throw new ArgumentException("Invalid flag name", nameof(flagName)); + return hasCondition ? Service.Condition[flagID] : !Service.Condition[flagID]; } /// @@ -463,6 +465,54 @@ public unsafe bool DeliverooIsTurnInRunning() return DeliverooIPC.IsTurnInRunning.InvokeFunc(); } + /// + public unsafe uint GetProgressIncrease(uint actionID) => this.GetActionResult(actionID).Progress; + + /// + public unsafe uint GetQualityIncrease(uint actionID) => this.GetActionResult(actionID).Quality; + + /// + public void LeaveDuty() => this.abandonDuty(false); + + private unsafe (uint Progress, uint Quality) GetActionResult(uint id) + { + + var agent = AgentCraftActionSimulator.Instance(); + if (agent == null) return (0, 0); + + var progress = 0U; + var quality = 0U; + + // Find Progress + var p = (ProgressEfficiencyCalculation*)agent->Progress; + for (var i = 0; i < sizeof(ProgressEfficiencyCalculations) / sizeof(ProgressEfficiencyCalculation); i++) + { + if (p == null) break; + if (p->ActionId == id) + { + progress = p->ProgressIncrease; + break; + } + + p++; + } + + var q = (QualityEfficiencyCalculation*)agent->Quality; + for (var i = 0; i < sizeof(QualityEfficiencyCalculations) / sizeof(QualityEfficiencyCalculation); i++) + { + if (q == null) break; + if (q->ActionId == id) + { + quality = q->QualityIncrease; + break; + } + + q++; + } + + return (progress, quality); + } + private unsafe int GetNodeTextAsInt(AtkTextNode* node, string error) { try diff --git a/SomethingNeedDoing/Misc/ICommandInterface.cs b/SomethingNeedDoing/Misc/ICommandInterface.cs index 887e26bf..e86654a7 100644 --- a/SomethingNeedDoing/Misc/ICommandInterface.cs +++ b/SomethingNeedDoing/Misc/ICommandInterface.cs @@ -188,10 +188,10 @@ public interface ICommandInterface /// /// Get the status of a given character condition. /// - /// Flag Name. + /// Flag ID. /// Bool flag to invert the condition check. /// Returns true if the player has the condition, false otherwise. Condition inverted if provided with hasCondition=false. - public bool GetCharacterCondition(string flagName, bool hasCondition = true); + public bool GetCharacterCondition(int flagID, bool hasCondition = true); /// /// Get the status of the player being in a given zone. @@ -226,4 +226,23 @@ public interface ICommandInterface /// /// Returns value of turn in function running, bool. public bool DeliverooIsTurnInRunning(); + + /// + /// Get the amount of progress a crafting action will give. + /// + /// Action ID. + /// Returns amount of increase in progress a given action will make in a craft, uint. + public uint GetProgressIncrease(uint actionID); + + /// + /// Get the amount of quality a crafting action will give. + /// + /// Action ID. + /// Returns amount of increase in quality a given action will make in a craft, uint. + public uint GetQualityIncrease(uint actionID); + + /// + /// Leaves an instance. + /// + public void LeaveDuty(); } diff --git a/SomethingNeedDoing/Service.cs b/SomethingNeedDoing/Service.cs index 80f28be1..8ea24fa4 100644 --- a/SomethingNeedDoing/Service.cs +++ b/SomethingNeedDoing/Service.cs @@ -121,5 +121,11 @@ internal class Service /// [PluginService] internal static IPluginLog Log { get; private set; } = null!; + + /// + /// Gets the Dalamud signature scanner. + /// + [PluginService] + internal static ISigScanner SigScanner { get; private set; } = null!; } } diff --git a/SomethingNeedDoing/SomethingNeedDoing.csproj b/SomethingNeedDoing/SomethingNeedDoing.csproj index 6be985ef..4dd513aa 100644 --- a/SomethingNeedDoing/SomethingNeedDoing.csproj +++ b/SomethingNeedDoing/SomethingNeedDoing.csproj @@ -3,7 +3,7 @@ daemitus, croizat - - 1.4.1.8 + 0.0.0.0 https://github.com/Jaksuhn/SomethingNeedDoing