Merge rynth/main (2026.10.8.1) into sk/features-on-rynth-main

Resolves the conflicts that kept PR #2 from merging. Where rynth/main
already ships the same feature, its version wins: the shared read-only
RynthInstallPaths, /ra iteminfo (PR #2's Mag-Tools item info window is
dropped), pet essence refill trust, object filing, spell metadata and the
Monster Editor's Category / MatchExpression.

See Changelog/2026-10-08-merge-rynth-main-into-pr2.md.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
BlankenshipG 2026-10-08 22:23:49 -04:00
commit 2e54796b15
160 changed files with 15447 additions and 2566 deletions

View file

@ -476,6 +476,8 @@ internal static class AfFileParser
case MetaConditionType.MainManaPHE:
case MetaConditionType.MainStamLE:
case MetaConditionType.VitaePHE:
// RynthAi only: NoKillsInMins 5 (minutes, decimals allowed).
case MetaConditionType.NoKillsWithinMinutes:
// These use bare numbers (no braces): e.g. MainSlotsLE 4, BlockE F6820033
rule.ConditionData = ExtractBareOrBrace(rest);
break;

View file

@ -139,6 +139,9 @@ internal static class AfFileWriter
case MetaConditionType.MainManaPHE:
case MetaConditionType.MainStamLE:
case MetaConditionType.VitaePHE:
// RynthAi only (NoKillsInMins 5): metaf can't compile it to a .met, and an older
// RynthAi loads it as Never with an "unknown condition keyword" warning.
case MetaConditionType.NoKillsWithinMinutes:
// Bare values (no braces): MainSlotsLE 4, MainHealthLE 50
writer.Write($"{keyword} {data}");
break;
@ -341,7 +344,7 @@ internal static class AfFileWriter
5543 => "Neftet Recall",
6321 => "Rynthid Recall",
6322 => "Viridian Rise Recall",
_ => $"Spell {spellId}"
_ => NavPoint.RecallName(spellId)
};
}
}

View file

@ -62,7 +62,7 @@ internal sealed class ExpressionEngine
// The three data paths are settable only so offline tests can point them at a scratch
// folder before anything reads or writes them; the plugin never changes them.
internal static string ItemGiverDir { get; set; }
= Path.Combine(@"C:\Games\RynthSuite\RynthAi", "ItemGiver");
= Path.Combine(RynthCore.Install.RynthInstallPaths.RynthAiDir, "ItemGiver");
/// <summary>Millisecond tick for delayexec and the var-flush throttle. Tests swap it for a
/// fake clock; the plugin never changes it.</summary>
@ -107,8 +107,8 @@ internal sealed class ExpressionEngine
private long _lastVarFlushMs;
private string? _pvarPathCached;
private const long VarFlushIntervalMs = 2000;
internal static string PvarsDir { get; set; } = Path.Combine(@"C:\Games\RynthSuite\RynthAi", "pvars");
internal static string GvarsPath { get; set; } = Path.Combine(@"C:\Games\RynthSuite\RynthAi", "gvars.txt");
internal static string PvarsDir { get; set; } = Path.Combine(RynthCore.Install.RynthInstallPaths.RynthAiDir, "pvars");
internal static string GvarsPath { get; set; } = Path.Combine(RynthCore.Install.RynthInstallPaths.RynthAiDir, "gvars.txt");
private Dictionary<string, (Func<string> Get, Action<string> Set)>? _settingsMap;
public IReadOnlyDictionary<string, string> Variables => _variables;
@ -156,6 +156,11 @@ internal sealed class ExpressionEngine
private CreatureProfileStore? _creatureStore;
public void SetCreatureStore(CreatureProfileStore? store) => _creatureStore = store;
// secondssincelastkill[]: the plugin's kill clock. Null (not wired) reads as 0, i.e.
// "just killed", so a "no kills for a while" test never holds by mistake.
private KillClock? _killClock;
public void SetKillClock(KillClock? clock) => _killClock = clock;
// ── Backward-compat shim ──────────────────────────────────────────────────
/// <summary>Executes an expression for its side effects. Always returns true.</summary>
@ -327,6 +332,8 @@ internal sealed class ExpressionEngine
"getdatetimelocal" => DateTime.Now.ToString(A(0)),
"getdatetimeutc" => DateTime.UtcNow.ToString(A(0)),
"getunixtime" => DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(System.Globalization.CultureInfo.InvariantCulture),
// Whole seconds since our last kill; before the first, since the macro start (or login).
"secondssincelastkill" => (_killClock?.SecondsSinceLastKill() ?? 0).ToString(CultureInfo.InvariantCulture),
// ── World object queries ──────────────────────────────────────────
"wobjectfindnearestbytemplatetype" => EvalWobjectFindNearestByTemplateType(A(0)),
@ -342,7 +349,8 @@ internal sealed class ExpressionEngine
"wobjectfindallinventorybynamerx" => EvalWobjectFindAllInventoryByNameRx(Tmpl(0)),
"wobjectfindininventorybyname" => EvalWobjectFindInInventoryByName(Tmpl(0)),
"wobjectfindininventorybynamerx" => EvalWobjectFindInInventoryByNameRx(Tmpl(0)),
"wobjectfindalllandscapebytemplatetype" => EvalWobjectFindAllLandscapeByTemplateType(A(0)),
"wobjectfindalllandscapebyobjectclass" => EvalWobjectFindAllLandscapeByObjectClass(A(0)),
"wobjectfindalllandscapebytemplatetype" =>EvalWobjectFindAllLandscapeByTemplateType(A(0)),
"wobjectfindalllandscapebynamerx" => EvalWobjectFindAllLandscapeByNameRx(Tmpl(0)),
"wobjectfindallbycontainer" => EvalWobjectFindAllByContainer(A(0)),
"wobjectgetselection" => EvalWobjectGetSelection(),
@ -1635,6 +1643,24 @@ internal sealed class ExpressionEngine
return NewList(items);
}
private string EvalWobjectFindAllLandscapeByObjectClass(string arg)
{
if (_worldObjectCache == null) return "[]";
if (!int.TryParse(arg.Trim(), out int targetClass)) return "[]";
var items = new List<string>();
var seen = new System.Collections.Generic.HashSet<int>();
void Check(WorldObject wo)
{
if (!seen.Add(wo.Id)) return;
if (ResolveEffectiveObjectClass(wo) == targetClass)
items.Add(MakeWobjectHandle(unchecked((uint)wo.Id), wo.Name));
}
foreach (var wo in _worldObjectCache.GetLandscapeObjects()) Check(wo);
foreach (var wo in _worldObjectCache.GetLandscape()) Check(wo);
return NewList(items);
}
private string EvalWobjectFindAllLandscapeByTemplateType(string arg)
{
if (_worldObjectCache == null || !_host.HasGetObjectWcid) return "[]";
@ -2412,8 +2438,8 @@ internal sealed class ExpressionEngine
{
if (!TryParseWobjectHandle(arg, out uint uid, out _) || uid == 0) return "0";
if (!_host.HasSelectItem) return "0";
_host.SelectItem(uid);
return "0";
RynthCore.Plugin.RynthAi.ItemInfo.SelfSelect.Mark(uid);
return _host.SelectItem(uid) ? "1" : "0";
}
private string EvalActionTryUseItem(string arg)
@ -2440,7 +2466,7 @@ internal sealed class ExpressionEngine
if (!EnsureMagicModeForCast()) return "0";
_host.CastSpell(targetId, spellId);
_host.CastSpellFor(targetId, spellId, "Meta", $"spell {spellId} (meta)", asked: true);
return "1";
}
@ -2486,7 +2512,7 @@ internal sealed class ExpressionEngine
if (!_host.HasGetCurrentCombatMode)
{
// Can't read mode — best-effort flip and bail.
if (_host.HasChangeCombatMode) _host.ChangeCombatMode(CombatMode.Magic);
if (_host.HasChangeCombatMode) _host.ChangeCombatModeFor(CombatMode.Magic, "Meta", "meta cast: Magic mode", force: true);
return false;
}
@ -2509,7 +2535,7 @@ internal sealed class ExpressionEngine
if (wandId == 0 || !_host.HasUseObject)
{
// No wand (or no UseObject) — try bare-handed magic.
if (_host.HasChangeCombatMode) _host.ChangeCombatMode(CombatMode.Magic);
if (_host.HasChangeCombatMode) _host.ChangeCombatModeFor(CombatMode.Magic, "Meta", "meta cast: Magic mode", force: true);
return false;
}
@ -2613,7 +2639,7 @@ internal sealed class ExpressionEngine
if (_host.HasChangeCombatMode
&& (now - _castStanceLastFlipAt).TotalMilliseconds > CastStanceFlipGateMs)
{
_host.ChangeCombatMode(CombatMode.Magic);
_host.ChangeCombatModeFor(CombatMode.Magic, "Meta", "meta cast: Magic mode", force: true);
_castStanceLastFlipAt = now;
}
return false;
@ -2717,7 +2743,7 @@ internal sealed class ExpressionEngine
if (targetId == 0) targetId = _host.GetPlayerId();
if (targetId == 0) return "2";
_host.CastSpell(targetId, spellId);
_host.CastSpellFor(targetId, spellId, "Meta", $"spell {spellId} (meta)", asked: true);
return "1";
}
@ -2867,7 +2893,11 @@ internal sealed class ExpressionEngine
_ => 0,
};
if (mode == 0) return "0";
return _host.ChangeCombatMode(mode) ? "1" : "0";
if (!_host.HasChangeCombatMode) return "0";
int seq = _host.HasUseDoneSeq ? _host.GetUseDoneSeq() : 0;
bool ok = _host.ChangeCombatMode(mode);
if (ok) ActionPacer.Begin(_host, PacedKind.CombatMode, 0, ActionPacer.ModeName(mode), "RynthAi/Meta (asked)", seq, mode);
return ok ? "1" : "0";
}
private string EvalGetBusyState()
@ -3306,7 +3336,9 @@ internal sealed class ExpressionEngine
["StopMacroOnNoComponents"] = (() => B(s.StopMacroOnNoComponents), v => s.StopMacroOnNoComponents = ToDouble(v) != 0),
["StopLootingWhenPackFull"] = (() => B(s.StopLootingWhenPackFull), v => s.StopLootingWhenPackFull = ToDouble(v) != 0),
["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),
["ItemInfoOnSelect"] = (() => B(s.ItemInfoOnSelect), v => s.ItemInfoOnSelect = ToDouble(v) != 0),
["StopMacroWhenPackFull"] = (() => B(s.StopMacroWhenPackFull), v => s.StopMacroWhenPackFull = ToDouble(v) != 0),
["SummonPets"] = (() => B(s.SummonPets), v => s.SummonPets = ToDouble(v) != 0),
["MineOnly"] = (() => B(s.MineOnly), v => s.MineOnly = ToDouble(v) != 0),
@ -3325,8 +3357,11 @@ internal sealed class ExpressionEngine
["MinRingTargets"] = (() => I(s.MinRingTargets), v => { if (int.TryParse(v, out int i)) s.MinRingTargets = i; }),
["BlastRange"] = (() => I(s.BlastRange), v => { if (int.TryParse(v, out int i)) s.BlastRange = i; }),
["MinBlastTargets"] = (() => I(s.MinBlastTargets), v => { if (int.TryParse(v, out int i)) s.MinBlastTargets = i; }),
["WallRange"] = (() => I(s.WallRange), v => { if (int.TryParse(v, out int i)) s.WallRange = i; }),
["MinWallTargets"] = (() => I(s.MinWallTargets), v => { if (int.TryParse(v, out int i)) s.MinWallTargets = i; }),
["HealAt"] = (() => I(s.HealAt), v => { if (int.TryParse(v, out int i)) s.HealAt = i; }),
["RestamAt"] = (() => I(s.RestamAt), v => { if (int.TryParse(v, out int i)) s.RestamAt = i; }),
["RestamTo"] = (() => I(s.RestamTo), v => { if (int.TryParse(v, out int i)) s.RestamTo = i; }),
["GetManaAt"] = (() => I(s.GetManaAt), v => { if (int.TryParse(v, out int i)) s.GetManaAt = i; }),
["TopOffHP"] = (() => I(s.TopOffHP), v => { if (int.TryParse(v, out int i)) s.TopOffHP = i; }),
["TopOffStam"] = (() => I(s.TopOffStam), v => { if (int.TryParse(v, out int i)) s.TopOffStam = i; }),
@ -3371,6 +3406,8 @@ internal sealed class ExpressionEngine
["MaxMonRange"] = (() => D(s.MaxMonRange), v => { if (double.TryParse(v, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double d)) s.MaxMonRange = d; }),
["NavRingThickness"] = (() => F(s.NavRingThickness), v => { if (float.TryParse(v, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out float f)) s.NavRingThickness = f; }),
["NavLineThickness"] = (() => F(s.NavLineThickness), v => { if (float.TryParse(v, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out float f)) s.NavLineThickness = f; }),
["NavLabelMode"] = (() => I(s.NavLabelMode), v => { if (int.TryParse(v, out int i)) s.NavLabelMode = NavLabelModes.Clamp(i); }),
["NavGuideLine"] = (() => B(s.NavGuideLine), v => s.NavGuideLine = ToDouble(v) != 0),
["CurrentNavPath"] = (() => s.CurrentNavPath, v => s.CurrentNavPath = v),
["CurrentLootPath"] = (() => s.CurrentLootPath, v => s.CurrentLootPath = v),
["CurrentMetaPath"] = (() => s.CurrentMetaPath, v => s.CurrentMetaPath = v),

View file

@ -728,6 +728,19 @@ getunixtime[]
Example: setvar[t, getunixtime[]] → snapshot a timestamp
Example: getunixtime[] - getvar[t] > 60 → true if 60s have elapsed
secondssincelastkill[]
Returns the whole number of seconds since your character's last kill.
Only kills credited to you count (the server's "you killed it" notice);
deaths you only see in chat, and your fellows' kills, do not.
Before your first kill this session it counts from when the macro was last
started, or from login (or a RynthAi reload) if the macro hasn't been started
since, so a meta can still react when nothing has been killed at all.
After a kill it is always the time since that kill, also across a macro stop/start.
The meta condition "No Kills Within Minutes" (.af: NoKillsInMins 5) uses the same clock.
Test in chat: /ra mexec secondssincelastkill[]
Example: secondssincelastkill[] → e.g. "42"
Example: secondssincelastkill[] >= 300 → true after 5 minutes without a kill
getaccounthash[]
Returns a lowercase MD5 hex string of the current account name.
Returns "" (empty string) if the account name is not yet available.

View file

@ -145,6 +145,15 @@ internal sealed class MetaManager
_expressions?.SetCreatureStore(store);
}
// The plugin's kill clock (secondssincelastkill[], No Kills Within Minutes). Without one
// (never in the plugin) the condition is false and the function says 0: fail closed.
private KillClock? _killClock;
public void SetKillClock(KillClock? clock)
{
_killClock = clock;
_expressions?.SetKillClock(clock);
}
public void SetPlayerId(uint id)
{
_playerId = id;
@ -201,6 +210,7 @@ internal sealed class MetaManager
engine.SetQuestTracker(_questTracker);
engine.SetSettings(_settings);
engine.SetCreatureStore(_creatureStore);
engine.SetKillClock(_killClock);
return engine;
}
@ -728,6 +738,14 @@ internal sealed class MetaManager
case MetaConditionType.NeedToBuff:
return _buffManager != null && _buffManager.NeedsAnyBuff();
// ── No kills within N minutes (RynthAi only) ──────────────────────
// The secondssincelastkill[] clock: our last kill (KillerNotification), or before
// the first one the last macro start / login. Bad or missing minutes never hold.
case MetaConditionType.NoKillsWithinMinutes:
return _killClock != null
&& KillClock.TryParseMinutes(rule.ConditionData, out double noKillMins)
&& _killClock.NoKillsFor(noKillMins);
default: return false;
}
}
@ -893,7 +911,7 @@ internal sealed class MetaManager
}
// Fallback: a standalone .nav file in NavProfiles.
string navFolder = System.IO.Path.Combine(RynthInstallPaths.RynthAiDir, @"NavProfiles");
string navFolder = System.IO.Path.Combine(RynthCore.Install.RynthInstallPaths.RynthAiDir, "NavProfiles");
string fullPath = Path.Combine(navFolder, routeName + ".nav");
if (File.Exists(fullPath))
{
@ -1092,7 +1110,7 @@ internal sealed class MetaManager
parts[2].Equals("load", StringComparison.OrdinalIgnoreCase))
{
string name = string.Join(" ", parts, 3, parts.Length - 3);
string metaDir = System.IO.Path.Combine(RynthInstallPaths.RynthAiDir, @"MetaFiles");
string metaDir = System.IO.Path.Combine(RynthCore.Install.RynthInstallPaths.RynthAiDir, "MetaFiles");
string afPath = Path.Combine(metaDir, name + ".af");
string metPath = Path.Combine(metaDir, name + ".met");
@ -1156,7 +1174,7 @@ internal sealed class MetaManager
string path = name;
if (!File.Exists(path))
{
string folder = @"C:\Games\RynthSuite\RynthAi\LootProfiles";
string folder = System.IO.Path.Combine(RynthCore.Install.RynthInstallPaths.RynthAiDir, "LootProfiles");
string stem = name.EndsWith(".utl", StringComparison.OrdinalIgnoreCase) || name.EndsWith(".json", StringComparison.OrdinalIgnoreCase)
? name : name + ".utl";
string candidate = Path.Combine(folder, stem);

View file

@ -0,0 +1,52 @@
using System.Collections.Generic;
using RynthCore.Plugin.RynthAi.LegacyUi;
namespace RynthCore.Plugin.RynthAi.Meta;
/// <summary>
/// How a rule edited in the Meta panel replaces the running one (update_rule / duplicate_rule).
///
/// The engine's Meta editor saves every change on its own since 2026-10-05 (debounced), so an
/// update must not disturb a meta that is running:
/// - the rule keeps its runtime latch (HasFired) and LastFiredAt. A fresh MetaRule had
/// HasFired = false, so every save of a rule in the current state fired it again
/// (an IF Always DO EmbedNav rule restarted its route from point 0 on each save);
/// - the panel's DTO has no CallReturnState (CallState's return state) or ChatColors
/// (ChatCapture's chat types), so an update used to drop both from VTank-imported rules.
/// They are kept while the rule still has that action / condition.
/// Nothing here touches the current state, the state clocks, the watchdog or the call stack.
/// </summary>
internal static class MetaRuleEdits
{
/// <summary>Puts <paramref name="edited"/> at <paramref name="index"/>, keeping the old rule's
/// runtime latch and the fields the panel can't send. False when the index is out of range.</summary>
public static bool Replace(List<MetaRule> rules, int index, MetaRule edited)
{
if (index < 0 || index >= rules.Count) return false;
MetaRule old = rules[index];
KeepHidden(old, edited);
edited.HasFired = old.HasFired;
edited.LastFiredAt = old.LastFiredAt;
rules[index] = edited;
return true;
}
/// <summary>Copies CallReturnState / ChatColors from <paramref name="from"/> into an edited copy
/// that still has the same action / condition and carries none of its own; children by position.</summary>
public static void KeepHidden(MetaRule from, MetaRule to)
{
if (to.Action == MetaActionType.CallMetaState && from.Action == MetaActionType.CallMetaState
&& string.IsNullOrEmpty(to.CallReturnState))
to.CallReturnState = from.CallReturnState;
if (to.Condition == MetaConditionType.ChatMessageCapture && from.Condition == MetaConditionType.ChatMessageCapture
&& string.IsNullOrEmpty(to.ChatColors))
to.ChatColors = from.ChatColors;
if (from.Children != null && to.Children != null)
for (int i = 0; i < from.Children.Count && i < to.Children.Count; i++)
KeepHidden(from.Children[i], to.Children[i]);
if (from.ActionChildren != null && to.ActionChildren != null)
for (int i = 0; i < from.ActionChildren.Count && i < to.ActionChildren.Count; i++)
KeepHidden(from.ActionChildren[i], to.ActionChildren[i]);
}
}

View file

@ -72,6 +72,8 @@ internal static class MetaSchema
new(MetaConditionType.MainManaPHE, "MainManaPHE", "Main Mana % >="),
new(MetaConditionType.MainStamLE, "MainStamLE", "Main Stam <="),
new(MetaConditionType.VitaePHE, "VitaePHE", "Vitae % >="),
// RynthAi only: VTank and metaf have no such condition (see AfFileWriter).
new(MetaConditionType.NoKillsWithinMinutes, "NoKillsInMins", "No Kills Within Minutes"),
};
// Index == (int)MetaActionType.