From 58ec1259f5c78b21b8e65db11583acba9ccbb33b Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Tue, 3 Dec 2024 14:00:20 +0100 Subject: [PATCH] Add diving condition to skip.StepIf --- .../RoslynElements/SkipConditionsExtensions.cs | 3 +++ QuestPaths/quest-v1.json | 3 +++ .../Questing/SkipStepConditions.cs | 4 +++- .../Controller/Steps/Shared/SkipCondition.cs | 16 +++++++++++++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/QuestPathGenerator/RoslynElements/SkipConditionsExtensions.cs b/QuestPathGenerator/RoslynElements/SkipConditionsExtensions.cs index e904e0f7..01106bda 100644 --- a/QuestPathGenerator/RoslynElements/SkipConditionsExtensions.cs +++ b/QuestPathGenerator/RoslynElements/SkipConditionsExtensions.cs @@ -48,6 +48,9 @@ internal static class SkipConditionsExtensions Assignment(nameof(SkipStepConditions.Flying), skipStepConditions.Flying, emptyStep.Flying) .AsSyntaxNodeOrToken(), + Assignment(nameof(SkipStepConditions.Diving), skipStepConditions.Diving, + emptyStep.Diving) + .AsSyntaxNodeOrToken(), Assignment(nameof(SkipStepConditions.Chocobo), skipStepConditions.Chocobo, emptyStep.Chocobo) .AsSyntaxNodeOrToken(), diff --git a/QuestPaths/quest-v1.json b/QuestPaths/quest-v1.json index a4975e39..af581147 100644 --- a/QuestPaths/quest-v1.json +++ b/QuestPaths/quest-v1.json @@ -211,6 +211,9 @@ "Unlocked" ] }, + "Diving": { + "type": ["boolean", "null"] + }, "NotTargetable": { "type": "boolean" }, diff --git a/Questionable.Model/Questing/SkipStepConditions.cs b/Questionable.Model/Questing/SkipStepConditions.cs index 25c1a46b..08d5c268 100644 --- a/Questionable.Model/Questing/SkipStepConditions.cs +++ b/Questionable.Model/Questing/SkipStepConditions.cs @@ -12,6 +12,7 @@ public sealed class SkipStepConditions public IList CompletionQuestVariablesFlags { get; set; } = new List(); public ELockedSkipCondition? Flying { get; set; } public ELockedSkipCondition? Chocobo { get; set; } + public bool? Diving { get; set; } public bool NotTargetable { get; set; } public List InTerritory { get; set; } = []; public List NotInTerritory { get; set; } = []; @@ -37,6 +38,7 @@ public sealed class SkipStepConditions return (CompletionQuestVariablesFlags.Count > 0 && CompletionQuestVariablesFlags.Any(x => x != null)) || Flying != null || Chocobo != null || + Diving != null || NotTargetable || InTerritory.Count > 0 || NotInTerritory.Count > 0 || @@ -53,6 +55,6 @@ public sealed class SkipStepConditions public override string ToString() { return - $"{nameof(Never)}: {Never}, {nameof(CompletionQuestVariablesFlags)}: {CompletionQuestVariablesFlags}, {nameof(Flying)}: {Flying}, {nameof(Chocobo)}: {Chocobo}, {nameof(NotTargetable)}: {NotTargetable}, {nameof(InTerritory)}: {string.Join(" ", InTerritory)}, {nameof(NotInTerritory)}: {string.Join(" ", NotInTerritory)}, {nameof(Item)}: {Item}, {nameof(QuestsAccepted)}: {string.Join(" ", QuestsAccepted)}, {nameof(QuestsCompleted)}: {string.Join(" ", QuestsCompleted)}, {nameof(NotNamePlateIconId)}: {string.Join(" ", NotNamePlateIconId)}, {nameof(NearPosition)}: {NearPosition}, {nameof(ExtraCondition)}: {ExtraCondition}"; + $"{nameof(Never)}: {Never}, {nameof(CompletionQuestVariablesFlags)}: {CompletionQuestVariablesFlags}, {nameof(Flying)}: {Flying}, {nameof(Chocobo)}: {Chocobo}, {nameof(Diving)}: {Diving}, {nameof(NotTargetable)}: {NotTargetable}, {nameof(InTerritory)}: {string.Join(" ", InTerritory)}, {nameof(NotInTerritory)}: {string.Join(" ", NotInTerritory)}, {nameof(Item)}: {Item}, {nameof(QuestsAccepted)}: {string.Join(" ", QuestsAccepted)}, {nameof(QuestsCompleted)}: {string.Join(" ", QuestsCompleted)}, {nameof(NotNamePlateIconId)}: {string.Join(" ", NotNamePlateIconId)}, {nameof(NearPosition)}: {NearPosition}, {nameof(ExtraCondition)}: {ExtraCondition}"; } } diff --git a/Questionable/Controller/Steps/Shared/SkipCondition.cs b/Questionable/Controller/Steps/Shared/SkipCondition.cs index 68297c4e..5abab059 100644 --- a/Questionable/Controller/Steps/Shared/SkipCondition.cs +++ b/Questionable/Controller/Steps/Shared/SkipCondition.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Numerics; +using Dalamud.Game.ClientState.Conditions; using Dalamud.Game.ClientState.Objects.Types; using Dalamud.Plugin.Services; using FFXIVClientStructs.FFXIV.Client.Game; @@ -54,7 +55,8 @@ internal static class SkipCondition AetheryteFunctions aetheryteFunctions, GameFunctions gameFunctions, QuestFunctions questFunctions, - IClientState clientState) : TaskExecutor + IClientState clientState, + ICondition condition) : TaskExecutor { protected override unsafe bool Start() { @@ -85,6 +87,18 @@ internal static class SkipCondition return true; } + if (skipConditions.Diving == true && condition[ConditionFlag.Diving]) + { + logger.LogInformation("Skipping step, as you're currently diving underwater"); + return true; + } + + if (skipConditions.Diving == false && !condition[ConditionFlag.Diving]) + { + logger.LogInformation("Skipping step, as you're not currently diving underwater"); + return true; + } + if (skipConditions.InTerritory.Count > 0 && skipConditions.InTerritory.Contains(clientState.TerritoryType)) {