fix(rynthai): respect 45s PetDevice cooldown; no false pet-assume on failed Use
Combat summon stuck after death/despawn when a refused Use left Structure unchanged: old path assumed a pet and parked only ~30s. Park every Use for 45s from IssueSummon; failed timeouts clear assume and do not restart the park. ProductVersion 2026.10.16.5 (HandWrittenVersion stays 0.5.0-legacy-ui).
This commit is contained in:
parent
10e0050b9f
commit
ee846559fe
5 changed files with 126 additions and 22 deletions
32
Changelog/2026-10-16-pet-summon-45s-cooldown-2026.10.16.5.md
Normal file
32
Changelog/2026-10-16-pet-summon-45s-cooldown-2026.10.16.5.md
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# 2026.10.16.5 - Pet summon: 45 s essence cooldown, no false “pet out”
|
||||
|
||||
Previous: RynthAi ProductVersion 2026.10.16.4 (HandWrittenVersion stays `0.5.0-legacy-ui` on `sk`).
|
||||
|
||||
## Problem
|
||||
|
||||
Kelpie: combat summon sometimes stuck or failed after a pet died / despawned. A Use the
|
||||
server refused (still on the retail ~45 s PetDevice cooldown, incline, busy, etc.) never
|
||||
drops Structure and never spawns a pet. The old path still assumed a pet for ~10 s and
|
||||
parked the essence only ~30 s — short of the cooldown — so the next try timed out again
|
||||
and left gaps between resummons.
|
||||
|
||||
## Fix (PetManager)
|
||||
|
||||
- Park every essence Use for **45 s** from IssueSummon (ACE / Summoning wiki PetDevice CD).
|
||||
- On action timeout with no charge drop and no live pet: treat as **failed Use** — clear
|
||||
`_assumePetActiveUntil`, do **not** restart the 45 s park from the timeout (that would
|
||||
wait ~53 s).
|
||||
- If the assume window is open but the pet is gone (death / despawn), clear it so the
|
||||
cooldown can finish and resummon.
|
||||
- Ignore Corpse / non-creature landscape objects named like the pet.
|
||||
- “Not enough charges” still clears / shortens the Use park so refill can run.
|
||||
- Host test: `pets: failed summon … waits the 45 s essence cooldown`.
|
||||
|
||||
## Files
|
||||
|
||||
- Plugins/RynthCore.Plugin.RynthAi/Combat/PetManager.cs
|
||||
- Tools/RynthCore.RynthAiHostTests/Tests/PetRefillTests.cs
|
||||
|
||||
## Deploy
|
||||
|
||||
`dotnet publish` RynthAi `-p:Version=2026.10.16.5` → `C:\Games\RynthSuite\RynthAi\`
|
||||
|
|
@ -22,7 +22,8 @@ namespace RynthCore.Plugin.RynthAi;
|
|||
/// Behaviour (per user spec):
|
||||
/// * Summon only when mobs are near — at least <c>PetMinMonsters</c> scanned,
|
||||
/// attackable monsters within <c>CustomPetRange</c> — and no pet is currently
|
||||
/// active. Re-summon when the pet despawns mid-fight.
|
||||
/// active. Re-summon when the pet despawns mid-fight (lifespan / death), after
|
||||
/// the essence's retail ~45 s use cooldown (Summoning wiki / ACE PetDevice).
|
||||
/// * Auto-refill an empty essence from an Encapsulated Spirit in inventory
|
||||
/// (gated on <c>PetAutoRefill</c>).
|
||||
///
|
||||
|
|
@ -30,6 +31,12 @@ namespace RynthCore.Plugin.RynthAi;
|
|||
/// guarded, one in-flight action at a time. Entirely plugin-side; the only AC
|
||||
/// actions issued are <c>Host.UseObject</c> (summon) and <c>Host.UseObjectOn</c>
|
||||
/// (refill), both selection-free.
|
||||
///
|
||||
/// Stuck/fail (Kelpie 2026-10-16): a Use that the server refused (cooldown, incline,
|
||||
/// busy) never drops Structure and never spawns a pet. The old path still assumed a
|
||||
/// pet for 10 s and parked the essence only 30 s — short of the 45 s item cooldown —
|
||||
/// so the next try timed out again. Failed summons no longer assume a pet; every
|
||||
/// Use parks the essence for <see cref="DeviceUseCooldownMs"/>.
|
||||
/// </summary>
|
||||
internal sealed class PetManager
|
||||
{
|
||||
|
|
@ -76,8 +83,14 @@ internal sealed class PetManager
|
|||
|
||||
private const long ThinkIntervalMs = 1000;
|
||||
private const long ActionTimeoutMs = 8000;
|
||||
private const long AssumeActiveAfterSummonMs = 10_000;
|
||||
private const long DeviceFailCooldownMs = 30_000;
|
||||
/// <summary>Brief hold after a confirmed summon until the pet lands in the landscape cache.</summary>
|
||||
private const long AssumeActiveAfterSummonMs = 5_000;
|
||||
/// <summary>
|
||||
/// Retail / ACE PetDevice use cooldown (~45 s). Applies after every Use we fire — success
|
||||
/// or fail — so we do not re-Use while the server still refuses the essence.
|
||||
/// </summary>
|
||||
private const long DeviceUseCooldownMs = 45_000;
|
||||
private const long DeviceFailCooldownMs = DeviceUseCooldownMs; // alias: failed Use still burns the CD
|
||||
private const long DeviceNoSpiritCooldownMs = 15_000;
|
||||
private const long ServerSaidFullTrustMs = 30 * 60_000;
|
||||
private const long RefillWindowMs = 120_000; // two refills inside this and the
|
||||
|
|
@ -158,13 +171,25 @@ internal sealed class PetManager
|
|||
// decrement that never lands), and waiting on it would wedge the subsystem.
|
||||
if (_state != PetState.Idle && now - _actionIssuedAt > ActionTimeoutMs)
|
||||
{
|
||||
RynthLog.Write(LogCat.Pets, $"[RynthAi] Pet: action timeout in {_state} after {now - _actionIssuedAt}ms (essence 0x{(uint)_activeDeviceId:X8}); cooling down.");
|
||||
if (_activeDeviceId != 0)
|
||||
_deviceCooldownUntil[_activeDeviceId] = now + DeviceFailCooldownMs;
|
||||
// A summon that we simply couldn't confirm very likely DID work — assume
|
||||
// a pet for a bit so we don't immediately re-issue into "already active".
|
||||
if (_state == PetState.Summoning)
|
||||
bool summonConfirmed = _state == PetState.Summoning
|
||||
&& (SummonLanded() || IsPetActive());
|
||||
// Host.Log so FakeHost / in-game logs see it; RynthLog for the Pets category file.
|
||||
string timeoutMsg =
|
||||
$"[RynthAi] Pet: action timeout in {_state} after {now - _actionIssuedAt}ms (essence 0x{(uint)_activeDeviceId:X8})"
|
||||
+ (summonConfirmed
|
||||
? "; summon confirmed late."
|
||||
: "; no charge drop / no pet — treating as failed Use.");
|
||||
_host.Log(timeoutMsg);
|
||||
RynthLog.Write(LogCat.Pets, timeoutMsg);
|
||||
// Do NOT restart DeviceUseCooldownMs here — IssueSummon already parked the essence
|
||||
// from the Use instant. Re-arming from timeout would wait ~53 s and leave gaps
|
||||
// after a refused Use (Kelpie stuck/fail).
|
||||
// Only assume a pet when the Use clearly landed; a failed Use must not block
|
||||
// resummon after the cooldown (false assume + short park left gaps).
|
||||
if (summonConfirmed)
|
||||
_assumePetActiveUntil = now + AssumeActiveAfterSummonMs;
|
||||
else if (_state == PetState.Summoning)
|
||||
_assumePetActiveUntil = 0;
|
||||
Reset();
|
||||
return;
|
||||
}
|
||||
|
|
@ -196,10 +221,15 @@ internal sealed class PetManager
|
|||
{
|
||||
_host.Log($"[RynthAi] Pet: essence 0x{(uint)_activeDeviceId:X8} reports empty; will refill.");
|
||||
_serverSaidFullUntil.Remove(_activeDeviceId); // really empty: the read is right again
|
||||
// The server-side pyreal refill didn't happen (charm off / no pyreals):
|
||||
// park the essence so the empty-summon path can't spin on it.
|
||||
if (AllowSummonOnEmpty?.Invoke() == true && _activeDeviceId != 0)
|
||||
_deviceCooldownUntil[_activeDeviceId] = NowMs + DeviceNoSpiritCooldownMs;
|
||||
// Empty Use does not burn the retail 45 s spawn cooldown the way a real summon
|
||||
// does; drop the Use park so the next think can refill (or re-try pyreal path).
|
||||
if (_activeDeviceId != 0)
|
||||
{
|
||||
if (AllowSummonOnEmpty?.Invoke() == true)
|
||||
_deviceCooldownUntil[_activeDeviceId] = NowMs + DeviceNoSpiritCooldownMs;
|
||||
else
|
||||
_deviceCooldownUntil.Remove(_activeDeviceId);
|
||||
}
|
||||
GoIdle();
|
||||
return;
|
||||
}
|
||||
|
|
@ -226,8 +256,15 @@ internal sealed class PetManager
|
|||
private void TryBeginAction(long now)
|
||||
{
|
||||
// A pet is already up (just summoned, or detected in the world) — done.
|
||||
if (now < _assumePetActiveUntil) return;
|
||||
if (IsPetActive())
|
||||
// If the assume window is still open but the pet is gone (despawn / death), clear it
|
||||
// so we can wait on the essence cooldown and resummon.
|
||||
bool petOut = IsPetActive();
|
||||
if (now < _assumePetActiveUntil)
|
||||
{
|
||||
if (petOut) return;
|
||||
_assumePetActiveUntil = 0;
|
||||
}
|
||||
if (petOut)
|
||||
{
|
||||
// A cosmetic pet in the slot steps aside for the fight; wait for the dismiss to land.
|
||||
if (YieldPetForCombat != null && MonstersNearby() && YieldPetForCombat())
|
||||
|
|
@ -298,15 +335,18 @@ internal sealed class PetManager
|
|||
private void IssueSummon(int deviceId, int charges)
|
||||
{
|
||||
// Don't fire the essence-use while a cast gesture is animating — AC
|
||||
// refuses item use mid-gesture, which would burn the 8s timeout and a
|
||||
// 30s device park for nothing. No state change; caller retries next tick.
|
||||
// refuses item use mid-gesture, which would burn the 8s timeout and the
|
||||
// 45 s essence cooldown for nothing. No state change; caller retries next tick.
|
||||
if (!_host.CanCastNow) return;
|
||||
long now = NowMs;
|
||||
_state = PetState.Summoning;
|
||||
_activeDeviceId = deviceId;
|
||||
_activeSpiritId = 0;
|
||||
_preActionCharges = charges;
|
||||
_actionIssuedAt = NowMs;
|
||||
RynthLog.Write(LogCat.Pets, $"[RynthAi] Pet: summoning from essence 0x{(uint)deviceId:X8} (charges={charges}).");
|
||||
_actionIssuedAt = now;
|
||||
// Server starts the PetDevice cooldown on Use, whether the pet spawns or not.
|
||||
_deviceCooldownUntil[deviceId] = now + DeviceUseCooldownMs;
|
||||
RynthLog.Write(LogCat.Pets, $"[RynthAi] Pet: summoning from essence 0x{(uint)deviceId:X8} (charges={charges}); essence cooldown {DeviceUseCooldownMs / 1000}s.");
|
||||
_host.UseFor(unchecked((uint)deviceId), "Pet", "summon a pet from the essence");
|
||||
}
|
||||
|
||||
|
|
@ -455,9 +495,14 @@ internal sealed class PetManager
|
|||
foreach (var wo in _objectCache.GetLandscape())
|
||||
{
|
||||
if (wo == null) continue;
|
||||
// Corpses keep the pet's name briefly; don't treat them as a live summon.
|
||||
if (wo.ObjectClass == AcObjectClass.Corpse) continue;
|
||||
if (wo.ObjectClass is not (AcObjectClass.Monster or AcObjectClass.CombatPet or AcObjectClass.Unknown))
|
||||
continue;
|
||||
string n = wo.Name;
|
||||
if (!string.IsNullOrEmpty(n) && n.StartsWith(prefix, StringComparison.Ordinal))
|
||||
return true;
|
||||
if (string.IsNullOrEmpty(n) || !n.StartsWith(prefix, StringComparison.Ordinal)) continue;
|
||||
if (n.Contains("Corpse", StringComparison.OrdinalIgnoreCase)) continue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ internal static class PetRefillTests
|
|||
r.Add("pets: 'not enough charges' after a confirmed refill ends the trust; refill again", TrustEndsOnEmptySummon);
|
||||
r.Add("pets: refilled twice in 2 min and still empty (no reply) -> parked 5 min", SilentRefillsParked);
|
||||
r.Add("pets: the server's 'full' trust expires after 30 min", TrustExpires);
|
||||
r.Add("pets: failed summon (no charge drop) does not assume a pet; waits the 45 s essence cooldown", FailedSummonRespectsCooldown);
|
||||
}
|
||||
|
||||
// ── Rig ───────────────────────────────────────────────────────────────
|
||||
|
|
@ -191,8 +192,32 @@ internal static class PetRefillTests
|
|||
int refills = rig.Refills;
|
||||
Check.Eq(refills, 1, "trusted: no second refill");
|
||||
// No summon lands (no pet appears, the read never moves): each summon times out and
|
||||
// parks the essence for 30 s. After 30 minutes the trust is gone and the read rules.
|
||||
// parks the essence for the 45 s PetDevice cooldown. After 30 minutes the trust is gone.
|
||||
rig.Run(31 * 60_000);
|
||||
Check.True(rig.Refills > refills, "after 30 minutes the empty read is believed again");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kelpie 2026-10-16: Use refused (cooldown / environment) leaves Structure unchanged.
|
||||
/// Must not assume a pet is out, and must wait the full ~45 s essence cooldown before retry.
|
||||
/// </summary>
|
||||
private static void FailedSummonRespectsCooldown()
|
||||
{
|
||||
using var rig = new Rig(charges: 50);
|
||||
rig.Run(1500);
|
||||
Check.Eq(rig.Summons, 1, "first Use fired");
|
||||
// Structure never drops and no pet appears → timeout treats it as a failed Use.
|
||||
Rig.SetCharges(50);
|
||||
rig.Run(9_000);
|
||||
Check.Eq(rig.Summons, 1, "still one Use during the 45 s cooldown (no false re-issue)");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("failed Use", StringComparison.OrdinalIgnoreCase)
|
||||
|| l.Contains("no charge drop", StringComparison.OrdinalIgnoreCase)),
|
||||
"failed Use is logged");
|
||||
// Park is from IssueSummon (~t=100 ms), not from the 8 s timeout. At ~44 s from start
|
||||
// still cooling; a few seconds more clears the 45 s essence cooldown.
|
||||
rig.Run(34_000);
|
||||
Check.Eq(rig.Summons, 1, "still cooling at ~44 s from first Use");
|
||||
rig.Run(4_000);
|
||||
Check.Eq(rig.Summons, 2, "second Use after the 45 s essence cooldown");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
1
installer/previous-release/last-built-version.txt
Normal file
1
installer/previous-release/last-built-version.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
2026.10.16.5
|
||||
1
installer/previous-release/previous-version.txt
Normal file
1
installer/previous-release/previous-version.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
2026.10.16.4
|
||||
Loading…
Reference in a new issue