RynthSuite as of 2026-11-15 (internal edf82e9): release 2026.11.15.1

This commit is contained in:
Tom Bohar 2026-11-15 10:51:38 -05:00
commit 047117cbb0
11 changed files with 419 additions and 23 deletions

View file

@ -447,6 +447,25 @@ internal static class Program
Eq(AutoVendorPlanner.MostCarriedUnit(new Dictionary<int, long> { [25_000] = 50, [30_000] = 50 }), 30_000, "tie: the higher value");
Eq(AutoVendorPlanner.MostCarriedUnit(new Dictionary<int, long>()), 0, "nothing: 0 (no override)");
// 2026-11-12 (DreamWeave, Pyreal Peas): the last full stack (100) split 21 off with 44 free slots. The
// 79 left keep 100 peas' Value (63,291 a pea) and outvote the 21 (50,000): read at that price the 21
// didn't fit, were merged back, and the split came again until the 8-try stop. The split-off stack
// is fresh from the server, so its unit wins.
var staleVotes = new Dictionary<int, long> { [5_000_000 / 79] = 79, [50_000] = 21 };
Eq(AutoVendorPlanner.MostCarriedUnit(staleVotes), 5_000_000 / 79, "the vote alone picks the stale price");
Eq(AutoVendorPlanner.TrueUnit(staleVotes, 50_000), 50_000, "a split-off stack's fresh unit wins");
Eq(AutoVendorPlanner.TrueUnit(staleVotes, 0), 5_000_000 / 79, "no fresh unit: the vote");
var lastFull = AutoVendorPlanner.PlanNext(v, none, new List<SellItem> { PyPea(1, 100) }, Pack(0, free: 44));
Eq(lastFull.Kind, PlanKind.Split, "44 free: split...");
Eq(lastFull.SplitAmount, 21, "...21 off");
SellItem StalePea(uint id, int stack) => new() { Id = id, Name = "Pyreal Pea", Value = 5_000_000 / 79 * stack, StackSize = stack,
Class = AcObjectClass.Misc, ItemType = 0x40000000, RuleName = "S: Peas", MaxStack = 100, Wcid = 9003 };
var staleRead = AutoVendorPlanner.PlanNext(v, none, new List<SellItem> { StalePea(1, 79), StalePea(2, 21) }, Pack(0, free: 43));
Eq(staleRead.Kind, PlanKind.Merge, "at the stale price the 21 is merged back (the loop)");
var freshRead = AutoVendorPlanner.PlanNext(v, none, new List<SellItem> { PyPea(1, 79), PyPea(2, 21) }, Pack(0, free: 43));
Eq(freshRead.Kind, PlanKind.Sell, "at the fresh price the 21 is sold");
Eq(freshRead.Sells.Single().Id, 2u, "the split-off 21");
var unknownMax = AutoVendorPlanner.PlanNext(v, none, new List<SellItem> { S(1, "Gem", 100_000, stack: 100), S(2, "Gem", 50_000, stack: 50) }, Pack(0, free: 3));
Eq(unknownMax.Kind, PlanKind.Split, "unknown max stack: the old plain split");

View file

@ -34,6 +34,8 @@ internal static class FightSelectedTests
r.Add("fight selected: a /ra targetlock lock is never moved; /ra targetlock on the selected one makes it explicit", TargetLockInteraction);
r.Add("fight selected: the setting off releases it; /ra fightselected, the settings face, profiles, metas", SettingPlumbing);
r.Add("fight selected: /ra why says it is fighting the monster you selected", WhySaysSo);
r.Add("fight selected: a monster selected while Combat, the macro or the setting was off is fought once they are on (R-20261115-051911-9105)", HeldSelectionFollowed);
r.Add("fight selected: a same-named neighbour's kill notice doesn't end the selected monster before it is attacked (R-20261112-030126-63b5)", NeighbourKillKeepsSelected);
}
// ── Rig ───────────────────────────────────────────────────────────────────
@ -124,6 +126,19 @@ internal static class FightSelectedTests
private static void PlayerSelectionWins()
{
// Macro stopped or Combat off: not followed, and the log says why (once per monster).
var off = new Rig();
off.S.IsMacroRunning = false;
Check.Eq(off.Select(B), null, "macro stopped: not followed");
off.Select(0);
off.Select(B);
Check.Eq(FakeHost.Logs.Count(l => l.Contains("'Mob B' not followed: the macro isn't running")), 1, "logged once");
off.S.IsMacroRunning = true;
off.S.EnableCombat = false;
Check.Eq(off.Select(A), null, "Combat off: not followed");
Check.True(FakeHost.Logs.Any(l => l.Contains("'Mob A' not followed: Combat is off")), "logged");
Check.Eq(off.Forced, 0, "no lock");
var t = new Rig();
Check.Eq(t.Pick((A, 2), (B, 6), (Boss, 4)), Boss, "normal: the Boss's priority wins");
Check.Eq(t.Select(B), "locked", "the player selects B");
@ -169,6 +184,11 @@ internal static class FightSelectedTests
bot.P.OnSelectedTargetChange(B, A);
Check.Eq(t.Forced, 0, "the bot selecting another monster: not the player's");
Check.Eq(t.Pick((A, 2), (B, 6)), A, "still A");
// R-20261112-030126-63b5: an ignored monster selection says why (a player's click
// taken for the bot's own shows in a report); the fight target's re-select doesn't.
Check.True(FakeHost.Logs.Any(l => l.Contains("fight-selected") && l.Contains("'Mob B' not followed: taken as RynthAi's own selection")),
"the bot's selection of another monster is logged");
Check.False(FakeHost.Logs.Any(l => l.Contains("'Mob A' not followed")), "its own target's re-select isn't");
// Several marks in a row: the earlier ones are still the bot's (not just the last).
SelfSelect.Mark(Boss);
@ -393,6 +413,153 @@ internal static class FightSelectedTests
Check.True(bot.AllChat.Contains("likely: fighting the monster you selected"), "the interpretation: " + bot.AllChat);
}
// R-20261115-051911-9105 (2026-11-15): the player turned Combat off, selected a monster that was
// attacking them, turned Combat back on with it still selected, and the bot fought another
// (lowest health). Only selection changes were followed; toggling the setting didn't help either.
private static void HeldSelectionFollowed()
{
// Combat off: the selection is held, then fought when Combat comes back on.
var t = new Rig();
t.S.EnableCombat = false;
FakeHost.SelectedItem = B;
Check.Eq(t.Select(B), null, "Combat off: not followed yet");
Check.True(FakeHost.Logs.Any(l => l.Contains("'Mob B' not followed: Combat is off")), "logged");
t.S.EnableCombat = true;
Check.Eq(t.Pick((A, 2), (B, 6), (Boss, 4)), B, "Combat on, B still selected: B, over the Boss and the closer A");
Check.Eq(t.Forced, I(B), "as the selected monster");
Check.True(t.Combat.ForcedBySelection, "a selection lock");
Check.True(FakeHost.Logs.Any(l => l.Contains("'Mob B' is still selected from before")), "logged");
Check.Eq(t.Pick((A, 2), (B, 6), (Boss, 4)), B, "kept");
// The setting off: said once while it stays off; turned on with B selected, B is fought.
t = new Rig(on: false);
FakeHost.SelectedItem = A;
t.Select(A);
FakeHost.SelectedItem = B;
t.Select(B);
Check.Eq(FakeHost.Logs.Count(l => l.Contains("not followed: the setting \"Fight the monster I select\" is off")), 1, "the setting off: one line");
Check.Eq(t.Pick((A, 2), (B, 6), (Boss, 4)), Boss, "off: normal priority");
t.S.FightSelectedTarget = true;
Check.Eq(t.Pick((A, 2), (B, 6), (Boss, 4)), B, "the setting turned on with B selected: B");
// The macro started with B selected: the same.
t = new Rig();
t.S.IsMacroRunning = false;
FakeHost.SelectedItem = B;
t.Select(B);
t.S.IsMacroRunning = true;
Check.Eq(t.Pick((A, 2), (B, 6), (Boss, 4)), B, "macro started with B selected: B");
// Selected away since (the bot's own pick, or the player's deselect): nothing held is fought.
t = new Rig();
t.S.EnableCombat = false;
FakeHost.SelectedItem = B;
t.Select(B);
FakeHost.SelectedItem = Corpse; // e.g. the looter opened a corpse
t.S.EnableCombat = true;
Check.Eq(t.Pick((A, 2), (B, 6), (Boss, 4)), Boss, "B no longer selected: normal priority");
Check.Eq(t.Forced, 0, "no lock");
t = new Rig();
t.S.EnableCombat = false;
FakeHost.SelectedItem = B;
t.Select(B);
FakeHost.SelectedItem = 0;
t.Select(0);
t.S.EnableCombat = true;
FakeHost.SelectedItem = B; // even if B were the selection again by the bot's doing
Check.Eq(t.Pick((A, 2), (B, 6), (Boss, 4)), Boss, "a deselect drops the held one");
// The bot's own selection doesn't replace a held one.
t = new Rig();
t.S.EnableCombat = false;
FakeHost.SelectedItem = B;
t.Select(B);
t.Combat.OnSelectionChanged(A, ours: true);
t.Combat.OnSelectionChanged(B, ours: true); // and back
t.S.EnableCombat = true;
Check.Eq(t.Pick((A, 2), (B, 6), (Boss, 4)), B, "the bot's selections in between don't drop it");
}
// R-20261112-030126-63b5 (2026-11-13, a mage with a pet and damage-over-time spells, a pack of
// same-named monsters): the player selected a monster, the bot switched to it, and 0.7 s later,
// before a single cast at it, a kill notice for the monster it had just left (the pet's or a
// DoT's kill) named the same name. The selected monster was taken for the dead one: dropped,
// kept off the scan as killed, "fight-selected ... ended: killed", and the bot went back to
// its own pick. The "not attacked yet" guard counted a hit from any time as an attack on it,
// and this one had been hurt by a ring a while before it was selected.
private static void NeighbourKillKeepsSelected()
{
const uint X = 0x80000A21, Y = 0x80000A22, Wcid = 3001;
const string Name = "Bovine Brute";
DateTime now = DateTime.Now;
RynthClock.TestNow = () => now;
try
{
FakeHost.Reset();
SelfSelect.Reset();
FakeHost.WeaponCalls = true; // installs GetCurrentCombatMode
FakeHost.CombatModeValue = CombatMode.Magic;
Place(Player, "Me", 96, 96, creature: false);
FakeHost.PlayerPose = (Lb | 0x1C, 96f, 96f, 0f);
Place(X, Name, 96, 98);
Place(Y, Name, 96, 100);
FakeHost.Wcids[X] = Wcid;
FakeHost.Wcids[Y] = Wcid;
var s = new LegacyUiSettings
{
MonsterRange = 20, TargetSelection = 1 /* closest */, TargetLock = false,
IsMacroRunning = true, EnableCombat = true, FightSelectedTarget = true,
};
var host = FakeHost.Create();
var cache = FakeHost.MakeCache(host, Player, new[] { X, Y });
var store = new RynthCore.Plugin.RynthAi.CreatureData.MonsterDamageStore();
store.SetManualHp(Wcid, 5000);
var c = new CombatManager(host, s, cache);
c.SetPlayerId(Player);
c.SetDamageStores(null, store);
c.TargetClock = () => now;
uint Pick()
{
c.SetScannedTargetsForTests(new[] { (X, 2.0), (Y, 4.0) }.Select(t => new CombatManager.ScannedTarget
{
Id = I(t.Item1), Distance = t.Item2, Angle = 0, Bearing = double.NaN, Name = Name,
}));
c.HandleCombatTrigger();
if (c.activeTargetId != 0) c.EngageForTest(c.activeTargetId); // Think's BeginFight for the new target
return unchecked((uint)c.activeTargetId);
}
Check.Eq(Pick(), X, "the bot fights X (closest)");
// A ring hurts both: the first line is the fight target's, the second the neighbour Y's.
c.HandleChatForDamage($"You wither {Name} for 1482 points with Clouded Soul.");
c.HandleChatForDamage($"You twist {Name} for 1222 points with Clouded Soul.");
Check.True(cache.IsHealthEstimated(I(Y)), "Y was hit by the ring (a damage estimate)");
now = now.AddSeconds(6);
Check.Eq(c.OnSelectionChanged(Y, false), "locked", "the player selects Y");
Check.Eq(Pick(), Y, "the bot switches to Y");
now = now.AddMilliseconds(700);
c.OnKillNotification($"{Name}'s last strength withers before you!"); // X died (the pet's kill)
Check.Eq(c.activeTargetId, I(Y), "Y, never attacked since it was selected, is kept");
Check.False(c.IsKillSuppressed(I(Y)), "and not kept off the scan as killed");
Check.True(FakeHost.Logs.Any(l => l.Contains("but it hasn't been attacked yet")), "logged: " + string.Join(" | ", FakeHost.Logs.Where(l => l.Contains("Kill"))));
Check.Eq(Pick(), Y, "still fought");
Check.Eq(c.ForcedTargetId, I(Y), "still the monster the player selected");
Check.False(FakeHost.Logs.Any(l => l.Contains("fight-selected") && l.Contains("ended")), "the selection didn't end");
// Hit in this fight: its own kill notice ends it, as before.
now = now.AddSeconds(1);
c.HandleChatForDamage($"You wither {Name} for 1482 points with Incantation of Nether Bolt.");
now = now.AddMilliseconds(500);
c.OnKillNotification($"You reduce {Name} to a drained, twisted corpse!");
Check.Eq(c.activeTargetId, 0, "hit since it was selected: its notice drops it");
Check.True(c.IsKillSuppressed(I(Y)), "as killed");
Pick();
Check.True(FakeHost.Logs.Any(l => l.Contains("fight-selected") && l.Contains("ended: killed")), "the selection ends: killed");
}
finally { RynthClock.TestNow = null; }
}
// ── Plugin harness ───────────────────────────────────────────────────────
private sealed class Bot

View file

@ -17,6 +17,7 @@ internal static class OutdoorHuntTests
r.Add("hunt: the next monster is the shortest walk, not the nearest in a straight line (one behind a building)", ShortestWalk);
r.Add("hunt: a higher Priority comes first, whatever the walk", PriorityFirst);
r.Add("hunt: no way to a monster (a cliff, water): left out for a while; a walk ending close enough still counts", Unreachable);
r.Add("hunt (11-12): a walk ending under a monster on a roof or the floor above doesn't reach it; one up a slope does", AboveTheWalk);
r.Add("hunt: it stays within Hunt Radius of where it started (0 = anywhere)", Radius);
r.Add("hunt: plans again when the monster moves, the walk runs out, or a while passes; not every tick", Replan);
r.Add("hunt: nothing in range: it waits where it is (no walk back to the start); Hunt Radius defaults to anywhere", WaitsWhereItIs);
@ -407,6 +408,31 @@ internal static class OutdoorHuntTests
Check.False(h.IsSkipped(1, T0.AddSeconds(h.SkipSec + 1)), "and tried again after SkipSec");
}
// 11-12: RynthNav finds the ground up to 64 yd under a goal, so a walk to a monster on a roof ended under it
// as an Ok walk, and the character stood there swinging up at it.
private static void AboveTheWalk()
{
var me = V(1000, 1000);
var h = new OutdoorHunt();
h.Start(T0, me);
var nav = new Nav();
var roof = new OutdoorHunt.Vec(1006, 1000, 8); // on a roof, 8 yd up
var below = new OutdoorHunt.Vec(1009, 1000, -6); // the floor below
var slope = new OutdoorHunt.Vec(1020, 1000, 8); // up a hillside, 8 yd up
nav.Overrides[(1006, 1000)] = new(OutdoorHunt.PathStatus.Ok, new[] { V(1006, 1000) }, 6, 8);
nav.Overrides[(1009, 1000)] = new(OutdoorHunt.PathStatus.Ok, new[] { V(1009, 1000) }, 9, 6);
nav.Overrides[(1020, 1000)] = new(OutdoorHunt.PathStatus.Ok, new[] { new OutdoorHunt.Vec(1020, 1000, 7.6) }, 22, 0.4);
var list = Sorted(new OutdoorHunt.Candidate(1, "Roof", roof, roof.DistanceTo(me), 1),
new OutdoorHunt.Candidate(2, "Below", below, below.DistanceTo(me), 1),
new OutdoorHunt.Candidate(3, "Hill", slope, slope.DistanceTo(me), 1));
var d = h.Tick(T0, me, true, list, nav.Path);
Check.Eq(d.TargetId, 3, "the one up the hillside (the walk ends level with it); not the ones above and below the walk's end");
Check.True(h.IsSkipped(1, T0.AddSeconds(60)) && h.IsSkipped(2, T0.AddSeconds(60)), "the roof and the floor below are left out a while");
var notes = string.Join(" | ", h.PendingNotes);
Check.True(notes.Contains("8 yd above the walk's end"), "says it is above: " + notes);
Check.True(notes.Contains("6 yd below the walk's end"), "says it is below: " + notes);
}
private static void Radius()
{
var start = V(1000, 1000);

View file

@ -55,9 +55,42 @@ internal static class TargetingTests
Check.Eq(missile.Tick(), 0u, "missile, 3 yd, a wall between: nor do arrows");
}
// 11-12: a test character locked golems on the floor above (d 9.0, h 6.7, dz +6.0; d 7.4, h 3.3, dz +6.6) and
// swung under them. Melee leaves out a monster more than 3 m up or down and steeper than 0.75 from here.
private static void MeleeOtherFloor()
{
Check.True(CombatManager.OutOfMeleeReachUpOrDown(9.0, 6.0), "the golem on the floor above (h 6.7, dz +6.0)");
Check.True(CombatManager.OutOfMeleeReachUpOrDown(7.4, 6.6), "the other one (h 3.3, dz +6.6)");
Check.True(CombatManager.OutOfMeleeReachUpOrDown(6.5, -6.0), "and on the floor below");
Check.False(CombatManager.OutOfMeleeReachUpOrDown(2.2, 0.9), "on the same floor");
Check.False(CombatManager.OutOfMeleeReachUpOrDown(10.0, 4.0), "up a ramp or a hillside (h 9.2, dz +4.0)");
Check.False(CombatManager.OutOfMeleeReachUpOrDown(3.5, 2.9), "2.9 m up, close: within reach");
var up = new ScanPick(20);
up.Place(A, "Mob A", north: 3, up: 6);
up.Place(B, "Mob B", north: 8);
FakeHost.WeaponCalls = true;
FakeHost.CombatModeValue = CombatMode.Melee;
Check.Eq(up.Tick(), B, "melee: the one 8 m off on this floor, not the one 3 m off on the floor above");
var alone = new ScanPick(20);
alone.Place(A, "Mob A", north: 3, up: 6);
FakeHost.WeaponCalls = true;
FakeHost.CombatModeValue = CombatMode.Melee;
Check.Eq(alone.Tick(), 0u, "melee: no target when the only one is on the floor above");
Check.False(alone.C.HasNearbyMonsters, "and it doesn't hold navigation (the hunt walks up to it)");
var magic = new ScanPick(20);
magic.Place(A, "Mob A", north: 3, up: 6);
FakeHost.WeaponCalls = true;
FakeHost.CombatModeValue = CombatMode.Magic;
Check.Eq(magic.Tick(), A, "magic: one on a balcony in sight is still a target");
}
public static void Register(Runner r)
{
r.Add("targeting: melee within 4 yd ignores the raycast; beyond it, or with magic or missile, it counts", MeleeThroughWalls);
r.Add("targeting (11-12): melee leaves out a monster on the floor above or below; magic doesn't", MeleeOtherFloor);
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);
@ -581,9 +614,9 @@ internal static class TargetingTests
}
/// <summary>A monster <paramref name="north"/>/<paramref name="east"/> m from the player.</summary>
public void Place(uint id, string name, double north = 0, double east = 0)
public void Place(uint id, string name, double north = 0, double east = 0, double up = 0)
{
TargetingTests.Place(id, name, (float)(96 + east), (float)(96 + north));
TargetingTests.Place(id, name, (float)(96 + east), (float)(96 + north), z: (float)up);
if (!_ids.Contains(id)) _ids.Add(id);
}
@ -664,10 +697,10 @@ internal static class TargetingTests
}
}
private static void Place(uint id, string name, float x, float y, bool creature = true)
private static void Place(uint id, string name, float x, float y, bool creature = true, float z = 0f)
{
FakeHost.Names[id] = name;
FakeHost.Positions[id] = (Lb | 0x1C, x, y, 0f);
FakeHost.Positions[id] = (Lb | 0x1C, x, y, z);
if (creature) FakeHost.ItemTypes[id] = 0x10;
}
}