feat: port SK test branch (2026.10.18.24) onto sk
Squash of test/hotbuild-2026-10-16 as merged onto aelrynth main 2026.10.17.1, matching the 2026.10.18.24 test installer. The test branch wins where both changed the same lines; sk-only changes kept; duplicate features cut to the test branch's copy. RynthAi HandWrittenVersion stays 0.5.0-legacy-ui on sk. Highlights: RynthOracle 0.6.0 (Legendary, Markers, Dynamic Stamps and Temple guardians merged into the Quests list, RynthNav Go to), RynthILT 0.2.20 (ub-IT auto-chunk rules, rating level, RynthILT.Data v3), RynthAi ub-IT /ub and VT/MT meta compatibility and the loot attribute checklist, RynthNav destination alternatives. Changelog/2026-10-18-sk-port-test-branch-2026.10.18.24.md.
This commit is contained in:
parent
23efcfee87
commit
7797901d69
287 changed files with 22602 additions and 1090 deletions
|
|
@ -0,0 +1,373 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.Meta;
|
||||
|
||||
/// <summary>
|
||||
/// ub-IT expression functions that were missing (2026-10-18 meta-compatibility pass), with
|
||||
/// ub-IT's names, arguments and return values. Where RynthAi has no matching data (character
|
||||
/// select, Decal views, ub-IT's own HUDs) the function still answers, with the value ub-IT gives
|
||||
/// when there is nothing to report, so an expression that calls it keeps working.
|
||||
/// </summary>
|
||||
internal sealed partial class ExpressionEngine
|
||||
{
|
||||
/// <summary>Corpses this character has opened (the plugin's loot bookkeeping), for
|
||||
/// hascorpsebeenopenedbyme[] and getcorpsesunopenedbyme[]. Null: none known.</summary>
|
||||
internal Func<int, bool>? CorpseOpenedByMe { get; set; }
|
||||
|
||||
/// <summary>The meta manager's '/vt opt set' (VTank names, distances in landblock units, the
|
||||
/// special options), for vtsetsetting[]; null: the plain settings map (an engine without one).</summary>
|
||||
internal Func<string, string, bool>? VtOptionSetter { get; set; }
|
||||
|
||||
/// <summary>The meta manager's '/vt opt get' (values read back in VTank's units), for vtgetsetting[].</summary>
|
||||
internal Func<string, string?>? VtOptionGetter { get; set; }
|
||||
|
||||
// getcooldownexpiration: shared cooldowns are enchantments whose spell id has this bit.
|
||||
private const uint CooldownSpellFlag = 0x8000;
|
||||
|
||||
// ub-IT's QuestRefreshCooldownSeconds default (canrefreshquests[]).
|
||||
private const double QuestRefreshCooldownSeconds = 60;
|
||||
|
||||
// Character property ids (PropertyInt64): total experience, available luminance.
|
||||
private const uint QuadTotalExperience = 1;
|
||||
private const uint QuadAvailableLuminance = 6;
|
||||
// PropertyInt StackSize.
|
||||
private const uint IntStackSize = 12;
|
||||
|
||||
// XP meter (xpreset/xpmeter/xpduration/xptotal/lumtotal/xpavg/lumavg). Starts on the
|
||||
// first call after login or a reset; luminance counts gains only (spending isn't earning).
|
||||
private long _xpStartMs = -1;
|
||||
private long _xpBase, _lumLast, _lumGained;
|
||||
|
||||
// Functions with no RynthAi data already logged (one line each per session).
|
||||
private readonly HashSet<string> _ubNoDataLogged = new(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>
|
||||
/// The functions above. Returns false for any other name, so the caller's unknown-function
|
||||
/// fallback still logs real typos.
|
||||
/// </summary>
|
||||
private bool TryEvalUbCompat(string funcName, List<string> rawArgs, Func<int, string> A, out string value)
|
||||
{
|
||||
value = funcName switch
|
||||
{
|
||||
// ── Inventory actions (1 = attempted, 0 = busy or not possible) ──────
|
||||
"actiontrymove" => EvalActionTryMove(A(0), A(1), rawArgs.Count > 2 ? A(2) : "0", rawArgs.Count > 3 ? A(3) : "1"),
|
||||
"actiontrysplit" => EvalActionTrySplit(A(0), A(1), rawArgs.Count > 2 ? A(2) : "", rawArgs.Count > 3 ? A(3) : "0"),
|
||||
"actiontrydrop" => NoData("actiontrydrop", "0"),
|
||||
|
||||
// ── Vitals of an object (current values; the selected target or yourself) ──
|
||||
"wobjectgethealthvalue" => EvalWobjectVital(A(0), 0),
|
||||
"wobjectgetstaminavalue" => EvalWobjectVital(A(0), 1),
|
||||
"wobjectgetmanavalue" => EvalWobjectVital(A(0), 2),
|
||||
|
||||
// ── Corpses ──────────────────────────────────────────────────────────
|
||||
"hascorpsebeenopenedbyme" => EvalCorpseOpenedByMe(A(0)),
|
||||
"getcorpsesunopenedbyme" => EvalCorpsesUnopenedByMe(),
|
||||
|
||||
// ── Casting, cooldowns, spell data ───────────────────────────────────
|
||||
"iscasting" => _host.HasGetCastBusyState && _host.GetCastBusyState() != 0 ? "1" : "0",
|
||||
"getcooldownexpiration" => EvalCooldownExpiration(A(0)),
|
||||
"spelldata" => EvalSpellData(A(0)),
|
||||
|
||||
// ── Macro state and delayed expressions ──────────────────────────────
|
||||
"vtmacroenabled" => _settings?.IsMacroRunning == true ? "1" : "0",
|
||||
"clearexec" => EvalClearExec(A(0)),
|
||||
|
||||
// ── Quests (myquests throttle; ACECustom quest bonus lives in RynthILT) ──
|
||||
"canrefreshquests" => EvalCanRefreshQuests(),
|
||||
"testquestbonus" => NoData("testquestbonus", "0"),
|
||||
"isrefreshingquestbonuses" => "0",
|
||||
"enlightenmentmaterials" => EvalEnlightenmentTokens(A(0), A(1)),
|
||||
|
||||
// ── XP meter ─────────────────────────────────────────────────────────
|
||||
"xpreset" => EvalXpReset(),
|
||||
"xpduration" => FormatNumber(XpSeconds()),
|
||||
"xptotal" => FormatNumber(XpTotal()),
|
||||
"lumtotal" => FormatNumber(LumTotal()),
|
||||
"xpavg" => FormatNumber(PerHour(XpTotal())),
|
||||
"lumavg" => FormatNumber(PerHour(LumTotal())),
|
||||
"xpmeter" => EvalXpMeterText(),
|
||||
|
||||
// ── No RynthAi equivalent: ub-IT's "nothing here" values ─────────────
|
||||
"getcharacterindex" => NoData("getcharacterindex", "-1"),
|
||||
"setnextlogin" => NoData("setnextlogin", "0"),
|
||||
"clearnextlogin" => NoData("clearnextlogin", "1"),
|
||||
"netclients" => NoData("netclients", "[]"),
|
||||
"statushud" => NoData("statushud", "1"),
|
||||
"statushudcolored" => NoData("statushudcolored", "1"),
|
||||
// Decal views: none exist here, so no view is found or shown.
|
||||
"uiviewexists" => NoData("uiviewexists", "0"),
|
||||
"uiviewvisible" => NoData("uiviewvisible", "0"),
|
||||
"uisetvisible" => NoData("uisetvisible", "0"),
|
||||
"uisetlabel" => NoData("uisetlabel", "0"),
|
||||
"uigetcontrol" => NoData("uigetcontrol", "0"),
|
||||
_ => null!,
|
||||
};
|
||||
return value != null;
|
||||
}
|
||||
|
||||
/// <summary>The fixed answer of a function RynthAi has no data for; logged once per session.</summary>
|
||||
private string NoData(string funcName, string result)
|
||||
{
|
||||
if (_ubNoDataLogged.Add(funcName))
|
||||
_host.Log($"[RynthAi] Expression {funcName}[]: ub-IT feature with no RynthAi equivalent; returns {result}.");
|
||||
return result;
|
||||
}
|
||||
|
||||
// ── Inventory actions ────────────────────────────────────────────────────
|
||||
|
||||
private bool IsBusy() => _host.HasGetBusyState && _host.GetBusyState() > 0;
|
||||
|
||||
private int StackSizeOf(uint id)
|
||||
{
|
||||
if (_worldObjectCache != null)
|
||||
{
|
||||
int n = _worldObjectCache.GetIntProperty(unchecked((int)id), IntStackSize, 0);
|
||||
if (n > 0) return n;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// <summary>actiontrymove[obj, container, slot=0, addToStack=1]: into a stack of the same
|
||||
/// name in that container when there is one (and addToStack), else into the slot.</summary>
|
||||
private string EvalActionTryMove(string objArg, string destArg, string slotArg, string stackArg)
|
||||
{
|
||||
if (!TryParseWobjectHandle(objArg, out uint id, out _) || id == 0) return "0";
|
||||
if (!TryParseWobjectHandle(destArg, out uint dest, out _) || dest == 0) return "0";
|
||||
if (IsBusy()) return "0";
|
||||
|
||||
if (ToBool(stackArg) && _worldObjectCache != null && _host.HasMergeStackInternal)
|
||||
{
|
||||
string name = _worldObjectCache[unchecked((int)id)]?.Name ?? "";
|
||||
foreach (var wo in _worldObjectCache.GetContainedItems(unchecked((int)dest)))
|
||||
{
|
||||
if (unchecked((uint)wo.Id) == id || !string.Equals(wo.Name, name, StringComparison.Ordinal)) continue;
|
||||
if (StackSizeOf(unchecked((uint)wo.Id)) <= 1 && StackSizeOf(id) <= 1) continue;
|
||||
return _host.MergeStackInternal(id, unchecked((uint)wo.Id)) ? "1" : "0";
|
||||
}
|
||||
}
|
||||
|
||||
if (!_host.HasMoveItemInternal) return "0";
|
||||
int slot = (int)Math.Max(0, ToDouble(slotArg));
|
||||
return _host.MoveItemInternal(id, dest, slot, StackSizeOf(id)) ? "1" : "0";
|
||||
}
|
||||
|
||||
/// <summary>actiontrysplit[obj, newStackSize, container=player, slot=0]: splits newStackSize off the stack.</summary>
|
||||
private string EvalActionTrySplit(string objArg, string countArg, string destArg, string slotArg)
|
||||
{
|
||||
if (!TryParseWobjectHandle(objArg, out uint id, out _) || id == 0) return "0";
|
||||
int count = (int)ToDouble(countArg);
|
||||
if (count < 1 || count >= StackSizeOf(id)) return "0";
|
||||
uint dest = TryParseWobjectHandle(destArg, out uint d, out _) && d != 0 ? d : _playerId;
|
||||
if (dest == 0 || IsBusy() || !_host.HasSplitStackInternal) return "0";
|
||||
int slot = (int)Math.Max(0, ToDouble(slotArg));
|
||||
return _host.SplitStackInternal(id, dest, slot, count) ? "1" : "0";
|
||||
}
|
||||
|
||||
// ── Vitals ───────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Current health (0), stamina (1) or mana (2) of the object; -1 when unknown. The
|
||||
/// game reports these for yourself and for the target you've selected (as ub-IT notes).</summary>
|
||||
private string EvalWobjectVital(string objArg, int which)
|
||||
{
|
||||
if (!TryParseWobjectHandle(objArg, out uint id, out _) || id == 0) return "-1";
|
||||
uint hp, st, mp;
|
||||
if (id == _playerId)
|
||||
{
|
||||
if (!_host.TryGetPlayerVitals(out hp, out _, out st, out _, out mp, out _)) return "-1";
|
||||
}
|
||||
else if (!_host.TryGetTargetVitals(id, out hp, out _, out st, out _, out mp, out _))
|
||||
{
|
||||
return "-1";
|
||||
}
|
||||
uint v = which switch { 0 => hp, 1 => st, _ => mp };
|
||||
return v.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
// ── Corpses ──────────────────────────────────────────────────────────────
|
||||
|
||||
private string EvalCorpseOpenedByMe(string objArg)
|
||||
{
|
||||
if (!TryParseWobjectHandle(objArg, out uint id, out _) || id == 0) return "0";
|
||||
return CorpseOpenedByMe?.Invoke(unchecked((int)id)) == true ? "1" : "0";
|
||||
}
|
||||
|
||||
/// <summary>Corpses in view this character hasn't opened, as a list of objects.</summary>
|
||||
private string EvalCorpsesUnopenedByMe()
|
||||
{
|
||||
if (_worldObjectCache == null) return "[]";
|
||||
var items = new List<string>();
|
||||
var seen = new HashSet<int>();
|
||||
foreach (var wo in _worldObjectCache.GetLandscape())
|
||||
{
|
||||
if (wo.ObjectClass != AcObjectClass.Corpse || !seen.Add(wo.Id)) continue;
|
||||
if (CorpseOpenedByMe?.Invoke(wo.Id) == true) continue;
|
||||
items.Add(MakeWobjectHandle(unchecked((uint)wo.Id), wo.Name));
|
||||
}
|
||||
return NewList(items);
|
||||
}
|
||||
|
||||
// ── Casting, cooldowns, spell data ───────────────────────────────────────
|
||||
|
||||
/// <summary>Seconds until shared cooldown <paramref name="idArg"/> ends; 0 when it isn't running.</summary>
|
||||
private string EvalCooldownExpiration(string idArg)
|
||||
{
|
||||
int want = (int)ToDouble(idArg);
|
||||
if (want <= 0 || !_host.HasReadPlayerEnchantments || !_host.HasGetServerTime) return "0";
|
||||
double now = _host.GetServerTime();
|
||||
if (now <= 0) return "0";
|
||||
const int Max = 512;
|
||||
uint[] ids = new uint[Max];
|
||||
double[] expiry = new double[Max];
|
||||
int count = _host.ReadPlayerEnchantments(ids, expiry, Max);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if ((ids[i] & CooldownSpellFlag) == 0 || (ids[i] & 0xFFF) != want) continue;
|
||||
double left = expiry[i] - now;
|
||||
return left > 0 ? ((int)Math.Ceiling(left)).ToString(CultureInfo.InvariantCulture) : "0";
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
|
||||
/// <summary>spelldata[id]: a dictionary of what RynthAi's spell table knows (Id, Name, Family,
|
||||
/// Difficulty, Category, Power, Level). Empty for an unknown spell, as in ub-IT.</summary>
|
||||
private string EvalSpellData(string idArg)
|
||||
{
|
||||
int id = (int)ToDouble(idArg);
|
||||
var d = new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
if (id > 0 && SpellDatabase.HasSpell(id))
|
||||
{
|
||||
d["Id"] = id.ToString(CultureInfo.InvariantCulture);
|
||||
d["Name"] = SpellDatabase.GetSpellName(id);
|
||||
if (SpellDatabase.TryGetSpellMeta(id, out int family, out int difficulty))
|
||||
{
|
||||
d["Family"] = family.ToString(CultureInfo.InvariantCulture);
|
||||
d["Difficulty"] = difficulty.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
if (SpellDatabase.TryGetCategoryAndPower(id, out int category, out int power))
|
||||
{
|
||||
d["Category"] = category.ToString(CultureInfo.InvariantCulture);
|
||||
d["Power"] = power.ToString(CultureInfo.InvariantCulture);
|
||||
d["Level"] = SpellDatabase.LevelFromPower(power).ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
return NewDict(d);
|
||||
}
|
||||
|
||||
// ── Delayed expressions ──────────────────────────────────────────────────
|
||||
|
||||
/// <summary>clearexec[id]: cancels the delayexec that returned that id. 1 if one was pending.</summary>
|
||||
private string EvalClearExec(string idArg)
|
||||
{
|
||||
long id = (long)ToDouble(idArg);
|
||||
int removed = _delayedExecs.RemoveAll(e => e.Id == id);
|
||||
return removed > 0 ? "1" : "0";
|
||||
}
|
||||
|
||||
// ── Quests ───────────────────────────────────────────────────────────────
|
||||
|
||||
private string EvalCanRefreshQuests()
|
||||
{
|
||||
if (_questTracker == null) return "1";
|
||||
if (_questTracker.IsRefreshing) return "0";
|
||||
return (DateTime.UtcNow - _questTracker.LastRefreshUtc).TotalSeconds >= QuestRefreshCooldownSeconds ? "1" : "0";
|
||||
}
|
||||
|
||||
/// <summary>enlightenmentmaterials[current, target]: ub-IT's token count. Levels 6-150 cost
|
||||
/// (level - 5) tokens each; levels 1-5 cost none and later levels cost other items.</summary>
|
||||
private static string EvalEnlightenmentTokens(string curArg, string tgtArg)
|
||||
{
|
||||
int cur = (int)ToDouble(curArg), tgt = (int)ToDouble(tgtArg);
|
||||
long tokens = 0;
|
||||
for (int level = Math.Max(cur + 1, 6); level <= Math.Min(tgt, 150); level++)
|
||||
tokens += level - 5;
|
||||
return tokens.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
// ── XP meter ─────────────────────────────────────────────────────────────
|
||||
|
||||
private long ReadQuad(uint stype)
|
||||
=> _playerId != 0 && _host.HasGetObjectQuadProperty && _host.TryGetObjectQuadProperty(_playerId, stype, out long v) ? v : 0;
|
||||
|
||||
/// <summary>Starts the meter on first use and folds in luminance gained since the last look.</summary>
|
||||
private void SampleXpMeter()
|
||||
{
|
||||
long lum = ReadQuad(QuadAvailableLuminance);
|
||||
if (_xpStartMs < 0)
|
||||
{
|
||||
_xpStartMs = TickMs();
|
||||
_xpBase = ReadQuad(QuadTotalExperience);
|
||||
_lumLast = lum;
|
||||
_lumGained = 0;
|
||||
return;
|
||||
}
|
||||
if (lum > _lumLast) _lumGained += lum - _lumLast;
|
||||
_lumLast = lum;
|
||||
}
|
||||
|
||||
/// <summary>Forgets the meter when the character changes (called from SetPlayerId).</summary>
|
||||
private void ResetXpMeter() => _xpStartMs = -1;
|
||||
|
||||
private string EvalXpReset()
|
||||
{
|
||||
ResetXpMeter();
|
||||
SampleXpMeter();
|
||||
return "1";
|
||||
}
|
||||
|
||||
private double XpSeconds()
|
||||
{
|
||||
SampleXpMeter();
|
||||
return Math.Max(0, (TickMs() - _xpStartMs) / 1000.0);
|
||||
}
|
||||
|
||||
private double XpTotal()
|
||||
{
|
||||
SampleXpMeter();
|
||||
return Math.Max(0, ReadQuad(QuadTotalExperience) - _xpBase);
|
||||
}
|
||||
|
||||
private double LumTotal()
|
||||
{
|
||||
SampleXpMeter();
|
||||
return _lumGained;
|
||||
}
|
||||
|
||||
private double PerHour(double amount)
|
||||
{
|
||||
double s = XpSeconds();
|
||||
return s <= 0 ? 0 : amount / s * 3600;
|
||||
}
|
||||
|
||||
/// <summary>ub-IT's meter text: "500m XP and 2k LUM, 51s, 35.39b XP/hr and 140k LUM/hr".</summary>
|
||||
private string EvalXpMeterText()
|
||||
{
|
||||
double xp = XpTotal(), lum = LumTotal(), s = XpSeconds();
|
||||
string head = lum > 0 ? $"{ShortNumber(xp)} XP and {ShortNumber(lum)} LUM" : $"{ShortNumber(xp)} XP";
|
||||
string rate = lum > 0 ? $"{ShortNumber(PerHour(xp))} XP/hr and {ShortNumber(PerHour(lum))} LUM/hr" : $"{ShortNumber(PerHour(xp))} XP/hr";
|
||||
return $"{head}, {ShortDuration(s)}, {rate}";
|
||||
}
|
||||
|
||||
private static string FormatNumber(double v) => Math.Round(v, 2).ToString("0.##", CultureInfo.InvariantCulture);
|
||||
|
||||
/// <summary>1234 -> 1.23k, 5.6e8 -> 560m, as ub-IT's formatExperience.</summary>
|
||||
private static string ShortNumber(double v)
|
||||
{
|
||||
string[] units = { "", "k", "m", "b", "t", "q" };
|
||||
int u = 0;
|
||||
while (Math.Abs(v) >= 1000 && u < units.Length - 1) { v /= 1000; u++; }
|
||||
return (u == 0 ? Math.Round(v).ToString("0", CultureInfo.InvariantCulture)
|
||||
: v.ToString("0.##", CultureInfo.InvariantCulture)) + units[u];
|
||||
}
|
||||
|
||||
private static string ShortDuration(double seconds)
|
||||
{
|
||||
var t = TimeSpan.FromSeconds(Math.Max(0, seconds));
|
||||
if (t.TotalHours >= 1) return $"{(int)t.TotalHours}h {t.Minutes}m";
|
||||
if (t.TotalMinutes >= 1) return $"{t.Minutes}m {t.Seconds}s";
|
||||
return $"{t.Seconds}s";
|
||||
}
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ namespace RynthCore.Plugin.RynthAi.Meta;
|
|||
/// Lists are text ("[a,b]"); the list functions that change a list write it back to the
|
||||
/// variable it came from. Dictionaries and stopwatches are handles ("D:0", "SW:0").
|
||||
/// </summary>
|
||||
internal sealed class ExpressionEngine
|
||||
internal sealed partial class ExpressionEngine
|
||||
{
|
||||
private readonly RynthCoreHost _host;
|
||||
private WorldObjectCache? _worldObjectCache;
|
||||
|
|
@ -71,7 +71,7 @@ internal sealed class ExpressionEngine
|
|||
if (_pvars != null) foreach (string v in _pvars.Values) Scan(v);
|
||||
if (_gvars != null) foreach (string v in _gvars.Values) Scan(v);
|
||||
foreach (string v in _options.Values) Scan(v);
|
||||
foreach (var (_, expr) in _delayedExecs) Scan(expr);
|
||||
foreach (var (_, _, expr) in _delayedExecs) Scan(expr);
|
||||
while (todo.Count > 0)
|
||||
foreach (var (k, v) in _dicts[todo.Dequeue()]) { Scan(k); Scan(v); }
|
||||
|
||||
|
|
@ -133,7 +133,8 @@ internal sealed class ExpressionEngine
|
|||
// hot-reload to fire into a freed engine). Instance-scoped so a hot-reload
|
||||
// discards pending execs. Single-threaded access (Evaluate and the pump
|
||||
// both run on the plugin-tick thread) → no lock needed.
|
||||
private readonly List<(long DueMs, string Expr)> _delayedExecs = new();
|
||||
private readonly List<(long Id, long DueMs, string Expr)> _delayedExecs = new();
|
||||
private long _nextDelayedExecId;
|
||||
|
||||
private uint _playerId;
|
||||
private LegacyUiSettings? _settings;
|
||||
|
|
@ -187,6 +188,7 @@ internal sealed class ExpressionEngine
|
|||
FlushVars(force: true); // persist the old char's pending pvars first
|
||||
_pvars = null;
|
||||
_pvarPathCached = null;
|
||||
ResetXpMeter();
|
||||
}
|
||||
_playerId = id;
|
||||
}
|
||||
|
|
@ -557,8 +559,12 @@ internal sealed class ExpressionEngine
|
|||
// UB vtgetmeta[]: the loaded meta's name (file name without extension).
|
||||
"vtgetmeta" or "ragetmeta" => string.IsNullOrEmpty(_settings?.CurrentMetaPath)
|
||||
? "" : Path.GetFileNameWithoutExtension(_settings!.CurrentMetaPath),
|
||||
"rasetsetting" or "vtsetsetting" => EvalVtSetSetting(Text(0), A(1)),
|
||||
"ragetsetting" or "vtgetsetting" or "vtankgetsetting" => EvalVtGetSetting(Text(0)),
|
||||
// vt*: VTank option names and units (landblock distances), the same as '/vt opt set|get';
|
||||
// ra*: RynthAi's own setting names, as they are.
|
||||
"vtsetsetting" => VtOptionSetter != null && Text(0).Length > 0 ? (VtOptionSetter(Text(0), A(1)) ? "1" : "0") : EvalVtSetSetting(Text(0), A(1)),
|
||||
"vtgetsetting" or "vtankgetsetting" => VtOptionGetter != null && Text(0).Length > 0 ? VtOptionGetter(Text(0)) ?? "" : EvalVtGetSetting(Text(0)),
|
||||
"rasetsetting" => EvalVtSetSetting(Text(0), A(1)),
|
||||
"ragetsetting" => EvalVtGetSetting(Text(0)),
|
||||
|
||||
// ── Dynamic evaluation ────────────────────────────────────────────
|
||||
"exec" => Evaluate(A(0)),
|
||||
|
|
@ -583,7 +589,8 @@ internal sealed class ExpressionEngine
|
|||
// "Strings support slices like arrays. ie test[1:]": a word that isn't a function,
|
||||
// followed by [start:stop].
|
||||
_ when TopLevelColon(argsStr) >= 0 => SliceBy(expr.Substring(0, lb).Trim(), argsStr),
|
||||
_ => EvalUnknownFunction(funcName)
|
||||
// ub-IT's remaining functions (ExpressionEngine.UbCompat.cs), then a real unknown.
|
||||
_ => TryEvalUbCompat(funcName, rawArgs, A, out string ubValue) ? ubValue : EvalUnknownFunction(funcName)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -3049,7 +3056,7 @@ internal sealed class ExpressionEngine
|
|||
|
||||
DateTime mtime = File.GetLastWriteTime(profilePath);
|
||||
|
||||
// Each pulse: fire MoveItemExternal for the first matching item still in inventory.
|
||||
// Each pulse: give (whole object) the first matching item still in inventory.
|
||||
// We retry the same item until it vanishes from the cache (server confirmed).
|
||||
// Once gone, the next iteration naturally picks up the next item.
|
||||
// Returns 1 while matching items remain, 0 when inventory is clear.
|
||||
|
|
@ -3629,6 +3636,17 @@ internal sealed class ExpressionEngine
|
|||
["CastDispelSelf"] = (() => B(s.CastDispelSelf), v => s.CastDispelSelf = ToDouble(v) != 0),
|
||||
["AutoFellowMgmt"] = (() => B(s.AutoFellowMgmt), v => s.AutoFellowMgmt = ToDouble(v) != 0),
|
||||
["UseRecklessness"] = (() => B(s.UseRecklessness), v => s.UseRecklessness = ToDouble(v) != 0),
|
||||
// The range a monster rule's Variable attack power picks from (percent of the bar).
|
||||
["VariablePowerMin"] = (() => I(s.VariablePowerMin), v => { if (int.TryParse(v, out int i)) s.VariablePowerMin = Math.Clamp(i, 0, 100); }),
|
||||
["VariablePowerMax"] = (() => I(s.VariablePowerMax), v => { if (int.TryParse(v, out int i)) s.VariablePowerMax = Math.Clamp(i, 0, 100); }),
|
||||
// Environment hits: 0 Off, 1 Move closer, 2 New target, 3 Move closer then new target.
|
||||
["MissileEnvironmentResponse"] = (() => I(s.MissileEnvironmentResponse), v => { if (int.TryParse(v, out int i)) s.MissileEnvironmentResponse = Math.Clamp(i, 0, 3); }),
|
||||
["MagicEnvironmentResponse"] = (() => I(s.MagicEnvironmentResponse), v => { if (int.TryParse(v, out int i)) s.MagicEnvironmentResponse = Math.Clamp(i, 0, 3); }),
|
||||
["EnvironmentImpactLimit"] = (() => I(s.EnvironmentImpactLimit), v => { if (int.TryParse(v, out int i)) s.EnvironmentImpactLimit = Math.Clamp(i, 1, 10); }),
|
||||
["EnvironmentImpactWindowSec"] = (() => I(s.EnvironmentImpactWindowSec), v => { if (int.TryParse(v, out int i)) s.EnvironmentImpactWindowSec = Math.Clamp(i, 5, 120); }),
|
||||
["EnvironmentApproachMeters"] = (() => I(s.EnvironmentApproachMeters), v => { if (int.TryParse(v, out int i)) s.EnvironmentApproachMeters = Math.Clamp(i, 1, 30); }),
|
||||
["EnvironmentMinDistance"] = (() => I(s.EnvironmentMinDistance), v => { if (int.TryParse(v, out int i)) s.EnvironmentMinDistance = Math.Clamp(i, 1, 30); }),
|
||||
["EnvironmentSkipSec"] = (() => I(s.EnvironmentSkipSec), v => { if (int.TryParse(v, out int i)) s.EnvironmentSkipSec = Math.Clamp(i, 5, 300); }),
|
||||
["WeaponSwapSettleMs"] = (() => I(s.WeaponSwapSettleMs), v => { if (int.TryParse(v, out int i)) s.WeaponSwapSettleMs = Math.Clamp(i, 0, 3000); }),
|
||||
["WeaponSwapMinHealthPct"] = (() => I(s.WeaponSwapMinHealthPct), v => { if (int.TryParse(v, out int i)) s.WeaponSwapMinHealthPct = Math.Clamp(i, 0, 100); }),
|
||||
["WeaponSwapMinGainPct"] = (() => I(s.WeaponSwapMinGainPct), v => { if (int.TryParse(v, out int i)) s.WeaponSwapMinGainPct = Math.Clamp(i, 0, 200); }),
|
||||
|
|
@ -3665,6 +3683,7 @@ internal sealed class ExpressionEngine
|
|||
["CorpseApproachRangeMin"] = (() => D(s.CorpseApproachRangeMin), v => { if (double.TryParse(v, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double d)) s.CorpseApproachRangeMin = d; }),
|
||||
["ManaStoneKeepCount"] = (() => I(s.ManaStoneKeepCount), v => { if (int.TryParse(v, out int i)) s.ManaStoneKeepCount = i; }),
|
||||
["RebuffSecondsRemaining"] = (() => I(s.RebuffSecondsRemaining), v => { if (int.TryParse(v, out int i)) s.RebuffSecondsRemaining = i; }),
|
||||
["BlacklistTimeoutSec"] = (() => I(s.BlacklistTimeoutSec), v => { if (double.TryParse(v, NumberStyles.Float, CultureInfo.InvariantCulture, out double d) && d >= 0) s.BlacklistTimeoutSec = (int)Math.Round(d); }),
|
||||
["RebuffTopOffSecondsRemaining"] = (() => I(s.RebuffTopOffSecondsRemaining), v => { if (int.TryParse(v, out int i)) s.RebuffTopOffSecondsRemaining = i; }),
|
||||
["CastBuffsOverItemBuffs"] = (() => B(s.CastBuffsOverItemBuffs), v => s.CastBuffsOverItemBuffs = ToDouble(v) != 0),
|
||||
["FastBuffChain"] = (() => B(s.FastBuffChain), v => s.FastBuffChain = ToDouble(v) != 0),
|
||||
|
|
@ -3722,8 +3741,10 @@ internal sealed class ExpressionEngine
|
|||
CultureInfo.InvariantCulture, out double delayMs))
|
||||
delayMs = 0;
|
||||
long ms = (long)Math.Max(0, delayMs);
|
||||
_delayedExecs.Add((TickMs() + ms, exprArg));
|
||||
return "1";
|
||||
// ub-IT returns the job's id (for clearexec); ids start at 1 so the result stays true.
|
||||
long id = ++_nextDelayedExecId;
|
||||
_delayedExecs.Add((id, TickMs() + ms, exprArg));
|
||||
return id.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1608,7 +1608,9 @@ ITEM GIVING
|
|||
|
||||
actiontrygiveprofile[lootprofile, target]
|
||||
Gives all inventory items matching Keep rules in the specified loot profile to a
|
||||
nearby player or NPC named target.
|
||||
nearby NPC or vendor named target, with AC's give action. Never to a player: a
|
||||
shared meta must not be able to hand your inventory to someone's character.
|
||||
To give to a player, type /ra ig <profile> to <player>.
|
||||
|
||||
Supports both VTank .utl profiles and native RynthAi .json profiles.
|
||||
Profile files are loaded from:
|
||||
|
|
@ -1620,10 +1622,13 @@ actiontrygiveprofile[lootprofile, target]
|
|||
the target was not found in the nearby world, no items matched, or the profile
|
||||
could not be loaded.
|
||||
|
||||
Param #0: lootprofile — filename (or full path) of the loot profile (.utl or .json).
|
||||
Param #0: lootprofile — filename of the loot profile (.utl or .json), inside ItemGiver\
|
||||
(a subfolder of it is fine). Full paths, drive letters, ':' and anything
|
||||
that climbs out with ..\ are refused (logged once, returns "0").
|
||||
Bare names without extension resolve as .utl from ItemGiver\.
|
||||
Regex-escaped dots in UB examples (e.g. salvage\.utl) are just literal dots.
|
||||
Param #1: target — exact name (case-insensitive) of the player or NPC to give to.
|
||||
Param #1: target — exact name (case-insensitive) of the NPC or vendor to give to.
|
||||
A player with that name is skipped.
|
||||
|
||||
Known limitations (TODO):
|
||||
- Currently gives one item per meta pulse. Full rapid-fire batch transfer not yet
|
||||
|
|
@ -1632,10 +1637,10 @@ actiontrygiveprofile[lootprofile, target]
|
|||
all item types correctly (e.g. salvage ObjectClass known issue).
|
||||
- Only .utl and .json profiles are supported; no fallback between profile directories.
|
||||
|
||||
Test in chat: /ra mexec actiontrygiveprofile[salvage.utl,My Salvage Mule]
|
||||
Example: actiontrygiveprofile[salvage.utl,My Salvage Mule]
|
||||
Test in chat: /ra mexec actiontrygiveprofile[salvage.utl,Town Crier]
|
||||
Example: actiontrygiveprofile[salvage.utl,Town Crier]
|
||||
→ "1" if items were given (VTank profile)
|
||||
Example: actiontrygiveprofile[mysalvage.json,My Salvage Mule]
|
||||
Example: actiontrygiveprofile[mysalvage.json,Town Crier]
|
||||
→ "1" if items were given (native JSON profile)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -179,6 +179,15 @@ internal sealed class MetaManager
|
|||
_expressions?.SetKillClock(clock);
|
||||
}
|
||||
|
||||
// Corpses this character opened (the plugin's loot bookkeeping), for ub-IT's
|
||||
// hascorpsebeenopenedbyme[] / getcorpsesunopenedbyme[].
|
||||
private Func<int, bool>? _corpseOpenedByMe;
|
||||
public void SetCorpseOpenedCheck(Func<int, bool>? check)
|
||||
{
|
||||
_corpseOpenedByMe = check;
|
||||
if (_expressions != null) _expressions.CorpseOpenedByMe = check;
|
||||
}
|
||||
|
||||
public void SetPlayerId(uint id)
|
||||
{
|
||||
_playerId = id;
|
||||
|
|
@ -231,6 +240,10 @@ internal sealed class MetaManager
|
|||
engine.SetSettings(_settings);
|
||||
engine.SetCreatureStore(_creatureStore);
|
||||
engine.SetKillClock(_killClock);
|
||||
engine.CorpseOpenedByMe = _corpseOpenedByMe;
|
||||
// vtsetsetting[] / vtgetsetting[] take VTank names and units, as '/vt opt set|get' does.
|
||||
engine.VtOptionSetter = TrySetVtOption;
|
||||
engine.VtOptionGetter = GetVtOption;
|
||||
return engine;
|
||||
}
|
||||
|
||||
|
|
@ -1171,6 +1184,39 @@ internal sealed class MetaManager
|
|||
return true;
|
||||
}
|
||||
|
||||
// /vt e — VTank's macro toggle (ub-IT sends it to switch VTank on or off).
|
||||
if (sub == "e")
|
||||
{
|
||||
_raCommandHandler?.Invoke(_settings.IsMacroRunning ? "/ra stop" : "/ra start");
|
||||
return true;
|
||||
}
|
||||
|
||||
// /vt jump [heading] [shift true|false] [holdms] — VTank's jump (universalremote.met, ub-IT):
|
||||
// RynthAi's jumper through /ra jump[s] [heading] [holdtime].
|
||||
if (sub == "jump")
|
||||
{
|
||||
string heading = parts.Length >= 3 ? parts[2] : "";
|
||||
bool shift = parts.Length >= 4 && (parts[3].Equals("true", StringComparison.OrdinalIgnoreCase) || parts[3] == "1");
|
||||
string hold = parts.Length >= 5 ? parts[4] : "";
|
||||
_raCommandHandler?.Invoke(("/ra jump" + (shift ? "s" : "") + " " + heading + " " + hold).Trim());
|
||||
return true;
|
||||
}
|
||||
|
||||
// /vt tapjump — a quick jump with no charge.
|
||||
if (sub == "tapjump")
|
||||
{
|
||||
if (!(_host.HasTapJump && _host.TapJump()))
|
||||
_host.WriteToChat("[RynthAi] /vt tapjump: the engine's jump isn't available.", 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
// /vt equipitemsfor <monster> — wield what that monster's rule names (weapon, off hand).
|
||||
if (sub == "equipitemsfor" && parts.Length >= 3)
|
||||
{
|
||||
_raCommandHandler?.Invoke("/ra equipfor " + string.Join(" ", parts, 2, parts.Length - 2));
|
||||
return true;
|
||||
}
|
||||
|
||||
// /vt meta load <name> — the same load as /ra meta load (LegacyDashboardRenderer.LoadMetaByName):
|
||||
// a meta in MetaFiles, or, when there is none by that name, a new blank one (2026-10-13).
|
||||
if (sub == "meta" && parts.Length >= 4 &&
|
||||
|
|
@ -1193,8 +1239,8 @@ internal sealed class MetaManager
|
|||
return true;
|
||||
}
|
||||
|
||||
// /vt loot load <name> — load a loot profile
|
||||
if ((sub == "loot" || sub == "lootprofile") && parts.Length >= 4 &&
|
||||
// /vt loot load <name> — load a loot profile ("looting load" too: FoundryIzexi.met, Meta_Society.met)
|
||||
if ((sub == "loot" || sub == "lootprofile" || sub == "looting") && parts.Length >= 4 &&
|
||||
parts[2].Equals("load", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
string name = string.Join(" ", parts, 3, parts.Length - 3).Trim().Trim('"');
|
||||
|
|
@ -1231,8 +1277,20 @@ internal sealed class MetaManager
|
|||
return true;
|
||||
}
|
||||
|
||||
// /vt settings load / loadchar — ignore silently
|
||||
if (sub == "settings") return true;
|
||||
// /vt settings loadchar|savechar <name> — RynthAi's settings profiles (/ra settings ...);
|
||||
// universalremote.met switches profiles this way. Any other /vt settings verb is ignored.
|
||||
if (sub == "settings")
|
||||
{
|
||||
if (parts.Length >= 4 && (parts[2].Equals("loadchar", StringComparison.OrdinalIgnoreCase)
|
||||
|| parts[2].Equals("savechar", StringComparison.OrdinalIgnoreCase)))
|
||||
_raCommandHandler?.Invoke($"/ra settings {parts[2].ToLowerInvariant()} {string.Join(" ", parts, 3, parts.Length - 3)}");
|
||||
return true;
|
||||
}
|
||||
|
||||
// /vt <option> <value> — an option written as a verb (DerethExploration: "/vt navclosestoprange
|
||||
// 0.005"): the same as /vt opt set, for the VTank options RynthAi maps.
|
||||
if (parts.Length == 3 && (VtOptionMap.ContainsKey(sub) || IsSpecialVtOption(sub)))
|
||||
return TrySetVtOption(sub, parts[2]);
|
||||
|
||||
// /vt <verb> aliases → existing /ra handlers (Phase 1.3 VTank-meta migration).
|
||||
// Re-dispatch through the /ra path (_raCommandHandler → HandleRaCommand).
|
||||
|
|
@ -1249,10 +1307,23 @@ internal sealed class MetaManager
|
|||
System.Globalization.CultureInfo.InvariantCulture, out double bar))
|
||||
{
|
||||
int pct = Math.Clamp((int)Math.Round(bar * 100), 0, 100);
|
||||
_lastAttackBarPct = pct;
|
||||
_raCommandHandler?.Invoke("/ra power " + pct.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
return true;
|
||||
}
|
||||
|
||||
// /vt deletemonster (S_Colo, leaving the arena): no RynthAi equivalent is known. Accepted so
|
||||
// it doesn't go on to AC's chat parser as an unknown command; logged once.
|
||||
if (sub == "deletemonster")
|
||||
{
|
||||
if (!_deleteMonsterLogged)
|
||||
{
|
||||
_deleteMonsterLogged = true;
|
||||
RynthLog.Write(LogCat.Meta, "[Meta] /vt deletemonster accepted and ignored (no RynthAi equivalent).");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// /vt reverseroute — reverse the active nav route in place (shared settings;
|
||||
// the engine re-reads CurrentRoute each tick, so the flip takes effect next tick).
|
||||
if (sub == "reverseroute")
|
||||
|
|
@ -1351,15 +1422,143 @@ internal sealed class MetaManager
|
|||
// converts it into FollowNavMin, the nav point reach (see ExpressionEngine).
|
||||
["navclosestoprange"] = "NavCloseStopRange",
|
||||
["follownavmin"] = "FollowNavMin", // RynthAi's own name, yards
|
||||
// 2026-10-17: options the metas in MetaFiles / MetaProfiles set that had no mapping.
|
||||
["navclosetoprange"] = "NavCloseStopRange", // the same option, misspelt in some metas
|
||||
["attackrange"] = "MonsterRange",
|
||||
["ringdistance"] = "RingRange",
|
||||
["minimumringtargets"] = "MinRingTargets",
|
||||
["corpseapproachrange"] = "CorpseApproachRangeMax",
|
||||
["corpseapproachrange-max"] = "CorpseApproachRangeMax",
|
||||
["corpseapproachrange-min"] = "CorpseApproachRangeMin",
|
||||
// 2026-10-18: the sample metas (S_*, Colo) set these and nothing read them.
|
||||
["rebufftimeremainingseconds"] = "RebuffSecondsRemaining", // VTank's spelling (the one above is a typo)
|
||||
["petcustomrange"] = "CustomPetRange", // landblock units -> whole yards
|
||||
["blacklistmonstertimeoutseconds"] = "BlacklistTimeoutSec",
|
||||
};
|
||||
|
||||
/// <summary>VTank options given in landblock units (x240 = yards) whose RynthAi setting is yards.
|
||||
/// NavCloseStopRange converts itself (the settings map takes landblock units).</summary>
|
||||
private static readonly HashSet<string> VtDistanceOptions = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
"attackdistance", "attackrange", "approachdistance", "dooropenrange", "opendoorrange", "ringdistance",
|
||||
"corpseapproachrange", "corpseapproachrange-max", "corpseapproachrange-min", "petcustomrange",
|
||||
};
|
||||
|
||||
/// <summary>RynthAi distance settings kept in whole yards (their setter refuses a decimal).</summary>
|
||||
private static readonly HashSet<string> IntYardSettings = new(StringComparer.Ordinal)
|
||||
{
|
||||
"MonsterRange", "ApproachRange", "RingRange", "CustomPetRange",
|
||||
};
|
||||
|
||||
/// <summary>A RynthAi yards value as VTank's landblock units (yards / 240), for reading a distance back.</summary>
|
||||
internal static string YardsToVtDistance(string yards)
|
||||
{
|
||||
if (!double.TryParse(yards, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out double v))
|
||||
return yards;
|
||||
return (v / 240.0).ToString("0.######", System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A VTank distance as RynthAi yards: a value up to 1 is landblock units (x240; VTank's own
|
||||
/// unit), a larger one is taken as yards already (typed by hand). Invariant culture.
|
||||
/// </summary>
|
||||
internal static string VtDistanceToYards(string value, bool wholeYards)
|
||||
{
|
||||
if (!double.TryParse(value, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out double v))
|
||||
return value; // not a number (an unexpanded expression): left for the setter to refuse
|
||||
double yards = v > 0 && v <= 1.0 ? v * 240.0 : v;
|
||||
return wholeYards
|
||||
? Math.Max(0, (int)Math.Round(yards)).ToString(System.Globalization.CultureInfo.InvariantCulture)
|
||||
: yards.ToString("0.###", System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
/// <summary>VTank options handled by <see cref="TrySetSpecialVtOption"/> (no 1:1 RynthAi setting).</summary>
|
||||
private static bool IsSpecialVtOption(string vtName) => vtName.ToLowerInvariant() is
|
||||
"defaultmeleeattackheight" or "lootfellowcorpses" or "lootallcorpses" or "usearcs" or "minimumhealkitsuccesschance"
|
||||
or "autoattackpower";
|
||||
|
||||
// The last /vt setattackbar power (percent), for AutoAttackPower false after it was on (-1 = none yet).
|
||||
private int _lastAttackBarPct = -1;
|
||||
private bool _deleteMonsterLogged;
|
||||
|
||||
/// <summary>
|
||||
/// The VTank options whose value means something else in RynthAi:
|
||||
/// DefaultMeleeAttackHeight 1-3 (low/medium/high) is RynthAi's 0-2; LootFellowCorpses /
|
||||
/// LootAllCorpses pick the loot-ownership mode (my kills / fellowship / all); UseArcs is a VTank
|
||||
/// mode number (2, 3 in the metas) for RynthAi's on/off; MinimumHealKitSuccessChance is a
|
||||
/// percent (a fraction up to 1 is scaled). False when <paramref name="vtName"/> isn't one of them.
|
||||
/// </summary>
|
||||
private bool TrySetSpecialVtOption(string vtName, string value)
|
||||
{
|
||||
var inv = System.Globalization.CultureInfo.InvariantCulture;
|
||||
bool num = double.TryParse(value, System.Globalization.NumberStyles.Float, inv, out double n);
|
||||
switch (vtName.ToLowerInvariant())
|
||||
{
|
||||
case "defaultmeleeattackheight":
|
||||
if (!num) return true;
|
||||
_settings.MeleeAttackHeight = Math.Clamp((int)Math.Round(n) - 1, 0, 2);
|
||||
return true;
|
||||
case "lootfellowcorpses":
|
||||
if (!num) return true;
|
||||
if (n != 0 && _settings.LootOwnership < 1) _settings.LootOwnership = 1;
|
||||
else if (n == 0 && _settings.LootOwnership == 1) _settings.LootOwnership = 0;
|
||||
return true;
|
||||
case "lootallcorpses":
|
||||
if (!num) return true;
|
||||
if (n != 0) _settings.LootOwnership = 2;
|
||||
else if (_settings.LootOwnership == 2) _settings.LootOwnership = 0;
|
||||
return true;
|
||||
case "usearcs":
|
||||
if (!num) return true;
|
||||
_settings.UseArcs = n != 0;
|
||||
return true;
|
||||
case "minimumhealkitsuccesschance":
|
||||
if (!num) return true;
|
||||
_settings.KitMinSuccessPct = Math.Clamp((int)Math.Round(n > 0 && n <= 1 ? n * 100 : n), 0, 100);
|
||||
return true;
|
||||
case "autoattackpower":
|
||||
// On: RynthAi picks the power itself (-1, its "auto"). Off: the attack bar's value,
|
||||
// the last /vt setattackbar (a power already set by hand stays as it is).
|
||||
if (!num) return true;
|
||||
if (n != 0)
|
||||
{
|
||||
_settings.MeleeAttackPower = _settings.MissileAttackPower = -1;
|
||||
}
|
||||
else if (_settings.MeleeAttackPower < 0 || _settings.MissileAttackPower < 0)
|
||||
{
|
||||
if (_lastAttackBarPct >= 0)
|
||||
_settings.MeleeAttackPower = _settings.MissileAttackPower = _lastAttackBarPct;
|
||||
else
|
||||
RynthLog.Write(LogCat.Meta, "[Meta] AutoAttackPower off with no /vt setattackbar value yet: attack power stays automatic.");
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The special options as VTank reads them back (height 1-3, ownership as two flags).</summary>
|
||||
private string? GetSpecialVtOption(string vtName) => vtName.ToLowerInvariant() switch
|
||||
{
|
||||
"defaultmeleeattackheight" => (_settings.MeleeAttackHeight + 1).ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
"lootfellowcorpses" => _settings.LootOwnership >= 1 ? "true" : "false",
|
||||
"lootallcorpses" => _settings.LootOwnership == 2 ? "true" : "false",
|
||||
"usearcs" => _settings.UseArcs ? "true" : "false",
|
||||
"minimumhealkitsuccesschance" => _settings.KitMinSuccessPct.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
"autoattackpower" => _settings.MeleeAttackPower < 0 ? "true" : "false",
|
||||
_ => null,
|
||||
};
|
||||
|
||||
/// <summary>A VTank option's current value (mapped setting, else a stored generic option).</summary>
|
||||
private string? GetVtOption(string vtName)
|
||||
{
|
||||
if (GetSpecialVtOption(vtName) is string special) return special;
|
||||
var map = Expressions.BuildSettingsMapPublic();
|
||||
if (VtOptionMap.TryGetValue(vtName, out string? raName))
|
||||
{
|
||||
if (map.TryGetValue(raName, out var entry)) return entry.Get();
|
||||
// Distances read back in VTank's landblock units, as they were set (6 yd reads 0.025).
|
||||
if (map.TryGetValue(raName, out var entry))
|
||||
return VtDistanceOptions.Contains(vtName) ? YardsToVtDistance(entry.Get()) : entry.Get();
|
||||
}
|
||||
// A RynthAi setting named directly (EnableCombat, OpenDoors, NavCloseStopRange...).
|
||||
if (map.TryGetValue(vtName, out var direct)) return direct.Get();
|
||||
|
|
@ -1372,6 +1571,15 @@ internal sealed class MetaManager
|
|||
// Translate VTank bool strings to numeric
|
||||
string value = NormalizeVtValue(vtValue);
|
||||
|
||||
// Options whose value means something else in RynthAi (a scale, an offset, a mode).
|
||||
if (TrySetSpecialVtOption(vtName, value)) return true;
|
||||
|
||||
// VTank distances are in landblock units (1 = 240 yd: AttackDistance .01666 is 4 yd); RynthAi's
|
||||
// are yards. Converted here, rounded where RynthAi keeps whole yards (an int setting refused
|
||||
// "0.01666" outright, so every meta's attack / approach distance was dropped).
|
||||
if (VtDistanceOptions.Contains(vtName) && VtOptionMap.TryGetValue(vtName, out string? distName))
|
||||
value = VtDistanceToYards(value, IntYardSettings.Contains(distName));
|
||||
|
||||
var map = Expressions.BuildSettingsMapPublic();
|
||||
if (VtOptionMap.TryGetValue(vtName, out string? raName))
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue