1
0
Fork 0
forked from aly/qstbak

muffin v7.5.12

This commit is contained in:
alydev 2026-08-19 13:19:57 +10:00
parent 3102923ce2
commit 911ed68baa
65 changed files with 2356 additions and 1539 deletions

View file

@ -1,6 +1,8 @@
using System;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using LLib;
using LLib.Shop;
using Microsoft.Extensions.Logging;
@ -89,6 +91,10 @@ internal sealed class SatisfactionSupplyTurnInExecutor(GameFunctions gameFunctio
case EPhase.SelectSlot:
if (_throttle.TryReset(0.5))
{
if (!PlanStillMatchesRequest())
{
return ETaskResult.RetryStep;
}
if (SatisfactionSupplyActions.IsNpcTradeReady())
{
logger.LogDebug("NpcTrade agent ready");
@ -106,10 +112,18 @@ internal sealed class SatisfactionSupplyTurnInExecutor(GameFunctions gameFunctio
}
break;
case EPhase.ConfirmTrade:
if (_throttle.TryReset(0.5) && SatisfactionSupplyActions.TryConfirmTrade())
if (_throttle.TryReset(0.5))
{
logger.LogDebug("Confirmed trade for slot {Slot}", base.Task.Slot);
SetPhase(EPhase.WaitForCutsceneStart);
if (!HasRemainingItems())
{
logger.LogWarning("Planned item {ItemId} is no longer available for turn-in", base.Task.ItemId);
return ETaskResult.RetryStep;
}
if (SatisfactionSupplyActions.TryConfirmTrade())
{
logger.LogDebug("Confirmed trade for slot {Slot}", base.Task.Slot);
SetPhase(EPhase.WaitForCutsceneStart);
}
}
break;
case EPhase.WaitForCutsceneStart:
@ -192,6 +206,32 @@ internal sealed class SatisfactionSupplyTurnInExecutor(GameFunctions gameFunctio
return SatisfactionSupplyActions.GetNpcState(base.Task.NpcIndex).UsedDeliveries > _lastUsedDeliveries;
}
private unsafe bool PlanStillMatchesRequest()
{
AgentSatisfactionSupply* ptr = AgentSatisfactionSupply.Instance();
if (ptr == null || !ptr->IsAgentActive() || !ptr->NpcInfo.Valid || !ptr->NpcInfo.Initialized)
{
return true;
}
uint id = ptr->Items[(int)base.Task.Slot].Id;
if (ptr->NpcInfo.Id == (uint)(base.Task.NpcIndex + 1) && id == base.Task.ItemId && HasRemainingItems())
{
return true;
}
logger.LogWarning("Turn-in plan no longer matches live request: NPC {NpcIndex}, slot {Slot}, planned item {PlannedItemId}, live item {LiveItemId}", base.Task.NpcIndex, base.Task.Slot, base.Task.ItemId, id);
return false;
}
private unsafe bool HasRemainingItems()
{
InventoryManager* ptr = InventoryManager.Instance();
if (ptr != null)
{
return ptr->GetInventoryItemCount(base.Task.ItemId, isHq: false, checkEquipped: true, checkArmory: true, (short)base.Task.Collectability) >= _remaining;
}
return false;
}
public override bool ShouldInterruptOnDamage()
{
return false;