From 3b439a66f1baea749bbe4582e4638d1316cb3488 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Sat, 7 Nov 2026 09:05:08 -0800 Subject: [PATCH] RynthAi: a relog ends "never reached your hand" weapon bans A 'never reached your hand' ban is a guess from a missing answer, unlike the server's own 'skill too low' refusal. Track those bans separately and lift them when the character logs in (or relogs); 'skill too low' bans stay. Co-Authored-By: Claude Opus 5.5 --- .../Combat/CombatManager.cs | 21 +++++++++++++-- .../Tests/WieldBanTests.cs | 26 ++++++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs index ef6853b..2afde97 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs @@ -1336,6 +1336,15 @@ public partial class CombatManager : IDisposable _inHandId = 0; _inHandReadAt = DateTime.MinValue; } + // A login or relog (the same character too): every "never reached your hand" ban ends. Those + // are guesses from a missing answer; the server's own "skill too low" bans stay. + if (_neverReachedBans.Count > 0) + { + foreach (int id in _neverReachedBans) _skillTooLowUntil.Remove(id); + _host.Log($"[EquipDiag] relog: {_neverReachedBans.Count} weapon(s) left out as 'never reached your hand' are back in the weapon choice"); + _neverReachedBans.Clear(); + _planCache = null; + } _playerId = playerId; _monsterMatchEval = new MonsterMatchEvaluator(_worldFilter, playerId); } @@ -5834,6 +5843,10 @@ public partial class CombatManager : IDisposable /// skill raise may let it in later). internal const double SkillTooLowSkipMin = 30; private readonly Dictionary _skillTooLowUntil = new(); + // The entries of _skillTooLowUntil put there because a wield "never reached your hand" (no + // server answer). A relog clears these; a real "skill too low" from the server stays. + private readonly HashSet _neverReachedBans = new(); + internal const string NeverReachedWhy = "it never reached your hand (the client refused the wield)"; /// /// True while sits out a SkillTooLow refusal. Drakkon (2026-10-16) was @@ -5845,14 +5858,18 @@ public partial class CombatManager : IDisposable if (!_skillTooLowUntil.TryGetValue(id, out DateTime until)) return false; if (RynthClock.Now < until) return true; _skillTooLowUntil.Remove(id); + _neverReachedBans.Remove(id); return false; } - private void NoteSkillTooLow(int id, string? why = null) + private void NoteSkillTooLow(int id, string? why = null, bool neverReached = false) { if (id == 0) return; bool first = !_skillTooLowUntil.ContainsKey(id); _skillTooLowUntil[id] = RynthClock.Now.AddMinutes(SkillTooLowSkipMin); + // The server's own "skill too low" outranks a "never reached your hand" on the same weapon. + if (!neverReached) _neverReachedBans.Remove(id); + else if (first) _neverReachedBans.Add(id); _planCache = null; if (first) { @@ -5879,7 +5896,7 @@ public partial class CombatManager : IDisposable // (the client refused it unasked). Out of the choice like a "skill too low" answer, // not retried every 2 minutes with the off hand taken off each time (the Tetsubo, 2026-10-18). if (SwapTracker.GaveUpId is int gaveUp && NeverReachedHand(gaveUp)) - NoteSkillTooLow(gaveUp, "it never reached your hand (the client refused the wield)"); + NoteSkillTooLow(gaveUp, NeverReachedWhy, neverReached: true); } SwapTracker.GaveUpId = null; if (step == WeaponSwapTracker.Step.Hold && (RynthClock.Now - _lastSwapHoldLogAt).TotalSeconds > 10) diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/WieldBanTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/WieldBanTests.cs index 88ca21c..87d1c57 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/WieldBanTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/WieldBanTests.cs @@ -25,6 +25,7 @@ internal static class WieldBanTests { r.Add("wield ban: a weapon seen wielded between combat's looks is not banned, its tries start over", SeenWieldedNotBanned); r.Add("wield ban: no ban while the equipment list shows the weapon at the give-up", ListShowsItAtGiveUp); + r.Add("wield ban: a relog ends 'never reached your hand' bans, not 'skill too low' ones", RelogClearsNeverReached); r.Add("wield ban: a wield that never shows in the list is still banned", NeverShownStillBanned); r.Add("wield ban: one sighting, then three wields never seen: banned (a new run forgets the sighting)", SeenOnceThenNeverBanned); r.Add("wield ban: a weapon in the shield slot is not a main-hand sighting, it still rests", ShieldSlotNotASighting); @@ -39,10 +40,11 @@ internal static class WieldBanTests private readonly MethodInfo _send = typeof(CombatManager).GetMethod("MarkWieldSent", F)!; private readonly MethodInfo _step = typeof(CombatManager).GetMethod("SwapStep", F)!; - public Rig(bool equipped = true) + public Rig(bool equipped = true, bool weenieErrors = false) { FakeHost.Reset(); FakeHost.EquippedCalls = equipped; + FakeHost.WeenieErrorCalls = weenieErrors; FakeHost.Names[Blade] = "Test Blade"; FakeHost.Names[Wand] = "Fire Wand"; FakeHost.Names[Nodachi] = "Nodachi"; @@ -117,6 +119,28 @@ internal static class WieldBanTests finally { EquippedState.Invalidate(); } } + /// SetPlayerId (a login or relog) ends 'never reached' bans only. + private static void RelogClearsNeverReached() + { + var rig = new Rig(weenieErrors: true); + try + { + // The blade: three wields that never show in the list -> 'never reached your hand'. + for (int i = 1; i <= 3; i++) { rig.Send(Blade, Wand); rig.C.OnHeartbeat(); rig.Step(Blade, Wand); } + Check.True(rig.Banned(Blade), "setup: the blade left out as 'never reached your hand'"); + // Nodachi: the server answers 'skill too low'. + rig.Send(Nodachi, Wand); + FakeHost.WeenieError(CombatManager.SkillTooLowErr, 0x00A0, Nodachi); + rig.Step(Nodachi, Wand); + Check.True(rig.Banned(Nodachi), "setup: Nodachi left out as 'skill too low'"); + + rig.C.SetPlayerId(Player); // the same character logs in again + Check.False(rig.Banned(Blade), "relog: the 'never reached your hand' ban is over"); + Check.True(rig.Banned(Nodachi), "relog: the server's 'skill too low' ban stays"); + } + finally { EquippedState.Invalidate(); } + } + /// A wield the client or server truly refuses (never in the list) still bans. private static void NeverShownStillBanned() {