Add diving condition to skip.StepIf

This commit is contained in:
Liza 2024-12-03 14:00:20 +01:00
parent 98aa8f2469
commit 58ec1259f5
Signed by: liza
GPG Key ID: 8DD6D21C03BB0848
4 changed files with 24 additions and 2 deletions

View File

@ -48,6 +48,9 @@ internal static class SkipConditionsExtensions
Assignment(nameof(SkipStepConditions.Flying), skipStepConditions.Flying, Assignment(nameof(SkipStepConditions.Flying), skipStepConditions.Flying,
emptyStep.Flying) emptyStep.Flying)
.AsSyntaxNodeOrToken(), .AsSyntaxNodeOrToken(),
Assignment(nameof(SkipStepConditions.Diving), skipStepConditions.Diving,
emptyStep.Diving)
.AsSyntaxNodeOrToken(),
Assignment(nameof(SkipStepConditions.Chocobo), skipStepConditions.Chocobo, Assignment(nameof(SkipStepConditions.Chocobo), skipStepConditions.Chocobo,
emptyStep.Chocobo) emptyStep.Chocobo)
.AsSyntaxNodeOrToken(), .AsSyntaxNodeOrToken(),

View File

@ -211,6 +211,9 @@
"Unlocked" "Unlocked"
] ]
}, },
"Diving": {
"type": ["boolean", "null"]
},
"NotTargetable": { "NotTargetable": {
"type": "boolean" "type": "boolean"
}, },

View File

@ -12,6 +12,7 @@ public sealed class SkipStepConditions
public IList<QuestWorkValue?> CompletionQuestVariablesFlags { get; set; } = new List<QuestWorkValue?>(); public IList<QuestWorkValue?> CompletionQuestVariablesFlags { get; set; } = new List<QuestWorkValue?>();
public ELockedSkipCondition? Flying { get; set; } public ELockedSkipCondition? Flying { get; set; }
public ELockedSkipCondition? Chocobo { get; set; } public ELockedSkipCondition? Chocobo { get; set; }
public bool? Diving { get; set; }
public bool NotTargetable { get; set; } public bool NotTargetable { get; set; }
public List<ushort> InTerritory { get; set; } = []; public List<ushort> InTerritory { get; set; } = [];
public List<ushort> NotInTerritory { get; set; } = []; public List<ushort> NotInTerritory { get; set; } = [];
@ -37,6 +38,7 @@ public sealed class SkipStepConditions
return (CompletionQuestVariablesFlags.Count > 0 && CompletionQuestVariablesFlags.Any(x => x != null)) || return (CompletionQuestVariablesFlags.Count > 0 && CompletionQuestVariablesFlags.Any(x => x != null)) ||
Flying != null || Flying != null ||
Chocobo != null || Chocobo != null ||
Diving != null ||
NotTargetable || NotTargetable ||
InTerritory.Count > 0 || InTerritory.Count > 0 ||
NotInTerritory.Count > 0 || NotInTerritory.Count > 0 ||
@ -53,6 +55,6 @@ public sealed class SkipStepConditions
public override string ToString() public override string ToString()
{ {
return 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}";
} }
} }

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects.Types; using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game;
@ -54,7 +55,8 @@ internal static class SkipCondition
AetheryteFunctions aetheryteFunctions, AetheryteFunctions aetheryteFunctions,
GameFunctions gameFunctions, GameFunctions gameFunctions,
QuestFunctions questFunctions, QuestFunctions questFunctions,
IClientState clientState) : TaskExecutor<SkipTask> IClientState clientState,
ICondition condition) : TaskExecutor<SkipTask>
{ {
protected override unsafe bool Start() protected override unsafe bool Start()
{ {
@ -85,6 +87,18 @@ internal static class SkipCondition
return true; 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 && if (skipConditions.InTerritory.Count > 0 &&
skipConditions.InTerritory.Contains(clientState.TerritoryType)) skipConditions.InTerritory.Contains(clientState.TerritoryType))
{ {