diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.cs
index 385140f..cf22201 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.cs
@@ -5665,6 +5665,7 @@ public partial class BuffManager : IDisposable
// GetAndWieldItem into the Held slot (the paperdoll drag). A use only wields a plain
// caster: one with a spell of its own (Electric Baton, Acid Staff) takes the use as
// "cast it" (Drakkon, 2026-10-18 14:00).
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
if (_host.HasWieldItem) _host.WieldItem((uint)step.Id, (uint)step.Slot);
else _host.UseFor((uint)step.Id, "Buff", "buffing: wield the wand");
_wandSwap.Sent(step, now);
@@ -5780,6 +5781,7 @@ public partial class BuffManager : IDisposable
if (hands.TryGetValue(id, out int slot) && (slot & HandSwapSequence.ShieldSlot) != 0) OffhandPutAway(id);
_host.PutItemInContainer(unchecked((uint)id), unchecked((uint)pack), 0);
}
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
_host.WieldItem(unchecked((uint)wandId), HeldSlot);
_wandSwap.SentBurst(moves, now);
_wandSwapLastMoved = wandId;
diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.Offhand.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.Offhand.cs
index d08d882..447fe2b 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.Offhand.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.Offhand.cs
@@ -431,6 +431,7 @@ public partial class CombatManager
// Another swap just went out (the main weapon, say): fight on and try again after the gate.
if (_weaponSwapGate != null && !_weaponSwapGate.TryBeginSwap("combat-offhand")) return false;
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
bool sent = _host.HasWieldItem
? _host.WieldItem(unchecked((uint)plan.Id), OffhandRules.ShieldSlot)
: _host.UseFor(unchecked((uint)plan.Id), "Combat", "offhand: wield the shield or offhand weapon");
diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs
index f49480e..22d8716 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs
@@ -2467,6 +2467,16 @@ public partial class CombatManager : IDisposable
if (hit) { _consecutiveCastMisses = 0; _magicMissesSinceHit = 0; return; }
+ // A swing or shot ACE refused in the air (WeenieError 0x4EB since it went out, Player_Melee /
+ // Player_Missile: IsJumping) never happened: not a no-damage attack. A cast's 0x4EB comes as
+ // its UseDone and is dropped before it gets here (JudgePendingOffensiveCast).
+ if (CurrentCombatMode != CombatMode.Magic && InTheAirErrorSince(_pendingJudgeErrSeq))
+ {
+ RefusedCastsNotJudged++;
+ _host.Log($"[Blacklist] attack at 0x{(uint)tid:X8} refused in the air (0x4EB): not counted as a no-damage attack");
+ return;
+ }
+
if (CurrentCombatMode == CombatMode.Magic) NoteMagicMissForResync(tid);
_consecutiveCastMisses++;
if (_consecutiveCastMisses >= _settings.BlacklistAttempts)
@@ -2513,11 +2523,13 @@ public partial class CombatManager : IDisposable
// A refusal is not a cast (in a client log, three healthy targets were blacklisted 'after 3
// no-damage casts' whose casts had all come back UseDone 0x1D):
// the answer 0x1D, or no answer yet while the server is taken as busy, is not judged.
- bool refused = _pendingOffensiveErr == ActionPacer.TooBusyErr || (_pendingOffensiveErr < 0 && ActionPacer.ServerBusy);
+ // So is 0x4EB, "You can't do that while in the air" (a cast sent in a jump).
+ bool inAir = _pendingOffensiveErr == InTheAirErr;
+ bool refused = _pendingOffensiveErr == ActionPacer.TooBusyErr || inAir || (_pendingOffensiveErr < 0 && ActionPacer.ServerBusy);
if (refused)
{
RefusedCastsNotJudged++;
- _host.Log($"[Blacklist] cast at 0x{(uint)_pendingOffensiveTargetId:X8} {(_pendingOffensiveErr >= 0 ? "refused 'too busy' (UseDone 0x1D)" : "unanswered while the server is busy")}: not counted as a no-damage cast");
+ _host.Log($"[Blacklist] cast at 0x{(uint)_pendingOffensiveTargetId:X8} {(inAir ? "refused in the air (UseDone 0x4EB)" : _pendingOffensiveErr >= 0 ? "refused 'too busy' (UseDone 0x1D)" : "unanswered while the server is busy")}: not counted as a no-damage cast");
_pendingOffensiveSpellId = 0;
_pendingOffensiveTargetId = 0;
_pendingOffensiveCastAt = DateTime.MinValue;
@@ -2572,6 +2584,30 @@ public partial class CombatManager : IDisposable
_pendingJudgeCastAt = RynthClock.Now;
_pendingJudgeTargetId = targetId;
_damageSincePendingCast = false;
+ _pendingJudgeErrSeq = WeenieErrorSeqNow();
+ }
+
+ /// WeenieError 0x4EB, "You can't do that while in the air" (ACE WeenieError.YouCantDoThatWhileInTheAir).
+ internal const uint InTheAirErr = 0x4EB;
+
+ private int _pendingJudgeErrSeq; // the engine's refusal counter when the judged attack was armed
+
+ private int WeenieErrorSeqNow()
+ {
+ try { return _host.HasGetLastWeenieError && _host.TryGetLastWeenieError(out int seq, out _, out _, out _) ? seq : 0; }
+ catch { return 0; }
+ }
+
+ /// The last refusal the engine saw is 0x4EB and came after .
+ private bool InTheAirErrorSince(int seqAtArm)
+ {
+ try
+ {
+ return _host.HasGetLastWeenieError
+ && _host.TryGetLastWeenieError(out int seq, out uint err, out _, out _)
+ && seq != seqAtArm && err == InTheAirErr;
+ }
+ catch { return false; }
}
///
@@ -3821,6 +3857,17 @@ public partial class CombatManager : IDisposable
_busyGate.Reset();
}
+ // In the air after a jump-loot pickup's jump: ACE refuses a cast, swing or shot in the
+ // air (YouCantDoThatWhileInTheAir), so the attack waits for the landing (capped at
+ // ActionPacer.JumpLandMaxMs). Only the attack: target, approach and stance above go on;
+ // nothing is stamped, counted or judged for the held tick.
+ if (ActionPacer.LootJumpAirborne(_host, out _))
+ {
+ LastCombatSkipReason = "loot-jump-air"; // D4 record-only
+ _tickWait = CombatLatencyTracker.Wait.Busy;
+ return true;
+ }
+
// Magic cadence guard: while a previous combat cast is still
// resolving on the ACE server, do NOT turn or issue another cast.
// A turn/stop MoveToState (or the next cast's free-hands stop-thunk)
@@ -5538,6 +5585,7 @@ public partial class CombatManager : IDisposable
case HandSwapSequence.Act.Wield:
{
bool off = step.Slot == HandSwapSequence.ShieldSlot;
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
if (_host.HasWieldItem) _host.WieldItem((uint)step.Id, (uint)step.Slot);
else _host.UseFor((uint)step.Id, "Combat", $"wield: {HandsSwapLabel}");
_rearmSwap.Sent(step, now);
@@ -5632,6 +5680,7 @@ public partial class CombatManager : IDisposable
var wants = _rearmWants;
foreach (var (id, slot) in wants)
{
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
_host.WieldItem(unchecked((uint)id), unchecked((uint)slot));
NoteRearmWield(id, slot == HandSwapSequence.ShieldSlot, now);
}
diff --git a/Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs b/Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs
index 94164dc..947472d 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
+using System.Threading;
using RynthCore.Plugin.RynthAi.LegacyUi;
using RynthCore.Plugin.RynthAi.Loot;
using RynthCore.Loot.VTank;
@@ -156,6 +157,8 @@ public sealed partial class RynthAiPlugin
private bool _currentLootItemSawAnim;
private bool _currentLootItemStackable; // a stack at send: it may merge into a pack stack and vanish
private bool _currentLootItemPipelined; // sent while the last pickup's Return played (ACE queues it)
+ private bool _currentLootItemJumped; // jump-loot: sent in the air, its own jump or the last one's (not a resend)
+ private bool _currentLootItemSentInAirWindow; // sent on the strength of the last no-bend-down pickup (JumpPickupInAir)
private int _currentLootItemErrSeqAtSend; // TryGetLastWeenieError seq at the send (0 = unknown)
private int _currentLootItemFreeRetries; // resends after a too-busy answer (not counted as attempts)
// 2026-10-29 (R-20261029-122319-321f): what the server said to the last send, and what the
@@ -194,6 +197,72 @@ public sealed partial class RynthAiPlugin
private bool _settlingSawAnim;
private bool _settlingAllowsPipeline;
private int _pipelinedAfterItemId; // the answered pickup a move was already queued behind
+ // A jump-loot pickup answered with no bend-down (JumpPickupHadNoMotion): until this CorpseNowMs
+ // the client's motion queue is the jump's own (take-off, fall, landing), not a server pickup.
+ private long _jumpPickupAirUntil;
+ // The no-bend-down call is off until this CorpseNowMs (DistrustJumpNoMotion): the server turned a
+ // move or open away as too busy that went out on it, so it had played a bend-down after all.
+ private long _jumpNoMotionOffUntil;
+ // The UseDone count before a corpse open sent inside the no-bend-down window (-1: none watched).
+ private int _openInAirWindowSeq = -1;
+ /// How long the no-bend-down call stays off after the server proved it wrong.
+ internal const long JumpNoMotionDistrustMs = 5 * 60_000;
+
+ // Flight budget. A pickup sent in the air with no fresh jump is a no-bend-down pickup
+ // only if the server still sees the character jumping when it processes the move. Prediction:
+ // jumpAge (ms since the loot jump) + expectedAnswerMs (the recent send-to-off-corpse time of
+ // no-bend-down pickups) must stay within this budget, else the send waits for the landing and
+ // takes a fresh jump. Measured in client logs from one server: of 56
+ // in-air sends answered with no bend-down, the largest jumpAge + off-corpse ms was 809 (an
+ // answer 313 ms after a send 496 ms into the flight); the two in-air sends that got a bend-down
+ // came out at 1701 and 2707 (the confirm time, the off-corpse time is not logged for them).
+ internal const long LootJumpFlightBudgetMs = 809;
+
+ /// The send-to-off-corpse time assumed until a no-bend-down pickup has been measured (log median 203 ms).
+ internal const long DefaultNoMotionOffCorpseMs = 200;
+
+ // The client's one pending-inventory-request slot refused a send: it printed "You can only move
+ // or use one item at a time" locally and sent nothing to the server. The item is sent again
+ // SlotRefusalRetryMs after the refused send, for up to SlotRefusalGiveUpMs from its first
+ // refusal, and no resend counts as one of the item's 3 tries.
+ // The line is taken for ours only when both of these hold:
+ // - it ARRIVED (its own stamp, NoteSlotRefusalChat) within the send's window after the send
+ // (SlotRefusalAttributionMs, or SlotRefusalDeferredWindowMs for a send made while the motion
+ // queue was busy). The window is by arrival, not by the tick that polls it.
+ // - no other item action of this plugin (UseAudit.LastItemActionAt) went out between one window
+ // before the send and the line, since another action's refusal reads the same.
+ // A count across the send call cannot make this exact: MoveItemExternal from the plugin thread
+ // only queues the move for AC's main thread (ClientHelperHooks.MoveItemExternal -> AcMainThreadQueue
+ // .MustQueue, ClientHelperHooks.cs:557-558), the client prints its refusal when that queue
+ // drains, and the chat line reaches the plugin later still, from the pump's queue
+ // (PluginManager.QueueChatWindowText / DispatchQueuedChatWindowText).
+ internal const long SlotRefusalRetryMs = 250;
+ internal const long SlotRefusalAttributionMs = 200;
+ // A send made while the character's motion queue is busy (the last pickup's Return, a jump's own
+ // motion) is held by AC's main-thread queue until that queue is empty or DrainDeferMaxMs has
+ // passed (RynthCore.Engine AcMainThreadQueue.Drain: it holds the whole ring while the
+ // pending-motion list is non-empty, DrainDeferMaxMs = 2500; RunsDuringGesture does not include
+ // item moves), so its refusal can arrive that much later than a send made when still.
+ internal const long SlotRefusalDeferredWindowMs = 2500;
+ // The engine clears a request slot whose object is still in the client only after its
+ // PendingTimeoutMs = 10000 (ClientActionGates.cs); the resends go on that long plus a margin
+ // from the item's first slot refusal, then the ordinary answer wait takes over.
+ internal const long SlotRefusalGiveUpMs = 10_000 + 1_500;
+ internal const string SlotRefusalChat = "You can only move or use one item at a time";
+
+ // The send-to-off-corpse ms of the last 4 pickups answered with no bend-down (ConfirmCurrentLootItem).
+ private readonly long[] _noMotionOffCorpse = new long[4];
+ private int _noMotionOffCorpseCount, _noMotionOffCorpseNext;
+ private bool _flightHoldLogged; // the hold for the current send has been logged
+ private int _slotRefusalSeq; // refusal lines heard in chat (Interlocked: the chat pump is not the tick)
+ private long _slotRefusalAt; // CorpseNowMs when the last of them arrived (written before the count)
+ private int _currentLootItemSlotSeqAtSend; // _slotRefusalSeq at the current item's last send
+ private long _currentLootItemSlotRefusedAt; // when the slot's refusal of the last send was seen (0 = none)
+ private int _currentLootItemSlotResends; // slot-refused sends of the current item sent again so far
+ private long _currentLootItemSlotWindowMs = SlotRefusalAttributionMs; // how late after the current send its refusal line may arrive
+ private long _currentLootItemFirstSlotRefusalAt; // when the current item's first slot refusal was seen (0 = none)
+ private bool _currentLootItemSlotGaveUp; // the resends ran out of time: the ordinary answer wait has the item
+ private int _slotRefusalCollisions; // refusals of a send by the held slot, this session
// [LootEval] lines: one per item per open (a matched item was re-printed before every pickup).
private readonly Dictionary _lootEvalLogged = new();
private int _manaStoneCapLoggedFor; // container the "ManaStone count for cap check" line was logged for
@@ -1832,9 +1901,11 @@ public sealed partial class RynthAiPlugin
// The character still animates. Right after a pickup's answer that is its "Return"
// (standing up): ACE queues a move that arrives then and runs it the moment the
// Return ends (Player.HandleActionPutItemInContainer_Verify, NextPickup), so the next
- // move goes out now - one, never two. Any other animation: wait until it ends.
+ // move goes out now - one, never two. Any other animation: wait until it ends. Not the
+ // jump's own motion after a jump-loot pickup the server answered with no bend-down: ACE
+ // has nothing to play then (no Return, not busy) and takes a pickup in the air.
bool pipelined = false;
- if (PickupAnimating(now))
+ if (PickupAnimating(now) && !JumpPickupInAir(now))
{
if (!CanPipelinePickup(now))
return;
@@ -1845,6 +1916,25 @@ public sealed partial class RynthAiPlugin
if (PickupHeldByServerAction())
return;
+ // Jump-loot (see the call below): the settings and the flight are read first, so a send
+ // held for the landing does nothing else this tick (no chat line, no selection).
+ bool jumpLoot = !pipelined && ShouldJumpLoot(settings);
+ long jumpAge = jumpLoot ? ActionPacer.LootJumpAgeMs() : -1;
+ bool stillInAir = jumpLoot && ActionPacer.LootJumpAirborne(Host, out _);
+ if (stillInAir && FlightBudgetSpent(jumpAge, out long expectedAnswerMs))
+ {
+ // A pickup sent now would reach the server after the jump's flight is over: it plays
+ // the whole bend-down and Return (about 2 s) where the landing and a fresh jump cost
+ // about 0.5 s. Hold until LootJumpAirborne says landed; the path below then jumps and sends.
+ if (!_flightHoldLogged)
+ {
+ _flightHoldLogged = true;
+ LootDiag($"[RynthAi] {LootTag}: jump-loot: holding 0x{(uint)firstMatchId:X8} '{matchItemName}' for the landing - {jumpAge} ms into the flight and an answer takes about {expectedAnswerMs} ms, over the {LootJumpFlightBudgetMs} ms flight budget.");
+ }
+ return;
+ }
+ _flightHoldLogged = false;
+
ChatLine($"[RynthAi] Loot rule: {matchItemName} -> [{matchActionLabel}] {matchRuleLabel}");
_currentLootItemId = firstMatchId;
RynthCore.Plugin.RynthAi.ItemInfo.SelfSelect.Mark(unchecked((uint)firstMatchId));
@@ -1861,9 +1951,14 @@ public sealed partial class RynthAiPlugin
// corpses hold one match, so a multi-item gate meant jump-loot almost never ran), with
// stamina > 5 to cover the cost. Not for a pipelined move: it is already queued behind
// the last pickup's Return, and a jump there would only disturb that queue. The tap jump
- // has a fixed height, so LootJumpHeight no longer has an effect.
- if (!pipelined && ShouldJumpLoot(settings))
- Host.TapJump();
+ // has a fixed height, so LootJumpHeight no longer has an effect. No second jump while
+ // still in the air (an air jump only costs stamina); a jump taken is noted for combat.
+ bool jumped = false;
+ if (jumpLoot && !stillInAir)
+ {
+ try { jumped = Host.TapJump(); } catch { jumped = false; }
+ if (jumped) ActionPacer.NoteLootJump(Host);
+ }
// Always a move into a pack, never a use: a use on a wearable corpse item is
// get-and-wield, which put salvage jewellery on the character (2026-10-02).
@@ -1914,9 +2009,12 @@ public sealed partial class RynthAiPlugin
// slot still held, or "You're too busy") must not cost the item one of its 3 tries.
_currentLootItemMoveAttempts = pipelined ? 0 : 1;
_currentLootItemPipelined = pipelined;
+ _currentLootItemJumped = jumped || stillInAir;
+ _currentLootItemSentInAirWindow = JumpPickupInAir(now);
_currentLootItemStackable = stackable;
_currentLootItemErrSeqAtSend = errSeqAtSend;
NoteLootMoveSent();
+ _currentLootItemSlotResends = 0;
_currentLootItemFreeRetries = 0;
_currentLootItemActionLabel = matchActionLabel;
_currentLootItemName = matchItemName;
@@ -1985,6 +2083,8 @@ public sealed partial class RynthAiPlugin
///
/// An answer sooner than this after the send isn't believed: ACE plays the whole pickup
/// motion (about 0.75 s standing, longer in a combat stance) before it moves the item.
+ /// Not for a jump-loot send's server-only answer (TickPendingCorpsePickup): with no motion it
+ /// comes in about the round trip.
///
internal const long PickupAnswerMinMs = 500;
@@ -2198,6 +2298,7 @@ public sealed partial class RynthAiPlugin
{
_currentLootItemAwaitingAnswer = true;
_currentLootItemResendWaitLogged = false;
+ _currentLootItemSlotRefusedAt = 0;
_currentLootItemRefusedAt = 0;
_currentLootItemRefusalError = 0;
_currentLootItemRefusalObject = 0;
@@ -2227,6 +2328,152 @@ public sealed partial class RynthAiPlugin
_currentLootItemRefusalBusy = !IsQuestPickupRefusal(err) && (err == WeenieErrorYoureTooBusy || after < PickupAnswerMinMs);
if (!_currentLootItemRefusalBusy && !_currentLootItemTimedOut)
NotePickupAnswerLatency(after);
+ if (_currentLootItemSentInAirWindow && RefusedAsTooBusy(err))
+ DistrustJumpNoMotion(now, $"0x{(uint)_currentLootItemId:X8}, sent on it, was refused as too busy {after} ms after the send");
+ }
+
+ ///
+ /// Chat from the game (RynthAiPlugin.OnChatWindowText; the chat pump, not the tick thread). The
+ /// client's own refusal of an item action while its one pending-inventory-request slot is held
+ /// is a LOCAL chat line, not a server answer: it reaches no WeenieError (those come from server
+ /// events), and the engine's MoveItemExternal returns true whether or not the client sent
+ /// anything. The line is the only sign the plugin gets, so it is counted here and read by
+ /// . Anchored at the line start: a player's chat quoting it is not it.
+ ///
+ internal void NoteSlotRefusalChat(string? text)
+ {
+ if (!ChatSource.StartsWithMarker(text, SlotRefusalChat, StringComparison.OrdinalIgnoreCase)) return;
+ Volatile.Write(ref _slotRefusalAt, CorpseNowMs); // the stamp first: a reader that sees the new count sees its time
+ Interlocked.Increment(ref _slotRefusalSeq);
+ }
+
+ ///
+ /// The current send was turned away by the client's held request slot (heard in chat since the
+ /// send, within SlotRefusalAttributionMs of it) and is due again SlotRefusalRetryMs after it.
+ /// Returns true while this item is in that state (the tick has nothing else to do for it).
+ /// The resend is not one of the item's 3 tries, is not a "too busy" free retry, and does not
+ /// wait for the PickupAnswerWaitMs (4-8 s) a send with no answer would. It keeps the jump when
+ /// the character is still inside the flight budget, else goes plain (the floor applies), and it
+ /// is a fresh send: a fight before it is not this send's. After
+ /// SlotRefusalGiveUpMs from the item's first refusal it stops and the ordinary answer wait takes
+ /// over (the engine's own watchdog empties a slot whose object is gone after 5 s and any slot
+ /// after 10 s).
+ ///
+ private bool PollSlotRefusal(long now)
+ {
+ if (_currentLootItemSlotGaveUp) return false;
+ if (_currentLootItemFirstSlotRefusalAt != 0 && now - _currentLootItemFirstSlotRefusalAt > SlotRefusalGiveUpMs)
+ {
+ _currentLootItemSlotGaveUp = true;
+ LootDiag($"[RynthAi] {LootTag}: 0x{(uint)_currentLootItemId:X8} was refused by the client's request slot for {now - _currentLootItemFirstSlotRefusalAt} ms ({_currentLootItemSlotResends} resends); the ordinary answer wait takes over.");
+ return false;
+ }
+ if (_currentLootItemSlotRefusedAt == 0)
+ {
+ if (!_currentLootItemAwaitingAnswer || _currentLootItemRefusedAt != 0) return false;
+ int seq = Volatile.Read(ref _slotRefusalSeq);
+ if (seq == _currentLootItemSlotSeqAtSend) return false;
+ _currentLootItemSlotSeqAtSend = seq; // taken: a later line is a new refusal
+ // By the line's own arrival time, not this tick's.
+ long lineAt = Volatile.Read(ref _slotRefusalAt);
+ long after = lineAt - _currentLootItemMoveRequestedAt;
+ if (after < 0 || after > _currentLootItemSlotWindowMs) return false; // not ours
+ long otherAt = UseAudit.LastItemActionAt;
+ if (otherAt != 0 && otherAt >= _currentLootItemMoveRequestedAt - _currentLootItemSlotWindowMs && otherAt <= lineAt)
+ return false; // another item action of ours went out around it: the line may be that one's refusal
+ _currentLootItemSlotRefusedAt = now;
+ if (_currentLootItemFirstSlotRefusalAt == 0) _currentLootItemFirstSlotRefusalAt = now;
+ _slotRefusalCollisions++;
+ LootDiag($"[RynthAi] {LootTag}: the client's one request slot refused the move of 0x{(uint)_currentLootItemId:X8}: the line arrived {after} ms after the send (window {_currentLootItemSlotWindowMs} ms) " +
+ $"(refusal #{_slotRefusalCollisions} this session); sending it again in {SlotRefusalRetryMs} ms, not counted as a try.");
+ }
+
+ if (now - _currentLootItemMoveRequestedAt < SlotRefusalRetryMs)
+ {
+ PauseCorpseClockWhileMoveAwaits(now);
+ return true;
+ }
+ if (PickupHeldByServerAction())
+ return true; // the server owes an answer to a cast or use: it would refuse this as too busy
+
+ RynthCore.Plugin.RynthAi.ItemInfo.SelfSelect.Mark(unchecked((uint)_currentLootItemId));
+ Host.SelectItem(unchecked((uint)_currentLootItemId));
+ int errSeqAtSend = LastWeenieErrorSeq();
+ long jumpAge = ActionPacer.LootJumpAgeMs();
+ bool inFlight = _currentLootItemJumped
+ && !FlightBudgetSpent(jumpAge, out _)
+ && ActionPacer.LootJumpAirborne(Host, out _);
+ LootPickupResult r = SendLootPickup(_currentLootItemId, _currentLootItemName, _openedContainerId, slotResend: true);
+ if (r == LootPickupResult.NoRoom || r == LootPickupResult.Refused)
+ return true; // SendLootPickup finished the item / corpse
+ _currentLootItemSlotResends++;
+ if (r != LootPickupResult.Moved && r != LootPickupResult.Used)
+ _currentLootItemSlotGaveUp = true; // the engine turned the call down: nothing more to repeat
+ _currentLootItemErrSeqAtSend = errSeqAtSend;
+ _currentLootItemMoveRequestedAt = now;
+ _currentLootItemJumped = inFlight;
+ _currentLootItemSentInAirWindow = inFlight && JumpPickupInAir(now);
+ _currentLootItemFightHeld = false; // a fresh send: a fight before it is not this send's
+ NoteLootMoveSent();
+ _currentLootItemStillSince = 0;
+ _currentLootItemSawAnim = false;
+ _lastLootActionAt = now;
+ LootDiag($"[RynthAi] {LootTag}: sent 0x{(uint)_currentLootItemId:X8} again after the slot's refusal (resend {_currentLootItemSlotResends}{(inFlight ? ", still in the flight" : ", no jump")}).");
+ return true;
+ }
+
+ ///
+ /// A pickup sent in the air now is predicted to reach the server after the loot jump's flight:
+ /// jumpAge + the expected answer time is over .
+ ///
+ private bool FlightBudgetSpent(long jumpAge, out long expectedAnswerMs)
+ {
+ expectedAnswerMs = ExpectedNoMotionAnswerMs();
+ return jumpAge >= 0 && jumpAge + expectedAnswerMs > LootJumpFlightBudgetMs;
+ }
+
+ /// The recent send-to-off-corpse time of pickups answered with no bend-down (mean of the last 4), or the default.
+ internal long ExpectedNoMotionAnswerMs()
+ {
+ if (_noMotionOffCorpseCount == 0) return DefaultNoMotionOffCorpseMs;
+ long sum = 0;
+ for (int i = 0; i < _noMotionOffCorpseCount; i++) sum += _noMotionOffCorpse[i];
+ return sum / _noMotionOffCorpseCount;
+ }
+
+ private void NoteNoMotionOffCorpse(long ms)
+ {
+ if (ms <= 0) return;
+ _noMotionOffCorpse[_noMotionOffCorpseNext] = ms;
+ _noMotionOffCorpseNext = (_noMotionOffCorpseNext + 1) % _noMotionOffCorpse.Length;
+ if (_noMotionOffCorpseCount < _noMotionOffCorpse.Length) _noMotionOffCorpseCount++;
+ }
+
+ ///
+ /// The refusal of the current send was ACE's "too busy", not another one (a full pack, a quest
+ /// item) that only came fast. ACE sends YoureTooBusy (0x1D) and then InventoryServerSaveFailed
+ /// with no code (Player_Inventory HandleActionPutItemInContainer_Verify); the engine keeps only
+ /// the last refusal but counts each, so the 0x1D is either the last code or the first of two
+ /// refusals since the send. A full pack sends one save-failed (its text is a transient string).
+ ///
+ private bool RefusedAsTooBusy(uint err) =>
+ err == WeenieErrorYoureTooBusy
+ || (err == 0 && LastWeenieErrorSeq() - _currentLootItemErrSeqAtSend >= 2);
+
+ ///
+ /// The server turned away as too busy a move or open that went out on a no-bend-down call: the
+ /// last pickup had a bend-down and a Return after all (a fast one: on a fast server it can be
+ /// 0.25-0.4 s, inside PickupAnswerMinMs). The call is wrong here: the window ends and
+ /// JumpPickupHadNoMotion says no for JumpNoMotionDistrustMs, so every pickup waits its Return.
+ ///
+ private void DistrustJumpNoMotion(long now, string why)
+ {
+ _jumpPickupAirUntil = 0;
+ _openInAirWindowSeq = -1;
+ bool was = now < _jumpNoMotionOffUntil;
+ _jumpNoMotionOffUntil = now + JumpNoMotionDistrustMs;
+ if (!was)
+ LootDiag($"[RynthAi] {LootTag}: jump-loot: {why}; the server played a bend-down after all - every pickup waits its Return for {JumpNoMotionDistrustMs / 60_000} min.");
}
///
@@ -2553,7 +2800,11 @@ public sealed partial class RynthAiPlugin
&& (currentItem == null || ObjectGoneFromClient(_currentLootItemId) || (currentContainer == 0 && _currentLootItemStackable)
|| MergedIntoInventoryStack(out mergedInto));
bool landed = inPack || mergedAway;
- bool believable = now - _currentLootItemMoveRequestedAt >= PickupAnswerMinMs;
+ // The floor is ACE's motion time; a jump send skips it only for the item seen in a pack,
+ // the server's answer about that object, which also frees the client's one request slot
+ // (a merged-away object can leave the slot held, so a merge keeps the floor).
+ bool jumpAnswer = _currentLootItemJumped && inPack;
+ bool believable = jumpAnswer || now - _currentLootItemMoveRequestedAt >= PickupAnswerMinMs;
long since = now - _currentLootItemLeftAt;
bool answered = landed && believable;
if (!answered && since < PickupArriveMaxMs)
@@ -2579,6 +2830,13 @@ public sealed partial class RynthAiPlugin
// counting it as one of the item's 3 tries. Refused after the pickup ran (no room): one
// of the tries, and the evidence a pack is full (PollCurrentPickupRefusal).
PollCurrentPickupRefusal(now);
+ // The client's own one-request slot turned the send away (nothing reached the server):
+ // sent again within SlotRefusalRetryMs, not one of the 3 tries, not the PickupAnswerWaitMs wait.
+ // Not while a fight has the tick (no resend then: below); the line is attributed by its own
+ // arrival time, so it is still taken after the fight. Only with Jump When Looting on: the net
+ // was measured on ACE's jump-loot cadence, and off it every send keeps its old wait.
+ if (!heldByFight && settings.LootJumpEnabled && PollSlotRefusal(now))
+ return;
bool refused = _currentLootItemRefusedAt != 0;
bool busyRefusal = refused && _currentLootItemRefusalBusy;
@@ -2750,6 +3008,8 @@ public sealed partial class RynthAiPlugin
_currentLootItemFightHeld = false;
_currentLootItemErrSeqAtSend = errSeqAtSend;
_currentLootItemMoveRequestedAt = now;
+ _currentLootItemJumped = false; // a resend goes without a jump
+ _currentLootItemSentInAirWindow = false;
if (retried) NoteLootMoveSent();
_currentLootItemStillSince = 0;
_currentLootItemSawAnim = false;
@@ -2793,9 +3053,17 @@ public sealed partial class RynthAiPlugin
/// never a use). NoRoom finishes the corpse like the free-slot check does; Refused
/// leaves the item. Both reset the current item, so the caller just returns.
///
- private LootPickupResult SendLootPickup(int itemId, string itemName, int corpseId)
+ private LootPickupResult SendLootPickup(int itemId, string itemName, int corpseId, bool slotResend = false)
{
- NoteMergeTargets(itemId, itemName);
+ // The refusal baseline lives here, in the one path every send goes through (the looter, the
+ // retry, the slot resend, the own-corpse recovery), so no send site can forget it: the
+ // session-wide refusal count is read before the move goes out, and only a refusal line
+ // heard after it can be this send's (PollSlotRefusal).
+ _currentLootItemSlotSeqAtSend = Volatile.Read(ref _slotRefusalSeq);
+ _currentLootItemSlotWindowMs = PickupAnimating(CorpseNowMs) ? SlotRefusalDeferredWindowMs : SlotRefusalAttributionMs;
+ // A slot resend sends the same item again: its stack baseline is the first send's, and a
+ // stack that has grown since is exactly what the confirm looks for.
+ if (!slotResend) NoteMergeTargets(itemId, itemName);
bool ownCorpse = corpseId != 0 && corpseId == _ownRecoveryCorpseId;
uint dest;
LootPickupResult r = ownCorpse
@@ -2874,8 +3142,12 @@ public sealed partial class RynthAiPlugin
if (answered) _currentLootItemDestsTried.Clear(); // landed: nothing to watch for (ResetCurrentLootItem)
_processedCorpseItems.Add(_currentLootItemId);
_corpseItemsLooted++;
+ bool noMotion = answered && JumpPickupHadNoMotion();
+ long jumpSentAt = _currentLootItemMoveRequestedAt;
LootDiag($"[RynthAi] {LootTag}: pickup confirmed for 0x{(uint)_currentLootItemId:X8}; {reason}" +
- $" ({now - _currentLootItemMoveRequestedAt} ms after the send{(_currentLootItemPipelined ? ", queued" : "")}).");
+ $" ({now - _currentLootItemMoveRequestedAt} ms after the send{(_currentLootItemPipelined ? ", queued" : "")}" +
+ $"{(noMotion ? $", jump-loot: off the corpse {_currentLootItemLeftAt - _currentLootItemMoveRequestedAt} ms after the send, no bend-down or Return to wait for" : "")}).");
+ if (noMotion) NoteNoMotionOffCorpse(_currentLootItemLeftAt - _currentLootItemMoveRequestedAt); // sizes the flight-budget prediction
// Each item taken is progress, so the corpse/chest timeout counts from the last pickup:
// a chest gets its 2 minutes per pickup, and a corpse with many keeps is no longer
// closed part way through by the 12 s timeout (SK, 2026-10-11). Not while a hold
@@ -2900,15 +3172,60 @@ public sealed partial class RynthAiPlugin
ResetCurrentLootItem();
_lastLootActionAt = now;
- // Its Return now plays: the close waits for it, and one move may be queued behind it.
+ _pickupAnimSince = 0; // the next pickup's animation gets its own PickupAnimMaxMs
+ if (noMotion)
+ {
+ // Jump-loot, answered with no bend-down: ACE played no pickup motion, so EnqueuePickupDone
+ // has no Return to play and the server is no longer busy. Nothing to settle: the corpse
+ // can close and the next pickup or open can go now, in the air. What the server refuses
+ // in the air (a cast, an attack) waits on its own gates, not here.
+ _settlingLootItemId = 0;
+ _settlingContainerId = 0;
+ _settlingAllowsPipeline = false;
+ // The flight ends JumpLandMaxMs after the JUMP, not after this send: a send that rode an
+ // earlier jump (the in-air path, a slot resend) is later than its jump. Looked up as an
+ // age so the pacer's clock and the loot clock need not agree; -1 (no jump noted: it has
+ // landed, or the pacer was reset) falls back to the send time.
+ long flightAge = ActionPacer.LootJumpAgeMs();
+ _jumpPickupAirUntil = flightAge >= 0
+ ? now + (ActionPacer.JumpLandMaxMs - flightAge)
+ : jumpSentAt + ActionPacer.JumpLandMaxMs;
+ return;
+ }
+
+ // Its Return now plays: the close waits for it, and one move may be queued behind it. A
+ // busy motion queue is that Return now, not an earlier jump's flight.
+ _jumpPickupAirUntil = 0;
_settlingLootItemId = itemId;
_settlingContainerId = _openedContainerId;
_settlingSince = now;
_settlingSawAnim = false;
_settlingAllowsPipeline = answered;
- _pickupAnimSince = 0; // the next pickup's animation gets its own PickupAnimMaxMs
}
+ ///
+ /// The current pickup was a jump-loot pickup the server ran with no bend-down: its jump went
+ /// out with this very send (not a resend), and the item was off the corpse sooner than
+ /// PickupAnswerMinMs after it - quicker than ACE's pickup motion, so ACE skipped it (with the
+ /// character in the air, Player_Inventory.GetPickupMotion returns Invalid under allow_jump_loot).
+ /// A jump pickup answered later (the server turned the character first and it had landed, or
+ /// allow_jump_loot is off) had a bend-down and gets its Return waited out as before. Measured
+ /// from the tick the item was first seen off the corpse, not from the confirm, which for a
+ /// jump send can come at once or wait out PickupAnswerMinMs (TickPendingCorpsePickup).
+ ///
+ private bool JumpPickupHadNoMotion() =>
+ _currentLootItemJumped
+ && CorpseNowMs >= _jumpNoMotionOffUntil
+ && _currentLootItemLeftAt != 0
+ && _currentLootItemLeftAt - _currentLootItemMoveRequestedAt < PickupAnswerMinMs;
+
+ ///
+ /// Inside the flight of the last jump pickup that had no bend-down (from its send, at most
+ /// ActionPacer.JumpLandMaxMs, the pacer's own longest flight): a busy motion queue now is the
+ /// jump's take-off, fall or landing, not a server pickup motion.
+ ///
+ private bool JumpPickupInAir(long now) => _jumpPickupAirUntil != 0 && now < _jumpPickupAirUntil;
+
///
/// WantLooting input for the ActivityArbiter (STEP 4). No game commands, no
/// state mutation — safe to call from the decision path every tick.
@@ -3870,7 +4187,16 @@ public sealed partial class RynthAiPlugin
_currentLootItemSawAnim = false;
_currentLootItemStackable = false;
_currentLootItemPipelined = false;
+ _currentLootItemJumped = false;
+ _currentLootItemSentInAirWindow = false;
_currentLootItemErrSeqAtSend = 0;
+ _flightHoldLogged = false; // a hold is logged once per send; a corpse completed or abandoned starts fresh
+ _currentLootItemSlotSeqAtSend = 0;
+ _currentLootItemSlotRefusedAt = 0;
+ _currentLootItemSlotResends = 0;
+ _currentLootItemSlotWindowMs = SlotRefusalAttributionMs;
+ _currentLootItemFirstSlotRefusalAt = 0;
+ _currentLootItemSlotGaveUp = false;
_currentLootItemFreeRetries = 0;
_currentLootItemFightHeld = false;
_currentLootItemFightResends = 0;
@@ -3996,6 +4322,8 @@ public sealed partial class RynthAiPlugin
bool sent = Host.UseFor(unchecked((uint)corpseId), "Loot", "open the claimed corpse");
if (watch && sent)
_useRefusals.OnOpenSent(corpseId, now, seqBefore);
+ // An open on a no-bend-down call: its answer says whether the server was free (DistrustJumpNoMotion).
+ _openInAirWindowSeq = watch && sent && JumpPickupInAir(now) ? seqBefore : -1;
LootDiag($"[RynthAi] Corpse loot: attempting open for 0x{(uint)corpseId:X8}.");
// The finished corpse held open (MarkCorpseCompleted): this use closes it on the server.
if (sent && _closeDeferredFor != 0 && _closeDeferredFor != corpseId)
@@ -4018,6 +4346,12 @@ public sealed partial class RynthAiPlugin
return;
int seq = Host.GetUseDoneSeq();
bool haveErr = Host.TryGetLastUseDone(out int lastSeq, out uint err) && lastSeq == seq;
+ if (_openInAirWindowSeq >= 0 && seq != _openInAirWindowSeq)
+ {
+ if (haveErr && err == WeenieErrorYoureTooBusy)
+ DistrustJumpNoMotion(now, "the next corpse's open, sent on it, was refused as too busy");
+ _openInAirWindowSeq = -1;
+ }
ApplyUseRefusalVerdict(_useRefusals.OnTick(now, seq, err, haveErr), now);
}
@@ -4245,6 +4579,11 @@ public sealed partial class RynthAiPlugin
private void ResetCorpseTarget()
{
StopCorpseMovement();
+ // The no-bend-down window belongs to the loot that set it (the macro off, a claim dropped).
+ // ActionPacer's air hold is the character's own flight: it ends on the landing, or at death,
+ // portal space and logout (RynthAiPlugin), not with a corpse.
+ _jumpPickupAirUntil = 0;
+ _openInAirWindowSeq = -1;
_targetCorpseId = 0;
_corpseTargetSince = 0;
_openedContainerAt = 0;
diff --git a/Plugins/RynthCore.Plugin.RynthAi/GroundLootController.cs b/Plugins/RynthCore.Plugin.RynthAi/GroundLootController.cs
index 250126f..5c79f61 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/GroundLootController.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/GroundLootController.cs
@@ -14,6 +14,7 @@
using System;
using System.Collections.Generic;
using RynthCore.Plugin.RynthAi.LegacyUi;
+using RynthCore.Plugin.Shared;
namespace RynthCore.Plugin.RynthAi;
@@ -279,6 +280,7 @@ public sealed partial class RynthAiPlugin
uint uid = unchecked((uint)_groundTargetId);
Host.SelectItem(uid);
_groundErrSeqAtSend = LastWeenieErrorSeq();
+ UseAudit.NoteItemAction();
bool sent = Host.HasMoveItemExternal
? Host.MoveItemExternal(uid, _playerId, 0)
: Host.UseObject(uid);
diff --git a/Plugins/RynthCore.Plugin.RynthAi/Huds/HudController.cs b/Plugins/RynthCore.Plugin.RynthAi/Huds/HudController.cs
index 6044ed2..af09f85 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/Huds/HudController.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/Huds/HudController.cs
@@ -282,6 +282,7 @@ internal sealed class HudController
var wo = inv.FirstOrDefault(w => w.Name.Equals(entry.Name, StringComparison.OrdinalIgnoreCase))
?? (entry.Wcid != 0 ? inv.FirstOrDefault(w => Wcid(w) == entry.Wcid) : null);
if (wo == null) { Chat($"[RynthAi] No {entry.Name} in your pack."); return; }
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
_host.UseObject(unchecked((uint)wo.Id));
RynthLog.Trace(LogCat.Huds, $"use {wo.Name} (0x{wo.Id:X8})");
}
diff --git a/Plugins/RynthCore.Plugin.RynthAi/Loot/InventoryManager.cs b/Plugins/RynthCore.Plugin.RynthAi/Loot/InventoryManager.cs
index b080161..dc69b5a 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/Loot/InventoryManager.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/Loot/InventoryManager.cs
@@ -344,6 +344,7 @@ public sealed class InventoryManager
var source = chosenSource.Value;
_host.Log($"[RynthAi] AutoStack: merge {source.Item.Name} src=0x{source.Item.Id:X8}({source.Count}) -> tgt=0x{target.Item.Id:X8}({target.Count}) max={max}");
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
bool ok = _host.MergeStackInternal(
unchecked((uint)source.Item.Id),
unchecked((uint)target.Item.Id));
diff --git a/Plugins/RynthCore.Plugin.RynthAi/Loot/SalvageManager.cs b/Plugins/RynthCore.Plugin.RynthAi/Loot/SalvageManager.cs
index e79dbd1..3a89465 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/Loot/SalvageManager.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/Loot/SalvageManager.cs
@@ -499,6 +499,7 @@ public sealed class SalvageManager
var ids = new uint[_batch.Count + _batchBags.Count];
_batch.CopyTo(ids, 0);
_batchBags.CopyTo(ids, _batch.Count);
+ UseAudit.NoteItemAction();
int sent = _host.SalvageDirect(_currentUstId, ids);
if (sent <= 0)
{
@@ -716,6 +717,7 @@ public sealed class SalvageManager
if (_batchAddIdx < _batch.Count)
{
uint id = _batch[_batchAddIdx];
+ UseAudit.NoteItemAction();
if (_host.SalvagePanelAddItem(id))
{
_batchAdded.Add(id);
@@ -787,8 +789,11 @@ public sealed class SalvageManager
{
int added = 0;
foreach (uint bagId in FindMatchingUnderFullBags(itemIds, int.MaxValue))
+ {
+ UseAudit.NoteItemAction();
if (_host.SalvagePanelAddItem(bagId))
added++;
+ }
return added;
}
@@ -1212,6 +1217,7 @@ public sealed class SalvageManager
{
uint[] bagIds = group.Take(RynthCoreHost.MaxSalvageDirectItems).ToArray();
_salvageChat.Clear();
+ UseAudit.NoteItemAction();
int sent = _host.SalvageDirect(ust, bagIds);
if (sent > 0)
{
@@ -1281,6 +1287,7 @@ public sealed class SalvageManager
if (_combineAddIdx < group.Count)
{
uint bagId = group[_combineAddIdx];
+ UseAudit.NoteItemAction();
if (_host.SalvagePanelAddItem(bagId))
Log($"[Salvage] Combine: added bag 0x{bagId:X8} to panel ({_combineAddIdx + 1}/{group.Count}).");
else
diff --git a/Plugins/RynthCore.Plugin.RynthAi/MagToolsCommands.Extra.cs b/Plugins/RynthCore.Plugin.RynthAi/MagToolsCommands.Extra.cs
index 8284526..a59a3c6 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/MagToolsCommands.Extra.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/MagToolsCommands.Extra.cs
@@ -202,6 +202,7 @@ public sealed partial class RynthAiPlugin
string name = string.Join(" ", parts, 3, parts.Length - 3);
var item = FindObject(name, inv: true, land: false, partial: sub == "addp");
if (item == null) { ReplyFail($"[RynthAi] Item not found: '{name}'"); return true; }
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
if (Host.TradeAdd(unchecked((uint)item.Id))) ReplyOk($"[RynthAi] Added {item.Name} to the trade.");
else ReplyFail("[RynthAi] Could not add it to the trade.");
return true;
diff --git a/Plugins/RynthCore.Plugin.RynthAi/MagToolsCommands.cs b/Plugins/RynthCore.Plugin.RynthAi/MagToolsCommands.cs
index d82bc87..cbe4294 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/MagToolsCommands.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/MagToolsCommands.cs
@@ -597,6 +597,7 @@ public sealed partial class RynthAiPlugin
// pretend it worked.
if (Host.HasGiveObjectTo)
{
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
bool ok = Host.GiveObjectTo(unchecked((uint)item.Id), unchecked((uint)target.Id), 0);
Host.Log($"[RynthAi] /mt give: {item.Name} → {target.Name} (give ok={ok})");
if (ok) ReplyOk($"[RynthAi] Giving {item.Name} to {target.Name}.");
@@ -783,6 +784,7 @@ public sealed partial class RynthAiPlugin
if (item == null) { ReplyFail($"[RynthAi] Item not found in inventory: '{name}'"); return true; }
// Drop = move to the ground (container 0)
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
Host.MoveItemExternal(unchecked((uint)item.Id), 0, 0);
Host.Log($"[RynthAi] /mt drop: {item.Name} (0x{(uint)item.Id:X8})");
ReplyOk($"[RynthAi] Dropping {item.Name}.");
@@ -841,6 +843,7 @@ public sealed partial class RynthAiPlugin
ReplyFail($"[RynthAi] /mt dequip: no open pack for '{found.Name}' — inventory full.");
return true;
}
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
Host.MoveItemInternal(unchecked((uint)found.Id), unchecked((uint)dest), 0, 1);
Host.Log($"[RynthAi] /mt dequip: {found.Name} (0x{(uint)found.Id:X8}) → pack 0x{(uint)dest:X8}");
ReplyOk($"[RynthAi] Taking off {found.Name} (into a pack).");
diff --git a/Plugins/RynthCore.Plugin.RynthAi/Meta/ExpressionEngine.UbCompat.cs b/Plugins/RynthCore.Plugin.RynthAi/Meta/ExpressionEngine.UbCompat.cs
index 4793421..f541fa4 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/Meta/ExpressionEngine.UbCompat.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/Meta/ExpressionEngine.UbCompat.cs
@@ -146,6 +146,7 @@ internal sealed partial class ExpressionEngine
{
if (unchecked((uint)wo.Id) == id || !string.Equals(wo.Name, name, StringComparison.Ordinal)) continue;
if (StackSizeOf(unchecked((uint)wo.Id)) <= 1 && StackSizeOf(id) <= 1) continue;
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
return _host.MergeStackInternal(id, unchecked((uint)wo.Id)) ? "1" : "0";
}
}
diff --git a/Plugins/RynthCore.Plugin.RynthAi/Meta/ExpressionEngine.cs b/Plugins/RynthCore.Plugin.RynthAi/Meta/ExpressionEngine.cs
index a78718f..80ead70 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/Meta/ExpressionEngine.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/Meta/ExpressionEngine.cs
@@ -3025,6 +3025,7 @@ internal sealed partial class ExpressionEngine
if (!_host.HasMoveItemExternal) return "0";
var wo = _worldObjectCache?[unchecked((int)giveId)];
int amount = wo != null ? Math.Max(1, wo.Values(LongValueKey.StackCount, 1)) : 1;
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
return _host.MoveItemExternal(giveId, destId, amount) ? "1" : "0";
}
@@ -3087,6 +3088,7 @@ internal sealed partial class ExpressionEngine
{
var (action, _) = RynthCore.Plugin.RynthAi.Loot.LootEvaluator.Classify(nativeProfile, wo, null);
if (action != RynthCore.Loot.LootAction.Keep) continue;
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
_host.GiveObjectTo((uint)wo.Id, targetId, 0);
return "1";
}
@@ -3114,6 +3116,7 @@ internal sealed partial class ExpressionEngine
if (VTankLootEvaluator.Match(rule, wo, lootCtx)) { match = rule; break; }
if (match == null || match.Action != VTankLootAction.Keep) continue;
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
_host.GiveObjectTo((uint)wo.Id, targetId, 0);
return "1";
}
@@ -3364,6 +3367,7 @@ internal sealed partial class ExpressionEngine
{
if (!uint.TryParse(objArg.Trim(), out uid) || uid == 0) return "0";
}
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
_host.SalvagePanelAddItem(uid);
return "1";
}
diff --git a/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/MiniRemoteInventory.cs b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/MiniRemoteInventory.cs
index fa49e7c..1af3e49 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/MiniRemoteInventory.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/MiniRemoteInventory.cs
@@ -119,7 +119,12 @@ internal sealed class MiniRemoteInventory
// ── Actions ─────────────────────────────────────────────────────────────
- public bool Use(WorldObject wo) => _host.HasUseObject && _host.UseObject(unchecked((uint)wo.Id));
+ public bool Use(WorldObject wo)
+ {
+ if (!_host.HasUseObject) return false;
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
+ return _host.UseObject(unchecked((uint)wo.Id));
+ }
/// Forgets cached WCIDs / appraisal throttles (logout).
public void Reset()
diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiCommands.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiCommands.cs
index 03fb851..39b79aa 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiCommands.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiCommands.cs
@@ -2819,6 +2819,7 @@ public sealed partial class RynthAiPlugin
///
internal bool GiveItem(uint itemId, uint targetId, int amount, int stackSize)
{
+ UseAudit.NoteItemAction();
if (Host.HasGiveObjectTo)
return Host.GiveObjectTo(itemId, targetId, amount <= 0 || amount >= stackSize ? 0 : amount);
return Host.MoveItemExternal(itemId, targetId, Math.Max(1, amount));
diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.ItemTool.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.ItemTool.cs
index 31b63ee..2f9eb4e 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.ItemTool.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.ItemTool.cs
@@ -581,7 +581,10 @@ public sealed partial class RynthAiPlugin
}
public bool Send(int itemId, int targetId)
- => Host.GiveObjectTo(unchecked((uint)itemId), unchecked((uint)targetId), 0); // amount 0 = the whole object
+ {
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
+ return Host.GiveObjectTo(unchecked((uint)itemId), unchecked((uint)targetId), 0); // amount 0 = the whole object
+ }
public int RefusalSeq()
=> Host.HasGetLastWeenieError && Host.TryGetLastWeenieError(out int seq, out _, out _, out _) ? seq : 0;
diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.Safety.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.Safety.cs
index a3625fc..a218e64 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.Safety.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.Safety.cs
@@ -81,6 +81,7 @@ public sealed partial class RynthAiPlugin
if (portaling && !_wasPortalingForPacer)
{
RynthCore.Plugin.Shared.ActionPacer.Forget("portal space");
+ RynthCore.Plugin.Shared.ActionPacer.ForgetLootJump(); // out of the air: the teleport moved the character
_buffManager?.ForgetPendingWield("portal space");
}
_wasPortalingForPacer = portaling;
@@ -115,6 +116,7 @@ public sealed partial class RynthAiPlugin
_combatManager?.ReleaseHeldTurn();
_navigationEngine?.Stop();
RynthCore.Plugin.Shared.ActionPacer.Forget("death"); // the server dropped whatever was open
+ RynthCore.Plugin.Shared.ActionPacer.ForgetLootJump(); // no landing to wait for after a death
_buffManager?.CancelPendingRecall("death"); // no /lifestone or macro restart after the respawn
_buffManager?.ForgetPendingWield("death"); // a swap the death cut short is not a failed swap
StopHunt("died", say: true); // from the lifestone it would walk all the way back to where it started
diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.cs
index c9e148a..8ee5866 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.cs
@@ -468,6 +468,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
while (_engineCommands.TryDequeue(out _)) { } // a fellowship button's command is for this character only
// The server drops whatever it was doing for this character at logout.
RynthCore.Plugin.Shared.ActionPacer.Forget("logout");
+ RynthCore.Plugin.Shared.ActionPacer.ForgetLootJump();
_navigationEngine?.Stop();
_navigationEngine = null;
// The dungeon cell graph is a static single-landblock cache; nothing may outlive the session.
@@ -2456,6 +2457,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
try { NoteServerPolicyChat(text); } catch { } // DreamWeave's Thread lines (ServerPolicy)
try { NoteDoorServerText(text); } catch { } // "The door is locked!" (the door logic)
try { ItemToolChat(text); } catch { } // the key's answers (chest looter)
+ try { NoteSlotRefusalChat(text); } catch { } // the client's own "one item at a time" refusal (loot resend)
try { _sessionStats?.OnChatWindowText(text); } catch (Exception ex) { RynthLog.Exception(LogCat.Huds, ex, "session stats chat"); }
try { NoteMonsterStatsChat(text, chatType); } catch (Exception ex) { RynthLog.Exception(LogCat.Huds, ex, "monster stats chat"); }
// The Meta Manager eats the reply to its own /myquests poll (only that).
diff --git a/Plugins/RynthCore.Plugin.RynthAi/Trade/AutoTradeCommands.cs b/Plugins/RynthCore.Plugin.RynthAi/Trade/AutoTradeCommands.cs
index 0566129..948c07a 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/Trade/AutoTradeCommands.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/Trade/AutoTradeCommands.cs
@@ -73,6 +73,7 @@ public sealed partial class RynthAiPlugin
{
uint item = ParseTradeId(arg);
if (item == 0) { ReplyFail("[RynthAi] Usage: /ra trade add - "); break; }
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
ReplyIf(Host.TradeAdd(item),
$"[RynthAi] Adding {TradeName(item)} to the trade window.",
"[RynthAi] Could not send the add.");
diff --git a/Plugins/RynthCore.Plugin.RynthAi/Trade/AutoTradeManager.cs b/Plugins/RynthCore.Plugin.RynthAi/Trade/AutoTradeManager.cs
index 8ab5312..1dde440 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/Trade/AutoTradeManager.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/Trade/AutoTradeManager.cs
@@ -736,6 +736,7 @@ internal sealed class AutoTradeManager
{
_handled.Add(itemId);
_host.Log($"[RynthAi] AutoTrade: Adding to trade window: {name}");
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
if (!_host.TradeAdd(itemId))
{
Error($"could not send {name} to the trade window");
diff --git a/Plugins/RynthCore.Plugin.RynthAi/Vendor/AutoVendorManager.cs b/Plugins/RynthCore.Plugin.RynthAi/Vendor/AutoVendorManager.cs
index b9dd984..c6eef4a 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/Vendor/AutoVendorManager.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/Vendor/AutoVendorManager.cs
@@ -1040,6 +1040,7 @@ internal sealed class AutoVendorManager
_mergeTargetCount = target.StackSize;
_splitName = source.Name;
_host.Log($"[RynthAi] AutoVendor merge {source.Name}:{source.Id:X8} ({source.StackSize}) onto {target.Id:X8} ({target.StackSize}) - {why}");
+ RynthCore.Plugin.Shared.UseAudit.NoteItemAction(); // a non-loot item action (UseAudit.LastItemActionAt)
if (!_host.MergeStackInternal(source.Id, target.Id))
{
TidyFailed($"could not merge {source.Name}");
diff --git a/Plugins/Shared/ActionPacer.cs b/Plugins/Shared/ActionPacer.cs
index fef99c6..f12fc9e 100644
--- a/Plugins/Shared/ActionPacer.cs
+++ b/Plugins/Shared/ActionPacer.cs
@@ -208,6 +208,7 @@ internal static class ActionPacer
_heldTurns = 0;
_forcedBreaks = 0;
_jumpAt = 0;
+ _lootJumpAt = 0;
_cycleBySpell.Clear();
_lastSeenSeq = int.MinValue;
_lastFrameMs = 0;
@@ -466,6 +467,9 @@ internal static class ActionPacer
{
if (!Enabled) { why = ""; return true; }
if (PlayerHoldsStart(host, who, out why)) return false;
+ // A buff, heal, kit or potion in the air is refused by ACE: wait for the landing. Combat checks
+ // it itself, at the attack, so a stance change is not held; loot and doors never.
+ if (who == "Buff" && LootJumpAirborne(host, out why)) return false;
if (ServerBusyHolds(host, who, attackRepeat, out why, out bool tryAfterBusy, heal)) return false;
// An emergency heal does not wait for the movement settle (150-600 ms): at Emergency Heal At
// the heal comes first; it still obeys the in-flight rules below (OutstandingAllows, GestureHolds).
@@ -1030,6 +1034,74 @@ internal static class ActionPacer
lock (Gate) { if (!ReferenceEquals(_stageFor, forAction)) _turnedAt = 0; _stage = stage; _stageAt = now; _stageFor = forAction; }
}
+ ///
+ /// Landed after a jump at from height : the height
+ /// is back (looked at from JumpLandMinMs on), or JumpLandMaxMs has passed whatever it says.
+ ///
+ private static bool Landed(RynthCoreHost host, long now, long jumpAt, float z0)
+ {
+ long air = now - jumpAt;
+ bool landed = air >= JumpLandMaxMs;
+ if (!landed && air >= JumpLandMinMs)
+ {
+ try { landed = !host.HasGetPlayerPose || (host.TryGetPlayerPose(out _, out _, out _, out float z, out _, out _, out _, out _) && Math.Abs(z - z0) < 0.1f); }
+ catch { landed = true; }
+ }
+ return landed;
+ }
+
+ // Jump-loot (CorpseOpenController): the corpse pickup's tap jump. ACE refuses a cast, a swing, a
+ // shot, a kit, food or a potion in the air (Player_Magic/Melee/Missile, Healer, Food: IsJumping ->
+ // YouCantDoThatWhileInTheAir), so combat and buffs wait until the character has landed. Loot does
+ // not: ACE takes a pickup and a corpse use in the air, so this never holds MayStart("Loot").
+ private static long _lootJumpAt; // 0 = not in the air after a loot jump
+ private static float _lootJumpZ;
+
+ /// A loot jump went out (the client took it): the character is in the air from now.
+ public static void NoteLootJump(RynthCoreHost host)
+ {
+ float z = 0;
+ try { if (host.HasGetPlayerPose) host.TryGetPlayerPose(out _, out _, out _, out z, out _, out _, out _, out _); } catch { }
+ long now = NowMs();
+ lock (Gate) { _lootJumpAt = now; _lootJumpZ = z; }
+ }
+
+ ///
+ /// True (with why) while the character is in the air after a loot jump: until the height is back
+ /// (from JumpLandMinMs) or JumpLandMaxMs at most, so a missed landing cannot stall anything. Pure
+ /// wait: nothing is counted, refused or retried. Independent of .
+ ///
+ public static bool LootJumpAirborne(RynthCoreHost host, out string why)
+ {
+ why = "";
+ long jumpAt; float z0;
+ lock (Gate) { jumpAt = _lootJumpAt; z0 = _lootJumpZ; }
+ if (jumpAt == 0) return false;
+ long now = NowMs();
+ if (!Landed(host, now, jumpAt, z0))
+ {
+ why = $"in the air after the loot jump ({now - jumpAt} ms)";
+ return true;
+ }
+ lock (Gate) { if (_lootJumpAt == jumpAt) _lootJumpAt = 0; }
+ return false;
+ }
+
+ ///
+ /// Ms since the last loot jump went out, or -1 when none is noted (never jumped, landed and
+ /// cleared by , or forgotten). Read it BEFORE LootJumpAirborne
+ /// when the answer matters: a landing seen there clears the jump.
+ ///
+ public static long LootJumpAgeMs()
+ {
+ long jumpAt;
+ lock (Gate) jumpAt = _lootJumpAt;
+ return jumpAt == 0 ? -1 : NowMs() - jumpAt;
+ }
+
+ /// No loot jump in the air any more (death, portal space, logout: RynthAiPlugin).
+ public static void ForgetLootJump() { lock (Gate) _lootJumpAt = 0; }
+
/// In the air after a breaker jump: hold until landed (height back, or JumpLandMaxMs).
private static bool AirborneHolds(RynthCoreHost host, long now, out string why)
{
@@ -1038,12 +1110,7 @@ internal static class ActionPacer
lock (Gate) { jumpAt = _jumpAt; z0 = _jumpZ; }
if (jumpAt == 0) return false;
long air = now - jumpAt;
- bool landed = air >= JumpLandMaxMs;
- if (!landed && air >= JumpLandMinMs)
- {
- try { landed = !host.HasGetPlayerPose || (host.TryGetPlayerPose(out _, out _, out _, out float z, out _, out _, out _, out _) && Math.Abs(z - z0) < 0.1f); }
- catch { landed = true; }
- }
+ bool landed = Landed(host, now, jumpAt, z0);
if (!landed)
{
why = $"in the air after the stuck-cast jump ({air} ms)";
diff --git a/Plugins/Shared/UseAudit.cs b/Plugins/Shared/UseAudit.cs
index fbb1206..dc50f72 100644
--- a/Plugins/Shared/UseAudit.cs
+++ b/Plugins/Shared/UseAudit.cs
@@ -26,6 +26,7 @@
using System;
using System.Collections.Generic;
+using System.Threading;
using RynthCore.PluginSdk;
namespace RynthCore.Plugin.Shared;
@@ -46,6 +47,38 @@ internal static class UseAudit
private const uint BfDoor = 0x1000;
private const uint BfCorpse = 0x2000;
+ private static long _lastItemActionAt;
+
+ ///
+ /// When (on ) this plugin last issued an item action other than a loot pickup.
+ /// The client refuses any of them with the same "one item at a time" line while its request slot
+ /// is held, so a refusal line heard near one of these cannot be told from a loot send's
+ /// (CorpseOpenController.PollSlotRefusal). 0 = none yet.
+ /// Stamped: every UseFor and UseOnFor except the looter's own ("Loot"); the wand, weapon and
+ /// offhand wields (BuffManager, CombatManager, CombatManager.Offhand); the ground pickup; the give
+ /// helper (GiveItem) and the item tool's give; the salvage sends and panel adds (SalvageManager);
+ /// the meta give actions and salvage-panel add (ExpressionEngine); the MagTools give, drop and
+ /// dequip; the HUD and MiniRemote item uses; the stack merges (MergeStackInternal in
+ /// InventoryManager, ExpressionEngine.UbCompat and AutoVendorManager); the trade adds (TradeAdd in
+ /// MagToolsCommands.Extra, AutoTradeCommands and AutoTradeManager).
+ /// Not stamped: vendor buy and sell (AutoVendorManager, MagToolsCommands.Extra); the salvage panel
+ /// execute (SalvageManager, ExpressionEngine); the pack-to-pack moves and stack splits
+ /// (MoveItemInternal, PutItemInContainer, SplitStackInternal) in BuffManager,
+ /// BuffManager.LegacySwap, CombatManager, CombatManager.Ammo, CombatManager.Offhand,
+ /// ExpressionEngine, ExpressionEngine.UbCompat, InventoryManager, AutoVendorManager and
+ /// AutoTradeManager; the legacy swap wields (BuffManager.LegacySwap, CombatManager.LegacySwap);
+ /// and the dashboard's panel drag (PanelDragWithLastItem, InstrumentDashboard).
+ /// Item actions of other plugins are not seen at all: each plugin compiles its own copy of this
+ /// file, so their stamps (where they have any) land on their own copy's clock, not this one's.
+ ///
+ public static long LastItemActionAt => Interlocked.Read(ref _lastItemActionAt);
+
+ /// Records that an item action just went out (see ).
+ public static void NoteItemAction() => Interlocked.Exchange(ref _lastItemActionAt, NowMs());
+
+ /// Forgets the last item action (a new session, and tests that move the clock).
+ public static void ForgetItemAction() => Interlocked.Exchange(ref _lastItemActionAt, 0);
+
/// The plugin's name in every line. Set once at Init.
public static string PluginName = "?";
@@ -76,6 +109,7 @@ internal static class UseAudit
{
PluginName = pluginName;
MacroOn = macroOn;
+ ForgetItemAction();
Seen.Clear();
_windowStart = long.MinValue;
_windowLines = 0;
@@ -116,6 +150,9 @@ internal static class UseAudit
try { seqBefore = host.HasUseDoneSeq ? host.GetUseDoneSeq() : 0; } catch { }
}
bool sent = host.UseObject(objectId);
+ // The one choke point for uses (buff and combat wields, salvage, doors, metas, commands).
+ // The looter's own corpse opens are not "another" item action for its pickups.
+ if (subsystem != "Loot") NoteItemAction();
if (track && sent)
MarkWorldUse(objectId, seqBefore);
if (sent && after != null)
@@ -224,6 +261,7 @@ internal static class UseAudit
try { seqBefore = host.HasUseDoneSeq ? host.GetUseDoneSeq() : 0; } catch { }
}
bool sent = host.UseObjectOn(sourceId, targetId);
+ if (subsystem != "Loot") NoteItemAction(); // kits, mana stones, lockpicks, crafting, pets, metas
if (sent && after != null)
{
try { after(host, new SentUse(sourceId, targetId, subsystem, $"{src} on {tgt}", doorOrCorpse, seqBefore, kind)); } catch { }
diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/CombatHookTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/CombatHookTests.cs
index 6ea13d5..3832162 100644
--- a/Tools/RynthCore.RynthAiHostTests/Tests/CombatHookTests.cs
+++ b/Tools/RynthCore.RynthAiHostTests/Tests/CombatHookTests.cs
@@ -53,6 +53,8 @@ internal static class CombatHookTests
r.Add("combat hook: a script answer at an ignored monster is rejected, even one hitting us (RynthAi casts its own)", HookRejectsIgnoredTarget);
r.Add("combat hook: a script heal (a drain) at a fight target whose rule turned to Priority 0 is rejected", HookHealRejectsIgnoredTarget);
r.Add("blacklist: casts answered 'too busy' (UseDone 0x1D) are not no-damage casts (answered 0: the target is dropped)", RefusedCastsNotJudged);
+ r.Add("loot jump: Think sends no cast while in the air after a loot jump; it casts on the landing, or at the cap", LootJumpHoldsAttack);
+ r.Add("loot jump: a swing refused in the air (WeenieError 0x4EB) is not a no-damage attack (without it: a miss)", MeleeInAirNotJudged);
r.Add("combat hook: ctx.pending is the cast in flight; ctx.last the last resolved one, err its first UseDone (final; -1 when missed or after 7 s)", LastErrIsTheCastsAnswer);
r.Add("combat hook: an attack and a heal in flight take their UseDones in send order (attack 0x401, heal 0)", AnswersInSendOrder);
r.Add("combat hook: a script heal refused for mana keeps its 2 s rest (no recovery fast retry)", ScriptHealNoFastRetry);
@@ -1049,9 +1051,9 @@ internal static class CombatHookTests
private static void RefusedCastsNotJudged() => Guard(() =>
{
int drain = Id("Drain Health Other V");
- foreach (uint answer in new uint[] { 0, ActionPacer.TooBusyErr })
+ foreach (uint answer in new uint[] { 0, ActionPacer.TooBusyErr, CombatManager.InTheAirErr })
{
- string what = answer == 0 ? "answered 0" : "answered 0x1D";
+ string what = answer == 0 ? "answered 0" : $"answered 0x{answer:X}";
var rig = new AttackRig(setup: () => { FakeHost.ServerGates = true; FakeHost.LastUseDoneCalls = true; });
rig.S.BlacklistAttempts = 2;
rig.S.EnableRaycasting = false;
@@ -1071,13 +1073,71 @@ internal static class CombatHookTests
Check.Eq(rig.C.activeTargetId, 0, "answered 0: two no-damage casts blacklist and drop the target");
else
{
- Check.Eq(rig.C.activeTargetId, Target, "answered 0x1D: refusals are not casts, the target is kept");
- Check.Eq(rig.C.RefusedCastsNotJudged, 2, "both kept out of the count");
- Check.True(FakeHost.Logs.Any(l => l.Contains("refused 'too busy' (UseDone 0x1D): not counted")), "logged");
+ Check.Eq(rig.C.activeTargetId, Target, $"{what}: refusals are not casts, the target is kept");
+ Check.Eq(rig.C.RefusedCastsNotJudged, 2, $"{what}: both kept out of the count");
+ Check.Eq(Field(rig.C, "_consecutiveCastMisses"), 0, $"{what}: no miss counted");
+ Check.True(FakeHost.Logs.Any(l => l.Contains(answer == ActionPacer.TooBusyErr
+ ? "refused 'too busy' (UseDone 0x1D): not counted" : "refused in the air (UseDone 0x4EB): not counted")), $"{what}: logged");
}
}
});
+ // A jump-loot pickup's jump (ActionPacer.NoteLootJump) holds the attack until the landing.
+ // ACE refuses a cast, swing or shot in the air (Player_Magic/Melee/Missile: IsJumping).
+ private static void LootJumpHoldsAttack() => Guard(() =>
+ {
+ bool pacer = ActionPacer.Enabled;
+ var clock = ActionPacer.NowMs;
+ long t = 1_000_000;
+ ActionPacer.Enabled = false; // only the air hold under test (it does not depend on the pacer switch)
+ ActionPacer.NowMs = () => t;
+ try
+ {
+ foreach (bool cap in new[] { false, true })
+ {
+ string what = cap ? "landing never seen" : "landing seen";
+ var rig = new AttackRig(think: true);
+ ActionPacer.ForgetLootJump();
+ ActionPacer.NoteLootJump(rig.Host); // the pickup's jump, from the ground
+ var ground = FakeHost.PlayerPose;
+ FakeHost.PlayerPose = (ground.Cell, ground.X, ground.Y, ground.Z + 1.0f);
+ rig.C.Think();
+ Check.Eq(FakeHost.Casts.Count, 0, $"{what}: no cast in the air");
+ Check.Eq(rig.C.LastCombatSkipReason, "loot-jump-air", $"{what}: held for the landing");
+ Check.Eq(rig.C.GetStateSnapshot().LastAttackCmd, DateTime.MinValue, $"{what}: no attack stamped");
+ Check.Eq(rig.C.activeTargetId, Target, $"{what}: the target stays");
+ t += ActionPacer.JumpLandMinMs + 100;
+ rig.C.Think();
+ Check.Eq(FakeHost.Casts.Count, 0, $"{what}: still up: no cast");
+ if (!cap)
+ FakeHost.PlayerPose = ground; // landed
+ else
+ t += ActionPacer.JumpLandMaxMs; // up for good: the cap
+ rig.C.Think();
+ Check.Eq(rig.LastCast, "Flame Bolt VI", $"{what}: the cast goes at once");
+ Check.Eq(Field(rig.C, "_consecutiveCastMisses"), 0, $"{what}: nothing counted for the held ticks");
+ }
+ }
+ finally { ActionPacer.Enabled = pacer; ActionPacer.NowMs = clock; ActionPacer.ForgetLootJump(); ActionPacer.Forget("test"); }
+ });
+
+ private static void MeleeInAirNotJudged() => Guard(() =>
+ {
+ foreach (bool inAir in new[] { false, true })
+ {
+ var rig = new AttackRig(setup: () => { FakeHost.WeaponCalls = true; FakeHost.CombatModeValue = CombatMode.Melee; FakeHost.WeenieErrorCalls = true; });
+ rig.S.BlacklistAttempts = 5;
+ rig.S.EnableRaycasting = false; // (the raycast warm-up drops every judgement)
+ rig.C.RecordOffensiveCast(Target); // a swing goes out
+ if (inAir) FakeHost.WeenieError(CombatManager.InTheAirErr); // ACE: "You can't do that while in the air"
+ SetField(rig.C, "_pendingJudgeCastAt", DateTime.Now.AddSeconds(-30));
+ CallPrivate(rig.C, "JudgePendingCast");
+ Check.Eq(Field(rig.C, "_consecutiveCastMisses"), inAir ? 0 : 1,
+ inAir ? "refused in the air: not a miss" : "control, no refusal: a no-damage swing is a miss");
+ if (inAir) Check.True(FakeHost.Logs.Any(l => l.Contains("refused in the air (0x4EB)")), "logged");
+ }
+ });
+
private static void LastErrIsTheCastsAnswer() => Guard(() =>
{
int drain = Id("Drain Health Other V");
diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/LootJumpTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/LootJumpTests.cs
index 193c42f..710066e 100644
--- a/Tools/RynthCore.RynthAiHostTests/Tests/LootJumpTests.cs
+++ b/Tools/RynthCore.RynthAiHostTests/Tests/LootJumpTests.cs
@@ -7,6 +7,7 @@ using System.Runtime.CompilerServices;
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;
@@ -24,6 +25,11 @@ internal static class LootJumpTests
private const uint CorpseA = 0x80263100;
private const uint GemA = 0x80263101;
private const uint GemA2 = 0x80263102;
+ private const uint GemA3 = 0x80263103;
+ private const uint PackStack = 0x80263120;
+ private const uint KeyMaxStack = 11, KeyStack = 12;
+ private const uint CorpseB = 0x80263110;
+ private const uint GemB = 0x80263111;
private const uint ItemTypeContainer = 0x200, ItemTypeGem = 0x800;
private const uint LongDescKey = 16;
private const string Me = "Test Looter";
@@ -36,6 +42,43 @@ internal static class LootJumpTests
r.Add("jump loot: a corpse's only match jumps too (one tap jump)", SingleItemJumps);
r.Add("jump loot: the setting off sends no jump", SettingOffNoJump);
r.Add("jump loot: stamina of 5 or less sends no jump", LowStaminaNoJump);
+ r.Add("jump loot: a pickup answered with no bend-down releases the corpse at once; the next corpse is opened while still in the air", NoReturnNextCorpseInAir);
+ r.Add("jump loot: after a pickup answered with no bend-down, the next item goes out at once in the air with no second jump (not queued); after the landing the next one jumps again", NoReturnNextItemJumps);
+ r.Add("jump loot: a jump pickup answered only after a bend-down's time still waits for its Return before the corpse is released", SlowAnswerKeepsReturnWait);
+ r.Add("jump loot: a bend-down answer inside an earlier jump's flight ends it: the next item is queued behind that Return, with no jump", SlowAnswerEndsAirWindow);
+ r.Add("jump loot: a jump send's answer at 150 ms is confirmed then, and the next corpse opened then, not at 500 ms", JumpAnswerConfirmedOnArrival);
+ r.Add("jump loot: a jump send merged into a pack stack keeps the floor (the client's request slot stays held for a merged-away object)", JumpMergeKeepsAnswerFloor);
+ r.Add("jump loot: the no-bend-down window after an in-air send that rode an earlier jump is anchored to that jump", AirWindowAnchoredToTheInAirJump);
+ r.Add("jump loot: a send the client's held request slot refused (chat line) is sent again within 250 ms, is not one of the 3 tries, and does not wait the answer window", SlotRefusedResentQuickly);
+ r.Add("jump loot: a slot refusal heard long after the send, or a player's words, is not ours (no resend)", LateSlotRefusalIgnored);
+ r.Add("jump loot: a refusal line 100 ms after the send, then the server answer at 200 ms, is a single move", ForeignRefusalThenAnswerSingleMove);
+ r.Add("jump loot: a slot resend inside the flight budget keeps the jump flag", ResendInsideBudgetKeepsJump);
+ r.Add("jump loot: a slot resend past the flight budget drops the jump flag", ResendPastBudgetDropsJump);
+ r.Add("jump loot: slot resends go on past 7.5 s (9 s of refusals, still resending, no try used)", SlotResendsStillGoingAt9s);
+ r.Add("jump loot: after 11.5 s of slot refusals the ordinary answer wait takes over", SlotResendCapHandsOver);
+ r.Add("jump loot: a send made while the motion queue is busy has its refusal at 700 ms taken for its own and resent", DeferredSendRefusalAt700IsResent);
+ r.Add("jump loot: another item action just before the refusal line keeps it from being taken for ours (one move)", ForeignItemActionSuppressesAttribution);
+ r.Add("jump loot: the no-bend-down window after a resend is anchored to the jump, not the resend", AirWindowAnchoredToTheJump);
+ r.Add("jump loot: ResetCurrentLootItem clears the slot-refusal fields and the hold-logged flag", ResetClearsSlotFields);
+ r.Add("jump loot: with Jump When Looting off a slot refusal line changes nothing (no quick resend)", SlotNetNeedsJumpLoot);
+ r.Add("jump loot: a slot refusal heard while a fight has the tick is resent only after the fight, at once, with no try used", SlotRefusalWaitsOutAFight);
+ r.Add("jump loot: a UseOnFor between the loot send and the refusal line keeps the line from being taken for ours (no resend)", UseOnForSuppressesAttribution);
+ r.Add("jump loot: the looter's own UseOnFor (Loot) is not stamped, so a refusal line after it is still ours (resent)", LootUseOnForIsNotStamped);
+ r.Add("jump loot: another item action 1 s before a busy-queue send (2500 ms window) keeps its refusal line from being taken for ours", ForeignActionLookbackUsesSendWindow);
+ r.Add("jump loot: the flight budget lets an early in-air send through with no new jump", FlightBudgetLetsEarlySendThrough);
+ r.Add("jump loot: the flight budget holds a late in-air send until the landing, then jumps again", FlightBudgetHoldsLateSend);
+ r.Add("jump loot: a fast refusal that is not 'too busy' (a code-0 save-failed) does not turn the no-bend-down call off", NonBusyRefusalKeepsNoMotion);
+ r.Add("jump loot: a send with no jump still waits PickupAnswerMinMs before its answer is believed", NoJumpKeepsAnswerFloor);
+ r.Add("jump loot: a jump send's weak sign (an unowned stack, no pack stack grown) still waits PickupAnswerMinMs", JumpWeakSignKeepsAnswerFloor);
+ r.Add("jump loot: a send with no jump answered at 100 ms still waits its Return before the next corpse", NoJumpFastAnswerWaitsReturn);
+ r.Add("jump loot: a jump send refused, then resent (no jump), answered at 100 ms still waits its Return", ResentFastAnswerWaitsReturn);
+ r.Add("jump loot: a move sent on a no-bend-down call and refused 'too busy' turns the call off: the next fast jump answer waits its Return", BusyRefusalTurnsNoMotionOff);
+ r.Add("jump loot: an open sent on a no-bend-down call and refused 'too busy' turns the call off too", BusyOpenTurnsNoMotionOff);
+ r.Add("jump loot: dropping the corpse claim (macro off) ends the no-bend-down window", ResetEndsAirWindow);
+ r.Add("jump loot: a pickup sent while still in the air from the last loot jump takes no second jump; after the landing the next one jumps", NoSecondJumpInTheAir);
+ r.Add("jump loot: the pickup's jump puts combat and buffs on hold until the landing (or the cap); loot never", JumpHoldsCombatNotLoot);
+ r.Add("jump loot: portal space and a death drop the combat hold (no landing is coming)", PortalAndDeathEndJumpHold);
+ r.Add("jump loot cadence: one move in flight at a time (the client's one inventory request), the next sent on the tick the answer shows", OneInFlightNextOnAnswerTick);
}
private static long _now;
@@ -43,45 +86,84 @@ internal static class LootJumpTests
private static void Clocked(Action body)
{
var old = RynthAiPlugin.CorpseClock;
+ var oldPace = ActionPacer.NowMs;
+ var oldUse = UseAudit.NowMs;
_now = 50_000_000;
+ UseAudit.ForgetItemAction();
+ UseAudit.NowMs = () => _now; // the item-action stamp (UseAudit.LastItemActionAt) on the same clock
RynthAiPlugin.CorpseClock = () => _now;
+ ActionPacer.NowMs = () => _now; // the loot jump's air hold (ActionPacer.LootJumpAirborne) on the same clock
+ ActionPacer.ForgetLootJump();
try { body(); }
- finally { RynthAiPlugin.CorpseClock = old; }
+ finally { RynthAiPlugin.CorpseClock = old; ActionPacer.NowMs = oldPace; UseAudit.NowMs = oldUse; ActionPacer.ForgetLootJump(); }
}
- private static void Gem(uint id)
+ private static RynthAiPlugin _bot = null!; // the bot LootUntilFirstMove made
+ private static RynthCoreHost _host; // and its host
+ private static T Field(string name) => (T)typeof(RynthAiPlugin).GetField(name, Any)!.GetValue(_bot)!;
+ private static void SetField(string name, object v) => typeof(RynthAiPlugin).GetField(name, Any)!.SetValue(_bot, v);
+
+ /// The character's height: up in the air, or back on the ground (ActionPacer's landing check reads it).
+ private static void Air(bool up) => FakeHost.PlayerPose = (Me0.Cell, Me0.X, Me0.Y, up ? Me0.Z + 1.0f : Me0.Z);
+
+ private static void Gem(uint id, uint container = CorpseA)
{
FakeHost.Names[id] = "Black Opal";
FakeHost.ItemTypes[id] = ItemTypeGem;
- FakeHost.Containers[id] = CorpseA;
+ FakeHost.Containers[id] = container;
FakeHost.Appraised.Add(id);
}
- private static void World(bool secondGem)
+ private static void Corpse(uint id, float dx)
+ {
+ FakeHost.Names[id] = "Corpse of Olthoi Swarm Drone";
+ FakeHost.ItemTypes[id] = ItemTypeContainer;
+ FakeHost.Strings[(id, LongDescKey)] = $"Killed by {Me}.";
+ FakeHost.NotAttackable.Add(id);
+ FakeHost.Positions[id] = (Me0.Cell, Me0.X + dx, Me0.Y, Me0.Z);
+ }
+
+ private static void World(bool secondGem, bool secondCorpse, bool serverGates, bool thirdGem = false, bool packStack = false)
{
FakeHost.Reset();
FakeHost.SalvageCalls = true; // UseObject + MoveItemExternal
FakeHost.WeaponCalls = true; // RequestId, HasAppraisalData
FakeHost.CloseContainerCalls = true; // CloseContainer + GetGroundContainerId
FakeHost.TapJumpCalls = true;
+ FakeHost.ServerGates = serverGates; // GetCastBusyState: the client's motion queue
+ FakeHost.LastUseDoneCalls = serverGates; // GetLastUseDone: the open's answer
+ FakeHost.WeenieErrorCalls = true; // GetLastWeenieError: "You're too busy"
FakeHost.Names[Player] = Me;
FakeHost.Positions[Player] = Me0;
FakeHost.PlayerPose = Me0;
- FakeHost.Names[CorpseA] = "Corpse of Olthoi Swarm Drone";
- FakeHost.ItemTypes[CorpseA] = ItemTypeContainer;
- FakeHost.Strings[(CorpseA, LongDescKey)] = $"Killed by {Me}.";
- FakeHost.NotAttackable.Add(CorpseA);
- FakeHost.Positions[CorpseA] = (Me0.Cell, Me0.X + 1.0f, Me0.Y, Me0.Z);
+ Corpse(CorpseA, 1.0f);
Gem(GemA);
if (secondGem) Gem(GemA2);
+ if (thirdGem) Gem(GemA3);
+ if (secondCorpse)
+ {
+ Corpse(CorpseB, 1.5f);
+ Gem(GemB, CorpseB);
+ }
+ if (packStack)
+ {
+ // GemA is a stack of 1, and the pack holds a same-name stack of 3 it can merge into.
+ FakeHost.Ints[(GemA, KeyMaxStack)] = 100;
+ FakeHost.Ints[(GemA, KeyStack)] = 1;
+ Gem(PackStack, Player);
+ FakeHost.Ints[(PackStack, KeyMaxStack)] = 100;
+ FakeHost.Ints[(PackStack, KeyStack)] = 3;
+ }
}
- /// Opens the corpse and ticks until the first pickup's move has gone out.
- private static void LootUntilFirstMove(bool jumpEnabled, bool secondGem, uint stamina)
+ /// Opens the corpse and ticks until the first pickup's move has gone out. Returns the tick.
+ private static Action LootUntilFirstMove(bool jumpEnabled, bool secondGem, uint stamina, bool secondCorpse = false, bool serverGates = false, bool thirdGem = false, bool packStack = false)
{
- World(secondGem);
+ World(secondGem, secondCorpse, serverGates, thirdGem, packStack);
var host = FakeHost.Create(Player);
+ _host = host;
var bot = new RynthAiPlugin();
+ _bot = bot;
var s = new LegacyUiSettings
{
IsMacroRunning = true, EnableLooting = true, EnableCombat = false, LootOwnership = 0,
@@ -113,17 +195,856 @@ internal static class LootJumpTests
Set("_activity", BotActivity.Looting);
typeof(RynthAiPlugin).GetMethod("TickCorpseOpening", Any)!.Invoke(bot, null);
}
- foreach (uint id in secondGem ? new[] { CorpseA, GemA, GemA2 } : new[] { CorpseA, GemA }) cache.OnCreateObject(id);
- cache.Tick();
+ var ids = new List { CorpseA, GemA };
+ if (secondGem) ids.Add(GemA2);
+ if (thirdGem) ids.Add(GemA3);
+ if (packStack) ids.Add(PackStack);
+ if (secondCorpse) { ids.Add(CorpseB); ids.Add(GemB); }
+ foreach (uint id in ids) cache.OnCreateObject(id);
+ for (int i = 0; i < 50; i++) cache.Tick();
Tick();
Check.True(FakeHost.Uses.Contains(CorpseA), "the corpse is opened");
FakeHost.UseDone(0);
FakeHost.GroundContainer = CorpseA;
bot.OnViewObjectContents(CorpseA);
+ _openedAt = _now;
for (int i = 0; i < 200 && FakeHost.ExternalMoves.Count == 0; i++) { _now += 20; Tick(); }
Check.True(FakeHost.ExternalMoves.Count > 0, "a gem's move is sent");
+ return Tick;
}
+ private const long TickMs = 20;
+
+ private static long _openedAt; // CorpseA's contents arrived (LootUntilFirstMove)
+
+ ///
+ /// The latest tick the next corpse's open may go out after the last item's confirm at
+ /// : at once, except that a corpse emptied sooner than the
+ /// Loot Empty Corpse floor (max(200 ms, LootEmptyCorpseMs) from its open, a user setting, not
+ /// a landing wait) is completed only then; a tick or two of slack.
+ ///
+ private static long NextOpenDue(long confirmed) => Math.Max(confirmed, _openedAt + 200) + 3 * TickMs;
+
+ private static bool Confirmed(uint id) => FakeHost.Logs.Any(l => l.Contains($"pickup confirmed for 0x{id:X8}"));
+
+ /// Ticks (TickMs each) until or has passed.
+ private static void TickUntil(Action tick, Func done, long maxMs)
+ {
+ long end = _now + maxMs;
+ while (_now < end && !done()) { _now += TickMs; tick(); }
+ }
+
+ private static void TickFor(Action tick, long ms)
+ {
+ long end = _now + ms;
+ while (_now < end) { _now += TickMs; tick(); }
+ }
+
+ // ACE with allow_jump_loot (Player_Inventory.GetPickupMotion): the move reaches the server while
+ // the character is in the air, the pickup motion is Invalid, so the item moves at once (about the
+ // round trip) and EnqueuePickupDone has no Return to play (IsBusy clears at once). What the
+ // client's motion queue (GetCastBusyState) reads in the air is not known, so both readings are
+ // run: busy (the jump's own motion for the whole flight) and idle.
+ private static void NoReturnNextCorpseInAir() => Clocked(() =>
+ {
+ foreach (int airQueue in new[] { 1, 0 })
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, secondCorpse: true, serverGates: true);
+ Check.Eq(FakeHost.ExternalMoves[0].Id, GemA, $"[air queue {airQueue}] corpse A's gem goes first");
+ long sent = _now;
+ FakeHost.CastBusy = airQueue;
+ TickFor(tick, 100);
+ FakeHost.Containers[GemA] = Player; // the answer, no bend-down
+ TickUntil(tick, () => Confirmed(GemA), 1000);
+ Check.True(Confirmed(GemA), $"[air queue {airQueue}] the pickup is confirmed");
+ long confirmed = _now;
+ TickUntil(tick, () => FakeHost.Uses.Contains(CorpseB), 1500);
+ Check.True(FakeHost.Uses.Contains(CorpseB), $"[air queue {airQueue}] the next corpse is opened");
+ Check.True(_now <= NextOpenDue(confirmed),
+ $"[air queue {airQueue}] the next corpse is opened at the confirm, not after a landing / Return wait: {_now - confirmed} ms after the confirm, {_now - sent} ms after the send");
+ }
+ });
+
+ // The second item goes out at once, still in the air, with no second jump (an air jump costs
+ // stamina on ACE and does nothing for the pickup); once the character has landed, the next one
+ // jumps again.
+ private static void NoReturnNextItemJumps() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: true, stamina: 100u, serverGates: true, thirdGem: true);
+ uint first = FakeHost.ExternalMoves[0].Id;
+ Check.Eq(FakeHost.TapJumps, 1, "the first pickup jumps");
+ Air(up: true);
+ FakeHost.CastBusy = 1; // the jump's motion plays
+ TickFor(tick, 100);
+ FakeHost.Containers[first] = Player; // the answer, no bend-down
+ TickUntil(tick, () => Confirmed(first), 1000);
+ Check.True(Confirmed(first), "the first pickup is confirmed");
+ long confirmed = _now;
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 2, 1500);
+ Check.Eq(FakeHost.ExternalMoves.Count, 2, "the second move is sent");
+ uint second = FakeHost.ExternalMoves[1].Id;
+ Check.True(_now - confirmed <= 3 * TickMs, $"at the confirm, not after the landing: {_now - confirmed} ms");
+ Check.Eq(FakeHost.TapJumps, 1, "no jump in the air: " + Order());
+ Check.False(FakeHost.Logs.Any(l => l.Contains("queuing 0x")), "not queued behind a Return that ACE never plays for it");
+
+ // The second, sent in the air, answered with no bend-down; the character has landed by now.
+ Air(up: false);
+ TickFor(tick, ActionPacer.JumpLandMinMs);
+ FakeHost.Containers[second] = Player;
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 3, 1500);
+ Check.Eq(FakeHost.ExternalMoves.Count, 3, "the third move is sent");
+ int at = FakeHost.Order.IndexOf($"move:{FakeHost.ExternalMoves[2].Id:X8}");
+ Check.True(at > 0 && FakeHost.Order[at - 1] == "tapjump", "landed: the third jumps again: " + Order());
+ Check.Eq(FakeHost.TapJumps, 2, "two jumps in all");
+ });
+
+ // The jump went out, but the answer took a bend-down's time (the server turned the character
+ // first and it landed, so ACE played the pickup motion and its Return): that Return is waited out.
+ private static void SlowAnswerKeepsReturnWait() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, secondCorpse: true, serverGates: true);
+ FakeHost.CastBusy = 1;
+ TickFor(tick, 800);
+ FakeHost.Containers[GemA] = Player; // answered after the bend-down; the Return plays
+ TickUntil(tick, () => Confirmed(GemA), 1000);
+ Check.True(Confirmed(GemA), "the pickup is confirmed");
+ TickFor(tick, 600);
+ Check.False(FakeHost.Uses.Contains(CorpseB), "no next open while the Return plays");
+ FakeHost.CastBusy = 0;
+ TickUntil(tick, () => FakeHost.Uses.Contains(CorpseB), 1000);
+ Check.True(FakeHost.Uses.Contains(CorpseB), "the next corpse is opened once the character stands still");
+ });
+
+ // First pickup in the air with no bend-down; the second, sent at once, is answered only after a
+ // bend-down (the character had landed), so its Return plays: the third is queued behind that
+ // Return (ACE NextPickup) and gets no jump, which would disturb the queue - the first jump's
+ // flight window no longer counts.
+ private static void SlowAnswerEndsAirWindow() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: true, stamina: 100u, serverGates: true, thirdGem: true);
+ uint first = FakeHost.ExternalMoves[0].Id;
+ FakeHost.CastBusy = 1;
+ TickFor(tick, 100);
+ FakeHost.Containers[first] = Player; // no bend-down
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 2, 1000);
+ Check.Eq(FakeHost.ExternalMoves.Count, 2, "the second move goes out at the first's confirm");
+ uint second = FakeHost.ExternalMoves[1].Id;
+ long secondSent = _now;
+ TickFor(tick, 700);
+ FakeHost.Containers[second] = Player; // answered after a bend-down: its Return plays
+ TickUntil(tick, () => Confirmed(second), 1000);
+ Check.True(Confirmed(second), "the second pickup is confirmed");
+ Check.True(_now - secondSent < 1500 - 100, $"(still inside the first jump's flight window: {_now - secondSent} ms after the second send)");
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 3, 300);
+ Check.Eq(FakeHost.ExternalMoves.Count, 3, "the third move goes out during the Return");
+ uint third = FakeHost.ExternalMoves[2].Id;
+ int at = FakeHost.Order.IndexOf($"move:{third:X8}");
+ Check.True(at > 0 && FakeHost.Order[at - 1] != "tapjump", "with no jump into the Return: " + Order());
+ Check.True(FakeHost.Logs.Any(l => l.Contains($"queuing 0x{third:X8}")), "queued behind the second's Return");
+ });
+
+ // -- The PickupAnswerMinMs floor --
+ // The floor is ACE's pickup motion time. A jump send has no motion: its server-only answer
+ // (the item in a pack, a pack stack grown, the object gone from the client) is believed on
+ // arrival. Every other send, and a jump send's weak sign (an unowned stack the client still has),
+ // keep the floor.
+
+ private const long AnswerAtMs = 150;
+
+ /// The ms from to the tick the pickup of is confirmed (-1: never, in 1.5 s).
+ private static long ConfirmAfter(Action tick, uint id, long sent)
+ {
+ TickUntil(tick, () => Confirmed(id), 1500);
+ return Confirmed(id) ? _now - sent : -1;
+ }
+
+ private static void JumpAnswerConfirmedOnArrival() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, secondCorpse: true, serverGates: true);
+ long sent = _now;
+ TickFor(tick, AnswerAtMs - TickMs);
+ FakeHost.Containers[GemA] = Player; // ACE's answer, no bend-down
+ long confirmedAfter = ConfirmAfter(tick, GemA, sent);
+ Check.True(confirmedAfter >= 0 && confirmedAfter <= AnswerAtMs + TickMs,
+ $"confirmed on the tick the answer shows ({AnswerAtMs} ms), not at PickupAnswerMinMs: {confirmedAfter} ms after the send");
+ long confirmed = _now;
+ TickUntil(tick, () => FakeHost.Uses.Contains(CorpseB), 1000);
+ Check.True(FakeHost.Uses.Contains(CorpseB) && _now <= NextOpenDue(confirmed),
+ $"the next corpse is opened then too (or at the empty-corpse floor, 200 ms from the open): {_now - sent} ms after the send, {_now - _openedAt} ms after the open");
+ Check.True(FakeHost.Logs.Any(l => l.Contains("no bend-down or Return to wait for")), "classed as a pickup with no bend-down");
+ });
+
+ private static void JumpMergeKeepsAnswerFloor() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, serverGates: true, packStack: true);
+ Check.Eq(FakeHost.ExternalMoves[0].Id, GemA, "the corpse gem goes");
+ long sent = _now;
+ TickFor(tick, AnswerAtMs - TickMs);
+ // ACE StackableMerge: the corpse item is removed (gone from the client) and the pack stack grows.
+ FakeHost.Containers.Remove(GemA);
+ FakeHost.Names.Remove(GemA);
+ FakeHost.Positions.Remove(GemA);
+ FakeHost.Ints[(PackStack, KeyStack)] = 4;
+ // The client's one-request slot is emptied only by an answer about that same object, and a
+ // merged-away object is gone (RynthCore ClientActionGates): the slot can stay held, and a move
+ // sent now would be dropped by the client. The floor is kept.
+ long confirmedAfter = ConfirmAfter(tick, GemA, sent);
+ Check.True(confirmedAfter >= RynthAiPlugin.PickupAnswerMinMs, $"a merge keeps the floor: confirmed {confirmedAfter} ms after the send");
+ // (By the floor the gem is gone from the client, which names no stack: either merge wording.)
+ Check.True(FakeHost.Logs.Any(l => l.Contains("pickup confirmed") && l.Contains("merged into")), "as a merge into the pack stack: "
+ + (FakeHost.Logs.LastOrDefault(l => l.Contains("pickup confirmed")) ?? "(none)"));
+ });
+
+ // The no-bend-down window after a pickup is anchored to the JUMP (it ends JumpLandMaxMs after
+ // it), not to the send that confirmed: a second send that rode the first jump, in the air, must
+ // not stretch it.
+ private static void AirWindowAnchoredToTheInAirJump() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: true, stamina: 100u, serverGates: true);
+ long jumpAt = _now;
+ uint first = FakeHost.ExternalMoves[0].Id;
+ Air(up: true);
+ TickFor(tick, 100);
+ FakeHost.Containers[first] = Player; // no bend-down
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 2, 500);
+ Check.Eq(FakeHost.ExternalMoves.Count, 2, "the second goes out in the air");
+ Check.Eq(FakeHost.TapJumps, 1, "riding the first jump");
+ uint second = FakeHost.ExternalMoves[1].Id;
+ long secondAt = _now;
+ TickFor(tick, 100);
+ FakeHost.Containers[second] = Player; // no bend-down
+ TickUntil(tick, () => Confirmed(second), 500);
+ Check.True(Confirmed(second), "the second is confirmed");
+ Check.True(FakeHost.Logs.Count(l => l.Contains("no bend-down or Return to wait for")) == 2, "both as no-bend-down pickups");
+ long until = Field("_jumpPickupAirUntil");
+ Check.True(Math.Abs(until - (jumpAt + ActionPacer.JumpLandMaxMs)) <= TickMs,
+ $"the window ends JumpLandMaxMs after the jump: {until - jumpAt} ms from it (the second send was {secondAt - jumpAt} ms in)");
+ });
+
+ private const string SlotChat = "You can only move or use one item at a time";
+
+ // The client's one request slot is held: it prints its refusal locally and sends nothing, so the
+ // server never answers. The send is repeated 250 ms after, without using one of the 3 tries and
+ // without waiting PickupAnswerWaitMs (4-8 s).
+ private static void SlotRefusedResentQuickly() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, serverGates: true);
+ long sent = _now;
+ Check.Eq(FakeHost.ExternalMoves.Count, 1, "one move out");
+ Check.Eq(Field("_currentLootItemMoveAttempts"), 1, "the first try");
+ TickFor(tick, 2 * TickMs);
+ _bot.NoteSlotRefusalChat(SlotChat); // the client's local refusal
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 2, 1000);
+ Check.Eq(FakeHost.ExternalMoves.Count, 2, "sent again");
+ long resentAfter = _now - sent;
+ Check.True(resentAfter >= RynthAiPlugin.SlotRefusalRetryMs - TickMs && resentAfter <= RynthAiPlugin.SlotRefusalRetryMs + 3 * TickMs,
+ $"about {RynthAiPlugin.SlotRefusalRetryMs} ms after the refused send: {resentAfter} ms");
+ Check.Eq(FakeHost.ExternalMoves[1].Id, GemA, "the same item");
+ Check.Eq(Field("_currentLootItemMoveAttempts"), 1, "still the first try");
+ Check.Eq(Field("_currentLootItemFreeRetries"), 0, "and not a too-busy free retry either");
+ Check.True(FakeHost.Logs.Any(l => l.Contains("request slot refused the move of 0x" + GemA.ToString("X8"))), "logged for the live logs");
+ Check.False(FakeHost.Logs.Any(l => l.Contains("retrying use")), "not the ordinary retry");
+ // Refused again: the same, still no try used.
+ TickFor(tick, 2 * TickMs);
+ _bot.NoteSlotRefusalChat(SlotChat);
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 3, 1000);
+ Check.Eq(FakeHost.ExternalMoves.Count, 3, "and again");
+ Check.Eq(Field("_currentLootItemMoveAttempts"), 1, "still the first try");
+ // The slot is free now and the server answers.
+ TickFor(tick, 100);
+ FakeHost.Containers[GemA] = Player;
+ TickUntil(tick, () => Confirmed(GemA), 1000);
+ Check.True(Confirmed(GemA), "the pickup is confirmed");
+ });
+
+ // The refusal text of something else (a buff swap, a use) first seen long after our send is not ours,
+ // and a player's words are never the client's line.
+ private static void LateSlotRefusalIgnored() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, serverGates: true);
+ _bot.NoteSlotRefusalChat("Tarsh tells you, \"" + SlotChat + "\"");
+ Check.Eq(Field("_slotRefusalSeq"), 0, "a player's words never count");
+ TickFor(tick, RynthAiPlugin.SlotRefusalAttributionMs + 100);
+ _bot.NoteSlotRefusalChat(SlotChat);
+ TickFor(tick, 600);
+ Check.Eq(FakeHost.ExternalMoves.Count, 1, "no resend: the move is still awaiting its answer");
+ Check.False(FakeHost.Logs.Any(l => l.Contains("request slot refused")), "not logged as ours");
+ });
+
+ // A refusal line from something else lands 100 ms after our send (inside the attribution window,
+ // so it is taken for ours); the server answers at 200 ms, before the resend is due at 250 ms:
+ // one move only.
+ private static void ForeignRefusalThenAnswerSingleMove() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, serverGates: true);
+ TickFor(tick, 100);
+ _bot.NoteSlotRefusalChat(SlotChat);
+ TickFor(tick, 100);
+ FakeHost.Containers[GemA] = Player; // the server answer at ~200 ms
+ TickFor(tick, 600);
+ Check.True(Confirmed(GemA), "the pickup is confirmed");
+ Check.Eq(FakeHost.ExternalMoves.Count, 1, "a single move: the answer beat the resend");
+ });
+
+ private static void ResendInsideBudgetKeepsJump() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, serverGates: true);
+ Air(up: true);
+ Check.True(Field("_currentLootItemJumped"), "the first send rode the jump");
+ TickFor(tick, 2 * TickMs);
+ _bot.NoteSlotRefusalChat(SlotChat);
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 2, 1000);
+ Check.Eq(FakeHost.ExternalMoves.Count, 2, "sent again");
+ Check.True(Field("_currentLootItemJumped"), "250 ms in, inside the budget: the resend keeps the jump (a no-bend-down answer is still believed)");
+ Check.Eq(FakeHost.TapJumps, 1, "and takes no new jump");
+ });
+
+ private static void ResendPastBudgetDropsJump() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, serverGates: true);
+ Air(up: true);
+ SetField("_noMotionOffCorpse", new long[] { 700, 0, 0, 0 }); // a slow server: jumpAge + 700 is over the budget
+ SetField("_noMotionOffCorpseCount", 1);
+ TickFor(tick, 2 * TickMs);
+ _bot.NoteSlotRefusalChat(SlotChat);
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 2, 1000);
+ Check.Eq(FakeHost.ExternalMoves.Count, 2, "sent again");
+ Check.False(Field("_currentLootItemJumped"), "past the budget the resend goes plain (the floor applies)");
+ });
+
+ // The resends are time-based: the engine clears a request slot whose object is still present only
+ // after 10 s, so the item keeps being sent for SlotRefusalGiveUpMs from its first refusal.
+ // One refused send after another, each answered by a refusal line 40 ms after the send, for
+ // of fake time. Returns the number of resends made.
+ private static int RefuseForMs(Action tick, long ms)
+ {
+ long end = _now + ms;
+ int resends = 0;
+ while (_now < end)
+ {
+ int before = FakeHost.ExternalMoves.Count;
+ TickFor(tick, 2 * TickMs);
+ _bot.NoteSlotRefusalChat(SlotChat);
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count > before, 500);
+ if (FakeHost.ExternalMoves.Count == before) break;
+ resends++;
+ }
+ return resends;
+ }
+
+ private static void SlotResendsStillGoingAt9s() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, serverGates: true);
+ int resends = RefuseForMs(tick, 9000);
+ Check.True(resends >= 30, $"still resending after 9 s of refusals (a count cap of 30 would have stopped at 7.5 s): {resends} resends");
+ Check.False(Field("_currentLootItemSlotGaveUp"), "not given up");
+ Check.Eq(Field("_currentLootItemMoveAttempts"), 1, "and no try used");
+ Check.Eq(FakeHost.ExternalMoves.Count, resends + 1, "one move per resend: " + Order());
+ });
+
+ // After SlotRefusalGiveUpMs from the first refusal the ordinary answer wait takes over.
+ private static void SlotResendCapHandsOver() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, serverGates: true);
+ long start = _now;
+ int resends = RefuseForMs(tick, RynthAiPlugin.SlotRefusalGiveUpMs + 2000);
+ Check.True(Field("_currentLootItemSlotGaveUp"), $"given up after {_now - start} ms ({resends} resends)");
+ Check.True(_now - start >= RynthAiPlugin.SlotRefusalGiveUpMs, $"not before {RynthAiPlugin.SlotRefusalGiveUpMs} ms: {_now - start}");
+ Check.True(_now - start <= RynthAiPlugin.SlotRefusalGiveUpMs + 1000, $"and soon after it: {_now - start}");
+ int moves = FakeHost.ExternalMoves.Count;
+ TickFor(tick, 2 * TickMs);
+ _bot.NoteSlotRefusalChat(SlotChat);
+ TickFor(tick, 1000);
+ Check.Eq(FakeHost.ExternalMoves.Count, moves, "no resend after it: the ordinary answer wait (4 s or more) holds the item");
+ Check.Eq(Field("_currentLootItemMoveAttempts"), 1, "and no try was used");
+ Check.True(FakeHost.Logs.Any(l => l.Contains("the ordinary answer wait takes over")), "logged");
+ });
+
+ // A send made while the character's motion queue is busy is held by the engine's main-thread queue
+ // (up to 2.5 s): its refusal line can come long after 200 ms and is still its own.
+ private static void DeferredSendRefusalAt700IsResent() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: true, stamina: 100u, serverGates: true);
+ uint first = FakeHost.ExternalMoves[0].Id;
+ Air(up: true);
+ TickFor(tick, 100);
+ FakeHost.CastBusy = 1; // the jump's motion plays
+ FakeHost.Containers[first] = Player; // no bend-down: the next goes out in the air
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 2, 500);
+ Check.Eq(FakeHost.ExternalMoves.Count, 2, "the second move is out while the queue is busy");
+ Check.Eq(Field("_currentLootItemSlotWindowMs"), RynthAiPlugin.SlotRefusalDeferredWindowMs, "its refusal window is the deferred one");
+ TickFor(tick, 700);
+ _bot.NoteSlotRefusalChat(SlotChat);
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 3, 600);
+ Check.Eq(FakeHost.ExternalMoves.Count, 3, "a refusal 700 ms after the send is taken for its own and the item is sent again");
+ });
+
+ // Another item action of this plugin went out just before the line: it may be that one's refusal.
+ private static void ForeignItemActionSuppressesAttribution() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, serverGates: true);
+ TickFor(tick, 50);
+ _host.UseFor(0x80263199u, "Buff", "test: a buff item use"); // the UseAudit choke point notes it
+ TickFor(tick, 50);
+ _bot.NoteSlotRefusalChat(SlotChat); // 100 ms after the send
+ TickFor(tick, 600);
+ FakeHost.Containers[GemA] = Player; // the answer, 700 ms in
+ TickFor(tick, 100);
+ Check.True(Confirmed(GemA), "the pickup is confirmed");
+ Check.Eq(FakeHost.ExternalMoves.Count, 1, "one move: the line was not taken for ours");
+ Check.False(FakeHost.Logs.Any(l => l.Contains("request slot refused")), "not logged as ours");
+ });
+
+ // The no-bend-down window after a pickup is anchored to the JUMP (it ends JumpLandMaxMs after
+ // it), not to the send that confirmed: a resend 250 ms later must not stretch it.
+ private static void AirWindowAnchoredToTheJump() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, serverGates: true);
+ long jumpAt = _now;
+ Air(up: true);
+ TickFor(tick, 2 * TickMs);
+ _bot.NoteSlotRefusalChat(SlotChat);
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 2, 1000);
+ Check.Eq(FakeHost.ExternalMoves.Count, 2, "resent");
+ long resendAt = _now;
+ TickFor(tick, 100);
+ FakeHost.Containers[GemA] = Player; // no bend-down
+ TickUntil(tick, () => Confirmed(GemA), 500);
+ Check.True(Confirmed(GemA), "confirmed");
+ Check.True(FakeHost.Logs.Any(l => l.Contains("no bend-down or Return to wait for")), "as a no-bend-down pickup");
+ long until = Field("_jumpPickupAirUntil");
+ Check.True(Math.Abs(until - (jumpAt + ActionPacer.JumpLandMaxMs)) <= TickMs,
+ $"the window ends JumpLandMaxMs after the jump: {until - jumpAt} ms from it (resend was {resendAt - jumpAt} ms in)");
+ });
+
+ private static void ResetClearsSlotFields() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, serverGates: true);
+ TickFor(tick, 2 * TickMs);
+ _bot.NoteSlotRefusalChat(SlotChat);
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 2, 1000);
+ SetField("_flightHoldLogged", true);
+ Check.True(Field("_currentLootItemSlotResends") > 0, "a slot resend was made");
+ typeof(RynthAiPlugin).GetMethod("ResetCurrentLootItem", Any)!.Invoke(_bot, null);
+ Check.Eq(Field("_currentLootItemSlotResends"), 0, "resends cleared");
+ Check.Eq(Field("_currentLootItemSlotSeqAtSend"), 0, "baseline cleared");
+ Check.Eq(Field("_currentLootItemSlotRefusedAt"), 0L, "refusal time cleared");
+ Check.False(Field("_flightHoldLogged"), "hold-logged flag cleared");
+ });
+
+ // The net runs with Jump When Looting on only: with it off, a refusal line changes nothing and
+ // the send keeps its ordinary answer wait.
+ private static void SlotNetNeedsJumpLoot() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: false, secondGem: false, stamina: 100u, serverGates: true);
+ TickFor(tick, 2 * TickMs);
+ _bot.NoteSlotRefusalChat(SlotChat); // inside the attribution window
+ TickFor(tick, 1000);
+ Check.Eq(FakeHost.ExternalMoves.Count, 1, "no quick resend with jump-loot off");
+ Check.False(FakeHost.Logs.Any(l => l.Contains("request slot refused")), "not taken for a slot refusal");
+ });
+
+ // A UseOnFor (a kit, a mana stone, a lockpick) between a loot send and the refusal line is another
+ // item action of this plugin: the line may be its refusal, so it is not taken for the loot send's.
+ private static void UseOnForSuppressesAttribution() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, serverGates: true);
+ TickFor(tick, 40);
+ _host.UseOnFor(0x80263198u, Player, "Buff", "test: a kit on the player"); // UseAudit.UseOnFor notes it
+ TickFor(tick, 40);
+ _bot.NoteSlotRefusalChat(SlotChat); // 80 ms after the send
+ TickFor(tick, 600);
+ Check.Eq(FakeHost.ExternalMoves.Count, 1, "no resend: the line was not taken for ours");
+ Check.False(FakeHost.Logs.Any(l => l.Contains("request slot refused")), "not logged as ours");
+ });
+
+ // The looter's own UseOnFor ("Loot") is not another item action: it leaves LastItemActionAt as it
+ // was, so a refusal line after it is still taken for the loot send's and the item is resent.
+ private static void LootUseOnForIsNotStamped() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, serverGates: true);
+ TickFor(tick, 40);
+ long before = UseAudit.LastItemActionAt;
+ _host.UseOnFor(0x80263198u, Player, "Loot", "test: the looter's own use");
+ Check.Eq(UseAudit.LastItemActionAt, before, "a Loot UseOnFor leaves the stamp as it was");
+ TickFor(tick, 40);
+ _bot.NoteSlotRefusalChat(SlotChat); // 80 ms after the send
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 2, 600);
+ Check.Eq(FakeHost.ExternalMoves.Count, 2, "resent: the line was taken for ours");
+ Check.True(FakeHost.Logs.Any(l => l.Contains("request slot refused")), "logged as ours");
+ });
+
+ // A send made while the motion queue is busy has a 2500 ms refusal window, and the look back for
+ // another item action is that same window: an action 1 s before such a send keeps a line that
+ // arrives 700 ms after it from being taken for the send's (a 200 ms look back would miss it).
+ private static void ForeignActionLookbackUsesSendWindow() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: true, stamina: 100u, serverGates: true);
+ uint first = FakeHost.ExternalMoves[0].Id;
+ Air(up: true);
+ TickFor(tick, 100);
+ FakeHost.CastBusy = 1; // the jump's motion plays
+ FakeHost.Containers[first] = Player; // no bend-down: the next goes out in the air
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 2, 500);
+ Check.Eq(FakeHost.ExternalMoves.Count, 2, "the second move is out while the queue is busy");
+ Check.Eq(Field("_currentLootItemSlotWindowMs"), RynthAiPlugin.SlotRefusalDeferredWindowMs, "its window is the deferred one");
+ var clock = UseAudit.NowMs;
+ UseAudit.NowMs = () => _now - 1000; // another item action 1 s before this send
+ UseAudit.NoteItemAction();
+ UseAudit.NowMs = clock;
+ TickFor(tick, 700);
+ _bot.NoteSlotRefusalChat(SlotChat);
+ TickFor(tick, 600);
+ Check.Eq(FakeHost.ExternalMoves.Count, 2, "no resend: the earlier item action may own the line");
+ Check.False(FakeHost.Logs.Any(l => l.Contains("request slot refused")), "not logged as ours");
+ });
+
+ // A fight has the tick (HoldOpenCorpseForFight, reached through TickCorpseOpening with Combat
+ // given the tick): no resend then, since the client drops an item move while the character
+ // attacks. The refusal heard during the fight is attributed by its own arrival time, so after the
+ // fight the item goes again at once, without costing a try, and the fight flag of the refused send
+ // is not carried onto the fresh one.
+ private static void SlotRefusalWaitsOutAFight() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, serverGates: true);
+ void FightTick()
+ {
+ SetField("_activity", BotActivity.Combat);
+ typeof(RynthAiPlugin).GetMethod("TickCorpseOpening", Any)!.Invoke(_bot, null);
+ }
+ TickFor(tick, 2 * TickMs);
+ _bot.NoteSlotRefusalChat(SlotChat); // 40 ms after the send: ours
+ for (int i = 0; i < 25; i++) { _now += TickMs; FightTick(); } // 500 ms of fight
+ Check.True(FakeHost.Logs.Any(l => l.Contains("waits for the fight")), "the corpse is held for the fight");
+ Check.Eq(FakeHost.ExternalMoves.Count, 1, "no resend while a fight has the tick");
+ long fightEnd = _now;
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 2, 500);
+ Check.Eq(FakeHost.ExternalMoves.Count, 2, "after the fight the refused move goes again");
+ Check.True(_now - fightEnd <= 2 * TickMs, $"at once: {_now - fightEnd} ms after the fight");
+ Check.Eq(Field("_currentLootItemMoveAttempts"), 1, "not one of the 3 tries");
+ Check.False(Field("_currentLootItemFightHeld"), "the fresh send carries no fight flag");
+ });
+
+ // The flight budget (RynthAiPlugin.LootJumpFlightBudgetMs): a send in the air with no fresh jump is
+ // predicted by jumpAge + the recent no-bend-down answer time.
+ private static void FlightBudgetLetsEarlySendThrough() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: true, stamina: 100u, serverGates: true, thirdGem: true);
+ uint first = FakeHost.ExternalMoves[0].Id;
+ Air(up: true);
+ TickFor(tick, 100);
+ FakeHost.Containers[first] = Player; // answered 100 ms in, no bend-down
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 2, 500);
+ Check.Eq(FakeHost.ExternalMoves.Count, 2, "the next send goes out at the confirm: " + Order());
+ Check.Eq(FakeHost.TapJumps, 1, "in the air, with no new jump");
+ Check.False(FakeHost.Logs.Any(l => l.Contains("holding 0x")), "no hold logged");
+ });
+
+ private static void FlightBudgetHoldsLateSend() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: true, stamina: 100u, serverGates: true, thirdGem: true);
+ uint first = FakeHost.ExternalMoves[0].Id;
+ Air(up: true);
+ TickFor(tick, 460);
+ FakeHost.Containers[first] = Player; // answered ~480 ms in, still no bend-down (under the 500 ms mark)
+ TickUntil(tick, () => Confirmed(first), 300);
+ Check.True(Confirmed(first), "the first is confirmed");
+ Check.True(FakeHost.Logs.Any(l => l.Contains("no bend-down or Return to wait for")), "as a no-bend-down pickup");
+ // jumpAge ~500 plus an answer that took ~480 ms is over the budget: the next one waits for the landing.
+ TickFor(tick, 400);
+ Check.Eq(FakeHost.ExternalMoves.Count, 1, "no send into the rest of the flight: " + Order());
+ Check.Eq(FakeHost.TapJumps, 1, "no jump yet");
+ Check.Eq(FakeHost.Logs.Count(l => l.Contains("holding 0x")), 1, "the hold is logged once");
+ string hold = FakeHost.Logs.FirstOrDefault(l => l.Contains("holding 0x")) ?? "(none)";
+ Check.True(hold.Contains("ms into the flight") && hold.Contains("takes about 4"), "naming jumpAge and expectedAnswerMs: " + hold);
+ Air(up: false); // landed
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 2, 1500);
+ Check.Eq(FakeHost.ExternalMoves.Count, 2, "after the landing the next goes");
+ int at = FakeHost.Order.IndexOf($"move:{FakeHost.ExternalMoves[1].Id:X8}");
+ Check.True(at > 0 && FakeHost.Order[at - 1] == "tapjump", "with a fresh jump: " + Order());
+ Check.Eq(FakeHost.TapJumps, 2, "two jumps in all");
+ });
+
+ // Only "You're too busy" (0x1D) proves the no-bend-down call wrong. A save-failed with
+ // no code (a full pack, or anything else) that comes fast is not that evidence.
+ private static void NonBusyRefusalKeepsNoMotion() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: true, stamina: 100u, serverGates: true);
+ uint first = FakeHost.ExternalMoves[0].Id;
+ TickFor(tick, 100 - TickMs);
+ FakeHost.Containers[first] = Player; // no bend-down: the window opens
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 2, 1000);
+ Check.True(Field("_jumpPickupAirUntil") > _now, "the window is open");
+ uint second = FakeHost.ExternalMoves[1].Id;
+ Check.True(Field("_currentLootItemSentInAirWindow"), "the second went out in it");
+ TickFor(tick, 100);
+ FakeHost.WeenieError(0, 0x00A0, second); // InventoryServerSaveFailed, no code, 100 ms after the send
+ TickFor(tick, 3 * TickMs);
+ Check.False(FakeHost.Logs.Any(l => l.Contains("the server played a bend-down after all")), "no distrust line");
+ Check.Eq(Field("_jumpNoMotionOffUntil"), 0L, "the call stays on");
+ });
+
+ private static void NoJumpKeepsAnswerFloor() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: false, secondGem: false, stamina: 100u, serverGates: true);
+ Check.Eq(FakeHost.TapJumps, 0, "no jump went out");
+ long sent = _now;
+ TickFor(tick, AnswerAtMs - TickMs);
+ FakeHost.Containers[GemA] = Player;
+ long confirmedAfter = ConfirmAfter(tick, GemA, sent);
+ Check.True(confirmedAfter >= RynthAiPlugin.PickupAnswerMinMs,
+ $"not believed before PickupAnswerMinMs ({RynthAiPlugin.PickupAnswerMinMs} ms): confirmed {confirmedAfter} ms after the send");
+ });
+
+ // -- What JumpPickupHadNoMotion must not take for a no-bend-down pickup --
+
+ ///
+ /// After the last item's confirm: the next corpse is not opened while the Return plays
+ /// (CastBusy 1 for ), and is opened once it ends.
+ ///
+ private static void NextOpenWaitsReturn(Action tick, uint item, long returnMs, string what)
+ {
+ TickUntil(tick, () => Confirmed(item), 1500);
+ Check.True(Confirmed(item), what + ": the pickup is confirmed");
+ TickFor(tick, returnMs);
+ Check.False(FakeHost.Uses.Contains(CorpseB), what + ": no next open while the Return plays");
+ FakeHost.CastBusy = 0;
+ TickUntil(tick, () => FakeHost.Uses.Contains(CorpseB), 1500);
+ Check.True(FakeHost.Uses.Contains(CorpseB), what + ": the next corpse is opened once the character stands still");
+ }
+
+ private static void NoJumpFastAnswerWaitsReturn() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: false, secondGem: false, stamina: 100u, secondCorpse: true, serverGates: true);
+ TickFor(tick, 100 - TickMs);
+ FakeHost.Containers[GemA] = Player;
+ FakeHost.CastBusy = 1; // its Return
+ NextOpenWaitsReturn(tick, GemA, 300, "no jump");
+ });
+
+ private static void ResentFastAnswerWaitsReturn() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, secondCorpse: true, serverGates: true);
+ Check.Eq(FakeHost.TapJumps, 1, "the first send jumps");
+ TickFor(tick, 40);
+ FakeHost.WeenieError(0x1D); // YoureTooBusy
+ FakeHost.WeenieError(0, 0x00A0, GemA); // InventoryServerSaveFailed(item)
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 2, 1000);
+ Check.Eq(FakeHost.ExternalMoves.Count, 2, "resent");
+ Check.Eq(FakeHost.TapJumps, 1, "the resend goes without a jump");
+ TickFor(tick, 100 - TickMs);
+ FakeHost.Containers[GemA] = Player;
+ FakeHost.CastBusy = 1;
+ NextOpenWaitsReturn(tick, GemA, 300, "resent");
+ });
+
+ // On a fast server a real bend-down can be 0.25-0.4 s, inside PickupAnswerMinMs.
+ // A move sent on the no-bend-down call and refused 'too busy' proves the call wrong: it is off.
+ private static void BusyRefusalTurnsNoMotionOff() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: true, stamina: 100u, secondCorpse: true, serverGates: true, thirdGem: true);
+ uint first = FakeHost.ExternalMoves[0].Id;
+ FakeHost.CastBusy = 1; // a fast real bend-down, then its Return
+ TickFor(tick, 300 - TickMs);
+ FakeHost.Containers[first] = Player; // answered at 300 ms: taken for no bend-down
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 2, 1000);
+ Check.True(FakeHost.Logs.Any(l => l.Contains("no bend-down or Return to wait for")), "the first is (wrongly) called no bend-down");
+ uint second = FakeHost.ExternalMoves[1].Id;
+ TickFor(tick, 40);
+ FakeHost.WeenieError(0x1D); // the Return is playing: too busy
+ FakeHost.WeenieError(0, 0x00A0, second);
+ TickFor(tick, 2 * TickMs);
+ Check.True(FakeHost.Logs.Any(l => l.Contains("the server played a bend-down after all")), "the call is turned off");
+ Check.Eq(Field("_jumpPickupAirUntil"), 0L, "and the window ended");
+
+ TickFor(tick, 400);
+ FakeHost.CastBusy = 0; // the Return ends: the refused move goes again
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 3, 1000);
+ Check.Eq(FakeHost.ExternalMoves[2].Id, second, "the refused move is resent");
+ TickFor(tick, 150);
+ FakeHost.Containers[second] = Player;
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 4, 1500);
+ Check.Eq(FakeHost.ExternalMoves.Count, 4, "the third goes");
+ uint third = FakeHost.ExternalMoves[3].Id;
+ int at = FakeHost.Order.IndexOf($"move:{third:X8}");
+ Check.True(at > 0 && FakeHost.Order[at - 1] == "tapjump", "with a jump (landed by now): " + Order());
+
+ // Answered at 300 ms again: with the call off it waits its Return.
+ FakeHost.CastBusy = 1;
+ TickFor(tick, 300 - TickMs);
+ FakeHost.Containers[third] = Player;
+ NextOpenWaitsReturn(tick, third, 300, "after the call was turned off");
+ });
+
+ private static void BusyOpenTurnsNoMotionOff() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, secondCorpse: true, serverGates: true);
+ TickFor(tick, 300 - TickMs);
+ FakeHost.Containers[GemA] = Player; // taken for no bend-down
+ TickUntil(tick, () => FakeHost.Uses.Contains(CorpseB), 1000);
+ Check.True(FakeHost.Uses.Contains(CorpseB), "the next corpse is opened on the call");
+ Check.True(Field("_openInAirWindowSeq") >= 0, "its answer is watched");
+ FakeHost.UseDone(0x1D); // too busy: the Return was playing
+ TickFor(tick, 2 * TickMs);
+ Check.True(FakeHost.Logs.Any(l => l.Contains("the next corpse's open, sent on it, was refused as too busy")), "the call is turned off");
+ Check.True(Field("_jumpNoMotionOffUntil") > _now, "for a while");
+ });
+
+ // The fastest cadence there is. The acclient holds ONE pending inventory request and refuses
+ // every other move until the server's answer about that object ("You can only move or use one
+ // item at a time", RynthCore ClientActionGates), and on a FastTick character ACE cancels a pickup
+ // whose turn is still pending when the next one arrives (Player_Move2.CreateMoveToChain2 ->
+ // CheckMoveToParams -> ActionCancelled). So never two at once: the next goes on the very tick
+ // the last one's answer shows, with no tick lost in between.
+ private static void OneInFlightNextOnAnswerTick() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: true, stamina: 100u, serverGates: true, thirdGem: true);
+ Air(up: true);
+ var answered = new HashSet();
+ int maxInFlight = 1;
+ for (int k = 0; k < 3; k++)
+ {
+ Check.Eq(FakeHost.ExternalMoves.Count, k + 1, $"move {k + 1} is out");
+ uint id = FakeHost.ExternalMoves[k].Id;
+ for (int i = 0; i < 4; i++)
+ {
+ _now += TickMs; tick();
+ maxInFlight = Math.Max(maxInFlight, FakeHost.ExternalMoves.Count - answered.Count);
+ }
+ Check.Eq(FakeHost.ExternalMoves.Count, k + 1, $"nothing more while move {k + 1} is unanswered");
+ FakeHost.Containers[id] = Player; // the answer arrives
+ answered.Add(id);
+ _now += TickMs; tick(); // the one tick that sees it
+ Check.True(Confirmed(id), $"move {k + 1} confirmed on the tick its answer shows");
+ if (k < 2)
+ Check.Eq(FakeHost.ExternalMoves.Count, k + 2, $"and move {k + 2} goes on that same tick");
+ }
+ Check.Eq(maxInFlight, 1, "never two moves in flight");
+ });
+
+ // Dropping the corpse claim ends the no-bend-down window and the open watch.
+ private static void ResetEndsAirWindow() => Clocked(() =>
+ {
+ LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, serverGates: true);
+ SetField("_jumpPickupAirUntil", _now + 1000);
+ SetField("_openInAirWindowSeq", 3);
+ typeof(RynthAiPlugin).GetMethod("ResetCorpseTarget", Any)!.Invoke(_bot, null);
+ Check.Eq(Field("_jumpPickupAirUntil"), 0L, "the window is gone");
+ Check.Eq(Field("_openInAirWindowSeq"), -1, "and the open watch");
+ });
+
+ // A pickup sent while the character is still in the air from the last loot jump takes no second
+ // jump: the move arrives in the air anyway, and ACE HandleActionJump has no ground check, so an
+ // air jump only costs stamina. Once the character has landed, the next pickup jumps again.
+ private static void NoSecondJumpInTheAir() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: true, stamina: 100u, serverGates: true, thirdGem: true);
+ long jumpAt = _now;
+ uint first = FakeHost.ExternalMoves[0].Id;
+ Check.Eq(FakeHost.TapJumps, 1, "the first pickup jumps");
+ Air(up: true); // and stays up: no landing is seen
+ TickFor(tick, 100);
+ FakeHost.Containers[first] = Player; // the answer
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 2, ActionPacer.JumpLandMaxMs);
+ Check.Eq(FakeHost.ExternalMoves.Count, 2, "the second move is sent");
+ Check.True(_now - jumpAt < ActionPacer.JumpLandMaxMs, $"(inside the first jump's flight: {_now - jumpAt} ms after it)");
+ Check.True(ActionPacer.LootJumpAirborne(_host, out _), "(still in the air at the second send)");
+ Check.Eq(FakeHost.TapJumps, 1, "no second jump in the air: " + Order());
+
+ uint second = FakeHost.ExternalMoves[1].Id;
+ Air(up: false); // landed
+ TickFor(tick, ActionPacer.JumpLandMinMs); // the landing check looks from JumpLandMinMs on
+ FakeHost.Containers[second] = Player;
+ TickUntil(tick, () => FakeHost.ExternalMoves.Count >= 3, 3000);
+ Check.Eq(FakeHost.ExternalMoves.Count, 3, "the third move is sent");
+ int at = FakeHost.Order.IndexOf($"move:{FakeHost.ExternalMoves[2].Id:X8}");
+ Check.True(at > 0 && FakeHost.Order[at - 1] == "tapjump", "landed: the third jumps again: " + Order());
+ Check.Eq(FakeHost.TapJumps, 2, "two jumps in all");
+ });
+
+ // The loot half: the pickup's jump is what holds combat and buffs (ActionPacer); loot is not held.
+ // CombatHookTests has the combat half (Think sends no attack while it holds).
+ private static void JumpHoldsCombatNotLoot() => Clocked(() =>
+ {
+ bool pacer = ActionPacer.Enabled;
+ try
+ {
+ LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, serverGates: true);
+ Check.Eq(FakeHost.TapJumps, 1, "the pickup jumped");
+ Check.True(ActionPacer.LootJumpAirborne(_host, out _), "and the loot code noted the jump for combat and buffs");
+ // The pacer from here on, on this clock, with nothing of other tests' left in it
+ // (CorpseCloseTests.PacerOn): only the jump can hold anything.
+ ActionPacer.Reset(); ActionPacer.Enabled = true;
+ MoveAudit.Reset(); MoveAudit.NowMs = () => _now;
+ UseAudit.NowMs = () => _now;
+ ActionPacer.NoteLootJump(_host); // (Reset dropped the pickup's; the same jump, noted again)
+ var host = _host;
+ Air(up: true);
+ Check.True(ActionPacer.LootJumpAirborne(host, out string why), "in the air after the pickup's jump: " + why);
+ Check.False(ActionPacer.MayStart(host, "Buff", HealNeed.None, out _), "a buff or heal waits");
+ Check.False(ActionPacer.MayStart(host, "Buff", HealNeed.Emergency, out _), "an emergency heal too (ACE refuses it in the air)");
+ Check.True(ActionPacer.MayStart(host, "Loot", HealNeed.None, out _), "loot does not");
+ _now += ActionPacer.JumpLandMinMs;
+ Check.True(ActionPacer.LootJumpAirborne(host, out _), "still up at the height check");
+ Air(up: false);
+ Check.False(ActionPacer.LootJumpAirborne(host, out _), "landed: the hold ends");
+ Check.True(ActionPacer.MayStart(host, "Buff", HealNeed.None, out _), "the buff goes");
+
+ // The cap: a landing never seen still ends the hold at JumpLandMaxMs.
+ ActionPacer.NoteLootJump(host);
+ Air(up: true);
+ _now += ActionPacer.JumpLandMaxMs - 1;
+ Check.True(ActionPacer.LootJumpAirborne(host, out _), "up, under the cap");
+ _now += 1;
+ Check.False(ActionPacer.LootJumpAirborne(host, out _), "the cap ends it");
+ }
+ finally
+ {
+ ActionPacer.Enabled = pacer; ActionPacer.Reset();
+ MoveAudit.Reset(); MoveAudit.NowMs = () => Environment.TickCount64;
+ UseAudit.NowMs = () => Environment.TickCount64;
+ }
+ });
+
+ // The plugin's portal-space and death paths drop the hold: no landing is coming to end it.
+ private static void PortalAndDeathEndJumpHold() => Clocked(() =>
+ {
+ var oldVitals = FakeHost.Vitals;
+ try
+ {
+ LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, serverGates: true);
+ var host = _host;
+ const System.Reflection.BindingFlags Inst = System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic;
+
+ Air(up: true);
+ Check.True(ActionPacer.LootJumpAirborne(host, out _), "the pickup's jump holds combat");
+ FakeHost.Portaling = true;
+ typeof(RynthAiPlugin).GetMethod("NotePortalForPacer", Inst)!.Invoke(_bot, null);
+ Check.False(ActionPacer.LootJumpAirborne(host, out _), "portal space ends the hold");
+ FakeHost.Portaling = false;
+ typeof(RynthAiPlugin).GetMethod("NotePortalForPacer", Inst)!.Invoke(_bot, null);
+
+ ActionPacer.NoteLootJump(host);
+ Check.True(ActionPacer.LootJumpAirborne(host, out _), "a second jump holds again");
+ FakeHost.Vitals = (0, 100, 0, 100, 0, 100);
+ typeof(RynthAiPlugin).GetMethod("HoldForDeath", Inst)!.Invoke(_bot, null);
+ Check.False(ActionPacer.LootJumpAirborne(host, out _), "the death ends the hold");
+ }
+ finally { FakeHost.Vitals = oldVitals; FakeHost.Portaling = false; Air(up: false); }
+ });
+
+ private static void JumpWeakSignKeepsAnswerFloor() => Clocked(() =>
+ {
+ var tick = LootUntilFirstMove(jumpEnabled: true, secondGem: false, stamina: 100u, serverGates: true, packStack: true);
+ Check.Eq(FakeHost.TapJumps, 1, "the jump went out");
+ long sent = _now;
+ TickFor(tick, AnswerAtMs - TickMs);
+ FakeHost.Containers[GemA] = 0; // an unowned stack; the pack stack has not grown
+ long confirmedAfter = ConfirmAfter(tick, GemA, sent);
+ Check.True(confirmedAfter >= RynthAiPlugin.PickupAnswerMinMs,
+ $"a weak sign keeps the floor ({RynthAiPlugin.PickupAnswerMinMs} ms): confirmed {confirmedAfter} ms after the send");
+ });
+
private static string Order() => string.Join(",", FakeHost.Order);
private static void TwoItemJumpsBeforeMove() => Clocked(() =>
diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/OwnCorpseTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/OwnCorpseTests.cs
index eb131b9..ae6d860 100644
--- a/Tools/RynthCore.RynthAiHostTests/Tests/OwnCorpseTests.cs
+++ b/Tools/RynthCore.RynthAiHostTests/Tests/OwnCorpseTests.cs
@@ -36,6 +36,7 @@ internal static class OwnCorpseTests
{
r.Add("own corpse: recognised by exact name + 'Killed by' line, never a namesake or another player's", Identification);
r.Add("own corpse: every item is taken, the loot profile and Loot From ignored, then closed", RecoveredWhole);
+ r.Add("own corpse: a slot-refusal line heard earlier in the session does not make an own-corpse send repeat (one move, the server silent)", EarlierSlotRefusalNoSpuriousResend);
r.Add("own corpse: another player's corpse with a similar name is left alone", SimilarNameUntouched);
r.Add("own corpse: Recover My Corpse off = the behaviour before (profile only, My Kills skips it)", SettingOffIsOldBehaviour);
r.Add("own corpse: beats a nearer corpse of your kill; a timeout retries it instead of writing it off", PriorityAndTimeout);
@@ -203,6 +204,32 @@ internal static class OwnCorpseTests
Check.False(bot.Get("_currentLootItemIsSalvage"), "nothing queued for salvage");
}
+ // The refusal count is session-wide. An own-corpse send used to leave its baseline at 0, so any
+ // refusal line heard earlier (a buff swap's) read as a refusal of this send and the item was
+ // sent again 250 ms later into a server that was still busy with the first (two in flight).
+ // The baseline is taken in the shared send path now. Real time, as the other tests here.
+ private static void EarlierSlotRefusalNoSpuriousResend()
+ {
+ World("Corpse of " + Me, "Killed by Ancient Water Elemental.", closeCalls: true);
+ var bot = NewBot();
+ bot.S.LootJumpEnabled = true; // the slot-refusal net runs only with Jump When Looting on
+ bot.P.NoteSlotRefusalChat("You can only move or use one item at a time"); // an earlier, unrelated refusal
+ bot.Tick(BotActivity.Looting);
+ Check.True(FakeHost.Uses.Contains(Corpse), "the corpse is opened");
+ foreach (uint id in new[] { Gem, Cloak, Coins })
+ bot.Cache.OnCreateObject(id);
+ bot.Cache.Tick();
+ FakeHost.GroundContainer = Corpse;
+ bot.P.OnViewObjectContents(Corpse);
+ for (int i = 0; i < 400 && FakeHost.ExternalMoves.Count == 0; i++) { bot.Tick(BotActivity.Looting); Thread.Sleep(10); }
+ Check.Eq(FakeHost.ExternalMoves.Count, 1, "the first own-corpse move is out: " + Moves());
+ Check.Eq(bot.Get("_currentLootItemSlotSeqAtSend"), bot.Get("_slotRefusalSeq"), "the send took the refusal baseline (shared send path)");
+ var sw = System.Diagnostics.Stopwatch.StartNew();
+ while (sw.ElapsedMilliseconds < 600) { bot.Tick(BotActivity.Looting); Thread.Sleep(10); } // the server is silent
+ Check.Eq(FakeHost.ExternalMoves.Count, 1, "exactly one move over 600 ms: " + Moves());
+ Check.False(FakeHost.Logs.Any(l => l.Contains("request slot refused")), "no refusal was taken for this send");
+ }
+
private static void SimilarNameUntouched()
{
World("Corpse of " + Me + "s", "Killed by Ancient Water Elemental.");