feat: port SK test branch (2026.10.18.24) onto sk

Squash of test/hotbuild-2026-10-16 as merged onto aelrynth main 2026.10.17.1, matching the
2026.10.18.24 test installer. The test branch wins where both changed the same lines; sk-only
changes kept; duplicate features cut to the test branch's copy. RynthAi HandWrittenVersion stays
0.5.0-legacy-ui on sk.

Highlights: RynthOracle 0.6.0 (Legendary, Markers, Dynamic Stamps and Temple guardians merged into
the Quests list, RynthNav Go to), RynthILT 0.2.20 (ub-IT auto-chunk rules, rating level,
RynthILT.Data v3), RynthAi ub-IT /ub and VT/MT meta compatibility and the loot attribute checklist,
RynthNav destination alternatives. Changelog/2026-10-18-sk-port-test-branch-2026.10.18.24.md.
This commit is contained in:
BlankenshipG 2026-10-18 16:22:40 -04:00
commit 7797901d69
287 changed files with 22602 additions and 1090 deletions

View file

@ -328,6 +328,8 @@ internal static unsafe class FakeHost
if (InstanceIds.Count > 0)
api.GetObjectInstanceIdPropertyFn = (IntPtr)(delegate* unmanaged[Cdecl]<uint, uint, uint*, int>)&GetObjectInstanceIdProperty;
api.SetAutoRunFn = (IntPtr)(delegate* unmanaged[Cdecl]<int, int>)&SetAutoRun;
if (SetMotionCalls)
api.SetMotionFn = (IntPtr)(delegate* unmanaged[Cdecl]<uint, int, int>)&SetMotion;
api.TurnToHeadingFn = (IntPtr)(delegate* unmanaged[Cdecl]<float, int>)&TurnToHeading;
api.JumpNonAutonomousFn = (IntPtr)(delegate* unmanaged[Cdecl]<float, int>)&JumpNonAutonomous;
if (TapJumpCalls)
@ -335,8 +337,6 @@ internal static unsafe class FakeHost
api.CastSpellFn = (IntPtr)(delegate* unmanaged[Cdecl]<uint, int, int>)&CastSpell;
if (StopCalls)
api.StopCompletelyFn = (IntPtr)(delegate* unmanaged[Cdecl]<int>)&StopCompletely;
if (SetMotionCalls)
api.SetMotionFn = (IntPtr)(delegate* unmanaged[Cdecl]<uint, int, int>)&SetMotion;
if (Nav3DCalls)
{
api.Nav3DClearFn = (IntPtr)(delegate* unmanaged[Cdecl]<void>)&Nav3DClear;

View file

@ -54,7 +54,10 @@ internal static class Program
PropertyDumpTests.Register(runner);
T11LootTests.Register(runner);
MagItemDescriberTests.Register(runner);
SelfRatingsTests.Register(runner);
IltClientLookupTests.Register(runner);
ExpressionTests.Register(runner);
GiveProfileTests.Register(runner);
MetaTests.Register(runner);
NoKillTests.Register(runner);
MetaSchedulerTests.Register(runner);
@ -71,6 +74,8 @@ internal static class Program
AmmoTests.Register(runner);
VTankYieldTests.Register(runner);
OffhandTests.Register(runner);
LauncherSwapTests.Register(runner);
MissileCraftingTests.Register(runner);
FloodPerfTests.Register(runner);
LootSalvageTests.Register(runner);
LootCorpseTests.Register(runner);
@ -89,9 +94,13 @@ internal static class Program
UseAtLoginTests.Register(runner);
LearnSpellsTests.Register(runner);
AttackLatencyTests.Register(runner);
RingEscapeTests.Register(runner);
TargetingTests.Register(runner);
LootAddItemTests.Register(runner);
GiveTests.Register(runner);
UbCompatTests.Register(runner);
MetaAuditTests.Register(runner);
MetaSampleCompatTests.Register(runner);
DungeonMapBakeTests.Register(runner);
MonsterEditorTests.Register(runner);
InstallPathsTests.Register(runner);
@ -128,6 +137,9 @@ internal static class Program
VTankHotkeyTests.Register(runner);
OneTouchHealTests.Register(runner);
SaveFailureTests.Register(runner);
EnvironmentImpactTests.Register(runner);
PetDamageTintTests.Register(runner);
TinkerTests.Register(runner);
DoorTests.Register(runner);
ServerPolicyTests.Register(runner);
BlankLoadTests.Register(runner);

View file

@ -0,0 +1,514 @@
using System;
using System.Collections.Generic;
using System.Linq;
using RynthCore.Plugin.RynthAi;
using RynthCore.Plugin.RynthAi.LegacyUi;
using RynthCore.Plugin.Shared;
using RynthCore.RynthAiHostTests.Fakes;
using RynthCore.RynthAiTests.Harness;
namespace RynthCore.RynthAiHostTests.Tests;
// Environment-impact throttle and per-monster attack power (2026-10-12). Arrows into a wall
// ("Your missile attack hit the environment.") or war bolts stopping short of the target count
// against that target; at the limit within the window, combat stops attacking it and moves closer,
// switches target (this one skipped for a while), or moves closer once and then switches, as chosen
// separately for missile and magic combat. The only monster in reach is never skipped. A monster
// rule's Power picks High / Reckless / Variable / Reckless + Variable per monster.
internal static class EnvironmentImpactTests
{
private const uint Player = 0x50000F01;
private const uint Lb = 0xA9B40000;
private const uint A = 0x80000401, B = 0x80000402, Bolt = 0x80000499;
public static void Register(Runner r)
{
r.Add("env impact: the response decision (move closer, new target, closer then new, the only monster)", Decide);
r.Add("env impact: hits count per target inside the window; approaches are remembered", Throttle);
r.Add("env impact: a projectile is short only when it stopped away from the target and nearer the caster", Judge);
r.Add("env impact: missile lines trip New target: the attack stops, the target is skipped, the next is picked", MissileNewTarget);
r.Add("env impact: Move closer runs toward the target and stops at the goal; the only monster is never skipped", MissileApproach);
r.Add("env impact: Off, or not in Missile mode: the line is ignored", MissileOff);
r.Add("env impact: a player's copy of the missile line (their chat type, or their name in front) is not a hit", MissileSpoof);
r.Add("env impact: a bolt stopping short with no hit counts; one with a hit line, or reaching the target, doesn't", MagicShort);
r.Add("env impact: an approach Think stops driving lets go of autorun", ApproachOrphan);
r.Add("env impact (flight 63260): 3 magic casts landing nothing -> one short real sidestep; a hit resets; 30 s apart", ResyncSidestep);
r.Add("env impact: the throttle switching target restarts the re-sync's miss count", ResyncCountResetByThrottle);
r.Add("env impact: moving closer drops a wanted re-sync sidestep", ResyncDroppedByApproach);
r.Add("env impact: a re-sync sidestep holding its key finishes before the throttle runs", ResyncStepFinishesFirst);
r.Add("env impact: a re-sync sidestep Think stops driving, or a macro stop, lets go of the key", ResyncKeyReleased);
r.Add("attack power: Default/High/Reckless/Variable/Reckless + Variable, the DEFAULT line, untrained Recklessness", Power);
r.Add("attack power: an engine without the Power column keeps each rule's power", PowerCarriedOver);
}
// ── Pure rules ───────────────────────────────────────────────────────────
private static void Decide()
{
var M = EnvironmentResponse.MoveCloser; var N = EnvironmentResponse.NewTarget; var C = EnvironmentResponse.CloserThenNewTarget;
EnvironmentAction D(EnvironmentResponse r, int done, double dist, bool alt) => EnvironmentImpactPlanner.Decide(r, done, dist, 3, alt);
Check.Eq(D(EnvironmentResponse.Off, 0, 20, true), EnvironmentAction.None, "Off: nothing");
Check.Eq(D(M, 0, 20, true), EnvironmentAction.Approach, "Move closer, far: approach");
Check.Eq(D(M, 3, 20, false), EnvironmentAction.Approach, "Move closer approaches every time it trips");
Check.Eq(D(M, 0, 3.2, true), EnvironmentAction.NewTarget, "Move closer, already at the closest: new target");
Check.Eq(D(M, 0, 3.2, false), EnvironmentAction.None, "... but not the only monster: keep attacking");
Check.Eq(D(N, 0, 20, true), EnvironmentAction.NewTarget, "New target with another in reach: switch");
Check.Eq(D(N, 0, 20, false), EnvironmentAction.Approach, "New target, nothing else: approach instead of idling");
Check.Eq(D(N, 0, 2, false), EnvironmentAction.None, "New target, nothing else, already close: keep attacking");
Check.Eq(D(C, 0, 20, true), EnvironmentAction.Approach, "Closer then new: the first trip approaches");
Check.Eq(D(C, 1, 14, true), EnvironmentAction.NewTarget, "... the second switches");
Check.Eq(D(C, 1, 14, false), EnvironmentAction.Approach, "... unless it's the only monster");
Check.Eq(D(M, 0, double.NaN, true), EnvironmentAction.NewTarget, "unknown distance: no approach");
Check.Near(EnvironmentImpactPlanner.ApproachGoal(20, 6, 3), 14, 1e-9, "goal: 6 m nearer");
Check.Near(EnvironmentImpactPlanner.ApproachGoal(7, 6, 3), 3, 1e-9, "goal: never inside the closest distance");
Check.Eq(EnvironmentImpactPlanner.Parse(9), EnvironmentResponse.Off, "an out-of-range saved value is Off");
Check.Eq(EnvironmentImpactPlanner.Name(3), "Move closer, then new target", "labels follow the enum");
}
private static void Throttle()
{
var t = new EnvironmentImpactThrottle();
var t0 = new DateTime(2026, 10, 12, 12, 0, 0);
Check.Eq(t.Record(1, t0, 20), 1, "first hit");
Check.Eq(t.Record(2, t0, 20), 1, "per target");
Check.Eq(t.Record(1, t0.AddSeconds(5), 20), 2, "second hit inside the window");
Check.Eq(t.Count(1, t0.AddSeconds(21), 20), 1, "the first hit ages out");
Check.Eq(t.Count(1, t0.AddSeconds(30), 20), 0, "both aged out");
t.Record(1, t0.AddSeconds(31), 20);
t.ResetHits(1);
Check.Eq(t.Count(1, t0.AddSeconds(31), 20), 0, "reset after acting");
t.NoteApproach(1);
Check.Eq(t.Approaches(1), 1, "approach remembered");
t.Forget(1);
Check.Eq(t.Approaches(1), 0, "a deleted id forgets everything");
Check.Eq(t.Record(0, t0, 20), 0, "no target: not counted");
}
private static void Judge()
{
Check.True(ProjectileImpactJudge.StoppedShort(impactToTarget: 10, casterToImpact: 10, casterToTarget: 20), "into a wall halfway");
Check.False(ProjectileImpactJudge.StoppedShort(1.5, 18.5, 20), "at the target's surface");
Check.False(ProjectileImpactJudge.StoppedShort(3.5, 17, 20), "a big monster's surface (within 4 m)");
Check.False(ProjectileImpactJudge.StoppedShort(6, 21, 20), "past the target (a miss beyond, not a wall in front)");
Check.False(ProjectileImpactJudge.StoppedShort(double.NaN, 10, 20), "unknown: never short");
}
// ── Through CombatManager ────────────────────────────────────────────────
private sealed class Rig
{
public readonly LegacyUiSettings S;
public readonly CombatManager C;
public readonly WorldObjectCache Cache;
public DateTime Now = new(2026, 10, 12, 12, 0, 0);
/// <summary>The player at (96, 96) facing north; <paramref name="mobs"/> placed after the reset.</summary>
public Rig(int mode, Action<LegacyUiSettings> set, params (uint Id, string Name, float X, float Y)[] mobs)
: this(mode, set, setMotion: false, mobs) { }
/// <summary>As above; <paramref name="setMotion"/> installs SetMotion (the re-sync sidestep needs it).</summary>
public Rig(int mode, Action<LegacyUiSettings> set, bool setMotion, params (uint Id, string Name, float X, float Y)[] mobs)
{
FakeHost.Reset();
FakeHost.WeaponCalls = true;
FakeHost.SetMotionCalls = setMotion;
FakeHost.CombatModeValue = mode;
Place(Player, "Me", 96, 96, creature: false);
foreach (var m in mobs) Place(m.Id, m.Name, m.X, m.Y);
FakeHost.PlayerPose = (Lb | 0x1C, 96f, 96f, 0f);
FakeHost.HeadingDeg = 0;
S = new LegacyUiSettings { MonsterRange = 50, IsMacroRunning = true, EnableCombat = true };
set(S);
var host = FakeHost.Create(Player); // Think measures distances from GetPlayerId
Cache = FakeHost.MakeCache(host, Player, mobs.Select(m => m.Id));
C = new CombatManager(host, S, Cache);
C.SetPlayerId(Player);
C.SetDamageStores(null, new RynthCore.Plugin.RynthAi.CreatureData.MonsterDamageStore());
C.EnvClock = () => Now;
C.ScanNearbyTargets();
C.HandleCombatTrigger();
FakeHost.MotionCalls.Clear(); // the trigger's turn-motion clear-out isn't under test
}
public double Dist(uint id)
{
var p = FakeHost.Positions[id];
double dx = p.X - FakeHost.PlayerPose.X, dy = p.Y - FakeHost.PlayerPose.Y;
return Math.Sqrt(dx * dx + dy * dy);
}
public bool Run() => C.RunEnvironmentImpact(Cache[C.activeTargetId]!, Dist((uint)C.activeTargetId));
public void MovePlayer(float x, float y)
{
FakeHost.PlayerPose = (Lb | 0x1C, x, y, 0f);
FakeHost.Positions[Player] = FakeHost.PlayerPose;
}
}
private const string MissileLine = "Your missile attack hit the environment.";
// 20 m north of the player (the pick), and 24 m east.
private static readonly (uint, string, float, float) Skulker = (A, "Drudge Skulker", 96f, 116f);
private static readonly (uint, string, float, float) Slinker = (B, "Drudge Slinker", 120f, 96f);
private static void MissileNewTarget()
{
var r = new Rig(CombatMode.Missile, s => { s.MissileEnvironmentResponse = 2; s.EnvironmentImpactLimit = 2; s.EnvironmentSkipSec = 30; }, Skulker, Slinker);
Check.Eq((uint)r.C.activeTargetId, A, "the nearer Skulker is locked");
r.C.HandleChatForDamage(MissileLine);
Check.False(r.Run(), "one hit: attacking on");
r.Now = r.Now.AddSeconds(3);
r.C.HandleChatForDamage(MissileLine);
Check.True(FakeHost.Logs.Any(l => l.Contains("[EnvImpact] missile") && l.Contains("2/2")), "both hits logged against the target");
Check.True(r.Run(), "the limit: this tick belongs to the response");
Check.Eq(r.C.activeTargetId, 0, "the Skulker is dropped");
Check.True(FakeHost.Logs.Any(l => l.Contains("leaving") && l.Contains("skipping it 30s")), "logged with the skip");
Rescan(r);
Check.False(r.C.ScannedTargets.Any(t => (uint)t.Id == A), "the skipped Skulker is out of the scan");
r.C.HandleCombatTrigger();
Check.Eq((uint)r.C.activeTargetId, B, "the Slinker is fought next");
r.Now = r.Now.AddSeconds(31);
Rescan(r);
Check.True(r.C.ScannedTargets.Any(t => (uint)t.Id == A), "after the skip the Skulker is back");
}
/// <summary>The scan runs at most every 50 ms of real time (SCAN_INTERVAL_MS).</summary>
private static void Rescan(Rig r)
{
System.Threading.Thread.Sleep(60);
r.C.ScanNearbyTargets();
}
private static void MissileApproach()
{
// The Skulker is the only monster.
var r = new Rig(CombatMode.Missile, s => { s.MissileEnvironmentResponse = 2; s.EnvironmentImpactLimit = 2; s.EnvironmentApproachMeters = 6; s.EnvironmentMinDistance = 3; }, Skulker);
r.C.HandleChatForDamage(MissileLine);
r.C.HandleChatForDamage(MissileLine);
Check.True(r.Run(), "New target with nothing else in reach: moves closer instead");
Check.Eq((uint)r.C.activeTargetId, A, "the only monster is kept");
Check.True(FakeHost.AutoRun, "running toward it");
Check.True(r.C.EnvironmentApproachActive, "approach under way");
Check.True(FakeHost.Logs.Any(l => l.Contains("moving closer") && l.Contains("stopping at 14.0m")), "goal: 6 m nearer");
r.Now = r.Now.AddMilliseconds(500);
r.MovePlayer(96, 99); // 17 m
Check.True(r.Run(), "still short of the goal: no attack");
r.Now = r.Now.AddMilliseconds(500);
r.MovePlayer(96, 102.5f); // 13.5 m
Check.False(r.Run(), "reached: attacking again this tick");
Check.False(FakeHost.AutoRun, "autorun off");
Check.False(r.C.EnvironmentApproachActive, "approach over");
// Two more hits: already approached once, still far enough: Move closer goes again.
r.S.MissileEnvironmentResponse = 1;
r.C.HandleChatForDamage(MissileLine);
r.C.HandleChatForDamage(MissileLine);
Check.True(r.Run(), "Move closer trips again");
Check.True(FakeHost.AutoRun, "running again");
// Blocked: no ground gained for 2.5 s.
r.Now = r.Now.AddSeconds(3);
Check.False(r.Run(), "no progress: the approach gives up and combat attacks");
Check.False(FakeHost.AutoRun, "autorun off when blocked");
Check.True(FakeHost.Logs.Any(l => l.Contains("ended: no progress")), "logged as blocked");
// At the closest distance with nothing else: keep attacking.
r.MovePlayer(96, 113.2f); // 2.8 m
r.C.HandleChatForDamage(MissileLine);
r.C.HandleChatForDamage(MissileLine);
Check.False(r.Run(), "already close and the only monster: attacking on");
Check.Eq((uint)r.C.activeTargetId, A, "not dropped");
}
private static void MissileOff()
{
var off = new Rig(CombatMode.Missile, s => { s.MissileEnvironmentResponse = 0; s.EnvironmentImpactLimit = 1; }, Skulker);
off.C.HandleChatForDamage(MissileLine);
Check.False(off.Run(), "Off: nothing happens");
Check.False(FakeHost.Logs.Any(l => l.Contains("[EnvImpact]")), "Off: not even counted");
var melee = new Rig(CombatMode.Melee, s => { s.MissileEnvironmentResponse = 2; s.EnvironmentImpactLimit = 1; }, Skulker);
melee.C.HandleChatForDamage(MissileLine);
Check.False(melee.Run(), "not in Missile mode: ignored");
}
private static void MissileSpoof()
{
var r = new Rig(CombatMode.Missile, s => { s.MissileEnvironmentResponse = 2; s.EnvironmentImpactLimit = 1; }, Skulker);
r.C.HandleChatForDamage("Bob says, \"" + MissileLine + "\"", 2);
r.C.HandleChatForDamage(MissileLine, 3); // a tell, whatever its text
r.C.HandleChatForDamage("Bob " + MissileLine, 12); // an emote
r.C.HandleChatForDamage("[Allegiance] Bob says, \"" + MissileLine + "\""); // type unknown: the anchor
Check.False(r.Run(), "no spoofed line counts");
Check.False(FakeHost.Logs.Any(l => l.Contains("[EnvImpact]")), "nothing recorded");
r.C.HandleChatForDamage(MissileLine, 0); // ACE's own line is a Broadcast
Check.True(r.Run(), "the server's line still trips the limit");
}
private static void MagicShort()
{
var r = new Rig(CombatMode.Magic, s => { s.MagicEnvironmentResponse = 2; s.EnvironmentImpactLimit = 2; }, Skulker, Slinker);
Check.Eq((uint)r.C.activeTargetId, A, "the Skulker is locked");
void Cast(float stopY, bool hitLine = false) => CastBolt(r, stopY, hitLine);
Cast(105);
Check.True(FakeHost.Logs.Any(l => l.Contains("[EnvImpact] magic") && l.Contains("1/2")), "a bolt stopping 9 m out, no hit: one environment hit");
Cast(115);
Check.False(FakeHost.Logs.Any(l => l.Contains("[EnvImpact] magic") && l.Contains("2/2")), "a bolt reaching the target: not counted");
Cast(105, hitLine: true);
Check.False(FakeHost.Logs.Any(l => l.Contains("[EnvImpact] magic") && l.Contains("2/2")), "a hit line for the cast: not counted");
Cast(105);
Check.True(FakeHost.Logs.Any(l => l.Contains("[EnvImpact] magic") && l.Contains("2/2")), "a second short bolt: the limit");
Check.True(r.Run(), "the response runs");
Check.Eq(r.C.activeTargetId, 0, "the Skulker is left for the Slinker");
// Rings and other casters' projectiles aren't ours to judge.
Check.False(CombatManager.IsWatchedProjectileName("Flame Ring"), "a ring isn't watched");
Check.True(CombatManager.IsWatchedProjectileName("Nether Bolt"), "void bolts are");
Check.False(CombatManager.IsWatchedProjectileName("Drudge Skulker"), "a monster isn't");
}
private static void ApproachOrphan()
{
var r = new Rig(CombatMode.Missile, s => { s.MissileEnvironmentResponse = 1; s.EnvironmentImpactLimit = 1; }, Skulker);
r.C.HandleChatForDamage(MissileLine);
Check.True(r.Run(), "approach starts");
Check.True(FakeHost.AutoRun, "running");
r.Now = r.Now.AddSeconds(2); // Think stopped calling (buffing took over)
r.C.PollEnvironmentImpact();
Check.False(FakeHost.AutoRun, "the heartbeat lets go of autorun");
Check.False(r.C.EnvironmentApproachActive, "approach over");
r.C.HandleChatForDamage(MissileLine);
Check.True(r.Run(), "a new approach");
r.C.OnHeartbeat(); // a heartbeat sees the macro running
Check.True(FakeHost.AutoRun, "still running while Think drives it");
r.S.IsMacroRunning = false;
r.C.OnHeartbeat();
Check.False(FakeHost.AutoRun, "a macro stop ends it too");
}
// ── Attack power ─────────────────────────────────────────────────────────
private static void Power()
{
float R(string mode, int global = -1, bool reck = false, bool trained = true, int min = 50, int max = 100, double rnd = 0.5)
=> AttackPowerModes.Resolve(mode, global, reck, trained, min, max, () => rnd);
Check.Near(R("Default"), 1.0, 1e-6, "Default, Auto, no Recklessness: 100%");
Check.Near(R("Default", reck: true), 0.8, 1e-6, "Default, Auto + Use Recklessness, trained: 80%");
Check.Near(R("Default", reck: true, trained: false), 1.0, 1e-6, "... untrained: 100%");
Check.Near(R("Default", global: 65), 0.65, 1e-6, "Default, a set power: that power");
Check.Near(R("High", global: 40), 1.0, 1e-6, "High: 100% whatever the global");
Check.Near(R("Reckless"), 0.8, 1e-6, "Reckless: 80%");
Check.Near(R("Reckless", trained: false), 1.0, 1e-6, "Reckless untrained: High");
Check.Near(R("Variable", rnd: 0), 0.5, 1e-6, "Variable: the min");
Check.Near(R("Variable", rnd: 0.999), 1.0, 1e-6, "Variable: up to the max");
Check.Near(R("Variable", min: 90, max: 30, rnd: 0), 0.3, 1e-6, "Variable: a reversed range is put in order");
Check.Near(R("Reckless + Variable", rnd: 0), 0.5, 1e-6, "Reckless + Variable: the Variable min (inside the band)");
Check.Near(R("Reckless + Variable", rnd: 0.999), 0.8, 1e-6, "... capped at the band's 80%");
Check.Near(R("Reckless + Variable", min: 85, max: 100, rnd: 0), 0.2, 1e-6, "no overlap with the band: the whole band");
Check.Near(R("Reckless + Variable", trained: false, rnd: 0.999), 1.0, 1e-6, "untrained: plain Variable");
var seen = new HashSet<float>();
foreach (double d in new[] { 0.1, 0.4, 0.7 }) seen.Add(R("Variable", rnd: d));
Check.Eq(seen.Count, 3, "Variable changes with each draw");
Check.Eq(AttackPowerModes.Normalize("reckless+variable"), AttackPowerModes.RecklessVariable, "hand-typed spelling");
Check.Eq(AttackPowerModes.Normalize(null), AttackPowerModes.Default, "missing: Default");
Check.Eq(AttackPowerModes.Normalize("Huge"), AttackPowerModes.Default, "unknown: Default");
var def = new MonsterRule { Name = "Default", AttackPower = "Reckless" };
Check.Eq(AttackPowerModes.Effective(new MonsterRule { Name = "Drudge" }, def), "Reckless", "a Default rule follows the DEFAULT line");
Check.Eq(AttackPowerModes.Effective(new MonsterRule { Name = "Drudge", AttackPower = "High" }, def), "High", "its own choice wins");
Check.Eq(AttackPowerModes.Effective(null, null), "Default", "no rules: the global settings");
Check.Eq(new MonsterRule().AttackPower, "Default", "a new rule (and an old file) is Default");
// Pull-away kite (2026-10-16): Default → DEFAULT row → Off on that row.
Check.Eq(KiteModes.Normalize("pull away"), KiteModes.PullAway, "hand-typed PullAway");
Check.Eq(KiteModes.Normalize(null), KiteModes.Default, "missing kite: Default");
var kiteDef = new MonsterRule { Name = "Default", Kite = KiteModes.PullAway };
Check.Eq(KiteModes.Effective(new MonsterRule { Name = "Drudge" }, kiteDef), KiteModes.PullAway, "a Default rule follows the DEFAULT kite");
Check.Eq(KiteModes.Effective(new MonsterRule { Name = "Drudge", Kite = KiteModes.Off }, kiteDef), KiteModes.Off, "its own kite wins");
Check.Eq(KiteModes.Effective(kiteDef, kiteDef), KiteModes.PullAway, "DEFAULT row PullAway is PullAway");
Check.Eq(KiteModes.Effective(new MonsterRule { Name = "Default" }, new MonsterRule { Name = "Default" }), KiteModes.Off, "DEFAULT Default means Off");
Check.True(KiteModes.WantsPullAway(new MonsterRule { Name = "X" }, kiteDef), "WantsPullAway follows DEFAULT");
Check.Eq(new MonsterRule().Kite, "Default", "a new rule (and an old file) is Default kite");
}
private static void PowerCarriedOver()
{
var current = new List<MonsterRule>
{
new() { Name = "Default", AttackPower = "High" },
new() { Name = "Drudge", AttackPower = "Variable" },
new() { Name = "Drudge", MatchExpression = "x", AttackPower = "Reckless" },
};
var incoming = new List<MonsterRule>
{
new() { Name = "Default" }, new() { Name = "drudge" }, new() { Name = "Drudge", MatchExpression = "x" }, new() { Name = "Mosswart" },
};
LegacyDashboardRenderer.CarryAttackPower(current, incoming);
Check.Eq(incoming[0].AttackPower, "High", "Default keeps its power");
Check.Eq(incoming[1].AttackPower, "Variable", "matched by name, any case");
Check.Eq(incoming[2].AttackPower, "Reckless", "and by expression");
Check.Eq(incoming[3].AttackPower, "Default", "a new rule stays Default");
}
// ── Magic position re-sync (upstream 2026.10.12.1) and the throttle ──────
private const uint StepRight = 0x6500000F, StepLeft = 0x65000010;
/// <summary>Upstream's CastNoDamageTests.ResyncSidestep, on this file's rig.</summary>
private static void ResyncSidestep()
{
var r = new Rig(CombatMode.Magic, s => { }, setMotion: true, Skulker, Slinker);
var c = r.C;
c.TargetClock = () => r.Now;
MoveAudit.Reset();
c.MagicMissForTest(unchecked((int)A));
c.MagicMissForTest(unchecked((int)B)); // a swap to the other monster doesn't reset the count
Check.False(c.ResyncActive, "two misses: nothing yet");
c.ReportDamageOnTarget(unchecked((int)A));
c.MagicMissForTest(unchecked((int)A));
c.MagicMissForTest(unchecked((int)A));
Check.False(c.ResyncActive, "a hit reset the count");
c.MagicMissForTest(unchecked((int)A));
Check.True(c.ResyncActive, "three in a row: a re-sync is wanted");
Check.Eq(FakeHost.Logs.Count(l => l.Contains("one short sidestep to re-sync")), 1, "said once");
Check.True(c.TickResyncStep(), "first tick: the step starts, no cast");
Check.True(FakeHost.MotionCalls.SequenceEqual(new[] { (StepRight, true) }), "sidestep right key down");
r.Now = r.Now.AddMilliseconds(200);
Check.True(c.TickResyncStep(), "still stepping at 200 ms");
r.Now = r.Now.AddMilliseconds(100);
Check.True(c.TickResyncStep(), "300 ms: key up, settling");
Check.True(FakeHost.MotionCalls.SequenceEqual(new[] { (StepRight, true), (StepRight, false) }), "key up");
r.Now = r.Now.AddMilliseconds(400);
Check.False(c.TickResyncStep(), "settled: casting may go on");
Check.Eq(c.ResyncSteps, 1, "one step");
for (int i = 0; i < 3; i++) c.MagicMissForTest(unchecked((int)A));
Check.False(c.ResyncActive, "within 30 s: no second step");
r.Now = r.Now.AddSeconds(30);
for (int i = 0; i < 3; i++) c.MagicMissForTest(unchecked((int)A));
Check.True(c.ResyncActive, "30 s later: another one");
c.TickResyncStep();
Check.True(FakeHost.MotionCalls[2] == (StepLeft, true), "the other side this time");
}
private static void ResyncCountResetByThrottle()
{
var r = new Rig(CombatMode.Magic, s => { s.MagicEnvironmentResponse = 2; s.EnvironmentImpactLimit = 2; }, setMotion: true, Skulker, Slinker);
r.C.TargetClock = () => r.Now;
r.C.MagicMissForTest(unchecked((int)A));
r.C.MagicMissForTest(unchecked((int)A));
CastBolt(r, 105);
CastBolt(r, 105);
Check.True(r.Run(), "two short bolts: the throttle switches target");
Check.Eq(r.C.activeTargetId, 0, "the Skulker is left");
r.C.MagicMissForTest(unchecked((int)B));
r.C.MagicMissForTest(unchecked((int)B));
Check.False(r.C.ResyncActive, "the misses the wall explained no longer count toward a sidestep");
r.C.MagicMissForTest(unchecked((int)B));
Check.True(r.C.ResyncActive, "three fresh misses on the new target still ask for one");
}
private static void ResyncDroppedByApproach()
{
var r = new Rig(CombatMode.Magic, s => { s.MagicEnvironmentResponse = 1; s.EnvironmentImpactLimit = 1; }, setMotion: true, Skulker);
r.C.TargetClock = () => r.Now;
for (int i = 0; i < 3; i++) r.C.MagicMissForTest(unchecked((int)A));
Check.True(r.C.ResyncActive, "a sidestep is wanted");
CastBolt(r, 105);
Check.True(r.Run(), "the throttle moves closer");
Check.True(FakeHost.AutoRun, "running toward the Skulker");
Check.False(r.C.ResyncActive, "the wanted sidestep is dropped: the run moves us anyway");
Check.True(FakeHost.Logs.Any(l => l.Contains("re-sync sidestep dropped: moving closer")), "logged");
Check.Eq(FakeHost.MotionCalls.Count, 0, "no sidestep key was sent");
}
private static void ResyncStepFinishesFirst()
{
var r = new Rig(CombatMode.Magic, s => { s.MagicEnvironmentResponse = 1; s.EnvironmentImpactLimit = 1; }, setMotion: true, Skulker);
r.C.TargetClock = () => r.Now;
for (int i = 0; i < 3; i++) r.C.MagicMissForTest(unchecked((int)A));
CastBolt(r, 105); // the throttle trips (its response waits for Think)
Check.True(r.C.TickResyncStep(), "the sidestep key goes down");
Check.True(r.Run(), "the throttle's tick: no attack");
Check.False(r.C.EnvironmentApproachActive, "but no run while the sidestep key is held");
Check.False(FakeHost.AutoRun, "autorun not sent");
r.Now = r.Now.AddMilliseconds(300);
Check.True(r.C.TickResyncStep(), "the sidestep key comes up");
Check.True(r.Run(), "now the approach runs");
Check.True(r.C.EnvironmentApproachActive, "approach under way");
Check.True(FakeHost.MotionCalls.SequenceEqual(new[] { (StepRight, true), (StepRight, false) }), "the key went up before the run");
}
private static void ResyncKeyReleased()
{
var r = new Rig(CombatMode.Magic, s => { }, setMotion: true, Skulker);
r.C.TargetClock = () => r.Now;
for (int i = 0; i < 3; i++) r.C.MagicMissForTest(unchecked((int)A));
r.C.TickResyncStep();
Check.True(FakeHost.MotionCalls.SequenceEqual(new[] { (StepRight, true) }), "key down");
r.Now = r.Now.AddSeconds(2); // Think stopped ticking it (left magic mode)
r.C.PollEnvironmentImpact();
Check.True(FakeHost.MotionCalls.SequenceEqual(new[] { (StepRight, true), (StepRight, false) }), "the heartbeat lets go of the key");
Check.False(r.C.ResyncActive, "the sidestep is over");
Check.True(FakeHost.Logs.Any(l => l.Contains("re-sync sidestep stopped: combat stopped driving it")), "logged");
r.C.OnHeartbeat(); // a heartbeat sees the macro running
r.C.MagicMissForTest(unchecked((int)A));
int before = FakeHost.MotionCalls.Count;
r.C.TickResyncStep();
Check.True(FakeHost.MotionCalls.Count == before + 1 && FakeHost.MotionCalls[^1] == (StepLeft, true), "a new sidestep, key down");
r.S.IsMacroRunning = false;
r.C.OnHeartbeat();
Check.True(FakeHost.MotionCalls[^1] == (StepLeft, false), "a macro stop lets go of it too");
Check.False(r.C.ResyncActive, "and ends it");
}
// ── Helpers ──────────────────────────────────────────────────────────────
/// <summary>One cast at the active target whose bolt flies from the caster north to <paramref name="stopY"/> and stops.</summary>
private static void CastBolt(Rig r, float stopY, bool hitLine = false)
{
r.C.RegisterCastWatch(r.C.activeTargetId, "Flame Bolt VI");
r.Now = r.Now.AddMilliseconds(800); // the windup
FakeHost.Names[Bolt] = "Flame Bolt";
FakeHost.Positions[Bolt] = (Lb | 0x1C, 96f, 97f, 0f); // spawns at the caster
r.C.OnEnvironmentObjectCreated(Bolt);
r.C.PollEnvironmentImpact();
for (float y = 99; y <= stopY; y += 2)
{
r.Now = r.Now.AddMilliseconds(100);
FakeHost.Positions[Bolt] = (Lb | 0x1C, 96f, y, 0f);
r.C.PollEnvironmentImpact();
}
if (hitLine) r.C.HandleChatForDamage("You singe Drudge Skulker for 40 points of fire damage!");
for (int i = 0; i < 15; i++) { r.Now = r.Now.AddMilliseconds(100); r.C.PollEnvironmentImpact(); }
r.C.OnObjectDeleted(Bolt);
FakeHost.Positions.Remove(Bolt);
}
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;
}
}

View file

@ -41,6 +41,7 @@ internal static class ExpressionTests
r.Add("expr: control flow (iif, if, ifthen, exec) is lazy", ControlFlow);
r.Add("expr: delayexec fires on the pump when due, in order", DelayExec);
r.Add("expr: stopwatches", Stopwatches);
r.Add("expr: ub-IT's remaining functions answer (no-equivalent ones with ub-IT's empty values)", UbCompatFunctions);
r.Add("expr: object type, options and unknown functions", TypesOptionsUnknown);
r.Add("expr: RynthAi settings and meta state from expressions", SettingsAndState);
r.Add("expr: character properties, skills, vitals through the host", CharacterFunctions);
@ -516,10 +517,14 @@ internal static class ExpressionTests
var e = Engine();
long now = 5_000;
e.TickMs = () => now;
// ub-IT: delayexec returns its id (1, 2, ...), which clearexec takes.
Is(e, "delayexec[1000, `setvar[x, first]`]", "1");
Is(e, "delayexec[1000, `setvar[x, second]`]", "1");
Is(e, "delayexec[-50, `setvar[neg, 1]`]", "1");
Is(e, "delayexec[soon, `setvar[bad, 1]`]", "1");
Is(e, "delayexec[1000, `setvar[x, second]`]", "2");
Is(e, "delayexec[-50, `setvar[neg, 1]`]", "3");
Is(e, "delayexec[soon, `setvar[bad, 1]`]", "4");
Is(e, "delayexec[1000, `setvar[cancelled, 1]`]", "5");
Is(e, "clearexec[5]", "1");
Is(e, "clearexec[5]", "0"); // already gone
e.PumpDelayedExecs();
Is(e, "getvar[neg]", "1"); // negative delay: next pump
Is(e, "getvar[bad]", "1"); // unreadable delay: next pump
@ -530,16 +535,76 @@ internal static class ExpressionTests
now += 1;
e.PumpDelayedExecs();
Is(e, "getvar[x]", "second"); // both fired, in the order scheduled
Is(e, "testvar[cancelled]", "0"); // the cleared one never ran
// A delayexec scheduled by a firing one waits for a later pump.
// (\` is an escaped backtick inside a backtick string.)
Is(e, "delayexec[0, `delayexec[0, \\`setvar[chain, 1]\\`]`]", "1");
Is(e, "delayexec[0, `delayexec[0, \\`setvar[chain, 1]\\`]`]", "6");
e.PumpDelayedExecs();
Is(e, "testvar[chain]", "0");
e.PumpDelayedExecs();
Is(e, "getvar[chain]", "1");
}
private static void UbCompatFunctions()
{
FakeHost.Reset();
var settings = new LegacyUiSettings();
var e = Engine(FakeHost.Create(), settings);
// enlightenmentmaterials: levels 6-150 cost (level - 5) tokens; 1-5 and 151+ none.
Is(e, "enlightenmentmaterials[0, 10]", "15"); // 1+2+3+4+5
Is(e, "enlightenmentmaterials[149, 151]", "145"); // only 150 costs tokens
Is(e, "enlightenmentmaterials[160, 165]", "0");
Is(e, "enlightenmentmaterials[10, 5]", "0");
// Macro state, casting, quests.
settings.IsMacroRunning = true;
Is(e, "vtmacroenabled[]", "1");
settings.IsMacroRunning = false;
Is(e, "vtmacroenabled[]", "0");
Is(e, "iscasting[]", "0");
Is(e, "canrefreshquests[]", "1"); // no tracker: nothing throttles it
Is(e, "isrefreshingquestbonuses[]", "0");
Is(e, "getcooldownexpiration[515]", "0");
// Corpses opened by this character come from the plugin's hook.
e.CorpseOpenedByMe = id => id == 0x50000123;
Is(e, "hascorpsebeenopenedbyme[0x50000123]", "1");
Is(e, "hascorpsebeenopenedbyme[0x50000124]", "0");
Is(e, "getcorpsesunopenedbyme[]", "[]"); // no cache, no corpses
// Unknown or unreadable objects: ub-IT's -1 / 0.
Is(e, "wobjectgethealthvalue[0]", "-1");
Is(e, "actiontrymove[0, 0]", "0");
Is(e, "actiontrysplit[0, 5]", "0");
Is(e, "actiontrydrop[0x50000123]", "0");
// spelldata of an unknown spell is an empty dictionary.
Is(e, "dictsize[spelldata[999999]]", "0");
// XP meter: starts at zero.
Is(e, "xpreset[]", "1");
Is(e, "xptotal[]", "0");
Is(e, "lumtotal[]", "0");
Is(e, "xpavg[]", "0");
Check.True(e.Evaluate("xpmeter[]").Contains("XP/hr"), "xpmeter[] is the meter text");
// No RynthAi equivalent: they answer so the expression keeps going.
Is(e, "statushud[kills, 5]", "1");
Is(e, "statushudcolored[kills, 5, red]", "1");
Is(e, "netclients[]", "[]");
Is(e, "getcharacterindex[Bob]", "-1");
Is(e, "setnextlogin[Bob]", "0");
Is(e, "clearnextlogin[]", "1");
Is(e, "uiviewexists[myview]", "0");
Is(e, "uiviewvisible[myview]", "0");
Is(e, "statushud[a, 1] && 7", "1"); // used inside a larger expression
// A real typo is still an unknown function.
Is(e, "nosuchfunctionatall[]", "");
}
private static void Stopwatches()
{
var e = Engine();

View file

@ -27,6 +27,7 @@ internal static class GiveTests
r.Add("give: /ub give with a count hands over that many", UbGiveCount);
r.Add("give: /mt give hands over only the first match", MtGivesFirst);
r.Add("give: /ub givep matches part of the name", UbGivePartial);
r.Add("give: a meta's /ub give hands over every match too (it used to take /mt give's one)", MetaUbGivesAll);
r.Add("give: the next give waits until the server took the last (it answers extra gives 'too busy')", WaitsForServer);
}
@ -112,6 +113,14 @@ internal static class GiveTests
Check.False(w.GivenItems.Contains(WornMote), "and never the worn one");
}
private static void MetaUbGivesAll()
{
var w = new World();
w.Call("HandleMetaChatCommand", "/ub give Mana Mote to Town Crier");
for (int i = 0; i < 20; i++) w.Call("DrainGiveQueue");
Check.Eq(FakeHost.Gives.Count, 3, "all three carried Mana Motes, as typed");
}
private static void UbGivePartial()
{
var w = new World();

View file

@ -0,0 +1,258 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using RynthCore.Plugin.RynthAi;
using RynthCore.Plugin.RynthAi.LegacyUi;
using RynthCore.Plugin.RynthAi.Meta;
using RynthCore.PluginCore;
using RynthCore.RynthAiHostTests.Fakes;
using RynthCore.RynthAiTests.Harness;
namespace RynthCore.RynthAiHostTests.Tests;
// Opt-in audit (RYNTH_META_AUDIT=<folder of .met files>): what each meta asks of RynthAi - its chat
// commands through the real /vt /mt /ub dispatchers, its expression functions through the engine,
// its VTank options against the option map - and a report of what isn't supported.
internal static class MetaAuditTests
{
private const BindingFlags Any = BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public;
public static void Register(Runner r)
{
string? dir = Environment.GetEnvironmentVariable("RYNTH_META_AUDIT");
if (!string.IsNullOrEmpty(dir) && Directory.Exists(dir)) r.Add("audit: sample metas (RYNTH_META_AUDIT)", () => Run(dir));
}
private sealed class Found
{
public readonly SortedDictionary<string, SortedSet<string>> Commands = new(StringComparer.OrdinalIgnoreCase);
public readonly SortedDictionary<string, SortedSet<string>> Functions = new(StringComparer.OrdinalIgnoreCase);
public readonly SortedDictionary<string, SortedSet<string>> Options = new(StringComparer.OrdinalIgnoreCase);
public readonly SortedDictionary<string, SortedSet<string>> Kinds = new(StringComparer.OrdinalIgnoreCase);
public readonly SortedDictionary<string, SortedSet<string>> States = new(StringComparer.OrdinalIgnoreCase);
public void Add(SortedDictionary<string, SortedSet<string>> d, string key, string meta)
{
if (!d.TryGetValue(key, out var s)) d[key] = s = new SortedSet<string>(StringComparer.OrdinalIgnoreCase);
s.Add(meta);
}
}
private static readonly Regex FnRx = new(@"(?<![\$@&\w])([A-Za-z_][A-Za-z0-9_]*)\[", RegexOptions.CultureInvariant);
private static readonly Regex CmdInExprRx = new(@"/(vt|mt|ub|ra)\s+[A-Za-z0-9_]+(?:\s+[A-Za-z0-9_]+)?", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
private static readonly Regex OptFnRx = new(@"\b(vtsetsetting|vtgetsetting|vtankgetsetting)\[\s*`?([A-Za-z0-9_\-]+)", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
private static void Run(string dir)
{
var f = new Found();
var report = new StringBuilder();
var definedStates = new Dictionary<string, HashSet<string>>(StringComparer.OrdinalIgnoreCase);
foreach (string path in Directory.GetFiles(dir, "*.met").OrderBy(p => p, StringComparer.OrdinalIgnoreCase))
{
string meta = Path.GetFileName(path);
LoadedMeta m = MetFileParser.Load(path);
report.AppendLine($"## {meta}: {m.Rules.Count} rules, {m.EmbeddedNavs.Count} navs" + (m.Warnings.Count > 0 ? ", warnings: " + string.Join(" | ", m.Warnings) : ""));
var states = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
definedStates[meta] = states;
foreach (MetaRule rule in m.Rules) { states.Add(rule.State); Walk(rule, meta, f); }
}
// Chat commands through the dispatchers.
var w = new PluginWorld();
report.AppendLine("\n# Chat commands");
foreach (var (cmd, metas) in f.Commands)
report.AppendLine($" [{Classify(cmd, w)}] {cmd} <- {string.Join(", ", metas)}");
// Expression functions through the engine.
report.AppendLine("\n# Expression functions not known to RynthAi");
FakeHost.Reset();
var host = FakeHost.Create();
foreach (var (fn, metas) in f.Functions)
{
var e = new ExpressionEngine(host);
int logs = FakeHost.Logs.Count;
try { e.Evaluate(fn + "[]"); } catch { }
bool unknown = FakeHost.Logs.Skip(logs).Any(l => l.Contains("unknown expression function '" + fn, StringComparison.OrdinalIgnoreCase));
if (unknown) report.AppendLine($" {fn} <- {string.Join(", ", metas)}");
}
report.AppendLine(" (all functions used: " + string.Join(", ", f.Functions.Keys) + ")");
// VTank options against the option map / settings map / special options.
report.AppendLine("\n# VTank options");
var mm = new MetaManager(new LegacyUiSettings(), host, new PlayerVitalsCache());
var map = (Dictionary<string, string>)typeof(MetaManager).GetField("VtOptionMap", Any)!.GetValue(null)!;
var special = typeof(MetaManager).GetMethod("IsSpecialVtOption", Any)!;
var settings = mm.Expressions.BuildSettingsMapPublic();
var settingsCi = new HashSet<string>(settings.Keys, StringComparer.OrdinalIgnoreCase);
foreach (var (opt, metas) in f.Options)
{
bool known = map.ContainsKey(opt) || settingsCi.Contains(opt) || (bool)special.Invoke(null, new object[] { opt })!;
report.AppendLine($" [{(known ? "ok" : "NOT MAPPED")}] {opt}{(map.TryGetValue(opt, out string? ra) ? " -> " + ra : "")} <- {string.Join(", ", metas)}");
}
// The same VTank values set two ways: '/vt opt set' and the vtsetsetting[] expression.
report.AppendLine("\n# /vt opt set vs vtsetsetting[] (VTank units in, RynthAi setting out)");
foreach (var (opt, val) in new[] { ("AttackDistance", "0.025"), ("ApproachDistance", "0.0208333"), ("NavCloseStopRange", "0.00625"), ("PetCustomRange", "0.0625"), ("LootOnlyRareCorpses", "1") })
{
var s1 = new LegacyUiSettings(); var m1 = new MetaManager(s1, host, new PlayerVitalsCache());
m1.TryHandleVtCommand($"/vt opt set {opt} {val}");
var s2 = new LegacyUiSettings(); var m2 = new MetaManager(s2, host, new PlayerVitalsCache());
m2.Expressions.Evaluate($"vtsetsetting[{opt},`{val}`]");
string Read(MetaManager mm2) => (string?)typeof(MetaManager).GetMethod("GetVtOption", Any)!.Invoke(mm2, new object[] { opt }) ?? "(null)";
report.AppendLine($" {opt}={val}: /vt opt set -> {Read(m1)} vtsetsetting -> {Read(m2)} (MonsterRange {s1.MonsterRange} vs {s2.MonsterRange}, ApproachRange {s1.ApproachRange} vs {s2.ApproachRange}, CustomPetRange {s1.CustomPetRange} vs {s2.CustomPetRange})");
}
report.AppendLine("\n# Rule kinds used");
foreach (var (k, metas) in f.Kinds) report.AppendLine($" {k} <- {string.Join(", ", metas)}");
report.AppendLine("\n# States set or called but not defined");
foreach (var (st, metas) in f.States)
foreach (string meta in metas)
if (definedStates.TryGetValue(meta, out var defined) && !defined.Contains(st)) report.AppendLine($" {meta}: '{st}'");
string outPath = Path.Combine(Path.GetTempPath(), "meta_audit.txt");
File.WriteAllText(outPath, report.ToString());
Console.WriteLine(" audit report: " + outPath);
Check.True(true, "audit ran");
}
private static void Walk(MetaRule r, string meta, Found f)
{
f.Add(f.Kinds, "if " + r.Condition, meta);
if (r.Condition == MetaConditionType.Expression) Expr(r.ConditionData, meta, f);
foreach (MetaRule c in r.Children) WalkCondition(c, meta, f);
Action(r, meta, f);
}
private static void WalkCondition(MetaRule c, string meta, Found f)
{
f.Add(f.Kinds, "if " + c.Condition, meta);
if (c.Condition == MetaConditionType.Expression) Expr(c.ConditionData, meta, f);
foreach (MetaRule cc in c.Children) WalkCondition(cc, meta, f);
}
private static void Action(MetaRule r, string meta, Found f)
{
f.Add(f.Kinds, "do " + r.Action, meta);
string d = r.ActionData ?? "";
switch (r.Action)
{
case MetaActionType.ChatCommand:
foreach (string line in d.Split('\n', StringSplitOptions.RemoveEmptyEntries))
{
string cmd = line.Trim();
f.Add(f.Commands, cmd, meta);
Match om = Regex.Match(cmd, @"^/vt\s+opt\s+(?:set|get)\s+(\S+)", RegexOptions.IgnoreCase);
if (om.Success) f.Add(f.Options, om.Groups[1].Value, meta);
}
break;
case MetaActionType.ExpressionAction:
case MetaActionType.ChatExpression:
Expr(d, meta, f);
break;
case MetaActionType.SetRAOption:
{ string[] p = d.Split(';', 2); f.Add(f.Options, p[0].Trim(), meta); if (p.Length > 1) Expr(p[1], meta, f); }
break;
case MetaActionType.GetRAOption:
{ string[] p = d.Split(';'); if (p.Length > 1) f.Add(f.Options, p[1].Trim(), meta); }
break;
case MetaActionType.SetMetaState:
case MetaActionType.CallMetaState:
f.Add(f.States, d.Split(';')[0].Trim(), meta);
if (r.CallReturnState.Length > 0) f.Add(f.States, r.CallReturnState, meta);
break;
}
foreach (MetaRule c in r.ActionChildren) Action(c, meta, f);
}
private static void Expr(string? text, string meta, Found f)
{
if (string.IsNullOrWhiteSpace(text)) return;
foreach (Match m in FnRx.Matches(text)) f.Add(f.Functions, m.Groups[1].Value.ToLowerInvariant(), meta);
string plain = text.Replace("\\/", "/").Replace("\\", "");
foreach (Match m in CmdInExprRx.Matches(plain)) f.Add(f.Commands, m.Value.Trim() + " (in an expression)", meta);
foreach (Match m in OptFnRx.Matches(text)) f.Add(f.Options, m.Groups[2].Value, meta);
Match setopt = Regex.Match(plain, @"/vt\s+opt\s+set\s+([A-Za-z0-9_]+)", RegexOptions.IgnoreCase);
if (setopt.Success) f.Add(f.Options, setopt.Groups[1].Value, meta);
}
/// <summary>A RynthAi plugin wired enough to run its /mt and /ub dispatchers, plus a meta manager for /vt.</summary>
private sealed class PluginWorld
{
public readonly RynthAiPlugin P = new();
public readonly MetaManager M;
public readonly HashSet<string> RaVerbs;
public PluginWorld()
{
FakeHost.Reset();
FakeHost.PluginCommandCalls = true;
FakeHost.Create(playerId: 0x50000F99);
typeof(RynthPluginBase).GetMethod("Attach", Any)!.Invoke(P, new object[] { FakeHost.LastApi });
var s = new LegacyUiSettings();
var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer));
typeof(LegacyDashboardRenderer).GetField("_settings", Any)!.SetValue(dash, s);
Set("_dashboard", dash);
Set("_initialized", true);
Set("_loginComplete", true);
M = new MetaManager(s, FakeHost.Create(playerId: 0x50000F99), new PlayerVitalsCache());
M.SetRaCommandHandler(_ => { });
RaVerbs = ReadRaVerbs();
}
private void Set(string n, object? v) => typeof(RynthAiPlugin).GetField(n, Any)!.SetValue(P, v);
public bool Meta(string cmd) => (bool)typeof(RynthAiPlugin).GetMethod("HandleMetaChatCommand", Any)!.Invoke(P, new object[] { cmd })!;
/// <summary>The /ra verbs: the case labels of DispatchRaCommand's switch (unknown ones are ignored silently).</summary>
private static HashSet<string> ReadRaVerbs()
{
var verbs = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
string? root = AppContext.BaseDirectory;
while (root != null && !Directory.Exists(Path.Combine(root, "Plugins"))) root = Path.GetDirectoryName(root);
if (root == null) return verbs;
string src = File.ReadAllText(Path.Combine(root, "Plugins", "RynthCore.Plugin.RynthAi", "RynthAiPlugin.cs"));
int a = src.IndexOf("private void DispatchRaCommand(", StringComparison.Ordinal);
int b = a >= 0 ? src.IndexOf("\n }\n", a, StringComparison.Ordinal) : -1;
string body = a >= 0 ? src.Substring(a, (b > a ? b : src.Length) - a) : "";
foreach (Match m in Regex.Matches(body, "case \"([a-z0-9_]+)\"")) verbs.Add(m.Groups[1].Value);
return verbs;
}
}
private static string Classify(string cmd, PluginWorld w)
{
// A command an expression builds: its arguments only exist at run time, so only the
// verb was captured; running it bare says nothing.
if (cmd.EndsWith("(in an expression)", StringComparison.Ordinal)) return "built at run time (verb only)";
string c = cmd.Trim();
if (!c.StartsWith("/") && !c.StartsWith("@")) return "say (plain chat)";
string[] parts = c.Split(' ', StringSplitOptions.RemoveEmptyEntries);
string prefix = parts[0].ToLowerInvariant();
string verb = parts.Length > 1 ? parts[1].ToLowerInvariant() : "";
try
{
switch (prefix)
{
case "/vt":
return w.M.TryHandleVtCommand(c) ? "vt ok" : "VT NOT HANDLED";
case "/mt":
case "/ub":
int chat = FakeHost.Chat.Count;
bool ok = w.Meta(c);
bool noop = FakeHost.Chat.Skip(chat).Any(l => l.Contains("no RynthAi equivalent"));
if (prefix == "/ub" && (bool)typeof(RynthAiPlugin).GetMethod("IsUbRythaiCommand", Any)!.Invoke(null, new object[] { verb, parts.Length > 2 ? string.Join(" ", parts, 2, parts.Length - 2) : "" })!)
return "ub-Rythai";
return !ok ? prefix.ToUpperInvariant().TrimStart('/') + " NOT HANDLED" : noop ? "accepted no-op" : prefix.TrimStart('/') + " ok";
case "/ra":
return w.RaVerbs.Contains(verb) || verb.StartsWith("jump") ? "ra ok" : "RA verb not in DispatchRaCommand (may be a hotkey verb)";
default:
return "game/server";
}
}
catch (Exception ex) { return "THREW " + (ex.InnerException ?? ex).GetType().Name + ": " + (ex.InnerException ?? ex).Message; }
}
}

View file

@ -0,0 +1,146 @@
using System;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using RynthCore.Plugin.RynthAi;
using RynthCore.Plugin.RynthAi.LegacyUi;
using RynthCore.Plugin.RynthAi.Meta;
using RynthCore.PluginCore;
using RynthCore.RynthAiHostTests.Fakes;
using RynthCore.RynthAiTests.Harness;
namespace RynthCore.RynthAiHostTests.Tests;
// What the sample metas (meta samples: PistolPete, S_Bulb/Caul/Colo/CountPhainor/Cows/Deewain,
// Willow; audited 2026-10-18 with MetaAuditTests) needed that RynthAi didn't do.
internal static class MetaSampleCompatTests
{
private const BindingFlags Any = BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public;
public static void Register(Runner r)
{
r.Add("meta samples: vtsetsetting[] takes VTank distances like /vt opt set (6 yd, not the 50 yd default)", VtSetSettingDistances);
r.Add("meta samples: the options they set map to RynthAi settings (pet range, blacklist, rebuff, auto attack power)", MappedOptions);
r.Add("meta samples: /vt deletemonster is accepted", DeleteMonster);
r.Add("meta samples: /ub close corpse closes the open corpse", UbCloseCorpse);
r.Add("meta samples: /ub <expression> is evaluated (the /ub bc vtsetmetastate[] broadcast)", UbExpression);
r.Add("meta samples: /mt face and /ub face take decimals and coordinates, and hold nav while turning", Face);
}
private static (LegacyUiSettings S, MetaManager M) Meta()
{
FakeHost.Reset();
var s = new LegacyUiSettings();
var m = new MetaManager(s, FakeHost.Create(), new PlayerVitalsCache());
m.SetRaCommandHandler(_ => { });
return (s, m);
}
private static void VtSetSettingDistances()
{
var (s, m) = Meta();
m.Expressions.Evaluate("vtsetsetting[AttackDistance,`0.025`]");
Check.Eq(s.MonsterRange, 6, "vtsetsetting AttackDistance 0.025 = 6 yd (was left at 50)");
m.Expressions.Evaluate("vtsetsetting[ApproachDistance,`0.0208333`]");
Check.Eq(s.ApproachRange, 5, "ApproachDistance 0.0208333 = 5 yd");
Check.Eq(m.Expressions.Evaluate("vtgetsetting[AttackDistance]"), "0.025", "vtgetsetting reads it back in VTank units");
m.TryHandleVtCommand("/vt opt set AttackDistance 0.2166");
Check.Eq(s.MonsterRange, 52, "/vt opt set the same way");
m.Expressions.Evaluate("vtsetsetting[IdlePeaceMode,`1`]");
Check.True(s.PeaceModeWhenIdle, "a bool through vtsetsetting");
m.Expressions.Evaluate("rasetsetting[MonsterRange,`7`]");
Check.Eq(s.MonsterRange, 7, "rasetsetting keeps RynthAi's own names and units");
}
private static void MappedOptions()
{
var (s, m) = Meta();
m.Expressions.Evaluate("vtsetsetting[PetCustomRange,`0.0625`]");
Check.Eq(s.CustomPetRange, 15, "PetCustomRange 0.0625 = 15 yd");
m.Expressions.Evaluate("vtsetsetting[BlacklistMonsterTimeoutSeconds,`45`]");
Check.Eq(s.BlacklistTimeoutSec, 45, "BlacklistMonsterTimeoutSeconds");
m.TryHandleVtCommand("/vt opt set rebufftimeremainingseconds 4500");
Check.Eq(s.RebuffSecondsRemaining, 4500, "rebufftimeremainingseconds (VTank's spelling)");
// AutoAttackPower: on = automatic (-1); off = the attack bar's value.
m.TryHandleVtCommand("/vt setattackbar .9");
m.Expressions.Evaluate("vtsetsetting[AutoAttackPower,`1`]");
Check.True(s.MeleeAttackPower == -1 && s.MissileAttackPower == -1, "AutoAttackPower on: automatic");
Check.Eq(m.Expressions.Evaluate("vtgetsetting[AutoAttackPower]"), "true", "reads back on");
m.TryHandleVtCommand("/vt opt set autoattackpower false");
Check.True(s.MeleeAttackPower == 90 && s.MissileAttackPower == 90, "AutoAttackPower off: the bar's 90%");
}
private static void DeleteMonster()
{
var (_, m) = Meta();
Check.True(m.TryHandleVtCommand("/vt deletemonster"), "/vt deletemonster handled (not sent to AC as unknown)");
}
private sealed class World
{
public readonly RynthAiPlugin P = new();
public World(bool closeCalls = true)
{
FakeHost.Reset();
FakeHost.CloseContainerCalls = closeCalls;
FakeHost.Create(playerId: 0x50000F31);
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, new LegacyUiSettings());
Set("_dashboard", dash);
Set("_initialized", true);
Set("_loginComplete", true);
}
public void Set(string f, object? v) => typeof(RynthAiPlugin).GetField(f, Any)!.SetValue(P, v);
public bool Ub(string line) => (bool)typeof(RynthAiPlugin).GetMethod("HandleUbCommand", Any)!.Invoke(P, new object[] { line })!;
public bool Mt(string line) => (bool)typeof(RynthAiPlugin).GetMethod("HandleMtCommand", Any)!.Invoke(P, new object[] { line })!;
}
private static void UbCloseCorpse()
{
var w = new World();
Check.True(w.Ub("/ub close corpse"), "/ub close corpse handled with nothing open");
Check.True(FakeHost.Chat.Any(c => c.Contains("No container is currently open")), "and says so, as ub-IT");
FakeHost.GroundContainer = 0x80F00001;
w.Ub("/ub close corpse");
Check.True(FakeHost.Closes.Contains(0x80F00001), "closes the open container");
Check.False(FakeHost.Chat.Any(c => c.Contains("Unrecognized")), "never 'Unrecognized /ub command'");
}
private static void UbExpression()
{
var w = new World();
Check.True(w.Ub("/ub vtsetmetastate[NavigatingToFlowerTwo]"), "/ub <expression> handled");
Check.False(w.Ub("/ub notaverb x"), "a plain unknown verb is still unknown");
}
private static void Face()
{
var w = new World();
// No jumper (not logged in fully): one plain turn.
Check.True(w.Mt("/mt face 135.5"), "/mt face 135.5 (decimal)");
Check.True(Math.Abs(FakeHost.HeadingDeg - 135.5f) < 0.01f, "turned to 135.5");
Check.True(w.Ub("/ub face 450"), "/ub face 450");
Check.True(Math.Abs(FakeHost.HeadingDeg - 90f) < 0.01f, "450 wraps to 90");
// A coordinate: from 10N 10E, 20N 10E is due north and 10N 20E due east.
FakeHost.SetNavPosition(10, 10);
Check.True(w.Mt("/mt face 20N, 10E"), "/mt face <coords>");
Check.True(FakeHost.HeadingDeg < 0.5f || FakeHost.HeadingDeg > 359.5f, "north is 0");
Check.True(w.Ub("/ub face 10N 20E"), "/ub face <coords> (no comma)");
Check.True(Math.Abs(FakeHost.HeadingDeg - 90f) < 0.5f, "east is 90");
Check.False(w.Mt("/mt face somewhere"), "not a heading or a coordinate: not handled");
// With the jumper: nav is held while turning and given back once the heading is reached.
var s = new LegacyUiSettings { EnableNavigation = true };
var jumper = new Jumper(FakeHost.Create(playerId: 0x50000F31), s, _ => { });
w.Set("_jumper", jumper);
w.Mt("/mt face 200");
Check.False(s.EnableNavigation, "nav held while turning");
System.Threading.Thread.Sleep(120);
jumper.Tick();
Check.True(s.EnableNavigation, "nav back once facing 200");
Check.False(jumper.IsBusy, "and the jumper is free");
}
}

View file

@ -45,6 +45,7 @@ internal static class MetaTests
r.Add("meta: expression condition fails closed on errors", ExpressionCondition);
r.Add("meta: need-to-buff with no buff manager, unknown condition types", NeedToBuffAndUnknown);
r.Add("meta action: chat commands, /ra, /vt and /mt", ChatCommands);
r.Add("meta action: the /vt verbs and options the metas use that were missing (2026-10-17)", VtPortedVerbs);
r.Add("meta action: SetMetaState, CallMetaState and ReturnFromCall", CallReturn);
r.Add("meta action: All runs every child in order", AllAction);
r.Add("meta action: embedded nav route", EmbeddedNav);
@ -915,6 +916,90 @@ internal static class MetaTests
Check.Eq(reversed.S.ActiveNavIndex, 2, "index mirrored");
}
// /vt verbs and options found in ub-IT and the metas on disk (universalremote.met, SASocietyTasks.met,
// FoundryIzexi.met, DerethExploration (1).met) that RynthAi didn't handle.
private static void VtPortedVerbs()
{
FakeHost.Reset();
FakeHost.TapJumpCalls = true; // the engine's tap jump, for /vt tapjump
var rig = new Rig(FakeHost.Create(), Player);
// /vt e toggles the macro. Straight to the /vt handler: a meta doesn't run with the macro off.
rig.S.IsMacroRunning = false;
Check.True(rig.M.TryHandleVtCommand("/vt e") && rig.Ra.Contains("/ra start"), "/vt e with the macro off starts it");
rig.S.IsMacroRunning = true;
Check.True(rig.M.TryHandleVtCommand("/vt e") && rig.Ra.Contains("/ra stop"), "/vt e with the macro on stops it");
// /vt jump heading shift holdms -> /ra jump[s] heading hold; /vt tapjump -> the engine's tap jump.
RunAction(rig, A.ChatCommand, "/vt jump 90 true 750");
Check.True(rig.Ra.Contains("/ra jumps 90 750"), "/vt jump 90 true 750 -> /ra jumps 90 750");
RunAction(rig, A.ChatCommand, "/vt jump 180 false 300");
Check.True(rig.Ra.Contains("/ra jump 180 300"), "shift false -> /ra jump");
int taps = FakeHost.TapJumps;
RunAction(rig, A.ChatCommand, "/vt tapjump");
Check.Eq(FakeHost.TapJumps, taps + 1, "/vt tapjump");
// Settings profiles go to /ra settings; other /vt settings verbs are still swallowed.
RunAction(rig, A.ChatCommand, "/vt settings savechar Banes");
Check.True(rig.Ra.Contains("/ra settings savechar Banes"), "/vt settings savechar");
RunAction(rig, A.ChatCommand, "/vt settings loadchar Base Profile");
Check.True(rig.Ra.Contains("/ra settings loadchar Base Profile"), "/vt settings loadchar keeps spaces");
// looting load = loot load; equipitemsfor -> /ra equipfor.
RunAction(rig, A.ChatCommand, "/vt looting load NoSuchProfile.utl");
Check.True(FakeHost.Chat.Any(c => c.Contains("Loot profile not found: NoSuchProfile.utl")), "/vt looting load is handled as loot load");
RunAction(rig, A.ChatCommand, "/vt equipitemsfor Pyre Skeleton");
Check.True(rig.Ra.Contains("/ra equipfor Pyre Skeleton"), "/vt equipitemsfor -> /ra equipfor");
// Distances: VTank landblock units (x240) -> yards; a value over 1 is already yards.
RunAction(rig, A.ChatCommand, "/vt opt set attackdistance .01666");
Check.Eq(rig.S.MonsterRange, 4, "attackdistance .01666 -> 4 yd (was dropped: an int setter refused the decimal)");
RunAction(rig, A.ChatCommand, "/vt opt set attackrange 0.04166");
Check.Eq(rig.S.MonsterRange, 10, "attackrange 0.04166 -> 10 yd");
RunAction(rig, A.ChatCommand, "/vt opt set approachdistance 0.0175");
Check.Eq(rig.S.ApproachRange, 4, "approachdistance 0.0175 -> 4 yd");
RunAction(rig, A.ChatCommand, "/vt opt set dooropenrange 0.005");
Check.Near(rig.S.OpenDoorRange, 1.2, 1e-3, "dooropenrange 0.005 -> 1.2 yd (was 0.005 yd)");
RunAction(rig, A.ChatCommand, "/vt opt set ringdistance 0.025");
Check.Eq(rig.S.RingRange, 6, "ringdistance 0.025 -> 6 yd");
RunAction(rig, A.ChatCommand, "/vt opt set corpseapproachrange-max 0.05");
Check.Near(rig.S.CorpseApproachRangeMax, 12, 1e-3, "corpseapproachrange-max 0.05 -> 12 yd");
RunAction(rig, A.ChatCommand, "/vt opt set minimumringtargets 3");
Check.Eq(rig.S.MinRingTargets, 3, "minimumringtargets");
RunAction(rig, A.ChatCommand, "/vt opt set attackdistance 25");
Check.Eq(rig.S.MonsterRange, 25, "a value over 1 is yards already");
// An option written as a verb (DerethExploration: /vt navclosestoprange 0.005).
RunAction(rig, A.ChatCommand, "/vt navclosestoprange 0.005");
Check.Near(rig.S.FollowNavMin, 1.2, 1e-3, "/vt navclosestoprange 0.005 -> nav point reach 1.2 yd");
RunAction(rig, A.ChatCommand, "/vt opt set navclosetoprange .00625");
Check.Near(rig.S.FollowNavMin, 1.5, 1e-3, "the misspelt navclosetoprange too");
// Options whose value means something else in RynthAi.
RunAction(rig, A.ChatCommand, "/vt opt set defaultmeleeattackheight 3");
Check.Eq(rig.S.MeleeAttackHeight, 2, "VTank height 3 (high) -> RynthAi 2");
RunAction(rig, A.ChatCommand, "/vt opt set defaultmeleeattackheight 2");
Check.Eq(rig.S.MeleeAttackHeight, 1, "VTank height 2 (medium) -> RynthAi 1");
rig.S.LootOwnership = 0;
RunAction(rig, A.ChatCommand, "/vt opt set lootfellowcorpses true");
Check.Eq(rig.S.LootOwnership, 1, "lootfellowcorpses -> fellowship kills");
RunAction(rig, A.ChatCommand, "/vt opt set lootallcorpses true");
Check.Eq(rig.S.LootOwnership, 2, "lootallcorpses -> all corpses");
RunAction(rig, A.ChatCommand, "/vt opt set lootallcorpses false");
Check.Eq(rig.S.LootOwnership, 0, "lootallcorpses false -> my kills");
RunAction(rig, A.ChatCommand, "/vt opt set usearcs 3");
Check.True(rig.S.UseArcs, "usearcs 3 -> on");
RunAction(rig, A.ChatCommand, "/vt opt set usearcs 0");
Check.False(rig.S.UseArcs, "usearcs 0 -> off");
RunAction(rig, A.ChatCommand, "/vt opt set minimumhealkitsuccesschance 55");
Check.Eq(rig.S.KitMinSuccessPct, 55, "minimumhealkitsuccesschance 55 %");
RunAction(rig, A.ChatCommand, "/vt opt set minimumhealkitsuccesschance 0.8");
Check.Eq(rig.S.KitMinSuccessPct, 80, "a fraction is scaled to a percent");
RunAction(rig, A.ChatCommand, "/vt opt set defaultmeleeattackheight 3");
RunAction(rig, A.ChatCommand, "/vt opt get defaultmeleeattackheight");
Check.True(FakeHost.Chat.Any(c => c.Contains("defaultmeleeattackheight = 3")), "read back in VTank's own 1-3");
}
private static void CallReturn()
{
var rig = new Rig(rules: new[]

View file

@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Text.Json;
using RynthCore.Plugin.RynthAi;
using RynthCore.Plugin.RynthAi.Huds;
using RynthCore.Plugin.RynthAi.LegacyUi;
using RynthCore.Plugin.RynthAi.MiniRemote;
using RynthCore.Plugin.Shared;
@ -126,20 +127,22 @@ internal static class MiniRemoteMoveTests
Check.True(c.HandleCommand("pets", new[] { "show" }), "pets show");
Check.True(FakeHost.Chat.Any(x => x.Contains("tab pets:show")), "same tab");
FakeHost.Chat.Clear();
// The Pets tab's Breeding sub-tab is RynthILT's (Infinite Leaftide only): without RynthILT there is none.
Check.False(c.Pets.BreedingOffered, "no Breeding sub-tab without RynthILT");
Check.True(c.HandleCommand("hub", new[] { "open", "breeding" }), "hub open breeding is answered");
Check.True(FakeHost.Chat.Any(x => x.Contains(IltClient.NotLoaded)), "it says RynthILT is needed");
Check.False(FakeHost.Chat.Any(x => x.Contains("tab pets:")), "and opens nothing");
Check.False(SelectBreedingPending(c.Pets), "no Breeding sub-tab request");
// RynthOracle's Pet Breeding tab links back here: the Pets tab, on its Breeding sub-tab.
Check.False(SelectBreedingPending(c.Pets), "no Breeding sub-tab request yet");
Check.True(c.HandleCommand("hub", new[] { "open", "breeding" }), "hub open breeding");
Check.True(FakeHost.Chat.Any(x => x.Contains("tab pets:show")), "shows the Pets tab");
Check.True(SelectBreedingPending(c.Pets), "and asks for the Breeding sub-tab on the next frame");
SelectBreedingPending(c.Pets) = false;
FakeHost.Chat.Clear();
Check.True(c.HandleCommand("hub", new[] { "tab", "Breed" }), "hub tab breed (the dashboard)");
Check.False(FakeHost.Chat.Any(), "tab switches quietly");
Check.False(SelectBreedingPending(c.Pets), "still no Breeding sub-tab request without RynthILT");
Check.True(c.HandleCommand("hub", new[] { "tab", "Breed" }), "hub tab breed");
Check.False(FakeHost.Chat.Any(), "tab selects quietly");
Check.True(SelectBreedingPending(c.Pets), "the Breeding sub-tab again");
Check.Eq(MovedTabs.OracleBreeding, "/ro breeding", "the Character menu's Pet Breeding opens RynthOracle's tab");
Check.Eq(MovedTabs.HomeOf(MovedTabs.OracleBreeding), "RynthOracle's Pet Breeding tab", "and names it");
FakeHost.Chat.Clear();
Check.True(c.HandleCommand("hub", new[] { "bank" }), "hub bank is handled (answered)");
Check.True(FakeHost.Chat.Any(x => x.Contains("RynthILT")), "it says the ILT verbs come with RynthILT");
Check.True(FakeHost.Chat.Any(x => x.Contains("/ra hub open pets|crafting [show|hide|toggle] /ra hub open breeding")), "and lists what RynthAi still has");
Check.True(FakeHost.Chat.Any(x => x.Contains("/ra hub open pets|breeding|crafting")), "and lists what RynthAi still has");
FakeHost.Chat.Clear();
// The Quests tab moved to RynthOracle (2026-10-13): its verbs and tab names say so.
Check.True(c.HandleCommand("hub", new[] { "open", "quests" }), "hub open quests is answered");

View file

@ -0,0 +1,182 @@
using System;
using System.Linq;
using System.Reflection;
using RynthCore.Plugin.RynthAi;
using RynthCore.Plugin.RynthAi.LegacyUi;
using RynthCore.Plugin.Shared;
using RynthCore.PluginSdk;
using RynthCore.RynthAiHostTests.Fakes;
using RynthCore.RynthAiTests.Harness;
namespace RynthCore.RynthAiHostTests.Tests;
// Silentkelpie, 2026-10-15: with Missile Crafting on, combat swapped Electric Bow + arrows for
// Fire Crossbow + quarrels, and crafting kept wielding 'Infinite Deadly Prismatic Arrow' every
// 5 s (784 tries in one session). The stowed bow still read wielded (the client keeps a stowed
// item's old wielder and slot), the crossbow in hand read slot 0, the server ignored each arrow
// wield, and every try stopped the nav route while it waited.
internal static class MissileCraftingTests
{
private const uint Player = 0x50000C01;
private const uint Crossbow = 0x80000601, Bow = 0x80000602, Quarrels = 0x80000603, Arrows = 0x80000604;
private const int MissileSlot = 0x00400000, AmmoSlot = 0x00800000;
public static void Register(Runner r)
{
r.Add("missile crafting: a stowed bow that still reads wielded is not the launcher (no arrows at a crossbow)", StowedBowNotLauncher);
r.Add("missile crafting: wielded quarrels are not taken for a bow launcher", AmmoNotLauncher);
r.Add("missile crafting: an ammo wield the server ignores backs off after 2 tries", IgnoredWieldBacksOff);
r.Add("missile crafting: a bow in hand with its arrows in the pack still gets them wielded", BowInHandArrowsInPack);
}
/// <summary>Kelpie's state at 13:36: crossbow and quarrels in hand (slot 0), bow and arrows in the main pack.</summary>
private static void StowedBowNotLauncher()
{
var cm = Rig(crossbowInHand: true);
Idle(cm);
Check.Eq(cm.State, MissileCraftingManager.CraftState.Idle, "crossbow with quarrels on: nothing to do");
Check.Eq(FakeHost.Uses.Count, 0, "no arrow wield");
Check.False(FakeHost.Logs.Any(l => l.Contains("MissileCraft: no")), "no evaluation logged");
}
/// <summary>The quarrels wielded at login (slot set, typed MissileWeapon) and no launcher readable.</summary>
private static void AmmoNotLauncher()
{
var cm = Rig(crossbowInHand: false, arrange: () =>
{
FakeHost.Containers.Remove(Bow); // no bow anywhere
FakeHost.Wielded.Remove(Bow);
FakeHost.Containers.Remove(Quarrels); // the quarrels on, the crossbow in the pack
FakeHost.Wielded[Quarrels] = AmmoSlot;
});
Idle(cm);
Check.Eq(cm.State, MissileCraftingManager.CraftState.Idle, "no launcher: crafting idles");
Check.Eq(FakeHost.Uses.Count, 0, "the quarrels never pass for a bow");
}
/// <summary>Bow in hand, arrows in the pack, and the server never puts them on.</summary>
private static void IgnoredWieldBacksOff()
{
var cm = BowRig();
for (int i = 0; i < 4; i++) Cycle(cm);
Check.Eq(FakeHost.Uses.Count(u => u == Arrows), 2, "two arrow wields, then no more");
Check.Eq(cm.State, MissileCraftingManager.CraftState.Idle, "crafting let go");
Check.True(FakeHost.Logs.Any(l => l.Contains("didn't wield") && l.Contains("2 tries")), "the back-off is logged");
Cycle(cm);
Check.Eq(FakeHost.Uses.Count(u => u == Arrows), 2, "inside the back-off: still two");
}
/// <summary>The fix must not stop crafting doing its job: no ammo on, the pack's arrows go on.</summary>
private static void BowInHandArrowsInPack()
{
var cm = BowRig();
Cycle(cm);
Check.Eq(FakeHost.Uses.LastOrDefault(), Arrows, "UseObject(arrows)");
Check.True(FakeHost.Logs.Any(l => l.Contains("MissileCraft: no Arrow") && l.Contains("'Longbow'")), "the launcher it saw is logged");
}
// ── The rig ─────────────────────────────────────────────────────────────
private static WorldObjectCache? _cache;
/// <param name="arrange">Changes to the fake world, made before the host and cache read it.</param>
private static MissileCraftingManager Rig(bool crossbowInHand, Action? arrange = null)
{
PaceOff();
FakeHost.Reset();
FakeHost.WeaponCalls = true; // UseObject, GetCurrentCombatMode
FakeHost.SalvageCalls = true; // GetObjectWielderInfo (answers from Wielded)
FakeHost.Names[Player] = "Silentkelpie";
Item(Crossbow, "Fire Crossbow", MissileSlot);
Item(Bow, "Electric Bow", MissileSlot);
Item(Quarrels, "Infinite Deadly Prismatic Quarrel", AmmoSlot);
Item(Arrows, "Infinite Deadly Prismatic Arrow", AmmoSlot);
// The pack listing holds only what is in the pack; the stowed bow's description still
// names the player and the missile slot.
FakeHost.Containers[Bow] = Player;
FakeHost.Containers[Arrows] = Player;
FakeHost.Wielded[Bow] = MissileSlot;
if (crossbowInHand)
{
FakeHost.Wielded[Crossbow] = 0; // wielded after login: slot reads 0
FakeHost.Wielded[Quarrels] = 0;
}
else
{
FakeHost.Containers[Crossbow] = Player;
FakeHost.Containers[Quarrels] = Player;
}
arrange?.Invoke();
var host = FakeHost.Create(Player);
_cache = FakeHost.MakeCache(host, Player, new[] { Crossbow, Bow, Quarrels, Arrows });
var cm = new MissileCraftingManager(host, new LegacyUiSettings { EnableMissileCrafting = true });
cm.SetObjectCache(_cache);
return cm;
}
/// <summary>A real bow in hand (slot set) with nothing in the ammo slot and arrows in the pack.</summary>
private static MissileCraftingManager BowRig() => Rig(crossbowInHand: false, arrange: () =>
{
FakeHost.Containers.Remove(Bow);
FakeHost.Names[Bow] = "Longbow";
});
private static void Item(uint id, string name, int validSlots)
{
FakeHost.Names[id] = name;
FakeHost.ItemTypes[id] = 0x100; // MissileWeapon, as the server types ammo too
FakeHost.Ints[(id, 9)] = validSlots;
}
private static readonly FieldInfo LastAmmoCheck =
typeof(MissileCraftingManager).GetField("_lastAmmoCheck", BindingFlags.Instance | BindingFlags.NonPublic)!;
private static readonly FieldInfo PhaseStart =
typeof(MissileCraftingManager).GetField("_phaseStart", BindingFlags.Instance | BindingFlags.NonPublic)!;
/// <summary>One idle tick with the 5 s ammo-check interval already passed.</summary>
private static void Idle(MissileCraftingManager cm)
{
LastAmmoCheck.SetValue(cm, DateTime.MinValue);
ForceRescan();
cm.ProcessCrafting();
}
/// <summary>One ammo check through to its wield (or its back-off), the clocks moved past each wait.</summary>
private static void Cycle(MissileCraftingManager cm)
{
for (int i = 0; i < 4 && (i == 0 || cm.State != MissileCraftingManager.CraftState.Idle); i++)
{
if (cm.State == MissileCraftingManager.CraftState.Idle)
{
// The back-off moves _lastAmmoCheck into the future; only an expired check is reset.
if ((DateTime)LastAmmoCheck.GetValue(cm)! <= DateTime.Now)
LastAmmoCheck.SetValue(cm, DateTime.MinValue);
}
else
{
PhaseStart.SetValue(cm, DateTime.Now.AddSeconds(-1)); // past EQUIP_DELAY_MS
}
ForceRescan();
cm.ProcessCrafting();
}
}
/// <summary>GetDirectInventory re-serves a scan under 1 s old; the test can't wait on the wall clock.</summary>
private static void ForceRescan() =>
typeof(WorldObjectCache).GetField("_lastDirectInventoryScan", BindingFlags.Instance | BindingFlags.NonPublic)!
.SetValue(_cache, DateTime.MinValue);
private static void PaceOff()
{
ActionPacer.Enabled = false;
ActionPacer.Reset();
ActionPacer.NowMs = () => Environment.TickCount64;
UseAudit.Reset("?", null);
UseAudit.NowMs = () => Environment.TickCount64;
MoveAudit.Reset();
MoveAudit.NowMs = () => Environment.TickCount64;
}
}

View file

@ -45,6 +45,7 @@ internal static class MonsterEditorTests
GravityWell = true, Imperil = true, Yield = true, Vuln = true, UseArc = true, UseRing = true,
UseStreak = true, UseBolt = false, UseBlast = true, UseWall = true, ExVuln = "Fire", OffhandId = 2,
PetDamage = "Cold", CustomDebuffs = "Corrosion Vulnerability Other, Fire Vulnerability Other VII",
Kite = "PullAway",
},
new PluginRule { Name = "", Category = "Expression only", MatchExpression = "wobjectfindnearestbytemplatetype[1]" },
};

View file

@ -0,0 +1,56 @@
using RynthCore.Plugin.RynthAi.MiniRemote;
using RynthCore.RynthAiTests.Harness;
namespace RynthCore.RynthAiHostTests.Tests;
// Pets roster tint (2026-10-12): every essence showed white because ILT essences mostly carry
// neither the captured damage type (9054) nor DamageType (45). As UB-ILT (PetDamageTypeTintPolicy,
// v2.0.1119), the essence name gives the school then, and an elemental name beats a physical-only
// 9054 (ILT reuses that id for the min-summon aug, where 1/2/4 read as Slash/Pierce/Bludgeon).
internal static class PetDamageTintTests
{
public static void Register(Runner r)
{
r.Add("pet tint: the school comes from the properties, else the essence name (UB-ILT v2.0.1119)", PickSchool);
r.Add("pet tint: the palette is UB-ILT's Leaftide damage-type colours", Palette);
}
private static void PickSchool()
{
string N(int captured, int mask, string name) => PetDamageTint.Name(PetDamageTint.PickPetFlag(captured, mask, name));
Check.Eq(N(0, 0, "Fire Banshee Essence (300)"), "Fire", "no properties: the name says Fire");
Check.Eq(N(0, 0, "Acid Phyntos Swarm Essence (250)"), "Acid", "Acid");
Check.Eq(N(0, 0, "Blizzard Wisp Essence (250)"), "Cold", "a Blizzard is Cold");
Check.Eq(N(0, 0, "Incendiary Knight Essence"), "Fire", "an ILT synonym");
Check.Eq(N(0, 0, "Shocked Grievver Essence"), "Lightning", "Lightning synonym");
Check.Eq(N(0, 0, "Novice Essence"), "", "'ice' inside a word doesn't count");
Check.Eq(N(0, 0, "Tremendous Monouga Essence"), "", "no school in the name: unknown");
Check.Eq(N(1024, 0, "Fire Banshee Essence"), "Nether", "an elemental 9054 wins over the name");
Check.Eq(N(1, 0, "Fire Banshee Essence"), "Fire", "a physical-only 9054 loses to an elemental name");
Check.Eq(N(4, 0, "Monouga Essence"), "Bludgeon", "... but stands when the name says nothing");
Check.Eq(N(0, 32, ""), "Acid", "the DamageType mask when 9054 is missing");
Check.Eq(N(0, 1024 | 1, ""), "Nether", "a combined mask: elements before physical");
Check.Eq(N(0, 3, ""), "Slash/Pierce", "Slash/Pierce is its own school");
}
private static void Palette()
{
static void Rgb(string school, int r, int g, int b)
{
var c = PetDamageTint.ForName(school);
Check.Near(c.X, r / 255f, 1e-4, school + " red");
Check.Near(c.Y, g / 255f, 1e-4, school + " green");
Check.Near(c.Z, b / 255f, 1e-4, school + " blue");
}
Rgb("Slash", 255, 180, 120);
Rgb("Pierce", 240, 200, 140);
Rgb("Bludgeon", 220, 190, 140);
Rgb("Cold", 160, 210, 255);
Rgb("Fire", 255, 130, 70);
Rgb("Acid", 160, 255, 140);
Rgb("Lightning", 255, 240, 120);
Rgb("Nether", 200, 160, 255);
Check.Eq(PetDamageTint.ForName(""), PetDamageTint.Unknown, "unknown: white");
}
}

View file

@ -0,0 +1,186 @@
using System;
using System.Collections.Generic;
using System.Linq;
using RynthCore.Plugin.RynthAi;
using RynthCore.Plugin.RynthAi.LegacyUi;
using RynthCore.RynthAiHostTests.Fakes;
using RynthCore.RynthAiTests.Harness;
namespace RynthCore.RynthAiHostTests.Tests;
// Empyrean Handler lethal-ring escape (2026-10-17). Silentkelpie heard the Handler's channel at
// 1.7 m, did the old single back-jump (backwards, after a 150 ms turn settle that hadn't taken),
// was still 1.5 m from it 1.6 s later and died 3.2 s after the line. The escape now faces
// directly away and runs, re-aiming away from the Handler, until outside the ring plus a margin,
// then holds attacks until the ring has gone off (running again if the Handler closes back in).
internal static class RingEscapeTests
{
private const uint Player = 0x50000E21;
private const uint Handler = 0x80000E31;
private const uint Lb = 0xA9B40000;
private const string Channel = "The handler briefly channels infused Empyrean hatred to release a lethal ring.";
private const int Emote = 0x0C;
public static void Register(Runner r)
{
r.Add("handler ring: the channel inside the ring runs away (faces away, autorun on), no back-jump", RunsAway);
r.Add("handler ring: outside the ring + margin the run stops, attacks stay held until the ring has gone off", StopsWhenClear);
r.Add("handler ring: the Handler closing back in before the ring goes off starts the run again", RunsAgain);
r.Add("handler ring: outside the ring at the channel nothing happens", OutsideStaysPut);
r.Add("handler ring: death / macro stop ends the run (autorun off, never carried through the portal)", StopEndsRun);
r.Add("handler ring: a player quoting the line in chat doesn't trigger it", PlayerQuoteIgnored);
r.Add("chaser ring: an Empyrean Chaser's lethal ring runs away from the Chaser too", ChaserRunsAway);
r.Add("chaser ring: 'The chaser ...' flees the Chaser even with a Handler nearer", ChaserNamedWins);
r.Add("ring: a line naming no caster flees the nearest Handler or Chaser; the line is logged once", NearestCasterWithoutSubject);
}
private const uint Chaser = 0x80000E32;
private static CombatManager Rig(float handlerNorthMeters, out LegacyUiSettings s, float? chaserSouthMeters = null)
{
FakeHost.Reset();
Place(Player, "Silentkelpie", 96, 96, creature: false);
FakeHost.PlayerPose = (Lb | 0x1C, 96f, 96f, 0f);
Place(Handler, "Empyrean Handler", 96, 96 + handlerNorthMeters);
var ids = new List<uint> { Handler };
if (chaserSouthMeters is float cs)
{
Place(Chaser, "Empyrean Chaser", 96, 96 - cs);
ids.Add(Chaser);
}
s = new LegacyUiSettings { MonsterRange = 60, EnableCombat = true, IsMacroRunning = true };
// The escape measures from the player: the fake answers GetPlayerId only when created with it.
var host = FakeHost.Create(Player);
var cache = FakeHost.MakeCache(host, Player, ids.ToArray());
var c = new CombatManager(host, s, cache);
c.SetPlayerId(Player);
c.SetDamageStores(null, new RynthCore.Plugin.RynthAi.CreatureData.MonsterDamageStore());
c.ScanNearbyTargets();
c.HandleCombatTrigger();
return c;
}
private static void RunsAway()
{
var c = Rig(1.7f, out _);
bool jumped = false;
c.RequestBackJump = (_, _) => { jumped = true; return true; };
c.HandleChatForRingEvade(Channel, Emote);
Check.True(FakeHost.AutoRun, "autorun is on");
Check.False(jumped, "the old back-jump isn't used when autorun and turning are there");
// The Handler is due north (0°): away is south (180°).
Check.True(Math.Abs(FakeHost.HeadingDeg - 180.0) < 1.0, $"faces directly away from the Handler (180°, got {FakeHost.HeadingDeg:0})");
Check.True(c.RingEvadeActive, "the evade holds combat");
Check.True(FakeHost.Logs.Any(l => l.Contains("[CombatEvade]") && l.Contains("running away")), "logged as a run");
Check.True(c.Think(), "Think is held while running");
Check.Eq(c.LastCombatSkipReason, "handler-ring-run", "skip reason: the run");
Check.True(FakeHost.AutoRun, "still running inside the ring");
}
private static void StopsWhenClear()
{
var c = Rig(1.7f, out _);
c.HandleChatForRingEvade(Channel, Emote);
MovePlayer(96, 96 - 16); // 17.7 m from the Handler: past the 12 m ring + 4 m margin
Check.True(c.Think(), "Think still held right after reaching safety (the ring hasn't gone off)");
Check.False(FakeHost.AutoRun, "the run stops outside the ring");
Check.Eq(c.LastCombatSkipReason, "handler-ring-wait", "now waiting for the ring");
Check.True(FakeHost.Logs.Any(l => l.Contains("Ring run stopped") && l.Contains("outside the ring")), "logged why it stopped");
Check.True(c.RingEvadeActive, "still holding attacks");
}
private static void RunsAgain()
{
var c = Rig(1.7f, out _);
c.HandleChatForRingEvade(Channel, Emote);
MovePlayer(96, 96 - 16);
c.Think();
Check.False(FakeHost.AutoRun, "stopped at a safe distance");
// The Handler follows back inside the ring before it has gone off.
FakeHost.Positions[Handler] = (Lb | 0x1C, 96f, 96f - 14f, 0f);
Check.True(c.Think(), "held");
Check.True(FakeHost.AutoRun, "running again");
Check.Eq(c.LastCombatSkipReason, "handler-ring-run", "back to the run");
Check.True(FakeHost.Logs.Any(l => l.Contains("back inside the ring")), "logged");
}
private static void OutsideStaysPut()
{
var c = Rig(20f, out _);
c.HandleChatForRingEvade(Channel, Emote);
Check.False(FakeHost.AutoRun, "no run at 20 m");
Check.False(c.RingEvadeActive, "combat isn't held");
Check.True(FakeHost.Logs.Any(l => l.Contains("staying put")), "logged as outside");
}
private static void StopEndsRun()
{
var c = Rig(1.7f, out _);
c.HandleChatForRingEvade(Channel, Emote);
Check.True(FakeHost.AutoRun, "running");
c.StopRingEscape("died");
Check.False(FakeHost.AutoRun, "autorun off");
Check.False(c.RingEvadeActive, "evade cleared");
Check.True(FakeHost.Logs.Any(l => l.Contains("Ring escape stopped: died")), "logged");
c.StopRingEscape("again");
Check.Eq(FakeHost.Logs.Count(l => l.Contains("Ring escape stopped")), 1, "a second stop is a no-op");
}
private static void PlayerQuoteIgnored()
{
var c = Rig(1.7f, out _);
c.HandleChatForRingEvade("Bob says, \"The handler briefly channels infused Empyrean hatred to release a lethal ring.\"", 0x02);
Check.False(FakeHost.AutoRun, "a player's quote doesn't start the run");
Check.False(c.RingEvadeActive, "combat isn't held");
}
private const string ChaserChannel = "The chaser briefly channels infused Empyrean hatred to release a lethal ring.";
private static void ChaserRunsAway()
{
// Handler far away (40 m north), a Chaser 2 m south: the Chaser's ring is the danger.
var c = Rig(40f, out _, chaserSouthMeters: 2f);
c.HandleChatForRingEvade(ChaserChannel, Emote);
Check.True(FakeHost.AutoRun, "running from the Chaser");
// The Chaser is due south (180°): away is north (0°).
Check.True(Math.Abs(((FakeHost.HeadingDeg % 360) + 360) % 360) < 1.0 || Math.Abs(FakeHost.HeadingDeg - 360) < 1.0,
$"faces away from the Chaser (0°, got {FakeHost.HeadingDeg:0})");
Check.True(FakeHost.Logs.Any(l => l.Contains("running away from 'Empyrean Chaser'")), "logged against the Chaser");
}
private static void ChaserNamedWins()
{
// Handler 1.5 m north, Chaser 3 m south; the emote names the Chaser.
var c = Rig(1.5f, out _, chaserSouthMeters: 3f);
c.HandleChatForRingEvade(ChaserChannel, Emote);
Check.True(FakeHost.Logs.Any(l => l.Contains("running away from 'Empyrean Chaser'")), "the named caster is the one fled");
Check.True(Math.Abs(FakeHost.HeadingDeg) < 1.0 || Math.Abs(FakeHost.HeadingDeg - 360) < 1.0, $"away from the Chaser (0°, got {FakeHost.HeadingDeg:0})");
}
private static void NearestCasterWithoutSubject()
{
// A line without "The handler/chaser" (a client that strips it): the nearest caster, the Chaser at 2 m.
var c = Rig(9f, out _, chaserSouthMeters: 2f);
c.HandleChatForRingEvade("briefly channels infused Empyrean hatred to release a lethal ring.", Emote);
Check.True(FakeHost.Logs.Any(l => l.Contains("running away from 'Empyrean Chaser'")), "the nearest caster (the Chaser)");
Check.Eq(FakeHost.Logs.Count(l => l.Contains("lethal-ring line heard")), 1, "the line that triggered is logged");
c.StopRingEscape("test");
c.HandleChatForRingEvade("briefly channels infused Empyrean hatred to release a lethal ring.", Emote);
Check.Eq(FakeHost.Logs.Count(l => l.Contains("lethal-ring line heard")), 1, "logged once per session");
}
private static void MovePlayer(float x, float y)
{
FakeHost.Positions[Player] = (Lb | 0x1C, x, y, 0f);
FakeHost.PlayerPose = (Lb | 0x1C, x, y, 0f);
}
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;
}
}

View file

@ -10,8 +10,7 @@ namespace RynthCore.RynthAiHostTests.Tests;
// Mini Remote sections (RynthCore 2026.10.5.46+): RynthCore sends its server verdicts (V lines) and
// section rail (X lines) in the "servermenu" payload, and reads RynthAi's views from
// RynthPluginGetSectionsJson. RynthAi lists its own views (Pets, Crafting, Spells, Fellowship) and
// hosts RynthILT's ILT tabs (RynthILT.Hub: Gear, Charms, Banking, Games); Quests are RynthOracle's,
// and RynthILT's Character tab moved out (RynthOracle's Character tab, Session Stats). The manifest is checked
// hosts RynthILT's ILT tabs (RynthILT.Hub); Quests are RynthOracle's. The manifest is checked
// against the engine's own parser and catalog (UI/Sections, linked), so the two sides can't drift.
internal static class SectionsTests
{
@ -22,20 +21,20 @@ internal static class SectionsTests
r.Add("sections: RynthAi's manifest passes the engine parser unchanged", ManifestRoundTrip);
r.Add("sections: the engine catalog places RynthAi's views by server", CatalogPlacement);
r.Add("sections: tab surfaces map back to their tabs; foreign ids are refused", SurfaceRoundTrip);
r.Add("sections: Character and Banking redirect; other ILT tabs stay on the Mini Remote", MovedTabRedirects);
r.Add("sections: Character / Charms / Banking redirect to RynthOracle and Global Inventory", MovedTabRedirects);
}
private static void MovedTabRedirects()
{
foreach (string tab in new[] { "character", "Char", " rates " })
foreach (string tab in new[] { "character", "Char", " rates ", "charms", "CHARM" })
Check.Eq(MovedTabs.CommandFor(tab), MovedTabs.OracleCharacter, tab + " -> RynthOracle's Character tab");
foreach (string tab in new[] { "banking", "bank" })
Check.Eq(MovedTabs.CommandFor(tab), MovedTabs.GlobalBank, tab + " -> Global Inventory");
foreach (string tab in new[] { "charms", "gear", "games", "pets", "crafting", "", null })
foreach (string tab in new[] { "banking", "Bank" })
Check.Eq(MovedTabs.CommandFor(tab), MovedTabs.GlobalBank, tab + " -> Global Inventory > Banking");
foreach (string tab in new[] { "gear", "games", "pets", "crafting", "", null })
Check.True(MovedTabs.CommandFor(tab) == null, (tab ?? "null") + " is still a Mini Remote tab (or none)");
Check.Eq(MovedTabs.OracleCharacter, "/ro character", "the Oracle command");
Check.Eq(MovedTabs.GlobalBank, "/ginv bank", "the Global Inventory banking alias");
Check.Eq(MovedTabs.GlobalInventory, "/ginv", "the Global Inventory command");
Check.Eq(MovedTabs.GlobalBank, "/ginv bank", "the Global Inventory command");
Check.Eq(MovedTabs.GlobalInventory, "/ginv", "the Global Inventory window command");
Check.Eq(MovedTabs.Diagnostics, "/rc diagnostics", "the engine's Diagnostics command");
}
@ -49,8 +48,8 @@ internal static class SectionsTests
/// <summary>
/// RynthILT's tabs as its GetTabs would give them (Gear not reported yet, Games hidden), plus the
/// Character tab an older RynthILT still reports: it moved out of the Mini Remote (2026-10-13)
/// and must not be placed any more.
/// Character / Charms / Banking tabs an older RynthILT still reports: those moved out of the Mini
/// Remote (2026-10-13) and must not be placed any more.
/// </summary>
private static readonly IltTabInfo[] IltTabs =
{
@ -128,12 +127,8 @@ internal static class SectionsTests
SectionContribution gear = m.Contributions.Single(c => c.Surface == SectionsManifest.SurfaceOf("gear"));
Check.False(gear.Enabled, "unavailable Gear is disabled");
Check.True(gear.Note.Length > 0, "with a note");
Check.False(views.Any(v => v.Surface == SectionsManifest.SurfaceOf("character")), "character moved out: not placed even if RynthILT reports it");
foreach (string kept in new[] { "charms", "banking" })
{
SectionsManifest.View v = views.Single(x => x.Surface == SectionsManifest.SurfaceOf(kept));
Check.True(v.Section == "inventory" && v.Server == SectionsManifest.IltServer && v.Enabled, kept + ": an ILT view in Inventory");
}
foreach (string moved in new[] { "character", "charms", "banking" })
Check.False(views.Any(v => v.Surface == SectionsManifest.SurfaceOf(moved)), moved + " moved out: not placed even if RynthILT reports it");
Check.True(json.Length < SectionManifestParser.MaxJsonLength / 16, "small");
SectionsManifest.View session = views.Single(v => v.Surface == SectionsManifest.SessionSurface);
@ -168,26 +163,24 @@ internal static class SectionsTests
List<SectionView> on = SectionCatalog.Build(new[] { m }, _ => false, new[] { iltOn });
SectionView charOn = on.Single(v => v.Id == "char");
Check.True(charOn.Panes.Length == 1 && charOn.Panes[0].Contribution?.Surface == SectionsManifest.SessionSurface,
"Session Stats on ILT: session stats only (no ILT Character tab)");
"Session Stats on ILT: session stats only (no ILT Character / Charms)");
SectionView inventoryOn = on.Single(v => v.Id == "inventory");
Check.True(inventoryOn.Panes.Any(p => p.Title == "Gear") && inventoryOn.Panes.Any(p => p.Title == "Charms")
&& inventoryOn.Panes.Any(p => p.Title == "Banking"),
"Inventory on ILT: RynthILT's Gear, Charms and Banking");
SectionView inventoryOff = off.Single(v => v.Id == "inventory");
Check.False(inventoryOff.Panes.Any(p => p.Title is "Gear" or "Charms" or "Banking"), "Inventory off ILT: none of RynthILT's tabs");
Check.True(inventoryOn.Panes.Any(p => p.Title == "Gear") && !inventoryOn.Panes.Any(p => p.Title == "Banking"),
"Inventory: Gear on ILT; Banking is Global Inventory's");
Check.True(on.Single(v => v.Id == "spells").Panes.Any(p => p.Contribution?.Surface == SectionsManifest.SpellsSurface), "Spells");
Check.True(on.Single(v => v.Id == "fellowship").Panes.Any(p => p.Contribution?.Surface == SectionsManifest.FellowshipSurface), "Fellowship");
}
private static void SurfaceRoundTrip()
{
foreach (string id in new[] { "gear", "games", "charms", "banking" })
foreach (string id in new[] { "gear", "games" })
{
string surface = SectionsManifest.SurfaceOf(id);
Check.True(SectionsManifest.TryIltTabOf(surface, out string back) && back == id, "round trip " + surface);
Check.Eq(SectionManifestParser.Surface(surface), surface, "the engine accepts " + surface);
}
Check.False(SectionsManifest.TryIltTabOf(SectionsManifest.SurfaceOf("character"), out _), "character isn't a section tab any more");
foreach (string moved in new[] { "character", "charms", "banking" })
Check.False(SectionsManifest.TryIltTabOf(SectionsManifest.SurfaceOf(moved), out _), moved + " isn't a section tab any more");
Check.Eq(SectionManifestParser.Surface(SectionsManifest.SessionSurface), SectionsManifest.SessionSurface, "the engine accepts the session surface");
Check.True(SectionsManifest.TryOwnTabOf(SectionsManifest.PetsSurface, out string pets) && pets == MiniRemoteTabs.Pets, "pets is RynthAi's");
Check.True(SectionsManifest.TryOwnTabOf(SectionsManifest.CraftingSurface, out string craft) && craft == MiniRemoteTabs.Crafting, "crafting is RynthAi's");

View file

@ -4,18 +4,15 @@ using System.Linq;
using RynthCore.Loot;
using RynthCore.Plugin.RynthAi.MiniRemote;
using RynthCore.Plugin.RynthAi.MiniRemote.Crafting;
using RynthCore.Plugin.Shared;
using RynthCore.RynthAiTests.Harness;
namespace RynthCore.RynthAiHostTests.Tests;
// The Crafting tab's tinkering (SilentKelpie's, 2026-10-12): ACE's retail chance
// (RecipeManager.GetTinkerChance), the planner's caps and order (imbue once, rend last), bag
// matching / choice, and the universal Crafting tab id. Server rows come from the server plugin's
// profile ("salvage", ServerSalvageView) and carry their own rules, checked here on rows shaped
// like Infinite Leaftide's (RynthILT serves those; RynthILT.Tests checks its data): no tink slot,
// applied ints, stack groups (Steel + Serpentine 10), after-cap rows (Leather), an own order, and
// prepared rows (tier bags, Ammunition).
// The Crafting tab's tinkering (2026-10-12): ACE's retail chance (RecipeManager.GetTinkerChance),
// the planner's caps and order (imbue once, ILT no-slot salvage, Steel + Serpentine 10, Leather
// after the cap, rend last), bag matching / choice, and the universal Crafting tab id.
// Phase 2: ILT trinkets (flags 384-387, tier-prepared bags, Ammunition) and the Rings
// inscription chain (UB-IT's ingredient names, queue order and scroll pairing).
internal static class TinkerTests
{
public static void Register(Runner r)
@ -23,15 +20,18 @@ internal static class TinkerTests
r.Add("tinker: retail difficulty and chance (ACE GetTinkerChance)", Chance);
r.Add("tinker: slot cap, one imbue, attempts this run", SlotsAndImbue);
r.Add("tinker: damage-type rend and rend last", Rend);
r.Add("tinker: server weapon rows (no slot, an after-cap row last only when the slots are full)", AfterCap);
r.Add("tinker: server jewelry rows (applied ints skip, a stack group shares one cap)", StackAndApplied);
r.Add("tinker: ILT weapon rows (no slot, Leather after the cap)", IltWeapon);
r.Add("tinker: ILT jewelry flags and Steel + Serpentine cap", IltJewelry);
r.Add("tinker: item rows (Moonstone, Leather, Sandstone)", ItemRows);
r.Add("tinker: scan filters", Filters);
r.Add("tinker: bag matching (full, Abyssal, Foolproof)", Bags);
r.Add("tinker: bag choice by chance and minimum", BagChoice);
r.Add("tinker: Crafting is a universal Mini Remote tab", Section);
r.Add("tinker: prepared server rows (applied ints, order, tier bags, Ammunition)", Trinkets);
r.Add("tinker: a server plugin's salvage (per tab, own keys, own order, no rules unless asked)", PluginSalvage);
r.Add("tinker: ILT trinkets (flags, order, tier bags, Ammunition)", Trinkets);
r.Add("tinker: a server plugin's salvage (per tab, own keys, no Leaftide rules)", PluginSalvage);
r.Add("rings: ingredient names, alternates and excludes", RingIngredients);
r.Add("rings: craft queue runs Step 1, then 2, then 3", RingQueue);
r.Add("rings: scroll glyph and UB-IT pairing", RingScrolls);
}
private static TinkerBenchSettings Settings(params (string Key, int Count)[] counts)
@ -48,41 +48,6 @@ internal static class TinkerTests
private static List<int> Mats(List<TinkerStep> plan) => plan.Select(p => p.Material).ToList();
private static ServerSalvageView Row(string bench, int material, string kind, bool slot = false, string nameMatch = "",
int applied = 0, bool prepared = false, int order = 0, bool afterCap = false,
string group = "", int cap = 0)
=> new(bench, material, kind, "server row", slot, nameMatch, applied, prepared, order, afterCap, group, cap);
/// <summary>The tab's rows with these server rows (as the Crafting tab builds them).</summary>
private static List<TinkerMaterial> WithServer(TinkerBench bench, params ServerSalvageView[] server)
=> TinkerPlanner.Rows(bench, TinkerCatalog.FromServerPlugin(bench, server), null);
// ILT-shaped rows (RynthILT's Hub/IltSalvage.cs has the real ones).
private const int JewelSilverInt = 374, TrinketDiamondInt = 384, TrinketGromnieInt = 386;
private static readonly ServerSalvageView[] Weapon =
{
Row("melee", TinkerCatalog.YellowGarnet, "once", order: 70),
Row("melee", TinkerCatalog.BlackGarnet, "once", slot: true, nameMatch: "Abyssal", order: 100),
Row("melee", TinkerCatalog.Leather, "once", order: 995, afterCap: true),
};
private static readonly ServerSalvageView[] Jewelry =
{
Row("jewelry", TinkerCatalog.Silver, "once", applied: JewelSilverInt, order: 10),
Row("jewelry", TinkerCatalog.Copper, "once", applied: 370, order: 20),
Row("jewelry", TinkerCatalog.Serpentine, "tink", order: 50, group: "jewelry-stack", cap: 10),
Row("jewelry", TinkerCatalog.Steel, "tink", order: 60, group: "jewelry-stack", cap: 10),
};
private static readonly ServerSalvageView[] TrinketRows =
{
Row("trinkets", TinkerCatalog.Diamond, "once", applied: TrinketDiamondInt, prepared: true, order: 10),
Row("trinkets", TinkerCatalog.Ruby, "once", applied: 385, prepared: true, order: 20),
Row("trinkets", TinkerCatalog.GromnieHide, "once", applied: TrinketGromnieInt, prepared: true, order: 30),
Row("trinkets", TinkerCatalog.Pyreal, "once", applied: 387, prepared: true, order: 40),
};
/// <summary>A plan's materials as "a,b,c" (Check.Eq compares lists by reference).</summary>
private static string Seq(List<TinkerStep> plan) => string.Join(",", Mats(plan));
@ -109,7 +74,7 @@ internal static class TinkerTests
private static void SlotsAndImbue()
{
var rows = TinkerPlanner.Rows(TinkerBench.Melee, null, null);
var rows = TinkerPlanner.Rows(TinkerBench.Melee, false, null);
var s = Settings(("r" + TinkerCatalog.Iron, 10), ("r" + TinkerCatalog.BlackOpal, 1), ("r" + TinkerCatalog.FireOpal, 1));
var plan = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, tinks: 6), s, rows);
Check.Eq(Mats(plan).Count(m => m == TinkerCatalog.BlackOpal), 1, "first imbue in order");
@ -136,7 +101,7 @@ internal static class TinkerTests
Check.Eq(TinkerCatalog.RendFor(0x400, false), TinkerCatalog.Onyx, "nether");
Check.Eq(TinkerCatalog.RendFor(0, false), 0, "no damage type, no rend");
var rows = TinkerPlanner.Rows(TinkerBench.Melee, null, null);
var rows = TinkerPlanner.Rows(TinkerBench.Melee, false, null);
var s = Settings(("r" + TinkerCatalog.RendId, 1), ("r" + TinkerCatalog.Iron, 2));
var first = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, damageType: 32), s, rows);
Check.Eq(first[0].Material, TinkerCatalog.Emerald, "acid weapon: Emerald first");
@ -147,9 +112,9 @@ internal static class TinkerTests
}
/// <summary>
/// Rows from a server plugin's profile (ServerPackInfo.Salvage): only the tab's own, in kind order
/// unless a row gives its own, keyed "p" (never sharing a count with retail "r"), and with no rule
/// the row doesn't ask for (a Leather without "afterCap" doesn't wait for the 10 ordinary tinks).
/// Rows from a server plugin's profile (ServerPackInfo.Salvage): only the tab's own, in kind order,
/// keyed "p" (never sharing a count with retail "r" or Leaftide "s"), and free of the Leaftide
/// rules (a plugin's Leather on a weapon doesn't wait for the 10 ordinary tinks).
/// </summary>
private static void PluginSalvage()
{
@ -173,83 +138,46 @@ internal static class TinkerTests
var plan = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, tinks: 5), s, rows);
Check.Eq(Seq(plan), Seq(TinkerCatalog.Emerald, TinkerCatalog.Iron, TinkerCatalog.Iron, TinkerCatalog.Leather),
"imbue, tinks, then once; Leather doesn't wait for the cap");
Check.True(server.All(r => !r.AfterCap && r.StackGroup.Length == 0 && r.AppliedInt == 0 && !r.Prepared), "no rules unless asked");
// A row's own order: this once-row runs before the retail imbues (101) and the plugin's tinks.
var ordered = TinkerCatalog.FromServerPlugin(TinkerBench.Melee, new[]
{
Row("melee", TinkerCatalog.Iron, "tink", slot: true),
Row("melee", TinkerCatalog.Turquoise, "once", order: 80),
});
Check.Eq(ordered[1].Order, 80, "the row's order");
Check.Eq(ordered[0].Order, 400, "no order: the kind's default");
var first = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon),
Settings(("r" + TinkerCatalog.BlackOpal, 1), ("p" + TinkerCatalog.Iron, 1), ("p" + TinkerCatalog.Turquoise, 1)),
TinkerPlanner.Rows(TinkerBench.Melee, ordered, null));
Check.Eq(Seq(first), Seq(TinkerCatalog.Turquoise, TinkerCatalog.BlackOpal, TinkerCatalog.Iron), "order 80 goes first");
// The optional fields map onto the planner's row.
var mapped = TinkerCatalog.FromServerPlugin(TinkerBench.Jewelry, Jewelry.Concat(new[]
{
Row("jewelry", TinkerCatalog.Moonstone, "tink", group: "no-cap"),
}));
Check.Eq(mapped[0].AppliedInt, JewelSilverInt, "applied int");
Check.Eq(mapped[2].StackGroup + "/" + mapped[2].StackCap, "jewelry-stack/10", "stack group and cap");
Check.Eq(mapped[4].StackGroup, "", "a group without a cap is no group");
Check.True(TinkerCatalog.FromServerPlugin(TinkerBench.Melee, Weapon)[2].AfterCap, "after cap");
Check.True(TinkerCatalog.FromServerPlugin(TinkerBench.Trinkets, TrinketRows).All(r => r.Prepared), "prepared");
}
private static void AfterCap()
private static void IltWeapon()
{
var rows = WithServer(TinkerBench.Melee, Weapon);
var s = Settings(("p" + TinkerCatalog.YellowGarnet, 1), ("r" + TinkerCatalog.Iron, 10), ("p" + TinkerCatalog.Leather, 1));
var rows = TinkerPlanner.Rows(TinkerBench.Melee, true, null);
var s = Settings(("s" + TinkerCatalog.YellowGarnet, 1), ("r" + TinkerCatalog.Iron, 10), ("s" + TinkerCatalog.Leather, 1));
var full = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, tinks: 10), s, rows);
Check.Eq(Seq(full), Seq(TinkerCatalog.YellowGarnet, TinkerCatalog.Leather), "capped item: no-slot rows, then Leather");
var some = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, tinks: 5), s, rows);
Check.Eq(some[^1].Material, TinkerCatalog.Leather, "Irons fill the last 5 slots, then Leather");
Check.Eq(Mats(some).Count(m => m == TinkerCatalog.Iron), 5, "five Irons");
Check.Eq(Mats(some).Count(m => m == TinkerCatalog.Leather), 1, "Leather once");
var open = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, tinks: 5),
Settings(("p" + TinkerCatalog.Leather, 1), ("r" + TinkerCatalog.Iron, 2)), rows);
Settings(("s" + TinkerCatalog.Leather, 1), ("r" + TinkerCatalog.Iron, 2)), rows);
Check.True(!Mats(open).Contains(TinkerCatalog.Leather), "Leather waits for the 10 ordinary tinks");
var retailOnly = TinkerPlanner.Plan(TinkerBench.Melee, Item(AcObjectClass.MeleeWeapon, tinks: 10), s,
TinkerPlanner.Rows(TinkerBench.Melee, null, null));
Check.Eq(retailOnly.Count, 0, "no server rows: nothing offered past the cap");
TinkerPlanner.Rows(TinkerBench.Melee, false, null));
Check.Eq(retailOnly.Count, 0, "off ILT: the server rows aren't offered");
}
private static void StackAndApplied()
private static void IltJewelry()
{
var rows = WithServer(TinkerBench.Jewelry, Jewelry);
var s = Settings(("p" + TinkerCatalog.Serpentine, 8), ("p" + TinkerCatalog.Steel, 8),
("p" + TinkerCatalog.Silver, 1), ("p" + TinkerCatalog.Copper, 1));
var rows = TinkerPlanner.Rows(TinkerBench.Jewelry, true, null);
var s = Settings(("s" + TinkerCatalog.Serpentine, 8), ("s" + TinkerCatalog.Steel, 8),
("s" + TinkerCatalog.Silver, 1), ("s" + TinkerCatalog.Copper, 1));
var plan = TinkerPlanner.Plan(TinkerBench.Jewelry, Item(AcObjectClass.Jewelry, tinks: 0,
flags: k => k == JewelSilverInt ? 2 : 0), s, rows);
flags: k => k == TinkerCatalog.IntJewelSilver ? 2 : 0), s, rows);
var m = Mats(plan);
Check.Eq(m.Count(x => x == TinkerCatalog.Serpentine), 8, "8 Serpentine");
Check.Eq(m.Count(x => x == TinkerCatalog.Steel), 2, "Steel stops at 10 combined");
Check.True(!m.Contains(TinkerCatalog.Silver), "Silver's applied int already reads 2");
Check.Eq(m[0], TinkerCatalog.Copper, "flag rows first (their order)");
// Two groups don't share; a row outside any group isn't capped.
var split = WithServer(TinkerBench.Jewelry,
Row("jewelry", TinkerCatalog.Serpentine, "tink", order: 50, group: "a", cap: 3),
Row("jewelry", TinkerCatalog.Steel, "tink", order: 60, group: "b", cap: 4),
Row("jewelry", TinkerCatalog.Iron, "tink", order: 70));
var p2 = Mats(TinkerPlanner.Plan(TinkerBench.Jewelry, Item(AcObjectClass.Jewelry),
Settings(("p" + TinkerCatalog.Serpentine, 9), ("p" + TinkerCatalog.Steel, 9), ("p" + TinkerCatalog.Iron, 9)), split));
Check.Eq(p2.Count(x => x == TinkerCatalog.Serpentine), 3, "group a: its cap");
Check.Eq(p2.Count(x => x == TinkerCatalog.Steel), 4, "group b: its own cap");
Check.Eq(p2.Count(x => x == TinkerCatalog.Iron), 9, "no group, no slot: all 9");
Check.True(TinkerCatalog.IsTrinket("Ornate Compass") && !TinkerCatalog.IsTrinket("Yellow Topaz Ring"), "trinkets left to their tab");
Check.True(!m.Contains(TinkerCatalog.Silver), "Silver flag already 2");
Check.Eq(m[0], TinkerCatalog.Copper, "flag rows first");
Check.True(TinkerCatalog.IsTrinket("Ornate Compass") && !TinkerCatalog.IsTrinket("Yellow Topaz Ring"), "trinkets left to their recipes");
}
private static void ItemRows()
{
var rows = TinkerPlanner.Rows(TinkerBench.Items, null, null);
var rows = TinkerPlanner.Rows(TinkerBench.Items, false, null);
var s = Settings(("r" + TinkerCatalog.Moonstone, 2), ("r" + TinkerCatalog.Leather, 1), ("r" + TinkerCatalog.Sandstone, 1));
var noMana = TinkerPlanner.Plan(TinkerBench.Items, Item(AcObjectClass.Armor), s, rows);
Check.Eq(Seq(noMana), Seq(TinkerCatalog.Leather), "no mana: no Moonstone; not retained: Leather, not Sandstone");
@ -279,7 +207,7 @@ internal static class TinkerTests
private static void Bags()
{
var melee = WithServer(TinkerBench.Melee, Weapon);
var melee = TinkerPlanner.Rows(TinkerBench.Melee, true, null);
var rend = new TinkerStep(melee.First(r => r.Id == TinkerCatalog.RendId), TinkerCatalog.BlackGarnet);
var abyssal = new TinkerStep(melee.First(r => r.NameMatch == "Abyssal"), TinkerCatalog.BlackGarnet);
var iron = new TinkerStep(melee.First(r => r.Id == TinkerCatalog.Iron), TinkerCatalog.Iron);
@ -318,18 +246,18 @@ internal static class TinkerTests
private static void Trinkets()
{
Check.Eq(TinkerPlanner.Rows(TinkerBench.Trinkets, null, null).Count, 0, "retail has no trinket rows");
var rows = WithServer(TinkerBench.Trinkets, TrinketRows);
var s = Settings(("p" + TinkerCatalog.Pyreal, 1), ("p" + TinkerCatalog.Diamond, 1), ("p" + TinkerCatalog.Ruby, 1),
("p" + TinkerCatalog.GromnieHide, 1));
Check.Eq(TinkerPlanner.Rows(TinkerBench.Trinkets, false, null).Count, 0, "off ILT: no trinket rows");
var rows = TinkerPlanner.Rows(TinkerBench.Trinkets, true, null);
var s = Settings(("s" + TinkerCatalog.Pyreal, 1), ("s" + TinkerCatalog.Diamond, 1), ("s" + TinkerCatalog.Ruby, 1),
("s" + TinkerCatalog.GromnieHide, 1));
var all = TinkerPlanner.Plan(TinkerBench.Trinkets, Item(AcObjectClass.Jewelry), s, rows);
Check.Eq(Seq(all), Seq(TinkerCatalog.Diamond, TinkerCatalog.Ruby, TinkerCatalog.GromnieHide, TinkerCatalog.Pyreal),
"the rows' order: Diamond, Ruby, Gromnie Hide, Pyreal");
"UB-IT order: Diamond, Ruby, Gromnie Hide, Pyreal");
var some = TinkerPlanner.Plan(TinkerBench.Trinkets, Item(AcObjectClass.Jewelry,
flags: k => k is TrinketDiamondInt or TrinketGromnieInt ? 2 : 0), s, rows);
Check.Eq(Seq(some), Seq(TinkerCatalog.Ruby, TinkerCatalog.Pyreal), "applied ints 384 / 386 already 2");
flags: k => k is TinkerCatalog.IntTrinketDiamond or TinkerCatalog.IntTrinketGromnie ? 2 : 0), s, rows);
Check.Eq(Seq(some), Seq(TinkerCatalog.Ruby, TinkerCatalog.Pyreal), "flags 384 / 386 already 2");
var capped = TinkerPlanner.Plan(TinkerBench.Trinkets, Item(AcObjectClass.Jewelry, tinks: 10), s, rows);
Check.Eq(capped.Count, 4, "no-slot rows ignore the tink cap");
Check.Eq(capped.Count, 4, "trinket salvage doesn't use tink slots");
var diamond = new TinkerStep(rows.First(r => r.Id == TinkerCatalog.Diamond), TinkerCatalog.Diamond);
Check.True(TinkerPlanner.BagMatches(diamond, "Major Diamond Salvage", TinkerCatalog.Diamond, 100, 2), "Major bag at Major");
@ -349,4 +277,48 @@ internal static class TinkerTests
&& !TinkerCatalog.IsTrinket("Imperial Topaz Necklace"), "trinket names (topaz isn't a top)");
Check.True(TinkerCatalog.Targets(TinkerBench.Trinkets, AcObjectClass.Jewelry), "trinkets are jewelry");
}
private static void RingIngredients()
{
var step1 = RingChain.Recipes[0];
Check.True(RingChain.Matches("Quill of Infliction", step1.Tool), "base quill");
Check.True(RingChain.Matches("Infliction Quill", step1.Tool), "alternate name");
Check.True(!RingChain.Matches("Enlightened Quill of Infliction", step1.Tool), "Enlightened excluded from Step 1");
Check.True(RingChain.Matches("Empyrean Trophy", step1.Target) && RingChain.Matches("Royal Summons", step1.Target), "trophies");
Check.True(!RingChain.Matches("Trophy Kit", step1.Target), "not every Trophy");
var step2 = RingChain.Recipes[1];
Check.True(RingChain.Matches("Enlightened Quill of Infliction", step2.Tool), "Step 2 quill");
Check.True(!RingChain.Matches("Enlightened Infliction Quill of Partition", step2.Tool), "partition quill excluded from Step 2");
Check.True(RingChain.Matches("Vial of Ink of Partition", step2.Target), "ink");
var flame = RingChain.Recipes.First(r => r.Id == "ring2_glyph_flame");
Check.True(RingChain.Matches("Enlightened Infliction Quill of Partition", flame.Tool), "Step 3 quill");
Check.True(RingChain.Matches("Glyph of Flame", flame.Target) && !RingChain.Matches("Glyph of Frost", flame.Target), "glyph by full name");
Check.True(!RingChain.Matches(null, flame.Target), "no name");
}
private static void RingQueue()
{
var runs = new Dictionary<string, int> { ["ring2_glyph_frost"] = 1, ["ring2_step2_ink"] = 2, ["ring2_step1_quill_trophy"] = 2, ["ring2_glyph_bludgeoning"] = 1 };
var q = RingChain.Expand(id => runs.TryGetValue(id, out int n) ? n : 0);
Check.Eq(string.Join(",", q.Select(r => r.Tier)), "1,1,2,2,3,3", "tiers in order");
Check.Eq(q[4].Id, "ring2_glyph_bludgeoning", "glyphs in definition order");
Check.Eq(RingChain.Expand(_ => 500).Count, RingChain.Recipes.Length * RingChain.MaxRuns, "runs capped at 99");
Check.Eq(RingChain.Expand(_ => 0).Count, 0, "nothing queued");
}
private static void RingScrolls()
{
Check.Eq(RingChain.GlyphOf("Inscription of Halo of Frost")?.Id, "ring2_glyph_frost", "Halo of Frost");
Check.Eq(RingChain.GlyphOf("Inscription of Cassius' Ring of Fire")?.Id, "ring2_glyph_flame", "Ring of Fire");
Check.Eq(RingChain.GlyphOf("Inscription of Something"), null, "unknown scroll");
Check.True(RingChain.IsInscriptionScroll("Inscription of Clouded Soul") && !RingChain.IsInscriptionScroll("Glyph of Nether"), "scroll marker");
var scrolls = new[] { (30, "Inscription of Searing Disc"), (10, "Inscription of Tectonic Rifts"), (20, "Inscription of Mystery") };
var pairs = RingChain.PairScrolls(scrolls, new[] { 900, 500, 700, 800 });
// Recipe ids sort bludgeoning < corrosion, unknown last; targets by id.
Check.Eq(string.Join(";", pairs.Select(p => $"{p.Scroll}>{p.Target}")), "10>500;30>700;20>800", "glyph order onto target id order");
Check.Eq(RingChain.PairScrolls(scrolls, Array.Empty<int>()).Count, 0, "no targets");
}
}

View file

@ -0,0 +1,146 @@
using System;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using RynthCore.Plugin.RynthAi;
using RynthCore.Plugin.RynthAi.LegacyUi;
using RynthCore.PluginCore;
using RynthCore.RynthAiHostTests.Fakes;
using RynthCore.RynthAiTests.Harness;
namespace RynthCore.RynthAiHostTests.Tests;
// ub-IT's remaining /ub verbs (2026-10-18): metas written for ub-IT send them, so every one is
// handled: mapped where RynthAi, RynthNav, RynthSort or the server has the feature, left to
// ub-Rythai for its verbs, and accepted quietly where nothing here matches (videopatch, ...).
internal static class UbCompatTests
{
private const uint Player = 0x50000F21;
private const uint Robe = 0x80282101, WornRobe = 0x80282102;
private const BindingFlags Any = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;
public static void Register(Runner r)
{
r.Add("ub compat: ub-IT verbs with no RynthAi equivalent are accepted, said once", NoEquivalentAccepted);
r.Add("ub compat: ub-Rythai's verbs get no RynthAi reply, and a meta passes them on", UbRythaiVerbsLeftAlone);
r.Add("ub compat: aliases and features map onto RynthAi, RynthNav, RynthSort and the server", AliasesAndFeatures);
r.Add("ub compat: a meta's /ub line uses the /ub meaning, not /mt's", MetaUsesUbMeaning);
}
private sealed class World
{
public readonly RynthAiPlugin P = new();
public readonly LegacyUiSettings S = new();
public World()
{
FakeHost.Reset();
FakeHost.PluginCommandCalls = true;
FakeHost.SalvageCalls = true; // GetObjectWielderInfo: the worn robe reads as worn
FakeHost.Names[Player] = "Kelpie";
FakeHost.PlayerIdValue = Player;
foreach (var (id, name) in new[] { (Robe, "Faran Robe"), (WornRobe, "Faran Robe") })
{
FakeHost.Names[id] = name;
FakeHost.Containers[id] = Player;
FakeHost.ItemTypes[id] = 0x2; // clothing
}
FakeHost.Wielded[WornRobe] = 0x0400;
var host = FakeHost.Create(playerId: Player);
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);
var cache = new WorldObjectCache(host);
cache.SetPlayerId(Player);
Set("_objectCache", cache);
Set("_playerId", Player);
Set("_initialized", true);
Set("_loginComplete", true);
foreach (uint id in new[] { Robe, WornRobe }) cache.OnCreateObject(id);
cache.Tick();
}
public void Set(string f, object? v) => typeof(RynthAiPlugin).GetField(f, Any)!.SetValue(P, v);
public bool Ub(string line) => (bool)typeof(RynthAiPlugin).GetMethod("HandleUbCommand", Any)!.Invoke(P, new object[] { line })!;
public bool Meta(string line) => (bool)typeof(RynthAiPlugin).GetMethod("HandleMetaChatCommand", Any)!.Invoke(P, new object[] { line })!;
public int ChatWith(string text) => FakeHost.Chat.Count(c => c.Contains(text, StringComparison.OrdinalIgnoreCase));
}
private static void NoEquivalentAccepted()
{
var w = new World();
Check.True(w.Ub("/ub videopatch on"), "/ub videopatch is handled");
Check.True(w.Ub("/ub videopatch off"), "again");
Check.Eq(w.ChatWith("/ub videopatch"), 1, "said once per session, not per meta pulse");
foreach (string line in new[] { "/ub chat max", "/ub playeroption AutoRepeatAttack on", "/ub statushud toggle", "/ub professor war 7", "/ub xp level" })
Check.True(w.Ub(line), line + " is handled");
Check.Eq(w.ChatWith("Unrecognized"), 0, "no 'Unrecognized /ub command'");
Check.False(w.Ub("/ub notaubitcommand"), "a verb ub-IT doesn't have is still unknown");
}
private static void UbRythaiVerbsLeftAlone()
{
var w = new World();
int chat = FakeHost.Chat.Count;
foreach (string line in new[] { "/ub bank status", "/ub periodic add 5 /say hi", "/ub xpmeter", "/ub portal use Aerlinthe", "/ub portal list", "/ub leaftide status" })
Check.True(w.Ub(line), line + ": not unknown");
Check.Eq(FakeHost.Chat.Count, chat, "RynthAi says nothing; ub-Rythai answers these");
// A meta hands them to the chat parser, which every plugin (ub-Rythai too) sees.
Check.False(w.Meta("/ub bank status"), "a meta's /ub bank goes on to the chat parser");
// "/ub portal <name>" is RynthAi's (the nearest portal), not a portal gem.
Check.False(RynthAiPluginIsUbRythai("portal", "Town Network"), "/ub portal <name> stays RynthAi's");
}
private static bool RynthAiPluginIsUbRythai(string cmd, string args)
=> (bool)typeof(RynthAiPlugin).GetMethod("IsUbRythaiCommand", BindingFlags.Static | BindingFlags.NonPublic)!.Invoke(null, new object[] { cmd, args })!;
private static void AliasesAndFeatures()
{
var w = new World();
// wear: the carried copy, never the worn one (using a worn item takes it off).
Check.True(w.Ub("/ub wear Faran Robe"), "/ub wear");
Check.True(FakeHost.Uses.Contains(Robe) && !FakeHost.Uses.Contains(WornRobe), "wears the carried robe only");
// Frame limits are RynthAi's FPS settings.
w.Ub("/ub globalframelimit 45");
Check.Eq(w.S.TargetFPSFocused, 45, "globalframelimit");
Check.True(w.S.EnableFPSLimit, "and the limit is on");
w.Ub("/ub bgframelimit 20");
Check.Eq(w.S.TargetFPSBackground, 20, "bgframelimit");
w.Ub("/ub globalframelimit 0");
Check.False(w.S.EnableFPSLimit, "0 turns the limit off");
// RynthNav and RynthSort through the plugin broker.
w.Ub("/ub arrow point 42.1N, 33.6E");
Check.True(FakeHost.PluginCommands.Contains(("RynthNav", "rnav", "arrow 42.1N, 33.6E")), "arrow point -> /rnav arrow");
w.Ub("/ub navgoto -12.5 40.25 walk");
Check.True(FakeHost.PluginCommands.Contains(("RynthNav", "rnav", "go 12.5S, 40.25E")), "navgoto signed coords -> /rnav go");
w.Ub("/ub packsort");
Check.True(FakeHost.PluginCommands.Contains(("RynthSort", "rsort", "now")), "packsort -> /rsort now");
// Server and engine commands go to the chat parser.
w.Ub("/ub qblist");
w.Ub("/ub augs");
w.Ub("/ub window save");
w.Ub("/ub fellow dismiss Storm");
Check.True(FakeHost.ChatCommands.Contains("/qb list"), "qblist -> /qb list");
Check.True(FakeHost.ChatCommands.Contains("/aug"), "augs -> /aug");
Check.True(FakeHost.ChatCommands.Contains("/rc window save"), "window save -> /rc window save");
Check.True(FakeHost.ChatCommands.Contains("/fellowship dismiss Storm"), "fellow dismiss -> /fellowship dismiss");
// stfl / getxy are the /mt strafe / cursor commands (no game window here: they say so).
Check.True(w.Ub("/ub stfl 500"), "stfl handled");
Check.True(w.Ub("/ub getxy"), "getxy handled");
}
private static void MetaUsesUbMeaning()
{
var w = new World();
// A /ub verb /mt doesn't know used to fall to the chat parser and come back round.
Check.True(w.Meta("/ub videopatch on"), "a meta's /ub line runs the /ub dispatcher");
Check.Eq(FakeHost.ChatCommands.Count(c => c.StartsWith("/ub", StringComparison.Ordinal)), 0, "not re-sent to the chat parser");
Check.True(w.Meta("/mt get xy"), "/mt lines still go to /mt");
}
}