Vitals: a kit its result line calls used up is not picked again #27

Open
AwfulWaffle wants to merge 1 commit from AwfulWaffle/RynthSuite:kit-used-up into main
First-time contributor

Independent: applies to main alone.

What went wrong in play

A kit's last heal ends with "... Your Treated Healing Kit is used up." (ACE Healer.DoHealing), and the server removes the kit. A used-up kit that was still listed got picked again and again. ACE answers a use of an item the player no longer has with a bare UseDone and no chat, so no heal landed. The character died with the next kit still in the pack.

Main's live-walk lookup removes most of this: kit picks read the client's own pack walk (WorldObjectCache.GetDirectInventory). Two gaps are left:

  • The walk's reuse window. The walk is reused for up to 1 s (DirectInventoryCooldownMs), and the next kit goes out 700 ms after the result line (KitLandGraceMs). Inside that window the used-up kit can still be picked from the last walk. A probe on pristine main showed it: the pick 750 ms after the line was the used-up kit.
  • An engine without GetContainerContents. There is no walk at all. The inventory view is the object cache, which can keep the removed kit for good. RynthAi feature-detects that call, so this is a supported configuration.

The fix

Combat/BuffManager.KitUsedUp.cs (new):

  • The skip. When the "is used up" line names the kit in flight, every kit pick skips that kit. The picks are:
    • the Consumables rule pick (ConsumableLookup.Resolve);
    • BestPackHealingKit and BestPackStaminaKit;
    • the HP failsafe's "can heal" check.
  • How long. With the live walk, the skip lasts 3 s (UsedUpKitSkipMs), long enough for a fresh walk to have dropped the kit. Without the walk it lasts for the session: the server deleted the object, and its id never comes back.
  • Only the kit in flight. A line naming another kit (a late line from a kit that timed out) is logged and ignored, so it can't mark the kit now in flight.
  • Lookup change. ConsumableLookup.Resolve takes an optional skip predicate. A skipped listed id falls through to the name match, so the next stack of that name is used.
  • Test seam. WorldObjectCache.WalkClock is the clock that GetDirectInventory's reuse runs on. It is RynthClock unless a test sets it. The tests freeze it, so the walk never refreshes and only the skip can keep the used-up kit out.

This is the only part of the earlier kit-drop work that the live walk has not made redundant. Not carried:

  • dropping a kit after two bare answers;
  • the 5-minute drop and its expiry;
  • the emergency last resort for dropped kits;
  • "never drop an animated kit";
  • dropped potion stacks.

How it was tested

Run from Tools\RynthCore.RynthAiHostTests:

dotnet build -c Release -r win-x86 -nodeReuse:false          (plugin project and host tests: 0 errors)
dotnet run -c Release -- "kit used up"                       6 tests, 47 checks: 6 passed
dotnet run -c Release                                        1501 tests: 1500 passed, 1 failed

The one failure is map bake: 0x6346 ..., the same one pristine main has (1494/1495).

New tests: KitUsedUpTests (6), with the walk's clock frozen:

  • the used-up line skips the kit inside the walk's reuse, for both the rule pick and the pack pick;
  • control: a line with uses left keeps the kit;
  • a line naming another kit is ignored;
  • with the walk, the skip expires at 3 s;
  • without GetContainerContents, the next pick at +3.2 s is still the next kit and never the used-up one;
  • the same skip works for a stamina kit.

Checked against deliberately broken code:

  • with KitUsedUp stubbed to false, 4 of 6 fail;
  • with the no-walk skip limited to 3 s, the no-walk test fails.

Scope and risk

  • Kit picks only. Kit use, the kit wait and potions are unchanged.
  • The skip only covers a kit that the server's own line called used up. A wrong skip needs the server to misname a kit.
  • WalkClock is a test seam. With nothing setting it, the walk behaves exactly as before.
  • vital-wand-gate (#28) stacks on this branch, because the gate must not count a kit that the picks skip.

🤖 Generated with Claude Code

Independent: applies to main alone. ## What went wrong in play A kit's last heal ends with "... Your Treated Healing Kit is used up." (ACE `Healer.DoHealing`), and the server removes the kit. A used-up kit that was still listed got picked again and again. ACE answers a use of an item the player no longer has with a bare UseDone and no chat, so no heal landed. The character died with the next kit still in the pack. Main's live-walk lookup removes most of this: kit picks read the client's own pack walk (`WorldObjectCache.GetDirectInventory`). Two gaps are left: - **The walk's reuse window.** The walk is reused for up to 1 s (`DirectInventoryCooldownMs`), and the next kit goes out 700 ms after the result line (`KitLandGraceMs`). Inside that window the used-up kit can still be picked from the last walk. A probe on pristine main showed it: the pick 750 ms after the line was the used-up kit. - **An engine without `GetContainerContents`.** There is no walk at all. The inventory view is the object cache, which can keep the removed kit for good. RynthAi feature-detects that call, so this is a supported configuration. ## The fix `Combat/BuffManager.KitUsedUp.cs` (new): - **The skip.** When the "is used up" line names the kit in flight, every kit pick skips that kit. The picks are: - the Consumables rule pick (`ConsumableLookup.Resolve`); - `BestPackHealingKit` and `BestPackStaminaKit`; - the HP failsafe's "can heal" check. - **How long.** With the live walk, the skip lasts 3 s (`UsedUpKitSkipMs`), long enough for a fresh walk to have dropped the kit. Without the walk it lasts for the session: the server deleted the object, and its id never comes back. - **Only the kit in flight.** A line naming another kit (a late line from a kit that timed out) is logged and ignored, so it can't mark the kit now in flight. - **Lookup change.** `ConsumableLookup.Resolve` takes an optional skip predicate. A skipped listed id falls through to the name match, so the next stack of that name is used. - **Test seam.** `WorldObjectCache.WalkClock` is the clock that `GetDirectInventory`'s reuse runs on. It is `RynthClock` unless a test sets it. The tests freeze it, so the walk never refreshes and only the skip can keep the used-up kit out. This is the only part of the earlier kit-drop work that the live walk has not made redundant. Not carried: - dropping a kit after two bare answers; - the 5-minute drop and its expiry; - the emergency last resort for dropped kits; - "never drop an animated kit"; - dropped potion stacks. ## How it was tested Run from `Tools\RynthCore.RynthAiHostTests`: ``` dotnet build -c Release -r win-x86 -nodeReuse:false (plugin project and host tests: 0 errors) dotnet run -c Release -- "kit used up" 6 tests, 47 checks: 6 passed dotnet run -c Release 1501 tests: 1500 passed, 1 failed ``` The one failure is `map bake: 0x6346 ...`, the same one pristine main has (1494/1495). New tests: `KitUsedUpTests` (6), with the walk's clock frozen: - the used-up line skips the kit inside the walk's reuse, for both the rule pick and the pack pick; - control: a line with uses left keeps the kit; - a line naming another kit is ignored; - with the walk, the skip expires at 3 s; - without `GetContainerContents`, the next pick at +3.2 s is still the next kit and never the used-up one; - the same skip works for a stamina kit. Checked against deliberately broken code: - with `KitUsedUp` stubbed to false, 4 of 6 fail; - with the no-walk skip limited to 3 s, the no-walk test fails. ## Scope and risk - Kit picks only. Kit use, the kit wait and potions are unchanged. - The skip only covers a kit that the server's own line called used up. A wrong skip needs the server to misname a kit. - `WalkClock` is a test seam. With nothing setting it, the walk behaves exactly as before. - vital-wand-gate (#28) stacks on this branch, because the gate must not count a kit that the picks skip. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A kit's last heal ends "... Your Treated Healing Kit is used up." (ACE
Healer.DoHealing) and the server removes the kit. A use of an item the
player no longer has is answered with a bare UseDone and no chat, so a
used-up kit picked again is a heal lost.

Kit picks read the client's live pack walk (ConsumableLookup.Resolve,
BestPackHealingKit, BestPackStaminaKit), which drops the removed kit, but
a walk is reused for up to 1 s (DirectInventoryCooldownMs), and the next
kit goes out 700 ms after the line (KitLandGraceMs): inside that reuse
the used-up kit was picked again. An engine without GetContainerContents
has no walk at all; its inventory view is the object cache, which can
keep the removed kit for good.

Now the "is used up" line, when it names the kit in flight, makes every
kit pick skip that kit: for 3 s (UsedUpKitSkipMs) with the live walk, long
enough for a fresh walk to have dropped it, and for the session without
it (the server deleted the object; its id never comes back). A line
naming another kit (a late line from a kit that timed out) is logged and
ignored. ConsumableLookup.Resolve takes an optional skip predicate; a
skipped listed id falls through to the name match. Healing and stamina
kits.

WorldObjectCache.WalkClock: the clock GetDirectInventory's reuse runs on
(RynthClock unless a test sets it), so the tests can hold the walk still
and prove the skip, not a refreshed walk, keeps the kit out.

Ported from the earlier kit-drop work onto the live-walk lookup: the rest
of that work (dropping a kit after two bare answers, the 5 minute drop,
the emergency last resort for dropped kits, dropped potion stacks) is
covered by the live walk and is not carried.

Tests: KitUsedUpTests (new, 6). The walk-window cases fail on main and
with KitUsedUp stubbed to false; the no-walk case fails with a 3 s skip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This pull request has changes conflicting with the target branch.
  • Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.KitUsedUp.cs
  • Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.cs
  • Tools/RynthCore.RynthAiHostTests/Program.cs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u kit-used-up:AwfulWaffle-kit-used-up
git switch AwfulWaffle-kit-used-up

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff AwfulWaffle-kit-used-up
git switch AwfulWaffle-kit-used-up
git rebase main
git switch main
git merge --ff-only AwfulWaffle-kit-used-up
git switch AwfulWaffle-kit-used-up
git rebase main
git switch main
git merge --no-ff AwfulWaffle-kit-used-up
git switch main
git merge --squash AwfulWaffle-kit-used-up
git switch main
git merge --ff-only AwfulWaffle-kit-used-up
git switch main
git merge AwfulWaffle-kit-used-up
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rynth/RynthSuite!27
No description provided.