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
|
|
@ -177,6 +177,8 @@ internal sealed partial class NavigationEngine
|
|||
public long PausedAt;
|
||||
public double PausedNs = double.NaN, PausedEw = double.NaN;
|
||||
public int Replans;
|
||||
public int StalledReplans; // re-plans that brought the walk no nearer (DetourMaxReplans of them end it)
|
||||
public double BestYd = double.MaxValue; // the shortest plan so far
|
||||
public int DoorRequestCount;
|
||||
public long NextDoorCheckAt;
|
||||
public readonly Dictionary<int, int> DoorRequests = new();
|
||||
|
|
@ -189,7 +191,8 @@ internal sealed partial class NavigationEngine
|
|||
private const int StuckSpotRepeat = 3; // stucks within StuckSpotYards: go straight to a detour
|
||||
private const double StuckSpotYards = 5.0;
|
||||
private const double DetourReplanMovedYd = 5.0; // moved this far while paused: plan again
|
||||
private const int DetourMaxReplans = 3;
|
||||
private const int DetourMaxReplans = 3; // re-plans that bring the walk no nearer
|
||||
private const double DetourReplanNearerYd = 5.0; // a re-plan at least this much shorter than the best so far is progress
|
||||
private const double DetourDoorCheckMs = 400.0;
|
||||
private const double DetourDoorLookYd = 12.0; // look for doors this far along the next leg
|
||||
private const double DetourDoorCorridorYd = 3.0; // ... and this close to it
|
||||
|
|
@ -689,11 +692,15 @@ internal sealed partial class NavigationEngine
|
|||
case NavPointType.Npc when _npcTalkIdx == idx && ReferenceEquals(_npcTalkRoute, route):
|
||||
HandleNpcTalk(pt, route);
|
||||
return;
|
||||
case NavPointType.OpenVendor when _vendorIdx == idx && ReferenceEquals(_vendorRoute, route):
|
||||
HandleVendorVisit(pt, route);
|
||||
return;
|
||||
}
|
||||
|
||||
// ── Standard coordinate waypoint ─────────────────────────────────────
|
||||
_portalState = PortalState.None;
|
||||
_npcTalkIdx = -1;
|
||||
_vendorIdx = -1;
|
||||
_inPause = false;
|
||||
_teleportedRoute = null;
|
||||
_firedRoute = null;
|
||||
|
|
@ -749,6 +756,7 @@ internal sealed partial class NavigationEngine
|
|||
// Advance before the jump: the Jumper pauses nav and later restores what it
|
||||
// saw, so jumping first turned a finished Once route back on (re-run from [0]).
|
||||
if (BeginNpcTalk(pt, route, idx)) return; // an NPC point advances once the NPC was used (NavigationEngine.NpcTalk.cs)
|
||||
if (BeginVendorVisit(pt, route, idx)) return; // a Vendor point, once the vendor was opened (NavigationEngine.VendorVisit.cs)
|
||||
Advance(route);
|
||||
if (pt.Type == NavPointType.Jump) FireJump(pt, idx);
|
||||
return;
|
||||
|
|
@ -766,6 +774,7 @@ internal sealed partial class NavigationEngine
|
|||
_closestDist = double.MaxValue;
|
||||
UpdateStatusLine(idx, dist, route, 0.0);
|
||||
if (BeginNpcTalk(pt, route, idx)) return; // an NPC point advances once the NPC was used (NavigationEngine.NpcTalk.cs)
|
||||
if (BeginVendorVisit(pt, route, idx)) return; // a Vendor point, once the vendor was opened (NavigationEngine.VendorVisit.cs)
|
||||
Advance(route);
|
||||
if (pt.Type == NavPointType.Jump) FireJump(pt, idx);
|
||||
return;
|
||||
|
|
@ -778,6 +787,7 @@ internal sealed partial class NavigationEngine
|
|||
_host.Log($"Nav: sweep-pass [{idx}] closest={_closestDist:F1} now={dist:F1}yd → advancing");
|
||||
_closestDist = double.MaxValue;
|
||||
if (BeginNpcTalk(pt, route, idx)) return; // an NPC point advances once the NPC was used (NavigationEngine.NpcTalk.cs)
|
||||
if (BeginVendorVisit(pt, route, idx)) return; // a Vendor point, once the vendor was opened (NavigationEngine.VendorVisit.cs)
|
||||
Advance(route);
|
||||
if (pt.Type == NavPointType.Jump) FireJump(pt, idx);
|
||||
return;
|
||||
|
|
@ -1176,9 +1186,22 @@ internal sealed partial class NavigationEngine
|
|||
if (_planner == null || !_host.HasGetPlayerPose) return -1;
|
||||
if (!_host.TryGetPlayerPose(out uint cell, out _, out _, out _, out _, out _, out _, out _)) return -1;
|
||||
if ((cell & 0xFFFF) < 0x0100) return -1;
|
||||
// The planner's walk length: a waypoint in your own room with nothing in the way is the straight line to it
|
||||
// (TryPlan has no plan for it, and it was left out: Desert Mine 2026-11-27).
|
||||
return NearestOnFoot(route, from, once, cur, ns, ew, _planner.WalkLengthYd, out walkYd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Of the <paramref name="candidatesNearest"/> plain waypoints nearest (<paramref name="ns"/>, <paramref name="ew"/>) by map
|
||||
/// distance (from <paramref name="from"/> on; a Once route stops at its next step), plus <paramref name="cur"/>, the one
|
||||
/// <paramref name="walk"/> says is the shortest walk (ties: the first looked at). -1 when none has a walk. The macro
|
||||
/// start's pick indoors, and the dungeon patrol's start when nothing of it is in sight (RynthAiCommands.TryBuildDunPatrol).
|
||||
/// </summary>
|
||||
internal static int NearestOnFoot(NavRouteParser route, int from, bool once, int cur, double ns, double ew,
|
||||
Func<NavPoint, double?> walk, out double walkYd, int candidatesNearest = WalkCandidates)
|
||||
{
|
||||
var near = new List<(int Idx, double D)>();
|
||||
for (int i = from; i < route.Points.Count; i++)
|
||||
for (int i = Math.Max(0, from); i < route.Points.Count; i++)
|
||||
{
|
||||
var p = route.Points[i];
|
||||
if (once && !NavRouteParser.IsPlainWaypoint(p.Type)) break;
|
||||
|
|
@ -1187,17 +1210,15 @@ internal sealed partial class NavigationEngine
|
|||
}
|
||||
near.Sort((a, b) => a.D.CompareTo(b.D));
|
||||
var candidates = new List<int>();
|
||||
for (int k = 0; k < near.Count && k < WalkCandidates; k++) candidates.Add(near[k].Idx);
|
||||
if (IndexValid(cur, route) && cur >= from && NavRouteParser.IsPlainWaypoint(route.Points[cur].Type) && !candidates.Contains(cur))
|
||||
for (int k = 0; k < near.Count && k < candidatesNearest; k++) candidates.Add(near[k].Idx);
|
||||
if (cur >= from && cur < route.Points.Count && NavRouteParser.IsPlainWaypoint(route.Points[cur].Type) && !candidates.Contains(cur))
|
||||
candidates.Add(cur);
|
||||
|
||||
int best = -1;
|
||||
double bestYd = double.MaxValue;
|
||||
foreach (int i in candidates)
|
||||
{
|
||||
// The planner's walk length: a waypoint in your own room with nothing in the way is the straight line to it
|
||||
// (TryPlan has no plan for it, and it was left out: Desert Mine 2026-11-27).
|
||||
double? yd = _planner.WalkLengthYd(route.Points[i]);
|
||||
double? yd = walk(route.Points[i]);
|
||||
if (yd == null) continue;
|
||||
if (yd.Value < bestYd) { bestYd = yd.Value; best = i; }
|
||||
}
|
||||
|
|
@ -3420,6 +3441,7 @@ internal sealed partial class NavigationEngine
|
|||
RejoinIdx = rejoin,
|
||||
Skipped = skipped,
|
||||
LengthYd = plan.LengthYd,
|
||||
BestYd = plan.LengthYd,
|
||||
Doorways = plan.Doorways,
|
||||
StartedAt = now,
|
||||
// Generous: ~0.6 s per yard (a slow walk) plus room for a door or two.
|
||||
|
|
@ -3544,11 +3566,17 @@ internal sealed partial class NavigationEngine
|
|||
DriveHeading(error, currentDeg, dist);
|
||||
}
|
||||
|
||||
// 2026-11-29, Lugian Excavations (0x02E7) on the patrol: the walk back to a waypoint 425 yd off (the map's way, 20
|
||||
// points, 5 doorways) was broken into by a fight every 10-30 s (Deepvein lugians all the way). Each fight re-planned it
|
||||
// from where it ended, every one nearer (531 -> 460 -> 442 -> 422 yd), but the third re-plan used the walk up: "out of
|
||||
// re-plans", a failed recovery, and nav steered straight at the waypoint, through the cave walls, until the next fight.
|
||||
// Three of those used up the waypoint's recoveries (the stuck escapes, running at the wall). A re-plan that is nearer
|
||||
// is the walk going well between fights: only the re-plans that bring it no nearer count.
|
||||
private bool ReplanDetour(NavRouteParser route, Detour d, double movedYd)
|
||||
{
|
||||
if (_planner == null || d.Replans >= DetourMaxReplans)
|
||||
if (_planner == null)
|
||||
{
|
||||
EndDetour($"moved {movedYd:F0}yd while paused and out of re-plans", success: false);
|
||||
EndDetour($"moved {movedYd:F0}yd while paused and no planner", success: false);
|
||||
return false;
|
||||
}
|
||||
var plan = _planner.TryPlan(route.Points[d.RejoinIdx], out string why);
|
||||
|
|
@ -3558,6 +3586,14 @@ internal sealed partial class NavigationEngine
|
|||
EndDetour($"moved {movedYd:F0}yd while paused, re-plan found nothing ({why})", success: false);
|
||||
return false;
|
||||
}
|
||||
bool nearer = plan.LengthYd <= d.BestYd - DetourReplanNearerYd;
|
||||
if (!nearer && d.StalledReplans >= DetourMaxReplans)
|
||||
{
|
||||
EndDetour($"moved {movedYd:F0}yd while paused and out of re-plans ({d.StalledReplans} brought it no nearer than {d.BestYd:F0}yd)", success: false);
|
||||
return false;
|
||||
}
|
||||
if (nearer) d.BestYd = plan.LengthYd;
|
||||
else d.StalledReplans++;
|
||||
d.Replans++;
|
||||
d.Points = plan.Points;
|
||||
d.Index = 0;
|
||||
|
|
@ -3567,7 +3603,8 @@ internal sealed partial class NavigationEngine
|
|||
d.LengthYd = plan.LengthYd;
|
||||
d.Doorways = plan.Doorways;
|
||||
d.DoorRequests.Clear();
|
||||
_host.Log($"Nav: recovery #{d.Number} re-planned after a pause (moved {movedYd:F0}yd): {plan.Points.Count} pts, {plan.LengthYd:F0}yd via {plan.Planner}");
|
||||
_host.Log($"Nav: recovery #{d.Number} re-planned after a pause (moved {movedYd:F0}yd): {plan.Points.Count} pts, {plan.LengthYd:F0}yd via {plan.Planner}"
|
||||
+ (nearer ? "" : $" (no nearer: {d.StalledReplans}/{DetourMaxReplans})"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue