diff --git a/Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs b/Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs
index a346cc4..947472d 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs
@@ -208,6 +208,19 @@ public sealed partial class RynthAiPlugin
/// 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
@@ -237,6 +250,10 @@ public sealed partial class RynthAiPlugin
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
@@ -1899,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));
@@ -1917,8 +1953,6 @@ public sealed partial class RynthAiPlugin
// 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. No second jump while
// still in the air (an air jump only costs stamina); a jump taken is noted for combat.
- bool jumpLoot = !pipelined && ShouldJumpLoot(settings);
- bool stillInAir = jumpLoot && ActionPacer.LootJumpAirborne(Host, out _);
bool jumped = false;
if (jumpLoot && !stillInAir)
{
@@ -2318,8 +2352,9 @@ public sealed partial class RynthAiPlugin
/// 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 goes without a jump
- /// (the floor applies), and it is a fresh send: a fight before it is not this send's. After
+ /// 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).
@@ -2364,6 +2399,10 @@ public sealed partial class RynthAiPlugin
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
@@ -2372,17 +2411,44 @@ public sealed partial class RynthAiPlugin
_currentLootItemSlotGaveUp = true; // the engine turned the call down: nothing more to repeat
_currentLootItemErrSeqAtSend = errSeqAtSend;
_currentLootItemMoveRequestedAt = now;
- _currentLootItemJumped = false; // a resend goes without a jump (the floor applies)
- _currentLootItemSentInAirWindow = false;
+ _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}, no jump).");
+ 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
@@ -3081,6 +3147,7 @@ public sealed partial class RynthAiPlugin
LootDiag($"[RynthAi] {LootTag}: pickup confirmed for 0x{(uint)_currentLootItemId:X8}; {reason}" +
$" ({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
@@ -3116,7 +3183,7 @@ public sealed partial class RynthAiPlugin
_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) is later than its jump. Looked up as 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();
@@ -4123,6 +4190,7 @@ public sealed partial class RynthAiPlugin
_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;
diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/LootJumpTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/LootJumpTests.cs
index c56055a..710066e 100644
--- a/Tools/RynthCore.RynthAiHostTests/Tests/LootJumpTests.cs
+++ b/Tools/RynthCore.RynthAiHostTests/Tests/LootJumpTests.cs
@@ -52,16 +52,21 @@ internal static class LootJumpTests
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: ResetCurrentLootItem clears the slot-refusal fields", ResetClearsSlotFields);
+ 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);
@@ -481,6 +486,32 @@ internal static class LootJumpTests
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
@@ -564,17 +595,41 @@ internal static class LootJumpTests
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
@@ -670,6 +725,46 @@ internal static class LootJumpTests
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(() =>