Snapshot for release 2026.10.11.1 (internal d20160b)
This commit is contained in:
parent
e6fffb0f42
commit
504a6f080a
66 changed files with 7865 additions and 310 deletions
|
|
@ -63,6 +63,7 @@ internal static class Program
|
|||
LootCorpseTests.Register(runner);
|
||||
OwnCorpseTests.Register(runner);
|
||||
UseRefusalTests.Register(runner);
|
||||
CorpseKillerTests.Register(runner);
|
||||
VitalsTests.Register(runner);
|
||||
MultiTargetTests.Register(runner);
|
||||
CastSafetyTests.Register(runner);
|
||||
|
|
@ -73,6 +74,7 @@ internal static class Program
|
|||
UseAtLoginTests.Register(runner);
|
||||
LearnSpellsTests.Register(runner);
|
||||
AttackLatencyTests.Register(runner);
|
||||
TargetingTests.Register(runner);
|
||||
LootAddItemTests.Register(runner);
|
||||
GiveTests.Register(runner);
|
||||
DungeonMapBakeTests.Register(runner);
|
||||
|
|
@ -87,6 +89,7 @@ internal static class Program
|
|||
ManaStoneChoiceTests.Register(runner);
|
||||
CustomDebuffTests.Register(runner);
|
||||
ProfileLoadTests.Register(runner);
|
||||
ActivityInterfaceTests.Register(runner);
|
||||
return runner.Run("RynthAi host tests", args.Length > 0 ? args[0] : null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,73 @@
|
|||
using System;
|
||||
using RynthCore.Plugin.RynthAi;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// "RynthAi.Activity" v1 (2026-10-11): the read-only bits RynthSort reads so its pack moves stay
|
||||
// out of RynthAi's way. The mapping from RynthAi's state is ActivityInterface.Compose; the table
|
||||
// comes from ActivityInterface.Query (what the engine's GetPluginInterface hands other plugins).
|
||||
internal static class ActivityInterfaceTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
private static void ArbiterBits()
|
||||
{
|
||||
Check.Eq(ActivityInterface.Compose(BotActivity.Idle, false, false, false, false, false, false), RynthAiActivity.None, "idle, macro off");
|
||||
Check.Eq(ActivityInterface.Compose(BotActivity.Idle, true, false, false, false, false, false), RynthAiActivity.MacroRunning, "idle, macro on");
|
||||
Check.Eq(ActivityInterface.Compose(BotActivity.Buffing, true, false, false, false, false, false),
|
||||
RynthAiActivity.MacroRunning | RynthAiActivity.Buffing, "buffing");
|
||||
Check.Eq(ActivityInterface.Compose(BotActivity.Combat, true, false, false, false, false, false),
|
||||
RynthAiActivity.MacroRunning | RynthAiActivity.Combat, "combat");
|
||||
Check.Eq(ActivityInterface.Compose(BotActivity.Looting, true, false, false, false, false, false),
|
||||
RynthAiActivity.MacroRunning | RynthAiActivity.Looting, "looting");
|
||||
Check.Eq(ActivityInterface.Compose(BotActivity.Salvaging, true, false, false, false, false, false),
|
||||
RynthAiActivity.MacroRunning | RynthAiActivity.Salvaging, "salvaging");
|
||||
Check.Eq(ActivityInterface.Compose(BotActivity.Navigating, true, false, false, false, false, false),
|
||||
RynthAiActivity.MacroRunning | RynthAiActivity.Navigating, "navigating");
|
||||
}
|
||||
|
||||
private static void ExtraBits()
|
||||
{
|
||||
// A corpse RynthAi opened or claimed counts as looting whatever the tick's owner is.
|
||||
RynthAiActivity f = ActivityInterface.Compose(BotActivity.Navigating, true, corpseInHand: true, false, false, false, false);
|
||||
Check.True((f & RynthAiActivity.Looting) != 0 && (f & RynthAiActivity.Navigating) != 0, "corpse in hand while navigating -> looting too");
|
||||
f = ActivityInterface.Compose(BotActivity.Combat, true, false, salvageBusy: true, false, false, false);
|
||||
Check.True((f & RynthAiActivity.Salvaging) != 0, "salvage queue while fighting -> salvaging");
|
||||
f = ActivityInterface.Compose(BotActivity.Idle, false, false, false, serverWait: true, false, false);
|
||||
Check.Eq(f, RynthAiActivity.ServerAction, "a player's command waiting on the server, macro off");
|
||||
f = ActivityInterface.Compose(BotActivity.Idle, true, false, false, false, crafting: true, autoCram: true);
|
||||
Check.Eq(f, RynthAiActivity.MacroRunning | RynthAiActivity.Crafting | RynthAiActivity.AutoCram, "crafting + AutoCram");
|
||||
}
|
||||
|
||||
private static unsafe void QueryTable()
|
||||
{
|
||||
try
|
||||
{
|
||||
Check.True(ActivityInterface.Query("RynthAi.Status", 1) == IntPtr.Zero, "another interface's name");
|
||||
Check.True(ActivityInterface.Query(RynthAiActivityApiV1.InterfaceName, 0) == IntPtr.Zero, "version 0");
|
||||
Check.True(ActivityInterface.Query(RynthAiActivityApiV1.InterfaceName, 2) == IntPtr.Zero, "a newer version than RynthAi has");
|
||||
IntPtr p = ActivityInterface.Query(RynthAiActivityApiV1.InterfaceName, 1);
|
||||
Check.True(p != IntPtr.Zero, "v1 answers");
|
||||
var t = (RynthAiActivityApiV1*)p;
|
||||
Check.Eq(t->Version, 1u, "table version");
|
||||
Check.Eq(t->StructSize, (uint)sizeof(RynthAiActivityApiV1), "table size");
|
||||
Check.True(t->GetActivityFlags != null, "function filled in");
|
||||
Check.True(ActivityInterface.Query(RynthAiActivityApiV1.InterfaceName, 1) == p, "the same table on every call");
|
||||
// No plugin instance (not logged in): not ready, flags cleared.
|
||||
uint flags = 0xFFFFFFFF;
|
||||
Check.Eq(t->GetActivityFlags(&flags), 0, "not ready without a logged-in plugin");
|
||||
Check.Eq(flags, 0u, "flags cleared when not ready");
|
||||
}
|
||||
finally
|
||||
{
|
||||
ActivityInterface.Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
54
Tools/RynthCore.RynthAiHostTests/Tests/CorpseKillerTests.cs
Normal file
54
Tools/RynthCore.RynthAiHostTests/Tests/CorpseKillerTests.cs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
using RynthCore.Plugin.RynthAi;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// 2026-10-06: Silentkelpie skipped its own kills unopened (Necrolytic Extract left behind). The
|
||||
// corpse LongDesc had gained "Corpse will decay in 56s" under the "Killed by" line and the killer
|
||||
// read as "Silentkelpie.\nCorpse will decay in 56s", which never matches the character name.
|
||||
internal static class CorpseKillerTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("corpse killer: plain 'Killed by X.'", Plain);
|
||||
r.Add("corpse killer: decay line after the killer is ignored", DecayLineIgnored);
|
||||
r.Add("corpse killer: CRLF and multi-word names", CrLfMultiWord);
|
||||
r.Add("corpse killer: no 'Killed by' line reads as unknown", Missing);
|
||||
r.Add("corpse killer: radar column reads the same name", RadarMatches);
|
||||
}
|
||||
|
||||
private static void Plain()
|
||||
{
|
||||
Check.Eq(RynthAiPlugin.ExtractCorpseKillerName("Killed by Silentkelpie."), "Silentkelpie", "plain line");
|
||||
Check.Eq(RynthAiPlugin.ExtractCorpseKillerName("Killed by Silentkelpie"), "Silentkelpie", "no trailing period");
|
||||
}
|
||||
|
||||
private static void DecayLineIgnored()
|
||||
{
|
||||
Check.Eq(RynthAiPlugin.ExtractCorpseKillerName("Killed by Silentkelpie.\nCorpse will decay in 56s"),
|
||||
"Silentkelpie", "LF decay line");
|
||||
Check.Eq(RynthAiPlugin.ExtractCorpseKillerName("Killed by Silentkelpie.\n\nCorpse will decay in 4m 12s."),
|
||||
"Silentkelpie", "blank line then decay line");
|
||||
}
|
||||
|
||||
private static void CrLfMultiWord()
|
||||
{
|
||||
Check.Eq(RynthAiPlugin.ExtractCorpseKillerName("Killed by Moreck II.\r\nCorpse will decay in 3m 10s"),
|
||||
"Moreck II", "CRLF and a roman-numeral suffix");
|
||||
}
|
||||
|
||||
private static void Missing()
|
||||
{
|
||||
Check.Null(RynthAiPlugin.ExtractCorpseKillerName(""), "empty LongDesc");
|
||||
Check.Null(RynthAiPlugin.ExtractCorpseKillerName(null), "null LongDesc");
|
||||
Check.Null(RynthAiPlugin.ExtractCorpseKillerName("Corpse will decay in 56s"), "decay line only");
|
||||
Check.Null(RynthAiPlugin.ExtractCorpseKillerName("Killed by .\nCorpse will decay in 56s"), "empty killer");
|
||||
}
|
||||
|
||||
private static void RadarMatches()
|
||||
{
|
||||
Check.Eq(RynthRadarUi.ExtractKiller("Killed by Silentkelpie.\nCorpse will decay in 56s"), "Silentkelpie", "radar decay line");
|
||||
Check.Eq(RynthRadarUi.ExtractKiller(null), "", "radar unknown is empty");
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ internal static class HazardEscapeTests
|
|||
r.Add("hazard: the hotspot damage line is read (amount, source); other lines are not", Parse);
|
||||
r.Add("hazard: a hit stops everything and walks back along the footsteps, then hands back", EscapeAlongFootsteps);
|
||||
r.Add("hazard: hurt again where it stopped - it goes further back", FurtherBack);
|
||||
r.Add("hazard: macro off - the cell is still learned, nothing moves", MacroOff);
|
||||
r.Add("hazard: macro off - nothing moves, nothing learned", MacroOff);
|
||||
r.Add("hazard: Escape Acid and Lava off - no escape and nothing learned (some walk through acid)", SettingOff);
|
||||
}
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ internal static class HazardEscapeTests
|
|||
|
||||
b.Hit();
|
||||
Check.True(b.P.HazardEscaping, "the hit starts the escape");
|
||||
Check.True(b.Cache.IsHazardCell(CellB), "the cell it was hurt in is a hazard now");
|
||||
Check.False(b.Cache.IsHazardCell(CellB), "the cell it was hurt in is not a patrol hazard (patrol as before 10-07)");
|
||||
Check.True(b.Hold(), "the escape owns the tick (nothing else runs)");
|
||||
Check.True(FakeHost.AutoRun, "running");
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ internal static class HazardEscapeTests
|
|||
b.S.IsMacroRunning = false;
|
||||
for (int i = 0; i <= 6; i++) b.At(CellA, 60f, -185f + i);
|
||||
b.Hit();
|
||||
Check.True(b.Cache.IsHazardCell(CellA), "the cell is learned");
|
||||
Check.False(b.Cache.IsHazardCell(CellA), "the cell is not learned");
|
||||
Check.False(b.P.HazardEscaping, "but nothing moves the character while you play it");
|
||||
Check.False(b.Hold(), "and the tick is not held");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ internal static class LootSalvageTests
|
|||
r.Add("salvage: an item queued before it reaches the pack waits, then is salvaged", SalvageWaitsForArrival);
|
||||
r.Add("salvage: a pickup whose confirm was lost is still salvaged (tracked + sweep)", SalvageLostConfirm);
|
||||
r.Add("salvage: no UST keeps the items until one is in the pack", SalvageNoUstKeepsItems);
|
||||
r.Add("salvage: no UST - HasUst false, no combine sweep; a UST in the pack turns both on", SalvageNoUstNoSweep);
|
||||
r.Add("salvage: skipped items are logged with their reason, once per batch", SalvageSkipReasonsLogged);
|
||||
r.Add("salvage: an item that keeps failing rests, retries, and is given up with a log line", SalvageGiveUpIsBounded);
|
||||
}
|
||||
|
|
@ -287,6 +288,24 @@ internal static class LootSalvageTests
|
|||
Check.True(items.All(id => !w.InWorld(id)), "every item salvaged");
|
||||
}
|
||||
|
||||
private static void SalvageNoUstNoSweep()
|
||||
{
|
||||
var w = new World(Items(0), withUst: false);
|
||||
w.Settings.EnableCombineSalvage = true;
|
||||
Check.False(w.Mgr.HasUst(), "no UST carried");
|
||||
w.Run(65_000, step: 500);
|
||||
Check.False(w.SalvageLogs.Any(l => l.Contains("Combine sweep", StringComparison.Ordinal)), "no combine sweep without a UST");
|
||||
Check.Eq(FakeHost.Uses.Count, 0, "nothing used");
|
||||
|
||||
var ids = new List<uint>();
|
||||
World.AddUst(ids);
|
||||
_ = w.Cache[unchecked((int)Ust)];
|
||||
w.Run(4_000, step: 500);
|
||||
Check.True(w.Mgr.HasUst(), "a UST in the pack is seen (within the 3 s cache)");
|
||||
w.Run(31_000, step: 500);
|
||||
Check.True(w.SalvageLogs.Any(l => l.Contains("Combine sweep", StringComparison.Ordinal)), "the combine sweep runs again");
|
||||
}
|
||||
|
||||
private static void SalvageSkipReasonsLogged()
|
||||
{
|
||||
uint good = ItemBase + 1, retained = ItemBase + 2, listed = ItemBase + 3;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RynthCore.Loot;
|
||||
using RynthCore.Plugin.RynthAi;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
|
|
@ -14,6 +17,149 @@ internal static class ManaStoneChoiceTests
|
|||
{
|
||||
r.Add("mana stones: only ordinary stones and charges are used; special stones only when a rule names them", OrdinaryOnly);
|
||||
r.Add("mana stones: with tapping off, charged stones and Mana Charges still refill worn gear", RefillWithoutTapping);
|
||||
r.Add("mana stones: a stone the server called charged refills worn gear though its charge can't be read", KnownChargedRefills);
|
||||
r.Add("mana stones: a stone just drained refills worn gear though its read still says empty", DrainedStoneRefills);
|
||||
r.Add("mana stones: a stone that gave its mana is not used again; 'fully charged' holds refills", GaveManaNotReused);
|
||||
r.Add("mana stones: tapping off, a stone whose charge can't be read is identified, then used", UnreadableStoneIdentified);
|
||||
}
|
||||
|
||||
// ── Refill rig (2026-10-11) ───────────────────────────────────────────
|
||||
// A stone's charge is read from its last appraisal; the server never sends a change to it.
|
||||
// 2026-10-10: five charged stones whose charge couldn't be read were tried as empty stones
|
||||
// ("The Ring is already full of mana."), marked known-charged, and then never used on a worn
|
||||
// Khanda-handled Mace at 0% for over an hour. 2026-10-08: a stone that had just given its mana
|
||||
// still read charged and was used again, cancelled by the server, timed out and parked.
|
||||
|
||||
private const uint Player = 0x50000E01;
|
||||
private const uint StoneA = 0x80400001, StoneB = 0x80400002, StoneC = 0x80400003;
|
||||
private const uint Mace = 0x80400010, Ring = 0x80400020;
|
||||
private const uint CurManaKey = 107, MaxManaKey = 108, WieldedSlotKey = 10;
|
||||
|
||||
private sealed class Rig : IDisposable
|
||||
{
|
||||
public long Now = 1_000_000;
|
||||
public readonly LegacyUiSettings S;
|
||||
public readonly ManaStoneManager M;
|
||||
|
||||
/// <param name="stones">Stone id and its charge read (null = can't be read).</param>
|
||||
public Rig(bool tapping, (uint Id, int? Mana)[] stones, bool ringToDrain = false)
|
||||
{
|
||||
FakeHost.Reset();
|
||||
FakeHost.UseOnCalls = true;
|
||||
FakeHost.WeaponCalls = true; // RequestId, HasAppraisalData
|
||||
FakeHost.Names[Player] = "Stone Tester";
|
||||
foreach (var (id, mana) in stones)
|
||||
{
|
||||
FakeHost.Names[id] = "Moderate Mana Stone";
|
||||
FakeHost.Containers[id] = Player;
|
||||
SetMana(id, mana);
|
||||
}
|
||||
FakeHost.Names[Mace] = "Khanda-handled Mace";
|
||||
FakeHost.Wielders[Mace] = Player;
|
||||
FakeHost.Ints[(Mace, WieldedSlotKey)] = 0x100000;
|
||||
FakeHost.Ints[(Mace, MaxManaKey)] = 5000;
|
||||
FakeHost.Ints[(Mace, CurManaKey)] = 0; // and it keeps reading 0: worn-item mana is an appraisal too
|
||||
var ids = new List<uint>();
|
||||
foreach (var st in stones) ids.Add(st.Id);
|
||||
ids.Add(Mace);
|
||||
if (ringToDrain)
|
||||
{
|
||||
FakeHost.Names[Ring] = "Ring";
|
||||
FakeHost.Containers[Ring] = Player;
|
||||
FakeHost.Ints[(Ring, MaxManaKey)] = 4000;
|
||||
FakeHost.Ints[(Ring, CurManaKey)] = 4000;
|
||||
ids.Add(Ring);
|
||||
}
|
||||
|
||||
var host = FakeHost.Create(Player);
|
||||
var cache = FakeHost.MakeCache(host, Player, ids);
|
||||
S = new LegacyUiSettings { EnableManaTapping = tapping, ManaTapMinMana = 100 };
|
||||
S.IsMacroRunning = true;
|
||||
ManaStoneManager.Clock = () => Now;
|
||||
M = new ManaStoneManager(host, S, cache);
|
||||
if (ringToDrain) M.MarkLootedForTap(unchecked((int)Ring));
|
||||
}
|
||||
|
||||
public static void SetMana(uint id, int? mana)
|
||||
{
|
||||
if (mana == null) FakeHost.Ints.Remove((id, CurManaKey));
|
||||
else FakeHost.Ints[(id, CurManaKey)] = mana.Value;
|
||||
}
|
||||
|
||||
public void Run(long ms)
|
||||
{
|
||||
for (long t = 0; t < ms; t += 100)
|
||||
{
|
||||
Now += 100;
|
||||
M.OnHeartbeat(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void Chat(string line) => M.OnChatWindowText(line);
|
||||
|
||||
public List<uint> OnPlayer => FakeHost.UsesOn.Where(u => u.Target == Player).Select(u => u.Source).ToList();
|
||||
public List<uint> OnRing => FakeHost.UsesOn.Where(u => u.Target == Ring).Select(u => u.Source).ToList();
|
||||
|
||||
public void Dispose() => ManaStoneManager.Clock = static () => Environment.TickCount64;
|
||||
}
|
||||
|
||||
private static void KnownChargedRefills()
|
||||
{
|
||||
using var rig = new Rig(tapping: true, new (uint, int?)[] { (StoneA, null), (StoneB, null) }, ringToDrain: true);
|
||||
rig.Run(1000);
|
||||
Check.Eq(rig.OnRing.Count, 1, "an unreadable stone is tried as the empty stone for the looted ring");
|
||||
rig.Chat("The Ring is already full of mana.");
|
||||
rig.Run(1000);
|
||||
Check.Eq(rig.OnRing.Count, 2, "the next unreadable stone is tried");
|
||||
Check.True(rig.OnRing[0] != rig.OnRing[1], "a different stone");
|
||||
rig.Chat("The Ring is already full of mana.");
|
||||
rig.Run(1000);
|
||||
Check.Eq(rig.OnRing.Count, 2, "no stone left to drain into");
|
||||
Check.Eq(rig.OnPlayer.Count, 1, "a stone the server called charged refills the 0% mace");
|
||||
}
|
||||
|
||||
private static void DrainedStoneRefills()
|
||||
{
|
||||
using var rig = new Rig(tapping: true, new (uint, int?)[] { (StoneA, null) }, ringToDrain: true);
|
||||
rig.Run(1000);
|
||||
Check.Eq(rig.OnRing.Count, 1, "the empty stone drains the looted ring");
|
||||
rig.Chat("The Mana Stone drains 3,600 points of mana from the Ring.\nThe Ring is destroyed.");
|
||||
rig.Run(1000);
|
||||
Check.Eq(rig.OnPlayer.Count, 1, "the stone it just charged refills the 0% mace");
|
||||
Check.Eq(rig.OnPlayer.FirstOrDefault(), StoneA, "that stone");
|
||||
}
|
||||
|
||||
private static void GaveManaNotReused()
|
||||
{
|
||||
using var rig = new Rig(tapping: false, new (uint, int?)[] { (StoneA, 3000), (StoneB, 2000), (StoneC, 1000) });
|
||||
rig.Run(1000);
|
||||
Check.Eq(rig.OnPlayer.Count, 1, "the fullest stone refills the mace");
|
||||
Check.Eq(rig.OnPlayer[0], StoneA, "stone A (3000)");
|
||||
rig.Chat("The Mana Stone gives 3,000 points of mana to the following items: Khanda-handled Mace.\nYou need 2,000 more mana to fully charge your items.");
|
||||
rig.Run(1000);
|
||||
Check.Eq(rig.OnPlayer.Count, 2, "the gear still needs mana: the next stone");
|
||||
Check.Eq(rig.OnPlayer[1], StoneB, "stone B, not A again (A's read still says 3000)");
|
||||
rig.Chat("The Mana Stone gives 2,000 points of mana to the following items: Khanda-handled Mace.\nYour items are fully charged.");
|
||||
rig.Run(60_000);
|
||||
Check.Eq(rig.OnPlayer.Count, 2, "fully charged: no stone for a while though the mace still reads 0%");
|
||||
rig.Run(70_000);
|
||||
Check.Eq(rig.OnPlayer.Count, 3, "after the hold the stale read is tried once more");
|
||||
Check.Eq(rig.OnPlayer[2], StoneC, "with stone C");
|
||||
rig.Chat("You have no items equipped that need mana.");
|
||||
rig.Run(60_000);
|
||||
Check.Eq(rig.OnPlayer.Count, 3, "the server says nothing needs mana: held again, C kept");
|
||||
}
|
||||
|
||||
private static void UnreadableStoneIdentified()
|
||||
{
|
||||
using var rig = new Rig(tapping: false, new (uint, int?)[] { (StoneA, null) });
|
||||
rig.Run(1000);
|
||||
Check.True(FakeHost.IdRequests.Contains(StoneA), "the stone whose charge can't be read is identified");
|
||||
Check.Eq(rig.OnPlayer.Count, 0, "not used before its charge is known");
|
||||
Rig.SetMana(StoneA, 3000); // the appraisal lands
|
||||
rig.Run(6000);
|
||||
Check.Eq(rig.OnPlayer.Count, 1, "then it refills the mace");
|
||||
Check.Eq(FakeHost.IdRequests.Count(i => i == StoneA), 1, "identified once");
|
||||
}
|
||||
|
||||
private static void OrdinaryOnly()
|
||||
|
|
|
|||
|
|
@ -26,6 +26,33 @@ namespace RynthCore.RynthAiHostTests.Tests;
|
|||
// inside corner gets a corner.
|
||||
internal static class PatrolDoorwayTests
|
||||
{
|
||||
// 2026-10-10, 0x6146: hazards cut the loops and the patrol fell back to every dead end. Now,
|
||||
// in that case, only short spurs (closets) go: a junction J with a 1-cell closet, a 3-cell
|
||||
// spur and a 5-cell branch hanging off a loop.
|
||||
private static void TrimShortSpurs()
|
||||
{
|
||||
var g = new Dictionary<uint, DungeonNavNode>();
|
||||
void Link(uint a, uint b)
|
||||
{
|
||||
foreach (uint c in new[] { a, b })
|
||||
if (!g.ContainsKey(c)) g[c] = new DungeonNavNode { CellId = c, NS = (c & 0xFF) * 0.01, EW = (c >> 8 & 0xFF) * 0.01 };
|
||||
g[a].Neighbors.Add(b); g[b].Neighbors.Add(a);
|
||||
}
|
||||
// Loop 1-2-3-4, J = 1.
|
||||
Link(0x01, 0x02); Link(0x02, 0x03); Link(0x03, 0x04); Link(0x04, 0x01);
|
||||
Link(0x01, 0x10); // closet
|
||||
Link(0x01, 0x20); Link(0x20, 0x21); Link(0x21, 0x22); // 3-cell spur
|
||||
Link(0x02, 0x30); Link(0x30, 0x31); Link(0x31, 0x32); Link(0x32, 0x33); Link(0x33, 0x34); // 5-cell branch
|
||||
var all = new HashSet<uint>(g.Keys);
|
||||
var kept = DungeonPathfinder.TrimShortSpurs(g, all, 0x03, DungeonPathfinder.PatrolMaxSpurCells);
|
||||
Check.False(kept.Contains(0x10), "the 1-cell closet goes");
|
||||
Check.False(kept.Overlaps(new uint[] { 0x20, 0x21, 0x22 }), "the 3-cell spur goes");
|
||||
Check.True(kept.IsSupersetOf(new uint[] { 0x30, 0x31, 0x32, 0x33, 0x34 }), "the 5-cell branch stays whole");
|
||||
Check.True(kept.IsSupersetOf(new uint[] { 1, 2, 3, 4 }), "the loop stays");
|
||||
var keepStart = DungeonPathfinder.TrimShortSpurs(g, all, 0x10, DungeonPathfinder.PatrolMaxSpurCells);
|
||||
Check.True(keepStart.Contains(0x10), "the start cell is never trimmed");
|
||||
}
|
||||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("dungeon doorways: an opening's centre, facing and width come from its portal polygons", DoorwayFromPortals);
|
||||
|
|
@ -38,6 +65,7 @@ internal static class PatrolDoorwayTests
|
|||
r.Add("dungeon patrol: a loop through a big room: no points inside it, every doorway taken", PatrolLoop);
|
||||
r.Add("dungeon patrol: a big dead-end room is looked into, not skirted", PatrolLooksIntoDeadEndRoom);
|
||||
r.Add("dungeon floors: a ceiling (facing down) is not a floor", CeilingIsNotFloor);
|
||||
r.Add("dungeon patrol: spurs of up to 3 cells trimmed, a long branch kept whole", TrimShortSpurs);
|
||||
r.Add("dungeon clearance: walls, floor edges and slopes too steep to stand on bound it; a face high above doesn't", ClearanceMeasure);
|
||||
r.Add("dungeon clearance: a point next to a wall (or past the floor's edge) is pushed out to 1 m", PushedOffWall);
|
||||
r.Add("dungeon clearance: a point in a corridor narrower than 2 m ends on its middle line", NarrowCorridorCentred);
|
||||
|
|
|
|||
286
Tools/RynthCore.RynthAiHostTests/Tests/TargetingTests.cs
Normal file
286
Tools/RynthCore.RynthAiHostTests/Tests/TargetingTests.cs
Normal file
|
|
@ -0,0 +1,286 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using RynthCore.Plugin.RynthAi;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.RynthAiHostTests.Fakes;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// Combat target selection (2026-10-10): the Targeting setting (lowest health, closest, farthest,
|
||||
// least turning) and Target Lock. Combat used to switch targets mid-fight on a blended score; now
|
||||
// a locked target is kept until it dies or goes, leaves Monster Range, or a higher-priority
|
||||
// monster is in range, and with the lock off a switch needs a clear margin under the rule.
|
||||
internal static class TargetingTests
|
||||
{
|
||||
private const uint Player = 0x50000E01;
|
||||
private const uint Lb = 0xA9B40000;
|
||||
private const uint A = 0x80000401, B = 0x80000402, C = 0x80000403, Boss = 0x80000404;
|
||||
|
||||
private const int LowestHealth = 0, Closest = 1, Farthest = 2, LeastTurning = 3;
|
||||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("targeting: each scheme picks its monster", SchemesPick);
|
||||
r.Add("targeting: unknown health counts as full; ties go to the closest, then the lower id", UnknownHealthAndTies);
|
||||
r.Add("targeting: Target Lock keeps the target when a better one of its tier appears", LockKeeps);
|
||||
r.Add("targeting: Target Lock lets go when the target goes (after the scan grace)", LockReleasesWhenGone);
|
||||
r.Add("targeting: Target Lock lets go when the target leaves Monster Range", LockReleasesOutOfRange);
|
||||
r.Add("targeting: a higher-priority monster in range takes over, lock or not", HigherPriorityWins);
|
||||
r.Add("targeting: lock off switches only past each scheme's margin", LockOffMargins);
|
||||
r.Add("targeting: lock off never switches with an attack at the target in flight", NoSwitchInFlight);
|
||||
r.Add("targeting: settings default to lowest health with the lock on", Defaults);
|
||||
}
|
||||
|
||||
// ── Schemes ───────────────────────────────────────────────────────────────
|
||||
|
||||
private static void SchemesPick()
|
||||
{
|
||||
// A: close, facing away, lightly wounded. B: mid, nearly ahead, badly wounded.
|
||||
// C: far, health unknown.
|
||||
var health = new Dictionary<uint, float> { [A] = 0.8f, [B] = 0.3f };
|
||||
(uint, double, double)[] scan = { (A, 2, 90), (B, 4, 10), (C, 6, 50) };
|
||||
|
||||
Check.Eq(new Rig(LowestHealth, true, health).Pick(scan), B, "lowest health: B at 30%");
|
||||
Check.Eq(new Rig(Closest, true, health).Pick(scan), A, "closest: A at 2 m");
|
||||
Check.Eq(new Rig(Farthest, true, health).Pick(scan), C, "farthest: C at 6 m");
|
||||
Check.Eq(new Rig(LeastTurning, true, health).Pick(scan), B, "least turning: B, 10 degrees off");
|
||||
|
||||
var t = new Rig(LeastTurning, true, health);
|
||||
t.Pick((A, 2, 90), (B, 4, 60), (C, 6, 5));
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("[CombatTarget] lock 0x80000403") && l.Contains("least turning: turn 5 deg")),
|
||||
"the lock line names the scheme and the deciding value");
|
||||
}
|
||||
|
||||
private static void UnknownHealthAndTies()
|
||||
{
|
||||
// B is at 95%, A unknown: unknown counts as full, so B is the more wounded.
|
||||
var t = new Rig(LowestHealth, true, new Dictionary<uint, float> { [B] = 0.95f });
|
||||
Check.Eq(t.Pick((A, 2, 0), (B, 5, 0)), B, "a known 95% beats an unknown (full) health");
|
||||
|
||||
// Every health unknown: all tie at full, so the closest.
|
||||
t = new Rig(LowestHealth, true);
|
||||
Check.Eq(t.Pick((A, 3, 0), (B, 1.5, 0), (C, 2, 0)), B, "all unknown: the closest");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("lowest health: health unknown (as full)")), "logged as unknown");
|
||||
|
||||
// Same distance: the lower id.
|
||||
t = new Rig(Closest, true);
|
||||
Check.Eq(t.Pick((B, 2, 0), (A, 2, 0)), A, "a tie in distance: the lower id");
|
||||
|
||||
// Lock off: an unknown-health monster never looks more wounded than the incumbent.
|
||||
t = new Rig(LowestHealth, false, new Dictionary<uint, float> { [A] = 0.5f });
|
||||
Check.Eq(t.Pick((A, 3, 0), (B, 1, 0)), A, "A at 50% is picked over an unknown B");
|
||||
Check.Eq(t.Pick((A, 3, 0), (B, 1, 0), (C, 1, 0)), A, "unknown B and C don't take over");
|
||||
}
|
||||
|
||||
// ── Target Lock ───────────────────────────────────────────────────────────
|
||||
|
||||
private static void LockKeeps()
|
||||
{
|
||||
var t = new Rig(Closest, true);
|
||||
Check.Eq(t.Pick((A, 4, 0)), A, "A, alone, is locked");
|
||||
int before = FakeHost.Logs.Count(l => l.Contains("[CombatTarget]"));
|
||||
Check.Eq(t.Pick((A, 4, 0), (B, 1, 0)), A, "B walks up to 1 m: the lock keeps A");
|
||||
Check.Eq(t.Pick((A, 4.5, 30), (B, 0.5, 0), (C, 0.8, 0)), A, "and keeps it with more around");
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("[CombatTarget]")), before, "nothing new is logged while the lock holds");
|
||||
|
||||
t = new Rig(LowestHealth, true, new Dictionary<uint, float> { [A] = 0.7f, [B] = 0.9f });
|
||||
Check.Eq(t.Pick((A, 3, 0), (B, 2, 0)), A, "lowest health: A at 70%");
|
||||
t.Health(B, 0.1f);
|
||||
Check.Eq(t.Pick((A, 3, 0), (B, 2, 0)), A, "B drops to 10%: the lock keeps A");
|
||||
}
|
||||
|
||||
private static void LockReleasesWhenGone()
|
||||
{
|
||||
var t = new Rig(Closest, true);
|
||||
Check.Eq(t.Pick((A, 2, 0), (B, 3, 0)), A, "A is locked");
|
||||
Check.Eq(t.Pick((B, 3, 0)), A, "A blinks out of the scan: kept within the scan grace");
|
||||
t.Advance(1000);
|
||||
Check.Eq(t.Pick((B, 3, 0)), A, "still within the 1.5 s grace");
|
||||
t.Advance(1000);
|
||||
Check.Eq(t.Pick((B, 3, 0)), B, "gone past the grace: B");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("[CombatTarget] switch 0x80000401") && l.Contains("(gone,")),
|
||||
"the switch says why: gone");
|
||||
|
||||
// A kill drops the target outright (DropTarget), and the next pick is fresh.
|
||||
t = new Rig(Closest, true);
|
||||
t.Pick((A, 2, 0), (B, 3, 0));
|
||||
t.Combat.OnKillNotification("Mob A's perforated corpse falls before you!");
|
||||
Check.Eq(t.Combat.activeTargetId, 0, "the kill drops A");
|
||||
Check.Eq(t.Pick((B, 3, 0)), B, "and B is locked");
|
||||
}
|
||||
|
||||
private static void LockReleasesOutOfRange()
|
||||
{
|
||||
var t = new Rig(Closest, true, monsterRange: 5);
|
||||
Check.Eq(t.Pick((A, 4, 0), (B, 4.5, 0)), A, "A is locked at 4 m");
|
||||
Check.Eq(t.Pick((A, 5.5, 0)), A, "A steps past Monster Range, nothing else in range: kept");
|
||||
Check.Eq(t.Pick((A, 6.5, 0), (B, 4.8, 0)), B, "past Monster Range with B inside it: B");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("[CombatTarget] switch 0x80000401") && l.Contains("out of Monster Range, 6.5 m")),
|
||||
"the switch says why: out of Monster Range");
|
||||
Check.Eq(t.Pick((A, 3, 0), (B, 4.8, 0)), B, "A coming back closer doesn't take it back (B is locked now)");
|
||||
}
|
||||
|
||||
private static void HigherPriorityWins()
|
||||
{
|
||||
foreach (bool lockOn in new[] { true, false })
|
||||
{
|
||||
string mode = lockOn ? "lock on" : "lock off";
|
||||
var t = new Rig(Closest, lockOn, monsterRange: 10);
|
||||
t.S.MonsterRules.Add(new MonsterRule { Name = "Boss", Priority = 2 });
|
||||
Check.Eq(t.Pick((A, 2, 0), (B, 3, 0)), A, $"{mode}: A is locked");
|
||||
Check.Eq(t.Pick((A, 2, 0), (B, 3, 0), (Boss, 12, 0)), A, $"{mode}: a Boss outside Monster Range doesn't count");
|
||||
Check.Eq(t.Pick((A, 2, 0), (B, 3, 0), (Boss, 9, 0)), Boss, $"{mode}: the Boss inside Monster Range takes over at once, farther or not");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("[CombatTarget] switch 0x80000401") && l.Contains("priority 1 < 2")),
|
||||
$"{mode}: the switch says why: priority");
|
||||
Check.Eq(t.Pick((A, 1, 0), (Boss, 9, 0)), Boss, $"{mode}: the Boss is kept over a closer, lower-priority A");
|
||||
}
|
||||
}
|
||||
|
||||
// ── Lock off ──────────────────────────────────────────────────────────────
|
||||
|
||||
private static void LockOffMargins()
|
||||
{
|
||||
// Closest: 1.5 m.
|
||||
var t = new Rig(Closest, false);
|
||||
Check.Eq(t.Pick((A, 3, 0)), A, "closest: A at 3 m");
|
||||
Check.Eq(t.Pick((A, 3, 0), (B, 2, 0)), A, "B 1 m closer: kept");
|
||||
Check.Eq(t.Pick((A, 3, 0), (B, 1.2, 0)), B, "B 1.8 m closer: switch");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("[CombatTarget] switch 0x80000401") && l.Contains("closest: 3.0 m, another is clearly better")
|
||||
&& l.Contains("-> 0x80000402") && l.Contains("closest: 1.2 m")),
|
||||
"the switch names the scheme and both values");
|
||||
|
||||
// Farthest: 1.5 m.
|
||||
t = new Rig(Farthest, false, monsterRange: 10);
|
||||
Check.Eq(t.Pick((A, 8, 0)), A, "farthest: A at 8 m");
|
||||
Check.Eq(t.Pick((A, 8, 0), (B, 9, 0)), A, "B 1 m farther: kept");
|
||||
Check.Eq(t.Pick((A, 8, 0), (B, 9.8, 0)), B, "B 1.8 m farther: switch");
|
||||
|
||||
// Lowest health: 5 percentage points.
|
||||
t = new Rig(LowestHealth, false, new Dictionary<uint, float> { [A] = 0.5f, [B] = 0.9f });
|
||||
Check.Eq(t.Pick((A, 3, 0), (B, 2, 0)), A, "lowest health: A at 50%");
|
||||
t.Health(B, 0.47f);
|
||||
Check.Eq(t.Pick((A, 3, 0), (B, 2, 0)), A, "B at 47% (3 points lower): kept");
|
||||
t.Health(B, 0.40f);
|
||||
Check.Eq(t.Pick((A, 3, 0), (B, 2, 0)), B, "B at 40% (10 points lower): switch");
|
||||
|
||||
// Least turning: 20 degrees.
|
||||
t = new Rig(LeastTurning, false);
|
||||
Check.Eq(t.Pick((A, 3, 30)), A, "least turning: A");
|
||||
Check.Eq(t.Pick((A, 3, 40), (B, 3, 25)), A, "B needs 15 degrees less: kept");
|
||||
Check.Eq(t.Pick((A, 3, 40), (B, 3, 15)), B, "B needs 25 degrees less: switch");
|
||||
}
|
||||
|
||||
private static void NoSwitchInFlight()
|
||||
{
|
||||
// An attack at A with no damage since: held for the flight window.
|
||||
var t = new Rig(Closest, false);
|
||||
Check.Eq(t.Pick((A, 3, 0)), A, "A is locked");
|
||||
t.Combat.RecordOffensiveCast(unchecked((int)A));
|
||||
Check.Eq(t.Pick((A, 3, 0), (B, 0.5, 0)), A, "a cast at A in flight: B (2.5 m closer) waits");
|
||||
t.Advance(2000);
|
||||
Check.Eq(t.Pick((A, 3, 0), (B, 0.5, 0)), A, "still in the 4 s window");
|
||||
t.Advance(2500);
|
||||
Check.Eq(t.Pick((A, 3, 0), (B, 0.5, 0)), B, "the window passed with nothing landed: switch");
|
||||
|
||||
// Damage landing ends the hold.
|
||||
t = new Rig(Closest, false);
|
||||
t.Pick((A, 3, 0));
|
||||
t.Combat.RecordOffensiveCast(unchecked((int)A));
|
||||
Check.Eq(t.Pick((A, 3, 0), (B, 0.5, 0)), A, "cast in flight: kept");
|
||||
t.Combat.ReportDamageOnTarget(unchecked((int)A));
|
||||
Check.Eq(t.Pick((A, 3, 0), (B, 0.5, 0)), B, "the cast landed: switch");
|
||||
|
||||
// A target that never takes damage can't hold it forever under continuous fire.
|
||||
t = new Rig(Closest, false);
|
||||
t.Pick((A, 3, 0));
|
||||
t.Advance(16000);
|
||||
t.Combat.RecordOffensiveCast(unchecked((int)A));
|
||||
Check.Eq(t.Pick((A, 3, 0), (B, 0.5, 0)), B, "16 s locked without damage: a fresh cast doesn't hold it");
|
||||
}
|
||||
|
||||
private static void Defaults()
|
||||
{
|
||||
var s = new LegacyUiSettings();
|
||||
Check.Eq(s.TargetSelection, 0, "Targeting: lowest health");
|
||||
Check.True(s.TargetLock, "Target Lock: on");
|
||||
var loaded = System.Text.Json.JsonSerializer.Deserialize("{\"MonsterRange\":7}", RynthAiJsonContext.Default.LegacyUiSettings);
|
||||
Check.True(loaded != null && loaded.TargetLock, "a profile saved before the setting loads the lock as on");
|
||||
|
||||
// Profile switch/load copies them (CopySettings is the hand-written field list).
|
||||
var copy = typeof(LegacyDashboardRenderer).GetMethod("CopySettings", BindingFlags.NonPublic | BindingFlags.Static)!;
|
||||
var dst = new LegacyUiSettings();
|
||||
copy.Invoke(null, new object[] { new LegacyUiSettings { TargetSelection = 3, TargetLock = false }, dst });
|
||||
Check.Eq(dst.TargetSelection, 3, "a profile's Targeting is copied");
|
||||
Check.False(dst.TargetLock, "and its lock off");
|
||||
copy.Invoke(null, new object[] { loaded!, dst });
|
||||
Check.True(dst.TargetLock && dst.TargetSelection == 0, "an old profile loads the defaults");
|
||||
|
||||
// Engine Settings face: the payload carries them; an engine without the fields leaves them alone.
|
||||
s = new LegacyUiSettings { TargetSelection = 2, TargetLock = false };
|
||||
var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer));
|
||||
typeof(LegacyDashboardRenderer).GetField("_settings", BindingFlags.NonPublic | BindingFlags.Instance)!.SetValue(dash, s);
|
||||
typeof(LegacyDashboardRenderer).GetField("_advancedSettingsUi", BindingFlags.NonPublic | BindingFlags.Instance)!
|
||||
.SetValue(dash, new LegacyAdvancedSettingsUi(s)); // BuildSettingsJson reads its crafting state
|
||||
var sent = System.Text.Json.JsonSerializer.Deserialize(dash.BuildSettingsJson(), RynthAiJsonContext.Default.SettingsBridgePayload);
|
||||
Check.True(sent != null && sent.TargetSelection == 2 && sent.TargetLock == false, "sent to the engine face");
|
||||
dash.ApplySettingsJson("{\"PatrolOnLogin\":false}");
|
||||
Check.True(s.TargetSelection == 2 && !s.TargetLock, "a save without the fields leaves them alone");
|
||||
dash.ApplySettingsJson("{\"TargetSelection\":1,\"TargetLock\":true}");
|
||||
Check.True(s.TargetSelection == 1 && s.TargetLock, "a save with them sets them");
|
||||
dash.ApplySettingsJson("{\"TargetSelection\":9}");
|
||||
Check.Eq(s.TargetSelection, 3, "an out-of-range choice is clamped");
|
||||
}
|
||||
|
||||
// ── Rig ───────────────────────────────────────────────────────────────────
|
||||
|
||||
private sealed class Rig
|
||||
{
|
||||
public readonly CombatManager Combat;
|
||||
public readonly LegacyUiSettings S;
|
||||
private readonly WorldObjectCache _cache;
|
||||
private DateTime _now = DateTime.Now;
|
||||
|
||||
public Rig(int scheme, bool targetLock, Dictionary<uint, float>? health = null, int monsterRange = 20)
|
||||
{
|
||||
FakeHost.Reset();
|
||||
Place(Player, "Me", 96, 96, creature: false);
|
||||
FakeHost.PlayerPose = (Lb | 0x1C, 96f, 96f, 0f);
|
||||
Place(A, "Mob A", 96, 98);
|
||||
Place(B, "Mob B", 96, 99);
|
||||
Place(C, "Mob C", 96, 100);
|
||||
Place(Boss, "Boss", 96, 101);
|
||||
S = new LegacyUiSettings { MonsterRange = monsterRange, TargetSelection = scheme, TargetLock = targetLock };
|
||||
var host = FakeHost.Create();
|
||||
_cache = FakeHost.MakeCache(host, Player, new[] { A, B, C, Boss }, health);
|
||||
Combat = new CombatManager(host, S, _cache);
|
||||
Combat.SetPlayerId(Player);
|
||||
Combat.SetDamageStores(null, new RynthCore.Plugin.RynthAi.CreatureData.MonsterDamageStore());
|
||||
Combat.TargetClock = () => _now;
|
||||
}
|
||||
|
||||
public void Health(uint id, float ratio) => _cache.OnUpdateHealth(id, ratio);
|
||||
public void Advance(double ms) => _now = _now.AddMilliseconds(ms);
|
||||
|
||||
/// <summary>One tick: the scan holds these (id, distance m, facing angle deg); returns the target.</summary>
|
||||
public uint Pick(params (uint Id, double Dist, double Angle)[] scan)
|
||||
{
|
||||
Combat.SetScannedTargetsForTests(scan.Select(t => new CombatManager.ScannedTarget
|
||||
{
|
||||
Id = unchecked((int)t.Id), Distance = t.Dist, Angle = t.Angle, Bearing = double.NaN, Name = FakeHost.Names[t.Id],
|
||||
}));
|
||||
Combat.HandleCombatTrigger();
|
||||
return unchecked((uint)Combat.activeTargetId);
|
||||
}
|
||||
}
|
||||
|
||||
private static void Place(uint id, string name, float x, float y, bool creature = true)
|
||||
{
|
||||
FakeHost.Names[id] = name;
|
||||
FakeHost.Positions[id] = (Lb | 0x1C, x, y, 0f);
|
||||
if (creature) FakeHost.ItemTypes[id] = 0x10;
|
||||
}
|
||||
}
|
||||
|
|
@ -24,6 +24,7 @@ internal static class VitalsTests
|
|||
r.Add("vitals: profiles without the Stamina to Health keys load today's 30 / 20", StaminaToHealthDefaults);
|
||||
r.Add("vitals: Re-stam To keeps a started recharge going to its line; off = one recharge as before", RestamTo);
|
||||
r.Add("vitals: out of Magic stance a listed stamina potion goes before Revitalize; a caster casts first", StaminaPotionFirst);
|
||||
r.Add("vitals: a listed potion whose stack ran out is drunk from the next stack of that name", ListedPotionNextStack);
|
||||
r.Add("vitals: after a kit, nothing else heals until the kit's result line lands", KitResultWait);
|
||||
r.Add("vitals: Heal Self known only above the tier Life Magic allows (vitae) is still cast", HealAboveAllowedTier);
|
||||
r.Add("vitals: low health wins the arbiter even on a busy tick; backs off when nothing can heal", HealthWinsArbiter);
|
||||
|
|
@ -290,6 +291,36 @@ internal static class VitalsTests
|
|||
}
|
||||
}
|
||||
|
||||
// Report 2026-10-10: 200+ Stamina Tinctures, and RynthAi stopped drinking them whenever the stack
|
||||
// the rule was added from ran out, until the player added the next stack by hand.
|
||||
private static void ListedPotionNextStack()
|
||||
{
|
||||
const uint Listed = 0x80001234, NextStack = 0x80005678;
|
||||
FakeHost.Reset();
|
||||
FakeHost.WeaponCalls = true;
|
||||
FakeHost.CombatModeValue = CombatMode.Melee;
|
||||
foreach (var row in SpellTable.Rows) FakeHost.Spellbook.Add((uint)row.Id);
|
||||
FakeHost.Skills[(Player, STypeLife)] = (400, 2);
|
||||
FakeHost.Names[NextStack] = "Stamina Tincture"; // the listed stack (Listed) is gone
|
||||
var host = FakeHost.Create();
|
||||
var s = new LegacyUiSettings { IsMacroRunning = true, HealAt = 0, TopOffHP = 0, EmergencyHealAt = 0, StaminaToHealthAt = 0,
|
||||
GetManaAt = 0, TopOffMana = 0, RestamAt = 30, TopOffStam = 95, UsePotions = true, EnableBuffing = false };
|
||||
s.ConsumableRules.Add(new ConsumableRule { Id = unchecked((int)Listed), Name = "Stamina Tincture", Type = "Stamina" });
|
||||
var skills = new CharacterSkills(host);
|
||||
skills.SetPlayerId(Player);
|
||||
var sm = new SpellManager(host, s);
|
||||
sm.InitializeNatively();
|
||||
sm.SetCharacterSkills(skills);
|
||||
var vitals = new PlayerVitalsCache { MaxHealth = 100, CurrentHealth = 100, MaxStamina = 100, CurrentStamina = 20, MaxMana = 100, CurrentMana = 100 };
|
||||
var b = new BuffManager(host, s, sm, vitals);
|
||||
b.SetCharacterSkills(skills);
|
||||
b.SetWorldObjectCache(FakeHost.MakeCache(host, Player, new[] { NextStack }));
|
||||
Check.True(b.CheckVitals(), "stamina 20% acts");
|
||||
Check.True(FakeHost.Uses.Contains(NextStack), "the next stack of Stamina Tinctures is drunk");
|
||||
Check.False(FakeHost.Uses.Contains(Listed), "not the stack that ran out");
|
||||
Check.Eq(FakeHost.Casts.Count, 0, "no Revitalize while a tincture is carried");
|
||||
}
|
||||
|
||||
// Tom, 2026-10-06: one Revitalize often doesn't recover enough stamina.
|
||||
private static void RestamTo()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue