RynthSuite as of 2026-11-30 (internal 805a055): release 2026.11.30.1

This commit is contained in:
Tom Bohar 2026-11-30 15:26:56 -05:00
commit e8e4228d15
19 changed files with 983 additions and 315 deletions

View file

@ -2134,9 +2134,8 @@ 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))
// A cram or stack move still out: the client would drop this pickup.
if (HoldForItemMove(firstMatchId, matchItemName))
return;
ChatLine($"[RynthAi] Loot rule: {matchItemName} -> [{matchActionLabel}] {matchRuleLabel}");
@ -2211,7 +2210,6 @@ 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
@ -2631,16 +2629,15 @@ public sealed partial class RynthAiPlugin
/// <summary>
/// Somewhere other than the pack just tried could take the item (the client's own counts).
/// The only loot destination is the main pack (FindLootDestination), so after it this is a
/// stack join, and one already tried is not a new place to try.
/// FindLootDestination picks it (the main pack, else the side pack with the most room, packs
/// marked full skipped); the pack just tried is not a new place to try.
/// </summary>
private bool HasOtherLootDestination()
{
if (_objectCache == null || _playerId == 0) return false;
long now = CorpseNowMs;
int dest = WorldObjectCache.FindLootDestination(_objectCache.GetDirectInventory(forceRefresh: false),
unchecked((int)_playerId), Host, id => _packRefusals.IsRefused(id, now),
_objectCache[_currentLootItemId]);
unchecked((int)_playerId), Host, id => _packRefusals.IsRefused(id, now));
return dest != 0 && dest != _currentLootItemDest;
}
@ -3103,9 +3100,9 @@ public sealed partial class RynthAiPlugin
{
_packRefusals.Refuse(dest, now, confirmed, _currentLootItemId);
if (confirmed && !_currentLootItemFullPacks.Contains(dest)) _currentLootItemFullPacks.Add(dest);
// Another round only where there is somewhere else to go. Loot goes only to the main
// pack (FindLootDestination), so after it there is at most a stack join: an item
// refused there for room is given up below, not sent round again into nothing.
// Another round only where there is somewhere else to go (FindLootDestination: the main
// pack, else the side pack with the most room, skipping packs marked full): an item
// refused for room with nowhere else is given up below, not sent round again into nothing.
bool another = !_currentLootItemPackRetried && HasOtherLootDestination();
LootDiag(confirmed
? $"[RynthAi] {LootTag}: {LootPackName(dest)} took none of {_currentLootItemMoveAttempts} tries for 0x{(uint)_currentLootItemId:X8} (the server refused {_currentLootItemDestRefusals} after the pickup ran); treating it as full for {RynthCore.Plugin.RynthAi.Loot.PackRefusals.HoldMs / 60_000} min" +
@ -3156,8 +3153,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
if (HoldForItemMove(_currentLootItemId, _currentLootItemName))
return; // a cram or stack move is out: its answer first, then the resend
RynthCore.Plugin.RynthAi.ItemInfo.SelfSelect.Mark(unchecked((uint)_currentLootItemId));
Host.SelectItem(unchecked((uint)_currentLootItemId));
@ -3265,9 +3262,9 @@ public sealed partial class RynthAiPlugin
ResetCurrentLootItem();
break;
case LootPickupResult.MainPackFull:
// This item only: a stack the next item joins still goes, and so does everything
// once the main pack has a slot again (RynthSort or cram moving things out of it).
LootDiag($"[RynthAi] {LootTag}: leaving '{itemName}' 0x{(uint)itemId:X8} on 0x{(uint)corpseId:X8} — the main pack is full, it joins no stack you carry, and the client takes nothing from a corpse or chest straight into a side pack.");
// Only on an engine before plugin API v80 (no raw move to send it into a side pack):
// this item only; everything goes again once the main pack has a slot.
LootDiag($"[RynthAi] {LootTag}: leaving '{itemName}' 0x{(uint)itemId:X8} on 0x{(uint)corpseId:X8} — the main pack is full, and this engine has no raw move to put it straight into a side pack (the client's own move refuses that from a corpse or chest).");
WarnMainPackFull(itemName);
_processedCorpseItems.Add(itemId);
ResetCurrentLootItem();
@ -3278,99 +3275,46 @@ public sealed partial class RynthAiPlugin
private DateTime _mainPackFullWarnedAt = DateTime.MinValue;
/// <summary>Once per 5 minutes in chat: the main pack is full, so loot is being left (looting goes on).</summary>
/// <summary>Once per 5 minutes in chat: the main pack is full and this engine can't loot into a side pack (looting goes on).</summary>
private void WarnMainPackFull(string itemName)
{
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), " +
"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.");
ChatLine($"[RynthAi] Main pack full: '{itemName}' is left. This RynthCore is too old to loot into a side pack " +
"(it needs plugin API v80); update it, or free a main-pack slot.");
}
// ── 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.
// ── A cram or stack move still out (2026-11-28) ───────────────────────
// AutoCram's or AutoStack's last move has no answer yet: the client holds it in its one pending
// item request and drops a pickup sent through it now, so the pickup waits for that answer.
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;
private bool _itemMoveHoldLogged;
private long _itemMoveHoldTickAt;
/// <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)
/// <summary>True while the pickup of <paramref name="itemId"/> waits for an inventory move's answer.</summary>
private bool HoldForItemMove(int itemId, string itemName)
{
_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 (_inventoryManager == null || !_inventoryManager.MoveUnanswered(out string waiting))
{
if (!_lootRoomHoldLogged)
{
_lootRoomHoldLogged = true;
LootDiag($"[RynthAi] {LootTag}: the pickup of '{itemName}' 0x{(uint)itemId:X8} waits: {waiting}.");
}
PauseCorpseClockForLootRoom();
return true;
_itemMoveHoldLogged = false;
_itemMoveHoldTickAt = 0;
return false;
}
_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();
if (!_itemMoveHoldLogged)
{
_itemMoveHoldLogged = true;
LootDiag($"[RynthAi] {LootTag}: the pickup of '{itemName}' 0x{(uint)itemId:X8} waits: {waiting}.");
}
PauseCorpseClockForItemMove();
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()
/// <summary>The corpse's timeout clock stands still while a pickup waits for a move's answer (as PauseCorpseClockWhileHeld does for a server answer).</summary>
private void PauseCorpseClockForItemMove()
{
long now = CorpseNowMs;
long last = _lootRoomHoldTickAt;
_lootRoomHoldTickAt = now;
long last = _itemMoveHoldTickAt;
_itemMoveHoldTickAt = now;
if (last == 0 || _targetCorpseId == 0 || _corpseTargetSince == 0)
return;
long gap = now - last;
@ -3392,6 +3336,9 @@ public sealed partial class RynthAiPlugin
return;
int itemId = _currentLootItemId;
// It is in a pack now (or merged): the next read of the inventory walks the packs again, so the
// next item's room check counts it (ExpireDirectInventory).
_objectCache?.ExpireDirectInventory();
if (answered)
{
// The pack it landed in has room, whatever it was marked (an earlier send may have