RynthSuite as of 2026-10-04 (internal c94715f): RynthOracle (based on Oracle of Dereth by Advis Eveldan) and RynthInventory, RynthAi patrol doorways and rooms, healing priority, strict monster priority, finish the wounded target, slayer weapons, arcs when clear, blasts like rings, learn unknown spells, looting fixes, release 2026.10.4.6

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Tom Bohar 2026-10-04 18:34:29 -04:00
commit 12ca25f911
426 changed files with 108239 additions and 7521 deletions

View file

@ -1,9 +1,19 @@
using System;
using System.Text;
using System.Threading;
namespace RynthCore.Plugin.RynthChat;
/// <summary>
/// The newest 500 chat lines, exported to the engine as JSON
/// (RynthChatGetScrollbackJson). Add runs on the game thread (chat dispatch),
/// BuildJson on the engine's pump thread; the lock covers both.
///
/// JSON per line: {"seq":N,"ts":"HH:mm:ss","chan":"Chat","type":3,"sender":"Bob"|null,"text":"..."}.
/// "type" (AC's ChatMessageType) was added in 0.2.0; engines before it ignore it.
/// Every non-ASCII character is written as a \uXXXX escape, so the export is
/// pure ASCII and survives the ANSI marshalling on both sides (before 0.2.0 an
/// accented name or the "→" of an outgoing tell arrived as "?").
/// </summary>
internal sealed class ChatBuffer
{
private const int Capacity = 500;
@ -23,18 +33,19 @@ internal sealed class ChatBuffer
string? sender = ChatClassifier.SenderFor(text, chatType);
string ts = DateTime.Now.ToString("HH:mm:ss");
var line = new ChatLine
{
Seq = Interlocked.Increment(ref _nextSeq) - 1,
Timestamp = ts,
Channel = channel,
Sender = sender,
Text = text,
};
lock (_lock)
{
_ring[_head % Capacity] = line;
// Numbered under the lock, so the ring is always in seq order (the
// engine skips anything at or below the last seq it has seen).
_ring[_head % Capacity] = new ChatLine
{
Seq = _nextSeq++,
Timestamp = ts,
Channel = channel,
ChatType = chatType,
Sender = sender,
Text = text,
};
_head = (_head + 1) % Capacity;
if (_count < Capacity) _count++;
}
@ -69,10 +80,12 @@ internal sealed class ChatBuffer
sb.Append("{\"seq\":");
sb.Append(line.Seq);
sb.Append(",\"ts\":\"");
sb.Append(line.Timestamp);
AppendEscaped(sb, line.Timestamp);
sb.Append("\",\"chan\":\"");
AppendEscaped(sb, line.Channel);
sb.Append("\",\"sender\":");
sb.Append("\",\"type\":");
sb.Append(line.ChatType);
sb.Append(",\"sender\":");
if (line.Sender != null)
{
sb.Append('"');
@ -94,8 +107,23 @@ internal sealed class ChatBuffer
private static void AppendEscaped(StringBuilder sb, string s)
{
foreach (char c in s)
for (int i = 0; i < s.Length; i++)
{
char c = s[i];
// A surrogate pair is escaped as two \uXXXX; a lone half becomes U+FFFD.
// System.Text.Json refuses a lone surrogate, and before 0.2.1 one such line
// failed the engine's whole batch (and every poll after it).
if (char.IsSurrogate(c))
{
if (char.IsHighSurrogate(c) && i + 1 < s.Length && char.IsLowSurrogate(s[i + 1]))
{
AppendUnicodeEscape(sb, c);
AppendUnicodeEscape(sb, s[++i]);
}
else
sb.Append("\\uFFFD");
continue;
}
switch (c)
{
case '"': sb.Append("\\\""); break;
@ -104,12 +132,20 @@ internal sealed class ChatBuffer
case '\r': sb.Append("\\r"); break;
case '\t': sb.Append("\\t"); break;
default:
if (c < 0x20)
sb.Append($"\\u{(int)c:X4}");
// Control characters and everything outside ASCII: the string is
// marshalled as ANSI, which would turn those into '?'.
if (c < 0x20 || c > 0x7E)
AppendUnicodeEscape(sb, c);
else
sb.Append(c);
break;
}
}
}
private static void AppendUnicodeEscape(StringBuilder sb, char c)
{
sb.Append("\\u");
sb.Append(((int)c).ToString("X4"));
}
}

View file

@ -50,35 +50,37 @@ internal static class ChatClassifier
};
// ── Sender extraction ──────────────────────────────────────────────────
// Bob says, "..." / Bob tells you, "..." / [General] Bob says, "..."
// [Allegiance] Bob says, "..." / Bob says on the Fellowship channel, "..."
// Before 0.2.0 the channel-tag forms captured "[General] Bob" as the sender.
// The sender is metadata (mentions, rules); the engine no longer prints it
// in front of the line, which already names the speaker.
private static readonly Regex _sayRe = new(@"^(.+?) says, """, RegexOptions.Compiled);
private static readonly Regex _tellInRe = new(@"^(.+?) tells you, """, RegexOptions.Compiled);
private static readonly Regex _tellOutRe = new(@"^You tell (.+?), """, RegexOptions.Compiled);
private static readonly Regex _allegianceRe = new(@"^(.+?) says on the Allegiance channel, """, RegexOptions.Compiled);
private static readonly Regex _fellowRe = new(@"^(.+?) says on the Fellowship channel, """, RegexOptions.Compiled);
private static readonly Regex _chanSenderRe = new(@"^(.+?) says on the .+? channel, """, RegexOptions.Compiled);
private static readonly TimeSpan Timeout = TimeSpan.FromMilliseconds(20);
private static readonly Regex _incomingRe = new(
@"^(?:\[[^\]]{1,40}\] )?(.+?) (?:says|tells you)\b[^""]{0,60}?, """, RegexOptions.CultureInvariant, Timeout);
private static readonly Regex _tellOutRe = new(@"^You tell (.+?), """, RegexOptions.CultureInvariant, Timeout);
internal static string? SenderFor(string text, int chatType) => (uint)chatType switch
{
0x02 => Match(_sayRe, text),
0x03 => Match(_tellInRe, text),
0x02 or 0x03 or 0x08 or 0x0A or 0x12 or 0x13 => Match(_incomingRe, text),
0x04 => TellOutSender(text),
0x12 => Match(_allegianceRe, text) ?? Match(_sayRe, text),
0x13 => Match(_fellowRe, text) ?? Match(_sayRe, text),
0x0A => Match(_sayRe, text),
0x08 => Match(_chanSenderRe, text),
_ => null,
};
private static string? Match(Regex re, string text)
{
var m = re.Match(text);
return m.Success ? m.Groups[1].Value : null;
try
{
var m = re.Match(text);
return m.Success ? m.Groups[1].Value : null;
}
catch (RegexMatchTimeoutException) { return null; }
}
private static string? TellOutSender(string text)
{
var m = _tellOutRe.Match(text);
return m.Success ? $"→{m.Groups[1].Value}" : null;
string? name = Match(_tellOutRe, text);
return name != null ? $"→{name}" : null;
}
}

View file

@ -5,6 +5,8 @@ internal sealed class ChatLine
internal ulong Seq { get; init; }
internal string Timestamp { get; init; } = "";
internal string Channel { get; init; } = "";
/// <summary>AC's raw ChatMessageType (exported as "type" so engine rules can match on it).</summary>
internal int ChatType { get; init; }
internal string? Sender { get; init; }
internal string Text { get; init; } = "";
}

View file

@ -32,9 +32,6 @@ public static unsafe class PluginExports
[UnmanagedCallersOnly(EntryPoint = "RynthPluginTick", CallConvs = new[] { typeof(CallConvCdecl) })]
public static void Tick() => Runtime.OnTick();
[UnmanagedCallersOnly(EntryPoint = "RynthPluginRender", CallConvs = new[] { typeof(CallConvCdecl) })]
public static void Render() => Runtime.OnRender();
[UnmanagedCallersOnly(EntryPoint = "RynthPluginOnChatWindowText", CallConvs = new[] { typeof(CallConvCdecl) })]
public static void OnChatWindowText(IntPtr textUtf16, int chatType, IntPtr eatFlag) => Runtime.OnChatWindowText(textUtf16, chatType, eatFlag);

View file

@ -7,7 +7,7 @@ namespace RynthCore.Plugin.RynthChat;
public sealed class RynthChatPlugin : RynthPluginBase
{
internal static readonly IntPtr NamePointer = Marshal.StringToHGlobalAnsi("RynthChat");
internal static readonly IntPtr VersionPointer = Marshal.StringToHGlobalAnsi("0.1.0");
internal static readonly IntPtr VersionPointer = Marshal.StringToHGlobalAnsi("0.2.1");
private readonly ChatBuffer _buffer = new();
@ -29,6 +29,9 @@ public sealed class RynthChatPlugin : RynthPluginBase
public override void OnChatWindowText(string? text, int chatType, ref int eat)
{
// A plugin earlier in the dispatch ate the line (RynthAi's Meta Manager eats the
// reply to its own /myquests poll): keep it out of the chat window.
if (eat != 0) return;
_buffer.Add(text, chatType);
}

View file

@ -17,19 +17,13 @@
<Platforms>x86</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ImGui.NET" Version="1.91.6.1" />
</ItemGroup>
<ItemGroup>
<TrimmerRootAssembly Include="ImGui.NET" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\RynthCore\src\RynthCore.PluginCore\RynthCore.PluginCore.csproj" />
<ProjectReference Include="..\..\..\RynthCore\src\RynthCore.PluginSdk\RynthCore.PluginSdk.csproj" />
</ItemGroup>
<!-- RynthChat no longer references ImGui.NET (it never drew with it). These stay so a
cimgui.dll left in bin\ or publish\ by an older build never ships beside the plugin. -->
<Target Name="RemoveBundledImGuiNativeFromBuild" AfterTargets="Build">
<Delete Files="$(OutputPath)cimgui.dll" Condition="Exists('$(OutputPath)cimgui.dll')" />
</Target>