RynthSuite as of 2026-11-29 (internal 46bae49): release 2026.11.28.1
This commit is contained in:
parent
25552fa794
commit
598f49c899
131 changed files with 11825 additions and 329 deletions
|
|
@ -162,6 +162,7 @@ internal sealed partial class NavigationEngine
|
|||
public string Planner = string.Empty;
|
||||
public bool Navmesh; // RynthNav navmesh corners: the corner gate applies (NavmeshRaycast)
|
||||
public bool TargetMoved; // the rejoin waypoint is inside something placed: the last point stands in for it
|
||||
public bool InSight; // a walk back to the route in sight after a pause (RejoinInSight), not a stuck recovery
|
||||
public List<NavPoint> Points = new();
|
||||
public int Index; // next detour point to reach
|
||||
public int StartIdx; // ActiveNavIndex when it began (a change cancels it)
|
||||
|
|
@ -840,20 +841,205 @@ internal sealed partial class NavigationEngine
|
|||
/// Nav took over again after a pause. With <c>NavResumeNearest</c> on and the pause having
|
||||
/// moved the character <see cref="ResumeMovedYards"/> or more (a chase, a corpse run), the
|
||||
/// route re-picks its closest waypoint instead of walking back to the one it was heading for.
|
||||
/// A detour or area hold in progress owns getting back, so it is left alone.
|
||||
/// A detour or area hold in progress owns getting back, so it is left alone. Then, in a dungeon,
|
||||
/// a waypoint with no clear straight walk to it is reached by way of the route in sight first
|
||||
/// (<see cref="RejoinInSight"/>), whichever waypoint that is and whatever NavResumeNearest says.
|
||||
/// </summary>
|
||||
private void ResumeAfterPause()
|
||||
{
|
||||
double pNs = _pauseNs, pEw = _pauseEw;
|
||||
ClearPausePosition();
|
||||
if (!_settings.NavResumeNearest || double.IsNaN(pNs)) return;
|
||||
if (_detour != null || _areaMismatch) return;
|
||||
if (KeepWaypointAfterPause?.Invoke() == true) return;
|
||||
if (double.IsNaN(pNs) || _areaMismatch) return;
|
||||
// A walk back to the route in sight that this pause broke into: looked at again from where we are now.
|
||||
bool inSightWalk = _detour is { InSight: true };
|
||||
if (inSightWalk) EndDetour("cancelled, another pause: looked at again from here", success: false);
|
||||
if (_detour != null) return;
|
||||
if (!TryGetPos(out double ns, out double ew)) return;
|
||||
|
||||
double movedYd = Math.Sqrt(Sq(ns - pNs) + Sq(ew - pEw)) * 240.0;
|
||||
if (movedYd < ResumeMovedYards || movedYd > ResumeTeleportYards) return;
|
||||
RepickNearestWaypoint($"back from a pause that moved {movedYd:F0}yd", resetRecovery: false);
|
||||
if (movedYd > ResumeTeleportYards) return;
|
||||
if (_settings.NavResumeNearest && movedYd >= ResumeMovedYards && KeepWaypointAfterPause?.Invoke() != true)
|
||||
RepickNearestWaypoint($"back from a pause that moved {movedYd:F0}yd", resetRecovery: false);
|
||||
if (movedYd >= InSightMinMovedYd || inSightWalk) RejoinInSight(movedYd);
|
||||
}
|
||||
|
||||
// ── Back to the route in sight (2026-11-28) ──────────────────────────────
|
||||
// Lugian Excavations (0x02E7), a melee character on the dungeon patrol with Monster Range at 20 m so the Deepvein
|
||||
// Hurlers (rock throwers) die before the melee lugians: the fights took it off the route, into side rooms and round
|
||||
// corners, and once everything was dead and looted nav steered straight at the waypoint it had been heading for (the
|
||||
// patrol keeps it: KeepWaypointAfterPause) and ran into the wall between. The stuck ladder only caught it after 5 s at
|
||||
// the wall, jumped, and planned a way 5 s later (18:56:16 back from looting, 18:56:31 stuck x1, 18:56:36 a detour, the
|
||||
// waypoint reached 18:56:56). Now, back from a pause that moved
|
||||
// the character, a waypoint the dungeon map shows no clear straight walk to (INavRecoveryPlanner.StraightWalkInSight)
|
||||
// is reached by way of the route: the cheapest spot of the route it can walk to straight, on the legs into the waypoint
|
||||
// (back at most InSightLegsBack legs, InSightBackYd of route) or the legs out of it (InSightLegsAhead, passing over at
|
||||
// most InSightAheadYd of route first). A spot behind costs the route walked again to the waypoint, a spot ahead half
|
||||
// the route it passes over, so a near spot on the leg into the waypoint wins over a nearer one far back or far on.
|
||||
// The 18:56 stuck there (cell 02E70125, 39.5 m from waypoint [15] across a wall) had the route in sight only two legs
|
||||
// on ([16]->[17]) and on the loop's way back; the way back stays out of reach (the patrol's order). Nothing in sight:
|
||||
// the map's way to the waypoint (a recovery detour, through the doorways). The map can't say (outdoors, not loaded):
|
||||
// as before.
|
||||
|
||||
private const int InSightLegsBack = 8; // legs into the waypoint looked along, back along the route
|
||||
private const double InSightBackYd = 80.0; // ... at most this much route behind it
|
||||
private const int InSightLegsAhead = 3; // legs out of it looked along
|
||||
private const double InSightAheadYd = 45.0; // ... passing over at most this much route before one starts
|
||||
private const double InSightSkipCost = 0.5; // a spot ahead costs this much of the route it passes over
|
||||
private const double InSightStepYd = 3.0; // spots along a leg this far apart (and the one nearest the character)
|
||||
private const double InSightMaxYd = 60.0; // spots farther than this from the character aren't tried
|
||||
private const int InSightMaxTests = 40; // walk tests at most, cheapest spot first
|
||||
private const double InSightMinMovedYd = 1.0; // a pause that moved the character less put nothing between
|
||||
|
||||
/// <summary>A spot of the route to walk back to: on the leg [From]→[Rejoin], Yd from the character; Over: the
|
||||
/// waypoints it passes over (a spot ahead), 0 for one on a leg into the waypoint.</summary>
|
||||
private readonly record struct InSightSpot(NavPoint Spot, int From, int Rejoin, double Yd, double Cost, int Over);
|
||||
|
||||
/// <summary>
|
||||
/// Back from a pause: when the dungeon map has no clear straight walk to the current waypoint, walks to the cheapest
|
||||
/// spot of the route near it that it has one to (an InSight detour, then the route goes on from its leg's end), or
|
||||
/// failing that plans the map's way to the waypoint. True when it started something.
|
||||
/// </summary>
|
||||
private bool RejoinInSight(double movedYd)
|
||||
{
|
||||
var route = _settings.CurrentRoute;
|
||||
if (route == null || !RecoveryEnabled || _planner == null) return false;
|
||||
if (route.RouteType == NavRouteType.Follow || route.NavmeshCorners || route.OutdoorHuntWalk) return false;
|
||||
int idx = _settings.ActiveNavIndex;
|
||||
if (!IndexValid(idx, route) || !IsWalkTarget(route.Points[idx].Type)) return false;
|
||||
if (!TryGetPos(out double ns, out double ew)) return false;
|
||||
|
||||
var target = route.Points[idx];
|
||||
if (_planner.StraightWalkInSight(target) != false) return false; // a clear walk, or the map can't say
|
||||
|
||||
var spots = InSightSpots(route, idx, ns, ew);
|
||||
int tests = 0;
|
||||
InSightSpot? found = null;
|
||||
foreach (var s in spots)
|
||||
{
|
||||
if (tests++ >= InSightMaxTests) break;
|
||||
if (_planner.StraightWalkInSight(s.Spot) == true) { found = s; break; }
|
||||
}
|
||||
|
||||
double toTarget = NavYd(target.NS - ns, target.EW - ew);
|
||||
if (found is not { } f)
|
||||
{
|
||||
_host.Log($"Nav: back from a pause (moved {movedYd:F0}yd): no clear walk to [{idx}] ({toTarget:F0}yd) on the dungeon map, and no spot of the route near it in sight ({Math.Min(tests, spots.Count)} of {spots.Count} tried): the map's way there");
|
||||
return TryStartDetour(route, idx, $"back from a pause, [{idx}] is behind a wall and the route near it is out of sight");
|
||||
}
|
||||
|
||||
string leg = $"the leg [{f.From}]->[{f.Rejoin}]";
|
||||
string over = f.Over switch
|
||||
{
|
||||
0 => "",
|
||||
1 => $", passing over [{idx}]",
|
||||
_ => $", passing over [{idx}] to [{f.From}] ({f.Over} waypoints)",
|
||||
};
|
||||
if (f.Yd < ArrivalYards)
|
||||
{
|
||||
// Already on the route there: go on from that leg's end.
|
||||
if (f.Rejoin != idx)
|
||||
{
|
||||
_host.Log($"Nav: back from a pause (moved {movedYd:F0}yd): no clear walk to [{idx}] on the dungeon map; on {leg} already, going on from [{f.Rejoin}]{over}");
|
||||
_settings.ActiveNavIndex = f.Rejoin;
|
||||
_closestDist = double.MaxValue;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
long now = Now;
|
||||
_detour = new Detour
|
||||
{
|
||||
Number = ++_recoveryNumber,
|
||||
Reason = $"back from a pause, no clear walk to [{idx}]",
|
||||
Planner = "the route in sight",
|
||||
InSight = true,
|
||||
Points = new List<NavPoint> { f.Spot },
|
||||
StartIdx = idx,
|
||||
RejoinIdx = f.Rejoin,
|
||||
Skipped = f.Over,
|
||||
LengthYd = f.Yd,
|
||||
StartedAt = now,
|
||||
DeadlineAt = now + 15000 + (long)(f.Yd * 600.0),
|
||||
};
|
||||
_closestDist = double.MaxValue;
|
||||
_host.Log($"Nav: back from a pause (moved {movedYd:F0}yd): no clear walk to [{idx}] ({toTarget:F0}yd) on the dungeon map (a wall or a drop in the way) - "
|
||||
+ $"walking to the route in sight first: {f.Yd:F0}yd to {leg}, then on from [{f.Rejoin}]{over} (recovery #{_detour.Number})");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The spots RejoinInSight tries, cheapest first: on each leg into <paramref name="idx"/> back along the route (the
|
||||
/// spot nearest the character and one every InSightStepYd, the waypoint itself left out: its walk is the one that
|
||||
/// failed), costing their distance plus the route from them on to the waypoint; and on the legs out of it, costing
|
||||
/// their distance plus InSightSkipCost of the route they pass over. Never past a step (a portal, a recall, a chat, a
|
||||
/// pause point), never round a whole loop, never on past a Jump point (it jumps on arrival).
|
||||
/// </summary>
|
||||
private List<InSightSpot> InSightSpots(NavRouteParser route, int idx, double ns, double ew)
|
||||
{
|
||||
var list = new List<InSightSpot>();
|
||||
int r = idx;
|
||||
double along = 0; // route from r on to idx
|
||||
for (int k = 0; k < InSightLegsBack && along <= InSightBackYd; k++)
|
||||
{
|
||||
int prev = PrevIndex(r, route);
|
||||
if (prev < 0 || prev == idx) break;
|
||||
var a = route.Points[prev];
|
||||
if (!IsWalkTarget(a.Type)) break;
|
||||
var b = route.Points[r];
|
||||
AddLegSpots(list, a, b, prev, r, along, over: 0, skipEnd: r == idx, ns, ew);
|
||||
along += NavYd(b.NS - a.NS, b.EW - a.EW);
|
||||
if (!NavRouteParser.IsPlainWaypoint(a.Type)) break; // a Jump: its leg is the landing, not walked back past
|
||||
r = prev;
|
||||
}
|
||||
|
||||
int cur = idx;
|
||||
double passed = 0; // route from idx to cur, passed over
|
||||
for (int k = 0; k < InSightLegsAhead && passed <= InSightAheadYd; k++)
|
||||
{
|
||||
var a = route.Points[cur];
|
||||
if (a.Type == NavPointType.Jump) break;
|
||||
int next = NextInOrder(cur, route);
|
||||
if (next < 0 || next == idx) break;
|
||||
var b = route.Points[next];
|
||||
if (!IsWalkTarget(b.Type)) break;
|
||||
AddLegSpots(list, a, b, cur, next, passed, over: k + 1, skipEnd: false, ns, ew);
|
||||
passed += NavYd(b.NS - a.NS, b.EW - a.EW);
|
||||
cur = next;
|
||||
}
|
||||
|
||||
list.Sort((x, y) => x.Cost.CompareTo(y.Cost));
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>Spots on the leg a→b ([from]→[rejoin]): the one nearest (ns, ew) and one every InSightStepYd. Behind
|
||||
/// (over 0): <paramref name="routeYd"/> is the route from b on to the waypoint; ahead: the route passed over before a.</summary>
|
||||
private static void AddLegSpots(List<InSightSpot> list, NavPoint a, NavPoint b, int from, int rejoin, double routeYd,
|
||||
int over, bool skipEnd, double ns, double ew)
|
||||
{
|
||||
bool ahead = over > 0;
|
||||
double vN = b.NS - a.NS, vE = b.EW - a.EW;
|
||||
double legYd = NavYd(vN, vE);
|
||||
var ts = new List<double>();
|
||||
if (legYd < 0.1) ts.Add(1.0);
|
||||
else
|
||||
{
|
||||
double len2 = vN * vN + vE * vE;
|
||||
ts.Add(Math.Clamp(((ns - a.NS) * vN + (ew - a.EW) * vE) / len2, 0, 1));
|
||||
for (double d = 0; d < legYd; d += InSightStepYd) ts.Add(d / legYd);
|
||||
ts.Add(1.0);
|
||||
}
|
||||
foreach (double t in ts)
|
||||
{
|
||||
// The waypoint itself (its walk is the one that failed); an ahead leg's start is the leg before's end.
|
||||
if ((skipEnd && t > 1 - 1e-9) || (ahead && t < 1e-9)) continue;
|
||||
double sN = a.NS + vN * t, sE = a.EW + vE * t;
|
||||
double yd = NavYd(sN - ns, sE - ew);
|
||||
if (yd > InSightMaxYd) continue;
|
||||
double z = a.Z != 0 && b.Z != 0 ? a.Z + (b.Z - a.Z) * t : (a.Z != 0 ? a.Z : b.Z);
|
||||
var spot = new NavPoint { Type = NavPointType.Point, NS = sN, EW = sE, Z = z };
|
||||
double cost = ahead ? yd + InSightSkipCost * (routeYd + t * legYd) : yd + (1 - t) * legYd + routeYd;
|
||||
list.Add(new InSightSpot(spot, from, rejoin, yd, cost, over));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1009,9 +1195,11 @@ internal sealed partial class NavigationEngine
|
|||
double bestYd = double.MaxValue;
|
||||
foreach (int i in candidates)
|
||||
{
|
||||
var plan = _planner.TryPlan(route.Points[i], out _);
|
||||
if (plan == null) continue;
|
||||
if (plan.LengthYd < bestYd) { bestYd = plan.LengthYd; best = i; }
|
||||
// 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]);
|
||||
if (yd == null) continue;
|
||||
if (yd.Value < bestYd) { bestYd = yd.Value; best = i; }
|
||||
}
|
||||
walkYd = best >= 0 ? bestYd : 0;
|
||||
return best;
|
||||
|
|
@ -3421,11 +3609,14 @@ internal sealed partial class NavigationEngine
|
|||
_lastDistYd = dist;
|
||||
_lastHeadingErr = headingErr;
|
||||
_lastSteerAt = Now;
|
||||
_settings.NavIsStuck = true;
|
||||
// A walk back to the route in sight after a fight is no trouble: not shown as stuck.
|
||||
_settings.NavIsStuck = !d.InSight;
|
||||
|
||||
string modeStr = _isTurning ? " [TURN]" : string.Empty;
|
||||
string errStr = Math.Abs(headingErr) > 0.5 ? $" err={headingErr:+0.0;-0.0}°" : string.Empty;
|
||||
_settings.NavStatusLine = $"Nav: recovering - detour {d.Index + 1}/{d.Points.Count} to waypoint {d.RejoinIdx + 1} {dist:F1}yd{errStr}{modeStr}";
|
||||
_settings.NavStatusLine = d.InSight
|
||||
? $"Nav: back to the route in sight, then waypoint {d.RejoinIdx + 1} {dist:F1}yd{errStr}{modeStr}"
|
||||
: $"Nav: recovering - detour {d.Index + 1}/{d.Points.Count} to waypoint {d.RejoinIdx + 1} {dist:F1}yd{errStr}{modeStr}";
|
||||
}
|
||||
|
||||
// ══════════════════════════════════════════════════════════════════════════
|
||||
|
|
|
|||
Loading…
Reference in a new issue