Vitals: heal grace - a heal never waits more than 2 s on pending state

"Stuck in Healing": a healing kit got no result line, and no vitals
action followed for 8 s and more with the label reading Healing; the
character died. The kit wait's timeout was 8 s.

VirindiTank re-sends a kit every 100 ms until the server plays the heal
motion (3 s at most), then waits up to 3 s for the result line. It never
parks on the client's busy state.

ActionPacer.HealGraceMs (2000) bounds what a heal under a heal line waits on:
- the kit wait (KitWaitVerdict): no motion, no UseDone and no line after
  2 s lets the kit go and the next tick sends it again; the kit's own
  UseDone(0) (the first after the send) with no line ends it after 700 ms;
  a started kit waits 3.5 s at most (KitResultTimeoutMs, was 8 s; stamina
  kits share this wait). An engine with neither GetCastBusyState nor the
  UseDone sequence can't show the server took a kit, so there only the
  3.5 s limit applies;
- an item use nobody answered (a lost kit) no longer holds the heal past
  2 s (corpse/door uses and our own casts keep their rules);
- the character's animation: 2 s for a plain heal (was 4 s), logged and
  counted once per busy spell;
- the 'too busy' probe for a waiting heal: at least every 2 s;
- the cast gate: closed 2 s under a heal line opens for the heal only
  (no mana, stamina or buff goes on that tick);
- a busy count: up 2 s (timed from its rise) no longer holds a heal.

Tests: HealGraceTests (new, 10), StuckCastTests' probe test split into the
non-heal doubling and the heal's capped probe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daniel Wallace 2026-11-07 08:36:04 -08:00
commit 486f72de58
6 changed files with 553 additions and 18 deletions

View file

@ -147,6 +147,14 @@ internal static class ActionPacer
public const long NoUseDoneFallbackMs = 600;
/// <summary>The longest one ask for the player's turn holds RynthAi (RynthAiYieldApiV1.MaxHoldMs).</summary>
public const long PlayerHoldMaxMs = 3000;
/// <summary>
/// Heal grace (the "stuck in Healing" report): the longest a heal under a heal line waits on
/// an item use nobody answered, on the character's animation, or on the 'too busy' probe. Past it the heal
/// goes (a refusal is an answer too, and the next heal retries), as VirindiTank does: it re-sends a kit
/// until the server starts it and never parks on the client's busy state. Corpse/door uses and our own
/// casts keep their rules (a server turn to stop; a cast the server would refuse).
/// </summary>
public const long HealGraceMs = 2000;
private static readonly object Gate = new();
private static PacedAction? _cur;
@ -157,6 +165,7 @@ internal static class ActionPacer
private static long _gestureHolds, _gestureLimits;
private static long _gestureBusySince; // when the client's motion queue was first seen busy (0 = clear)
private static bool _gestureOverride; // the hold limit passed: open until the queue reads clear
private static bool _gestureHealGrace; // the heal grace let a heal through this busy spell (logged once)
private static readonly HashSet<string> _gestureLogged = new();
private static long _maxWaitMs;
private static string _maxWaitWhat = "";
@ -195,6 +204,7 @@ internal static class ActionPacer
_swingSentMs = 0; _swingSeenBusy = false; _swingHolds = 0; _swingLogged.Clear();
_gestureBusySince = 0;
_gestureOverride = false;
_gestureHealGrace = false;
_gestureLogged.Clear();
_maxWaitMs = 0;
_maxWaitWhat = "";
@ -529,6 +539,15 @@ internal static class ActionPacer
lock (Gate) _healsAhead++;
return true;
}
// An item use (a kit, a potion, a wield) still unanswered after HealGraceMs: the heal goes (see
// HealGraceMs). Its own pack has no server turn to stop; a lost or swallowed kit is re-sent here.
if (a.Kind == PacedKind.ItemUse && age >= HealGraceMs)
{
bool logAhead;
lock (Gate) { _healsAhead++; logAhead = a.LoggedWaits.Add(who + "/heal-grace"); }
if (logAhead) Log(host, $"[Pace] {who}: the heal goes ahead of {Describe(a.Kind, a.Label)} (unanswered for {age} ms, heal grace {HealGraceMs} ms)");
return true;
}
}
why = $"{Describe(a.Kind, a.Label)} sent {age} ms ago by {a.Who} has no answer yet";
@ -570,6 +589,7 @@ internal static class ActionPacer
line = "[Pace] the character's animation queue reads clear again";
_gestureBusySince = 0;
_gestureOverride = false;
_gestureHealGrace = false;
_gestureLogged.Clear();
}
else
@ -592,6 +612,17 @@ internal static class ActionPacer
line = $"[Pace] {who}: emergency heal after {age} ms of animation - going on";
busy = false;
}
else if (heal == HealNeed.Heal && age >= HealGraceMs)
{
// Once per busy spell: logged and counted when the grace first lets a heal through.
if (!_gestureHealGrace)
{
_gestureHealGrace = true;
_gestureLimits++;
line = $"[Pace] {who}: heal after {age} ms of animation (heal grace) - going on";
}
busy = false;
}
else
{
_gestureHolds++;
@ -915,8 +946,11 @@ internal static class ActionPacer
// use would send first every time and the heal would see the next slot, up to BusyProbeMaxMs later).
if (heal == HealNeed.Heal && _busySince != 0) _healWaitAt = now;
bool healWaiting = heal != HealNeed.Heal && _healWaitAt != 0 && now - _healWaitAt < HealWaitFreshMs;
// A waiting heal's probe comes at least every HealGraceMs (the doubling would reach BusyProbeMaxMs).
long probeWait = Math.Min(BusyProbeMs << Math.Min(_probes, 8), BusyProbeMaxMs);
if (heal == HealNeed.Heal) probeWait = Math.Min(probeWait, HealGraceMs);
if (!attackRepeat && stuck == null && _busySince != 0 && _stage == BreakStage.None && !healWaiting
&& now - Math.Max(_busySince, _lastProbeAt) >= Math.Min(BusyProbeMs << Math.Min(_probes, 8), BusyProbeMaxMs))
&& now - Math.Max(_busySince, _lastProbeAt) >= probeWait)
{
probe = true; // spent in MayStart once the start passes its other checks (SpendTryAfterBusy)
}