From b3960e157d967b19caee16140a1593462c611828 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Mon, 12 Oct 2026 16:20:31 -0700 Subject: [PATCH] Hold corpse pickups while the server owes an answer to a cast or use ACE refuses a pickup while the player is busy (Player.HandleActionPutItemInContainer_Verify: YoureTooBusy and InventoryServerSaveFailed). In a client log, a pickup went out while Bloodstone Bolt VII was unanswered and came back 0x1D; the assess-timeout path skips the busy-count gate, and the pickup path never asked the action pacer. - The first pickup and the retry wait while ActionPacer has an action outstanding (logged once per hold); a held retry uses up no attempt. - Test: PickupWaitsForCastAnswer. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../CorpseOpenController.cs | 30 +++++++++++++ .../Tests/LootCorpseTests.cs | 43 +++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs b/Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs index 50a021f..e7b8be5 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs @@ -1461,6 +1461,10 @@ public sealed partial class RynthAiPlugin if (PickupAnimating(CorpseNowMs)) return; + // The server still owes an answer to a cast or use: it refuses a pickup now. + if (PickupHeldByServerAction()) + return; + ChatLine($"[RynthAi] Loot rule: {matchItemName} -> [{matchActionLabel}] {matchRuleLabel}"); _currentLootItemId = firstMatchId; RynthCore.Plugin.RynthAi.ItemInfo.SelfSelect.Mark(unchecked((uint)firstMatchId)); @@ -1569,6 +1573,30 @@ public sealed partial class RynthAiPlugin return now - _pickupAnimSince < PickupAnimMaxMs; } + private bool _pickupHeldLogged; + + /// + /// True while the server owes an answer to a cast or use (ActionPacer): ACE refuses a pickup + /// then (Player.HandleActionPutItemInContainer_Verify: IsBusy -> YoureTooBusy and + /// InventoryServerSaveFailed). In a client log, a pickup sent while Bloodstone Bolt VII + /// was unanswered came back 0x1D. The assess-timeout path skips the busy-count gate above, so + /// this is the gate that holds it. Logged once per hold. + /// + private bool PickupHeldByServerAction() + { + if (!ActionPacer.Outstanding(Host, out var pending) || pending == null) + { + _pickupHeldLogged = false; + return false; + } + if (!_pickupHeldLogged) + { + _pickupHeldLogged = true; + LootDiag($"[RynthAi] Corpse loot: pickup waits - the server still owes an answer to {ActionPacer.Describe(pending.Kind, pending.Label)} ({pending.Who})."); + } + return true; + } + private void TickPendingCorpsePickup(LegacyUiSettings settings) { if (_objectCache == null || _openedContainerId == 0 || _currentLootItemId == 0) @@ -1637,6 +1665,8 @@ public sealed partial class RynthAiPlugin if (_busyCount > 0) return; // Client is busy — don't queue retry + if (PickupHeldByServerAction()) + return; // a retry now would be refused as too busy and use up an attempt RynthCore.Plugin.RynthAi.ItemInfo.SelfSelect.Mark(unchecked((uint)_currentLootItemId)); Host.SelectItem(unchecked((uint)_currentLootItemId)); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/LootCorpseTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/LootCorpseTests.cs index 47aad8a..5060e3c 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/LootCorpseTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/LootCorpseTests.cs @@ -8,6 +8,7 @@ using System.Threading; using RynthCore.Loot; using RynthCore.Plugin.RynthAi; using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.Plugin.Shared; using RynthCore.PluginCore; using RynthCore.PluginSdk; using RynthCore.RynthAiHostTests.Fakes; @@ -51,6 +52,7 @@ internal static class LootCorpseTests r.Add("corpse close: an abandoned open corpse is closed once", AbandonedCorpseClosed); r.Add("corpse close: stopping the macro mid-loot closes the open corpse, not marked completed", MacroStopClosesCorpse); r.Add("loot pacing: a pickup waits for the last bend-down, and no retry is timed while it plays", PickupWaitsForAnimation); + r.Add("loot pacing: no pickup (first or retry) while the server owes an answer to a cast; it goes on the UseDone", PickupWaitsForCastAnswer); r.Add("corpse close: not while the last item is between the corpse and the pack - it closes once the item is in the inventory", CloseWaitsForInventory); } @@ -487,6 +489,47 @@ internal static class LootCorpseTests Check.Eq(FakeHost.ExternalMoves.Count(m => m.Id == Gem), 2, "then one retry"); } + // A pickup sent while Bloodstone Bolt VII was unanswered came back + // "too busy" (ACE refuses a pickup while IsBusy); the assess-timeout path skips the busy gate. + private static void PickupWaitsForCastAnswer() + { + BaseWorld(corpsePositioned: true); + FakeHost.ServerGates = true; // GetCastBusyState, GetUseDoneSeq + var host = FakeHost.Create(Player); + var bot = new Bot(host); + long t = 80_000_000; + ActionPacer.Reset(); ActionPacer.Enabled = true; ActionPacer.NowMs = () => t; + try + { + bot.Cache.OnCreateObject(Corpse); + bot.Cache.Tick(); + bot.Tick(BotActivity.Looting); + Check.True(FakeHost.Uses.Contains(Corpse), "the corpse is opened"); + ActionPacer.Reset(); ActionPacer.Enabled = true; ActionPacer.NowMs = () => t; // the open is answered + + // A cast goes out (Combat) and has no answer yet when the contents arrive. + ActionPacer.Begin(host, PacedKind.Cast, 0, "Bloodstone Bolt VII", "Combat", FakeHost.UseDoneSeq); + bot.Cache.OnCreateObject(Gem); + bot.Cache.Tick(); + bot.P.OnViewObjectContents(Corpse); + for (int i = 0; i < 10; i++) { t += 50; bot.Tick(BotActivity.Looting); Thread.Sleep(10); } + Check.False(FakeHost.ExternalMoves.Any(m => m.Id == Gem), "no pickup while the cast is unanswered"); + Check.Eq(FakeHost.Logs.Count(l => l.Contains("pickup waits - the server still owes an answer")), 1, "the hold is logged once"); + + FakeHost.UseDone(0); // the cast's answer + for (int i = 0; i < 100 && !FakeHost.ExternalMoves.Any(m => m.Id == Gem); i++) { t += 50; bot.Tick(BotActivity.Looting); Thread.Sleep(10); } + Check.Eq(FakeHost.ExternalMoves.Count(m => m.Id == Gem), 1, "the pickup goes on the cast's UseDone"); + + // The item stays on the corpse (refused); the next cast is unanswered when a retry is due. + ActionPacer.Begin(host, PacedKind.Cast, 0, "Bloodstone Bolt I", "Combat", FakeHost.UseDoneSeq); + TickFor(bot, 1_500); + Check.Eq(FakeHost.ExternalMoves.Count(m => m.Id == Gem), 1, "no retry while a cast is unanswered"); + FakeHost.UseDone(0); + TickFor(bot, 300); + Check.Eq(FakeHost.ExternalMoves.Count(m => m.Id == Gem), 2, "the retry goes once it is answered"); + } + finally { ActionPacer.Enabled = false; ActionPacer.Reset(); ActionPacer.NowMs = () => Environment.TickCount64; } + } // 2026-10-07: the client takes an item off the corpse list as soon as the move is sent; the // corpse was closed then, and the character picked the item up after the corpse closed. private static void CloseWaitsForInventory()