Make AcceptQuest/CompleteQuest skippable if their relevant quest has been accepted...
authorLiza Carvelli <liza@carvel.li>
Sun, 21 Jul 2024 08:40:39 +0000 (10:40 +0200)
committerLiza Carvelli <liza@carvel.li>
Sun, 21 Jul 2024 08:41:27 +0000 (10:41 +0200)
QuestPaths/quest-v1.json
Questionable.Model/V1/Converter/SkipConditionConverter.cs
Questionable.Model/V1/ESkipCondition.cs
Questionable/Controller/Steps/Shared/SkipCondition.cs
Questionable/Controller/Steps/Shared/WaitAtEnd.cs

index 6f00e483aaa8c8c78188b46afc72c9e3b00e2408..d49f4864124c42bdceaffd4227fd87f604aa05b6 100644 (file)
                       "ChocoboUnlocked",
                       "AetheryteShortcutIfInSameTerritory",
                       "NotTargetable",
-                      "ItemNotInInventory"
+                      "ItemNotInInventory",
+                      "WakingSandsMainArea"
                     ]
                   }
                 },
index 4a31f616ccbff9c3b02f22277cd9221f2e34359d..7e7b780c844f66c8cd3d99836672f48dcd95cdf1 100644 (file)
@@ -13,5 +13,6 @@ public sealed class SkipConditionConverter() : EnumConverter<ESkipCondition>(Val
         { ESkipCondition.AetheryteShortcutIfInSameTerritory, "AetheryteShortcutIfInSameTerritory" },
         { ESkipCondition.NotTargetable, "NotTargetable" },
         { ESkipCondition.ItemNotInInventory, "ItemNotInInventory" },
+        { ESkipCondition.WakingSandsMainArea, "WakingSandsMainArea" },
     };
 }
index f5f0e6762c01e3d787668a0c2380f9c339751a2b..8c766996c6fba0580de57e0950b70e341488571c 100644 (file)
@@ -14,4 +14,7 @@ public enum ESkipCondition
     AetheryteShortcutIfInSameTerritory,
     NotTargetable,
     ItemNotInInventory,
+
+    // TODO: This is an indication the whole skip bit should be optimized/parameterized to some extent
+    WakingSandsMainArea,
 }
index b509c9c6736095e24c996d556fa8e8b89139f20d..256cf702e0f37c9a9b9220ebbd9c1c571d1c69a0 100644 (file)
@@ -28,7 +28,9 @@ internal static class SkipCondition
                 step.SkipIf.Where(x => x != ESkipCondition.AetheryteShortcutIfInSameTerritory).ToList();
             if (relevantConditions.Count == 0 &&
                 step.CompletionQuestVariablesFlags.Count == 0 &&
-                step.RequiredQuestVariables.Count == 0)
+                step.RequiredQuestVariables.Count == 0 &&
+                step.PickUpQuestId == null &&
+                step.NextQuestId == null)
                 return null;
 
             return serviceProvider.GetRequiredService<CheckTask>()
@@ -143,6 +145,28 @@ internal static class SkipCondition
                 }
             }
 
+            if (Step.SkipIf.Contains(ESkipCondition.WakingSandsMainArea))
+            {
+                var position = clientState.LocalPlayer!.Position;
+                if (position.X < 24)
+                {
+                    logger.LogInformation("Skipping step, as we're not in the Solar");
+                    return true;
+                }
+            }
+
+            if (Step.PickUpQuestId != null && gameFunctions.IsQuestAcceptedOrComplete(Step.PickUpQuestId.Value))
+            {
+                logger.LogInformation("Skipping step, as we have already picked up the relevant quest");
+                return true;
+            }
+
+            if (Step.TurnInQuestId != null && gameFunctions.IsQuestComplete(Step.TurnInQuestId.Value))
+            {
+                logger.LogInformation("Skipping step, as we have already completed the relevant quest");
+                return true;
+            }
+
             return false;
         }
 
index 947e425f6b3d0c3b8437a789816af3579f3b2104..6af28d97582a70fa18f5df4c49a4772ef5c62b3d 100644 (file)
@@ -108,20 +108,26 @@ internal static class WaitAtEnd
                     ];
 
                 case EInteractionType.AcceptQuest:
-                    return
-                    [
-                        serviceProvider.GetRequiredService<WaitQuestAccepted>()
-                            .With(step.PickUpQuestId ?? quest.QuestId),
-                        serviceProvider.GetRequiredService<WaitDelay>()
-                    ];
+                {
+                    var accept = serviceProvider.GetRequiredService<WaitQuestAccepted>()
+                        .With(step.PickUpQuestId ?? quest.QuestId);
+                    var delay = serviceProvider.GetRequiredService<WaitDelay>();
+                    if (step.PickUpQuestId != null)
+                        return [accept, delay, Next(quest, sequence)];
+                    else
+                        return [accept, delay];
+                }
 
                 case EInteractionType.CompleteQuest:
-                    return
-                    [
-                        serviceProvider.GetRequiredService<WaitQuestCompleted>()
-                            .With(step.TurnInQuestId ?? quest.QuestId),
-                        serviceProvider.GetRequiredService<WaitDelay>()
-                    ];
+                {
+                    var complete = serviceProvider.GetRequiredService<WaitQuestCompleted>()
+                        .With(step.TurnInQuestId ?? quest.QuestId);
+                    var delay = serviceProvider.GetRequiredService<WaitDelay>();
+                    if (step.NextQuestId != null)
+                        return [complete, delay, Next(quest, sequence)];
+                    else
+                        return [complete, delay];
+                }
 
                 case EInteractionType.Interact:
                 default: