RynthSuite as of 2026-11-19 (internal 48a8cc7e): release 2026.11.19.1

This commit is contained in:
Tom Bohar 2026-11-19 21:35:23 -05:00
commit 660e6b5b1c
31 changed files with 1381 additions and 29 deletions

View file

@ -310,6 +310,8 @@ public partial class BuffManager : IDisposable
private const double BusyHealRetryMs = 1500;
// Refusals in a row (with backoff, about 3.5 s or more) before StopCompletely: longer than any real gesture.
private const int BusyStopAtStreak = 4;
// The player's hand-cast refusal line was logged for this run (cleared by a refusal outside one).
private bool _handRefusalLogged;
// "Not enough mana" refusal (see OnChatWindowText): the refused family rests
// briefly and buffing pauses; neither is a silent-no-show strike.
@ -4493,7 +4495,7 @@ public partial class BuffManager : IDisposable
/// <summary>
/// Buffing's built-in list (no buff profile chosen): creature mastery, Focus, Willpower and
/// Life Magic Mastery first, the other creature buffs for usable skills, life protections,
/// Life Magic Mastery first, then Mana Conversion Mastery, the other creature buffs for usable skills, life protections,
/// weapon auras, armor banes. Pump thread: it reads the character's skills.
/// </summary>
internal List<string> BuildBuiltInBuffList() => BuildBuiltInBuffList(out _);
@ -4507,6 +4509,7 @@ public partial class BuffManager : IDisposable
var step2_Focus = new List<string>();
var step3_Willpower = new List<string>();
var step3b_LifeMastery = new List<string>();
var step3c_ManaConversion = new List<string>();
var step4_OtherCreature = new List<string>();
var step5_LifeAndItem = new List<string>();
var step6_WeaponAuras = new List<string>();
@ -4529,6 +4532,12 @@ public partial class BuffManager : IDisposable
}
if (kvp.Value.Contains("Creature Enchantment Mastery"))
step1_CreatureMastery.Add(kvp.Value);
// Right after the four that raise casting skill (R-20261119-195743-1993): Mana Conversion
// lowers what every buff after it costs, and it came near the end of the creature buffs.
// Not before Focus and Willpower: it is a creature spell, and cast before they raise the
// skill it would land a level low and be recast in the same run (the upgrade pass).
else if (kvp.Value == "Mana Conversion Mastery")
step3c_ManaConversion.Add(kvp.Value);
else if (kvp.Value == "Life Magic Mastery")
step3b_LifeMastery.Add(kvp.Value);
else if (!BaseCreatureBuffs.Contains(kvp.Value))
@ -4570,6 +4579,7 @@ public partial class BuffManager : IDisposable
final.AddRange(step2_Focus);
final.AddRange(step3_Willpower);
final.AddRange(step3b_LifeMastery); // the four that raise casting skill and mana come first
final.AddRange(step3c_ManaConversion); // then what cheapens every cast after it
final.AddRange(step4_OtherCreature);
final.AddRange(step5_LifeAndItem);
final.AddRange(step6_WeaponAuras);
@ -4725,6 +4735,23 @@ public partial class BuffManager : IDisposable
// construction → 0x00460D1D killed regardless of gate precision.
if (lower.Contains("you're too busy") || lower.Contains("you are too busy"))
{
// The player casting by hand (2026-11-18, R-20261118-214609-a9a8 / R-20261118-205826-9c70):
// this is the refusal of the player's own click from AC's spell bar, not of anything RynthAi
// sent (RynthAi starts nothing while the player casts, ActionPacer.HandCastHolds). Counting it
// escalated the backoff to 8 s and, at the 4th, sent StopCompletely into the cast that was
// running (the player's, or RynthAi's own), which can drop it. A kit or buff of ours still
// waiting keeps waiting for its own result or give-up time.
if (ActionPacer.HandCasting(_host))
{
ObserveLastUseDone();
if (!_handRefusalLogged)
{
_handRefusalLogged = true;
_host.Log("[BuffChat] 'You're too busy!' answers the player's own cast by hand (AC's spell bar or a hotkey), not RynthAi's: no backoff, no stop, pending kept.");
}
return;
}
_handRefusalLogged = false;
// A kit in flight with no result yet: this is its refusal (see KitRefused). Our bot
// sends nothing else while a kit is pending (CheckVitals returns at KitPending).
if (_kitUsedAt != DateTime.MinValue && _kitLandedAt == DateTime.MinValue

View file

@ -0,0 +1,74 @@
// ============================================================================
// RynthSuite - Combat/CombatManager.OutOfReach.cs
// A target past the attack's reach (2026-11-19, R-20261119-155301-121a, 2026.11.15.3).
//
// Back from a death, a caster held an Olthoi Hive Warrior 88 m off: every Incantation of Force
// Arc at it came back UseDone 0x550 (ACE's MissileOutOfRange, the client's "Out of Range!")
// about 60 ms after the send, and combat cast again at once: 1,027 casts since the last kill,
// about 12 a second, for well over a minute. The no-damage count never got there, because a cast
// sent inside the last one's 500 ms refusal window restarts that window, and the target was in the
// scan because Monster Range reached past the spell's own range. The server's answer says it
// plainly: from here, this attack can't reach it.
//
// Now one such answer drops the target and leaves it out of the scan while it is no nearer than
// OutOfReachCloserM inside the distance it was refused at, for OutOfReachSkipSec at most. Said
// once in chat per target. The hunt still walks toward it (it doesn't read this), so closing in
// brings it back.
// ============================================================================
using System;
using System.Collections.Generic;
namespace RynthCore.Plugin.RynthAi;
public partial class CombatManager
{
/// <summary>ACE's MissileOutOfRange, as a UseDone error ("Out of Range!"): the attack can't reach the target from here.</summary>
internal const uint MissileOutOfRangeErr = 0x550;
/// <summary>A target refused as out of range stays out of the scan at most this long.</summary>
internal const double OutOfReachSkipSec = 60;
/// <summary>...and only while it is no nearer than this inside the distance it was refused at (meters).</summary>
internal const double OutOfReachCloserM = 3;
private readonly Dictionary<int, (double Distance, DateTime Until)> _outOfReach = new();
private int _outOfReachSaidId;
/// <summary>The server answered an attack at <paramref name="target"/> MissileOutOfRange.</summary>
private void NoteOutOfReach(int target)
{
double dist = _worldFilter.Distance(unchecked((int)_playerId), target);
if (dist >= double.MaxValue) return; // no positions: nothing to measure "nearer" against
DateTime now = RynthClock.Now;
if (_outOfReach.Count >= 64) PruneOutOfReach(now);
_outOfReach[target] = (dist, now.AddSeconds(OutOfReachSkipSec));
string name = _worldFilter[target]?.Name ?? $"0x{(uint)target:X8}";
string why = $"out of range at {dist:0} m (the server answered 'Out of Range!', UseDone 0x550): " +
$"left until it is within {Math.Max(0, dist - OutOfReachCloserM):0} m, {OutOfReachSkipSec:0} s at most";
_host.Log($"[CombatTarget] 0x{(uint)target:X8} '{name}' {why}");
if (_outOfReachSaidId != target)
{
_outOfReachSaidId = target;
_host.WriteToChat($"[RynthAi] {name} is out of range at {dist:0} yd: fighting others until it comes closer" +
(dist <= _settings.MonsterRange ? $" (Monster Range {_settings.MonsterRange:0} reaches past the attack)." : "."), 1);
}
if (target == activeTargetId) DropTarget(why);
}
/// <summary>The scan leaves <paramref name="id"/> out: refused as out of range, and no nearer yet.</summary>
private bool IsOutOfReach(int id, double dist)
{
if (_outOfReach.Count == 0 || !_outOfReach.TryGetValue(id, out var e)) return false;
if (RynthClock.Now < e.Until && dist > e.Distance - OutOfReachCloserM) return true;
_outOfReach.Remove(id);
return false;
}
private readonly List<int> _outOfReachPrune = new();
private void PruneOutOfReach(DateTime now)
{
_outOfReachPrune.Clear();
foreach (var kv in _outOfReach)
if (now >= kv.Value.Until) _outOfReachPrune.Add(kv.Key);
foreach (int id in _outOfReachPrune) _outOfReach.Remove(id);
}
}

View file

@ -55,6 +55,7 @@ public partial class CombatManager
internal const string PassedOverNeverAttack = "on the never-attack list";
internal const string PassedOverGhost = "a ghost (the server doesn't have it)";
internal const string PassedOverEnvironment = "left for hitting the environment";
internal const string PassedOverOutOfReach = "out of range of the attack (the server said so), no nearer yet";
internal const string PassedOverNotAttackable = "not attackable";
/// <summary>Tests: the LOS verdict per monster instead of the ray test (true = blocked).</summary>

View file

@ -267,6 +267,9 @@ public partial class CombatManager : IDisposable
// Grace period: keep activeTargetId alive for this long after it disappears from scan,
// so a single bad LOS result or scan gap doesn't hand control to navigation.
private DateTime _targetLostScanTime = DateTime.MinValue;
// The last scan that left the fight target out for a wall in the way: the drop line says why
// (R-20261119-114214-b9ed: "scan grace expired" didn't say it was line of sight).
private DateTime _engagedLosBlockedAt = DateTime.MinValue;
private const double TARGET_SCAN_GRACE_MS = 1500.0;
// The locked target (see HandleCombatTrigger: with Target Lock on it is held until it dies,
@ -1229,6 +1232,13 @@ public partial class CombatManager : IDisposable
continue;
}
// Refused 'Out of Range!' and no nearer since (CombatManager.OutOfReach.cs).
if (IsOutOfReach(wo.Id, dist))
{
if (notePassed) NotePassedOver(wo.Id, dist, PassedOverOutOfReach);
continue;
}
// Just killed (KillerNotification) but not yet a corpse — skip so we
// don't re-lock and cast at it during its death animation.
if (_recentlyKilled.ContainsKey(wo.Id)) continue;
@ -1298,6 +1308,7 @@ public partial class CombatManager : IDisposable
if (losBlocked)
{
_nearbyNoLos++; // in range + attackable but wall-blocked — still stops nav
if (isEngaged) _engagedLosBlockedAt = RynthClock.Now;
if (notePassed) NotePassedOver(wo.Id, dist, PassedOverLos);
continue;
}
@ -1484,6 +1495,7 @@ public partial class CombatManager : IDisposable
private void NoteOffensiveAnswer(int target, uint err)
{
if (target == 0) return;
if (err == MissileOutOfRangeErr) NoteOutOfReach(target); // CombatManager.OutOfReach.cs
if (err != TargetNotAcquiredErr)
{
// A 'too busy' says nothing about the target; any other answer means the server has it.
@ -2000,7 +2012,10 @@ public partial class CombatManager : IDisposable
// count toward the blacklist miss streak. Clear pending silently
// so JudgePendingOffensiveCast's 500ms no-too-busy window stays
// honest, and the next attempt can be issued under the throttle.
if (lo.Contains("you're too busy") || lo.Contains("you are too busy"))
// The player's own click refused while our cast runs (2026-11-18, R-20261118-205826-9c70,
// 15:52:54-58: refusals of 'Casting Incantation of Force Streak' during our Force Arc, which
// hit) is not ours: our cast stays pending and counted.
if ((lo.Contains("you're too busy") || lo.Contains("you are too busy")) && !ActionPacer.HandCasting(_host))
{
_pendingOffensiveSpellId = 0;
_pendingOffensiveTargetId = 0;
@ -2092,8 +2107,10 @@ public partial class CombatManager : IDisposable
// Refused mid-gesture: the debuff never went out, so don't let the result timeout
// mark it as landed. Retry it (counted, so a refusal loop can't run forever).
if (text.IndexOf("you're too busy", StringComparison.OrdinalIgnoreCase) >= 0
|| text.IndexOf("you are too busy", StringComparison.OrdinalIgnoreCase) >= 0)
// Not when it is the player's own cast by hand that was refused (2026-11-18): our debuff is running.
if ((text.IndexOf("you're too busy", StringComparison.OrdinalIgnoreCase) >= 0
|| text.IndexOf("you are too busy", StringComparison.OrdinalIgnoreCase) >= 0)
&& !ActionPacer.HandCasting(_host))
{
NoteDebuffFailed("Refused");
return;
@ -3002,22 +3019,43 @@ public partial class CombatManager : IDisposable
float curHp = tid != 0 ? _worldFilter.GetHealthRatio(tid) : -1f;
bool curServerAlive = curHp > 0f && !_worldFilter.IsHealthEstimated(tid);
bool noticeForNeighbour = otherVictim != 0 && curServerAlive;
if (tid != 0 && curMatches && (noticeForSwappedMob || !curAttacked || noticeForNeighbour))
// 2026-11-18, R-20261118-012228-179f (DreamWeave, melee, a pack of same-named Olthoi): the
// fight target was dropped as dead twice in 4 s while it was alive and fighting. The weapon
// cleaves: each swing hits the target and a same-named neighbour, and in Melee mode every
// damage line naming the target is the target's (ResolveHitVictim), so the neighbour is
// never "hit by us" and FindRecentlyHitVictim finds no one when the neighbour dies. The
// notice was the target's, the target was dropped, kept off the scan for 4 s, and the bot
// swung at the next one (the "dead" target was back in the scan exactly 4 s later). But
// the server said the target was alive: combat's QueryHealth makes it the server's
// selection, so ACE pushes its health with every hit, the lethal one too (DamageHistory.Add
// sends the 0 before OnDeath sends the notice), and a cleave strikes the aimed target first.
// A server health that came with or after our last hit on it, above 0, means the notice is
// a neighbour's even when we can't say which. The health is asked again: a target that did
// die some other way (a damage-over-time tick sends no health) answers 0 and is dropped as
// "hp=0" on the next tick.
bool aliveByFreshHealth = !noticeForNeighbour && tid != 0 && curMatches && curServerAlive
&& _fightTargetId == tid && TryFreshFightHealth(out float freshHp) && freshHp > 0f;
if (tid != 0 && curMatches && (noticeForSwappedMob || !curAttacked || noticeForNeighbour || aliveByFreshHealth))
{
_host.Log($"[RynthAi] Kill notice names 0x{tid:X8} '{curName}' but " +
(noticeForSwappedMob ? $"belongs to predicted kill 0x{pendingKillId:X8}"
: noticeForNeighbour ? $"it is alive ({curHp:0.00}); a neighbour we hit died (0x{otherVictim:X8})"
: aliveByFreshHealth ? $"the server says it is alive ({DescribeFightHealthAge()}); a same-named monster near it died (a cleave, a pet, a ring), not known which; its health is asked again"
: "it hasn't been attacked yet") +
" — keeping the target");
if (noticeForNeighbour)
SuppressGuessedDeath(otherVictim, nowKill);
if (aliveByFreshHealth)
try { if (_host.HasQueryHealth) _host.QueryHealth((uint)tid); } catch { }
}
else if (tid != 0 && curMatches)
{
_recentlyKilled[tid] = nowKill.AddMilliseconds(RECENTLY_KILLED_SUPPRESS_MS);
NoteConfirmedKill(tid, nowKill);
ForgetScanned(tid);
DropTarget("killed (KillerNotification)");
// The server health it was dropped on, so a report shows whether the drop was sure
// (R-20261118-012228-179f).
DropTarget($"killed (KillerNotification; {(_fightTargetId == tid ? DescribeFightHealthAge() : "not the fight being tracked")})");
}
else if (pendingKillId == 0)
{
@ -3376,6 +3414,18 @@ public partial class CombatManager : IDisposable
|| _fightHealthAt >= _fightLastHitAt.AddMilliseconds(-FightHealthHitSlackMs);
}
/// <summary>The fight target's last server health and how old it and our last hit on it are, for
/// the kill-notice log lines (R-20261118-012228-179f): "server health 0.61 40 ms ago, last hit
/// 35 ms ago", or "no server health this fight".</summary>
private string DescribeFightHealthAge()
{
if (_fightHealthAt == DateTime.MinValue) return "no server health this fight";
DateTime now = TargetClock();
string hit = _fightLastHitAt == DateTime.MinValue ? "no hit yet"
: $"last hit {(now - _fightLastHitAt).TotalMilliseconds:0} ms ago";
return $"server health {_fightHealth:0.00} {(now - _fightHealthAt).TotalMilliseconds:0} ms ago, {hit}";
}
/// <summary>
/// The evidence says the cast just fired can't finish the fight target: what is left of it is more
/// than KILL_VETO_REACH casts of <paramref name="perCast"/>. Two sources, either one enough:
@ -3819,7 +3869,9 @@ public partial class CombatManager : IDisposable
_targetLostScanTime = RynthClock.Now;
if ((RynthClock.Now - _targetLostScanTime).TotalMilliseconds > TARGET_SCAN_GRACE_MS)
DropTarget("scan grace expired");
DropTarget((RynthClock.Now - _engagedLosBlockedAt).TotalMilliseconds <= TARGET_SCAN_GRACE_MS
? "scan grace expired (out of sight: the line-of-sight check finds a wall in the way)"
: "scan grace expired");
return true;
}
_targetLostScanTime = DateTime.MinValue; // back in scan — reset grace timer

View file

@ -1018,6 +1018,22 @@ public sealed partial class RynthAiPlugin
}
return;
}
// AutoCram's or AutoStack's move has no answer yet (2026-11-18, R-20261117-230613-88c5). The
// cram runs on the first tick after a corpse is released, and this open went out 1-3 ms
// after it: the client still held the cram in its one pending item request, refused the use
// ("You can only move or use one item at a time") and sent nothing, and the looter waited
// 5 s for an answer before opening it again. The answer takes 50-300 ms; the claim's clock
// stops meanwhile (as for the salvage panel above).
if (ItemMoveHold() is string moveHold)
{
FreezeCorpseTimeout(now);
if (_openHeldByMoveLoggedFor != _targetCorpseId)
{
_openHeldByMoveLoggedFor = _targetCorpseId;
LootDiag($"[RynthAi] Corpse loot: open of 0x{(uint)_targetCorpseId:X8} waits: {moveHold} (the client takes one item action at a time).");
}
return;
}
// A starved turn's open waits for combat's first attack at a target it has just locked
// (2026-11-15, R-20261115-165857-1de7). A monster came into range 0.4 s after the claim,
// the starved turn kept Looting (none within 5 yd), and the open went out 0.3 s after the
@ -1108,6 +1124,7 @@ public sealed partial class RynthAiPlugin
private long _corpseOpenBusyWaitSince;
private bool _openHeldBySalvageLogged;
private int _openHeldByMoveLoggedFor; // the corpse whose open waited for AutoCram's/AutoStack's move (logged once)
private int _openHeldForAttackLoggedFor; // the corpse whose open waited for combat's first attack (logged once)
/// <summary>A starved turn's open waits this long at most for combat's first attack at a fresh lock

View file

@ -497,13 +497,26 @@ internal sealed partial class LegacyDashboardRenderer
RefreshAllLists();
// Load MonsterRules from monsters.json (overrides what was in the profile)
// and migrate existing rules to that file if it doesn't exist yet.
// The Monsters rules belong to the profile (2026-11-18). The MonsterProfiles file is the
// active profile's copy, kept for the Monster Editor and tagged with that profile's name.
// It overrides the profile's rules only when it is this profile's copy (or untagged, from
// before the tag: then it was the one list every profile used). Another profile's copy is
// replaced by this profile's rules. Before, the file always won, so a reload or relog
// brought back the rules last edited under another profile.
MigrateMonstersToFile();
LoadMonstersFromFile();
string? monstersOwner = ReadMonstersOwner();
bool fileIsOurs = monstersOwner == null || monstersOwner.Equals(activeProfile, StringComparison.OrdinalIgnoreCase);
if (fileIsOurs) LoadMonstersFromFile();
// Always re-insert the catch-all "Default" rule at index 0; without it the
// combat system has no fallback weapon/damage selection for unmatched mobs.
_settings.EnsureDefaultRule();
if (!fileIsOurs)
{
_host.Log($"[RynthAi] Monsters: the Monsters file held profile '{monstersOwner}''s rules; using profile '{activeProfile}''s own.");
SaveMonstersFile();
}
else if (monstersOwner == null && File.Exists(MonstersFilePath))
WriteMonstersOwner();
SetupMonsterWatcher();
if (holdUnreadable)
@ -1012,6 +1025,31 @@ internal sealed partial class LegacyDashboardRenderer
LoadMonstersFromFile();
}
// Which profile the MonsterProfiles file belongs to: "<file>.profile", one line, the profile name.
// A separate file so the rules file keeps the shape the Monster Editor reads and writes.
private string MonstersOwnerPath => MonstersFilePath.Length == 0 ? string.Empty : MonstersFilePath + ".profile";
/// <summary>The profile the Monsters file was written for; null when it isn't tagged (or there's no file).</summary>
private string? ReadMonstersOwner()
{
try
{
string path = MonstersOwnerPath;
if (path.Length == 0 || !File.Exists(path)) return null;
string name = File.ReadAllText(path).Trim();
return name.Length > 0 ? name : null;
}
catch { return null; }
}
private void WriteMonstersOwner()
{
string path = MonstersOwnerPath;
string profile = _settings.SelectedProfile ?? string.Empty;
if (path.Length == 0 || profile.Length == 0) return;
try { File.WriteAllText(path, profile); } catch { }
}
/// <summary>Saves the Monsters rules after a change made outside the panel (a chat command).</summary>
public void SaveMonsterRules() => SaveMonstersFile();
@ -1037,6 +1075,7 @@ internal sealed partial class LegacyDashboardRenderer
Directory.CreateDirectory(_monstersFolder);
File.WriteAllText(path, json);
});
WriteMonstersOwner();
if (_monsterWatcher != null)
_monsterWatcher.EnableRaisingEvents = wasEnabled;
@ -1832,6 +1871,7 @@ internal sealed partial class LegacyDashboardRenderer
EnableManaTapping = _settings.EnableManaTapping,
ManaTapMinMana = _settings.ManaTapMinMana,
ManaStoneKeepCount = _settings.ManaStoneKeepCount,
ManaTapMacroOff = _settings.ManaTapMacroOff,
CurrentTargetName = _currentTargetId != 0 ? (_targetLabel ?? string.Empty) : string.Empty,
// The engine's Items face marks these "(missing)"; display only (ApplyItemsJson ignores it).
MissingIds = MissingWeaponIds().OrderBy(id => id).ToList(),
@ -1856,6 +1896,7 @@ internal sealed partial class LegacyDashboardRenderer
_settings.EnableManaTapping = p.EnableManaTapping;
_settings.ManaTapMinMana = p.ManaTapMinMana;
_settings.ManaStoneKeepCount = p.ManaStoneKeepCount;
if (p.ManaTapMacroOff is bool tapMacroOff) _settings.ManaTapMacroOff = tapMacroOff; // an engine without the toggle leaves it
SaveSettings();
}
catch { }
@ -2040,6 +2081,11 @@ internal sealed partial class LegacyDashboardRenderer
_lastSavedJson = string.Empty;
}
// The Monsters rules just loaded are this profile's: the Monsters file (and the Monster
// Editor) now hold them, tagged with this profile, so a reload or relog keeps them.
_settings.EnsureDefaultRule();
SaveMonstersFile();
ApplyUiStateFromSettings();
// Reload nav route for the new profile
@ -2359,6 +2405,7 @@ internal sealed partial class LegacyDashboardRenderer
dst.EnableManaTapping = tmp.EnableManaTapping;
dst.ManaTapMinMana = tmp.ManaTapMinMana;
dst.ManaStoneKeepCount = tmp.ManaStoneKeepCount;
dst.ManaTapMacroOff = tmp.ManaTapMacroOff;
dst.AutoVendorEnabled = tmp.AutoVendorEnabled;
dst.AutoVendorEnableBuying = tmp.AutoVendorEnableBuying;
dst.AutoVendorEnableSelling = tmp.AutoVendorEnableSelling;

View file

@ -839,6 +839,9 @@ public sealed class LegacyUiSettings
public bool EnableManaTapping = true;
public int ManaTapMinMana = 2500;
public int ManaStoneKeepCount = 5;
/// <summary>Mana tap with macro off: refills and drains run with the macro stopped too (on by default;
/// absent from an older profile = on). Off: only while the macro runs.</summary>
public bool ManaTapMacroOff = true;
// ── AutoVendor (UtilityBelt AutoVendor; /ub autovendor, /ub vendor) ────────
/// <summary>Run AutoVendor when a vendor opens (and allow /ub autovendor). UB defaults this on;
@ -1244,6 +1247,8 @@ public sealed class ItemsBridgePayload
public bool EnableManaTapping { get; set; } = true; // absent from an old profile = the new default
public int ManaTapMinMana { get; set; }
public int ManaStoneKeepCount { get; set; }
/// <summary>Mana tap with macro off. Absent (an engine without the toggle) = unchanged.</summary>
public bool? ManaTapMacroOff { get; set; }
public string CurrentTargetName { get; set; } = string.Empty;
/// <summary>Listed weapons the character no longer carries (not in the pack, not wielded), by
/// id: the engine's Items face shows them as missing. Display only, never read back.</summary>

View file

@ -71,6 +71,86 @@ public sealed class InventoryManager
_cache = cache;
}
// ── The last move or merge, until the server answers it (2026-11-18, R-20261117-230613-88c5) ──
// AC lets the client have one item request out at a time: a pack move fills the client's pending
// inventory request slot, and until the server's answer about that item comes back the client
// refuses every use, move and pickup with "You can only move or use one item at a time" and
// sends nothing (RynthCore ClientActionGates). AutoCram runs on the first tick after a corpse is
// released, and the looter claimed and used the next corpse 1-3 ms after the cram's move, four
// times in 100 s in the report: each open was refused, the looter waited 5 s for an answer that
// could never come, then opened the corpse again. So the next item action (a corpse, door or chest
// use, salvage, a mana stone, a pet) waits for this move's answer: the item seen out of the pack it
// was moved from, or out of the stack it was merged from, or the server refusing it
// (InventoryServerSaveFailed naming it). At most MoveAnswerMaxMs, so a lost answer holds nothing
// for long.
private uint _flightId;
private int _flightFrom;
private int _flightStack;
private bool _flightIsMerge;
private int _flightErrSeq;
private DateTime _flightSentAt = DateTime.MinValue;
private string _flightWhat = "";
/// <summary>Longest a move counts as unanswered: answers come in 50-300 ms; this only bounds a lost one.</summary>
internal const double MoveAnswerMaxMs = 3000;
private const uint EventInventoryServerSaveFailed = 0x00A0;
private void NoteMoveSent(uint id, int fromContainer, int stackCount, bool merge, string what)
{
_flightId = id;
_flightFrom = fromContainer;
_flightStack = stackCount;
_flightIsMerge = merge;
_flightErrSeq = LastWeenieErrorSeq();
_flightSentAt = RynthClock.Now;
_flightWhat = what;
}
private int LastWeenieErrorSeq()
{
try { return _host.HasGetLastWeenieError && _host.TryGetLastWeenieError(out int seq, out _, out _, out _) ? seq : 0; }
catch { return 0; }
}
/// <summary>
/// True while AutoCram's or AutoStack's last move has no answer from the server yet: the client
/// refuses any other item action until it has one. <paramref name="what"/> says which move.
/// </summary>
public bool MoveUnanswered(out string what)
{
what = "";
if (_flightId == 0) return false;
double age = (RynthClock.Now - _flightSentAt).TotalMilliseconds;
if (age >= MoveAnswerMaxMs || age < 0 || MoveAnswered())
{
_flightId = 0;
return false;
}
what = $"the {(_flightIsMerge ? "merge" : "move")} of {_flightWhat} sent {age:0} ms ago has no answer yet";
return true;
}
private bool MoveAnswered()
{
int id = unchecked((int)_flightId);
try
{
// The server refused it: InventoryServerSaveFailed names the item (it empties the client's slot too).
if (_host.HasGetLastWeenieError && _host.TryGetLastWeenieError(out int seq, out _, out uint evt, out uint obj)
&& seq != _flightErrSeq && evt == EventInventoryServerSaveFailed && obj == _flightId)
return true;
}
catch { }
// Gone from the client (merged away, destroyed) or out of the pack it was moved from.
int container = _cache.GetContainerId(id);
if (container == 0 || container != _flightFrom) return true;
// A merge that left the source in place: its stack shrank.
if (_flightIsMerge && (_cache[id]?.Values(LongValueKey.StackCount, -999) ?? -999) is int n
&& n != -999 && n != _flightStack)
return true;
return false;
}
// Kept as a no-op for call-site compatibility. Scans are now driven by
// the backoff timer below — we re-scan every 2 seconds when idle, every
// 500 ms after an action, so external "dirty" signals aren't needed.
@ -234,6 +314,7 @@ public sealed class InventoryManager
// Enqueue accepted — record as PENDING and confirm on a later snapshot (do
// NOT blacklist; success and a deferred-but-pending move look identical here).
_cramPending[item.Id] = new Pending { EnqueuedAt = RynthClock.Now, FromContainer = playerId };
NoteMoveSent(unchecked((uint)item.Id), playerId, amount, merge: false, $"'{item.Name}'");
return true; // one action per tick
}
@ -375,6 +456,7 @@ public sealed class InventoryManager
EnqueuedAt = RynthClock.Now, FromContainer = playerId, TargetCount = target.Count, SourceCount = source.Count,
Group = g.Key, Name = source.Item.Name ?? "", Guessed = guessed,
};
NoteMoveSent(unchecked((uint)source.Item.Id), source.Item.Container, source.Count, merge: true, $"'{source.Item.Name}'");
return true; // one action per tick
}

View file

@ -199,7 +199,9 @@ internal sealed class ManaStoneManager
// on for any refill, so charged stones and bought Mana Charges were never used with it
// off (2026-10-08).
if (!_settings.EnableManaTapping && !HasChargedRefillStone()) { Reset(); return; }
if (!_settings.IsMacroRunning) { Reset(); return; }
// Mana tap with macro off (on by default, 2026-11-19): stones refill worn gear and drain
// tap loot while you play by hand too. Off: only while the macro runs, as before.
if (!_settings.IsMacroRunning && !_settings.ManaTapMacroOff) { Reset(); return; }
long now = NowMs;

View file

@ -3749,6 +3749,7 @@ internal sealed partial class ExpressionEngine
["CorpseApproachRangeMax"] = (() => D(s.CorpseApproachRangeMax), v => { if (double.TryParse(v, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double d)) s.CorpseApproachRangeMax = d; }),
["CorpseApproachRangeMin"] = (() => D(s.CorpseApproachRangeMin), v => { if (double.TryParse(v, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double d)) s.CorpseApproachRangeMin = d; }),
["ManaStoneKeepCount"] = (() => I(s.ManaStoneKeepCount), v => { if (int.TryParse(v, out int i)) s.ManaStoneKeepCount = i; }),
["ManaTapMacroOff"] = (() => B(s.ManaTapMacroOff), v => s.ManaTapMacroOff = ToDouble(v) != 0), // Items > Mana Stone Tapping > With macro off
["RebuffSecondsRemaining"] = (() => I(s.RebuffSecondsRemaining), v => { if (int.TryParse(v, out int i)) s.RebuffSecondsRemaining = i; }),
["BlacklistTimeoutSec"] = (() => I(s.BlacklistTimeoutSec), v => { if (double.TryParse(v, NumberStyles.Float, CultureInfo.InvariantCulture, out double d) && d >= 0) s.BlacklistTimeoutSec = (int)Math.Round(d); }),
["RebuffTopOffSecondsRemaining"] = (() => I(s.RebuffTopOffSecondsRemaining), v => { if (int.TryParse(v, out int i)) s.RebuffTopOffSecondsRemaining = i; }),

View file

@ -222,6 +222,26 @@ internal sealed partial class MetaManager
if (_expressions != null) _expressions.CombatTargetCount = count;
}
// Combat's ghosts (GhostTracker: monsters the server no longer has for us), left out of the
// monster-distance conditions like the combat scan leaves them out.
private Func<int, bool>? _isGhostMonster;
public void SetGhostCheck(Func<int, bool>? isGhost) => _isGhostMonster = isGhost;
/// <summary>
/// A monster the monster-distance conditions count: alive or not yet known (no health update),
/// attackable, not a ghost. ACE sends a monster's health only once it is selected, appraised or
/// hit, so most monsters nearby have none; skipping those (2026-04-17 to 11-19) made "no monsters
/// within 30" hold the moment the last monster fought died, with others standing 7 m away
/// (R-20261119-123029-4bd1: a meta's clear-the-site state left and turned combat off). The combat
/// scan and Monster Priority Count have always counted them.
/// </summary>
private bool CountsAsLiveMonster(WorldObjectCache cache, WorldObject obj)
{
if (cache.GetHealthRatio(obj.Id) == 0f) return false; // dead, pending reclassification
if (_host.HasObjectIsAttackable && !_host.ObjectIsAttackable(unchecked((uint)obj.Id))) return false;
return _isGhostMonster?.Invoke(obj.Id) != true;
}
// The last chest looted to the end, for ralastchestlooted[].
private Func<uint>? _lastChestLooted;
public void SetLastChestLooted(Func<uint>? lastChest)
@ -761,9 +781,7 @@ internal sealed partial class MetaManager
{
if (obj.Id == pid) continue;
if (obj.ObjectClass != AcObjectClass.Monster) continue;
float hp = _objectCache.GetHealthRatio(obj.Id);
if (hp == 0f || hp < 0f) continue;
if (_host.HasObjectIsAttackable && !_host.ObjectIsAttackable(unchecked((uint)obj.Id))) continue;
if (!CountsAsLiveMonster(_objectCache, obj)) continue;
if (_objectCache.Distance(obj.Id, pid) <= maxDist && rx.IsMatch(obj.Name))
matchCount++;
}
@ -783,10 +801,7 @@ internal sealed partial class MetaManager
{
if (obj.Id == pid) continue; // never count self
if (obj.ObjectClass != AcObjectClass.Monster) continue;
float hp = _objectCache.GetHealthRatio(obj.Id);
if (hp == 0f) continue; // dead, pending reclassification
if (hp < 0f) continue; // never received a health update — stale/untracked
if (_host.HasObjectIsAttackable && !_host.ObjectIsAttackable(unchecked((uint)obj.Id))) continue;
if (!CountsAsLiveMonster(_objectCache, obj)) continue;
if (_objectCache.Distance(obj.Id, pid) <= maxD)
return false;
}

View file

@ -1277,6 +1277,21 @@ namespace RynthCore.Plugin.RynthAi.Raycasting
if (setup.PartIds != null && setup.PartIds.Length > 0)
{
var gfxVol = GetGfxObjBounds(setup.PartIds[0]);
// A big object's first-part sphere is its render bound, not a wall (R-20261119-114214-b9ed,
// landblock 0xB64A): wall panel 0x02001C33 is 24 x 0.4 m but its part sphere 28 m round,
// and 0x02001C39 (29 parts, not one with physics polygons) got a 13 m sphere. They stand
// every 24 m along the landblock edge, so the spheres filled the corner: a line between a
// character and a monster 1.5 m off crossed a sphere's surface and read as blocked, and
// the selected monster was locked and dropped every 2 s without a cast (and a line through
// a panel, both ends inside a sphere, read as clear). Its parts' physics polygons are what
// AC collides with; with none at all nothing stops a spell there.
// Tools/RynthCore.LosProof checks this spot.
if (gfxVol != null && gfxVol.Type == BoundingVolume.VolumeType.Sphere && gfxVol.Dimensions.X > LargePartSphereRadius)
{
var mesh = PartsPhysicsMesh(setup, out bool drawingOnly);
if (mesh != null) { result.Add(mesh); return result; }
if (drawingOnly) return result;
}
if (gfxVol != null)
result.Add(gfxVol);
}
@ -1284,6 +1299,70 @@ namespace RynthCore.Plugin.RynthAi.Raycasting
return result;
}
/// <summary>Past this radius a part's sorting sphere is too coarse to stand for the object (meters).</summary>
internal const float LargePartSphereRadius = 4.0f;
/// <summary>
/// The physics polygons of every part of <paramref name="setup"/>, placed by its part frames, as one
/// triangle mesh (null when there are none or a part couldn't be read). <paramref name="drawingOnly"/>:
/// every part was read and none has physics polygons (the GfxObj's HasPhysics flag, 0x01), so nothing
/// in the object collides.
/// </summary>
private BoundingVolume PartsPhysicsMesh(SetupInfo setup, out bool drawingOnly)
{
drawingOnly = false;
int count = setup.PartIds.Length;
bool anyPhysics = false, allRead = true;
for (int i = 0; i < count; i++)
{
byte[] head = _portalDat.GetFileData(setup.PartIds[i]);
if (head == null || head.Length < 8) { allRead = false; continue; }
if ((BitConverter.ToUInt32(head, 4) & 0x01) != 0) anyPhysics = true;
}
if (!anyPhysics)
{
drawingOnly = allRead;
return null;
}
if (setup.PartFrames == null || setup.PartFrames.Length < count) return null;
var triangles = new List<Vector3>();
for (int i = 0; i < count && triangles.Count / 3 < MAX_BUILDING_TRIANGLES; i++)
{
if (setup.PartFrames[i] == null) return null;
var mesh = LoadGfxObjMesh(setup.PartIds[i]);
if (mesh == null) continue; // a drawing-only part (or unreadable: the rest still stand)
foreach (var face in mesh.Faces)
{
TriangulateAndTransform(face, mesh.Vertices, setup.PartFrames[i], triangles);
if (triangles.Count / 3 >= MAX_BUILDING_TRIANGLES) break;
}
}
if (triangles.Count < 3) return null;
float minX = float.MaxValue, minY = float.MaxValue, minZ = float.MaxValue;
float maxX = float.MinValue, maxY = float.MinValue, maxZ = float.MinValue;
foreach (var v in triangles)
{
if (v.X < minX) minX = v.X; if (v.X > maxX) maxX = v.X;
if (v.Y < minY) minY = v.Y; if (v.Y > maxY) maxY = v.Y;
if (v.Z < minZ) minZ = v.Z; if (v.Z > maxZ) maxZ = v.Z;
}
return new BoundingVolume
{
Type = BoundingVolume.VolumeType.TriangleMesh,
Center = new Vector3((minX + maxX) * 0.5f, (minY + maxY) * 0.5f, (minZ + maxZ) * 0.5f),
Dimensions = new Vector3(maxX - minX, maxY - minY, maxZ - minZ),
Min = new Vector3(minX, minY, minZ),
Max = new Vector3(maxX, maxY, maxZ),
MeshTriangles = triangles.ToArray(),
IsDoor = false,
// Physics polygons only, so no box stands in for missing walls (and a thin panel turned
// on the landblock would make a big one).
NoAabbFallback = true
};
}
// ── Triangle mesh loading ───────────────────────────────────────────
/// <summary>
@ -1678,7 +1757,8 @@ namespace RynthCore.Plugin.RynthAi.Raycasting
Min = worldMin,
Max = worldMax,
MeshTriangles = tris,
IsDoor = localVol.IsDoor
IsDoor = localVol.IsDoor,
NoAabbFallback = localVol.NoAabbFallback // a parts mesh (PartsPhysicsMesh): its triangles are all of it
};
}

View file

@ -448,6 +448,10 @@ public sealed partial class RynthAiPlugin
}
if (now < _chestReopenDueAt || _activity != BotActivity.Looting)
return true;
// AutoCram's or AutoStack's move has no answer yet: the client would refuse the use (2026-11-18,
// R-20261117-230613-88c5). It takes 50-300 ms; ChestReopenStaleMs still bounds the wait.
if (ItemMoveHold() != null)
return true;
if (IsLootingBlockedByPack(settings))
{

View file

@ -0,0 +1,47 @@
using System;
using RynthCore.Plugin.Shared;
namespace RynthCore.Plugin.RynthAi;
// ============================================================================
// The player casting by hand (2026-11-18, R-20261118-214609-a9a8, R-20261118-205826-9c70).
//
// A cast from AC's own spell bar or a spell hotkey prints "Casting <spell>" in the chat (type 26,
// AC's own client status lines: "Using the Corpse of ...", "You're too busy!", "In Portal Space -
// Please Wait..."). RynthAi's casts go through the engine (FreeHandsAndCastSpell / CastSpell with
// no UI) and never print it: in both reports and in the local logs, hundreds of RynthAi casts, no
// such line, while the player's clicks each printed one and drew "You're too busy!" 35-50 ms later.
// Each line goes to ActionPacer.NoteHandCast: the player has the character for a moment (see the
// ActionPacer section "The player casting by hand").
// ============================================================================
public sealed partial class RynthAiPlugin
{
/// <summary>AC's chat type for its own client status lines ("Casting ...", "You're too busy!").</summary>
internal const int AcStatusChatType = 26;
/// <summary>
/// True for AC's own "Casting <paramref name="spell"/>" line (a cast from the spell bar or a hotkey).
/// Not RynthAi's "[RynthAi] Casting: ..." lines, not another plugin's "Casting X..." notice, not speech.
/// </summary>
internal static bool TryParseHandCast(string? text, int chatType, out string spell)
{
spell = "";
if (chatType != AcStatusChatType || string.IsNullOrEmpty(text)) return false;
const string Prefix = "Casting ";
if (!text.StartsWith(Prefix, StringComparison.Ordinal)) return false;
string rest = text.Substring(Prefix.Length).Trim();
if (rest.Length == 0 || rest.Length > 80) return false;
if (rest.EndsWith("...", StringComparison.Ordinal) || rest.IndexOf(':') >= 0 || rest.IndexOf('"') >= 0) return false;
if (!char.IsLetter(rest[0])) return false;
spell = rest;
return true;
}
/// <summary>A chat line: AC's "Casting ..." marks the player's own cast by hand (ActionPacer.NoteHandCast).</summary>
private void NoteHandCastChat(string text, int chatType)
{
if (TryParseHandCast(text, chatType, out string spell))
ActionPacer.NoteHandCast(Host, spell);
}
}

View file

@ -177,6 +177,7 @@ public sealed partial class RynthAiPlugin
if (_p._targetCorpseId != 0 || _p._openedContainerId != 0) return "the corpse looter is busy";
if (_p.GroundPickupInFlight) return "a ground pickup is in flight";
if (_p._salvageManager?.PanelPending == true) return "the salvage panel is opening";
if (_p.ItemMoveHold() is string move) return move; // R-20261117-230613-88c5: the client would refuse the use
if (!ActionPacer.MayStart(Host, "Loot", HealNeed.None, out string why))
return why.Length > 0 ? why : "the server owes an answer";
long now = CorpseNowMs;

View file

@ -21,6 +21,19 @@ public sealed partial class RynthAiPlugin
private string? SalvagePanelHold() =>
_salvageManager?.PanelPending == true ? "the salvage panel is opening; the use waits for the salvage to go out" : null;
/// <summary>
/// AutoCram's or AutoStack's last move has no answer from the server yet (2026-11-18,
/// R-20261117-230613-88c5). The client holds that move in its one pending item request, and a
/// corpse, chest or door use sent now is refused with "You can only move or use one item at a
/// time" and never sent, so the looter waited 5 s for an answer that could not come. Null when
/// nothing is in flight.
/// </summary>
private string? ItemMoveHold() =>
_inventoryManager?.MoveUnanswered(out string what) == true ? what : null;
/// <summary>UseAudit.WorldUseHold: what an automatic door or corpse use waits for, or null.</summary>
private string? WorldUseHoldReason() => SalvagePanelHold() ?? ItemMoveHold();
/// <summary>UseAudit.AfterSend: a use or use-on went out - record it as the action the server is answering.</summary>
private static void RecordUseForPacing(RynthCoreHost host, UseAudit.SentUse use)
{
@ -63,6 +76,10 @@ public sealed partial class RynthAiPlugin
if (ActionPacer.Enabled
&& (ActionPacer.Current(Host) != null || ActionPacer.GestureHolds(Host, "Items", HealNeed.None, out _)))
busy++; // an unanswered server action, or the character still animating (a pack move of a wielded item, a stone, a summon would start on top)
// AutoCram's or AutoStack's move has no answer yet: the client refuses any other item
// action until it has one (2026-11-18, R-20261117-230613-88c5; ItemMoveHold).
if (_inventoryManager?.MoveUnanswered(out _) == true)
busy++;
return busy;
}
}

View file

@ -260,7 +260,9 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
var hookHost = Host;
CombatHook.LastUseDone = () => hookHost.HasUseDoneSeq && hookHost.TryGetLastUseDone(out int s, out uint e) ? (s, e) : null;
RynthCore.Plugin.Shared.UseAudit.AfterSend = RecordUseForPacing;
RynthCore.Plugin.Shared.UseAudit.WorldUseHold = SalvagePanelHold;
// The salvage panel opening, or AutoCram's/AutoStack's move not answered yet (2026-11-18,
// R-20261117-230613-88c5): either way the client would refuse the use.
RynthCore.Plugin.Shared.UseAudit.WorldUseHold = WorldUseHoldReason;
// "The door is locked!" comes as a transient string (ACE Door.ActOnUse): the door logic picks a
// lock only when the server says so (DoorInteractionController). The chat line is the fallback.
// The four combat events (hits and evades both ways, by name) feed the Monster Stats
@ -855,6 +857,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
_metaManager.SetKillClock(_killClock);
_metaManager.SetCorpseOpenedCheck(id => _completedCorpses.ContainsKey(id));
_metaManager.SetCombatTargetCount(() => _combatManager?.LastScanPossible ?? -1);
_metaManager.SetGhostCheck(id => _combatManager?.Ghosts.IsGhost(id) == true);
_metaManager.SetLastChestLooted(() => _lastChestLootedId);
_metaManager.SetDunExploreStatus(DunExploreStatus, DunExploreInfoJson);
if (_dashboard != null)
@ -2529,6 +2532,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
public override void OnChatWindowText(string? text, int chatType, ref int eat)
{
if (string.IsNullOrEmpty(text)) return;
try { NoteHandCastChat(text, chatType); } catch { } // the player casting by hand (RynthAiPlugin.HandCast.cs), before the refusal handlers
try { NoteServerPolicyChat(text); } catch { } // DreamWeave's Thread lines (ServerPolicy)
try { NoteDoorServerText(text); } catch { } // "The door is locked!" (the door logic)
try { ItemToolChat(text); } catch { } // the key's answers (chest looter)

View file

@ -209,6 +209,10 @@ internal static class ActionPacer
_holdsByWho.Clear();
_playerHoldUntil = _playerHoldSince = _playerHolds = _playerHeldStarts = 0;
_playerHoldLogged.Clear();
_handCastAt = _handCastSince = 0; _handRunCasts = _handRunRefusals = 0;
_handCasts = _handRuns = _handRefusals = _handHeldStarts = 0;
_handSpell = "";
_handLogged.Clear();
_lastTimeout = "";
ClearBusyLocked();
_stuckBreaks = 0;
@ -432,6 +436,127 @@ internal static class ActionPacer
Log(host, $"[Pace] the player's turn is over after {held} ms; RynthAi goes on");
}
// ── The player casting by hand (2026-11-18) ─────────────────────────────
// R-20261118-214609-a9a8 and R-20261118-205826-9c70 (DreamWeave, 2026.11.15.3), "spells are not
// connecting anymore", the player "casting arc VII": a 'too busy' UseDone about every 0.4 s with
// nothing sent by RynthAi (no [CombatCast], no pending buff, the pacer only waiting). The sender
// was the player, casting from AC's own spell bar or hotkeys while the macro ran: AC prints
// "Casting <spell>" (chat type 26) for each of those (15:52:54.643 'Casting Incantation of Force
// Arc', then 'Casting Incantation of Force Streak' x3, each answered 'You're too busy!' 35-50 ms
// later), and the heartbeat's input clock read idle=0 exactly while the refusals ran. RynthAi's
// own casts never print that line. ACE refuses every cast while the character's last one is
// still running (VerifyBusy), so each click during a cast came back 0x1D.
// RynthAi took those refusals as its own: the buff step escalated its backoff to 8 s and, at
// the 4th, sent StopCompletely "to clear a stuck gesture" in the middle of a running cast (the
// player's at 16:45:18.6, its own Force Arc at 15:52:58.2), which can drop that cast; and its
// buff pass kept the server busy so the player's clicks were refused.
// Now each such line gives the player the character for HandCastHoldMs from it: RynthAi starts
// no cast, use, stance change or movement (an emergency heal still may), the 'too busy' answers
// in that time are the player's (no breaker evidence, no backoff, no stop), logged at the start
// and the end of the run.
/// <summary>How long after the player's last cast by hand (AC's "Casting ..." line) RynthAi leaves the character to the player.</summary>
public const long HandCastHoldMs = 3000;
private static long _handCastAt; // the last "Casting ..." line (0 = none yet)
private static long _handCastSince; // the first one of this run
private static int _handRunCasts, _handRunRefusals;
private static long _handCasts, _handRuns, _handRefusals, _handHeldStarts;
private static string _handSpell = "";
private static readonly HashSet<string> _handLogged = new();
/// <summary>The player's casts by hand seen (AC's "Casting ..." lines), runs of them, and the 'too busy' answers to them.</summary>
public static long HandCasts => _handCasts;
public static long HandCastRuns => _handRuns;
public static long HandCastRefusals => _handRefusals;
/// <summary>
/// AC printed "Casting <paramref name="spell"/>": the player cast from the spell bar or a hotkey (RynthAi's
/// casts never print it). Starts or extends the player's hand-cast run (HandCastHoldMs from now).
/// </summary>
public static void NoteHandCast(RynthCoreHost host, string spell)
{
if (!Enabled) return;
long now = NowMs();
string? end = EndHandRunIfOver(now);
bool began;
lock (Gate)
{
began = _handCastAt == 0;
if (began)
{
_handCastSince = now;
_handRunCasts = 0;
_handRunRefusals = 0;
_handRuns++;
_handLogged.Clear();
}
_handCastAt = now;
_handRunCasts++;
_handCasts++;
_handSpell = spell;
}
if (end != null) Log(host, end);
if (began)
Log(host, $"[Pace] the player is casting by hand: AC's own 'Casting {spell}' (the spell bar or a hotkey, not RynthAi). " +
$"RynthAi starts nothing new (an emergency heal still may) and takes the server's 'too busy' answers as the player's " +
$"until {HandCastHoldMs} ms after the last one");
}
/// <summary>True within HandCastHoldMs of the player's last cast by hand.</summary>
public static bool HandCasting(RynthCoreHost host)
{
if (!Enabled) return false;
string? end = EndHandRunIfOver(NowMs());
if (end != null) { Log(host, end); return false; }
lock (Gate) return _handCastAt != 0;
}
/// <summary>The run's end line when HandCastHoldMs has passed since its last cast (the run is closed), else null.</summary>
private static string? EndHandRunIfOver(long now)
{
lock (Gate)
{
if (_handCastAt == 0 || now - _handCastAt < HandCastHoldMs) return null;
string line = $"[Pace] the player's casting by hand is over ({_handRunCasts} cast(s) in {_handCastAt - _handCastSince} ms, " +
$"last '{_handSpell}', {_handRunRefusals} 'too busy' answer(s) to them): RynthAi goes on";
_handCastAt = 0;
_handLogged.Clear();
return line;
}
}
/// <summary>A 'too busy' answer while the player casts by hand: theirs (counted). False when no run is on.</summary>
private static bool TakeHandRefusalLocked(long now)
{
if (_handCastAt == 0 || now - _handCastAt >= HandCastHoldMs) return false;
_handRunRefusals++;
_handRefusals++;
return true;
}
/// <summary>True (with why) while the player casts by hand; an emergency heal is not held. One log line per run and subsystem.</summary>
private static bool HandCastHolds(RynthCoreHost host, string who, HealNeed heal, out string why)
{
why = "";
if (!HandCasting(host)) return false;
// The server's answers are still read while the run holds every start (ServerBusyHolds, which
// reads them, is not reached): its 'too busy' answers are counted as the player's here.
ObserveUseDone(host, NowMs(), out string? seen);
if (seen != null) Log(host, seen);
if (heal == HealNeed.Emergency) return false;
string spell;
bool log;
lock (Gate)
{
_handHeldStarts++;
log = _handLogged.Add(who);
spell = _handSpell;
}
why = $"the player is casting by hand ({spell})";
if (log) Log(host, $"[Pace] {who} waits: {why}");
return true;
}
/// <summary>True (with why) while another plugin has the player's turn. One log line per hold and subsystem.</summary>
private static bool PlayerHoldsStart(RynthCoreHost host, string who, out string why)
{
@ -478,6 +603,7 @@ internal static class ActionPacer
{
if (!Enabled) { why = ""; return true; }
if (PlayerHoldsStart(host, who, out why)) return false;
if (HandCastHolds(host, who, heal, out why)) return false; // the player casting by hand (2026-11-18)
// A buff, heal, kit or potion in the air is refused by ACE: wait for the landing. Combat checks
// it itself, at the attack, so a stance change is not held; loot and doors never.
if (who == "Buff" && LootJumpAirborne(host, out why)) return false;
@ -604,6 +730,7 @@ internal static class ActionPacer
why = "";
if (!Enabled) return false;
if (PlayerHoldsStart(host, who, out why)) return true; // the item managers' moves wait too
if (HandCastHolds(host, who, heal, out why)) return true; // and while the player casts by hand
bool busy;
try { busy = host.HasGetCastBusyState && host.GetCastBusyState() != 0; } catch { busy = false; }
long now = NowMs();
@ -897,7 +1024,10 @@ internal static class ActionPacer
if (err == TooBusyErr)
{
if (_busySince == 0) { _busySince = now; if (_hung == null) _busyLogged.Clear(); }
_busyRefusals++;
// The player's click refused while a cast runs (2026-11-18, R-20261118-214609-a9a8): the
// server is busy all the same (the latch), but it says nothing about a cast of ours, so it is
// no evidence for the stuck-cast breaker.
if (!TakeHandRefusalLocked(now)) _busyRefusals++;
return;
}
if (_busySince != 0 || _hung != null || _stage != BreakStage.None)
@ -1377,6 +1507,7 @@ internal static class ActionPacer
lines.Add($" Sent {_started}, answered {_answered}, no answer in time {_timedOut}{(_lastTimeout.Length > 0 ? $" (last: {_lastTimeout})" : "")}");
lines.Add($" Starts held {_heldStarts}, moves held {_heldMoves}, heals let ahead {_healsAhead}, sent over an unanswered one {_sentOverOutstanding}");
lines.Add($" The player's turn (key presses from other plugins): {_playerHolds}, starts held for them {_playerHeldStarts}");
lines.Add($" The player casting by hand (AC's 'Casting ...'): {_handCasts} cast(s) in {_handRuns} run(s), {_handRefusals} 'too busy' answer(s) to them, starts held {_handHeldStarts}");
lines.Add($" Mode changes refused while waiting {_modeRefused}, skipped (already in that mode) {_modeSkipped}");
lines.Add($" Held while the character was animating {_gestureHolds}, animation time limits {_gestureLimits}");
lines.Add($" Held after a 'too busy' answer {_refusalHolds}, held casts turned to {_heldTurns}, stuck casts broken {_stuckBreaks} ({_forcedBreaks} by the HP failsafe; limit {StuckCastMs} ms)");
@ -1457,6 +1588,8 @@ internal static class ActionPacer
return false;
}
if (PlayerHoldsStart(host, "mode:" + who, out _)) return false;
// A stance change fails a cast in progress on ACE: never under the player's own cast (2026-11-18).
if (HandCastHolds(host, "mode:" + who, HealNeed.None, out _)) return false;
PacedAction? a = Current(host);
if (a != null)
{

View file

@ -126,6 +126,8 @@ internal static class MoveAudit
private static readonly System.Collections.Generic.HashSet<uint> _motionsOn = new();
private static readonly System.Collections.Generic.HashSet<string> _actionHoldLogged = new();
private static long _actionHoldLoggedFor = long.MinValue;
private static readonly System.Collections.Generic.HashSet<string> _handHoldLogged = new();
private static long _handHoldLoggedRun = -1;
/// <summary>Callers whose movement is never held: the cast nudge, a macro stop, typed commands.</summary>
internal static bool IsExemptFromActionHold(string who) =>
@ -151,6 +153,23 @@ internal static class MoveAudit
lock (Gate) moving = motion != 0 ? _motionsOn.Contains(motion) : (_autoRunOn || _motionsOn.Count > 0);
if (moving) return false; // a real stop always goes through, however old the start
}
// The player casting by hand (2026-11-18, R-20261118-214609-a9a8): a start or a turn of ours would
// move the character in the player's cast windup. Stops are left to the rules below.
if (!isStop && ActionPacer.HandCasting(host))
{
bool logHand;
lock (Gate)
{
if (_handHoldLoggedRun != ActionPacer.HandCastRuns) { _handHoldLoggedRun = ActionPacer.HandCastRuns; _handHoldLogged.Clear(); }
logHand = Enabled && _handHoldLogged.Add(who);
}
if (logHand)
{
try { host.Log($"[Move] {PluginName}/{who} {call} held (move/turn): the player is casting by hand"); }
catch { }
}
return true;
}
var pending = ActionPacer.Current(host);
if (pending == null) return false;
if (!ActionPacer.HoldsMovement(host, out string what)) return false;