From 3dd5c07a1a770451a035b2ff28ac2895ff7de61e Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Sat, 19 Oct 2024 10:31:27 +0200 Subject: [PATCH] Add new skip conditions for NIN quests --- QuestPaths/quest-v1.json | 4 +- .../Converter/SkipConditionConverter.cs | 2 + .../Questing/EExtraSkipCondition.cs | 11 +++++- .../Controller/Steps/Shared/SkipCondition.cs | 37 ++++++++++--------- 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/QuestPaths/quest-v1.json b/QuestPaths/quest-v1.json index 3751b47d..4551e444 100644 --- a/QuestPaths/quest-v1.json +++ b/QuestPaths/quest-v1.json @@ -286,7 +286,9 @@ "type": "string", "enum": [ "WakingSandsMainArea", - "RisingStonesSolar" + "RisingStonesSolar", + "RoguesGuild", + "DockStorehouse" ] } }, diff --git a/Questionable.Model/Questing/Converter/SkipConditionConverter.cs b/Questionable.Model/Questing/Converter/SkipConditionConverter.cs index 4088446e..3de919b9 100644 --- a/Questionable.Model/Questing/Converter/SkipConditionConverter.cs +++ b/Questionable.Model/Questing/Converter/SkipConditionConverter.cs @@ -9,5 +9,7 @@ public sealed class SkipConditionConverter() : EnumConverter + /// Location for ROG quests in Limsa Lominsa; located far underneath the actual lower decks. + /// + RoguesGuild, + + /// + /// Location for NIN quests in Eastern La Noscea; located far underneath the actual zone. + /// + DockStorehouse, } diff --git a/Questionable/Controller/Steps/Shared/SkipCondition.cs b/Questionable/Controller/Steps/Shared/SkipCondition.cs index c95ee8ea..c1efdbde 100644 --- a/Questionable/Controller/Steps/Shared/SkipCondition.cs +++ b/Questionable/Controller/Steps/Shared/SkipCondition.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using System.Numerics; using Dalamud.Game.ClientState.Objects.Types; using Dalamud.Plugin.Services; @@ -225,24 +226,14 @@ internal static class SkipCondition } } - if (skipConditions.ExtraCondition == EExtraSkipCondition.WakingSandsMainArea && - clientState.TerritoryType == 212) + if (skipConditions.ExtraCondition != null && skipConditions.ExtraCondition != EExtraSkipCondition.None) { - var position = clientState.LocalPlayer!.Position; - if (position.X < 24) + var position = clientState.LocalPlayer?.Position; + if (position != null && + clientState.TerritoryType != 0 && + MatchesExtraCondition(skipConditions.ExtraCondition.Value, position.Value, clientState.TerritoryType)) { - logger.LogInformation("Skipping step, as we're not in the Solar"); - return true; - } - } - - if (skipConditions.ExtraCondition == EExtraSkipCondition.RisingStonesSolar && - clientState.TerritoryType == 351) - { - var position = clientState.LocalPlayer!.Position; - if (position.Z <= -28) - { - logger.LogInformation("Skipping step, as we're in the Rising Stones Solar"); + logger.LogInformation("Skipping step, extra condition {} matches", skipConditions.ExtraCondition); return true; } } @@ -262,6 +253,18 @@ internal static class SkipCondition return false; } + private static bool MatchesExtraCondition(EExtraSkipCondition condition, Vector3 position, ushort territoryType) + { + return condition switch + { + EExtraSkipCondition.WakingSandsMainArea => territoryType == 212 && position.X < 24, + EExtraSkipCondition.RisingStonesSolar => territoryType == 351 && position.Z <= -28, + EExtraSkipCondition.RoguesGuild => territoryType == 129 && position.Y <= -115, + EExtraSkipCondition.DockStorehouse => territoryType == 137 && position.Y <= -20, + _ => throw new ArgumentOutOfRangeException(nameof(condition), condition, null) + }; + } + public override ETaskResult Update() => ETaskResult.SkipRemainingTasksForStep; } }