From 917ae4f4b873a9d7c688fc8a4e30894bdc9a88a7 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Wed, 10 Jul 2024 18:53:34 +0200 Subject: [PATCH] Skip aetheryte teleport if you're standing within interaction distance of your target --- Questionable.Model/V1/QuestStep.cs | 10 ++++++++++ Questionable/Controller/MovementController.cs | 4 +--- .../Controller/Steps/BaseFactory/AetheryteShortcut.cs | 6 ++++++ Questionable/Controller/Steps/BaseFactory/Move.cs | 7 +------ 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Questionable.Model/V1/QuestStep.cs b/Questionable.Model/V1/QuestStep.cs index a23c20ca5..7b5bc5f25 100644 --- a/Questionable.Model/V1/QuestStep.cs +++ b/Questionable.Model/V1/QuestStep.cs @@ -9,6 +9,8 @@ namespace Questionable.Model.V1; public sealed class QuestStep { + public const float DefaultStopDistance = 3f; + public EInteractionType InteractionType { get; set; } public uint? DataId { get; set; } @@ -64,4 +66,12 @@ public sealed class QuestStep Position = position; TerritoryId = territoryId; } + + public float CalculateActualStopDistance() + { + if (InteractionType == EInteractionType.WalkTo) + return StopDistance ?? 0.25f; + else + return StopDistance ?? DefaultStopDistance; + } } diff --git a/Questionable/Controller/MovementController.cs b/Questionable/Controller/MovementController.cs index 0360bf0dd..badf5f0b7 100644 --- a/Questionable/Controller/MovementController.cs +++ b/Questionable/Controller/MovementController.cs @@ -23,8 +23,6 @@ namespace Questionable.Controller; internal sealed class MovementController : IDisposable { - public const float DefaultStopDistance = 3f; - private static readonly List BlacklistedAreas = [ new(1191, new(-223.0412f, 31.937134f, -584.03906f), 5f, 7.75f), @@ -266,7 +264,7 @@ internal sealed class MovementController : IDisposable _chatFunctions.ExecuteCommand("/automove off"); } - Destination = new DestinationData(dataId, to, stopDistance ?? (DefaultStopDistance - 0.2f), fly, sprint, + Destination = new DestinationData(dataId, to, stopDistance ?? (QuestStep.DefaultStopDistance - 0.2f), fly, sprint, useNavmesh); MovementStartedAt = DateTime.MaxValue; } diff --git a/Questionable/Controller/Steps/BaseFactory/AetheryteShortcut.cs b/Questionable/Controller/Steps/BaseFactory/AetheryteShortcut.cs index 7a9655ef1..3542c888f 100644 --- a/Questionable/Controller/Steps/BaseFactory/AetheryteShortcut.cs +++ b/Questionable/Controller/Steps/BaseFactory/AetheryteShortcut.cs @@ -75,6 +75,12 @@ internal static class AetheryteShortcut } Vector3 pos = clientState.LocalPlayer!.Position; + if (Step.Position != null && (pos - Step.Position.Value).Length() < Step.CalculateActualStopDistance()) + { + logger.LogInformation("Skipping aetheryte teleport, we're near the target"); + return false; + } + if (aetheryteData.CalculateDistance(pos, territoryType, TargetAetheryte) < 20 || (Step.AethernetShortcut != null && (aetheryteData.CalculateDistance(pos, territoryType, Step.AethernetShortcut.From) < 20 || diff --git a/Questionable/Controller/Steps/BaseFactory/Move.cs b/Questionable/Controller/Steps/BaseFactory/Move.cs index 32ee4c616..6633c484a 100644 --- a/Questionable/Controller/Steps/BaseFactory/Move.cs +++ b/Questionable/Controller/Steps/BaseFactory/Move.cs @@ -69,12 +69,7 @@ internal static class Move yield return new WaitConditionTask(() => movementController.IsNavmeshReady, "Wait(navmesh ready)"); - float distance; - if (Step.InteractionType == EInteractionType.WalkTo) - distance = Step.StopDistance ?? 0.25f; - else - distance = Step.StopDistance ?? MovementController.DefaultStopDistance; - + float distance = Step.CalculateActualStopDistance(); var position = clientState.LocalPlayer?.Position ?? new Vector3(); float actualDistance = (position - Destination).Length();