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;
}
}
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;
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()
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;
}
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<CheckTask>()
- .With(step, skipConditions, quest.QuestId);
+ return serviceProvider.GetRequiredService<CheckSkip>()
+ .With(step, skipConditions ?? new(), quest.QuestId);
}
}
- internal sealed class CheckTask(
- ILogger<CheckTask> logger,
+ internal sealed class CheckSkip(
+ ILogger<CheckSkip> logger,
GameFunctions gameFunctions,
IClientState clientState) : ITask
{
}
public static bool MatchesRequiredQuestWorkConfig(List<List<QuestWorkValue>?> requiredQuestVariables,
- QuestWork questWork, ILogger<SkipCondition.CheckTask> logger)
+ QuestWork questWork, ILogger<SkipCondition.CheckSkip> logger)
{
if (requiredQuestVariables.Count != 6 || requiredQuestVariables.All(x => x == null || x.Count == 0))
{
// task factories
serviceCollection.AddTaskWithFactory<StepDisabled.Factory, StepDisabled.Task>();
serviceCollection.AddTaskWithFactory<AetheryteShortcut.Factory, AetheryteShortcut.UseAetheryteShortcut>();
- serviceCollection.AddTaskWithFactory<SkipCondition.Factory, SkipCondition.CheckTask>();
+ serviceCollection.AddTaskWithFactory<SkipCondition.Factory, SkipCondition.CheckSkip>();
serviceCollection.AddTaskWithFactory<AethernetShortcut.Factory, AethernetShortcut.UseAethernetShortcut>();
serviceCollection.AddTaskWithFactory<WaitAtStart.Factory, WaitAtStart.WaitDelay>();
serviceCollection.AddTaskWithFactory<Move.Factory, Move.MoveInternal, Move.ExpectToBeNearDataId, Move.Land>();