Recast a buff at a higher level once one becomes castable

The buff level comes from the live buffed skill (SpellManager.ComputeTier over
BuffMinSkillLevelTier1..8) and the spellbook. Inside a force or batch run a family
cast earlier in the run read active, so Creature Enchantment Mastery, Focus and
Willpower cast at the level the skill allowed before they landed stayed there for
the whole run; between passes a failed upgrade could arm the landed-tier cap and
lose the upgrade until the plugin reloaded.

- In a run, a family already cast reads active only while the level castable now is
  not strictly higher than the level the run CONFIRMED for it; a higher level is cast
  again right away (after the priority buffs). Never lower.
- The attempted tier kept since load is written on confirmation, so a fizzled or refused
  upgrade is cast again at the next opportunity, in the run or on the next pass.
- No try cap, and no rest after a fizzle, a client refusal or a no-show; a server mana or
  component refusal still rests the family as it does for any buff. Casting thresholds
  are consistent, so the bot keeps trying until it lands. Pacing stays: a client-refused cast waits
  SpellCastIntervalMs, and a fizzled upgrade is sent once per server answer, never
  while one is unanswered.
- While the pending cast is an upgrade, the registry counts the family as landed only
  when its entry moved (a later expiry, or the pending level or higher). A late "You
  cast" line for a lower level, or one the cast tracker credits to an earlier send,
  does not confirm the pending upgrade.
- An upgrade's no-show is never a silent-no-show strike, a 30 min park or a
  blacklist entry, so the lower level it was cast over is still recast when it runs low.
- One "[Buff] upgrade: <buff> level a -> b" line per cast that replaces an active
  lower level (BuffUpgrades counts them), at the same effective level IsBuffActive
  uses: refreshing an Incantation that lands a level low is not an upgrade.
- A scroll read that teaches a spell ("The scroll is destroyed.") makes the next buff
  check read the spellbook at once.
- Integrates with the mana reserve hold (BuffWaitsForMana): the hold runs first, on
  the upgrade's own spell id, so an upgrade that would leave mana under the reserve
  is not sent, counted or logged; Stamina to Mana goes and the upgrade follows.

Tests: in-run order, next-pass upgrade with equal-level and lower-skill controls,
the scroll case, fizzle and refusal retries (run, next pass, heartbeat, client
refusal pacing), registry no-shows, late lines, no park on no-shows (self and item
spells), and an upgrade held by the mana reserve (fails with the hold disabled).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Daniel Wallace 2026-10-12 16:26:22 -07:00
commit 88502d4efa
3 changed files with 879 additions and 51 deletions

View file

@ -126,9 +126,10 @@ public class BuffManager : IDisposable
// a buff bot's level 8 expiring over our own fresh VI (2026-10-05). Permanent marks an
// item-granted entry (no expiry), which CastBuffsOverItemBuffs leaves out.
private readonly Dictionary<int, List<(int Level, DateTime Expiration, bool Permanent)>> _familyLiveEntries = new();
// Highest tier this session has CAST per family (nominal level). The achieved-tier cap
// applies only once the target tier has been tried, so a family deliberately cast low
// first (the tier-7 creature bootstrap before 8s) still upgrades.
// Highest tier CONFIRMED per family since load (nominal level; written on the cast's
// confirmation, so a fizzled or refused try doesn't count). The achieved-tier cap applies
// only once the target tier has gone through, so a family deliberately cast low first (the
// tier-7 creature bootstrap before 8s) still upgrades, and a failed upgrade is retried.
private readonly Dictionary<int, int> _familyAttemptedTier = new();
/// <summary>Keyed by (objectId, spellFamily) packed as long.</summary>
private readonly Dictionary<long, ItemBuffTimerInfo> _itemBuffTimers = new();
@ -144,6 +145,13 @@ public class BuffManager : IDisposable
// Force Rebuff cycle tracking — when set, IsBuffActive consults this instead
// of the live timer dicts so FR re-casts every spell to align all timers.
private readonly HashSet<int> _forceRebuffCastFamilies = new();
// The level each family CONFIRMED at in this run (the highest), written only where the family
// joins _forceRebuffCastFamilies; an upgrade that fizzles or is refused leaves it alone.
private readonly Dictionary<int, int> _runConfirmedLevelByFamily = new();
// The buff cast in flight that is an upgrade (a lower level of its family was on), 0 = none.
// A failed upgrade is not counted or rested; it is cast again at the next opportunity, paced
// like any cast.
private int _pendingUpgradeSpellId;
// Per-family diagnostic throttle — last reason string we logged. Suppresses
// dup spam when IsBuffActive is polled every tick by NeedsAnyBuff + CheckAndCastSelfBuffs.
@ -862,7 +870,7 @@ public class BuffManager : IDisposable
{
_isForceRebuffing = true;
_isAutoBatchRebuff = false;
_forceRebuffCastFamilies.Clear();
ClearRunFamilies();
_buffFailCooldownUntil.Clear(); // explicit recast-all must not be blocked by stale cooldowns
_silentNoShowCounts.Clear(); // give parked families a fresh shot on FR too
_unsatisfiedStrikes.Clear(); // ditto for the post-batch satisfaction audit
@ -1283,12 +1291,23 @@ public class BuffManager : IDisposable
&& expiryThen > issuedAt // it was on when we cast
&& st!.Expiration <= expiryThen.AddSeconds(2)) // and hasn't been refreshed
active = false;
// An upgrade is cast over its own lower level, so the family is "on" whatever
// happened, at the give-up as well: it landed only when the entry MOVED (a later
// expiry, or the pending level or higher; an Incantation landing a level low shows
// a lower level, so for one it is the expiry that moves). Unmoved: a no-show.
if (active && _pendingSpellId == _pendingUpgradeSpellId)
{
bool later = _expiryAtCastByFamily.TryGetValue(pendingSpell.Family, out DateTime upThen)
&& st!.Expiration > upThen.AddSeconds(2);
bool higher = st!.SpellLevel >= GetSpellLevel(pendingSpell);
active = later || higher;
}
if (active)
{
// During an auto-batch / force-rebuff, IsBuffActive gates on
// _forceRebuffCastFamilies (not timers), so the family MUST be
// marked cast here or the batch respins this buff forever.
if (_isForceRebuffing) _forceRebuffCastFamilies.Add(pendingSpell.Family);
NoteBuffConfirmed(pendingSpell);
_cast.Confirmed(_pendingSpellId, "confirmed in the enchantment registry");
_pendingSpellId = 0; // landed — registry confirms it; advance
NoteCastAccepted(); // it went through — end any too-busy backoff
@ -1300,27 +1319,39 @@ public class BuffManager : IDisposable
// A WARM snapshot already excludes unknown tiers, so a no-show
// is lag/fizzle → retry (NO blacklist). A COLD snapshot has no
// other tier-down signal → blacklist this id to drop a tier.
bool cold = !_spellManager.IsKnownSnapshotWarm;
if (cold) _spellManager.MarkSpellUnresolvable(_pendingSpellId);
// Per-family silent-no-show bookkeeping (the /god loop break).
// Increment regardless of warmth — even the "warm → retry" path
// needs an upper bound, otherwise a buff whose family is in the
// dynamic list but can never actually land loops forever.
// An upgrade's no-show ends that attempt and nothing else: no strike, no 30 min park,
// no blacklist (any of them would delay the next try and the lower level it was cast
// over). Read before EndPendingUpgrade clears the pending upgrade.
bool isUpgrade = _pendingSpellId == _pendingUpgradeSpellId;
int fam = pendingSpell.Family;
int noShowCount = _silentNoShowCounts.TryGetValue(fam, out int prev) ? prev + 1 : 1;
_silentNoShowCounts[fam] = noShowCount;
bool parked = false;
if (noShowCount >= SilentNoShowThreshold)
if (isUpgrade)
{
_buffFailCooldownUntil[fam] = DateTime.Now + SilentNoShowCooldown;
parked = true;
_host.Log($"[BuffDiag] upgrade '{pendingSpell.Name}' (id={_pendingSpellId}, fam={fam}) not in the live registry after {sinceCastMs:0}ms (the lower level is unchanged): no strike, tried again.");
}
else
{
bool cold = !_spellManager.IsKnownSnapshotWarm;
if (cold) _spellManager.MarkSpellUnresolvable(_pendingSpellId);
_host.Log($"[BuffDiag] self-buff '{pendingSpell.Name}' (id={_pendingSpellId}, fam={fam}) absent from live registry after {sinceCastMs:0}ms — " +
(cold ? "cold snapshot → blacklisted, tier-down." : "warm snapshot → retry (lag/fizzle).") +
$" noShows={noShowCount}/{SilentNoShowThreshold}" +
(parked ? $" — family parked {SilentNoShowCooldown.TotalMinutes:0}min." : ""));
// Per-family silent-no-show bookkeeping (the /god loop break).
// Increment regardless of warmth — even the "warm → retry" path
// needs an upper bound, otherwise a buff whose family is in the
// dynamic list but can never actually land loops forever.
int noShowCount = _silentNoShowCounts.TryGetValue(fam, out int prev) ? prev + 1 : 1;
_silentNoShowCounts[fam] = noShowCount;
bool parked = false;
if (noShowCount >= SilentNoShowThreshold)
{
_buffFailCooldownUntil[fam] = DateTime.Now + SilentNoShowCooldown;
parked = true;
}
_host.Log($"[BuffDiag] self-buff '{pendingSpell.Name}' (id={_pendingSpellId}, fam={fam}) absent from live registry after {sinceCastMs:0}ms — " +
(cold ? "cold snapshot → blacklisted, tier-down." : "warm snapshot → retry (lag/fizzle).") +
$" noShows={noShowCount}/{SilentNoShowThreshold}" +
(parked ? $" — family parked {SilentNoShowCooldown.TotalMinutes:0}min." : ""));
}
EndPendingUpgrade(_pendingSpellId, "no-show");
_pendingSpellId = 0;
_onCastResolved?.Invoke("self-buff no-show (registry)");
}
@ -1340,8 +1371,10 @@ public class BuffManager : IDisposable
{
int stuckId = _pendingSpellId;
var stuck = SpellTableStub.GetById(stuckId);
// An upgrade: no strike, park or blacklist, as on the self-buff path.
bool isUpgrade = stuckId == _pendingUpgradeSpellId;
bool confirmedKnown = _spellManager.IsKnownSnapshotWarm && _spellManager.IsKnownSpellId(stuckId);
if (!confirmedKnown)
if (!confirmedKnown && !isUpgrade)
_spellManager.MarkSpellUnresolvable(stuckId);
// 2026-05-25 — per-family silent-no-show bookkeeping on the
@ -1367,7 +1400,7 @@ public class BuffManager : IDisposable
// there's no armor to bind to.
int fam = stuck?.Family ?? 0;
bool parked = false;
if (fam != 0)
if (fam != 0 && !isUpgrade)
{
int noShowCount = _silentNoShowCounts.TryGetValue(fam, out int prev) ? prev + 1 : 1;
_silentNoShowCounts[fam] = noShowCount;
@ -1380,9 +1413,10 @@ public class BuffManager : IDisposable
_host.Log($"[BuffChat] NO-CHAT TIMEOUT (armor) pending={stuckId} ('{stuck?.Name}') — no chat in " +
$"{NoChatResolveTimeoutMs:0}ms. confirmedKnown={confirmedKnown}. " +
(confirmedKnown ? "Lag/busy — NOT blacklisted." : "Blacklisted → tier-down.") +
(fam != 0 ? $" noShows={_silentNoShowCounts[fam]}/{SilentNoShowThreshold}" : "") +
(isUpgrade ? "An upgrade: no strike, tried again." : confirmedKnown ? "Lag/busy — NOT blacklisted." : "Blacklisted → tier-down.") +
(fam != 0 && !isUpgrade ? $" noShows={_silentNoShowCounts[fam]}/{SilentNoShowThreshold}" : "") +
(parked ? $" — family parked {SilentNoShowCooldown.TotalMinutes:0}min." : ""));
EndPendingUpgrade(_pendingSpellId, "no-chat timeout");
_pendingSpellId = 0;
_onCastResolved?.Invoke("no-chat timeout (armor)");
}
@ -1552,7 +1586,7 @@ public class BuffManager : IDisposable
// every family would read "active"), and the set must still be
// populated — it is what the audit iterates.
AuditBatchSatisfied();
_forceRebuffCastFamilies.Clear();
ClearRunFamilies();
_chain.PassEnd("complete", s => _host.Log(s));
_host.WriteToChat(wasAutoBatch ? "[RynthAi] Rebuff complete." : "[RynthAi] Force Rebuff Complete.", 1);
}
@ -2472,7 +2506,7 @@ public class BuffManager : IDisposable
// cooldowns are short-lived (120s) so they expire on their own.
_isForceRebuffing = true;
_isAutoBatchRebuff = true;
_forceRebuffCastFamilies.Clear();
ClearRunFamilies();
_chain.PassStart();
LogFilterSkips();
}
@ -2555,6 +2589,11 @@ public class BuffManager : IDisposable
if (BuffWaitsForMana(spellId, buffBaseName))
return true;
// An upgrade replaces this family's active lower level (read before the cast is recorded).
var spellInfo = SpellTableStub.GetById(spellId);
int upgradeTo = spellInfo == null ? 0 : IsItemEnchantment(spellInfo.Name) ? GetSpellLevel(spellInfo) : EffectiveTargetLevel(spellInfo);
int upgradeFrom = spellInfo != null && buffFamily != 0 ? ActiveLevelBelow(buffFamily, upgradeTo) : 0;
_pendingSpellId = spellId;
if (buffFamily != 0)
{
@ -2563,9 +2602,13 @@ public class BuffManager : IDisposable
_expiryAtCastByFamily[buffFamily] = CurrentExpiryFor(buffFamily);
}
var spellInfo = SpellTableStub.GetById(spellId);
if (spellInfo != null)
_host.WriteToChat($"[RynthAi] Casting: {spellInfo.Name}", 5);
if (upgradeFrom > 0 && spellInfo != null)
{
BuffUpgrades++;
_host.Log($"[Buff] upgrade: {buffBaseName} level {upgradeFrom} -> {upgradeTo} ({spellInfo.Name}){(_isForceRebuffing ? " in this buff run" : "")}");
}
// NOTE: timers are recorded ONLY on chat confirmation ("you cast X"),
// never optimistically here. An optimistic item-timer at cast time
// left a phantom 1h "active" buff whenever a cast silently failed
@ -2588,16 +2631,12 @@ public class BuffManager : IDisposable
{
_chain.ClientRefused(spellId, spellInfo?.Name ?? buffBaseName, fast, s => _host.Log(s));
}
if (castOk && buffFamily != 0 && spellInfo != null)
{
// Highest tier cast per family this session: IsBuffActive's landed-tier cap only
// applies once the target tier has been tried.
int castLevel = GetSpellLevel(spellInfo);
if (!_familyAttemptedTier.TryGetValue(buffFamily, out int prevAttempt) || castLevel > prevAttempt)
_familyAttemptedTier[buffFamily] = castLevel;
}
// An upgrade in flight (its registry check and no-show handling differ; EndPendingUpgrade
// ends it on a failure).
_pendingUpgradeSpellId = upgradeFrom > 0 ? spellId : 0;
if (!castOk)
{
EndPendingUpgrade(spellId, "the client refused it"); // retried after SpellCastIntervalMs (_lastCastAttempt is set above)
// Local CastSpell rejected — packet never went out, so no chat
// will ever arrive. Clear the gate immediately so the cycle
// doesn't hang on this spell. (No timer to undo — we no longer
@ -2611,6 +2650,9 @@ public class BuffManager : IDisposable
return false;
}
/// <summary>Casts that replaced an active buff of the same family at a lower level (tests, status).</summary>
internal int BuffUpgrades { get; private set; }
private int FindBestSpellId(string baseName, AcSkillType skill)
=> _spellManager.GetDynamicSelfBuffId(baseName, skill);
@ -2830,7 +2872,11 @@ public class BuffManager : IDisposable
// to their own timers.
if (_isForceRebuffing)
{
if (_forceRebuffCastFamilies.Contains(targetSpell.Family)) return true;
// Cast this run: done, unless a strictly higher level is castable now than the one this
// run cast (the priority buffs landed and raised the skill, or a higher spell was
// learned). Never lower: a skill that dropped leaves the run's cast alone.
if (_forceRebuffCastFamilies.Contains(targetSpell.Family))
return !(CastLevelThisRun(targetSpell.Family) is int ran && ran > 0 && GetSpellLevel(targetSpell) > ran);
if (!_isAutoBatchRebuff) return false;
rebufferSecOverride = Math.Max(_settings.RebuffTopOffSecondsRemaining, _settings.RebuffSecondsRemaining);
}
@ -2893,11 +2939,7 @@ public class BuffManager : IDisposable
// skill reaches 8) landed at exactly what was cast; capping it there kept those
// three at 7 while everything after them went to 8. No attempt recorded (fresh
// login) keeps the cap, so a relog doesn't recast every capped Incantation.
int effectiveTarget = targetLevel;
bool triedLowerOnly = _familyAttemptedTier.TryGetValue(targetSpell.Family, out int attempted) && attempted < targetLevel;
if (!triedLowerOnly
&& _familyAchievedTier.TryGetValue(targetSpell.Family, out int achieved) && achieved < effectiveTarget)
effectiveTarget = achieved;
int effectiveTarget = EffectiveTargetLevel(targetSpell);
if (timer.SpellLevel < effectiveTarget)
{
@ -2935,6 +2977,80 @@ public class BuffManager : IDisposable
return false;
}
/// <summary>The level this force/batch run CONFIRMED <paramref name="family"/> at, 0 = none confirmed.</summary>
private int CastLevelThisRun(int family)
=> _runConfirmedLevelByFamily.TryGetValue(family, out int level) ? level : 0;
private void ClearRunFamilies()
{
_forceRebuffCastFamilies.Clear();
_runConfirmedLevelByFamily.Clear();
}
/// <summary>
/// A buff cast went through (chat, enchantment event or registry): the highest level confirmed
/// per family since load (the landed-tier cap's "tried" mark, so a failed upgrade is retried),
/// and in a force/batch run the family is done at that level.
/// </summary>
private void NoteBuffConfirmed(SpellInfo spell)
{
int level = GetSpellLevel(spell);
if (!_familyAttemptedTier.TryGetValue(spell.Family, out int prev) || level > prev)
_familyAttemptedTier[spell.Family] = level;
// The pending upgrade (or better) landed.
if (_pendingUpgradeSpellId != 0 && SpellTableStub.GetById(_pendingUpgradeSpellId) is { } up
&& up.Family == spell.Family && level >= GetSpellLevel(up))
_pendingUpgradeSpellId = 0;
if (!_isForceRebuffing) return;
_forceRebuffCastFamilies.Add(spell.Family);
if (!_runConfirmedLevelByFamily.TryGetValue(spell.Family, out int ran) || level > ran)
_runConfirmedLevelByFamily[spell.Family] = level;
}
/// <summary>
/// The pending upgrade cast <paramref name="spellId"/> did not take (fizzle, refusal, no mana,
/// no-show): it is no longer pending, and it is cast again at the next opportunity. No try cap,
/// and no rest after a fizzle, a client refusal or a no-show; a server mana or component refusal
/// still rests the family as it does for any buff.
/// </summary>
private void EndPendingUpgrade(int spellId, string why)
{
if (spellId == 0 || spellId != _pendingUpgradeSpellId) return;
_pendingUpgradeSpellId = 0;
_host.Log($"[Buff] upgrade to {SpellTableStub.GetById(spellId)?.Name ?? spellId.ToString()} did not take ({why}); cast again at the next opportunity.");
}
/// <summary>
/// The level IsBuffActive holds a player buff to: the target spell's level, capped at the
/// highest level that family has landed at, once the target level has been confirmed and
/// saw it land lower (Incantations that land skill-capped).
/// </summary>
private int EffectiveTargetLevel(SpellInfo targetSpell)
{
int targetLevel = GetSpellLevel(targetSpell);
bool triedLowerOnly = _familyAttemptedTier.TryGetValue(targetSpell.Family, out int attempted) && attempted < targetLevel;
if (!triedLowerOnly && _familyAchievedTier.TryGetValue(targetSpell.Family, out int achieved) && achieved < targetLevel)
return achieved;
return targetLevel;
}
/// <summary>
/// The level of <paramref name="family"/> that is on now (this run's confirmed cast during a
/// force/batch run, else a live timer or an item spell with time left), when it is below
/// <paramref name="newLevel"/>; 0 otherwise. A cast that replaces it is an upgrade.
/// </summary>
private int ActiveLevelBelow(int family, int newLevel)
{
int on = 0;
if (_isForceRebuffing && _forceRebuffCastFamilies.Contains(family)) on = CastLevelThisRun(family);
else if (_ramBuffTimers.TryGetValue(family, out RamTimerInfo? t)
&& !(t.IsPermanent && _settings.CastBuffsOverItemBuffs)
&& (t.IsPermanent || t.Expiration > DateTime.Now))
on = t.SpellLevel;
else if (_itemSpellTimers.TryGetValue(family, out ItemSpellRecord? it) && it.ExpiresAt > DateTime.Now)
on = it.SpellLevel;
return on > 0 && on < newLevel ? on : 0;
}
/// <summary>True when the last live read holds an entry in <paramref name="family"/> at
/// <paramref name="minLevel"/> or above with more than <paramref name="rebufferSec"/> left
/// (a permanent one counts unless CastBuffsOverItemBuffs is on: then only our timed
@ -3715,7 +3831,7 @@ public class BuffManager : IDisposable
// same pump tick, and that chat handler only marks the force-rebuff family
// while _pendingSpellId is still set. Clearing pending here without marking
// it would make an auto-batch respin this buff forever.
if (_isForceRebuffing) _forceRebuffCastFamilies.Add(pendingSpell.Family);
NoteBuffConfirmed(pendingSpell);
_cast.Confirmed(_pendingSpellId, "enchantment landed");
_pendingSpellId = 0;
NoteCastAccepted();
@ -3773,6 +3889,9 @@ public class BuffManager : IDisposable
{
string lower = text.ToLowerInvariant();
// A scroll read that taught a spell (ACE: "The scroll is destroyed."): read the spellbook on
// the next buff check, so a newly learned higher level is cast (an upgrade) at once.
if (text.Trim() == "The scroll is destroyed.") _spellManager.InvalidateKnownSpells();
// Diagnostic: log every chat seen while waiting on a cast confirmation,
// so we can see what AC is actually emitting and adjust our matchers.
@ -3924,6 +4043,7 @@ public class BuffManager : IDisposable
}
_host.Log($"[BuffChat] CLEARED+COOLED pending={_pendingSpellId} ({BuffFailCooldownSec:0}s) — hard rejection in '{text}'");
}
EndPendingUpgrade(_pendingSpellId, "refused");
_pendingSpellId = 0;
_onCastResolved?.Invoke("hard-reject");
return;
@ -3961,6 +4081,7 @@ public class BuffManager : IDisposable
_buffFailCooldownUntil[pendingSpell.Family] = DateTime.Now.AddSeconds(restSec);
}
_host.Log($"[BuffChat] CLEARED pending={_pendingSpellId} - not enough mana; resting the family {restSec:0}s, buffs {LowManaBuffPauseMs / 1000:0}s.");
EndPendingUpgrade(_pendingSpellId, "not enough mana");
_pendingSpellId = 0;
_lowManaPauseUntil = DateTime.Now.AddMilliseconds(LowManaBuffPauseMs);
_onCastResolved?.Invoke("not enough mana");
@ -3985,6 +4106,7 @@ public class BuffManager : IDisposable
_host.Log($"[BuffChat] CLEARED pending={_pendingSpellId} via soft-fail in '{text}'");
}
_lastCastAttempt = DateTime.MinValue;
EndPendingUpgrade(_pendingSpellId, "fizzled");
_pendingSpellId = 0;
_onCastResolved?.Invoke("soft-fail");
return;
@ -4036,6 +4158,21 @@ public class BuffManager : IDisposable
return;
}
// A result naming a LOWER level of the pending family, or naming an earlier cast of ours
// (the cast tracker matched it to another send), is a late line: recorded for that spell,
// and the pending cast keeps waiting for its own result. An Incantation's line names the
// Incantation (BuffTests "You cast Incantation of Strength Self"), so a pending one is not
// exempt; one that never reports is judged by the registry poll at its give-up.
if (pendingInfo != null && spellInfo != null && spellInfo.Family == pendingInfo.Family
&& (GetSpellLevel(spellInfo) < GetSpellLevel(pendingInfo)
|| (tracked != null && tracked.SpellId != _pendingSpellId)))
{
if (IsItemEnchantment(spellInfo.Name)) RecordItemSpellCast(spellInfo);
else RecordSpellTimer(spellInfo);
_host.Log($"[BuffChat] result for '{spellInfo.Name}' is a lower level than pending={_pendingSpellId} ('{pendingInfo.Name}') - a late line, recorded; pending kept.");
return;
}
if (spellInfo != null)
{
_buffFailCooldownUntil.Remove(spellInfo.Family); // it cast — clear any stale hard-fail cooldown
@ -4055,11 +4192,8 @@ public class BuffManager : IDisposable
if (_pendingSpellId != 0)
{
if (_isForceRebuffing)
{
var ps = SpellTableStub.GetById(_pendingSpellId);
if (ps != null) _forceRebuffCastFamilies.Add(ps.Family);
}
var ps = SpellTableStub.GetById(_pendingSpellId);
if (ps != null) NoteBuffConfirmed(ps);
_host.Log($"[BuffChat] CLEARED pending={_pendingSpellId} via ou-cast match name='{spellName}' resolvedId={spellId}");
}
_pendingSpellId = 0;

View file

@ -330,6 +330,9 @@ public class SpellManager
/// </summary>
public bool IsKnownSpellId(int id) => _knownSpellIds.Contains(id);
/// <summary>The next RefreshKnownSpells reads the spellbook at once (a spell was just learned).</summary>
public void InvalidateKnownSpells() => _lastKnownRefreshUtc = DateTime.MinValue;
/// <summary>
/// Refresh the known-spell inventory from the engine's main-thread
/// spellbook snapshot (host ReadKnownSpells). Throttled. Safe no-op if the