Snapshot for release 2026.10.6.2 (internal e3a94cf)
Faster weapon switches; T11 loot support (by SilentKelpie, rynth/RynthSuite PR #3).
This commit is contained in:
parent
5416e8066a
commit
dafd6084a7
24 changed files with 1645 additions and 34 deletions
|
|
@ -39,6 +39,8 @@ public enum LongValueKey
|
|||
public enum StringValueKey
|
||||
{
|
||||
Name = 1,
|
||||
// ACECustom puts the T11 "Modifiers:" block of armor, clothing and jewelry here.
|
||||
Use = 14,
|
||||
ShortDesc = 15,
|
||||
LongDesc = 16,
|
||||
PluralName = 20,
|
||||
|
|
@ -117,13 +119,27 @@ public class WorldObject
|
|||
|
||||
public int Values(int key, int defaultValue)
|
||||
{
|
||||
// T11 virtual keys are computed from the item's text, never stored on the object.
|
||||
if (RynthCore.Loot.T11.T11Keys.IsVirtual(key))
|
||||
return Loot.T11ItemSupport.VirtualValue(this, key, defaultValue);
|
||||
|
||||
var o = Overlay;
|
||||
if (o != null)
|
||||
{
|
||||
if (o.Ints.TryGetValue(unchecked((uint)key), out int v)) return v;
|
||||
if (!o.LiveFallback) return defaultValue;
|
||||
if (!o.LiveFallback) return Loot.T11ItemSupport.StrippedValue(this, key, defaultValue);
|
||||
}
|
||||
return Cache?.GetIntProperty(Id, (uint)key, defaultValue) ?? defaultValue;
|
||||
if (Cache == null) return Loot.T11ItemSupport.StrippedValue(this, key, defaultValue);
|
||||
|
||||
// T11 appraisals omit the item-aug wield gate (158-160) and modifier-carried ratings
|
||||
// (370-379); an absent or zero value there falls back to what the item's text says.
|
||||
if (RynthCore.Loot.T11.T11Keys.IsStrippedKey(key))
|
||||
{
|
||||
int live = Cache.GetIntProperty(Id, (uint)key, int.MinValue);
|
||||
if (live != int.MinValue && live != 0) return live;
|
||||
return Loot.T11ItemSupport.StrippedValue(this, key, live == int.MinValue ? defaultValue : 0);
|
||||
}
|
||||
return Cache.GetIntProperty(Id, (uint)key, defaultValue);
|
||||
}
|
||||
|
||||
public string Values(StringValueKey key, string defaultValue)
|
||||
|
|
|
|||
|
|
@ -328,6 +328,13 @@ public class BuffManager : IDisposable
|
|||
// stow the bow into a capacity-verified open pack FIRST (AutoCram pattern), then wield
|
||||
// the wand. All paths are bounded so a stale/no-op dequip or unwieldable wand can never
|
||||
// loop forever; on exhaustion the buff family is parked and the bot fights unbuffed.
|
||||
// Switch like a player (2026-10-06): a use of the wand goes through ClientUISystem::UseObject,
|
||||
// the client's double-click, which puts the weapon in hand away by itself (ACE's
|
||||
// DoHandleActionGetAndWieldItem: "the client handles dequipping a lot of conflicting items
|
||||
// automatically"). Drakkon's axe -> wand took 4.2 s with the pack move first (1.2 s for it,
|
||||
// then the swap gate's flat 3 s). The pack move stays as the fallback: once a use hasn't
|
||||
// got the wand into the hand in WieldResolveTimeoutMs, this session moves the weapon first.
|
||||
private bool _directWandSwapFailed;
|
||||
private int _bowDequipPendingId;
|
||||
private DateTime _bowDequipAt = DateTime.MinValue;
|
||||
private int _bowDequipAttempts;
|
||||
|
|
@ -3893,6 +3900,15 @@ public class BuffManager : IDisposable
|
|||
if ((now - _pendingWieldAt).TotalMilliseconds < WieldResolveTimeoutMs)
|
||||
return false;
|
||||
|
||||
int stillInHand = _directWandSwapFailed ? 0 : FindWieldedNonWandWeapon(wandId);
|
||||
if (stillInHand != 0 && IsWieldedLive(stillInHand))
|
||||
{
|
||||
_directWandSwapFailed = true;
|
||||
_pendingWieldId = 0;
|
||||
_host.Log($"[WieldGate] using the wand didn't put 0x{(uint)stillInHand:X8} away in {WieldResolveTimeoutMs:0} ms; " +
|
||||
"from now on the weapon goes into a pack first");
|
||||
return false;
|
||||
}
|
||||
_host.Log($"[WieldGate] UseObject(0x{(uint)_pendingWieldId:X8}) not confirmed in " +
|
||||
$"{WieldResolveTimeoutMs:0}ms — cooling down {WieldCooldownMs:0}ms");
|
||||
_pendingWieldId = 0;
|
||||
|
|
@ -3930,7 +3946,7 @@ public class BuffManager : IDisposable
|
|||
// non-wand weapon into a capacity-verified open pack FIRST (AutoCram pattern,
|
||||
// AV-safe), then UseObject(wand) once the hand is free. Fully bounded.
|
||||
int bowId = FindWieldedNonWandWeapon(wandId);
|
||||
if (bowId != 0)
|
||||
if (bowId != 0 && (_directWandSwapFailed || !IsWieldedLive(bowId))) // else the use swaps (see _directWandSwapFailed)
|
||||
{
|
||||
if (_bowDequipPendingId == bowId
|
||||
&& (now - _bowDequipAt).TotalMilliseconds < WieldResolveTimeoutMs
|
||||
|
|
@ -3953,6 +3969,7 @@ public class BuffManager : IDisposable
|
|||
if (_worldObjectCache?[bowId] is WorldObject blocker && IsInOffhandSlot(blocker))
|
||||
OffhandStowed?.Invoke(bowId); // a shield: combat puts it back after
|
||||
_host.MoveItemInternal((uint)bowId, (uint)openPack, 0, 1); // amount>=1 (engine rejects 0)
|
||||
_weaponSwapGate?.NoteMove(bowId, wieldedNow: true);
|
||||
_bowDequipPendingId = bowId;
|
||||
_bowDequipAt = now;
|
||||
_lastCastAttempt = now;
|
||||
|
|
@ -3962,7 +3979,7 @@ public class BuffManager : IDisposable
|
|||
_bowDequipPendingId = 0; // bow confirmed unwielded — fall through to wield the wand
|
||||
}
|
||||
|
||||
_host.UseFor((uint)wandId, "Buff", "buffing: wield the wand");
|
||||
_host.UseFor((uint)wandId, "Buff", bowId != 0 && !_directWandSwapFailed ? "buffing: switch to the wand" : "buffing: wield the wand");
|
||||
NoteStanceRequest();
|
||||
_pendingWieldId = wandId;
|
||||
_pendingWieldAt = now;
|
||||
|
|
|
|||
|
|
@ -220,6 +220,7 @@ public partial class CombatManager
|
|||
var wo = _worldFilter[wielded.Id];
|
||||
int amount = Math.Max(1, wo?.Values(LongValueKey.StackCount, 1) ?? 1); // the whole stack, not one arrow
|
||||
_host.MoveItemInternal(unchecked((uint)wielded.Id), unchecked((uint)packId), 0, amount);
|
||||
_weaponSwapGate?.NoteMove(wielded.Id, wieldedNow: true);
|
||||
_ammoDequipPendingId = wielded.Id;
|
||||
_ammoDequipAt = now;
|
||||
_ammoDequipTries++;
|
||||
|
|
|
|||
|
|
@ -285,6 +285,7 @@ public partial class CombatManager
|
|||
if (!gateHeld && _weaponSwapGate != null && !_weaponSwapGate.TryBeginSwap("combat-offhand-dequip")) return OffPrep.Busy;
|
||||
|
||||
_host.MoveItemInternal(unchecked((uint)offId), unchecked((uint)packId), 0, 1);
|
||||
_weaponSwapGate?.NoteMove(offId, wieldedNow: true);
|
||||
_offDequipPendingId = offId;
|
||||
_offDequipAt = now;
|
||||
_offDequipTries++;
|
||||
|
|
@ -379,6 +380,7 @@ public partial class CombatManager
|
|||
if (_host.HasGetLastUseDone && _host.TryGetLastUseDone(out int uSeq, out _)) _swapUseDoneSeq = uSeq;
|
||||
if (_host.HasGetLastWeenieError && _host.TryGetLastWeenieError(out int wSeq, out _, out _, out _)) _swapWeenieSeq = wSeq;
|
||||
OffhandTracker.Sent(plan.Id, _offSwapFrom, now);
|
||||
_weaponSwapGate?.NoteMove(plan.Id, wieldedNow: false);
|
||||
_offSwapFrom = 0;
|
||||
_lastEquipTime = now;
|
||||
if (plan.Id != _stowedOffhandId) _stowedOffhandId = 0; // a listed one replaces what was taken off
|
||||
|
|
|
|||
|
|
@ -113,6 +113,12 @@ public partial class CombatManager : IDisposable
|
|||
// Combat must stow the bow into an open pack FIRST, then UseObject(wand), and
|
||||
// only request Magic once the wand is actually wielded (handled by the
|
||||
// alreadyWielded branch). Mirrors the proven BuffManager.EnsureMagicMode path.
|
||||
// Switch like a player (2026-10-06, see BuffManager._directWandSwapFailed): the wand's use
|
||||
// puts the weapon in hand away by itself; the pack move first is the fallback once a use
|
||||
// hasn't done it in DirectWandSwapFallbackMs.
|
||||
private bool _combatDirectWandSwapFailed;
|
||||
private DateTime _combatDirectSwapSince = DateTime.MinValue;
|
||||
private const double DirectWandSwapFallbackMs = 2000; // SwapTracker retries at 2500: that retry is the pack move
|
||||
private int _combatBowDequipPendingId;
|
||||
private int _combatBowDequipAttempts;
|
||||
private DateTime _combatBowDequipAt = DateTime.MinValue;
|
||||
|
|
@ -146,6 +152,7 @@ public partial class CombatManager : IDisposable
|
|||
_combatBowDequipPendingId = 0;
|
||||
_combatBowDequipAttempts = 0;
|
||||
_combatSwapTeardownDone = false;
|
||||
_combatDirectSwapSince = DateTime.MinValue;
|
||||
}
|
||||
|
||||
// ── Face-before-attack state ─────────────────────────────────────────
|
||||
|
|
@ -4068,7 +4075,9 @@ public partial class CombatManager : IDisposable
|
|||
// nothing when the wand genuinely isn't wielded: ACE just denies it, and the
|
||||
// gated UseObject below still does the wielding. Mirrors the non-wand branch,
|
||||
// which has always sent both.
|
||||
if ((DateTime.Now - lastStanceAttempt).TotalMilliseconds > StanceRetryDelayMs()
|
||||
// A weapon still in hand: the wand's use swaps it and the server then puts us in Magic.
|
||||
if (FindWieldedNonWandWeapon(targetWeaponId) == 0
|
||||
&& (DateTime.Now - lastStanceAttempt).TotalMilliseconds > StanceRetryDelayMs()
|
||||
&& _host.ChangeCombatModeFor(desiredMode, "Combat", "stance"))
|
||||
{
|
||||
if (diagNow) _host.Log($"[EquipDiag] hand clear — ChangeCombatMode({desiredMode}) alongside wand equip (mode={CurrentCombatMode})");
|
||||
|
|
@ -4156,6 +4165,16 @@ public partial class CombatManager : IDisposable
|
|||
private bool EnsureHandClearForWand(int wandId, bool diagNow)
|
||||
{
|
||||
int bowId = FindWieldedNonWandWeapon(wandId);
|
||||
DateTime now = DateTime.Now;
|
||||
if (bowId != 0 && !_combatDirectWandSwapFailed && IsWieldedLive(bowId))
|
||||
{
|
||||
if (_combatDirectSwapSince == DateTime.MinValue) _combatDirectSwapSince = now;
|
||||
if ((now - _combatDirectSwapSince).TotalMilliseconds <= DirectWandSwapFallbackMs)
|
||||
return true; // the wand's use swaps
|
||||
_combatDirectWandSwapFailed = true;
|
||||
_host.Log($"[EquipDiag] using the wand didn't put 0x{(uint)bowId:X8} away in {DirectWandSwapFallbackMs:0} ms; from now on the weapon goes into a pack first");
|
||||
}
|
||||
_combatDirectSwapSince = DateTime.MinValue;
|
||||
if (bowId == 0)
|
||||
{
|
||||
_combatBowDequipPendingId = 0; _combatBowDequipAttempts = 0;
|
||||
|
|
@ -4165,7 +4184,6 @@ public partial class CombatManager : IDisposable
|
|||
return ClearOffhandFor(wandId, _curOffhandMode, gateHeld: true) == OffPrep.Ready;
|
||||
}
|
||||
|
||||
DateTime now = DateTime.Now;
|
||||
if (_combatBowDequipPendingId == bowId
|
||||
&& (now - _combatBowDequipAt).TotalMilliseconds < WandSwapWieldResolveMs
|
||||
&& IsWieldedLive(bowId))
|
||||
|
|
@ -4173,7 +4191,7 @@ public partial class CombatManager : IDisposable
|
|||
|
||||
if (IsWieldedLive(bowId))
|
||||
{
|
||||
int openPack = WorldObjectCache.FindPackFor(_host, _worldFilter, includeMainPack: true, requireFree: 1);
|
||||
int openPack = OpenPackOverride?.Invoke() ?? WorldObjectCache.FindPackFor(_host, _worldFilter, includeMainPack: true, requireFree: 1);
|
||||
if (openPack == 0 || _combatBowDequipAttempts >= CombatBowDequipMaxAttempts)
|
||||
{
|
||||
// No verified-open pack to receive the bow, or repeated failures — the swap
|
||||
|
|
@ -4192,6 +4210,7 @@ public partial class CombatManager : IDisposable
|
|||
}
|
||||
_combatBowDequipAttempts++;
|
||||
_host.MoveItemInternal((uint)bowId, (uint)openPack, 0, 1); // amount>=1 (engine rejects 0)
|
||||
_weaponSwapGate?.NoteMove(bowId, wieldedNow: true);
|
||||
_combatBowDequipPendingId = bowId;
|
||||
_combatBowDequipAt = now;
|
||||
_host.Log($"[EquipDiag] dequip bow 0x{(uint)bowId:X8} -> pack 0x{(uint)openPack:X8} (attempt {_combatBowDequipAttempts}/{CombatBowDequipMaxAttempts}) before wand equip");
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ namespace RynthCore.Plugin.RynthAi;
|
|||
/// they didn't know about each other, so cross-subsystem swaps still raced.
|
||||
///
|
||||
/// This gate is a single shared instance both managers consult: a swap is only
|
||||
/// allowed if no other swap has been issued within MinIntervalMs. The loser
|
||||
/// yields and retries on a later tick. Spell casts and non-weapon item actions
|
||||
/// allowed once the last one is done on the server (or MinIntervalMs has passed).
|
||||
/// The loser yields and retries on a later tick. Spell casts and non-weapon item actions
|
||||
/// (loot moves, corpse opens) do NOT go through here.
|
||||
/// </summary>
|
||||
public sealed class WeaponSwapGate
|
||||
|
|
@ -24,37 +24,83 @@ public sealed class WeaponSwapGate
|
|||
private readonly object _lock = new();
|
||||
private long _lastSwapTickMs = long.MinValue / 4;
|
||||
private string _lastSwapBy = "";
|
||||
private int _movingId;
|
||||
private bool _movingWasWielded;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum milliseconds between two weapon swaps. ~3s comfortably covers
|
||||
/// AC's equip + stance-change settle (matches the existing 3000ms cast
|
||||
/// equip-gate in CombatManager) so a swap fully resolves before the next.
|
||||
/// The longest one swap holds the next: a swap the server's answer can't be seen for (or
|
||||
/// with no <see cref="ServerIdle"/>) waits this long, as before 2026-10-06.
|
||||
/// </summary>
|
||||
public int MinIntervalMs { get; set; } = 3000;
|
||||
|
||||
/// <summary>
|
||||
/// Atomically claim the swap slot. Returns true (recording the swap) when
|
||||
/// no swap has occurred within MinIntervalMs; false when the caller must
|
||||
/// wait. Only mutates state when it returns true, so a denied caller never
|
||||
/// Swap speed (2026-10-06): the next swap may go once the last one is done on the server,
|
||||
/// after at least this long. A weapon change takes up to three steps (a shield or arrows
|
||||
/// into the pack, the weapon, the off hand); at a flat 3 s per step it took 6-9 s.
|
||||
/// </summary>
|
||||
public int FloorMs { get; set; } = 400;
|
||||
|
||||
/// <summary>True when no use or cast is waiting for the server's answer (ActionPacer).</summary>
|
||||
public Func<bool>? ServerIdle { get; set; }
|
||||
|
||||
/// <summary>Reads whether the character wields an item (for a noted move, <see cref="NoteMove"/>).</summary>
|
||||
public Func<int, bool>? IsWielded { get; set; }
|
||||
|
||||
public Func<long> NowMs { get; set; } = () => Environment.TickCount64;
|
||||
|
||||
/// <summary>
|
||||
/// Atomically claim the swap slot. Returns true (recording the swap) when the last swap is
|
||||
/// done on the server (see <see cref="FloorMs"/>) or MinIntervalMs has passed; false when
|
||||
/// the caller must wait. Only mutates state when it returns true, so a denied caller never
|
||||
/// "wastes" the slot.
|
||||
/// </summary>
|
||||
public bool TryBeginSwap(string requestedBy)
|
||||
{
|
||||
long now = Environment.TickCount64;
|
||||
long now = NowMs();
|
||||
lock (_lock)
|
||||
{
|
||||
if (now - _lastSwapTickMs < MinIntervalMs)
|
||||
long since = now - _lastSwapTickMs;
|
||||
if (since < MinIntervalMs && !LastSwapDone(since))
|
||||
return false;
|
||||
_lastSwapTickMs = now;
|
||||
_lastSwapBy = requestedBy ?? "";
|
||||
_movingId = 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The claimed swap moved <paramref name="itemId"/> into or out of a hand without a use (a
|
||||
/// pack move or a slot wield, which the server answers with no UseDone): the swap is done
|
||||
/// once the item's wielded state is no longer <paramref name="wieldedNow"/>.
|
||||
/// </summary>
|
||||
public void NoteMove(int itemId, bool wieldedNow)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_movingId = itemId;
|
||||
_movingWasWielded = wieldedNow;
|
||||
}
|
||||
}
|
||||
|
||||
private bool LastSwapDone(long since)
|
||||
{
|
||||
if (since < FloorMs || ServerIdle == null || IsWielded == null) return false;
|
||||
try
|
||||
{
|
||||
if (!ServerIdle()) return false;
|
||||
return _movingId == 0 || IsWielded(_movingId) != _movingWasWielded;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Milliseconds since the last successful swap (diagnostics).</summary>
|
||||
public long MsSinceLastSwap
|
||||
{
|
||||
get { lock (_lock) { return Environment.TickCount64 - _lastSwapTickMs; } }
|
||||
get { lock (_lock) { return NowMs() - _lastSwapTickMs; } }
|
||||
}
|
||||
|
||||
/// <summary>Who last claimed a swap (diagnostics).</summary>
|
||||
|
|
|
|||
|
|
@ -948,6 +948,7 @@ internal sealed class LegacyDashboardRenderer
|
|||
BlacklistCastSettleMs = s.BlacklistCastSettleMs,
|
||||
TargetNoProgressTimeoutSec = s.TargetNoProgressTimeoutSec,
|
||||
GiveQueueIntervalMs = s.GiveQueueIntervalMs,
|
||||
T11ItemAugsOverride = s.T11ItemAugsOverride,
|
||||
// Recharge
|
||||
HealAt = s.HealAt,
|
||||
UsePotions = s.UsePotions,
|
||||
|
|
@ -1154,6 +1155,7 @@ internal sealed class LegacyDashboardRenderer
|
|||
if (p.BlacklistCastSettleMs > 0) s.BlacklistCastSettleMs = p.BlacklistCastSettleMs;
|
||||
s.TargetNoProgressTimeoutSec = p.TargetNoProgressTimeoutSec;
|
||||
s.GiveQueueIntervalMs = p.GiveQueueIntervalMs;
|
||||
s.T11ItemAugsOverride = p.T11ItemAugsOverride ?? -1;
|
||||
// Recharge
|
||||
s.HealAt = p.HealAt;
|
||||
s.UsePotions = p.UsePotions;
|
||||
|
|
@ -1770,6 +1772,7 @@ internal sealed class LegacyDashboardRenderer
|
|||
dst.NavLabelMode = NavLabelModes.Clamp(tmp.NavLabelMode);
|
||||
dst.NavGuideLine = tmp.NavGuideLine;
|
||||
dst.GiveQueueIntervalMs = tmp.GiveQueueIntervalMs;
|
||||
dst.T11ItemAugsOverride = tmp.T11ItemAugsOverride;
|
||||
dst.SpellCastIntervalMs = tmp.SpellCastIntervalMs;
|
||||
dst.AttackSpellIntervalMs = tmp.AttackSpellIntervalMs;
|
||||
dst.EmbeddedNavs = tmp.EmbeddedNavs;
|
||||
|
|
|
|||
|
|
@ -267,6 +267,13 @@ public sealed class LegacyUiSettings
|
|||
|
||||
public int GiveQueueIntervalMs = 150;
|
||||
|
||||
/// <summary>
|
||||
/// Item augmentation count used for T11 wield gates in loot rules ("T11: Can Wield").
|
||||
/// -1 = automatic (read from the server's "/aug" reply). ACECustom doesn't send the count
|
||||
/// at login, so this is the fallback when "/aug" is unavailable. Set with /ra t11 augs.
|
||||
/// </summary>
|
||||
public int T11ItemAugsOverride = -1;
|
||||
|
||||
public int SpellCastIntervalMs = 400;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -771,6 +778,7 @@ public sealed class SettingsBridgePayload
|
|||
public int BlacklistCastSettleMs { get; set; } = -1;
|
||||
public int TargetNoProgressTimeoutSec { get; set; }
|
||||
public int GiveQueueIntervalMs { get; set; }
|
||||
public int? T11ItemAugsOverride { get; set; }
|
||||
|
||||
// Recharge
|
||||
public int HealAt { get; set; }
|
||||
|
|
|
|||
116
Plugins/RynthCore.Plugin.RynthAi/Loot/T11ItemSupport.cs
Normal file
116
Plugins/RynthCore.Plugin.RynthAi/Loot/T11ItemSupport.cs
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using RynthCore.Loot.T11;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.Loot;
|
||||
|
||||
/// <summary>
|
||||
/// T11 (tier 11+ ACECustom) loot support for <see cref="WorldObject.Values(int, int)"/>:
|
||||
/// answers the virtual T11 keys (<see cref="T11Keys"/>) and puts back the wield-requirement and
|
||||
/// rating properties the server strips from T11 appraisals. Parsed item text is cached per
|
||||
/// object and re-parsed only when the text changes. Holds the player's "/aug" counters for
|
||||
/// the "Can Wield" key. One character per process, so the state is static.
|
||||
/// </summary>
|
||||
internal static class T11ItemSupport
|
||||
{
|
||||
/// <summary>The logged-in character's T11 wield counters.</summary>
|
||||
public static T11PlayerAugs Player { get; } = new();
|
||||
|
||||
private static readonly T11AugReportParser AugParser = new();
|
||||
private static readonly object Gate = new();
|
||||
private static readonly Dictionary<int, Entry> Parsed = new();
|
||||
|
||||
// Bound so a long session's corpse items can't grow the cache without limit; a full
|
||||
// clear is fine because re-parsing is cheap and only happens for items still in use.
|
||||
private const int MaxEntries = 4096;
|
||||
|
||||
private sealed class Entry
|
||||
{
|
||||
public string Name = string.Empty;
|
||||
public string LongDesc = string.Empty;
|
||||
public string Use = string.Empty;
|
||||
public T11ItemInfo Info = T11ItemInfo.None;
|
||||
}
|
||||
|
||||
/// <summary>True when <paramref name="name"/> carries the server's T11 drop prefix.</summary>
|
||||
public static bool HasT11Name(string? name)
|
||||
=> !string.IsNullOrEmpty(name) && name.StartsWith(T11Catalog.NamePrefix, StringComparison.Ordinal);
|
||||
|
||||
/// <summary>The parsed T11 view of <paramref name="item"/> (<see cref="T11ItemInfo.None"/> for other items).</summary>
|
||||
public static T11ItemInfo Get(WorldObject item)
|
||||
{
|
||||
string name = item.Name.Length > 0 ? item.Name : item.Values(StringValueKey.Name, string.Empty);
|
||||
string longDesc = item.Values(StringValueKey.LongDesc, string.Empty);
|
||||
string use = item.Values(StringValueKey.Use, string.Empty);
|
||||
|
||||
lock (Gate)
|
||||
{
|
||||
if (Parsed.TryGetValue(item.Id, out Entry? e)
|
||||
&& string.Equals(e.Name, name, StringComparison.Ordinal)
|
||||
&& string.Equals(e.LongDesc, longDesc, StringComparison.Ordinal)
|
||||
&& string.Equals(e.Use, use, StringComparison.Ordinal))
|
||||
return e.Info;
|
||||
}
|
||||
|
||||
T11ItemInfo info = T11ItemInfo.Parse(name, longDesc, use);
|
||||
lock (Gate)
|
||||
{
|
||||
if (Parsed.Count >= MaxEntries) Parsed.Clear();
|
||||
Parsed[item.Id] = new Entry { Name = name, LongDesc = longDesc, Use = use, Info = info };
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
/// <summary>A virtual T11 key's value, or <paramref name="defaultValue"/> for an unused id.</summary>
|
||||
public static int VirtualValue(WorldObject item, int key, int defaultValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
return T11Keys.TryGetValue(Get(item), key, Player, out int value) ? value : defaultValue;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The value a T11 appraisal stripped for a retail key (158/159/160, 370-379), else
|
||||
/// <paramref name="fallback"/>. Only T11-named items are parsed, so other items pay a
|
||||
/// string compare.
|
||||
/// </summary>
|
||||
public static int StrippedValue(WorldObject item, int key, int fallback)
|
||||
{
|
||||
if (!T11Keys.IsStrippedKey(key)) return fallback;
|
||||
try
|
||||
{
|
||||
string name = item.Name.Length > 0 ? item.Name : item.Values(StringValueKey.Name, string.Empty);
|
||||
if (!HasT11Name(name)) return fallback;
|
||||
return T11Keys.TryGetStrippedValue(Get(item), key, out int value) ? value : fallback;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Feeds a chat line to the "/aug" reader. Returns true when a counter changed.</summary>
|
||||
public static bool OnChat(string? text) => AugParser.Feed(text, Environment.TickCount64, Player);
|
||||
|
||||
/// <summary>Applies the saved item-aug override (-1 = automatic). Cheap; called every tick.</summary>
|
||||
public static void SyncOverride(int itemAugsOverride)
|
||||
=> Player.ItemAugOverride = itemAugsOverride >= 0 ? itemAugsOverride : null;
|
||||
|
||||
/// <summary>Drops the cached parse of a deleted object.</summary>
|
||||
public static void Forget(int objectId)
|
||||
{
|
||||
lock (Gate) Parsed.Remove(objectId);
|
||||
}
|
||||
|
||||
/// <summary>Forgets the character's counters and every cached item (logout).</summary>
|
||||
public static void Reset()
|
||||
{
|
||||
Player.Clear();
|
||||
lock (Gate) Parsed.Clear();
|
||||
}
|
||||
}
|
||||
|
|
@ -36,6 +36,7 @@ public sealed partial class RynthAiPlugin
|
|||
ChatLine("[RynthAi] /ra attackable — check if target is attackable");
|
||||
ChatLine("[RynthAi] /ra wielded — show wielded items");
|
||||
ChatLine("[RynthAi] /ra dumpprops [0xId] — every property of the selection (else yourself)");
|
||||
ChatLine("[RynthAi] /ra t11 [augs <n|auto>|refresh|item] — T11 loot: wield counters, aug override, parsed item");
|
||||
ChatLine("[RynthAi] /ra iteminfo [name] — the selected (or named) item's details, Mag-Tools style");
|
||||
ChatLine("[RynthAi] /ra mexec <expr> — evaluate meta expression");
|
||||
ChatLine("[RynthAi] /ra listvars — show session variables");
|
||||
|
|
|
|||
|
|
@ -258,6 +258,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
{
|
||||
Log("RynthAi: logout — tearing down session.");
|
||||
try { _dashboard?.SaveSettings(); } catch { }
|
||||
Loot.T11ItemSupport.Reset();
|
||||
// A real logout: the next OnLoginComplete is a fresh login, not a hot reload.
|
||||
ClearInGameMarker();
|
||||
TeardownSession();
|
||||
|
|
@ -585,6 +586,9 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
// other (the collision behind "you can only move or use one item at a
|
||||
// time" and the object-teardown AV).
|
||||
_weaponSwapGate ??= new WeaponSwapGate();
|
||||
// The next swap goes once the server is done with the last one (not a flat 3 s).
|
||||
_weaponSwapGate.ServerIdle = () => RynthCore.Plugin.Shared.ActionPacer.Enabled && RynthCore.Plugin.Shared.ActionPacer.Current(Host) == null;
|
||||
_weaponSwapGate.IsWielded = id => RynthCore.Plugin.Shared.ActionPacer.IsWieldedByPlayer(Host, unchecked((uint)id));
|
||||
|
||||
_buffManager = new BuffManager(Host, _dashboard.Settings, _spellManager, _vitals);
|
||||
_inGameMarkerSet = false;
|
||||
|
|
@ -1398,6 +1402,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
DrainGiveQueue();
|
||||
if (diag) Host.Log("[RynthAi] OnTick: after drain give queue");
|
||||
if (_loginComplete) TickItemInfo();
|
||||
Loot.T11ItemSupport.SyncOverride(_dashboard?.Settings.T11ItemAugsOverride ?? -1);
|
||||
_jumper?.Tick();
|
||||
if (diag) Host.Log("[RynthAi] OnTick: after jumper tick");
|
||||
|
||||
|
|
@ -2039,6 +2044,9 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
_scrollLearner?.OnChat(text);
|
||||
_metaManager?.HandleChat(text, chatType);
|
||||
_questTracker?.OnChatLine(text);
|
||||
// The "/aug" reply carries the T11 wield counters.
|
||||
try { Loot.T11ItemSupport.OnChat(text); }
|
||||
catch (Exception ex) { Log("RynthAi: T11 /aug parse failed: " + ex.Message); }
|
||||
CheckChatForSafetyStops(text);
|
||||
try { OnOwnCorpseChat(text); } catch { }
|
||||
}
|
||||
|
|
@ -2071,6 +2079,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
_objectCache?.OnDeleteObject(objectId);
|
||||
_combatManager?.OnObjectDeleted(objectId); // D7/D8: free per-id maps + clear cast-wait if it was our target
|
||||
_scrollLearner?.OnObjectDeleted(objectId); // a read scroll is consumed
|
||||
Loot.T11ItemSupport.Forget(unchecked((int)objectId));
|
||||
HandleCorpseObjectDeleted(objectId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -3068,6 +3077,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
case "dumpprops": HandleDumpPropsCommand(parts); break;
|
||||
case "iteminfo": HandleItemInfoCommand(parts); break;
|
||||
case "version": HandleVersionCommand(); break;
|
||||
case "t11": HandleT11Command(parts); break;
|
||||
case "wielded": HandleWieldedCommand(); break;
|
||||
case "scan": HandleScanCommand(); break;
|
||||
case "buildinfo": HandleBuildInfoCommand(); break;
|
||||
|
|
|
|||
124
Plugins/RynthCore.Plugin.RynthAi/RynthAiT11Command.cs
Normal file
124
Plugins/RynthCore.Plugin.RynthAi/RynthAiT11Command.cs
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using RynthCore.Loot.T11;
|
||||
using RynthCore.Plugin.RynthAi.Loot;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi;
|
||||
|
||||
public sealed partial class RynthAiPlugin
|
||||
{
|
||||
/// <summary>
|
||||
/// /ra t11 [augs <n|auto> | refresh | item [0xId]]: T11 loot support.
|
||||
/// No argument shows the wield counters the loot rules use; "augs" sets or clears the
|
||||
/// item-aug override; "refresh" asks the server for "/aug"; "item" shows how the selected
|
||||
/// item's T11 text was read and the values its virtual loot keys return.
|
||||
/// </summary>
|
||||
private void HandleT11Command(string[] parts)
|
||||
{
|
||||
string sub = parts.Length >= 3 ? parts[2].ToLowerInvariant() : string.Empty;
|
||||
switch (sub)
|
||||
{
|
||||
case "":
|
||||
case "status":
|
||||
PrintT11Status();
|
||||
break;
|
||||
case "augs":
|
||||
SetT11ItemAugOverride(parts.Length >= 4 ? parts[3] : string.Empty);
|
||||
break;
|
||||
case "refresh":
|
||||
if (!Host.HasInvokeChatParser) { ChatLine("[RynthAi] This engine can't send chat commands."); break; }
|
||||
Host.InvokeChatParser("/aug");
|
||||
ChatLine("[RynthAi] T11: sent /aug - the counters update from its reply.");
|
||||
break;
|
||||
case "item":
|
||||
PrintT11Item(parts.Length >= 4 ? parts[3] : null);
|
||||
break;
|
||||
default:
|
||||
ChatLine("[RynthAi] Usage: /ra t11 [augs <n|auto> | refresh | item [0xId]]");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The counters the "T11: Can Wield" loot key compares wield gates against.</summary>
|
||||
private void PrintT11Status()
|
||||
{
|
||||
T11PlayerAugs p = T11ItemSupport.Player;
|
||||
int saved = _dashboard?.Settings.T11ItemAugsOverride ?? -1;
|
||||
string updated = p.UpdatedUtc is DateTime t ? t.ToLocalTime().ToString("t", CultureInfo.CurrentCulture) : "never";
|
||||
ChatLine($"[RynthAi] === T11 loot (last /aug read: {updated}) ===");
|
||||
foreach ((T11Counter counter, string name) in T11Catalog.CounterNames)
|
||||
{
|
||||
long? v = p.Get(counter);
|
||||
string source = counter == T11Counter.ItemAugmentations && saved >= 0 ? " (override)" : string.Empty;
|
||||
ChatLine($"[RynthAi] {name}: {(v.HasValue ? v.Value.ToString("N0", CultureInfo.CurrentCulture) : "unknown")}{source}");
|
||||
}
|
||||
if (p.UpdatedUtc == null && saved < 0)
|
||||
ChatLine("[RynthAi] Unknown counters make \"T11: Can Wield\" -1. Use /ra t11 refresh, or /ra t11 augs <n>.");
|
||||
}
|
||||
|
||||
/// <summary>/ra t11 augs <n|auto>: saves the item-aug override (-1 = read from /aug).</summary>
|
||||
private void SetT11ItemAugOverride(string arg)
|
||||
{
|
||||
if (_dashboard == null) { ChatLine("[RynthAi] Settings aren't loaded yet."); return; }
|
||||
int value;
|
||||
if (arg.Equals("auto", StringComparison.OrdinalIgnoreCase) || arg == "-1")
|
||||
value = -1;
|
||||
else if (!int.TryParse(arg.Replace(",", string.Empty), NumberStyles.Integer, CultureInfo.InvariantCulture, out value) || value < 0)
|
||||
{
|
||||
ChatLine("[RynthAi] Usage: /ra t11 augs <n|auto> (n = your item augmentation count)");
|
||||
return;
|
||||
}
|
||||
_dashboard.Settings.T11ItemAugsOverride = value;
|
||||
_dashboard.SaveSettings();
|
||||
T11ItemSupport.SyncOverride(value);
|
||||
ChatLine(value < 0
|
||||
? "[RynthAi] T11: item augmentations now come from /aug."
|
||||
: $"[RynthAi] T11: item augmentations fixed at {value:N0} for loot rules.");
|
||||
}
|
||||
|
||||
/// <summary>/ra t11 item [0xId]: the parsed T11 text of an item (selected item by default).</summary>
|
||||
private void PrintT11Item(string? idArg)
|
||||
{
|
||||
uint id = 0;
|
||||
if (!string.IsNullOrEmpty(idArg))
|
||||
uint.TryParse(idArg.StartsWith("0x", StringComparison.OrdinalIgnoreCase) ? idArg[2..] : idArg,
|
||||
NumberStyles.HexNumber, CultureInfo.InvariantCulture, out id);
|
||||
if (id == 0 && Host.HasGetSelectedItemId) id = Host.GetSelectedItemId();
|
||||
if (id == 0) { ChatLine("[RynthAi] T11: select an item first (or pass 0xId)."); return; }
|
||||
|
||||
int iid = unchecked((int)id);
|
||||
WorldObject item = _objectCache?[iid]
|
||||
?? new WorldObject(iid, Host.TryGetObjectName(id, out string n) ? n : string.Empty) { Cache = _objectCache };
|
||||
T11ItemInfo info = T11ItemSupport.Get(item);
|
||||
if (!info.IsT11)
|
||||
{
|
||||
bool appraised = !Host.HasHasAppraisalData || Host.HasAppraisalData(id);
|
||||
ChatLine(appraised
|
||||
? $"[RynthAi] T11: {item.Name} is not a T11 item."
|
||||
: $"[RynthAi] T11: {item.Name} isn't appraised yet - ID it and try again.");
|
||||
return;
|
||||
}
|
||||
|
||||
ChatLine($"[RynthAi] === T11: {item.Name} (0x{id:X8}) ===");
|
||||
ChatLine($"[RynthAi] Tier ~{info.EstimatedTier}" + (info.Grade != null ? $", grade {info.Grade} ({info.DamagePercent}% of max damage)" : string.Empty)
|
||||
+ (info.ZoneLocked ? ", zone locked" : string.Empty));
|
||||
foreach (T11WieldGate g in info.WieldGates)
|
||||
ChatLine($"[RynthAi] Wield requires {g.Amount:N0} {T11Catalog.CounterName(g.Counter)}");
|
||||
foreach (T11Modifier m in info.Modifiers)
|
||||
{
|
||||
string band = m.Min.HasValue && m.Max.HasValue ? $" [{m.Min}-{m.Max}] roll {m.RollPercent}%" : string.Empty;
|
||||
ChatLine($"[RynthAi] Mod {m.Name} {(m.IsSlotSpecial ? "(special)" : "+" + m.Value)}{band}");
|
||||
}
|
||||
foreach ((string name, double chance) in info.Procs)
|
||||
ChatLine($"[RynthAi] Cast on strike: {name} ({chance.ToString("0.#", CultureInfo.CurrentCulture)}%)");
|
||||
|
||||
int canWield = item.Values(T11Keys.CanWield, -1);
|
||||
ChatLine($"[RynthAi] Can wield: {(canWield == 1 ? "yes" : canWield == 0 ? "no" : "unknown (no /aug read, or not appraised)")}"
|
||||
+ $", modifier ratings {info.ModifierRatingTotal}, average roll {info.AverageRollPercent}%");
|
||||
string keys = string.Join(", ", T11Keys.Names()
|
||||
.Where(k => k.Id < T11Keys.ModifierBase)
|
||||
.Select(k => $"{k.Name.Replace("T11: ", string.Empty)}={item.Values(k.Id, 0)}"));
|
||||
ChatLine($"[RynthAi] Loot keys: {keys}");
|
||||
}
|
||||
}
|
||||
|
|
@ -355,7 +355,7 @@ internal static class ActionPacer
|
|||
1 => "Peace", 2 => "Melee", 4 => "Missile", 8 => "Magic", _ => $"mode {mode}",
|
||||
};
|
||||
|
||||
private static bool IsWieldedByPlayer(RynthCoreHost host, uint id)
|
||||
internal static bool IsWieldedByPlayer(RynthCoreHost host, uint id)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,17 +38,25 @@ public static class LootRuleText
|
|||
|
||||
// ── Key tables (the common ones; unknown ids show as "key N") ──────────
|
||||
|
||||
public static readonly (int Id, string Name)[] LongKeys =
|
||||
/// <summary>Retail / Decal long keys, then RynthAi's virtual T11 keys (T11Keys; RynthAi-only).</summary>
|
||||
public static readonly (int Id, string Name)[] LongKeys = BuildLongKeys();
|
||||
|
||||
private static (int Id, string Name)[] BuildLongKeys()
|
||||
{
|
||||
(5, "EncumbVal"), (9, "Locations"), (19, "Value"), (25, "Level"), (28, "ArmorLevel"), (44, "Damage"), (45, "DamageType"),
|
||||
(48, "WeaponSkill"), (54, "MaxDamage"),
|
||||
(87, "MaxStructure"), (88, "Structure"), (105, "ItemWorkmanship"), (107, "ItemMaxMana"),
|
||||
(131, "MaterialType"), (158, "WieldRequirements"), (159, "WieldSkilltype"), (160, "WieldDifficulty"),
|
||||
(218, "EquippedSlots"), (353, "ImbuedEffect"), (370, "DamageRating"), (371, "DamageResistRating"),
|
||||
(372, "CritRating"), (373, "CritResistRating"), (374, "CritDamageRating"),
|
||||
(375, "CritDamageResistRating"), (376, "HealBoostRating"), (379, "VitalityRating"),
|
||||
(0x0D000000, "Type (WCID)"), // Decal's synthetic key: the weenie class id
|
||||
};
|
||||
var keys = new List<(int, string)>
|
||||
{
|
||||
(5, "EncumbVal"), (9, "Locations"), (19, "Value"), (25, "Level"), (28, "ArmorLevel"), (44, "Damage"), (45, "DamageType"),
|
||||
(48, "WeaponSkill"), (54, "MaxDamage"),
|
||||
(87, "MaxStructure"), (88, "Structure"), (105, "ItemWorkmanship"), (107, "ItemMaxMana"),
|
||||
(131, "MaterialType"), (158, "WieldRequirements"), (159, "WieldSkilltype"), (160, "WieldDifficulty"),
|
||||
(218, "EquippedSlots"), (353, "ImbuedEffect"), (370, "DamageRating"), (371, "DamageResistRating"),
|
||||
(372, "CritRating"), (373, "CritResistRating"), (374, "CritDamageRating"),
|
||||
(375, "CritDamageResistRating"), (376, "HealBoostRating"), (377, "NetherResistRating"), (379, "VitalityRating"),
|
||||
(0x0D000000, "Type (WCID)"), // Decal's synthetic key: the weenie class id
|
||||
};
|
||||
keys.AddRange(T11.T11Keys.Names());
|
||||
return keys.ToArray();
|
||||
}
|
||||
|
||||
public static readonly (int Id, string Name)[] DoubleKeys =
|
||||
{
|
||||
|
|
@ -56,9 +64,10 @@ public static class LootRuleText
|
|||
(63, "WeaponOffense"), (152, "ElementalDamageVsMonsters"), (167, "ManaRate"),
|
||||
};
|
||||
|
||||
/// <summary>String keys. Use (14) and LongDesc (16) hold the T11 "Modifiers:" / "Property Details:" text.</summary>
|
||||
public static readonly (int Id, string Name)[] StringKeys =
|
||||
{
|
||||
(1, "Name"), (5, "Inscription"), (7, "Title"),
|
||||
(1, "Name"), (5, "Inscription"), (7, "Title"), (14, "Use"), (16, "LongDesc"),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -85,12 +94,15 @@ public static class LootRuleText
|
|||
|
||||
// ── Value tables (what a long key's number means) ──────────────────────
|
||||
|
||||
/// <summary>WieldRequirements (158): what WieldDifficulty is checked against (ACE's WieldRequirement enum).</summary>
|
||||
/// <summary>
|
||||
/// WieldRequirements (158): what WieldDifficulty is checked against (ACE's WieldRequirement
|
||||
/// enum). 13 is ACECustom's Int64Stat, the T11 item-aug gate (RynthAi restores it on T11 items).
|
||||
/// </summary>
|
||||
public static readonly (int Id, string Name)[] WieldRequirements =
|
||||
{
|
||||
(0, "Invalid"), (1, "Skill"), (2, "Base Skill"), (3, "Attribute"), (4, "Base Attribute"),
|
||||
(5, "Vital"), (6, "Base Vital"), (7, "Level"), (8, "Training"), (9, "Int Property"),
|
||||
(10, "Bool Property"), (11, "Creature Type"), (12, "Heritage"),
|
||||
(10, "Bool Property"), (11, "Creature Type"), (12, "Heritage"), (13, "Int64 Property"),
|
||||
};
|
||||
|
||||
/// <summary>MaterialType (131): ACE's MaterialType enum, in id order (grouped cloth, gems, hides, metals, stone, wood).</summary>
|
||||
|
|
@ -134,6 +146,7 @@ public static class LootRuleText
|
|||
131 => Materials,
|
||||
158 => WieldRequirements,
|
||||
159 => Skills,
|
||||
T11.T11Keys.WeaponGrade => T11.T11Catalog.Grades,
|
||||
_ => null,
|
||||
};
|
||||
|
||||
|
|
@ -141,7 +154,7 @@ public static class LootRuleText
|
|||
public static bool ValueTableIsFlags(int longKey) => longKey == 45;
|
||||
|
||||
/// <summary>The long keys that have a value table, for the vocabulary.</summary>
|
||||
public static readonly int[] KeysWithValueTables = { 45, 48, 131, 158, 159 };
|
||||
public static readonly int[] KeysWithValueTables = { 45, 48, 131, 158, 159, T11.T11Keys.WeaponGrade };
|
||||
|
||||
/// <summary>
|
||||
/// True for the conditions whose value is picked by name when the key has a
|
||||
|
|
|
|||
197
Shared/RynthCore.LootSdk/T11/T11Catalog.cs
Normal file
197
Shared/RynthCore.LootSdk/T11/T11Catalog.cs
Normal file
|
|
@ -0,0 +1,197 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RynthCore.Loot.T11;
|
||||
|
||||
/// <summary>
|
||||
/// The player counter a T11 wield gate is checked against. On the server these are
|
||||
/// PropertyInt64 values (WieldRequirement.Int64Stat); the client never receives the
|
||||
/// gate as properties, only as a "Wield requires: N <counter>" description line.
|
||||
/// </summary>
|
||||
public enum T11Counter
|
||||
{
|
||||
/// <summary>LumAugItemCount (PropertyInt64 9008). The server checks the raw count, without Triune Weave.</summary>
|
||||
ItemAugmentations = 9008,
|
||||
/// <summary>TriuneWeaveCount (PropertyInt64 50000), the T16+ armor gate.</summary>
|
||||
TriuneWeave = 50000,
|
||||
/// <summary>BattlemagesWrathCharmCount (PropertyInt64 50001).</summary>
|
||||
BattlemagesWrath = 50001,
|
||||
/// <summary>NetherVeilCharmCount (PropertyInt64 50002).</summary>
|
||||
NetherVeil = 50002,
|
||||
/// <summary>CrashingSteelCharmCount (PropertyInt64 50003).</summary>
|
||||
CrashingSteel = 50003,
|
||||
/// <summary>TrueShotCharmCount (PropertyInt64 50004).</summary>
|
||||
TrueShot = 50004,
|
||||
}
|
||||
|
||||
/// <summary>One Zone Control modifier the server can stamp on T11 gear.</summary>
|
||||
/// <param name="Key">The server's catalog key (ZoneModifiers.Catalog).</param>
|
||||
/// <param name="Name">The name printed at the start of the appraisal line.</param>
|
||||
/// <param name="RatingKey">The retail Gear* rating property the modifier sets, or 0.</param>
|
||||
/// <param name="SlotSpecial">True for the one-per-slot specials, whose line has no roll band.</param>
|
||||
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
|
||||
/// 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>
|
||||
public static class T11Catalog
|
||||
{
|
||||
/// <summary>The name prefix the server gives every tier 11+ drop (ApplyT11NamePrefix).</summary>
|
||||
public const string NamePrefix = "T11 - ";
|
||||
|
||||
/// <summary>Retail rating keys counted by the TotalRatings condition (VTank's set).</summary>
|
||||
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.
|
||||
/// </summary>
|
||||
public static readonly (int Id, string Name)[] Grades =
|
||||
{
|
||||
(16, "S"), (15, "A+"), (14, "A"), (13, "A-"), (12, "B+"), (11, "B"), (10, "B-"),
|
||||
(9, "C+"), (8, "C"), (7, "C-"), (6, "D+"), (5, "D"), (4, "D-"), (3, "F+"), (2, "F"), (1, "F-"),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// ZoneModifiers.Catalog (ACECustom). Rating keys: 370 Damage, 371 Damage Resist, 372 Crit,
|
||||
/// 373 Crit Resist, 374 Crit Damage, 375 Crit Damage Resist, 376 Healing Boost,
|
||||
/// 377 Nether Resist, 379 Max Health.
|
||||
/// </summary>
|
||||
public static readonly T11ModifierDef[] Modifiers =
|
||||
{
|
||||
new(19, "Max Health", 379, false),
|
||||
new(25, "Armor Level", 0, false),
|
||||
new(28, "Damage Rating", 370, false),
|
||||
new(29, "Crit Damage Rating", 374, false),
|
||||
new(31, "Healing Boost", 376, false),
|
||||
new(32, "Spell Duration", 0, false),
|
||||
new(33, "Crit Chance", 372, false),
|
||||
new(41, "Fortify Vitals", 0, true),
|
||||
new(42, "Battle Mending", 0, true),
|
||||
new(43, "All Attributes", 0, false),
|
||||
new(44, "Pct HP Damage", 0, true),
|
||||
new(45, "Cheat Death", 0, true),
|
||||
new(46, "Regeneration", 0, true),
|
||||
new(47, "Max Health Pct", 0, false),
|
||||
new(48, "Life on Hit", 0, false),
|
||||
new(49, "Reinforced", 0, false),
|
||||
new(50, "Damage Resist", 371, false),
|
||||
new(51, "Crit Damage Resist", 375, false),
|
||||
new(52, "Crit Resist", 373, false),
|
||||
new(53, "Nether Resist", 377, false),
|
||||
};
|
||||
|
||||
// Longest names first, so "Max Health Pct" is tried before "Max Health".
|
||||
private static readonly T11ModifierDef[] ModifiersByNameLength = SortByNameLength(Modifiers);
|
||||
|
||||
private static T11ModifierDef[] SortByNameLength(T11ModifierDef[] defs)
|
||||
{
|
||||
var copy = (T11ModifierDef[])defs.Clone();
|
||||
Array.Sort(copy, (a, b) => b.Name.Length.CompareTo(a.Name.Length));
|
||||
return copy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The catalog entry whose name starts <paramref name="text"/> as a whole word
|
||||
/// ("Max Health Pct +2%" is Max Health Pct, not Max Health), or null.
|
||||
/// </summary>
|
||||
public static T11ModifierDef? MatchModifier(string text)
|
||||
{
|
||||
foreach (var def in ModifiersByNameLength)
|
||||
{
|
||||
if (!text.StartsWith(def.Name, StringComparison.OrdinalIgnoreCase)) continue;
|
||||
if (text.Length == def.Name.Length || text[def.Name.Length] == ' ') return def;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>The catalog entry for a server key, or null.</summary>
|
||||
public static T11ModifierDef? ModifierByKey(int key)
|
||||
{
|
||||
foreach (var def in Modifiers)
|
||||
if (def.Key == key) return def;
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Rank of a sub-grade label ("B+" = 12), or 0 when it isn't one.</summary>
|
||||
public static int GradeRank(string? label)
|
||||
{
|
||||
if (string.IsNullOrEmpty(label)) return 0;
|
||||
foreach (var (id, name) in Grades)
|
||||
if (string.Equals(name, label, StringComparison.OrdinalIgnoreCase)) return id;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>The words a "Wield requires:" line uses for each counter.</summary>
|
||||
public static readonly (T11Counter Counter, string Name)[] CounterNames =
|
||||
{
|
||||
(T11Counter.ItemAugmentations, "Item Augmentations"),
|
||||
(T11Counter.TriuneWeave, "Triune Weave"),
|
||||
(T11Counter.BattlemagesWrath, "Battlemage's Wrath"),
|
||||
(T11Counter.NetherVeil, "Nether Veil"),
|
||||
(T11Counter.CrashingSteel, "Crashing Steel"),
|
||||
(T11Counter.TrueShot, "True Shot"),
|
||||
};
|
||||
|
||||
/// <summary>The counter named by a "Wield requires:" line, or null.</summary>
|
||||
public static T11Counter? CounterByName(string name)
|
||||
{
|
||||
foreach (var (counter, n) in CounterNames)
|
||||
if (string.Equals(n, name.Trim(), StringComparison.OrdinalIgnoreCase)) return counter;
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Display name of a counter.</summary>
|
||||
public static string CounterName(T11Counter counter)
|
||||
{
|
||||
foreach (var (c, n) in CounterNames)
|
||||
if (c == counter) return n;
|
||||
return counter.ToString();
|
||||
}
|
||||
|
||||
/// <summary>Highest loot tier on the server's default weapon-scaling ladder (T11-T25).</summary>
|
||||
public const int MaxTier = 25;
|
||||
|
||||
/// <summary>
|
||||
/// Triune Weave required per tier above 15 on the default ladder: 500 at T16 up to 5,000
|
||||
/// at T25. Weapons and armor carry the same Triune gate; weapons add a family-charm gate
|
||||
/// of the same size, which isn't needed for the estimate.
|
||||
/// </summary>
|
||||
public const int TriunePerTier = 500;
|
||||
|
||||
/// <summary>
|
||||
/// The loot tier implied by an item-augmentation wield gate, using the server's default
|
||||
/// weapon-scaling table: T11 = 2,000, T12 = 2,500, then +500 per tier, capped at 4,000.
|
||||
/// Without a Triune Weave gate the cap makes T15 and above read as 15 (see the
|
||||
/// three-argument overload). Returns 11 for a T11-named item with no gate read yet, and 0
|
||||
/// for anything else. The server owner can retune the table, so this is an estimate.
|
||||
/// </summary>
|
||||
public static int EstimateTier(int itemAugGate, bool isT11)
|
||||
{
|
||||
if (itemAugGate <= 0) return isT11 ? 11 : 0;
|
||||
if (itemAugGate < 2500) return 11;
|
||||
return Math.Min(15, 12 + (itemAugGate - 2500) / 500);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The loot tier implied by both T11 wield gates. The item-aug gate stops rising at T15,
|
||||
/// so from T16 the Triune Weave gate (<see cref="TriunePerTier"/> x (tier - 15)) carries
|
||||
/// the tier: 500 = T16 ... 5,000 = T25. Any Triune gate means T16 or higher (the server
|
||||
/// only stamps it from T16) and the result is capped at <see cref="MaxTier"/>. Without a
|
||||
/// Triune gate this is <see cref="EstimateTier(int, bool)"/>.
|
||||
/// </summary>
|
||||
public static int EstimateTier(int itemAugGate, int triuneGate, bool isT11)
|
||||
{
|
||||
if (triuneGate > 0) return Math.Clamp(15 + triuneGate / TriunePerTier, 16, MaxTier);
|
||||
return EstimateTier(itemAugGate, isT11);
|
||||
}
|
||||
|
||||
/// <summary>Modifier keys with a rating, for callers that map Gear* keys back to modifiers.</summary>
|
||||
public static IEnumerable<T11ModifierDef> RatingModifiers()
|
||||
{
|
||||
foreach (var def in Modifiers)
|
||||
if (def.RatingKey != 0) yield return def;
|
||||
}
|
||||
}
|
||||
348
Shared/RynthCore.LootSdk/T11/T11ItemInfo.cs
Normal file
348
Shared/RynthCore.LootSdk/T11/T11ItemInfo.cs
Normal file
|
|
@ -0,0 +1,348 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace RynthCore.Loot.T11;
|
||||
|
||||
/// <summary>One "Wield requires: N <counter>" gate.</summary>
|
||||
public readonly record struct T11WieldGate(T11Counter Counter, int Amount);
|
||||
|
||||
/// <summary>One line of the appraisal's "Modifiers:" section.</summary>
|
||||
public sealed class T11Modifier
|
||||
{
|
||||
/// <summary>Catalog key (T11Catalog.Modifiers), or 0 for a name the catalog doesn't know.</summary>
|
||||
public int Key { get; init; }
|
||||
/// <summary>The modifier name as printed.</summary>
|
||||
public string Name { get; init; } = string.Empty;
|
||||
/// <summary>The rolled value (the first number after the name; 0 for value-less specials).</summary>
|
||||
public int Value { get; init; }
|
||||
/// <summary>Low end of the "[min-max]" roll band, or null when the line has none.</summary>
|
||||
public int? Min { get; init; }
|
||||
/// <summary>High end of the "[min-max]" roll band, or null when the line has none.</summary>
|
||||
public int? Max { get; init; }
|
||||
/// <summary>Where the value landed in its band, 0-100, or -1 without a usable band.</summary>
|
||||
public int RollPercent { get; init; } = -1;
|
||||
/// <summary>The retail Gear* rating key the modifier sets, or 0.</summary>
|
||||
public int RatingKey { get; init; }
|
||||
/// <summary>True for a one-per-slot special (Fortify Vitals, Battle Mending, ...).</summary>
|
||||
public bool IsSlotSpecial { 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.
|
||||
/// </summary>
|
||||
public sealed class T11ItemInfo
|
||||
{
|
||||
/// <summary>A non-T11 item: every field at its default.</summary>
|
||||
public static readonly T11ItemInfo None = new();
|
||||
|
||||
/// <summary>True when the item is T11 gear (name prefix, or T11-only text in its description).</summary>
|
||||
public bool IsT11 { get; private set; }
|
||||
/// <summary>True when the name starts with "T11 - ".</summary>
|
||||
public bool HasNamePrefix { get; private set; }
|
||||
/// <summary>Weapon sub-grade label ("B+"), or null.</summary>
|
||||
public string? Grade { get; private set; }
|
||||
/// <summary>Sub-grade rank, S = 16 ... F- = 1, 0 = no grade.</summary>
|
||||
public int GradeRank { get; private set; }
|
||||
/// <summary>"N% of max damage" from the grade line, or -1.</summary>
|
||||
public int DamagePercent { get; private set; } = -1;
|
||||
/// <summary>Every wield gate, at most one per counter.</summary>
|
||||
public IReadOnlyList<T11WieldGate> WieldGates => _gates;
|
||||
/// <summary>The Zone Control modifier lines, in appraisal order.</summary>
|
||||
public IReadOnlyList<T11Modifier> Modifiers => _modifiers;
|
||||
/// <summary>"Cast on Strike" lines: spell name and proc chance percent.</summary>
|
||||
public IReadOnlyList<(string Name, double ChancePercent)> Procs => _procs;
|
||||
/// <summary>True when the appraisal said "Zone Locked (Power Reduced)" (depends on where the examiner stood).</summary>
|
||||
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; }
|
||||
|
||||
private readonly List<T11WieldGate> _gates = new();
|
||||
private readonly List<T11Modifier> _modifiers = new();
|
||||
private readonly List<(string, double)> _procs = new();
|
||||
|
||||
/// <summary>The item-augmentation gate, or 0 when there is none.</summary>
|
||||
public int WieldItemAugs => GateAmount(T11Counter.ItemAugmentations);
|
||||
|
||||
/// <summary>The amount required of <paramref name="counter"/>, or 0 when it isn't gated.</summary>
|
||||
public int GateAmount(T11Counter counter)
|
||||
{
|
||||
foreach (var g in _gates)
|
||||
if (g.Counter == counter) return g.Amount;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The estimated loot tier (11-25), or 0 for non-T11 items. T16 and up come from the
|
||||
/// Triune Weave gate; an item without one reads at most 15.
|
||||
/// </summary>
|
||||
public int EstimatedTier => T11Catalog.EstimateTier(WieldItemAugs, GateAmount(T11Counter.TriuneWeave), IsT11);
|
||||
|
||||
/// <summary>Sum of modifier values that land on the TotalRatings keys.</summary>
|
||||
public int ModifierRatingTotal
|
||||
{
|
||||
get
|
||||
{
|
||||
int total = 0;
|
||||
foreach (var m in _modifiers)
|
||||
if (Array.IndexOf(T11Catalog.TotalRatingKeys, m.RatingKey) >= 0) total += m.Value;
|
||||
return total;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Sum of modifier values that set <paramref name="ratingKey"/>, or 0.</summary>
|
||||
public int RatingFromModifiers(int ratingKey)
|
||||
{
|
||||
int total = 0;
|
||||
foreach (var m in _modifiers)
|
||||
if (m.RatingKey == ratingKey) total += m.Value;
|
||||
return total;
|
||||
}
|
||||
|
||||
/// <summary>The value of the modifier with catalog key <paramref name="key"/>, or 0 when absent.</summary>
|
||||
public int ModifierValue(int key)
|
||||
{
|
||||
foreach (var m in _modifiers)
|
||||
if (m.Key == key) return m.Value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>Average roll position (0-100) of the banded modifiers, or 0 without any.</summary>
|
||||
public int AverageRollPercent
|
||||
{
|
||||
get
|
||||
{
|
||||
int sum = 0, n = 0;
|
||||
foreach (var m in _modifiers)
|
||||
if (m.RollPercent >= 0) { sum += m.RollPercent; n++; }
|
||||
return n == 0 ? 0 : (int)Math.Round(sum / (double)n, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Best roll position (0-100) of the banded modifiers, or 0 without any.</summary>
|
||||
public int BestRollPercent
|
||||
{
|
||||
get
|
||||
{
|
||||
int best = 0;
|
||||
foreach (var m in _modifiers)
|
||||
if (m.RollPercent > best) best = m.RollPercent;
|
||||
return best;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>True when any modifier is a slot special.</summary>
|
||||
public bool HasSlotSpecial
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (var m in _modifiers)
|
||||
if (m.IsSlotSpecial) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Parsing ─────────────────────────────────────────────────────────────
|
||||
|
||||
private const RegexOptions Opt = RegexOptions.CultureInvariant | RegexOptions.IgnoreCase;
|
||||
|
||||
// "- Weapon Grade: B+ (86% of max damage)" / "- Weapon Grade: S"
|
||||
private static readonly Regex GradeLine = new(
|
||||
@"^-?\s*Weapon Grade:\s*(?<g>S|[A-DF][+-]?)(?=\s|\(|$)(?:\s*\((?<pct>\d+)% of max damage\))?", Opt);
|
||||
|
||||
// "- Wield requires: 2,000 Item Augmentations" (weapons) / "Wield requires: 2,000 Item Augmentations" (armor).
|
||||
// ACE prints N0, so the group separator follows the server's culture: keep digits only.
|
||||
private static readonly Regex WieldLine = new(
|
||||
@"^-?\s*Wield requires:\s*(?<n>\d[\d,.\s']*?)\s+(?<what>[A-Za-z' ]+?)\s*$", Opt);
|
||||
|
||||
// "- Cast on Strike: Force Arc (13% proc chance)"
|
||||
private static readonly Regex ProcLine = new(
|
||||
@"^-\s*Cast on Strike:\s*(?<name>.+?)\s*\((?<pct>\d+(?:\.\d+)?)% proc chance\)\s*$", Opt);
|
||||
|
||||
// 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);
|
||||
|
||||
// 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);
|
||||
// Checked before GenericModifier, whose lazy name would stop at "Modifier" and read the key as the value.
|
||||
private static readonly Regex UnknownKeyName = new(@"^(?<name>Modifier (?<key>\d+))(?=\s|$)", RegexOptions.CultureInvariant);
|
||||
|
||||
private const string ModifiersHeader = "Modifiers:";
|
||||
private const string ZoneLockedText = "Zone Locked (Power Reduced)";
|
||||
|
||||
/// <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.
|
||||
/// </summary>
|
||||
public static T11ItemInfo Parse(string? name, string? longDesc, string? use)
|
||||
{
|
||||
bool prefix = !string.IsNullOrEmpty(name) && name.StartsWith(T11Catalog.NamePrefix, StringComparison.Ordinal);
|
||||
if (!prefix && string.IsNullOrEmpty(longDesc) && string.IsNullOrEmpty(use)) return None;
|
||||
|
||||
var info = new T11ItemInfo
|
||||
{
|
||||
HasNamePrefix = prefix,
|
||||
HasText = !string.IsNullOrEmpty(longDesc) || !string.IsNullOrEmpty(use),
|
||||
};
|
||||
try
|
||||
{
|
||||
info.ParseText(longDesc);
|
||||
info.ParseText(use);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 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;
|
||||
return info.IsT11 ? info : None;
|
||||
}
|
||||
|
||||
private void ParseText(string? text)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text)) return;
|
||||
string[] lines = text.Replace("\r\n", "\n").Split('\n');
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
string line = lines[i].Trim();
|
||||
if (line.Length == 0) continue;
|
||||
|
||||
if (line.Contains(ZoneLockedText, StringComparison.OrdinalIgnoreCase)) { ZoneLocked = true; continue; }
|
||||
|
||||
if (string.Equals(line, ModifiersHeader, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
i = ParseModifierBlock(lines, i + 1) - 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
Match m = GradeLine.Match(line);
|
||||
if (m.Success && GradeRank == 0)
|
||||
{
|
||||
Grade = m.Groups["g"].Value.ToUpperInvariant();
|
||||
GradeRank = T11Catalog.GradeRank(Grade);
|
||||
if (m.Groups["pct"].Success && int.TryParse(m.Groups["pct"].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out int pct))
|
||||
DamagePercent = pct;
|
||||
continue;
|
||||
}
|
||||
|
||||
m = WieldLine.Match(line);
|
||||
if (m.Success && T11Catalog.CounterByName(m.Groups["what"].Value) is T11Counter counter)
|
||||
{
|
||||
int amount = DigitsOnly(m.Groups["n"].Value);
|
||||
if (amount > 0) AddGate(counter, amount);
|
||||
continue;
|
||||
}
|
||||
|
||||
m = ProcLine.Match(line);
|
||||
if (m.Success && double.TryParse(m.Groups["pct"].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out double chance))
|
||||
_procs.Add((m.Groups["name"].Value, chance));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Reads "- ..." lines after a "Modifiers:" header; returns the index of the first line not consumed.</summary>
|
||||
private int ParseModifierBlock(string[] lines, int start)
|
||||
{
|
||||
int i = start;
|
||||
for (; i < lines.Length; i++)
|
||||
{
|
||||
string line = lines[i].Trim();
|
||||
if (line.Length == 0 || !line.StartsWith("-", StringComparison.Ordinal)) break;
|
||||
string body = line.Substring(1).Trim();
|
||||
if (body.Length == 0) continue;
|
||||
if (body.Contains(ZoneLockedText, StringComparison.OrdinalIgnoreCase)) { ZoneLocked = true; continue; }
|
||||
_modifiers.Add(ParseModifier(body));
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
private static T11Modifier ParseModifier(string body)
|
||||
{
|
||||
T11ModifierDef? def = T11Catalog.MatchModifier(body);
|
||||
string name;
|
||||
string rest;
|
||||
int key = 0;
|
||||
if (def != null)
|
||||
{
|
||||
name = def.Name;
|
||||
key = def.Key;
|
||||
rest = body.Substring(def.Name.Length);
|
||||
}
|
||||
else if (UnknownKeyName.Match(body) is { Success: true } k
|
||||
&& int.TryParse(k.Groups["key"].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out int parsedKey))
|
||||
{
|
||||
key = parsedKey;
|
||||
name = k.Groups["name"].Value;
|
||||
rest = body.Substring(name.Length);
|
||||
def = T11Catalog.ModifierByKey(parsedKey);
|
||||
if (def != null) name = def.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
Match g = GenericModifier.Match(body);
|
||||
name = g.Success ? g.Groups["name"].Value.Trim() : body;
|
||||
rest = g.Success ? body.Substring(g.Groups["name"].Length) : string.Empty;
|
||||
}
|
||||
|
||||
int value = 0;
|
||||
Match num = FirstNumber.Match(rest);
|
||||
if (num.Success) int.TryParse(num.Value, NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out value);
|
||||
|
||||
int? min = null, max = null;
|
||||
int roll = -1;
|
||||
Match band = Band.Match(rest);
|
||||
if (band.Success
|
||||
&& int.TryParse(band.Groups["min"].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out int lo)
|
||||
&& int.TryParse(band.Groups["max"].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out int hi))
|
||||
{
|
||||
min = lo;
|
||||
max = hi;
|
||||
if (hi > lo) roll = Math.Clamp((int)Math.Round((value - lo) * 100.0 / (hi - lo), MidpointRounding.AwayFromZero), 0, 100);
|
||||
}
|
||||
|
||||
return new T11Modifier
|
||||
{
|
||||
Key = key,
|
||||
Name = name,
|
||||
Value = value,
|
||||
Min = min,
|
||||
Max = max,
|
||||
RollPercent = roll,
|
||||
RatingKey = def?.RatingKey ?? 0,
|
||||
IsSlotSpecial = def?.SlotSpecial ?? false,
|
||||
};
|
||||
}
|
||||
|
||||
private void AddGate(T11Counter counter, int amount)
|
||||
{
|
||||
for (int i = 0; i < _gates.Count; i++)
|
||||
{
|
||||
if (_gates[i].Counter != counter) continue;
|
||||
if (amount > _gates[i].Amount) _gates[i] = new T11WieldGate(counter, amount);
|
||||
return;
|
||||
}
|
||||
_gates.Add(new T11WieldGate(counter, amount));
|
||||
}
|
||||
|
||||
private static int DigitsOnly(string s)
|
||||
{
|
||||
long v = 0;
|
||||
foreach (char c in s)
|
||||
{
|
||||
if (c < '0' || c > '9') continue;
|
||||
v = v * 10 + (c - '0');
|
||||
if (v > int.MaxValue) return int.MaxValue;
|
||||
}
|
||||
return (int)v;
|
||||
}
|
||||
}
|
||||
161
Shared/RynthCore.LootSdk/T11/T11Keys.cs
Normal file
161
Shared/RynthCore.LootSdk/T11/T11Keys.cs
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace RynthCore.Loot.T11;
|
||||
|
||||
/// <summary>
|
||||
/// Virtual long-value keys for T11 loot rules. A loot rule uses them like any long key
|
||||
/// (LongValKeyGE / LE / E / NE), so VTank-format profiles need no new node types. RynthAi
|
||||
/// answers them from <see cref="T11ItemInfo"/>; other loot engines (VTank, Mag) don't know
|
||||
/// them and read them as 0.
|
||||
/// </summary>
|
||||
public static class T11Keys
|
||||
{
|
||||
/// <summary>
|
||||
/// First id of the reserved block ("RY" in the high bytes). Far above retail STypeInt ids,
|
||||
/// ACECustom's custom ids (9000-50999) and Decal's 0x0D000000 WCID key.
|
||||
/// </summary>
|
||||
public const int Base = 0x52590000;
|
||||
|
||||
/// <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>
|
||||
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;
|
||||
/// <summary>The weapon's damage as a percent of a perfect roll, 0 when not shown.</summary>
|
||||
public const int DamagePercent = Base + 4;
|
||||
/// <summary>Item augmentations required to wield, 0 for none.</summary>
|
||||
public const int WieldItemAugs = Base + 5;
|
||||
/// <summary>1 = this character meets every wield gate, 0 = it doesn't, -1 = a needed counter is unknown.</summary>
|
||||
public const int CanWield = Base + 6;
|
||||
/// <summary>Number of Zone Control modifier lines.</summary>
|
||||
public const int ModifierCount = Base + 7;
|
||||
/// <summary>Sum of modifier values that count toward TotalRatings.</summary>
|
||||
public const int ModifierRatingTotal = Base + 8;
|
||||
/// <summary>Average roll position of the banded modifiers, 0-100.</summary>
|
||||
public const int AverageRollPercent = Base + 9;
|
||||
/// <summary>Best roll position of the banded modifiers, 0-100.</summary>
|
||||
public const int BestRollPercent = Base + 10;
|
||||
/// <summary>1 when the item has a slot special (Fortify Vitals, Battle Mending, ...).</summary>
|
||||
public const int HasSlotSpecial = Base + 11;
|
||||
/// <summary>Number of "Cast on Strike" procs.</summary>
|
||||
public const int CastOnStrikeCount = Base + 12;
|
||||
/// <summary>1 when the appraisal said "Zone Locked (Power Reduced)". Depends on where you stood when it was appraised.</summary>
|
||||
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>
|
||||
/// Base of the per-modifier keys: <c>ModifierBase + catalog key</c> is that modifier's value
|
||||
/// on the item, 0 when absent (ModifierBase + 28 = Damage Rating).
|
||||
/// </summary>
|
||||
public const int ModifierBase = Base + 0x100;
|
||||
|
||||
/// <summary>One past the last id in the block.</summary>
|
||||
public const int End = Base + 0x200;
|
||||
|
||||
/// <summary>True for any id in the T11 block.</summary>
|
||||
public static bool IsVirtual(int key) => key > Base && key < End;
|
||||
|
||||
/// <summary>The per-modifier key for a catalog key.</summary>
|
||||
public static int ForModifier(int catalogKey) => ModifierBase + catalogKey;
|
||||
|
||||
/// <summary>Editor names for every T11 key, summary keys first.</summary>
|
||||
public static IEnumerable<(int Id, string Name)> Names()
|
||||
{
|
||||
yield return (IsT11, "T11: Is T11");
|
||||
yield return (EstimatedTier, "T11: Tier (est.)");
|
||||
yield return (WeaponGrade, "T11: Weapon Grade");
|
||||
yield return (DamagePercent, "T11: Damage % of Max");
|
||||
yield return (WieldItemAugs, "T11: Wield Item Augs");
|
||||
yield return (WieldTriuneWeave, "T11: Wield Triune Weave");
|
||||
yield return (CanWield, "T11: Can Wield");
|
||||
yield return (ModifierCount, "T11: Modifier Count");
|
||||
yield return (ModifierRatingTotal, "T11: Modifier Ratings");
|
||||
yield return (AverageRollPercent, "T11: Avg Roll %");
|
||||
yield return (BestRollPercent, "T11: Best Roll %");
|
||||
yield return (HasSlotSpecial, "T11: Has Slot Special");
|
||||
yield return (CastOnStrikeCount, "T11: Cast on Strike Count");
|
||||
yield return (ZoneLocked, "T11: Zone Locked");
|
||||
foreach (var def in T11Catalog.Modifiers)
|
||||
yield return (ForModifier(def.Key), "T11 Mod: " + def.Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The value of T11 key <paramref name="key"/> for <paramref name="item"/>. CanWield needs
|
||||
/// <paramref name="player"/>; without it CanWield reads -1 (unknown) for gated items.
|
||||
/// Returns false for an id outside the block or an unused id in it.
|
||||
/// </summary>
|
||||
public static bool TryGetValue(T11ItemInfo item, int key, T11PlayerAugs? player, out int value)
|
||||
{
|
||||
value = 0;
|
||||
if (!IsVirtual(key)) return false;
|
||||
if (key >= ModifierBase)
|
||||
{
|
||||
int catalogKey = key - ModifierBase;
|
||||
if (T11Catalog.ModifierByKey(catalogKey) == null) return false;
|
||||
value = item.ModifierValue(catalogKey);
|
||||
return true;
|
||||
}
|
||||
switch (key)
|
||||
{
|
||||
case IsT11: value = item.IsT11 ? 1 : 0; return true;
|
||||
case EstimatedTier: value = item.EstimatedTier; 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;
|
||||
case WieldTriuneWeave: value = item.GateAmount(T11Counter.TriuneWeave); return true;
|
||||
case CanWield:
|
||||
// Before its ID a T11 item's gates are unknown, so it can't count as wieldable yet.
|
||||
if (item.WieldGates.Count == 0) value = item.IsT11 && !item.HasText ? -1 : 1;
|
||||
else value = player?.CanWield(item) ?? -1;
|
||||
return true;
|
||||
case ModifierCount: value = item.Modifiers.Count; return true;
|
||||
case ModifierRatingTotal: value = item.ModifierRatingTotal; return true;
|
||||
case AverageRollPercent: value = item.AverageRollPercent; return true;
|
||||
case BestRollPercent: value = item.BestRollPercent; return true;
|
||||
case HasSlotSpecial: value = item.HasSlotSpecial ? 1 : 0; return true;
|
||||
case CastOnStrikeCount: value = item.Procs.Count; return true;
|
||||
case ZoneLocked: value = item.ZoneLocked ? 1 : 0; return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The value the server stripped from a T11 item's appraisal, for the retail keys loot rules
|
||||
/// already use: wield requirement slot 1 (158 = 13 Int64 Property, 159 = 9008, 160 = the
|
||||
/// item-aug gate) and the Gear* ratings a modifier line carries (370-379). Only call this
|
||||
/// when the live property is absent. Returns false when the item supplies no value.
|
||||
/// </summary>
|
||||
public static bool TryGetStrippedValue(T11ItemInfo item, int key, out int value)
|
||||
{
|
||||
value = 0;
|
||||
if (!item.IsT11) return false;
|
||||
switch (key)
|
||||
{
|
||||
case 158:
|
||||
if (item.WieldItemAugs <= 0) return false;
|
||||
value = WieldRequirementInt64Stat;
|
||||
return true;
|
||||
case 159:
|
||||
if (item.WieldItemAugs <= 0) return false;
|
||||
value = (int)T11Counter.ItemAugmentations;
|
||||
return true;
|
||||
case 160:
|
||||
if (item.WieldItemAugs <= 0) return false;
|
||||
value = item.WieldItemAugs;
|
||||
return true;
|
||||
}
|
||||
if (key < 370 || key > 379) return false;
|
||||
int fromMods = item.RatingFromModifiers(key);
|
||||
if (fromMods == 0) return false;
|
||||
value = fromMods;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>ACECustom's WieldRequirement.Int64Stat (the value after HeritageType = 12).</summary>
|
||||
public const int WieldRequirementInt64Stat = 13;
|
||||
|
||||
/// <summary>True for the retail keys <see cref="TryGetStrippedValue"/> can answer.</summary>
|
||||
public static bool IsStrippedKey(int key) => key is 158 or 159 or 160 || (key >= 370 && key <= 379);
|
||||
}
|
||||
138
Shared/RynthCore.LootSdk/T11/T11PlayerAugs.cs
Normal file
138
Shared/RynthCore.LootSdk/T11/T11PlayerAugs.cs
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace RynthCore.Loot.T11;
|
||||
|
||||
/// <summary>
|
||||
/// The player counters T11 wield gates are checked against. ACECustom doesn't send these at
|
||||
/// login (they aren't [SendOnLogin]), so they come from the "/aug" reply, or from a manual
|
||||
/// item-aug override. Thread-safe: chat writes it, loot evaluation reads it.
|
||||
/// </summary>
|
||||
public sealed class T11PlayerAugs
|
||||
{
|
||||
private readonly object _gate = new();
|
||||
private readonly Dictionary<T11Counter, long> _counts = new();
|
||||
private long? _itemAugOverride;
|
||||
|
||||
/// <summary>When the counters were last updated from "/aug" (UTC), or null.</summary>
|
||||
public DateTime? UpdatedUtc { get; private set; }
|
||||
|
||||
/// <summary>The manual item-aug count that replaces the "/aug" value, or null for automatic.</summary>
|
||||
public long? ItemAugOverride
|
||||
{
|
||||
get { lock (_gate) return _itemAugOverride; }
|
||||
set { lock (_gate) _itemAugOverride = value is < 0 ? null : value; }
|
||||
}
|
||||
|
||||
/// <summary>Records one counter read from "/aug".</summary>
|
||||
public void Set(T11Counter counter, long value)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
_counts[counter] = Math.Max(0, value);
|
||||
UpdatedUtc = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The player's count for <paramref name="counter"/>, or null when unknown. Item
|
||||
/// augmentations honour the manual override.
|
||||
/// </summary>
|
||||
public long? Get(T11Counter counter)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
if (counter == T11Counter.ItemAugmentations && _itemAugOverride.HasValue) return _itemAugOverride;
|
||||
return _counts.TryGetValue(counter, out long v) ? v : null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Forgets the "/aug" counts (logout). The manual override is kept.</summary>
|
||||
public void Clear()
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
_counts.Clear();
|
||||
UpdatedUtc = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the player meets every wield gate of <paramref name="item"/>: 1 = yes (or the
|
||||
/// item has no gate), 0 = a gate is not met, -1 = a needed counter is unknown. Mirrors the
|
||||
/// server's check (Player_Inventory, WieldRequirement.Int64Stat): raw counter >= amount.
|
||||
/// </summary>
|
||||
public int CanWield(T11ItemInfo item)
|
||||
{
|
||||
bool unknown = false;
|
||||
foreach (var gate in item.WieldGates)
|
||||
{
|
||||
long? have = Get(gate.Counter);
|
||||
if (have == null) { unknown = true; continue; }
|
||||
if (have.Value < gate.Amount) return 0;
|
||||
}
|
||||
return unknown ? -1 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads ACECustom's "/aug" reply into <see cref="T11PlayerAugs"/>. The reply is one chat line
|
||||
/// per counter ("Item:1,234", "Triune Weave: 5 (adds ...)"), so a bare "Item:" line is only
|
||||
/// trusted shortly after the "Advanced Augmentation Levels:" header.
|
||||
/// </summary>
|
||||
public sealed class T11AugReportParser
|
||||
{
|
||||
/// <summary>How long after the header (or the last accepted line) reply lines are trusted.</summary>
|
||||
public const long WindowMs = 5000;
|
||||
|
||||
private const RegexOptions Opt = RegexOptions.CultureInvariant | RegexOptions.IgnoreCase;
|
||||
private static readonly Regex Header = new(@"^Advanced Augmentation Levels:\s*$", Opt);
|
||||
private static readonly Regex Line = new(@"^(?<what>[A-Za-z' ]+?)\s*:\s*(?<n>\d[\d,.\s']*)", Opt);
|
||||
|
||||
private long _openUntil = long.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Feeds one chat line. Returns true when it updated a counter. <paramref name="nowMs"/>
|
||||
/// is any monotonic millisecond clock.
|
||||
/// </summary>
|
||||
public bool Feed(string? text, long nowMs, T11PlayerAugs into)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text)) return false;
|
||||
string line = text.Trim();
|
||||
if (Header.IsMatch(line))
|
||||
{
|
||||
_openUntil = nowMs + WindowMs;
|
||||
return false;
|
||||
}
|
||||
if (nowMs > _openUntil) return false;
|
||||
|
||||
Match m = Line.Match(line);
|
||||
if (!m.Success) return false;
|
||||
T11Counter? counter = CounterFor(m.Groups["what"].Value.Trim());
|
||||
if (counter == null) return false;
|
||||
|
||||
long value = 0;
|
||||
foreach (char c in m.Groups["n"].Value)
|
||||
{
|
||||
if (c < '0' || c > '9') { if (c == ' ' || c == ',' || c == '.' || c == '\'') continue; break; }
|
||||
value = value * 10 + (c - '0');
|
||||
}
|
||||
into.Set(counter.Value, value);
|
||||
_openUntil = nowMs + WindowMs;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>The counter a "/aug" line label stands for, or null for the ones T11 gates don't use.</summary>
|
||||
private static T11Counter? CounterFor(string label) => label.ToLowerInvariant() switch
|
||||
{
|
||||
"item" => T11Counter.ItemAugmentations,
|
||||
"triune weave" => T11Counter.TriuneWeave,
|
||||
"battlemage's wrath charm" => T11Counter.BattlemagesWrath,
|
||||
"nether veil charm" => T11Counter.NetherVeil,
|
||||
"crashing steel charm" => T11Counter.CrashingSteel,
|
||||
"true shot charm" => T11Counter.TrueShot,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
210
Tools/RynthCore.LootSdkTests/LootT11Tests.cs
Normal file
210
Tools/RynthCore.LootSdkTests/LootT11Tests.cs
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using RynthCore.Loot.Editing;
|
||||
using RynthCore.Loot.T11;
|
||||
|
||||
namespace RynthCore.LootSdkTests;
|
||||
|
||||
// T11 (ACECustom tier 11+) loot support: the item-text parser against the server's exact
|
||||
// strings, tier estimates, the "/aug" reply reader, wield checks, virtual keys, the stripped
|
||||
// wield/rating fallbacks, and the editor's key names and grade table.
|
||||
internal static partial class Program
|
||||
{
|
||||
// A T13 weapon as ACECustom appraises it: Property Details then Modifiers in LongDesc.
|
||||
private const string T11WeaponLongDesc =
|
||||
"A finely made sword.\n\n" +
|
||||
"Property Details:\n" +
|
||||
"- Weapon Grade: B+ (86% of max damage)\n" +
|
||||
"- Wield requires: 3,000 Item Augmentations\n" +
|
||||
"- Wield requires: 25 Crashing Steel\n" +
|
||||
"- Cast on Strike: Force Arc (13% proc chance)\n" +
|
||||
"\n" +
|
||||
"Modifiers:\n" +
|
||||
"- Damage Rating +41 [14-69]\n" +
|
||||
"- Crit Damage Rating +10 [5-15]\n" +
|
||||
"- Pct HP Damage 2%\n" +
|
||||
"- Zone Locked (Power Reduced)\n";
|
||||
|
||||
// T16 armor: gates in LongDesc without a dash, Modifiers in the Use string.
|
||||
private const string T11ArmorLongDesc =
|
||||
"Sturdy plate.\n" +
|
||||
"Wield requires: 4.000 Item Augmentations\n" +
|
||||
"Wield requires: 500 Triune Weave\n";
|
||||
|
||||
private const string T11ArmorUse =
|
||||
"Modifiers:\n" +
|
||||
"- Damage Resist +8 [2-12]\n" +
|
||||
"- Max Health +120 [40-200]\n" +
|
||||
"- Max Health Pct +2% [1-4]\n" +
|
||||
"- Modifier 60 +3 [1-5]\n";
|
||||
|
||||
private static void RunT11Tests()
|
||||
{
|
||||
Console.WriteLine("\n-- T11 loot --");
|
||||
TestT11WeaponParse();
|
||||
TestT11ArmorParse();
|
||||
TestT11NonT11();
|
||||
TestT11Tier();
|
||||
TestT11AugReport();
|
||||
TestT11Keys();
|
||||
TestT11Editor();
|
||||
}
|
||||
|
||||
private static void TestT11WeaponParse()
|
||||
{
|
||||
T11ItemInfo w = T11ItemInfo.Parse("T11 - Tachi", T11WeaponLongDesc, null);
|
||||
Check(w.IsT11 && w.HasNamePrefix, "weapon: T11 by prefix");
|
||||
Eq(w.Grade, "B+", "weapon: grade label");
|
||||
Eq(w.GradeRank, 12, "weapon: grade rank B+ = 12");
|
||||
Eq(w.DamagePercent, 86, "weapon: damage % of max");
|
||||
Eq(w.WieldItemAugs, 3000, "weapon: item-aug gate with group separator");
|
||||
Eq(w.GateAmount(T11Counter.CrashingSteel), 25, "weapon: charm gate");
|
||||
Eq(w.Procs.Count, 1, "weapon: one cast on strike");
|
||||
Eq(w.Procs.Count > 0 ? w.Procs[0].Name : "", "Force Arc", "weapon: proc name");
|
||||
Eq(w.Procs.Count > 0 ? w.Procs[0].ChancePercent : 0, 13.0, "weapon: proc chance");
|
||||
Check(w.ZoneLocked, "weapon: zone locked line inside Modifiers");
|
||||
Eq(w.Modifiers.Count, 3, "weapon: zone lock line is not a modifier");
|
||||
T11Modifier dr = w.Modifiers.First(m => m.Key == 28);
|
||||
Eq(dr.Value, 41, "weapon: Damage Rating value");
|
||||
Eq((dr.Min, dr.Max), ((int?)14, (int?)69), "weapon: Damage Rating band");
|
||||
Eq(dr.RollPercent, 49, "weapon: Damage Rating roll (41-14)/(69-14)");
|
||||
Check(w.Modifiers.Any(m => m.Key == 44 && m.IsSlotSpecial), "weapon: slot special without a band");
|
||||
Check(w.HasSlotSpecial, "weapon: HasSlotSpecial");
|
||||
Eq(w.RatingFromModifiers(370), 41, "weapon: 370 from Damage Rating");
|
||||
Eq(w.RatingFromModifiers(374), 10, "weapon: 374 from Crit Damage Rating");
|
||||
Eq(w.ModifierRatingTotal, 51, "weapon: modifier rating total");
|
||||
Eq(w.EstimatedTier, 13, "weapon: 3,000 gate = T13");
|
||||
Eq(w.BestRollPercent, 50, "weapon: best roll (Crit Damage 10 in 5-15)");
|
||||
}
|
||||
|
||||
private static void TestT11ArmorParse()
|
||||
{
|
||||
T11ItemInfo a = T11ItemInfo.Parse("T11 - Celdon Breastplate", T11ArmorLongDesc, T11ArmorUse);
|
||||
Check(a.IsT11, "armor: T11");
|
||||
Eq(a.Grade, null, "armor: no weapon grade");
|
||||
Eq(a.WieldItemAugs, 4000, "armor: dot group separator, no dash");
|
||||
Eq(a.GateAmount(T11Counter.TriuneWeave), 500, "armor: Triune Weave gate");
|
||||
Eq(a.EstimatedTier, 16, "armor: 500 Triune Weave = T16");
|
||||
Eq(T11Keys.TryGetValue(a, T11Keys.EstimatedTier, null, out int at) ? at : 0, 16, "armor: tier key reads T16");
|
||||
Eq(a.Modifiers.Count, 4, "armor: modifiers from Use");
|
||||
Check(a.Modifiers.Any(m => m.Key == 47 && m.Value == 2), "armor: Max Health Pct is not Max Health");
|
||||
Check(a.Modifiers.Any(m => m.Key == 19 && m.Value == 120), "armor: Max Health");
|
||||
Check(a.Modifiers.Any(m => m.Key == 60 && m.Name == "Modifier 60" && m.Value == 3), "armor: unknown server key kept");
|
||||
Eq(a.RatingFromModifiers(371), 8, "armor: 371 from Damage Resist");
|
||||
Eq(a.RatingFromModifiers(379), 120, "armor: 379 from Max Health");
|
||||
Eq(a.ModifierRatingTotal, 128, "armor: rating total 371 + 379");
|
||||
}
|
||||
|
||||
private static void TestT11NonT11()
|
||||
{
|
||||
Check(!T11ItemInfo.Parse("Tachi", "A finely made sword.", "").IsT11, "plain item is not T11");
|
||||
Check(!T11ItemInfo.Parse(null, null, null).IsT11, "no text is not T11");
|
||||
Check(!T11ItemInfo.Parse("Wand", "- Cast on Strike: Bolt (5% proc chance)", null).IsT11, "a proc alone doesn't mark T11");
|
||||
Check(T11ItemInfo.Parse("T11 - Robe", null, null).IsT11, "unappraised T11 name still T11");
|
||||
Eq(T11ItemInfo.Parse("T11 - Robe", null, null).EstimatedTier, 11, "unappraised T11 = tier 11");
|
||||
Check(!T11ItemInfo.Parse("T11 - Robe", null, null).HasText, "unappraised T11 has no text");
|
||||
Eq(T11Keys.TryGetValue(T11ItemInfo.Parse("T11 - Robe", null, null), T11Keys.CanWield, new T11PlayerAugs(), out int cw) ? cw : 99, -1,
|
||||
"unappraised T11: Can Wield unknown");
|
||||
Eq(T11Keys.TryGetValue(T11ItemInfo.Parse("T11 - Robe", "A robe.", null), T11Keys.CanWield, null, out int cw2) ? cw2 : 99, 1,
|
||||
"appraised T11 without a gate: wieldable");
|
||||
Check(!T11ItemInfo.Parse("x", "Modifiers:\n- ", "\n\n- [").IsT11, "malformed text doesn't throw or mark");
|
||||
}
|
||||
|
||||
private static void TestT11Tier()
|
||||
{
|
||||
Eq(T11Catalog.EstimateTier(0, false), 0, "tier: nothing");
|
||||
Eq(T11Catalog.EstimateTier(2000, true), 11, "tier: 2,000 = T11");
|
||||
Eq(T11Catalog.EstimateTier(2500, true), 12, "tier: 2,500 = T12");
|
||||
Eq(T11Catalog.EstimateTier(3500, true), 14, "tier: 3,500 = T14");
|
||||
Eq(T11Catalog.EstimateTier(9000, true), 15, "tier: capped at 15");
|
||||
|
||||
// T16-T25: the item-aug gate is frozen at 4,000, the Triune Weave gate carries the tier.
|
||||
Eq(T11Catalog.EstimateTier(4000, 0, true), 15, "tier: 4,000 without Triune = T15");
|
||||
Eq(T11Catalog.EstimateTier(3000, 0, true), 13, "tier: no Triune falls back to the item-aug gate");
|
||||
Eq(T11Catalog.EstimateTier(4000, 500, true), 16, "tier: 500 Triune = T16");
|
||||
Eq(T11Catalog.EstimateTier(4000, 1500, true), 18, "tier: 1,500 Triune = T18");
|
||||
Eq(T11Catalog.EstimateTier(4000, 5000, true), 25, "tier: 5,000 Triune = T25");
|
||||
Eq(T11Catalog.EstimateTier(4000, 9000, true), T11Catalog.MaxTier, "tier: capped at T25");
|
||||
Eq(T11Catalog.EstimateTier(4000, 250, true), 16, "tier: any Triune gate is at least T16");
|
||||
Eq(T11Catalog.EstimateTier(0, 0, false), 0, "tier: nothing (three-argument)");
|
||||
|
||||
// A T25 weapon as appraised: item augs frozen at 4,000, Triune and family charm 5,000 each.
|
||||
T11ItemInfo t25 = T11ItemInfo.Parse("T11 - Tachi",
|
||||
"Property Details:\n" +
|
||||
"- Weapon Grade: A (95% of max damage)\n" +
|
||||
"- Wield requires: 4,000 Item Augmentations\n" +
|
||||
"- Wield requires: 5,000 Triune Weave\n" +
|
||||
"- Wield requires: 5,000 Crashing Steel\n", null);
|
||||
Eq(t25.EstimatedTier, 25, "tier: T25 weapon from its Triune gate");
|
||||
Eq(t25.GateAmount(T11Counter.CrashingSteel), 5000, "tier: T25 weapon charm gate");
|
||||
}
|
||||
|
||||
private static void TestT11AugReport()
|
||||
{
|
||||
var p = new T11PlayerAugs();
|
||||
var r = new T11AugReportParser();
|
||||
Check(!r.Feed("Item:2,500", 0, p), "aug: Item line before the header ignored");
|
||||
Check(!r.Feed("Advanced Augmentation Levels:", 1000, p), "aug: header opens the window");
|
||||
Check(r.Feed("Item:2,500", 1100, p), "aug: Item line read");
|
||||
Check(r.Feed("Triune Weave: 3 (adds 3% damage)", 1200, p), "aug: Triune Weave read");
|
||||
Check(r.Feed("Crashing Steel Charm: 20", 1300, p), "aug: charm read");
|
||||
Check(!r.Feed("Item:9999", 1300 + T11AugReportParser.WindowMs + 1, p), "aug: window closes");
|
||||
Eq(p.Get(T11Counter.ItemAugmentations), (long?)2500, "aug: item count");
|
||||
Eq(p.Get(T11Counter.TriuneWeave), (long?)3, "aug: triune count");
|
||||
Eq(p.Get(T11Counter.NetherVeil), null, "aug: unreported counter unknown");
|
||||
|
||||
T11ItemInfo weapon = T11ItemInfo.Parse("T11 - Tachi", T11WeaponLongDesc, null);
|
||||
Eq(p.CanWield(weapon), 0, "wield: 2,500 < 3,000");
|
||||
p.ItemAugOverride = 3000;
|
||||
Eq(p.CanWield(weapon), 0, "wield: crashing steel 20 < 25");
|
||||
p.Set(T11Counter.CrashingSteel, 25);
|
||||
Eq(p.CanWield(weapon), 1, "wield: override + charm met");
|
||||
p.Clear();
|
||||
Eq(p.Get(T11Counter.ItemAugmentations), (long?)3000, "aug: Clear keeps the override");
|
||||
Eq(p.CanWield(weapon), -1, "wield: charm unknown after Clear");
|
||||
}
|
||||
|
||||
private static void TestT11Keys()
|
||||
{
|
||||
T11ItemInfo w = T11ItemInfo.Parse("T11 - Tachi", T11WeaponLongDesc, null);
|
||||
int V(int key, T11PlayerAugs? pl = null) => T11Keys.TryGetValue(w, key, pl, out int v) ? v : int.MinValue;
|
||||
Eq(V(T11Keys.IsT11), 1, "key: IsT11");
|
||||
Eq(V(T11Keys.EstimatedTier), 13, "key: tier");
|
||||
Eq(V(T11Keys.WeaponGrade), 12, "key: grade");
|
||||
Eq(V(T11Keys.DamagePercent), 86, "key: damage %");
|
||||
Eq(V(T11Keys.WieldItemAugs), 3000, "key: wield item augs");
|
||||
Eq(V(T11Keys.CanWield), -1, "key: can wield unknown without player");
|
||||
Eq(V(T11Keys.ModifierCount), 3, "key: modifier count");
|
||||
Eq(V(T11Keys.ModifierRatingTotal), 51, "key: modifier ratings");
|
||||
Eq(V(T11Keys.CastOnStrikeCount), 1, "key: procs");
|
||||
Eq(V(T11Keys.ZoneLocked), 1, "key: zone locked");
|
||||
Eq(V(T11Keys.ForModifier(28)), 41, "key: per-modifier Damage Rating");
|
||||
Eq(V(T11Keys.ForModifier(50)), 0, "key: absent modifier = 0");
|
||||
Eq(V(T11Keys.ModifierBase + 999), int.MinValue, "key: unknown modifier id unused");
|
||||
Eq(V(370), int.MinValue, "key: retail key isn't virtual");
|
||||
Check(T11Keys.IsVirtual(T11Keys.IsT11) && !T11Keys.IsVirtual(T11Keys.Base) && !T11Keys.IsVirtual(T11Keys.End), "key: block bounds");
|
||||
|
||||
int S(T11ItemInfo item, int key) => T11Keys.TryGetStrippedValue(item, key, out int v) ? v : int.MinValue;
|
||||
Eq(S(w, 158), 13, "stripped: 158 = Int64 Property");
|
||||
Eq(S(w, 159), 9008, "stripped: 159 = item augs stat");
|
||||
Eq(S(w, 160), 3000, "stripped: 160 = gate");
|
||||
Eq(S(w, 370), 41, "stripped: 370 from modifier");
|
||||
Eq(S(w, 371), int.MinValue, "stripped: no modifier for 371");
|
||||
Eq(S(T11ItemInfo.None, 158), int.MinValue, "stripped: non-T11 gives nothing");
|
||||
Eq(S(T11ItemInfo.Parse("T11 - Robe", null, null), 160), int.MinValue, "stripped: no gate read yet");
|
||||
Check(T11Keys.IsStrippedKey(158) && T11Keys.IsStrippedKey(379) && !T11Keys.IsStrippedKey(161), "stripped: key set");
|
||||
}
|
||||
|
||||
private static void TestT11Editor()
|
||||
{
|
||||
Check(LootRuleText.LongKeys.Any(k => k.Id == T11Keys.CanWield && k.Name == "T11: Can Wield"), "editor: Can Wield key named");
|
||||
Check(LootRuleText.LongKeys.Any(k => k.Id == T11Keys.ForModifier(28) && k.Name == "T11 Mod: Damage Rating"), "editor: per-modifier key named");
|
||||
Check(LootRuleText.LongKeys.Any(k => k.Id == 377), "editor: NetherResistRating listed");
|
||||
Eq(LootRuleText.LongKeys.Select(k => k.Id).Distinct().Count(), LootRuleText.LongKeys.Length, "editor: long key ids unique");
|
||||
Check(ReferenceEquals(LootRuleText.ValueTableFor(T11Keys.WeaponGrade), T11Catalog.Grades), "editor: grade value table");
|
||||
Eq(LootRuleText.ValueName(T11Keys.WeaponGrade, "12"), "B+", "editor: grade 12 named B+");
|
||||
Eq(LootRuleText.WieldRequirements.First(w => w.Id == 13).Name, "Int64 Property", "editor: wield requirement 13");
|
||||
Check(LootRuleText.StringKeys.Any(k => k.Id == 14) && LootRuleText.StringKeys.Any(k => k.Id == 16), "editor: Use and LongDesc string keys");
|
||||
Eq(T11Catalog.Grades.Select(g => g.Name).Distinct().Count(), T11Catalog.Grades.Length, "editor: grade names unique");
|
||||
}
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ internal static partial class Program
|
|||
Eq(LootRuleText.Materials.First(m => m.Id == 15).Name, "Black Garnet", "material 15");
|
||||
Eq(LootRuleText.Materials.Length, 78, "materials 0..77");
|
||||
Eq(LootRuleText.WieldRequirements.First(w => w.Id == 2).Name, "Base Skill", "wield requirement 2 (RawSkill)");
|
||||
Eq(LootRuleText.WieldRequirements.Length, 13, "wield requirements 0..12");
|
||||
Eq(LootRuleText.WieldRequirements.Length, 14, "wield requirements 0..13 (13 = ACECustom Int64 Property)");
|
||||
Eq(LootRuleText.DamageTypes.First(d => d.Id == 64).Name, "Electric", "damage type 64");
|
||||
|
||||
// Lookup and labels; unknown and odd values stay expressible.
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ internal static partial class Program
|
|||
TestMalformedInputs();
|
||||
RunLootEditTests(args);
|
||||
RunLootAddTests(args);
|
||||
RunT11Tests();
|
||||
|
||||
Console.WriteLine($"\nGolden tests: {_asserts} assertions, {_fails} failed.");
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ internal static class Program
|
|||
var runner = new Runner();
|
||||
NativeLootTests.Register(runner);
|
||||
VTankLootTests.Register(runner);
|
||||
T11LootTests.Register(runner);
|
||||
ExpressionTests.Register(runner);
|
||||
MetaTests.Register(runner);
|
||||
NoKillTests.Register(runner);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ internal static class OffhandTests
|
|||
r.Add("offhand: two-hander -> the shield comes off first, back on with a one-hander", TwoHanderShieldOff);
|
||||
r.Add("offhand: bow -> the shield comes off, then the arrows still go on", BowShieldOffThenAmmo);
|
||||
r.Add("offhand: a caster -> the shield comes off first (swap gate held)", CasterShieldOff);
|
||||
r.Add("swap speed: a weapon in hand -> one use of the wand (the client swaps); the pack move only as the fallback", CasterDirectSwap);
|
||||
r.Add("swap speed: the gate lets the next step go once the server is done, else after 3 s", SwapGateSettles);
|
||||
r.Add("offhand: dual wield with the Dual Wield skill", DualWield);
|
||||
r.Add("offhand: no Dual Wield skill -> the shield", NoSkillShield);
|
||||
r.Add("offhand: None -> hands off (a worn shield is never taken off)", NoneHandsOff);
|
||||
|
|
@ -331,6 +333,56 @@ internal static class OffhandTests
|
|||
Check.Eq(FakeHost.Wields.Count, 0, "no shield with a caster");
|
||||
}
|
||||
|
||||
// 2026-10-06: Drakkon's axe -> wand took 4.2 s: the axe into the pack (1.2 s), then the swap
|
||||
// gate's flat 3 s before the wand. A use of the wand (the client's double-click) swaps by itself.
|
||||
private static void CasterDirectSwap()
|
||||
{
|
||||
var rig = new Rig(); // the sword in hand
|
||||
rig.List(Wand);
|
||||
rig.C.CanCastOverride = _ => true;
|
||||
Check.False(rig.Tick(), "not ready");
|
||||
Check.True(FakeHost.Uses.Contains(Wand), "UseObject(wand) with the sword still in hand");
|
||||
Check.Eq(FakeHost.Moves.Count, 0, "no pack move first");
|
||||
|
||||
// The use didn't swap in 2 s (SwapTracker retries at 2.5 s): the sword goes into the pack first from now on.
|
||||
var since = typeof(CombatManager).GetField("_combatDirectSwapSince", BindingFlags.Instance | BindingFlags.NonPublic)!;
|
||||
since.SetValue(rig.C, DateTime.Now.AddSeconds(-3));
|
||||
rig.C.SwapTracker.Reset(); // its 2.5 s resolve time is up
|
||||
rig.Tick();
|
||||
Check.True(FakeHost.Moves.Any(m => m.Id == Sword), "fallback: the sword into the pack");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("from now on the weapon goes into a pack first")), "logged once");
|
||||
}
|
||||
|
||||
private static void SwapGateSettles()
|
||||
{
|
||||
long t = 0;
|
||||
bool idle = true;
|
||||
var wielded = new Dictionary<int, bool> { [7] = true };
|
||||
var g = new WeaponSwapGate { NowMs = () => t, ServerIdle = () => idle, IsWielded = id => wielded[id] };
|
||||
Check.True(g.TryBeginSwap("shield off"), "first swap");
|
||||
g.NoteMove(7, wieldedNow: true);
|
||||
t = 500;
|
||||
Check.False(g.TryBeginSwap("weapon"), "the shield is still in hand");
|
||||
wielded[7] = false;
|
||||
Check.True(g.TryBeginSwap("weapon"), "the shield is off: the weapon goes at once (not at 3 s)");
|
||||
t = 700;
|
||||
Check.False(g.TryBeginSwap("off hand"), "under the 400 ms floor");
|
||||
t = 1000;
|
||||
idle = false;
|
||||
Check.False(g.TryBeginSwap("off hand"), "the weapon's use is still unanswered");
|
||||
idle = true;
|
||||
Check.True(g.TryBeginSwap("off hand"), "answered: the off hand goes");
|
||||
|
||||
// No pacing (ServerIdle unset): the flat 3 s, as before.
|
||||
t = 0;
|
||||
var flat = new WeaponSwapGate { NowMs = () => t };
|
||||
Check.True(flat.TryBeginSwap("a"), "first");
|
||||
t = 2999;
|
||||
Check.False(flat.TryBeginSwap("b"), "inside 3 s");
|
||||
t = 3000;
|
||||
Check.True(flat.TryBeginSwap("b"), "after 3 s");
|
||||
}
|
||||
|
||||
private static void DualWield()
|
||||
{
|
||||
var rig = new Rig(dualWieldSkill: true);
|
||||
|
|
|
|||
127
Tools/RynthCore.RynthAiHostTests/Tests/T11LootTests.cs
Normal file
127
Tools/RynthCore.RynthAiHostTests/Tests/T11LootTests.cs
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
using RynthCore.Loot;
|
||||
using RynthCore.Loot.T11;
|
||||
using RynthCore.Loot.VTank;
|
||||
using RynthCore.Plugin.RynthAi;
|
||||
using RynthCore.Plugin.RynthAi.Loot;
|
||||
using RynthCore.RynthAiHostTests.Fakes;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
using N = RynthCore.Loot.VTank.VTankNodeTypes;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// T11 (ACECustom tier 11+) items through the real evaluator: the virtual T11 keys answered by
|
||||
// WorldObject.Values, the wield requirement and ratings the server strips put back from the
|
||||
// item text, and "Can Wield" fed by the "/aug" reply.
|
||||
internal static class T11LootTests
|
||||
{
|
||||
private const string WeaponLongDesc =
|
||||
"Property Details:\n" +
|
||||
"- Weapon Grade: A- (91% of max damage)\n" +
|
||||
"- Wield requires: 2,500 Item Augmentations\n" +
|
||||
"\n" +
|
||||
"Modifiers:\n" +
|
||||
"- Damage Rating +30 [14-69]\n" +
|
||||
"- Crit Chance +4 [1-8]\n";
|
||||
|
||||
private const string ArmorUse =
|
||||
"Modifiers:\n" +
|
||||
"- Damage Resist +6 [2-12]\n" +
|
||||
"- Max Health +100 [40-200]\n";
|
||||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("loot t11: virtual keys read the item text", VirtualKeys);
|
||||
r.Add("loot t11: stripped wield requirement 158/159/160 restored", StrippedWield);
|
||||
r.Add("loot t11: modifier ratings feed Gear* keys and TotalRatings", ModifierRatings);
|
||||
r.Add("loot t11: a live rating wins over the modifier text", LiveRatingWins);
|
||||
r.Add("loot t11: retail items are untouched", RetailUntouched);
|
||||
r.Add("loot t11: Can Wield from the /aug reply and the override", CanWield);
|
||||
}
|
||||
|
||||
private static VTankLootCondition C(int node, params string[] data) => new(node, "0", data);
|
||||
|
||||
private static bool M(WorldObject item, params VTankLootCondition[] conds)
|
||||
{
|
||||
var rule = new VTankLootRule { Name = "r", Action = VTankLootAction.Keep };
|
||||
rule.Conditions.AddRange(conds);
|
||||
return VTankLootEvaluator.Match(rule, item);
|
||||
}
|
||||
|
||||
private static string K(int key) => key.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
private static Item Weapon() => new Item("T11 - Tachi", AcObjectClass.MeleeWeapon).Str(16, WeaponLongDesc);
|
||||
|
||||
private static void VirtualKeys()
|
||||
{
|
||||
T11ItemSupport.Reset();
|
||||
WorldObject w = Weapon();
|
||||
Check.Eq(w.Values(T11Keys.IsT11, -5), 1, "IsT11");
|
||||
Check.Eq(w.Values(T11Keys.EstimatedTier, -5), 12, "2,500 gate = T12");
|
||||
Check.Eq(w.Values(T11Keys.WeaponGrade, -5), 13, "A- = 13");
|
||||
Check.True(M(w, C(N.LongValKeyGE, "12", K(T11Keys.WeaponGrade))), "rule: grade B+ or better");
|
||||
Check.False(M(w, C(N.LongValKeyGE, "14", K(T11Keys.WeaponGrade))), "rule: grade A or better");
|
||||
Check.True(M(w, C(N.LongValKeyGE, "25", K(T11Keys.ForModifier(28)))), "rule: Damage Rating mod >= 25");
|
||||
Check.True(M(w, C(N.LongValKeyE, "0", K(T11Keys.ZoneLocked))), "rule: not zone locked");
|
||||
Check.Eq(w.Values(T11Keys.Base + 0x1FF, -5), -5, "unused virtual id = default");
|
||||
Check.Eq(new Item("Tachi").Wo.Values(T11Keys.IsT11, -5), 0, "retail item: IsT11 = 0");
|
||||
}
|
||||
|
||||
private static void StrippedWield()
|
||||
{
|
||||
T11ItemSupport.Reset();
|
||||
WorldObject w = Weapon();
|
||||
Check.Eq(w.Values(158, 0), T11Keys.WieldRequirementInt64Stat, "158 = Int64 Property");
|
||||
Check.Eq(w.Values(159, 0), 9008, "159 = item augs");
|
||||
Check.Eq(w.Values(160, 0), 2500, "160 = gate");
|
||||
Check.True(M(w, C(N.LongValKeyLE, "2500", "160")), "rule: wield difficulty <= 2500");
|
||||
Check.False(M(w, C(N.LongValKeyLE, "2000", "160")), "rule: wield difficulty <= 2000");
|
||||
Check.Eq(w.Values(161, -1), -1, "other keys keep the default");
|
||||
}
|
||||
|
||||
private static void ModifierRatings()
|
||||
{
|
||||
T11ItemSupport.Reset();
|
||||
WorldObject w = Weapon();
|
||||
Check.Eq(w.Values(370, 0), 30, "370 Damage Rating from text");
|
||||
Check.Eq(w.Values(372, 0), 4, "372 Crit from text");
|
||||
Check.True(M(w, C(N.TotalRatingsGE, "34")), "TotalRatings counts modifier ratings");
|
||||
Check.False(M(w, C(N.TotalRatingsGE, "35")), "TotalRatings exact");
|
||||
|
||||
WorldObject armor = new Item("T11 - Celdon Breastplate", AcObjectClass.Armor).Str(14, ArmorUse);
|
||||
Check.Eq(armor.Values(371, 0), 6, "371 from the Use string");
|
||||
Check.True(M(armor, C(N.TotalRatingsGE, "106")), "armor TotalRatings 371 + 379");
|
||||
}
|
||||
|
||||
private static void LiveRatingWins()
|
||||
{
|
||||
T11ItemSupport.Reset();
|
||||
WorldObject w = Weapon().Int(370, 7);
|
||||
Check.Eq(w.Values(370, 0), 7, "a property the item has is never replaced");
|
||||
}
|
||||
|
||||
private static void RetailUntouched()
|
||||
{
|
||||
T11ItemSupport.Reset();
|
||||
WorldObject retail = new Item("Tachi", AcObjectClass.MeleeWeapon).Str(16, WeaponLongDesc);
|
||||
Check.Eq(retail.Values(160, 0), 0, "no T11 prefix: no stripped-key fallback");
|
||||
Check.Eq(retail.Values(370, -1), -1, "no T11 prefix: rating default kept");
|
||||
}
|
||||
|
||||
private static void CanWield()
|
||||
{
|
||||
T11ItemSupport.Reset();
|
||||
WorldObject w = Weapon();
|
||||
Check.Eq(w.Values(T11Keys.CanWield, -5), -1, "unknown before /aug");
|
||||
T11ItemSupport.OnChat("Advanced Augmentation Levels:");
|
||||
T11ItemSupport.OnChat("Item:2,400");
|
||||
Check.Eq(w.Values(T11Keys.CanWield, -5), 0, "2,400 < 2,500");
|
||||
Check.False(M(w, C(N.LongValKeyE, "1", K(T11Keys.CanWield))), "rule: wieldable fails");
|
||||
T11ItemSupport.SyncOverride(2500);
|
||||
Check.Eq(w.Values(T11Keys.CanWield, -5), 1, "override 2,500 meets the gate");
|
||||
T11ItemSupport.SyncOverride(-1);
|
||||
Check.Eq(w.Values(T11Keys.CanWield, -5), 0, "back to the /aug count");
|
||||
Check.Eq(new Item("T11 - Robe").Wo.Values(T11Keys.CanWield, -5), -1, "not appraised yet: unknown");
|
||||
Check.Eq(new Item("T11 - Robe").Str(16, "A robe.").Wo.Values(T11Keys.CanWield, -5), 1, "appraised, no gate: wieldable");
|
||||
T11ItemSupport.Reset();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue