From f0af3045a71b2bbfb605395310b05aa793f37e7d Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Fri, 19 Jul 2024 09:14:18 +0200 Subject: [PATCH] Update validation for instant quests --- .../3603_The Boutique Always Wins.json | 3 +- .../Shaaloani/5126_A Refined Perspective.json | 2 +- .../Instant/5003_Leves of Tuliyollal.json | 21 ++++++++++ .../Instant/5006_Sights of the West.json | 21 ++++++++++ .../5007_Sights of the West and Beyond.json | 3 +- .../Instant/5008_Dawn of a New Deal.json | 3 +- Questionable/Controller/QuestController.cs | 7 ---- Questionable/Model/QuestInfo.cs | 4 +- .../Validators/BasicSequenceValidator.cs | 40 +++++++++++++------ Questionable/Windows/QuestSelectionWindow.cs | 8 +++- Questionable/Windows/QuestWindow.cs | 23 ++++++----- 11 files changed, 98 insertions(+), 37 deletions(-) create mode 100644 QuestPaths/7.x - Dawntrail/Unlocks/Instant/5003_Leves of Tuliyollal.json create mode 100644 QuestPaths/7.x - Dawntrail/Unlocks/Instant/5006_Sights of the West.json diff --git a/QuestPaths/5.x - Shadowbringers/Unlocks/Instant/3603_The Boutique Always Wins.json b/QuestPaths/5.x - Shadowbringers/Unlocks/Instant/3603_The Boutique Always Wins.json index 43e1af19..4c51e613 100644 --- a/QuestPaths/5.x - Shadowbringers/Unlocks/Instant/3603_The Boutique Always Wins.json +++ b/QuestPaths/5.x - Shadowbringers/Unlocks/Instant/3603_The Boutique Always Wins.json @@ -13,8 +13,7 @@ "Z": -25.223206 }, "TerritoryId": 820, - "InteractionType": "AcceptQuest", - "Comment": "Quest is completed instantly" + "InteractionType": "AcceptQuest" } ] } diff --git a/QuestPaths/7.x - Dawntrail/Side Quests/Shaaloani/5126_A Refined Perspective.json b/QuestPaths/7.x - Dawntrail/Side Quests/Shaaloani/5126_A Refined Perspective.json index 5b67efc9..03a6cbcd 100644 --- a/QuestPaths/7.x - Dawntrail/Side Quests/Shaaloani/5126_A Refined Perspective.json +++ b/QuestPaths/7.x - Dawntrail/Side Quests/Shaaloani/5126_A Refined Perspective.json @@ -29,7 +29,7 @@ }, "TerritoryId": 1190, "InteractionType": "Instruction", - "Comment": "(from left to right) pump, middle of the connecting pipes, barrels" + "Comment": "Click (from left to right) pump, middle of the connecting pipes, barrels" } ] }, diff --git a/QuestPaths/7.x - Dawntrail/Unlocks/Instant/5003_Leves of Tuliyollal.json b/QuestPaths/7.x - Dawntrail/Unlocks/Instant/5003_Leves of Tuliyollal.json new file mode 100644 index 00000000..0f5b27e7 --- /dev/null +++ b/QuestPaths/7.x - Dawntrail/Unlocks/Instant/5003_Leves of Tuliyollal.json @@ -0,0 +1,21 @@ +{ + "$schema": "https://carvel.li/questionable/quest-1.0", + "Author": "liza", + "QuestSequence": [ + { + "Sequence": 0, + "Steps": [ + { + "DataId": 1048390, + "Position": { + "X": 15.243713, + "Y": -14.000001, + "Z": 85.83191 + }, + "TerritoryId": 1185, + "InteractionType": "AcceptQuest" + } + ] + } + ] +} diff --git a/QuestPaths/7.x - Dawntrail/Unlocks/Instant/5006_Sights of the West.json b/QuestPaths/7.x - Dawntrail/Unlocks/Instant/5006_Sights of the West.json new file mode 100644 index 00000000..6d5abccc --- /dev/null +++ b/QuestPaths/7.x - Dawntrail/Unlocks/Instant/5006_Sights of the West.json @@ -0,0 +1,21 @@ +{ + "$schema": "https://carvel.li/questionable/quest-1.0", + "Author": "liza", + "QuestSequence": [ + { + "Sequence": 0, + "Steps": [ + { + "DataId": 1048510, + "Position": { + "X": 28.67163, + "Y": 50.13025, + "Z": -40.940002 + }, + "TerritoryId": 1185, + "InteractionType": "AcceptQuest" + } + ] + } + ] +} diff --git a/QuestPaths/7.x - Dawntrail/Unlocks/Instant/5007_Sights of the West and Beyond.json b/QuestPaths/7.x - Dawntrail/Unlocks/Instant/5007_Sights of the West and Beyond.json index fd2ab340..17c970cb 100644 --- a/QuestPaths/7.x - Dawntrail/Unlocks/Instant/5007_Sights of the West and Beyond.json +++ b/QuestPaths/7.x - Dawntrail/Unlocks/Instant/5007_Sights of the West and Beyond.json @@ -13,8 +13,7 @@ "Z": -52.99463 }, "TerritoryId": 1186, - "InteractionType": "AcceptQuest", - "Comment": "Quest is completed instantly" + "InteractionType": "AcceptQuest" } ] } diff --git a/QuestPaths/7.x - Dawntrail/Unlocks/Instant/5008_Dawn of a New Deal.json b/QuestPaths/7.x - Dawntrail/Unlocks/Instant/5008_Dawn of a New Deal.json index 4cc2f982..40a70b2e 100644 --- a/QuestPaths/7.x - Dawntrail/Unlocks/Instant/5008_Dawn of a New Deal.json +++ b/QuestPaths/7.x - Dawntrail/Unlocks/Instant/5008_Dawn of a New Deal.json @@ -13,8 +13,7 @@ "Z": -38.132385 }, "TerritoryId": 1186, - "InteractionType": "AcceptQuest", - "Comment": "Quest is completed instantly" + "InteractionType": "AcceptQuest" } ] } diff --git a/Questionable/Controller/QuestController.cs b/Questionable/Controller/QuestController.cs index 2f5de9f1..141bc91d 100644 --- a/Questionable/Controller/QuestController.cs +++ b/Questionable/Controller/QuestController.cs @@ -83,7 +83,6 @@ internal sealed class QuestController public QuestProgress? NextQuest => _nextQuest; public string? DebugState { get; private set; } - public string? Comment { get; private set; } public void Reload() { @@ -212,7 +211,6 @@ internal sealed class QuestController if (questToRun == null) { DebugState = "No quest active"; - Comment = null; Stop("No quest active"); return; } @@ -240,7 +238,6 @@ internal sealed class QuestController if (sequence == null) { DebugState = "Sequence not found"; - Comment = null; Stop("Unknown sequence"); return; } @@ -248,7 +245,6 @@ internal sealed class QuestController if (questToRun.Step == 255) { DebugState = "Step completed"; - Comment = null; if (_currentTask != null || _taskQueue.Count > 0) Stop("Step complete", continueIfAutomatic: true); return; @@ -257,14 +253,11 @@ internal sealed class QuestController if (questToRun.Step >= sequence.Steps.Count) { DebugState = "Step not found"; - Comment = null; Stop("Unknown step"); return; } - var step = sequence.Steps[questToRun.Step]; DebugState = null; - Comment = step.Comment ?? sequence.Comment ?? q.Root.Comment; } } diff --git a/Questionable/Model/QuestInfo.cs b/Questionable/Model/QuestInfo.cs index 5b7523e8..4ae13547 100644 --- a/Questionable/Model/QuestInfo.cs +++ b/Questionable/Model/QuestInfo.cs @@ -22,6 +22,7 @@ internal sealed class QuestInfo QuestLocks = quest.QuestLock.Select(x => (ushort)(x.Row & 0xFFFFF)).Where(x => x != 0).ToImmutableList(); QuestLockJoin = (QuestJoin)quest.QuestLockJoin; IsMainScenarioQuest = quest.JournalGenre?.Value?.JournalCategory?.Value?.JournalSection?.Row is 0 or 1; + CompletesInstantly = quest.ToDoCompleteSeq[0] == 0; } public ushort QuestId { get; } @@ -31,9 +32,10 @@ internal sealed class QuestInfo public bool IsRepeatable { get; } public ImmutableList PreviousQuests { get; } public QuestJoin PreviousQuestJoin { get; } - public bool IsMainScenarioQuest { get; } public ImmutableList QuestLocks { get; set; } public QuestJoin QuestLockJoin { get; set; } + public bool IsMainScenarioQuest { get; } + public bool CompletesInstantly { get; set; } public string SimplifiedName => Name .TrimStart(SeIconChar.QuestSync.ToIconChar(), SeIconChar.QuestRepeatable.ToIconChar(), ' '); diff --git a/Questionable/Validation/Validators/BasicSequenceValidator.cs b/Questionable/Validation/Validators/BasicSequenceValidator.cs index 8ea19a14..c8d40a36 100644 --- a/Questionable/Validation/Validators/BasicSequenceValidator.cs +++ b/Questionable/Validation/Validators/BasicSequenceValidator.cs @@ -27,21 +27,37 @@ internal sealed class BasicSequenceValidator : IQuestValidator yield break; } - int maxSequence = sequences.Select(x => x.Sequence) - .Where(x => x != 255) - .Max(); - - for (int i = 0; i < maxSequence; i++) + if (quest.Info.CompletesInstantly) { - var foundSequences = sequences.Where(x => x.Sequence == i).ToList(); - var issue = ValidateSequences(quest, i, foundSequences); - if (issue != null) - yield return issue; + foreach (var sequence in sequences) + { + if (sequence == foundStart) + continue; + + yield return new ValidationIssue + { + QuestId = quest.QuestId, + Sequence = (byte)sequence.Sequence, + Step = null, + Severity = EIssueSeverity.Error, + Description = "Instant quest should not have any sequences after the start", + }; + } } - - // some quests finish instantly - if (maxSequence > 0 || foundStart.Steps.Count > 1) + else { + int maxSequence = sequences.Select(x => x.Sequence) + .Where(x => x != 255) + .Max(); + + for (int i = 0; i < maxSequence; i++) + { + var foundSequences = sequences.Where(x => x.Sequence == i).ToList(); + var issue = ValidateSequences(quest, i, foundSequences); + if (issue != null) + yield return issue; + } + var foundEnding = sequences.Where(x => x.Sequence == 255).ToList(); var endingIssue = ValidateSequences(quest, 255, foundEnding); if (endingIssue != null) diff --git a/Questionable/Windows/QuestSelectionWindow.cs b/Questionable/Windows/QuestSelectionWindow.cs index 4ff4c3c0..9ed5c439 100644 --- a/Questionable/Windows/QuestSelectionWindow.cs +++ b/Questionable/Windows/QuestSelectionWindow.cs @@ -172,7 +172,13 @@ internal sealed class QuestSelectionWindow : LWindow ImGui.TextUnformatted("Repeatable"); } - if (!_questRegistry.IsKnownQuest(quest.QuestId)) + if (quest.CompletesInstantly) + { + ImGui.SameLine(); + ImGui.TextUnformatted("Instant"); + } + + if (!isKnownQuest) { ImGui.SameLine(); ImGui.TextUnformatted("NoQuestPath"); diff --git a/Questionable/Windows/QuestWindow.cs b/Questionable/Windows/QuestWindow.cs index 0ebe5517..a5e3044a 100644 --- a/Questionable/Windows/QuestWindow.cs +++ b/Questionable/Windows/QuestWindow.cs @@ -220,11 +220,19 @@ internal sealed class QuestWindow : LWindow, IPersistableWindowConfig else { ImGui.BeginDisabled(); - ImGui.TextUnformatted(_questController.DebugState ?? "--"); + ImGui.TextUnformatted(_questController.DebugState ?? string.Empty); ImGui.EndDisabled(); } - ImGui.TextUnformatted(_questController.Comment ?? "--"); + QuestSequence? currentSequence = currentQuest.Quest.FindSequence(currentQuest.Sequence); + QuestStep? currentStep = currentSequence?.FindStep(currentQuest.Step); + bool colored = currentStep is + { InteractionType: EInteractionType.Instruction or EInteractionType.WaitForManualProgress }; + if (colored) + ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudOrange); + ImGui.TextUnformatted(currentStep?.Comment ?? currentSequence?.Comment ?? currentQuest.Quest.Root.Comment ?? string.Empty); + if (colored) + ImGui.PopStyleColor(); //var nextStep = _questController.GetNextStep(); //ImGui.BeginDisabled(nextStep.Step == null); @@ -257,15 +265,12 @@ internal sealed class QuestWindow : LWindow, IPersistableWindowConfig _questController.Stop("Manual"); } - QuestStep? currentStep = currentQuest.Quest - .FindSequence(currentQuest.Sequence) - ?.FindStep(currentQuest.Step); bool lastStep = currentStep == currentQuest.Quest.FindSequence(currentQuest.Sequence)?.Steps.LastOrDefault(); - bool colored = currentStep != null - && !lastStep - && currentStep.InteractionType == EInteractionType.Instruction - && _questController.HasCurrentTaskMatching(); + colored = currentStep != null + && !lastStep + && currentStep.InteractionType == EInteractionType.Instruction + && _questController.HasCurrentTaskMatching(); ImGui.BeginDisabled(lastStep); if (colored)