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

@ -0,0 +1,152 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace RynthCore.Plugin.RynthOracle.Data;
/// <summary>
/// One Infinite Leaftide Dynamic Stamp (dynstamps.csv): an NPC hand-in that puts a
/// "Dynamic_N_..." quest flag on the character. List from the players' "ExtraDyn" sheet
/// (10.13.2026, one sheet per area, the wiki's Dynamic Stamps page); NPCs that give no stamp
/// are left out. A stamp is a one-time flag: having it in /myquests means it's done.
/// </summary>
internal sealed class DynamicStamp
{
public string Area = "";
/// <summary>Where in the area (a town, a dungeon, coordinates), or "".</summary>
public string Place = "";
public string Npc = "";
/// <summary>What the NPC gives back (the sheet's "X gives you Y"), or "".</summary>
public string Reward = "";
/// <summary>The quest flag, lower case (as QuestFlagStore keys it).</summary>
public string Stamp = "";
public string Note = "";
/// <summary>The NPC, else the place (a few sheet rows only name the spot).</summary>
public string Label => Npc.Length > 0 ? Npc : Place;
/// <summary>
/// The flag this character has for the stamp, or null. The sheet has a few stamps copied
/// without their closing "!" or cut short: those also match with "!" added and, when at
/// least <see cref="MinPrefixLength"/> long, the one Dynamic flag on the character starting
/// with them.
/// </summary>
public string? MatchedFlag(QuestFlagStore flags)
{
if (flags.TryGet(Stamp, out _)) return Stamp;
if (Stamp.EndsWith('!')) return null;
if (flags.TryGet(Stamp + "!", out _)) return Stamp + "!";
if (Stamp.Length < MinPrefixLength) return null;
string? only = null;
foreach (string key in flags.Flags.Keys)
{
if (!key.StartsWith(Stamp, StringComparison.OrdinalIgnoreCase)) continue;
if (only != null) return null; // more than one: can't tell which
only = key;
}
return only;
}
public bool Have(QuestFlagStore flags) => MatchedFlag(flags) != null;
// Sheet areas that are groupings, not places on the map.
private static readonly HashSet<string> NotPlaces = new(StringComparer.OrdinalIgnoreCase)
{
"Looking Around", "Odd Stamps", "Odd Stamps 2",
};
/// <summary>
/// Where RynthNav should go for this stamp, best first (RynthNav takes the first that is on its
/// map): the coordinates in the note or the place, the place and its parts ("Mhoire Castle -
/// Great Hall" also tries "Mhoire Castle"), the NPC, then the area. Empty when there is nothing.
/// </summary>
public List<string> NavCandidates()
{
var list = new List<string>();
void Add(string s)
{
s = s.Trim().Trim('.', ',', ';', ':').Trim();
if (s.Length >= 4 && !char.IsDigit(s[0]) && !list.Contains(s, StringComparer.OrdinalIgnoreCase)) list.Add(s);
}
foreach (string text in new[] { Note, Place })
if (NavTargets.FirstCoords(text) is string c && !list.Contains(c)) list.Add(c);
string place = NavTargets.WithoutCoords(Place);
place = System.Text.RegularExpressions.Regex.Replace(place, @"\b(at|in the|nearby)\b", " ", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
place = System.Text.RegularExpressions.Regex.Replace(place, @"\s+", " ").Trim();
Add(place);
foreach (string part in place.Split(new[] { " - ", " / ", "(", ")" }, StringSplitOptions.RemoveEmptyEntries))
Add(part);
Add(Npc);
if (!NotPlaces.Contains(Area)) Add(Area);
return list;
}
/// <summary>A truncated stamp shorter than this is matched exactly only (too many flags share a short stem).</summary>
public const int MinPrefixLength = 14;
}
internal static class DynamicStampList
{
/// <summary>Dynamic stamp quest flags start with this (lower case).</summary>
public const string FlagPrefix = "dynamic_";
public static List<DynamicStamp> All { get; } = Load();
/// <summary>The areas in list order (Facility Hub, Looking Around, ...).</summary>
public static List<string> Areas { get; } = BuildAreas();
/// <summary>
/// Dynamic stamps on this character that the list doesn't have (new or unlisted NPCs), so the
/// tab can show them and the count isn't only what the sheet knows.
/// </summary>
public static List<string> Unlisted(QuestFlagStore flags)
{
var matched = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
foreach (DynamicStamp s in All)
if (s.MatchedFlag(flags) is string f) matched.Add(f);
var extra = new List<string>();
foreach (string key in flags.Flags.Keys)
if (key.StartsWith(FlagPrefix, StringComparison.OrdinalIgnoreCase) && !matched.Contains(key))
extra.Add(key);
extra.Sort(StringComparer.OrdinalIgnoreCase);
return extra;
}
private static List<DynamicStamp> Load()
{
var list = new List<DynamicStamp>();
using StreamReader r = Csv.OpenEmbedded("dynstamps.csv");
Dictionary<string, int> col = Csv.MapColumns(r.ReadLine() ?? "");
int cArea = Csv.Column(col, "Area"), cPlace = Csv.Column(col, "Place"), cNpc = Csv.Column(col, "Npc"),
cReward = Csv.Column(col, "Reward"), cStamp = Csv.Column(col, "Stamp"), cNote = Csv.Column(col, "Note");
var seen = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
while (r.ReadLine() is string line)
{
if (string.IsNullOrWhiteSpace(line)) continue;
string[] f = Csv.ParseLine(line);
string stamp = Csv.Field(f, cStamp).Trim().ToLowerInvariant();
if (!stamp.StartsWith(FlagPrefix, StringComparison.Ordinal) || !seen.Add(stamp)) continue;
list.Add(new DynamicStamp
{
Area = Csv.Field(f, cArea),
Place = Csv.Field(f, cPlace),
Npc = Csv.Field(f, cNpc),
Reward = Csv.Field(f, cReward),
Stamp = stamp,
Note = Csv.Field(f, cNote),
});
}
return list;
}
private static List<string> BuildAreas()
{
var areas = new List<string>();
foreach (DynamicStamp s in All)
if (!areas.Contains(s.Area)) areas.Add(s.Area);
return areas;
}
}

View file

@ -0,0 +1,117 @@
using System;
using System.Collections.Generic;
using System.IO;
namespace RynthCore.Plugin.RynthOracle.Data;
/// <summary>
/// One Legendary Key quest (legendary.csv; list and notes from the "Arwic John Route" sheet).
/// The quest's own /myquests flags say whether it was ever done and when it can be run again:
/// the first flag is its completion stamp, any others only add their repeat timers (a key pickup
/// timer, say). John in Arwic counts 30 different ones (legendaryquestcounter_0913).
/// </summary>
internal sealed class LegendaryQuest
{
public string Group = "";
public string Name = "";
/// <summary>The short name players use ("RTW", "HMD"), or "".</summary>
public string CommonName = "";
public int Luminance;
public string[] Flags = Array.Empty<string>();
public string Url = "";
public string Note = "";
public string Video = "";
/// <summary>The short name when the sheet has one, else the quest name.</summary>
public string Label => CommonName.Length > 0 ? $"{Name} ({CommonName})" : Name;
/// <summary>Done at least once: any of its flags is on this character.</summary>
public bool Have(QuestFlagStore flags)
{
foreach (string f in Flags)
if (flags.TryGet(f, out _)) return true;
return false;
}
/// <summary>
/// Time until it can be run again: the longest wait among its flags that have a repeat timer;
/// zero when every timer is up (or it has none). Null when it was never done.
/// </summary>
public TimeSpan? TimeLeft(QuestFlagStore flags, DateTime utcNow)
{
bool any = false;
TimeSpan left = TimeSpan.Zero;
foreach (string f in Flags)
{
if (!flags.TryGet(f, out QuestFlag q)) continue;
any = true;
if (q.RepeatTime <= TimeSpan.Zero || q.CompletedOnUtc == DateTime.MinValue) continue;
TimeSpan d = q.NextAvailableTime(utcNow);
if (d > left) left = d;
}
return any ? left : null;
}
/// <summary>"missing", "ready" or the time left ("14h 3m").</summary>
public string Status(QuestFlagStore flags, DateTime utcNow)
{
TimeSpan? left = TimeLeft(flags, utcNow);
if (left == null) return "missing";
return left.Value.TotalSeconds > 0 ? TimeText.Friendly(left.Value) : "ready";
}
}
internal static class LegendaryList
{
/// <summary>John's count of different Legendary Key quests done (needs 30).</summary>
public const string CounterFlag = "legendaryquestcounter_0913";
/// <summary>Legendary Key quests John asks for.</summary>
public const int JohnTarget = 30;
public static List<LegendaryQuest> All { get; } = Load();
/// <summary>The groups in list order (Graveyard, Rynthid, ...).</summary>
public static List<string> Groups { get; } = BuildGroups();
/// <summary>John's counter for this character; null when /myquests doesn't have it (not started).</summary>
public static int? JohnCount(QuestFlagStore flags) =>
flags.TryGet(CounterFlag, out QuestFlag q) ? q.Solves : null;
private static List<LegendaryQuest> Load()
{
var list = new List<LegendaryQuest>();
using StreamReader r = Csv.OpenEmbedded("legendary.csv");
Dictionary<string, int> col = Csv.MapColumns(r.ReadLine() ?? "");
int cGroup = Csv.Column(col, "Group"), cName = Csv.Column(col, "Quest"), cCommon = Csv.Column(col, "CommonName"),
cLum = Csv.Column(col, "Luminance"), cFlags = Csv.Column(col, "Flags"), cUrl = Csv.Column(col, "Url"),
cNote = Csv.Column(col, "Note"), cVideo = Csv.Column(col, "Video");
while (r.ReadLine() is string line)
{
if (string.IsNullOrWhiteSpace(line)) continue;
string[] f = Csv.ParseLine(line);
string name = Csv.Field(f, cName);
if (name.Length == 0) continue;
list.Add(new LegendaryQuest
{
Group = Csv.Field(f, cGroup),
Name = name,
CommonName = Csv.Field(f, cCommon),
Luminance = int.TryParse(Csv.Field(f, cLum), out int lum) ? lum : 0,
Flags = Csv.Field(f, cFlags).ToLowerInvariant()
.Split(';', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries),
Url = Csv.Field(f, cUrl),
Note = Csv.Field(f, cNote),
Video = Csv.Field(f, cVideo),
});
}
return list;
}
private static List<string> BuildGroups()
{
var groups = new List<string>();
foreach (LegendaryQuest q in All)
if (!groups.Contains(q.Group)) groups.Add(q.Group);
return groups;
}
}

View file

@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;
namespace RynthCore.Plugin.RynthOracle.Data;
/// <summary>
/// Coordinates in Oracle's text (quest walkthroughs, Dynamic Stamp notes) as RynthNav targets.
/// The lists write them every which way: "59.6S 88.0W", "8.8S, 53.1E", "42.6n 62.4e".
/// </summary>
internal static class NavTargets
{
private static readonly Regex CoordsRx = new(
@"(?<ns>\d+(?:\.\d+)?)\s*(?<nsc>[NnSs])[\s,]*(?<ew>\d+(?:\.\d+)?)\s*(?<ewc>[EeWw])\b",
RegexOptions.CultureInvariant);
/// <summary>One place to go: what the text calls it (may be empty) and its coordinates ("59.6S, 88.0W").</summary>
internal readonly record struct Stop(string Label, string Coords)
{
/// <summary>The RynthNav target: the coordinates, then the label (RynthNav uses an Atlas
/// place of that name there, e.g. a dungeon's entrance).</summary>
public string Target => Label.Length > 0 ? Coords + " " + Label : Coords;
/// <summary>How a picker shows it: "Kill Mukkir Progenitor - 86.5N, 57.3E".</summary>
public string Display => Label.Length > 0 ? Label + " - " + Coords : Coords;
}
/// <summary>
/// A named place with no coordinates (an exploration marker's location): its name is the whole
/// RynthNav target, and RynthNav finds it on its Atlas.
/// </summary>
public static Stop Place(string name) => new("", name.Trim());
/// <summary>The first coordinates in <paramref name="text"/>, written "8.8S, 53.1E", or null.</summary>
public static string? FirstCoords(string? text)
{
if (string.IsNullOrEmpty(text)) return null;
Match m = CoordsRx.Match(text);
return m.Success ? Format(m) : null;
}
/// <summary><paramref name="text"/> with its coordinates taken out.</summary>
public static string WithoutCoords(string? text) => string.IsNullOrEmpty(text) ? "" : CoordsRx.Replace(text, " ");
/// <summary>
/// Every coordinate pair in <paramref name="text"/>, in order, each labelled with the words just
/// before it in its step (walkthroughs separate steps with " - "): "Speak with Hoshar ibn Jalaq
/// 59.6S 88.0W - Kill Mukkir Progenitor 86.5N 57.3E" gives two stops. The same coordinates
/// twice are one stop.
/// </summary>
public static List<Stop> Stops(string? text)
{
var stops = new List<Stop>();
if (string.IsNullOrEmpty(text)) return stops;
foreach (Match m in CoordsRx.Matches(text))
{
string coords = Format(m);
if (stops.Exists(s => s.Coords == coords)) continue;
stops.Add(new Stop(LabelBefore(text, m.Index), coords));
}
return stops;
}
/// <summary>The words between the previous step break (" - ", ". ", "; ", "|") or coordinates and <paramref name="at"/>.</summary>
private static string LabelBefore(string text, int at)
{
int from = 0;
foreach (string sep in new[] { " - ", ". ", "; ", "|", "(" })
{
int i = text.LastIndexOf(sep, Math.Max(0, at - 1), StringComparison.Ordinal);
if (i >= 0 && i + sep.Length <= at) from = Math.Max(from, i + sep.Length);
}
// Not back past the previous coordinates ("Cragstone 26.0N 47.0E Speak with ...").
foreach (Match m in CoordsRx.Matches(text.Substring(0, at)))
from = Math.Max(from, m.Index + m.Length);
string label = text.Substring(from, at - from).Trim(' ', ',', ':', '-', '.', '(', ')');
// "at 42.1N ..." and "Meet at 42.1N ...": the little words around the coordinates aren't the place.
label = Regex.Replace(label, @"^(at|in|near|to)\s+|\s+(at|in|near|to)$", "", RegexOptions.IgnoreCase).Trim();
return label.Length > 60 ? label.Substring(0, 60).TrimEnd() : label;
}
private static string Format(Match m) =>
string.Create(CultureInfo.InvariantCulture,
$"{m.Groups["ns"].Value}{char.ToUpperInvariant(m.Groups["nsc"].Value[0])}, {m.Groups["ew"].Value}{char.ToUpperInvariant(m.Groups["ewc"].Value[0])}");
}

View file

@ -33,7 +33,7 @@ internal sealed class QuestFlag
}
/// <summary>What one chat line is, as far as /myquests goes.</summary>
internal enum MyQuestsLine { None, Quest, Empty, Disabled }
internal enum MyQuestsLine { None, Quest, Empty, Disabled, Throttled }
/// <summary>
/// The character's quest flags, read from the server's /myquests reply (ACE: one Broadcast line
@ -55,10 +55,21 @@ internal sealed class QuestFlagStore
public const string EmptyText = "Quest list is empty.";
public const string DisabledText = "The command \"myquests\" is not currently enabled on this server.";
/// <summary>ACECustom's per-session throttle reply ("... may only be run once every 60 seconds.").</summary>
public const string ThrottledText = "[MyQuests] This command may only be run once every";
private const int QuietMs = 1500; // a reply is complete once no line came for this long
private const int RequestTimeoutMs = 10_000;
private const int MinRequestGapMs = 5_000;
/// <summary>ACECustom answers one /myquests a minute per session (whoever sent the last one).</summary>
private const int ServerThrottleMs = 60_000;
/// <summary>
/// A reply this much smaller than the flags already held is taken as cut short (chat lines
/// dropped before they reached the plugin), so it updates the flags instead of replacing them.
/// </summary>
private const double PartialReplyRatio = 0.8;
/// <summary>Below this many flags held, a smaller reply always replaces (nothing much to lose).</summary>
private const int PartialReplyMinHeld = 20;
public Dictionary<string, QuestFlag> Flags { get; private set; } = new(StringComparer.OrdinalIgnoreCase);
private Dictionary<string, QuestFlag>? _pending;
@ -66,6 +77,15 @@ internal sealed class QuestFlagStore
public DateTime LastReadUtc { get; private set; } = DateTime.MinValue;
public bool ServerDisabled { get; private set; }
/// <summary>The server refused the last /myquests (its once-a-minute limit) until this tick.</summary>
public long ThrottledUntilMs { get; private set; } = long.MinValue / 2;
/// <summary>This server has shown its throttle line this session, so every reply starts its minute.</summary>
private bool _serverThrottles;
/// <summary>
/// Set when the last reply looked cut short and was merged into the held flags (lines in the
/// reply, flags held before it). The plugin logs it once and clears it.
/// </summary>
public (int Got, int Had)? LastPartialReply { get; set; }
/// <summary>Bumps whenever the flags change (views rebuild their caches on it).</summary>
public int Revision { get; private set; }
@ -77,10 +97,16 @@ internal sealed class QuestFlagStore
public bool Loading => _pending != null || AwaitingOurs;
/// <summary>Seconds left on the server's /myquests limit (0 when a request would be answered).</summary>
public int ThrottleSecondsLeft(long nowMs) =>
nowMs < ThrottledUntilMs ? (int)((ThrottledUntilMs - nowMs + 999) / 1000) : 0;
/// <summary>Sends /myquests unless one went out moments ago. Returns false if nothing was sent.</summary>
public bool Request(Func<string, bool> invokeChat, long nowMs)
{
if (nowMs - _requestedMs < MinRequestGapMs) return false;
// The server would only answer with its throttle line; don't spend the request.
if (nowMs < ThrottledUntilMs) return false;
_requestedMs = nowMs;
Interlocked.Increment(ref _selfSends);
if (!invokeChat("/myquests"))
@ -120,6 +146,16 @@ internal sealed class QuestFlagStore
Revision++;
return MyQuestsLine.Disabled;
}
if (line.Contains(ThrottledText, StringComparison.Ordinal))
{
// No reply is coming: stop "Reading..." and keep the flags already held. The minute
// really started at the last answered request; a full minute from now is the safe side.
_serverThrottles = true;
ThrottledUntilMs = nowMs + ServerThrottleMs;
AwaitingOurs = false;
Revision++;
return MyQuestsLine.Throttled;
}
if (line.IndexOf(" solves (", StringComparison.Ordinal) < 0) return MyQuestsLine.None;
QuestFlag? flag = Parse(line);
@ -139,9 +175,27 @@ internal sealed class QuestFlagStore
if (_pending != null && nowMs - _lastLineMs >= QuietMs)
{
Flags = _pending;
Dictionary<string, QuestFlag> reply = _pending;
_pending = null;
int had = Flags.Count;
// A full reply replaces the list (a flag the server dropped goes away). One much
// smaller than what is held lost lines on the way (the engine's chat queue drops the
// oldest of a long burst): update what came and keep the rest, rather than blanking.
if (had >= PartialReplyMinHeld && reply.Count > 0 && reply.Count < had * PartialReplyRatio)
{
var merged = new Dictionary<string, QuestFlag>(Flags, StringComparer.OrdinalIgnoreCase);
foreach (KeyValuePair<string, QuestFlag> kv in reply) merged[kv.Key] = kv.Value;
Flags = merged;
LastPartialReply = (reply.Count, had);
}
else
{
Flags = reply;
}
LastReadUtc = DateTime.UtcNow;
// On a throttling server any reply (ours, the player's, RynthAi's poll) starts its minute.
if (_serverThrottles)
ThrottledUntilMs = nowMs + ServerThrottleMs - QuietMs;
AwaitingOurs = false;
Revision++;
}
@ -158,6 +212,9 @@ internal sealed class QuestFlagStore
AwaitingOurs = false;
LastReadUtc = DateTime.MinValue;
ServerDisabled = false;
ThrottledUntilMs = long.MinValue / 2;
_serverThrottles = false;
LastPartialReply = null;
Revision++;
}