Snapshot for release 2026.10.13.1 (internal d2b5fb3)

This commit is contained in:
Tom Bohar 2026-10-13 14:25:49 -04:00
commit 319740ff5d
291 changed files with 58505 additions and 2107 deletions

View file

@ -422,6 +422,7 @@ public sealed class LootEditSession
/// </summary>
public bool Save(bool force = false)
{
_writeError = null;
if (!IsOpen) return Fail("No profile open.");
if (_utl == null) return Fail(_readOnlyReason);
try
@ -441,16 +442,49 @@ public sealed class LootEditSession
}
catch (Exception ex)
{
_writeError = ex;
return Fail($"Save failed: {ex.Message}");
}
}
/// <summary>
/// The exception of the last save that threw (folder not writable, file in use, ...), once:
/// the in-game bridge hands it to RynthAi's save-failure report (2026-10-13). Null when
/// the last save failed for another reason or succeeded.
/// </summary>
public Exception? TakeWriteError()
{
Exception? e = _writeError;
_writeError = null;
return e;
}
private Exception? _writeError;
/// <summary>
/// Clears the ReadOnly attribute of a file we are about to replace (a read-only profile,
/// its .bak or a stale .tmp can't be overwritten). Never throws.
/// </summary>
internal static void ClearReadOnly(string path)
{
try
{
if (!File.Exists(path)) return;
FileAttributes a = File.GetAttributes(path);
if ((a & FileAttributes.ReadOnly) != 0) File.SetAttributes(path, a & ~FileAttributes.ReadOnly);
}
catch { }
}
/// <summary>Writes a temp file and swaps it in, the old file kept as .bak.</summary>
private static void WriteFile(string path, byte[] bytes)
{
string? dir = System.IO.Path.GetDirectoryName(path);
if (!string.IsNullOrEmpty(dir)) Directory.CreateDirectory(dir);
string tmp = path + ".tmp";
ClearReadOnly(tmp);
ClearReadOnly(path);
ClearReadOnly(path + ".bak");
File.WriteAllBytes(tmp, bytes);
if (File.Exists(path))
{
@ -549,6 +583,7 @@ public sealed class LootEditSession
private bool InsertJson(LootRule native, int index)
{
_writeError = null;
try
{
byte[] bytes = File.ReadAllBytes(_path);
@ -570,6 +605,7 @@ public sealed class LootEditSession
}
catch (Exception ex)
{
_writeError = ex;
return Fail($"Not added: {ex.Message}");
}
}

View file

@ -60,8 +60,8 @@ public sealed class LootItemRuleOptions
/// <summary>Null or blank: "Keep Copper Pea" and the like.</summary>
public string? RuleName { get; set; }
/// <summary>
/// Also require the item's T11 attributes (tier, grade, damage %, each modifier, slot
/// special, Cast on Strike), each at least as good as this item's. Works with any match.
/// Also require the item's T11 attributes (tier, weapon / gear grade, damage %, each modifier,
/// slot special, Cast on Strike), each at least as good as this item's. Works with any match.
/// </summary>
public bool IncludeT11 { get; set; }
}
@ -263,12 +263,13 @@ public static class LootItemRules
}
/// <summary>
/// The T11 conditions, on RynthAi's virtual T11 keys: Is T11, then tier, grade, damage %,
/// 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) and the modifier
/// count / rating total / roll % (they follow from the per-modifier values).
/// How many it added.
/// 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.
/// </summary>
private static int AddT11Conditions(VTankLootRule rule, LootItemFacts f, List<string> notes)
{
@ -290,9 +291,10 @@ public static class LootItemRules
return rule.Conditions.Count - n;
}
AtLeast(T11Keys.EstimatedTier, t.EstimatedTier);
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>();

View file

@ -63,6 +63,10 @@ public static class LootRuleText
(0x0D00001A, "Category"), (0x0D00001F, "WeapSpeed"), (0x0D000020, "EquipSkill"),
(0x0D000021, "DamageType (Decal)"), (0x0D000022, "MaxDamage"),
(0x0D000029, "IconOverlay"), (0x0D00002A, "IconUnderlay"),
// ACECustom T11 properties sent in the appraisal: real keys, so VTank reads them too.
(T11.T11Catalog.PropWeaponAugScaleQuality, "WeaponAugScaleQuality"),
(T11.T11Catalog.PropWeaponAugScaleTier, "WeaponAugScaleTier"),
(T11.T11Catalog.PropZcTier, "ZcTier"),
};
keys.AddRange(T11.T11Keys.Names());
return keys.ToArray();
@ -166,6 +170,7 @@ public static class LootRuleText
158 => WieldRequirements,
159 => Skills,
T11.T11Keys.WeaponGrade => T11.T11Catalog.Grades,
T11.T11Keys.GearGrade => T11.T11Catalog.Grades,
_ => null,
};
@ -173,7 +178,7 @@ public static class LootRuleText
public static bool ValueTableIsFlags(int longKey) => longKey is 45 or 0x0D000021;
/// <summary>The long keys that have a value table, for the vocabulary.</summary>
public static readonly int[] KeysWithValueTables = { 45, 48, 131, 158, 159, 0x0D000020, 0x0D000021, T11.T11Keys.WeaponGrade };
public static readonly int[] KeysWithValueTables = { 45, 48, 131, 158, 159, 0x0D000020, 0x0D000021, T11.T11Keys.WeaponGrade, T11.T11Keys.GearGrade };
/// <summary>
/// True for the conditions whose value is picked by name when the key has a

View file

@ -32,7 +32,7 @@ public enum T11Counter
public sealed record T11ModifierDef(int Key, string Name, int RatingKey, bool SlotSpecial);
/// <summary>
/// Static T11 tables mirrored from ACECustom: weapon sub-grades, the Zone Control
/// Static T11 tables mirrored from ACECustom: sub-grades, the Zone Control
/// modifier catalog, the wield-gate counter names and the tier-from-gate estimate.
/// Pure data, shared by the RynthAi evaluator, the loot editor and the tests.
/// </summary>
@ -45,8 +45,8 @@ public static class T11Catalog
public static readonly int[] TotalRatingKeys = { 370, 371, 372, 373, 374, 375, 376, 379 };
/// <summary>
/// Weapon sub-grades best to worst with their rank (S = 16 ... F- = 1, 0 = no grade).
/// Order and labels follow WeaponScalingManager.SubGradeBands.
/// Sub-grades best to worst with their rank (S = 16 ... F- = 1, 0 = no grade). Order and
/// labels follow WeaponScalingManager.SubGradeBands; Weapon Grade and Gear Grade share them.
/// </summary>
public static readonly (int Id, string Name)[] Grades =
{
@ -81,8 +81,23 @@ public static class T11Catalog
new(51, "Crit Damage Resist", 375, false),
new(52, "Crit Resist", 373, false),
new(53, "Nether Resist", 377, false),
// Jewelry only; the value is the rolled power percent ("Cast on Strike 75% power [50-100] - Force Arc, 13% per hit").
new(54, "Cast on Strike", 0, false),
};
/// <summary>
/// PropertyInt WeaponAugScaleQuality (ACECustom 9060): a T11+ weapon's quality roll, 0-1000, the
/// number its Weapon Grade letter comes from. Sent in the appraisal since 2026-09-29.
/// </summary>
public const int PropWeaponAugScaleQuality = 9060;
/// <summary>PropertyInt WeaponAugScaleTier (ACECustom 9061): the loot tier a T11+ weapon was stamped at.</summary>
public const int PropWeaponAugScaleTier = 9061;
/// <summary>PropertyInt ZcTier (ACECustom 50109): the Zone Control loot tier a ZC-lined piece was stamped at.</summary>
public const int PropZcTier = 50109;
/// <summary>Lowest tier the server stamps T11 gear at (LootGenerationFactory.ZoneLootSetMinTier).</summary>
public const int MinTier = 11;
// Longest names first, so "Max Health Pct" is tried before "Max Health".
private static readonly T11ModifierDef[] ModifiersByNameLength = SortByNameLength(Modifiers);

View file

@ -27,14 +27,37 @@ public sealed class T11Modifier
public int RatingKey { get; init; }
/// <summary>True for a one-per-slot special (Fortify Vitals, Battle Mending, ...).</summary>
public bool IsSlotSpecial { get; init; }
/// <summary>"(Built-in)": the line uses no property slot (Always Rolled resists, slot specials).</summary>
public bool BuiltIn { get; init; }
/// <summary>"(Locked)": a Gear Essence locked this line, so bag rerolls leave it alone.</summary>
public bool Locked { get; init; }
/// <summary>"(+N tinkered)": what a tinker adds on top of <see cref="Value"/>, 0 for none.</summary>
public int Tinkered { get; init; }
}
/// <summary>
/// What the client can learn about a T11 (tier 11+) ACECustom drop. The server keeps the
/// T11 properties (weapon quality, loot tier, the Zone Control record, the item-aug wield
/// gate) out of the appraisal and prints them as description text instead, so this is
/// parsed from the name, LongDesc (key 16) and Use (key 14). See ACECustom AppraiseInfo
/// (BuildProperties, BuildWeapon, PromoteZoneModifierLines) for the formats.
/// T11 properties the server sends as real appraisal values (ACECustom marked them
/// AssessmentProperty on 2026-09-29). 0 / -1 = not sent (older server, or not that kind of item).
/// </summary>
/// <param name="ZcTier">PropertyInt ZcTier (50109): the loot tier a Zone Control piece was stamped at.</param>
/// <param name="WeaponTier">PropertyInt WeaponAugScaleTier (9061): the loot tier a T11+ weapon was stamped at.</param>
/// <param name="WeaponQuality">PropertyInt WeaponAugScaleQuality (9060): the weapon's 0-1000 quality roll, -1 when absent.</param>
public readonly record struct T11ServerProps(int ZcTier, int WeaponTier, int WeaponQuality)
{
/// <summary>Nothing sent. Use this, not <c>default</c>: a 0 quality is a real (F-) roll.</summary>
public static readonly T11ServerProps None = new(0, 0, -1);
/// <summary>The stamped loot tier (ZcTier first, then the weapon tier), or 0 when neither was sent.</summary>
public int Tier => ZcTier > 0 ? ZcTier : WeaponTier > 0 ? WeaponTier : 0;
}
/// <summary>
/// What the client can learn about a T11 (tier 11+) ACECustom drop. Most T11 state (the
/// Zone Control record, the item-aug wield gate, grades, slot counts) only reaches the client
/// as description text, so this is parsed from the name, LongDesc (key 16) and Use (key 14).
/// The loot tier and the weapon quality roll are also sent as real properties
/// (<see cref="T11ServerProps"/>), which win over the text estimates when present. See ACECustom
/// AppraiseInfo (BuildProperties, BuildWeapon, PromoteZoneModifierLines) for the formats.
/// </summary>
public sealed class T11ItemInfo
{
@ -61,6 +84,28 @@ public sealed class T11ItemInfo
public bool ZoneLocked { get; private set; }
/// <summary>True when the item had appraisal text (false for a T11 name seen before its ID).</summary>
public bool HasText { get; private set; }
/// <summary>Gear Grade label ("B+") of armor / jewelry / clothing / cloaks, or null.</summary>
public string? GearGrade { get; private set; }
/// <summary>Gear Grade rank, S = 16 ... F- = 1, 0 = no grade.</summary>
public int GearGradeRank { get; private set; }
/// <summary>How many rolled lines the Gear Grade averages, 0 when not shown.</summary>
public int GearGradeLines { get; private set; }
/// <summary>"Properties: N of M": property slots in use, -1 when the line isn't shown.</summary>
public int PropertySlots { get; private set; } = -1;
/// <summary>"Properties: N of M": the tier's slot limit, 0 when there is none or the line isn't shown.</summary>
public int PropertySlotCap { get; private set; }
/// <summary>"Tainted: bags no longer work on this item".</summary>
public bool Tainted { get; private set; }
/// <summary>The server-sent properties this item was parsed with.</summary>
public T11ServerProps Server { get; private set; } = T11ServerProps.None;
/// <summary>The weapon's 0-1000 quality roll (WeaponAugScaleQuality), -1 when not sent.</summary>
public int WeaponQuality => Server.WeaponQuality;
/// <summary>True when <see cref="Tier"/> is the server's stamped tier rather than an estimate.</summary>
public bool TierIsExact => IsT11 && Server.Tier > 0;
/// <summary>The loot tier: the server's stamped tier when sent, else <see cref="EstimatedTier"/>.</summary>
public int Tier => TierIsExact ? Server.Tier : EstimatedTier;
/// <summary>Free property slots (cap minus used), 0 without a known cap.</summary>
public int FreePropertySlots => PropertySlotCap > 0 && PropertySlots >= 0 ? Math.Max(0, PropertySlotCap - PropertySlots) : 0;
private readonly List<T11WieldGate> _gates = new();
private readonly List<T11Modifier> _modifiers = new();
@ -167,8 +212,26 @@ public sealed class T11ItemInfo
// A modifier's value: the first signed whole number after the name.
private static readonly Regex FirstNumber = new(@"[+-]?\d+", RegexOptions.CultureInvariant);
// The roll band at the end of a modifier line: "[14-69]".
private static readonly Regex Band = new(@"\[(?<min>\d+)\s*-\s*(?<max>\d+)\]\s*$", RegexOptions.CultureInvariant);
// "- Gear Grade: B+ (average of 4 rolled lines)": armor / jewelry / clothing / cloaks, leads the Modifiers block.
private static readonly Regex GearGradeLine = new(
@"^-?\s*Gear Grade:\s*(?<g>S|[A-DF][+-]?)(?=\s|\(|$)(?:\s*\(average of (?<n>\d+) rolled lines?\))?", Opt);
// "- Properties: 3 of 5" (or "- Properties: 3" when the tier has no limit): Modifiers block or Property Details.
private static readonly Regex PropertiesLine = new(@"^-?\s*Properties:\s*(?<n>\d+)(?:\s+of\s+(?<cap>\d+))?\s*$", Opt);
// "- Tainted: bags no longer work on this item".
private static readonly Regex TaintedLine = new(@"^-?\s*Tainted:", Opt);
// The roll band of a modifier line: "[14-69]". Not anchored: markers and the jewelry proc follow it.
private static readonly Regex Band = new(@"\[(?<min>\d+)\s*-\s*(?<max>\d+)\]", RegexOptions.CultureInvariant);
// Markers the server appends to a modifier line, in this order after the value and band.
private static readonly Regex TinkeredMark = new(@"\s*\((?<n>[+-]\d+) tinkered\)", Opt);
private static readonly Regex BuiltInMark = new(@"\s*\(Built-in\)", Opt);
private static readonly Regex LockedMark = new(@"\s*\(Locked\)", Opt);
private static readonly Regex OffHereMark = new(@"\s*\(off here\)", Opt);
// Jewelry Cast on Strike (key 54): "Cast on Strike 75% power [50-100] - Force Arc, 13% per hit".
private static readonly Regex JewelProcTail = new(@"\s+-\s+(?<name>[^,\[\]]+?),\s*(?<pct>\d+(?:\.\d+)?)% per hit", Opt);
// An uncatalogued modifier from a newer server: "Some Name +12 [5-20]" or "Modifier 60 +3 [1-5]".
private static readonly Regex GenericModifier = new(@"^(?<name>.+?)\s+(?<val>[+-]?\d+)", RegexOptions.CultureInvariant);
@ -181,17 +244,21 @@ public sealed class T11ItemInfo
/// <summary>
/// Parses an item. <paramref name="name"/>, <paramref name="longDesc"/> and
/// <paramref name="use"/> may be null or empty (an item not yet appraised has no text;
/// the name prefix alone still marks it T11). Never throws.
/// the name prefix alone still marks it T11). <paramref name="server"/> carries the tier and
/// quality properties the appraisal sent (null = none). Never throws.
/// </summary>
public static T11ItemInfo Parse(string? name, string? longDesc, string? use)
public static T11ItemInfo Parse(string? name, string? longDesc, string? use, T11ServerProps? server = null)
{
T11ServerProps props = server ?? T11ServerProps.None;
bool prefix = !string.IsNullOrEmpty(name) && name.StartsWith(T11Catalog.NamePrefix, StringComparison.Ordinal);
if (!prefix && string.IsNullOrEmpty(longDesc) && string.IsNullOrEmpty(use)) return None;
bool serverT11 = props.Tier >= T11Catalog.MinTier;
if (!prefix && !serverT11 && string.IsNullOrEmpty(longDesc) && string.IsNullOrEmpty(use)) return None;
var info = new T11ItemInfo
{
HasNamePrefix = prefix,
HasText = !string.IsNullOrEmpty(longDesc) || !string.IsNullOrEmpty(use),
Server = props,
};
try
{
@ -203,12 +270,52 @@ public sealed class T11ItemInfo
// Malformed text never breaks loot evaluation; whatever parsed so far stands.
}
// Grade, gates and banded modifiers only appear on T11 gear; Cast on Strike and the
// zone-lock line alone do not mark an item.
info.IsT11 = prefix || info.GradeRank > 0 || info._gates.Count > 0 || info._modifiers.Count > 0;
// Grades, gates, slot counts, banded modifiers and a stamped tier of 11+ only appear on
// T11 gear; Cast on Strike, Tainted and the zone-lock line alone do not mark an item.
info.IsT11 = prefix || serverT11 || info.GradeRank > 0 || info.GearGradeRank > 0 || info.PropertySlots >= 0
|| info._gates.Count > 0 || info._modifiers.Count > 0;
return info.IsT11 ? info : None;
}
/// <summary>
/// Reads a Gear Grade / Properties / Tainted line (with or without the leading dash).
/// Returns false for any other line.
/// </summary>
private bool TryParseItemLine(string line)
{
Match m = GearGradeLine.Match(line);
if (m.Success)
{
if (GearGradeRank == 0)
{
GearGrade = m.Groups["g"].Value.ToUpperInvariant();
GearGradeRank = T11Catalog.GradeRank(GearGrade);
if (m.Groups["n"].Success && int.TryParse(m.Groups["n"].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out int n))
GearGradeLines = n;
}
return true;
}
m = PropertiesLine.Match(line);
if (m.Success)
{
if (PropertySlots < 0 && int.TryParse(m.Groups["n"].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out int used))
{
PropertySlots = used;
if (m.Groups["cap"].Success && int.TryParse(m.Groups["cap"].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out int cap))
PropertySlotCap = cap;
}
return true;
}
if (TaintedLine.IsMatch(line))
{
Tainted = true;
return true;
}
return false;
}
private void ParseText(string? text)
{
if (string.IsNullOrEmpty(text)) return;
@ -226,6 +333,8 @@ public sealed class T11ItemInfo
continue;
}
if (TryParseItemLine(line)) continue;
Match m = GradeLine.Match(line);
if (m.Success && GradeRank == 0)
{
@ -261,13 +370,41 @@ public sealed class T11ItemInfo
string body = line.Substring(1).Trim();
if (body.Length == 0) continue;
if (body.Contains(ZoneLockedText, StringComparison.OrdinalIgnoreCase)) { ZoneLocked = true; continue; }
_modifiers.Add(ParseModifier(body));
// Gear Grade, Properties and Tainted lead the block but describe the item, not a modifier.
if (TryParseItemLine(body)) continue;
_modifiers.Add(ParseModifier(body, out var proc));
if (proc is { } p) _procs.Add(p);
}
return i;
}
private static T11Modifier ParseModifier(string body)
/// <summary>
/// One modifier line. <paramref name="proc"/> is the jewelry Cast on Strike's spell and
/// chance when the line carries one, else null.
/// </summary>
private static T11Modifier ParseModifier(string body, out (string Name, double ChancePercent)? proc)
{
proc = null;
// Peel the server's markers off first so the name, value and band read as on a plain line.
int tinkered = 0;
Match tm = TinkeredMark.Match(body);
if (tm.Success)
{
int.TryParse(tm.Groups["n"].Value, NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out tinkered);
body = body.Remove(tm.Index, tm.Length);
}
bool builtIn = Strip(ref body, BuiltInMark);
bool locked = Strip(ref body, LockedMark);
Strip(ref body, OffHereMark);
Match jp = JewelProcTail.Match(body);
if (jp.Success)
{
if (double.TryParse(jp.Groups["pct"].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out double chance))
proc = (jp.Groups["name"].Value.Trim(), chance);
body = body.Remove(jp.Index, jp.Length);
}
body = body.Trim();
T11ModifierDef? def = T11Catalog.MatchModifier(body);
string name;
string rest;
@ -320,9 +457,21 @@ public sealed class T11ItemInfo
RollPercent = roll,
RatingKey = def?.RatingKey ?? 0,
IsSlotSpecial = def?.SlotSpecial ?? false,
BuiltIn = builtIn,
Locked = locked,
Tinkered = tinkered,
};
}
/// <summary>Removes the first match of <paramref name="mark"/>; true when there was one.</summary>
private static bool Strip(ref string body, Regex mark)
{
Match m = mark.Match(body);
if (!m.Success) return false;
body = body.Remove(m.Index, m.Length);
return true;
}
private void AddGate(T11Counter counter, int amount)
{
for (int i = 0; i < _gates.Count; i++)

View file

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
namespace RynthCore.Loot.T11;
@ -18,7 +19,10 @@ public static class T11Keys
/// <summary>1 when the item is T11 gear, else 0.</summary>
public const int IsT11 = Base + 1;
/// <summary>Estimated loot tier from the wield gates (11-25; T16+ from the Triune Weave gate), 0 for non-T11.</summary>
/// <summary>
/// Loot tier (11-25), 0 for non-T11: the server's stamped tier (ZcTier 50109 / WeaponAugScaleTier 9061)
/// when the appraisal sent it, else estimated from the wield gates (T16+ from the Triune Weave gate).
/// </summary>
public const int EstimatedTier = Base + 2;
/// <summary>Weapon sub-grade rank: S = 16, A+ = 15 ... F- = 1, 0 = no grade.</summary>
public const int WeaponGrade = Base + 3;
@ -44,6 +48,18 @@ public static class T11Keys
public const int ZoneLocked = Base + 13;
/// <summary>Triune Weave required to wield (T16+ armor), 0 for none.</summary>
public const int WieldTriuneWeave = Base + 14;
/// <summary>Gear Grade rank of armor / jewelry / clothing: S = 16, A+ = 15 ... F- = 1, 0 = no grade.</summary>
public const int GearGrade = Base + 15;
/// <summary>Property slots in use ("Properties: N of M"), 0 when not shown.</summary>
public const int PropertySlots = Base + 16;
/// <summary>The tier's property slot limit ("Properties: N of M"), 0 when unlimited or not shown.</summary>
public const int PropertySlotCap = Base + 17;
/// <summary>Free property slots (limit minus used), 0 without a known limit.</summary>
public const int FreePropertySlots = Base + 18;
/// <summary>1 when the item is Tainted (Gear Essence bags no longer work on it).</summary>
public const int Tainted = Base + 19;
/// <summary>1 when the tier is the server's stamped value, 0 when it is estimated from the wield gates.</summary>
public const int TierIsExact = Base + 20;
/// <summary>
/// Base of the per-modifier keys: <c>ModifierBase + catalog key</c> is that modifier's value
@ -64,9 +80,15 @@ public static class T11Keys
public static IEnumerable<(int Id, string Name)> Names()
{
yield return (IsT11, "T11: Is T11");
yield return (EstimatedTier, "T11: Tier (est.)");
yield return (EstimatedTier, "T11: Tier");
yield return (TierIsExact, "T11: Tier Is Exact");
yield return (WeaponGrade, "T11: Weapon Grade");
yield return (DamagePercent, "T11: Damage % of Max");
yield return (GearGrade, "T11: Gear Grade");
yield return (PropertySlots, "T11: Property Slots Used");
yield return (PropertySlotCap, "T11: Property Slot Limit");
yield return (FreePropertySlots, "T11: Free Property Slots");
yield return (Tainted, "T11: Tainted");
yield return (WieldItemAugs, "T11: Wield Item Augs");
yield return (WieldTriuneWeave, "T11: Wield Triune Weave");
yield return (CanWield, "T11: Can Wield");
@ -100,7 +122,13 @@ public static class T11Keys
switch (key)
{
case IsT11: value = item.IsT11 ? 1 : 0; return true;
case EstimatedTier: value = item.EstimatedTier; return true;
case EstimatedTier: value = item.Tier; return true;
case TierIsExact: value = item.TierIsExact ? 1 : 0; return true;
case GearGrade: value = item.GearGradeRank; return true;
case PropertySlots: value = Math.Max(0, item.PropertySlots); return true;
case PropertySlotCap: value = item.PropertySlotCap; return true;
case FreePropertySlots: value = item.FreePropertySlots; return true;
case Tainted: value = item.Tainted ? 1 : 0; return true;
case WeaponGrade: value = item.GradeRank; return true;
case DamagePercent: value = item.DamagePercent < 0 ? 0 : item.DamagePercent; return true;
case WieldItemAugs: value = item.WieldItemAugs; return true;

77
Shared/UbMobSeed.cs Normal file
View file

@ -0,0 +1,77 @@
using System.Collections.Generic;
namespace RynthCore.CreatureSeed;
/// <summary>
/// Monster damage-type seed derived from UtilityBelt's <c>mob_damage_insights.ldb</c>.
/// Written by the Monster Editor ("Import UB damage insights"); read (never written)
/// by the RynthAi plugin as a fallback for the "Auto" damage type when a monster
/// has no appraised resists yet.
/// File: <c>&lt;SuiteDir&gt;\RynthAi\CreatureData\ub-mob-seed.json</c>.
/// Compiled into both projects so the schema cannot drift; plain properties with
/// defaults keep it source-generator (NativeAOT) friendly.
/// </summary>
public sealed class UbMobSeedFile
{
/// <summary>Current schema version written by the importer.</summary>
public const int CurrentVersion = 1;
/// <summary>File name inside <c>RynthAi\CreatureData</c>.</summary>
public const string FileName = "ub-mob-seed.json";
/// <summary>Schema version of this file; readers ignore files with a newer major version.</summary>
public int Version { get; set; } = CurrentVersion;
/// <summary>UTC time the importer produced the file (ISO-8601).</summary>
public string GeneratedUtc { get; set; } = string.Empty;
/// <summary>Most common UB world name across the imported rows (e.g. "InfiniteLeaftide").</summary>
public string World { get; set; } = string.Empty;
/// <summary>Hits a damage type needs before it is ranked at all.</summary>
public int MinHitsPerType { get; set; }
/// <summary>Source databases that contributed rows (full paths, for traceability).</summary>
public List<string> Sources { get; set; } = new();
/// <summary>One entry per monster with at least two comparable damage types.</summary>
public List<UbMobSeedEntry> Entries { get; set; } = new();
}
/// <summary>Seeded damage-type ranking for one monster.</summary>
public sealed class UbMobSeedEntry
{
/// <summary>Weenie class id; 0 for name-only rows imported from Mag-Tools.</summary>
public uint Wcid { get; set; }
/// <summary>Last display name UB saw for this monster.</summary>
public string Name { get; set; } = string.Empty;
/// <summary>"ub" (live UB wcid rows) or "magtools" (name-keyed Mag-Tools XML imports).</summary>
public string Source { get; set; } = string.Empty;
/// <summary>All hits UB recorded against this monster (every type, including unranked ones).</summary>
public long TotalHits { get; set; }
/// <summary>Ranked damage types, best first. Only types meeting the hit threshold are listed.</summary>
public List<UbMobSeedElement> Elements { get; set; } = new();
}
/// <summary>Observed outgoing-damage statistics for one damage type against one monster.</summary>
public sealed class UbMobSeedElement
{
/// <summary>RynthAi element name: Slash, Pierce, Bludgeon, Fire, Cold, Lightning, Acid or Nether.</summary>
public string Element { get; set; } = string.Empty;
/// <summary>Hits recorded with this damage type.</summary>
public int Hits { get; set; }
/// <summary>Average damage per hit with this damage type.</summary>
public double AvgDamage { get; set; }
/// <summary>Largest single hit (0 for Mag-Tools rows, which do not record it).</summary>
public long MaxHit { get; set; }
/// <summary>Relative effectiveness 0..1 (1 = best type for this monster); used for the ranking.</summary>
public double Score { get; set; }
}