Skip to content

Commit

Permalink
landing fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaksuhn committed Apr 23, 2024
1 parent b237571 commit aed5ece
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Automaton/Automaton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
56 changes: 40 additions & 16 deletions Automaton/Features/Achievements/DateWithDestiny.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}");
Expand All @@ -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();
}
Expand All @@ -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;
}
}
Expand All @@ -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
Expand All @@ -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)
{
Expand All @@ -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;
}
Expand All @@ -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);
}
}
}
Expand All @@ -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);
Expand Down
43 changes: 43 additions & 0 deletions Automaton/Features/Debugging/SatisfactionSupplyDebug.cs
Original file line number Diff line number Diff line change
@@ -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)}");
}
}
3 changes: 1 addition & 2 deletions Automaton/Features/Experiments/ClickToTP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using ECommons;
using ECommons.DalamudServices;
using System.Collections.Generic;
using System.Windows.Forms;

namespace Automaton.Features.Experiments;

Expand Down Expand Up @@ -39,7 +38,7 @@ protected override void OnCommand(List<string> 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)
{
Expand Down
3 changes: 1 addition & 2 deletions Automaton/Features/Other/ClickToMove.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using ECommons.DalamudServices;
using ImGuiNET;
using System.Numerics;
using System.Windows.Forms;

namespace Automaton.Features.Other;

Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion Automaton/Features/Other/StopKillingTheGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
2 changes: 1 addition & 1 deletion Automaton/Features/UI/WorkshopTurnIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 1 addition & 3 deletions Automaton/FeaturesSetup/BaseFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,7 +18,6 @@
using ImGuiNET;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down
2 changes: 1 addition & 1 deletion ECommons
Submodule ECommons updated 70 files
+1 −2 ECommons/Automation/LegacyTaskManager/TaskManager.cs
+1 −5 ECommons/Automation/LegacyTaskManager/[email protected]
+1 −5 ECommons/Automation/LegacyTaskManager/[email protected]
+1 −5 ECommons/Automation/LegacyTaskManager/[email protected]
+1 −1 ECommons/Automation/LegacyTaskManager/TaskManagerTask.cs
+39 −0 ECommons/Automation/NeoTaskManager/TaskManager.Delay.cs
+53 −0 ECommons/Automation/NeoTaskManager/TaskManager.Enqueue.cs
+53 −0 ECommons/Automation/NeoTaskManager/TaskManager.Insert.cs
+264 −0 ECommons/Automation/NeoTaskManager/TaskManager.cs
+158 −0 ECommons/Automation/NeoTaskManager/TaskManagerConfiguration.cs
+60 −0 ECommons/Automation/NeoTaskManager/TaskManagerTask.cs
+6 −0 ECommons/Automation/NeoTaskManager/TaskTimeoutException.cs
+15 −0 ECommons/Automation/NeoTaskManager/Tasks/DelayTask.cs
+16 −0 ECommons/Automation/NeoTaskManager/Tasks/FrameDelayTask.cs
+10 −0 ECommons/Automation/WindowsKeypress.Forms.cs
+10 −8 ECommons/Automation/WindowsKeypress.cs
+1 −1 ECommons/Commands/CmdManager.cs
+33 −8 ECommons/Configuration/DefaultSerializationFactory.cs
+0 −6 ECommons/Configuration/EzConfig.cs
+1 −7 ECommons/Configuration/EzConfigValueStorage.cs
+3 −1 ECommons/DalamudServices/Svc.cs
+98 −95 ECommons/ECommons.csproj
+15 −3 ECommons/ECommonsMain.cs
+0 −1 ECommons/ExcelServices/ExcelJobHelper.cs
+1 −3 ECommons/ExcelServices/ExcelWorldHelper.cs
+8 −0 ECommons/ExcelServices/GrandCompany.cs
+0 −3 ECommons/ExcelServices/TerritoryIntendedUseEnum.cs
+0 −4 ECommons/EzHookManager/EzHookAttribute.cs
+1 −2 ECommons/EzHookManager/EzSignatureHelper.cs
+104 −30 ECommons/EzIpcManager/EzIPC.cs
+2 −2 ECommons/EzIpcManager/EzIPC.md
+5 −6 ECommons/EzIpcManager/EzIPCAttribute.cs
+0 −4 ECommons/EzIpcManager/EzIPCDisposalToken.cs
+0 −4 ECommons/EzIpcManager/EzIPCEventAttribute.cs
+0 −7 ECommons/EzIpcManager/EzIPCExtensions.cs
+22 −0 ECommons/EzIpcManager/SafeWrapper.cs
+284 −0 ECommons/EzIpcManager/SafeWrapperAny.cs
+285 −0 ECommons/EzIpcManager/SafeWrapperIPC.cs
+4 −2 ECommons/GameHelpers/Player.cs
+108 −0 ECommons/GenericHelpers.Forms.cs
+31 −76 ECommons/GenericHelpers.cs
+0 −4 ECommons/ImGuiMethods/EnumMemberNameAttribute.cs
+23 −0 ECommons/ImGuiMethods/EzFullscreenOverlayWindow.cs
+48 −0 ECommons/ImGuiMethods/EzOverlayWindow.cs
+0 −1 ECommons/ImGuiMethods/FontAwesome.cs
+0 −4 ECommons/ImGuiMethods/ImGuiEx/Alignment.cs
+0 −5 ECommons/ImGuiMethods/ImGuiEx/Checkbox.cs
+9 −5 ECommons/ImGuiMethods/ImGuiEx/CollectionCheckbox.cs
+5 −7 ECommons/ImGuiMethods/ImGuiEx/EzTable.cs
+73 −6 ECommons/ImGuiMethods/ImGuiEx/ImGuiEx.cs
+0 −4 ECommons/ImGuiMethods/ImGuiEx/InternalUtilities.cs
+0 −3 ECommons/ImGuiMethods/ImGuiEx/ObsoleteOverloads.cs
+7 −6 ECommons/ImGuiMethods/Notify.cs
+0 −4 ECommons/ImGuiMethods/NotifyWindow.cs
+9 −5 ECommons/ImGuiMethods/ThreadLoadImageHandler.cs
+12 −6 ECommons/Logging/DuoLog.cs
+2 −0 ECommons/Logging/InternalLog.cs
+2 −2 ECommons/PartyFunctions/UniversalPartyMember.cs
+0 −5 ECommons/Reflection/CachedPluginEntry.cs
+30 −0 ECommons/Reflection/FieldPropertyUnion/IFieldPropertyUnion.cs
+46 −0 ECommons/Reflection/FieldPropertyUnion/UnionField.cs
+46 −0 ECommons/Reflection/FieldPropertyUnion/UnionProperty.cs
+28 −4 ECommons/Reflection/ReflectionHelper/Call.cs
+0 −2 ECommons/Reflection/ReflectionHelper/CallStatic.cs
+40 −13 ECommons/Reflection/ReflectionHelper/ReflectionHelper.cs
+43 −5 ECommons/Reflection/ReflectionHelper/Utils.cs
+3 −2 ECommons/SimpleGui/ConfigWindow.cs
+15 −5 ECommons/SimpleGui/EzConfigGui.cs
+1 −1 ECommons/UIHelpers/AtkReader.cs
+6 −0 README.md

0 comments on commit aed5ece

Please sign in to comment.