Skip to content

Commit

Permalink
added LeaveDuty and dynamis publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaksuhn committed Nov 5, 2023
1 parent e41a988 commit d676c7b
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 9 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
40 changes: 39 additions & 1 deletion SomethingNeedDoing/Interface/HelpWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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();
}
}
}
60 changes: 55 additions & 5 deletions SomethingNeedDoing/Misc/CommandInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,6 +22,10 @@ namespace SomethingNeedDoing.Misc;
/// </summary>
public class CommandInterface : ICommandInterface
{
private readonly AbandonDuty abandonDuty = Marshal.GetDelegateForFunctionPointer<AbandonDuty>(Service.SigScanner.ScanText("E8 ?? ?? ?? ?? 48 8B 43 28 B1 01"));

private delegate void AbandonDuty(bool a1);

/// <summary>
/// Gets the static instance.
/// </summary>
Expand Down Expand Up @@ -429,12 +434,9 @@ public unsafe string GetSelectIconStringText(int index)
}

/// <inheritdoc/>
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];
}

/// <inheritdoc/>
Expand Down Expand Up @@ -463,6 +465,54 @@ public unsafe bool DeliverooIsTurnInRunning()
return DeliverooIPC.IsTurnInRunning.InvokeFunc();
}

/// <inheritdoc/>
public unsafe uint GetProgressIncrease(uint actionID) => this.GetActionResult(actionID).Progress;

/// <inheritdoc/>
public unsafe uint GetQualityIncrease(uint actionID) => this.GetActionResult(actionID).Quality;

/// <inheritdoc/>
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
Expand Down
23 changes: 21 additions & 2 deletions SomethingNeedDoing/Misc/ICommandInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ public interface ICommandInterface
/// <summary>
/// Get the status of a given character condition.
/// </summary>
/// <param name="flagName">Flag Name.</param>
/// <param name="flagID">Flag ID.</param>
/// <param name="hasCondition">Bool flag to invert the condition check.</param>
/// <returns>Returns true if the player has the condition, false otherwise. Condition inverted if provided with hasCondition=false.</returns>
public bool GetCharacterCondition(string flagName, bool hasCondition = true);
public bool GetCharacterCondition(int flagID, bool hasCondition = true);

/// <summary>
/// Get the status of the player being in a given zone.
Expand Down Expand Up @@ -226,4 +226,23 @@ public interface ICommandInterface
/// </summary>
/// <returns>Returns value of turn in function running, bool.</returns>
public bool DeliverooIsTurnInRunning();

/// <summary>
/// Get the amount of progress a crafting action will give.
/// </summary>
/// <param name="actionID">Action ID.</param>
/// <returns>Returns amount of increase in progress a given action will make in a craft, uint.</returns>
public uint GetProgressIncrease(uint actionID);

/// <summary>
/// Get the amount of quality a crafting action will give.
/// </summary>
/// <param name="actionID">Action ID.</param>
/// <returns>Returns amount of increase in quality a given action will make in a craft, uint.</returns>
public uint GetQualityIncrease(uint actionID);

/// <summary>
/// Leaves an instance.
/// </summary>
public void LeaveDuty();
}
6 changes: 6 additions & 0 deletions SomethingNeedDoing/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,11 @@ internal class Service
/// </summary>
[PluginService]
internal static IPluginLog Log { get; private set; } = null!;

/// <summary>
/// Gets the Dalamud signature scanner.
/// </summary>
[PluginService]
internal static ISigScanner SigScanner { get; private set; } = null!;
}
}
2 changes: 1 addition & 1 deletion SomethingNeedDoing/SomethingNeedDoing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Authors>daemitus, croizat</Authors>
<Company>-</Company>
<Version>1.4.1.8</Version>
<Version>0.0.0.0</Version>
<Description></Description>
<Copyright></Copyright>
<PackageProjectUrl>https://github.com/Jaksuhn/SomethingNeedDoing</PackageProjectUrl>
Expand Down

0 comments on commit d676c7b

Please sign in to comment.