From aed5ece88d260ee24c9394d1f532a3b48e5447b2 Mon Sep 17 00:00:00 2001 From: Jackson <9527380+Jaksuhn@users.noreply.github.com> Date: Tue, 23 Apr 2024 23:24:47 +0200 Subject: [PATCH] landing fix? --- Automaton/Automaton.cs | 2 +- .../Features/Achievements/DateWithDestiny.cs | 56 +++++++++++++------ .../Debugging/SatisfactionSupplyDebug.cs | 43 ++++++++++++++ Automaton/Features/Experiments/ClickToTP.cs | 3 +- Automaton/Features/Other/ClickToMove.cs | 3 +- .../Features/Other/StopKillingTheGame.cs | 2 +- Automaton/Features/UI/WorkshopTurnIn.cs | 2 +- Automaton/FeaturesSetup/BaseFeature.cs | 4 +- ECommons | 2 +- 9 files changed, 90 insertions(+), 27 deletions(-) create mode 100644 Automaton/Features/Debugging/SatisfactionSupplyDebug.cs diff --git a/Automaton/Automaton.cs b/Automaton/Automaton.cs index 9eace62..a4e9086 100644 --- a/Automaton/Automaton.cs +++ b/Automaton/Automaton.cs @@ -6,7 +6,7 @@ using Dalamud.IoC; using Dalamud.Plugin; using ECommons; -using ECommons.Automation; +using ECommons.Automation.LegacyTaskManager; using ECommons.DalamudServices; using ImGuiNET; using System.Collections.Generic; diff --git a/Automaton/Features/Achievements/DateWithDestiny.cs b/Automaton/Features/Achievements/DateWithDestiny.cs index ae9423c..4bc5206 100644 --- a/Automaton/Features/Achievements/DateWithDestiny.cs +++ b/Automaton/Features/Achievements/DateWithDestiny.cs @@ -27,6 +27,8 @@ internal class DateWithDestiny : Feature public override FeatureType FeatureType => FeatureType.Achievements; private bool active = false; + private string step; + private static Vector3 TargetPos; private Throttle action = new(); private NavmeshIPC navmesh; private Random random; @@ -105,14 +107,17 @@ private ushort FateID protected override DrawConfigDelegate DrawConfigTree => (ref bool hasChanged) => { if (ImGui.Button("Start/Stop")) + { active ^= true; - - ImGui.TextUnformatted($"Active: {active}"); + step = string.Empty; + navmesh.Stop(); + } + ImGui.TextUnformatted($"Status: {(active ? "on" : "off")}. Step: {step}"); ImGui.TextUnformatted($"Filtered FATEs:"); var fates = GetFates(); if (fates != null) foreach (var fate in fates) - ImGui.TextUnformatted($"{fate.Name} @ {fate.Position} {Vector3.DistanceSquared(fate.Position, Svc.ClientState.LocalPlayer.Position)} {fate.Progress}%% {fate.TimeRemaining}"); + ImGui.TextUnformatted($"{fate.Name} @ {fate.Position} {Vector3.DistanceSquared(fate.Position, Svc.ClientState.LocalPlayer.Position)} {fate.Progress}% {fate.TimeRemaining}"); ImGui.TextUnformatted($"Unfiltered FATEs:"); foreach (var fate in Svc.Fates) ImGui.TextUnformatted($"{fate.Name} @ {fate.Position} {fate.Progress} {fate.TimeRemaining}/{fate.Duration}"); @@ -137,8 +142,11 @@ private unsafe void OnUpdate(IFramework framework) if (!active || Svc.Fates.Count == 0 || Svc.Condition[ConditionFlag.Unknown57]) return; if (navmesh.IsRunning()) { - if (Vector3.DistanceSquared(FateManager.Instance()->GetFateById(nextFateID)->Location, Svc.ClientState.LocalPlayer.Position) > 3) + if (DistanceToTarget() > 5) + { + step = "Naving to FATE"; return; + } else navmesh.Stop(); } @@ -151,18 +159,21 @@ private unsafe void OnUpdate(IFramework framework) fateMaxLevel = cf->MaxLevel; if (Svc.Condition[ConditionFlag.Mounted]) ExecuteDismount(); - if (!Svc.Condition[ConditionFlag.InCombat]) + if (!Svc.Condition[ConditionFlag.InCombat] && Svc.Targets.Target == null) { var target = GetFateMob(); if (target != null) { - Svc.Log.Debug("Targeting fate mob"); - Svc.Targets.Target = target; - if (!navmesh.IsRunning() || !navmesh.PathfindInProgress()) + if (Svc.Targets.Target == null) + { + step = "Targeting new FATE mob"; + Svc.Targets.Target = target; + } + if (!navmesh.PathfindInProgress()) { - Svc.Log.Debug("Finding path to fate"); - // maybe get the closest point that's 3y from the hitbox instead - navmesh.PathfindAndMoveTo(target.Position, false); + step = "Moving to new mob"; + TargetPos = target.Position; + navmesh.PathfindAndMoveTo(TargetPos, false); return; } } @@ -179,6 +190,7 @@ private unsafe void OnUpdate(IFramework framework) if (HaveYokaiMinionsMissing() && !HasWatchEquipped() && InventoryManager.Instance()->GetInventoryItemCount(YokaiWatch) > 0) { Svc.Log.Debug("Equipping watch watch"); + step = "Equipping Yo-Kai watch"; Equip.EquipItem(15222); } // fate farm until 15 legendary medals @@ -187,6 +199,7 @@ private unsafe void OnUpdate(IFramework framework) { // check for other companions, summon them, repeat Svc.Log.Debug("Have 15 of the relevant Legendary Medal. Swapping minions"); + step = "Swapping minions"; var minion = yokai.FirstOrDefault(x => CompanionUnlocked(x.Minion) && InventoryManager.Instance()->GetInventoryItemCount(x.Medal) < 15).Minion; if (minion != default) { @@ -200,20 +213,21 @@ private unsafe void OnUpdate(IFramework framework) if (!zones.Contains((Z)Svc.ClientState.TerritoryType)) { Svc.Log.Debug("Have Yokai minion equipped but not in appropiate zone. Teleporting"); + step = "Swapping zones"; Telepo.Instance()->Teleport(CoordinatesHelper.GetZoneMainAetheryte((uint)zones.First()), 0); return; } } if (!Svc.Condition[ConditionFlag.Mounted] && !Svc.Condition[ConditionFlag.Casting]) { - Svc.Log.Debug("Mounting"); + step = "Mounting"; ExecuteMount(); return; } if (Svc.Condition[ConditionFlag.Mounted] && !Svc.Condition[ConditionFlag.InFlight]) { - Svc.Log.Debug("Jumping"); + step = "Jumping"; ExecuteJump(); return; } @@ -222,8 +236,10 @@ private unsafe void OnUpdate(IFramework framework) if (nextFate is not null && Svc.Condition[ConditionFlag.InFlight] && !navmesh.PathfindInProgress()) { Svc.Log.Debug("Finding path to fate"); + step = "Finding path to fate"; nextFateID = nextFate.FateId; - navmesh.PathfindAndMoveTo(GetRandomPointInFate(nextFateID), true); + TargetPos = nextFate.Position; + navmesh.PathfindAndMoveTo(TargetPos, true); } } } @@ -237,14 +253,22 @@ private unsafe void OnUpdate(IFramework framework) => Svc.Fates.Where(f => f.GameData.Rule == 1 && f.State != FateState.Preparation && (f.Duration <= 900 || f.Progress > 0) && f.Progress <= 90 && f.TimeRemaining > 120) .OrderBy(f => Vector3.DistanceSquared(Svc.ClientState.LocalPlayer.Position, f.Position)); private unsafe GameObject GetFateMob() - => Svc.Objects.OrderByDescending(x => (x as Character)?.MaxHp ?? 0).ThenByDescending(x => ObjectFunctions.GetAttackableEnemyCountAroundPoint(x.Position, 5)) - .FirstOrDefault(x => !x.IsDead && x.IsTargetable && x.IsHostile() && x.Struct() != null && x.Struct()->FateId == FateID && x.ObjectKind == ObjectKind.BattleNpc && x.SubKind == (byte)BattleNpcSubKind.Enemy); + => Svc.Objects.OrderByDescending(x => Vector3.DistanceSquared(x.Position, Svc.ClientState.LocalPlayer.Position)) + .ThenByDescending(x => (x as Character)?.MaxHp ?? 0) + .ThenByDescending(x => ObjectFunctions.GetAttackableEnemyCountAroundPoint(x.Position, 5)) + .Where(x => x.Struct() != null && x.Struct()->FateId == FateID) + .Where(x => !x.IsDead && x.IsTargetable && x.IsHostile() && x.ObjectKind == ObjectKind.BattleNpc && x.SubKind == (byte)BattleNpcSubKind.Enemy) + .Where(x => Math.Sqrt(Math.Pow(x.Position.X - CurrentFate->Location.X, 2) + Math.Pow(x.Position.Z - CurrentFate->Location.Z, 2)) < CurrentFate->Radius) + .FirstOrDefault(); private unsafe uint CurrentCompanion => Svc.ClientState.LocalPlayer.Struct()->Character.CompanionObject->Character.GameObject.DataID; private unsafe bool CompanionUnlocked(uint id) => UIState.Instance()->IsCompanionUnlocked(id); private unsafe bool HasWatchEquipped() => InventoryManager.Instance()->GetInventoryContainer(InventoryType.EquippedItems)->GetInventorySlot(10)->ItemID == YokaiWatch; private unsafe bool HaveYokaiMinionsMissing() => yokai.Any(x => CompanionUnlocked(x.Minion)); + private unsafe FateContext* CurrentFate => FateManager.Instance()->GetFateById(nextFateID); + private unsafe float DistanceToFate() => Vector3.DistanceSquared(CurrentFate->Location, Svc.ClientState.LocalPlayer.Position); + private unsafe float DistanceToTarget() => Vector3.DistanceSquared(TargetPos, Svc.ClientState.LocalPlayer.Position); private unsafe Vector3 GetRandomPointInFate(ushort fateID) { var fate = FateManager.Instance()->GetFateById(fateID); diff --git a/Automaton/Features/Debugging/SatisfactionSupplyDebug.cs b/Automaton/Features/Debugging/SatisfactionSupplyDebug.cs new file mode 100644 index 0000000..089f411 --- /dev/null +++ b/Automaton/Features/Debugging/SatisfactionSupplyDebug.cs @@ -0,0 +1,43 @@ +using Automaton.Debugging; +using FFXIVClientStructs.FFXIV.Client.Game; +using FFXIVClientStructs.FFXIV.Client.UI.Agent; +using ImGuiNET; + +namespace Automaton.Features.Debugging; + +public unsafe class SatisfactionSupplyDebug : DebugHelper +{ + public override string Name => $"{nameof(SatisfactionSupplyDebug).Replace("Debug", "")} Debugging"; + + public override void Draw() + { + ImGui.Text($"{Name}"); + ImGui.Separator(); + + var agent = AgentSatisfactionSupply.Instance(); + if (agent == null) return; + + ImGui.TextUnformatted($"NPC: [{agent->NpcId}] {agent->NpcInfo.SatisfactionRank}"); + ImGui.TextUnformatted($"ClassJobId: {agent->ClassJobId}"); + ImGui.TextUnformatted($"ClassJobLevel: {agent->ClassJobLevel}"); + ImGui.TextUnformatted($"RemainingAllowances: {agent->RemainingAllowances}"); + ImGui.TextUnformatted($"LevelUnlocked: {agent->LevelUnlocked}"); + ImGui.TextUnformatted($"CanGlamour: {agent->CanGlamour}"); + ImGui.TextUnformatted($"Items: {agent->Item[0]} {agent->Item[1]} {agent->Item[2]}"); + ImGui.TextUnformatted($"WhiteCrafterScrriptId: {agent->WhiteCrafterScrriptId}"); + ImGui.TextUnformatted($"PurpleCrafterScriptId: {agent->PurpleCrafterScriptId}"); + ImGui.TextUnformatted($"WhiteGathererScriptId: {agent->WhiteGathererScriptId}"); + ImGui.TextUnformatted($"PurpleGathererScriptId: {agent->PurpleGathererScriptId}"); + ImGui.TextUnformatted($"TimeRemainingHours: {agent->TimeRemainingHours}"); + ImGui.TextUnformatted($"TimeRemainingMinutes: {agent->TimeRemainingMinutes}"); + foreach (var item in agent->ItemSpan) + { + ImGui.TextUnformatted($"[{item.Id}] c{item.Collectability1}/{item.Collectability2}/{item.Collectability3} b{item.Bonus} r{item.Reward1Id}/{item.Reward2Id} f{item.FishingSpotId}/{item.SpearFishingSpotId}"); + } + + ImGui.TextUnformatted($"WhiteCrafter: {InventoryManager.Instance()->GetInventoryItemCount(AgentSatisfactionSupply.Instance()->WhiteCrafterScrriptId)}"); + ImGui.TextUnformatted($"PurpleCrafter: {InventoryManager.Instance()->GetInventoryItemCount(AgentSatisfactionSupply.Instance()->PurpleCrafterScriptId)}"); + ImGui.TextUnformatted($"WhiteGatherer: {InventoryManager.Instance()->GetInventoryItemCount(AgentSatisfactionSupply.Instance()->WhiteGathererScriptId)}"); + ImGui.TextUnformatted($"PurpleGatherer: {InventoryManager.Instance()->GetInventoryItemCount(AgentSatisfactionSupply.Instance()->PurpleGathererScriptId)}"); + } +} diff --git a/Automaton/Features/Experiments/ClickToTP.cs b/Automaton/Features/Experiments/ClickToTP.cs index 33f6e88..b911353 100644 --- a/Automaton/Features/Experiments/ClickToTP.cs +++ b/Automaton/Features/Experiments/ClickToTP.cs @@ -4,7 +4,6 @@ using ECommons; using ECommons.DalamudServices; using System.Collections.Generic; -using System.Windows.Forms; namespace Automaton.Features.Experiments; @@ -39,7 +38,7 @@ protected override void OnCommand(List args) private void ModifyPOS(IFramework framework) { if (!active) return; - if (GenericHelpers.IsKeyPressed(Keys.LButton) && Misc.IsClickingInGameWorld()) + if (GenericHelpers.IsKeyPressed(ECommons.Interop.LimitedKeys.LeftMouseButton) && Misc.IsClickingInGameWorld()) { if (!isPressed) { diff --git a/Automaton/Features/Other/ClickToMove.cs b/Automaton/Features/Other/ClickToMove.cs index fc13431..b8d8ca3 100644 --- a/Automaton/Features/Other/ClickToMove.cs +++ b/Automaton/Features/Other/ClickToMove.cs @@ -5,7 +5,6 @@ using ECommons.DalamudServices; using ImGuiNET; using System.Numerics; -using System.Windows.Forms; namespace Automaton.Features.Other; @@ -47,7 +46,7 @@ private void MoveTo(IFramework framework) { if (Vector3.DistanceSquared(Svc.ClientState.LocalPlayer.Position, destination) < 0.0025) movement.Enabled = false; - if (GenericHelpers.IsKeyPressed(Keys.LButton) && Misc.IsClickingInGameWorld()) + if (GenericHelpers.IsKeyPressed(ECommons.Interop.LimitedKeys.LeftMouseButton) && Misc.IsClickingInGameWorld()) { if (!isPressed) { diff --git a/Automaton/Features/Other/StopKillingTheGame.cs b/Automaton/Features/Other/StopKillingTheGame.cs index a8f0a69..21b8baf 100644 --- a/Automaton/Features/Other/StopKillingTheGame.cs +++ b/Automaton/Features/Other/StopKillingTheGame.cs @@ -150,7 +150,7 @@ private void CheckDialogue(IFramework framework) var addon = (AtkUnitBase*)Svc.GameGui.GetAddonByName("Dialogue"); if (!addon->IsVisible) return; - WindowsKeypress.SendKeypress(System.Windows.Forms.Keys.NumPad0); + WindowsKeypress.SendKeypress(ECommons.Interop.LimitedKeys.NumPad0); } } } diff --git a/Automaton/Features/UI/WorkshopTurnIn.cs b/Automaton/Features/UI/WorkshopTurnIn.cs index d00d661..fa784a1 100644 --- a/Automaton/Features/UI/WorkshopTurnIn.cs +++ b/Automaton/Features/UI/WorkshopTurnIn.cs @@ -396,7 +396,7 @@ private static bool ConfirmProductRetrieval() => else { //pi.Framework.Gui.Chat.Print(Environment.TickCount + " Now loading not visible"); - if (WindowsKeypress.SendKeypress(Keys.Escape)) + if (WindowsKeypress.SendKeypress(ECommons.Interop.LimitedKeys.Escape)) { return true; } diff --git a/Automaton/FeaturesSetup/BaseFeature.cs b/Automaton/FeaturesSetup/BaseFeature.cs index c5c2cb9..85ed5cb 100644 --- a/Automaton/FeaturesSetup/BaseFeature.cs +++ b/Automaton/FeaturesSetup/BaseFeature.cs @@ -7,9 +7,8 @@ using Dalamud.Memory; using Dalamud.Plugin; using ECommons; -using ECommons.Automation; +using ECommons.Automation.LegacyTaskManager; using ECommons.DalamudServices; -using ECommons.Reflection; using ECommons.Throttlers; using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game.Control; @@ -19,7 +18,6 @@ using ImGuiNET; using Newtonsoft.Json; using System; -using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; diff --git a/ECommons b/ECommons index 799762f..31d8383 160000 --- a/ECommons +++ b/ECommons @@ -1 +1 @@ -Subproject commit 799762f43cb41e803c422fd2841a0fe58f1f0c00 +Subproject commit 31d8383a4f704bebbeb86d4b0351e312318c8218