RynthAi jump loot: flight budget for in-air sends
A pickup sent in the air on an earlier jump is a no-bend-down pickup only if the server still sees the character jumping when the move reaches it. Sent late in the flight it arrived after the landing, and ACE played the whole bend-down and Return (about 2 s; in client logs from one server the in-air bend-downs came out at 1701 and 2707 ms) where landing and taking a fresh jump costs about 0.5 s. When jumpAge + the recent no-bend-down send-to-off-corpse time (mean of the last 4, 200 ms until one is measured) is over LootJumpFlightBudgetMs (809, the largest jumpAge + off-corpse among 56 in-air no-bend-down sends in those logs), the pickup is held for the landing and then goes with a fresh jump. The hold is logged once per send. A slot resend keeps the jump inside the budget and goes plain past it. Only jump sends take this path, so it needs Jump When Looting (LootJumpEnabled, default off). Host tests: a slot resend inside the budget keeps the jump flag and one past it drops it; the window after a slot resend is anchored to the jump; the reset clears the hold-logged flag; the budget lets an early in-air send through and holds a late one until the landing, then jumps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
04ecdd64f4
commit
f758a35b37
2 changed files with 172 additions and 9 deletions
|
|
@ -208,6 +208,19 @@ public sealed partial class RynthAiPlugin
|
|||
/// <summary>How long the no-bend-down call stays off after the server proved it wrong.</summary>
|
||||
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;
|
||||
|
||||
/// <summary>The send-to-off-corpse time assumed until a no-bend-down pickup has been measured (log median 203 ms).</summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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 <see cref="LootJumpFlightBudgetMs"/>.
|
||||
/// </summary>
|
||||
private bool FlightBudgetSpent(long jumpAge, out long expectedAnswerMs)
|
||||
{
|
||||
expectedAnswerMs = ExpectedNoMotionAnswerMs();
|
||||
return jumpAge >= 0 && jumpAge + expectedAnswerMs > LootJumpFlightBudgetMs;
|
||||
}
|
||||
|
||||
/// <summary>The recent send-to-off-corpse time of pickups answered with no bend-down (mean of the last 4), or the default.</summary>
|
||||
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++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue