diff --git a/Questionable.Model/V1/SkipStepConditions.cs b/Questionable.Model/V1/SkipStepConditions.cs index 97222ebd7..480f8d11f 100644 --- a/Questionable.Model/V1/SkipStepConditions.cs +++ b/Questionable.Model/V1/SkipStepConditions.cs @@ -21,6 +21,8 @@ public sealed class SkipStepConditions public bool HasSkipConditions() { - return Never || Flying != null || Chocobo != null || InTerritory.Count > 0 || NotInTerritory.Count > 0 || Item != null; + if (Never) + return false; + return Flying != null || Chocobo != null || InTerritory.Count > 0 || NotInTerritory.Count > 0 || Item != null; } } diff --git a/Questionable/Controller/CombatController.cs b/Questionable/Controller/CombatController.cs index 7e5ed36ad..923b7c866 100644 --- a/Questionable/Controller/CombatController.cs +++ b/Questionable/Controller/CombatController.cs @@ -9,6 +9,7 @@ using Dalamud.Game.ClientState.Objects.Types; using Dalamud.Plugin.Services; using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game.Object; +using FFXIVClientStructs.FFXIV.Client.Game.UI; using FFXIVClientStructs.FFXIV.Common.Math; using Microsoft.Extensions.Logging; using Questionable.Controller.CombatModules; @@ -211,23 +212,42 @@ internal sealed class CombatController : IDisposable if (battleNpc.BattleNpcKind is BattleNpcSubKind.BattleNpcPart or BattleNpcSubKind.Enemy) { var gameObjectStruct = (GameObject*)gameObject.Address; - if (gameObjectStruct->NamePlateIconId is 60093 or 60732) // npc that starts a fate or does turn-ins; not sure why they're marked as hostile + + // npc that starts a fate or does turn-ins; not sure why they're marked as hostile + if (gameObjectStruct->NamePlateIconId is 60093 or 60732) return 0; - var enemyData = _currentFight?.Data.ComplexCombatDatas.FirstOrDefault(x => x.DataId == battleNpc.DataId); + var enemyData = + _currentFight?.Data.ComplexCombatDatas.FirstOrDefault(x => x.DataId == battleNpc.DataId); if (enemyData is { IgnoreQuestMarker: true }) - return battleNpc.StatusFlags.HasFlag(StatusFlags.InCombat) ? 20 : 0; + { + if (battleNpc.StatusFlags.HasFlag(StatusFlags.InCombat)) + return 20; + } else - return gameObjectStruct->NamePlateIconId != 0 ? 30 : 0; + { + if (gameObjectStruct->NamePlateIconId != 0) + return 30; + } } // stuff trying to kill us if (battleNpc.TargetObjectId == _clientState.LocalPlayer?.GameObjectId) return 10; - } + // stuff on our enmity list that's not necessarily targeting us + var haters = UIState.Instance()->Hater; + for (int i = 0; i < haters.HaterCount; ++i) + { + var hater = haters.Haters[i]; + if (hater.EntityId == battleNpc.GameObjectId) + return 5; + } - return 0; + return 0; + } + else + return 0; } public void Stop() diff --git a/Questionable/Controller/Steps/Interactions/Combat.cs b/Questionable/Controller/Steps/Interactions/Combat.cs index c8a7e9290..52ab696f6 100644 --- a/Questionable/Controller/Steps/Interactions/Combat.cs +++ b/Questionable/Controller/Steps/Interactions/Combat.cs @@ -113,7 +113,9 @@ internal static class Combat if (questWork == null) return ETaskResult.StillRunning; - if (!QuestWorkUtils.MatchesQuestWork(_completionQuestVariableFlags, questWork.Value, false)) + if (QuestWorkUtils.MatchesQuestWork(_completionQuestVariableFlags, questWork.Value, false)) + return ETaskResult.TaskComplete; + else return ETaskResult.StillRunning; } diff --git a/Questionable/Controller/Steps/Shared/SkipCondition.cs b/Questionable/Controller/Steps/Shared/SkipCondition.cs index 04f338a79..68982ebbf 100644 --- a/Questionable/Controller/Steps/Shared/SkipCondition.cs +++ b/Questionable/Controller/Steps/Shared/SkipCondition.cs @@ -22,23 +22,23 @@ internal static class SkipCondition public ITask? CreateTask(Quest quest, QuestSequence sequence, QuestStep step) { var skipConditions = step.SkipConditions?.StepIf; - if (skipConditions == null || skipConditions.Never) + if (skipConditions is { Never: true }) return null; - if (skipConditions.HasSkipConditions() && - step.CompletionQuestVariablesFlags.Count == 0 && + if ((skipConditions == null || !skipConditions.HasSkipConditions()) && + !QuestWorkUtils.HasCompletionFlags(step.CompletionQuestVariablesFlags) && step.RequiredQuestVariables.Count == 0 && step.PickUpQuestId == null && step.NextQuestId == null) return null; - return serviceProvider.GetRequiredService() - .With(step, skipConditions, quest.QuestId); + return serviceProvider.GetRequiredService() + .With(step, skipConditions ?? new(), quest.QuestId); } } - internal sealed class CheckTask( - ILogger logger, + internal sealed class CheckSkip( + ILogger logger, GameFunctions gameFunctions, IClientState clientState) : ITask { diff --git a/Questionable/Controller/Utils/QuestWorkUtils.cs b/Questionable/Controller/Utils/QuestWorkUtils.cs index 360007ed3..33edd4981 100644 --- a/Questionable/Controller/Utils/QuestWorkUtils.cs +++ b/Questionable/Controller/Utils/QuestWorkUtils.cs @@ -50,7 +50,7 @@ internal static class QuestWorkUtils } public static bool MatchesRequiredQuestWorkConfig(List?> requiredQuestVariables, - QuestWork questWork, ILogger logger) + QuestWork questWork, ILogger logger) { if (requiredQuestVariables.Count != 6 || requiredQuestVariables.All(x => x == null || x.Count == 0)) { diff --git a/Questionable/QuestionablePlugin.cs b/Questionable/QuestionablePlugin.cs index f9318b706..3b230b84b 100644 --- a/Questionable/QuestionablePlugin.cs +++ b/Questionable/QuestionablePlugin.cs @@ -105,7 +105,7 @@ public sealed class QuestionablePlugin : IDalamudPlugin // task factories serviceCollection.AddTaskWithFactory(); serviceCollection.AddTaskWithFactory(); - serviceCollection.AddTaskWithFactory(); + serviceCollection.AddTaskWithFactory(); serviceCollection.AddTaskWithFactory(); serviceCollection.AddTaskWithFactory(); serviceCollection.AddTaskWithFactory();