Improve mount task
authorLiza Carvelli <liza@carvel.li>
Wed, 12 Jun 2024 20:49:10 +0000 (22:49 +0200)
committerLiza Carvelli <liza@carvel.li>
Wed, 12 Jun 2024 20:49:10 +0000 (22:49 +0200)
QuestPaths/Endwalker/MSQ/E-Elpis/4424_Lives Apart.json
Questionable/Controller/Steps/BaseTasks/MountTask.cs

index 7fe9bd4263bbf4103e068c9fad8115f95714968f..dc20f4315ea3e4f9d8e2c4f952f75c9adf8e8d60 100644 (file)
           "InteractionType": "UseItem",
           "ItemId": 2003234,
           "GroundTarget": true,
+          "CompletionQuestVariablesFlags": [
+            null,
+            null,
+            null,
+            null,
+            null,
+            128
+          ],
           "$": "QuestValues after: 1 16 0 0 0 128"
         },
         {
           "TerritoryId": 961,
           "InteractionType": "UseItem",
           "ItemId": 2003234,
-          "GroundTarget": true
+          "GroundTarget": true,
+          "CompletionQuestVariablesFlags": [
+            null,
+            null,
+            null,
+            null,
+            null,
+            64
+          ]
         }
       ]
     },
index 65fb649d9952c2004b704b4604e5cb2e7ec37d46..e9aa7b654f5dabb40609f925b67b5df682658ebf 100644 (file)
@@ -1,4 +1,5 @@
-using Dalamud.Game.ClientState.Conditions;
+using System;
+using Dalamud.Game.ClientState.Conditions;
 using Dalamud.Plugin.Services;
 using Microsoft.Extensions.Logging;
 using Questionable.Data;
@@ -13,6 +14,7 @@ internal sealed class MountTask(
 {
     private ushort _territoryId;
     private bool _mountTriggered;
+    private DateTime _retryAt = DateTime.MinValue;
 
     public ITask With(ushort territoryId)
     {
@@ -40,7 +42,7 @@ internal sealed class MountTask(
         logger.LogInformation("Step wants a mount, trying to mount in territory {Id}...", _territoryId);
         if (!condition[ConditionFlag.InCombat])
         {
-            _mountTriggered = gameFunctions.Mount();
+            _retryAt = DateTime.Now.AddSeconds(0.5);
             return true;
         }
 
@@ -49,6 +51,13 @@ internal sealed class MountTask(
 
     public ETaskResult Update()
     {
+        if (_mountTriggered && !condition[ConditionFlag.Mounted] && DateTime.Now > _retryAt)
+        {
+            logger.LogInformation("Not mounted, retrying...");
+            _mountTriggered = false;
+            _retryAt = DateTime.MaxValue;
+        }
+
         if (!_mountTriggered)
         {
             if (gameFunctions.HasStatusPreventingSprintOrMount())
@@ -58,6 +67,7 @@ internal sealed class MountTask(
             }
 
             _mountTriggered = gameFunctions.Mount();
+            _retryAt = DateTime.Now.AddSeconds(5);
             return ETaskResult.StillRunning;
         }