Vitals: hand combat the tick when no heal is landing in a fight #26

Open
AwfulWaffle wants to merge 2 commits from AwfulWaffle/RynthSuite:heal-hold into main
First-time contributor

Stacks on heal-grace (#25): review/apply that first.

What went wrong in play

A melee character with a shield went to Buffing at 48% health and stopped attacking the boss. It stood there for 17 s re-sending a healing kit the server no longer had, then died. Health under a heal line wins the arbiter's tick by itself (WantsVitalRecharge). That is right while heals land and wrong when none does: nothing healed, and nothing fought either.

The fix

Combat/BuffManager.HealHold.cs (new), wired into OnHeartbeat, WantsVitalRecharge and CheckVitals:

  • The release. In a fight (a monster within Monster Range, InCombatNow), 6 s under a heal line with no heal landing hands combat the tick for 5 s. After that the vitals hold it again.
    • A heal landing means health up 3 points, the HP failsafe's own test.
    • A heal landing, or health back over the line, ends the episode.
    • 6 s is VirindiTank's give-up for one kit: 3 s to start, 3 s for the result.
  • Kits and potions keep going. The vitals step still runs every tick meanwhile. While combat has the tick, though, it makes no stance change or wield for a vital:
    • no wand swap for Heal Self;
    • no peace switch for a kit in any stance, including Magic with Use Kits in Magic Mode;
    • a caster already in Magic stance still casts its heal spell.
  • Kit chance in the current stance. With no peace switch going out, Kit Min Success (and Stamina Kit Min Success) is computed in the stance the character is in, not as if in peace.
  • A heal under way finishes first. A release waits for:
    • a kit whose heal motion has played (heal-grace (#25)'s NoteKitProgress, which is why this stacks on heal-grace (#25));
    • a wand wield in flight.
  • The hold resets whenever the macro is off, on the stop and on the HP failsafe's recall stop, so a restart in a fight starts a fresh count.
  • No monster in range: nothing changes, and nav and looting don't get the tick at low health.

How it was tested

Run from Tools\RynthCore.RynthAiHostTests on this branch (heal-grace (#25) plus this):

dotnet build -c Release -r win-x86 -nodeReuse:false          (plugin project and host tests: 0 errors)
dotnet run -c Release -- "heal hold"                         6 tests, 41 checks: 6 passed
dotnet run -c Release -- "heal grace"                        10 tests, 60 checks: 10 passed
dotnet run -c Release                                        1511 tests: 1510 passed, 1 failed

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

New tests: HealHoldTests (6):

  • the release and re-hold timeline;
  • no stance change while released;
  • a caster in Magic still casts;
  • a Magic-stance kit sends no peace switch while released (with a not-released control);
  • the macro-stop reset;
  • no release while a kit animates, though a kit that never animates still releases;
  • no release while a wield is in flight;
  • the released Kit Min Success chance in melee stance.

Checked against deliberately broken code:

  • with the released-chance argument reverted, the chance test fails;
  • with the peace-switch gate limited to non-Magic stances, the Magic-stance kit case fails.

Scope and risk

  • Only in a fight, with health under a heal line and nothing landing for 6 s. Outside that, behaviour is identical.
  • While released, the character does not leave its stance for a heal. If kits and potions are failing too, it fights on at low health in 5 s windows instead of standing still. That is the intent.
  • Overlap with vital-wand-gate (#28). Both branches edit the Stamina Kit Min Success check in AttemptStaminaKitUse. On the vital-wand-gate (#28) branch that method becomes AttemptStaminaKit(bool ignoreMinSuccess, out bool underMinSuccess). Applying both gives one conflict hunk there. The resolution keeps both changes:
if (!ignoreMinSuccess && !KitChanceOk(kit.Id, kit.Name ?? "", missing, _settings.PeaceModeForKits && !_vitalsNoPeaceSwitch, _settings.StaminaKitMinSuccessPct))
{
    underMinSuccess = true;
    return false;
}
if (_settings.PeaceModeForKits && mode != CombatMode.NonCombat && _host.HasChangeCombatMode && !_vitalsNoPeaceSwitch)

All four branches applied together with that resolution build, and the host tests give 1534 tests, 1533 passed, with only map bake failing.

🤖 Generated with Claude Code

Stacks on heal-grace (#25): review/apply that first. ## What went wrong in play A melee character with a shield went to Buffing at 48% health and stopped attacking the boss. It stood there for 17 s re-sending a healing kit the server no longer had, then died. Health under a heal line wins the arbiter's tick by itself (`WantsVitalRecharge`). That is right while heals land and wrong when none does: nothing healed, and nothing fought either. ## The fix `Combat/BuffManager.HealHold.cs` (new), wired into `OnHeartbeat`, `WantsVitalRecharge` and `CheckVitals`: - **The release.** In a fight (a monster within Monster Range, `InCombatNow`), 6 s under a heal line with no heal landing hands combat the tick for 5 s. After that the vitals hold it again. - A heal landing means health up 3 points, the HP failsafe's own test. - A heal landing, or health back over the line, ends the episode. - 6 s is VirindiTank's give-up for one kit: 3 s to start, 3 s for the result. - **Kits and potions keep going.** The vitals step still runs every tick meanwhile. While combat has the tick, though, it makes no stance change or wield for a vital: - no wand swap for Heal Self; - no peace switch for a kit in any stance, including Magic with Use Kits in Magic Mode; - a caster already in Magic stance still casts its heal spell. - **Kit chance in the current stance.** With no peace switch going out, Kit Min Success (and Stamina Kit Min Success) is computed in the stance the character is in, not as if in peace. - **A heal under way finishes first.** A release waits for: - a kit whose heal motion has played (heal-grace (#25)'s `NoteKitProgress`, which is why this stacks on heal-grace (#25)); - a wand wield in flight. - **The hold resets whenever the macro is off**, on the stop and on the HP failsafe's recall stop, so a restart in a fight starts a fresh count. - **No monster in range:** nothing changes, and nav and looting don't get the tick at low health. ## How it was tested Run from `Tools\RynthCore.RynthAiHostTests` on this branch (heal-grace (#25) plus this): ``` dotnet build -c Release -r win-x86 -nodeReuse:false (plugin project and host tests: 0 errors) dotnet run -c Release -- "heal hold" 6 tests, 41 checks: 6 passed dotnet run -c Release -- "heal grace" 10 tests, 60 checks: 10 passed dotnet run -c Release 1511 tests: 1510 passed, 1 failed ``` The one failure is `map bake: 0x6346 ...`, the same one pristine main has (1494/1495). New tests: `HealHoldTests` (6): - the release and re-hold timeline; - no stance change while released; - a caster in Magic still casts; - a Magic-stance kit sends no peace switch while released (with a not-released control); - the macro-stop reset; - no release while a kit animates, though a kit that never animates still releases; - no release while a wield is in flight; - the released Kit Min Success chance in melee stance. Checked against deliberately broken code: - with the released-chance argument reverted, the chance test fails; - with the peace-switch gate limited to non-Magic stances, the Magic-stance kit case fails. ## Scope and risk - Only in a fight, with health under a heal line and nothing landing for 6 s. Outside that, behaviour is identical. - While released, the character does not leave its stance for a heal. If kits and potions are failing too, it fights on at low health in 5 s windows instead of standing still. That is the intent. - **Overlap with vital-wand-gate (#28).** Both branches edit the Stamina Kit Min Success check in `AttemptStaminaKitUse`. On the vital-wand-gate (#28) branch that method becomes `AttemptStaminaKit(bool ignoreMinSuccess, out bool underMinSuccess)`. Applying both gives one conflict hunk there. The resolution keeps both changes: ``` if (!ignoreMinSuccess && !KitChanceOk(kit.Id, kit.Name ?? "", missing, _settings.PeaceModeForKits && !_vitalsNoPeaceSwitch, _settings.StaminaKitMinSuccessPct)) { underMinSuccess = true; return false; } if (_settings.PeaceModeForKits && mode != CombatMode.NonCombat && _host.HasChangeCombatMode && !_vitalsNoPeaceSwitch) ``` All four branches applied together with that resolution build, and the host tests give 1534 tests, 1533 passed, with only `map bake` failing. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
"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>
Health under a heal line holds the arbiter on Buffing by itself. A melee
character with a shield was held in Buffing for 17 s with no heal
landing (a used-up kit re-sent), stopped attacking the boss and died.

Now, in a fight (a monster within Monster Range), 6 s under a heal line
with no heal landing (health up 3 points, the HP failsafe's test) hands
combat the tick for 5 s, then the vitals hold it again; a heal landing or
health over the line ends the episode. 6 s is VirindiTank's give-up for
one kit (3 s to start, 3 s for the result).

- The vitals step still runs every tick meanwhile (kits and potions go),
  but makes no stance change or wield for a vital while combat has the
  tick: no wand swap for Heal Self, and no peace switch for a kit in any
  stance (Magic included, with Use Kits in Magic Mode). A caster already
  in Magic stance casts its heal spell as before.
- With no peace switch going out, Kit Min Success (and Stamina Kit Min
  Success) is computed in the current stance, not as if in peace.
- A release waits for a heal under way: a kit whose heal motion has played
  (heal grace's NoteKitProgress), or a wand wield in flight.
- The hold resets whenever the macro is off (the stop, and the HP
  failsafe's recall stop), so a restart in a fight starts a fresh count.

Tests: HealHoldTests (new, 6).

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.HealHold.cs
  • Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.cs
  • Plugins/Shared/ActionPacer.cs
  • Tools/RynthCore.RynthAiHostTests/Program.cs
  • Tools/RynthCore.RynthAiHostTests/Tests/HealGraceTests.cs
  • Tools/RynthCore.RynthAiHostTests/Tests/HealHoldTests.cs
  • Tools/RynthCore.RynthAiHostTests/Tests/StuckCastTests.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 heal-hold:AwfulWaffle-heal-hold
git switch AwfulWaffle-heal-hold

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-heal-hold
git switch AwfulWaffle-heal-hold
git rebase main
git switch main
git merge --ff-only AwfulWaffle-heal-hold
git switch AwfulWaffle-heal-hold
git rebase main
git switch main
git merge --no-ff AwfulWaffle-heal-hold
git switch main
git merge --squash AwfulWaffle-heal-hold
git switch main
git merge --ff-only AwfulWaffle-heal-hold
git switch main
git merge AwfulWaffle-heal-hold
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!26
No description provided.