Snapshot for release 2026.10.29.3 (internal f81a090)
This commit is contained in:
parent
6c15f65e94
commit
aa8bf65897
27 changed files with 1821 additions and 61 deletions
|
|
@ -85,6 +85,7 @@ internal static class Program
|
|||
FloodPerfTests.Register(runner);
|
||||
LootSalvageTests.Register(runner);
|
||||
LootCorpseTests.Register(runner);
|
||||
LootRetryTimingTests.Register(runner);
|
||||
ChestLootTests.Register(runner);
|
||||
OwnCorpseTests.Register(runner);
|
||||
UseRefusalTests.Register(runner);
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ internal static class ActionPacingTests
|
|||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("pacing: a use is the server action until its UseDone; a refusal answers it too; a wield answers by wielding", UseAnswers);
|
||||
r.Add("pacing: the player's turn (RynthAi.Yield) holds every start, mode change and move, ends by itself, and lets what is out finish", PlayersTurn);
|
||||
r.Add("pacing: the stall onset replayed - the idle peace swap waits for the corpse use's answer, then goes; no swap to the mode you're in", OnsetModeChangeHeld);
|
||||
r.Add("pacing: moves and turns wait while the server answers; a stop with nothing of ours moving waits too, is never dropped; a real stop and the cast nudge go through", MovesHeld);
|
||||
r.Add("pacing (stop burst, flight 63260): a held stop goes out once the server answers, before the next start", HeldStopSentAfterAnswer);
|
||||
|
|
@ -151,6 +152,65 @@ internal static class ActionPacingTests
|
|||
|
||||
// ── The pacer ───────────────────────────────────────────────────────────────
|
||||
|
||||
private static void PlayersTurn()
|
||||
{
|
||||
PaceOff();
|
||||
var off = World();
|
||||
Check.False(ActionPacer.HoldForPlayer(off, 1500), "pacing off: RynthAi can't hold (it doesn't know what it has in flight)");
|
||||
Check.True(ActionPacer.MayStart(off, "Combat", HealNeed.None, out _), "and nothing is held");
|
||||
|
||||
Paced(() =>
|
||||
{
|
||||
var host = World();
|
||||
Check.True(ActionPacer.MayStart(host, "Buff", HealNeed.None, out _), "free before the ask");
|
||||
Check.True(ActionPacer.HoldForPlayer(host, 1500), "the ask is taken");
|
||||
Check.False(ActionPacer.MayStart(host, "Buff", HealNeed.None, out string why), "a buff cast waits");
|
||||
Check.True(why.Contains("key press"), "and says why: " + why);
|
||||
Check.False(ActionPacer.MayStart(host, "Combat", HealNeed.Emergency, out _), "an emergency heal waits too (the press is the player's choice)");
|
||||
Check.False(ActionPacer.MayStart(host, "Combat", HealNeed.None, out _, animationGate: false, settleGate: false, attackRepeat: true), "an attack repeat waits");
|
||||
Check.True(ActionPacer.GestureHolds(host, "Loot", HealNeed.None, out _), "the item managers' moves wait");
|
||||
FakeHost.CombatModeRequests.Clear();
|
||||
Check.False(host.ChangeCombatModeFor(CombatMode.Magic, "Buff", "wand"), "a stance change is held");
|
||||
Check.Eq(FakeHost.CombatModeRequests.Count, 0, "and not sent");
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("the player's turn: a key press")), 1, "the hold logged once");
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("[Pace] Buff waits: the player's key press goes first")), 1, "each subsystem's wait logged once");
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("[Pace] mode:Buff waits: the player's key press")), 1, "the held stance change its own line");
|
||||
Check.False(ActionPacer.MayStart(host, "Buff", HealNeed.None, out _), "asked again: still held");
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("[Pace] Buff waits: the player's key press")), 1, "not logged again");
|
||||
|
||||
// Renewed: the newest ask sets the end.
|
||||
_t += 1000;
|
||||
Check.True(ActionPacer.HoldForPlayer(host, 1500), "asked again a second later");
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("the player's turn: a key press")), 1, "a renewal is the same hold");
|
||||
_t += 1400;
|
||||
Check.False(ActionPacer.MayStart(host, "Buff", HealNeed.None, out _), "2.4 s in, 1.4 s after the renewal: held");
|
||||
_t += 200;
|
||||
Check.True(ActionPacer.MayStart(host, "Buff", HealNeed.None, out _), "the asker stopped asking: the hold ends by itself");
|
||||
Check.Eq(ActionPacer.PlayerHolds, 1L, "one hold counted");
|
||||
|
||||
// Capped at PlayerHoldMaxMs whatever is asked.
|
||||
Check.True(ActionPacer.HoldForPlayer(host, 60_000), "a long ask");
|
||||
_t += ActionPacer.PlayerHoldMaxMs - 1;
|
||||
Check.False(ActionPacer.MayStart(host, "Buff", HealNeed.None, out _), "held up to the cap");
|
||||
_t += 2;
|
||||
Check.True(ActionPacer.MayStart(host, "Buff", HealNeed.None, out _), "free past it");
|
||||
|
||||
// Released early: free at once, logged.
|
||||
Check.True(ActionPacer.HoldForPlayer(host, 1500), "a third hold");
|
||||
ActionPacer.ReleasePlayerHold(host);
|
||||
Check.True(ActionPacer.MayStart(host, "Buff", HealNeed.None, out _), "released: free at once");
|
||||
Check.True(Logged("the player's turn is over"), "the release logged");
|
||||
int lines = FakeHost.Logs.Count;
|
||||
ActionPacer.ReleasePlayerHold(host);
|
||||
Check.Eq(FakeHost.Logs.Count, lines, "a second release says nothing");
|
||||
|
||||
// What is already out finishes: a hold doesn't touch the outstanding action.
|
||||
Check.True(host.UseFor(Corpse, "Loot", "open the claimed corpse"), "a corpse open goes out");
|
||||
Check.True(ActionPacer.HoldForPlayer(host, 1500), "then the press takes the turn");
|
||||
Check.True(ActionPacer.Current(host) != null, "the corpse open is still RynthAi's outstanding action");
|
||||
});
|
||||
}
|
||||
|
||||
private static void UseAnswers() => Paced(() =>
|
||||
{
|
||||
var host = World();
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ internal static class ActivityInterfaceTests
|
|||
r.Add("activity: each arbiter decision maps to its own bit", ArbiterBits);
|
||||
r.Add("activity: corpse, salvage queue, server wait, crafting and AutoCram add their bits", ExtraBits);
|
||||
r.Add("activity: the table answers only its own name and versions", QueryTable);
|
||||
r.Add("activity: RynthAi's own unanswered action has its own bit (PacedAction), apart from the busy count", PacedBit);
|
||||
r.Add("yield: the RynthAi.Yield table answers only its own name and versions; nothing held before login", YieldTable);
|
||||
}
|
||||
|
||||
private static void ArbiterBits()
|
||||
|
|
@ -70,4 +72,37 @@ internal static class ActivityInterfaceTests
|
|||
ActivityInterface.Release();
|
||||
}
|
||||
}
|
||||
|
||||
private static void PacedBit()
|
||||
{
|
||||
RynthAiActivity f = ActivityInterface.Compose(BotActivity.Buffing, true, false, false, serverWait: true, false, false, pacedWait: true);
|
||||
Check.Eq(f, RynthAiActivity.MacroRunning | RynthAiActivity.Buffing | RynthAiActivity.ServerAction | RynthAiActivity.PacedAction,
|
||||
"a cast of RynthAi's out: waiting on the server, and its own action");
|
||||
f = ActivityInterface.Compose(BotActivity.Idle, false, false, false, serverWait: true, false, false);
|
||||
Check.Eq(f, RynthAiActivity.ServerAction, "only the busy count up (a leftover): no PacedAction");
|
||||
Check.Eq((uint)RynthAiActivity.PacedAction, 1u << 9, "the next free bit, after AutoCram");
|
||||
}
|
||||
|
||||
private static unsafe void YieldTable()
|
||||
{
|
||||
try
|
||||
{
|
||||
Check.True(YieldInterface.Query(RynthAiActivityApiV1.InterfaceName, 1) == IntPtr.Zero, "another interface's name");
|
||||
Check.True(YieldInterface.Query(RynthAiYieldApiV1.InterfaceName, 0) == IntPtr.Zero, "version 0");
|
||||
Check.True(YieldInterface.Query(RynthAiYieldApiV1.InterfaceName, 2) == IntPtr.Zero, "a newer version than RynthAi has");
|
||||
IntPtr p = YieldInterface.Query(RynthAiYieldApiV1.InterfaceName, 1);
|
||||
Check.True(p != IntPtr.Zero, "v1 answers");
|
||||
var t = (RynthAiYieldApiV1*)p;
|
||||
Check.Eq(t->Version, 1u, "table version");
|
||||
Check.Eq(t->StructSize, (uint)sizeof(RynthAiYieldApiV1), "table size");
|
||||
Check.True(t->HoldForPlayer != null && t->ReleaseHold != null, "functions filled in");
|
||||
Check.True(YieldInterface.Query(RynthAiYieldApiV1.InterfaceName, 1) == p, "the same table on every call");
|
||||
Check.Eq(t->HoldForPlayer(1500), 0, "no logged-in plugin: nothing held");
|
||||
Check.Eq(t->ReleaseHold(), 1, "a release with nothing held is fine");
|
||||
}
|
||||
finally
|
||||
{
|
||||
YieldInterface.Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ internal static class BuffTests
|
|||
r.Add("buff timers: tier-8 weapon auras last 90 minutes", TierEightAuras); // was a known failure; fixed by 9a317a8
|
||||
r.Add("buff chat: another player's speech can't record a buff timer", SpeechIsNotACast); // was a known failure; fixed by 0e384d2
|
||||
r.Add("buff school: Armor Tinkering Expertise is a Creature Enchantment spell", ArmorTinkeringSchool); // was a known failure
|
||||
r.Add("mana floor: under Get Mana At with nothing to refill mana, buffs go on while a heal's mana is kept (R-20261029-103248-ce48)", ManaFloorNoRefill);
|
||||
r.Add("buff upgrade: in a force run, the priority buffs go first, then the families cast before the skill rose are recast a level higher", UpgradeInRun);
|
||||
r.Add("buff upgrade: the next pass recasts every buff a level higher once the skill allows it; equal level or a lower skill casts nothing", UpgradeNextPass);
|
||||
r.Add("buff upgrade: a higher level learned from a scroll is cast at once (the spellbook is read again)", UpgradeAfterScroll);
|
||||
|
|
@ -1219,6 +1220,85 @@ internal static class BuffTests
|
|||
Check.True(line.Contains("level 6 -> 7 (Incantation of Strength Self)"), "the line says 6 -> 7, the level counted: " + line);
|
||||
}
|
||||
|
||||
// A report (DreamWeave, 2026-10-29: "Buffing seems to be getting stuck"): logged in at
|
||||
// 209/207 mana, the first buffs took max mana to 536, the same 209 read 39% under Get Mana At
|
||||
// 40%, and with no Stamina to Mana known and no mana potion every buff after waited on regen.
|
||||
private static BuffRig FloorRig(bool knowStaminaToMana, uint mana, uint stamina = 383)
|
||||
{
|
||||
FakeHost.Reset();
|
||||
foreach (var row in SpellTable.Rows)
|
||||
if (knowStaminaToMana || !row.Name.StartsWith("Stamina to Mana", StringComparison.Ordinal))
|
||||
FakeHost.Spellbook.Add((uint)row.Id);
|
||||
FakeHost.Skills[(Player, STypeCreature)] = (300, 2);
|
||||
FakeHost.Skills[(Player, STypeLife)] = (300, 2);
|
||||
FakeHost.Skills[(Player, STypeItem)] = (300, 2);
|
||||
FakeHost.WeaponCalls = true;
|
||||
FakeHost.CombatModeValue = CombatMode.Magic;
|
||||
var rig = new BuffRig();
|
||||
rig.B.SetWorldObjectCache(FakeHost.MakeCache(rig.Host, Player, Array.Empty<uint>()));
|
||||
BuffManager.ManaCostOverride = id => LevelOf(id) * 10;
|
||||
rig.S.IsMacroRunning = true;
|
||||
rig.S.SpellCastIntervalMs = 0;
|
||||
rig.S.GetManaAt = 40; rig.S.TopOffMana = 40;
|
||||
rig.S.HealAt = 0; rig.S.TopOffHP = 0; rig.S.EmergencyHealAt = 0; rig.S.StaminaToHealthAt = 0;
|
||||
rig.S.RestamAt = 0; rig.S.TopOffStam = 0; rig.S.UsePotions = false;
|
||||
rig.V.MaxHealth = 400; rig.V.CurrentHealth = 400;
|
||||
rig.V.MaxStamina = 383; rig.V.CurrentStamina = stamina;
|
||||
rig.V.MaxMana = 536; rig.V.CurrentMana = mana;
|
||||
var at = FakeClock(rig);
|
||||
at(0);
|
||||
rig.B.MarkLiveBuffsReadyForTests();
|
||||
rig.Live(("Strength Self I", 3000));
|
||||
rig.B.ForceFullRebuff();
|
||||
return rig;
|
||||
}
|
||||
|
||||
private static int FloorBeats(BuffRig rig, int n)
|
||||
{
|
||||
int before = FakeHost.Casts.Count;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
rig.B.OnHeartbeat();
|
||||
if (FakeHost.Casts.Count > before)
|
||||
{
|
||||
int id = FakeHost.Casts.Last().SpellId;
|
||||
rig.B.OnChatWindowText($"You cast {NameOf(id)} on {(BuffManager.IsItemEnchantment(NameOf(id)) ? "Rune Robe" : "yourself")}", 7);
|
||||
SetFld(rig.B, "_lastCastAttempt", DateTime.Now.AddSeconds(-10));
|
||||
SetFld(rig.B, "_lastSelfBuffPollAt", DateTime.MinValue);
|
||||
}
|
||||
}
|
||||
return FakeHost.Casts.Count - before;
|
||||
}
|
||||
|
||||
private static void ManaFloorNoRefill()
|
||||
{
|
||||
// The report: 209/536 (39%), Get Mana At 40%, no Stamina to Mana, no potion. Buffs go.
|
||||
var r = FloorRig(knowStaminaToMana: false, mana: 209);
|
||||
int keep = r.B.ManaFloorHealReserve();
|
||||
Check.True(keep > 0, $"a heal's mana is kept ({keep})");
|
||||
int sent = FloorBeats(r, 6);
|
||||
Check.True(sent > 0, $"buffs are cast under the floor (sent {sent}, last skip: {r.B.LastBuffSkipReason})");
|
||||
Check.True(FakeHost.Casts.All(c => !NameOf(c.SpellId).StartsWith("Stamina to Mana", StringComparison.Ordinal)), "no Stamina to Mana (none is known)");
|
||||
Check.True(FakeHost.Logs.Count(l => l.Contains("nothing can refill it") && l.Contains("buffing goes on")) == 1, "logged once");
|
||||
|
||||
// Down near the heal reserve: buffing waits, and the line names every source's reason.
|
||||
var low = FloorRig(knowStaminaToMana: false, mana: (uint)(keep + 10));
|
||||
Check.Eq(FloorBeats(low, 6), 0, "under a heal's mana plus a buff: buffing waits");
|
||||
string line = FakeHost.Logs.LastOrDefault(l => l.Contains("buffing waits: mana")) ?? "";
|
||||
Check.True(line.Contains("Stamina to Mana: no known") && line.Contains("mana potion: Use Potions is off") && line.Contains("for healing"),
|
||||
"the line gives each reason: " + line);
|
||||
|
||||
// Stamina to Mana known, stamina under its line: the floor still refills first, as before
|
||||
// (Revitalize for stamina, then Stamina to Mana); no buff goes while it can refill.
|
||||
var s2m = FloorRig(knowStaminaToMana: true, mana: 209, stamina: 20);
|
||||
FloorBeats(s2m, 6);
|
||||
var sentNames = FakeHost.Casts.Select(c => NameOf(c.SpellId)).ToList();
|
||||
Check.True(sentNames.Count > 0 && sentNames.All(n => n.StartsWith("Revitalize", StringComparison.Ordinal) || n.StartsWith("Stamina to Mana", StringComparison.Ordinal)
|
||||
|| n.Contains("Revitalize") || n.Contains("Stamina to Mana")),
|
||||
"Stamina to Mana known: only refills go, no buff: " + string.Join(", ", sentNames));
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("buffing goes on")), 0, "the no-refill path isn't taken");
|
||||
}
|
||||
|
||||
private static T Fld<T>(BuffManager b, string name) => (T)typeof(BuffManager).GetField(name, BindingFlags.NonPublic | BindingFlags.Instance)!.GetValue(b)!;
|
||||
private static void SetFld(BuffManager b, string name, object v) => typeof(BuffManager).GetField(name, BindingFlags.NonPublic | BindingFlags.Instance)!.SetValue(b, v);
|
||||
|
||||
|
|
|
|||
|
|
@ -757,6 +757,7 @@ internal static class LootCorpseTests
|
|||
FakeHost.CastBusy = 0;
|
||||
TickFor(bot, retryWindowMs / 2);
|
||||
Check.Eq(FakeHost.ExternalMoves.Count(m => m.Id == Gem), 1, "the retry window counts from when the character is still");
|
||||
// (Also past the 4 s answer wait from the send by now: R-20261029-122319-321f.)
|
||||
TickFor(bot, retryWindowMs);
|
||||
Check.Eq(FakeHost.ExternalMoves.Count(m => m.Id == Gem), 2, "then one retry");
|
||||
}
|
||||
|
|
@ -765,6 +766,8 @@ internal static class LootCorpseTests
|
|||
// contents unknown to the client), 3 tries each, and every item on every corpse was skipped.
|
||||
// A pack that takes none of an item's tries now counts as full for a while: the item gets one
|
||||
// more round into another pack, and with none left looting stops with the pack-full message.
|
||||
// 2026-10-29 (R-20261029-122319-321f): only the server's refusals mark a pack full, so the
|
||||
// refusals are given here (unanswered tries: LootRetryTimingTests).
|
||||
private static void RefusingPackIsLeftOut()
|
||||
{
|
||||
var refusals = new RynthCore.Plugin.RynthAi.Loot.PackRefusals();
|
||||
|
|
@ -776,6 +779,7 @@ internal static class LootCorpseTests
|
|||
Check.False(refusals.IsRefused(8, 1), "an item landing there ends the hold");
|
||||
|
||||
BaseWorld(corpsePositioned: true);
|
||||
FakeHost.WeenieErrorCalls = true; // the server's refusals (2026-10-29: only they mark a pack full)
|
||||
var host = FakeHost.Create(Player);
|
||||
var bot = new Bot(host);
|
||||
bot.Cache.OnCreateObject(Corpse);
|
||||
|
|
@ -785,10 +789,25 @@ internal static class LootCorpseTests
|
|||
bot.Cache.Tick();
|
||||
bot.P.OnViewObjectContents(Corpse);
|
||||
|
||||
// The main pack (the only destination here) never takes the gem: it stays on the corpse.
|
||||
int retryWindowMs = bot.S.LootRetryTimeoutMs;
|
||||
TickFor(bot, retryWindowMs * 4 + 600);
|
||||
Check.True(FakeHost.ExternalMoves.Count(m => m.Id == Gem) >= 3, "three tries into the main pack");
|
||||
// The main pack (the only destination here) never takes the gem: it stays on the corpse,
|
||||
// and the server refuses each move once its pickup has run (~0.8 s: "Unable to put X into
|
||||
// container" + InventoryServerSaveFailed with no error code).
|
||||
int seen = 0;
|
||||
var refuseAt = new List<long>();
|
||||
long end = Environment.TickCount64 + 6000;
|
||||
while (Environment.TickCount64 < end && !FakeHost.Logs.Any(l => l.Contains("no pack has a free slot")))
|
||||
{
|
||||
for (; seen < FakeHost.ExternalMoves.Count; seen++)
|
||||
if (FakeHost.ExternalMoves[seen].Id == Gem) refuseAt.Add(Environment.TickCount64 + 800);
|
||||
while (refuseAt.Count > 0 && Environment.TickCount64 >= refuseAt[0])
|
||||
{
|
||||
refuseAt.RemoveAt(0);
|
||||
FakeHost.WeenieError(0, 0x00A0, Gem);
|
||||
}
|
||||
bot.Tick(BotActivity.Looting);
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
Check.Eq(FakeHost.ExternalMoves.Count(m => m.Id == Gem), 3, "three tries into the main pack, each after the last one's refusal");
|
||||
Check.True(FakeHost.ExternalMoves.Where(m => m.Id == Gem).All(m => m.Target == Player), "all into the main pack");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("took none of 3 tries") && l.Contains("trying another pack")), "the refusing pack is left out, said once");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("no pack has a free slot")), "no other pack: the corpse is left");
|
||||
|
|
@ -827,9 +846,10 @@ internal static class LootCorpseTests
|
|||
for (int i = 0; i < 100 && !FakeHost.ExternalMoves.Any(m => m.Id == Gem); i++) { t += 50; bot.Tick(BotActivity.Looting); Thread.Sleep(10); }
|
||||
Check.Eq(FakeHost.ExternalMoves.Count(m => m.Id == Gem), 1, "the pickup goes on the cast's UseDone");
|
||||
|
||||
// The item stays on the corpse (refused); the next cast is unanswered when a retry is due.
|
||||
// The item stays on the corpse (no answer); the next cast is unanswered when a retry is
|
||||
// due (after the answer wait, 2026-10-29: R-20261029-122319-321f).
|
||||
ActionPacer.Begin(host, PacedKind.Cast, 0, "Bloodstone Bolt I", "Combat", FakeHost.UseDoneSeq);
|
||||
TickFor(bot, 1_500);
|
||||
TickFor(bot, (int)RynthAiPlugin.PickupAnswerWaitMinMs + bot.S.LootRetryTimeoutMs + 500);
|
||||
Check.Eq(FakeHost.ExternalMoves.Count(m => m.Id == Gem), 1, "no retry while a cast is unanswered");
|
||||
FakeHost.UseDone(0);
|
||||
TickFor(bot, 300);
|
||||
|
|
|
|||
473
Tools/RynthCore.RynthAiHostTests/Tests/LootRetryTimingTests.cs
Normal file
473
Tools/RynthCore.RynthAiHostTests/Tests/LootRetryTimingTests.cs
Normal file
|
|
@ -0,0 +1,473 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using RynthCore.Loot;
|
||||
using RynthCore.Plugin.RynthAi;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.PluginCore;
|
||||
using RynthCore.PluginSdk;
|
||||
using RynthCore.RynthAiHostTests.Fakes;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// R-20261029-122319-321f (Conquest, RynthAi 2026.10.29.1): "If max loot attempts are reached it
|
||||
// locks up on looting other items". A pack move was retried every ~0.5 s once the character stood
|
||||
// still, and after 3 tries (~1.6 s) the pack counted as full for 5 min. That server answered a
|
||||
// pickup 1.5-2.7 s after the send (one confirmation landed after attempt 3 had gone out), and a
|
||||
// resend while a move is out is dropped by the client (one pending inventory request) or turned
|
||||
// away by ACE as too busy. Side packs were marked full one after another until looting stopped.
|
||||
// Also: a full main pack's refusals (InventoryServerSaveFailed, "error 0x0") were all taken for
|
||||
// "too busy" and resent for free, 6 sends over 18 s.
|
||||
// The server is simulated (SlowAce): a 1.7 s pickup motion, room per pack, refusals for room only
|
||||
// after the motion, "too busy" on arrival, the queued move behind a Return, and the client's own
|
||||
// one-request slot (a move sent while the last is unanswered never leaves the client).
|
||||
// The loot clock (CorpseOpenController.CorpseClock) is moved by hand.
|
||||
internal static class LootRetryTimingTests
|
||||
{
|
||||
private const uint Player = 0x50000D31;
|
||||
private const uint Corpse = 0x80263100;
|
||||
private const uint SidePack = 0x80263001;
|
||||
private const uint ItemTypeContainer = 0x200, ItemTypeGem = 0x800;
|
||||
private const uint LongDescKey = 16, ItemsCapacityKey = 6;
|
||||
private const string Me = "Brannoc Vell";
|
||||
private const BindingFlags Any = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;
|
||||
private const long TickMs = 25;
|
||||
private static (uint Cell, float X, float Y, float Z) Me0 => (0x1048002Au, 100f, 100f, 0f);
|
||||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("loot retry (R-20261029-122319-321f): with 1.7 s answers no move is resent while one is out, no pack is marked full, every item lands", SlowServerNoFalseFull);
|
||||
r.Add("loot retry (R-20261029-122319-321f): a full main pack's refusals after the pickup count as tries (no free resends) and mark it full; the items go to the side pack", FullMainPackRefusals);
|
||||
r.Add("loot retry (R-20261029-122319-321f): unanswered moves are retried only after the answer wait; their pack marks end with the item, the next item starts fresh", UnansweredMovesDontPoison);
|
||||
r.Add("loot retry (R-20261029-122319-321f): an item that lands late, after its pack was given up on, un-marks that pack", LateLandingUnmarks);
|
||||
r.Add("loot retry (R-20261029-122319-321f): a refusal on arrival is 'too busy' (free resend), one after the pickup is the pack's answer", RefusalTiming);
|
||||
r.Add("loot retry (R-20261029-122319-321f): the answer wait grows with the server's measured answers, within 4-8 s", AnswerWaitAdapts);
|
||||
r.Add("loot retry (R-20261029-122319-321f): PackRefusals keeps confirmed marks and drops the unconfirmed ones with the item", PackRefusalMarks);
|
||||
}
|
||||
|
||||
// ── Clock and world ───────────────────────────────────────────────────────
|
||||
|
||||
private static long _now;
|
||||
|
||||
private static void Clocked(Action body)
|
||||
{
|
||||
var old = RynthAiPlugin.CorpseClock;
|
||||
_now = 70_000_000;
|
||||
RynthAiPlugin.CorpseClock = () => _now;
|
||||
try { body(); }
|
||||
finally { RynthAiPlugin.CorpseClock = old; }
|
||||
}
|
||||
|
||||
private static void World(bool sidePack, params uint[] gems)
|
||||
{
|
||||
FakeHost.Reset();
|
||||
FakeHost.SalvageCalls = true; // UseObject + MoveItemExternal
|
||||
FakeHost.WeaponCalls = true; // RequestId, HasAppraisalData
|
||||
FakeHost.CloseContainerCalls = true; // CloseContainer + GetGroundContainerId
|
||||
FakeHost.ServerGates = true; // GetCastBusyState (the pickup motions)
|
||||
FakeHost.WeenieErrorCalls = true; // GetLastWeenieError (the refusals)
|
||||
FakeHost.Names[Player] = Me;
|
||||
FakeHost.Positions[Player] = Me0;
|
||||
FakeHost.PlayerPose = Me0;
|
||||
FakeHost.Names[Corpse] = "Corpse of Brier Wasp";
|
||||
FakeHost.ItemTypes[Corpse] = ItemTypeContainer;
|
||||
FakeHost.Strings[(Corpse, LongDescKey)] = $"Killed by {Me}.";
|
||||
FakeHost.NotAttackable.Add(Corpse);
|
||||
FakeHost.Positions[Corpse] = (Me0.Cell, Me0.X + 1.0f, Me0.Y, Me0.Z);
|
||||
if (sidePack)
|
||||
{
|
||||
FakeHost.Names[SidePack] = "Backpack";
|
||||
FakeHost.ItemTypes[SidePack] = ItemTypeContainer;
|
||||
FakeHost.Ints[(SidePack, ItemsCapacityKey)] = 24;
|
||||
FakeHost.Containers[SidePack] = Player;
|
||||
}
|
||||
foreach (uint g in gems)
|
||||
{
|
||||
FakeHost.Names[g] = $"Gem {g & 0xFF}";
|
||||
FakeHost.ItemTypes[g] = ItemTypeGem;
|
||||
FakeHost.Containers[g] = Corpse;
|
||||
FakeHost.Appraised.Add(g);
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class Bot
|
||||
{
|
||||
public readonly RynthAiPlugin P = new();
|
||||
public readonly LegacyUiSettings S = new()
|
||||
{
|
||||
IsMacroRunning = true, EnableLooting = true, EnableCombat = false, LootOwnership = 0,
|
||||
LootContentSettleMs = 0, LootEmptyCorpseMs = 0, StopLootingWhenPackFull = false,
|
||||
};
|
||||
public readonly WorldObjectCache Cache;
|
||||
public SlowAce? Sim;
|
||||
|
||||
public Bot(RynthCoreHost host)
|
||||
{
|
||||
typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi });
|
||||
var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer));
|
||||
typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, S);
|
||||
Set("_dashboard", dash);
|
||||
Cache = new WorldObjectCache(host);
|
||||
Cache.SetPlayerId(Player);
|
||||
Set("_objectCache", Cache);
|
||||
Set("_playerId", Player);
|
||||
Set("_vitals", new PlayerVitalsCache { MaxHealth = 100, CurrentHealth = 100, MaxStamina = 100, CurrentStamina = 100, MaxMana = 100, CurrentMana = 100 });
|
||||
|
||||
string profile = Path.Combine(Program.TempRoot, "loot-retry-timing.json");
|
||||
var p = new LootProfile { Name = "gems" };
|
||||
var rule = new LootRule { Name = "Gems", Action = LootAction.Keep };
|
||||
rule.Conditions.Add(new ObjectClassCondition { ObjectClass = AcObjectClass.Gem });
|
||||
p.Rules.Add(rule);
|
||||
p.Save(profile);
|
||||
S.CurrentLootPath = profile;
|
||||
}
|
||||
|
||||
public void Set(string f, object? v) => typeof(RynthAiPlugin).GetField(f, Any)!.SetValue(P, v);
|
||||
public T Get<T>(string f) => (T)typeof(RynthAiPlugin).GetField(f, Any)!.GetValue(P)!;
|
||||
public object? Call(string m, params object[] a) => typeof(RynthAiPlugin).GetMethod(m, Any)!.Invoke(P, a);
|
||||
|
||||
/// <summary>One plugin tick: the clock moves on, the simulated server catches up, the looter runs.</summary>
|
||||
public void Tick()
|
||||
{
|
||||
_now += TickMs;
|
||||
Sim?.Step(_now);
|
||||
Set("_activity", BotActivity.Looting);
|
||||
Call("TickCorpseOpening");
|
||||
}
|
||||
|
||||
public void TickUntil(Func<bool> done, long maxMs)
|
||||
{
|
||||
long end = _now + maxMs;
|
||||
while (_now < end && !done()) Tick();
|
||||
}
|
||||
|
||||
public int MovesOf(uint id) => FakeHost.ExternalMoves.Count(m => m.Id == id);
|
||||
|
||||
public RynthCore.Plugin.RynthAi.Loot.PackRefusals Refusals => Get<RynthCore.Plugin.RynthAi.Loot.PackRefusals>("_packRefusals");
|
||||
|
||||
public bool Completed => Get<Dictionary<int, long>>("_completedCorpses").ContainsKey(unchecked((int)Corpse));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ACE's pickup (Player_Inventory.cs): the move arrives, the pickup motion plays (PickupMs), then
|
||||
/// the item goes into the pack or, with no room there, "Unable to put X into container" +
|
||||
/// InventoryServerSaveFailed(item, no error code); then the Return. A move arriving during the
|
||||
/// Return is queued (NextPickup), one during the motion is "You're too busy". The client keeps
|
||||
/// one pending inventory request: a move sent while one is unanswered never leaves the client.
|
||||
/// <see cref="Lag"/>: extra delay before the server takes up an item's first move (a lag spike);
|
||||
/// <see cref="NeverAnswer"/>: items whose moves the server never answers. The engine empties a
|
||||
/// pending request that has had no answer for 10 s (ClientActionGates.PendingTimeoutMs).
|
||||
/// </summary>
|
||||
private sealed class SlowAce
|
||||
{
|
||||
public long Rtt = 200, PickupMs = 1700, ReturnMs = 740;
|
||||
public readonly Dictionary<uint, int> Room = new(); // the server's free slots per pack (absent: plenty)
|
||||
public readonly Dictionary<uint, long> Lag = new();
|
||||
public readonly HashSet<uint> NeverAnswer = new();
|
||||
public long ClientPendingTimeoutMs = 10_000;
|
||||
public int TooBusy, LocalRefused, Queued, RoomRefusals;
|
||||
public readonly List<(uint Id, uint Pack, long At)> Landed = new();
|
||||
|
||||
private enum St { Idle, Pickup, Return }
|
||||
private St _st;
|
||||
private (uint Id, uint Pack) _next;
|
||||
private int _seenMoves;
|
||||
private uint _clientPending;
|
||||
private long _clientPendingAt;
|
||||
private readonly List<(long At, int Seq, Action Act)> _events = new();
|
||||
private int _seq;
|
||||
|
||||
private void At(long at, Action act) => _events.Add((at, _seq++, act));
|
||||
|
||||
public void Step(long now)
|
||||
{
|
||||
while (_seenMoves < FakeHost.ExternalMoves.Count)
|
||||
{
|
||||
var m = FakeHost.ExternalMoves[_seenMoves++];
|
||||
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;
|
||||
_clientPendingAt = now;
|
||||
if (NeverAnswer.Contains(m.Id)) continue;
|
||||
long arrive = now - TickMs + Rtt / 2;
|
||||
if (Lag.Remove(m.Id, out long lag)) arrive += lag;
|
||||
At(arrive, () => Receive(m.Id, m.Target, arrive));
|
||||
}
|
||||
while (true)
|
||||
{
|
||||
var due = _events.Where(e => e.At <= now).OrderBy(e => e.At).ThenBy(e => e.Seq).ToList();
|
||||
if (due.Count == 0) break;
|
||||
var e = due[0];
|
||||
_events.Remove(e);
|
||||
e.Act();
|
||||
}
|
||||
}
|
||||
|
||||
private void Answered(uint id) { if (_clientPending == id) _clientPending = 0; }
|
||||
|
||||
private void Receive(uint id, uint pack, long ts)
|
||||
{
|
||||
if (_st == St.Idle) { StartPickup(id, pack, ts); return; }
|
||||
if (_st == St.Return && _next.Id == 0) { _next = (id, pack); Queued++; return; }
|
||||
TooBusy++;
|
||||
At(ts + Rtt / 2, () =>
|
||||
{
|
||||
FakeHost.WeenieError(0x1D); // YoureTooBusy
|
||||
FakeHost.WeenieError(0, 0x00A0, id); // InventoryServerSaveFailed(item)
|
||||
Answered(id);
|
||||
});
|
||||
}
|
||||
|
||||
private void StartPickup(uint id, uint pack, long ts)
|
||||
{
|
||||
_st = St.Pickup;
|
||||
At(ts + Rtt / 2, () => FakeHost.CastBusy = 1);
|
||||
At(ts + PickupMs, () => Finish(id, pack, ts + PickupMs));
|
||||
}
|
||||
|
||||
private void Finish(uint id, uint pack, long ts)
|
||||
{
|
||||
_st = St.Return;
|
||||
if (Room.TryGetValue(pack, out int free) && free <= 0)
|
||||
{
|
||||
RoomRefusals++;
|
||||
At(ts + Rtt / 2, () =>
|
||||
{
|
||||
FakeHost.WeenieError(0, 0x00A0, id); // "Unable to put X into container" + save failed, no code
|
||||
Answered(id);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Room.ContainsKey(pack)) Room[pack] = free - 1;
|
||||
At(ts + Rtt / 2, () =>
|
||||
{
|
||||
FakeHost.Containers[id] = pack;
|
||||
Landed.Add((id, pack, ts + Rtt / 2));
|
||||
Answered(id);
|
||||
});
|
||||
}
|
||||
At(ts + ReturnMs, () => ReturnDone(ts + ReturnMs));
|
||||
}
|
||||
|
||||
private void ReturnDone(long ts)
|
||||
{
|
||||
if (_next.Id != 0)
|
||||
{
|
||||
var n = _next;
|
||||
_next = default;
|
||||
StartPickup(n.Id, n.Pack, ts);
|
||||
return;
|
||||
}
|
||||
_st = St.Idle;
|
||||
At(ts + Rtt / 2, () => FakeHost.CastBusy = 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Claims and opens the corpse (the server's ViewContents), with the side pack known to the cache.</summary>
|
||||
private static Bot Open(SlowAce sim, bool sidePack, params uint[] gems)
|
||||
{
|
||||
var host = FakeHost.Create(Player);
|
||||
var bot = new Bot(host) { Sim = sim };
|
||||
var ids = new List<uint> { Corpse };
|
||||
if (sidePack) ids.Add(SidePack);
|
||||
ids.AddRange(gems);
|
||||
foreach (uint id in ids) bot.Cache.OnCreateObject(id);
|
||||
for (int i = 0; i < 50; i++) bot.Cache.Tick();
|
||||
if (sidePack)
|
||||
Check.True(bot.Cache.GetDirectInventory(forceRefresh: true).Any(o => o.Id == unchecked((int)SidePack) && o.ObjectClass == AcObjectClass.Container),
|
||||
"the side pack is in the inventory as a container");
|
||||
bot.Tick();
|
||||
Check.True(FakeHost.Uses.Contains(Corpse), "the corpse is opened");
|
||||
FakeHost.UseDone(0);
|
||||
FakeHost.GroundContainer = Corpse;
|
||||
bot.P.OnViewObjectContents(Corpse);
|
||||
return bot;
|
||||
}
|
||||
|
||||
private static bool Logged(string part) => FakeHost.Logs.Any(l => l.Contains(part, StringComparison.Ordinal));
|
||||
|
||||
/// <summary>Ticks until <paramref name="done"/>, noting the clock at each new move.</summary>
|
||||
private static List<(uint Id, long At)> Run(Bot bot, Func<bool> done, long maxMs)
|
||||
{
|
||||
var sends = new List<(uint, long)>();
|
||||
int seen = FakeHost.ExternalMoves.Count;
|
||||
long end = _now + maxMs;
|
||||
while (_now < end && !done())
|
||||
{
|
||||
bot.Tick();
|
||||
while (seen < FakeHost.ExternalMoves.Count) sends.Add((FakeHost.ExternalMoves[seen++].Id, _now));
|
||||
}
|
||||
return sends;
|
||||
}
|
||||
|
||||
// ── 1. A slow server, room everywhere ─────────────────────────────────────
|
||||
|
||||
private static void SlowServerNoFalseFull() => Clocked(() =>
|
||||
{
|
||||
const uint G1 = 0x80263101, G2 = 0x80263102, G3 = 0x80263103, G4 = 0x80263104;
|
||||
World(sidePack: true, G1, G2, G3, G4);
|
||||
var sim = new SlowAce();
|
||||
var bot = Open(sim, sidePack: true, G1, G2, G3, G4);
|
||||
|
||||
Run(bot, () => bot.Completed, 60_000);
|
||||
|
||||
foreach (uint g in new[] { G1, G2, G3, G4 })
|
||||
{
|
||||
Check.Eq(bot.MovesOf(g), 1, $"0x{g:X8} is sent once: its answer (~1.8 s, or behind the last Return) is waited for");
|
||||
Check.True(sim.Landed.Any(l => l.Id == g), $"0x{g:X8} lands");
|
||||
}
|
||||
Check.Eq(sim.LocalRefused, 0, "no move sent while another was unanswered (the client would drop it)");
|
||||
Check.Eq(sim.TooBusy, 0, "no 'too busy' from the server");
|
||||
Check.False(Logged("took none of"), "no pack judged full");
|
||||
Check.False(Logged("pickup failed"), "nothing given up on");
|
||||
Check.False(Logged("retrying use"), "no retries at all");
|
||||
Check.False(bot.Refusals.IsRefused(unchecked((int)Player), _now), "the main pack is not marked");
|
||||
Check.True(bot.Completed, "the corpse is finished");
|
||||
});
|
||||
|
||||
// ── 2. The main pack is full (the client counts room) ─────────────────────
|
||||
|
||||
private static void FullMainPackRefusals() => Clocked(() =>
|
||||
{
|
||||
const uint Map = 0x80263111, G2 = 0x80263112;
|
||||
World(sidePack: true, Map, G2);
|
||||
var sim = new SlowAce();
|
||||
sim.Room[Player] = 0; // the server's main pack is full; the client's count says room
|
||||
var bot = Open(sim, sidePack: true, Map, G2);
|
||||
|
||||
Run(bot, () => bot.Completed, 60_000);
|
||||
|
||||
var mapMoves = FakeHost.ExternalMoves.Where(m => m.Id == Map).ToList();
|
||||
Check.Eq(mapMoves.Count(m => m.Target == Player), 3, "three tries into the main pack (each refused after the pickup ran), no free resends");
|
||||
Check.False(Logged("as too busy"), "a refusal after the pickup is not taken for 'too busy'");
|
||||
Check.True(Logged("the main pack took none of 3 tries") && Logged("the server refused 3 after the pickup ran") && Logged("treating it as full"),
|
||||
"the main pack is judged full on the server's refusals");
|
||||
Check.True(mapMoves.Last().Target == SidePack && sim.Landed.Any(l => l.Id == Map && l.Pack == SidePack), "then the map goes into the side pack and lands");
|
||||
Check.True(FakeHost.ExternalMoves.Where(m => m.Id == G2).All(m => m.Target == SidePack), "the next item goes straight to the side pack");
|
||||
Check.True(sim.Landed.Any(l => l.Id == G2), "and lands");
|
||||
Check.True(bot.Refusals.IsConfirmed(unchecked((int)Player), _now), "the main pack stays marked (confirmed by the server)");
|
||||
Check.False(bot.Refusals.IsRefused(unchecked((int)SidePack), _now), "the side pack is not marked");
|
||||
Check.Eq(sim.LocalRefused, 0, "no move sent while another was unanswered");
|
||||
});
|
||||
|
||||
// ── 3. Moves the server never answers ─────────────────────────────────────
|
||||
|
||||
private static void UnansweredMovesDontPoison() => Clocked(() =>
|
||||
{
|
||||
const uint Lost = 0x80263121, Next = 0x80263122;
|
||||
World(sidePack: true, Lost, Next);
|
||||
var sim = new SlowAce();
|
||||
sim.NeverAnswer.Add(Lost); // the server never answers the lost item's moves
|
||||
var bot = Open(sim, sidePack: true, Lost, Next);
|
||||
var sends = Run(bot, () => bot.Completed, 90_000).Where(s => s.Id == Lost).ToList();
|
||||
|
||||
var lostMoves = FakeHost.ExternalMoves.Where(m => m.Id == Lost).ToList();
|
||||
Check.Eq(lostMoves.Count, 6, "three tries into the main pack, three into the side pack");
|
||||
var gaps = sends.Zip(sends.Skip(1), (a, b) => b.At - a.At).ToList();
|
||||
Check.True(gaps.Count > 0 && gaps.All(g => g >= RynthAiPlugin.PickupAnswerWaitMinMs - TickMs),
|
||||
$"each retry only after the answer wait ({string.Join(", ", gaps)} ms)");
|
||||
Check.True(Logged("trying another pack for this item only"), "the main pack is left out for this item only");
|
||||
Check.False(Logged("treating it as full"), "no pack is judged full on unanswered tries");
|
||||
Check.True(Logged("pickup failed for 0x80263121"), "the item is given up after the second round");
|
||||
Check.False(bot.Refusals.IsRefused(unchecked((int)Player), _now), "the main pack's mark ended with the item");
|
||||
Check.False(bot.Refusals.IsRefused(unchecked((int)SidePack), _now), "so did the side pack's");
|
||||
Check.True(FakeHost.ExternalMoves.Where(m => m.Id == Next).All(m => m.Target == Player), "the next item goes into the main pack again");
|
||||
Check.True(sim.Landed.Any(l => l.Id == Next && l.Pack == Player), "and lands there");
|
||||
Check.False(Logged("pickup failed for 0x80263122"), "the next item is not given up on");
|
||||
Check.False(Logged("no pack has a free slot"), "looting does not stop for want of a pack");
|
||||
});
|
||||
|
||||
// ── 4. A late landing ─────────────────────────────────────────────────────
|
||||
|
||||
private static void LateLandingUnmarks() => Clocked(() =>
|
||||
{
|
||||
const uint Slow = 0x80263131, Next = 0x80263132;
|
||||
World(sidePack: true, Slow, Next);
|
||||
var sim = new SlowAce();
|
||||
sim.Lag[Slow] = 12_500; // a lag spike: the server takes up the first move 12.5 s late
|
||||
var bot = Open(sim, sidePack: true, Slow, Next);
|
||||
|
||||
Run(bot, () => bot.Completed, 90_000);
|
||||
|
||||
Check.True(sim.Landed.Any(l => l.Id == Slow && l.Pack == Player), "the first move lands in the main pack, late");
|
||||
Check.True(Logged("trying another pack for this item only"), "after three unanswered tries the main pack was left out for the item");
|
||||
Check.True(Logged("0x80263131 landed in the main pack; it has room after all and is no longer treated as full"), "the late landing un-marks the main pack");
|
||||
Check.False(bot.Refusals.IsRefused(unchecked((int)Player), _now), "the main pack is not marked");
|
||||
Check.True(sim.Landed.Any(l => l.Id == Next), "the next item lands too");
|
||||
Check.False(Logged("pickup failed for 0x80263132"), "the next item is not given up on");
|
||||
Check.False(Logged("no pack has a free slot"), "looting does not stop");
|
||||
Check.Eq((long)bot.Call("PickupAnswerWaitMs")!, RynthAiPlugin.PickupAnswerWaitMinMs,
|
||||
"the lag spike's late answer (to an earlier, timed-out send) does not stretch the answer wait");
|
||||
});
|
||||
|
||||
// ── 5. Busy or room ───────────────────────────────────────────────────────
|
||||
|
||||
private static void RefusalTiming() => Clocked(() =>
|
||||
{
|
||||
const uint G1 = 0x80263141;
|
||||
World(sidePack: false, G1);
|
||||
var bot = Open(new SlowAce(), sidePack: false, G1);
|
||||
bot.Sim = null; // the answers are given by hand here
|
||||
bot.TickUntil(() => bot.MovesOf(G1) > 0, 2000);
|
||||
Check.Eq(bot.MovesOf(G1), 1, "the move is sent");
|
||||
|
||||
// Refused on arrival (ACE: YoureTooBusy, then InventoryServerSaveFailed with no code; the
|
||||
// engine keeps the last one, error 0x0): a free resend once still.
|
||||
bot.Tick();
|
||||
FakeHost.WeenieError(0x1D);
|
||||
FakeHost.WeenieError(0, 0x00A0, G1);
|
||||
bot.TickUntil(() => bot.MovesOf(G1) > 1, 1000);
|
||||
Check.Eq(bot.MovesOf(G1), 2, "resent at once");
|
||||
Check.True(Logged("the server refused 0x80263141 as too busy"), "logged as too busy");
|
||||
Check.Eq(bot.Get<int>("_currentLootItemMoveAttempts"), 1, "not one of the 3 tries");
|
||||
|
||||
// Refused after its pickup ran (no room; the same error 0x0): one of the tries.
|
||||
FakeHost.CastBusy = 1;
|
||||
bot.TickUntil(() => false, 1800);
|
||||
FakeHost.WeenieError(0, 0x00A0, G1);
|
||||
bot.Tick();
|
||||
FakeHost.CastBusy = 0;
|
||||
bot.TickUntil(() => bot.MovesOf(G1) > 2, 3000);
|
||||
Check.Eq(bot.MovesOf(G1), 3, "sent again after the retry window");
|
||||
Check.Eq(bot.Get<int>("_currentLootItemMoveAttempts"), 2, "counted as a try");
|
||||
Check.True(Logged("retrying use for 0x80263141 attempt 2 (last: refused"), "logged as refused after its pickup ran");
|
||||
Check.Eq(bot.Get<int>("_currentLootItemDestRefusals"), 1, "and it counts against the main pack (the busy one does not)");
|
||||
});
|
||||
|
||||
// ── 6. The wait itself ────────────────────────────────────────────────────
|
||||
|
||||
private static void AnswerWaitAdapts() => Clocked(() =>
|
||||
{
|
||||
World(sidePack: false);
|
||||
var bot = new Bot(FakeHost.Create(Player));
|
||||
long Wait() => (long)bot.Call("PickupAnswerWaitMs")!;
|
||||
Check.Eq(Wait(), RynthAiPlugin.PickupAnswerWaitMinMs, "4 s with nothing measured");
|
||||
foreach (long ms in new long[] { 1500, 1657, 2735 }) bot.Call("NotePickupAnswerLatency", ms);
|
||||
Check.Eq(Wait(), 2735 + RynthAiPlugin.PickupAnswerWaitMarginMs, "the slowest answer (2.7 s, Conquest's queued pickups) plus 1.5 s");
|
||||
bot.Call("NotePickupAnswerLatency", 20_000L);
|
||||
Check.Eq(Wait(), RynthAiPlugin.PickupAnswerWaitMaxMs, "at most 8 s");
|
||||
for (int i = 0; i < 8; i++) bot.Call("NotePickupAnswerLatency", 800L);
|
||||
Check.Eq(Wait(), RynthAiPlugin.PickupAnswerWaitMinMs, "the last 8 answers only, never under 4 s");
|
||||
});
|
||||
|
||||
private static void PackRefusalMarks()
|
||||
{
|
||||
var r = new RynthCore.Plugin.RynthAi.Loot.PackRefusals();
|
||||
r.Refuse(1, 0, confirmed: true);
|
||||
r.Refuse(2, 0, confirmed: false);
|
||||
Check.True(r.IsRefused(1, 10) && r.IsConfirmed(1, 10), "a confirmed mark");
|
||||
Check.True(r.IsRefused(2, 10) && !r.IsConfirmed(2, 10), "an unconfirmed mark is left out too");
|
||||
r.Refuse(1, 5, confirmed: false);
|
||||
Check.True(r.IsConfirmed(1, 10), "a confirmed mark is not weakened by an unconfirmed one");
|
||||
r.ClearUnconfirmed();
|
||||
Check.True(r.IsRefused(1, 10), "the confirmed mark stays");
|
||||
Check.False(r.IsRefused(2, 10), "the unconfirmed one goes with its item");
|
||||
r.Accepted(1);
|
||||
Check.False(r.IsRefused(1, 10), "an item landing there ends a confirmed mark");
|
||||
}
|
||||
}
|
||||
|
|
@ -54,6 +54,9 @@ internal static class SelfTestMetaTests
|
|||
var cache = FakeHost.MakeCache(host, Player, new[] { buffBot }, new Dictionary<uint, float> { [buffBot] = 1f });
|
||||
var r = new Run(host, cache, "T2 Fight");
|
||||
r.M.SetCombatTargetCount(() => targets);
|
||||
// What the Default state sets before the run reaches the fight. It came from an earlier test's
|
||||
// pvars file, which reached the disk only when its real-time save throttle allowed (a flake).
|
||||
r.M.Expressions.Evaluate("setpvar[rt_fight,`PENDING`]");
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ internal static class WeaponTests
|
|||
r.Add("slayer: read through the host (int 166, float 138, monster int 2), cached by wcid", SlayerFromHost);
|
||||
r.Add("refusal: a refused stance change in combat's equip pass sets no backoff and starts no stuck clock", StanceRefusedKeepsBackoff);
|
||||
r.Add("weapon choice: an unlisted wand is never picked (Damage tab, learned, pack, name)", UnlistedNeverPicked);
|
||||
r.Add("cast element: with the plan's wand not in hand (a held swap), the wand in hand casts its own element (R-20261029-125901-e22d)", HeldWandCastsItsElement);
|
||||
r.Add("weapon choice: the Monsters rule's weapon is used (R-20261022-193411-fb72), below this monster's Damage tab pick; the Default row's like the Damage tab default", MonsterRuleWeapon);
|
||||
r.Add("Items list: a listed item no longer carried is reported missing (pack, hand, unknown)", MissingFromPack);
|
||||
r.Add("weapon choice: a listed weapon someone else now has (sold) is skipped, even as this monster's Damage tab pick", SoldWeaponSkipped);
|
||||
|
|
@ -888,6 +889,36 @@ internal static class WeaponTests
|
|||
/// Lightning wand; the rule says the fire wand. Each step uses a new rule object, so PlanFor's
|
||||
/// cache (keyed on the rule by reference) doesn't hand back the previous answer.
|
||||
/// </summary>
|
||||
// Conquest, 2026-10-29: "not swapping 0x80181B46 'Frost Sceptre' for 0x8024231C 'Acid Staff' yet
|
||||
// (target at 23% health)", then Incantation of Acid Blast cast through the Frost Sceptre.
|
||||
private static void HeldWandCastsItsElement()
|
||||
{
|
||||
var rig = new Rig(1535, "Ethereal Wisp");
|
||||
rig.S.ItemRules.Add(new() { Id = unchecked((int)FireWand), Name = "Fire Wand", Element = "Fire", ElementSource = "icon" });
|
||||
var rule = new MonsterRule { Name = "Ethereal" }; // damage type Auto
|
||||
var pref = typeof(CombatManager).GetMethod("GetPreferredElement", BindingFlags.Instance | BindingFlags.NonPublic)!;
|
||||
string Elem() => (string)pref.Invoke(rig.C, new object?[] { rig.Target, rule })!;
|
||||
|
||||
var plan = rig.C.PlanFor(rig.Target, rule);
|
||||
Check.Eq(unchecked((uint)plan.WeaponId), ListedWand, "the plan: the Lightning wand (the weakness)");
|
||||
|
||||
rig.C.InHandOverride = () => unchecked((int)ListedWand);
|
||||
Check.Eq(Elem(), "Lightning", "the plan's wand in hand: its element");
|
||||
|
||||
rig.C.InHandOverride = () => unchecked((int)FireWand); // the swap was held: the fire wand stays
|
||||
Check.Eq(Elem(), "Fire", "the fire wand in hand casts Fire, not the plan's Lightning");
|
||||
Check.True(FakeHost.Logs.Count(l => l.Contains("isn't in hand: casting Fire")) == 1, "logged once");
|
||||
Elem();
|
||||
Check.True(FakeHost.Logs.Count(l => l.Contains("isn't in hand: casting Fire")) == 1, "still once");
|
||||
|
||||
rig.C.CanCastOverride = e => e != "Nether" && e != "Fire"; // a wand whose element can't be cast
|
||||
Check.Eq(Elem(), "Lightning", "an element the character can't cast: the plan's element");
|
||||
|
||||
rig.C.InHandOverride = () => 0; // nothing readable in hand
|
||||
rig.C.CanCastOverride = e => e != "Nether";
|
||||
Check.Eq(Elem(), "Lightning", "nothing in hand: the plan's element");
|
||||
}
|
||||
|
||||
private static void MonsterRuleWeapon()
|
||||
{
|
||||
var rig = new Rig(1535, "Ethereal Wisp");
|
||||
|
|
|
|||
Loading…
Reference in a new issue