From dcdc288b081a6779ee22d3c1da1d9b43ac417331 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Sat, 22 Feb 2025 01:06:41 +0100 Subject: [PATCH] Add special handling for Lahabrea fight --- .../4522_The Ultimate Weapon.json | 5 +- Questionable/Controller/QuestController.cs | 9 +++- .../Steps/Interactions/SinglePlayerDuty.cs | 47 ++++++++++++++++++- Questionable/Functions/GameFunctions.cs | 6 +++ Questionable/QuestionablePlugin.cs | 1 + 5 files changed, 62 insertions(+), 6 deletions(-) diff --git a/QuestPaths/2.x - A Realm Reborn/MSQ-2/C9-Ultimate Weapon/4522_The Ultimate Weapon.json b/QuestPaths/2.x - A Realm Reborn/MSQ-2/C9-Ultimate Weapon/4522_The Ultimate Weapon.json index 8d6f72e7..ffa07f49 100644 --- a/QuestPaths/2.x - A Realm Reborn/MSQ-2/C9-Ultimate Weapon/4522_The Ultimate Weapon.json +++ b/QuestPaths/2.x - A Realm Reborn/MSQ-2/C9-Ultimate Weapon/4522_The Ultimate Weapon.json @@ -105,10 +105,7 @@ "TerritoryId": 1053, "InteractionType": "SinglePlayerDuty", "SinglePlayerDutyOptions": { - "Enabled": false, - "Notes": [ - "Doesn't handle death properly" - ] + "Enabled": true } } ] diff --git a/Questionable/Controller/QuestController.cs b/Questionable/Controller/QuestController.cs index 9fbaadfd..b509de18 100644 --- a/Questionable/Controller/QuestController.cs +++ b/Questionable/Controller/QuestController.cs @@ -10,6 +10,7 @@ using Dalamud.Plugin.Services; using FFXIVClientStructs.FFXIV.Client.Game; using Microsoft.Extensions.Logging; using Questionable.Controller.Steps; +using Questionable.Controller.Steps.Interactions; using Questionable.Controller.Steps.Shared; using Questionable.External; using Questionable.Functions; @@ -200,7 +201,13 @@ internal sealed class QuestController : MiniTaskController if (!_clientState.IsLoggedIn || _condition[ConditionFlag.Unconscious]) { - if (!_taskQueue.AllTasksComplete) + if (_condition[ConditionFlag.Unconscious] && + _condition[ConditionFlag.SufferingStatusAffliction63] && + _clientState.TerritoryType == SinglePlayerDuty.LahabreaTerritoryId) + { + // ignore, we're in the lahabrea fight + } + else if (!_taskQueue.AllTasksComplete) { Stop("HP = 0"); _movementController.Stop(); diff --git a/Questionable/Controller/Steps/Interactions/SinglePlayerDuty.cs b/Questionable/Controller/Steps/Interactions/SinglePlayerDuty.cs index 188729be..7bf43b81 100644 --- a/Questionable/Controller/Steps/Interactions/SinglePlayerDuty.cs +++ b/Questionable/Controller/Steps/Interactions/SinglePlayerDuty.cs @@ -1,7 +1,12 @@ using System; using System.Collections.Generic; +using System.Linq; +using Dalamud.Game.ClientState.Conditions; +using Dalamud.Game.ClientState.Objects; +using Dalamud.Game.ClientState.Objects.Types; using Dalamud.Plugin.Services; using FFXIVClientStructs.FFXIV.Client.Game; +using Questionable.Controller.Steps.Common; using Questionable.Controller.Steps.Shared; using Questionable.Data; using Questionable.External; @@ -12,9 +17,13 @@ namespace Questionable.Controller.Steps.Interactions; internal static class SinglePlayerDuty { + public const int LahabreaTerritoryId = 1052; + internal sealed class Factory( BossModIpc bossModIpc, - TerritoryData territoryData) : ITaskFactory + TerritoryData territoryData, + ICondition condition, + IClientState clientState) : ITaskFactory { public IEnumerable CreateAllTasks(Quest quest, QuestSequence sequence, QuestStep step) { @@ -28,6 +37,14 @@ internal static class SinglePlayerDuty yield return new StartSinglePlayerDuty(cfcData.ContentFinderConditionId); yield return new EnableAi(); + if (cfcData.TerritoryId == LahabreaTerritoryId) + { + yield return new SetTarget(14643); + yield return new WaitCondition.Task(() => condition[ConditionFlag.Unconscious] || clientState.TerritoryType != LahabreaTerritoryId, "Wait(death)"); + yield return new DisableAi(); + yield return new WaitCondition.Task(() => !condition[ConditionFlag.Unconscious] || clientState.TerritoryType != LahabreaTerritoryId, "Wait(resurrection)"); + yield return new EnableAi(); + } yield return new WaitSinglePlayerDuty(cfcData.ContentFinderConditionId); yield return new DisableAi(); yield return new WaitAtEnd.WaitNextStepOrSequence(); @@ -113,4 +130,32 @@ internal static class SinglePlayerDuty public override bool ShouldInterruptOnDamage() => false; } + + // TODO this should be handled in VBM + internal sealed record SetTarget(uint DataId) : ITask + { + public override string ToString() => $"SetTarget({DataId})"; + } + + internal sealed class SetTargetExecutor( + ITargetManager targetManager, + IObjectTable objectTable) : TaskExecutor + { + protected override bool Start() => true; + + public override ETaskResult Update() + { + if (targetManager.Target?.DataId == Task.DataId) + return ETaskResult.TaskComplete; + + IGameObject? gameObject = objectTable.FirstOrDefault(x => x.DataId == Task.DataId); + if (gameObject == null) + return ETaskResult.StillRunning; + + targetManager.Target = gameObject; + return ETaskResult.StillRunning; + } + + public override bool ShouldInterruptOnDamage() => false; + } } diff --git a/Questionable/Functions/GameFunctions.cs b/Questionable/Functions/GameFunctions.cs index 09a9be25..27c5fc86 100644 --- a/Questionable/Functions/GameFunctions.cs +++ b/Questionable/Functions/GameFunctions.cs @@ -16,6 +16,7 @@ using FFXIVClientStructs.FFXIV.Component.GUI; using LLib.GameUI; using Lumina.Excel.Sheets; using Microsoft.Extensions.Logging; +using Questionable.Controller.Steps.Interactions; using Questionable.Model; using Questionable.Model.Questing; using Action = Lumina.Excel.Sheets.Action; @@ -427,6 +428,11 @@ internal sealed unsafe class GameFunctions return true; } + if (_condition[ConditionFlag.Unconscious] && + _condition[ConditionFlag.SufferingStatusAffliction63] && + _clientState.TerritoryType == SinglePlayerDuty.LahabreaTerritoryId) + return false; // needed to process the tasks + return _condition[ConditionFlag.Occupied] || _condition[ConditionFlag.Occupied30] || _condition[ConditionFlag.Occupied33] || _condition[ConditionFlag.Occupied38] || _condition[ConditionFlag.Occupied39] || _condition[ConditionFlag.OccupiedInEvent] || diff --git a/Questionable/QuestionablePlugin.cs b/Questionable/QuestionablePlugin.cs index e6a82af2..753ddb13 100644 --- a/Questionable/QuestionablePlugin.cs +++ b/Questionable/QuestionablePlugin.cs @@ -231,6 +231,7 @@ public sealed class QuestionablePlugin : IDalamudPlugin serviceCollection .AddTaskExecutor(); serviceCollection.AddTaskExecutor(); + serviceCollection.AddTaskExecutor(); serviceCollection.AddTaskExecutor(); serviceCollection.AddTaskFactory();