From f0eab9cdbe6db3a3c6622a7ba4fde11171facd6c Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Sat, 17 Feb 2024 09:58:50 +0100 Subject: [PATCH] Trying to turn in a Red Onion Helm should close the supply window/disable the turn in instead of being stuck --- Deliveroo/Deliveroo.csproj | 2 +- Deliveroo/DeliverooPlugin.SelectString.cs | 16 +++++++-------- Deliveroo/DeliverooPlugin.Supply.cs | 25 ++++++++++++++++++++--- Deliveroo/DeliverooPlugin.cs | 8 ++++++-- Deliveroo/Stage.cs | 5 +++-- 5 files changed, 40 insertions(+), 16 deletions(-) diff --git a/Deliveroo/Deliveroo.csproj b/Deliveroo/Deliveroo.csproj index b702d33..a741f4d 100644 --- a/Deliveroo/Deliveroo.csproj +++ b/Deliveroo/Deliveroo.csproj @@ -1,7 +1,7 @@ net7.0-windows - 3.0 + 3.1 11.0 enable true diff --git a/Deliveroo/DeliverooPlugin.SelectString.cs b/Deliveroo/DeliverooPlugin.SelectString.cs index 4aeafe9..3883a01 100644 --- a/Deliveroo/DeliverooPlugin.SelectString.cs +++ b/Deliveroo/DeliverooPlugin.SelectString.cs @@ -17,17 +17,17 @@ partial class DeliverooPlugin if (CurrentStage == Stage.OpenGcSupply) { desiredText = _gameStrings.UndertakeSupplyAndProvisioningMission; - followUp = OpenGcSupplyFollowUp; + followUp = OpenGcSupplySelectStringFollowUp; } - else if (CurrentStage == Stage.CloseGcSupply) + else if (CurrentStage == Stage.CloseGcSupplySelectString) { desiredText = _gameStrings.ClosePersonnelOfficerTalk; - followUp = CloseGcSupplyFollowUp; + followUp = CloseGcSupplySelectStringFollowUp; } - else if (CurrentStage == Stage.CloseGcSupplyThenStop) + else if (CurrentStage == Stage.CloseGcSupplySelectStringThenStop) { desiredText = _gameStrings.ClosePersonnelOfficerTalk; - followUp = CloseGcSupplyThenCloseFollowUp; + followUp = CloseGcSupplySelectStringThenStopFollowUp; } else return; @@ -58,13 +58,13 @@ partial class DeliverooPlugin _pluginLog.Verbose($"Text '{desiredText}' was not found in prompt."); } - private void OpenGcSupplyFollowUp() + private void OpenGcSupplySelectStringFollowUp() { ResetTurnInErrorHandling(); CurrentStage = Stage.SelectExpertDeliveryTab; } - private void CloseGcSupplyFollowUp() + private void CloseGcSupplySelectStringFollowUp() { if (GetNextItemToPurchase() == null) { @@ -79,7 +79,7 @@ partial class DeliverooPlugin } } - private void CloseGcSupplyThenCloseFollowUp() + private void CloseGcSupplySelectStringThenStopFollowUp() { if (GetNextItemToPurchase() == null) { diff --git a/Deliveroo/DeliverooPlugin.Supply.cs b/Deliveroo/DeliverooPlugin.Supply.cs index bd80862..856e031 100644 --- a/Deliveroo/DeliverooPlugin.Supply.cs +++ b/Deliveroo/DeliverooPlugin.Supply.cs @@ -104,7 +104,7 @@ partial class DeliverooPlugin { _pluginLog.Information( $"No items to turn in ({addonGc->ListEmptyTextNode->AtkResNode.IsVisible}, {currentListSize})"); - CurrentStage = Stage.CloseGcSupplyThenStop; + CurrentStage = Stage.CloseGcSupplySelectStringThenStop; addon->FireCallbackInt(-1); return; } @@ -135,7 +135,7 @@ partial class DeliverooPlugin if (items.Count == 0) { // probably shouldn't happen with the previous node visibility check - CurrentStage = Stage.CloseGcSupplyThenStop; + CurrentStage = Stage.CloseGcSupplySelectStringThenStop; addon->FireCallbackInt(-1); return; } @@ -161,7 +161,7 @@ partial class DeliverooPlugin // Helms from being turned in. if (GetCurrentSealCount() + items[0].SealsWithBonus > GetSealCap()) { - CurrentStage = Stage.CloseGcSupply; + CurrentStage = Stage.CloseGcSupplySelectString; addon->FireCallbackInt(-1); return; } @@ -192,6 +192,7 @@ partial class DeliverooPlugin .Build()); addonSupplyReward->AtkUnitBase.FireCallbackInt(1); + CurrentStage = Stage.CloseGcSupplyWindowThenStop; return; } @@ -226,4 +227,22 @@ partial class DeliverooPlugin return ItemFilterType.HideGearSetItems; } + + private unsafe void CloseGcSupplyWindow() + { + var agentInterface = AgentModule.Instance()->GetAgentByInternalId(AgentId.GrandCompanySupply); + if (agentInterface != null && agentInterface->IsAgentActive()) + { + var addonId = agentInterface->GetAddonID(); + if (addonId == 0) + return; + + AtkUnitBase* addon = LAddon.GetAddonById(addonId); + if (addon == null || !LAddon.IsAddonReady(addon)) + return; + + CurrentStage = Stage.CloseGcSupplySelectStringThenStop; + addon->FireCallbackInt(-1); + } + } } diff --git a/Deliveroo/DeliverooPlugin.cs b/Deliveroo/DeliverooPlugin.cs index e2abe4e..209b6e3 100644 --- a/Deliveroo/DeliverooPlugin.cs +++ b/Deliveroo/DeliverooPlugin.cs @@ -302,14 +302,18 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin FinalizeTurnInItem(); break; - case Stage.CloseGcSupply: + case Stage.CloseGcSupplySelectString: // see SelectStringPostSetup break; - case Stage.CloseGcSupplyThenStop: + case Stage.CloseGcSupplySelectStringThenStop: // see SelectStringPostSetup break; + case Stage.CloseGcSupplyWindowThenStop: + CloseGcSupplyWindow(); + break; + case Stage.TargetQuartermaster: InteractWithQuartermaster(personnelOfficer!, quartermaster!); break; diff --git a/Deliveroo/Stage.cs b/Deliveroo/Stage.cs index 5fbe112..a905747 100644 --- a/Deliveroo/Stage.cs +++ b/Deliveroo/Stage.cs @@ -8,8 +8,9 @@ internal enum Stage SelectItemToTurnIn, TurnInSelected, FinalizeTurnIn, - CloseGcSupply, - CloseGcSupplyThenStop, + CloseGcSupplySelectString, + CloseGcSupplySelectStringThenStop, + CloseGcSupplyWindowThenStop, TargetQuartermaster, SelectRewardTier,