RynthSuite as of 2026-11-29 (internal 3c6745b): release 2026.11.29.1
This commit is contained in:
parent
598f49c899
commit
95282c83fa
13 changed files with 916 additions and 36 deletions
|
|
@ -94,6 +94,7 @@ internal static class ActionPacingTests
|
|||
r.Add("corpse id: an accepted request with no data is asked again after 3 s (not before), once per 3 s, at most 3 re-asks per corpse", CorpseIdReaskedWithoutData);
|
||||
r.Add("corpse id: Loot From All Corpses needs no killer name - the first request goes out, no re-ask ever follows; My Kills Only gives up after 3 re-asks, a new corpse starts over", CorpseIdAllCorpsesNoReask);
|
||||
r.Add("corpse id: two corpses in range, no data for either - only the targeted one re-asks; the other stays at one accepted request (a refused one is still retried)", CorpseIdOnlyCandidateReasks);
|
||||
r.Add("corpse id (11-29): Loot Only Rare Corpses - an unclaimed corpse in loot range with no description re-asks (3 s, 3 re-asks at most) and opens once the rare line lands; one out of range asks once, and again when the bot comes within range", CorpseIdRareOnlyWaitingReasks);
|
||||
r.Add("corpse id: 20 uncached corpses, a refusal window, then accept - at most 2 requests in the first accepted tick, the target among them; refused retries are 250 ms apart", CorpseIdBurstCapped);
|
||||
r.Add("corpse id: the open container is a candidate and re-asks; delete and the >200 prune clear every id map", CorpseIdOpenContainerAndCleanup);
|
||||
r.Add("pacing (vitals): a heal waits for an unanswered corpse use's answer, then goes at once; the emergency stance settle is unchanged", HealLatencyKept);
|
||||
|
|
@ -1068,6 +1069,52 @@ internal static class ActionPacingTests
|
|||
_t += 3_000; Both();
|
||||
Check.Eq(Asked(CorpseB), 2, "once it becomes the candidate it re-asks");
|
||||
});
|
||||
|
||||
// Loot Only Rare Corpses never claims a corpse before its description says "This corpse generated a
|
||||
// rare item!", so no waiting corpse is the target and the target's re-asks never reached one: an
|
||||
// accepted request the engine dropped (stale, around a portal) left a rare corpse closed for good.
|
||||
private static void CorpseIdRareOnlyWaitingReasks() => Paced(() =>
|
||||
{
|
||||
LootWorld();
|
||||
FakeHost.Strings.Remove((Corpse, LongDescKey));
|
||||
FakeHost.Strings.Remove((CorpseB, LongDescKey));
|
||||
FakeHost.Positions[CorpseB] = (Me0.Cell, Me0.X + 60f, Me0.Y, Me0.Z); // far past the 10 yd approach range
|
||||
var host = FakeHost.Create(Player);
|
||||
var bot = new Bot(host);
|
||||
bot.S.LootOnlyRareCorpses = true;
|
||||
var cache = bot.Get<WorldObjectCache>("_objectCache");
|
||||
var near = cache[unchecked((int)Corpse)]!;
|
||||
var far = cache[unchecked((int)CorpseB)]!;
|
||||
int Asked(uint id) => FakeHost.IdRequests.Count(i => i == id);
|
||||
bool Loots(WorldObject o)
|
||||
{
|
||||
object d = bot.Call("EvaluateCorpseLootDecision", o)!;
|
||||
return (bool)d.GetType().GetProperty("ShouldLoot")!.GetValue(d)!;
|
||||
}
|
||||
void Both() { Loots(near); Loots(far); }
|
||||
|
||||
Check.Eq(bot.Get<int>("_targetCorpseId"), 0, "nothing is claimed");
|
||||
Check.False(Loots(near), "no description yet: the corpse waits, closed");
|
||||
Loots(far);
|
||||
Check.Eq(Asked(Corpse), 1, "t=0: the first request goes out");
|
||||
Check.Eq(Asked(CorpseB), 1, "the far corpse gets its first request too");
|
||||
_t += 2_999; Both();
|
||||
Check.Eq(Asked(Corpse), 1, "2.999 s, no answer: not yet");
|
||||
_t += 1; Both();
|
||||
Check.Eq(Asked(Corpse), 2, "3 s, no answer (the request was dropped): asked again, though it is not the target");
|
||||
for (int i = 0; i < 6; i++) { _t += 3_000; Both(); }
|
||||
Check.Eq(Asked(Corpse), 4, "three re-asks at most");
|
||||
Check.Eq(Asked(CorpseB), 1, "out of loot range: one request only");
|
||||
|
||||
FakeHost.Positions[CorpseB] = (Me0.Cell, Me0.X + 1.5f, Me0.Y, Me0.Z);
|
||||
_t += 3_000; Both();
|
||||
Check.Eq(Asked(CorpseB), 2, "the bot came within range of it: asked again");
|
||||
|
||||
FakeHost.Strings[(Corpse, LongDescKey)] = $"Killed by {Me}. This corpse generated a rare item!";
|
||||
Check.True(Loots(near), "the description arrived with the rare line: it opens");
|
||||
FakeHost.Strings[(CorpseB, LongDescKey)] = $"Killed by {Me}.";
|
||||
Check.False(Loots(far), "no rare line: it stays closed");
|
||||
});
|
||||
private static void CorpseIdBurstCapped() => Paced(() =>
|
||||
{
|
||||
LootWorld();
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ internal static class DunRouteTests
|
|||
r.Add("dun routes: plugin: the patrol save asks the server policy as dunnav-patrol does; dunroute isn't refused", PluginPatrolPolicy);
|
||||
r.Add("dun routes: plugin: interface jobs run on the tick, wait out portal space, give up after 30 s, answer JSON", PluginJobs);
|
||||
r.Add("dun routes: plugin: where lists the portals with distances and the exit; arrival is where the character landed", PluginWhere);
|
||||
r.Add("dun routes (11-29): plugin: a portal the client forgot (out of sight) is still kept out of, and its coming back rebuilds nothing; one gone from its own cell for 5 s is forgotten", PluginPortalsRemembered);
|
||||
r.Add("dun routes: Tiny Hive 0x0289 on the real dats: a route to the Surface Portal and to the far end (if the dats are here)", TinyHiveRealDats);
|
||||
r.Add("dun doorways: the doorway flags survive save and reload (NavProfiles\\.rynthai-routes.json); the .nav stays VTank's", DoorwaysSurviveReload);
|
||||
r.Add("dun doorways: an edited file gets no flags (one log line); a nav the route maker didn't write is never touched", DoorwaysEditedFile);
|
||||
|
|
@ -934,6 +935,57 @@ internal static class DunRouteTests
|
|||
Check.True(said[0].Contains("circular") && said[0].Contains("made for this dungeon: yes"), "info on the saved patrol: " + Show(said));
|
||||
}
|
||||
|
||||
private static void PluginPortalsRemembered()
|
||||
{
|
||||
// 2026-11-29 Lugian Excavations (0x02E7): two portals ~500 m apart, the client forgetting each out of sight, the
|
||||
// patrol laid again round whichever "came into view", the other forgotten: every 6-14 minutes all session.
|
||||
var rig = new Rig("NavProfiles-portalmem");
|
||||
long clock = 1_000_000;
|
||||
RynthAiPlugin.PortalClock = () => clock;
|
||||
try
|
||||
{
|
||||
List<PatrolPortal> Known() => (List<PatrolPortal>)rig.Call("PatrolPortalsIn", Lb)!;
|
||||
Check.Eq(Known().Count, 2, "both portals known");
|
||||
|
||||
// Out of sight: the client forgets the Surface Portal. It is still there.
|
||||
rig.Cache.OnDeleteObject(SurfaceId); rig.Cache.Tick();
|
||||
var later = Known();
|
||||
Check.Eq(later.Count, 2, "the one the client forgot is still kept out of");
|
||||
var s = later.First(p => p.Id == SurfaceId);
|
||||
Check.True(Math.Abs(s.X - (Ox + 15)) < 0.01 && Math.Abs(s.Y - (Oy + 52)) < 0.01 && s.Cell == rig.D.Nook && s.Name == "Surface Portal",
|
||||
$"where it stood, by name ({s.X - Ox:F1}, {s.Y - Oy:F1}) cell {s.Cell:X8}");
|
||||
s.Radius = 99; // a build fills these in on its copy
|
||||
Check.True(Known().First(p => p.Id == SurfaceId).Radius < 99, "a fresh copy each time");
|
||||
|
||||
// The patrol built round both: the Surface Portal coming back into view lays nothing again.
|
||||
rig.Call("MarkPatrolPortals", Known());
|
||||
rig.Cache.OnCreateObject(SurfaceId); rig.Cache.Tick();
|
||||
rig.Set("_dunPatrolLandblock", Lb);
|
||||
rig.Set("_dunPatrolPortalCheckAt", 0L);
|
||||
Check.False((bool)rig.Call("PatrolPortalAppeared")!, "it coming back into view rebuilds nothing");
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("came into view")), 0, "no 'came into view'");
|
||||
|
||||
// A portal really gone (a summoned one): in its own cell without the client having it, kept 5 s, then forgotten.
|
||||
rig.Cache.OnDeleteObject(SurfaceId); rig.Cache.Tick();
|
||||
rig.At(15, 50, rig.D.Nook);
|
||||
Check.True(Known().Any(p => p.Id == SurfaceId), "in its cell: kept at first (the server's create can lag)");
|
||||
clock += 4000;
|
||||
Check.True(Known().Any(p => p.Id == SurfaceId), "kept after 4 s");
|
||||
clock += 1000;
|
||||
var gone = Known();
|
||||
Check.False(gone.Any(p => p.Id == SurfaceId), "forgotten after 5 s");
|
||||
Check.Eq(gone.Count, 1, "the other portal stays");
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("isn't there any more")), 1, "said once in the log");
|
||||
|
||||
// Far from it (not its cell) a forgotten-by-the-client portal is never taken for gone.
|
||||
rig.At(15, 15, rig.D.Start);
|
||||
rig.Cache.OnDeleteObject(DepthsId); rig.Cache.Tick();
|
||||
clock += 60_000;
|
||||
Check.True(Known().Any(p => p.Id == DepthsId), "the Depths portal, out of sight from the start, is kept");
|
||||
}
|
||||
finally { RynthAiPlugin.PortalClock = static () => Environment.TickCount64; }
|
||||
}
|
||||
|
||||
private static void PluginPatrolPolicy()
|
||||
{
|
||||
// The patrol is off in Threads on DreamWeave (ServerPolicy): the save builds the same patrol, so it asks too.
|
||||
|
|
|
|||
|
|
@ -44,8 +44,10 @@ internal static class LootRaresModeTests
|
|||
{
|
||||
r.Add("loot rares mode: the rares and a needed mana stone are looted; the OD crossbow LootSnob keeps and the gold salvage are not", RaresModeCorpse);
|
||||
r.Add("loot rares mode: a mana stone at the keep count is left (not needed), and the corpse's end line says the mode", StoneNotNeeded);
|
||||
r.Add("loot rares mode: profile mode is unchanged (crossbow kept, helm salvaged, stone kept, the rares left)", ProfileModeUnchanged);
|
||||
r.Add("loot rares mode: profile mode keeps its rules (crossbow kept, helm salvaged, stone kept) and, since 11-29, the rares no LootSnob rule takes", ProfileModeUnchanged);
|
||||
r.Add("loot rares mode: a rare needs no ID (rare icon) or is known by its RareId; Mana Tap takes nothing", NoIdNoTap);
|
||||
r.Add("rare left (11-29): a rare that won't move keeps its corpse from being marked done - set aside and looted again 3 times, each said in chat, then a line names it to take by hand", RareLeftSetAside);
|
||||
r.Add("rare left (11-29): a corpse with a rare is claimed ahead of a nearer one, and its rare is picked up first", RareCorpseAndRareFirst);
|
||||
r.Add("loot rares mode: the loot details line names the reason (rare, mana stone (needed))", DetailsLineNamesReason);
|
||||
r.Add("loot rares mode: the setting round trip (profile file, profile switch, engine face, meta LootMode)", SettingRoundTrip);
|
||||
r.Add("loot rares mode: /ra loot mode replies with the mode, or why not and the usage; /ra loot why gives the mode's verdict", Commands);
|
||||
|
|
@ -65,9 +67,13 @@ internal static class LootRaresModeTests
|
|||
finally { RynthAiPlugin.CorpseClock = old; }
|
||||
}
|
||||
|
||||
/// <summary>Moves the server never lands (the item stays on the corpse).</summary>
|
||||
private static readonly HashSet<uint> NeverLands = new();
|
||||
|
||||
private static void World(bool stoneInPack)
|
||||
{
|
||||
FakeHost.Reset();
|
||||
NeverLands.Clear();
|
||||
FakeHost.SalvageCalls = true; // UseObject + MoveItemExternal
|
||||
FakeHost.WeaponCalls = true; // RequestId, HasAppraisalData
|
||||
FakeHost.CloseContainerCalls = true; // CloseContainer + GetGroundContainerId
|
||||
|
|
@ -170,7 +176,8 @@ internal static class LootRaresModeTests
|
|||
while (_seenMoves < FakeHost.ExternalMoves.Count)
|
||||
{
|
||||
var m = FakeHost.ExternalMoves[_seenMoves++];
|
||||
FakeHost.Containers[m.Id] = m.Target;
|
||||
if (!NeverLands.Contains(m.Id))
|
||||
FakeHost.Containers[m.Id] = m.Target;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -286,7 +293,10 @@ internal static class LootRaresModeTests
|
|||
Check.True(Said("Loot rule: Helm -> [Salvage] (Salv) Gold"), "for LootSnob's (Salv) Gold");
|
||||
Check.True(Moved(Stone), "the mana stone is kept by the built-in stone rule");
|
||||
Check.True(Said("Loot rule: Mana Stone -> [Keep] ManaStone (Consumable, 1/5)"), "under its old label");
|
||||
Check.False(Moved(RareGem), "the rare gem: no LootSnob rule takes it, so profile mode leaves it, as before");
|
||||
// 2026-11-29 (no rare may be left on a corpse): a rare is always kept, ahead of the profile.
|
||||
Check.True(Moved(RareGem), "the rare gem: no LootSnob rule takes it, but a rare is always kept");
|
||||
Check.True(Moved(RareRing), "the rare ring (RareId) too");
|
||||
Check.True(Said("Loot rule: Pearl of Spirit Drinking -> [Keep] Rare (always kept)"), "under its own label");
|
||||
Check.False(Said("Rares mode"), "nothing says rares mode");
|
||||
});
|
||||
|
||||
|
|
@ -315,15 +325,106 @@ internal static class LootRaresModeTests
|
|||
Check.True(stone.Taken && stone.Rule == LootModes.StoneRule, $"the stone: 1 in the pack, keep count 5: [{stone.Action}] {stone.Rule}");
|
||||
Check.True(stone.BuiltIn.StartsWith("a needed mana stone, 1 of 5 kept", StringComparison.Ordinal), stone.BuiltIn);
|
||||
|
||||
// Profile mode, same world: no LootSnob rule takes the 4,000-mana ring, so Mana Tap does.
|
||||
// Profile mode, same world: no LootSnob rule takes the 4,000-mana ring. As a rare it is kept, never
|
||||
// drained (2026-11-29); the same ring without its RareId is a Mana Tap pickup, as before.
|
||||
FakeHost.Ints[(RareRing, 107)] = 4000;
|
||||
bot.S.LootMode = LootModes.Profile;
|
||||
var kept = bot.Classify(RareRing);
|
||||
Check.True(kept.Taken && kept.Action == "Keep" && kept.Rule == RareItems.AlwaysKeptRule, $"profile mode: the rare ring is kept, not drained: [{kept.Action}] {kept.Rule}");
|
||||
Check.False((bool)bot.Call("ItemNeedsAppraisalForLoot", bot.Cache[unchecked((int)RareGem)]!)!, "profile mode: a rare with its rare icon asks for no ID");
|
||||
FakeHost.Ints.Remove((RareRing, RareItems.RareIdKey));
|
||||
var tap = bot.Classify(RareRing);
|
||||
Check.True(tap.Taken && tap.Action == "ManaTap", $"profile mode: Mana Tap as before: [{tap.Action}] {tap.Rule}");
|
||||
Check.True(tap.Taken && tap.Action == "ManaTap", $"profile mode, not a rare: Mana Tap as before: [{tap.Action}] {tap.Rule}");
|
||||
FakeHost.Ints[(RareRing, RareItems.RareIdKey)] = 30183;
|
||||
bot.S.LootMode = LootModes.Rares;
|
||||
Check.Eq(bot.Classify(RareRing).Action, "Keep", "rares mode: the same ring is kept as a rare, not drained");
|
||||
});
|
||||
|
||||
/// <summary>Loots until the corpse is marked done or <paramref name="ms"/> passes, answering every open
|
||||
/// (the server's ViewContents) and every close. Returns how many opens were sent.</summary>
|
||||
private static int LootWithReopens(Bot bot, long ms, Action? eachTick = null)
|
||||
{
|
||||
int opens = 0, closes = 0;
|
||||
long end = _now + ms;
|
||||
while (_now < end && !bot.CorpseDone)
|
||||
{
|
||||
eachTick?.Invoke();
|
||||
bot.Tick();
|
||||
int closed = FakeHost.Closes.Count(c => c == Corpse);
|
||||
if (closed > closes) { closes = closed; FakeHost.GroundContainer = 0; }
|
||||
int used = FakeHost.Uses.Count(u => u == Corpse);
|
||||
if (used > opens)
|
||||
{
|
||||
opens = used;
|
||||
FakeHost.UseDone(0);
|
||||
FakeHost.GroundContainer = Corpse;
|
||||
bot.P.OnViewObjectContents(Corpse);
|
||||
bot.P.OnUpdateObjectInventory(Corpse);
|
||||
}
|
||||
}
|
||||
return opens;
|
||||
}
|
||||
|
||||
// 2026-11-29: no rare may be left on a corpse. The gem's move is never answered, so every open
|
||||
// ends with it still there.
|
||||
private static void RareLeftSetAside() => Clocked(() =>
|
||||
{
|
||||
World(stoneInPack: false);
|
||||
NeverLands.Add(RareGem);
|
||||
var host = FakeHost.Create(Player);
|
||||
var bot = new Bot(host, LootModes.Profile);
|
||||
var ids = new List<uint> { Corpse };
|
||||
ids.AddRange(OnCorpse);
|
||||
bot.Create(ids.ToArray());
|
||||
|
||||
int opens = LootWithReopens(bot, 180_000);
|
||||
const string Line = "[RynthAi] A rare is still on Corpse of Olthoi Swarm Drone: Pearl of Spirit Drinking.";
|
||||
for (int t = 1; t <= RynthAiPlugin.RareLeftMaxRetries; t++)
|
||||
Check.True(Said($"{Line} Looting it again in 5 s (try {t} of {RynthAiPlugin.RareLeftMaxRetries})."), $"try {t} is said ({ChatDump()})");
|
||||
Check.True(Said($"{Line} Looted {RynthAiPlugin.RareLeftMaxRetries} more times and it stayed. Take it by hand."), "then the line to take it by hand");
|
||||
Check.True(bot.CorpseDone, "the corpse is marked done only then");
|
||||
Check.True(opens >= 1 + RynthAiPlugin.RareLeftMaxRetries, $"opened again for each try ({opens} opens)");
|
||||
Check.True(Moved(RareRing) && Moved(Xbow), "the rest was looted on the first open");
|
||||
Check.Eq(FakeHost.ExternalMoves.Count(m => m.Id == Xbow), 1, "and not taken again");
|
||||
|
||||
// The gem lands on a later open: no line to take it by hand, the corpse is done.
|
||||
World(stoneInPack: false);
|
||||
NeverLands.Add(RareGem);
|
||||
bot = new Bot(FakeHost.Create(Player), LootModes.Profile);
|
||||
bot.Create(ids.ToArray());
|
||||
LootWithReopens(bot, 60_000, () => { if (Said($"{Line} Looting it again in 5 s (try 1 of")) NeverLands.Clear(); });
|
||||
Check.True(FakeHost.Containers[RareGem] == Player, $"the gem is taken on a later open ({ChatDump()})");
|
||||
Check.True(bot.CorpseDone, "and the corpse is done");
|
||||
Check.False(Said("Take it by hand."), "and nothing says to take it by hand");
|
||||
});
|
||||
|
||||
private static void RareCorpseAndRareFirst() => Clocked(() =>
|
||||
{
|
||||
// A nearer corpse with no rare, and ours (1 m) moved to 3 m with the rare line on it.
|
||||
World(stoneInPack: false);
|
||||
const uint Plain = 0x80267120;
|
||||
FakeHost.Names[Plain] = "Corpse of Olthoi Swarm Drone";
|
||||
FakeHost.ItemTypes[Plain] = ItemTypeContainer;
|
||||
FakeHost.Strings[(Plain, LongDescKey)] = $"Killed by {Me}.";
|
||||
FakeHost.NotAttackable.Add(Plain);
|
||||
FakeHost.Positions[Plain] = (Me0.Cell, Me0.X + 1.0f, Me0.Y, Me0.Z);
|
||||
FakeHost.Positions[Corpse] = (Me0.Cell, Me0.X + 3.0f, Me0.Y, Me0.Z);
|
||||
FakeHost.Strings[(Corpse, LongDescKey)] = $"Killed by {Me}. This corpse generated a rare item!";
|
||||
var bot = new Bot(FakeHost.Create(Player), LootModes.Profile);
|
||||
var ids = new List<uint> { Corpse, Plain };
|
||||
ids.AddRange(OnCorpse);
|
||||
bot.Create(ids.ToArray());
|
||||
|
||||
object?[] args = { 30.0, null, null };
|
||||
bool found = (bool)typeof(RynthAiPlugin).GetMethod("TryFindNearestCorpse", Any)!.Invoke(bot.P, args)!;
|
||||
Check.True(found && ((WorldObject)args[1]!).Id == unchecked((int)Corpse), "the rare corpse is claimed though another is nearer");
|
||||
|
||||
LootWithReopens(bot, 30_000);
|
||||
int first = FakeHost.ExternalMoves.FindIndex(m => m.Id == RareGem || m.Id == RareRing);
|
||||
int other = FakeHost.ExternalMoves.FindIndex(m => m.Id == Xbow || m.Id == Helm || m.Id == Stone);
|
||||
Check.True(first >= 0 && (other < 0 || first < other), $"a rare is the first pickup ({string.Join(",", FakeHost.ExternalMoves.Select(m => $"{m.Id:X8}"))})");
|
||||
});
|
||||
|
||||
private static void DetailsLineNamesReason() => Clocked(() =>
|
||||
{
|
||||
LootCorpse(LootModes.Rares, setUp: bot => bot.S.ItemInfoSettings.LootChat = true);
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ internal static class NavEngineTests
|
|||
r.Add("nav engine (11-28): back from a fight, nothing of the route near in sight: the map's way to the waypoint", InSightNoneFallsBack);
|
||||
r.Add("nav engine (11-28): a fight during the walk to the route in sight: looked at again from where it ends", InSightInterrupted);
|
||||
r.Add("nav engine (11-28): Lugian Excavations 0x02E7 on the real dats: the patrol's legs are clear walks, the 18:56 wall stuck isn't, and the route in sight is found from there and from the rooms off the route (if the dats are here)", InSightLugianRealDats);
|
||||
r.Add("nav engine (11-29): the map's long way back through fight after fight: planned again after each while it gets nearer; three that bring it no nearer end it", LongWalkThroughFights);
|
||||
r.Add("nav engine (11-29): the nearest waypoint on foot (the patrol's start with nothing in sight): the shortest walk of the nearest few and the old start", NearestOnFootPick);
|
||||
r.Add("nav engine: Go To Closest Waypoint off keeps the last waypoint (hazard/corpse still rejoin)", ResumeNearestOff);
|
||||
r.Add("nav engine: a loaded route starts at [0] for Once/Follow, or for any route with the option off", StartsAtFirstPoint);
|
||||
r.Add("nav engine: nearest waypoint lookup", FindNearest);
|
||||
|
|
@ -94,6 +96,10 @@ internal static class NavEngineTests
|
|||
r.Add("nav engine: an NPC point (VTank type 7) uses its NPC on arrival, once, waits for the answer, then goes on", NpcPointUsesTheNpc);
|
||||
r.Add("nav engine: an NPC point waits while the client is busy with the use, 20 s at most", NpcPointWaitsWhileBusy);
|
||||
r.Add("nav engine: an NPC point whose NPC can't be found says so once and goes on after 15 s", NpcPointNotFound);
|
||||
r.Add("nav engine (11-29): a Vendor point (VTank type 5) opens its vendor on arrival, once, waits for the window, then goes on", VendorPointOpensTheVendor);
|
||||
r.Add("nav engine (11-29): a Vendor point whose window never opens says so once and goes on after 20 s", VendorPointNeverOpens);
|
||||
r.Add("nav engine (11-29): a Vendor point whose vendor can't be found says so once and goes on after 15 s", VendorPointNotFound);
|
||||
r.Add("nav engine (11-29): a vendor opened by hand away from a Vendor point changes nothing", VendorOpenedElsewhere);
|
||||
}
|
||||
|
||||
// ── Rig ───────────────────────────────────────────────────────────────────
|
||||
|
|
@ -527,6 +533,91 @@ internal static class NavEngineTests
|
|||
Check.True(nav.S.EnableNavigation, "nav stays on");
|
||||
}
|
||||
|
||||
// ── Vendor points (OpenVendor, type 5) ────────────────────────────────────
|
||||
|
||||
private const uint VendorId = 0x7A000003;
|
||||
|
||||
private static Nav VendorRoute(bool vendorThere)
|
||||
{
|
||||
FakeHost.Reset(); At(0, 0);
|
||||
FakeHost.WeaponCalls = true; // UseObject
|
||||
var pose = FakeHost.PlayerPose;
|
||||
FakeHost.Names[NpcMe] = "Tester";
|
||||
FakeHost.Positions[NpcMe] = pose;
|
||||
if (vendorThere)
|
||||
{
|
||||
FakeHost.Names[VendorId] = "Renald the Grocer";
|
||||
FakeHost.Positions[VendorId] = (pose.Cell, pose.X + 2f, pose.Y, pose.Z);
|
||||
}
|
||||
var host = FakeHost.Create(NpcMe);
|
||||
var cache = FakeHost.MakeCache(host, NpcMe, vendorThere ? new[] { VendorId } : Array.Empty<uint>());
|
||||
var vendor = Pt(0, 0, T.OpenVendor); vendor.TargetName = "Renald the Grocer"; vendor.VendorId = VendorId;
|
||||
var nav = new Nav(Route(RT.Once, vendor, Pt(20, 0), Pt(40, 0)));
|
||||
nav.E.SetWorldObjectCache(cache);
|
||||
nav.E.SetPlayerId(NpcMe);
|
||||
return nav;
|
||||
}
|
||||
|
||||
private static void VendorPointOpensTheVendor()
|
||||
{
|
||||
var nav = VendorRoute(vendorThere: true);
|
||||
nav.Tick();
|
||||
Check.Eq(nav.Idx, 0, "arrived at the Vendor point: it doesn't go on yet (it used to walk straight past)");
|
||||
Check.False(FakeHost.AutoRun, "it stops there");
|
||||
nav.Run(1.0);
|
||||
Check.Eq(FakeHost.Uses.Count(u => u == VendorId), 1, $"the vendor is used, once (uses: {string.Join(",", FakeHost.Uses.Select(u => u.ToString("X8")))})");
|
||||
Check.Eq(LogCount("UseObject vendor 'Renald the Grocer'"), 1, "logged as a vendor use");
|
||||
nav.Run(10.0);
|
||||
Check.Eq(nav.Idx, 0, "10 s after the use and no window yet: still waiting for it");
|
||||
Check.Eq(FakeHost.Uses.Count(u => u == VendorId), 1, "and not used again while it waits");
|
||||
nav.E.NoteVendorOpened(VendorId); // AutoVendor would hold the bot here; the fake doesn't
|
||||
nav.Run(1.5);
|
||||
Check.Eq(nav.Idx, 0, "under 2 s after the window opened: still at the vendor");
|
||||
nav.Run(1.0);
|
||||
Check.Eq(nav.Idx, 1, "then on to [1]");
|
||||
Check.Eq(FakeHost.Uses.Count(u => u == VendorId), 1, "never used twice");
|
||||
Check.Eq(FakeHost.Chat.Count(l => l.Contains("vendor 'Renald the Grocer'")), 0, "nothing said in chat when it worked");
|
||||
At(19.5, 0); nav.Tick();
|
||||
Check.Eq(nav.Idx, 2, "the next plain waypoint is walked as before");
|
||||
}
|
||||
|
||||
private static void VendorPointNeverOpens()
|
||||
{
|
||||
var nav = VendorRoute(vendorThere: true);
|
||||
nav.Tick();
|
||||
nav.Run(1.0);
|
||||
Check.Eq(FakeHost.Uses.Count(u => u == VendorId), 1, "used");
|
||||
nav.Run(18.0);
|
||||
Check.Eq(nav.Idx, 0, "18 s after the use, no window: still waiting");
|
||||
nav.Run(2.5);
|
||||
Check.Eq(nav.Idx, 1, "past 20 s: goes on without it");
|
||||
Check.Eq(FakeHost.Chat.Count(l => l.Contains("vendor 'Renald the Grocer'") && l.Contains("didn't open")), 1, "one chat line says so");
|
||||
Check.True(nav.S.EnableNavigation, "nav stays on");
|
||||
}
|
||||
|
||||
private static void VendorPointNotFound()
|
||||
{
|
||||
var nav = VendorRoute(vendorThere: false);
|
||||
nav.Tick();
|
||||
nav.Run(14.0);
|
||||
Check.Eq(nav.Idx, 0, "14 s looking for the vendor: still there");
|
||||
Check.Eq(FakeHost.Uses.Count, 0, "nothing used");
|
||||
nav.Run(1.5);
|
||||
Check.Eq(nav.Idx, 1, "15 s: goes on without it");
|
||||
Check.Eq(FakeHost.Chat.Count(l => l.Contains("vendor 'Renald the Grocer'") && l.Contains("wasn't found")), 1, "one chat line says so");
|
||||
Check.True(nav.S.EnableNavigation, "nav stays on");
|
||||
}
|
||||
|
||||
private static void VendorOpenedElsewhere()
|
||||
{
|
||||
FakeHost.Reset(); At(0, 0);
|
||||
var nav = new Nav(Line(RT.Once, 3, 20));
|
||||
nav.E.NoteVendorOpened(VendorId);
|
||||
nav.Tick();
|
||||
Check.Eq(nav.Idx, 1, "a plain route arrives at [0] and goes on as before");
|
||||
Check.Eq(LogCount("opened for Vendor point"), 0, "the open isn't taken for a Vendor point's");
|
||||
}
|
||||
|
||||
private static void RecallTimeoutNear()
|
||||
{
|
||||
var nav = RecallRoute(30);
|
||||
|
|
@ -867,6 +958,84 @@ internal static class NavEngineTests
|
|||
Check.Eq(nav.Idx, 2, "on to [2]");
|
||||
}
|
||||
|
||||
// ── Long walks through fights, and the start on foot (11-29) ─────────────
|
||||
// Lugian Excavations again: the patrol laid again mid-dungeon started at [0] 425 yd off, and the map's way there was
|
||||
// broken into by a fight every 10-30 s. Every re-plan was nearer, but the third ended the walk ("out of re-plans") and
|
||||
// nav steered straight at [0] through the cave walls until the next fight.
|
||||
|
||||
private static void LongWalkThroughFights()
|
||||
{
|
||||
FakeHost.Reset(); At(14, 40);
|
||||
double walk = 530;
|
||||
var p = new FakePlanner { InSight = _ => false, WalkYd = _ => walk };
|
||||
var nav = new Nav(Square(), idx: 2, planner: p);
|
||||
nav.E.KeepWaypointAfterPause = () => true;
|
||||
nav.Tick();
|
||||
nav.E.Stop();
|
||||
At(14, 52);
|
||||
nav.Run(1.0);
|
||||
Check.Eq(LogCount("started (back from a pause, [2] is behind a wall"), 1, "the map's way to [2]");
|
||||
|
||||
// Five fights on the way, each ending 10 yd from where it began, the walk 40 yd shorter each time.
|
||||
for (int k = 0; k < 5; k++)
|
||||
{
|
||||
nav.E.Stop();
|
||||
At(14, k % 2 == 0 ? 62 : 52);
|
||||
walk -= 40;
|
||||
nav.Run(1.0);
|
||||
}
|
||||
Check.Eq(LogCount("re-planned after a pause"), 5, "planned again after each fight");
|
||||
Check.Eq(LogCount("out of re-plans"), 0, "never out of re-plans while each is nearer");
|
||||
Check.Eq(LogCount("(no nearer"), 0, "none said to be no nearer");
|
||||
Check.True(nav.Recovery.Contains("via fake planner"), $"still walking it ({nav.Recovery})");
|
||||
Check.Eq(LogCount("attempt 2/"), 0, "no second recovery counted against [2]");
|
||||
Check.Eq(LogCount("FAILED"), 0, "nothing failed");
|
||||
|
||||
// Fights that pull it back as far each time: three bring it no nearer, the fourth ends the walk as before.
|
||||
for (int k = 0; k < 4; k++)
|
||||
{
|
||||
nav.E.Stop();
|
||||
At(14, k % 2 == 0 ? 52 : 62);
|
||||
nav.Run(1.0);
|
||||
}
|
||||
Check.Eq(LogCount("(no nearer: 1/3)") + LogCount("(no nearer: 2/3)") + LogCount("(no nearer: 3/3)"), 3, "three said to be no nearer");
|
||||
Check.Eq(LogCount("out of re-plans (3 brought it no nearer than 330yd)"), 1, "then out of re-plans, saying why");
|
||||
Check.False(nav.Recovery.Contains("via fake planner"), $"that walk is over ({nav.Recovery})");
|
||||
}
|
||||
|
||||
private static void NearestOnFootPick()
|
||||
{
|
||||
// The lap's [0] across the dungeon; the lap crosses the character's cave later. [7] is nearest but behind a wall,
|
||||
// [8] has no way there on the map, [9] is a short walk.
|
||||
var route = Route(RT.Circular,
|
||||
Pt(425, 0), Pt(300, 0), Pt(200, 0), Pt(120, 0), Pt(80, 0), Pt(60, 0), Pt(40, 0),
|
||||
Pt(20, 0), Pt(0, 25), Pt(0, 30), Pt(-60, 0), Pt(-140, 0));
|
||||
var walks = new Dictionary<int, double?> { [0] = 520, [7] = 300, [8] = null, [9] = 35 };
|
||||
var asked = new List<int>();
|
||||
double? Walk(NavPoint p)
|
||||
{
|
||||
int i = route.Points.IndexOf(p);
|
||||
asked.Add(i);
|
||||
if (walks.TryGetValue(i, out var w)) return w;
|
||||
var (n, e) = NE(p);
|
||||
return Math.Sqrt(n * n + e * e) * 1.2;
|
||||
}
|
||||
int best = NavigationEngine.NearestOnFoot(route, 0, false, 0, NS0, EW0, Walk, out double yd, candidatesNearest: 6);
|
||||
Check.Eq(best, 9, "the short walk, not the nearer one behind the wall, the one with no way, or [0]");
|
||||
Check.True(Math.Abs(yd - 35) < 1e-9, $"its walk ({yd:F1} yd)");
|
||||
Check.Eq(string.Join(",", asked.OrderBy(i => i)), "0,5,6,7,8,9,10", "the six nearest and the old start asked, no more");
|
||||
|
||||
Check.Eq(NavigationEngine.NearestOnFoot(route, 0, false, 0, NS0, EW0, _ => null, out _, candidatesNearest: 6), -1,
|
||||
"no walk to any: -1 (the patrol keeps its start)");
|
||||
walks[0] = 10;
|
||||
Check.Eq(NavigationEngine.NearestOnFoot(route, 0, false, 0, NS0, EW0, Walk, out _, candidatesNearest: 6), 0,
|
||||
"the old start the shortest walk: kept");
|
||||
|
||||
// Steps are never picked (a portal or a chat point between).
|
||||
var steps = Route(RT.Circular, Pt(300, 0), Pt(5, 0, T.Chat), Pt(20, 0));
|
||||
Check.Eq(NavigationEngine.NearestOnFoot(steps, 0, false, 0, NS0, EW0, p => 1.0, out _), 2, "a tie goes to the nearer; never the chat point");
|
||||
}
|
||||
|
||||
// ── The same on the real map: Lugian Excavations (0x02E7) ───────────────
|
||||
|
||||
/// <summary>The dungeon patrol laid 2026-11-28 18:50:47 from cell 02E70285 (71 points; world x, y, z).</summary>
|
||||
|
|
|
|||
Loading…
Reference in a new issue