Consider quest step complete if QuestWork matches + maybe fix some interact interruptions

This commit is contained in:
Liza 2024-10-01 21:47:30 +02:00
parent fad4f0e720
commit 35eeb83b49
Signed by: liza
GPG Key ID: 7199F8D727D55F67

View File

@ -7,6 +7,7 @@ using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Questionable.Controller.Steps.Shared; using Questionable.Controller.Steps.Shared;
using Questionable.Controller.Utils;
using Questionable.Functions; using Questionable.Functions;
using Questionable.Model; using Questionable.Model;
using Questionable.Model.Questing; using Questionable.Model.Questing;
@ -57,7 +58,7 @@ internal static class Interact
yield return new Task(step.DataId.Value, quest, step.InteractionType, yield return new Task(step.DataId.Value, quest, step.InteractionType,
step.TargetTerritoryId != null || quest.Id is SatisfactionSupplyNpcId || step.TargetTerritoryId != null || quest.Id is SatisfactionSupplyNpcId ||
step.SkipConditions is { StepIf.Never: true } || step.InteractionType == EInteractionType.PurchaseItem, step.SkipConditions is { StepIf.Never: true } || step.InteractionType == EInteractionType.PurchaseItem,
step.PickUpItemId, step.SkipConditions?.StepIf); step.PickUpItemId, step.SkipConditions?.StepIf, step.CompletionQuestVariablesFlags);
} }
} }
@ -67,15 +68,25 @@ internal static class Interact
EInteractionType InteractionType, EInteractionType InteractionType,
bool SkipMarkerCheck = false, bool SkipMarkerCheck = false,
uint? PickUpItemId = null, uint? PickUpItemId = null,
SkipStepConditions? SkipConditions = null) : ITask SkipStepConditions? SkipConditions = null,
List<QuestWorkValue?>? CompletionQuestVariablesFlags = null) : ITask
{ {
public List<QuestWorkValue?> CompletionQuestVariablesFlags { get; } = CompletionQuestVariablesFlags ?? [];
public bool HasCompletionQuestVariablesFlags { get; } =
Quest != null &&
CompletionQuestVariablesFlags != null &&
QuestWorkUtils.HasCompletionFlags(CompletionQuestVariablesFlags);
public bool ShouldRedoOnInterrupt() => true; public bool ShouldRedoOnInterrupt() => true;
public override string ToString() => $"Interact({DataId})"; public override string ToString() =>
$"Interact{(HasCompletionQuestVariablesFlags ? "*" : "")}({DataId})";
} }
internal sealed class DoInteract( internal sealed class DoInteract(
GameFunctions gameFunctions, GameFunctions gameFunctions,
QuestFunctions questFunctions,
ICondition condition, ICondition condition,
ILogger<DoInteract> logger) ILogger<DoInteract> logger)
: TaskExecutor<Task>, IConditionChangeAware : TaskExecutor<Task>, IConditionChangeAware
@ -151,13 +162,22 @@ internal static class Interact
return ETaskResult.TaskComplete; return ETaskResult.TaskComplete;
} }
} }
else else if (InteractionType == EInteractionType.Gather && condition[ConditionFlag.Gathering])
{
if (ProgressContext != null && (ProgressContext.WasSuccessful() ||
_interactionState == EInteractionState.InteractionConfirmed))
return ETaskResult.TaskComplete; return ETaskResult.TaskComplete;
else if (Quest != null && Task.HasCompletionQuestVariablesFlags)
if (InteractionType == EInteractionType.Gather && condition[ConditionFlag.Gathering]) {
var questWork = questFunctions.GetQuestProgressInfo(Quest.Id);
return questWork != null &&
QuestWorkUtils.MatchesQuestWork(Task.CompletionQuestVariablesFlags, questWork)
? ETaskResult.TaskComplete
: ETaskResult.StillRunning;
}
else if (ProgressContext != null)
{
if (ProgressContext.WasInterrupted())
return ETaskResult.StillRunning;
else if (ProgressContext.WasSuccessful() ||
_interactionState == EInteractionState.InteractionConfirmed)
return ETaskResult.TaskComplete; return ETaskResult.TaskComplete;
} }