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
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue