Skip to content

Commit

Permalink
add triggers to return and ceruleum
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaksuhn committed Oct 27, 2024
1 parent 51e7a16 commit 9a8e07a
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Automaton/Features/ARCeruleum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public override void DrawConfig()

private unsafe void CheckCharacter()
{
if (!P.UsingARPostProcess && InventoryManager.Instance()->GetInventoryItemCount(CeruleumTankId) <= 200 && CompanyWorkshopTerritories.Contains(Player.Territory))
if (!P.UsingARPostProcess && P.AutoRetainerAPI.GetOfflineCharacterData(Player.CID).EnabledSubs.Count > 0 && InventoryManager.Instance()->GetInventoryItemCount(CeruleumTankId) <= 200 && CompanyWorkshopTerritories.Contains(Player.Territory))
{
P.UsingARPostProcess = true;
AutoRetainer.RequestCharacterPostprocess();
Expand Down
13 changes: 12 additions & 1 deletion Automaton/Features/DebugTools.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using Dalamud.Game.ClientState.Keys;
using Automaton.IPC;
using Automaton.UI;
using Dalamud.Game.ClientState.Keys;
using Dalamud.Game.Gui.Toast;
using ECommons;
using ECommons.Interop;
using ECommons.SimpleGui;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using FFXIVClientStructs.FFXIV.Client.System.Framework;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets2;

namespace Automaton.Features;

Expand Down Expand Up @@ -57,6 +61,10 @@ private unsafe void OnSetup(AddonEvent type, AddonArgs args)
private void OnTeleportClick(string command, string arguments)
{
tpActive ^= true;
if (tpActive)
EzConfigGui.WindowSystem.AddWindow(new MousePositionOverlay());
else
EzConfigGui.RemoveWindow<MousePositionOverlay>();
Svc.Toasts.ShowNormal($"TPClick {(tpActive ? "Enabled" : "Disabled")}", new ToastOptions() { Speed = ToastSpeed.Fast });
}

Expand Down Expand Up @@ -88,16 +96,19 @@ private void OnNoClip(string command, string arguments)
[CommandHandler(["/move", "/speed"], "Modify your movement speed", nameof(Config.EnableMoveSpeed))]
private void OnMoveSpeed(string command, string arguments) => Player.Speed = float.TryParse(arguments, out var speed) ? speed : 1.0f;

public static bool ShowMouseOverlay;
private bool IsLButtonPressed;
private bool tpActive;
private bool ncActive;
private unsafe void OnUpdate(IFramework framework)
{
if (!Player.Available || Player.Occupied) return;
ShowMouseOverlay = false;
if (Config.EnableTPClick && tpActive)
{
if (!Framework.Instance()->WindowInactive && IsKeyPressed([LimitedKeys.LeftControlKey, LimitedKeys.RightControlKey]) && Utils.IsClickingInGameWorld())
{
ShowMouseOverlay = true;
var pos = ImGui.GetMousePos();
if (Svc.GameGui.ScreenToWorld(pos, out var res))
{
Expand Down
29 changes: 15 additions & 14 deletions Automaton/UI/DebugWindow.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
using Dalamud;
using Dalamud.Interface.Windowing;
using ECommons;
using FFXIVClientStructs.Attributes;
using FFXIVClientStructs.FFXIV.Application.Network.WorkDefinitions;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using System.Diagnostics.Metrics;
using System.Reflection;
using System.Runtime.InteropServices;

Expand All @@ -26,21 +21,27 @@ public DebugWindow() : base($"{Name} - Debug {P.GetType().Assembly.GetName().Ver

public static void Dispose() { }

public unsafe override void Draw()
public override unsafe void Draw()
{
for (var i = 0; i < RaptureAtkUnitManager.Instance()->FocusedUnitsList.Count; i++)
for (var i = 0; i < RaptureAtkUnitManager.Instance()->AllLoadedUnitsList.Count; i++)
{
var atk = RaptureAtkUnitManager.Instance()->FocusedUnitsList.Entries[i].Value;
ImGui.TextUnformatted($"{i} {atk == null} {(atk != null ? atk->NameString : "")}");
}
ImGui.TextUnformatted($"{RaptureAtkUnitManager.Instance()->FocusedUnitsList.Entries[^1].Value == null}");
if (GenericHelpers.TryGetAddonByName<AtkUnitBase>("LookingForGroup", out var lfg))
{
ImGui.TextUnformatted($"{RaptureAtkUnitManager.Instance()->FocusedUnitsList.Entries[^1].Value == lfg}");
var atk = RaptureAtkUnitManager.Instance()->AllLoadedUnitsList.Entries[i].Value;
if (atk == null || (atk->Flags198 & 0b1100_0000) != 0 || atk->HostId != 0) continue;
ImGui.TextUnformatted($"special addon: {atk->NameString}");
}
//for (var i = 0; i < RaptureAtkUnitManager.Instance()->FocusedUnitsList.Count; i++)
//{
// var atk = RaptureAtkUnitManager.Instance()->FocusedUnitsList.Entries[i].Value;
// ImGui.TextUnformatted($"{i} {atk == null} {(atk != null ? atk->NameString : "")}");
//}
//ImGui.TextUnformatted($"{RaptureAtkUnitManager.Instance()->FocusedUnitsList.Entries[^1].Value == null}");
//if (TryGetAddonByName<AtkUnitBase>("LookingForGroup", out var lfg))
//{
// ImGui.TextUnformatted($"{RaptureAtkUnitManager.Instance()->FocusedUnitsList.Entries[^1].Value == lfg}");
//}
//for (var i = 0; i < RaptureAtkUnitManager.Instance()->FocusedUnitsList.Count; i++)
//{
// var atk = RaptureAtkUnitManager.Instance()->FocusedUnitsList.Entries[i].Value;
// if (atk == null) continue;
// var str = GetAddonStruct(atk);
// if (str == null) continue;
Expand Down
78 changes: 78 additions & 0 deletions Automaton/UI/MousePositionOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using Automaton.Features;
using Dalamud.Interface.Windowing;
using ECommons.ImGuiMethods;
using ECommons.Interop;
using ECommons.SimpleGui;
using ImGuiNET;

namespace Automaton.UI;
public class MousePositionOverlay : Window
{
public MousePositionOverlay() : base("Hyperborea Overlay", ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.AlwaysUseWindowPadding, true)
{
Position = Vector2.Zero;
PositionCondition = ImGuiCond.Always;
Size = ImGuiHelpers.MainViewport.Size;
SizeCondition = ImGuiCond.Always;
EzConfigGui.WindowSystem.AddWindow(this);
IsOpen = true;
RespectCloseHotkey = false;
}

public override void PreDraw() => ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero);
public override void PostDraw() => ImGui.PopStyleVar();
public override bool DrawConditions() => DebugTools.ShowMouseOverlay;

public override void Draw()
{
var pos = ImGui.GetMousePos();
if (Svc.GameGui.ScreenToWorld(pos, out var res))
{
var col = GradientColor.Get(EColor.RedBright, EColor.YellowBright);
DrawRingWorld(res, 0.5f, col.ToUint(), 2f);
var l = MathF.Sqrt(2f) / 2f * 0.5f;
DrawLineWorld(res + new Vector3(-l, 0, -l), res + new Vector3(l, 0, l), col.ToUint(), 2f);
DrawLineWorld(res + new Vector3(l, 0, -l), res + new Vector3(-l, 0, l), col.ToUint(), 2f);
}
}

void DrawLineWorld(Vector3 a, Vector3 b, uint color, float thickness)
{
var result = GetAdjustedLine(a, b);
if (result.posA == null) return;
ImGui.GetWindowDrawList().PathLineTo(new Vector2(result.posA.Value.X, result.posA.Value.Y));
ImGui.GetWindowDrawList().PathLineTo(new Vector2(result.posB.Value.X, result.posB.Value.Y));

Check warning on line 44 in Automaton/UI/MousePositionOverlay.cs

View workflow job for this annotation

GitHub Actions / Build

Nullable value type may be null.
ImGui.GetWindowDrawList().PathStroke(color, ImDrawFlags.None, thickness);
}

(Vector2? posA, Vector2? posB) GetAdjustedLine(Vector3 pointA, Vector3 pointB)
{
var resultA = Svc.GameGui.WorldToScreen(pointA, out Vector2 posA);
var resultB = Svc.GameGui.WorldToScreen(pointB, out Vector2 posB);
//if (!resultA || !resultB) return default;
return (posA, posB);
}

public void DrawRingWorld(Vector3 position, float radius, uint color, float thickness)
{
var segments = 50;
int seg = segments / 2;
Vector2?[] elements = new Vector2?[segments];
for (int i = 0; i < segments; i++)
{
Svc.GameGui.WorldToScreen(
new Vector3(position.X + radius * (float)Math.Sin(Math.PI / seg * i),
position.Y,
position.Z + radius * (float)Math.Cos(Math.PI / seg * i)
),
out Vector2 pos);
elements[i] = new Vector2(pos.X, pos.Y);
}
foreach (var pos in elements)
{
if (pos == null) continue;
ImGui.GetWindowDrawList().PathLineTo(pos.Value);
}
ImGui.GetWindowDrawList().PathStroke(color, ImDrawFlags.Closed, thickness);
}
}
41 changes: 41 additions & 0 deletions Automaton/Utilities/FocusWatcher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Component.GUI;
using FFXIVClientStructs.Interop;

namespace Automaton.Utilities;
public unsafe class FocusWatcher : IDisposable
{
public FocusWatcher() => Svc.Framework.Update += CheckAddonFocus;

public static event Action<Pointer<AtkUnitBase>> AddonFocusChanged;
public static void OnAddonFocusChange(Pointer<AtkUnitBase> atk)
{
LastFocusedAddon = atk != null ? atk.Value->NameString : string.Empty;
AddonFocusChanged?.Invoke(atk);
}

private static string LastFocusedAddon = string.Empty;
private void CheckAddonFocus(IFramework framework)
{
var focus = AtkStage.Instance()->GetFocus();
if (focus == null && LastFocusedAddon != string.Empty)
{
LastFocusedAddon = string.Empty;
Svc.Log.Info($"{nameof(LastFocusedAddon)} is now null");
AddonFocusChanged?.Invoke(null);
return;
}
for (var i = 0; i < RaptureAtkUnitManager.Instance()->FocusedUnitsList.Count; i++)
{
var atk = RaptureAtkUnitManager.Instance()->FocusedUnitsList.Entries[i].Value;
if (atk != null && atk->RootNode == GetRootNode(focus) && atk->NameString != LastFocusedAddon)
{
LastFocusedAddon = atk->NameString;
Svc.Log.Info($"New addon focused {LastFocusedAddon}");
AddonFocusChanged?.Invoke(atk);
}
}
}

public void Dispose() => Svc.Framework.Update -= CheckAddonFocus;
}
18 changes: 18 additions & 0 deletions Automaton/Utilities/Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,22 @@ public static unsafe List<Pointer<InventoryItem>> GetDesynthableItems(IEnumerabl
}
return items;
}

public static unsafe uint GetEmptySlots(IEnumerable<InventoryType> inventories = null)

Check warning on line 103 in Automaton/Utilities/Inventory.cs

View workflow job for this annotation

GitHub Actions / Build

Cannot convert null literal to non-nullable reference type.
{
if (inventories == null)
return InventoryManager.Instance()->GetEmptySlotsInBag();
else
{
uint count = 0;
foreach (var inv in inventories)
{
var cont = InventoryManager.Instance()->GetInventoryContainer(inv);
for (var i = 0; i < cont->Size; ++i)
if (cont->GetInventorySlot(i)->ItemId == 0)
count++;
}
return count;
}
}
}
3 changes: 2 additions & 1 deletion Automaton/Utilities/Memory.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Dalamud.Game.Network.Structures;
using Dalamud.Hooking;
using ECommons.Automation;
using ECommons.EzHookManager;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.Character;
Expand Down Expand Up @@ -280,7 +281,7 @@ private unsafe nint IsFlightProhibitedDetour(nint a1)

private byte ReturnDetour(AgentInterface* agent)
{
if (ActionManager.Instance()->GetActionStatus(ActionType.GeneralAction, 6) != 0)
if (ActionManager.Instance()->GetActionStatus(ActionType.GeneralAction, 6) != 0 || GameMain.IsInPvPInstance())
return ReturnHook.Original(agent);

ExecuteCommand(214);
Expand Down
2 changes: 1 addition & 1 deletion Automaton/Utilities/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace Automaton.Utilities;

public unsafe static class Player
public static unsafe class Player
{
public static IPlayerCharacter Object => Svc.ClientState.LocalPlayer;
public static bool Available => Svc.ClientState.LocalPlayer != null;
Expand Down
2 changes: 1 addition & 1 deletion ECommons
Submodule ECommons updated 89 files
+11 −0 ECommons/GenericHelpers.cs
+5 −2 ECommons/ImGuiMethods/EzOverlayWindow.cs
+21 −6 ECommons/ImGuiMethods/ImGuiEx/ImGuiEx.cs
+21 −0 ECommons/MathHelpers/Number.cs
+37 −4 ECommons/UIHelpers/AddonMasterImplementations/!AddonMasterBase.cs
+17 −0 ECommons/UIHelpers/AddonMasterImplementations/AirShipExploration.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/AirShipExplorationResult.cs
+23 −0 ECommons/UIHelpers/AddonMasterImplementations/Bank.cs
+54 −0 ECommons/UIHelpers/AddonMasterImplementations/BankaCraftworksSupply.cs
+5 −0 ECommons/UIHelpers/AddonMasterImplementations/BannerEditor.cs
+5 −0 ECommons/UIHelpers/AddonMasterImplementations/BannerList.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/CollectablesShop.cs
+27 −0 ECommons/UIHelpers/AddonMasterImplementations/ColorantColoring.cs
+17 −0 ECommons/UIHelpers/AddonMasterImplementations/CompanyCraftRecipeNoteBook.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/CompanyCraftSupply.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/ContentsFinderConfirm.cs
+19 −0 ECommons/UIHelpers/AddonMasterImplementations/ContentsFinderSetting.cs
+30 −13 ECommons/UIHelpers/AddonMasterImplementations/ContextMenu.cs
+20 −0 ECommons/UIHelpers/AddonMasterImplementations/Dialogue.cs
+5 −0 ECommons/UIHelpers/AddonMasterImplementations/DifficultySelectYesNo.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/FreeCompanyCreditShop.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/Gathering.cs
+11 −0 ECommons/UIHelpers/AddonMasterImplementations/GatheringMasterpiece.cs
+33 −0 ECommons/UIHelpers/AddonMasterImplementations/GcArmyChangeClass.cs
+15 −0 ECommons/UIHelpers/AddonMasterImplementations/GcArmyExpedition.cs
+15 −0 ECommons/UIHelpers/AddonMasterImplementations/GcArmyExpeditionResult.cs
+37 −0 ECommons/UIHelpers/AddonMasterImplementations/GcArmyMenberProfile.cs
+17 −0 ECommons/UIHelpers/AddonMasterImplementations/GcArmyTraining.cs
+23 −0 ECommons/UIHelpers/AddonMasterImplementations/GearSetList.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/GrandCompanySupplyReward.cs
+24 −0 ECommons/UIHelpers/AddonMasterImplementations/InputNumeric.cs
+17 −0 ECommons/UIHelpers/AddonMasterImplementations/ItemFinder.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/ItemInspectionResult.cs
+61 −0 ECommons/UIHelpers/AddonMasterImplementations/ItemSearchResult.cs
+3 −0 ECommons/UIHelpers/AddonMasterImplementations/JournalDetail.cs
+2 −1 ECommons/UIHelpers/AddonMasterImplementations/JournalResult.cs
+17 −0 ECommons/UIHelpers/AddonMasterImplementations/LetterHistory.cs
+21 −0 ECommons/UIHelpers/AddonMasterImplementations/LetterList.cs
+36 −0 ECommons/UIHelpers/AddonMasterImplementations/LetterViewer.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/LookingForGroup.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/LookingForGroupCondition.cs
+10 −8 ECommons/UIHelpers/AddonMasterImplementations/LookingForGroupDetail.cs
+21 −0 ECommons/UIHelpers/AddonMasterImplementations/LookingForGroupPrivate.cs
+24 −0 ECommons/UIHelpers/AddonMasterImplementations/LotteryWeeklyInput.cs
+45 −0 ECommons/UIHelpers/AddonMasterImplementations/LotteryWeeklyRewardList.cs
+26 −0 ECommons/UIHelpers/AddonMasterImplementations/ManeuversArmorBoarding.cs
+20 −0 ECommons/UIHelpers/AddonMasterImplementations/ManeuversRecord.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/MateriaAttachDialog.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/MateriaRetrieveDialog.cs
+3 −14 ECommons/UIHelpers/AddonMasterImplementations/MaterializeDialog.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/MiragePrismExecute.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/MiragePrismRemove.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/PurifyAutoDialog.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/PurifyResult.cs
+17 −0 ECommons/UIHelpers/AddonMasterImplementations/PvpProfile.cs
+23 −0 ECommons/UIHelpers/AddonMasterImplementations/PvpReward.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/RecipeNote.cs
+19 −0 ECommons/UIHelpers/AddonMasterImplementations/RecommendEquip.cs
+2 −12 ECommons/UIHelpers/AddonMasterImplementations/Repair.cs
+2 −12 ECommons/UIHelpers/AddonMasterImplementations/Request.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/RetainerItemTransferList.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/RetainerItemTransferProgress.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/RetainerList.cs
+4 −2 ECommons/UIHelpers/AddonMasterImplementations/RetainerSell.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/RetainerTaskAsk.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/RetainerTaskResult.cs
+21 −0 ECommons/UIHelpers/AddonMasterImplementations/ReturnerDialog.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/SalvageAutoDialog.cs
+5 −4 ECommons/UIHelpers/AddonMasterImplementations/SalvageDialog.cs
+3 −2 ECommons/UIHelpers/AddonMasterImplementations/SalvageResult.cs
+31 −10 ECommons/UIHelpers/AddonMasterImplementations/SelectIconString.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/SelectOk.cs
+31 −20 ECommons/UIHelpers/AddonMasterImplementations/SelectString.cs
+11 −4 ECommons/UIHelpers/AddonMasterImplementations/SelectYesno.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/ShopCardDialog.cs
+22 −0 ECommons/UIHelpers/AddonMasterImplementations/ShopExchangeCurrencyDialog.cs
+19 −0 ECommons/UIHelpers/AddonMasterImplementations/ShopExchangeItemDialog.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/Talk.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/TitleDCWorldMap.cs
+36 −0 ECommons/UIHelpers/AddonMasterImplementations/TripleTriadRequest.cs
+26 −0 ECommons/UIHelpers/AddonMasterImplementations/TripleTriadResult.cs
+21 −0 ECommons/UIHelpers/AddonMasterImplementations/VoteMvp.cs
+19 −0 ECommons/UIHelpers/AddonMasterImplementations/WeeklyBingoResult.cs
+14 −14 ECommons/UIHelpers/AddonMasterImplementations/_CharaSelectListMenu.cs
+2 −0 ECommons/UIHelpers/AddonMasterImplementations/_CharaSelectWorldServer.cs
+15 −8 ECommons/UIHelpers/AddonMasterImplementations/_TitleMenu.cs
+54 −0 ECommons/UIHelpers/AtkReaderImplementations/ReaderBannerList.cs
+27 −0 ECommons/UIHelpers/AtkReaderImplementations/ReaderLetterHistory.cs
+17 −0 ECommons/UIHelpers/AtkReaderImplementations/ReaderLetterViewer.cs
4 changes: 1 addition & 3 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
Better targeting that works in pvp
- ability to preview which target is next/prev
auto hide helmet during cutscene
autoretainer companion tweaks
- auto turn in when inventory is at a certain level
- auto buy tanks at a certain level
relay helper: minion support
Some sort of go to npc command that incorporates itemvendorlocation/lifestream/navmesh
/tplast command to teleport to the last linked loc
Enhanced login/logout, ability to do commands when those are triggered
Expand Down

0 comments on commit 9a8e07a

Please sign in to comment.