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

@ -138,10 +138,53 @@ public sealed class LootEditItemRequest
/// 2026-10-07; an older engine never sends it, so it reads false.
/// </summary>
public bool IncludeT11 { get; set; }
/// <summary>
/// The attribute checklist's choices (added 2026-10-18), one per row the player changed; rows
/// without a choice keep their default (ticked for "items like this", T11 rows with
/// IncludeT11). Null from an older engine: every row at its default, as before.
/// </summary>
public List<LootEditItemChoice>? Choices { get; set; }
/// <summary>Echoed in the draft so the popup knows the answer is to its latest ask.</summary>
public int Seq { get; set; }
}
/// <summary>One checklist row as the player set it (LootEditItemAttribute.Id).</summary>
public sealed class LootEditItemChoice
{
public string Id { get; set; } = string.Empty;
public bool On { get; set; }
/// <summary>A LootItemAttributeOp code; -1 = the row's default.</summary>
public int Op { get; set; } = -1;
/// <summary>The edited value; empty = the item's own.</summary>
public string Value { get; set; } = string.Empty;
}
/// <summary>
/// One row of the popup's attribute checklist (added 2026-10-18): something the item has that a
/// rule can require, its value, and how it is required now.
/// </summary>
public sealed class LootEditItemAttribute
{
/// <summary>Stable within the item ("L:131", "D:152", "spell:Major Strength", "t11:tier").</summary>
public string Id { get; set; } = string.Empty;
/// <summary>Item, Weapon / Armor, Ratings, Spells, Pet essence, T11, Requirements.</summary>
public string Group { get; set; } = string.Empty;
public string Label { get; set; } = string.Empty;
/// <summary>The item's own value, for display ("Gold", "7", "1.12", "Major").</summary>
public string ItemValue { get; set; } = string.Empty;
/// <summary>The value the rule uses now (the item's, or the player's edit).</summary>
public string Value { get; set; } = string.Empty;
/// <summary>The row's comparison now (LootItemAttributeOp).</summary>
public int Op { get; set; }
/// <summary>The comparisons the row offers, the default first.</summary>
public List<int> Ops { get; set; } = new();
/// <summary>The value can be typed (a number); named values and spells can't.</summary>
public bool Editable { get; set; }
/// <summary>The rule requires this row now.</summary>
public bool On { get; set; }
public string Tip { get; set; } = string.Empty;
}
/// <summary>The rule an item makes, as the popup shows it, and what happened when it was added.</summary>
public sealed class LootEditItemDraft
{
@ -182,6 +225,13 @@ public sealed class LootEditItemDraft
/// </summary>
public string BuiltInReason { get; set; } = string.Empty;
public List<string> Notes { get; set; } = new();
/// <summary>
/// True from a RynthAi with the attribute checklist (added 2026-10-18): the popup shows
/// <see cref="Attributes"/> instead of its single "Include T11 attributes" box.
/// </summary>
public bool AttributesSupported { get; set; }
/// <summary>The item's checklist rows, grouped in display order (added 2026-10-18).</summary>
public List<LootEditItemAttribute> Attributes { get; set; } = new();
/// <summary>item_add went through; Message says what was added where.</summary>
public bool Added { get; set; }
public string Message { get; set; } = string.Empty;

View file

@ -0,0 +1,539 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using RynthCore.Loot.T11;
using RynthCore.Loot.VTank;
namespace RynthCore.Loot.Editing;
// "Add to loot profile"'s attribute checklist (2026-10-18): every attribute a clicked item
// has that a loot rule can require, grouped for the popup, each with the item's value, the
// comparisons it offers and whether it is ticked by default. LootItemRules.Build turns the
// ticked rows into conditions, in row order. With no choices from the popup (an older engine,
// /ra loot add) the defaults reproduce the rules "items like this" and "Include T11
// attributes" always made.
/// <summary>How a checklist row is required (LootEditItemAttribute.Op).</summary>
public enum LootItemAttributeOp
{
AtLeast = 0,
Exactly = 1,
AtMost = 2,
Not = 3,
/// <summary>A spell by its exact name.</summary>
SpellExact = 10,
/// <summary>This spell at this tier or a higher one (Major Strength: Major, Epic or Legendary).</summary>
SpellOrBetter = 11,
/// <summary>This spell at any tier.</summary>
SpellAnyTier = 12,
}
/// <summary>One checklist row while a rule is built (the wire form is LootEditItemAttribute).</summary>
public sealed class LootItemAttribute
{
internal enum Shape { Long, Double, TotalRatings, Spell, CantripTier, SpellCount }
public string Id { get; init; } = string.Empty;
public string Group { get; init; } = string.Empty;
public string Label { get; init; } = string.Empty;
public string Tip { get; init; } = string.Empty;
internal Shape Kind { get; init; }
/// <summary>The property key (long or double rows), or the cantrip tier (CantripTier rows).</summary>
internal int Key { get; init; }
internal double ItemValue { get; init; }
public string ItemText { get; init; } = string.Empty;
public LootItemAttributeOp[] Ops { get; init; } = Array.Empty<LootItemAttributeOp>();
/// <summary>The item's value can be replaced by a typed number.</summary>
public bool Editable { get; init; }
/// <summary>Spell rows: the spell's name.</summary>
internal string Spell { get; init; } = string.Empty;
// Where the row stands now (defaults, then the player's choice).
public bool On { get; set; }
public LootItemAttributeOp Op { get; set; }
internal double Value { get; set; }
/// <summary>The value as the player typed it (empty: the item's).</summary>
internal string Typed { get; set; } = string.Empty;
public LootEditItemAttribute ToWire() => new()
{
Id = Id, Group = Group, Label = Label, ItemValue = ItemText, Tip = Tip, Editable = Editable, On = On,
Op = (int)Op, Ops = new List<int>(Array.ConvertAll(Ops, o => (int)o)),
Value = Editable ? LootItemAttributes.Number(Value) : ItemText,
};
}
public static class LootItemAttributes
{
public const string GroupItem = "Item", GroupGear = "Weapon / Armor", GroupRatings = "Ratings", GroupSpells = "Spells",
GroupPet = "Pet essence", GroupT11 = "T11", GroupRequirements = "Requirements";
/// <summary>Cantrip tiers, lowest first: "Major Strength" is tier 2.</summary>
public static readonly string[] CantripTiers = { "Minor", "Major", "Epic", "Legendary" };
private static readonly string[] Roman = { "I", "II", "III", "IV", "V", "VI", "VII", "VIII" };
// Pet essence property ids (ACECustom; the Mini Remote's PetStats reads the same).
public const int KeyBond = 9053, KeyCapturedDamageType = 9054, KeyPotencyStored = 9056, KeyBreedingCharges = 9057,
KeyMutations = 9075, KeySummoningMastery = 362, KeyUseLevelRequirement = 364, KeyUseRequiresSkill = 366,
KeyUseRequiresSkillSpec = 368, KeyUseRequiresLevel = 369;
private const int SkillSummoning = 54;
private enum Cmp { Min, Max, Named }
private readonly record struct Spec(string Group, int Key, bool IsDouble, string Label, Cmp Cmp, string Tip = "");
/// <summary>The property rows, in display (and condition) order. Spells, T11 and the rating total are built separately.</summary>
private static readonly Spec[] Specs =
{
new(GroupItem, LootItemRules.KeyMaterial, false, "Material", Cmp.Named),
new(GroupItem, LootItemRules.KeyWorkmanship, false, "Workmanship", Cmp.Min),
new(GroupItem, 19, false, "Value", Cmp.Min),
new(GroupItem, 5, false, "Burden", Cmp.Max),
new(GroupItem, 106, false, "Spellcraft", Cmp.Min),
new(GroupItem, 108, false, "Max mana", Cmp.Min),
new(GroupItem, 109, false, "Arcane Lore to use", Cmp.Max, "The Arcane Lore the item's spells need (lower is easier)."),
new(GroupItem, 92, false, "Uses left", Cmp.Min),
new(GroupItem, 91, false, "Max uses", Cmp.Min),
new(GroupItem, 265, false, "Armor set", Cmp.Named, "The set id (the same set's pieces share it)."),
new(GroupItem, 353, false, "Imbue", Cmp.Named),
new(GroupItem, 166, false, "Slayer", Cmp.Named),
new(GroupItem, 45, false, "Damage type", Cmp.Named),
new(GroupGear, LootItemRules.KeyWieldSkill, false, "Wield skill", Cmp.Named),
new(GroupGear, LootItemRules.KeyWeaponSkill, false, "Weapon skill", Cmp.Named),
new(GroupGear, LootItemRules.KeyDamage, false, "Max damage", Cmp.Min),
new(GroupGear, 22, true, "Damage variance", Cmp.Max, "Lower is steadier damage."),
new(GroupGear, 63, true, "Damage modifier", Cmp.Min, "Missile weapons' damage multiplier."),
new(GroupGear, 62, true, "Attack modifier", Cmp.Min),
new(GroupGear, 29, true, "Melee defense modifier", Cmp.Min),
new(GroupGear, 149, true, "Missile defense modifier", Cmp.Min),
new(GroupGear, 150, true, "Magic defense modifier", Cmp.Min),
new(GroupGear, 144, true, "Mana conversion modifier", Cmp.Min),
new(GroupGear, LootItemRules.KeyElementalDamageMod, true, "Elemental damage vs monsters", Cmp.Min),
new(GroupGear, LootItemRules.KeyEquipSlots, false, "Equip slots", Cmp.Named, "Where it is worn or wielded."),
new(GroupGear, LootItemRules.KeyArmorLevel, false, "Armor level", Cmp.Min),
// The rating total comes first in this group (built separately); then each rating.
new(GroupRatings, 370, false, "Damage rating", Cmp.Min),
new(GroupRatings, 371, false, "Damage resist rating", Cmp.Min),
new(GroupRatings, 372, false, "Crit rating", Cmp.Min),
new(GroupRatings, 373, false, "Crit resist rating", Cmp.Min),
new(GroupRatings, 374, false, "Crit damage rating", Cmp.Min),
new(GroupRatings, 375, false, "Crit damage resist rating", Cmp.Min),
new(GroupRatings, 376, false, "Heal boost rating", Cmp.Min),
new(GroupRatings, 377, false, "Nether resist rating", Cmp.Min),
new(GroupRatings, 379, false, "Vitality rating", Cmp.Min),
new(GroupPet, KeyBond, false, "Bond level", Cmp.Min),
new(GroupPet, KeyUseRequiresLevel, false, "Level", Cmp.Min),
new(GroupPet, KeyUseLevelRequirement, false, "Level requirement", Cmp.Min),
new(GroupPet, KeyPotencyStored, false, "Potency stored", Cmp.Min),
new(GroupPet, KeySummoningMastery, false, "Summoning mastery", Cmp.Named),
new(GroupPet, KeyMutations, false, "Mutations", Cmp.Min),
new(GroupPet, 9070, false, "Damage mutations", Cmp.Min),
new(GroupPet, 9071, false, "Damage resist mutations", Cmp.Min),
new(GroupPet, 9072, false, "Crit mutations", Cmp.Min),
new(GroupPet, 9073, false, "Vitality mutations", Cmp.Min),
new(GroupPet, 9074, false, "Potency mutations", Cmp.Min),
new(GroupPet, KeyCapturedDamageType, false, "Captured damage type", Cmp.Named),
new(GroupPet, 307, false, "Pet damage rating", Cmp.Min),
new(GroupPet, 308, false, "Pet damage resist rating", Cmp.Min),
new(GroupPet, 313, false, "Pet crit rating", Cmp.Min),
new(GroupPet, 314, false, "Pet crit damage rating", Cmp.Min),
new(GroupPet, 315, false, "Pet crit resist rating", Cmp.Min),
new(GroupPet, 316, false, "Pet crit damage resist rating", Cmp.Min),
new(GroupPet, KeyBreedingCharges, false, "Breeding charges", Cmp.Min),
new(GroupRequirements, 158, false, "Wield requirement", Cmp.Named),
new(GroupRequirements, 160, false, "Wield difficulty", Cmp.Max, "Lower is easier to wield."),
};
/// <summary>Every int property a checklist can use: what RynthAi reads into LootItemFacts.</summary>
public static readonly int[] IntKeys = BuildKeys(isDouble: false);
/// <summary>Every float property a checklist can use.</summary>
public static readonly int[] DoubleKeys = BuildKeys(isDouble: true);
private static int[] BuildKeys(bool isDouble)
{
var keys = new List<int>();
foreach (Spec s in Specs)
if (s.IsDouble == isDouble && !keys.Contains(s.Key)) keys.Add(s.Key);
if (!isDouble)
foreach (int k in new[] { KeyUseRequiresSkill, KeyUseRequiresSkillSpec })
if (!keys.Contains(k)) keys.Add(k);
return keys.ToArray();
}
/// <summary>
/// A combat / summoning essence: the plugin says so, or the item carries ACECustom's bond or
/// potency, or using it needs Summoning.
/// </summary>
public static bool IsPetEssence(LootItemFacts f)
=> f.IsPetEssence || f.Int(KeyBond) > 0 || f.Ints.ContainsKey(KeyPotencyStored)
|| f.Int(KeyUseRequiresSkill) == SkillSummoning || f.Int(KeyUseRequiresSkillSpec) == SkillSummoning
|| f.ObjectClass == (int)AcObjectClass.CombatPet;
/// <summary>
/// The item's rows with their defaults: ticked for "items like this" (<paramref name="like"/>)
/// what that match always required, the T11 rows when <paramref name="includeT11"/>.
/// </summary>
public static List<LootItemAttribute> For(LootItemFacts f, bool like, bool includeT11)
{
var rows = new List<LootItemAttribute>();
bool pet = IsPetEssence(f);
HashSet<int> likeKeys = like ? LikeKeys(f, pet) : new HashSet<int>();
foreach (Spec s in Specs)
{
if (s.Group == GroupPet && !pet) continue;
if (s.Group == GroupRatings && s.Key == 370) AddTotalRatings(rows, f, like);
double v = s.IsDouble ? f.Double(s.Key) : f.Int(s.Key);
if (s.Cmp == Cmp.Named ? v == 0 : v <= 0) continue;
// A pet's level comes from 369 when it has one (PetStats does the same).
if (s.Key == KeyUseLevelRequirement && f.Int(KeyUseRequiresLevel) > 0) continue;
rows.Add(PropertyRow(s, v, likeKeys.Contains(s.IsDouble ? -s.Key : s.Key)));
}
// Spells and T11 go after the ratings and before Requirements.
int req = rows.FindIndex(r => r.Group == GroupRequirements);
var tail = req >= 0 ? rows.GetRange(req, rows.Count - req) : new List<LootItemAttribute>();
if (req >= 0) rows.RemoveRange(req, rows.Count - req);
AddSpellRows(rows, f, like);
AddT11Rows(rows, f, includeT11);
rows.AddRange(tail);
return rows;
}
/// <summary>
/// The keys "items like this" required before the checklist (doubles negated), plus a
/// pet essence's bond, level, potency, mastery and mutations.
/// </summary>
private static HashSet<int> LikeKeys(LootItemFacts f, bool pet)
{
var k = new HashSet<int> { LootItemRules.KeyMaterial, LootItemRules.KeyWorkmanship };
int wieldSkill = f.Int(LootItemRules.KeyWieldSkill);
switch ((AcObjectClass)f.ObjectClass)
{
case AcObjectClass.MeleeWeapon:
k.Add(wieldSkill != 0 ? LootItemRules.KeyWieldSkill : LootItemRules.KeyWeaponSkill);
k.Add(LootItemRules.KeyDamage);
break;
case AcObjectClass.MissileWeapon:
k.Add(wieldSkill != 0 ? LootItemRules.KeyWieldSkill : LootItemRules.KeyWeaponSkill);
break;
case AcObjectClass.WandStaffOrb:
k.Add(LootItemRules.KeyWieldSkill);
k.Add(-LootItemRules.KeyElementalDamageMod);
break;
case AcObjectClass.Armor:
case AcObjectClass.Clothing:
k.Add(LootItemRules.KeyEquipSlots);
k.Add(LootItemRules.KeyArmorLevel);
break;
case AcObjectClass.Jewelry:
k.Add(LootItemRules.KeyEquipSlots);
break;
}
if (pet)
foreach (int key in new[] { KeyBond, KeyUseRequiresLevel, KeyUseLevelRequirement, KeyPotencyStored, KeySummoningMastery, KeyMutations })
k.Add(key);
return k;
}
private static LootItemAttribute PropertyRow(Spec s, double v, bool on)
{
LootItemAttributeOp[] ops = s.Cmp switch
{
Cmp.Named => new[] { LootItemAttributeOp.Exactly, LootItemAttributeOp.Not },
Cmp.Max => new[] { LootItemAttributeOp.AtMost, LootItemAttributeOp.Exactly, LootItemAttributeOp.AtLeast },
_ => new[] { LootItemAttributeOp.AtLeast, LootItemAttributeOp.Exactly, LootItemAttributeOp.AtMost },
};
string text = s.IsDouble ? Number(v) : NamedOrNumber(s.Key, (int)v);
return new LootItemAttribute
{
Id = (s.IsDouble ? "D:" : "L:") + s.Key.ToString(CultureInfo.InvariantCulture),
Group = s.Group, Label = s.Label, Tip = s.Tip,
Kind = s.IsDouble ? LootItemAttribute.Shape.Double : LootItemAttribute.Shape.Long,
Key = s.Key, ItemValue = v, ItemText = text, Ops = ops, Editable = s.Cmp != Cmp.Named,
On = on, Op = ops[0], Value = v,
};
}
private static void AddTotalRatings(List<LootItemAttribute> rows, LootItemFacts f, bool like)
{
int total = 0;
foreach (int k in LootItemRules.RatingKeys) total += Math.Max(0, f.Int(k));
if (total <= 0 || rows.Exists(r => r.Kind == LootItemAttribute.Shape.TotalRatings)) return;
rows.Add(new LootItemAttribute
{
Id = "ratings", Group = GroupRatings, Label = "Total ratings", Kind = LootItemAttribute.Shape.TotalRatings,
Tip = "Damage, damage resist, crit, crit resist, crit damage, crit damage resist, heal boost and vitality ratings added up.",
ItemValue = total, ItemText = Number(total), Ops = new[] { LootItemAttributeOp.AtLeast }, Editable = true,
On = like, Op = LootItemAttributeOp.AtLeast, Value = total,
});
}
// ── Spells ──────────────────────────────────────────────────────────────
/// <summary>"Major Strength": tier 1 (CantripTiers index) and "Strength".</summary>
public static bool TryCantrip(string spell, out int tier, out string rest)
{
for (int i = 0; i < CantripTiers.Length; i++)
{
string p = CantripTiers[i] + " ";
if (spell.StartsWith(p, StringComparison.OrdinalIgnoreCase) && spell.Length > p.Length)
{
tier = i;
rest = spell.Substring(p.Length);
return true;
}
}
tier = -1;
rest = string.Empty;
return false;
}
/// <summary>"Strength Self VI": level 6 and "Strength Self".</summary>
public static bool TryLevel(string spell, out int level, out string rest)
{
int sp = spell.LastIndexOf(' ');
if (sp > 0)
{
int idx = Array.IndexOf(Roman, spell.Substring(sp + 1).ToUpperInvariant());
if (idx >= 0)
{
level = idx + 1;
rest = spell.Substring(0, sp);
return true;
}
}
level = 0;
rest = string.Empty;
return false;
}
/// <summary>The spell condition's pattern for a spell row's comparison.</summary>
public static string SpellPattern(string spell, LootItemAttributeOp op)
{
if (op == LootItemAttributeOp.SpellOrBetter || op == LootItemAttributeOp.SpellAnyTier)
{
int from;
if (TryCantrip(spell, out int tier, out string rest))
{
from = op == LootItemAttributeOp.SpellAnyTier ? 0 : tier;
return "^(" + string.Join("|", CantripTiers, from, CantripTiers.Length - from) + ") " + LootItemRules.EscapeText(rest) + "$";
}
if (TryLevel(spell, out int level, out rest))
{
from = op == LootItemAttributeOp.SpellAnyTier ? 0 : level - 1;
return "^" + LootItemRules.EscapeText(rest) + " (" + string.Join("|", Roman, from, Roman.Length - from) + ")$";
}
}
return LootItemRules.ExactPattern(spell);
}
/// <summary>
/// A row per spell (cantrips default to "or better", leveled spells to the exact spell, as
/// "items like this" always did; the first <see cref="LootItemRules.MaxSpells"/> ticked
/// for it), then "N cantrips of a tier or better" and the spell count.
/// </summary>
private static void AddSpellRows(List<LootItemAttribute> rows, LootItemFacts f, bool like)
{
var seen = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
var tiers = new List<int>();
int ticked = 0, count = 0;
foreach (string raw in f.Spells)
{
string s = LootItemRules.OneLine(raw).Trim();
if (s.Length == 0 || !seen.Add(s)) continue;
count++;
bool cantrip = TryCantrip(s, out int tier, out _);
int level = 0;
bool leveled = !cantrip && TryLevel(s, out level, out _);
if (cantrip) tiers.Add(tier);
LootItemAttributeOp[] ops = cantrip
? new[] { LootItemAttributeOp.SpellOrBetter, LootItemAttributeOp.SpellExact, LootItemAttributeOp.SpellAnyTier }
: leveled
? new[] { LootItemAttributeOp.SpellExact, LootItemAttributeOp.SpellOrBetter, LootItemAttributeOp.SpellAnyTier }
: new[] { LootItemAttributeOp.SpellExact };
bool on = like && ticked < LootItemRules.MaxSpells;
if (on) ticked++;
rows.Add(new LootItemAttribute
{
Id = "spell:" + s, Group = GroupSpells, Label = s, Kind = LootItemAttribute.Shape.Spell, Spell = s,
ItemText = cantrip ? CantripTiers[tier] + " cantrip" : leveled ? "level " + Roman[level - 1] : "spell",
Tip = cantrip ? "Or better: this cantrip at this tier or higher. Any tier: Minor to Legendary."
: leveled ? "Or better: this spell at this level or higher. Any tier: any level."
: "The item has this spell.",
Ops = ops, On = on, Op = ops[0],
});
}
// "At least N Epic-or-better cantrips": one row per tier the item has, highest first.
tiers.Sort();
for (int t = CantripTiers.Length - 1; t >= 0; t--)
{
if (!tiers.Contains(t)) continue;
int n = tiers.FindAll(x => x >= t).Count;
string label = t == CantripTiers.Length - 1 ? CantripTiers[t] + " cantrips" : CantripTiers[t] + "-or-better cantrips";
rows.Add(new LootItemAttribute
{
Id = "cantrips:" + CantripTiers[t], Group = GroupSpells, Label = label, Kind = LootItemAttribute.Shape.CantripTier,
Key = t, ItemValue = n, ItemText = Number(n), Ops = new[] { LootItemAttributeOp.AtLeast }, Editable = true,
Tip = "How many of the item's cantrips are this tier or higher.", Op = LootItemAttributeOp.AtLeast, Value = n,
});
}
if (count > 0)
rows.Add(new LootItemAttribute
{
Id = "spellcount", Group = GroupSpells, Label = "Spell count", Kind = LootItemAttribute.Shape.SpellCount,
ItemValue = count, ItemText = Number(count), Ops = new[] { LootItemAttributeOp.AtLeast }, Editable = true,
Op = LootItemAttributeOp.AtLeast, Value = count,
});
}
/// <summary>How many spell rows there are (the "more than 4 spells" note).</summary>
internal static int SpellRowCount(List<LootItemAttribute> rows) => rows.FindAll(r => r.Kind == LootItemAttribute.Shape.Spell).Count;
/// <summary>True for the T11 group's rows.</summary>
internal static bool IsT11Row(LootItemAttribute r) => r.Group == GroupT11;
// ── T11 ─────────────────────────────────────────────────────────────────
/// <summary>
/// The T11 rows on RynthAi's virtual T11 keys, in the order "Include T11 attributes" always
/// added them (Is T11, tier, weapon grade, damage %, gear grade, each catalogued modifier,
/// Has Slot Special for a value-less one, Cast on Strike count), then the summary keys,
/// off by default. Left out on purpose: Can Wield (the character), Zone Locked (where it
/// was appraised), property slots and Tainted (bag state, not quality).
/// </summary>
private static void AddT11Rows(List<LootItemAttribute> rows, LootItemFacts f, bool on)
{
T11ItemInfo? t = f.T11;
if (t == null || !t.IsT11) return;
void Row(string id, string label, int key, int v, bool named, bool def = true, bool equal = false, string tip = "")
{
LootItemAttributeOp[] ops = equal ? new[] { LootItemAttributeOp.Exactly }
: new[] { LootItemAttributeOp.AtLeast, LootItemAttributeOp.Exactly, LootItemAttributeOp.AtMost };
rows.Add(new LootItemAttribute
{
Id = "t11:" + id, Group = GroupT11, Label = label, Kind = LootItemAttribute.Shape.Long, Key = key, Tip = tip,
ItemValue = v, ItemText = named ? NamedOrNumber(key, v) : equal ? "yes" : Number(v), Ops = ops,
Editable = !named && !equal, On = on && def, Op = ops[0], Value = v,
});
}
Row("is", "Is T11", T11Keys.IsT11, 1, named: false, equal: true);
if (!t.HasText) return;
if (t.Tier > 0) Row("tier", t.TierIsExact ? "Tier" : "Tier (estimated)", T11Keys.EstimatedTier, t.Tier, named: false);
if (t.GradeRank > 0) Row("grade", "Weapon grade", T11Keys.WeaponGrade, t.GradeRank, named: true);
if (t.DamagePercent > 0) Row("dmgpct", "Damage %", T11Keys.DamagePercent, t.DamagePercent, named: false);
if (t.GearGradeRank > 0) Row("geargrade", "Gear grade", T11Keys.GearGrade, t.GearGradeRank, named: true);
bool valuelessSpecial = false;
foreach (T11Modifier m in t.Modifiers)
{
if (T11Catalog.ModifierByKey(m.Key) == null) continue;
// A modifier's key reads 0 when it is absent, so a value-less one can't be required by value.
if (m.Value > 0) Row("mod:" + m.Key.ToString(CultureInfo.InvariantCulture), "Mod: " + m.Name, T11Keys.ForModifier(m.Key), m.Value, named: false);
else if (m.IsSlotSpecial) valuelessSpecial = true;
}
if (valuelessSpecial) Row("special", "Has slot special", T11Keys.HasSlotSpecial, 1, named: false, equal: true);
if (t.Procs.Count > 0) Row("cos", "Cast on Strike count", T11Keys.CastOnStrikeCount, t.Procs.Count, named: false);
foreach (var (key, label) in new[] { (T11Keys.ModifierCount, "Modifier count"), (T11Keys.ModifierRatingTotal, "Modifier rating total"), (T11Keys.BestRollPercent, "Best roll %") })
if (T11Keys.TryGetValue(t, key, null, out int v) && v > 0)
Row("sum:" + key.ToString(CultureInfo.InvariantCulture), label, key, v, named: false, def: false);
}
/// <summary>The catalogued-but-unknown T11 modifiers (the rule can't require them).</summary>
internal static List<string> UnknownT11Modifiers(LootItemFacts f)
{
var unknown = new List<string>();
if (f.T11 is { IsT11: true } t)
foreach (T11Modifier m in t.Modifiers)
if (T11Catalog.ModifierByKey(m.Key) == null) unknown.Add(m.Name);
return unknown;
}
// ── Choices and conditions ──────────────────────────────────────────────
/// <summary>
/// The player's choices onto the rows (unknown ids are ignored: the item may have changed).
/// A typed value that isn't a number keeps the item's and says so in <paramref name="notes"/>.
/// </summary>
public static void Apply(List<LootItemAttribute> rows, IReadOnlyList<LootEditItemChoice>? choices, List<string> notes)
{
if (choices == null) return;
foreach (LootEditItemChoice c in choices)
{
LootItemAttribute? r = rows.Find(x => x.Id == c.Id);
if (r == null) continue;
r.On = c.On;
if (c.Op >= 0 && Array.IndexOf(r.Ops, (LootItemAttributeOp)c.Op) >= 0) r.Op = (LootItemAttributeOp)c.Op;
string typed = (c.Value ?? string.Empty).Trim();
if (!r.Editable || typed.Length == 0) continue;
bool whole = r.Kind != LootItemAttribute.Shape.Double;
if (double.TryParse(typed, NumberStyles.Float, CultureInfo.InvariantCulture, out double v) && v >= 0 && (!whole || v == Math.Floor(v)))
{
r.Value = v;
r.Typed = typed;
}
else
notes.Add($"{r.Label}: '{typed}' isn't a{(whole ? " whole" : "")} number of 0 or more; the item's {r.ItemText} is used.");
}
}
/// <summary>The ticked rows' conditions onto <paramref name="rule"/>, in row order; how many rows added one.</summary>
public static int AddConditions(VTankLootRule rule, List<LootItemAttribute> rows)
{
int n = 0;
foreach (LootItemAttribute r in rows)
{
if (!r.On) continue;
n++;
string key = r.Key.ToString(CultureInfo.InvariantCulture);
switch (r.Kind)
{
case LootItemAttribute.Shape.Long:
string iv = ((long)r.Value).ToString(CultureInfo.InvariantCulture);
int type = r.Op switch
{
LootItemAttributeOp.Exactly => VTankNodeTypes.LongValKeyE,
LootItemAttributeOp.AtMost => VTankNodeTypes.LongValKeyLE,
LootItemAttributeOp.Not => VTankNodeTypes.LongValKeyNE,
_ => VTankNodeTypes.LongValKeyGE,
};
rule.Conditions.Add(Cond(type, iv, key));
break;
case LootItemAttribute.Shape.Double:
string dv = Number(r.Value);
if (r.Op != LootItemAttributeOp.AtMost) rule.Conditions.Add(Cond(VTankNodeTypes.DoubleValKeyGE, dv, key));
if (r.Op != LootItemAttributeOp.AtLeast) rule.Conditions.Add(Cond(VTankNodeTypes.DoubleValKeyLE, dv, key));
break;
case LootItemAttribute.Shape.TotalRatings:
rule.Conditions.Add(Cond(VTankNodeTypes.TotalRatingsGE, Number(r.Value)));
break;
case LootItemAttribute.Shape.Spell:
rule.Conditions.Add(Cond(VTankNodeTypes.SpellNameMatch, SpellPattern(r.Spell, r.Op)));
break;
case LootItemAttribute.Shape.CantripTier:
string tiers = string.Join("|", CantripTiers, r.Key, CantripTiers.Length - r.Key);
rule.Conditions.Add(Cond(VTankNodeTypes.SpellMatch, "^(" + tiers + ") ", string.Empty, Number(r.Value)));
break;
case LootItemAttribute.Shape.SpellCount:
rule.Conditions.Add(Cond(VTankNodeTypes.SpellCountGE, Number(r.Value)));
break;
}
}
return n;
}
private static VTankLootCondition Cond(int type, params string[] lines) => new(type, "0", lines);
/// <summary>A number as rules write it: whole numbers plain, decimals to 4 places.</summary>
public static string Number(double v) => v.ToString("0.####", CultureInfo.InvariantCulture);
/// <summary>A long key's value by name when it has one ("Gold", "Light Weapons"), else the number.</summary>
private static string NamedOrNumber(int key, int v)
=> LootRuleText.ValueName(key, v.ToString(CultureInfo.InvariantCulture)) ?? v.ToString(CultureInfo.InvariantCulture);
}

View file

@ -32,6 +32,8 @@ public sealed class LootItemFacts
/// <see cref="T11ItemInfo.None"/> for an item that isn't T11 gear.
/// </summary>
public T11ItemInfo? T11 { get; set; }
/// <summary>The plugin knows it for a summoning essence (by WCID, icon, use requirement; added 2026-10-18).</summary>
public bool IsPetEssence { get; set; }
public bool Stackable => MaxStackSize > 1 || StackSize > 1;
@ -64,6 +66,11 @@ public sealed class LootItemRuleOptions
/// slot special, Cast on Strike), each at least as good as this item's. Works with any match.
/// </summary>
public bool IncludeT11 { get; set; }
/// <summary>
/// The popup's attribute checklist choices (LootItemAttributes); null: every row at its
/// default, which is the rule "items like this" and IncludeT11 always made.
/// </summary>
public IReadOnlyList<LootEditItemChoice>? Choices { get; set; }
}
/// <summary>A built rule, ready to preview and insert.</summary>
@ -76,6 +83,8 @@ public sealed class LootItemRuleDraft
public string DefaultName { get; init; } = string.Empty;
/// <summary>Things the player should know (a broad rule, spells left out...).</summary>
public List<string> Notes { get; init; } = new();
/// <summary>The item's checklist rows as the rule used them (the popup shows them).</summary>
public List<LootItemAttribute> Attributes { get; init; } = new();
}
public static class LootItemRules
@ -86,10 +95,9 @@ public static class LootItemRules
public const int KeyElementalDamageMod = 152;
/// <summary>The ratings TotalRatingsGE adds up (same list as both evaluators).</summary>
public static readonly int[] RatingKeys = { 370, 371, 372, 373, 374, 375, 376, 379 };
/// <summary>The int properties a "like this" rule can use: what RynthAi reads into LootItemFacts.</summary>
public static readonly int[] IntKeys =
{ KeyArmorLevel, KeyEquipSlots, KeyDamage, KeyWeaponSkill, KeyWorkmanship, KeyMaterial, KeyWieldSkill, 370, 371, 372, 373, 374, 375, 376, 379 };
public static readonly int[] DoubleKeys = { KeyElementalDamageMod };
/// <summary>The int properties a rule from an item can use: what RynthAi reads into LootItemFacts.</summary>
public static int[] IntKeys => LootItemAttributes.IntKeys;
public static int[] DoubleKeys => LootItemAttributes.DoubleKeys;
/// <summary>Spell conditions a "like this" rule takes at most (all must match: more makes it narrower).</summary>
public const int MaxSpells = 4;
@ -109,16 +117,17 @@ public static class LootItemRules
/// A name as an exact, case-insensitive regex: ^name$ with the regex
/// metacharacters escaped (spaces left alone, unlike Regex.Escape, so it reads well).
/// </summary>
public static string ExactPattern(string name)
public static string ExactPattern(string name) => "^" + EscapeText(name) + "$";
/// <summary>Text with the regex metacharacters escaped (spaces left alone), for a pattern's middle.</summary>
public static string EscapeText(string text)
{
var sb = new StringBuilder(name.Length + 8);
sb.Append('^');
foreach (char ch in name)
var sb = new StringBuilder(text.Length + 8);
foreach (char ch in text)
{
if ("\\*+?|{}[]()^$.#".IndexOf(ch) >= 0) sb.Append('\\');
sb.Append(ch);
}
sb.Append('$');
return sb.ToString();
}
@ -189,139 +198,60 @@ public static class LootItemRules
return null;
}
rule.Conditions.Add(Cond(VTankNodeTypes.ObjectClass, Num(f.ObjectClass)));
likeBare = AddLikeConditions(rule, f, notes) == 0;
likeBare = true;
break;
}
int t11Added = o.IncludeT11 ? AddT11Conditions(rule, f, notes) : 0;
if (likeBare && t11Added == 0)
// The attribute checklist: defaults for this match, then the popup's choices.
List<LootItemAttribute> rows = LootItemAttributes.For(f, match == LootItemMatch.Like, o.IncludeT11);
LootItemAttributes.Apply(rows, o.Choices, notes);
int added = LootItemAttributes.AddConditions(rule, rows);
AddRowNotes(f, o, rows, match, notes);
if (likeBare && added == 0)
notes.Add($"Nothing but the class to go on: this rule matches every {ClassName(f.ObjectClass)}."
+ (f.Ints.Count == 0 ? " (Assess the item first for its material, workmanship and stats.)" : string.Empty));
string defaultName = DefaultRuleName(name.Length > 0 ? name : ClassName(f.ObjectClass), action, keep, match);
string ruleName = OneLine(o.RuleName).Trim();
rule.Name = ruleName.Length > 0 ? ruleName : defaultName;
return new LootItemRuleDraft { Rule = rule, Match = match, Action = action, KeepCount = keep, DefaultName = defaultName, Notes = notes };
}
/// <summary>The "like this" conditions for the item's kind; how many it added.</summary>
private static int AddLikeConditions(VTankLootRule rule, LootItemFacts f, List<string> notes)
{
int n = rule.Conditions.Count;
var cls = (AcObjectClass)f.ObjectClass;
void LongE(int key) { int v = f.Int(key); if (v != 0) rule.Conditions.Add(Cond(VTankNodeTypes.LongValKeyE, Num(v), Num(key))); }
void LongGE(int key) { int v = f.Int(key); if (v > 0) rule.Conditions.Add(Cond(VTankNodeTypes.LongValKeyGE, Num(v), Num(key))); }
void DoubleGE(int key)
return new LootItemRuleDraft
{
double v = f.Double(key);
if (v > 0) rule.Conditions.Add(Cond(VTankNodeTypes.DoubleValKeyGE, v.ToString("0.####", CultureInfo.InvariantCulture), Num(key)));
}
LongE(KeyMaterial);
LongGE(KeyWorkmanship);
switch (cls)
{
case AcObjectClass.MeleeWeapon:
if (f.Int(KeyWieldSkill) != 0) LongE(KeyWieldSkill); else LongE(KeyWeaponSkill);
LongGE(KeyDamage);
break;
case AcObjectClass.MissileWeapon:
if (f.Int(KeyWieldSkill) != 0) LongE(KeyWieldSkill); else LongE(KeyWeaponSkill);
break;
case AcObjectClass.WandStaffOrb:
if (f.Int(KeyWieldSkill) != 0) LongE(KeyWieldSkill);
DoubleGE(KeyElementalDamageMod);
break;
case AcObjectClass.Armor:
case AcObjectClass.Clothing:
LongE(KeyEquipSlots);
LongGE(KeyArmorLevel);
break;
case AcObjectClass.Jewelry:
LongE(KeyEquipSlots);
break;
}
int ratings = 0;
foreach (int k in RatingKeys) ratings += Math.Max(0, f.Int(k));
if (ratings > 0) rule.Conditions.Add(Cond(VTankNodeTypes.TotalRatingsGE, Num(ratings)));
int spells = 0;
foreach (string s in f.Spells)
{
string sn = OneLine(s).Trim();
if (sn.Length == 0) continue;
if (spells == MaxSpells)
{
notes.Add($"The item has more than {MaxSpells} spells; the rule checks the first {MaxSpells}.");
break;
}
rule.Conditions.Add(Cond(VTankNodeTypes.SpellNameMatch, ExactPattern(sn)));
spells++;
}
return rule.Conditions.Count - n;
Rule = rule, Match = match, Action = action, KeepCount = keep, DefaultName = defaultName, Notes = notes, Attributes = rows,
};
}
/// <summary>
/// The T11 conditions, on RynthAi's virtual T11 keys: Is T11, then tier (the server's
/// stamped tier when sent), weapon grade, damage %, gear grade, every catalogued modifier,
/// slot special and Cast on Strike count, each at least this item's. Left out on purpose:
/// Can Wield (the character, not the item), Zone Locked (where it was appraised), the wield
/// gates (they follow from the tier), the modifier count / rating total / roll % (they
/// follow from the per-modifier values), and the property slots and Tainted (bag state,
/// not quality). How many it added.
/// What the player should know about the rows: spells "like this" left unticked, a T11 item
/// not identified yet, T11 modifiers RynthAi has no key for, T11 asked of a non-T11 item.
/// </summary>
private static int AddT11Conditions(VTankLootRule rule, LootItemFacts f, List<string> notes)
private static void AddRowNotes(LootItemFacts f, LootItemRuleOptions o, List<LootItemAttribute> rows, LootItemMatch match, List<string> notes)
{
if (match == LootItemMatch.Like && o.Choices == null && LootItemAttributes.SpellRowCount(rows) > MaxSpells)
notes.Add($"The item has more than {MaxSpells} spells; the rule checks the first {MaxSpells} (the Add to loot profile popup can tick the rest).");
bool t11Asked = o.IncludeT11 || rows.Exists(r => r.On && LootItemAttributes.IsT11Row(r));
if (!t11Asked) return;
T11ItemInfo? t = f.T11;
if (t == null || !t.IsT11)
{
notes.Add("Not a T11 item, so there are no T11 attributes to add.");
return 0;
return;
}
int n = rule.Conditions.Count;
void Equal(int key, int v) => rule.Conditions.Add(Cond(VTankNodeTypes.LongValKeyE, Num(v), Num(key)));
void AtLeast(int key, int v) { if (v > 0) rule.Conditions.Add(Cond(VTankNodeTypes.LongValKeyGE, Num(v), Num(key))); }
Equal(T11Keys.IsT11, 1);
if (!t.HasText)
{
notes.Add("The item hasn't been identified, so only \"Is T11\" could be added. Assess it and preview again for its tier, grade and modifiers.");
return rule.Conditions.Count - n;
return;
}
AtLeast(T11Keys.EstimatedTier, t.Tier);
AtLeast(T11Keys.WeaponGrade, t.GradeRank);
AtLeast(T11Keys.DamagePercent, t.DamagePercent);
AtLeast(T11Keys.GearGrade, t.GearGradeRank);
bool valuelessSpecial = false;
var unknown = new List<string>();
foreach (T11Modifier m in t.Modifiers)
{
if (T11Catalog.ModifierByKey(m.Key) == null)
{
unknown.Add(m.Name);
continue;
}
// A modifier's key reads 0 when it is absent, so a value-less one can't be required by value.
if (m.Value > 0) AtLeast(T11Keys.ForModifier(m.Key), m.Value);
else if (m.IsSlotSpecial) valuelessSpecial = true;
}
if (valuelessSpecial) Equal(T11Keys.HasSlotSpecial, 1);
AtLeast(T11Keys.CastOnStrikeCount, t.Procs.Count);
List<string> unknown = LootItemAttributes.UnknownT11Modifiers(f);
if (unknown.Count > 0)
notes.Add("Left out (RynthAi has no loot key for these modifiers yet): " + string.Join(", ", unknown) + ".");
return rule.Conditions.Count - n;
}
private static VTankLootCondition Cond(int type, params string[] lines) => new(type, "0", lines);
private static string Num(int v) => v.ToString(CultureInfo.InvariantCulture);
private static string OneLine(string? s) =>
internal static string OneLine(string? s) =>
string.IsNullOrEmpty(s) ? string.Empty : s.Replace("\r\n", " ").Replace('\r', ' ').Replace('\n', ' ');
// =====================================================================

View file

@ -47,11 +47,24 @@ public static class LootRuleText
{
(5, "EncumbVal"), (9, "Locations"), (19, "Value"), (25, "Level"), (28, "ArmorLevel"), (44, "Damage (max)"), (45, "DamageType"),
(48, "WeaponSkill"), (54, "WeaponEncumbrance"), // 54 was labelled MaxDamage until 2026-10-07; max damage is 44
(87, "MaxStructure"), (88, "Structure"), (105, "ItemWorkmanship"), (107, "ItemMaxMana"),
// 87 / 88 were labelled MaxStructure / Structure until 2026-10-18; uses are 91 / 92
// (what the Pets tab reads for an essence's uses), and 107 is the current mana.
(86, "MinLevelRestrict"), (87, "MaxLevelRestrict"), (88, "LockpickSkillBonus"),
(91, "UsesTotal (MaxStructure)"), (92, "UsesRemaining (Structure)"),
(105, "ItemWorkmanship"), (106, "ItemSpellcraft"), (107, "ItemCurMana"), (108, "ItemMaxMana"),
(109, "ItemDifficulty (Arcane Lore)"),
(131, "MaterialType"), (158, "WieldRequirements"), (159, "WieldSkilltype"), (160, "WieldDifficulty"),
// ACECustom / ACE appraisal: slayer weapons (166) and combat-essence pet stats (9053 / 9056).
// ACECustom / ACE appraisal: slayer weapons (166) and combat-essence pet stats (9053-9075).
// "Slayer Type" is the player-facing name; the ACE property is still SlayerCreatureType.
(166, "Slayer Type"), (9053, "Pet Bond Level"), (9056, "Pet Potency Stored"),
(166, "Slayer Type"), (9053, "Pet Bond Level"), (9054, "Pet Captured Damage Type"), (9056, "Pet Potency Stored"),
(9057, "Pet Breeding Charges"), (9070, "Pet Damage Mutations"), (9071, "Pet Damage Resist Mutations"),
(9072, "Pet Crit Mutations"), (9073, "Pet Vitality Mutations"), (9074, "Pet Potency Mutations"),
(9075, "Pet Mutation Count"),
(307, "Pet DamageRating"), (308, "Pet DamageResistRating"), (313, "Pet CritRating"),
(314, "Pet CritDamageRating"), (315, "Pet CritResistRating"), (316, "Pet CritDamageResistRating"),
(362, "SummoningMastery"), (364, "UseLevelRequirement"), (366, "UseRequiresSkill"),
(368, "UseRequiresSkillSpec"), (369, "UseRequiresLevel"),
(179, "Imbued (Decal)"), (265, "EquipmentSetId (armor set)"),
(218, "EquippedSlots"), (353, "ImbuedEffect"), (370, "DamageRating"), (371, "DamageResistRating"),
(372, "CritRating"), (373, "CritResistRating"), (374, "CritDamageRating"),
(375, "CritDamageResistRating"), (376, "HealBoostRating"), (377, "NetherResistRating"), (379, "VitalityRating"),
@ -202,24 +215,45 @@ public static class LootRuleText
/// The names for a long key's value, or null when the key's value is a plain
/// number. Unknown values are still valid: show them as "value N".
/// </summary>
/// <summary>
/// ImbuedEffect (353): ACE's ImbuedEffectType flags. A combination (two imbues) shows as
/// "value N".
/// </summary>
public static readonly (int Id, string Name)[] ImbuedEffects =
{
(1, "Critical Strike"), (2, "Crippling Blow"), (4, "Armor Rending"), (8, "Slash Rending"),
(16, "Pierce Rending"), (32, "Bludgeon Rending"), (64, "Acid Rending"), (128, "Cold Rending"),
(256, "Electric Rending"), (512, "Fire Rending"), (1024, "Melee Defense"), (2048, "Missile Defense"),
(4096, "Magic Defense"), (8192, "Spellbook"), (16384, "Nether Rending"),
};
/// <summary>SummoningMastery (362): the pet school an essence needs (ACE SummoningMastery).</summary>
public static readonly (int Id, string Name)[] SummoningMasteries =
{
(1, "Primalist"), (2, "Necromancer"), (3, "Naturalist"),
};
public static (int Id, string Name)[]? ValueTableFor(int longKey) => longKey switch
{
45 or 0x0D000021 => DamageTypes,
45 or 0x0D000021 or 9054 => DamageTypes,
48 or 0x0D000020 => Skills,
131 => Materials,
158 => WieldRequirements,
159 => Skills,
159 or 366 or 368 => Skills,
166 => CreatureTypes,
353 => ImbuedEffects,
362 => SummoningMasteries,
T11.T11Keys.WeaponGrade => T11.T11Catalog.Grades,
T11.T11Keys.GearGrade => T11.T11Catalog.Grades,
_ => null,
};
/// <summary>True when the long key's value is a set of flags (a named value is one flag or a common pair).</summary>
public static bool ValueTableIsFlags(int longKey) => longKey is 45 or 0x0D000021;
public static bool ValueTableIsFlags(int longKey) => longKey is 45 or 0x0D000021 or 9054 or 353;
/// <summary>The long keys that have a value table, for the vocabulary.</summary>
public static readonly int[] KeysWithValueTables = { 45, 48, 131, 158, 159, 166, 0x0D000020, 0x0D000021, T11.T11Keys.WeaponGrade, T11.T11Keys.GearGrade };
public static readonly int[] KeysWithValueTables =
{ 45, 48, 131, 158, 159, 166, 353, 362, 366, 368, 9054, 0x0D000020, 0x0D000021, T11.T11Keys.WeaponGrade, T11.T11Keys.GearGrade };
/// <summary>
/// True for the conditions whose value is picked by name when the key has a