From 28d50dfc8148d3063596346d98333cfce7eff4ea Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Mon, 12 Aug 2024 16:23:03 +0200 Subject: [PATCH] Move to aethernet shards using a mount if mounts are allowed in the zone --- .../Steps/Shared/AethernetShortcut.cs | 50 ++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/Questionable/Controller/Steps/Shared/AethernetShortcut.cs b/Questionable/Controller/Steps/Shared/AethernetShortcut.cs index 2a639390e..6e7ad1649 100644 --- a/Questionable/Controller/Steps/Shared/AethernetShortcut.cs +++ b/Questionable/Controller/Steps/Shared/AethernetShortcut.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Numerics; +using Dalamud.Game.ClientState.Conditions; using Dalamud.Plugin.Services; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -33,13 +34,18 @@ internal static class AethernetShortcut internal sealed class UseAethernetShortcut( ILogger logger, AetheryteFunctions aetheryteFunctions, + GameFunctions gameFunctions, IClientState clientState, AetheryteData aetheryteData, + TerritoryData territoryData, LifestreamIpc lifestreamIpc, - MovementController movementController) : ISkippableTask + MovementController movementController, + ICondition condition) : ISkippableTask { private bool _moving; private bool _teleported; + private bool _triedMounting; + private DateTime _continueAt = DateTime.MinValue; public EAetheryteLocation From { get; set; } public EAetheryteLocation To { get; set; } @@ -123,11 +129,19 @@ internal static class AethernetShortcut } else { - logger.LogInformation("Moving to aethernet shortcut"); - _moving = true; - movementController.NavigateTo(EMovementType.Quest, (uint)From, aetheryteData.Locations[From], - false, true, - AetheryteConverter.IsLargeAetheryte(From) ? 10.9f : 6.9f); + if (territoryData.CanUseMount(territoryType) && + aetheryteData.CalculateDistance(playerPosition, territoryType, From) > 30 && + !gameFunctions.HasStatusPreventingMount()) + { + _triedMounting = gameFunctions.Mount(); + if (_triedMounting) + { + _continueAt = DateTime.Now.AddSeconds(0.5); + return true; + } + } + + MoveTo(From); return true; } } @@ -140,8 +154,32 @@ internal static class AethernetShortcut return false; } + private void MoveTo(EAetheryteLocation from) + { + logger.LogInformation("Moving to aethernet shortcut"); + _moving = true; + movementController.NavigateTo(EMovementType.Quest, (uint)From, aetheryteData.Locations[From], + false, true, + AetheryteConverter.IsLargeAetheryte(From) ? 10.9f : 6.9f); + } + public ETaskResult Update() { + if (DateTime.Now < _continueAt) + return ETaskResult.StillRunning; + + if (_triedMounting) + { + if (condition[ConditionFlag.Mounted]) + { + _triedMounting = false; + MoveTo(From); + return ETaskResult.StillRunning; + } + else + return ETaskResult.StillRunning; + } + if (_moving) { var movementStartedAt = movementController.MovementStartedAt;