RynthSuite as of 2026-11-15 (internal 907fc16c): release 2026.11.15.3
This commit is contained in:
parent
047117cbb0
commit
04add6c51b
30 changed files with 2268 additions and 20 deletions
|
|
@ -1263,8 +1263,24 @@ public partial class CombatManager : IDisposable
|
|||
// Melee reaches through walls, on both sides: a monster this close is a target when
|
||||
// melee is, or is about to be, the attack (the owner, 2026-11-06). It was left out while
|
||||
// hitting the character, who then read as having nothing to fight.
|
||||
if (losBlocked && dist <= MeleeIgnoresLosWithin && MeleeIsTheAttackOn(wo, attackType))
|
||||
// Not through a building's wall (2026-11-13): Drakkon, outside, locked a sorcerer 3.6 m off
|
||||
// inside a building and swung at the wall for 12 s with nothing landing either way. One of
|
||||
// the two in a building's rooms and the other outside: left to the hunt (it walks in
|
||||
// through a door), and, like the floor above, not counted as out of sight, so the walk to
|
||||
// that door isn't held for it.
|
||||
// A setting since 2026-11-15 (Melee through walls, on by default). Off: none of this; a
|
||||
// blocked monster this close is out of sight like one farther off (counted below, so
|
||||
// jump-looting waits; it isn't swung at, so it is never blacklisted for a wall; the hunt,
|
||||
// which needs no line of sight, still walks round to it, and leaves it out if it can't).
|
||||
if (losBlocked && _settings.MeleeThroughWalls && dist <= MeleeIgnoresLosWithin && MeleeIsTheAttackOn(wo, attackType))
|
||||
{
|
||||
if (hasPlayerPos && AcrossBuildingWall(meCell, (uint)wo.Id))
|
||||
{
|
||||
if (notePassed) NotePassedOver(wo.Id, dist, PassedOverLos);
|
||||
continue;
|
||||
}
|
||||
losBlocked = false;
|
||||
}
|
||||
|
||||
// Don't blacklist from scan — just exclude from this result.
|
||||
// Blacklisting only happens when an active target fails LOS during attack.
|
||||
|
|
@ -7042,6 +7058,19 @@ public partial class CombatManager : IDisposable
|
|||
|
||||
/// <summary>A monster <paramref name="dist"/> m away (3D), <paramref name="dz"/> m above (+) or below (-),
|
||||
/// is out of melee's reach: on another floor, or on a ledge or a roof.</summary>
|
||||
/// <summary>True when one of the two cells is a building's room on an outdoor landblock and the other
|
||||
/// is outside (cells under 0x0100 are the landscape). Two dungeon cells are not: a dungeon has no
|
||||
/// outdoor cells, and a monster round a dungeon corner is still reached through the wall.</summary>
|
||||
internal static bool InsideVersusOutside(uint cellA, uint cellB)
|
||||
{
|
||||
bool aIn = (cellA & 0xFFFF) >= 0x0100, bIn = (cellB & 0xFFFF) >= 0x0100;
|
||||
return aIn != bIn;
|
||||
}
|
||||
|
||||
private bool AcrossBuildingWall(uint meCell, uint targetId)
|
||||
=> meCell != 0 && _host.TryGetObjectPosition(targetId, out uint tc, out _, out _, out _) && tc != 0
|
||||
&& InsideVersusOutside(meCell, tc);
|
||||
|
||||
internal static bool OutOfMeleeReachUpOrDown(double dist, double dz)
|
||||
{
|
||||
double rise = Math.Abs(dz);
|
||||
|
|
|
|||
|
|
@ -107,6 +107,8 @@ internal interface IDashboardHost
|
|||
void ToggleActiveGear();
|
||||
/// <summary>The Timed Commands window (commands sent every N seconds) open or closed.</summary>
|
||||
void ToggleTimedCommands();
|
||||
/// <summary>The Find a Feature window (search every feature: where it is, its command) open, its box ready.</summary>
|
||||
void OpenFeatureSearch();
|
||||
/// <summary>The Classic (retail) look: RynthCore's own face comes back for it.</summary>
|
||||
void UseClassicLook();
|
||||
/// <summary>The Mini Remote, drawn into the current window; the size it wants.</summary>
|
||||
|
|
@ -341,7 +343,7 @@ internal sealed unsafe class InstrumentDashboard
|
|||
cx += chip + chipGap;
|
||||
bool menuOpen = ImGui.IsPopupOpen(OptionsId);
|
||||
if (ChipButton("##c_menu", RynthIcons.DotsThree, new Vector2(cx, cy), menuOpen ? _text : _faint,
|
||||
"Options: opacity, size, the Classic look, pop out.", menuOpen))
|
||||
"Options: opacity, size, Find a feature, the Classic look, pop out.", menuOpen))
|
||||
OpenOptions(new Vector2(cx + chip, cy + chip + Px(4)), anchorRight: true);
|
||||
cx += chip + chipGap;
|
||||
if (ChipButton("##c_min", prefs.Minimized ? RynthIcons.ArrowsOutLineVertical : RynthIcons.ArrowsInLineVertical,
|
||||
|
|
@ -1102,6 +1104,14 @@ internal sealed unsafe class InstrumentDashboard
|
|||
dl.AddLine(new Vector2(p.X, p.Y + 0.5f), new Vector2(p.X + w, p.Y + 0.5f), _line);
|
||||
p.Y += Px(5);
|
||||
|
||||
// Search every feature (RynthAiPlugin.FeatureSearch.cs): its own window, no bar button.
|
||||
if (MenuItem(dl, ref p, w, "##m_find", RynthIcons.MagnifyingGlass, "Find a feature", "/ra find",
|
||||
"Can't find something? Search every RynthSuite feature by a word (death, vendor, buffs...):\n" +
|
||||
"where it is, its command, and a button that opens it (the Find a Feature window)."))
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
_d.OpenFeatureSearch();
|
||||
}
|
||||
if (MenuItem(dl, ref p, w, "##m_classic", RynthIcons.Scroll, "Classic look", "/rc dashboard classic",
|
||||
"The retail-style window with tabs (Main, Monsters, Gear, Buffs, Route, Loot, Meta, Tuning)."))
|
||||
{
|
||||
|
|
|
|||
183
Plugins/RynthCore.Plugin.RynthAi/Features/FeatureCatalog.cs
Normal file
183
Plugins/RynthCore.Plugin.RynthAi/Features/FeatureCatalog.cs
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
// ============================================================================
|
||||
// RynthAi - Features/FeatureCatalog.cs
|
||||
// The feature catalog (2026-11-13): one entry per thing a player would look
|
||||
// for, across RynthSuite and RynthCore, read from Docs/features/<area>.json
|
||||
// (the website's search reads the same files; Docs/features/SCHEMA in the
|
||||
// repo's featsearch notes). Every file there is embedded in RynthAi
|
||||
// (RynthCore.Plugin.RynthAi.csproj: EmbeddedResource with a wildcard, logical
|
||||
// names "RynthAi.Features.<file>.json") and read once, through the
|
||||
// source-generated RynthAiJsonContext (NativeAOT: no reflection).
|
||||
//
|
||||
// A file that doesn't parse logs one line and is skipped; an entry without an
|
||||
// id or a name is dropped (counted in the same line). Never throws.
|
||||
// ============================================================================
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.Features;
|
||||
|
||||
/// <summary>One catalog file: Docs/features/<area>.json.</summary>
|
||||
internal sealed class FeatureFile
|
||||
{
|
||||
public string Area { get; set; } = string.Empty;
|
||||
public List<FeatureEntry> Features { get; set; } = new();
|
||||
}
|
||||
|
||||
/// <summary>One thing a player would look for (the schema's fields; JSON names are the lower-case ones).</summary>
|
||||
internal sealed class FeatureEntry
|
||||
{
|
||||
/// <summary>"<prefix>.<kebab-name>", unique across every file.</summary>
|
||||
public string Id { get; set; } = string.Empty;
|
||||
/// <summary>The name the player sees in the UI, exactly.</summary>
|
||||
public string Name { get; set; } = string.Empty;
|
||||
/// <summary>"RynthAi", "RynthOracle", ... or "RynthCore".</summary>
|
||||
public string Plugin { get; set; } = string.Empty;
|
||||
/// <summary>A short category for browsing (Combat, Buffs, Hunting, ...).</summary>
|
||||
public string Group { get; set; } = string.Empty;
|
||||
/// <summary>One or two plain sentences, 200 characters at most.</summary>
|
||||
public string Summary { get; set; } = string.Empty;
|
||||
/// <summary>Button paths to it, ">" between steps.</summary>
|
||||
public List<string> Where { get; set; } = new();
|
||||
/// <summary>The typed command with its arguments, or empty.</summary>
|
||||
public string Command { get; set; } = string.Empty;
|
||||
/// <summary>A command that only opens where the feature lives (the window's Open button), or empty.</summary>
|
||||
public string Open { get; set; } = string.Empty;
|
||||
/// <summary>The LegacyUiSettings fields it covers (RynthAi only).</summary>
|
||||
public List<string> Settings { get; set; } = new();
|
||||
/// <summary>Words a player might type that aren't in the name or summary.</summary>
|
||||
public List<string> Keywords { get; set; } = new();
|
||||
}
|
||||
|
||||
/// <summary>One embedded file as it was read: its resource name, the file (null when it didn't parse) and the error.</summary>
|
||||
internal sealed record FeatureFileRead(string Resource, FeatureFile? File, string Error, int Dropped);
|
||||
|
||||
/// <summary>Every embedded catalog file, read once.</summary>
|
||||
internal sealed class FeatureCatalog
|
||||
{
|
||||
/// <summary>The logical-name prefix of the embedded files (the csproj's LogicalName).</summary>
|
||||
public const string ResourcePrefix = "RynthAi.Features.";
|
||||
|
||||
private static readonly object Gate = new();
|
||||
private static FeatureCatalog? _loaded;
|
||||
|
||||
/// <summary>Every entry, in file order (files by name).</summary>
|
||||
public IReadOnlyList<FeatureEntry> Entries { get; }
|
||||
|
||||
/// <summary>What each embedded file gave (tests, and the load's log line).</summary>
|
||||
public IReadOnlyList<FeatureFileRead> Files { get; }
|
||||
|
||||
public static readonly FeatureCatalog Empty = new(Array.Empty<FeatureEntry>(), Array.Empty<FeatureFileRead>());
|
||||
|
||||
private FeatureCatalog(IReadOnlyList<FeatureEntry> entries, IReadOnlyList<FeatureFileRead> files)
|
||||
{
|
||||
Entries = entries;
|
||||
Files = files;
|
||||
}
|
||||
|
||||
/// <summary>The embedded catalog, read on first use (any thread). <paramref name="log"/> gets one line per bad file.</summary>
|
||||
public static FeatureCatalog Shared(Action<string>? log)
|
||||
{
|
||||
lock (Gate)
|
||||
{
|
||||
return _loaded ??= LoadEmbedded(log);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The logical names of the embedded catalog files, sorted.</summary>
|
||||
public static List<string> ResourceNames()
|
||||
{
|
||||
var names = new List<string>();
|
||||
foreach (string n in typeof(FeatureCatalog).Assembly.GetManifestResourceNames())
|
||||
if (n.StartsWith(ResourcePrefix, StringComparison.Ordinal) && n.EndsWith(".json", StringComparison.OrdinalIgnoreCase))
|
||||
names.Add(n);
|
||||
names.Sort(StringComparer.Ordinal);
|
||||
return names;
|
||||
}
|
||||
|
||||
/// <summary>Reads every embedded catalog file. Never throws.</summary>
|
||||
public static FeatureCatalog LoadEmbedded(Action<string>? log)
|
||||
{
|
||||
var entries = new List<FeatureEntry>();
|
||||
var files = new List<FeatureFileRead>();
|
||||
List<string> names;
|
||||
try { names = ResourceNames(); }
|
||||
catch (Exception ex)
|
||||
{
|
||||
log?.Invoke($"[RynthAi] Find a Feature: couldn't list the catalog ({ex.GetType().Name}: {ex.Message}).");
|
||||
return Empty;
|
||||
}
|
||||
Assembly asm = typeof(FeatureCatalog).Assembly;
|
||||
foreach (string name in names)
|
||||
{
|
||||
FeatureFileRead read;
|
||||
try
|
||||
{
|
||||
using Stream? s = asm.GetManifestResourceStream(name);
|
||||
read = s == null ? new FeatureFileRead(name, null, "not found", 0) : Parse(name, s);
|
||||
}
|
||||
catch (Exception ex) { read = new FeatureFileRead(name, null, ex.GetType().Name + ": " + ex.Message, 0); }
|
||||
files.Add(read);
|
||||
string shown = name.Substring(ResourcePrefix.Length);
|
||||
if (read.File == null)
|
||||
log?.Invoke($"[RynthAi] Find a Feature: skipped {shown}, it doesn't read ({read.Error}).");
|
||||
else
|
||||
{
|
||||
entries.AddRange(read.File.Features);
|
||||
if (read.Dropped > 0)
|
||||
log?.Invoke($"[RynthAi] Find a Feature: {shown}: {read.Dropped} entries without an id or a name left out.");
|
||||
}
|
||||
}
|
||||
return new FeatureCatalog(entries, files);
|
||||
}
|
||||
|
||||
/// <summary>One file's JSON (the embedded stream, or a file on disk in the tests).</summary>
|
||||
public static FeatureFileRead Parse(string name, Stream json)
|
||||
{
|
||||
try
|
||||
{
|
||||
FeatureFile? f = JsonSerializer.Deserialize(json, RynthAiJsonContext.Default.FeatureFile);
|
||||
if (f == null) return new FeatureFileRead(name, null, "empty", 0);
|
||||
return Clean(name, f);
|
||||
}
|
||||
catch (JsonException ex) { return new FeatureFileRead(name, null, "line " + ((ex.LineNumber ?? -1) + 1) + ": " + ex.Message, 0); }
|
||||
catch (Exception ex) { return new FeatureFileRead(name, null, ex.GetType().Name + ": " + ex.Message, 0); }
|
||||
}
|
||||
|
||||
/// <summary>Nulls (an explicit JSON null) become empty; entries without an id or a name are dropped.</summary>
|
||||
private static FeatureFileRead Clean(string name, FeatureFile f)
|
||||
{
|
||||
f.Area ??= string.Empty;
|
||||
var kept = new List<FeatureEntry>();
|
||||
int dropped = 0;
|
||||
foreach (FeatureEntry? e in f.Features ?? new List<FeatureEntry>())
|
||||
{
|
||||
if (e == null) { dropped++; continue; }
|
||||
e.Id ??= string.Empty;
|
||||
e.Name ??= string.Empty;
|
||||
e.Plugin ??= string.Empty;
|
||||
e.Group ??= string.Empty;
|
||||
e.Summary ??= string.Empty;
|
||||
e.Command ??= string.Empty;
|
||||
e.Open ??= string.Empty;
|
||||
e.Where = NoNulls(e.Where);
|
||||
e.Settings = NoNulls(e.Settings);
|
||||
e.Keywords = NoNulls(e.Keywords);
|
||||
if (e.Id.Trim().Length == 0 || e.Name.Trim().Length == 0) { dropped++; continue; }
|
||||
if (e.Plugin.Length == 0) e.Plugin = f.Area;
|
||||
kept.Add(e);
|
||||
}
|
||||
f.Features = kept;
|
||||
return new FeatureFileRead(name, f, string.Empty, dropped);
|
||||
}
|
||||
|
||||
private static List<string> NoNulls(List<string>? list)
|
||||
{
|
||||
var r = new List<string>();
|
||||
if (list == null) return r;
|
||||
foreach (string? s in list) if (!string.IsNullOrWhiteSpace(s)) r.Add(s);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
215
Plugins/RynthCore.Plugin.RynthAi/Features/FeatureSearch.cs
Normal file
215
Plugins/RynthCore.Plugin.RynthAi/Features/FeatureSearch.cs
Normal file
|
|
@ -0,0 +1,215 @@
|
|||
// ============================================================================
|
||||
// RynthAi - Features/FeatureSearch.cs
|
||||
// The Find a Feature search (pure; RynthAiHostTests' FeatureSearchTests).
|
||||
//
|
||||
// Every typed word must match somewhere in the entry: its name, keywords,
|
||||
// summary, where paths, command / open, group or plugin. Case doesn't matter;
|
||||
// a word matches a word of the entry it is the start of ("vend" finds Vendors),
|
||||
// after light stemming on both sides (a plural s, -ing, -ed: "dying" stays,
|
||||
// "deaths" finds Death, "looting" finds Loot). Ranked by where each word hit:
|
||||
// the name over the keywords over the command, group, summary and where. No
|
||||
// words: every entry, grouped by its group.
|
||||
// ============================================================================
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.Features;
|
||||
|
||||
/// <summary>One result: the entry and its score (higher first).</summary>
|
||||
internal readonly record struct FeatureHit(FeatureEntry Entry, int Score);
|
||||
|
||||
/// <summary>One group of the browse view (no words typed): its name and its entries by name.</summary>
|
||||
internal sealed record FeatureGroup(string Name, List<FeatureEntry> Entries);
|
||||
|
||||
internal static class FeatureSearch
|
||||
{
|
||||
// Weights per field a word hit in (the best one counts for that word).
|
||||
public const int NameWeight = 100, KeywordWeight = 60, CommandWeight = 45, GroupWeight = 40,
|
||||
SummaryWeight = 30, WhereWeight = 25, PluginWeight = 20;
|
||||
/// <summary>A word that is a whole word of the field (not just its start) scores this much more.</summary>
|
||||
public const int WholeWordBonus = 10;
|
||||
|
||||
/// <summary>The schema's groups, in the order the browse view shows them (others after, by name).</summary>
|
||||
public static readonly string[] GroupOrder =
|
||||
{
|
||||
"Help", "Windows", "Combat", "Buffs", "Hunting", "Navigation", "Looting", "Vendors", "Inventory", "Crafting",
|
||||
"Metas", "Character", "Quests", "Chat", "HUD", "Death", "Fellowship", "Pets", "Scripts", "Server", "Settings",
|
||||
};
|
||||
|
||||
/// <summary>The query's words, lower case, without punctuation ("/ra hunt" is "ra", "hunt").</summary>
|
||||
public static List<string> Words(string? text)
|
||||
{
|
||||
var words = new List<string>();
|
||||
if (string.IsNullOrEmpty(text)) return words;
|
||||
var sb = new StringBuilder();
|
||||
foreach (char ch in text)
|
||||
{
|
||||
if (char.IsLetterOrDigit(ch)) sb.Append(char.ToLowerInvariant(ch));
|
||||
else if (ch == '\'' || ch == '’') continue; // "don't" is "dont"
|
||||
else Flush(sb, words);
|
||||
}
|
||||
Flush(sb, words);
|
||||
return words;
|
||||
}
|
||||
|
||||
private static void Flush(StringBuilder sb, List<string> words)
|
||||
{
|
||||
if (sb.Length == 0) return;
|
||||
words.Add(sb.ToString());
|
||||
sb.Clear();
|
||||
}
|
||||
|
||||
/// <summary>Light stemming: a plural s ("vendors"), -ing ("looting"), -ed ("looted"), a doubled last letter after them ("stopped").</summary>
|
||||
public static string Stem(string word)
|
||||
{
|
||||
string w = word;
|
||||
if (w.Length > 5 && w.EndsWith("ing", StringComparison.Ordinal)) w = Undouble(w[..^3]);
|
||||
else if (w.Length > 4 && w.EndsWith("ed", StringComparison.Ordinal)) w = Undouble(w[..^2]);
|
||||
else if (w.Length > 4 && w.EndsWith("ies", StringComparison.Ordinal)) w = w[..^3] + "y";
|
||||
else if (w.Length > 3 && w.EndsWith('s') && !w.EndsWith("ss", StringComparison.Ordinal) && !w.EndsWith("us", StringComparison.Ordinal)) w = w[..^1];
|
||||
return w;
|
||||
}
|
||||
|
||||
/// <summary>"stopp" is "stop"; "kill", "pass" and "buzz" keep their double letter.</summary>
|
||||
private static string Undouble(string w) =>
|
||||
w.Length >= 3 && w[^1] == w[^2] && !IsVowel(w[^1]) && w[^1] is not ('l' or 's' or 'z') ? w[..^1] : w;
|
||||
|
||||
private static bool IsVowel(char c) => c is 'a' or 'e' or 'i' or 'o' or 'u';
|
||||
|
||||
/// <summary>
|
||||
/// How well the typed word <paramref name="q"/> matches the field word <paramref name="w"/>:
|
||||
/// 0 no match, 1 the start of it, 2 the whole word (after stemming).
|
||||
/// </summary>
|
||||
public static int WordMatch(string q, string w)
|
||||
{
|
||||
if (q.Length == 0 || w.Length == 0) return 0;
|
||||
string sq = Stem(q), sw = Stem(w);
|
||||
if (sq == sw || q == w) return 2;
|
||||
if (sw.StartsWith(sq, StringComparison.Ordinal) || w.StartsWith(q, StringComparison.Ordinal)) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>The best match of <paramref name="q"/> against any word of <paramref name="field"/>.</summary>
|
||||
private static int FieldMatch(string q, List<string> field)
|
||||
{
|
||||
int best = 0;
|
||||
foreach (string w in field)
|
||||
{
|
||||
int m = WordMatch(q, w);
|
||||
if (m > best) { best = m; if (best == 2) break; }
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
/// <summary>An entry's words, by field (built per search; the catalog is a few hundred entries).</summary>
|
||||
private sealed class Fields
|
||||
{
|
||||
public readonly List<string> Name, Keywords, Command, Group, Summary, Where, Plugin;
|
||||
|
||||
public Fields(FeatureEntry e)
|
||||
{
|
||||
Name = Words(e.Name);
|
||||
Keywords = new List<string>();
|
||||
foreach (string k in e.Keywords) Keywords.AddRange(Words(k));
|
||||
Command = Words(e.Command);
|
||||
Command.AddRange(Words(e.Open));
|
||||
Group = Words(e.Group);
|
||||
Summary = Words(e.Summary);
|
||||
Where = new List<string>();
|
||||
foreach (string p in e.Where) Where.AddRange(Words(p));
|
||||
Plugin = Words(e.Plugin);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The score of <paramref name="e"/> for <paramref name="words"/>, or 0 when a word matches nowhere.</summary>
|
||||
public static int Score(FeatureEntry e, IReadOnlyList<string> words)
|
||||
{
|
||||
var f = new Fields(e);
|
||||
int total = 0;
|
||||
foreach (string q in words)
|
||||
{
|
||||
int best = 0;
|
||||
best = Math.Max(best, Weigh(FieldMatch(q, f.Name), NameWeight));
|
||||
best = Math.Max(best, Weigh(FieldMatch(q, f.Keywords), KeywordWeight));
|
||||
best = Math.Max(best, Weigh(FieldMatch(q, f.Command), CommandWeight));
|
||||
best = Math.Max(best, Weigh(FieldMatch(q, f.Group), GroupWeight));
|
||||
best = Math.Max(best, Weigh(FieldMatch(q, f.Summary), SummaryWeight));
|
||||
best = Math.Max(best, Weigh(FieldMatch(q, f.Where), WhereWeight));
|
||||
best = Math.Max(best, Weigh(FieldMatch(q, f.Plugin), PluginWeight));
|
||||
if (best == 0) return 0; // every word must match somewhere
|
||||
total += best;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
private static int Weigh(int match, int weight) => match == 0 ? 0 : match == 2 ? weight + WholeWordBonus : weight;
|
||||
|
||||
/// <summary>
|
||||
/// The entries every word of <paramref name="query"/> matches, best first (ties by name). No words:
|
||||
/// every entry in browse order (by group, then name), each with score 0.
|
||||
/// </summary>
|
||||
public static List<FeatureHit> Search(IReadOnlyList<FeatureEntry> all, string? query)
|
||||
{
|
||||
List<string> words = Words(query);
|
||||
var hits = new List<FeatureHit>();
|
||||
if (words.Count == 0)
|
||||
{
|
||||
foreach (FeatureGroup g in Grouped(all))
|
||||
foreach (FeatureEntry e in g.Entries) hits.Add(new FeatureHit(e, 0));
|
||||
return hits;
|
||||
}
|
||||
foreach (FeatureEntry e in all)
|
||||
{
|
||||
int s = Score(e, words);
|
||||
if (s > 0) hits.Add(new FeatureHit(e, s));
|
||||
}
|
||||
hits.Sort((a, b) => a.Score != b.Score ? b.Score.CompareTo(a.Score) : CompareNames(a.Entry, b.Entry));
|
||||
return hits;
|
||||
}
|
||||
|
||||
/// <summary>Every entry by group (the schema's order, then others by name; no group is "Other"), each group by name.</summary>
|
||||
public static List<FeatureGroup> Grouped(IReadOnlyList<FeatureEntry> all)
|
||||
{
|
||||
var byName = new Dictionary<string, FeatureGroup>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (FeatureEntry e in all)
|
||||
{
|
||||
string g = e.Group.Trim().Length > 0 ? e.Group.Trim() : "Other";
|
||||
if (!byName.TryGetValue(g, out FeatureGroup? group)) byName[g] = group = new FeatureGroup(g, new List<FeatureEntry>());
|
||||
group.Entries.Add(e);
|
||||
}
|
||||
var groups = new List<FeatureGroup>(byName.Values);
|
||||
groups.Sort((a, b) =>
|
||||
{
|
||||
int ia = GroupRank(a.Name), ib = GroupRank(b.Name);
|
||||
return ia != ib ? ia.CompareTo(ib) : string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase);
|
||||
});
|
||||
foreach (FeatureGroup g in groups) g.Entries.Sort(CompareNames);
|
||||
return groups;
|
||||
}
|
||||
|
||||
private static int GroupRank(string g)
|
||||
{
|
||||
int i = Array.FindIndex(GroupOrder, x => x.Equals(g, StringComparison.OrdinalIgnoreCase));
|
||||
return i >= 0 ? i : GroupOrder.Length;
|
||||
}
|
||||
|
||||
private static int CompareNames(FeatureEntry a, FeatureEntry b)
|
||||
{
|
||||
int c = string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase);
|
||||
return c != 0 ? c : string.Compare(a.Plugin, b.Plugin, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>"12 features match 'death'", "1 feature matches 'death'", "No feature matches 'xyz'", "40 features".</summary>
|
||||
public static string CountLine(int count, string? query)
|
||||
{
|
||||
string q = (query ?? string.Empty).Trim();
|
||||
if (Words(q).Count == 0) return count == 1 ? "1 feature" : $"{count} features";
|
||||
return count switch
|
||||
{
|
||||
0 => $"No feature matches '{q}'",
|
||||
1 => $"1 feature matches '{q}'",
|
||||
_ => $"{count} features match '{q}'",
|
||||
};
|
||||
}
|
||||
}
|
||||
275
Plugins/RynthCore.Plugin.RynthAi/Features/FeatureSearchWindow.cs
Normal file
275
Plugins/RynthCore.Plugin.RynthAi/Features/FeatureSearchWindow.cs
Normal file
|
|
@ -0,0 +1,275 @@
|
|||
// ============================================================================
|
||||
// RynthAi - Features/FeatureSearchWindow.cs
|
||||
// The Find a Feature window (2026-11-13): a search box (focused when the
|
||||
// window opens), the count line, and the results: each with its name, the
|
||||
// plugin it is in, what it does, where to find it (the button path), its
|
||||
// command (Copy puts it on the clipboard) and Open when the catalog says how
|
||||
// to open it. No words typed: the groups, each a header to fold open.
|
||||
//
|
||||
// RynthCore hosts the window (the sections manifest's "featuresearch" window,
|
||||
// plugin API v89: header, pop-out, resize, remembered place; no bar button)
|
||||
// and calls Draw through RynthPluginRenderEmbed. AC's render thread: the
|
||||
// catalog is read once and never changes; Open goes to the tick as a chat
|
||||
// command. Looks: Shared/RynthUi (the player's theme), as Active Gear.
|
||||
// ============================================================================
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.Plugin.Shared.RynthUi;
|
||||
using RynthCore.PluginSdk;
|
||||
using static RynthCore.Plugin.Shared.RynthUi.RynthUi;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.Features;
|
||||
|
||||
internal sealed class FeatureSearchWindow
|
||||
{
|
||||
private readonly Func<IReadOnlyList<FeatureEntry>> _entries;
|
||||
private readonly Action<string> _run;
|
||||
|
||||
private string _query = string.Empty;
|
||||
private string? _builtFor;
|
||||
private List<FeatureHit> _hits = new();
|
||||
private List<FeatureGroup> _groups = new();
|
||||
private readonly HashSet<string> _openGroups = new(StringComparer.OrdinalIgnoreCase);
|
||||
private bool _focus = true;
|
||||
private bool _scrollTop;
|
||||
private string _copied = string.Empty;
|
||||
private long _copiedAtMs;
|
||||
|
||||
private float _k = 1f;
|
||||
private float Px(float v) => v * _k;
|
||||
|
||||
private const string HelpText =
|
||||
"Type what you are looking for: every word has to match, in any order (\"death hunt\", \"vend\", \"loot rares\").\n\n" +
|
||||
"Each result says where to find it (the buttons to click, from the RynthCore bar, the RynthAi window's ⋯ menu " +
|
||||
"or a window's title), its chat command, and Open when it can open the place for you.\n\n" +
|
||||
"Clear the box to browse everything by group.\n\n" +
|
||||
"/ra find <words> opens this window with the words in the box.";
|
||||
|
||||
/// <param name="entries">The catalog (read once).</param>
|
||||
/// <param name="run">Runs an Open command (a chat command, on the tick).</param>
|
||||
public FeatureSearchWindow(Func<IReadOnlyList<FeatureEntry>> entries, Action<string> run)
|
||||
{
|
||||
_entries = entries;
|
||||
_run = run;
|
||||
}
|
||||
|
||||
/// <summary>The words in the box (/ra find's words); the box gets the keyboard on the next draw.</summary>
|
||||
public void SetQuery(string query)
|
||||
{
|
||||
_query = query ?? string.Empty;
|
||||
_focus = true;
|
||||
_scrollTop = true;
|
||||
}
|
||||
|
||||
/// <summary>The window was off screen and is back: the box gets the keyboard.</summary>
|
||||
public void Reopened() => _focus = true;
|
||||
|
||||
/// <summary>Draws the window body into the current ImGui window and returns the size it would like. Render thread.</summary>
|
||||
public Vector2 Draw()
|
||||
{
|
||||
_k = Math.Max(0.5f, Font(RynthUiFont.Ui11).FontSize / 11f);
|
||||
Vector2 origin = ImGui.GetCursorScreenPos();
|
||||
Vector2 size = ImGui.GetContentRegionAvail();
|
||||
var want = new Vector2(Px(560), Px(460));
|
||||
if (size.X < 60 || size.Y < 40) return want;
|
||||
ImDrawListPtr frame = ImGui.GetWindowDrawList();
|
||||
frame.AddRectFilled(origin, origin + size, Background, 4);
|
||||
using (PushFont(RynthUiFont.Ui11))
|
||||
{
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(4, 4));
|
||||
ImGui.SetCursorScreenPos(origin + new Vector2(6, 6));
|
||||
ImGui.Indent(6);
|
||||
float w = size.X - 12;
|
||||
DrawTop(w);
|
||||
Build();
|
||||
ImGui.PushTextWrapPos(ImGui.GetCursorScreenPos().X + w);
|
||||
Label(FeatureSearch.CountLine(Words() ? _hits.Count : _entries().Count, _query) + ".", Mute);
|
||||
ImGui.PopTextWrapPos();
|
||||
|
||||
// The host's resize grip sits over the bottom-right corner: the rows end above it.
|
||||
float bodyH = Math.Max(Px(30), origin.Y + size.Y - 6 - ImGui.GetCursorScreenPos().Y - Px(10));
|
||||
ImGui.PushStyleColor(ImGuiCol.ChildBg, Field);
|
||||
ImGui.BeginChild("##fs_rows", new Vector2(w, bodyH));
|
||||
if (_scrollTop) { ImGui.SetScrollY(0); _scrollTop = false; }
|
||||
ImGui.Indent(Px(6));
|
||||
ImGui.Dummy(new Vector2(0, Px(2)));
|
||||
if (_entries().Count == 0) Label("The feature list didn't load (the RynthCore log says why).", Highlight);
|
||||
else if (Words()) DrawHits();
|
||||
else DrawGroups();
|
||||
ImGui.Unindent(Px(6));
|
||||
ImGui.EndChild();
|
||||
ImGui.PopStyleColor();
|
||||
|
||||
ImGui.Unindent(6);
|
||||
ImGui.PopStyleVar();
|
||||
}
|
||||
frame.AddRect(origin, origin + size, Border, 4);
|
||||
return want;
|
||||
}
|
||||
|
||||
private bool Words() => FeatureSearch.Words(_query).Count > 0;
|
||||
|
||||
// ── Top: the box, Clear, help ───────────────────────────────────────
|
||||
|
||||
private void DrawTop(float w)
|
||||
{
|
||||
Vector2 start = ImGui.GetCursorScreenPos();
|
||||
float h = Px(22), iconW = Px(22);
|
||||
float clearW = ButtonWidth("Clear");
|
||||
float boxW = Math.Max(Px(60), w - clearW - iconW - Px(8));
|
||||
ImGui.SetNextItemWidth(boxW);
|
||||
ImGui.PushStyleColor(ImGuiCol.FrameBg, Field);
|
||||
if (_focus)
|
||||
{
|
||||
ImGui.SetKeyboardFocusHere();
|
||||
_focus = false;
|
||||
}
|
||||
if (ImGui.InputTextWithHint("##fs_query", "Find a feature: type a word (death, vendor, buffs, loot...)", ref _query, 96u))
|
||||
_scrollTop = true;
|
||||
ImGui.PopStyleColor();
|
||||
float x = start.X + boxW + Px(4);
|
||||
if (Button("##fs_clear", "Clear", new Vector2(x, start.Y), new Vector2(clearW, h), Text, ButtonFill, enabled: _query.Length > 0))
|
||||
{
|
||||
_query = string.Empty;
|
||||
_focus = true;
|
||||
_scrollTop = true;
|
||||
}
|
||||
ImGui.SetItemTooltip("Clear the box: every feature, by group.");
|
||||
x += clearW + Px(4);
|
||||
IconButton("##fs_help", RynthIcons.Info, new Vector2(x, start.Y), new Vector2(iconW, h), Mute, ButtonFill, font: RynthUiFont.Ui11);
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.BeginTooltip();
|
||||
ImGui.PushTextWrapPos(ImGui.GetFontSize() * 32);
|
||||
ImGui.TextUnformatted(HelpText);
|
||||
ImGui.PopTextWrapPos();
|
||||
ImGui.EndTooltip();
|
||||
}
|
||||
ImGui.SetCursorScreenPos(new Vector2(start.X, start.Y + h + Px(4)));
|
||||
ImGui.Dummy(Vector2.Zero);
|
||||
}
|
||||
|
||||
private void Build()
|
||||
{
|
||||
if (_builtFor == _query) return;
|
||||
_builtFor = _query;
|
||||
IReadOnlyList<FeatureEntry> all = _entries();
|
||||
_hits = FeatureSearch.Search(all, _query);
|
||||
if (_groups.Count == 0 && all.Count > 0) _groups = FeatureSearch.Grouped(all);
|
||||
}
|
||||
|
||||
// ── Results ─────────────────────────────────────────────────────────
|
||||
|
||||
private void DrawHits()
|
||||
{
|
||||
if (_hits.Count == 0)
|
||||
{
|
||||
ImGui.PushTextWrapPos(0);
|
||||
Label("Nothing matches every word. Try fewer words, or the start of one (\"vend\" finds Vendors).", Mute);
|
||||
ImGui.PopTextWrapPos();
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < _hits.Count; i++) DrawEntry(_hits[i].Entry, i);
|
||||
}
|
||||
|
||||
private void DrawGroups()
|
||||
{
|
||||
int n = 0;
|
||||
foreach (FeatureGroup g in _groups)
|
||||
{
|
||||
ImGui.PushID("g_" + g.Name);
|
||||
bool open = _openGroups.Contains(g.Name);
|
||||
Vector2 p = ImGui.GetCursorScreenPos();
|
||||
float w = Math.Max(1, ImGui.GetContentRegionAvail().X - Px(4));
|
||||
float h = Px(22);
|
||||
bool clicked = ImGui.InvisibleButton("##hdr", new Vector2(w, h));
|
||||
bool hot = ImGui.IsItemHovered();
|
||||
if (clicked)
|
||||
{
|
||||
if (open) _openGroups.Remove(g.Name); else _openGroups.Add(g.Name);
|
||||
open = !open;
|
||||
}
|
||||
SafeImGui.SetItemTooltip(open ? "Click to fold " + g.Name + " away." : "Click for the " + g.Name + " features.");
|
||||
ImDrawListPtr dl = ImGui.GetWindowDrawList();
|
||||
dl.AddRectFilled(p, p + new Vector2(w, h), hot ? Selected : ButtonFill, 3);
|
||||
DrawCentered(dl, Font(RynthUiFont.Ui11), open ? RynthIcons.CaretDown : RynthIcons.CaretRight,
|
||||
new Vector2(p.X + Px(2), p.Y), new Vector2(Px(16), h), Mute);
|
||||
ImFontPtr bold = Font(RynthUiFont.UiBold11);
|
||||
dl.AddText(bold, bold.FontSize, new Vector2(p.X + Px(20), p.Y + (h - bold.FontSize) * 0.5f), Text, g.Name);
|
||||
string count = g.Entries.Count.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
float cw = ImGui.CalcTextSize(count).X;
|
||||
dl.AddText(new Vector2(p.X + w - cw - Px(8), p.Y + (h - ImGui.GetFontSize()) * 0.5f), Mute, count);
|
||||
if (open)
|
||||
{
|
||||
ImGui.Dummy(new Vector2(0, Px(2)));
|
||||
foreach (FeatureEntry e in g.Entries) DrawEntry(e, n++);
|
||||
}
|
||||
ImGui.PopID();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>One feature: name and plugin tag, Copy and Open; what it does; where; the command.</summary>
|
||||
private void DrawEntry(FeatureEntry e, int index)
|
||||
{
|
||||
ImGui.PushID(index);
|
||||
ImGui.PushID(e.Id);
|
||||
float w = Math.Max(Px(120), ImGui.GetContentRegionAvail().X - Px(4));
|
||||
Vector2 p = ImGui.GetCursorScreenPos();
|
||||
ImDrawListPtr dl = ImGui.GetWindowDrawList();
|
||||
float lineH = Px(22);
|
||||
|
||||
// The buttons on the name's line, at the right: Copy (the command), Open.
|
||||
bool hasOpen = e.Open.Length > 0, hasCommand = e.Command.Length > 0;
|
||||
float openW = hasOpen ? ButtonWidth("Open") : 0, copyW = hasCommand ? ButtonWidth("Copy") : 0;
|
||||
float bx = p.X + w;
|
||||
if (hasOpen)
|
||||
{
|
||||
bx -= openW;
|
||||
if (Button("##fs_open", "Open", new Vector2(bx, p.Y), new Vector2(openW, lineH), Text, AccentFill))
|
||||
_run(e.Open);
|
||||
SafeImGui.SetItemTooltip("Opens it: runs " + e.Open);
|
||||
bx -= Px(4);
|
||||
}
|
||||
if (hasCommand)
|
||||
{
|
||||
bx -= copyW;
|
||||
if (Button("##fs_copy", "Copy", new Vector2(bx, p.Y), new Vector2(copyW, lineH), Text, ButtonFill))
|
||||
{
|
||||
ImGui.SetClipboardText(e.Command);
|
||||
_copied = e.Id;
|
||||
_copiedAtMs = Environment.TickCount64;
|
||||
}
|
||||
bool justCopied = _copied == e.Id && Environment.TickCount64 - _copiedAtMs < 2500;
|
||||
SafeImGui.SetItemTooltip(justCopied ? "Copied: paste it in chat (Ctrl+V)." : "Copy the command: " + e.Command);
|
||||
bx -= Px(4);
|
||||
}
|
||||
|
||||
// Name (bold) and the plugin's tag, clipped short of the buttons.
|
||||
ImFontPtr bold = Font(RynthUiFont.UiBold11);
|
||||
float ty = p.Y + (lineH - bold.FontSize) * 0.5f;
|
||||
float textRight = bx - Px(4);
|
||||
dl.PushClipRect(p, new Vector2(Math.Max(p.X + 1, textRight), p.Y + lineH), true);
|
||||
dl.AddText(bold, bold.FontSize, new Vector2(p.X, ty), Accent, e.Name);
|
||||
float nameW = bold.CalcTextSizeA(bold.FontSize, float.MaxValue, 0f, e.Name).X;
|
||||
if (e.Plugin.Length > 0)
|
||||
Badge(dl, new Vector2(p.X + nameW + Px(8), p.Y + (lineH - Px(14)) * 0.5f), Px(14), e.Plugin, RowAlt, Mute);
|
||||
dl.PopClipRect();
|
||||
ImGui.SetCursorScreenPos(new Vector2(p.X, p.Y + lineH + Px(1)));
|
||||
|
||||
ImGui.PushTextWrapPos(p.X + w);
|
||||
if (e.Summary.Length > 0) Label(e.Summary, Text);
|
||||
foreach (string where in e.Where) Label("Where: " + where, Mute);
|
||||
if (hasCommand) Label("Command: " + e.Command, Highlight);
|
||||
ImGui.PopTextWrapPos();
|
||||
|
||||
ImGui.Dummy(new Vector2(0, Px(2)));
|
||||
Vector2 q = ImGui.GetCursorScreenPos();
|
||||
dl.AddLine(new Vector2(p.X, q.Y), new Vector2(p.X + w, q.Y), Border);
|
||||
ImGui.Dummy(new Vector2(0, Px(4)));
|
||||
ImGui.PopID();
|
||||
ImGui.PopID();
|
||||
}
|
||||
}
|
||||
|
|
@ -98,21 +98,28 @@ internal static class SectionsManifest
|
|||
/// </summary>
|
||||
public const string ActiveGearTitle = RynthAiPlugin.ActiveGearTitle, ActiveGearSurface = RynthAiPlugin.ActiveGearSurface;
|
||||
|
||||
/// <summary>
|
||||
/// The Find a Feature window (RynthAiPlugin.FeatureSearch.cs, 2026-11-13): searches the feature catalog
|
||||
/// (Docs/features/*.json), drawn by RynthAi in the engine's frame (plugin API v89). No bar button (the
|
||||
/// bar is full): the dashboard's options menu (Find a feature) and /ra find open it.
|
||||
/// </summary>
|
||||
public const string FeatureSearchTitle = RynthAiPlugin.FeatureSearchTitle, FeatureSearchSurface = RynthAiPlugin.FeatureSearchSurface;
|
||||
|
||||
/// <summary>
|
||||
/// The manifest JSON for <paramref name="views"/> (UTF-8 text, schema version 1), with the dashboard
|
||||
/// window when <paramref name="dashboard"/>, the Monster Stats window when <paramref name="monsterStats"/>,
|
||||
/// the Timed Commands window when <paramref name="timedCommands"/> and the Active Gear window when
|
||||
/// <paramref name="activeGear"/>.
|
||||
/// the Timed Commands window when <paramref name="timedCommands"/>, the Active Gear window when
|
||||
/// <paramref name="activeGear"/> and the Find a Feature window when <paramref name="featureSearch"/>.
|
||||
/// </summary>
|
||||
public static string Build(IReadOnlyList<View> views, IReadOnlyList<Section> sections, bool dashboard = false, bool monsterStats = false,
|
||||
bool timedCommands = false, bool activeGear = false)
|
||||
bool timedCommands = false, bool activeGear = false, bool featureSearch = false)
|
||||
{
|
||||
using var stream = new MemoryStream(4096);
|
||||
using (var w = new Utf8JsonWriter(stream))
|
||||
{
|
||||
w.WriteStartObject();
|
||||
w.WriteNumber("version", 1);
|
||||
bool windows = dashboard || monsterStats || timedCommands || activeGear;
|
||||
bool windows = dashboard || monsterStats || timedCommands || activeGear || featureSearch;
|
||||
if (windows)
|
||||
w.WriteStartArray("windows");
|
||||
if (dashboard)
|
||||
|
|
@ -178,6 +185,21 @@ internal static class SectionsManifest
|
|||
w.WriteBoolean("edgeToEdge", true);
|
||||
w.WriteEndObject();
|
||||
}
|
||||
if (featureSearch)
|
||||
{
|
||||
w.WriteStartObject();
|
||||
w.WriteString("id", "featuresearch");
|
||||
w.WriteString("title", FeatureSearchTitle);
|
||||
w.WriteString("surface", FeatureSearchSurface);
|
||||
w.WriteString("icon", RynthCore.Plugin.Shared.RynthUi.RynthIcons.MagnifyingGlass);
|
||||
w.WriteNumber("width", 560);
|
||||
w.WriteNumber("height", 460);
|
||||
w.WriteNumber("minWidth", 360);
|
||||
w.WriteNumber("minHeight", 200);
|
||||
w.WriteBoolean("bar", false);
|
||||
w.WriteBoolean("edgeToEdge", true);
|
||||
w.WriteEndObject();
|
||||
}
|
||||
if (windows)
|
||||
w.WriteEndArray();
|
||||
w.WriteStartArray("sections");
|
||||
|
|
|
|||
|
|
@ -368,6 +368,9 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
_settings.PatrolOnLogin = false;
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(LoginAutoStart.HuntOnLoginTip);
|
||||
ImGui.Checkbox("Keep Hunting After Death", ref _settings.KeepHuntingAfterDeath);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(AfterDeath.Tip);
|
||||
ImGui.Checkbox("Resume Meta After Reload", ref _settings.ResumeMetaOnReload);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("After a hot reload the meta carries on in the same state, with its variables,\nfired rules and route. A real login still starts in Default.");
|
||||
|
|
@ -806,6 +809,9 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
ImGui.Checkbox("Fight the monster I select", ref _settings.FightSelectedTarget);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(LegacyUiSettings.FightSelectedTargetTip);
|
||||
ImGui.Checkbox("Melee through walls", ref _settings.MeleeThroughWalls);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(LegacyUiSettings.MeleeThroughWallsTip);
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Text("Corpse Acquisition (Yards)");
|
||||
|
|
|
|||
|
|
@ -1387,6 +1387,7 @@ internal sealed partial class LegacyDashboardRenderer
|
|||
TargetSelection = s.TargetSelection,
|
||||
TargetLock = s.TargetLock,
|
||||
FightSelectedTarget = s.FightSelectedTarget,
|
||||
MeleeThroughWalls = s.MeleeThroughWalls,
|
||||
RingRange = s.RingRange,
|
||||
ApproachRange = s.ApproachRange,
|
||||
CorpseApproachRangeMax = s.CorpseApproachRangeMax,
|
||||
|
|
@ -1679,6 +1680,7 @@ internal sealed partial class LegacyDashboardRenderer
|
|||
if (p.TargetSelection is int targeting) s.TargetSelection = Math.Clamp(targeting, 0, 3); // absent = unchanged
|
||||
if (p.TargetLock is bool targetLock) s.TargetLock = targetLock; // absent = unchanged
|
||||
if (p.FightSelectedTarget is bool fightSel) s.FightSelectedTarget = fightSel; // absent = unchanged
|
||||
if (p.MeleeThroughWalls is bool meleeWalls) s.MeleeThroughWalls = meleeWalls; // absent = unchanged
|
||||
s.RingRange = p.RingRange;
|
||||
s.ApproachRange = p.ApproachRange;
|
||||
s.CorpseApproachRangeMax = p.CorpseApproachRangeMax;
|
||||
|
|
@ -2205,6 +2207,7 @@ internal sealed partial class LegacyDashboardRenderer
|
|||
dst.TargetSelection = Math.Clamp(tmp.TargetSelection, 0, 3);
|
||||
dst.TargetLock = tmp.TargetLock;
|
||||
dst.FightSelectedTarget = tmp.FightSelectedTarget;
|
||||
dst.MeleeThroughWalls = tmp.MeleeThroughWalls;
|
||||
dst.RingRange = tmp.RingRange;
|
||||
dst.HandlerRingEvade = tmp.HandlerRingEvade; // obsolete (RynthILT's now): carried so the profile keeps it for RynthILT's one-time import
|
||||
dst.ApproachRange = tmp.ApproachRange;
|
||||
|
|
@ -2373,6 +2376,7 @@ internal sealed partial class LegacyDashboardRenderer
|
|||
dst.StartMacroOnLogin = tmp.StartMacroOnLogin;
|
||||
dst.PatrolOnLogin = tmp.PatrolOnLogin;
|
||||
dst.HuntOnLogin = tmp.HuntOnLogin;
|
||||
dst.KeepHuntingAfterDeath = tmp.KeepHuntingAfterDeath;
|
||||
dst.ResumeMetaOnReload = tmp.ResumeMetaOnReload;
|
||||
dst.YieldToVTank = tmp.YieldToVTank;
|
||||
dst.FeatureServerNames = tmp.FeatureServerNames;
|
||||
|
|
|
|||
|
|
@ -335,6 +335,19 @@ public sealed class LegacyUiSettings
|
|||
"another monster or deselect. The bot's own selections never count. Ignored (Priority 0) and\n" +
|
||||
"never-attack monsters are not followed (/ra targetlock still forces them). Out to Disengage Range.\n" +
|
||||
"/ra fightselected [on|off]";
|
||||
// Melee through walls (2026-11-15, on by default, the meta option meleethroughwalls): melee within
|
||||
// 4 m (CombatManager.MeleeIgnoresLosWithin) ignores a blocked line of sight, except across a
|
||||
// building's wall (one side in its rooms, the other outside). Off: a blocked monster is never a
|
||||
// melee target for being close; it is treated like a blocked monster farther off (out of sight,
|
||||
// left to the hunt). A profile saved before this setting loads it as on.
|
||||
public bool MeleeThroughWalls = true;
|
||||
internal const string MeleeThroughWallsTip =
|
||||
"On: melee reaches a monster within 4 m even when the line of sight test says a wall is in the way\n" +
|
||||
"(a corner, a pillar, a thin dungeon wall: melee lands where the test is too strict). Not across a\n" +
|
||||
"building's wall: one of you inside its rooms and the other outside is left to the hunt, which walks\n" +
|
||||
"in through a door.\n" +
|
||||
"Off: a monster behind a wall is never a melee target for being close; it is treated like any monster\n" +
|
||||
"out of sight. On by default. /ra meleewalls [on|off]";
|
||||
public int RingRange = 5;
|
||||
// Obsolete since 2026-10-20 (unused here, kept so profiles still load and carry it): the Empyrean
|
||||
// Handler lethal-ring evade is Infinite Leaftide's and lives in RynthILT now (its ILT settings,
|
||||
|
|
@ -547,6 +560,13 @@ public sealed class LegacyUiSettings
|
|||
/// </summary>
|
||||
public bool HuntOnLogin;
|
||||
/// <summary>
|
||||
/// Keep Hunting After Death (2026-11-13, RynthAiPlugin.AfterDeath.cs): a death pauses the Outdoor Hunt
|
||||
/// instead of ending it, and it starts again once the character is back up (after Recall On Death and
|
||||
/// Travel Back To My Corpse); the Dungeon Patrol also follows into a dungeon a death sent it to. Off by
|
||||
/// default (a death ended the hunt before it).
|
||||
/// </summary>
|
||||
public bool KeepHuntingAfterDeath;
|
||||
/// <summary>
|
||||
/// Resume Meta After Reload (2026-11-07, Tom: "remembers which meta state you're in and restarts in
|
||||
/// that state so Drakkon doesn't recall back every time"). A hot reload carries the meta's whole
|
||||
/// runtime over (Meta/MetaResume.cs): state, variables, fired rules, call stack, watchdog, route.
|
||||
|
|
@ -1449,6 +1469,7 @@ public sealed class SettingsBridgePayload
|
|||
public int? TargetSelection { get; set; }
|
||||
public bool? TargetLock { get; set; }
|
||||
public bool? FightSelectedTarget { get; set; }
|
||||
public bool? MeleeThroughWalls { get; set; } // Melee through walls; absent (an engine without the row) = unchanged
|
||||
public int RingRange { get; set; }
|
||||
public int ApproachRange { get; set; }
|
||||
public double CorpseApproachRangeMax { get; set; }
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ namespace RynthCore.Plugin.RynthAi;
|
|||
[JsonSerializable(typeof(RynthCore.Plugin.RynthAi.MiniRemote.MiniRemoteState))]
|
||||
[JsonSerializable(typeof(RynthCore.Plugin.RynthAi.MiniRemote.LegacyHubFile))]
|
||||
[JsonSerializable(typeof(RynthCore.Plugin.RynthAi.BuffProfile))]
|
||||
// The feature catalog (Docs/features/*.json, embedded): Find a Feature (Features/FeatureCatalog.cs).
|
||||
[JsonSerializable(typeof(RynthCore.Plugin.RynthAi.Features.FeatureFile))]
|
||||
[JsonSourceGenerationOptions(
|
||||
WriteIndented = true,
|
||||
IncludeFields = true,
|
||||
|
|
|
|||
|
|
@ -252,6 +252,7 @@ public sealed partial class RynthAiPlugin
|
|||
["lootpriorityboost"] = "BoostLootPriority",
|
||||
["pickupmacrooff"] = "LootChestsMacroOff", // Settings > Looting > Pickup with macro off
|
||||
["lootchestsmacrooff"] = "LootChestsMacroOff",
|
||||
["meleethroughwalls"] = "MeleeThroughWalls", // Settings > Combat > Targeting > Melee through walls
|
||||
["dooropenrange"] = "OpenDoorRange",
|
||||
["autofellowmanagement"] = "AutoFellowMgmt",
|
||||
["switchwandstodebuff"] = "UseDispelItems",
|
||||
|
|
|
|||
|
|
@ -3664,6 +3664,7 @@ internal sealed partial class ExpressionEngine
|
|||
["LootOwnCorpse"] = (() => B(s.LootOwnCorpse), v => s.LootOwnCorpse = ToDouble(v) != 0),
|
||||
["EscapeHazards"] = (() => B(s.EscapeHazards), v => s.EscapeHazards = ToDouble(v) != 0),
|
||||
["TravelToOwnCorpse"] = (() => B(s.TravelToOwnCorpse), v => s.TravelToOwnCorpse = ToDouble(v) != 0),
|
||||
["KeepHuntingAfterDeath"] = (() => B(s.KeepHuntingAfterDeath), v => s.KeepHuntingAfterDeath = ToDouble(v) != 0),
|
||||
["ItemInfoOnSelect"] = (() => B(s.ItemInfoSettings.OnSelect), v => s.ItemInfoSettings.OnSelect = ToDouble(v) != 0),
|
||||
// The looter's "Looted" line names the rule and the item's details (salvage: on request).
|
||||
["ItemInfoLootChat"] = (() => B(s.ItemInfoSettings.LootChat), v => s.ItemInfoSettings.LootChat = ToDouble(v) != 0),
|
||||
|
|
@ -3711,6 +3712,7 @@ internal sealed partial class ExpressionEngine
|
|||
["TargetSelection"] = (() => I(s.TargetSelection), v => { if (int.TryParse(v, out int i)) s.TargetSelection = Math.Clamp(i, 0, 3); }),
|
||||
["TargetLock"] = (() => B(s.TargetLock), v => s.TargetLock = ToDouble(v) != 0),
|
||||
["FightSelectedTarget"] = (() => B(s.FightSelectedTarget), v => s.FightSelectedTarget = ToDouble(v) != 0),
|
||||
["MeleeThroughWalls"] = (() => B(s.MeleeThroughWalls), v => s.MeleeThroughWalls = ToDouble(v) != 0),
|
||||
["RingRange"] = (() => I(s.RingRange), v => { if (int.TryParse(v, out int i)) s.RingRange = i; }),
|
||||
["ApproachRange"] = (() => I(s.ApproachRange), v => { if (int.TryParse(v, out int i)) s.ApproachRange = i; }),
|
||||
["MinRingTargets"] = (() => I(s.MinRingTargets), v => { if (int.TryParse(v, out int i)) s.MinRingTargets = i; }),
|
||||
|
|
|
|||
|
|
@ -1598,6 +1598,7 @@ internal sealed partial class MetaManager
|
|||
["lootpriorityboost"] = "BoostLootPriority",
|
||||
["pickupmacrooff"] = "LootChestsMacroOff", // Settings > Looting > Pickup with macro off
|
||||
["lootchestsmacrooff"] = "LootChestsMacroOff",
|
||||
["meleethroughwalls"] = "MeleeThroughWalls", // Settings > Combat > Targeting > Melee through walls
|
||||
["dooropenrange"] = "OpenDoorRange",
|
||||
["autofellowmanagement"] = "AutoFellowMgmt",
|
||||
["switchwandstodebuff"] = "UseDispelItems",
|
||||
|
|
|
|||
|
|
@ -184,6 +184,12 @@ public static unsafe class PluginExports
|
|||
int drawn = plugin.RenderActiveGear(popped, out want);
|
||||
if (drawn != 1) return drawn;
|
||||
}
|
||||
else if (name.SequenceEqual("window:featuresearch"u8))
|
||||
{
|
||||
// The Find a Feature window (RynthAiPlugin.FeatureSearch.cs): 1 drawn, 0 not ready, -2 failed.
|
||||
int drawn = plugin.RenderFeatureSearch(popped, out want);
|
||||
if (drawn != 1) return drawn;
|
||||
}
|
||||
else if (name.StartsWith("section:"u8))
|
||||
{
|
||||
// Section names are short ASCII ids (Huds/SectionsManifest.cs); anything longer isn't ours.
|
||||
|
|
|
|||
|
|
@ -68,10 +68,12 @@ public sealed partial class RynthAiPlugin
|
|||
ChatLine("[RynthAi] === Commands ===");
|
||||
ChatLine("[RynthAi] /ra fellow — fellowship diagnostics and queries");
|
||||
ChatLine("[RynthAi] /ra help — show this list");
|
||||
ChatLine("[RynthAi] /ra find [words] — Find a Feature: search every RynthSuite feature, where it is and its command");
|
||||
ChatLine("[RynthAi] /ra version — RynthAi version and build date, and the engine it runs on");
|
||||
ChatLine("[RynthAi] /ra server - which server RynthCore says this is, its overrides, and the server plugin's settings");
|
||||
ChatLine("[RynthAi] /ra power <0-100|auto> — set attack power (auto = recklessness-aware)");
|
||||
ChatLine("[RynthAi] /ra dfheight [on|off|status|window] — Dirty Fighting rotation: attack heights by the effects on the target");
|
||||
ChatLine("[RynthAi] /ra meleewalls [on|off] — Melee through walls: melee reaches a monster within 4 m behind a wall (not a building's)");
|
||||
ChatLine("[RynthAi] /ra cast <spellId> — cast spell on current target");
|
||||
ChatLine("[RynthAi] /ra buffs — show active buff timers");
|
||||
ChatLine("[RynthAi] /ra buffitems [list|allow|block|add|addselected|remove|repeat|open] — the buff items RynthAi may use");
|
||||
|
|
@ -3779,12 +3781,14 @@ public sealed partial class RynthAiPlugin
|
|||
/// those say how to patrol here instead.
|
||||
/// </summary>
|
||||
internal static PatrolFollow DecidePatrolFollow(uint patrolLb, uint playerCell, bool isDungeonLandblock,
|
||||
bool portaling, uint triedLb, long msSinceDeath, bool arrivedWhileRunning)
|
||||
bool portaling, uint triedLb, long msSinceDeath, bool arrivedWhileRunning,
|
||||
bool followAfterDeath = false)
|
||||
{
|
||||
uint lb = playerCell >> 16;
|
||||
if (playerCell == 0 || lb == patrolLb || (playerCell & 0xFFFF) < 0x0100) return PatrolFollow.None;
|
||||
if (portaling || !isDungeonLandblock || lb == triedLb) return PatrolFollow.None;
|
||||
if (msSinceDeath >= 0 && msSinceDeath < PatrolFollowDeathMs) return PatrolFollow.AfterDeath;
|
||||
// Keep Hunting After Death: the patrol is the mode through a death too (RynthAiPlugin.AfterDeath.cs).
|
||||
if (msSinceDeath >= 0 && msSinceDeath < PatrolFollowDeathMs && !followAfterDeath) return PatrolFollow.AfterDeath;
|
||||
return arrivedWhileRunning ? PatrolFollow.Follow : PatrolFollow.CameWhileStopped;
|
||||
}
|
||||
|
||||
|
|
@ -3805,7 +3809,8 @@ public sealed partial class RynthAiPlugin
|
|||
bool portaling = (Host.HasIsPortaling && Host.IsPortaling()) || _deathHolding;
|
||||
long sinceDeath = _lastDeathAt == 0 ? -1 : Environment.TickCount64 - _lastDeathAt;
|
||||
var what = DecidePatrolFollow(_dunPatrolLandblock, cell, _navPlanner.IsDungeonLandblock(lb, cellDat), portaling,
|
||||
_dunPatrolFollowTriedLb, sinceDeath, _dunPatrolArrivedRunning);
|
||||
_dunPatrolFollowTriedLb, sinceDeath, _dunPatrolArrivedRunning,
|
||||
followAfterDeath: settings.KeepHuntingAfterDeath);
|
||||
if (what == PatrolFollow.None) return false;
|
||||
|
||||
uint was = _dunPatrolLandblock;
|
||||
|
|
@ -3820,6 +3825,8 @@ public sealed partial class RynthAiPlugin
|
|||
}
|
||||
|
||||
Host.Log($"[RynthAi] DunNav-Patrol: the character went from dungeon 0x{was:X4} into 0x{lb:X4} - building the patrol here.");
|
||||
if (sinceDeath >= 0 && sinceDeath < PatrolFollowDeathMs)
|
||||
ChatLine($"[RynthAi] Dungeon Patrol: in dungeon 0x{lb:X4} after the death; patrolling here (Keep Hunting After Death).");
|
||||
BuildDunPatrol(isRebuild: true, followedIn: true);
|
||||
if (!_dunPatrolActive || _dunPatrolLandblock != lb)
|
||||
ChatLine($"[RynthAi] Dungeon Patrol: couldn't lay a patrol in dungeon 0x{lb:X4} from here. Press Patrol to try again.");
|
||||
|
|
|
|||
127
Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.AfterDeath.cs
Normal file
127
Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.AfterDeath.cs
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
// RynthAiPlugin.AfterDeath.cs - Keep Hunting After Death (2026-11-13).
|
||||
//
|
||||
// Players asked for the hunt to stay on after a death, and the same for the patrol. Off by default:
|
||||
// a death still ends the Outdoor Hunt (from the lifestone it would hunt round the lifestone). With
|
||||
// Keep Hunting After Death on and the macro still running (Stop Macro On Death off):
|
||||
// - the Outdoor Hunt is paused at the death and starts again once the character is back up and
|
||||
// the death's own steps are done (the settle after the respawn, Recall On Death, Travel Back To
|
||||
// My Corpse), from where the character stands then (its Hunt Radius is round that spot);
|
||||
// - the Dungeon Patrol, which already carries on when the character gets back into its dungeon,
|
||||
// also follows it into another dungeon a death sent it to (DecidePatrolFollow).
|
||||
// A route loaded meanwhile (a meta's death handling), the macro stopped, or the box turned off: the
|
||||
// hunt stays off and says why. Tick thread.
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi;
|
||||
|
||||
/// <summary>The decision half of the hunt's restart after a death (pure, for the tests).</summary>
|
||||
internal static class AfterDeath
|
||||
{
|
||||
internal enum HuntStep
|
||||
{
|
||||
/// <summary>Not yet: the death's steps aren't done, or the character is in portal space.</summary>
|
||||
Wait,
|
||||
/// <summary>Start the hunt again from here.</summary>
|
||||
Start,
|
||||
/// <summary>The box was turned off: forget it quietly.</summary>
|
||||
DropOff,
|
||||
/// <summary>The macro was stopped: forget it and say so.</summary>
|
||||
DropMacro,
|
||||
/// <summary>Another route was loaded meanwhile (a meta's death handling): forget it and say so.</summary>
|
||||
DropRoute,
|
||||
}
|
||||
|
||||
internal const string Tip =
|
||||
"After a death, the Outdoor Hunt starts again once you're back up: after Recall On Death and\n" +
|
||||
"Travel Back To My Corpse when they're on, from where you are then (Hunt Radius is round that spot).\n" +
|
||||
"The Dungeon Patrol carries on in its dungeon, and also in a dungeon a recall takes you to after the death.\n" +
|
||||
"Needs the macro to keep running (Stop Macro On Death off). A route a meta loads after the death wins.";
|
||||
|
||||
internal static HuntStep DecideHunt(bool keepOn, bool macroRunning, bool routeReplaced, bool deathStepsBusy, bool portaling)
|
||||
{
|
||||
if (!keepOn) return HuntStep.DropOff;
|
||||
if (!macroRunning) return HuntStep.DropMacro;
|
||||
if (routeReplaced) return HuntStep.DropRoute;
|
||||
if (deathStepsBusy || portaling) return HuntStep.Wait;
|
||||
return HuntStep.Start;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed partial class RynthAiPlugin
|
||||
{
|
||||
private bool _huntAfterDeath; // the hunt was on at a death, to start again once back up
|
||||
private NavRouteParser? _huntAfterDeathRoute; // the empty route the paused hunt left (another one = a meta took over)
|
||||
|
||||
internal const string KeepHuntingUsage = "/ra hunt death [on|off]";
|
||||
|
||||
/// <summary>The death edge (HoldForDeath): the hunt ends, or with Keep Hunting After Death pauses until the character is back up.</summary>
|
||||
private void PauseHuntForDeath()
|
||||
{
|
||||
var s = _dashboard?.Settings;
|
||||
bool keep = (_hunt.Active || _huntAfterDeath) && s is { KeepHuntingAfterDeath: true, IsMacroRunning: true };
|
||||
if (_hunt.Active)
|
||||
StopHunt(keep ? "died; it starts again once you're back up (Keep Hunting After Death)" : "died", say: true);
|
||||
_huntAfterDeath = keep;
|
||||
_huntAfterDeathRoute = keep ? s!.CurrentRoute : null;
|
||||
}
|
||||
|
||||
/// <summary>Each tick the hunt is off (TickOutdoorHunt): the paused hunt starts again when the death's steps are done.</summary>
|
||||
private void TickHuntAfterDeath()
|
||||
{
|
||||
if (!_huntAfterDeath) return;
|
||||
var s = _dashboard?.Settings;
|
||||
if (s == null) return;
|
||||
bool replaced = !ReferenceEquals(s.CurrentRoute, _huntAfterDeathRoute) || s.CurrentNavPath.Length > 0;
|
||||
bool busy = _deathHolding || _deathRecall != null || _ownCorpseTravel != OwnCorpseTravelState.None;
|
||||
bool portaling = Host.HasIsPortaling && Host.IsPortaling();
|
||||
var step = AfterDeath.DecideHunt(s.KeepHuntingAfterDeath, s.IsMacroRunning, replaced, busy, portaling);
|
||||
if (step == AfterDeath.HuntStep.Wait) return;
|
||||
_huntAfterDeath = false;
|
||||
_huntAfterDeathRoute = null;
|
||||
switch (step)
|
||||
{
|
||||
case AfterDeath.HuntStep.Start:
|
||||
StartHunt(afterDeath: true);
|
||||
break;
|
||||
case AfterDeath.HuntStep.DropMacro:
|
||||
ChatLine(KeepHuntingRefusedPrefix + "the macro is off.");
|
||||
break;
|
||||
case AfterDeath.HuntStep.DropRoute:
|
||||
ChatLine(KeepHuntingRefusedPrefix + $"{PatrolReplacementName(s)} is the route now.");
|
||||
break;
|
||||
default:
|
||||
Host.Log("[RynthAi] Hunt: not started again after the death (Keep Hunting After Death was turned off).");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
internal const string KeepHuntingRefusedPrefix = "[RynthAi] Keep Hunting After Death: the hunt didn't start again: ";
|
||||
|
||||
/// <summary>"/ra hunt death [on|off]": Keep Hunting After Death. No word: says it now.</summary>
|
||||
private void SetKeepHuntingAfterDeath(string value)
|
||||
{
|
||||
var s = _dashboard?.Settings;
|
||||
if (s == null) { ReplyFail("[RynthAi] Settings not ready."); return; }
|
||||
string v = value.Trim().ToLowerInvariant();
|
||||
if (v.Length == 0)
|
||||
{
|
||||
ReplyOk($"[RynthAi] Keep Hunting After Death: {(s.KeepHuntingAfterDeath ? "on" : "off")}. {KeepHuntingUsage} to change it.");
|
||||
return;
|
||||
}
|
||||
bool? on = v switch
|
||||
{
|
||||
"on" or "true" or "1" or "yes" => true,
|
||||
"off" or "false" or "0" or "no" => false,
|
||||
_ => null,
|
||||
};
|
||||
if (on is not bool want)
|
||||
{
|
||||
ReplyFail($"[RynthAi] Keep Hunting After Death: '{value.Trim()}' isn't on or off (it is {(s.KeepHuntingAfterDeath ? "on" : "off")} now). Usage: {KeepHuntingUsage}");
|
||||
return;
|
||||
}
|
||||
s.KeepHuntingAfterDeath = want;
|
||||
ReplyOk(want
|
||||
? "[RynthAi] Keep Hunting After Death set: on. After a death the hunt starts again once you're back up (after Recall On Death and Travel Back To My Corpse), and the Dungeon Patrol carries on."
|
||||
: "[RynthAi] Keep Hunting After Death set: off. A death ends the hunt.");
|
||||
}
|
||||
}
|
||||
|
|
@ -332,6 +332,7 @@ internal sealed class DashboardBridge : IDashboardHost
|
|||
public void ToggleSpells() => _p.EnqueueRemoteCommand("spells", "toggle");
|
||||
public void ToggleActiveGear() => Queue(_p.ToggleActiveGearWindow);
|
||||
public void ToggleTimedCommands() => Queue(_p.ToggleTimedCommandsWindow);
|
||||
public void OpenFeatureSearch() => Queue(_p.OpenFeatureSearchWindow);
|
||||
public void UseClassicLook() => _p.UseClassicLook();
|
||||
|
||||
public ProfileFileInfo ProfileInfo(int kind)
|
||||
|
|
|
|||
176
Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.FeatureSearch.cs
Normal file
176
Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.FeatureSearch.cs
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
// RynthAiPlugin.FeatureSearch.cs — the Find a Feature window and /ra find (2026-11-13, approved by the
|
||||
// owner: players couldn't find RynthSuite's features).
|
||||
//
|
||||
// The catalog is Docs/features/*.json (every RynthSuite plugin's features and RynthCore's), embedded in
|
||||
// RynthAi and read once (Features/FeatureCatalog.cs); the website's search reads the same files. The
|
||||
// search is Features/FeatureSearch.cs (pure, tested), the window Features/FeatureSearchWindow.cs.
|
||||
//
|
||||
// Ways in, buttons first: the dashboard's options menu (⋯ > Find a feature) and /ra find [words], which
|
||||
// opens the window with the words in the box and says how many match. The window is a plugin window
|
||||
// (API v89) declared in the sections manifest without a bar button (the bar is full). Without plugin
|
||||
// windows /ra find prints the best matches in chat instead.
|
||||
//
|
||||
// Threads: /ra find runs on the pump thread and leaves its words for the window (a volatile string);
|
||||
// the window is drawn on the render thread and sends Open's command to the tick (QueueDashCommand).
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Threading;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Plugin.RynthAi.Features;
|
||||
using RynthCore.PluginSdk;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi;
|
||||
|
||||
public sealed partial class RynthAiPlugin
|
||||
{
|
||||
/// <summary>The window's title (its panel key) and surface (Huds/SectionsManifest.cs).</summary>
|
||||
internal const string FeatureSearchTitle = "Find a Feature", FeatureSearchSurface = "window:featuresearch";
|
||||
|
||||
internal const string FeatureSearchUsage = "Usage: /ra find [words] (no words: browse every feature)";
|
||||
|
||||
/// <summary>The most a /ra find may type (the window's box holds as much).</summary>
|
||||
internal const int FeatureQueryMax = 96;
|
||||
|
||||
/// <summary>How many matches /ra find prints in chat when the window can't open.</summary>
|
||||
internal const int FeatureChatMatches = 5;
|
||||
|
||||
private volatile string? _featureQueryPending; // /ra find's words for the window (pump writes, render takes)
|
||||
private FeatureSearchWindow? _featureWindow; // render thread
|
||||
private long _featureDrawnMs = long.MinValue / 2; // render thread
|
||||
private int _featureFailures; // render thread
|
||||
|
||||
/// <summary>The window goes in the manifest on an engine with plugin windows (v89).</summary>
|
||||
private bool FeatureSearchWindowWanted => Host.HasUiTheme && Host.HasSetPanelOpen;
|
||||
|
||||
/// <summary>The catalog, read on first use (any thread); a bad file logs one line.</summary>
|
||||
internal FeatureCatalog FeatureList => FeatureCatalog.Shared(line => Host.Log(line));
|
||||
|
||||
/// <summary>The words /ra find left for the window (tests).</summary>
|
||||
internal string? FeatureQueryPendingForTests => _featureQueryPending;
|
||||
|
||||
// ── /ra find ─────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// "/ra find [words]": opens the window with the words in the box and says how many features match
|
||||
/// (no words: how many there are to browse). "?" says the usage. Every form replies. Pump thread.
|
||||
/// </summary>
|
||||
private void HandleFindCommand(string[] parts)
|
||||
{
|
||||
string words = parts.Length > 2 ? string.Join(" ", parts, 2, parts.Length - 2).Trim() : string.Empty;
|
||||
if (words is "?" or "-?" or "/?")
|
||||
{
|
||||
ChatLine("[RynthAi] /ra find <words> — opens Find a Feature with every feature those words match (\"/ra find death\", \"/ra find vend\")");
|
||||
ChatLine("[RynthAi] /ra find — opens it to browse every feature by group (also: the RynthAi window's ⋯ menu > Find a feature)");
|
||||
return;
|
||||
}
|
||||
if (words.Length > FeatureQueryMax)
|
||||
{
|
||||
ReplyFail($"[RynthAi] Find a Feature: that's {words.Length} characters to look for, {FeatureQueryMax} at most. {FeatureSearchUsage}");
|
||||
return;
|
||||
}
|
||||
if (words.Length > 0 && FeatureSearch.Words(words).Count == 0)
|
||||
{
|
||||
ReplyFail($"[RynthAi] Find a Feature: '{words}' has no letters or numbers to look for. {FeatureSearchUsage}");
|
||||
return;
|
||||
}
|
||||
FeatureCatalog catalog = FeatureList;
|
||||
if (catalog.Entries.Count == 0)
|
||||
{
|
||||
ReplyFail("[RynthAi] Find a Feature: the feature list didn't load (the RynthCore log says why).");
|
||||
return;
|
||||
}
|
||||
|
||||
List<FeatureHit> hits = FeatureSearch.Search(catalog.Entries, words);
|
||||
_featureQueryPending = words;
|
||||
int open = OpenFeatureWindow();
|
||||
string where = open == 1 ? " (Find a Feature open)"
|
||||
: open == -2 ? string.Empty
|
||||
: " (the window isn't there yet: RynthCore adds it a few seconds after login)";
|
||||
string count = FeatureSearch.CountLine(hits.Count, words);
|
||||
if (words.Length > 0 && hits.Count == 0)
|
||||
ReplyFail($"[RynthAi] Find a Feature: {count}{where}. Try fewer words, or the start of one. {FeatureSearchUsage}");
|
||||
else if (words.Length == 0)
|
||||
ReplyOk($"[RynthAi] Find a Feature: {count} to browse by group{where}.");
|
||||
else
|
||||
ReplyOk($"[RynthAi] Find a Feature: {count}{where}.");
|
||||
// No window to show them in: the best few in chat.
|
||||
if (open != 1 && words.Length > 0)
|
||||
for (int i = 0; i < hits.Count && i < FeatureChatMatches; i++) ChatLine("[RynthAi] " + ChatText(hits[i].Entry));
|
||||
}
|
||||
|
||||
/// <summary>"Name (Plugin): where; /command" for chat.</summary>
|
||||
internal static string ChatText(FeatureEntry e)
|
||||
{
|
||||
string text = e.Name + (e.Plugin.Length > 0 ? " (" + e.Plugin + ")" : string.Empty);
|
||||
if (e.Where.Count > 0) text += ": " + e.Where[0];
|
||||
if (e.Command.Length > 0) text += (e.Where.Count > 0 ? "; " : ": ") + e.Command;
|
||||
return text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The window open: 1 open, 0 closed, -1 not there yet (RynthCore adds plugin windows a few seconds
|
||||
/// after login), -2 no plugin windows on this RynthCore. Any thread.
|
||||
/// </summary>
|
||||
private int OpenFeatureWindow()
|
||||
{
|
||||
if (!Host.HasSetPanelOpen) return -2;
|
||||
int r = Host.SetPanelOpen(FeatureSearchTitle, RynthPanelOpen.Open);
|
||||
return r < 0 ? -1 : r;
|
||||
}
|
||||
|
||||
/// <summary>The dashboard's ⋯ > Find a feature: the window open, the box ready to type in. Any thread.</summary>
|
||||
internal void OpenFeatureSearchWindow()
|
||||
{
|
||||
if (OpenFeatureWindow() == -1)
|
||||
ChatLine("[RynthAi] Find a Feature isn't there yet (RynthCore adds it a few seconds after login). Try again in a moment, or type /ra find <words>.");
|
||||
}
|
||||
|
||||
/// <summary>The window's Open: a feature's open command, run as typed (on the tick).</summary>
|
||||
private void RunFeatureOpen(string command)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(command)) return;
|
||||
if (!Host.HasInvokeChatParser)
|
||||
{
|
||||
ChatLine("[RynthAi] Find a Feature: this RynthCore can't run commands for RynthAi; type " + command);
|
||||
return;
|
||||
}
|
||||
QueueDashCommand(command.Trim());
|
||||
}
|
||||
|
||||
// ── Window (render thread) ───────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// RynthPluginRenderEmbed "window:featuresearch": the Find a Feature window body, docked or popped out.
|
||||
/// 1 drawn, 0 not ready, -2 failed (three draws in a row threw).
|
||||
/// </summary>
|
||||
internal int RenderFeatureSearch(bool popped, out Vector2 want)
|
||||
{
|
||||
want = default;
|
||||
if (!_initialized || Host.ImGuiContext == IntPtr.Zero) return 0;
|
||||
long now = Environment.TickCount64;
|
||||
bool reopened = now - _featureDrawnMs > 1000;
|
||||
_featureDrawnMs = now;
|
||||
IntPtr previous = ImGui.GetCurrentContext();
|
||||
ImGui.SetCurrentContext(EmbedContext());
|
||||
try
|
||||
{
|
||||
_featureWindow ??= new FeatureSearchWindow(() => FeatureList.Entries, RunFeatureOpen);
|
||||
string? pending = Interlocked.Exchange(ref _featureQueryPending, null);
|
||||
if (pending != null) _featureWindow.SetQuery(pending);
|
||||
else if (reopened) _featureWindow.Reopened();
|
||||
want = _featureWindow.Draw();
|
||||
_featureFailures = 0;
|
||||
return 1;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RynthLog.Exception(LogCat.UI, ex, "RenderFeatureSearch");
|
||||
return ++_featureFailures >= 3 ? -2 : 0;
|
||||
}
|
||||
finally
|
||||
{
|
||||
ImGui.SetCurrentContext(previous);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -494,7 +494,7 @@ public sealed partial class RynthAiPlugin
|
|||
if (!_initialized || !_loginComplete) return null;
|
||||
return Huds.SectionsManifest.Build(Huds.SectionsManifest.Views(), Huds.SectionsManifest.OwnSections,
|
||||
dashboard: DashboardWindowWanted, monsterStats: MonsterStatsWindowWanted, timedCommands: TimedCommandsWindowWanted,
|
||||
activeGear: ActiveGearWindowWanted);
|
||||
activeGear: ActiveGearWindowWanted, featureSearch: FeatureSearchWindowWanted);
|
||||
}
|
||||
/// <summary>Chat Translate window in the dashboard colours (no-op while hidden).</summary>
|
||||
private void RenderTranslateWindow()
|
||||
|
|
|
|||
|
|
@ -62,6 +62,10 @@ public sealed partial class RynthAiPlugin
|
|||
case "login":
|
||||
SetHuntOnLogin(parts.Length > 3 ? parts[3] : "");
|
||||
break;
|
||||
case "death":
|
||||
case "keep":
|
||||
SetKeepHuntingAfterDeath(parts.Length > 3 ? parts[3] : "");
|
||||
break;
|
||||
case "panel":
|
||||
case "settings":
|
||||
ToggleHuntPanel();
|
||||
|
|
@ -70,7 +74,7 @@ public sealed partial class RynthAiPlugin
|
|||
if (_hunt.Active) StopHunt("stopped", say: true); else StartHunt();
|
||||
break;
|
||||
default:
|
||||
ChatLine("[RynthAi] /ra hunt [start|stop|status|panel] | /ra hunt range <yd> | /ra hunt radius <yd, 0 = anywhere> | " + HuntPickUsage + " | " + HuntLoginUsage);
|
||||
ChatLine("[RynthAi] /ra hunt [start|stop|status|panel] | /ra hunt range <yd> | /ra hunt radius <yd, 0 = anywhere> | " + HuntPickUsage + " | " + HuntLoginUsage + " | " + KeepHuntingUsage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -193,6 +197,8 @@ public sealed partial class RynthAiPlugin
|
|||
string note = _hunt.Note;
|
||||
if (on && note.Length > 0) Wrapped(note, Ui.Text);
|
||||
HuntOnLoginCheckbox(s);
|
||||
ImGui.Checkbox("Keep Hunting After Death##huntkeepdeath", ref s.KeepHuntingAfterDeath);
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip(AfterDeath.Tip);
|
||||
ImGui.Separator();
|
||||
|
||||
float range = s.OutdoorHuntRange;
|
||||
|
|
@ -259,9 +265,13 @@ public sealed partial class RynthAiPlugin
|
|||
|
||||
internal const string HuntOnLoginRefusedPrefix = "[RynthAi] Hunt On Login: the hunt didn't start. ";
|
||||
|
||||
/// <summary>The Hunt button, /ra hunt and Hunt On Login (<paramref name="onLogin"/>: its lines say so).</summary>
|
||||
internal void StartHunt(bool onLogin = false)
|
||||
/// <summary>
|
||||
/// The Hunt button, /ra hunt, Hunt On Login (<paramref name="onLogin"/>) and Keep Hunting After Death
|
||||
/// (<paramref name="afterDeath"/>): their lines say which.
|
||||
/// </summary>
|
||||
internal void StartHunt(bool onLogin = false, bool afterDeath = false)
|
||||
{
|
||||
_huntAfterDeath = false; // started now, by whichever: nothing waits for the respawn any more
|
||||
var s = _dashboard?.Settings;
|
||||
uint cell = 0;
|
||||
OutdoorHunt.Vec me = default;
|
||||
|
|
@ -277,7 +287,7 @@ public sealed partial class RynthAiPlugin
|
|||
{
|
||||
string why = OutdoorHunt.StartBlockText(block);
|
||||
if (onLogin) Host.Log("[RynthAi] Hunt On Login: not started (" + block + ").");
|
||||
ChatLine((onLogin ? HuntOnLoginRefusedPrefix : "[RynthAi] ") + why);
|
||||
ChatLine((onLogin ? HuntOnLoginRefusedPrefix : afterDeath ? KeepHuntingRefusedPrefix : "[RynthAi] ") + why);
|
||||
return;
|
||||
}
|
||||
if (!s.IsMacroRunning && RefuseMacroStartForVTank()) return; // one bot per client (Decal bridge)
|
||||
|
|
@ -295,7 +305,9 @@ public sealed partial class RynthAiPlugin
|
|||
s.IsMacroRunning = true;
|
||||
_macroWasRunning = true; // no macro-start "nearest waypoint" pick: the hunt plans its own walks
|
||||
}
|
||||
ChatLine((onLogin ? "[RynthAi] Hunt On Login: outdoor hunt on: " : "[RynthAi] Outdoor hunt on: ")
|
||||
ChatLine((onLogin ? "[RynthAi] Hunt On Login: outdoor hunt on: "
|
||||
: afterDeath ? "[RynthAi] Outdoor hunt on again after the death, from here (Keep Hunting After Death): "
|
||||
: "[RynthAi] Outdoor hunt on: ")
|
||||
+ HuntSettingsText(s) + " /ra hunt range <yd> to change.");
|
||||
}
|
||||
|
||||
|
|
@ -384,7 +396,7 @@ public sealed partial class RynthAiPlugin
|
|||
/// <summary>Each plugin tick while logged in: the hunt's next walk, when nothing else wants the character.</summary>
|
||||
private void TickOutdoorHunt()
|
||||
{
|
||||
if (!_hunt.Active) return;
|
||||
if (!_hunt.Active) { TickHuntAfterDeath(); return; }
|
||||
var s = _dashboard?.Settings;
|
||||
if (s == null) return;
|
||||
if (!s.IsMacroRunning) { StopHunt("the macro stopped"); return; }
|
||||
|
|
|
|||
|
|
@ -121,7 +121,9 @@ public sealed partial class RynthAiPlugin
|
|||
_buffManager?.CancelPendingRecall("death"); // no /lifestone or macro restart after the respawn
|
||||
_buffManager?.ForgetPendingWield("death"); // a swap the death cut short is not a failed swap
|
||||
_petManager?.OnPlayerDeath(); // the pet out is left behind with the corpse
|
||||
StopHunt("died", say: true); // from the lifestone it would walk all the way back to where it started
|
||||
// From the lifestone it would walk all the way back to where it started: off, or with Keep
|
||||
// Hunting After Death paused until the character is back up (RynthAiPlugin.AfterDeath.cs).
|
||||
PauseHuntForDeath();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ namespace RynthCore.Plugin.RynthAi;
|
|||
// /ra setmetastate <state> Meta: <state> switch the meta state (no state: list them)
|
||||
// /ra targetlock [off] Target lock attack the selected monster (again / off: release)
|
||||
// /ra fightselected [on|off] Fight the monster I select (no argument: toggle)
|
||||
// /ra meleewalls [on|off] Melee through walls (no argument: toggle)
|
||||
// /ra meleelow|meleemid|meleehigh melee attack height
|
||||
// /ra navaddpt NavAddPt waypoint at your position (same as /ra addnavpt)
|
||||
// /ra testitem TestItem the selected item against the loot profile
|
||||
|
|
@ -55,6 +56,8 @@ public sealed partial class RynthAiPlugin
|
|||
case "targetlock": HandleTargetLockCommand(parts); return true;
|
||||
case "fightselected":
|
||||
case "fightselect": HandleFightSelectedCommand(parts); return true;
|
||||
case "meleewalls":
|
||||
case "meleethroughwalls": HandleMeleeWallsCommand(parts); return true;
|
||||
case "meleelow": SetMeleeAttackHeight(0); return true;
|
||||
case "meleemid":
|
||||
case "meleemedium": SetMeleeAttackHeight(1); return true;
|
||||
|
|
@ -205,6 +208,32 @@ public sealed partial class RynthAiPlugin
|
|||
: "[RynthAi] Fight the monster I select: off.");
|
||||
}
|
||||
|
||||
// ── Melee through walls ──────────────────────────────────────────────────
|
||||
|
||||
private void HandleMeleeWallsCommand(string[] parts)
|
||||
{
|
||||
var dash = _dashboard;
|
||||
var s = dash?.Settings;
|
||||
if (s == null) { ReplyFail("[RynthAi] Settings not ready."); return; }
|
||||
string arg = parts.Length >= 3 ? parts[2].ToLowerInvariant() : "";
|
||||
bool? set = arg switch
|
||||
{
|
||||
"" or "toggle" => !s.MeleeThroughWalls,
|
||||
"on" or "1" or "true" => true,
|
||||
"off" or "0" or "false" => false,
|
||||
_ => null,
|
||||
};
|
||||
if (set is not bool on)
|
||||
{
|
||||
ReplyFail($"[RynthAi] Melee through walls: unknown '{arg}'. Usage: /ra meleewalls [on|off] (now {(s.MeleeThroughWalls ? "on" : "off")}).");
|
||||
return;
|
||||
}
|
||||
s.MeleeThroughWalls = on;
|
||||
dash!.SaveSettings();
|
||||
ReplyOk(on ? "[RynthAi] Melee through walls: on (melee reaches a monster within 4 m behind a wall, not across a building's wall)."
|
||||
: "[RynthAi] Melee through walls: off (a monster behind a wall is never a melee target for being close).");
|
||||
}
|
||||
|
||||
// ── Melee attack height ──────────────────────────────────────────────────
|
||||
|
||||
private void SetMeleeAttackHeight(int height)
|
||||
|
|
|
|||
|
|
@ -4150,6 +4150,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
case "mstats": HandleMonsterStatsCommand(parts); break; // RynthAiPlugin.MonsterStats.cs
|
||||
case "gear": HandleGearCommand(parts); break; // RynthAiPlugin.ActiveGear.cs
|
||||
case "timed": HandleTimedCommand(parts); break; // RynthAiPlugin.TimedCommands.cs
|
||||
case "find": HandleFindCommand(parts); break; // RynthAiPlugin.FeatureSearch.cs
|
||||
case "aetheria": HandleAetheriaCommand(parts); break; // RynthAiPlugin.Aetheria.cs
|
||||
case "autoconfirm": HandleAutoConfirmCommand(parts); break; // RynthAiPlugin.AutoConfirm.cs
|
||||
case "why": HandleWhyCommand(); break;
|
||||
|
|
|
|||
|
|
@ -106,6 +106,10 @@
|
|||
C:\Games\RynthSuite\RynthAi\Data wins over the built-in one. -->
|
||||
<EmbeddedResource Include="Data\creature_weakness.json" />
|
||||
<None Include="Data\creature_weakness.json" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
|
||||
<!-- The feature catalog (Find a Feature, Features/FeatureCatalog.cs): every Docs\features\*.json, the
|
||||
same files the website's search reads. Logical names "RynthAi.Features.<file>.json", enumerated
|
||||
at run time, so a new area's file is picked up without touching this line. -->
|
||||
<EmbeddedResource Include="..\..\Docs\features\*.json" LogicalName="RynthAi.Features.%(Filename)%(Extension)" Link="Features\Catalog\%(Filename)%(Extension)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
Loading…
Reference in a new issue