RynthSuite as of 2026-11-29 (internal 46bae49): release 2026.11.28.1

This commit is contained in:
Tom Bohar 2026-11-29 00:38:53 -05:00
commit 598f49c899
131 changed files with 11825 additions and 329 deletions

View file

@ -58,6 +58,13 @@ public sealed partial class RynthAiPlugin
private const long AppraisalWaitMs = 3_000; // extra wait past the assess window for an item's appraisal
private const long ContentsSweepMs = 500; // how often an open corpse's contents are checked for items the cache missed
private long _lastContentsSweepAt;
// Before a corpse is finished, one more look at what the client says it holds. A corpse finished
// 130 ms after it opened, from the cache's items alone, left an item the client listed but could not
// read yet unjudged. The finish waits until FinalSweepMinMs after the open, and an unreadable listed
// item holds it up to UnreadContentsWaitMs after the open.
internal const long FinalSweepMinMs = 200; // the empty-corpse floor already
internal const long UnreadContentsWaitMs = 2_500;
private int _unreadHoldLoggedFor;
private int _lastContentsSweepCorpse;
private const long AppraisalHoldTimeoutMarginMs = 1_000; // stop holding this long before the corpse timeout
@ -1999,7 +2006,8 @@ public sealed partial class RynthAiPlugin
// Empty corpse check
if (visibleItemCount == 0)
{
if (openAge >= Math.Max(200, settings.LootEmptyCorpseMs) && !LastPickupSettling(now))
if (openAge >= Math.Max(200, settings.LootEmptyCorpseMs) && !LastPickupSettling(now)
&& !HoldForContentsNotSeen(corpseId, containedItems, openAge))
{
LootDiag($"[RynthAi] {LootTag}: no items on 0x{(uint)corpseId:X8} after {openAge}ms; marking complete.");
MarkCorpseCompleted(corpseId);
@ -2013,6 +2021,19 @@ public sealed partial class RynthAiPlugin
// moves (AC's one-item-at-a-time gate is the pending inventory request, not m_cBusy).
if (firstMatchId != 0)
{
// Gone from the client already (2026-11-28, Item Tool on a DreamWeave Legendary Chest): the
// server had cleared a leftover 'Platemail Gauntlets' out of the chest, the cache still
// listed it there, and judged on what was left of it (wcid 0) it matched a Keep rule. The
// pickup went out for an object that no longer existed and its absence read as "merged
// into a stack". Not sent, not counted as wanted (the Item Tool's nothing-taken stop).
if (ObjectGoneFromClient(firstMatchId))
{
LootDiag($"[RynthAi] {LootTag}: skipping 0x{(uint)firstMatchId:X8} '{matchItemName}' on 0x{(uint)corpseId:X8} - gone from the client (the server removed it; the cache still listed it there).");
_processedCorpseItems.Add(firstMatchId);
_corpseMatchedIds.Remove(firstMatchId);
return;
}
// Keep room for weapon swaps: with a full pack the bow can't be put away to
// switch to the wand, so buffs and spell heals stop (2026-09-28 death). Leave
// the corpse rather than filling the last slots; -1 = side-pack capacity unknown.
@ -2075,6 +2096,11 @@ public sealed partial class RynthAiPlugin
return;
}
// The main pack is full and a side pack has room: one item goes from the main pack to
// the side pack first (the client takes loot only into the main pack), then this one.
if (HoldForLootRoom(firstMatchId, matchItemName))
return;
ChatLine($"[RynthAi] Loot rule: {matchItemName} -> [{matchActionLabel}] {matchRuleLabel}");
_currentLootItemId = firstMatchId;
RynthCore.Plugin.RynthAi.ItemInfo.SelfSelect.Mark(unchecked((uint)firstMatchId));
@ -2147,6 +2173,7 @@ public sealed partial class RynthAiPlugin
_scrollLearner?.NoteLooted(firstMatchId, matchItemName, fromProfile: matchRuleLabel != ScrollLearner.RuleLabel);
// Keep # per day: on its way, so it counts until it lands (then it is recorded).
NotePerDaySent(firstMatchId);
NoteLootBroughtIn(firstMatchId);
_currentLootItemMovePending = true;
_currentLootItemMoveRequestedAt = now;
// A queued move that the client or server turned away (the client's one-request
@ -2173,11 +2200,43 @@ public sealed partial class RynthAiPlugin
// has played out (closing while it was under way: 2026-10-07).
if (pendingDataCount == 0 && !LastPickupSettling(now))
{
if (HoldForContentsNotSeen(corpseId, containedItems, openAge))
return;
LootDiag($"[RynthAi] {LootTag}: all {visibleItemCount} items on 0x{(uint)corpseId:X8} evaluated; marking complete.");
MarkCorpseCompleted(corpseId);
}
}
/// <summary>
/// True while the corpse mustn't be finished yet: it opened under <see cref="FinalSweepMinMs"/> ago, the
/// client lists an item in it the cache hasn't got (looked up now; the next tick's sweep judges it), or it
/// lists one that can't be read yet (held up to <see cref="UnreadContentsWaitMs"/> after the open).
/// </summary>
private bool HoldForContentsNotSeen(int corpseId, List<WorldObject> containedItems, long openAge)
{
if (_objectCache == null) return false;
if (openAge < FinalSweepMinMs) return true;
List<WorldObject> missed = _objectCache.RescueContainedItems(corpseId, containedItems, out int unread);
if (missed.Count > 0)
{
_lastContentsSweepAt = 0; // the next tick's sweep adds them to what is judged
LootDiag($"[RynthAi] Corpse loot: before finishing 0x{(uint)corpseId:X8}, found {missed.Count} item(s) the object cache had missed: " +
string.Join(", ", missed.Select(w => $"0x{(uint)w.Id:X8} '{w.Name}' {w.ObjectClass}")) + ".");
return true;
}
if (unread > 0 && openAge < UnreadContentsWaitMs)
{
if (_unreadHoldLoggedFor != corpseId)
{
_unreadHoldLoggedFor = corpseId;
LootDiag($"[RynthAi] Corpse loot: 0x{(uint)corpseId:X8} holds {unread} item(s) that can't be read yet; " +
$"waiting up to {UnreadContentsWaitMs} ms after the open before finishing.");
}
return true;
}
return false;
}
// A pickup that merges into a stack already in the pack (a Silver Pea onto the Silver Peas):
// the server removes the corpse item (InventoryRemoveObject) and raises the pack stack's size,
// so the picked object never shows up in the inventory and the arrival check waited out
@ -2858,6 +2917,20 @@ public sealed partial class RynthAiPlugin
bool jumpAnswer = _currentLootItemJumped && inPack;
bool believable = jumpAnswer || now - _currentLootItemMoveRequestedAt >= PickupAnswerMinMs;
long since = now - _currentLootItemLeftAt;
// Only a stack merges away. An item that is not one and is gone from the client without
// ever showing in a pack was not looted (2026-11-28: a Legendary Chest's 'Helmet' and
// 'Olthoi Sollerets' the client was letting go of were "merged into a stack in the pack").
if (believable && !inPack && mergedInto == 0 && !_currentLootItemStackable
&& (currentItem == null || ObjectGoneFromClient(_currentLootItemId)))
{
LootDiag($"[RynthAi] {LootTag}: 0x{(uint)_currentLootItemId:X8} '{_currentLootItemName}' is gone from the client without showing in a pack " +
$"({now - _currentLootItemMoveRequestedAt} ms after the send); not a stack, so it didn't merge: not looted.");
_processedCorpseItems.Add(_currentLootItemId);
ResetCurrentLootItem();
_lastLootActionAt = now;
return;
}
bool answered = landed && believable;
if (!answered && since < PickupArriveMaxMs)
return;
@ -3045,6 +3118,8 @@ public sealed partial class RynthAiPlugin
}
if (PickupHeldByServerAction())
return; // a retry now would be refused as too busy and use up an attempt
if (HoldForLootRoom(_currentLootItemId, _currentLootItemName))
return; // the main pack filled meanwhile: room first, then the resend
RynthCore.Plugin.RynthAi.ItemInfo.SelfSelect.Mark(unchecked((uint)_currentLootItemId));
Host.SelectItem(unchecked((uint)_currentLootItemId));
@ -3171,7 +3246,98 @@ public sealed partial class RynthAiPlugin
if ((RynthClock.Now - _mainPackFullWarnedAt).TotalMinutes < 5) return;
_mainPackFullWarnedAt = RynthClock.Now;
ChatLine($"[RynthAi] Main pack full: '{itemName}' is left. AC loots only into the main pack (or onto a stack you already carry), " +
"not straight into a side pack. Move items out of the main pack (RynthSort, cram) and looting takes everything again.");
"and nothing in the main pack could be moved to a side pack to make room. Free a main-pack slot and looting takes everything again.");
}
// ── Room for loot in a full main pack (2026-11-28) ────────────────────
// Since 8c14ea53 a pickup goes only into the main pack (the client refuses a corpse or chest item
// aimed straight at a side pack), so with the main pack full every item that joined no stack was
// left, even with side packs empty: looting looked stopped. Now the pickup first has one loose item
// moved from the main pack to a side pack (InventoryManager.MakeLootRoom), waits for that move's
// answer (the client refuses a pickup while it is out), and then takes the freed slot. Up to
// LootRoomMovesPerItem room moves per item; after that, or with nothing that may move, the item is
// left as before.
private readonly List<int> _lootBroughtIn = new(); // items the looter sent for, oldest first
private readonly Dictionary<int, int> _lootRoomMoves = new(); // corpse item -> room moves made for it
private const int LootRoomMovesPerItem = 2;
private bool _lootRoomHoldLogged;
private long _lootRoomHoldTickAt;
/// <summary>A pickup went out for <paramref name="itemId"/>: it is loot, so it is first to move when the main pack needs room.</summary>
private void NoteLootBroughtIn(int itemId)
{
_lootBroughtIn.Remove(itemId);
_lootBroughtIn.Add(itemId);
if (_lootBroughtIn.Count > 200) _lootBroughtIn.RemoveRange(0, _lootBroughtIn.Count - 200);
}
private IEnumerable<int> LootBroughtInNewestFirst(int except)
{
for (int i = _lootBroughtIn.Count - 1; i >= 0; i--)
if (_lootBroughtIn[i] != except) yield return _lootBroughtIn[i];
}
/// <summary>
/// True while the pickup of <paramref name="itemId"/> waits for room in the main pack: a room move
/// was just sent, or the last one has no answer yet. False when the item fits (a free main-pack
/// slot, or a stack it joins), when no side pack has room (the pickup's NoRoom finishes the corpse,
/// as before), or when no room move can be made (the item is left, as before).
/// </summary>
private bool HoldForLootRoom(int itemId, string itemName)
{
var inventory = _inventoryManager;
if (inventory == null || _objectCache == null || _playerId == 0 || !Host.HasMoveItemExternal)
return false;
if (inventory.MoveUnanswered(out string waiting))
{
if (!_lootRoomHoldLogged)
{
_lootRoomHoldLogged = true;
LootDiag($"[RynthAi] {LootTag}: the pickup of '{itemName}' 0x{(uint)itemId:X8} waits: {waiting}.");
}
PauseCorpseClockForLootRoom();
return true;
}
_lootRoomHoldLogged = false;
_lootRoomHoldTickAt = 0;
int pid = unchecked((int)_playerId);
Func<int, bool> refused = id => _packRefusals.IsRefused(id, CorpseNowMs);
var item = _objectCache[itemId];
if (WorldObjectCache.FindLootDestination(_objectCache.GetDirectInventory(forceRefresh: false), pid, Host, refused, item) != 0)
return false;
// Read afresh before moving anything: the last room move may have landed since the cached list
// was built (the pickup's own read then sees this list too).
var inv = _objectCache.GetDirectInventory(forceRefresh: true);
if (WorldObjectCache.FindLootDestination(inv, pid, Host, refused, item) != 0)
return false;
if (!WorldObjectCache.SidePackHasRoom(inv, pid, Host))
return false;
_lootRoomMoves.TryGetValue(itemId, out int made);
if (made >= LootRoomMovesPerItem)
return false;
if (!inventory.MakeLootRoom(LootBroughtInNewestFirst(itemId), out string moved))
return false;
if (_lootRoomMoves.Count > 200) _lootRoomMoves.Clear();
_lootRoomMoves[itemId] = made + 1;
LootDiag($"[RynthAi] {LootTag}: the main pack is full: moving {moved} so '{itemName}' 0x{(uint)itemId:X8} fits there.");
PauseCorpseClockForLootRoom();
return true;
}
/// <summary>The corpse's timeout clock stands still while a pickup waits for room (as PauseCorpseClockWhileHeld does for a server answer).</summary>
private void PauseCorpseClockForLootRoom()
{
long now = CorpseNowMs;
long last = _lootRoomHoldTickAt;
_lootRoomHoldTickAt = now;
if (last == 0 || _targetCorpseId == 0 || _corpseTargetSince == 0)
return;
long gap = now - last;
if (gap > 0 && gap <= PickupHoldMaxGapMs)
_corpseTargetSince += gap;
}
/// <summary>