RynthSuite as of 2026-11-08 (internal 6ec9b64): release 2026.11.8.1
This commit is contained in:
parent
7166d256ce
commit
f8fa62b64c
196 changed files with 24980 additions and 633 deletions
|
|
@ -101,6 +101,7 @@ internal sealed class PacedAction
|
|||
public uint Target; // a cast's target (the held-cast turn faces it)
|
||||
public bool Script; // a cast a script chose (the combat hook): the breaker waits ScriptCastMinBreakMs
|
||||
public bool WieldedAtSend;
|
||||
public bool OnSelf; // an item used on the character (a kit): the heal grace may go ahead of it
|
||||
public bool ResultSeen; // a cast's result is in (enchantment / chat); the server is in its recoil
|
||||
public bool HealQueued; // the one heal allowed behind that recoil went out
|
||||
public long ModeSeenMs; // when the client first read the requested mode
|
||||
|
|
@ -147,6 +148,13 @@ internal static class ActionPacer
|
|||
public const long NoUseDoneFallbackMs = 600;
|
||||
/// <summary>The longest one ask for the player's turn holds RynthAi (RynthAiYieldApiV1.MaxHoldMs).</summary>
|
||||
public const long PlayerHoldMaxMs = 3000;
|
||||
/// <summary>
|
||||
/// The heal grace (2026-11-07): the longest a heal under a heal line waits on a use of an item on
|
||||
/// the character (a kit) the server hasn't answered, and between the 'too busy' probes. Past it the
|
||||
/// heal goes (a refusal is an answer too, and the next heal retries). An item on yourself has no
|
||||
/// server turn to stop; corpse/door uses, casts, wields and the animation gate keep their rules.
|
||||
/// </summary>
|
||||
public const long HealGraceMs = 2000;
|
||||
|
||||
private static readonly object Gate = new();
|
||||
private static PacedAction? _cur;
|
||||
|
|
@ -208,6 +216,7 @@ internal static class ActionPacer
|
|||
_heldTurns = 0;
|
||||
_forcedBreaks = 0;
|
||||
_jumpAt = 0;
|
||||
_lootJumpAt = 0;
|
||||
_cycleBySpell.Clear();
|
||||
_lastSeenSeq = int.MinValue;
|
||||
_lastFrameMs = 0;
|
||||
|
|
@ -250,7 +259,8 @@ internal static class ActionPacer
|
|||
/// BEFORE the send. Logs once when it went out over another unanswered action (a player command,
|
||||
/// a meta, or a heal let ahead).
|
||||
/// </summary>
|
||||
public static void Begin(RynthCoreHost host, PacedKind kind, uint id, string label, string who, int seqAtSend, int modeTarget = 0)
|
||||
public static void Begin(RynthCoreHost host, PacedKind kind, uint id, string label, string who, int seqAtSend, int modeTarget = 0,
|
||||
bool onSelf = false)
|
||||
{
|
||||
if (!Enabled || kind == PacedKind.None) return;
|
||||
PacedAction? prev = Current(host);
|
||||
|
|
@ -258,6 +268,7 @@ internal static class ActionPacer
|
|||
var a = new PacedAction
|
||||
{
|
||||
Kind = kind, Id = id, Label = label, Who = who, SentMs = now, SeqAtSend = seqAtSend, ModeTarget = modeTarget,
|
||||
OnSelf = onSelf && kind == PacedKind.ItemUse,
|
||||
};
|
||||
if (kind == PacedKind.ItemUse) a.WieldedAtSend = IsWieldedByPlayer(host, id);
|
||||
string? over = null;
|
||||
|
|
@ -466,6 +477,9 @@ internal static class ActionPacer
|
|||
{
|
||||
if (!Enabled) { why = ""; return true; }
|
||||
if (PlayerHoldsStart(host, who, out why)) return false;
|
||||
// A buff, heal, kit or potion in the air is refused by ACE: wait for the landing. Combat checks
|
||||
// it itself, at the attack, so a stance change is not held; loot and doors never.
|
||||
if (who == "Buff" && LootJumpAirborne(host, out why)) return false;
|
||||
if (ServerBusyHolds(host, who, attackRepeat, out why, out bool tryAfterBusy, heal)) return false;
|
||||
// An emergency heal does not wait for the movement settle (150-600 ms): at Emergency Heal At
|
||||
// the heal comes first; it still obeys the in-flight rules below (OutstandingAllows, GestureHolds).
|
||||
|
|
@ -529,6 +543,15 @@ internal static class ActionPacer
|
|||
lock (Gate) _healsAhead++;
|
||||
return true;
|
||||
}
|
||||
// The heal grace: an item used on the character (a kit) still unanswered after HealGraceMs.
|
||||
// A lost or swallowed kit is sent again instead of holding every heal to ItemUseMaxMs.
|
||||
if (a.OnSelf && age >= HealGraceMs)
|
||||
{
|
||||
bool logAhead;
|
||||
lock (Gate) { _healsAhead++; logAhead = a.LoggedWaits.Add(who + "/heal-grace"); }
|
||||
if (logAhead) Log(host, $"[Pace] {who}: the heal goes ahead of {Describe(a.Kind, a.Label)} (unanswered for {age} ms, heal grace {HealGraceMs} ms)");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
why = $"{Describe(a.Kind, a.Label)} sent {age} ms ago by {a.Who} has no answer yet";
|
||||
|
|
@ -915,8 +938,11 @@ internal static class ActionPacer
|
|||
// use would send first every time and the heal would see the next slot, up to BusyProbeMaxMs later).
|
||||
if (heal == HealNeed.Heal && _busySince != 0) _healWaitAt = now;
|
||||
bool healWaiting = heal != HealNeed.Heal && _healWaitAt != 0 && now - _healWaitAt < HealWaitFreshMs;
|
||||
// A waiting heal's probe comes at least every HealGraceMs (the doubling would reach BusyProbeMaxMs).
|
||||
long probeWait = Math.Min(BusyProbeMs << Math.Min(_probes, 8), BusyProbeMaxMs);
|
||||
if (heal == HealNeed.Heal) probeWait = Math.Min(probeWait, HealGraceMs);
|
||||
if (!attackRepeat && stuck == null && _busySince != 0 && _stage == BreakStage.None && !healWaiting
|
||||
&& now - Math.Max(_busySince, _lastProbeAt) >= Math.Min(BusyProbeMs << Math.Min(_probes, 8), BusyProbeMaxMs))
|
||||
&& now - Math.Max(_busySince, _lastProbeAt) >= probeWait)
|
||||
{
|
||||
probe = true; // spent in MayStart once the start passes its other checks (SpendTryAfterBusy)
|
||||
}
|
||||
|
|
@ -1030,6 +1056,76 @@ internal static class ActionPacer
|
|||
lock (Gate) { if (!ReferenceEquals(_stageFor, forAction)) _turnedAt = 0; _stage = stage; _stageAt = now; _stageFor = forAction; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Landed after a jump at <paramref name="jumpAt"/> from height <paramref name="z0"/>: the height
|
||||
/// is back (looked at from JumpLandMinMs on), or JumpLandMaxMs has passed whatever it says.
|
||||
/// </summary>
|
||||
private static bool Landed(RynthCoreHost host, long now, long jumpAt, float z0)
|
||||
{
|
||||
long air = now - jumpAt;
|
||||
bool landed = air >= JumpLandMaxMs;
|
||||
if (!landed && air >= JumpLandMinMs)
|
||||
{
|
||||
try { landed = !host.HasGetPlayerPose || (host.TryGetPlayerPose(out _, out _, out _, out float z, out _, out _, out _, out _) && Math.Abs(z - z0) < 0.1f); }
|
||||
catch { landed = true; }
|
||||
}
|
||||
return landed;
|
||||
}
|
||||
|
||||
// Jump-loot (CorpseOpenController): the corpse pickup's tap jump. ACE refuses a cast, a swing, a
|
||||
// shot, a kit, food or a potion in the air (Player_Magic/Melee/Missile, Healer, Food: IsJumping ->
|
||||
// YouCantDoThatWhileInTheAir, 0x4EB), so combat and buffs wait until the character has landed
|
||||
// instead of sending into a certain refusal. Loot does not: ACE takes a pickup and a corpse use in
|
||||
// the air, so this never holds MayStart("Loot"). The hold is a pure wait, capped at JumpLandMaxMs
|
||||
// from the jump, so a missed landing cannot stall a heal for longer than that.
|
||||
private static long _lootJumpAt; // 0 = not in the air after a loot jump
|
||||
private static float _lootJumpZ;
|
||||
|
||||
/// <summary>A loot jump went out (the client took it): the character is in the air from now.</summary>
|
||||
public static void NoteLootJump(RynthCoreHost host)
|
||||
{
|
||||
float z = 0;
|
||||
try { if (host.HasGetPlayerPose) host.TryGetPlayerPose(out _, out _, out _, out z, out _, out _, out _, out _); } catch { }
|
||||
long now = NowMs();
|
||||
lock (Gate) { _lootJumpAt = now; _lootJumpZ = z; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True (with why) while the character is in the air after a loot jump: until the height is back
|
||||
/// (from JumpLandMinMs) or JumpLandMaxMs at most. Pure wait: nothing is counted, refused or
|
||||
/// retried. Independent of <see cref="Enabled"/>.
|
||||
/// </summary>
|
||||
public static bool LootJumpAirborne(RynthCoreHost host, out string why)
|
||||
{
|
||||
why = "";
|
||||
long jumpAt; float z0;
|
||||
lock (Gate) { jumpAt = _lootJumpAt; z0 = _lootJumpZ; }
|
||||
if (jumpAt == 0) return false;
|
||||
long now = NowMs();
|
||||
if (!Landed(host, now, jumpAt, z0))
|
||||
{
|
||||
why = $"in the air after the loot jump ({now - jumpAt} ms)";
|
||||
return true;
|
||||
}
|
||||
lock (Gate) { if (_lootJumpAt == jumpAt) _lootJumpAt = 0; }
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ms since the last loot jump went out, or -1 when none is noted (never jumped, landed and
|
||||
/// cleared by <see cref="LootJumpAirborne"/>, or forgotten). Read it BEFORE LootJumpAirborne
|
||||
/// when the answer matters: a landing seen there clears the jump.
|
||||
/// </summary>
|
||||
public static long LootJumpAgeMs()
|
||||
{
|
||||
long jumpAt;
|
||||
lock (Gate) jumpAt = _lootJumpAt;
|
||||
return jumpAt == 0 ? -1 : NowMs() - jumpAt;
|
||||
}
|
||||
|
||||
/// <summary>No loot jump in the air any more (death, portal space, logout: RynthAiPlugin).</summary>
|
||||
public static void ForgetLootJump() { lock (Gate) _lootJumpAt = 0; }
|
||||
|
||||
/// <summary>In the air after a breaker jump: hold until landed (height back, or JumpLandMaxMs).</summary>
|
||||
private static bool AirborneHolds(RynthCoreHost host, long now, out string why)
|
||||
{
|
||||
|
|
@ -1038,12 +1134,7 @@ internal static class ActionPacer
|
|||
lock (Gate) { jumpAt = _jumpAt; z0 = _jumpZ; }
|
||||
if (jumpAt == 0) return false;
|
||||
long air = now - jumpAt;
|
||||
bool landed = air >= JumpLandMaxMs;
|
||||
if (!landed && air >= JumpLandMinMs)
|
||||
{
|
||||
try { landed = !host.HasGetPlayerPose || (host.TryGetPlayerPose(out _, out _, out _, out float z, out _, out _, out _, out _) && Math.Abs(z - z0) < 0.1f); }
|
||||
catch { landed = true; }
|
||||
}
|
||||
bool landed = Landed(host, now, jumpAt, z0);
|
||||
if (!landed)
|
||||
{
|
||||
why = $"in the air after the stuck-cast jump ({air} ms)";
|
||||
|
|
|
|||
106
Plugins/Shared/DerethClock.cs
Normal file
106
Plugins/Shared/DerethClock.cs
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
// ============================================================================
|
||||
// RynthSuite - Plugins/Shared/DerethClock.cs
|
||||
// Dereth's clock: day or night now, the hour's name, and how long until the
|
||||
// next dawn or dusk in real time (a request 2026-11-01: a small window with
|
||||
// the real minutes until the next day/night change). Pure: the caller reads
|
||||
// the raw clock and hands it in, so RynthDefective.Tests checks the math.
|
||||
//
|
||||
// The raw clock is the double at 0x008379A8 (acclient's Timer::cur_time, in
|
||||
// seconds). It is only readable once the player is in world, and a fault
|
||||
// there is an AccessViolation .NET can't catch: never read it before world
|
||||
// entry (RynthAi's Meta/ExpressionEngine.cs ReadGameClock has the same rule).
|
||||
//
|
||||
// The calendar is RynthAi's meta expressions' (the same file, which matches
|
||||
// UtilityBelt's DerethTime): 476.25 ticks an hour, 16 hours a day; day is
|
||||
// hours 4 (Dawnsong) to 11 (Warmtide-and-Half), night 12 (Evensong) to 3
|
||||
// (Foredawn-and-Half). A tick is one real second (the clock counts seconds),
|
||||
// so a Dereth day is 16 x 476.25 = 7620 s = 2 h 7 min of real time: 63.5
|
||||
// real minutes of day, then 63.5 of night.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace RynthCore.Plugin.Shared;
|
||||
|
||||
/// <summary>Dereth's time of day at one reading of the clock.</summary>
|
||||
internal readonly record struct DerethNow(
|
||||
bool IsDay,
|
||||
int Hour, // 0-15
|
||||
string HourName, // "Dawnsong", "Evensong-and-Half"...
|
||||
double SecondsToChange) // real seconds until the next dawn (at night) or dusk (by day)
|
||||
{
|
||||
/// <summary>What comes next: "Night" by day, "Day" at night.</summary>
|
||||
public string Next => IsDay ? "Night" : "Day";
|
||||
|
||||
/// <summary>The hour the change comes at: Evensong (dusk) or Dawnsong (dawn).</summary>
|
||||
public string NextHourName => DerethClock.HourNames[IsDay ? DerethClock.DuskHour : DerethClock.DawnHour];
|
||||
}
|
||||
|
||||
internal static class DerethClock
|
||||
{
|
||||
/// <summary>acclient's Timer::cur_time: a double, in seconds. Mapped only once in world.</summary>
|
||||
public const uint ClockAddress = 0x008379A8;
|
||||
|
||||
public const double TicksInHour = 476.25;
|
||||
public const int HoursInDay = 16;
|
||||
public const double TicksInDay = TicksInHour * HoursInDay; // 7620
|
||||
/// <summary>The clock counts seconds: one tick is one real second.</summary>
|
||||
public const double SecondsPerTick = 1.0;
|
||||
public const int DawnHour = 4, DuskHour = 12;
|
||||
|
||||
// RynthAi's GetGameTicks: the raw clock to Dereth's calendar (UB's DerethTime). Only its
|
||||
// -210 + 8 hours moves the time of day; the 10 years are whole days.
|
||||
private const double CalendarOffset = -210 + TicksInHour * 8 + TicksInHour * HoursInDay * 30 * 12 * 10;
|
||||
|
||||
public static readonly string[] HourNames =
|
||||
{
|
||||
"Darktide", "Darktide-and-Half", "Foredawn", "Foredawn-and-Half",
|
||||
"Dawnsong", "Dawnsong-and-Half", "Morntide", "Morntide-and-Half",
|
||||
"Midsong", "Midsong-and-Half", "Warmtide", "Warmtide-and-Half",
|
||||
"Evensong", "Evensong-and-Half", "Gloaming", "Gloaming-and-Half",
|
||||
};
|
||||
|
||||
/// <summary>A reading worth using: a number, past zero (0 before the clock is set).</summary>
|
||||
public static bool IsUsable(double raw) => double.IsFinite(raw) && raw > 0;
|
||||
|
||||
/// <summary>Dereth's calendar ticks for the raw clock (RynthAi's getgameticks).</summary>
|
||||
public static double GameTicks(double raw) => raw + CalendarOffset;
|
||||
|
||||
/// <summary>Ticks since Darktide began today, 0 to just under <see cref="TicksInDay"/>.</summary>
|
||||
public static double TicksIntoDay(double raw)
|
||||
{
|
||||
double t = GameTicks(raw) % TicksInDay;
|
||||
return t < 0 ? t + TicksInDay : t;
|
||||
}
|
||||
|
||||
/// <summary>Day or night, the hour, and the real seconds until the next dawn or dusk.</summary>
|
||||
public static DerethNow At(double raw)
|
||||
{
|
||||
double into = TicksIntoDay(raw);
|
||||
int hour = Math.Clamp((int)(into / TicksInHour), 0, HoursInDay - 1);
|
||||
bool day = hour >= DawnHour && hour < DuskHour;
|
||||
double dawn = DawnHour * TicksInHour, dusk = DuskHour * TicksInHour;
|
||||
double ticks = day ? dusk - into
|
||||
: into < dawn ? dawn - into
|
||||
: TicksInDay - into + dawn;
|
||||
return new DerethNow(day, hour, HourNames[hour], ticks * SecondsPerTick);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A countdown in real time: "1h 4m" and "23m" (whole minutes, rounded up) from 10 minutes,
|
||||
/// "4m 10s" under 10 minutes, "45s" under one. Never "0s" before the change: rounded up.
|
||||
/// </summary>
|
||||
public static string Countdown(double seconds)
|
||||
{
|
||||
long s = (long)Math.Ceiling(Math.Max(0, seconds));
|
||||
if (s < 60) return s.ToString(CultureInfo.InvariantCulture) + "s";
|
||||
if (s < 600) return (s / 60).ToString(CultureInfo.InvariantCulture) + "m " + (s % 60).ToString(CultureInfo.InvariantCulture) + "s";
|
||||
long m = (s + 59) / 60;
|
||||
if (m < 60) return m.ToString(CultureInfo.InvariantCulture) + "m";
|
||||
return (m / 60).ToString(CultureInfo.InvariantCulture) + "h " + (m % 60).ToString(CultureInfo.InvariantCulture) + "m";
|
||||
}
|
||||
|
||||
/// <summary>The window's line: "Night in 23m", "Day in 4m 10s".</summary>
|
||||
public static string Label(DerethNow now, double seconds) => now.Next + " in " + Countdown(seconds);
|
||||
}
|
||||
221
Plugins/Shared/RynthAiRoutesApi.cs
Normal file
221
Plugins/Shared/RynthAiRoutesApi.cs
Normal file
|
|
@ -0,0 +1,221 @@
|
|||
// ============================================================================
|
||||
// RynthSuite - Plugins/Shared/RynthAiRoutesApi.cs
|
||||
// The "RynthAi.Routes" interface (2026-10-30): another plugin (an AI layer
|
||||
// that drives characters, a route panel) has RynthAi make dungeon nav routes
|
||||
// and gets JSON answers. The same work as the chat commands, one
|
||||
// implementation (RynthAiPlugin.DunRoutes.cs, DungeonRouteMaker.cs):
|
||||
// /ra dunroute <name> to exit|far|portal <name>|<x> <y> <z>|room <n> [overwrite]
|
||||
// /ra dunpatrol-save <name> [overwrite]
|
||||
// /ra dunroute info <name> /ra dunroute where
|
||||
// Routes are written as VTank .nav files in RynthAi's NavProfiles folder,
|
||||
// where RynthAi's Nav picker lists them and /ra nav load <name> runs them.
|
||||
// RynthAi does not load or start a route it saves. The points are the ones
|
||||
// DungeonPathfinder lays for the patrol and dunnav (centred on doorways,
|
||||
// straight across rooms). The .nav format (VTank's, unchanged) has no field
|
||||
// for the doorway flag, so the doorway points are listed beside the routes
|
||||
// in NavProfiles\.rynthai-routes.json (file, SHA-256, dungeon landblock,
|
||||
// point count, doorway indexes; DunRouteSidecar.cs). When RynthAi loads an
|
||||
// unchanged route-maker file in its dungeon it puts the flags back, so the
|
||||
// route walks doorways as dunnav-patrol does; an edited file runs with the
|
||||
// ordinary point reach. Other tools ignore the list.
|
||||
//
|
||||
// Rules:
|
||||
// - Append-only: new functions go at the end, and Version goes up. A caller
|
||||
// checks StructSize before using a field past the ones it knows.
|
||||
// - Strings are UTF-8, NUL-terminated. The string handed back through a
|
||||
// byte** belongs to RynthAi and stays valid only until the next call into
|
||||
// this table: copy it at once.
|
||||
// - Call only from the plugin pump thread (OnTick and the events it drains),
|
||||
// never from Render. Resolve the table again every tick (a RynthAi reload
|
||||
// frees it). Every function returns safely.
|
||||
// - Threads: the work is not done off the game thread. DungeonPathfinder
|
||||
// keeps static per-landblock caches (the cell graph, the map geometry) and
|
||||
// DungeonGeometry a clearance memo, none of them thread-safe, and every
|
||||
// caller of them (the dungeon patrol, nav recovery detours) runs on the
|
||||
// plugin pump thread. So Request only checks the JSON and queues the job;
|
||||
// RynthAi works one job per tick in its own OnTick, on that thread, file
|
||||
// write included (a route file is a few KB).
|
||||
//
|
||||
// ── The two calls ──────────────────────────────────────────────────────────
|
||||
// Request(json, &answer) -> job id
|
||||
// Checks the request and queues it. Returns the job id (1 and up) with
|
||||
// answer = {"id":7,"state":"queued"}; or 0, refused at once, with
|
||||
// answer = {"error":"<why>"} (bad JSON, a wrong field, RynthAi not logged
|
||||
// in, 32 jobs still unfinished).
|
||||
// Poll(id, &json) -> 1 known job | 0 no such job
|
||||
// json = {"id":7,"op":"dunroute","state":"queued","detail":"...","result":null}
|
||||
// state queued waiting its turn (one job a RynthAi tick)
|
||||
// working started, waiting on the client (portal space, the
|
||||
// dungeon data loading); detail says what. It gives up
|
||||
// after 30 s and fails.
|
||||
// done result holds the answer (below)
|
||||
// failed detail says why (the same line chat would show);
|
||||
// result is null
|
||||
// detail one line, the one the chat command answers with.
|
||||
// An id RynthAi doesn't have (never given, dropped, or a RynthAi reload
|
||||
// since): 0, with json = {"id":7,"state":"unknown","detail":"..."}.
|
||||
// The last 32 jobs are kept: a new one drops the oldest finished one. Ids
|
||||
// are never reused while RynthAi stays loaded.
|
||||
//
|
||||
// ── Requests (one JSON object; unknown fields and wrong types are refused) ─
|
||||
// {"op":"dunroute","name":"Hive exit","to":"exit"}
|
||||
// {"op":"dunroute","name":"To depths","to":{"portal":"Portal to the Hive Depths"},"overwrite":true}
|
||||
// {"op":"dunroute","name":"Spot","to":{"x":110.5,"y":-3.25,"z":-24}}
|
||||
// {"op":"dunroute","name":"Far end","to":"far"}
|
||||
// {"op":"dunroute","name":"Room 12","to":{"room":12}}
|
||||
// {"op":"dunpatrol","name":"Hive patrol","overwrite":false}
|
||||
// {"op":"info","name":"Hive patrol"}
|
||||
// {"op":"where"}
|
||||
// op "dunroute" | "dunpatrol" | "info" | "where" (required)
|
||||
// name the route's name (dunroute, dunpatrol, info): a file name in
|
||||
// NavProfiles without ".nav" (".nav" on the end is dropped);
|
||||
// no folders, no \ / : * ? " < > |, no "..", not ending in a dot
|
||||
// or a space, at most 120 characters, not a name Windows
|
||||
// reserves (CON, NUL, COM1...)
|
||||
// to dunroute only (required):
|
||||
// "exit" the exit portal (picked as below)
|
||||
// "far" the reachable spot farthest from the
|
||||
// character on foot
|
||||
// {"portal":"n"} a portal by name: the exact name (any case),
|
||||
// else the names containing it; the nearest
|
||||
// when several match
|
||||
// {"x":..,"y":..,"z":..} a spot in dungeon coordinates: metres
|
||||
// in the landblock's own frame, the numbers
|
||||
// where's x/y/z and /ra navdebug's "local=" show
|
||||
// {"room":n} a room by its number (where's "room", the
|
||||
// rooms the dungeon map joins cells into;
|
||||
// needs the map loaded)
|
||||
// overwrite dunroute, dunpatrol: true replaces a file of that name; without
|
||||
// it an existing file is never replaced (the job fails, saying so)
|
||||
//
|
||||
// "exit": a dungeon is left by a portal (or a recall). The client is not told
|
||||
// where a portal goes, so the exit is the first that fits of: a portal whose
|
||||
// appraised destination (string property 38) is a spot on the landscape
|
||||
// ("12.3N, 45.6E"); a portal named like an exit (exit, surface, leave,
|
||||
// outside, out, return); the portal nearest where the character came into
|
||||
// this dungeon (within 40 m; RynthAi saw it arrive); the only portal known.
|
||||
// Nothing fits: the job fails and lists the portals known (then ask for one
|
||||
// by name). A one-way drop or a trap that teleports is the server's and
|
||||
// can't be seen by the client.
|
||||
//
|
||||
// ── Results (state done) ───────────────────────────────────────────────────
|
||||
// Positions: "x","y","z" are landblock-local metres, as in the requests;
|
||||
// "cell"/"id"/"landblock" are hex strings ("028902A5", "7028905D", "0289").
|
||||
// "yards" are RynthAi's yards (metres in the world). "leftOut" says what the
|
||||
// route does not cover or keeps out of; "notes" what a reader should know
|
||||
// (the map not loaded yet, portals the client hasn't been sent...).
|
||||
//
|
||||
// dunroute (a Once route: the character's spot first, the target last; a
|
||||
// portal target ends with a Portal step that uses the portal):
|
||||
// {"file":"C:\\Games\\RynthSuite\\RynthAi\\NavProfiles\\Hive exit.nav","name":"Hive exit",
|
||||
// "type":"once","points":14,"waypoints":13,"yards":96.4,"landblock":"0289",
|
||||
// "from":{"cell":"028902A5","x":110.0,"y":92.0,"z":-30.0},
|
||||
// "to":{"kind":"exit","portal":"Surface Portal","id":"7028905D","cell":"028902BA",
|
||||
// "x":110.0,"y":-3.78,"z":-24.0,"why":"named like an exit"},
|
||||
// "cells":9,"doorways":4,"doorwayPoints":3,"overwrote":false,
|
||||
// "leftOut":["3 lava/acid cells kept out of"],
|
||||
// "notes":["2 portals known in this dungeon (the client only knows the ones it has been sent)"]}
|
||||
// to.kind is "exit" | "portal" | "position" | "room" | "far"; to.portal,
|
||||
// to.id are there for a portal (null otherwise), to.room for a room.
|
||||
// points: every point in the file; waypoints: the ones walked to.
|
||||
// cells: cells the path goes through; doorways: narrow openings it lines
|
||||
// up on; doorwayPoints: the points flagged for them (recorded in
|
||||
// .rynthai-routes.json; a problem writing that list is in "notes").
|
||||
//
|
||||
// dunpatrol (the circular patrol /ra dunnav-patrol would walk from here, from
|
||||
// the waypoint it would start at; one lap):
|
||||
// {"file":"...\\Hive patrol.nav","name":"Hive patrol","type":"circular","points":355,
|
||||
// "waypoints":355,"yards":2210.5,"landblock":"0289",
|
||||
// "from":{"cell":"028902A5","x":110.0,"y":92.0,"z":-30.0},"startCell":"028902A5",
|
||||
// "cells":524,"reachable":480,"covered":402,"doorwayPoints":120,"overwrote":false,
|
||||
// "coverage":"coverage whole dungeon, skip dead ends <= 10, lava/acid floors avoided, walls 1.0 m, look into rooms >= 10 m",
|
||||
// "leftOut":["44 of 524 cells can't be walked to from here (behind drops or lava/acid, or not joined)",
|
||||
// "78 reachable cells left out by the coverage (whole dungeon, dead ends of up to 10 cells; Settings > Dungeon Patrol)",
|
||||
// "beyond portal 'Surface Portal': 1 opening(s) closed (a portal fires at a touch)"],
|
||||
// "notes":["..."]}
|
||||
// cells: the dungeon's cells; reachable: those walkable from here;
|
||||
// covered: those the patrol's coverage keeps (Settings > Navigation >
|
||||
// Dungeon Patrol, as dunnav-patrol). startCell: the cell the lap is laid
|
||||
// from. doorwayPoints: as for dunroute. The walk out of a hazard or a
|
||||
// portal's reach that dunnav-patrol puts first (only needed from where
|
||||
// the character stands) is not saved.
|
||||
// The patrol is refused where a server's owners asked for it to be off
|
||||
// (ServerPolicy), exactly as dunnav-patrol is.
|
||||
//
|
||||
// info (a saved route described; any .nav in NavProfiles):
|
||||
// {"file":"...","name":"Hive patrol","type":"circular","points":355,"waypoints":355,
|
||||
// "steps":{"portal":0,"recall":0,"pause":0,"chat":0,"jump":0,"npc":0,"vendor":0,"checkpoint":0},
|
||||
// "yards":2210.5,"landblock":"0289","landblocks":["0289"],"dungeon":true,
|
||||
// "cells":201,"startCell":"028902A5","endCell":"028902A5",
|
||||
// "forThisDungeon":"yes","pointsHere":355,"notes":[]}
|
||||
// landblock: the dungeon its points are in: the character's when they
|
||||
// are there, else the dungeon (of the landblocks round the ones its
|
||||
// points fall in) whose cells hold at least half of them, else the
|
||||
// landblock most points fall in (a landscape route); null with no points.
|
||||
// landblocks: the 192 m squares its points' coordinates fall in, most
|
||||
// first (a dungeon's cells can lie outside its own square: Tiny Hive
|
||||
// 0x0289's are in 0x0288's). dungeon: that landblock is a dungeon (null:
|
||||
// the dats aren't loaded); cells: distinct cells its points are in (null
|
||||
// when not a dungeon); startCell/endCell: the first and last point's.
|
||||
// forThisDungeon: "yes" (every point in the dungeon the character is in,
|
||||
// as NavigationEngine's area hold judges it), "partly", "no", or
|
||||
// "unknown" (the character isn't in a dungeon); pointsHere: how many are.
|
||||
//
|
||||
// where (where the character is; no file):
|
||||
// {"inDungeon":true,"landblock":"0289","cell":"028902A5","x":110.0,"y":92.0,"z":-30.0,
|
||||
// "ns":-0.1,"ew":-99.9,"cells":524,"reachable":480,"map":true,"rooms":120,"room":12,
|
||||
// "explored":0.35,"hazards":3,
|
||||
// "arrival":{"cell":"028902A5","x":110.2,"y":91.0,"z":-30.0},
|
||||
// "portals":[{"name":"Surface Portal","id":"7028905D","cell":"028902BA","x":110.0,
|
||||
// "y":-3.78,"z":-24.0,"yards":96.1,"walkYards":101.0,
|
||||
// "exit":"named like an exit","destination":null}]}
|
||||
// map: the dungeon map geometry (doorways, floors) is loaded; rooms/room
|
||||
// need it (null without). explored: the share of the floor the radar has
|
||||
// painted as visited this visit (null when the radar hasn't drawn this
|
||||
// dungeon). arrival: where RynthAi saw the character come in (null:
|
||||
// RynthAi was loaded after). portals: every portal the client knows here,
|
||||
// nearest first; walkYards along the cell path (null: no walkable way);
|
||||
// exit: why it would be the exit (null: it wouldn't); destination: its
|
||||
// appraised destination text, when the client has it.
|
||||
// Outside a dungeon: {"inDungeon":false,"landblock":..,"cell":..,"x","y","z","ns","ew"}.
|
||||
//
|
||||
// ── A caller ───────────────────────────────────────────────────────────────
|
||||
// var t = (RynthAiRoutesApiV1*)host.GetPluginInterface("RynthAi",
|
||||
// RynthAiRoutesApiV1.InterfaceName, RynthAiRoutesApiV1.InterfaceVersion);
|
||||
// if (t == null || t->Version < 1 || t->StructSize < (uint)sizeof(RynthAiRoutesApiV1)) return;
|
||||
// byte* answer;
|
||||
// uint id = t->Request(jsonUtf8, &answer); // 0: refused, answer says why
|
||||
// ... on later ticks: t->Poll(id, &json) until state is done or failed.
|
||||
// ============================================================================
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RynthCore.Plugin.Shared;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public unsafe struct RynthAiRoutesApiV1
|
||||
{
|
||||
public const string InterfaceName = "RynthAi.Routes";
|
||||
public const uint InterfaceVersion = 1;
|
||||
|
||||
/// <summary>Jobs kept: a new one drops the oldest finished one; with this many unfinished, Request refuses.</summary>
|
||||
public const int MaxJobs = 32;
|
||||
|
||||
/// <summary>The longest request accepted, in UTF-8 bytes.</summary>
|
||||
public const int MaxRequestBytes = 8192;
|
||||
|
||||
public uint Version; // InterfaceVersion of the table RynthAi filled
|
||||
public uint StructSize; // sizeof(RynthAiRoutesApiV1) as RynthAi built it
|
||||
|
||||
/// <summary>
|
||||
/// Queues a request (UTF-8 JSON, see the header). Returns the job id (1 and up) with *answer =
|
||||
/// {"id":N,"state":"queued"}, or 0 when refused at once with *answer = {"error":"..."}.
|
||||
/// </summary>
|
||||
public delegate* unmanaged[Cdecl]<byte*, byte**, uint> Request;
|
||||
|
||||
/// <summary>
|
||||
/// A job's state: 1 with *json = {"id","op","state","detail","result"}; 0 for an id RynthAi doesn't
|
||||
/// have, with *json = {"id":N,"state":"unknown","detail":"..."}.
|
||||
/// </summary>
|
||||
public delegate* unmanaged[Cdecl]<uint, byte**, int> Poll;
|
||||
}
|
||||
170
Plugins/Shared/RynthNavRoutesApi.cs
Normal file
170
Plugins/Shared/RynthNavRoutesApi.cs
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
// ============================================================================
|
||||
// RynthSuite - Plugins/Shared/RynthNavRoutesApi.cs
|
||||
// The "RynthNav.Routes" interface (2026-10-30): RynthNav's route maker offered
|
||||
// to other plugins through the host's GetPluginInterface (API v68). Plan trips,
|
||||
// make RynthAi nav routes that follow real walkable paths (a trip, a hunting
|
||||
// loop, a path through points), describe a saved one, search the Atlas, walk
|
||||
// somewhere and stop, and ask where the player is. Everything is JSON: a
|
||||
// caller sends a request, gets a job id at once, and polls the job until it
|
||||
// is done or failed. The /rnav makeroute, makeloop, makepath and routeinfo
|
||||
// commands are the same jobs (RynthNav's RynthNavPlugin.RouteMaker.cs).
|
||||
// Compiled into RynthNav and into every plugin that calls it (linked source),
|
||||
// so the layout can't drift.
|
||||
//
|
||||
// Rules (same as RynthAi.Script and RynthNav.Path):
|
||||
// - Append-only: new functions go at the end, and Version goes up. A caller
|
||||
// checks StructSize before using a field past the ones it knows.
|
||||
// - Strings are UTF-8, NUL-terminated. A string handed back through a byte**
|
||||
// belongs to RynthNav and stays valid only until the next call into this
|
||||
// table: copy it at once.
|
||||
// - Call only from the plugin pump thread (OnTick and the events it drains).
|
||||
// Resolve the table again every tick: never keep the pointer across ticks
|
||||
// (RynthNav can be reloaded or unloaded between them; a reload forgets the
|
||||
// jobs, and Poll then answers "unknown").
|
||||
// - Every function returns safely (no exception crosses the boundary).
|
||||
// - The work itself runs on a RynthNav worker, never on the caller's thread;
|
||||
// Request returns at once. Poll once a tick or slower.
|
||||
//
|
||||
// ── Calls ───────────────────────────────────────────────────────────────────
|
||||
// Request(json, &reply) -> job id > 0, reply = the job as Poll shows it
|
||||
// ({"id":..,"op":..,"state":"queued","detail":"queued","result":null});
|
||||
// -> 0, reply = {"error": why, "usage": the op's JSON form} for a refused request
|
||||
// (not JSON, over 16384 characters, an unknown op, a missing or wrong field,
|
||||
// out of range, a bad name, or 32 jobs already queued or working).
|
||||
// Poll(id, &json) -> 1, json = {"id":n,"op":"makeloop","state":"queued|working|done|failed",
|
||||
// "detail":"one line saying where it is or why it failed",
|
||||
// "result": the op's result below (null until there is one;
|
||||
// {"error": why, ...} for most failed jobs)}
|
||||
// -> 0, json = {"id":n,"state":"unknown","error":...}: not a job RynthNav keeps
|
||||
// (only the last 32 are kept; a reload forgets them).
|
||||
// Job ids are positive and go up; they start from the clock, so a reload doesn't reuse old ones.
|
||||
// Jobs that work out walks (plan, makeroute, makeloop, makepath, info) run one at a time, in the
|
||||
// order asked; atlas, where, stop and go run on RynthNav's next tick.
|
||||
//
|
||||
// ── Requests ────────────────────────────────────────────────────────────────
|
||||
// Every request is a JSON object with "op". Unknown fields are ignored; a known field of the wrong
|
||||
// type is refused. Coordinates are map coordinates: {"ns": 42.1, "ew": 33.6}, north and east
|
||||
// positive, at most 102 either way. A place is a name from RynthNav's Atlas ("Holtburg") or
|
||||
// coordinates as text ("42.1N, 33.6E"), exactly what /rnav go takes. A route "name" is a nav file
|
||||
// name: no path, no characters a file name can't hold, at most 100 characters, ".nav" optional; it
|
||||
// goes in RynthAi's NavProfiles folder, and a file already there is only replaced with
|
||||
// "overwrite": true.
|
||||
//
|
||||
// plan {"op":"plan", "to":"Holtburg" | {"ns":42.1,"ew":33.6}, "portals":true|false, "show":false}
|
||||
// Plans a trip from where the player stands, as /rnav route (portals and recalls when
|
||||
// "portals" is true; left out = the player's "portals" switch), and works out its walks.
|
||||
// "show": true also shows it in RynthNav's panel and on the ground.
|
||||
// result {"to":{"name","ns","ew"}, "portals":true,
|
||||
// "steps":[{"kind":"walk|portal|recall|town","name":"...","ns":..,"ew":..,"yards":412,
|
||||
// "land":{"ns","ew"} (portal, recall, town: where it lands)}, ...],
|
||||
// "yards":3312, "teleports":2, "minutes":6.4, "notes":["step 2: ..."]}
|
||||
// kind town = through the Town Network to its exit "name". minutes is rough: running at
|
||||
// 10 yd/s, 36 s for each teleport, and each recall's cast time.
|
||||
//
|
||||
// makeroute {"op":"makeroute", "name":"To Holtburg", "to":"Holtburg" | {"ns","ew"}, "portals":true|false,
|
||||
// "overwrite":false, "show":false}
|
||||
// plan, then save it as a RynthAi nav route (type once), as /rnav route then /rnav saveroute.
|
||||
// result {"name","file":"C:\\...\\NavProfiles\\To Holtburg.nav","type":"once","points":47,
|
||||
// "yards":3290,"dropped":0,"droppedPoints":[],"to":{"name","ns","ew"},"waypoints":44,
|
||||
// "portals":1,"recalls":1,"teleports":2,"stoppedShort":null | "step 3: why",
|
||||
// "notes":[...]}
|
||||
//
|
||||
// makeloop {"op":"makeloop", "name":"Holtburg loop", "at":"here" | {"ns","ew"} | "42.1N, 33.6E",
|
||||
// "radius":80, "points":8, "overwrite":false}
|
||||
// A hunting loop, saved as a circular nav route: "points" walkable spots round the centre
|
||||
// ("at"; left out = here) within "radius" yards (20 to 250; points 3 to 16, left out =
|
||||
// about one per 45 yd of the circle), out of buildings, 20 yd or more from any portal, off
|
||||
// walls, each reachable from the centre; walked in order round the centre with no two legs
|
||||
// crossing, each leg a real path that never enters a portal's circle, pushed off walls by
|
||||
// RynthNav's wall clearance, round buildings where it can. Spots that can't be used are
|
||||
// dropped and listed.
|
||||
// result {"name","file","type":"circular","points":38,"yards":612,"dropped":1,
|
||||
// "droppedPoints":[{"ns","ew","why":"not reachable from the centre"}],
|
||||
// "centre":{"ns","ew"},"radius":80,"loopPoints":7,"asked":8,"notes":[...]}
|
||||
// points = the nav file's points (waypoints along the legs); loopPoints = the chosen spots.
|
||||
//
|
||||
// makepath {"op":"makepath", "name":"Ridge walk", "type":"loop|line|once",
|
||||
// "points":[{"ns":42.1,"ew":33.6}, "42.3N, 33.9E", ...], "overwrite":false}
|
||||
// A nav route through the points in that order (2 to 32; type loop = circular, line =
|
||||
// linear, once; left out = once), each leg a real path (RynthNav's portal and wall avoid
|
||||
// settings), a loop also back from the last to the first. Fails, naming the leg, when one
|
||||
// can't be walked; fails naming the point when one has no ground within 12 yd or stands in
|
||||
// a portal's circle.
|
||||
// result {"name","file","type":"once","points":31,"yards":450,"dropped":0,"droppedPoints":[],
|
||||
// "given":3,"legs":2,"notes":[]}
|
||||
//
|
||||
// info {"op":"info", "name":"Holtburg loop"}
|
||||
// What a nav file in NavProfiles is (/rnav routeinfo).
|
||||
// result {"name","file","type":"circular|linear|once|follow","points":38,
|
||||
// "counts":{"waypoints","portals","recalls","chats","pauses","other"},
|
||||
// "yards":612 (walking; a circular route's lap; not across teleports),
|
||||
// "box":{"minNs","maxNs","minEw","maxEw"},"centre":{"ns","ew"},
|
||||
// "start":{"ns","ew","yards" (from the player, null when not on the map)},
|
||||
// "nearest":{"index","ns","ew","yards"} | null (the waypoint nearest the player),
|
||||
// "landblocks":["A9B4",...],"dungeon":false,"dungeonLandblocks":[],
|
||||
// "portals":["Portal to ..."],"recalls":["Lifestone Recall"],"chats":["@lifestone"],
|
||||
// "warning": RynthAi's reader's warning, when it gave one}
|
||||
//
|
||||
// atlas {"op":"atlas", "search":"holt", "max":10}
|
||||
// result {"search","count":3,"places":[{"name":"Holtburg","kind":"Town","onMap":true,
|
||||
// "ns":42.1,"ew":33.6,"yards":1234 (from the player; null when not on the map)},
|
||||
// {"name","kind":"Dungeon","onMap":false,"ns":null,"ew":null,"yards":null,"where":"..."}]}
|
||||
// max 1 to 50 (left out = 10).
|
||||
//
|
||||
// go {"op":"go", "to":"Holtburg" | {"ns","ew"}}
|
||||
// Walks there as /rnav go does (a dungeon walks into its entrance portal). The job stays
|
||||
// "working" while it walks (detail: "walking to Holtburg, 1.2k yd left") and ends:
|
||||
// done with outcome "arrived" (or "stopped" when stopped by stop, /rnav stop, the panel,
|
||||
// or another goto taking over), failed with the reason (no progress, a portal on the way,
|
||||
// no route, logged out...).
|
||||
// result {"started":true,"to":{"name","ns","ew"},"enter":"<dungeon>"|null,"steps":3,
|
||||
// "teleports":2,"outcome":"walking|arrived|stopped|failed","reason":"..."}
|
||||
// A walk that couldn't start: failed, {"started":false,"outcome":"failed","reason":...}.
|
||||
//
|
||||
// stop {"op":"stop"} stops a walk (any, as /rnav stop). result {"wasWalking":true}
|
||||
//
|
||||
// where {"op":"where"}
|
||||
// result {"onMap":true,"ns":42.1,"ew":33.6 (null in a dungeon),"landblock":"A9B4",
|
||||
// "cell":"A9B40031","indoors":false,"dungeon":false,"walking":false,
|
||||
// "nearest":{"name","kind","ns","ew","yards"} | null (the nearest Atlas place)}
|
||||
//
|
||||
// Ops that need the player (plan, makeroute, go, where, makeloop "here") fail with "no player
|
||||
// position yet" before login; makeloop "at", makepath, info and atlas don't need one.
|
||||
//
|
||||
// ── Example ─────────────────────────────────────────────────────────────────
|
||||
// var t = (RynthNavRoutesApiV1*)Host.GetPluginInterface("RynthNav", "RynthNav.Routes", 1);
|
||||
// byte* reply;
|
||||
// int id = t->Request(utf8("{\"op\":\"makeloop\",\"name\":\"Hunt 1\",\"radius\":80}"), &reply);
|
||||
// ... a later tick (resolve t again) ...
|
||||
// byte* json; t->Poll(id, &json); // {"id":..,"op":"makeloop","state":"done","detail":"saved Hunt 1.nav: 8 points, 612 yd a lap","result":{...}}
|
||||
// ============================================================================
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RynthCore.Plugin.Shared;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public unsafe struct RynthNavRoutesApiV1
|
||||
{
|
||||
public const string PluginName = "RynthNav";
|
||||
public const string InterfaceName = "RynthNav.Routes";
|
||||
public const uint InterfaceVersion = 1;
|
||||
|
||||
/// <summary>How many jobs RynthNav keeps (finished ones are dropped oldest first).</summary>
|
||||
public const int MaxJobs = 32;
|
||||
|
||||
public uint Version; // InterfaceVersion of the table RynthNav filled
|
||||
public uint StructSize; // sizeof(RynthNavRoutesApiV1) as RynthNav built it
|
||||
|
||||
/// <summary>
|
||||
/// Queues a request (UTF-8 JSON, see the header). Returns its job id (> 0) with *reply = the job's
|
||||
/// JSON, or 0 with *reply = {"error", "usage"} when the request is refused.
|
||||
/// </summary>
|
||||
public delegate* unmanaged[Cdecl]<byte*, byte**, int> Request;
|
||||
|
||||
/// <summary>
|
||||
/// A job's state: 1 with *json = {id, op, state, detail, result}; 0 with *json = {id, state: "unknown",
|
||||
/// error} for an id RynthNav doesn't keep.
|
||||
/// </summary>
|
||||
public delegate* unmanaged[Cdecl]<int, byte**, int> Poll;
|
||||
}
|
||||
|
|
@ -51,8 +51,11 @@
|
|||
// // (RynthAelrynth; RynthAi keeps learned HP and kills per tier)
|
||||
// "vendorBank": 1, // the server's bank pays a pyreal vendor what the packs are short
|
||||
// // of (absent or 0 = it doesn't: readers count the packs only),
|
||||
// "vendorBankPyreals": 5000 // and what the bank can add beyond the pyreals the game shows
|
||||
// } // (absent = not known: the server decides). RynthDefective's buys.
|
||||
// "vendorBankPyreals": 5000, // and what the bank can add beyond the pyreals the game shows
|
||||
// // (absent = not known: the server decides). RynthDefective's buys.
|
||||
// "bankLuminance": 8904758 // the luminance in the server's bank, deposits taken out, for a
|
||||
// } // server that banks earned luminance where the client can't see
|
||||
// // it (RynthDreamWeave's /b); rises are luminance earned (Lum/hr).
|
||||
// }
|
||||
// ============================================================================
|
||||
|
||||
|
|
@ -103,6 +106,16 @@ public static class RynthServerProfile
|
|||
/// leave the money to the server.
|
||||
/// </summary>
|
||||
public const string ValueVendorBankPyreals = "vendorBankPyreals";
|
||||
|
||||
/// <summary>
|
||||
/// The luminance in this character's bank on the server, as last read, less what the server
|
||||
/// plugin saw deposited from the character since login (whole luminance, 0 or more), for a
|
||||
/// server that banks earned luminance where the client can't read it (no bank property). A rise
|
||||
/// is luminance earned; a drop is spending. Absent: not known (not read yet, or the server has
|
||||
/// no such bank). The session stats (SessionStatsTracker) count its rises when the client has
|
||||
/// no bank property of its own. (2026-11-02, RynthDreamWeave's every-minute /b.)
|
||||
/// </summary>
|
||||
public const string ValueBankLuminance = "bankLuminance";
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ internal static class RynthIcons
|
|||
public const string MapTrifold = "\uE31A";
|
||||
public const string Minus = "\uE32A";
|
||||
public const string Monitor = "\uE32E";
|
||||
public const string Moon = "\uE330";
|
||||
public const string NavigationArrow = "\uEADE";
|
||||
public const string Package = "\uE390";
|
||||
public const string Path = "\uE39C";
|
||||
|
|
|
|||
|
|
@ -19,6 +19,11 @@
|
|||
// rises are ignored. "Deposited N luminance" and "Received N
|
||||
// luminance from X" move lum into the bank without earning it:
|
||||
// they are taken out of the next bank rises.
|
||||
// Server bank a server that banks earned luminance out of the client's
|
||||
// sight: its server plugin reads the bank (a chat command once
|
||||
// a minute) and publishes it in its profile ("bankLuminance");
|
||||
// SessionStatsTracker passes that in as BankLum when 9005 isn't
|
||||
// readable, so it counts exactly as ACECustom's bank (2026-11-02).
|
||||
// Pass-up ACECustom never sends the allegiance counters (9013/9014).
|
||||
// A vassal's pass-up lands in the bank silently, while your own
|
||||
// kill and quest lum prints "You've banked N Luminance.", so
|
||||
|
|
|
|||
|
|
@ -9,6 +9,17 @@
|
|||
// Threading: every call except RequestReset and View runs on the pump
|
||||
// thread. RequestReset only sets a flag (any thread); View is an immutable
|
||||
// record swapped in after each poll (any thread).
|
||||
//
|
||||
// The bank's luminance where the client has no bank property (2026-11-02):
|
||||
// a server that keeps earned luminance in its bank out of the client's sight
|
||||
// has its server plugin read the bank and publish it in its profile
|
||||
// ("RynthServer.Profile" values, RynthServerProfile.ValueBankLuminance;
|
||||
// RynthDreamWeave's every-minute /b). Read every few seconds from the active
|
||||
// server's owner (ServerStateClient) and only while ACECustom's 9005 isn't
|
||||
// readable, it goes in as that bank's reading: the same baseline (the
|
||||
// session file's "bank"), so rises are earned luminance and drops aren't.
|
||||
// Needs, linked into the plugin: ServerStateClient.cs, EngineServerState.cs,
|
||||
// RynthServerProfileApi.cs.
|
||||
// ============================================================================
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -40,6 +51,9 @@ internal sealed class SessionStatsTracker
|
|||
private readonly string _saveDirectory;
|
||||
private readonly SessionStats _stats = new();
|
||||
private readonly List<(uint Id, DateTime Seen)> _pendingCorpses = new();
|
||||
private readonly ServerStateClient _server = new();
|
||||
private long? _profileBankLum; // the active server profile's bank luminance (null = none)
|
||||
private long _nextProfileMs;
|
||||
|
||||
private uint _playerId;
|
||||
private bool _loggedIn; // between OnLoginComplete and OnLogout
|
||||
|
|
@ -66,6 +80,12 @@ internal sealed class SessionStatsTracker
|
|||
/// <summary>True while a session is running (pump thread).</summary>
|
||||
public bool Active => _active;
|
||||
|
||||
/// <summary>
|
||||
/// How often the active server profile's bank luminance is re-read (a server plugin reads its bank
|
||||
/// once a minute at most). Tests set it lower.
|
||||
/// </summary>
|
||||
internal long ProfileIntervalMs { get; init; } = 5000;
|
||||
|
||||
/// <summary>Starts a fresh session on the next tick (any thread).</summary>
|
||||
public void RequestReset() => _pendingReset = true;
|
||||
|
||||
|
|
@ -91,6 +111,9 @@ internal sealed class SessionStatsTracker
|
|||
_loggedIn = false;
|
||||
_active = false;
|
||||
_pendingCorpses.Clear();
|
||||
_server.Clear();
|
||||
_profileBankLum = null;
|
||||
_nextProfileMs = 0;
|
||||
_view = SessionStatsView.Empty;
|
||||
_host.Log($"{_tag} Session ended.");
|
||||
}
|
||||
|
|
@ -186,7 +209,7 @@ internal sealed class SessionStatsTracker
|
|||
long nowMs = Environment.TickCount64;
|
||||
if (nowMs < _nextPollMs) return;
|
||||
_nextPollMs = nowMs + PollIntervalMs;
|
||||
Poll(now);
|
||||
Poll(now, nowMs);
|
||||
_view = _stats.View(now);
|
||||
|
||||
// Saved right after a poll, so totals and baselines in the file always match.
|
||||
|
|
@ -197,13 +220,13 @@ internal sealed class SessionStatsTracker
|
|||
}
|
||||
}
|
||||
|
||||
private void Poll(DateTime now)
|
||||
private void Poll(DateTime now, long nowMs)
|
||||
{
|
||||
if (_playerId == 0 || !_host.HasGetObjectQuadProperty) return;
|
||||
_stats.Sample(new SessionSample(
|
||||
Read(Int64TotalExperience),
|
||||
Read(Int64AvailableLuminance),
|
||||
Read(Int64BankedLuminance),
|
||||
Read(Int64BankedLuminance) ?? ProfileBankLum(nowMs),
|
||||
Read(Int64LuminanceBanked),
|
||||
Read(Int64LuminanceDrawn),
|
||||
Read(Int64RadianceEarned)), now);
|
||||
|
|
@ -212,6 +235,24 @@ internal sealed class SessionStatsTracker
|
|||
private long? Read(uint stype)
|
||||
=> _host.TryGetObjectQuadProperty(_playerId, stype, out long value) ? value : null;
|
||||
|
||||
/// <summary>
|
||||
/// The active server profile's bank luminance (RynthServerProfile.ValueBankLuminance), re-read every
|
||||
/// few seconds and held in between; null while the profile has none (or the engine is older than v86).
|
||||
/// </summary>
|
||||
private long? ProfileBankLum(long nowMs)
|
||||
{
|
||||
if (nowMs < _nextProfileMs) return _profileBankLum;
|
||||
_nextProfileMs = nowMs + ProfileIntervalMs;
|
||||
try
|
||||
{
|
||||
_server.Poll(_host, nowMs, force: true); // throttled here, not by the client's own 2 s
|
||||
double v = ServerProfileView.Value(_server.ProfileJson, RynthServerProfile.ValueBankLuminance, double.NaN);
|
||||
_profileBankLum = v >= 0 && v < long.MaxValue ? (long)v : null;
|
||||
}
|
||||
catch { _profileBankLum = null; }
|
||||
return _profileBankLum;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The player's health from the engine's vitals (the same reading RynthAi's death hold uses),
|
||||
/// then the server's death counter, in the order the server sends them (SessionStats counts
|
||||
|
|
|
|||
Loading…
Reference in a new issue