Snapshot for release 2026.10.15.1 (internal 6f00bd7)
This commit is contained in:
parent
caaa73a288
commit
a89ae04005
24 changed files with 855 additions and 49 deletions
|
|
@ -28,6 +28,7 @@
|
|||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\LegacyUi\NavRouteParser.cs" Link="Linked\NavRouteParser.cs" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\DungeonPathfinder.cs" Link="Linked\DungeonPathfinder.cs" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\DungeonPathfinder.Rooms.cs" Link="Linked\DungeonPathfinder.Rooms.cs" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\DungeonPathfinder.Sweep.cs" Link="Linked\DungeonPathfinder.Sweep.cs" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\DungeonGeometry.cs" Link="Linked\DungeonGeometry.cs" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\DungeonPatrolOptions.cs" Link="Linked\DungeonPatrolOptions.cs" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAi\DungeonHazardSurfaces.cs" Link="Linked\DungeonHazardSurfaces.cs" />
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace RynthCore.PatrolProof;
|
|||
// summary summary lines only tiny only waypoints in rooms of <= 5 cells
|
||||
// The patrol settings (Settings > Navigation > Dungeon Patrol; DungeonPatrolOptions), default
|
||||
// as in the game:
|
||||
// coverage whole|loops|all spurs N (0-30: dead-end areas of <= N cells skipped) floors on|off walls M (0.5-2) lookin M (3-40)
|
||||
// coverage whole|loops|all|sweep sight M (5-60, sweep's sight distance) spurs N (0-30: dead-end areas of <= N cells skipped) floors on|off walls M (0.5-2) lookin M (3-40)
|
||||
// floors off keeps the surface cells out of the hazards unless hzfile/hz also list them, as
|
||||
// BuildDunPatrol does with the cells in DungeonHazards/<lb>.txt.
|
||||
// modes for each start, one line per setting variant (coverage modes, dead-end limits,
|
||||
|
|
@ -51,7 +51,8 @@ internal static class Waypoints
|
|||
else if (a == "modes") modes = true;
|
||||
else if (a == "pockets") pocketList = true;
|
||||
else if (a == "coverage" && i + 1 < args.Length)
|
||||
opt = opt with { Coverage = args[++i] switch { "loops" => PatrolCoverage.LoopsOnly, "all" or "everything" => PatrolCoverage.Everything, _ => PatrolCoverage.WholeDungeon } };
|
||||
opt = opt with { Coverage = args[++i] switch { "loops" => PatrolCoverage.LoopsOnly, "all" or "everything" => PatrolCoverage.Everything, "sweep" => PatrolCoverage.Sweep, _ => PatrolCoverage.WholeDungeon } };
|
||||
else if (a == "sight" && i + 1 < args.Length) opt = opt with { SightMeters = double.Parse(args[++i], inv) };
|
||||
else if (a == "spurs" && i + 1 < args.Length) opt = opt with { MaxDeadEndCells = int.Parse(args[++i], inv) };
|
||||
else if (a == "floors" && i + 1 < args.Length) opt = opt with { AvoidHazardFloors = args[++i] != "off" };
|
||||
else if (a == "walls" && i + 1 < args.Length) opt = opt with { WallClearance = double.Parse(args[++i], inv) };
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ internal static class ActionPacingTests
|
|||
r.Add("pacing (stop burst): a stop for our own autorun goes through however long ago it was turned on", OldAutorunStopGoesThrough);
|
||||
r.Add("pacing: no answer - each kind's time limit lets the next action go, logged, and nothing is force-cleared", TimeLimits);
|
||||
r.Add("pacing: heals (a plain heal waits for a corpse use's answer, 300 ms at Emergency, one behind a cast's result, 300 ms after the stance reads)", HealRules);
|
||||
r.Add("pacing: the first swing goes 300 ms after the client reads Melee, not the full stance settle; a use still waits for it", FirstSwingAfterStance);
|
||||
r.Add("pacing (vitals): Drakkon 07:03 - a cast whose result is in waits for its UseDone: one cast, not a too-busy flood", CastWaitsForUseDone);
|
||||
r.Add("refusal: a refused mode change begins no paced action, and the next one is not held by it", RefusedBeginsNothing);
|
||||
r.Add("refusal: the engine refusing for 5 s burns nothing; a streak past 30 s counts as a failure again, with one log line each end", RefusalStreakFailsOpen);
|
||||
|
|
@ -352,6 +353,25 @@ internal static class ActionPacingTests
|
|||
Check.False(ActionPacer.MayStart(host, "Buff", HealNeed.None, out _), "a buff waits for the full 800 ms settle");
|
||||
});
|
||||
|
||||
// 2026-10-14: every fight's first swing came 0.8 s after the stance change (ModeSettleMs).
|
||||
private static void FirstSwingAfterStance() => Paced(() =>
|
||||
{
|
||||
var host = World(combatMode: 1);
|
||||
host.ChangeCombatModeFor(CombatMode.Melee, "Combat", "target: Melee mode");
|
||||
_t += 60;
|
||||
Check.False(ActionPacer.MayStart(host, "Combat", HealNeed.None, out _, attackRepeat: true), "the client hasn't read Melee: no swing");
|
||||
FakeHost.CombatModeValue = 2;
|
||||
Check.False(ActionPacer.MayStart(host, "Combat", HealNeed.None, out _, attackRepeat: true), "Melee just read: not yet");
|
||||
_t += 299;
|
||||
Check.False(ActionPacer.MayStart(host, "Combat", HealNeed.None, out _, attackRepeat: true), "299 ms after the read: not yet");
|
||||
_t += 1;
|
||||
Check.True(ActionPacer.MayStart(host, "Combat", HealNeed.None, out _, animationGate: false, settleGate: false, attackRepeat: true),
|
||||
"300 ms after the read: the swing goes");
|
||||
Check.False(ActionPacer.MayStart(host, "Loot", HealNeed.None, out _), "a use still waits for the full 800 ms settle");
|
||||
_t += 500;
|
||||
Check.True(ActionPacer.MayStart(host, "Loot", HealNeed.None, out _), "settled: the use goes");
|
||||
});
|
||||
|
||||
// ── BuffManager ──────────────────────────────────────────────────────────────
|
||||
|
||||
private sealed class BuffRig
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RynthCore.Plugin.RynthAi;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
|
|
@ -30,6 +31,69 @@ internal static class HpFailsafeTests
|
|||
r.Add("hp failsafe: a failed recall does not switch the macro back on past a VTank yield", VTankYieldRespected);
|
||||
r.Add("hp failsafe: our name unreadable: the recall line is taken as ours, and that is logged once", RecallNameUnreadable);
|
||||
r.Add("vitals (L8):a heal the server leaves unanswered is not re-sent at the 2.5 s give-up after a 'too busy' answer", VitalResendObeysLatch);
|
||||
r.Add("vitals: under Emergency Heal At with a weapon out and no usable kit, a health potion before Heal Self's wand swap", EmergencyPotionBeforeWandSwap);
|
||||
r.Add("low components: tapers at 10, a scarab at 2 (not Diamond), kinds never carried ignored, a kind run out still counts", LowComponentsRule);
|
||||
}
|
||||
|
||||
// Recall When Low On Components (RynthAiPlugin.LowComponents.cs), the rule itself.
|
||||
private static void LowComponentsRule()
|
||||
{
|
||||
var seen = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
var counts = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
[RynthAiPlugin.TaperKey] = 250, ["Lead Scarab"] = 12, ["Iron Scarab"] = 3,
|
||||
};
|
||||
Check.Null(RynthAiPlugin.LowComponents(counts, seen, 10, 2), "plenty of everything: nothing low");
|
||||
counts[RynthAiPlugin.TaperKey] = 10;
|
||||
Check.Eq(RynthAiPlugin.LowComponents(counts, seen, 10, 2), "tapers 10", "10 tapers: at the line");
|
||||
counts[RynthAiPlugin.TaperKey] = 11;
|
||||
counts["Iron Scarab"] = 2;
|
||||
Check.Eq(RynthAiPlugin.LowComponents(counts, seen, 10, 2), "Iron Scarab 2", "2 Iron Scarabs: low");
|
||||
counts.Remove("Iron Scarab"); // used the last ones: gone from the pack
|
||||
Check.Eq(RynthAiPlugin.LowComponents(counts, seen, 10, 2), "Iron Scarab 0", "run out entirely: still low (seen before)");
|
||||
Check.Null(RynthAiPlugin.LowComponents(counts, seen, 10, 0), "Low Scarabs At 0: scarabs aren't checked");
|
||||
|
||||
var fighter = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
Check.Null(RynthAiPlugin.LowComponents(new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase), fighter, 10, 2),
|
||||
"a character that never carried tapers or scarabs is never low");
|
||||
|
||||
var inv = new[]
|
||||
{
|
||||
new WorldObject(1, "Prismatic Taper"), new WorldObject(2, "Red Taper"),
|
||||
new WorldObject(3, "Diamond Scarab"), new WorldObject(4, "Mana Scarab"), new WorldObject(5, "Scarab Shell Armor"),
|
||||
};
|
||||
var c = RynthAiPlugin.CountComponents(inv);
|
||||
Check.Eq(c.GetValueOrDefault(RynthAiPlugin.TaperKey), 2, "every kind of taper counts together");
|
||||
Check.False(c.ContainsKey("Diamond Scarab"), "Diamond Scarabs never count");
|
||||
Check.Eq(c.GetValueOrDefault("Mana Scarab"), 1, "a Mana Scarab counts");
|
||||
Check.Eq(c.Count, 2, "only tapers and scarabs (not 'Scarab Shell Armor')");
|
||||
}
|
||||
|
||||
// Drakkon, 2026-10-14: 15% health in melee among Depraved Shadows, the kit at 3% (under Kit Min
|
||||
// Success), and the chain went to Heal Self: a wand swap still unanswered when he died 3.2 s later.
|
||||
// The potion came after Heal Self, so it was never reached. Now the emergency step drinks first.
|
||||
private static void EmergencyPotionBeforeWandSwap()
|
||||
{
|
||||
const uint Potion = 0x80001234;
|
||||
try
|
||||
{
|
||||
var r = new Rig(healthPct: 15);
|
||||
FakeHost.CombatModeValue = CombatMode.Melee;
|
||||
FakeHost.Names[Potion] = "Healing Elixir";
|
||||
r.S.UsePotions = true;
|
||||
r.S.ConsumableRules.Add(new ConsumableRule { Id = unchecked((int)Potion), Name = "Healing Elixir", Type = "HealthPotion" });
|
||||
var cache = new WorldObjectCache(r.Host);
|
||||
cache.SetPlayerId(Player);
|
||||
cache.OnCreateObject(Player);
|
||||
_ = cache[unchecked((int)Potion)];
|
||||
cache.Tick();
|
||||
r.B.SetWorldObjectCache(cache);
|
||||
|
||||
r.Run(0, 0.3);
|
||||
Check.True(FakeHost.Uses.Contains(Potion), "the health potion is drunk: " + string.Join(" | ", FakeHost.Logs.Where(l => l.Contains("Vitals")).Take(10)));
|
||||
Check.Eq(FakeHost.Casts.Count, 0, "no Heal Self cast (no wand swap) while the potion goes");
|
||||
}
|
||||
finally { Done(); }
|
||||
}
|
||||
|
||||
// No re-send into a busy server: a client log re-sent a heal every 2.5 s (the vitals give-up) into a server
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ internal static class ManaReserveTests
|
|||
r.Add("mana reserve: under 1.5x Stamina to Mana's cost, Stamina to Mana is chosen over an attack", ReserveChoosesStaminaToMana);
|
||||
r.Add("mana reserve: under Stamina to Mana's cost, no attack spam and no 15 s park on 'not enough Mana'", StarvedNoSpamNoPark);
|
||||
r.Add("mana reserve: as mana regenerates, the level it can pay for goes, then attacks resume", RecoversAsManaRegenerates);
|
||||
r.Add("mana reserve: stamina too low for Stamina to Mana - stamina is refilled first", StaminaFirst);
|
||||
r.Add("mana reserve: stamina too low for Stamina to Mana (under Re-stam At, at least 15%) - stamina is refilled first", StaminaFirst);
|
||||
r.Add("mana reserve: combat holds an attack it can't pay for, and casts once mana is back", CombatHoldsCast);
|
||||
r.Add("mana reserve: a melee fighter's attacks aren't held; Get Mana At off means no reserve", MeleeAndOff);
|
||||
r.Add("mana reserve: the dat's BaseMana is read (when this PC has a portal.dat)", DatBaseMana);
|
||||
|
|
@ -212,6 +212,18 @@ internal static class ManaReserveTests
|
|||
off.S.RestamAt = 0;
|
||||
Check.True(off.B.CheckVitals(), "Re-stam At 0: still refilled for Stamina to Mana");
|
||||
Check.Eq(FamilyOfCast(0), Family("Revitalize Self I"), "Revitalize");
|
||||
|
||||
// 2026-10-14: the floor is Re-stam At (when over 15): at 25% stamina with Re-stam At 30,
|
||||
// stamina is refilled before Stamina to Mana (each one cost Drakkon 110-126 stamina).
|
||||
var floor = new Rig(mana: 50, stamina: 96); // 25%
|
||||
floor.S.RestamAt = 30;
|
||||
Check.Eq(floor.B.StaminaToManaFloorPct(), 30, "the floor is Re-stam At");
|
||||
Check.True(floor.B.CheckVitals(), "vitals act");
|
||||
Check.Eq(FamilyOfCast(0), Family("Revitalize Self I"), $"25% under Re-stam At 30: stamina first ({NameOf(FakeHost.Casts[0].SpellId)})");
|
||||
var over = new Rig(mana: 50, stamina: 134); // 35%
|
||||
over.S.RestamAt = 30;
|
||||
Check.True(over.B.CheckVitals(), "vitals act");
|
||||
Check.Eq(FamilyOfCast(0), Family("Stamina to Mana Self I"), $"35%: Stamina to Mana ({NameOf(FakeHost.Casts[0].SpellId)})");
|
||||
}
|
||||
|
||||
private static void CombatHoldsCast()
|
||||
|
|
@ -262,11 +274,14 @@ internal static class ManaReserveTests
|
|||
|
||||
private static void MeleeAndOff()
|
||||
{
|
||||
// A melee fighter (no combat manager: the stance decides) at low mana: no reserve, no hold.
|
||||
// A melee fighter (no combat manager: the stance decides) at low mana: no hold of the fight.
|
||||
var melee = new Rig(mana: 1, combatMode: CombatMode.Melee);
|
||||
Check.False(melee.B.WantsManaNow(), "melee: vitals don't hold the fight for mana");
|
||||
melee.V.CurrentMana = 85; // 22%: over Get Mana At 20%, under a caster's reserve (90)
|
||||
Check.False(melee.B.ManaUnderLine(true, out int line), $"melee: only Get Mana At ({line})");
|
||||
// But the reserve is its refill line too (2026-10-14: a melee character's buffs spent mana under
|
||||
// Stamina to Mana's cost and nothing could refill it).
|
||||
melee.V.CurrentMana = 85; // 22%: over Get Mana At 20%, under the reserve (90)
|
||||
Check.True(melee.B.ManaUnderLine(true, out int line), $"melee: under the reserve ({line})");
|
||||
Check.Eq(line, 90, "the line is the reserve");
|
||||
|
||||
// Get Mana At 0 (mana recharge off in combat): no reserve, nothing held.
|
||||
var off = new Rig(mana: 100, getManaAt: 0);
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ internal static class PatrolDoorwayTests
|
|||
r.Add("dungeon doorways: in a short chamfered bend (crypt corner) the points come off the bend's outer wall", ChamferedBend);
|
||||
r.Add("dungeon patrol: a dead end's look-in point comes out of the end cap onto the floor", DeadEndLookInOnFloor);
|
||||
r.Add("dungeon legs: a leg cutting an inside corner gets a corner put in", LegAroundInsideCorner);
|
||||
r.Add("dungeon patrol (sweep): a pillar hall is walked in lanes, every cell within sight of the route; far fewer points than Whole dungeon", SweepPillarHall);
|
||||
r.Add("dungeon patrol (sweep): a wall blocks sight, so two corridors side by side are both walked", SweepWallBlocksSight);
|
||||
}
|
||||
|
||||
// ── Fixture builder ──────────────────────────────────────────────────────
|
||||
|
|
@ -143,6 +145,93 @@ internal static class PatrolDoorwayTests
|
|||
new V3((float)x1, (float)y1, 3f), new V3((float)x0, (float)y0, 3f),
|
||||
};
|
||||
|
||||
// A 10 x 10 hall of 5 m cells joined by 3 m openings (doorways, so 100 rooms): to the patrol,
|
||||
// what the 0x00AE pillar hall is (2026-10-14).
|
||||
private static (Dungeon D, uint[,] Cells) PillarHall(int n = 10, double size = 5)
|
||||
{
|
||||
var d = new Dungeon();
|
||||
var c = new uint[n, n];
|
||||
for (int i = 0; i < n; i++)
|
||||
for (int j = 0; j < n; j++)
|
||||
c[i, j] = d.Cell(i * size, j * size, (i + 1) * size, (j + 1) * size);
|
||||
for (int i = 0; i < n; i++)
|
||||
for (int j = 0; j < n; j++)
|
||||
{
|
||||
double x0 = i * size, y0 = j * size;
|
||||
if (i + 1 < n) d.OpenX(c[i, j], c[i + 1, j], x0 + size, y0 + 1, y0 + 4);
|
||||
if (j + 1 < n) d.OpenY(c[i, j], c[i, j + 1], y0 + size, x0 + 1, x0 + 4);
|
||||
}
|
||||
return (d, c);
|
||||
}
|
||||
|
||||
private static void SweepPillarHall()
|
||||
{
|
||||
var (d, c) = PillarHall();
|
||||
var geo = d.Geo();
|
||||
var whole = DungeonPathfinder.BuildPatrolRoute(d.Graph, c[0, 0], null, geo);
|
||||
var sweep = DungeonPathfinder.BuildPatrolRoute(d.Graph, c[0, 0], null, geo,
|
||||
new DungeonPatrolOptions { Coverage = PatrolCoverage.Sweep, SightMeters = 15 });
|
||||
Check.True(sweep.Points.Count > 0 && sweep.Points.Count * 2 < whole.Points.Count,
|
||||
$"sweep {sweep.Points.Count} points, whole dungeon {whole.Points.Count}");
|
||||
Check.Eq(DungeonPathfinder.LastSweepSeen, DungeonPathfinder.LastSweepCells, "every cell is seen by a stop");
|
||||
Check.True(DungeonPathfinder.LastSweepStops > 1 && DungeonPathfinder.LastSweepStops < 40, $"{DungeonPathfinder.LastSweepStops} stops for 100 cells");
|
||||
// Every cell's middle within the sight distance of the route (its points or the legs between them).
|
||||
double worst = 0;
|
||||
foreach (var node in d.Graph.Values)
|
||||
{
|
||||
double cx = DungeonGeometry.NavToWorld(node.EW), cy = DungeonGeometry.NavToWorld(node.NS), best = double.MaxValue;
|
||||
for (int i = 0; i < sweep.Points.Count; i++)
|
||||
{
|
||||
var a = sweep.Points[i]; var b = sweep.Points[(i + 1) % sweep.Points.Count];
|
||||
best = Math.Min(best, SegDist(cx, cy, X(a), Y(a), X(b), Y(b)));
|
||||
}
|
||||
worst = Math.Max(worst, best);
|
||||
}
|
||||
// The route goes through a stop's doorways, not its exact middle: within half a cell of the sight.
|
||||
Check.True(worst <= 15.0 + 2.5, $"the farthest cell is {worst:F1} m from the route (sight 15, cells 5 m)");
|
||||
int stops15 = DungeonPathfinder.LastSweepStops;
|
||||
DungeonPathfinder.BuildPatrolRoute(d.Graph, c[0, 0], null, geo,
|
||||
new DungeonPatrolOptions { Coverage = PatrolCoverage.Sweep, SightMeters = 30 });
|
||||
Check.True(DungeonPathfinder.LastSweepStops < stops15, $"a longer sight, fewer stops ({DungeonPathfinder.LastSweepStops} vs {stops15})");
|
||||
}
|
||||
|
||||
private static void SweepWallBlocksSight()
|
||||
{
|
||||
// Two corridors of 8 cells (y 0..5 and 5..10), joined only at their two ends, a wall all along
|
||||
// between them. Without the wall one corridor's walk would see the other at 15 m.
|
||||
var d = new Dungeon();
|
||||
var a = new uint[8]; var b = new uint[8];
|
||||
for (int i = 0; i < 8; i++) { a[i] = d.Cell(i * 5, 0, i * 5 + 5, 5); b[i] = d.Cell(i * 5, 5, i * 5 + 5, 10); }
|
||||
for (int i = 0; i + 1 < 8; i++) { d.OpenX(a[i], a[i + 1], i * 5 + 5, 1, 4); d.OpenX(b[i], b[i + 1], i * 5 + 5, 6, 9); }
|
||||
d.OpenY(a[0], b[0], 5, 1, 4);
|
||||
d.OpenY(a[7], b[7], 5, 36, 39);
|
||||
for (int i = 1; i < 7; i++) { d.Wall(a[i], i * 5, 5, i * 5 + 5, 5); d.Wall(b[i], i * 5, 5, i * 5 + 5, 5); }
|
||||
var geo = d.Geo();
|
||||
var sweep = DungeonPathfinder.BuildPatrolRoute(d.Graph, a[0], null, geo,
|
||||
new DungeonPatrolOptions { Coverage = PatrolCoverage.Sweep, SightMeters = 15 });
|
||||
Check.Eq(DungeonPathfinder.LastSweepSeen, DungeonPathfinder.LastSweepCells, "every cell seen");
|
||||
// A leg along each corridor through its middle (x 20).
|
||||
bool Leg(Func<double, bool> side)
|
||||
{
|
||||
for (int i = 0; i < sweep.Points.Count; i++)
|
||||
{
|
||||
var p = sweep.Points[i]; var q = sweep.Points[(i + 1) % sweep.Points.Count];
|
||||
if (Math.Min(X(p), X(q)) < 20 && Math.Max(X(p), X(q)) > 20 && side(Y(p)) && side(Y(q))) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool south = Leg(y => y < 5), north = Leg(y => y > 5);
|
||||
Check.True(south && north, "both corridors walked in the middle: " + string.Join(" ", sweep.Points.Select(p => $"({X(p):F0},{Y(p):F0})")));
|
||||
}
|
||||
|
||||
private static double SegDist(double px, double py, double ax, double ay, double bx, double by)
|
||||
{
|
||||
double dx = bx - ax, dy = by - ay, l2 = dx * dx + dy * dy;
|
||||
double t = l2 < 1e-9 ? 0 : Math.Clamp(((px - ax) * dx + (py - ay) * dy) / l2, 0, 1);
|
||||
double qx = ax + dx * t - px, qy = ay + dy * t - py;
|
||||
return Math.Sqrt(qx * qx + qy * qy);
|
||||
}
|
||||
|
||||
private static double X(NavPoint p) => DungeonGeometry.NavToWorld(p.EW);
|
||||
private static double Y(NavPoint p) => DungeonGeometry.NavToWorld(p.NS);
|
||||
|
||||
|
|
@ -554,8 +643,13 @@ internal static class PatrolDoorwayTests
|
|||
var (d, west, corner, north) = ChamferDungeon();
|
||||
var geo = d.Geo();
|
||||
var pts = Path(d, geo, -8, 1.67, 5, 15, west, corner, north);
|
||||
var inBend = pts.Where(p => X(p) > 0 && Y(p) < 6.67).ToList();
|
||||
Check.True(inBend.Count >= 1, $"points in the bend ({inBend.Count})");
|
||||
// The bend is walked through: a point at or past the west opening and one at or before the
|
||||
// north one. Since 2026-10-14 the two openings (at right angles) are one run: their centres,
|
||||
// and the leg between cuts the chamfer (the checks below keep it on the floor and off the walls).
|
||||
string path = string.Join(" ", pts.Select(p => $"({X(p):F2},{Y(p):F2})"));
|
||||
Check.True(pts.Any(p => X(p) >= -0.01 && Y(p) < 6.67) && pts.Any(p => X(p) > 0 && Y(p) <= 6.68),
|
||||
"the path goes through the bend: " + path);
|
||||
Check.True(pts.Count <= 5, "no doubling back in the bend: " + path);
|
||||
foreach (var p in pts)
|
||||
Check.True(Clear(geo, p) >= 0.98, $"({X(p):F2}, {Y(p):F2}) is 1 m from every wall ({Clear(geo, p):F2})");
|
||||
// Before: the exit point on the west opening's centre line, 1 m in: 0.47 m from the outer wall.
|
||||
|
|
|
|||
|
|
@ -154,39 +154,47 @@ internal static class PatrolSettingsTests
|
|||
var s = new LegacyUiSettings
|
||||
{
|
||||
DunPatrolCoverage = 7, DunPatrolSkipDeadEnds = 99, DunPatrolAvoidFloors = false,
|
||||
DunPatrolWallDistance = 9f, DunPatrolLookInSize = -4f,
|
||||
DunPatrolWallDistance = 9f, DunPatrolLookInSize = -4f, DunPatrolSightYd = 200f,
|
||||
};
|
||||
var o = RynthAiPlugin.PatrolOptionsFrom(s);
|
||||
Check.Eq(o.Coverage, PatrolCoverage.Everything, "coverage 7 -> 2 (everything)");
|
||||
Check.Eq(o.Coverage, PatrolCoverage.Sweep, "coverage 7 -> 3 (sweep, the last)");
|
||||
Check.Near(o.SightMeters, 60.0, 1e-9, "sight 200 -> 60 m");
|
||||
Check.Eq(o.MaxDeadEndCells, 30, "dead ends 99 -> 30");
|
||||
Check.False(o.AvoidHazardFloors, "floors off");
|
||||
Check.Near(o.WallClearance, 2.0, 1e-9, "walls 9 -> 2 m");
|
||||
Check.Near(o.LookInRoomMeters, 3.0, 1e-9, "look-in -4 -> 3 m");
|
||||
s.DunPatrolCoverage = 1; s.DunPatrolSkipDeadEnds = 5; s.DunPatrolWallDistance = 1.5f; s.DunPatrolLookInSize = 20f;
|
||||
s.DunPatrolCoverage = 1; s.DunPatrolSkipDeadEnds = 5; s.DunPatrolWallDistance = 1.5f; s.DunPatrolLookInSize = 20f; s.DunPatrolSightYd = 25f;
|
||||
o = RynthAiPlugin.PatrolOptionsFrom(s);
|
||||
Check.True(o.Coverage == PatrolCoverage.LoopsOnly && o.MaxDeadEndCells == 5 && o.WallClearance == 1.5 && o.LookInRoomMeters == 20,
|
||||
Check.True(o.Coverage == PatrolCoverage.LoopsOnly && o.MaxDeadEndCells == 5 && o.WallClearance == 1.5 && o.LookInRoomMeters == 20 && o.SightMeters == 25,
|
||||
"in-range values pass through: " + o.Describe());
|
||||
s.DunPatrolCoverage = 3;
|
||||
o = RynthAiPlugin.PatrolOptionsFrom(s);
|
||||
Check.True(o.Coverage == PatrolCoverage.Sweep && o.Describe().Contains("sight 25 m"), "sweep, and its sight in the description: " + o.Describe());
|
||||
}
|
||||
|
||||
private static void EnginePayload()
|
||||
{
|
||||
var s = new LegacyUiSettings { DunPatrolCoverage = 1, DunPatrolSkipDeadEnds = 6, DunPatrolAvoidFloors = false, DunPatrolWallDistance = 1.25f, DunPatrolLookInSize = 15f };
|
||||
var s = new LegacyUiSettings { DunPatrolCoverage = 1, DunPatrolSkipDeadEnds = 6, DunPatrolAvoidFloors = false, DunPatrolWallDistance = 1.25f, DunPatrolLookInSize = 15f, DunPatrolSightYd = 30f };
|
||||
var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer));
|
||||
typeof(LegacyDashboardRenderer).GetField("_settings", BindingFlags.NonPublic | BindingFlags.Instance)!.SetValue(dash, s);
|
||||
typeof(LegacyDashboardRenderer).GetField("_advancedSettingsUi", BindingFlags.NonPublic | BindingFlags.Instance)!
|
||||
.SetValue(dash, new LegacyAdvancedSettingsUi(s));
|
||||
var sent = JsonSerializer.Deserialize(dash.BuildSettingsJson(), RynthAiJsonContext.Default.SettingsBridgePayload)!;
|
||||
Check.True(sent.DunPatrolCoverage == 1 && sent.DunPatrolSkipDeadEnds == 6 && sent.DunPatrolAvoidFloors == false
|
||||
&& sent.DunPatrolWallDistance == 1.25f && sent.DunPatrolLookInSize == 15f, "every patrol setting sent to the engine face");
|
||||
&& sent.DunPatrolWallDistance == 1.25f && sent.DunPatrolLookInSize == 15f && sent.DunPatrolSightYd == 30f, "every patrol setting sent to the engine face");
|
||||
|
||||
dash.ApplySettingsJson("{\"PatrolOnLogin\":false}");
|
||||
Check.True(s.DunPatrolCoverage == 1 && s.DunPatrolSkipDeadEnds == 6 && !s.DunPatrolAvoidFloors && s.DunPatrolWallDistance == 1.25f
|
||||
&& s.DunPatrolLookInSize == 15f, "a save from an engine without them leaves them alone");
|
||||
&& s.DunPatrolLookInSize == 15f && s.DunPatrolSightYd == 30f, "a save from an engine without them leaves them alone");
|
||||
dash.ApplySettingsJson("{\"DunPatrolCoverage\":3,\"DunPatrolSightYd\":40}");
|
||||
Check.True(s.DunPatrolCoverage == 3 && s.DunPatrolSightYd == 40f, "sweep and its sight applied");
|
||||
dash.ApplySettingsJson("{\"DunPatrolSightYd\":1}");
|
||||
Check.True(s.DunPatrolSightYd == 5f, "sight 1 -> 5 (clamped)");
|
||||
dash.ApplySettingsJson("{\"DunPatrolCoverage\":2,\"DunPatrolSkipDeadEnds\":0,\"DunPatrolAvoidFloors\":true,\"DunPatrolWallDistance\":0.75,\"DunPatrolLookInSize\":30}");
|
||||
Check.True(s.DunPatrolCoverage == 2 && s.DunPatrolSkipDeadEnds == 0 && s.DunPatrolAvoidFloors && s.DunPatrolWallDistance == 0.75f
|
||||
&& s.DunPatrolLookInSize == 30f, "a save with them applies them");
|
||||
dash.ApplySettingsJson("{\"DunPatrolCoverage\":9,\"DunPatrolSkipDeadEnds\":40,\"DunPatrolWallDistance\":0.1,\"DunPatrolLookInSize\":100}");
|
||||
Check.True(s.DunPatrolCoverage == 2 && s.DunPatrolSkipDeadEnds == 30 && s.DunPatrolWallDistance == 0.5f && s.DunPatrolLookInSize == 40f,
|
||||
Check.True(s.DunPatrolCoverage == 3 && s.DunPatrolSkipDeadEnds == 30 && s.DunPatrolWallDistance == 0.5f && s.DunPatrolLookInSize == 40f,
|
||||
$"out of range clamped ({s.DunPatrolCoverage}, {s.DunPatrolSkipDeadEnds}, {s.DunPatrolWallDistance}, {s.DunPatrolLookInSize})");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ internal static class WeaponTests
|
|||
r.Add("refusal: a refused stance change in combat's equip pass sets no backoff and starts no stuck clock", StanceRefusedKeepsBackoff);
|
||||
r.Add("weapon choice: an unlisted wand is never picked (Damage tab, learned, pack, name)", UnlistedNeverPicked);
|
||||
r.Add("Items list: a listed item no longer carried is reported missing (pack, hand, unknown)", MissingFromPack);
|
||||
r.Add("weapon choice: a listed weapon someone else now has (sold) is skipped, even as this monster's Damage tab pick", SoldWeaponSkipped);
|
||||
r.Add("weapon swap: one in flight, confirmed, retry cap, then what's in hand", SwapOneInFlight);
|
||||
r.Add("weapon swap: no flip-flop between two weapons", SwapNoFlipFlop);
|
||||
r.Add("weapon swap: a new target that wants the weapon just swapped away from gets it at once (Drakkon 2026-10-12)", SwapBackForNewTarget);
|
||||
|
|
@ -670,6 +671,46 @@ internal static class WeaponTests
|
|||
}
|
||||
}
|
||||
|
||||
// 2026-10-14: a sold Flaming Greataxe, still listed and still known to the client, was the weapon
|
||||
// chosen for the monster; three wield tries over 13 s with the character standing in the fight.
|
||||
private static void SoldWeaponSkipped()
|
||||
{
|
||||
const uint Vendor = 0x80099999;
|
||||
FakeHost.Reset();
|
||||
FakeHost.WeaponCalls = true;
|
||||
FakeHost.CombatModeValue = CombatMode.Magic;
|
||||
FakeHost.Names[ListedWand] = "Wand"; FakeHost.ItemTypes[ListedWand] = 0x8000;
|
||||
FakeHost.Ints[(ListedWand, 45)] = 0x40; // Lightning
|
||||
FakeHost.Names[FireWand] = "Fire Wand"; FakeHost.ItemTypes[FireWand] = 0x8000;
|
||||
FakeHost.Ints[(FireWand, 18)] = 0x20; // Fire
|
||||
FakeHost.Wcids[Monster] = 1535;
|
||||
FakeHost.Containers[ListedWand] = Player; // ours
|
||||
FakeHost.Containers[FireWand] = Vendor; // sold: the vendor has it now
|
||||
var host = FakeHost.Create();
|
||||
var cache = FakeHost.MakeCache(host, Player, new[] { ListedWand, FireWand });
|
||||
var s = new LegacyUiSettings();
|
||||
var store = new MonsterDamageStore();
|
||||
var c = new CombatManager(host, s, cache);
|
||||
c.SetPlayerId(Player);
|
||||
c.SetDamageStores(null, store);
|
||||
c.CanCastOverride = e => e != "Nether";
|
||||
s.ItemRules = new List<ItemRule>
|
||||
{
|
||||
new() { Id = unchecked((int)ListedWand), Name = "Wand", Element = "Lightning", ElementSource = "properties" },
|
||||
new() { Id = unchecked((int)FireWand), Name = "Fire Wand", Element = "Fire", ElementSource = "properties" },
|
||||
};
|
||||
store.SetManualWeapon(1535, FireWand); // the Damage tab's pick for this monster
|
||||
var target = new WorldObject(unchecked((int)Monster), "Ethereal Wisp", AcObjectClass.Monster);
|
||||
|
||||
var plan = c.PlanFor(target, null);
|
||||
Check.Eq(unchecked((uint)plan.WeaponId), ListedWand, "the carried wand, not the sold Damage tab pick");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("isn't in your pack")), "the skip is logged: " + string.Join(" | ", FakeHost.Logs.Take(10)));
|
||||
Check.Eq(c.ListedCandidates().Count, 1, "the sold weapon isn't a candidate at all");
|
||||
|
||||
FakeHost.Containers[FireWand] = Player; // bought back
|
||||
Check.Eq(c.ListedCandidates().Count, 2, "back in the pack: a candidate again");
|
||||
}
|
||||
|
||||
private static void MissingFromPack()
|
||||
{
|
||||
// 2026-10-11: Drakkon's buff wand left his pack and the Items slot still just said "Wand".
|
||||
|
|
|
|||
Loading…
Reference in a new issue