Skip to content

Commit

Permalink
Reward pick coffer priority
Browse files Browse the repository at this point in the history
  • Loading branch information
Limiana committed Aug 28, 2024
1 parent 4ce77cb commit b10a566
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 14 deletions.
2 changes: 1 addition & 1 deletion TextAdvance/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Config : IEzConfig
public int Mount = 0;
public bool NavStatusChat = false;
public bool DisplayFunding = true;
internal bool EnableFlight = false;
public bool EnableFlight = false;

public bool GetEnableQuestAccept()
{
Expand Down
40 changes: 40 additions & 0 deletions TextAdvance/Executors/ExecPickReward.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using ECommons.Automation.NeoTaskManager;
using ECommons.ChatMethods;
using ECommons.ExcelServices;
using ECommons.GameFunctions;
using ECommons.GameHelpers;
using ECommons.Throttlers;
using FFXIVClientStructs.FFXIV.Component.GUI;
Expand Down Expand Up @@ -110,9 +111,48 @@ internal static void Shutdown()
Random = null;
}

internal static string[] DetermineGearCoffer()
{
if (Player.Object.GetRole() == CombatRole.Tank) return Lang.CofferOfFending;
if (Player.Object.GetRole() == CombatRole.Healer) return Lang.CofferOfHealing;
if (Player.Job.GetUpgradedJob().EqualsAny(Job.BRD, Job.DNC, Job.MCH)) return Lang.CofferOfAiming;
if (Player.Job.GetUpgradedJob().EqualsAny(Job.DRG, Job.RPR)) return Lang.CofferOfMaiming;
if (Player.Job.GetUpgradedJob().EqualsAny(Job.NIN, Job.VPR)) return Lang.CofferOfScouting;
if (Player.Object.ClassJob.GameData.Role == 2) return Lang.CofferOfSlaying; //other melees
if (Player.Object.GetRole() == CombatRole.DPS) return Lang.CofferOfCasting; //only casters left
return null; //doh/dol
}

internal static string[] DetermineAccessoryCoffer()
{
if (Player.Object.GetRole() == CombatRole.Tank) return Lang.CofferOfFending;
if (Player.Object.GetRole() == CombatRole.Healer) return Lang.CofferOfHealing;
if (Player.Job.GetUpgradedJob().EqualsAny(Job.BRD, Job.DNC, Job.MCH, Job.NIN, Job.VPR)) return Lang.CofferOfAiming;
if (Player.Object.ClassJob.GameData.Role == 3) return Lang.CofferOfCasting; //phys rangeds are excluded before
if (Player.Object.GetRole() == CombatRole.DPS) return Lang.CofferOfStriking; //only non-aiming melee left
return null; //doh/dol
}

internal static bool TrySelectCoffer(List<ReaderJournalResult.OptionalReward> data, out int index)
{
List<int> possible = [];
var accessoryString = DetermineAccessoryCoffer();
var gearString = DetermineGearCoffer();
for (int i = 0; i < data.Count; i++)
{
if (gearString != null && data[i].Name.ContainsAny(StringComparison.OrdinalIgnoreCase, gearString))
{
PluginLog.Information($"Gear string was {gearString.Print()}");
index = i;
return true;
}
if (accessoryString != null && data[i].Name.ContainsAny(StringComparison.OrdinalIgnoreCase, gearString))
{
PluginLog.Information($"Accessory string was {gearString.Print()}");
index = i;
return true;
}
}
for (var i = 0; i < data.Count; i++)
{
var d = data[i];
Expand Down
4 changes: 4 additions & 0 deletions TextAdvance/Gui/Overlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public override void Draw()
{
col = EColor.GreenBright;
}
if (P.IsDisableButtonHeld())
{
col = ImGuiColors.DalamudRed;
}
ImGuiEx.Text(col, "TextAdvance: ");
ImGui.SameLine(0, 0);
if (!blocked || Environment.TickCount64 % 2000 > 1000)
Expand Down
1 change: 1 addition & 0 deletions TextAdvance/Gui/TabConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ internal static void Draw()
ImGui.EndCombo();
}
ImGui.Checkbox($"Print navigation status into chat", ref P.config.NavStatusChat);
ImGui.Checkbox("(very experimental) Allow flight", ref P.config.EnableFlight);
})

.Section("Miscellaneous")
Expand Down
20 changes: 19 additions & 1 deletion TextAdvance/Lang.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
namespace TextAdvance;
using Dalamud.Utility.Timing;
using ECommons.ExcelServices;
using System;

namespace TextAdvance;

internal static class Lang
{
internal static string[] AcceptStr = ["Accept", "接受", "Annehmen", "Accepter", "受注"];
internal static string[] SkipCutsceneStr = ["Skip cutscene?", "要跳过这段过场动画吗?", "要跳過這段過場動畫嗎?", "Videosequenz überspringen?", "Passer la scène cinématique ?", "このカットシーンをスキップしますか?"];
internal static string[] YesStr = ["Yes.", "", "Ja", "Oui", "はい"];
internal static string[] CompleteStr = ["Complete", "完成", "Abschließen", "Accepter", "コンプリート"];

/*Scaevan accessories of fending coffer
Scaevan accessories of slaying coffer
Scaevan accessories of aiming coffer
Scaevan accessories of healing coffer
Scaevan accessories of casting coffer*/
internal static string[] CofferOfAiming = ["aiming"];
internal static string[] CofferOfStriking = ["striking"];
internal static string[] CofferOfHealing = ["healing"];
internal static string[] CofferOfSlaying = ["slaying"];
internal static string[] CofferOfCasting = ["casting"];
internal static string[] CofferOfFending = ["fending"];
internal static string[] CofferOfMaiming = ["maiming"];
internal static string[] CofferOfScouting = ["scouting"];
}
4 changes: 2 additions & 2 deletions TextAdvance/Navmesh/MoveManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ public void EnqueueMoveAndInteract(MoveData data)
SpecialAdjust(data);
P.NavmeshManager.Stop();
P.EntityOverlay.TaskManager.Abort();
if (Svc.Condition[ConditionFlag.InFlight])
/*if (Svc.Condition[ConditionFlag.InFlight])
{
Svc.Toasts.ShowError("[TextAdvance] Flying pathfinding is not supported");
return;
}
}*/
if (Vector3.Distance(data.Position, Player.Object.Position) > 20f)
{
P.EntityOverlay.TaskManager.Enqueue(MountIfCan);
Expand Down
17 changes: 9 additions & 8 deletions TextAdvance/TextAdvance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Component.GUI;
using Lumina.Excel.GeneratedSheets;
using System.Security.Principal;
using TextAdvance.Executors;
using TextAdvance.Gui;
using TextAdvance.Navmesh;
Expand Down Expand Up @@ -214,7 +215,7 @@ private void HandleCommand(string command, string arguments)

internal bool IsEnabled(bool pure = false)
{
return (Enabled || S.IPCProvider.IsInExternalControl() || IsTerritoryEnabled()) && (!Locked || pure);
return (Enabled || S.IPCProvider.IsInExternalControl() || IsTerritoryEnabled() || IsEnableButtonHeld()) && (!Locked || pure);
}

internal bool IsTerritoryEnabled()
Expand Down Expand Up @@ -262,7 +263,7 @@ private void Tick()
}
if (config.GetEnableAutoInteract()) ExecAutoInteract.Tick();
}
if ((IsEnabled() || (IsEnableButtonHeld() && Native.ApplicationIsActivated())) &&
if (IsEnabled() &&
(Svc.Condition[ConditionFlag.OccupiedInQuestEvent] ||
Svc.Condition[ConditionFlag.Occupied33] ||
Svc.Condition[ConditionFlag.OccupiedInEvent] ||
Expand Down Expand Up @@ -300,17 +301,17 @@ private void Tick()

internal bool IsDisableButtonHeld()
{
if (config.TempDisableButton == Button.ALT && ImGui.GetIO().KeyAlt) return true;
if (config.TempDisableButton == Button.CTRL && ImGui.GetIO().KeyCtrl) return true;
if (config.TempDisableButton == Button.SHIFT && ImGui.GetIO().KeyShift) return true;
if (config.TempDisableButton == Button.ALT && ImGui.GetIO().KeyAlt) return !CSFramework.Instance()->WindowInactive;
if (config.TempDisableButton == Button.CTRL && ImGui.GetIO().KeyCtrl) return !CSFramework.Instance()->WindowInactive;
if (config.TempDisableButton == Button.SHIFT && ImGui.GetIO().KeyShift) return !CSFramework.Instance()->WindowInactive;
return false;
}

bool IsEnableButtonHeld()
{
if (config.TempEnableButton == Button.ALT && ImGui.GetIO().KeyAlt) return true;
if (config.TempEnableButton == Button.CTRL && ImGui.GetIO().KeyCtrl) return true;
if (config.TempEnableButton == Button.SHIFT && ImGui.GetIO().KeyShift) return true;
if (config.TempEnableButton == Button.ALT && ImGui.GetIO().KeyAlt) return !CSFramework.Instance()->WindowInactive;
if (config.TempEnableButton == Button.CTRL && ImGui.GetIO().KeyCtrl) return !CSFramework.Instance()->WindowInactive;
if (config.TempEnableButton == Button.SHIFT && ImGui.GetIO().KeyShift) return !CSFramework.Instance()->WindowInactive;
return false;
}
}
2 changes: 1 addition & 1 deletion TextAdvance/TextAdvance.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Authors>NightmareXIV</Authors>
<Version>3.2.3.3</Version>
<Version>3.2.3.4</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion TextAdvance/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static string GetMountName(int id)
return Svc.Data.GetExcelSheet<Mount>().GetRow((uint)id).Singular.ExtractText();
}

public static bool CanFly() => false;// C.EnableFlight && P.Memory.IsFlightProhibited(P.Memory.FlightAddr) == 0;
public static bool CanFly() => C.EnableFlight && P.Memory.IsFlightProhibited(P.Memory.FlightAddr) == 0;

public static bool ThrottleAutoInteract() => EzThrottler.Throttle("AutoInteract");
public static bool ReThrottleAutoInteract() => EzThrottler.Throttle("AutoInteract", rethrottle:true);
Expand Down

0 comments on commit b10a566

Please sign in to comment.