diff --git a/Plugins/RynthCore.Plugin.RynthAi/ActivityArbiter.cs b/Plugins/RynthCore.Plugin.RynthAi/ActivityArbiter.cs index 8a95f02..ba3938e 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/ActivityArbiter.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/ActivityArbiter.cs @@ -51,7 +51,11 @@ internal readonly struct ArbiterInputs /// Actively engaged (a live attack target), not merely "something is engageable". public readonly bool CombatEngaged; - /// BoostNavPriority: RynthAi only navigates (no combat, no looting), route or not. + /// + /// Boost Nav Priority is on AND a nav route runs (BoostNavRule.Active): RynthAi only follows the + /// route (no combat, no looting). False with no route, at the end of a Once route, and during the + /// Outdoor Hunt, so the flag changes nothing there (R-20261103-000159-a65e). + /// public readonly bool BoostNav; /// BoostLootPriority — looting preempts combat. public readonly bool BoostLoot; @@ -115,15 +119,17 @@ internal sealed class ActivityArbiter if (s.WantBuffing) return BotActivity.Buffing; // ── User priority overrides ──────────────────────────────────────── - // BoostNavPriority (owner's rule, 2026-11-02): RynthAi ONLY navigates. No - // hunting, no looting, and no fighting back even with a monster on it: with - // a route (or a follow) it navigates, with nothing to navigate it stands - // idle. Buffing (above) still outranks it. This used to be guarded by - // WantNav, so with no route the flag did nothing and the bot hunted as - // usual; the player never noticed it was on and only saw that it would not - // loot (R-20261102-041824-3f7c). Two things still get a slot: a container - // the player flagged with /ra lootthis (looted with Boost Nav on, as with - // the macro off), and the salvage queue (an inventory chore, no fight). + // BoostNavPriority (owner's corrected rule, 2026-11-02, R-20261103-000159-a65e): + // "Boost nav priority should only run the nav route, not from mob to mob. So + // when no nav route is loaded it should fight." s.BoostNav is true only while + // a nav route (or a follow) runs (BoostNavRule.Active); then RynthAi only + // follows it: no hunting, no looting, no fighting back even with a monster on + // it. With no route, a Once route at its end, or the Outdoor Hunt, s.BoostNav + // is false and the default order below runs, as with the flag off. Buffing + // (above) still outranks it. Two things still get a slot: a container the + // player flagged with /ra lootthis (looted with Boost Nav on, as with the + // macro off), and the salvage queue (an inventory chore, no fight). Idle is + // left for the moment nav itself waits (travelling back to your corpse). if (s.BoostNav) { if (s.WantNav) return BotActivity.Navigating; diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs index 59b7192..f49480e 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs @@ -4622,12 +4622,13 @@ public partial class CombatManager : IDisposable DropTarget("combat disabled"); } - // Boost Nav Priority (owner's rule, 2026-11-02): RynthAi only navigates. No hunting and no - // fighting back, whatever BotAction says. canRun used to block combat only while the - // arbiter held "Navigating", so with no route (BotAction "Default") Think ran and the bot - // hunted as usual with the flag on (R-20261102-041824-3f7c). The scan above still runs: - // it is what tells the arbiter (and the once-per-session notice) a fight is being skipped. - if (_settings.BoostNavPriority) + // Boost Nav Priority (owner's corrected rule, 2026-11-02, R-20261103-000159-a65e): while a + // nav route runs RynthAi only follows it. No hunting and no fighting back, whatever + // BotAction says. With no route (or a Once route at its end, or the Outdoor Hunt) the flag + // does nothing and combat runs as usual: BoostNavRule.Active is the one test. The scan + // above still runs: it is what tells the arbiter (and the once-per-session notice) a fight + // is being skipped, and what picks the fight back up the moment the route is gone. + if (BoostNavRule.Active(_settings)) { StandDownForBoostNav(); return; @@ -4635,7 +4636,9 @@ public partial class CombatManager : IDisposable if (_boostNavStoodDown) { _boostNavStoodDown = false; - _host.Log("[RynthAi] Combat: Boost Nav Priority is off - hunting again."); + _host.Log(_settings.BoostNavPriority + ? "[RynthAi] Combat: Boost Nav Priority is on but no nav route runs - hunting again." + : "[RynthAi] Combat: Boost Nav Priority is off - hunting again."); } // Combat can run in Default/Combat, can interrupt navigation, and can interrupt looting @@ -4665,8 +4668,9 @@ public partial class CombatManager : IDisposable internal bool BoostNavStoodDown => _boostNavStoodDown; /// - /// Boost Nav Priority (owner's rule, 2026-11-02), every combat tick while the flag is on: - /// nothing is attacked, and a fight the flag came on in the middle of is let go cleanly. The + /// Boost Nav Priority (owner's corrected rule, 2026-11-02), every combat tick while the flag is + /// on and a nav route runs (BoostNavRule.Active): nothing is attacked, and a fight the flag (or + /// a route loaded with it on) came in the middle of is let go cleanly. The /// target is dropped (which ends a kite or an environment approach), the server's melee or /// missile attack is cancelled (or it keeps swinging and walking us to the mob), a held turn /// is let go, and with Peace Mode When Idle the stance goes back to Peace as it does between @@ -4679,13 +4683,13 @@ public partial class CombatManager : IDisposable if (!_boostNavStoodDown) { _boostNavStoodDown = true; - _host.Log("[RynthAi] Combat: Boost Nav Priority is on - no hunting and no fighting back, RynthAi only navigates."); + _host.Log("[RynthAi] Combat: Boost Nav Priority is on and a nav route runs - no hunting and no fighting back, RynthAi only follows the route."); // The flag came on mid-fight: end the server's attack even if our record of it is gone. if (mode == CombatMode.Melee || mode == CombatMode.Missile) ReleaseServerAttack("Boost Nav Priority", log: false); } if (activeTargetId != 0 || _lockedTargetId != 0) - DropTarget("Boost Nav Priority is on (RynthAi only navigates)"); + DropTarget("Boost Nav Priority is on and a nav route runs (RynthAi only follows it)"); if (_serverAttackTargetId != 0) ReleaseServerAttack("Boost Nav Priority", log: false); ReleaseHeldTurn(); @@ -4700,7 +4704,7 @@ public partial class CombatManager : IDisposable // The idle swap's backoff (ThinkCore): 500 ms for the first 4 sends, then doubling to 15 s. double peaceDelayMs = Math.Min(15_000, 500 * Math.Pow(2, Math.Min(5, _idlePeaceAttempts / 4))); if ((RynthClock.Now - _lastPeaceAttempt).TotalMilliseconds > peaceDelayMs - && _host.ChangeCombatModeFor(CombatMode.NonCombat, "Combat", "Boost Nav Priority: RynthAi only navigates (Peace Mode When Idle)")) + && _host.ChangeCombatModeFor(CombatMode.NonCombat, "Combat", "Boost Nav Priority: RynthAi only follows the nav route (Peace Mode When Idle)")) { _lastPeaceAttempt = RynthClock.Now; _idlePeaceAttempts++; diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/PetManager.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/PetManager.cs index 9974287..160eabc 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Combat/PetManager.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/PetManager.cs @@ -277,10 +277,11 @@ internal sealed class PetManager if (!_petSeenSinceSummon) return; _assumePetActiveUntil = 0; } - // Boost Nav Priority (owner's rule, 2026-11-02): RynthAi only navigates, so there is no - // fight to summon for (a summoned pet attacks the monsters it was called for), and a - // cosmetic pet stays out. - if (_settings.BoostNavPriority) return; + // Boost Nav Priority (owner's corrected rule, 2026-11-02, R-20261103-000159-a65e): while a nav + // route runs RynthAi only follows it, so there is no fight to summon for (a summoned pet + // attacks the monsters it was called for), and a cosmetic pet stays out. With no route it + // hunts, and pets are summoned as with the flag off. + if (BoostNavRule.Active(_settings)) return; if (petOut) { // A cosmetic pet in the slot steps aside for the fight; wait for the dismiss to land. diff --git a/Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs b/Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs index 6c1aed1..94164dc 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs @@ -171,6 +171,13 @@ public sealed partial class RynthAiPlugin private readonly List _currentLootItemDestsTried = new(); private readonly List _currentLootItemFullPacks = new(); // packs this item's refusals marked full private long _moveAwaitTickAt; // CorpseNowMs of the previous answer-wait call + // 2026-11-02 (R-20261102-204309-206c): an open corpse while a fight has the tick (HoldOpenCorpseForFight). + private long _fightHoldSince; // CorpseNowMs the open corpse began waiting for the fight; 0 = none + private long _fightHoldTickAt; // CorpseNowMs of the previous held tick (the corpse clock is paid back) + private long _fightHoldEndedAt; // CorpseNowMs the last such wait ended (NoteNextSendWaits counts from it) + private bool _currentLootItemFightHeld; // the last send had no answer when a fight took the tick + private int _currentLootItemFightResends; // resends for a fight in between (not counted as tries) + private bool _currentLootItemResendWaitLogged; // the "next send waits" line was written for the last send // How long the server took to answer recent pickups (confirmations and refusals after the // pickup ran): the answer wait is sized from the slowest of them. private readonly long[] _pickupAnswerLatencies = new long[8]; @@ -700,16 +707,17 @@ public sealed partial class RynthAiPlugin } /// - /// Boost Nav Priority means no looting at all: corpses are passed by and the bot navigates - /// (owner, 2026-10-31: "when navprio is on it shouldn't loot at all, just bypass all corpses - /// and navigate"), route or not. The looter stood down for the flag, but HasLootWork still - /// offered the corpses, so with no route the arbiter's BoostNav clause (guarded by WantNav) - /// gave Looting the tick and the bot sat in Looting forever with nothing claimed - /// (R-20261031-203155-cea0). Both now read this one test: with the flag on there is no loot - /// work, so Looting never takes the tick. A forced loot (/ra lootthis) still goes. + /// Boost Nav Priority with a nav route running means no looting at all: corpses are passed by + /// and the bot follows the route (owner, 2026-10-31: "when navprio is on it shouldn't loot at + /// all, just bypass all corpses and navigate"). The claim and HasLootWork both read this one + /// test, so Looting never takes the tick while the looter stands down + /// (R-20261031-203155-cea0). Owner's corrected rule (2026-11-02, R-20261103-000159-a65e): + /// only while a nav route runs (BoostNavRule.Active); with no route, a Once route at its end, + /// or the Outdoor Hunt, corpses are looted as with the flag off. A forced loot (/ra lootthis) + /// always goes. /// private static bool BoostNavHoldsLoot(LegacyUiSettings settings) - => settings.BoostNavPriority; + => BoostNavRule.Active(settings); private void TickCorpseOpeningCore() { @@ -734,7 +742,7 @@ public sealed partial class RynthAiPlugin if ((!settings.IsMacroRunning || !settings.EnableLooting || BoostNavHoldsLoot(settings)) && !ForcedLootHolds()) { _lootSkipWhy = !settings.IsMacroRunning ? "the macro is off" - : !settings.EnableLooting ? "looting is off" : "Boost Nav Priority is on (RynthAi only navigates)"; + : !settings.EnableLooting ? "looting is off" : "Boost Nav Priority is on and a nav route runs (RynthAi only follows it)"; ResetCorpseTarget(); return; } @@ -777,7 +785,9 @@ public sealed partial class RynthAiPlugin // ── Combat takes priority over claiming NEW corpses ─────────────── // But if we already have an opened container, finish looting it - // (no movement, no conflict with combat). + // (no movement, no conflict with combat) - while the arbiter gives Looting + // the tick; one that gives Combat the tick makes the open corpse wait + // for the fight (HoldOpenCorpseForFight). // Exception: loot starvation (see LootStarveMs) - the arbiter gave this tick to // Looting because a corpse waited too long and no monster is close. if (settings.EnableCombat @@ -1070,7 +1080,7 @@ public sealed partial class RynthAiPlugin if (!settings.IsMacroRunning || !settings.EnableLooting) return false; - if (settings.BoostNavPriority) + if (BoostNavHoldsLoot(settings)) return false; // Combat is #1 priority — block new corpse claims while combat is @@ -1487,6 +1497,10 @@ public sealed partial class RynthAiPlugin if (_openedContainerAt == 0) _openedContainerAt = now; + // A fight has the tick: the corpse waits for it, its clock stopped (R-20261102-204309-206c). + if (HoldOpenCorpseForFight(settings, corpseId, now)) + return; + if (HasCorpseTimedOut(settings, now)) { AbandonCurrentCorpse(now, "timeout"); @@ -1980,6 +1994,12 @@ public sealed partial class RynthAiPlugin /// Resends after a "You're too busy" that don't count as one of the item's 3 tries. internal const int PickupFreeRetries = 3; + /// Resends after a fight came in before the send's answer that don't count as one of the item's 3 tries. + internal const int PickupFightResends = 2; + + /// A send with no answer this long past the answer wait, whose next send is still held, is logged (once per send). + internal const long PickupResendWaitLogMs = 3000; + private const uint WeenieErrorYoureTooBusy = 0x001D; private const uint EventInventoryServerSaveFailed = 0x00A0; @@ -2177,6 +2197,7 @@ public sealed partial class RynthAiPlugin private void NoteLootMoveSent() { _currentLootItemAwaitingAnswer = true; + _currentLootItemResendWaitLogged = false; _currentLootItemRefusedAt = 0; _currentLootItemRefusalError = 0; _currentLootItemRefusalObject = 0; @@ -2407,7 +2428,95 @@ public sealed partial class RynthAiPlugin _corpseTargetSince += gap; } - private void TickPendingCorpsePickup(LegacyUiSettings settings) + // ── A fight while a corpse is open (2026-11-02, R-20261102-204309-206c) ── + // Conquest, RynthAi 2026.11.2.1, outdoors, Boost Loot Priority on: "it will open the corpse and + // highlight the item and then just sit waiting". The bow's move went out and had no answer when + // monsters came 4.4 s later; the arbiter gave Combat the tick (combat is engaged, Boost Loot or + // not). The open corpse's looter ran on under Combat as if it looted: the answer wait ran out in + // a lull between shots, the send was counted as an unanswered try, and the resend was held by + // the shot's busy count, then by the 1 s of stillness the missile fight never gave - silently. + // With no answer awaited any more nothing stopped the corpse's clock (PauseCorpseClockWhileMoveAwaits + // runs only while one is), so 19 s after the send the corpse was abandoned mid-pickup with the + // 30-minute completed mark, and the bow stayed on it. A resend during the fight would not have + // done better: the client drops an item move while the character attacks ("You cannot move or + // use an item while attacking", ClientActionGates) and ACE answers one that gets through with + // "You're too busy". Now, while Combat has the tick, the open corpse waits: its clock stopped, + // no new pickup, and a move already out is only watched for (it may still land, or be refused). + // After the fight one with no answer goes again without costing one of its 3 tries + // (PickupFightResends), and every step says so in the log. + + /// + /// TickOpenCorpseLooting: true while a fight has the tick, the open corpse waiting for it (your + /// own death corpse excepted: its recovery runs as before). Logs when the wait begins and ends. + /// + private bool HoldOpenCorpseForFight(LegacyUiSettings settings, int corpseId, long now) + { + bool fight = _activity == BotActivity.Combat && !IsOwnDeathCorpseId(settings, corpseId); + bool pending = _currentLootItemMovePending && _currentLootItemId != 0; + if (!fight) + { + if (_fightHoldSince != 0) + { + _fightHoldEndedAt = now; + LootDiag($"[RynthAi] {LootTag}: the fight is over after {(now - _fightHoldSince) / 1000.0:0.0}s; looting 0x{(uint)corpseId:X8} goes on" + + (pending ? $" (the move of 0x{(uint)_currentLootItemId:X8} '{_currentLootItemName}' sent {now - _currentLootItemMoveRequestedAt} ms ago " + + (_currentLootItemRefusedAt != 0 ? "was refused)." : "has no answer yet).") : ".")); + } + _fightHoldSince = 0; + _fightHoldTickAt = 0; + return false; + } + if (_fightHoldSince == 0) + { + _fightHoldSince = now; + LootDiag(pending + ? $"[RynthAi] {LootTag}: 0x{(uint)corpseId:X8} waits for the fight: the move of 0x{(uint)_currentLootItemId:X8} '{_currentLootItemName}' sent {now - _currentLootItemMoveRequestedAt} ms ago " + + (_currentLootItemRefusedAt != 0 ? "was refused" : "has no answer yet") + + "; it is watched for but not sent again while combat has the tick (the client drops item moves during an attack); the corpse's timeout clock is stopped." + : $"[RynthAi] {LootTag}: 0x{(uint)corpseId:X8} waits for the fight: no pickup while combat has the tick; the corpse's timeout clock is stopped."); + } + PauseCorpseClockForFight(now); + if (pending && _openedContainerInventoryObservedAt != 0) + TickPendingCorpsePickup(settings, heldByFight: true); + return true; + } + + /// + /// The corpse's timeout clock does not run while a fight holds it, as for the cast-answer hold + /// (PauseCorpseClockWhileHeld, and for the same reason: the open-container branch resets the + /// frozen age FreezeCorpseTimeout keeps). A pickup confirmed during the hold restarts the clock. + /// + private void PauseCorpseClockForFight(long now) + { + long last = _fightHoldTickAt; + _fightHoldTickAt = now; + if (last == 0 || _targetCorpseId == 0 || _corpseTargetSince == 0) + return; + long gap = now - last; + if (gap > 0 && gap <= PickupHoldMaxGapMs) + _corpseTargetSince += gap; + } + + /// + /// The current item's next send is held () although its last send has had + /// no answer (or a refusal) for PickupResendWaitLogMs past the answer wait (and past the end of a + /// fight's wait): said once per send, so no pickup waits without a line (R-20261102-204309-206c: + /// 19 s with none). + /// + private void NoteNextSendWaits(long now, long answerWaitMs, string why) + { + if (_currentLootItemResendWaitLogged) + return; + long since = now - _currentLootItemMoveRequestedAt; + long due = Math.Max(_currentLootItemMoveRequestedAt + answerWaitMs, _fightHoldEndedAt); + if (now - due < PickupResendWaitLogMs) + return; + _currentLootItemResendWaitLogged = true; + string last = _currentLootItemRefusedAt != 0 ? "was refused" : "has had no answer"; + LootDiag($"[RynthAi] {LootTag}: the last send of 0x{(uint)_currentLootItemId:X8} '{_currentLootItemName}' ({since} ms ago) {last}; the next send waits: {why}."); + } + + private void TickPendingCorpsePickup(LegacyUiSettings settings, bool heldByFight = false) { if (_objectCache == null || _openedContainerId == 0 || _currentLootItemId == 0) { @@ -2481,6 +2590,20 @@ public sealed partial class RynthAiPlugin return; } + // A fight has the tick (HoldOpenCorpseForFight, R-20261102-204309-206c): the answer is + // watched for (above) and nothing else. No resend: the client drops an item move while the + // character attacks and ACE answers one that gets through "You're too busy". A send with + // no answer yet goes again after the fight without costing one of the 3 tries. + if (heldByFight) + { + if (!refused) _currentLootItemFightHeld = true; + _currentLootItemStillSince = 0; + _moveAwaitTickAt = 0; // the fight's hold pays the corpse clock back, not the answer wait + return; + } + + long answerWaitMs = PickupAnswerWaitMs(); + // Item still on corpse — wait before retrying the UseObject. The window counts from // when the character is still: while a pickup animation plays the engine holds the // move, and a retry timed from the send gave up on items whose move had not gone @@ -2490,16 +2613,18 @@ public sealed partial class RynthAiPlugin { _currentLootItemStillSince = 0; if (_currentLootItemAwaitingAnswer) PauseCorpseClockWhileMoveAwaits(now); + NoteNextSendWaits(now, answerWaitMs, "the character keeps animating"); return; } if (_currentLootItemStillSince == 0) _currentLootItemStillSince = now; bool freeRetry = busyRefusal && _currentLootItemFreeRetries < PickupFreeRetries; + // The last send had no answer when a fight took the tick: it goes again, free (bounded). + bool fightResend = !freeRetry && !refused && _currentLootItemFightHeld && _currentLootItemFightResends < PickupFightResends; // No answer yet: no resend before PickupAnswerWaitMs (2026-10-29, R-20261029-122319-321f). // The Loot Retry Timeout alone (0.5-1 s) is shorter than a slow server's answer (1.5-2.7 s // on Conquest), and a resend while the move is out is dropped by the client or refused. - long answerWaitMs = PickupAnswerWaitMs(); long sinceSend = now - _currentLootItemMoveRequestedAt; if (_currentLootItemAwaitingAnswer && !refused && sinceSend < answerWaitMs) { @@ -2509,7 +2634,10 @@ public sealed partial class RynthAiPlugin long verifyWindowMs = Math.Max(150, settings.LootRetryTimeoutMs); long windowStart = Math.Max(_currentLootItemMoveRequestedAt, _currentLootItemStillSince); if (!freeRetry && now - windowStart < verifyWindowMs) + { + NoteNextSendWaits(now, answerWaitMs, $"the character has not stood still for {verifyWindowMs} ms"); return; + } // The last send failed: what it came to, once per send (a free resend's "too busy" is // not one of the tries). Refused after the pickup ran counts against the pack; no answer @@ -2519,7 +2647,13 @@ public sealed partial class RynthAiPlugin { _currentLootItemAwaitingAnswer = false; long answerMs = refused ? _currentLootItemRefusedAt - _currentLootItemMoveRequestedAt : sinceSend; - if (!refused) + if (fightResend) + { + // The fight, not the pack: no timeout counted against it (JudgeLootDest). + _currentLootItemTimedOut = true; + lastTry = $"no answer in {answerMs} ms, a fight in between"; + } + else if (!refused) { _currentLootItemDestTimeouts++; _currentLootItemTimedOut = true; @@ -2540,7 +2674,7 @@ public sealed partial class RynthAiPlugin lastTry = $"too busy, {answerMs} ms after the send"; } - if (!freeRetry && _currentLootItemMoveAttempts >= 3) + if (!freeRetry && !fightResend && _currentLootItemMoveAttempts >= 3) { // None of the tries landed. When the server refused them after running the pickup, // the pack they went to is full (its contents unknown to the client): leave it out @@ -2589,7 +2723,12 @@ public sealed partial class RynthAiPlugin } if (_busyCount > 0) - return; // Client is busy — don't queue retry + { + // Client is busy — don't queue retry. (R-20261102-204309-206c: a shot's busy count + // held the resend here, with no line, until the corpse timed out.) + NoteNextSendWaits(now, answerWaitMs, $"the client's busy count is {_busyCount}"); + return; + } if (PickupHeldByServerAction()) return; // a retry now would be refused as too busy and use up an attempt @@ -2604,8 +2743,11 @@ public sealed partial class RynthAiPlugin bool retried = retry == LootPickupResult.Moved || retry == LootPickupResult.Used; if (freeRetry) _currentLootItemFreeRetries++; + else if (fightResend) + _currentLootItemFightResends++; else _currentLootItemMoveAttempts++; + _currentLootItemFightHeld = false; _currentLootItemErrSeqAtSend = errSeqAtSend; _currentLootItemMoveRequestedAt = now; if (retried) NoteLootMoveSent(); @@ -2614,6 +2756,10 @@ public sealed partial class RynthAiPlugin _lastLootActionAt = now; LootDiag(freeRetry ? $"[RynthAi] {LootTag}: the server refused 0x{(uint)_currentLootItemId:X8} as too busy ({refusedAfter} ms after the send, before its pickup ran; error 0x{refusal:X}); sending it again now the character is still." + : fightResend + ? $"[RynthAi] {LootTag}: sending 0x{(uint)_currentLootItemId:X8} again after the fight" + + (lastTry.Length > 0 ? $" (last: {lastTry})" : "") + + $"; not one of its 3 tries ({_currentLootItemMoveAttempts} used)." : $"[RynthAi] {LootTag}: retrying use for 0x{(uint)_currentLootItemId:X8} attempt {_currentLootItemMoveAttempts}" + (lastTry.Length > 0 ? $" (last: {lastTry})." : ".")); @@ -2790,8 +2936,8 @@ public sealed partial class RynthAiPlugin if (!settings.IsMacroRunning || (!settings.EnableLooting && !ForcedLootHolds())) return false; - // The claim's own full stop (TickCorpseOpening): with Boost Nav Priority on the looter - // stands down, so there is no loot work to offer (R-20261031-203155-cea0). + // The claim's own full stop (TickCorpseOpening): with Boost Nav Priority on and a nav route + // running the looter stands down, so there is no loot work to offer (R-20261031-203155-cea0). if (BoostNavHoldsLoot(settings) && !ForcedLootHolds()) return false; @@ -2860,7 +3006,8 @@ public sealed partial class RynthAiPlugin } /// - /// Boost Nav Priority is passing by a corpse in range that would be looted with it off. For + /// Boost Nav Priority, with a nav route running, is passing by a corpse in range that would be + /// looted with it off. For /// the once-per-session notice only (RynthAiPlugin.BoostNav.cs), which calls it every /// BoostNavLootCheckMs until it has spoken. The scan's loot-starvation mark is put back: it /// belongs to HasLootWork's tick, not to this look. @@ -3725,6 +3872,9 @@ public sealed partial class RynthAiPlugin _currentLootItemPipelined = false; _currentLootItemErrSeqAtSend = 0; _currentLootItemFreeRetries = 0; + _currentLootItemFightHeld = false; + _currentLootItemFightResends = 0; + _currentLootItemResendWaitLogged = false; _currentLootItemActionLabel = string.Empty; _currentLootItemName = string.Empty; _currentLootItemIsSalvage = false; @@ -4103,6 +4253,8 @@ public sealed partial class RynthAiPlugin _lastLootActionAt = 0; _corpseIdsRequested = false; _corpseApproachTurnsActive = false; + _fightHoldSince = 0; + _fightHoldTickAt = 0; ResetCurrentLootItem(); _processedCorpseItems.Clear(); _corpseItemAttempts.Clear(); diff --git a/Plugins/RynthCore.Plugin.RynthAi/Dashboard/InstrumentDashboard.cs b/Plugins/RynthCore.Plugin.RynthAi/Dashboard/InstrumentDashboard.cs index 6fcbb73..1631ad5 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Dashboard/InstrumentDashboard.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Dashboard/InstrumentDashboard.cs @@ -374,9 +374,10 @@ internal sealed unsafe class InstrumentDashboard ImGui.SetCursorScreenPos(min); // A click asks why it is doing that (or nothing): /ra why's diagnosis, in chat. if (ImGui.InvisibleButton("##activity", new Vector2(w, h))) _d.Command("/ra why"); - // Boost Nav Priority (owner's rule, 2026-11-02): it reads Idle or Navigating, and says why. + // Boost Nav Priority (owner's corrected rule, 2026-11-02): while a nav route runs it reads + // Idle or Navigating, and says why. With no route the flag changes nothing, so nothing is said. SafeImGui.SetItemTooltip("Bot activity: " + activity - + (_r.BoostNav ? "\nBoost Nav Priority is on: RynthAi only navigates (no hunting, no looting)." : "") + + (_r.BoostNav ? "\nBoost Nav Priority is on and a nav route runs: RynthAi only follows it (no hunting, no looting)." : "") + "\nMeta state: " + state + "\nClick: why it's doing that, in chat (/ra why)."); return y + h; } diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyAdvancedSettingsUi.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyAdvancedSettingsUi.cs index 69bc3c7..f3508f5 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyAdvancedSettingsUi.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyAdvancedSettingsUi.cs @@ -790,7 +790,7 @@ internal sealed class LegacyAdvancedSettingsUi case "Navigation": ImGui.Checkbox("Boost Nav Priority", ref _settings.BoostNavPriority); if (ImGui.IsItemHovered()) - ImGui.SetTooltip("RynthAi only navigates: no hunting, no looting, no fighting back (owner's rule, 2026-11-02). With no route it stands idle. Buffing and healing still run."); + ImGui.SetTooltip("While a nav route runs (a loaded route or a follow), RynthAi only follows it: no hunting, no looting, no fighting back. With no route, at the end of a Once route, or during Outdoor Hunt it hunts and loots as usual. Buffing and healing always run."); ImGui.SetNextItemWidth(120); ImGui.InputFloat("Nav point reach (yd)", ref _settings.FollowNavMin, 0.1f, 1.0f, "%.1f"); _settings.FollowNavMin = LegacyUiSettings.ClampFollowNavMin(_settings.FollowNavMin); @@ -1105,6 +1105,16 @@ internal sealed class LegacyAdvancedSettingsUi ImGui.Checkbox("Pickup with macro off", ref _settings.LootChestsMacroOff); if (ImGui.IsItemHovered()) ImGui.SetTooltip("A chest you open is looted by the loaded loot profile\neven with the macro or Looting off."); + if (_settings.LootChestsMacroOff) + { + ImGui.Indent(); + ImGui.Checkbox("Leave the chest open", ref _settings.LootChestsMacroOffLeaveOpen); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("When the pickup is done the chest stays open and chat says what was taken,\n" + + "so you can check it and take anything your profile missed. Untick it and\n" + + "RynthAi closes the chest when it's done (some chests lock again on close)."); + ImGui.Unindent(); + } ImGui.Checkbox("Jump When Looting", ref _settings.LootJumpEnabled); if (ImGui.IsItemHovered()) ImGui.SetTooltip("Hop (the keyboard jump) just before each pickup,\nso the server skips the bend-down. The hop has a fixed height."); diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.Instrument.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.Instrument.cs index 65a6a72..a75c30d 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.Instrument.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.Instrument.cs @@ -52,7 +52,7 @@ internal sealed partial class LegacyDashboardRenderer _isLocked, _bgOpacity, !string.IsNullOrEmpty(_vendorProfilePath?.Invoke()) ? _vendorProfilePath!.Invoke() : _settings.CurrentLootPath ?? string.Empty, LootMode: Loot.LootModes.Clamp(_settings.LootMode), - BoostNav: _settings.BoostNavPriority); + BoostNav: BoostNavRule.Active(_settings)); // the flag counts only while a nav route runs } /// The five pickers' lists (copied under the lists' lock) and the entry in use. Any thread. diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.cs index 27ee1d5..363b8cd 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.cs @@ -1406,6 +1406,7 @@ internal sealed partial class LegacyDashboardRenderer LootOnlyRareCorpses = s.LootOnlyRareCorpses, LootJumpEnabled = s.LootJumpEnabled, LootChestsMacroOff = s.LootChestsMacroOff, + LootChestsMacroOffLeaveOpen = s.LootChestsMacroOffLeaveOpen, LootJumpHeight = s.LootJumpHeight, LootOwnership = s.LootOwnership, LootOwnCorpse = s.LootOwnCorpse, @@ -1672,6 +1673,7 @@ internal sealed partial class LegacyDashboardRenderer s.LootOnlyRareCorpses = p.LootOnlyRareCorpses; s.LootJumpEnabled = p.LootJumpEnabled; s.LootChestsMacroOff = p.LootChestsMacroOff; + s.LootChestsMacroOffLeaveOpen = p.LootChestsMacroOffLeaveOpen; s.LootJumpHeight = p.LootJumpHeight; s.LootOwnership = p.LootOwnership; if (p.EscapeHazards is bool escape) s.EscapeHazards = escape; // absent = unchanged @@ -2059,6 +2061,7 @@ internal sealed partial class LegacyDashboardRenderer dst.LootCorpseTimeoutMs = tmp.LootCorpseTimeoutMs; dst.LootJumpEnabled = tmp.LootJumpEnabled; dst.LootChestsMacroOff = tmp.LootChestsMacroOff; + dst.LootChestsMacroOffLeaveOpen = tmp.LootChestsMacroOffLeaveOpen; dst.LootJumpHeight = tmp.LootJumpHeight; dst.SalvageOpenDelayFirstMs = tmp.SalvageOpenDelayFirstMs; dst.SalvageOpenDelayFastMs = tmp.SalvageOpenDelayFastMs; diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs index 0748f48..5f7f3d4 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs @@ -151,6 +151,12 @@ public sealed class LegacyUiSettings /// macro's own chest looting takes it. /// public bool LootChestsMacroOff = true; + /// + /// Pickup with macro off > Leave the chest open (2026-11-02, off by default: the chest is closed when done, as before): when the pickup is done the + /// chest stays open and chat says so, instead of RynthAi closing it (a chest that locks itself on close + /// can't be opened again without its key or quest item). + /// + public bool LootChestsMacroOffLeaveOpen = false; public int LootJumpHeight = 10; // kept for old profiles and metas; jump-loot uses the keyboard tap jump (fixed height) public int SalvageOpenDelayFirstMs = 400; @@ -1374,6 +1380,7 @@ public sealed class SettingsBridgePayload public bool LootOnlyRareCorpses { get; set; } public bool LootJumpEnabled { get; set; } public bool LootChestsMacroOff { get; set; } = true; // an engine that doesn't know it leaves it on + public bool LootChestsMacroOffLeaveOpen { get; set; } // off: an engine that doesn't know it closes, as before public int LootJumpHeight { get; set; } public int LootOwnership { get; set; } // Nullable, as CastBuffsOverItemBuffs: an engine that predates them doesn't send them, diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavRouteParser.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavRouteParser.cs index 2fd75c5..9495f9c 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavRouteParser.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavRouteParser.cs @@ -109,6 +109,13 @@ public sealed class NavRouteParser public NavRouteType RouteType { get; set; } public List Points { get; set; } = new(); + /// + /// The Outdoor Hunt's own walk to its next monster (RynthAiPlugin.OutdoorHunt.cs), not a nav + /// route the player loaded. Boost Nav Priority leaves it alone (BoostNavRule): the hunt goes + /// from monster to monster, so it fights and loots as usual. Never set on a loaded route. + /// + public bool OutdoorHuntWalk { get; set; } + /// /// Non-null if the last load hit an unknown waypoint type or a malformed /// line. The route still holds whatever points parsed cleanly before that. diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiCommands.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiCommands.cs index 2fceb6a..03fb851 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiCommands.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiCommands.cs @@ -2071,9 +2071,10 @@ public sealed partial class RynthAiPlugin // Interpretation — the point of D2/D3: name the most likely reason it isn't attacking. string why = !s.IsMacroRunning ? "macro is STOPPED (start it from the panel / command)." : - // Owner's rule (2026-11-02): with Boost Nav Priority on RynthAi only navigates. - _dashboard?.Settings?.BoostNavPriority == true - ? "Boost Nav Priority is on: RynthAi only navigates (no hunting, no looting). Turn it off to hunt and loot." : + // Owner's corrected rule (2026-11-02, R-20261103-000159-a65e): Boost Nav Priority only + // while a nav route runs; with no route it changes nothing, so it is no reason then. + _dashboard?.Settings is { } boostSettings && BoostNavRule.Active(boostSettings) + ? "Boost Nav Priority is on and a nav route runs: RynthAi only follows it (no hunting, no looting). Turn it off to hunt along the route." : !s.EnableCombat ? "combat is disabled in settings." : s.BusyCount > 0 ? "AC busy>0 — waiting on a server action (cast/use/move); try /ra clearbusy if stuck." : forced != 0 && forced == s.ActiveTargetId && bySelection diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.BoostNav.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.BoostNav.cs index 7e8bb1e..1278f37 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.BoostNav.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.BoostNav.cs @@ -2,18 +2,21 @@ using RynthCore.Plugin.RynthAi.LegacyUi; namespace RynthCore.Plugin.RynthAi; -// Boost Nav Priority (owner's rule, 2026-11-02): with the flag on RynthAi ONLY navigates. No -// hunting, no looting, no fighting back; with nothing to navigate it stands idle. Buffing and -// vitals still run. The arbiter (ActivityArbiter.Decide) never picks Combat or Looting with the -// flag on, CombatManager.OnHeartbeat stands down (drops the target, ends the attack, lets go of a -// turn), the looter passes every corpse by (CorpseOpenController.BoostNavHoldsLoot) and no pet is -// summoned (PetManager). The flag comes on quietly from NavLootPrio or a hunting meta's SetOpt, and -// a player who never knew it was on saw only that the bot would not loot -// (R-20261102-041824-3f7c). So the first fight or corpse it skips says so, once per session. +// Boost Nav Priority, owner's corrected rule (2026-11-02, R-20261103-000159-a65e): "Boost nav +// priority should only run the nav route, not from mob to mob. So when no nav route is loaded it +// should fight." The flag counts only while a nav route runs (BoostNavRule.Active). Then RynthAi +// only follows the route: no hunting, no looting, no fighting back (the arbiter never picks Combat +// or Looting, CombatManager.OnHeartbeat stands down, the looter passes every corpse by through +// CorpseOpenController.BoostNavHoldsLoot, PetManager summons nothing). Buffing and vitals still run. +// With no route, a Once route at its end ("when a 'once' nav route is at the end it should hunt +// as well"), nav off, or the Outdoor Hunt walking from monster to monster, the flag does nothing: RynthAi hunts, fights and loots as with it off. +// The flag comes on quietly from NavLootPrio or a hunting meta's SetOpt, and a player who never +// knew it was on saw only that the bot would not loot (R-20261102-041824-3f7c). So the first fight +// or corpse it skips along a route says so, once per session. public sealed partial class RynthAiPlugin { internal const string BoostNavNotice = - "[RynthAi] Boost Nav Priority is on: RynthAi only navigates (no hunting, no looting). Turn it off to hunt and loot."; + "[RynthAi] Boost Nav Priority is on: while a nav route runs, RynthAi only follows it (no hunting, no looting). Turn it off to hunt along the route."; /// How often the corpse half of the notice looks for a corpse it would have looted. internal const long BoostNavLootCheckMs = 2000; @@ -22,13 +25,14 @@ public sealed partial class RynthAiPlugin private long _boostNavLootCheckAt; // CorpseNowMs of the last corpse look /// - /// After the arbiter's decision, every tick: Boost Nav Priority is why a fight (combat on and a - /// monster to engage) or a corpse (looting on and one in range it would loot) is skipped. Says - /// so once per session, in chat and the log; nothing at all once said. + /// After the arbiter's decision, every tick: Boost Nav Priority, with a nav route running, is + /// why a fight (combat on and a monster to engage) or a corpse (looting on and one in range it + /// would loot) is skipped. Says so once per session, in chat and the log; nothing at all once + /// said, and nothing while no route runs (then the flag skips nothing). /// private void NoteBoostNavSkip(LegacyUiSettings settings, bool wantCombat) { - if (_boostNavNoticeSaid || !settings.IsMacroRunning || !settings.BoostNavPriority) return; + if (_boostNavNoticeSaid || !BoostNavRule.Active(settings)) return; string? skipped = null; if (wantCombat) @@ -49,3 +53,37 @@ public sealed partial class RynthAiPlugin Host.WriteToChat(BoostNavNotice, 2); } } + +/// +/// The one test for Boost Nav Priority (owner's corrected rule, 2026-11-02, R-20261103-000159-a65e): +/// it applies only while a nav route runs. Read by the arbiter's input, CombatManager's stand-down, +/// PetManager, the looter and the notice, so they can never disagree. +/// +internal static class BoostNavRule +{ + /// Boost Nav Priority is on and a nav route runs: RynthAi only follows the route. + public static bool Active(LegacyUiSettings s) => s.BoostNavPriority && NavRouteRuns(s); + + /// + /// A nav route runs: the macro runs, navigation is on, and either a follow is steering (a + /// Follow route or fellowship follow; VTank counts a follow as a nav route too) or a loaded + /// route has points left to walk. Not a route: none loaded or an empty one, a Once route that + /// has walked off its last point, and the Outdoor Hunt's walk to its next monster (it goes + /// from monster to monster, which is hunting). The Dungeon Patrol's generated loop counts: + /// it is walked waypoint by waypoint like a loaded route. + /// + public static bool NavRouteRuns(LegacyUiSettings s) + { + if (!s.IsMacroRunning || !s.EnableNavigation) return false; + if (RynthAiPlugin.IsFollowActive(s)) return true; + var route = s.CurrentRoute; + if (route == null || route.Points.Count == 0) return false; + // A hunt walk saved to a file (a nav path set) is a loaded route from then on. + if (route.OutdoorHuntWalk && string.IsNullOrEmpty(s.CurrentNavPath)) return false; + // Owner (2026-11-02): "When a 'once' nav route is at the end it should hunt as well." The nav + // engine's CompleteOnceRoute leaves the index past the last point (and turns nav off); loading + // the route again or /ra nav restart rewinds it, and Boost Nav applies again. Circular and + // Linear routes never finish. + return !s.NavRouteFinished(); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.ChestLoot.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.ChestLoot.cs index b7fa6cc..37a529c 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.ChestLoot.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.ChestLoot.cs @@ -220,14 +220,22 @@ public sealed partial class RynthAiPlugin /// private void FinishChestLoot(int chestId, string why, bool close, bool sayNothingMatched) { - if (close) + // Pickup with macro off > Leave the chest open: a chest the player opened stays open, and chat says so. + bool leaveOpen = close && chestId == _manualChestLootId && (_dashboard?.Settings?.LootChestsMacroOffLeaveOpen ?? false); + if (chestId == _manualChestLootId) + _manualChestLootId = 0; + if (close && !leaveOpen) CloseCorpseContainer(chestId, why); - if (sayNothingMatched) + string chestName = _objectCache?[chestId]?.Name is { Length: > 0 } cn ? cn : "the chest"; + if (sayNothingMatched && NothingLootedLine(chestName, chest: true) is { } nothingLine) + ChatLine(nothingLine); + if (leaveOpen) { - string chestName = _objectCache?[chestId]?.Name is { Length: > 0 } cn ? cn : "the chest"; - if (NothingLootedLine(chestName, chest: true) is { } nothingLine) - ChatLine(nothingLine); + string done = why == "completed" + ? _corpseItemsLooted > 0 ? $"done with {chestName}: took {_corpseItemsLooted} item(s)." : $"done with {chestName}." + : $"stopped on {chestName} ({why})."; + ChatLine($"[RynthAi] Pickup with macro off: {done} Left it open: close it when you're done."); } LootDiag($"[RynthAi] Chest loot: done with chest 0x{(uint)chestId:X8} ({why}); not marked, so opening it again loots it again."); @@ -282,6 +290,8 @@ public sealed partial class RynthAiPlugin private const long ManualChestWaitMs = 3000; // for the chest's owner and name to be readable private int _manualChestId; private long _manualChestSince; + /// The chest Pickup with macro off is looting (0 = none): FinishChestLoot leaves it open when set to. + private int _manualChestLootId; /// OnViewObjectContents for a non-corpse container: a chest the player may have opened. private void NoteManualChestOpened(int id) @@ -311,5 +321,6 @@ public sealed partial class RynthAiPlugin } LootDiag($"[RynthAi] Pickup with macro off: looting the opened chest 0x{(uint)id:X8} by the loot profile."); ForceLootOpenChest(id); + _manualChestLootId = id; } } diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.OutdoorHunt.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.OutdoorHunt.cs index 6e67856..0c7dda5 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.OutdoorHunt.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.OutdoorHunt.cs @@ -216,7 +216,7 @@ public sealed partial class RynthAiPlugin _dunPatrolActive = false; // the hunt's route replaces the patrol's CopyHuntSettings(s); _hunt.Start(RynthClock.Now, me); - _huntRoute = new NavRouteParser { RouteType = NavRouteType.Once }; + _huntRoute = new NavRouteParser { RouteType = NavRouteType.Once, OutdoorHuntWalk = true }; s.CurrentNavPath = string.Empty; s.CurrentRoute = _huntRoute; s.ActiveNavIndex = 0; @@ -303,7 +303,8 @@ public sealed partial class RynthAiPlugin private void InstallHuntRoute(LegacyUiSettings s, IReadOnlyList corners) { - var route = new NavRouteParser { RouteType = NavRouteType.Once }; + // Marked as the hunt's walk: Boost Nav Priority does not count it as a nav route (BoostNavRule). + var route = new NavRouteParser { RouteType = NavRouteType.Once, OutdoorHuntWalk = true }; foreach (var c in corners) { route.Points.Add(new NavPoint diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.VTankHotkeys.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.VTankHotkeys.cs index 2cc3ca6..91768cf 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.VTankHotkeys.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.VTankHotkeys.cs @@ -243,8 +243,11 @@ public sealed partial class RynthAiPlugin (s.BoostNavPriority, s.BoostLootPriority) = NextPriority(s.BoostNavPriority, s.BoostLootPriority, nav, loot, arg); dash!.SaveSettings(); string On(bool b) => b ? "on" : "off"; - // Owner's rule (2026-11-02): with Boost Nav on RynthAi only navigates; say so when it comes on. - string navOnly = nav && s.BoostNavPriority ? " RynthAi only navigates (no hunting, no looting)." : ""; + // Owner's corrected rule (2026-11-02, R-20261103-000159-a65e): Boost Nav counts only while a + // nav route runs; say so when it comes on. + string navOnly = nav && s.BoostNavPriority + ? " While a nav route runs RynthAi only follows it (no hunting, no looting); with no route it hunts and loots as usual." + : ""; ReplyOk(nav && loot ? $"[RynthAi] Boost Nav Priority {On(s.BoostNavPriority)}, Boost Loot Priority {On(s.BoostLootPriority)}.{navOnly}" : nav ? $"[RynthAi] Boost Nav Priority {On(s.BoostNavPriority)}.{navOnly}" : $"[RynthAi] Boost Loot Priority {On(s.BoostLootPriority)}."); @@ -366,7 +369,7 @@ public sealed partial class RynthAiPlugin } string note = !settings.IsMacroRunning ? " (the macro is off: this container only)" : !settings.EnableLooting ? " (Looting is off: this container only)" - : BoostNavHoldsLoot(settings) ? " (Boost Nav Priority is on: this container only)" : ""; + : BoostNavHoldsLoot(settings) ? " (Boost Nav Priority is on and a nav route runs: this container only)" : ""; LootDiag($"[RynthAi] LootThisCont: 0x{(uint)id:X8} '{name}' flagged{(already ? " (already open as the loot container)" : "")}."); ChatLine($"[RynthAi] LootThisCont: looting {name}{note}."); } diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.cs index 696a926..c9e148a 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.cs @@ -922,7 +922,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase /// as nav work in its own right: without this, turning Follow on with no route loaded would /// leave the arbiter's wantNav false and NavigationEngine.Tick would never do the following. /// - private static bool IsFollowActive(LegacyUiSettings settings) + internal static bool IsFollowActive(LegacyUiSettings settings) => (settings.FollowMode && settings.FollowTargetId != 0) || (settings.CurrentRoute != null && settings.CurrentRoute.RouteType == NavRouteType.Follow && settings.CurrentRoute.FollowTargetName.Length > 0); @@ -930,8 +930,8 @@ public sealed partial class RynthAiPlugin : RynthPluginBase /// /// The arbiter's WantNav input: the macro runs, navigation is on, and there is a route (or a /// follow) to run. Travelling back to your corpse (RynthNav walks): RynthAi's own route waits. - /// Also read by BoostNavHoldsLoot, so the looter stands down for Boost Nav Priority exactly - /// when the arbiter's BoostNav clause can give nav the tick. + /// The Outdoor Hunt's walks count here (nav walks them); Boost Nav Priority's own test of "a + /// nav route runs" is BoostNavRule.NavRouteRuns, which leaves them out. /// private bool NavWantsTick(LegacyUiSettings settings) => settings.IsMacroRunning && settings.EnableNavigation @@ -1913,7 +1913,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase var inputs = new ArbiterInputs( settings.IsMacroRunning, wantBuff, wantCombat, wantLoot, wantSalvage, wantNav, combatEngaged: engaged, - boostNav: settings.BoostNavPriority, + boostNav: BoostNavRule.Active(settings), // only while a nav route runs (R-20261103-000159-a65e) boostLoot: settings.BoostLootPriority, followActive: followActive, lootStarved: lootStarved, diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/BoostNavTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/BoostNavTests.cs index fcb5ea5..0fc3fde 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/BoostNavTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/BoostNavTests.cs @@ -10,13 +10,14 @@ using RynthCore.RynthAiTests.Harness; namespace RynthCore.RynthAiHostTests.Tests; -// Boost Nav Priority, owner's rule (2026-11-02): with the flag on RynthAi ONLY navigates. No hunting, -// no looting, and no fighting back even with a monster attacking it; with a route (or a follow) it -// navigates, with nothing to navigate it stands idle. Buffing and vitals still run, buffing on top. -// R-20261102-041824-3f7c: the flag came on through NavLootPrio (or a hunting meta), there was no -// route, and the arbiter's WantNav-guarded clause let combat win, so the bot hunted as usual and the -// player never noticed the flag; they only saw that it would not loot. The first fight or corpse -// the flag skips now says so in chat, once per session. +// Boost Nav Priority, owner's corrected rule (2026-11-02, R-20261103-000159-a65e): "Boost nav +// priority should only run the nav route, not from mob to mob. So when no nav route is loaded it +// should fight." And: "When a 'once' nav route is at the end it should hunt as well." While a nav +// route (or a follow) runs, RynthAi only follows it: no hunting, no looting, no fighting back. With +// no route, a Once route at its end, or the Outdoor Hunt (its walks go from monster to monster), +// the flag does nothing: RynthAi hunts, fights and loots as with it off. Buffing stays on top. +// The first fight or corpse the flag skips along a route is said in chat, once per session +// (R-20261102-041824-3f7c: the flag came on quietly through NavLootPrio). internal static class BoostNavTests { private const uint Player = 0x50000F51; @@ -26,12 +27,34 @@ internal static class BoostNavTests public static void Register(Runner r) { - r.Add("boost nav (owner, 2026-11-02): the arbiter never picks Combat or Looting with the flag on, route or not; buffing stays on top", ArbiterRule); - r.Add("boost nav: no route, a monster attacking: never Combat or Looting, no attack sent, no target locked", NoRouteNeverFights); + r.Add("boost nav (R-20261103-000159-a65e): with a route running the arbiter never picks Combat or Looting; without, the usual order; buffing on top", ArbiterRule); + r.Add("boost nav (R-20261103-000159-a65e): a nav route running: loaded, follow; not: none, empty, nav off, a Once route at its end, an Outdoor Hunt walk", RouteRunsRule); + r.Add("boost nav: no route, a monster attacking: it fights (Combat, attack sent, target locked)", NoRouteFights); + r.Add("boost nav: Outdoor Hunt walking to a monster: it fights (the hunt is no nav route)", OutdoorHuntFights); r.Add("boost nav: with a route: Navigating every tick, no attack sent even with a monster on top", RouteNavigatesOnly); - r.Add("boost nav: turned on mid-fight: the target is dropped, the server attack cancelled, the stance back to Peace", MidFightDisengages); - r.Add("boost nav: turned off again: hunting resumes (target locked, attack sent)", OffResumesHunting); - r.Add("boost nav: the skipped fight is said in chat and the log once per session, never with the flag off", NoticeOncePerSession); + r.Add("boost nav: a route loaded mid-fight: the target is dropped, the server attack cancelled, the stance back to Peace", RouteMidFightDisengages); + r.Add("boost nav: the route unloaded: hunting resumes (target locked, attack sent)", UnloadResumesHunting); + r.Add("boost nav: a Once route navigates only until its last point, then it fights; Circular and Linear keep running", OnceRouteEndFights); + r.Add("boost nav: turned off on a route: hunting resumes", OffResumesHunting); + r.Add("boost nav: the skipped fight is said in chat and the log once per session, only while a route runs", NoticeOncePerSession); + } + + // ── Routes ──────────────────────────────────────────────────────────────── + + private static NavRouteParser Route(NavRouteType type = NavRouteType.Circular, int points = 3, bool huntWalk = false) + { + var r = new NavRouteParser { RouteType = type, OutdoorHuntWalk = huntWalk }; + for (int i = 0; i < points; i++) + r.Points.Add(new NavPoint { Type = NavPointType.Point, NS = 10.5 + i, EW = -3.25 - i }); + return r; + } + + /// Loads a route the way a nav file load does: nav on, from [0]. + private static void Load(LegacyUiSettings s, NavRouteParser route) + { + s.CurrentRoute = route; + s.ActiveNavIndex = 0; + s.EnableNavigation = true; } // ── 1. The pure rule ────────────────────────────────────────────────────── @@ -45,34 +68,89 @@ internal static class BoostNavTests private static void ArbiterRule() { - // Every combination of combat / engaged / loot / loot-starved / Boost Loot, no route: Idle. + // The arbiter's boostNav input is BoostNavRule.Active: the flag AND a route running. Every + // combination of combat / engaged / loot / loot-starved / Boost Loot along a route: Navigating. for (int bits = 0; bits < 32; bits++) { bool combat = (bits & 1) != 0, engaged = (bits & 2) != 0, loot = (bits & 4) != 0, starved = (bits & 8) != 0, boostLoot = (bits & 16) != 0; - var noRoute = D(combat: combat, engaged: engaged, loot: loot, starved: starved, boostLoot: boostLoot); - Check.Eq(noRoute, BotActivity.Idle, $"no route (combat={combat} engaged={engaged} loot={loot} starved={starved} boostLoot={boostLoot}): Idle"); var route = D(combat: combat, engaged: engaged, loot: loot, starved: starved, boostLoot: boostLoot, nav: true); Check.Eq(route, BotActivity.Navigating, $"a route (combat={combat} engaged={engaged} loot={loot}): Navigating"); } + Check.Eq(D(combat: true, boostNav: false), BotActivity.Combat, "no route (input false): Combat, as with the flag off"); + Check.Eq(D(loot: true, boostNav: false), BotActivity.Looting, "no route: Looting, as with the flag off"); Check.Eq(D(combat: true, engaged: true, nav: true, follow: true), BotActivity.Navigating, "a follow is navigating too"); Check.Eq(D(buff: true, combat: true, nav: true), BotActivity.Buffing, "buffing still outranks it"); - Check.Eq(D(buff: true, combat: true), BotActivity.Buffing, "buffing with no route too"); - Check.Eq(D(loot: true, forced: true), BotActivity.Looting, "a /ra lootthis container is still looted (no route)"); - Check.Eq(D(loot: true, forced: true, nav: true), BotActivity.Navigating, "with a route nav keeps the tick, as before"); - Check.Eq(D(salv: true, combat: true), BotActivity.Salvaging, "the salvage queue (an inventory chore) still runs"); + Check.Eq(D(loot: true, forced: true, nav: true), BotActivity.Navigating, "with a route nav keeps the tick over a /ra lootthis"); + Check.Eq(D(combat: true), BotActivity.Idle, "a route loaded but nav waiting (corpse travel): Idle, no fight"); Check.Eq(D(combat: true, nav: true, boostNav: false), BotActivity.Combat, "flag off: combat outranks nav as usual"); - Check.Eq(D(loot: true, boostNav: false), BotActivity.Looting, "flag off: looting as usual"); Check.Eq(ActivityArbiter.ToBotAction(BotActivity.Idle), "Default", "Idle shows as Default (the dashboard reads Idle)"); } + private static void RouteRunsRule() + { + var s = new LegacyUiSettings { IsMacroRunning = true, BoostNavPriority = true }; + Check.False(BoostNavRule.Active(s), "nothing loaded"); + s.EnableNavigation = true; + Check.False(BoostNavRule.Active(s), "nav on, no route"); + Load(s, Route(points: 0)); + Check.False(BoostNavRule.Active(s), "an empty route"); + + foreach (var type in new[] { NavRouteType.Circular, NavRouteType.Linear }) + { + Load(s, Route(type)); + Check.True(BoostNavRule.Active(s), $"{type} route: running"); + s.ActiveNavIndex = 2; + Check.True(BoostNavRule.Active(s), $"{type} route at its last point: still running (it repeats)"); + } + + Load(s, Route(NavRouteType.Once, points: 2)); + Check.True(BoostNavRule.Active(s), "Once route at [0]: running"); + s.ActiveNavIndex = 1; + Check.True(BoostNavRule.Active(s), "Once route at its last point: still being walked"); + s.ActiveNavIndex = 2; + Check.False(BoostNavRule.Active(s), "Once route past its last point: finished, no route runs"); + s.EnableNavigation = false; // what the nav engine's CompleteOnceRoute does + Check.False(BoostNavRule.Active(s), "and with nav switched off by the engine"); + Check.True(s.RearmFinishedNavRoute(), "rig: /ra nav restart rewinds it"); + s.EnableNavigation = true; + Check.True(BoostNavRule.Active(s), "restarted: running again"); + Load(s, Route(NavRouteType.Once, points: 2)); + Check.True(BoostNavRule.Active(s), "loaded again: running again"); + + Load(s, Route(NavRouteType.Once, huntWalk: true)); + Check.False(BoostNavRule.Active(s), "the Outdoor Hunt's walk to a monster: no nav route"); + s.CurrentNavPath = "saved-walk.nav"; + Check.True(BoostNavRule.Active(s), "the same walk saved to a nav file is a loaded route"); + s.CurrentNavPath = string.Empty; + + Load(s, new NavRouteParser { RouteType = NavRouteType.Follow, FollowTargetName = "Leader" }); + Check.True(BoostNavRule.Active(s), "a Follow route counts (as in VTank)"); + Load(s, new NavRouteParser()); + s.FollowMode = true; + s.FollowTargetId = 0x50000001; + Check.True(BoostNavRule.Active(s), "fellowship follow counts too"); + s.FollowMode = false; + s.FollowTargetId = 0; + + Load(s, Route()); + s.EnableNavigation = false; + Check.False(BoostNavRule.Active(s), "a route loaded with nav off: not running"); + s.EnableNavigation = true; + s.IsMacroRunning = false; + Check.False(BoostNavRule.Active(s), "macro off: not running"); + s.IsMacroRunning = true; + s.BoostNavPriority = false; + Check.False(BoostNavRule.Active(s), "flag off: never"); + Check.True(BoostNavRule.NavRouteRuns(s), "(the route itself still runs)"); + } + // ── A melee rig, ticked the way OnTick ticks it ─────────────────────────── private sealed class Rig { public readonly LegacyUiSettings S; public readonly CombatManager C; - public bool Route; public readonly List Decisions = new(); public Rig(float mobY) @@ -90,6 +168,7 @@ internal static class BoostNavTests S = new LegacyUiSettings { MonsterRange = 50, IsMacroRunning = true, EnableCombat = true, EnableLooting = true, + EnableNavigation = true, MonsterRules = new List { new() { Name = "Default" } }, }; var host = FakeHost.Create(Player); @@ -100,13 +179,15 @@ internal static class BoostNavTests C.ScanNearbyTargets(); } - /// One tick: the arbiter decides from combat's own wants (as OnTick does), writes - /// BotAction, and combat ticks. The attack cadence runs on the real clock, so it is reset. + /// One tick: the arbiter decides from combat's own wants and the loaded route (as + /// OnTick does: NavWantsTick's route test, BoostNavRule.Active), writes BotAction, and combat + /// ticks. The attack cadence runs on the real clock, so it is reset. public BotActivity Tick() { bool wantCombat = S.EnableCombat && C.HasEngageableTarget; - var inputs = new ArbiterInputs(S.IsMacroRunning, false, wantCombat, false, false, Route, - combatEngaged: C.IsUnderCloseAttack, boostNav: S.BoostNavPriority, boostLoot: S.BoostLootPriority); + bool wantNav = S.IsMacroRunning && S.EnableNavigation && S.CurrentRoute != null && S.CurrentRoute.Points.Count > 0; + var inputs = new ArbiterInputs(S.IsMacroRunning, false, wantCombat, false, false, wantNav, + combatEngaged: C.IsUnderCloseAttack, boostNav: BoostNavRule.Active(S), boostLoot: S.BoostLootPriority); BotActivity act = ActivityArbiter.Decide(in inputs); S.BotAction = ActivityArbiter.ToBotAction(act); LastAttackCmd.SetValue(C, DateTime.MinValue); @@ -137,71 +218,143 @@ internal static class BoostNavTests private static bool Logged(string part) => FakeHost.Logs.Any(l => l.Contains(part, StringComparison.Ordinal)); - // ── 2. No route ─────────────────────────────────────────────────────────── + // ── 2. No route: it fights ──────────────────────────────────────────────── - private static void NoRouteNeverFights() + private static void NoRouteFights() { var rig = new Rig(mobY: 97.5f); // 1.5 m: on top of us, the "attacking me" case - rig.S.BoostNavPriority = true; + rig.S.BoostNavPriority = true; // NavLootPrio turned it on; no route loaded Check.True(rig.C.HasEngageableTarget && rig.C.IsUnderCloseAttack, "rig: a monster close enough to be attacking"); - rig.Ticks(60); - Check.False(rig.Decisions.Any(a => a is BotActivity.Combat or BotActivity.Looting), "never Combat or Looting"); - Check.True(rig.Decisions.All(a => a == BotActivity.Idle), "Idle the whole time (nothing to navigate)"); - Check.Eq(FakeHost.AttackCalls.Count, 0, "no attack sent"); - Check.Eq(rig.C.activeTargetId, 0, "no target locked"); - Check.True(rig.C.BoostNavStoodDown, "combat stands down for the flag"); - Check.True(Logged("Boost Nav Priority is on - no hunting and no fighting back"), "and the log says why"); - Check.True(rig.C.HasEngageableTarget, "the scan still runs (it is what the notice reads)"); + Check.True(rig.TickToAttack(), "an attack goes out"); + Check.Eq((uint)rig.C.activeTargetId, Mob, "the monster is locked"); + Check.True(rig.Decisions.Contains(BotActivity.Combat), "the arbiter gives Combat the tick"); + Check.False(rig.C.BoostNavStoodDown, "combat does not stand down"); + Check.False(Logged("no hunting and no fighting back"), "nothing logged about standing down"); } - // ── 3. A route ──────────────────────────────────────────────────────────── + // ── 3. The Outdoor Hunt: it fights ──────────────────────────────────────── + + private static void OutdoorHuntFights() + { + var rig = new Rig(mobY: 99f); + rig.S.BoostNavPriority = true; + Load(rig.S, Route(NavRouteType.Once, points: 2, huntWalk: true)); // the hunt walking to the monster + Check.True(rig.TickToAttack(), "an attack goes out"); + Check.Eq((uint)rig.C.activeTargetId, Mob, "the monster is locked"); + Check.True(rig.Decisions.Contains(BotActivity.Combat), "Combat over the hunt's walk, as with the flag off"); + Check.False(rig.Decisions.Contains(BotActivity.Navigating), "never held in Navigating with a monster to fight"); + Check.False(rig.C.BoostNavStoodDown, "combat does not stand down"); + } + + // ── 4. A route: navigate only ───────────────────────────────────────────── private static void RouteNavigatesOnly() { var rig = new Rig(mobY: 97.5f); rig.S.BoostNavPriority = true; - rig.Route = true; + Load(rig.S, Route()); rig.Ticks(60); Check.True(rig.Decisions.All(a => a == BotActivity.Navigating), "Navigating every tick"); Check.Eq(rig.S.BotAction, "Navigating", "BotAction says Navigating"); Check.Eq(FakeHost.AttackCalls.Count, 0, "no attack sent"); Check.Eq(rig.C.activeTargetId, 0, "no target locked"); + Check.True(rig.C.BoostNavStoodDown, "combat stands down for the route"); + Check.True(Logged("Boost Nav Priority is on and a nav route runs - no hunting and no fighting back"), "and the log says why"); + Check.True(rig.C.HasEngageableTarget, "the scan still runs (it is what the notice reads)"); } - // ── 4. Mid-fight ────────────────────────────────────────────────────────── + // ── 5. A route loaded mid-fight ─────────────────────────────────────────── - private static void MidFightDisengages() + private static void RouteMidFightDisengages() { var rig = new Rig(mobY: 99f); // 3 m north - Check.True(rig.TickToAttack(), "flag off: the fight starts (an attack goes out)"); + rig.S.BoostNavPriority = true; // on, but no route: it fights + Check.True(rig.TickToAttack(), "no route: the fight starts (an attack goes out)"); Check.Eq((uint)rig.C.activeTargetId, Mob, "the Drudge is the target"); Check.Eq(rig.Decisions[^1], BotActivity.Combat, "in Combat"); int attacks = FakeHost.AttackCalls.Count; int cancels = FakeHost.CancelAttacks; FakeHost.CombatModeRequests.Clear(); - rig.S.BoostNavPriority = true; // NavLootPrio, or a meta's SetOpt navpriorityboost - Check.Eq(rig.Tick(), BotActivity.Idle, "the next tick: Idle, not Combat"); + Load(rig.S, Route()); // a nav file loaded (or a meta's route) + Check.Eq(rig.Tick(), BotActivity.Navigating, "the next tick: Navigating, not Combat"); Check.Eq(rig.C.activeTargetId, 0, "the target is dropped"); Check.True(FakeHost.CancelAttacks > cancels, "the server's attack is cancelled (no more swings, no walk to the mob)"); - Check.True(Logged("DropTarget 0x80000451: Boost Nav Priority is on"), "the drop is logged with the reason"); + Check.True(Logged("DropTarget 0x80000451: Boost Nav Priority is on and a nav route runs"), "the drop is logged with the reason"); Check.True(FakeHost.CombatModeRequests.Contains(CombatMode.NonCombat), "Peace Mode When Idle: back to Peace, no stance left up"); FakeHost.CombatModeValue = CombatMode.NonCombat; // the server lands the swap int modeAsks = FakeHost.CombatModeRequests.Count; rig.Ticks(60); - Check.Eq(FakeHost.AttackCalls.Count, attacks, "no attack after the flag came on"); + Check.Eq(FakeHost.AttackCalls.Count, attacks, "no attack while the route runs"); Check.Eq(rig.C.activeTargetId, 0, "nothing re-locked"); Check.Eq(FakeHost.CombatModeRequests.Count, modeAsks, "in Peace: no more mode changes"); - Check.False(rig.Decisions.Skip(rig.Decisions.Count - 60).Any(a => a == BotActivity.Combat), "never Combat again while it is on"); + Check.False(rig.Decisions.Skip(rig.Decisions.Count - 60).Any(a => a == BotActivity.Combat), "never Combat again while it runs"); } - // ── 5. Off again ────────────────────────────────────────────────────────── + // ── 6. The route unloaded ───────────────────────────────────────────────── + + private static void UnloadResumesHunting() + { + var rig = new Rig(mobY: 99f); + rig.S.BoostNavPriority = true; + Load(rig.S, Route()); + rig.Ticks(20); + Check.Eq(FakeHost.AttackCalls.Count, 0, "route: nothing attacked"); + + rig.S.CurrentRoute = new NavRouteParser(); // unloaded; the flag stays on + Check.True(rig.TickToAttack(), "no route: an attack goes out again"); + Check.Eq((uint)rig.C.activeTargetId, Mob, "the Drudge is locked"); + Check.True(rig.Decisions.Contains(BotActivity.Combat), "the arbiter gives Combat the tick again"); + Check.False(rig.C.BoostNavStoodDown, "combat no longer stands down"); + Check.True(Logged("Boost Nav Priority is on but no nav route runs - hunting again"), "logged once the route is gone"); + } + + // ── 7. A Once route at its end ──────────────────────────────────────────── + + private static void OnceRouteEndFights() + { + var rig = new Rig(mobY: 99f); + rig.S.BoostNavPriority = true; + Load(rig.S, Route(NavRouteType.Once, points: 2)); + rig.Ticks(10); + rig.S.ActiveNavIndex = 1; // walking to the last point + rig.Ticks(10); + Check.True(rig.Decisions.All(a => a == BotActivity.Navigating), "while the Once route is walked: Navigating only"); + Check.Eq(FakeHost.AttackCalls.Count, 0, "no attack on the way"); + + // The last point reached: the nav engine's CompleteOnceRoute leaves the index past the end + // and switches nav off. + rig.S.ActiveNavIndex = 2; + rig.S.EnableNavigation = false; + Check.True(rig.TickToAttack(), "at the end: an attack goes out (it hunts)"); + Check.Eq((uint)rig.C.activeTargetId, Mob, "the Drudge is locked"); + Check.False(rig.C.BoostNavStoodDown, "combat no longer stands down"); + + // A meta turning nav back on over the finished route: still finished, still hunting. + rig.S.EnableNavigation = true; + rig.Ticks(5); + Check.Eq(rig.Decisions[^1], BotActivity.Combat, "nav on over a finished Once route: still Combat"); + + foreach (var type in new[] { NavRouteType.Circular, NavRouteType.Linear }) + { + var r2 = new Rig(mobY: 99f); + r2.S.BoostNavPriority = true; + Load(r2.S, Route(type, points: 2)); + r2.S.ActiveNavIndex = 1; // at the last point: it goes round (or back) again + r2.Ticks(30); + Check.True(r2.Decisions.All(a => a == BotActivity.Navigating), $"{type} route at its last point: still Navigating only"); + Check.Eq(FakeHost.AttackCalls.Count, 0, $"{type}: no attack"); + } + } + + // ── 8. The flag off on a route ──────────────────────────────────────────── private static void OffResumesHunting() { var rig = new Rig(mobY: 99f); rig.S.BoostNavPriority = true; + Load(rig.S, Route()); rig.Ticks(20); Check.Eq(FakeHost.AttackCalls.Count, 0, "on: nothing attacked"); @@ -211,10 +364,10 @@ internal static class BoostNavTests Check.True(rig.Decisions.Contains(BotActivity.Combat), "the arbiter gives Combat the tick again"); Check.False(rig.C.BoostNavStoodDown, "combat no longer stands down"); Check.True(Logged("Boost Nav Priority is off - hunting again"), "logged once it is off"); - // Looting coming back once the flag is off: LootClaimMismatchTests' Boost Nav test. + // Looting along and off a route: LootClaimMismatchTests' Boost Nav tests. } - // ── 6. The notice ───────────────────────────────────────────────────────── + // ── 9. The notice ───────────────────────────────────────────────────────── private static RynthAiPlugin Plugin() { @@ -239,8 +392,17 @@ internal static class BoostNavTests Check.Eq(NoticeCount(), 0, "flag off: nothing said"); s.BoostNavPriority = true; + s.EnableNavigation = true; + for (int i = 0; i < 20; i++) Note(p, s, wantCombat: true); + Check.Eq(NoticeCount(), 0, "flag on, no route: it fights, nothing is skipped, nothing said"); + + Load(s, Route(NavRouteType.Once, huntWalk: true)); + Note(p, s, wantCombat: true); + Check.Eq(NoticeCount(), 0, "the Outdoor Hunt: nothing said"); + + Load(s, Route()); Note(p, s, wantCombat: false); - Check.Eq(NoticeCount(), 0, "flag on, nothing skipped (no monster, looting off): nothing said"); + Check.Eq(NoticeCount(), 0, "a route, nothing skipped (no monster, looting off): nothing said"); s.IsMacroRunning = false; Note(p, s, wantCombat: true); @@ -248,10 +410,10 @@ internal static class BoostNavTests s.IsMacroRunning = true; Note(p, s, wantCombat: true); - Check.Eq(NoticeCount(), 1, "the first skipped fight: said in chat"); + Check.Eq(NoticeCount(), 1, "the first fight skipped along a route: said in chat"); Check.Eq(RynthAiPlugin.BoostNavNotice, - "[RynthAi] Boost Nav Priority is on: RynthAi only navigates (no hunting, no looting). Turn it off to hunt and loot.", - "the owner's wording"); + "[RynthAi] Boost Nav Priority is on: while a nav route runs, RynthAi only follows it (no hunting, no looting). Turn it off to hunt along the route.", + "the wording"); Check.True(Logged(RynthAiPlugin.BoostNavNotice + " (skipped a fight)"), "and in the log, with what was skipped"); Check.Eq(FakeHost.ChatTypes[FakeHost.Chat.IndexOf(RynthAiPlugin.BoostNavNotice)], 2, "in the warning colour"); @@ -261,7 +423,11 @@ internal static class BoostNavTests Check.Eq(NoticeCount(), 1, "once per session: not again, not even after the flag goes off and on"); var next = Plugin(); // a new session (a login or a reload starts a new plugin instance) + s.CurrentRoute = new NavRouteParser(); Note(next, s, wantCombat: true); - Check.Eq(NoticeCount(), 2, "a new session says it again, once"); + Check.Eq(NoticeCount(), 1, "a new session with no route: nothing said"); + Load(s, Route()); + Note(next, s, wantCombat: true); + Check.Eq(NoticeCount(), 2, "a new session along a route says it again, once"); } } diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/ChestLootTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/ChestLootTests.cs index 70e402f..f4e86a5 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/ChestLootTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/ChestLootTests.cs @@ -42,6 +42,7 @@ internal static class ChestLootTests r.Add("chest loot: Looting off and Pickup with macro off off -> nothing taken, the loot check still runs", LootingOffNothing); r.Add("chest loot: Pickup with macro off (on by default) loots an opened chest with the macro off or Looting off", PickupWithMacroOff); r.Add("chest loot: Pickup with macro off never takes from house storage or your own side pack", PickupWithMacroOffRefuses); + r.Add("chest loot: Pickup with macro off leaves the chest open and says so with Leave the chest open (off by default: it closes it)", PickupLeavesChestOpen); r.Add("chest loot: reopening the chest loots it again (never marked done)", ReopenLootsAgain); r.Add("chest loot: a salvage-only item is left when no UST is carried, as on corpses", SalvageWithoutUstLeft); r.Add("chest loot: opened mid-fight it waits for combat, then is looted if still open", ChestWaitsForCombat); @@ -356,6 +357,49 @@ internal static class ChestLootTests } } + private static void PickupLeavesChestOpen() + { + Check.False(new LegacyUiSettings().LootChestsMacroOffLeaveOpen, "Leave the chest open is off by default (the chest is closed)"); + foreach (bool leaveOpen in new[] { true, false }) + { + BaseWorld(); + var host = FakeHost.Create(Player); + var bot = new Bot(host); + bot.S.IsMacroRunning = false; + bot.S.LootChestsMacroOffLeaveOpen = leaveOpen; + string what = leaveOpen ? "leave open" : "close"; + bot.Create(Chest, Gem, Spoon); + + bot.ServerOpens(Chest); + bot.TickUntil(() => bot.Moved(Gem)); + FakeHost.Containers[Gem] = Player; // it lands in the pack + if (leaveOpen) + { + bot.TickUntil(() => FakeHost.Chat.Any(c => c.Contains("Left it open"))); + Check.Eq(FakeHost.Closes.Count, 0, $"{what}: the chest is not closed"); + Check.True(FakeHost.Chat.Any(c => c.Contains("Pickup with macro off: done with") && c.Contains("took 1 item(s)") && c.Contains("Left it open")), + $"{what}: chat says what was taken and that it's open (chat: {string.Join(" | ", FakeHost.Chat)})"); + Check.False(bot.HasLootWork(), $"{what}: the looter is done with it"); + } + else + { + bot.TickUntil(() => FakeHost.Closes.Count > 0); + Check.Eq(FakeHost.Closes.Count, 1, $"{what}: the chest is closed once when done"); + Check.False(FakeHost.Chat.Any(c => c.Contains("Left it open")), $"{what}: no left-open line"); + } + } + + // The macro's own chest looting (macro and Looting on) still closes: the option is Pickup with macro off's. + BaseWorld(); + var h2 = FakeHost.Create(Player); + var b2 = new Bot(h2); + b2.Create(Chest, Gem, Spoon); + b2.ServerOpens(Chest); + LootGemAndFinish(b2, Gem); + Check.Eq(FakeHost.Closes.Count, 1, "macro on: the chest is closed when done, as before"); + Check.False(FakeHost.Chat.Any(c => c.Contains("Left it open")), "macro on: no left-open line"); + } + private static void PickupWithMacroOffRefuses() { BaseWorld(); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/LootClaimMismatchTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/LootClaimMismatchTests.cs index b33a7a2..eae4f24 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/LootClaimMismatchTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/LootClaimMismatchTests.cs @@ -19,7 +19,9 @@ namespace RynthCore.RynthAiHostTests.Tests; // "Corpse loot:" line followed (no [LootSettings] line the whole session either). Boost Nav Priority // was on with no route to run: the arbiter's BoostNav clause is guarded by WantNav, so Looting won, // while TickCorpseOpening's full stop took the flag alone and reset every claim. Owner's rule -// (2026-10-31): Boost Nav Priority means no looting at all, so HasLootWork offers nothing either. The kill's corpse +// (2026-10-31): Boost Nav Priority means no looting, so HasLootWork offers nothing either; corrected +// 2026-11-02 (R-20261103-000159-a65e): only while a nav route runs. With no route, a Once route at +// its end, or the Outdoor Hunt, corpses are looted as with the flag off. The kill's corpse // ('Treasure of ...', no corpse name) was first filed as a no-position inventory Container and // rescued to Corpse by its weenie flag 3 s later; it must be claimed and looted like any other. // The loot clock (CorpseOpenController.CorpseClock) is moved by hand; the server answers at once. @@ -39,10 +41,11 @@ internal static class LootClaimMismatchTests public static void Register(Runner r) { r.Add("loot claim (R-20261031-203155-cea0): a corpse first filed as a no-position inventory Container, then rescued, is claimed and looted", RescuedCorpseLooted); - r.Add("loot claim (R-20261031-203155-cea0): Boost Nav Priority with no route: no loot work, never in Looting; looted once the flag is off", BoostNavNoRouteLoots); - r.Add("loot claim (R-20261031-203155-cea0): Boost Nav Priority with a route, then none: nav has the tick, nothing claimed either way", BoostNavWithRouteYields); + r.Add("loot claim (R-20261103-000159-a65e): Boost Nav Priority with no route: loot work, Looting, the corpse looted as with the flag off", BoostNavNoRouteLoots); + r.Add("loot claim (R-20261103-000159-a65e): Boost Nav Priority with a route: nav has the tick, nothing claimed; route unloaded: looted", BoostNavWithRouteYields); + r.Add("loot claim (R-20261103-000159-a65e): Boost Nav Priority on an Outdoor Hunt walk, and at the end of a Once route: looted", BoostNavHuntAndOnceEndLoot); r.Add("loot claim (R-20261031-203155-cea0): Looting with nothing claimed is logged with the reason after 3 s, then throttled", LootStallLogged); - r.Add("boost nav (R-20261102-041824-3f7c): a corpse it passes by is said once in chat; nothing claimed; looted once the flag is off", BoostNavCorpseNotice); + r.Add("boost nav (R-20261102-041824-3f7c): a corpse passed by along a route is said once in chat; none said with no route; looted once the route is gone", BoostNavCorpseNotice); } // ── Clock and world ─────────────────────────────────────────────────────── @@ -122,7 +125,7 @@ internal static class LootClaimMismatchTests public BotActivity Decide() { var inputs = new ArbiterInputs(S.IsMacroRunning, false, false, HasLootWork(), false, NavWants(), - boostNav: S.BoostNavPriority, boostLoot: S.BoostLootPriority); + boostNav: BoostNavRule.Active(S), boostLoot: S.BoostLootPriority); return ActivityArbiter.Decide(in inputs); } @@ -206,35 +209,42 @@ internal static class LootClaimMismatchTests Check.False(bot.HasLootWork(), "no loot work left: the bot leaves Looting"); }); - // ── 2. The report: Boost Nav Priority on, nothing to navigate ───────────── + private static NavRouteParser Route(NavRouteType type, bool huntWalk = false) + { + var route = new NavRouteParser { RouteType = type, OutdoorHuntWalk = huntWalk }; + route.Points.Add(new NavPoint { Type = NavPointType.Point, NS = 10.5, EW = -3.25 }); + route.Points.Add(new NavPoint { Type = NavPointType.Point, NS = 11.5, EW = -4.25 }); + return route; + } - // Owner, 2026-10-31: Boost Nav Priority means no looting at all, route or not. + private static void LootedToTheEnd(Bot bot, string when) + { + Check.True(bot.HasLootWork(), $"{when}: loot work"); + Check.Eq(bot.Tick(), BotActivity.Looting, $"{when}: Looting has the tick"); + Check.Eq(bot.Claimed, unchecked((int)Corpse), $"{when}: the corpse is claimed"); + LootToTheEnd(bot); + Check.True(bot.Completed, $"{when}: looted to the end"); + Check.True(FakeHost.ExternalMoves.Any(m => m.Id == Gem && m.Target == Player), $"{when}: the gem is in the pack"); + } + + // ── 2. The report's setting, nothing to navigate: it loots ──────────────── + + // Owner's corrected rule (2026-11-02, R-20261103-000159-a65e): "when no nav route is loaded it + // should fight", and loot: with no route the flag changes nothing. private static void BoostNavNoRouteLoots() => Clocked(() => { World(); var bot = RescuedCorpse(); bot.S.BoostNavPriority = true; - bot.S.BoostLootPriority = true; // both on, as in the report: nav wins + bot.S.BoostLootPriority = true; // both on, as in the report (NavLootPrio) bot.S.EnableNavigation = true; // on, but no route loaded (want[nav=False] in the report) Check.False(bot.NavWants(), "nav has nothing to run"); - Check.False(bot.HasLootWork(), "Boost Nav Priority: no loot work, the corpse is passed by"); - Check.True(bot.Decide() != BotActivity.Looting, "the arbiter never gives Looting the tick"); - - for (int i = 0; i < 200; i++) Check.True(bot.Tick() != BotActivity.Looting, "never in Looting (5 s)"); - Check.Eq(bot.Claimed, 0, "nothing claimed"); - Check.False(FakeHost.Uses.Contains(Corpse), "nothing opened"); - Check.False(Logged("Looting has held the tick"), "no stall: Looting never had the tick"); - - bot.S.BoostNavPriority = false; // the flag off: the corpse is looted as usual - Check.True(bot.HasLootWork(), "loot work again"); - bot.Tick(); - Check.Eq(bot.Claimed, unchecked((int)Corpse), "the corpse is claimed"); - LootToTheEnd(bot); - Check.True(bot.Completed, "looted to the end"); - Check.True(FakeHost.ExternalMoves.Any(m => m.Id == Gem && m.Target == Player), "the gem is in the pack"); + Check.False(BoostNavRule.Active(bot.S), "Boost Nav Priority does not count with no route"); + LootedToTheEnd(bot, "no route, flag on"); + Check.False(Logged("Boost Nav Priority is on and a nav route runs"), "no Boost Nav skip reason logged"); }); - // ── 3. Boost Nav Priority with a route still yields to nav ──────────────── + // ── 3. Boost Nav Priority with a route yields to nav; unloaded, it loots ── private static void BoostNavWithRouteYields() => Clocked(() => { @@ -242,24 +252,51 @@ internal static class LootClaimMismatchTests var bot = RescuedCorpse(); bot.S.BoostNavPriority = true; bot.S.EnableNavigation = true; - var route = new NavRouteParser { RouteType = NavRouteType.Linear }; - route.Points.Add(new NavPoint { Type = NavPointType.Point, NS = 10.5, EW = -3.25 }); - route.Points.Add(new NavPoint { Type = NavPointType.Point, NS = 11.5, EW = -4.25 }); - bot.S.CurrentRoute = route; + bot.S.CurrentRoute = Route(NavRouteType.Linear); Check.True(bot.NavWants(), "nav has a route to run"); Check.False(bot.HasLootWork(), "no loot work to offer: the looter stands down for the route"); Check.Eq(bot.Decide(), BotActivity.Navigating, "nav has the tick"); - for (int i = 0; i < 200; i++) bot.Tick(); // 5 s + for (int i = 0; i < 200; i++) Check.Eq(bot.Tick(), BotActivity.Navigating, "Navigating along the route (5 s)"); Check.Eq(bot.Claimed, 0, "nothing claimed"); Check.False(FakeHost.Uses.Contains(Corpse), "nothing opened"); Check.False(Logged("Looting has held the tick"), "not a Looting stall: Looting never had the tick"); - bot.S.CurrentRoute = null; // the route is unloaded: still no looting while the flag is on - Check.True(bot.Tick() != BotActivity.Looting, "no route, flag on: still no Looting"); - Check.Eq(bot.Claimed, 0, "still nothing claimed"); + bot.S.CurrentRoute = new NavRouteParser(); // the route is unloaded; the flag stays on + LootedToTheEnd(bot, "route unloaded, flag on"); }); + // ── 3b. The Outdoor Hunt, and a Once route at its end: it loots ─────────── + + private static void BoostNavHuntAndOnceEndLoot() + { + Clocked(() => + { + World(); + var bot = RescuedCorpse(); + bot.S.BoostNavPriority = true; + bot.S.EnableNavigation = true; + bot.S.CurrentRoute = Route(NavRouteType.Once, huntWalk: true); // the hunt walking to its next monster + Check.True(bot.NavWants(), "nav walks the hunt's walk"); + Check.False(BoostNavRule.Active(bot.S), "the hunt's walk is no nav route"); + LootedToTheEnd(bot, "Outdoor Hunt, flag on"); + }); + Clocked(() => + { + World(); + var bot = RescuedCorpse(); + bot.S.BoostNavPriority = true; + bot.S.EnableNavigation = true; + bot.S.CurrentRoute = Route(NavRouteType.Once); + bot.S.ActiveNavIndex = 1; // walking to the last point + Check.Eq(bot.Tick(), BotActivity.Navigating, "the Once route still walked: Navigating, no loot"); + Check.Eq(bot.Claimed, 0, "nothing claimed on the way"); + bot.S.ActiveNavIndex = 2; // the nav engine's CompleteOnceRoute: past the end... + bot.S.EnableNavigation = false; // ...and nav off + LootedToTheEnd(bot, "Once route at its end, flag on"); + }); + } + // ── 4. A stall is never silent ──────────────────────────────────────────── private static void LootStallLogged() => Clocked(() => @@ -290,19 +327,25 @@ internal static class LootClaimMismatchTests Check.True(Logged("the Looting stall is over"), "and the end of the stall is logged"); }); - // ── 5. Boost Nav Priority says it skipped the corpse (owner, 2026-11-02) ─── + // ── 5. Boost Nav Priority says it skipped the corpse along a route ──────── private static void BoostNavCorpseNotice() => Clocked(() => { World(); var bot = RescuedCorpse(); - bot.S.BoostNavPriority = true; // NavLootPrio turned it on; no route, no monster + bot.S.BoostNavPriority = true; // NavLootPrio turned it on; no monster + bot.S.EnableNavigation = true; int Notices() => FakeHost.Chat.Count(c => c == RynthAiPlugin.BoostNavNotice); void Note() => bot.Call("NoteBoostNavSkip", bot.S, false); - for (int i = 0; i < 200; i++) // 5 s of ticks, the notice looked at after each decision + // No route: the flag skips nothing, so nothing is said. + for (int i = 0; i < 200; i++) { Note(); _now += TickMs; } + Check.Eq(Notices(), 0, "no route: nothing said"); + + bot.S.CurrentRoute = Route(NavRouteType.Circular); + for (int i = 0; i < 200; i++) // 5 s of ticks along the route, the notice looked at after each decision { - Check.True(bot.Tick() != BotActivity.Looting, "never in Looting"); + Check.True(bot.Tick() != BotActivity.Looting, "never in Looting along the route"); Note(); } Check.Eq(Notices(), 1, "the passed-by corpse is said once in chat"); @@ -310,10 +353,10 @@ internal static class LootClaimMismatchTests Check.Eq(bot.Claimed, 0, "nothing claimed"); Check.False(FakeHost.Uses.Contains(Corpse), "nothing opened"); - bot.S.BoostNavPriority = false; + bot.S.CurrentRoute = new NavRouteParser(); // the route unloaded; the flag stays on Note(); bot.Tick(); - Check.Eq(bot.Claimed, unchecked((int)Corpse), "flag off: the corpse is claimed"); + Check.Eq(bot.Claimed, unchecked((int)Corpse), "no route: the corpse is claimed"); LootToTheEnd(bot); Check.True(bot.Completed, "and looted to the end"); Check.Eq(Notices(), 1, "nothing more said"); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/LootRetryTimingTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/LootRetryTimingTests.cs index a7f890f..a0f26e7 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/LootRetryTimingTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/LootRetryTimingTests.cs @@ -54,6 +54,9 @@ internal static class LootRetryTimingTests r.Add("loot pickup timer (#rynth-issues 'Stopped looting'): an item refused 'for room' in every pack it tries takes its pack marks with it; the next item lands", RefusedInEveryPackWithdrawn); r.Add("loot pickup timer (#rynth-issues 'Stopped looting'): a refusal with an error code counts as a try but not against the pack", CodedRefusalNotThePack); r.Add("loot pickup timer (#rynth-issues 'Stopped looting'): PackRefusals withdraws an item's own marks, keeps the ones another item backs", PackRefusalWithdraw); + r.Add("loot pickup in a fight (R-20261102-204309-206c): a move with no answer when a fight takes the tick is held, sent again after the fight and lands; the corpse completes, not abandoned", FightAfterLostMove); + r.Add("loot pickup in a fight (R-20261102-204309-206c): a move that lands during the fight is confirmed then; the next item waits for the fight's end", FightWhileMoveLands); + r.Add("loot pickup in a fight (R-20261102-204309-206c): an item the server never answers, a fight in between: one resend after the fight (no try counted), then given up with a log line", FightNeverAnswered); } // ── Clock and world ─────────────────────────────────────────────────────── @@ -111,6 +114,7 @@ internal static class LootRetryTimingTests }; public readonly WorldObjectCache Cache; public SlowAce? Sim; + public BotActivity Activity = BotActivity.Looting; // what the arbiter gave the tick public Bot(RynthCoreHost host) { @@ -142,7 +146,7 @@ internal static class LootRetryTimingTests { _now += TickMs; Sim?.Step(_now); - Set("_activity", BotActivity.Looting); + Set("_activity", Activity); Call("TickCorpseOpening"); } @@ -184,6 +188,11 @@ internal static class LootRetryTimingTests public readonly Dictionary Room = new(); // the server's free slots per pack (absent: plenty) public readonly Dictionary Lag = new(); public readonly HashSet NeverAnswer = new(); + /// Items whose first move never leaves the client: no answer ever comes to it. + public readonly HashSet LoseFirst = new(); + /// The client's attacking flag: a move sent now is dropped there ("You cannot move or use an item while attacking"). + public bool Attacking; + public int AttackRefused, Lost; public readonly HashSet QuestTimer = new(), NeedsQuest = new(), RefusedForItem = new(); public int QuestRefusals, Unlocks; public long ClientPendingTimeoutMs = 10_000; @@ -209,6 +218,8 @@ internal static class LootRetryTimingTests while (_seenMoves < FakeHost.ExternalMoves.Count) { var m = FakeHost.ExternalMoves[_seenMoves++]; + if (Attacking) { AttackRefused++; continue; } // "You cannot move or use an item while attacking" + if (LoseFirst.Remove(m.Id)) { Lost++; continue; } // never left the client if (_clientPending != 0 && now - _clientPendingAt >= ClientPendingTimeoutMs) _clientPending = 0; // the engine lets it go if (_clientPending != 0) { LocalRefused++; continue; } // "You can only move or use one item at a time" _clientPending = m.Id; @@ -698,4 +709,143 @@ internal static class LootRetryTimingTests Check.Eq(r.Withdraw(0, 10).Count, 0, "nothing for item 0"); Check.True(r.IsConfirmed(4, 10), "a mark with no item stays"); } + + // ── 8. A fight comes in while a pickup is out (R-20261102-204309-206c) ───────────────────── + // Conquest, RynthAi 2026.11.2.1, outdoors, Boost Loot Priority on: "sometimes it gets stuck on + // picking up loot like it will open the corpse and highlight the item and then just sit + // waiting". The corpse opened and the bow's move went out; it had no answer when monsters + // came 4.4 s later and the arbiter gave Combat the tick. The open corpse's looter still ran + // under Combat: the resend waited for 1 s of stillness the missile fight never gave, and once + // the answer wait was over nothing stopped the corpse's clock. 19 s after the send the corpse + // was abandoned mid-pickup (and marked completed: the bow was never picked up), with no line + // about the item at all. A move sent during the fight is dropped by the client anyway (its + // attacking flag). + + /// + /// A fight of : Combat has the tick. With each + /// shot animates 1.25 s (the cast gate and the client's attacking flag), then 150 ms of + /// stillness; the client's busy count is up from each shot's start to its end. From 3.5 s to + /// 6.5 s into the fight a lull (as at 15:39:25-28 in the report: no shot for 3 s, busy=1): the + /// character stands still, the last shot's busy count still up. Returns the moves sent during it. + /// + private static List<(uint Id, long At)> Fight(Bot bot, SlowAce sim, long ms, bool shots = true) + { + bot.Activity = BotActivity.Combat; + long start = _now, end = _now + ms; + bool swinging = false, busy = false; + var sends = new List<(uint, long)>(); + int seen = FakeHost.ExternalMoves.Count; + while (_now < end) + { + long t = _now - start; + bool lull = t >= 3500 && t < 6500; + bool swing = shots && !lull && t % 1400 < 1250; + bool wantBusy = swing || (shots && lull); + if (swing != swinging) + { + swinging = swing; + sim.Attacking = swing; + FakeHost.CastBusy = swing ? 1 : 0; + } + if (wantBusy != busy) + { + busy = wantBusy; + if (busy) bot.P.OnBusyCountIncremented(); else bot.P.OnBusyCountDecremented(); + } + bot.Tick(); + while (seen < FakeHost.ExternalMoves.Count) sends.Add((FakeHost.ExternalMoves[seen++].Id, _now)); + } + sim.Attacking = false; + FakeHost.CastBusy = 0; + if (busy) bot.P.OnBusyCountDecremented(); + bot.Activity = BotActivity.Looting; + return sends; + } + + private static bool Abandoned() => Logged("abandoning corpse"); + + private static void FightAfterLostMove() => Clocked(() => + { + const uint Bow = 0x80263171, G2 = 0x80263172; + World(sidePack: false, Bow, G2); + var sim = new SlowAce(); + sim.LoseFirst.Add(Bow); // the first move gets no answer (it never reached the server) + var bot = Open(sim, sidePack: false, Bow, G2); + bot.Call("NotePickupAnswerLatency", 3360L); // the report's answer wait: 4.86 s (its retries came 4860 ms apart) + bot.Set("_corpseTargetSince", _now - 3300); // the claim's age when the move went out (peace swap, walk, open) + + bot.TickUntil(() => bot.MovesOf(Bow) > 0, 2000); + Check.Eq(bot.MovesOf(Bow), 1, "the move is sent"); + bot.TickUntil(() => false, 4400); // standing at the corpse, no answer + Check.Eq(bot.MovesOf(Bow), 1, "not resent within the answer wait"); + + var during = Fight(bot, sim, 16_300); // the report's fight: 15:39:21.583-37.928 + + Check.Eq(during.Count, 0, "nothing is sent during the fight (the client would drop it)"); + Check.Eq(sim.AttackRefused, 0, "no move dropped for the attacking flag"); + Check.False(Abandoned(), "the corpse is not abandoned during the fight"); + Check.True(Logged("waits for the fight") && Logged("0x80263171 'Gem 113' sent"), "the held pickup is logged when the fight takes the tick"); + + var after = Run(bot, () => bot.Completed, 30_000); + + Check.True(Logged("the fight is over"), "the end of the hold is logged"); + Check.True(after.Count > 0 && after[0].Id == Bow, "the bow is sent again first after the fight"); + Check.True(Logged("sending 0x80263171 again after the fight"), "the resend is logged as the fight's"); + Check.True(sim.Landed.Any(l => l.Id == Bow && l.Pack == Player), "the bow lands"); + Check.True(sim.Landed.Any(l => l.Id == G2 && l.Pack == Player), "the next item lands"); + Check.False(Abandoned(), "the corpse is never abandoned"); + Check.False(Logged("pickup failed"), "nothing given up"); + Check.False(Logged("took none of"), "no pack judged on the lost move"); + Check.True(bot.Completed, "the corpse completes"); + }); + + private static void FightWhileMoveLands() => Clocked(() => + { + const uint G1 = 0x80263181, G2 = 0x80263182; + World(sidePack: false, G1, G2); + var sim = new SlowAce(); + var bot = Open(sim, sidePack: false, G1, G2); + + bot.TickUntil(() => bot.MovesOf(G1) > 0, 2000); + Check.Eq(bot.MovesOf(G1), 1, "the move is sent"); + bot.TickUntil(() => false, 300); // a monster comes before the answer (the pickup takes ~1.8 s) + + var during = Fight(bot, sim, 14_000, shots: false); + + Check.True(sim.Landed.Any(l => l.Id == G1), "the item lands during the fight"); + Check.True(Logged("pickup confirmed for 0x80263181"), "and is confirmed then"); + Check.Eq(bot.MovesOf(G1), 1, "never resent"); + Check.Eq(during.Count, 0, "the next item is not sent while combat has the tick"); + Check.False(Abandoned(), "the corpse is not abandoned during the fight"); + + Run(bot, () => bot.Completed, 30_000); + + Check.True(sim.Landed.Any(l => l.Id == G2), "the next item lands after the fight"); + Check.False(Abandoned(), "never abandoned"); + Check.True(bot.Completed, "the corpse completes"); + }); + + private static void FightNeverAnswered() => Clocked(() => + { + const uint Lost = 0x80263191, G2 = 0x80263192; + World(sidePack: false, Lost, G2); + var sim = new SlowAce(); + sim.NeverAnswer.Add(Lost); + sim.ClientPendingTimeoutMs = 0; // every move of it leaves the client (the engine's watchdog is not the subject here) + var bot = Open(sim, sidePack: false, Lost, G2); + + bot.TickUntil(() => bot.MovesOf(Lost) > 0, 2000); + bot.TickUntil(() => false, 2000); + var during = Fight(bot, sim, 15_000); + Check.Eq(during.Count, 0, "nothing sent during the fight"); + + Run(bot, () => bot.Completed, 60_000); + + Check.Eq(bot.MovesOf(Lost), 4, "the first send, one resend for the fight, then the 2 tries left"); + Check.True(Logged("sending 0x80263191 again after the fight"), "the fight's resend is logged"); + Check.True(Logged("pickup failed for 0x80263191"), "then it is given up, with a line"); + Check.True(sim.Landed.Any(l => l.Id == G2), "the next item lands"); + Check.False(Abandoned(), "the corpse is not abandoned"); + Check.True(bot.Completed, "the corpse completes"); + }); } diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/PetRefillTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/PetRefillTests.cs index 3e30d9f..735eed0 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/PetRefillTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/PetRefillTests.cs @@ -41,19 +41,41 @@ internal static class PetRefillTests r.Add("pets: the server's 'full' trust expires after 30 min", TrustExpires); r.Add("pets: a landed summon whose pet is not in the cache yet holds a second essence back for the 10 s window", LandedSummonHoldsWindow); r.Add("pets: failed summon (no charge drop) does not assume a pet; waits the 45 s essence cooldown", FailedSummonRespectsCooldown); - r.Add("pets: Boost Nav Priority on (RynthAi only navigates): no summon with a monster near; off: it summons", BoostNavNoSummon); + r.Add("pets: Boost Nav Priority along a route (RynthAi only follows it): no summon with a monster near; route unloaded: it summons", BoostNavNoSummon); + r.Add("pets: Boost Nav Priority with no route: it summons as with the flag off (R-20261103-000159-a65e)", BoostNavNoRouteSummons); } - // Owner's rule (2026-11-02): with Boost Nav Priority on there is no fight, so no pet is called for one. + private static NavRouteParser Route() + { + var route = new NavRouteParser { RouteType = NavRouteType.Circular }; + route.Points.Add(new NavPoint { Type = NavPointType.Point, NS = 10.5, EW = -3.25 }); + route.Points.Add(new NavPoint { Type = NavPointType.Point, NS = 11.5, EW = -4.25 }); + return route; + } + + // Owner's corrected rule (2026-11-02, R-20261103-000159-a65e): while a nav route runs with Boost Nav + // Priority on there is no fight, so no pet is called for one. private static void BoostNavNoSummon() { using var rig = new Rig(charges: 50); rig.S.BoostNavPriority = true; + rig.S.EnableNavigation = true; + rig.S.CurrentRoute = Route(); rig.Run(5000); - Check.Eq(rig.AllSummons, 0, "flag on: no summon in 5 s with the monster 3 m away"); - rig.S.BoostNavPriority = false; + Check.Eq(rig.AllSummons, 0, "a route runs: no summon in 5 s with the monster 3 m away"); + rig.S.CurrentRoute = new NavRouteParser(); // unloaded; the flag stays on rig.Run(1500); - Check.Eq(rig.Summons, 1, "flag off: it summons"); + Check.Eq(rig.Summons, 1, "no route: it summons"); + } + + // "When no nav route is loaded it should fight": the flag alone holds no pet back. + private static void BoostNavNoRouteSummons() + { + using var rig = new Rig(charges: 50); + rig.S.BoostNavPriority = true; + rig.S.EnableNavigation = true; + rig.Run(1500); + Check.Eq(rig.Summons, 1, "flag on, no route: it summons"); } // ── Rig ───────────────────────────────────────────────────────────────