Buff order priority, unusable-buff filter, Force Buff button and /ra buff
- Life Magic Mastery joins Creature Enchantment Mastery, Focus and Willpower at the head of the buff list (all four raise casting skill or mana); the rest keeps its order. - A mastery for an untrained skill is never cast. - New setting SkipUnusableBuffs (default on; profile, bridge, copy, settings map, UI) leaves out the weapon enchantments the character has no use for: Blood Drinker / Heart Seeker / Swift Killer without a melee or missile weapon (listed or in hand), Spirit Drinker / Hermetic Link without a wand (listed, in hand, or the pack wand buffing would wield when WieldUnlistedWandWhenNoneListed is on), Defender without either. Unclassifiable listed items filter nothing; no cache means no filtering; ammo is no weapon. The weapon kit is cached for 1 s and rebuilt when the Items list, the unlisted-wand setting or the cache changes. - Skipped buffs are reported once per run (Force Rebuff or the automatic batch), grouped by reason and capped at 5 names per reason, printed when the content changes or every 30 s, in chat and the log, in /ra buff skipped, and on the Buffing settings page. - Force Buff and Cancel buttons on the Buffing settings page, and /ra buff force|cancel|skipped, both reusing the existing queued Force Rebuff request (FR button, /ra forcebuff). Tests: priority order, force suite vs idle, skill and weapon filters (pack wand, wielded weapons, ammo, unclassified items), visibility, the setting, and the /ra buff command handler. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1643835c7c
commit
36565dca33
8 changed files with 737 additions and 9 deletions
|
|
@ -877,6 +877,7 @@ public class BuffManager : IDisposable
|
|||
_host.WriteToChat("[RynthAi] Starting Force Rebuff...", 5);
|
||||
|
||||
var list = BuildDynamicBuffList();
|
||||
LogFilterSkips(); // the skips of the pass just made
|
||||
_host.Log($"[FR] buff list ({list.Count}): {string.Join(", ", list)}");
|
||||
_host.Log($"[FR] macroRunning={_settings.IsMacroRunning} liveRefreshed={_liveBuffsRefreshed}");
|
||||
}
|
||||
|
|
@ -2473,6 +2474,7 @@ public class BuffManager : IDisposable
|
|||
_isAutoBatchRebuff = true;
|
||||
_forceRebuffCastFamilies.Clear();
|
||||
_chain.PassStart();
|
||||
LogFilterSkips();
|
||||
}
|
||||
|
||||
List<string> desiredBuffs = BuildDynamicBuffList();
|
||||
|
|
@ -3424,11 +3426,189 @@ public class BuffManager : IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
// What the character's weapons allow (BuildDynamicBuffList's weapon-aura filter).
|
||||
// Physical = a melee or missile weapon is listed or wielded; Caster = a wand/staff/orb is listed,
|
||||
// wielded, or (WieldUnlistedWandWhenNoneListed) in the pack; Unknown = something listed that the
|
||||
// object cache can't classify (nothing is filtered then).
|
||||
internal readonly record struct ListedWeaponKit(bool Physical, bool Caster, bool Unknown);
|
||||
|
||||
// The kit is read from the object cache (a pack walk), so it is kept for KitTtlMs and
|
||||
// recomputed early when the Items list (its reference or length), the unlisted-wand setting or
|
||||
// the cache changes. A weapon swap shows within the TTL.
|
||||
private ListedWeaponKit _kit;
|
||||
private long _kitAt = long.MinValue / 2;
|
||||
private List<ItemRule>? _kitRules;
|
||||
private int _kitRuleCount;
|
||||
private bool _kitUnlisted;
|
||||
private WorldObjectCache? _kitCache;
|
||||
private const long KitTtlMs = 1000;
|
||||
/// <summary>Clock (ms) for the kit's TTL; tests replace it.</summary>
|
||||
internal Func<long> KitClockMs = () => Environment.TickCount64;
|
||||
/// <summary>Times the kit was actually computed (tests).</summary>
|
||||
internal int KitComputations { get; private set; }
|
||||
|
||||
internal ListedWeaponKit ListedWeapons()
|
||||
{
|
||||
long now = KitClockMs();
|
||||
var rules = _settings.ItemRules;
|
||||
bool unlisted = _settings.WieldUnlistedWandWhenNoneListed;
|
||||
if (ReferenceEquals(rules, _kitRules) && rules.Count == _kitRuleCount && unlisted == _kitUnlisted
|
||||
&& ReferenceEquals(_worldObjectCache, _kitCache) && now >= _kitAt && now - _kitAt < KitTtlMs)
|
||||
return _kit;
|
||||
_kit = ComputeListedWeapons();
|
||||
_kitAt = now;
|
||||
_kitRules = rules;
|
||||
_kitRuleCount = rules.Count;
|
||||
_kitUnlisted = unlisted;
|
||||
_kitCache = _worldObjectCache;
|
||||
KitComputations++;
|
||||
return _kit;
|
||||
}
|
||||
|
||||
private ListedWeaponKit ComputeListedWeapons()
|
||||
{
|
||||
var cache = _worldObjectCache;
|
||||
if (cache == null) return new ListedWeaponKit(false, false, true); // no cache yet: can't tell, don't filter
|
||||
bool physical = false, caster = false, unknown = false;
|
||||
List<ItemRule> rules;
|
||||
try { rules = new List<ItemRule>(_settings.ItemRules); }
|
||||
catch { return new ListedWeaponKit(false, false, true); } // list edited mid-copy: don't filter this pass
|
||||
foreach (var r in rules)
|
||||
{
|
||||
if (WeaponList.IsShieldRule(r)) continue; // a shield is neither
|
||||
var wo = cache[r.Id];
|
||||
if (wo == null) { unknown = true; continue; }
|
||||
if (!IsKnownWeaponClass(wo)) wo = cache.RefreshIdentity(wo); // blank name / Unknown class
|
||||
if (!IsKnownWeaponClass(wo)) wo = cache.ReclassifyFromItemType(r.Id) ?? wo; // a stuck name-based guess
|
||||
if (WorldObjectCache.IsAmmo(wo)) continue; // arrows are no weapon
|
||||
if (wo.ObjectClass == AcObjectClass.MeleeWeapon || wo.ObjectClass == AcObjectClass.MissileWeapon) physical = true;
|
||||
else if (WeaponList.IsWand(wo)) caster = true;
|
||||
else if (wo.ObjectClass == AcObjectClass.Armor) continue; // a shield filed without the Shield action
|
||||
else unknown = true; // still unclassified: don't filter on it
|
||||
}
|
||||
try
|
||||
{
|
||||
// What is in hand counts too (CombatManager.InHandWeaponId's rules: not ammo, not the off hand).
|
||||
foreach (var wo in cache.GetDirectInventory(forceRefresh: true))
|
||||
{
|
||||
if (WorldObjectCache.IsAmmo(wo)) continue;
|
||||
if ((wo.Values(LongValueKey.CurrentWieldedLocation, 0) & OffhandRules.ShieldSlot) != 0) continue;
|
||||
bool phys = wo.ObjectClass == AcObjectClass.MeleeWeapon || wo.ObjectClass == AcObjectClass.MissileWeapon;
|
||||
bool wand = !phys && WeaponList.IsWand(wo);
|
||||
if (!phys && !wand) continue;
|
||||
if (!WorldObjectCache.IsWieldedByPlayer(_host, wo)) continue;
|
||||
if (phys) physical = true; else caster = true;
|
||||
}
|
||||
// No wand listed or in hand, but buffing may wield one from the pack (WieldUnlistedWandWhenNoneListed,
|
||||
// WeaponList.FindWand's unlisted branch: a WandStaffOrb by object class): that wand counts as a caster.
|
||||
if (!caster && _settings.WieldUnlistedWandWhenNoneListed)
|
||||
foreach (var wo in cache.GetInventory())
|
||||
if (wo.ObjectClass == AcObjectClass.WandStaffOrb) { caster = true; break; }
|
||||
}
|
||||
catch { unknown = true; }
|
||||
return new ListedWeaponKit(physical, caster, unknown);
|
||||
}
|
||||
|
||||
private static bool IsKnownWeaponClass(WorldObject wo) =>
|
||||
wo.ObjectClass == AcObjectClass.MeleeWeapon || wo.ObjectClass == AcObjectClass.MissileWeapon
|
||||
|| wo.ObjectClass == AcObjectClass.WandStaffOrb || wo.ObjectClass == AcObjectClass.Armor
|
||||
|| WorldObjectCache.IsAmmo(wo);
|
||||
|
||||
/// <summary>Why a weapon aura is left out for this kit, or "" when it stays.</summary>
|
||||
internal static string WeaponAuraSkipReason(string buff, ListedWeaponKit kit)
|
||||
{
|
||||
if (kit.Unknown) return "";
|
||||
switch (buff)
|
||||
{
|
||||
case "Blood Drinker Self":
|
||||
case "Heart Seeker Self":
|
||||
case "Swift Killer Self":
|
||||
return kit.Physical ? "" : "no melee or missile weapon listed";
|
||||
case "Spirit Drinker Self":
|
||||
case "Hermetic Link Self":
|
||||
return kit.Caster ? "" : "no wand listed";
|
||||
case "Defender Self":
|
||||
return kit.Physical || kit.Caster ? "" : "no weapon or wand listed";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// Buffs BuildDynamicBuffList left out on its last pass, with the reason. Replaced (never edited)
|
||||
// only when the content changes, so a reader on another thread (the settings face) never sees it
|
||||
// change under it, and the summary text is rebuilt only then.
|
||||
private IReadOnlyList<(string Buff, string Reason)> _filterSkips = Array.Empty<(string, string)>();
|
||||
private string _filterSummary = "";
|
||||
public IReadOnlyList<(string Buff, string Reason)> FilterSkips => _filterSkips;
|
||||
private DateTime _filterSkipLoggedAt = DateTime.MinValue;
|
||||
private string _filterSkipLoggedSummary = "";
|
||||
private const double FilterSkipLogMinSec = 30;
|
||||
private const int SummaryNamesPerReason = 5;
|
||||
|
||||
private void SetFilterSkips(List<(string Buff, string Reason)> skips)
|
||||
{
|
||||
var old = _filterSkips;
|
||||
bool same = old.Count == skips.Count;
|
||||
for (int i = 0; same && i < skips.Count; i++) same = old[i] == skips[i];
|
||||
if (same) return;
|
||||
_filterSkips = skips.Count == 0 ? Array.Empty<(string, string)>() : skips;
|
||||
_filterSummary = BuildSummary(skips);
|
||||
}
|
||||
|
||||
/// <summary>"skill untrained: A, B, C, D, E (+12 more); no melee or missile weapon listed: Blood Drinker, Heart Seeker".</summary>
|
||||
internal static string BuildSummary(IReadOnlyList<(string Buff, string Reason)> skips)
|
||||
{
|
||||
if (skips.Count == 0) return "";
|
||||
var order = new List<string>();
|
||||
var byReason = new Dictionary<string, List<string>>();
|
||||
foreach (var (buff, reason) in skips)
|
||||
{
|
||||
if (!byReason.TryGetValue(reason, out var names)) { byReason[reason] = names = new List<string>(); order.Add(reason); }
|
||||
names.Add(ShortName(buff));
|
||||
}
|
||||
var groups = new List<string>(order.Count);
|
||||
foreach (string reason in order)
|
||||
{
|
||||
var names = byReason[reason];
|
||||
string shown = string.Join(", ", names.GetRange(0, Math.Min(SummaryNamesPerReason, names.Count)));
|
||||
if (names.Count > SummaryNamesPerReason) shown += $" (+{names.Count - SummaryNamesPerReason} more)";
|
||||
groups.Add($"{reason}: {shown}");
|
||||
}
|
||||
return string.Join("; ", groups);
|
||||
}
|
||||
|
||||
private static string ShortName(string buff)
|
||||
{
|
||||
foreach (string suffix in new[] { " Self", " Mastery" })
|
||||
if (buff.EndsWith(suffix, StringComparison.Ordinal)) buff = buff.Substring(0, buff.Length - suffix.Length);
|
||||
return buff;
|
||||
}
|
||||
|
||||
/// <summary>The skipped buffs grouped by reason, or "".</summary>
|
||||
public string FilterSkipSummary() => _filterSummary;
|
||||
|
||||
// One line per buff run (Force Rebuff, or the automatic batch starting). Same content as the
|
||||
// last line is held back for FilterSkipLogMinSec; different content prints at once. Reads the
|
||||
// skips of the BuildDynamicBuffList pass the caller just made.
|
||||
private void LogFilterSkips()
|
||||
{
|
||||
string summary = _filterSummary;
|
||||
if (summary.Length == 0) return;
|
||||
var now = DateTime.Now;
|
||||
if (summary == _filterSkipLoggedSummary && (now - _filterSkipLoggedAt).TotalSeconds < FilterSkipLogMinSec) return;
|
||||
_filterSkipLoggedAt = now;
|
||||
_filterSkipLoggedSummary = summary;
|
||||
_host.WriteToChat($"[RynthAi] Buff run skips {_filterSkips.Count} buff(s) this character can't use - {summary}", 1);
|
||||
_host.Log($"[Buff] filter skips: {summary}");
|
||||
}
|
||||
internal List<string> BuildDynamicBuffList()
|
||||
{
|
||||
bool filter = _settings.SkipUnusableBuffs;
|
||||
var skips = new List<(string Buff, string Reason)>();
|
||||
var step1_CreatureMastery = new List<string>();
|
||||
var step2_Focus = new List<string>();
|
||||
var step3_Willpower = new List<string>();
|
||||
var step3b_LifeMastery = new List<string>();
|
||||
var step4_OtherCreature = new List<string>();
|
||||
var step5_LifeAndItem = new List<string>();
|
||||
var step6_WeaponAuras = new List<string>();
|
||||
|
|
@ -3443,13 +3623,18 @@ public class BuffManager : IDisposable
|
|||
|
||||
foreach (var kvp in CreatureSkillBuffs)
|
||||
{
|
||||
if (IsSkillUsable(kvp.Key))
|
||||
if (!IsSkillUsable(kvp.Key))
|
||||
{
|
||||
if (kvp.Value.Contains("Creature Enchantment Mastery"))
|
||||
step1_CreatureMastery.Add(kvp.Value);
|
||||
else if (!BaseCreatureBuffs.Contains(kvp.Value))
|
||||
step4_OtherCreature.Add(kvp.Value);
|
||||
// Always left out (no skill, no mastery to cast); the setting only decides whether it is reported.
|
||||
if (filter && !BaseCreatureBuffs.Contains(kvp.Value)) skips.Add((kvp.Value, "skill untrained"));
|
||||
continue;
|
||||
}
|
||||
if (kvp.Value.Contains("Creature Enchantment Mastery"))
|
||||
step1_CreatureMastery.Add(kvp.Value);
|
||||
else if (kvp.Value == "Life Magic Mastery")
|
||||
step3b_LifeMastery.Add(kvp.Value);
|
||||
else if (!BaseCreatureBuffs.Contains(kvp.Value))
|
||||
step4_OtherCreature.Add(kvp.Value);
|
||||
}
|
||||
|
||||
step5_LifeAndItem.AddRange(new List<string> {
|
||||
|
|
@ -3460,10 +3645,22 @@ public class BuffManager : IDisposable
|
|||
"Bludgeoning Protection Self"
|
||||
});
|
||||
|
||||
step6_WeaponAuras.AddRange(new List<string> {
|
||||
var allAuras = new[] {
|
||||
"Blood Drinker Self", "Hermetic Link Self", "Heart Seeker Self",
|
||||
"Spirit Drinker Self", "Swift Killer Self", "Defender Self"
|
||||
});
|
||||
};
|
||||
if (filter)
|
||||
{
|
||||
var kit = ListedWeapons();
|
||||
foreach (string aura in allAuras)
|
||||
{
|
||||
string why = WeaponAuraSkipReason(aura, kit);
|
||||
if (why.Length == 0) step6_WeaponAuras.Add(aura);
|
||||
else skips.Add((aura, why));
|
||||
}
|
||||
}
|
||||
else
|
||||
step6_WeaponAuras.AddRange(allAuras);
|
||||
|
||||
step7_ArmorBanes.AddRange(new List<string> {
|
||||
"Impenetrability", "Acid Bane", "Blade Bane", "Bludgeoning Bane",
|
||||
|
|
@ -3474,6 +3671,7 @@ public class BuffManager : IDisposable
|
|||
final.AddRange(step1_CreatureMastery);
|
||||
final.AddRange(step2_Focus);
|
||||
final.AddRange(step3_Willpower);
|
||||
final.AddRange(step3b_LifeMastery); // the four that raise casting skill and mana come first
|
||||
final.AddRange(step4_OtherCreature);
|
||||
final.AddRange(step5_LifeAndItem);
|
||||
final.AddRange(step6_WeaponAuras);
|
||||
|
|
@ -3483,7 +3681,11 @@ public class BuffManager : IDisposable
|
|||
// the cast loop never casts them and NeedsAnyBuff never waits on them: a skipped buff
|
||||
// can't hold the bot in Buffing.
|
||||
if (_settings.DisabledBuffs.Count > 0)
|
||||
{
|
||||
final.RemoveAll(_settings.IsBuffDisabled);
|
||||
skips.RemoveAll(s => _settings.IsBuffDisabled(s.Buff)); // the player already turned these off
|
||||
}
|
||||
SetFilterSkips(skips);
|
||||
return final;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,15 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
private Func<string>? _autoVendorStatus;
|
||||
public void SetAutoVendorStatusProvider(Func<string> status) => _autoVendorStatus = status;
|
||||
|
||||
// Buffing page: the Force Buff button's actions and the list of buffs the unusable-buff
|
||||
// filter is leaving out (wired by RynthAiPlugin once the BuffManager exists).
|
||||
private Action? _forceBuff, _cancelBuff;
|
||||
private Func<string>? _buffSkips;
|
||||
public void SetBuffActions(Action? force, Action? cancel, Func<string>? skips)
|
||||
{
|
||||
_forceBuff = force; _cancelBuff = cancel; _buffSkips = skips;
|
||||
}
|
||||
|
||||
private Func<string>? _autoTradeStatus;
|
||||
public void SetAutoTradeStatusProvider(Func<string> status) => _autoTradeStatus = status;
|
||||
private string _newAutoAcceptPattern = "";
|
||||
|
|
@ -763,6 +772,27 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
"without waiting for the cast's recoil animation to end.\n" +
|
||||
"A refused cast turns it off for the rest of that buff pass.\n" +
|
||||
"On by default. Off = every buff waits for the animation.");
|
||||
ImGui.Checkbox("Skip buffs this character can't use", ref _settings.SkipUnusableBuffs);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(
|
||||
"Leave out Blood Drinker / Heart Seeker / Swift Killer when you have no melee or\n" +
|
||||
"missile weapon (listed or in hand), Spirit Drinker / Hermetic Link when you have no\n" +
|
||||
"wand, and Defender when you have neither. Masteries for untrained skills are\n" +
|
||||
"always skipped. On by default. Off = weapon enchantments are cast regardless of\n" +
|
||||
"listed weapons.");
|
||||
string skipped = _buffSkips?.Invoke() ?? "";
|
||||
if (_settings.SkipUnusableBuffs && skipped.Length > 0)
|
||||
ImGui.TextWrapped("Skipping: " + skipped);
|
||||
|
||||
ImGui.Spacing();
|
||||
if (ImGui.Button("Force Buff##forceBuff") && _forceBuff != null) _forceBuff();
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(
|
||||
"Recast every buff now, whatever time is left on it, starting with\n" +
|
||||
"Creature Enchantment, Focus, Willpower and Life Magic.\n" +
|
||||
"Same as /ra buff force (and the FR button).");
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("Cancel##cancelBuff") && _cancelBuff != null) _cancelBuff();
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Separator();
|
||||
|
|
|
|||
|
|
@ -297,6 +297,7 @@ internal sealed class LegacyDashboardRenderer
|
|||
|
||||
public void SetMissileCraftingManager(MissileCraftingManager mgr) => _advancedSettingsUi.SetMissileCraftingManager(mgr);
|
||||
public void SetAutoVendorStatusProvider(Func<string> status) => _advancedSettingsUi.SetAutoVendorStatusProvider(status);
|
||||
public void SetBuffActions(Action? force, Action? cancel, Func<string>? skips) => _advancedSettingsUi.SetBuffActions(force, cancel, skips);
|
||||
public void SetAutoTradeStatusProvider(Func<string> status) => _advancedSettingsUi.SetAutoTradeStatusProvider(status);
|
||||
|
||||
// The open vendor's AutoVendor profile path (null when no vendor is open), for the
|
||||
|
|
@ -1058,6 +1059,7 @@ internal sealed class LegacyDashboardRenderer
|
|||
RebuffSecondsRemaining = s.RebuffSecondsRemaining,
|
||||
RebuffTopOffSecondsRemaining = s.RebuffTopOffSecondsRemaining,
|
||||
CastBuffsOverItemBuffs = s.CastBuffsOverItemBuffs,
|
||||
SkipUnusableBuffs = s.SkipUnusableBuffs,
|
||||
DisabledBuffs = new List<string>(s.DisabledBuffs),
|
||||
BuffMinSkillLevelTier1 = s.BuffMinSkillLevelTier1,
|
||||
BuffMinSkillLevelTier2 = s.BuffMinSkillLevelTier2,
|
||||
|
|
@ -1272,6 +1274,7 @@ internal sealed class LegacyDashboardRenderer
|
|||
s.RebuffSecondsRemaining = p.RebuffSecondsRemaining;
|
||||
if (p.RebuffTopOffSecondsRemaining > 0) s.RebuffTopOffSecondsRemaining = p.RebuffTopOffSecondsRemaining;
|
||||
if (p.CastBuffsOverItemBuffs is bool castOverItems) s.CastBuffsOverItemBuffs = castOverItems; // absent = unchanged
|
||||
if (p.SkipUnusableBuffs is bool skipUnusable) s.SkipUnusableBuffs = skipUnusable; // absent = unchanged
|
||||
if (p.DisabledBuffs is { } disabledBuffs) s.DisabledBuffs = new List<string>(disabledBuffs); // absent = unchanged
|
||||
s.BuffMinSkillLevelTier1 = p.BuffMinSkillLevelTier1;
|
||||
s.BuffMinSkillLevelTier2 = p.BuffMinSkillLevelTier2;
|
||||
|
|
@ -1714,6 +1717,7 @@ internal sealed class LegacyDashboardRenderer
|
|||
dst.RebuffTopOffSecondsRemaining = tmp.RebuffTopOffSecondsRemaining;
|
||||
dst.CastBuffsOverItemBuffs = tmp.CastBuffsOverItemBuffs;
|
||||
dst.FastBuffChain = tmp.FastBuffChain;
|
||||
dst.SkipUnusableBuffs = tmp.SkipUnusableBuffs;
|
||||
dst.DisabledBuffs = tmp.DisabledBuffs;
|
||||
dst.BlacklistAttempts = tmp.BlacklistAttempts;
|
||||
dst.BlacklistTimeoutSec = tmp.BlacklistTimeoutSec;
|
||||
|
|
|
|||
|
|
@ -268,6 +268,15 @@ public sealed class LegacyUiSettings
|
|||
/// </summary>
|
||||
public bool FastBuffChain = true;
|
||||
/// <summary>
|
||||
/// Leave out the weapon enchantments this character has no use for: Blood Drinker / Heart Seeker /
|
||||
/// Swift Killer without a melee or missile weapon (listed or in hand), Spirit Drinker / Hermetic
|
||||
/// Link without a wand (listed, in hand, or the pack wand buffing would wield), Defender without
|
||||
/// either. Also reports, once per run, what was left out. On by default; a profile saved before
|
||||
/// this setting existed loads it as on. Off = the weapon enchantments are cast regardless of
|
||||
/// listed weapons. A mastery for an untrained skill is never cast, whatever this says.
|
||||
/// </summary>
|
||||
public bool SkipUnusableBuffs = true;
|
||||
/// <summary>
|
||||
/// Buff base names the player unticked in Buffing settings (the Protections and Banes grid,
|
||||
/// e.g. "Fire Protection Self", "Flame Bane"): left out of the buff list, so never cast and
|
||||
/// never waited on. Empty = every buff on, which is also what a profile saved before this
|
||||
|
|
@ -957,6 +966,7 @@ public sealed class SettingsBridgePayload
|
|||
// Nullable: an engine that predates the setting doesn't send it, and a save from its
|
||||
// Settings face must leave the setting alone rather than force it either way.
|
||||
public bool? CastBuffsOverItemBuffs { get; set; }
|
||||
public bool? SkipUnusableBuffs { get; set; }
|
||||
// Null (absent) likewise leaves the unticked prots/banes alone; an empty list ticks them all.
|
||||
public List<string>? DisabledBuffs { get; set; }
|
||||
public int BuffMinSkillLevelTier1 { get; set; }
|
||||
|
|
|
|||
|
|
@ -3597,6 +3597,7 @@ internal sealed class ExpressionEngine
|
|||
["RebuffTopOffSecondsRemaining"] = (() => I(s.RebuffTopOffSecondsRemaining), v => { if (int.TryParse(v, out int i)) s.RebuffTopOffSecondsRemaining = i; }),
|
||||
["CastBuffsOverItemBuffs"] = (() => B(s.CastBuffsOverItemBuffs), v => s.CastBuffsOverItemBuffs = ToDouble(v) != 0),
|
||||
["FastBuffChain"] = (() => B(s.FastBuffChain), v => s.FastBuffChain = ToDouble(v) != 0),
|
||||
["SkipUnusableBuffs"] = (() => B(s.SkipUnusableBuffs), v => s.SkipUnusableBuffs = ToDouble(v) != 0),
|
||||
// AutoVendor (UB names map here through /ub opt: AutoVendor.Enabled -> AutoVendorEnabled, ...)
|
||||
["AutoVendorEnabled"] = (() => B(s.AutoVendorEnabled), v => s.AutoVendorEnabled = ToDouble(v) != 0),
|
||||
["AutoVendorEnableBuying"] = (() => B(s.AutoVendorEnableBuying), v => s.AutoVendorEnableBuying = ToDouble(v) != 0),
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ public sealed partial class RynthAiPlugin
|
|||
ChatLine("[RynthAi] /ra panic — full AC state reset (cancel attack + peace mode + stop motion + clear busy)");
|
||||
ChatLine("[RynthAi] /ra forcebuff — force-recast all buffs immediately");
|
||||
ChatLine("[RynthAi] /ra cancelforcebuff — cancel an in-progress force rebuff");
|
||||
ChatLine("[RynthAi] /ra buff force|cancel|skipped - force buff, cancel it, or list buffs left out as unusable");
|
||||
ChatLine("[RynthAi] /ra bufftest — one-shot: snapshot enchant registries pre/post next item-spell cast (logs to RynthCore.log)");
|
||||
ChatLine("[RynthAi] /ra settings savechar <name> — save current settings to named profile (create if new)");
|
||||
ChatLine("[RynthAi] /ra settings loadchar <name> — load named settings profile (create from current if new)");
|
||||
|
|
@ -2251,6 +2252,32 @@ public sealed partial class RynthAiPlugin
|
|||
_buffManager.RequestForceFullRebuff(); // chat commands run on AC's thread; applied on the pump
|
||||
}
|
||||
|
||||
// /ra buff force | cancel | skipped: the same actions as /ra forcebuff, /ra cancelforcebuff
|
||||
// and the Force Buff button, plus the buffs the "Skip buffs this character can't use"
|
||||
// setting is leaving out right now.
|
||||
private void HandleBuffCommand(string[] parts)
|
||||
{
|
||||
string sub = parts.Length >= 3 ? parts[2].ToLowerInvariant() : "";
|
||||
switch (sub)
|
||||
{
|
||||
case "force": HandleForceBuff(); break;
|
||||
case "cancel": HandleCancelForceBuff(); break;
|
||||
case "skipped":
|
||||
if (_buffManager == null) { ChatLine("[RynthAi] Buff manager not ready."); break; }
|
||||
_buffManager.BuildDynamicBuffList(); // refresh the skip list
|
||||
string summary = _buffManager.FilterSkipSummary();
|
||||
ChatLine(summary.Length == 0
|
||||
? "[RynthAi] Buff filter: nothing is being skipped."
|
||||
: $"[RynthAi] Buff filter skips: {summary}");
|
||||
break;
|
||||
default:
|
||||
ChatLine("[RynthAi] /ra buff force - recast every buff now, whatever time is left");
|
||||
ChatLine("[RynthAi] /ra buff cancel - cancel an in-progress force buff");
|
||||
ChatLine("[RynthAi] /ra buff skipped - buffs left out because this character can't use them");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleCancelForceBuff()
|
||||
{
|
||||
if (_buffManager == null) { ChatLine("[RynthAi] Buff manager not ready."); return; }
|
||||
|
|
|
|||
|
|
@ -621,6 +621,8 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
// fires on the render thread and the exports on their caller's thread.
|
||||
_dashboard.OnForceRebuffRequested = () => _buffManager?.RequestForceFullRebuff();
|
||||
_dashboard.OnCancelForceRebuffRequested = () => _buffManager?.RequestCancelBuffing();
|
||||
_dashboard.SetBuffActions(() => _buffManager?.RequestForceFullRebuff(), () => _buffManager?.RequestCancelBuffing(),
|
||||
() => _buffManager?.FilterSkipSummary() ?? "");
|
||||
|
||||
// Override disk timers with live client memory — gets accurate remaining times
|
||||
// including login-restored enchantments the event hook missed at startup.
|
||||
|
|
@ -3289,6 +3291,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
case "panic": HandlePanicCommand(); break;
|
||||
case "forcebuff": HandleForceBuff(); break;
|
||||
case "cancelforcebuff": HandleCancelForceBuff(); break;
|
||||
case "buff": HandleBuffCommand(parts); break;
|
||||
case "bufftest":
|
||||
if (_buffManager == null) { ChatLine("[RynthAi] BuffManager not ready (not logged in yet)."); break; }
|
||||
_buffManager.EnableCastRegistryDiagnostic = !_buffManager.EnableCastRegistryDiagnostic;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Text.Json;
|
|||
using RynthCore.Loot;
|
||||
using RynthCore.Plugin.RynthAi;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.PluginCore;
|
||||
using RynthCore.PluginSdk;
|
||||
using RynthCore.RynthAiHostTests.Fakes;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
|
@ -58,6 +59,19 @@ internal static class BuffTests
|
|||
r.Add("buff toggles: an unticked prot or bane is never cast and never holds NeedsAnyBuff", UntickedSkipped);
|
||||
r.Add("buff toggles: an old profile loads all on; the list saves, copies and bridges", TogglesSetting);
|
||||
|
||||
r.Add("buff order: Creature Enchantment, Focus, Willpower, Life Magic come first", PriorityOrder);
|
||||
r.Add("buff order: a run casts them first, and a lone expiring buff is still just recast", PriorityCastOrderAndLoneExpiry);
|
||||
r.Add("force buff: recasts the whole filtered suite in order; without it nothing is cast", ForceBuffSuite);
|
||||
r.Add("force buff: /ra buff force and the button reach the same request", ForceBuffEntryPoints);
|
||||
r.Add("buff filter: a mastery for an untrained skill is never cast, trained is; the setting only controls the report", SkillFilter);
|
||||
r.Add("buff filter: weapon auras follow the registered melee/missile weapon or wand", WeaponFilter);
|
||||
r.Add("buff filter: an unlisted pack wand counts as a caster when WieldUnlistedWandWhenNoneListed is on", UnlistedWandCounts);
|
||||
r.Add("buff filter: an unclassifiable listed item, no cache, ammo, wielded weapons", KitEdgeCases);
|
||||
r.Add("buff filter: the skip line groups by reason, is capped, and repeats only when it changes", SkipLineGroupedAndCapped);
|
||||
r.Add("buff filter: the weapon kit is cached for a second, and rebuilt when its inputs change", KitCached);
|
||||
r.Add("buff filter: skipped buffs are named, once per run", FilterVisibility);
|
||||
r.Add("buff filter: SkipUnusableBuffs defaults on, loads, saves, bridges, is in the settings map", SkipUnusableSetting);
|
||||
|
||||
r.Add("buff choice: spell names the tables miss (Bludgeon Bane, Nuhmudira's, T'ing, Celdiseth's)", NameGapsResolve); // was a known failure; fixed by 940cb21
|
||||
r.Add("buff choice: a mastery whose name has several spell ids", MultiIdMastery); // was a known failure; fixed by 0aedcee
|
||||
r.Add("buff timers: tier-8 weapon auras last 90 minutes", TierEightAuras); // was a known failure; fixed by 9a317a8
|
||||
|
|
@ -120,11 +134,13 @@ internal static class BuffTests
|
|||
public readonly LegacyUiSettings S = new() { EnableBuffing = true };
|
||||
public readonly BuffManager B;
|
||||
public readonly SpellManager Sm;
|
||||
public readonly RynthCoreHost Host;
|
||||
|
||||
/// <summary>Call FakeHost.Reset(), set skills and the spellbook first.</summary>
|
||||
public BuffRig()
|
||||
{
|
||||
var host = FakeHost.Create();
|
||||
Host = host;
|
||||
var skills = Skills(host);
|
||||
Sm = NewSpells(host, S, skills);
|
||||
B = new BuffManager(host, S, Sm, new PlayerVitalsCache());
|
||||
|
|
@ -258,7 +274,8 @@ internal static class BuffTests
|
|||
ForceBuffTier(s, t);
|
||||
byTier[t] = NewSpells(host, s);
|
||||
}
|
||||
bm = new BuffManager(host, new LegacyUiSettings(), byTier[8], new PlayerVitalsCache());
|
||||
// The whole list, whatever this character could use (the unusable-buff filter is its own tests).
|
||||
bm = new BuffManager(host, new LegacyUiSettings { SkipUnusableBuffs = false }, byTier[8], new PlayerVitalsCache());
|
||||
var result = new List<(string, int, int)>();
|
||||
foreach (string buff in bm.BuildDynamicBuffList())
|
||||
{
|
||||
|
|
@ -633,7 +650,7 @@ internal static class BuffTests
|
|||
if (FakeHost.Casts.Count == before) { done = !acted; break; }
|
||||
string name = NameOf(FakeHost.Casts.Last().SpellId);
|
||||
cast.Add(name);
|
||||
rig.B.OnChatWindowText($"You cast {name} on {(name.Contains("Bane") ? "Rune Robe" : "yourself")}", 7);
|
||||
rig.B.OnChatWindowText($"You cast {name} on {(BuffManager.IsItemEnchantment(name) ? "Rune Robe" : "yourself")}", 7);
|
||||
}
|
||||
return cast;
|
||||
}
|
||||
|
|
@ -772,4 +789,438 @@ internal static class BuffTests
|
|||
Check.Eq(SpellTable.ById(496)?.Name, "Missile Weapon Mastery Self VI", "496 is a Missile Weapon Mastery Self VI");
|
||||
Check.Eq(sm.GetDynamicSelfBuffId("Missile Weapon Mastery", AcSkillType.CreatureEnchantment), 496, "resolves to the id the character knows");
|
||||
}
|
||||
|
||||
// -- Priority order, Force Buff and the unusable-buff filter ----
|
||||
|
||||
private const uint SkillHeavy = 44, SkillMissile = 47, SkillMagicDefense = 15;
|
||||
private const uint Sword = 0x80000401, Bow = 0x80000406, Wand = 0x80000408, Shield = 0x80000404;
|
||||
|
||||
/// <summary>Tier 6 Creature/Life/Item Magic, in Magic stance, knowing the head of the list, a
|
||||
/// couple of ordinary buffs and all six weapon auras. <paramref name="listed"/> are the items on
|
||||
/// the Items list (id, name, ItemType: 0x1 melee, 0x100 missile, 0x8000 caster, 0x2 shield).</summary>
|
||||
private static BuffRig SuiteRig(params (uint Id, string Name, uint ItemType)[] listed)
|
||||
{
|
||||
FakeHost.Reset();
|
||||
Know("Creature Enchantment Mastery Self VI", "Focus Self VI", "Willpower Self VI", "Life Magic Mastery Self VI",
|
||||
"Strength Self VI", "Heavy Weapon Mastery Self VI", "Armor Self VI",
|
||||
"Aura of Blood Drinker Self VI", "Aura of Hermetic Link Self VI", "Aura of Heart Seeker Self VI",
|
||||
"Aura of Spirit Drinker Self VI", "Aura of Swift Killer Self VI", "Aura of Defender Self VI");
|
||||
FakeHost.Skills[(Player, STypeCreature)] = (300, 2);
|
||||
FakeHost.Skills[(Player, STypeLife)] = (300, 2);
|
||||
FakeHost.Skills[(Player, STypeItem)] = (300, 2);
|
||||
FakeHost.WeaponCalls = true;
|
||||
FakeHost.CombatModeValue = CombatMode.Magic;
|
||||
foreach (var (id, name, type) in listed)
|
||||
{
|
||||
FakeHost.Names[id] = name;
|
||||
FakeHost.ItemTypes[id] = type;
|
||||
FakeHost.Ints[(id, 9)] = type == 0x2 ? 0x00200000 : type == 0x8000 ? 0x01000000 : type == 0x100 ? 0x00400000 : 0x00100000;
|
||||
}
|
||||
var rig = new BuffRig();
|
||||
rig.S.ItemRules = listed.Select(l => new ItemRule
|
||||
{
|
||||
Id = unchecked((int)l.Id), Name = l.Name, Element = "", ElementSource = "",
|
||||
Action = l.ItemType == 0x2 ? WeaponList.ShieldAction : "Weapon",
|
||||
}).ToList();
|
||||
rig.B.SetWorldObjectCache(FakeHost.MakeCache(rig.Host, Player, listed.Select(l => l.Id))); // even with nothing listed: the empty-pack path runs
|
||||
return rig;
|
||||
}
|
||||
|
||||
private static readonly (uint, string, uint) MeleeItem = (Sword, "Long Sword", 0x1);
|
||||
private static readonly (uint, string, uint) BowItem = (Bow, "Longbow", 0x100);
|
||||
private static readonly (uint, string, uint) WandItem = (Wand, "Wand", 0x8000);
|
||||
private static readonly (uint, string, uint) ShieldItem = (Shield, "Kite Shield", 0x2);
|
||||
|
||||
private static readonly string[] Head =
|
||||
{ "Creature Enchantment Mastery", "Focus Self", "Willpower Self", "Life Magic Mastery" };
|
||||
|
||||
/// <summary>Every buff the rig knows, on with plenty of time left (item auras by chat).</summary>
|
||||
private static void AllOn(BuffRig rig, params string[] except)
|
||||
{
|
||||
var live = new[] { "Creature Enchantment Mastery Self VI", "Focus Self VI", "Willpower Self VI", "Life Magic Mastery Self VI",
|
||||
"Strength Self VI", "Heavy Weapon Mastery Self VI", "Armor Self VI" }
|
||||
.Where(n => !except.Contains(n)).Select(n => (n, 3000.0)).ToArray();
|
||||
rig.Live(live);
|
||||
foreach (string aura in new[] { "Blood Drinker", "Hermetic Link", "Heart Seeker", "Spirit Drinker", "Swift Killer", "Defender" })
|
||||
rig.B.OnChatWindowText($"You cast Aura of {aura} Self VI on Rune Sword", 7);
|
||||
}
|
||||
|
||||
private static void PriorityOrder()
|
||||
{
|
||||
var rig = SuiteRig(MeleeItem, WandItem);
|
||||
var list = rig.B.BuildDynamicBuffList();
|
||||
Check.Eq(string.Join(", ", list.Take(4)), string.Join(", ", Head), "Creature Enchantment, Focus, Willpower, Life Magic first");
|
||||
int strength = list.IndexOf("Strength Self"), heavy = list.IndexOf("Heavy Weapon Mastery"), armor = list.IndexOf("Armor Self");
|
||||
Check.True(strength == 4, $"everything else follows, Strength next (at {strength})");
|
||||
Check.True(strength < heavy && heavy < armor, "and keeps its old order (attributes, masteries, prots)");
|
||||
Check.True(list.IndexOf("Blood Drinker Self") > armor, "weapon auras stay after the prots");
|
||||
|
||||
// The head is the head with every skill trained or not: an untrained Life Magic just isn't there.
|
||||
var noLifeRig = SuiteRig(MeleeItem);
|
||||
FakeHost.Skills[(Player, STypeLife)] = (10, 1);
|
||||
var noLife = noLifeRig.B.BuildDynamicBuffList();
|
||||
Check.Eq(string.Join(", ", noLife.Take(3)), string.Join(", ", Head.Take(3)), "head without Life Magic");
|
||||
Check.False(noLife.Contains("Life Magic Mastery"), "untrained Life Magic: no Life Magic Mastery");
|
||||
}
|
||||
|
||||
private static void PriorityCastOrderAndLoneExpiry()
|
||||
{
|
||||
// A full run on a character with nothing on: the head goes out first, in order.
|
||||
var rig = SuiteRig(MeleeItem);
|
||||
rig.Live(("Strength Self I", 3000)); // a registry read, with none of the suite on
|
||||
rig.B.ForceFullRebuff();
|
||||
var cast = CastAll(rig, out bool done);
|
||||
Check.Eq(string.Join(", ", cast.Take(4)),
|
||||
"Creature Enchantment Mastery Self VI, Focus Self VI, Willpower Self VI, Life Magic Mastery Self VI",
|
||||
$"the four first (last skip: {rig.B.LastBuffSkipReason})");
|
||||
Check.Eq(cast.Count, 11, $"then the rest: {string.Join(", ", cast)}");
|
||||
Check.True(done, "and the run ends");
|
||||
|
||||
// The automatic batch recasts a lone expiring buff alone: timers still drive it.
|
||||
var lone = SuiteRig(MeleeItem);
|
||||
AllOn(lone, "Strength Self VI");
|
||||
lone.Live(("Creature Enchantment Mastery Self VI", 3000), ("Focus Self VI", 3000), ("Willpower Self VI", 3000),
|
||||
("Life Magic Mastery Self VI", 3000), ("Strength Self VI", 200), ("Heavy Weapon Mastery Self VI", 3000), ("Armor Self VI", 3000));
|
||||
Check.True(lone.B.NeedsAnyBuff(), "Strength is under the rebuff line");
|
||||
cast = CastAll(lone, out done);
|
||||
Check.Eq(string.Join(", ", cast), "Strength Self VI", "only the expiring buff is recast");
|
||||
|
||||
// ... and when a priority buff is the one expiring, it is the one cast.
|
||||
var head = SuiteRig(MeleeItem);
|
||||
AllOn(head);
|
||||
head.Live(("Creature Enchantment Mastery Self VI", 200), ("Focus Self VI", 3000), ("Willpower Self VI", 3000),
|
||||
("Life Magic Mastery Self VI", 3000), ("Strength Self VI", 3000), ("Heavy Weapon Mastery Self VI", 3000), ("Armor Self VI", 3000));
|
||||
cast = CastAll(head, out done);
|
||||
Check.Eq(string.Join(", ", cast), "Creature Enchantment Mastery Self VI", "a lone expiring priority buff: just it");
|
||||
}
|
||||
|
||||
private static void ForceBuffSuite()
|
||||
{
|
||||
var rig = SuiteRig(MeleeItem);
|
||||
AllOn(rig);
|
||||
Check.False(rig.B.NeedsAnyBuff(), "everything has long timers: nothing due");
|
||||
var none = CastAll(rig, out bool done);
|
||||
Check.Eq(none.Count, 0, $"without force nothing is cast ({string.Join(", ", none)})");
|
||||
Check.True(done, "and the loop is idle");
|
||||
|
||||
rig.B.ForceFullRebuff();
|
||||
Check.True(rig.B.NeedsAnyBuff(), "force: everything is due");
|
||||
var cast = CastAll(rig, out done);
|
||||
Check.Eq(string.Join(", ", cast),
|
||||
"Creature Enchantment Mastery Self VI, Focus Self VI, Willpower Self VI, Life Magic Mastery Self VI, " +
|
||||
"Strength Self VI, Heavy Weapon Mastery Self VI, Armor Self VI, " +
|
||||
"Aura of Blood Drinker Self VI, Aura of Heart Seeker Self VI, Aura of Swift Killer Self VI, Aura of Defender Self VI",
|
||||
"the whole filtered suite, in priority order; Spirit Drinker and Hermetic Link (no wand) are not in it");
|
||||
Check.True(done, "and finishes");
|
||||
|
||||
// Cancel ends a run in progress.
|
||||
var c = SuiteRig(MeleeItem);
|
||||
AllOn(c);
|
||||
c.B.ForceFullRebuff();
|
||||
Check.True(c.B.GetStateSnapshot().IsForceRebuffing, "force run under way");
|
||||
c.B.CancelBuffing();
|
||||
Check.False(c.B.GetStateSnapshot().IsForceRebuffing, "cancelled: the run is over");
|
||||
}
|
||||
|
||||
private static void ForceBuffEntryPoints()
|
||||
{
|
||||
// /ra buff force runs the command handler: one request, applied on the next heartbeat.
|
||||
var rig = SuiteRig(MeleeItem);
|
||||
AllOn(rig);
|
||||
var plugin = new RynthAiPlugin();
|
||||
typeof(RynthPluginBase).GetMethod("Attach", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)!
|
||||
.Invoke(plugin, new object[] { FakeHost.LastApi });
|
||||
typeof(RynthAiPlugin).GetField("_buffManager", BindingFlags.Instance | BindingFlags.NonPublic)!.SetValue(plugin, rig.B);
|
||||
void Cmd(params string[] words) => typeof(RynthAiPlugin).GetMethod("HandleBuffCommand", BindingFlags.Instance | BindingFlags.NonPublic)!
|
||||
.Invoke(plugin, new object[] { new[] { "/ra", "buff" }.Concat(words).ToArray() });
|
||||
|
||||
rig.B.MarkLiveBuffsReadyForTests();
|
||||
Cmd("force");
|
||||
Check.False(rig.B.GetStateSnapshot().IsForceRebuffing, "the command only queues the request");
|
||||
rig.B.OnHeartbeat();
|
||||
Check.True(rig.B.GetStateSnapshot().IsForceRebuffing, "the next heartbeat starts the force run");
|
||||
Check.True(FakeHost.Chat.Any(c => c.Contains("Starting Force Rebuff")), "and says so");
|
||||
|
||||
Cmd("cancel");
|
||||
rig.B.OnHeartbeat();
|
||||
Check.False(rig.B.GetStateSnapshot().IsForceRebuffing, "/ra buff cancel ends it");
|
||||
|
||||
FakeHost.Chat.Clear();
|
||||
Cmd("skipped");
|
||||
Check.True(FakeHost.Chat.Any(c => c.Contains("Buff filter")), "/ra buff skipped answers");
|
||||
FakeHost.Chat.Clear();
|
||||
Cmd();
|
||||
Check.True(FakeHost.Chat.Any(c => c.Contains("/ra buff force")), "no word: the help");
|
||||
}
|
||||
private static void SkillFilter()
|
||||
{
|
||||
var trained = SuiteRig(MeleeItem);
|
||||
Check.True(trained.B.BuildDynamicBuffList().Contains("Heavy Weapon Mastery"), "Heavy Weapons trained: its mastery is cast");
|
||||
|
||||
FakeHost.Reset();
|
||||
var rig = SuiteRig(MeleeItem);
|
||||
FakeHost.Skills[(Player, SkillHeavy)] = (10, 1); // untrained
|
||||
FakeHost.Skills[(Player, SkillMagicDefense)] = (5, 1);
|
||||
var list = rig.B.BuildDynamicBuffList();
|
||||
Check.False(list.Contains("Heavy Weapon Mastery"), "Heavy Weapons untrained: its mastery is skipped");
|
||||
Check.True(list.Contains("Strength Self") && list.Contains("Armor Self"), "attribute and vital/prot buffs are untouched");
|
||||
Check.True(list.Contains("Magic Resistance Self"), "magic defense is not filtered even when untrained");
|
||||
Check.True(rig.B.FilterSkips.Any(s => s.Buff == "Heavy Weapon Mastery" && s.Reason == "skill untrained"), "and the skip is recorded");
|
||||
|
||||
rig.S.SkipUnusableBuffs = false;
|
||||
Check.False(rig.B.BuildDynamicBuffList().Contains("Heavy Weapon Mastery"), "filter off: an untrained skill' mastery is still never cast");
|
||||
Check.Eq(rig.B.FilterSkips.Count, 0, "filter off: nothing is reported either");
|
||||
|
||||
// The cast loop agrees: untrained and filtered, the mastery is never cast.
|
||||
var run = SuiteRig(MeleeItem);
|
||||
FakeHost.Skills[(Player, SkillHeavy)] = (10, 1);
|
||||
run.Live(("Strength Self I", 3000));
|
||||
run.B.ForceFullRebuff();
|
||||
Check.False(CastAll(run, out _).Contains("Heavy Weapon Mastery Self VI"), "the cast loop skips it too");
|
||||
var off = SuiteRig(MeleeItem);
|
||||
off.S.SkipUnusableBuffs = false;
|
||||
FakeHost.Skills[(Player, SkillHeavy)] = (10, 1);
|
||||
off.Live(("Strength Self I", 3000));
|
||||
off.B.ForceFullRebuff();
|
||||
Check.False(CastAll(off, out _).Contains("Heavy Weapon Mastery Self VI"), "filter off: the cast loop still skips an untrained mastery");
|
||||
}
|
||||
|
||||
private static string[] AuraList(BuffRig rig) =>
|
||||
rig.B.BuildDynamicBuffList().Where(b => b is "Blood Drinker Self" or "Heart Seeker Self" or "Swift Killer Self"
|
||||
or "Spirit Drinker Self" or "Hermetic Link Self" or "Defender Self").ToArray();
|
||||
|
||||
private static void WeaponFilter()
|
||||
{
|
||||
const string phys = "Blood Drinker Self, Heart Seeker Self, Swift Killer Self";
|
||||
string Join(IEnumerable<string> a) => string.Join(", ", a);
|
||||
|
||||
var wand = SuiteRig(WandItem);
|
||||
Check.Eq(Join(AuraList(wand)), "Hermetic Link Self, Spirit Drinker Self, Defender Self", "only a wand: Spirit Drinker, Hermetic Link, Defender");
|
||||
var melee = SuiteRig(MeleeItem);
|
||||
Check.Eq(Join(AuraList(melee)), "Blood Drinker Self, Heart Seeker Self, Swift Killer Self, Defender Self", "a melee weapon: Blood Drinker, Heart Seeker, Swift Killer, Defender");
|
||||
Check.True(Join(AuraList(melee)).StartsWith(phys), "Blood Drinker is cast with a melee weapon");
|
||||
var bow = SuiteRig(BowItem);
|
||||
Check.Eq(Join(AuraList(bow)), "Blood Drinker Self, Heart Seeker Self, Swift Killer Self, Defender Self", "a missile weapon counts as physical");
|
||||
var both = SuiteRig(MeleeItem, WandItem);
|
||||
Check.Eq(AuraList(both).Length, 6, "melee and a wand: all six");
|
||||
var none = SuiteRig();
|
||||
Check.Eq(AuraList(none).Length, 0, "nothing registered: every weapon aura is skipped");
|
||||
var shield = SuiteRig(ShieldItem);
|
||||
Check.Eq(AuraList(shield).Length, 0, "a shield alone is no weapon");
|
||||
|
||||
none.S.SkipUnusableBuffs = false;
|
||||
Check.Eq(AuraList(none).Length, 6, "filter off: all six again");
|
||||
|
||||
// A listed item the object cache can't place yet doesn't hide anything.
|
||||
var unknown = SuiteRig();
|
||||
unknown.S.ItemRules = new List<ItemRule> { new() { Id = 0x7FFFFFF1, Name = "Mystery", Action = "Weapon", Element = "", ElementSource = "" } };
|
||||
Check.Eq(AuraList(unknown).Length, 6, "a listed weapon we can't classify yet: nothing filtered");
|
||||
|
||||
// The reasons, named.
|
||||
var kit = new BuffManager.ListedWeaponKit(false, true, false);
|
||||
Check.Eq(BuffManager.WeaponAuraSkipReason("Blood Drinker Self", kit), "no melee or missile weapon listed", "reason, physical aura");
|
||||
Check.Eq(BuffManager.WeaponAuraSkipReason("Spirit Drinker Self", kit), "", "wand: Spirit Drinker stays");
|
||||
Check.Eq(BuffManager.WeaponAuraSkipReason("Impenetrability", kit), "", "other buffs have no weapon rule");
|
||||
}
|
||||
|
||||
private static void UnlistedWandCounts()
|
||||
{
|
||||
string Join(IEnumerable<string> a) => string.Join(", ", a);
|
||||
// A wand in the pack, the Items list empty.
|
||||
var rig = SuiteRig(WandItem);
|
||||
rig.S.ItemRules = new List<ItemRule>();
|
||||
rig.S.WieldUnlistedWandWhenNoneListed = true;
|
||||
Check.Eq(Join(AuraList(rig)), "Hermetic Link Self, Spirit Drinker Self, Defender Self", "unlisted wand mode on, wand in the pack: caster auras cast");
|
||||
rig.S.WieldUnlistedWandWhenNoneListed = false;
|
||||
Check.Eq(AuraList(rig).Length, 0, "setting off: every weapon aura skipped");
|
||||
|
||||
// Physical auras still need a listed melee or missile weapon.
|
||||
var mixed = SuiteRig(MeleeItem, WandItem);
|
||||
mixed.S.ItemRules = mixed.S.ItemRules.Where(x => x.Id == unchecked((int)Sword)).ToList(); // wand in the pack, only the sword listed
|
||||
mixed.S.WieldUnlistedWandWhenNoneListed = true;
|
||||
Check.Eq(AuraList(mixed).Length, 6, "sword listed + unlisted pack wand: all six");
|
||||
mixed.S.WieldUnlistedWandWhenNoneListed = false;
|
||||
Check.Eq(Join(AuraList(mixed)), "Blood Drinker Self, Heart Seeker Self, Swift Killer Self, Defender Self", "setting off: the sword's auras only");
|
||||
|
||||
// On, but no wand anywhere: nothing to wield, so nothing counts.
|
||||
var empty = SuiteRig();
|
||||
empty.S.WieldUnlistedWandWhenNoneListed = true;
|
||||
Check.Eq(AuraList(empty).Length, 0, "on, but no wand available: skipped");
|
||||
}
|
||||
|
||||
private static void FilterVisibility()
|
||||
{
|
||||
var rig = SuiteRig(WandItem);
|
||||
FakeHost.Skills[(Player, SkillHeavy)] = (10, 1);
|
||||
rig.Live(("Strength Self I", 3000));
|
||||
rig.B.ForceFullRebuff();
|
||||
rig.B.ForceFullRebuff(); // a restart straight away
|
||||
var lines = FakeHost.Logs.Where(l => l.Contains("[Buff] filter skips:")).ToList();
|
||||
Check.Eq(lines.Count, 1, "one skip line for two runs inside the rate limit");
|
||||
Check.True(lines[0].Contains("skill untrained: ") && lines[0].Contains("Heavy Weapon"), "it names the untrained mastery and why: " + lines[0]);
|
||||
Check.True(lines[0].Contains("no melee or missile weapon listed: Blood Drinker"), "and the weapon aura and why: " + lines[0]);
|
||||
Check.False(lines[0].Contains("Spirit Drinker"), "but not what stays");
|
||||
Check.True(FakeHost.Chat.Any(c => c.Contains("Buff run skips")), "the same line goes to chat");
|
||||
Check.True(rig.B.FilterSkipSummary().Contains("Swift Killer"), "the settings page reads the same list");
|
||||
|
||||
// The automatic batch logs it too, once.
|
||||
var auto = SuiteRig(WandItem);
|
||||
FakeHost.Skills[(Player, SkillHeavy)] = (10, 1);
|
||||
AllOn(auto, "Strength Self VI");
|
||||
auto.Live(("Creature Enchantment Mastery Self VI", 3000), ("Strength Self VI", 200));
|
||||
CastAll(auto, out _);
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("[Buff] filter skips:")), 1, "an automatic run logs the skips once");
|
||||
|
||||
// Nothing to skip, nothing said.
|
||||
var clean = SuiteRig(MeleeItem, WandItem);
|
||||
clean.Live(("Strength Self I", 3000));
|
||||
clean.B.ForceFullRebuff();
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("[Buff] filter skips:")), 0, "nothing skipped: no line");
|
||||
}
|
||||
|
||||
private static void KitEdgeCases()
|
||||
{
|
||||
// A listed item the cache keeps unclassified (a Misc-typed thing): nothing is filtered.
|
||||
const uint Odd = 0x80000411;
|
||||
FakeHost.Reset();
|
||||
var odd = SuiteRig();
|
||||
FakeHost.Names[Odd] = "Mystery Thing";
|
||||
FakeHost.ItemTypes[Odd] = 0;
|
||||
odd.B.SetWorldObjectCache(FakeHost.MakeCache(odd.Host, Player, new[] { Odd }));
|
||||
odd.S.ItemRules = new List<ItemRule> { new() { Id = unchecked((int)Odd), Name = "Mystery Thing", Action = "Weapon", Element = "", ElementSource = "" } };
|
||||
var cls = odd.B.ListedWeapons();
|
||||
Check.True(cls.Unknown, $"the odd item stays unclassified (kit {cls})");
|
||||
Check.Eq(AuraList(odd).Length, 6, "an unclassifiable listed item: all six auras kept");
|
||||
|
||||
// No cache at all, nothing listed: can't tell, so nothing is filtered.
|
||||
FakeHost.Reset();
|
||||
Know("Aura of Blood Drinker Self VI");
|
||||
var bare = new BuffRig();
|
||||
Check.Eq(AuraList(bare).Length, 6, "no object cache: nothing filtered");
|
||||
|
||||
// Only ammo listed: not a weapon.
|
||||
const uint Arrows = 0x80000407;
|
||||
FakeHost.Reset();
|
||||
var ammo = SuiteRig();
|
||||
FakeHost.Names[Arrows] = "Arrow";
|
||||
FakeHost.ItemTypes[Arrows] = 0x100;
|
||||
FakeHost.Ints[(Arrows, 9)] = 0x00800000;
|
||||
ammo.B.SetWorldObjectCache(FakeHost.MakeCache(ammo.Host, Player, new[] { Arrows }));
|
||||
ammo.S.ItemRules = new List<ItemRule> { new() { Id = unchecked((int)Arrows), Name = "Arrow", Action = "Weapon", Element = "", ElementSource = "" } };
|
||||
var k = ammo.B.ListedWeapons();
|
||||
Check.False(k.Physical, "ammo is no physical weapon");
|
||||
Check.Eq(AuraList(ammo).Length, 0, "ammo-only list (and nothing else): every weapon aura skipped");
|
||||
|
||||
// Wielded weapons count with an empty Items list.
|
||||
var sword = SuiteRig(MeleeItem);
|
||||
sword.S.ItemRules = new List<ItemRule>();
|
||||
sword.S.WieldUnlistedWandWhenNoneListed = false;
|
||||
Check.Eq(AuraList(sword).Length, 0, "control: sword in the pack, not wielded, nothing listed: skipped");
|
||||
sword = SuiteRig(MeleeItem);
|
||||
sword.S.ItemRules = new List<ItemRule>();
|
||||
sword.S.WieldUnlistedWandWhenNoneListed = false;
|
||||
FakeHost.Ints[(Sword, 10)] = 0x00100000; // wielded in the melee slot
|
||||
Check.Eq(string.Join(", ", AuraList(sword)), "Blood Drinker Self, Heart Seeker Self, Swift Killer Self, Defender Self", "wielded sword, empty Items list: physical auras and Defender");
|
||||
|
||||
var wand = SuiteRig(WandItem);
|
||||
wand.S.ItemRules = new List<ItemRule>();
|
||||
wand.S.WieldUnlistedWandWhenNoneListed = false;
|
||||
FakeHost.Ints[(Wand, 10)] = 0x01000000; // wielded in the held slot
|
||||
Check.Eq(string.Join(", ", AuraList(wand)), "Hermetic Link Self, Spirit Drinker Self, Defender Self", "wielded wand, empty Items list: caster auras and Defender");
|
||||
}
|
||||
|
||||
private static void SkipLineGroupedAndCapped()
|
||||
{
|
||||
var rig = SuiteRig(WandItem);
|
||||
foreach (AcSkillType sk in Enum.GetValues<AcSkillType>())
|
||||
{
|
||||
uint st = CharacterSkills.AcSkillTypeToSTypeSkill(sk);
|
||||
if (st == 0 || st == STypeCreature || st == STypeLife || st == STypeItem) continue;
|
||||
FakeHost.Skills[(Player, st)] = (5, 1);
|
||||
}
|
||||
rig.Live(("Strength Self I", 3000));
|
||||
rig.B.ForceFullRebuff();
|
||||
var lines = FakeHost.Logs.Where(l => l.Contains("[Buff] filter skips:")).ToList();
|
||||
Check.Eq(lines.Count, 1, "one line");
|
||||
string line = lines[0].Substring(lines[0].IndexOf("skips:", StringComparison.Ordinal) + 7);
|
||||
Check.True(line.Length <= 200, $"{line.Length} chars: {line}");
|
||||
Check.True(line.Contains("more)"), "the long group is capped: " + line);
|
||||
Check.True(line.Contains("no melee or missile weapon listed: Blood Drinker, Heart Seeker, Swift Killer"), "the weapon-aura skip is still named: " + line);
|
||||
|
||||
// The same content again inside 30 s: held back. A change prints at once.
|
||||
rig.B.ForceFullRebuff();
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("[Buff] filter skips:")), 1, "same content: no second line");
|
||||
rig.S.ItemRules = new List<ItemRule> { new() { Id = unchecked((int)Sword), Name = "Long Sword", Action = "Weapon", Element = "", ElementSource = "" } };
|
||||
FakeHost.Ints[(Sword, 9)] = 0x00100000; FakeHost.Names[Sword] = "Long Sword"; FakeHost.ItemTypes[Sword] = 0x1;
|
||||
rig.B.SetWorldObjectCache(FakeHost.MakeCache(rig.Host, Player, new[] { Sword, Wand }));
|
||||
rig.B.ForceFullRebuff();
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("[Buff] filter skips:")), 2, "different content prints at once");
|
||||
|
||||
// The summary string is built once per change.
|
||||
string a = rig.B.FilterSkipSummary(), b = rig.B.FilterSkipSummary();
|
||||
Check.True(ReferenceEquals(a, b), "cached summary");
|
||||
}
|
||||
|
||||
private static void KitCached()
|
||||
{
|
||||
var rig = SuiteRig(MeleeItem);
|
||||
long now = 10_000;
|
||||
rig.B.KitClockMs = () => now;
|
||||
for (int i = 0; i < 100; i++) rig.B.BuildDynamicBuffList();
|
||||
Check.Eq(rig.B.KitComputations, 1, "100 passes inside a second: one computation");
|
||||
now += 1_500;
|
||||
rig.B.BuildDynamicBuffList();
|
||||
Check.Eq(rig.B.KitComputations, 2, "after the TTL: again");
|
||||
rig.S.ItemRules = new List<ItemRule>(rig.S.ItemRules);
|
||||
rig.B.BuildDynamicBuffList();
|
||||
Check.Eq(rig.B.KitComputations, 3, "a new Items list: again, before the TTL");
|
||||
rig.S.ItemRules.Add(new ItemRule { Id = 1, Name = "x", Action = "Weapon" });
|
||||
rig.B.BuildDynamicBuffList();
|
||||
Check.Eq(rig.B.KitComputations, 4, "an item added in place: again");
|
||||
rig.S.WieldUnlistedWandWhenNoneListed = !rig.S.WieldUnlistedWandWhenNoneListed;
|
||||
rig.B.BuildDynamicBuffList();
|
||||
Check.Eq(rig.B.KitComputations, 5, "the unlisted-wand setting flipped: again");
|
||||
rig.B.BuildDynamicBuffList();
|
||||
Check.Eq(rig.B.KitComputations, 5, "and then cached");
|
||||
}
|
||||
|
||||
private static void SkipUnusableSetting()
|
||||
{
|
||||
Check.True(new LegacyUiSettings().SkipUnusableBuffs, "a new profile: on");
|
||||
var old = JsonSerializer.Deserialize("{\"EnableBuffing\":true,\"RebuffSecondsRemaining\":300}", RynthAiJsonContext.Default.LegacyUiSettings);
|
||||
Check.True(old != null && old.SkipUnusableBuffs, "a profile saved before the setting: on");
|
||||
var off = JsonSerializer.Deserialize(
|
||||
JsonSerializer.Serialize(new LegacyUiSettings { SkipUnusableBuffs = false }, RynthAiJsonContext.Default.LegacyUiSettings),
|
||||
RynthAiJsonContext.Default.LegacyUiSettings);
|
||||
Check.True(off != null && !off.SkipUnusableBuffs, "off is saved and loaded");
|
||||
|
||||
var copy = typeof(LegacyDashboardRenderer).GetMethod("CopySettings", BindingFlags.NonPublic | BindingFlags.Static)!;
|
||||
var dst = new LegacyUiSettings();
|
||||
copy.Invoke(null, new object[] { new LegacyUiSettings { SkipUnusableBuffs = false }, dst });
|
||||
Check.False(dst.SkipUnusableBuffs, "a profile with it off loads off");
|
||||
copy.Invoke(null, new object[] { old!, dst });
|
||||
Check.True(dst.SkipUnusableBuffs, "an old profile loads on");
|
||||
|
||||
var payload = JsonSerializer.Deserialize("{\"PatrolOnLogin\":false}", RynthAiJsonContext.Default.SettingsBridgePayload);
|
||||
Check.True(payload != null && payload.SkipUnusableBuffs == null, "an older engine's payload has no value");
|
||||
var s = new LegacyUiSettings { SkipUnusableBuffs = false };
|
||||
var dash = (LegacyDashboardRenderer)RuntimeHelpers.GetUninitializedObject(typeof(LegacyDashboardRenderer));
|
||||
typeof(LegacyDashboardRenderer).GetField("_settings", BindingFlags.NonPublic | BindingFlags.Instance)!.SetValue(dash, s);
|
||||
typeof(LegacyDashboardRenderer).GetField("_advancedSettingsUi", BindingFlags.NonPublic | BindingFlags.Instance)!
|
||||
.SetValue(dash, new LegacyAdvancedSettingsUi(s));
|
||||
var sent = JsonSerializer.Deserialize(dash.BuildSettingsJson(), RynthAiJsonContext.Default.SettingsBridgePayload);
|
||||
Check.True(sent != null && sent.SkipUnusableBuffs == false, "sent to the engine face");
|
||||
dash.ApplySettingsJson("{\"PatrolOnLogin\":false}");
|
||||
Check.False(s.SkipUnusableBuffs, "a save without the field leaves it off");
|
||||
dash.ApplySettingsJson("{\"SkipUnusableBuffs\":true}");
|
||||
Check.True(s.SkipUnusableBuffs, "a save with it on turns it on");
|
||||
|
||||
// The settings map the meta engine (and /ra settings) reads.
|
||||
var live = new LegacyUiSettings();
|
||||
var map = ExpressionTests.Engine(settings: live).BuildSettingsMapPublic();
|
||||
Check.True(map.TryGetValue("SkipUnusableBuffs", out var entry), "SkipUnusableBuffs is in the settings map");
|
||||
Check.Eq(entry.Get(), "1", "reads on");
|
||||
entry.Set("0");
|
||||
Check.False(live.SkipUnusableBuffs, "and sets off");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue