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:
BlankenshipG 2026-10-18 16:22:40 -04:00
commit 7797901d69
287 changed files with 22602 additions and 1090 deletions

View file

@ -0,0 +1,126 @@
// RingChain.cs - Infinite Leaftide's ring inscription chain (Crafting > Rings), from UB-IT's
// ImbueSpellCraftDefinitions / SpellcraftInventoryPolicy.
//
// Step 1: Quill of Infliction used on a Trophy -> Enlightened Quill of Infliction
// Step 2: Enlightened Quill used on Ink of Partition -> partition quill
// Step 3: partition quill used on a Glyph -> "Inscription of ..." scroll
// Then each scroll is used on a ring / jewelry / weapon.
//
// Pure: ingredient matching (case-insensitive substrings with alternates and one exclude), the
// craft queue order and the scroll-to-target pairing. RingChainRunner does the using.
using System;
using System.Collections.Generic;
using System.Linq;
namespace RynthCore.Plugin.RynthAi.MiniRemote.Crafting;
/// <summary>One ingredient: the first of <see cref="Names"/> found in an item's name, unless it also has <see cref="Exclude"/>.</summary>
internal sealed record RingIngredient(string Label, string[] Names, string Exclude = "");
/// <summary>One combine: <see cref="Tool"/> is used on <see cref="Target"/>.</summary>
/// <param name="Tier">1 quill + trophy, 2 + ink, 3 + glyph: the queue runs every tier-1 run first.</param>
/// <param name="ScrollMarkers">Step 3: the words the resulting inscription scroll's name carries.</param>
internal sealed record RingRecipe(string Id, int Tier, string Name, string Notes,
RingIngredient Tool, RingIngredient Target, string[] ScrollMarkers);
internal static class RingChain
{
/// <summary>Every inscription scroll's name has this.</summary>
public const string InscriptionMarker = "Inscription of";
/// <summary>Most runs of one recipe the tab queues.</summary>
public const int MaxRuns = 99;
private static readonly RingIngredient PartitionQuill = new("Enlightened Infliction Quill of Partition",
new[] { "Enlightened Infliction Quill of Partition", "Enlightened Quill of Infliction of Partition" });
private static RingRecipe Glyph(string id, string element, string scroll) => new(
id, 3, $"Step 3: {element} glyph - {scroll}",
$"Partition quill used on Glyph of {element} -> Inscription of {scroll} scroll.",
PartitionQuill,
// The full glyph name: a short one can match the wrong stack.
new RingIngredient($"Glyph of {element}", new[] { $"Glyph of {element}" }),
new[] { scroll, element });
/// <summary>The chain, in UB-IT's order.</summary>
public static readonly RingRecipe[] Recipes =
{
new("ring2_step1_quill_trophy", 1, "Step 1: Quill of Infliction + Trophy",
"Quill of Infliction used on a Trophy -> Enlightened Quill of Infliction.",
new RingIngredient("Quill of Infliction", new[] { "Quill of Infliction", "Infliction Quill" }, Exclude: "Enlightened"),
// Not plain "Trophy": scrolls and kits carry that word too.
new RingIngredient("Trophy", new[] { "Royal Summons", "Empyrean Trophy", "Summoning Gem" }),
Array.Empty<string>()),
new("ring2_step2_ink", 2, "Step 2: Enlightened Quill + Ink of Partition",
"Enlightened Quill of Infliction (from Step 1) used on Ink of Partition -> partition quill.",
new RingIngredient("Enlightened Quill of Infliction",
new[] { "Enlightened Quill of Infliction", "Enlightened Infliction Quill", "Enlightened Infliction Quill of" }, Exclude: "Partition"),
new RingIngredient("Ink of Partition", new[] { "Ink of Partition", "Partition Ink" }),
Array.Empty<string>()),
Glyph("ring2_glyph_bludgeoning", "Bludgeoning", "Tectonic Rifts"),
Glyph("ring2_glyph_lightning", "Lightning", "Eye of the Storm"),
Glyph("ring2_glyph_piercing", "Piercing", "Nuhmudira's Spines"),
Glyph("ring2_glyph_nether", "Nether", "Clouded Soul"),
Glyph("ring2_glyph_corrosion", "Corrosion", "Searing Disc"),
Glyph("ring2_glyph_frost", "Frost", "Halo of Frost"),
Glyph("ring2_glyph_slashing", "Slashing", "Horizon's Blades"),
Glyph("ring2_glyph_flame", "Flame", "Cassius' Ring of Fire"),
};
/// <summary>True when an item's name is this ingredient.</summary>
public static bool Matches(string? name, RingIngredient ing)
{
if (string.IsNullOrEmpty(name)) return false;
if (ing.Exclude.Length > 0 && name.IndexOf(ing.Exclude, StringComparison.OrdinalIgnoreCase) >= 0) return false;
foreach (string n in ing.Names)
if (n.Length > 0 && name.IndexOf(n, StringComparison.OrdinalIgnoreCase) >= 0) return true;
return false;
}
/// <summary>
/// The craft queue: every Step 1 run, then every Step 2 run, then the glyphs, each tier in
/// definition order (a later tier's ingredients come out of the earlier one).
/// </summary>
public static List<RingRecipe> Expand(Func<string, int> runs)
{
var queue = new List<RingRecipe>();
foreach (var r in Recipes.OrderBy(r => r.Tier))
{
int n = Math.Clamp(runs(r.Id), 0, MaxRuns);
for (int i = 0; i < n; i++) queue.Add(r);
}
return queue;
}
/// <summary>The glyph recipe a scroll came from (null when its name has no known marker).</summary>
public static RingRecipe? GlyphOf(string? scrollName)
{
if (string.IsNullOrEmpty(scrollName)) return null;
foreach (var r in Recipes)
foreach (string m in r.ScrollMarkers)
if (scrollName.IndexOf(m, StringComparison.OrdinalIgnoreCase) >= 0) return r;
return null;
}
public static bool IsInscriptionScroll(string? name)
=> !string.IsNullOrEmpty(name) && name.IndexOf(InscriptionMarker, StringComparison.OrdinalIgnoreCase) >= 0;
/// <summary>
/// Pairs scrolls with targets the way UB-IT does: scrolls by glyph recipe id (unknown ones
/// last, by name), targets by object id, one scroll per target.
/// </summary>
public static List<(int Scroll, int Target)> PairScrolls(IEnumerable<(int Id, string Name)> scrolls, IEnumerable<int> targets)
{
var ordered = scrolls
.OrderBy(s => GlyphOf(s.Name)?.Id ?? "zzz_" + s.Name, StringComparer.Ordinal)
.ThenBy(s => s.Id)
.ToList();
var pairs = new List<(int, int)>();
int i = 0;
foreach (int t in targets.Distinct().OrderBy(x => x))
{
if (i >= ordered.Count) break;
pairs.Add((ordered[i++].Id, t));
}
return pairs;
}
}

View file

@ -0,0 +1,387 @@
// RingChainRunner.cs - Crafts Infinite Leaftide's ring inscription chain and applies the scrolls
// (Crafting > Rings).
//
// Pump thread only (the tab's Render reads the volatile snapshots and posts the commands).
// Crafting: the queue from RingChain.Expand, one combine at a time:
// 1. gates: peace mode (unless the server allows combat crafting), not busy, ActionPacer;
// 2. find the tool and the target by name; a later step's ingredients come out of the earlier
// combine, so a missing one is looked for again for a while (inventory lag) before giving up;
// 3. arm the engine's confirmation answer (Yes: the player queued it) and use tool on target;
// 4. the combine is done when the tool or the target stack shrinks or the output shows up.
// No sign of it stops the job instead of retrying, so nothing is crafted twice.
// Scrolls: each "Inscription of ..." scroll is used on its target (the item selected in AC, or
// the last Jewelry / weapon scan's items paired the UB-IT way) and is done when it leaves the pack.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using RynthCore.Loot;
using RynthCore.Plugin.Shared;
using RynthCore.PluginSdk;
namespace RynthCore.Plugin.RynthAi.MiniRemote.Crafting;
/// <summary>One line of the Rings scan: a recipe header (Found null) or an ingredient.</summary>
/// <param name="State">0 found, 1 comes from an earlier step, 2 missing.</param>
internal sealed record RingScanLine(string Text, string? Found, int State);
internal sealed class RingChainRunner
{
private const uint ErrorYoureTooBusy = 0x1D;
private const long StepTimeoutMs = 15_000;
/// <summary>The player answers AC's own dialog: give them time.</summary>
private const long ManualTimeoutMs = 60_000;
private const long StepGapMs = 700;
private const long RetryDelayMs = 1_500;
private const int MaxBusyRetries = 3;
/// <summary>A missing ingredient is looked for this often and this many times (~10 s).</summary>
private const long LookAgainMs = 250;
private const int LookTries = 40;
private static readonly Regex CannotUse = new(@"^The .+ cannot be used on the .+\.$", RegexOptions.Compiled | RegexOptions.CultureInvariant);
private enum Mode { Idle, Craft, Apply }
private readonly MiniRemoteContext _ctx;
/// <summary>True while another crafting job (the tinker runner) owns the pack.</summary>
private readonly Func<bool> _blocked;
// Job (pump thread)
private Mode _mode;
private List<RingRecipe> _queue = new();
private List<(int Scroll, int Target)> _pairs = new();
private int _index, _crafted, _lookTries, _busyRetries, _confSeq, _errSeq;
private bool _waiting, _manual;
private long _stepAt, _nextAt;
// Counts before the current combine (craft) / the scroll's stack (apply).
private long _toolBefore, _targetBefore, _outputBefore;
private int _scrollStackBefore;
// Render snapshots
private volatile string _status = "idle";
private volatile RingScanLine[] _scan = Array.Empty<RingScanLine>();
private volatile (int Id, string Name)[] _scrolls = Array.Empty<(int, string)>();
private volatile bool _running;
public RingChainRunner(MiniRemoteContext ctx, Func<bool> blocked)
{
_ctx = ctx;
_blocked = blocked;
}
public bool Running => _running;
public string Status => _status;
public RingScanLine[] ScanLines => _scan;
/// <summary>The inscription scrolls the last scan found.</summary>
public (int Id, string Name)[] Scrolls => _scrolls;
private RynthCoreHost Host => _ctx.Host;
private MiniRemoteInventory Inv => _ctx.Inventory;
private CraftingTabState C => _ctx.State.Crafting;
private int Runs(string id)
{
var map = C.RingRuns;
lock (map) return map.TryGetValue(id, out int n) ? n : 0;
}
// ── Inventory ───────────────────────────────────────────────────────────
private IEnumerable<WorldObject> Carried() => Inv.Items().Where(w => !Inv.IsEquipped(w));
private WorldObject? Find(RingIngredient ing) => Carried().FirstOrDefault(w => RingChain.Matches(w.Name, ing));
private long Count(RingIngredient ing) => Carried().Where(w => RingChain.Matches(w.Name, ing)).Sum(w => (long)Inv.StackSize(w));
private long ScrollCount() => Carried().Where(w => RingChain.IsInscriptionScroll(w.Name)).Sum(w => (long)Inv.StackSize(w));
/// <summary>What a recipe makes, counted: Step 1 the enlightened quill, Step 2 the partition quill, Step 3 a scroll.</summary>
private long OutputCount(RingRecipe r) => r.Tier switch
{
1 => Count(RingChain.Recipes[1].Tool),
2 => Count(RingChain.Recipes[2].Tool),
_ => ScrollCount(),
};
// ── Scan ────────────────────────────────────────────────────────────────
/// <summary>
/// Lists every queued recipe's ingredients, marking the ones a later step only gets from an
/// earlier combine (UB-IT's "(after Step 1)"), and the carried inscription scrolls.
/// </summary>
public void Scan()
{
var lines = new List<RingScanLine>();
bool Stocked(int tier) => RingChain.Recipes
.Where(r => r.Tier == tier && Runs(r.Id) > 0)
.All(r => Find(r.Tool) != null && Find(r.Target) != null);
bool tier1 = Stocked(1), tier2 = Stocked(2);
bool any = false, blocking = false;
foreach (var r in RingChain.Recipes)
{
int runs = Runs(r.Id);
if (runs <= 0) continue;
any = true;
lines.Add(new RingScanLine($"{r.Name} x{runs}", null, 0));
foreach (var ing in new[] { r.Tool, r.Target })
{
var found = Find(ing);
if (found != null) { lines.Add(new RingScanLine(ing.Label, $"{found.Name} ({Count(ing)})", 0)); continue; }
string? later = r.Tier == 2 && !tier1 ? "(after Step 1)"
: r.Tier == 3 && !tier1 ? "(after Step 1)"
: r.Tier == 3 && !tier2 ? "(after Step 2)"
: null;
if (later == null) blocking = true;
lines.Add(new RingScanLine(ing.Label, later ?? "(not found)", later == null ? 2 : 1));
}
}
_scan = lines.ToArray();
RefreshScrolls();
_status = !any ? "set how many times to craft at least one recipe"
: blocking ? "missing ingredients are marked (not found)"
: "ready: Create runs every Step 1, then Step 2, then Step 3";
}
private void RefreshScrolls()
=> _scrolls = Carried().Where(w => RingChain.IsInscriptionScroll(w.Name))
.Select(w => (w.Id, w.Name ?? string.Empty))
.OrderBy(s => RingChain.GlyphOf(s.Item2)?.Id ?? "zzz_" + s.Item2, StringComparer.Ordinal)
.ToArray();
// ── Job control ─────────────────────────────────────────────────────────
/// <summary>Crafts the queued recipes (pump thread, after the tab's confirm).</summary>
public void Create()
{
if (_running) return;
if (_blocked()) { _status = "a tinkering job is running"; return; }
var queue = RingChain.Expand(Runs);
if (queue.Count == 0) { _status = "set how many times to craft at least one recipe"; return; }
Begin(Mode.Craft);
_queue = queue;
_status = $"crafting {queue.Count} combine(s)";
RynthLog.Write(LogCat.Crafting, $"[Crafting] Rings: create, {queue.Count} combine(s)");
}
/// <summary>Uses one scroll on the item selected in AC.</summary>
public void ApplyToSelected(int scrollId)
{
uint sel = Host.GetSelectedItemId();
if (sel == 0) { _status = "select the ring or item in AC first"; return; }
if (unchecked((int)sel) == scrollId) { _status = "the scroll itself is selected: select the ring or item"; return; }
ApplyPairs(new List<(int, int)> { (scrollId, unchecked((int)sel)) });
}
/// <summary>Pairs the carried scrolls with these items (the last Jewelry / weapon scan) and uses them.</summary>
public void ApplyToItems(IReadOnlyList<int> targetIds)
{
RefreshScrolls();
if (_scrolls.Length == 0) { _status = "no inscription scroll in the pack (name has \"Inscription of\")"; return; }
if (targetIds.Count == 0) { _status = "scan the Jewelry or a Weapons tab first: its items are the targets"; return; }
ApplyPairs(RingChain.PairScrolls(_scrolls, targetIds));
}
private void ApplyPairs(List<(int Scroll, int Target)> pairs)
{
if (_running) return;
if (_blocked()) { _status = "a tinkering job is running"; return; }
if (pairs.Count == 0) { _status = "nothing to apply"; return; }
Begin(Mode.Apply);
_pairs = pairs;
_status = $"applying {pairs.Count} inscription(s)";
RynthLog.Write(LogCat.Crafting, $"[Crafting] Rings: apply {pairs.Count} inscription(s)");
}
private void Begin(Mode mode)
{
_mode = mode;
_index = 0;
_crafted = 0;
_lookTries = 0;
_busyRetries = 0;
_waiting = false;
_nextAt = 0;
_running = true;
}
public void Stop(string why)
{
if (_waiting && Host.HasConfirmationAnswers) Host.ArmConfirmation(RynthCoreHost.ConfirmationKind.CraftInteraction, 0, 0);
_mode = Mode.Idle;
_waiting = false;
_running = false;
_queue = new List<RingRecipe>();
_pairs = new List<(int, int)>();
_status = why;
}
public void OnLogout()
{
Stop("idle");
_scan = Array.Empty<RingScanLine>();
_scrolls = Array.Empty<(int, string)>();
}
// ── Tick (pump thread) ──────────────────────────────────────────────────
public void Tick(long nowMs)
{
if (_mode == Mode.Idle) return;
if (_waiting) { Wait(nowMs); return; }
if (nowMs < _nextAt) return;
if (!C.AllowInCombat && !Inv.InPeaceMode) { _status = "waiting for peace mode"; return; }
if (Inv.IsBusy) return;
if (!ActionPacer.MayStart(Host, "Crafting", HealNeed.None, out string why)) { _status = "waiting: " + why; return; }
if (_mode == Mode.Craft) NextCombine(nowMs);
else NextScroll(nowMs);
}
private void NextCombine(long nowMs)
{
if (_index >= _queue.Count)
{
Stop($"done - {_crafted} combine(s)");
RefreshScrolls();
RynthLog.Write(LogCat.Crafting, $"[Crafting] Rings: done, {_crafted} combine(s)");
return;
}
var r = _queue[_index];
var tool = Find(r.Tool);
var target = Find(r.Target);
if (tool == null || target == null)
{
string label = tool == null ? r.Tool.Label : r.Target.Label;
if (++_lookTries <= LookTries)
{
_nextAt = nowMs + LookAgainMs;
_status = $"{r.Name}: looking for {label}";
return;
}
Stop($"{r.Name}: no {label} in the pack");
return;
}
_lookTries = 0;
_toolBefore = Count(r.Tool);
_targetBefore = Count(r.Target);
_outputBefore = OutputCount(r);
if (!Use(tool, target, $"Rings: {r.Name} ({_index + 1}/{_queue.Count})"))
{
Stop($"{r.Name}: the use request didn't go out");
return;
}
string ask = _manual ? " - click Yes in AC's craft dialog" : "";
_status = $"{r.Name} ({_index + 1}/{_queue.Count}): {tool.Name} on {target.Name}{ask}";
}
private void NextScroll(long nowMs)
{
if (_index >= _pairs.Count)
{
Stop($"done - {_crafted} inscription(s) applied");
RefreshScrolls();
return;
}
var (scrollId, targetId) = _pairs[_index];
var scroll = Inv.Cache?[scrollId];
var target = Inv.Cache?[targetId];
if (scroll == null || target == null)
{
// UB-IT moves on past a pair whose scroll or item is gone.
_status = $"inscription {_index + 1}: the scroll or the item is gone - skipped";
_index++;
_nextAt = nowMs + StepGapMs;
return;
}
if (Inv.IsEquipped(target)) { Stop($"{target.Name} is equipped: take it off to inscribe it"); return; }
_scrollStackBefore = Inv.StackSize(scroll);
if (!Use(scroll, target, $"Rings: {scroll.Name} on {target.Name}"))
{
Stop("the use request didn't go out");
return;
}
string ask = _manual ? " - click Yes in AC's dialog" : "";
_status = $"inscription {_index + 1}/{_pairs.Count}: {scroll.Name} on {target.Name}{ask}";
}
/// <summary>Arms the dialog answer (Yes: the player asked for this) and uses source on target.</summary>
private bool Use(WorldObject source, WorldObject target, string why)
{
_manual = !(C.AnswerCraftDialog && Host.HasConfirmationAnswers
&& Host.ArmConfirmation(RynthCoreHost.ConfirmationKind.CraftInteraction, 0, (int)StepTimeoutMs) == 1);
_confSeq = Host.TryGetLastConfirmation(out int cs, out _, out _, out _, out _) ? cs : 0;
_errSeq = Host.TryGetLastWeenieError(out int es, out _, out _, out _) ? es : 0;
if (!Host.UseOnFor(unchecked((uint)source.Id), unchecked((uint)target.Id), "Crafting", why, UseKind.Asked))
{
if (!_manual) Host.ArmConfirmation(RynthCoreHost.ConfirmationKind.CraftInteraction, 0, 0);
return false;
}
_waiting = true;
_stepAt = Environment.TickCount64;
return true;
}
private void Wait(long nowMs)
{
if (Host.TryGetLastConfirmation(out int seq, out uint type, out int pct, out int outcome, out _)
&& seq != _confSeq && type == RynthCoreHost.ConfirmationKind.CraftInteraction)
{
_confSeq = seq;
if (outcome == RynthCoreHost.ConfirmationOutcome.Declined) { Stop("the craft dialog was answered No"); return; }
if (outcome is RynthCoreHost.ConfirmationOutcome.Shown or RynthCoreHost.ConfirmationOutcome.SendFailed)
{
_manual = true;
_status = $"click Yes in AC's craft dialog ({(pct >= 0 ? pct + "%" : "chance not shown")})";
}
}
if (Host.TryGetLastWeenieError(out int es, out uint error, out _, out _) && es != _errSeq)
{
_errSeq = es;
// Busy: the server did nothing, so the same combine can go again.
if (error == ErrorYoureTooBusy && ++_busyRetries <= MaxBusyRetries)
{
_waiting = false;
_nextAt = nowMs + RetryDelayMs;
_status = $"server says busy - trying again ({_busyRetries}/{MaxBusyRetries})";
return;
}
Stop($"the server refused it (error 0x{error:X})");
return;
}
if (Done()) { Next(nowMs); return; }
if (nowMs - _stepAt > (_manual ? ManualTimeoutMs : StepTimeoutMs))
Stop(_manual ? "no answer to AC's dialog - stopped" : "no result seen - stopped (check the pack before going on)");
}
/// <summary>The current combine or inscription went through.</summary>
private bool Done()
{
if (_mode == Mode.Craft)
{
var r = _queue[_index];
return Count(r.Tool) < _toolBefore || Count(r.Target) < _targetBefore || OutputCount(r) > _outputBefore;
}
var scroll = Inv.Cache?[_pairs[_index].Scroll];
return scroll == null || Inv.StackSize(scroll) < _scrollStackBefore;
}
private void Next(long nowMs)
{
_waiting = false;
_busyRetries = 0;
_crafted++;
_index++;
_nextAt = nowMs + StepGapMs;
}
/// <summary>"cannot be used on" ends the job: the names didn't match what the server expects.</summary>
public void OnChat(string text)
{
if (!_waiting || string.IsNullOrEmpty(text)) return;
if (CannotUse.IsMatch(text)) Stop(text);
}
}

View file

@ -5,11 +5,12 @@
// mana / retain. Every retail tinker (imbues too) uses one of the item's 10 tinker slots and the
// success chance follows RecipeManager.GetTinkerChance (TinkerMath).
//
// Server: the connected server's own recipes come from the plugin that owns it (its
// "RynthServer.Profile" JSON's "salvage" list, read by FromServerPlugin): a server plugin, or
// RynthILT for Infinite Leaftide. Nothing server-specific lives here. Their chances are the
// server's: the Crafting runner relies on the confirmation's percent.
// The player adds their own rows per world (CraftingTabState.CustomByWorld).
// Server: Infinite Leaftide / ACECustom extras, taken from UB-IT (LeaftideImbueHelper): jewelry
// rating salvages (Copper, Silver, Green Jade, Tourmaline, Serpentine, Steel), the weapon crit
// lines (Yellow Garnet, Turquoise, White Quartz, Abyssal-Touched gems, Tourmaline, Wool), Tiger
// Eye on missile weapons and Leather as the post-cap tink. ILT's recipes live in its database,
// so their chances are the server's: the Crafting runner relies on the confirmation's percent.
// Other custom shards add their own rows per world (CraftingTabState.CustomByWorld).
using System;
using System.Collections.Generic;
using RynthCore.Loot;
@ -25,7 +26,7 @@ internal enum TinkerBench
Caster,
Jewelry,
Items,
/// <summary>Trinkets (compass, goggles, scarab...): server salvage, often tier-prepared.</summary>
/// <summary>Infinite Leaftide trinkets (compass, goggles, scarab...): tier-prepared salvage.</summary>
Trinkets,
}
@ -34,9 +35,14 @@ internal enum TinkerOrigin
{
/// <summary>Stock ACE (retail) tinkering.</summary>
Retail,
/// <summary>Infinite Leaftide / ACECustom recipe.</summary>
Server,
/// <summary>A row the player added for this server.</summary>
Custom,
/// <summary>A row the server's own plugin defines (its profile's "salvage" list, ServerPackInfo.Salvage).</summary>
/// <summary>
/// A row the server's own plugin defines (its profile's "salvage" list, ServerPackInfo.Salvage).
/// Kept apart from <see cref="Server"/> so the Leaftide-only planner rules never apply to it.
/// </summary>
Plugin,
}
@ -47,24 +53,20 @@ internal enum TinkerKind
Tink,
/// <summary>One imbue per item (ImbuedEffect): a second imbue of any kind is refused.</summary>
Imbue,
/// <summary>One application (retain, heritage, a server's flag recipes...).</summary>
/// <summary>One application, tracked by its own flag (ILT jewelry ratings, retain...).</summary>
Once,
}
/// <summary>One salvage a tab can apply.</summary>
/// <param name="Id">MaterialType (131); <see cref="TinkerCatalog.RendId"/> = the weapon's damage-type rend.</param>
/// <param name="UsesTinkSlot">Counts toward the 10-tink cap.</param>
/// <param name="AppliedInt">An int property of the item: the material is on it when it reads 2 (0 = none).</param>
/// <param name="NameMatch">The bag must have this in its name (server bags that share a material id).</param>
/// <param name="AppliedInt">ILT flag int: the material is on the item when it reads 2 (0 = none).</param>
/// <param name="NameMatch">The bag must have this in its name (ILT bags that share a material id).</param>
/// <param name="Order">Apply order (lower first).</param>
/// <param name="Prepared">The bag must first be prepared on tier Ammunition: its name then carries the tier.</param>
/// <param name="AfterCap">Goes on last, and only once the item's tink slots are full.</param>
/// <param name="StackGroup">Rows with the same group share <paramref name="StackCap"/> per item ("" = none).</param>
/// <param name="StackCap">The group's combined cap per item.</param>
/// <param name="Prepared">The bag must first be prepared on tier Ammunition (ILT trinkets): its name then carries the tier.</param>
internal sealed record TinkerMaterial(
int Id, string Name, TinkerOrigin Origin, TinkerKind Kind, string Effect, int Order,
bool UsesTinkSlot = true, int AppliedInt = 0, string NameMatch = "", int Skill = 0, bool Prepared = false,
bool AfterCap = false, string StackGroup = "", int StackCap = 0);
bool UsesTinkSlot = true, int AppliedInt = 0, string NameMatch = "", int Skill = 0, bool Prepared = false);
internal static class TinkerCatalog
{
@ -91,9 +93,19 @@ internal static class TinkerCatalog
public const int Diamond = 20, Ruby = 38, GromnieHide = 54, Pyreal = 62;
/// <summary>Prepared salvage tiers: the word in the Ammunition's and the prepared bag's name.</summary>
// ILT jewelry flag ints (applied = 2).
public const int IntJewelCopper = 370, IntJewelGreenJade = 371, IntJewelSerpentine = 372,
IntJewelSilver = 374, IntJewelTourmaline = 375, IntJewelSteel = 376;
// ILT trinket flag ints (applied = 2).
public const int IntTrinketDiamond = 384, IntTrinketRuby = 385, IntTrinketGromnie = 386, IntTrinketPyreal = 387;
/// <summary>Trinket salvage tiers: the word in the Ammunition's and the prepared bag's name.</summary>
public static readonly string[] TrinketTiers = { "Minor", "Moderate", "Major" };
/// <summary>Steel and Serpentine stack on ILT jewelry, at most this many combined.</summary>
public const int JewelryStackCap = 10;
/// <summary>The ordinary tinker slots on an item.</summary>
public const int MaxTinks = 10;
@ -180,14 +192,66 @@ internal static class TinkerCatalog
[TinkerBench.Trinkets] = Array.Empty<TinkerMaterial>(),
};
private static readonly Dictionary<TinkerBench, TinkerMaterial[]> Server = new()
{
[TinkerBench.Armor] = Array.Empty<TinkerMaterial>(),
[TinkerBench.Melee] = new TinkerMaterial[]
{
new(YellowGarnet, "Yellow Garnet", TinkerOrigin.Server, TinkerKind.Once, "Biting Strike (no tink slot)", 70, UsesTinkSlot: false),
new(Turquoise, "Turquoise", TinkerOrigin.Server, TinkerKind.Once, "Crushing Blow (no tink slot)", 80, UsesTinkSlot: false),
new(WhiteQuartz, "White Quartz", TinkerOrigin.Server, TinkerKind.Once, "Cleaving (no tink slot)", 90, UsesTinkSlot: false),
new(BlackGarnet, "Abyssal-Touched Gems", TinkerOrigin.Server, TinkerKind.Once, "Crit line (bag of Abyssal-Touched Gems)", 100, NameMatch: "Abyssal"),
new(Tourmaline, "Tourmaline", TinkerOrigin.Server, TinkerKind.Once, "Crit line (no tink slot)", 104, UsesTinkSlot: false),
new(Wool, "Wool", TinkerOrigin.Server, TinkerKind.Once, "Biting Strike (no tink slot)", 108, UsesTinkSlot: false),
new(Leather, "Leather", TinkerOrigin.Server, TinkerKind.Once, "100% tink once the 10 ordinary tinks are on", 995, UsesTinkSlot: false),
},
[TinkerBench.Missile] = new TinkerMaterial[]
{
new(YellowGarnet, "Yellow Garnet", TinkerOrigin.Server, TinkerKind.Once, "Biting Strike (no tink slot)", 70, UsesTinkSlot: false),
new(Turquoise, "Turquoise", TinkerOrigin.Server, TinkerKind.Once, "Crushing Blow (no tink slot)", 80, UsesTinkSlot: false),
new(BlackGarnet, "Abyssal-Touched Gems", TinkerOrigin.Server, TinkerKind.Once, "Crit line (bag of Abyssal-Touched Gems)", 100, NameMatch: "Abyssal"),
new(Tourmaline, "Tourmaline", TinkerOrigin.Server, TinkerKind.Once, "Crit line (no tink slot)", 104, UsesTinkSlot: false),
new(Wool, "Wool", TinkerOrigin.Server, TinkerKind.Once, "Biting Strike (no tink slot)", 108, UsesTinkSlot: false),
new(TigerEye, "Tiger Eye", TinkerOrigin.Server, TinkerKind.Tink, "+missile defense bonus", 230),
new(Leather, "Leather", TinkerOrigin.Server, TinkerKind.Once, "100% tink once the 10 ordinary tinks are on", 995, UsesTinkSlot: false),
},
[TinkerBench.Caster] = new TinkerMaterial[]
{
new(YellowGarnet, "Yellow Garnet", TinkerOrigin.Server, TinkerKind.Once, "Biting Strike (no tink slot)", 70, UsesTinkSlot: false),
new(Turquoise, "Turquoise", TinkerOrigin.Server, TinkerKind.Once, "Crushing Blow (no tink slot)", 80, UsesTinkSlot: false),
new(Leather, "Leather", TinkerOrigin.Server, TinkerKind.Once, "100% tink once the 10 ordinary tinks are on", 995, UsesTinkSlot: false),
},
[TinkerBench.Jewelry] = new TinkerMaterial[]
{
// ILT keeps these in their own ints (370-376) with their own cap, not the 10 tinker slots.
new(Silver, "Silver", TinkerOrigin.Server, TinkerKind.Once, "+1 critical damage rating", 10, UsesTinkSlot: false, AppliedInt: IntJewelSilver),
new(Copper, "Copper", TinkerOrigin.Server, TinkerKind.Once, "+1 damage rating", 20, UsesTinkSlot: false, AppliedInt: IntJewelCopper),
new(GreenJade, "Green Jade", TinkerOrigin.Server, TinkerKind.Once, "+1 damage resist rating", 30, UsesTinkSlot: false, AppliedInt: IntJewelGreenJade),
new(Tourmaline, "Tourmaline", TinkerOrigin.Server, TinkerKind.Once, "+1 critical damage resist rating", 40, UsesTinkSlot: false, AppliedInt: IntJewelTourmaline),
new(Serpentine, "Serpentine", TinkerOrigin.Server, TinkerKind.Tink, "+1 critical rating (stacks with Steel, 10 max)", 50, UsesTinkSlot: false),
new(Steel, "Steel", TinkerOrigin.Server, TinkerKind.Tink, "Steel stack tier (stacks with Serpentine, 10 max)", 60, UsesTinkSlot: false),
},
[TinkerBench.Items] = Array.Empty<TinkerMaterial>(),
// UB-IT LeaftideImbueHelper trinket imbues: Diamond, Ruby, Gromnie Hide, Pyreal, in that order.
[TinkerBench.Trinkets] = new TinkerMaterial[]
{
new(Diamond, "Diamond", TinkerOrigin.Server, TinkerKind.Once, "Trinket tier: Diamond", 10, UsesTinkSlot: false, AppliedInt: IntTrinketDiamond, Prepared: true),
new(Ruby, "Ruby", TinkerOrigin.Server, TinkerKind.Once, "Trinket tier: Ruby", 20, UsesTinkSlot: false, AppliedInt: IntTrinketRuby, Prepared: true),
new(GromnieHide, "Gromnie Hide", TinkerOrigin.Server, TinkerKind.Once, "Trinket tier: Gromnie Hide", 30, UsesTinkSlot: false, AppliedInt: IntTrinketGromnie, Prepared: true),
new(Pyreal, "Pyreal", TinkerOrigin.Server, TinkerKind.Once, "Trinket tier: Pyreal", 40, UsesTinkSlot: false, AppliedInt: IntTrinketPyreal, Prepared: true),
},
};
/// <summary>The retail rows of a tab.</summary>
public static IReadOnlyList<TinkerMaterial> RetailFor(TinkerBench bench) => Retail[bench];
/// <summary>The Infinite Leaftide / ACECustom rows of a tab.</summary>
public static IReadOnlyList<TinkerMaterial> ServerFor(TinkerBench bench) => Server[bench];
/// <summary>
/// A server plugin's salvage rows for one tab (its profile's "salvage" list). Rows for other
/// tabs, unknown tab names and unknown kinds are left out. A row's own "order" decides where it
/// runs; without one, imbues run before tinks and one-application rows after them, each in the
/// plugin's list order.
/// tabs, unknown tab names and unknown kinds are left out; imbues run before tinks, and
/// one-application rows after them, each in the plugin's own order.
/// </summary>
public static List<TinkerMaterial> FromServerPlugin(TinkerBench bench, IEnumerable<RynthCore.Plugin.Shared.ServerSalvageView>? salvage)
{
@ -212,23 +276,18 @@ internal static class TinkerCatalog
TinkerKind.Once => 600,
_ => 400,
} + i++;
if (s.Order != 0) order = s.Order;
string group = s.StackCap > 0 ? (s.StackGroup ?? string.Empty).Trim() : string.Empty;
rows.Add(new TinkerMaterial(s.Material, MaterialName(s.Material), TinkerOrigin.Plugin, kind.Value,
string.IsNullOrWhiteSpace(s.Effect) ? "server recipe" : s.Effect.Trim(), order,
UsesTinkSlot: s.UsesTinkSlot, AppliedInt: s.AppliedInt, NameMatch: s.NameMatch ?? string.Empty,
Prepared: s.Prepared, AfterCap: s.AfterCap, StackGroup: group, StackCap: group.Length > 0 ? s.StackCap : 0));
UsesTinkSlot: s.UsesTinkSlot, NameMatch: s.NameMatch ?? string.Empty));
}
return rows;
}
/// <summary>
/// Settings key for a row: retail and server rows of one tab share ids (Wool, Steel...). Keys
/// with the old "s" prefix (RynthAi's own Leaftide rows before they moved to RynthILT) match no row.
/// </summary>
/// <summary>Settings key for a row: retail and server rows of one tab share ids (Wool, Steel...).</summary>
public static string Key(TinkerMaterial m) => m.Origin switch
{
TinkerOrigin.Retail => "r" + m.Id,
TinkerOrigin.Server => "s" + m.Id,
TinkerOrigin.Plugin => "p" + m.Id,
_ => "c" + m.Id,
};
@ -247,8 +306,8 @@ internal static class TinkerCatalog
};
/// <summary>
/// Trinkets (compass, goggles, scarab, watch, puzzle box, tops) are jewelry the Jewelry tab
/// leaves alone: they take the Trinkets tab's recipes instead (UB-IT IsLeaftideTrinketJewelry).
/// ILT trinkets (compass, goggles, scarab, watch, puzzle box, tops) are jewelry the Jewelry
/// tab leaves alone: they take the trinket recipes instead (UB-IT IsLeaftideTrinketJewelry).
/// </summary>
public static bool IsTrinket(string name)
{
@ -301,7 +360,7 @@ internal static class TinkerCatalog
};
}
/// <summary>The rend gem a Foolproof bag's name advertises (server bags may not set Material), else 0.</summary>
/// <summary>The rend gem a Foolproof bag's name advertises (ILT bags may not set Material), else 0.</summary>
public static int RendFromFoolproofName(string name)
{
if (string.IsNullOrEmpty(name) || name.IndexOf("Foolproof", StringComparison.OrdinalIgnoreCase) < 0) return 0;

View file

@ -2,17 +2,17 @@
//
// Pure: the scan reads the item into TinkerItemFacts and the runner re-plans from fresh facts,
// so these rules are the only place the apply order and caps live (and the host tests drive
// them directly). Server rows say which rules apply to them (TinkerMaterial, from the server
// plugin's profile); nothing here knows a server:
// * rows run in TinkerMaterial.Order (imbues and server crit lines before stat tinks; with
// them directly):
// * rows run in TinkerMaterial.Order (imbues and ILT crit lines before stat tinks; with
// "rend last" the rend moves to the end, the way UB-IT's foolproof-rend option does);
// * a tink-slot row is cut to the free slots (10 minus the item's tinks); no-slot rows aren't;
// * a tink-slot row is cut to the free slots (10 minus the item's tinks); ILT's no-slot
// salvages aren't;
// * one imbue per item (the item's own, or the first planned one);
// * a row with an applied int is skipped once that int reads 2 on the item;
// * rows of one stack group stop at the group's cap combined;
// * an after-cap row goes on last, once, and only when the tink slots are full;
// * a prepared row needs a bag prepared at the chosen tier (its name says Minor, Moderate or
// Major); a raw bag becomes one on that tier's Ammunition.
// * an ILT flag row (jewelry Copper...) is skipped once its flag reads 2;
// * ILT jewelry Steel + Serpentine stop at 10 combined;
// * ILT Leather on a weapon goes on once, after the 10 ordinary tinks are on;
// * an ILT trinket salvage needs a bag prepared at the chosen tier (its name says Minor,
// Moderate or Major); a raw bag becomes one on that tier's Ammunition.
using System;
using System.Collections.Generic;
using System.Linq;
@ -39,7 +39,7 @@ internal sealed class TinkerItemFacts
/// <summary>ItemMaxMana (108).</summary>
public int MaxMana;
public bool Equipped;
/// <summary>Reads an int property of the item (a row's applied int: 2 = that salvage is on).</summary>
/// <summary>Reads an ILT flag int (370-376); 2 = that salvage is on.</summary>
public Func<int, int> FlagInt = _ => 0;
}
@ -51,9 +51,16 @@ internal readonly record struct TinkerBagChoice(int Id, double Workmanship, doub
internal static class TinkerPlanner
{
/// <summary>
/// The rows a tab offers on this world: retail, the server's (ILT-like worlds) and the
/// player's custom rows for this world.
/// </summary>
public static List<TinkerMaterial> Rows(TinkerBench bench, bool iltWorld, IEnumerable<CustomTinker>? custom)
=> Rows(bench, iltWorld ? TinkerCatalog.ServerFor(bench) : null, custom);
/// <summary>
/// The rows a tab offers: retail, then <paramref name="server"/> (the connected server's own
/// salvage, from the plugin that owns it), then the player's custom rows.
/// salvage: RynthAi's Leaftide rows on ILT, or the server plugin's), then the player's custom rows.
/// </summary>
public static List<TinkerMaterial> Rows(TinkerBench bench, IEnumerable<TinkerMaterial>? server, IEnumerable<CustomTinker>? custom)
{
@ -91,8 +98,8 @@ internal static class TinkerPlanner
/// <summary>
/// The ordered steps for one item (empty when nothing ticked applies).
/// <paramref name="attempted"/> is how many times this run already tried a row key on the
/// item: the item's tinks count failures too, but no-slot server rows and the ticked counts
/// don't show on it, so a re-plan would otherwise repeat them.
/// item: the item's tinks count failures too, but ILT rows and the ticked counts don't show
/// on it, so a re-plan would otherwise repeat them.
/// </summary>
public static List<TinkerStep> Plan(TinkerBench bench, TinkerItemFacts item, TinkerBenchSettings s,
IReadOnlyList<TinkerMaterial> rows, Func<string, int>? attempted = null)
@ -100,8 +107,9 @@ internal static class TinkerPlanner
var steps = new List<TinkerStep>();
int free = Math.Max(0, TinkerCatalog.MaxTinks - item.Tinks);
bool imbueTaken = item.Imbued;
Dictionary<string, int>? stacked = null;
List<TinkerStep>? afterCap = null;
int jewelryStack = 0;
TinkerStep? leatherLast = null;
bool weapon = bench is TinkerBench.Melee or TinkerBench.Missile or TinkerBench.Caster;
foreach (var row in rows.OrderBy(r => OrderOf(r, s)))
{
@ -121,16 +129,15 @@ internal static class TinkerPlanner
imbueTaken = true;
}
if (row.AppliedInt != 0 && item.FlagInt(row.AppliedInt) == 2) continue;
if (row.StackGroup.Length > 0 && row.StackCap > 0)
if (bench == TinkerBench.Jewelry && row.Origin == TinkerOrigin.Server
&& material is TinkerCatalog.Steel or TinkerCatalog.Serpentine)
{
stacked ??= new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
int used = stacked.TryGetValue(row.StackGroup, out int u) ? u : 0;
n = Math.Min(n, row.StackCap - used);
stacked[row.StackGroup] = used + Math.Max(0, n);
n = Math.Min(n, TinkerCatalog.JewelryStackCap - jewelryStack);
jewelryStack += Math.Max(0, n);
}
if (row.AfterCap)
if (weapon && row.Origin == TinkerOrigin.Server && material == TinkerCatalog.Leather)
{
(afterCap ??= new List<TinkerStep>()).Add(new TinkerStep(row, material));
leatherLast = new TinkerStep(row, material);
continue;
}
if (row.UsesTinkSlot)
@ -140,7 +147,7 @@ internal static class TinkerPlanner
}
for (int i = 0; i < n; i++) steps.Add(new TinkerStep(row, material));
}
if (afterCap != null && free == 0) steps.AddRange(afterCap);
if (leatherLast is TinkerStep leather && free == 0) steps.Add(leather);
return steps;
}
@ -158,7 +165,7 @@ internal static class TinkerPlanner
}
/// <summary>
/// Whether a salvage bag can serve a step: a full bag (100 units) of the material, server bags
/// Whether a salvage bag can serve a step: a full bag (100 units) of the material, ILT bags
/// matched by name (Abyssal-Touched Gems share Black Garnet's id, Foolproof rend bags may not
/// carry a material at all).
/// </summary>
@ -176,7 +183,7 @@ internal static class TinkerPlanner
return step.Row.Id == TinkerCatalog.RendId && TinkerCatalog.RendFromFoolproofName(bagName) == step.Material;
}
/// <summary>The prepared tier a name carries (0 Minor, 1 Moderate, 2 Major), else -1.</summary>
/// <summary>The trinket tier a name carries (0 Minor, 1 Moderate, 2 Major), else -1.</summary>
public static int TierOf(string name)
{
name ??= string.Empty;
@ -185,11 +192,11 @@ internal static class TinkerPlanner
return -1;
}
/// <summary>A full, not yet prepared bag of a prepared row's salvage (no tier in its name).</summary>
/// <summary>A full, not yet prepared bag of a trinket salvage (no tier in its name).</summary>
public static bool IsRawTrinketBag(int material, string bagName, int bagMaterial, int bagUses)
=> bagUses >= 100 && bagMaterial == material && TierOf(bagName) < 0;
/// <summary>The Ammunition that prepares a raw bag into a tier bag.</summary>
/// <summary>The Ammunition that prepares a raw trinket bag into a tier bag.</summary>
public static bool IsTierAmmunition(string name, int tier)
=> (name ?? string.Empty).IndexOf("Ammunition", StringComparison.OrdinalIgnoreCase) >= 0
&& TierOf(name!) == Math.Clamp(tier, 0, TinkerCatalog.TrinketTiers.Length - 1);

View file

@ -11,11 +11,10 @@
// confirmation, "cannot be used on", or a WeenieError (YoureTooBusy retries).
// Without the v81 engine (or with dialog answering off) AC shows its own dialog and the player
// clicks it; the runner waits longer for that.
// Prepared rows (a server's trinket salvage): with no bag prepared at the chosen tier, a raw bag
// is first used on that tier's Ammunition (UB-IT's "prep salvage") and the step runs once the
// prepared bag shows up.
// Items a run finished are left out of later scans this session, so server rows that don't show
// on the item aren't applied twice and "auto next batch" moves on to the next items.
// Trinkets: with no bag prepared at the chosen tier, a raw bag is first used on that tier's
// Ammunition (UB-IT's "prep salvage") and the step runs once the prepared bag shows up.
// Items a run finished are left out of later scans this session, so ILT rows that don't show on
// the item aren't applied twice and "auto next batch" moves on to the next items.
using System;
using System.Collections.Generic;
using System.Linq;
@ -56,7 +55,7 @@ internal sealed class TinkerRunner
private const int MaxRetries = 3;
/// <summary>Appraisal requests one scan may send (the Items tab sees the whole pack).</summary>
private const int MaxAppraisalsPerScan = 25;
/// <summary>UB-IT polls up to ~30 s for the prepared bag.</summary>
/// <summary>UB-IT polls up to ~30 s for the prepared trinket bag.</summary>
private const long PrepTimeoutMs = 30_000;
/// <summary>Auto next batch: re-scan while items are still being appraised, this often and this many times.</summary>
private const long AutoRescanDelayMs = 3_000;
@ -89,7 +88,7 @@ internal sealed class TinkerRunner
private bool _manual;
private long _stepAt, _nextAt;
private Dictionary<int, TinkerRow> _byId = new();
/// <summary>The wait is for a bag being prepared, not a tinker.</summary>
/// <summary>The wait is for a trinket bag being prepared, not a tinker.</summary>
private bool _prep;
private int _prepsThisItem;
/// <summary>Bags this batch used up (auto next batch stops after a batch that used none).</summary>
@ -117,6 +116,8 @@ internal sealed class TinkerRunner
/// <summary>A job is on (set by Start, cleared by Stop: the queue empties before the batch-done step runs).</summary>
public bool Running => _active;
private volatile bool _active;
/// <summary>True while another crafting job (the Rings chain) owns the pack.</summary>
public Func<bool> Blocked { get; set; } = () => false;
public TinkerBench Bench => _bench;
public string Status => _status;
/// <summary>The last scan's rows (for <see cref="ScannedBench"/>).</summary>
@ -238,6 +239,7 @@ internal sealed class TinkerRunner
public void Start(TinkerBench bench)
{
if (Running) return;
if (Blocked()) { _status = "the Rings chain is running"; return; }
if (_scannedBench != (int)bench || _scan.Length == 0) { _status = "scan first"; return; }
_bench = bench;
_queue.Clear();
@ -434,7 +436,7 @@ internal sealed class TinkerRunner
_status = $"{facts.Name}: applying {_bagName}{pctText}{ask}";
}
/// <summary>The full bags that can serve a step (prepared rows: prepared at the chosen tier).</summary>
/// <summary>The full bags that can serve a step (trinket steps: prepared at the chosen tier).</summary>
private List<WorldObject> BagsFor(TinkerStep step)
=> Inv.Items()
.Where(b => b.ObjectClass == AcObjectClass.Salvage
@ -442,7 +444,7 @@ internal sealed class TinkerRunner
.ToList();
/// <summary>
/// No prepared bag: use a raw one on the tier's Ammunition (UB-IT's prep). The wait
/// No prepared trinket bag: use a raw one on the tier's Ammunition (UB-IT's prep). The wait
/// ends when a prepared bag shows up; the next tick then applies it.
/// </summary>
private void Prepare(long nowMs, TinkerStep step, string key, string matName)
@ -464,7 +466,7 @@ internal sealed class TinkerRunner
_step = step;
_prep = true;
if (!Host.UseOnFor(unchecked((uint)raw.Id), unchecked((uint)ammo.Id), "Crafting",
$"{TinkerCatalog.Label(_bench)}: prepare {matName} on {ammo.Name}", UseKind.Asked))
$"Trinkets: prepare {matName} on {ammo.Name}", UseKind.Asked))
{
if (!_manual) Host.ArmConfirmation(RynthCoreHost.ConfirmationKind.CraftInteraction, 0, 0);
Retry(nowMs, "the prepare request didn't go out");

View file

@ -1,15 +1,15 @@
// CraftingTab.cs - The Mini Remote's universal "Crafting" tab (every world, like Quests and Pets).
//
// UB-IT's crafting benches, one sub-tab each: Armor, Weapons (Melee / Missile / Caster),
// Jewelry, Trinkets and Items tinkering. (Infinite Leaftide's own crafting - chunking / clap,
// split arrows, the Rings inscription chain - belongs in RynthILT.) Every tinker tab has two
// sections:
// Jewelry, Trinkets and Items tinkering, and the Rings inscription chain. (Infinite Leaftide's
// chunking / clap and split-arrow tools stay on RynthILT's Gear tab.) Every tinker tab has
// two sections:
// * Retail tinkering - stock ACE salvage (TinkerCatalog.Retail), chance from TinkerMath;
// * Server tinkering - the connected server's own salvage, from the plugin that owns it (its
// "RynthServer.Profile" JSON's "salvage" list, MiniRemoteContext.ServerSalvage; RynthILT's on
// Infinite Leaftide), then the player's own rows for this world (CraftingTabState.CustomByWorld).
// With none defined it says so.
// One TinkerRunner works one tab's scan at a time.
// * Server tinkering - the connected server's own salvage: RynthAi's built-in rows on
// Infinite Leaftide, otherwise the active server plugin's (its profile's "salvage" list,
// MiniRemoteContext.ServerSalvage), then the player's own rows for this world
// (CraftingTabState.CustomByWorld). With none defined it says so.
// One TinkerRunner works one tab's scan at a time; the RingChainRunner and it never run together.
using System;
using System.Collections.Generic;
using System.Linq;
@ -25,6 +25,7 @@ internal sealed class CraftingTab
private readonly MiniRemoteContext _ctx;
public TinkerRunner Runner { get; }
public RingChainRunner Rings { get; }
// Custom-row editor (render thread only)
private int _newMaterial = TinkerCatalog.Steel;
@ -39,6 +40,8 @@ internal sealed class CraftingTab
{
_ctx = ctx;
Runner = new TinkerRunner(ctx, RowsFor, SettingsFor);
Rings = new RingChainRunner(ctx, () => Runner.Running);
Runner.Blocked = () => Rings.Running;
}
private CraftingTabState C => _ctx.State.Crafting;
@ -69,20 +72,35 @@ internal sealed class CraftingTab
private IReadOnlyList<TinkerMaterial> RowsFor(TinkerBench bench)
=> TinkerPlanner.Rows(bench, ServerRowsFor(bench), CustomRows());
/// <summary>The connected server's own salvage for a bench: what its plugin's profile defines.</summary>
/// <summary>
/// The connected server's own salvage for a bench: RynthAi's built-in rows on Infinite Leaftide
/// (RynthILT says so), otherwise what the active server plugin's profile defines.
/// </summary>
private IReadOnlyList<TinkerMaterial> ServerRowsFor(TinkerBench bench)
=> TinkerCatalog.FromServerPlugin(bench, _ctx.ServerSalvage);
=> _ctx.Ilt.IsIltWorld ? TinkerCatalog.ServerFor(bench) : TinkerCatalog.FromServerPlugin(bench, _ctx.ServerSalvage);
/// <summary>The connected server defines salvage for at least one bench.</summary>
private bool ServerHasSalvage => _ctx.ServerSalvage.Count > 0;
private bool ServerHasSalvage => _ctx.Ilt.IsIltWorld || _ctx.ServerSalvage.Count > 0;
// ── Lifecycle (MiniRemoteController) ─────────────────────────────────────────────────────────
public void Tick(long nowMs) => Runner.Tick(nowMs);
public void Tick(long nowMs)
{
Runner.Tick(nowMs);
Rings.Tick(nowMs);
}
public void OnChat(string text) => Runner.OnChat(text);
public void OnChat(string text)
{
Runner.OnChat(text);
Rings.OnChat(text);
}
public void OnLogout() => Runner.OnLogout();
public void OnLogout()
{
Runner.OnLogout();
Rings.OnLogout();
}
// ── UI (render thread) ──────────────────────────────────────────────────
@ -103,13 +121,26 @@ internal sealed class CraftingTab
}
if (ImGui.BeginTabItem("Jewelry")) { RenderBench(TinkerBench.Jewelry); ImGui.EndTabItem(); }
if (ImGui.BeginTabItem("Trinkets")) { RenderBench(TinkerBench.Trinkets); ImGui.EndTabItem(); }
if (ImGui.BeginTabItem("Rings"))
{
IltOnlyNote();
RenderRings();
ImGui.EndTabItem();
}
if (ImGui.BeginTabItem("Items")) { RenderBench(TinkerBench.Items); ImGui.EndTabItem(); }
ImGui.EndTabBar();
}
private void IltOnlyNote()
{
if (!_ctx.Ilt.IsIltWorld)
ImGui.TextColored(LegacyDashboardRenderer.ColAmber, "Infinite Leaftide recipes: this server may not have them.");
}
private void RenderBench(TinkerBench bench)
{
var s = SettingsFor(bench);
bool ilt = _ctx.Ilt.IsIltWorld;
string world = _ctx.WorldName;
bool weapon = bench is TinkerBench.Melee or TinkerBench.Missile or TinkerBench.Caster;
ImGui.PushID((int)bench);
@ -133,8 +164,8 @@ internal sealed class CraftingTab
if (serverRows.Count > 0)
{
RenderRows(s, serverRows, "server");
if (serverRows.Any(r => !r.UsesTinkSlot && r.AppliedInt == 0))
ImGui.TextDisabled("Rows without a tink slot don't show on the item: a run applies each once, and items\n"
if (ilt && weapon)
SafeImGui.TextDisabled("These weapon lines don't show on the item: a run applies each once, and items\n"
+ "finished this session are left out of later scans (Forget brings them back).");
}
else if (ServerHasSalvage)
@ -178,7 +209,7 @@ internal sealed class CraftingTab
}
}
/// <summary>Trinkets: the prepared salvage tier and whether to prepare raw bags on the tier's Ammunition.</summary>
/// <summary>Trinkets: the salvage tier and whether to prepare raw bags on the tier's Ammunition.</summary>
private void RenderTrinketOptions()
{
int tier = Math.Clamp(C.TrinketTier, 0, TinkerCatalog.TrinketTiers.Length - 1);
@ -253,7 +284,7 @@ internal sealed class CraftingTab
if (world.Length == 0) { ImGui.TextDisabled("Log in to add rows for this server."); return; }
var mine = CustomRows().Where(c => c.Bench == (int)bench).ToList();
var rows = TinkerPlanner.Rows(bench, null, mine).Where(r => r.Origin == TinkerOrigin.Custom).ToList();
var rows = TinkerPlanner.Rows(bench, false, mine).Where(r => r.Origin == TinkerOrigin.Custom).ToList();
if (rows.Count == 0) ImGui.TextDisabled("None yet.");
for (int i = 0; i < rows.Count; i++)
{
@ -370,7 +401,7 @@ internal sealed class CraftingTab
if (ImGui.SmallButton("Forget")) _ctx.Post(() => Runner.ForgetDone(bench));
ImGui.EndDisabled();
if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled))
ImGui.SetTooltip("Let finished items show in scans again (server rows that don't show on the item could go on twice).");
ImGui.SetTooltip("Let finished items show in scans again (Leaftide lines that don't show on the item could go on twice).");
}
bool running = Runner.Running;
@ -378,7 +409,7 @@ internal sealed class CraftingTab
ImGui.BeginDisabled(running);
if (ImGui.Button("Scan")) _ctx.Post(() => Runner.Scan(bench));
ImGui.SameLine();
ImGui.BeginDisabled(!mine || Runner.Rows.Length == 0);
ImGui.BeginDisabled(!mine || Runner.Rows.Length == 0 || Rings.Running);
if (ImGui.Button("Start"))
{
int n = Runner.Rows.Length;
@ -398,6 +429,8 @@ internal sealed class CraftingTab
ImGui.SameLine();
if (running && Runner.Bench != bench)
SafeImGui.TextColored(LegacyDashboardRenderer.ColAmber, $"{TinkerCatalog.Label(Runner.Bench)} is running");
else if (Rings.Running)
ImGui.TextColored(LegacyDashboardRenderer.ColAmber, "the Rings chain is running");
else
SafeImGui.TextDisabled(Runner.Status);
@ -431,4 +464,125 @@ internal sealed class CraftingTab
}
ImGui.EndTable();
}
// ── Rings ───────────────────────────────────────────────────────────────
/// <summary>The ring inscription chain: runs per recipe, Scan / Create / Stop, then the scrolls.</summary>
private void RenderRings()
{
ImGui.TextDisabled("Quill of Infliction -> Enlightened Quill -> partition quill -> glyph -> Inscription scroll -> ring.");
if (ImGui.BeginTable("##ringrecipes", 2, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingStretchProp))
{
ImGui.TableSetupColumn("Runs", ImGuiTableColumnFlags.WidthFixed, 100);
ImGui.TableSetupColumn("Recipe");
var runs = C.RingRuns;
foreach (var r in RingChain.Recipes)
{
ImGui.PushID(r.Id);
ImGui.TableNextRow();
ImGui.TableNextColumn();
int n;
lock (runs) n = runs.TryGetValue(r.Id, out int v) ? v : 0;
ImGui.SetNextItemWidth(90);
if (ImGui.InputInt("##runs", ref n, 1))
{
n = Math.Clamp(n, 0, RingChain.MaxRuns);
lock (runs)
{
if (n == 0) runs.Remove(r.Id);
else runs[r.Id] = n;
}
}
ImGui.TableNextColumn();
ImGui.TextUnformatted(r.Name);
if (ImGui.IsItemHovered()) SafeImGui.SetTooltip(r.Notes);
ImGui.PopID();
}
ImGui.EndTable();
}
bool running = Rings.Running;
bool tinkering = Runner.Running;
ImGui.BeginDisabled(running);
if (ImGui.Button("Scan##rings")) _ctx.Post(() => Rings.Scan());
ImGui.SameLine();
ImGui.BeginDisabled(tinkering);
if (ImGui.Button("Create"))
{
int total = RingChain.Expand(id => { lock (C.RingRuns) return C.RingRuns.TryGetValue(id, out int v) ? v : 0; }).Count;
_ctx.Confirm("Rings chain", $"Craft {total} combine(s)?\n\nEvery Step 1 run goes first, then Step 2, then Step 3.\nThe ingredients are used up.",
() => Rings.Create(), "Create");
}
ImGui.EndDisabled();
ImGui.EndDisabled();
ImGui.SameLine();
ImGui.BeginDisabled(!running);
if (ImGui.Button("Stop##rings")) _ctx.Post(() => Rings.Stop("stopped by player"));
ImGui.EndDisabled();
ImGui.SameLine();
if (tinkering) SafeImGui.TextColored(LegacyDashboardRenderer.ColAmber, $"{TinkerCatalog.Label(Runner.Bench)} tinkering is running");
else SafeImGui.TextDisabled(Rings.Status);
var lines = Rings.ScanLines;
if (lines.Length > 0 && ImGui.BeginTable("##ringscan", 2, ImGuiTableFlags.RowBg | ImGuiTableFlags.Borders | ImGuiTableFlags.SizingStretchProp))
{
foreach (var l in lines)
{
ImGui.TableNextRow();
ImGui.TableNextColumn();
if (l.Found == null) { SafeImGui.TextColored(LegacyDashboardRenderer.ColTeal, l.Text); continue; }
ImGui.TextUnformatted(" " + l.Text);
ImGui.TableNextColumn();
if (l.State == 0) ImGui.TextUnformatted(l.Found);
else if (l.State == 1) SafeImGui.TextDisabled(l.Found);
else SafeImGui.TextColored(LegacyDashboardRenderer.ColAmber, l.Found);
}
ImGui.EndTable();
}
ImGui.Separator();
RenderScrolls(running || tinkering);
}
/// <summary>The carried inscription scrolls: one to the selected item, or all to the last scan's items.</summary>
private void RenderScrolls(bool busy)
{
ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Inscription scrolls");
var scrolls = Rings.Scrolls;
if (scrolls.Length == 0) { ImGui.TextDisabled("None carried (Scan to look again)."); return; }
ImGui.BeginDisabled(busy);
foreach (var (id, name) in scrolls)
{
ImGui.PushID(id);
if (ImGui.SmallButton("Apply to selected"))
{
int scrollId = id;
string scrollName = name;
_ctx.Confirm("Ring inscription", $"Use {scrollName} on the item selected in AC?",
() => Rings.ApplyToSelected(scrollId), "Apply");
}
ImGui.SameLine();
ImGui.TextUnformatted(name);
ImGui.PopID();
}
// UB-IT pairs the scrolls with the last Jewelry or weapon scan's items.
int scanned = Runner.ScannedBench;
bool usable = scanned is (int)TinkerBench.Jewelry or (int)TinkerBench.Melee or (int)TinkerBench.Missile or (int)TinkerBench.Caster;
var targets = usable ? Runner.Rows.Select(r => r.Id).ToList() : new List<int>();
string from = usable ? TinkerCatalog.Label((TinkerBench)scanned) : "Jewelry / Weapons";
ImGui.BeginDisabled(targets.Count == 0);
if (ImGui.Button($"Apply all to the last {from} scan ({targets.Count})"))
{
int pairs = Math.Min(targets.Count, scrolls.Length);
_ctx.Confirm("Ring inscriptions", $"Use {pairs} inscription scroll(s) on the items of the last {from} scan, one each?",
() => Rings.ApplyToItems(targets), "Apply");
}
ImGui.EndDisabled();
if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled))
SafeImGui.SetTooltip("Scrolls in glyph order go on the scanned items in id order (UB-IT's pairing).\n"
+ "Scan the Jewelry or a Weapons tab first.");
ImGui.EndDisabled();
}
}

View file

@ -35,7 +35,7 @@ internal sealed class MiniRemoteController
/// <summary>Where the quest UI went (chat reply for the retired "/ra quests" verbs and tab names).</summary>
public const string QuestsMovedText =
"[Mini Remote] Quests moved to RynthOracle: /ro (Quests tab: timers, tracking, rewards), /ro timers (Quest Timers window).";
"[Mini Remote] Quests moved to RynthOracle: /ro (Quests tab: timers, tracking, rewards, /qb), /ro timers (Quest Timers window).";
private readonly MiniRemoteContext _ctx;
private readonly Func<QuestTracker?> _quests;
@ -45,7 +45,7 @@ internal sealed class MiniRemoteController
private bool _confirmOpened;
public PetsTab Pets { get; }
/// <summary>The Crafting tab (tinker benches and server salvage; any world). SilentKelpie's.</summary>
/// <summary>The Crafting tab (tinker benches and the Rings chain; any world).</summary>
public CraftingTab Crafting { get; }
public VTankUsdImporter Usd { get; }
@ -113,13 +113,14 @@ internal sealed class MiniRemoteController
}
}
/// <summary>Pump-thread chat line (the heal pet's heal). Never eats.</summary>
/// <summary>Pump-thread chat line (the heal pet's heal, a tinker run's results). Never eats.</summary>
public void OnChat(string text)
{
if (string.IsNullOrEmpty(text)) return;
try { Pets.OnChat(text.TrimEnd('\r', '\n')); }
string line = text.TrimEnd('\r', '\n');
try { Pets.OnChat(line); }
catch (Exception ex) { RynthLog.Exception(LogCat.Pets, ex, "PetsTab.OnChat"); }
try { Crafting.OnChat(text.TrimEnd('\r', '\n')); }
try { Crafting.OnChat(line); }
catch (Exception ex) { RynthLog.Exception(LogCat.Crafting, ex, "CraftingTab.OnChat"); }
}
@ -220,11 +221,10 @@ internal sealed class MiniRemoteController
// ── Commands ────────────────────────────────────────────────────────────
/// <summary>
/// "/ra hub [show|hide|toggle|open pets|crafting [show|hide|toggle]|open breeding|tab pets|crafting|breeding|remote]",
/// "/ra hub [show|hide|toggle|open pets|breeding|crafting [show|hide|toggle]|tab pets|breeding|crafting|remote]",
/// "/ra quests [refresh]", "/ra pets [show|hide|toggle]"; every other "/ra hub ..." verb,
/// "/ra guardian ..." and "/ra bounty|bounties|bountys ..." go to RynthILT. The retired quest
/// verbs and tab names ("/ra quests window", "/ra hub open quests", ...) say where quests went,
/// and "/ra hub open|tab character" opens RynthOracle's Character tab (Huds/MovedTabs.cs).
/// verbs and tab names ("/ra quests window", "/ra hub open quests", ...) say where quests went.
/// Returns false if not handled.
/// </summary>
public bool HandleCommand(string verb, string[] args)
@ -254,14 +254,22 @@ internal sealed class MiniRemoteController
_ctx.Chat(QuestsMovedText);
return true;
}
// "/ra hub open|tab character": the Character tab left the Mini Remote (2026-10-13);
// HudController.HandleTabCommand opens RynthOracle's Character tab.
// "/ra hub open|tab character|charms|banking": those left the Mini Remote (2026-10-13);
// HudController.HandleTabCommand opens RynthOracle's Character tab or Global Inventory > Banking.
if (cmd is "open" or "tab" && args.Length > 1 && Huds.MovedTabs.CommandFor(args[1]) != null)
{
string? reply = MiniRemoteTabCommand?.Invoke(args[1].Trim().ToLowerInvariant(), "show");
if (cmd == "open" && reply != null) _ctx.Chat("[Mini Remote] " + reply);
return true;
}
// "/ra hub open|tab breeding": the Pets tab on its Breeding sub-tab (RynthOracle's Pet Breeding tab links here).
if (cmd is "open" or "tab" && args.Length > 1 && args[1].Trim().ToLowerInvariant() is "breeding" or "breed")
{
Pets.SelectBreeding();
if (cmd == "open") OpenTab(MiniRemoteTabs.Pets, "show");
else MiniRemoteTabCommand?.Invoke(MiniRemoteTabs.Pets, "select");
return true;
}
switch (cmd)
{
case "show":
@ -270,9 +278,6 @@ internal sealed class MiniRemoteController
// The Mini Remote is the Hub's main window.
_ctx.Chat(MiniRemoteCommand != null ? MiniRemoteCommand(cmd) : "[Mini Remote] The Mini Remote is not available yet.");
return true;
case "open" or "tab" when args.Length > 1 && IsBreedingTabName(args[1]):
OpenBreeding(cmd);
return true;
case "open" when args.Length > 1 && MiniRemoteTabs.Parse(args[1]) is { } openTab:
OpenTab(openTab, args.Length > 2 ? args[2] : "toggle");
return true;
@ -299,37 +304,10 @@ internal sealed class MiniRemoteController
private void PrintHelp()
{
_ctx.Chat("[Mini Remote] /ra hub [show|hide|toggle] (Mini Remote) /ra hub open pets|crafting [show|hide|toggle] /ra hub open breeding (ILT)");
_ctx.Chat("[Mini Remote] /ra hub [show|hide|toggle] (Mini Remote) /ra hub open pets|crafting [show|hide|toggle]");
_ctx.Chat("[Mini Remote] /ra quests refresh (quiet /myquests) /ra pets [show|hide] Quest list, timers and rewards: RynthOracle (/ro).");
_ctx.Chat("[Mini Remote] Banking, gear, charms, games, the Guardian, bounties, /ra hub attr ...: Infinite Leaftide, the RynthILT plugin.");
_ctx.Chat("[Mini Remote] Character overview and session: RynthOracle (/ro character). Force a server: /rc diagnostics.");
}
/// <summary>"breeding" / "breed": the Pets tab's Breeding sub-tab (RynthILT's tracker, Infinite Leaftide).</summary>
private static bool IsBreedingTabName(string text) => text.Trim().ToLowerInvariant() is "breeding" or "breed";
/// <summary>
/// "/ra hub open|tab breeding": the Pets tab on its Breeding sub-tab when RynthILT offers it. "open"
/// shows the Mini Remote and says why when there is no Breeding sub-tab; "tab" (the engine's
/// dashboard) only switches tabs, to the Pets roster when there is none.
/// </summary>
private void OpenBreeding(string cmd)
{
bool offered = Pets.BreedingOffered;
if (offered) Pets.SelectBreeding();
if (cmd == "tab")
{
MiniRemoteTabCommand?.Invoke(MiniRemoteTabs.Pets, "select");
return;
}
if (!offered)
{
_ctx.Chat("[Mini Remote] " + (!_ctx.Ilt.Loaded ? IltClient.NotLoaded
: !_ctx.Ilt.IsIltWorld ? "Pet breeding is an Infinite Leaftide feature; this world isn't Infinite Leaftide."
: "This server reports pet breeding off."));
return;
}
OpenTab(MiniRemoteTabs.Pets, "show");
_ctx.Chat("[Mini Remote] Gear, games, the Guardian, bounties, /ra hub attr ...: Infinite Leaftide, the RynthILT plugin.");
_ctx.Chat("[Mini Remote] Character and charms: RynthOracle (/ro character). Banking: Global Inventory (/ginv bank). Force a server: /rc diagnostics.");
}
private static bool IsRemoteTabName(string text)

View file

@ -21,7 +21,7 @@ public sealed class MiniRemoteState
public int SchemaVersion = 1;
public PetTabState Pet = new();
public QuestsTabState Quests = new();
/// <summary>The Crafting tab (tinker benches); the ILT Hub's Crafting before.</summary>
/// <summary>The Crafting tab (tinker benches, Rings chain); the ILT Hub's Crafting before.</summary>
public CraftingTabState Crafting = new();
/// <summary>Last VTank .usd file the importer read (the ILT Hub's Gear.LastUsdPath before).</summary>
public string LastUsdPath = string.Empty;
@ -44,17 +44,18 @@ public sealed class CraftingTabState
public bool AutoNextBatch;
/// <summary>...and start it without asking again.</summary>
public bool AutoStartNextBatch;
/// <summary>Prepared salvage tier: 0 Minor, 1 Moderate, 2 Major (TinkerCatalog.TrinketTiers).</summary>
/// <summary>Trinket salvage tier: 0 Minor, 1 Moderate, 2 Major (TinkerCatalog.TrinketTiers).</summary>
public int TrinketTier;
/// <summary>Prepare a raw bag on the tier's Ammunition when no prepared bag is carried.</summary>
/// <summary>Prepare a raw trinket bag on the tier's Ammunition when no prepared bag is carried.</summary>
public bool TrinketPrep;
// "RingRuns" (the Rings chain, now left to RynthILT) may still be in older files: it is ignored.
/// <summary>Rings chain: recipe id (RingChain) to how many times to craft it.</summary>
public Dictionary<string, int> RingRuns = new();
}
/// <summary>One tinker bench's choices.</summary>
public sealed class TinkerBenchSettings
{
/// <summary>Row key (TinkerCatalog.Key: r/p/c + material id) to how many times (imbues and flags: 0 or 1).</summary>
/// <summary>Row key (TinkerCatalog.Key: r/s/c + material id) to how many times (imbues and flags: 0 or 1).</summary>
public Dictionary<string, int> Counts = new();
/// <summary>Skip a step whose chance is under this percent (0 = any chance).</summary>
public int MinChancePercent;
@ -123,7 +124,7 @@ public sealed class PetTabState
// Auto siphon-lens capture (ACECustom MonsterCapture; Mini Remote > Pets).
/// <summary>When on, use the selected siphon lens on a nearby creature once it is weak enough.</summary>
public bool AutoCaptureEnabled;
/// <summary>Index into <see cref="PetCaptureRules.Lenses"/> (Flawed to Asheron).</summary>
/// <summary>Index into <see cref="PetCaptureRules.Lenses"/> (Flawed…Asheron's).</summary>
public int CaptureLensIndex;
}
@ -264,6 +265,7 @@ internal sealed class MiniRemoteStore
s.Crafting ??= new CraftingTabState();
s.Crafting.Benches ??= new();
s.Crafting.CustomByWorld ??= new();
s.Crafting.RingRuns ??= new();
s.Crafting.BatchSize = Math.Clamp(s.Crafting.BatchSize, 1, 200);
s.Crafting.TrinketTier = Math.Clamp(s.Crafting.TrinketTier, 0, 2);
s.LastUsdPath ??= string.Empty;

View file

@ -0,0 +1,124 @@
// PetDamageTint.cs — damage-type colours and pet essence school picking, after UB-ILT.
//
// Palette: UB-ILT Lib\LeaftideDamageTypeVtColors.ForDamageTypeFlag (the Virindi Tank / Leaftide
// label colours its Items, Spell and Pets tabs share). The engine's Items panel uses the same
// values (RynthCore ImGui\Panels\DamageTypeColors.cs); keep the two tables in step.
// School picking: UB-ILT Lib\PetDamageTypeTintPolicy.PickFlag (v2.0.1119).
using System;
using System.Numerics;
namespace RynthCore.Plugin.RynthAi.MiniRemote;
/// <summary>ACE damage-type flags, colours per school, and the pet essence school pick.</summary>
internal static class PetDamageTint
{
public const uint Slash = 1, Pierce = 2, Bludgeon = 4, SlashPierce = 3, Cold = 8, Fire = 16,
Acid = 32, Lightning = 64, Nether = 1024;
/// <summary>Text colour when the school is unknown (white, as UB for an essence in the pack).</summary>
public static readonly Vector4 Unknown = new(0.95f, 0.95f, 0.95f, 1f);
// Combined masks are read in this order (UB DamageProbeOrder): elements before physical.
private static readonly uint[] ProbeOrder = { Nether, Lightning, Acid, Fire, Cold, Bludgeon, SlashPierce, Pierce, Slash };
/// <summary>Colour for a school name as RynthAi writes it (Slash, Pierce, Bludgeon, Fire, Cold, Lightning, Acid, Nether).</summary>
public static Vector4 ForName(string? school) => school switch
{
"Slash" or "Slashing" => Rgb(255, 180, 120),
"Pierce" or "Piercing" => Rgb(240, 200, 140),
"Bludgeon" or "Bludgeoning" => Rgb(220, 190, 140),
"Slash/Pierce" => Rgb(255, 160, 100),
"Cold" or "Frost" => Rgb(160, 210, 255),
"Fire" => Rgb(255, 130, 70),
"Acid" => Rgb(160, 255, 140),
"Lightning" or "Electric" or "Storm" => Rgb(255, 240, 120),
"Nether" => Rgb(200, 160, 255),
_ => Unknown,
};
/// <summary>School name for one flag (empty for 0 or an undefined value).</summary>
public static string Name(uint flag) => flag switch
{
Slash => "Slash",
Pierce => "Pierce",
Bludgeon => "Bludgeon",
SlashPierce => "Slash/Pierce",
Cold => "Cold",
Fire => "Fire",
Acid => "Acid",
Lightning => "Lightning",
Nether => "Nether",
_ => string.Empty,
};
/// <summary>
/// One school for a pet essence: the captured source's damage (ACE 9054), else the essence's
/// DamageType mask (45), else the name ("Fire Banshee Essence", "Incendiary Knight"). 0 = unknown.
/// ILT reuses 9054 as the min-summon-aug id on some builds, where 1/2/4 read as Slash/Pierce/
/// Bludgeon; an elemental name wins over such a physical-only property read.
/// </summary>
public static uint PickPetFlag(int capturedSourceDamageType, int damageTypeMask, string? displayName)
{
uint fromProps = PickFromProperties(capturedSourceDamageType, damageTypeMask);
uint fromName = InferFromName(displayName);
if (fromName != 0 && IsPhysicalOnly(fromProps)) return fromName;
return fromProps != 0 ? fromProps : fromName;
}
/// <summary>School from Mag-Tools essence names and ILT catalog adjectives (whole words only).</summary>
public static uint InferFromName(string? displayName)
{
if (string.IsNullOrWhiteSpace(displayName)) return 0;
string n = displayName.ToLowerInvariant();
if (HasAny(n, "nether")) return Nether;
if (HasAny(n, "lightning", "electric", "voltaic", "galvanic", "electrified", "shocked", "excited", "volt", "shock"))
return Lightning;
if (HasAny(n, "acid", "caustic", "corrosion", "blistered", "blistering", "corrosive")) return Acid;
if (HasAny(n, "fire", "flaming", "incendiary", "charred", "volcanic", "scorched", "pyre", "magma", "ember"))
return Fire;
if (HasAny(n, "frost", "glacial", "frozen", "frigid", "freezing", "arctic", "blizzard", "ice", "chill"))
return Cold;
if (HasAny(n, "bludgeon", "bludgeoning")) return Bludgeon;
if (HasAny(n, "slash", "slashing")) return Slash;
if (HasAny(n, "pierce", "piercing")) return Pierce;
return 0;
}
private static uint PickFromProperties(int captured, int mask)
{
if (IsDefined(captured)) return (uint)captured;
if (IsDefined(mask)) return (uint)mask;
if (mask <= 0) return 0;
uint m = unchecked((uint)mask);
foreach (uint v in ProbeOrder)
if ((m & v) == v) return v;
return 0;
}
private static bool IsDefined(int raw) => raw > 0 && Name(unchecked((uint)raw)).Length > 0;
private static bool IsPhysicalOnly(uint flag) => flag is Slash or Pierce or Bludgeon or SlashPierce;
private static bool HasAny(string haystack, params string[] tokens)
{
foreach (string t in tokens)
if (HasToken(haystack, t)) return true;
return false;
}
/// <summary>True when <paramref name="token"/> appears as a whole word ("ice" not in "Novice").</summary>
private static bool HasToken(string haystack, string token)
{
int i = 0;
while ((i = haystack.IndexOf(token, i, StringComparison.Ordinal)) >= 0)
{
int end = i + token.Length;
if ((i == 0 || !char.IsLetter(haystack[i - 1])) && (end >= haystack.Length || !char.IsLetter(haystack[end])))
return true;
i++;
}
return false;
}
private static Vector4 Rgb(int r, int g, int b) => new(r / 255f, g / 255f, b / 255f, 1f);
}

View file

@ -152,9 +152,9 @@ internal static class PetStatsReader
_ => string.Empty,
};
int dmg = inv.Int(wo, IntCapturedDamageType);
if (dmg <= 0) dmg = inv.Int(wo, IntDamageType);
s.DamageType = DamageTypeName(dmg);
// Most essences carry neither property; the name then gives the school (UB-ILT v2.0.1119).
s.DamageType = PetDamageTint.Name(PetDamageTint.PickPetFlag(
inv.Int(wo, IntCapturedDamageType), inv.Int(wo, IntDamageType), wo.Name));
// Gear ratings first (what Mag ItemInfo shows), else the base rating ids.
s.D = inv.Int(wo, IntGearDamage);
@ -290,20 +290,6 @@ internal static class PetStatsReader
return sb.Length > 0 ? "[" + sb + "]" : string.Empty;
}
/// <summary>Single AC DamageType flag → name (combined flags return empty).</summary>
private static string DamageTypeName(int flags) => flags switch
{
1 => "Slash",
2 => "Pierce",
4 => "Bludgeon",
8 => "Cold",
16 => "Fire",
32 => "Acid",
64 => "Lightning",
1024 => "Nether",
_ => string.Empty,
};
private static bool TryBool(RynthCoreHost host, uint id, uint stype, out bool v)
{
v = false;

View file

@ -24,7 +24,7 @@
// * Healing pet (UB HealingBuddy subset): summons a heal pet when HP drops, dismisses it
// after the heal lands, holds PetManager's combat summons while it is out.
// * Auto siphon capture (ACECustom MonsterCapture): when enabled, uses the chosen lens on the
// nearest attackable creature within 5 m once it is <=20% health or under 20 HP (Asheron's
// nearest attackable creature within 5 m once it is ≤20% health or under 20 HP (Asheron's
// Lens skips the health gate). Resonance still needs a prior failed capture on the server.
// * /pets and /shinies logs: RynthILT's (RynthILT.Hub section "pets-logs", ILT only).
// * Breeding sub-tab (Infinite Leaftide only): the tab becomes Roster | Breeding when RynthILT
@ -475,8 +475,6 @@ internal sealed class PetsTab
if (essence != null) _ctx.Inventory.Use(essence);
}
// ── Active pet ──────────────────────────────────────────────────────────
// ── Auto siphon capture (ACECustom MonsterCapture) ───────────────────────
/// <summary>
@ -611,6 +609,8 @@ internal sealed class PetsTab
return true;
}
// ── Active pet ──────────────────────────────────────────────────────────
/// <summary>The live "&lt;Me&gt;'s …" creature (server pet naming), or null.</summary>
private WorldObject? FindOwnPet()
{
@ -899,19 +899,23 @@ internal sealed class PetsTab
/// <summary>Shows the Breeding sub-tab on the next frame (any thread).</summary>
public void SelectBreeding() => _selectBreeding = true;
/// <summary>
/// RynthILT offers the Breeding sub-tab: it calls this world Infinite Leaftide and the server
/// hasn't reported pet breeding off. False without RynthILT. Any thread.
/// </summary>
public bool BreedingOffered => _ctx.Ilt.IsIltWorld && !_ctx.Ilt.IsOff(RynthIltHub.FeaturePetBreeding);
/// <summary>Whether auto siphon-lens capture is on (Mini Remote Capture toggle; settings on the roster).</summary>
/// <summary>Whether auto siphon-lens capture is on (Mini Remote Options / Pets roster).</summary>
public bool AutoCaptureEnabled
{
get => S.AutoCaptureEnabled;
set => S.AutoCaptureEnabled = value;
}
/// <summary>Selected siphon lens index (<see cref="PetCaptureRules.LensNames"/>).</summary>
public int CaptureLensIndex
{
get => S.CaptureLensIndex;
set => S.CaptureLensIndex = value;
}
/// <summary>Live auto-capture status line for the Mini Remote capture row.</summary>
public string CaptureStatus => _captureStatus;
/// <summary>
/// Mini Remote Pet toggle on: enable combat auto-summon and summon the Pets tab's active
/// combat essence now (first ticked priority, or the highlighted row). Pump thread.
@ -932,19 +936,14 @@ internal sealed class PetsTab
}
/// <summary>
/// The Pets tab: the universal roster, and on Infinite Leaftide the Roster | Breeding sub-tabs
/// (Breeding is drawn by RynthILT).
/// The Pets tab: the universal Roster, and Breeding (RynthILT's breeding tracker, section
/// "pets-breeding", the same tracker as RynthOracle's Pet Breeding tab).
/// </summary>
public void Render()
{
var settings = _ctx.Settings;
if (settings == null) { ImGui.TextDisabled("Not logged in."); return; }
if (!BreedingOffered)
{
RenderRoster(settings);
return;
}
if (!ImGui.BeginTabBar("##petsub")) return;
if (ImGui.BeginTabItem("Roster##petroster"))
{
@ -955,9 +954,7 @@ internal sealed class PetsTab
_selectBreeding = false;
if (BeginTab(BreedingTabLabel, breedFlags))
{
// RynthILT's tracker; an older RynthILT (before 0.3.1) has no such section and draws nothing.
if (!_ctx.Ilt.RenderSection(RynthIltHub.SectionPetBreeding))
ImGui.TextDisabled("This RynthILT has no pet breeding tracker; update RynthILT to 0.3.1 or later.");
RenderBreeding();
ImGui.EndTabItem();
}
ImGui.EndTabBar();
@ -965,16 +962,33 @@ internal sealed class PetsTab
private static readonly byte[] BreedingTabLabel = System.Text.Encoding.UTF8.GetBytes("Breeding##petbreeding\0");
/// <summary>
/// BeginTabItem with flags but no close button (ImGui.NET pairs the flags overload with p_open,
/// which draws an X on the tab).
/// </summary>
/// <summary>BeginTabItem with flags but no close button (ImGui.NET pairs the flags overload with p_open, which draws an X).</summary>
private static unsafe bool BeginTab(byte[] labelUtf8Z, ImGuiTabItemFlags flags)
{
fixed (byte* label = labelUtf8Z)
return ImGuiNative.igBeginTabItem(label, null, flags) != 0;
}
/// <summary>
/// Breeding is Infinite Leaftide's and RynthILT's: drawn by RynthILT, with a pointer when it
/// isn't loaded or this isn't an ILT world.
/// </summary>
private void RenderBreeding()
{
if (!_ctx.Ilt.Loaded)
{
ImGui.TextDisabled("Pet breeding is tracked by RynthILT (the Infinite Leaftide plugin), which isn't loaded.");
return;
}
if (!_ctx.Ilt.IsIltWorld)
{
ImGui.TextDisabled("Pet breeding is an Infinite Leaftide feature; this world isn't Infinite Leaftide.");
return;
}
if (!_ctx.Ilt.RenderSection(RynthIltHub.SectionPetBreeding))
ImGui.TextDisabled("This RynthILT has no breeding tracker yet; update RynthILT to 0.2.7 or later.");
}
/// <summary>The universal roster: types, summons, ILT charms, healing pets and RynthILT's /pets logs.</summary>
private void RenderRoster(LegacyUiSettings settings)
{
@ -1050,7 +1064,7 @@ internal sealed class PetsTab
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Dismiss the pet that is out.");
ImGui.SameLine();
if (ImGui.Button("Scan pack")) _ctx.Post(ScanPack);
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Appraise every pet to refresh bond, potency and breeding, and check pet-named items\n(an \"... Essence\" name alone isn't enough — the item must be a summoning pet device).");
if (ImGui.IsItemHovered()) SafeImGui.SetTooltip("Appraise every pet to refresh bond, potency and breeding, and check pet-named items\n(an \"... Essence\" name alone isn't enough — the item must be a summoning pet device).");
ImGui.SameLine();
if (ImGui.Button("Add sel.")) _ctx.Post(() => AddSelectedAs(summonKind));
if (ImGui.IsItemHovered()) SafeImGui.SetTooltip($"Make the item selected in your pack a {KindNames[(int)kind].ToLowerInvariant()} pet.");
@ -1148,7 +1162,7 @@ internal sealed class PetsTab
_highlightId = _highlightId == r.Id ? 0 : r.Id;
RenderRowContextMenu(r);
ImGui.SetCursorPos(start);
SafeImGui.TextColored(DamageColor(r.DamageType), r.Line1);
SafeImGui.TextColored(PetDamageTint.ForName(r.DamageType), r.Line1);
SafeImGui.TextColored(LegacyDashboardRenderer.ColAmber, " " + r.Line2);
if (r.UsesMax > 0 && r.UsesCur == 0) SafeImGui.TextColored(LegacyDashboardRenderer.ColHp, " " + r.Line3);
else SafeImGui.TextDisabled(" " + r.Line3);
@ -1183,17 +1197,6 @@ internal sealed class PetsTab
ImGui.EndPopup();
}
/// <summary>Line-1 colour by the pet's damage type (white when unknown / not appraised).</summary>
private static Vector4 DamageColor(string damageType) => damageType switch
{
"Fire" => new Vector4(1.00f, 0.55f, 0.30f, 1f),
"Cold" => new Vector4(0.55f, 0.80f, 1.00f, 1f),
"Acid" => new Vector4(0.55f, 0.95f, 0.45f, 1f),
"Lightning" => new Vector4(0.85f, 0.70f, 1.00f, 1f),
"Nether" => new Vector4(0.75f, 0.50f, 0.90f, 1f),
_ => new Vector4(0.95f, 0.95f, 0.95f, 1f),
};
private void RenderCharms()
{
ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Pet charms");