Skip aetheryte teleport if you're standing within interaction distance of your target
authorLiza Carvelli <liza@carvel.li>
Wed, 10 Jul 2024 16:53:34 +0000 (18:53 +0200)
committerLiza Carvelli <liza@carvel.li>
Wed, 10 Jul 2024 16:53:34 +0000 (18:53 +0200)
Questionable.Model/V1/QuestStep.cs
Questionable/Controller/MovementController.cs
Questionable/Controller/Steps/BaseFactory/AetheryteShortcut.cs
Questionable/Controller/Steps/BaseFactory/Move.cs

index a23c20ca58c86026fd1550840e95fa0a77b369de..7b5bc5f2536db94e08b68a66527f211ec876d802 100644 (file)
@@ -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;
+    }
 }
index 0360bf0dd37fbc8c9aa3bbaf813eb90d4d30d83d..badf5f0b7587a56fab2b246da321a104ca0d6cda 100644 (file)
@@ -23,8 +23,6 @@ namespace Questionable.Controller;
 
 internal sealed class MovementController : IDisposable
 {
-    public const float DefaultStopDistance = 3f;
-
     private static readonly List<BlacklistedArea> 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;
     }
index 7a9655ef19fca9d9577882cad324cba6984d6179..3542c888fd87744d4a279762140883cf0dada583 100644 (file)
@@ -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 ||
index 32ee4c616d66cc277351e35889251f6a3aa46eff..6633c484a79f6a0eb316cd55cdd4e2977750cae7 100644 (file)
@@ -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();