Skip to content

Commit

Permalink
add query to fate location
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaksuhn committed Apr 24, 2024
1 parent 2ba6a18 commit 124436b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
11 changes: 6 additions & 5 deletions Automaton/Features/Achievements/DateWithDestiny.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.Fate;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using System;
Expand Down Expand Up @@ -131,7 +130,7 @@ private ushort FateID
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} {fate.Progress}% {fate.TimeRemaining}");
ImGui.TextUnformatted($"Unfiltered FATEs:");
foreach (var fate in Svc.Fates)
{
Expand Down Expand Up @@ -249,7 +248,8 @@ private unsafe void OnUpdate(IFramework framework)
{
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);
if (!Svc.Condition[ConditionFlag.Casting])
Telepo.Instance()->Teleport(CoordinatesHelper.GetZoneMainAetheryte((uint)zones.First()), 0);
return;
}
}
Expand Down Expand Up @@ -308,8 +308,9 @@ private unsafe Vector3 GetRandomPointInFate(ushort fateID)
{
var fate = FateManager.Instance()->GetFateById(fateID);
var angle = random.NextDouble() * 2 * Math.PI;
var randomPoint = new Vector3((float)(fate->Radius / 2 * Math.Cos(angle)), fate->Location.Y, (float)(fate->Radius / 2 * Math.Sin(angle)));
return navmesh.NearestPoint(randomPoint, 5, 5);
var randomPoint = new Vector3((float)(fate->Location.X + (fate->Radius / 2 * Math.Cos(angle))), fate->Location.Y, (float)(fate->Location.Z + (fate->Radius / 2 * Math.Sin(angle))));
var point = navmesh.NearestPoint(randomPoint, 5, 5);
return (Vector3)(point != null ? point : fate->Location);
}

private void SyncFate(ushort value)
Expand Down
21 changes: 17 additions & 4 deletions Automaton/Features/Debugging/FateDebug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using ECommons.DalamudServices;
using FFXIVClientStructs.FFXIV.Client.Game.Fate;
using ImGuiNET;
using System;
using System.Linq;
using System.Numerics;

Expand All @@ -12,6 +13,8 @@ internal unsafe class FateDebug : DebugHelper
public override string Name => $"{nameof(FateDebug).Replace("Debug", "")} Debugging";

FateManager* fm = FateManager.Instance();
NavmeshIPC navmesh = new();
Random random = new();

public override void Draw()
{
Expand All @@ -33,10 +36,20 @@ public override void Draw()
foreach (var fate in active)
{
ImGui.Text($"[{fate}] {fm->GetFateById(fate)->Name} ({fm->GetFateById(fate)->Duration}) {fm->GetFateById(fate)->Progress}%% <{fm->GetFateById(fate)->State}>");
ImGui.SameLine();
var loc = fm->GetFateById(fate)->Location;
var cmd = $"/vnavmesh moveto {loc.X} {loc.Y} {loc.Z}";
Svc.Log.Info($"executing command {cmd}");
}

if (ImGui.Button("Get Random Point"))
{
Svc.Log.Info(GetRandomPointInFate(Svc.Fates.First().FateId).ToString());
}
}

private unsafe Vector3 GetRandomPointInFate(ushort fateID)
{
var fate = FateManager.Instance()->GetFateById(fateID);
var angle = random.NextDouble() * 2 * Math.PI;
var randomPoint = new Vector3((float)(fate->Location.X + (fate->Radius / 2 * Math.Cos(angle))), fate->Location.Y, (float)(fate->Location.Z + (fate->Radius / 2 * Math.Sin(angle))));
var x = navmesh.NearestPoint(randomPoint, 5, 5);
return (Vector3)(x != null ? x : Vector3.Zero);
}
}
4 changes: 2 additions & 2 deletions Automaton/IPC/vnavmeshIPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ internal class NavmeshIPC
[EzIPC("Path.%m")] public readonly Action Stop;
[EzIPC("Path.%m")] public readonly Func<bool> IsRunning;

[EzIPC("Query.Mesh.%m")] public readonly Func<Vector3, float, float, Vector3> NearestPoint;
[EzIPC("Query.Mesh.%m")] public readonly Func<Vector3, float, bool, Vector3> PointOnFloor;
[EzIPC("Query.Mesh.%m")] public readonly Func<Vector3, float, float, Vector3?> NearestPoint;
[EzIPC("Query.Mesh.%m")] public readonly Func<Vector3, float, bool, Vector3?> PointOnFloor;
}

0 comments on commit 124436b

Please sign in to comment.