Vitals: no wand swap for a vital spell while a kit or potion heals #28

Open
AwfulWaffle wants to merge 2 commits from AwfulWaffle/RynthSuite:vital-wand-gate into main

2026-11-07

Daniel Wallace
Vitals: no wand swap for a vital spell while a kit or potion heals
Kits are the standard heal, and the shield stays on: putting the shield
away for a wand costs more damage than a small heal spell buys back. A
melee character under Heal At put its shield away and pulled a wand for
Heal Self with kits in the pack; the wand was skipped only at Emergency
Heal At.

CastVital (Heal Self, Stamina to Health, Revitalize, Stamina to Mana and
the script hook's heal) now refuses as not handled when the character is
out of Magic mode, no caster is in hand, and a usable kit or potion for
that vital is carried (BuffManager.VitalWandGate.cs). The chain falls
through to the potion and the kit despite Kit Min Success.

- With no kit and no potion at all the swap is still allowed.
- A caster already wielded still gets the Magic stance change (no weapon
  moves); the wielded-wand check is extracted from EnsureMagicMode into
  IsBuffWandWielded so the gate and the swap agree. With no wand found
  the Magic stance goes bare-handed (no weapon moves): not gated either.
- A swap already under way finishes.
- Stamina to Mana never swaps in a fight (InCombatNow), potion or not;
  out of a fight it may, even with a mana potion carried.
- A kit counts only if the kit picks would use it: the live pack walk,
  minus a kit its line called used up, minus a kit the server refused 3
  times within 10 s. A streak with no refusal for 10 s ages out; a kit
  landing, or the macro stopping, ends every streak.
- The stamina sources share one order (AttemptStaminaRestore) for the
  stamina step, the mana step's refill and the buffing mana floor, ending
  with the stamina kit despite Stamina Kit Min Success % as the last
  resort, since Revitalize is refused here.
- Buffing is unchanged and still swaps.

Tests: VitalWandGateTests (new, 17).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 09:35:14 -08:00
Daniel Wallace
Vitals: a kit its result line calls used up is not picked again
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>
2026-11-07 09:32:29 -08:00