Snapshot for release 2026.10.28.2 (internal 48c46bd)
This commit is contained in:
parent
b23cabc338
commit
636adfcef2
41 changed files with 3402 additions and 120 deletions
|
|
@ -120,7 +120,7 @@ public partial class BuffManager
|
|||
}
|
||||
_bowDequipAttempts++;
|
||||
if (_worldObjectCache?[bowId] is WorldObject blocker && IsInOffhandSlot(blocker))
|
||||
OffhandStowed?.Invoke(bowId); // a shield: combat puts it back after
|
||||
OffhandPutAway(bowId); // a shield: combat puts it back after (and it is buffed in the pack)
|
||||
_host.MoveItemInternal((uint)bowId, (uint)openPack, 0, 1); // amount>=1 (engine rejects 0)
|
||||
_weaponSwapGate?.NoteMove(bowId, wieldedNow: true);
|
||||
_bowDequipPendingId = bowId;
|
||||
|
|
|
|||
549
Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.Shield.cs
Normal file
549
Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.Shield.cs
Normal file
|
|
@ -0,0 +1,549 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using RynthCore.PluginSdk;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi;
|
||||
|
||||
/// <summary>
|
||||
/// The shield's armor spells (2026-10-28). Impenetrability and the seven Banes are cast on the
|
||||
/// player, and ACE puts them on every worn piece of armor and a worn shield
|
||||
/// (WorldObject_Magic.TryCastItemEnchantment_WithRedirects). But buffing holds a wand, and ACE won't
|
||||
/// wield a caster beside a shield: the wand swap puts the shield into a pack first, so the
|
||||
/// self-cast never reached it. The shield now gets its own casts, aimed at it, after the armor's.
|
||||
///
|
||||
/// * Which shield: one in the Items list (the Shield action, or a shield filed as a weapon) that
|
||||
/// is in use: in the off hand, or put into a pack by buffing's own wand swap (combat puts it
|
||||
/// back). A listed shield that was in a pack before (not worn) is left alone, as armor in a
|
||||
/// pack is; an unlisted shield is never a target. No listed shield: nothing here runs.
|
||||
/// * Which spells: the armor's, Impenetrability and the Banes still in the buff list (the
|
||||
/// Protections and Banes ticks, or a buff profile), at the level the armor gets. Weapon
|
||||
/// enchantments never go on the shield. Buff the shield (LegacyUiSettings.BuffShield, on by
|
||||
/// default) turns it off.
|
||||
/// * When: on the armor's rules (Rebuff With, Also Refresh Under in a batch, Force Rebuff), on the
|
||||
/// shield's own timers, recorded from the "You cast X on <shield>" line.
|
||||
/// * Never at a shield being moved (its pack move or wield not settled, a swap under way).
|
||||
/// * A cast at the shield that gets no answer twice in a row, or that the server says can't be
|
||||
/// cast on it, stops shield buffing for ShieldParkTime; the armor is never held up by it.
|
||||
/// </summary>
|
||||
public partial class BuffManager
|
||||
{
|
||||
/// <summary>The shield's armor spells: keyed by (shield id, spell family), <see cref="ShieldKey"/>.</summary>
|
||||
private readonly Dictionary<long, ItemSpellRecord> _shieldSpellTimers = new();
|
||||
internal static long ShieldKey(int shieldId, int family) => ((long)unchecked((uint)shieldId) << 32) | unchecked((uint)family);
|
||||
|
||||
// The shield the pending cast is aimed at. Means something only while _pendingSpellId is set:
|
||||
// every other cast clears it when it is sent.
|
||||
private int _pendingShieldId;
|
||||
private bool PendingIsShield => _pendingSpellId != 0 && _pendingShieldId != 0;
|
||||
|
||||
// Families confirmed on the shield in this force/batch run, at their level (ClearRunFamilies).
|
||||
private readonly Dictionary<int, int> _shieldRunLevels = new();
|
||||
// A family the server refused on the shield (no components, no mana): rested, the armor's not touched.
|
||||
private readonly Dictionary<int, DateTime> _shieldFamilyRestUntil = new();
|
||||
// Casts at the shield with no answer in a row; at ShieldNoShowsToPark the shield is parked.
|
||||
private int _shieldNoShows;
|
||||
private int _shieldParkedId;
|
||||
private DateTime _shieldParkedUntil = DateTime.MinValue;
|
||||
internal const int ShieldNoShowsToPark = 2;
|
||||
internal static readonly TimeSpan ShieldParkTime = TimeSpan.FromMinutes(30);
|
||||
|
||||
// The off-hand item buffing's wand swap put into a pack (combat puts it back on), and when.
|
||||
// Seen in the off hand again after StowedSightingGraceMs, it is forgotten: the next time it is
|
||||
// in a pack, something else put it there.
|
||||
private int _stowedShieldId;
|
||||
private DateTime _stowedShieldAt = DateTime.MinValue;
|
||||
private const double StowedSightingGraceMs = 10000;
|
||||
|
||||
// ShieldToBuff walks the inventory: its answer is kept ShieldReadMs (the arbiter asks every tick),
|
||||
// and worked out again at once when the Items list or the cache changes. Tests set ShieldReadMs 0.
|
||||
internal long ShieldReadMs = 1000;
|
||||
private int _shieldChoice;
|
||||
private string _shieldChoiceWhy = "";
|
||||
private long _shieldChoiceAt = long.MinValue / 2;
|
||||
private List<ItemRule>? _shieldChoiceRules;
|
||||
private int _shieldChoiceRuleCount;
|
||||
private WorldObjectCache? _shieldChoiceCache;
|
||||
private string _shieldChoiceLogged = "";
|
||||
|
||||
/// <summary>Impenetrability (Brogard's Defiance) and the Banes: the armor spells, which a shield takes too.</summary>
|
||||
internal static bool IsArmorItemSpell(string name) =>
|
||||
name.IndexOf("Impenetrability", StringComparison.OrdinalIgnoreCase) >= 0
|
||||
|| name.IndexOf("Brogard's Defiance", StringComparison.OrdinalIgnoreCase) >= 0
|
||||
|| name.IndexOf(" Bane", StringComparison.OrdinalIgnoreCase) >= 0
|
||||
|| name.StartsWith("Bane", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>
|
||||
/// Buffing's wand swap put <paramref name="id"/> (the off hand) into a pack: combat puts it back
|
||||
/// (OffhandStowed), and a shield there is still the one in use, so it is buffed in the pack.
|
||||
/// </summary>
|
||||
internal void OffhandPutAway(int id)
|
||||
{
|
||||
if (id != 0)
|
||||
{
|
||||
_stowedShieldId = id;
|
||||
_stowedShieldAt = RynthClock.Now;
|
||||
_shieldChoiceAt = long.MinValue / 2;
|
||||
}
|
||||
OffhandStowed?.Invoke(id);
|
||||
}
|
||||
|
||||
/// <summary>The Items list's shields the cache knows, in list order.</summary>
|
||||
private List<int> ListedShields()
|
||||
{
|
||||
var found = new List<int>();
|
||||
var cache = _worldObjectCache;
|
||||
if (cache == null) return found;
|
||||
List<ItemRule> rules;
|
||||
try { rules = new List<ItemRule>(_settings.ItemRules); }
|
||||
catch { return found; } // the list edited mid-copy: next read
|
||||
foreach (var r in rules)
|
||||
{
|
||||
if (r.Id == 0 || found.Contains(r.Id)) continue;
|
||||
var wo = cache[r.Id];
|
||||
if (wo == null) continue;
|
||||
if (CombatManager.IsShieldItem(wo) || (WeaponList.IsShieldRule(r) && wo.ObjectClass == AcObjectClass.Armor))
|
||||
found.Add(r.Id);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
private bool InInventory(int id)
|
||||
{
|
||||
if (_worldObjectCache == null || id == 0) return false;
|
||||
foreach (var wo in _worldObjectCache.GetDirectInventory())
|
||||
if (wo.Id == id) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The listed shield to buff now (0 = none) and where it is: the one in the off hand, else the
|
||||
/// one buffing put into a pack for the wand. <paramref name="fresh"/> reads it again now.
|
||||
/// </summary>
|
||||
internal int ShieldToBuff(out string where, bool fresh = false)
|
||||
{
|
||||
long now = KitClockMs();
|
||||
var rules = _settings.ItemRules;
|
||||
if (!fresh && ReferenceEquals(rules, _shieldChoiceRules) && rules.Count == _shieldChoiceRuleCount
|
||||
&& ReferenceEquals(_worldObjectCache, _shieldChoiceCache) && now >= _shieldChoiceAt && now - _shieldChoiceAt < ShieldReadMs)
|
||||
{
|
||||
where = _shieldChoiceWhy;
|
||||
return _shieldChoice;
|
||||
}
|
||||
int id = FindShieldToBuff(out where, out bool anyListed);
|
||||
_shieldChoice = id;
|
||||
_shieldChoiceWhy = where;
|
||||
_shieldChoiceAt = now;
|
||||
_shieldChoiceRules = rules;
|
||||
_shieldChoiceRuleCount = rules.Count;
|
||||
_shieldChoiceCache = _worldObjectCache;
|
||||
// One log line when the answer changes, only for a character with a shield listed.
|
||||
string line = anyListed ? $"{id:X8}|{where}" : "";
|
||||
if (line != _shieldChoiceLogged)
|
||||
{
|
||||
_shieldChoiceLogged = line;
|
||||
if (anyListed)
|
||||
_host.Log(id != 0
|
||||
? $"[Buff] shield: 0x{(uint)id:X8} '{ItemName(id)}' ({where}) takes the armor spells"
|
||||
: $"[Buff] shield: none buffed ({where})");
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
private int FindShieldToBuff(out string where, out bool anyListed)
|
||||
{
|
||||
anyListed = false;
|
||||
if (!_settings.BuffShield) { where = "Buff the shield is off"; return 0; }
|
||||
var listed = ListedShields();
|
||||
anyListed = listed.Count > 0;
|
||||
if (!anyListed) { where = "no shield listed"; return 0; }
|
||||
foreach (int id in listed)
|
||||
{
|
||||
if (!IsWieldedLive(id)) continue;
|
||||
if (id == _stowedShieldId && !ShieldMidSwap(id, out _)
|
||||
&& (RynthClock.Now - _stowedShieldAt).TotalMilliseconds > StowedSightingGraceMs)
|
||||
_stowedShieldId = 0; // back in the off hand
|
||||
where = "in the off hand";
|
||||
return id;
|
||||
}
|
||||
if (_stowedShieldId != 0 && listed.Contains(_stowedShieldId) && InInventory(_stowedShieldId))
|
||||
{
|
||||
where = "put into a pack for the wand";
|
||||
return _stowedShieldId;
|
||||
}
|
||||
where = "the listed shield is in a pack, not worn";
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True while <paramref name="shieldId"/> may be on its way into or out of a hand: the wand swap
|
||||
/// under way, the shield's move into a pack not confirmed, or a swap the shared gate says just
|
||||
/// moved it (combat's off-hand wield or dequip, a held multi-step swap).
|
||||
/// </summary>
|
||||
private bool ShieldMidSwap(int shieldId, out string why)
|
||||
{
|
||||
if (_wandSwap.Active) { why = "the wand swap is under way"; return true; }
|
||||
if (_pendingWieldId != 0) { why = "the wand's wield is in flight"; return true; }
|
||||
if (_bowDequipPendingId == shieldId && shieldId != 0) { why = "its move into a pack is in flight"; return true; }
|
||||
if (_weaponSwapGate != null && _weaponSwapGate.MayBeMoving(shieldId))
|
||||
{
|
||||
why = $"a swap is moving it ({_weaponSwapGate.LastSwapBy})";
|
||||
return true;
|
||||
}
|
||||
why = "";
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool ShieldParked(int shieldId) =>
|
||||
shieldId != 0 && shieldId == _shieldParkedId && RynthClock.Now < _shieldParkedUntil;
|
||||
|
||||
/// <summary>A family resting after a refusal: on the shield, or for the armor too (no components, a parked family).</summary>
|
||||
private bool ShieldFamilyResting(int family)
|
||||
{
|
||||
DateTime now = RynthClock.Now;
|
||||
return (_shieldFamilyRestUntil.TryGetValue(family, out DateTime s) && now < s)
|
||||
|| (_buffFailCooldownUntil.TryGetValue(family, out DateTime a) && now < a);
|
||||
}
|
||||
|
||||
/// <summary>The armor spells of <paramref name="desiredBuffs"/> this character can cast, resolved like the armor's.</summary>
|
||||
private List<(SpellInfo Spell, string BaseName)> ShieldSpells(List<string> desiredBuffs)
|
||||
{
|
||||
var list = new List<(SpellInfo, string)>();
|
||||
foreach (string baseName in desiredBuffs)
|
||||
{
|
||||
if (!IsArmorItemSpell(baseName)) continue; // weapon enchantments never go on the shield
|
||||
AcSkillType skill = SkillFor(baseName);
|
||||
if (!IsSkillUsable(skill)) continue;
|
||||
int spellId = FindBestSpellId(baseName, skill);
|
||||
if (spellId == 0) continue;
|
||||
var spell = SpellTableStub.GetById(spellId);
|
||||
if (spell == null || !IsArmorItemSpell(spell.Name)) continue;
|
||||
list.Add((spell, baseName));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>IsBuffActive for the shield: its own timer, the armor's rules.</summary>
|
||||
private bool IsShieldBuffActive(int shieldId, SpellInfo spell, int? rebufferSecOverride = null)
|
||||
{
|
||||
int level = GetSpellLevel(spell);
|
||||
if (_isForceRebuffing)
|
||||
{
|
||||
// Cast on the shield in this run: done, unless a higher level is castable now.
|
||||
if (_shieldRunLevels.TryGetValue(spell.Family, out int ran)) return UpgradeParked(spell.Family) || level <= ran;
|
||||
if (!_isAutoBatchRebuff) return false;
|
||||
rebufferSecOverride = Math.Max(_settings.RebuffTopOffSecondsRemaining, _settings.RebuffSecondsRemaining);
|
||||
}
|
||||
int rebufferSec = Math.Max(0, rebufferSecOverride ?? _settings.RebuffSecondsRemaining);
|
||||
if (!_shieldSpellTimers.TryGetValue(ShieldKey(shieldId, spell.Family), out ItemSpellRecord? rec)) return false;
|
||||
if (rec.SpellLevel < level && !UpgradeParked(spell.Family)) return false; // a higher level: recast, as the armor's
|
||||
return RynthClock.Now < rec.ExpiresAt.AddSeconds(-rebufferSec);
|
||||
}
|
||||
|
||||
/// <summary>AnyBuffBelowThreshold's shield half: an armor spell on the shield to buff under <paramref name="thresholdSec"/>.</summary>
|
||||
private bool ShieldBuffBelowThreshold(List<string> desiredBuffs, int thresholdSec)
|
||||
{
|
||||
int shield = ShieldToBuff(out _);
|
||||
if (shield == 0 || ShieldParked(shield)) return false;
|
||||
foreach (var (spell, _) in ShieldSpells(desiredBuffs))
|
||||
{
|
||||
if (ShieldFamilyResting(spell.Family)) continue;
|
||||
if (!IsShieldBuffActive(shield, spell, thresholdSec)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// CheckAndCastSelfBuffs' last step, once every buff on the character is on: the next armor
|
||||
/// spell the shield needs, aimed at the shield. True when it acted (a cast, or the tick yielded
|
||||
/// to the wand swap or a move of the shield).
|
||||
/// </summary>
|
||||
private bool CastShieldBuffs(List<string> desiredBuffs, bool diagnose)
|
||||
{
|
||||
// This step runs on every buff tick: the kept answer first (no inventory walk while
|
||||
// nothing is due), a fresh read only once a spell is due on the shield.
|
||||
int shield = ShieldToBuff(out string where);
|
||||
if (shield == 0) return false;
|
||||
if (ShieldParked(shield))
|
||||
{
|
||||
LastBuffSkipReason = $"shield buffs parked ({(_shieldParkedUntil - RynthClock.Now).TotalMinutes:0} min left)";
|
||||
return false;
|
||||
}
|
||||
var spells = ShieldSpells(desiredBuffs);
|
||||
if (!spells.Exists(s => !IsShieldBuffActive(shield, s.Spell) && !ShieldFamilyResting(s.Spell.Family))) return false;
|
||||
int read = ShieldToBuff(out where, fresh: true);
|
||||
if (read != shield) return read != 0; // another shield (next tick), or none any more
|
||||
|
||||
foreach (var (spell, baseName) in spells)
|
||||
{
|
||||
if (IsShieldBuffActive(shield, spell)) continue;
|
||||
if (ShieldFamilyResting(spell.Family))
|
||||
{
|
||||
LastBuffSkipReason = $"resting on the shield: {baseName}";
|
||||
if (diagnose) DiagSkip(baseName + "@shield", $"[FR] skip '{baseName}' on the shield — resting after a refusal");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!EnsureMagicMode(forBuff: true))
|
||||
{
|
||||
if (_wandSwapExhausted)
|
||||
{
|
||||
// The wand can't be wielded now (see the self-buff loop): rest this family on the
|
||||
// shield so buffing lets go and combat runs.
|
||||
_shieldFamilyRestUntil[spell.Family] = RynthClock.Now.AddSeconds(BuffFailCooldownSec);
|
||||
LastBuffSkipReason = $"wand-swap exhausted: {baseName} on the shield";
|
||||
continue;
|
||||
}
|
||||
LastBuffSkipReason = "magic-mode swap in progress (yielding tick)";
|
||||
return true;
|
||||
}
|
||||
|
||||
// The wand swap may just have put the shield into a pack: where is it now?
|
||||
int now = ShieldToBuff(out where, fresh: true);
|
||||
if (now != shield) return now != 0; // another shield (next tick), or none any more
|
||||
if (ShieldMidSwap(shield, out string moving))
|
||||
{
|
||||
LastBuffSkipReason = $"the shield is being moved: {moving}";
|
||||
return true;
|
||||
}
|
||||
|
||||
// The mana reserve holds these as it holds every buff (see the self-buff loop).
|
||||
if (_fastChainTick && BuffNeedsManaFirst(spell.Id, out _, out _))
|
||||
{
|
||||
_fastChainTick = false;
|
||||
_chain.HoldForAnimation();
|
||||
LastBuffSkipReason = "mana reserve before " + baseName + " on the shield: Stamina to Mana waits for the animation";
|
||||
return true;
|
||||
}
|
||||
if (BuffWaitsForMana(spell.Id, baseName))
|
||||
return true;
|
||||
|
||||
SendShieldCast(shield, spell, baseName, where, diagnose);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void SendShieldCast(int shield, SpellInfo spell, string baseName, string where, bool diagnose)
|
||||
{
|
||||
int spellId = spell.Id;
|
||||
string shieldName = ItemName(shield);
|
||||
_pendingSpellId = spellId;
|
||||
_pendingShieldId = shield;
|
||||
_pendingUpgradeSpellId = 0; // the upgrade bookkeeping is the armor's
|
||||
_host.WriteToChat($"[RynthAi] Casting: {spell.Name} on {shieldName}", 5);
|
||||
if (diagnose) _host.Log($"[FR] CAST '{baseName}' on the shield 0x{(uint)shield:X8} '{shieldName}' ({where}) resolvedSpellId={spellId} (pending now set)");
|
||||
NoteBuffCastMana(SpellManaCost(spellId));
|
||||
_host.Log($"[Buff] mana {_vitals.CurrentMana}/{_vitals.MaxMana} ({_vitals.ManaPct}%) before {spell.Name} on the shield '{shieldName}' ({where}) (cost {SpellManaCost(spellId)}, reserve {ManaReserve()}, Get Mana At {_settings.GetManaAt}%)");
|
||||
bool fast = _fastChainTick;
|
||||
if (fast)
|
||||
_host.Log($"[BuffChain] '{spell.Name}' on the shield goes without waiting for the animation: {_fastChainWhy}");
|
||||
int seqAtSend = UseDoneSeqNow();
|
||||
bool castOk = _host.CastSpellFor(unchecked((uint)shield), spellId, "Buff", $"{spell.Name} on the shield");
|
||||
_lastCastAttempt = RynthClock.Now;
|
||||
if (castOk)
|
||||
{
|
||||
NoteCastIssued(spellId);
|
||||
_chain.Sent(spellId, spell.Name, seqAtSend, ActionPacer.Started, ActionPacer.AttacksSent, MoveAudit.MovementSends, fast);
|
||||
}
|
||||
else
|
||||
{
|
||||
_chain.ClientRefused(spellId, spell.Name, fast, s => _host.Log(s));
|
||||
_pendingSpellId = 0; // the packet never went out: no answer will come
|
||||
_pendingShieldId = 0;
|
||||
LastBuffSkipReason = $"local CastSpell rejected: {baseName} on the shield (id={spellId})";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>An armor spell landed on the shield: its timer, and in a force/batch run the family is done on it.</summary>
|
||||
private void ShieldSpellLanded(int shieldId, SpellInfo spell)
|
||||
{
|
||||
RecordShieldSpell(shieldId, spell);
|
||||
int level = GetSpellLevel(spell);
|
||||
if (_isForceRebuffing && (shieldId == _pendingShieldId || shieldId == ShieldToBuff(out _))
|
||||
&& (!_shieldRunLevels.TryGetValue(spell.Family, out int ran) || level > ran))
|
||||
_shieldRunLevels[spell.Family] = level;
|
||||
}
|
||||
|
||||
private void RecordShieldSpell(int shieldId, SpellInfo spell)
|
||||
{
|
||||
int level = GetSpellLevel(spell);
|
||||
double duration = GetCustomSpellDuration(level);
|
||||
var now = RynthClock.Now;
|
||||
_shieldSpellTimers[ShieldKey(shieldId, spell.Family)] = new ItemSpellRecord
|
||||
{
|
||||
CastAt = now,
|
||||
ExpiresAt = now.AddSeconds(duration),
|
||||
SpellName = spell.Name,
|
||||
SpellLevel = level,
|
||||
};
|
||||
_host.Log($"[BuffDiag] RECORD '{spell.Name}' on the shield 0x{(uint)shieldId:X8} (fam={spell.Family}, lvl={level}, durSec={duration:F0}, expiresAt={now.AddSeconds(duration):HH:mm:ss})");
|
||||
SaveBuffTimers();
|
||||
}
|
||||
|
||||
/// <summary>"Flame Bane VI on Kite Shield, refreshing Flame Bane V" -> "Kite Shield"; "" with no target.</summary>
|
||||
internal static string CastTarget(string afterCast)
|
||||
{
|
||||
int on = afterCast.IndexOf(" on ", StringComparison.OrdinalIgnoreCase);
|
||||
if (on < 0) return "";
|
||||
string rest = afterCast.Substring(on + 4);
|
||||
int comma = rest.IndexOf(',');
|
||||
if (comma >= 0) rest = rest.Substring(0, comma);
|
||||
return rest.Trim().TrimEnd('.', '!').Trim();
|
||||
}
|
||||
|
||||
private bool NamesShield(string target, int shieldId)
|
||||
{
|
||||
string name = _worldObjectCache?[shieldId]?.Name ?? "";
|
||||
return name.Length == 0 || target.Equals(name, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>The listed shield a cast line names (the pending one first), 0 = none.</summary>
|
||||
private int ListedShieldNamed(string target)
|
||||
{
|
||||
if (target.Length == 0) return 0;
|
||||
var listed = ListedShields();
|
||||
if (_pendingShieldId != 0 && listed.Contains(_pendingShieldId) && NamesShield(target, _pendingShieldId)
|
||||
&& (_worldObjectCache?[_pendingShieldId]?.Name ?? "").Length > 0)
|
||||
return _pendingShieldId;
|
||||
foreach (int id in listed)
|
||||
{
|
||||
string name = _worldObjectCache?[id]?.Name ?? "";
|
||||
if (name.Length > 0 && target.Equals(name, StringComparison.OrdinalIgnoreCase)) return id;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OnChatWindowText's "You cast X on Y" for the shield, before the armor's handling: the pending
|
||||
/// shield cast's result, a late line for a listed shield, or a self-cast that reached a worn
|
||||
/// shield. Records the shield's timer. True when the line is done with here.
|
||||
/// </summary>
|
||||
private bool ShieldCastLine(SpellInfo spell, string afterCast)
|
||||
{
|
||||
if (!IsArmorItemSpell(spell.Name)) return false;
|
||||
string target = CastTarget(afterCast);
|
||||
var pending = PendingIsShield ? SpellTableStub.GetById(_pendingSpellId) : null;
|
||||
if (pending != null && pending.Family == spell.Family)
|
||||
{
|
||||
if (target.Length > 0 && !NamesShield(target, _pendingShieldId))
|
||||
{
|
||||
// A late line of the armor's own cast of this family: the armor's; the shield's cast waits.
|
||||
RecordItemSpellCast(spell);
|
||||
_host.Log($"[BuffChat] '{spell.Name}' on '{target}' is the armor's, not pending={_pendingSpellId} on the shield - recorded, pending kept.");
|
||||
return true;
|
||||
}
|
||||
ShieldSpellLanded(_pendingShieldId, spell);
|
||||
_shieldFamilyRestUntil.Remove(spell.Family);
|
||||
_shieldNoShows = 0;
|
||||
NoteCastAccepted();
|
||||
_host.Log($"[BuffChat] CLEARED pending={_pendingSpellId} (on the shield 0x{(uint)_pendingShieldId:X8}) via ou-cast match name='{spell.Name}'");
|
||||
_pendingSpellId = 0;
|
||||
_pendingShieldId = 0;
|
||||
_onCastResolved?.Invoke($"cast '{spell.Name}' on the shield");
|
||||
return true;
|
||||
}
|
||||
|
||||
int named = ListedShieldNamed(target);
|
||||
if (named == 0) return false;
|
||||
ShieldSpellLanded(named, spell);
|
||||
// A self-cast of this family that reached a worn shield: the armor's result as well.
|
||||
var selfPending = _pendingSpellId != 0 && !PendingIsShield ? SpellTableStub.GetById(_pendingSpellId) : null;
|
||||
if (selfPending != null && selfPending.Family == spell.Family) return false;
|
||||
_host.Log($"[BuffChat] '{spell.Name}' on the shield '{target}' - a late line, recorded{(_pendingSpellId != 0 ? $"; pending={_pendingSpellId} kept" : "")}.");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>The pending shield cast was refused or fizzled: the armor's timers and families are left alone.</summary>
|
||||
private void ShieldCastRefused(SpellInfo? spell, string why, double restSec)
|
||||
{
|
||||
if (spell != null && restSec > 0)
|
||||
_shieldFamilyRestUntil[spell.Family] = RynthClock.Now.AddSeconds(restSec);
|
||||
_host.Log($"[BuffChat] CLEARED pending={_pendingSpellId} on the shield 0x{(uint)_pendingShieldId:X8} - {why}" +
|
||||
(restSec > 0 ? $"; {spell?.Name} rests on the shield {restSec:0}s." : "; tried again."));
|
||||
}
|
||||
|
||||
/// <summary>The pending shield cast got no answer in time (the tick's no-chat give-up).</summary>
|
||||
private void ShieldCastNoShow(SpellInfo? spell)
|
||||
{
|
||||
int shield = _pendingShieldId;
|
||||
_shieldNoShows++;
|
||||
if (_shieldNoShows >= ShieldNoShowsToPark)
|
||||
{
|
||||
_shieldNoShows = 0;
|
||||
ParkShield(shield, $"{ShieldNoShowsToPark} casts on it got no answer");
|
||||
}
|
||||
else
|
||||
_host.Log($"[BuffChat] NO-CHAT TIMEOUT (shield) pending={_pendingSpellId} ('{spell?.Name}') on 0x{(uint)shield:X8} - " +
|
||||
$"no answer in {NoChatResolveTimeoutMs:0}ms ({_shieldNoShows}/{ShieldNoShowsToPark} before shield buffing rests).");
|
||||
}
|
||||
|
||||
private void ParkShield(int shield, string why)
|
||||
{
|
||||
_shieldParkedId = shield;
|
||||
_shieldParkedUntil = RynthClock.Now + ShieldParkTime;
|
||||
_host.Log($"[Buff] shield 0x{(uint)shield:X8} '{ItemName(shield)}': {why} - not buffing it for {ShieldParkTime.TotalMinutes:0} min.");
|
||||
_host.WriteToChat($"[RynthAi] Not buffing the shield '{ItemName(shield)}' for {ShieldParkTime.TotalMinutes:0} min ({why}).", 2);
|
||||
}
|
||||
|
||||
/// <summary>Force Rebuff: the shield starts over too.</summary>
|
||||
private void ResetShieldBuffs()
|
||||
{
|
||||
_shieldSpellTimers.Clear();
|
||||
_shieldRunLevels.Clear();
|
||||
_shieldFamilyRestUntil.Clear();
|
||||
_shieldNoShows = 0;
|
||||
_shieldParkedId = 0;
|
||||
_shieldParkedUntil = DateTime.MinValue;
|
||||
_pendingShieldId = 0;
|
||||
}
|
||||
|
||||
/// <summary>bufftimers.txt lines for the shield: "shield|id|family|castTicks|expiresTicks|level|name".</summary>
|
||||
private void SaveShieldTimers(List<string> lines)
|
||||
{
|
||||
foreach (var kvp in _shieldSpellTimers)
|
||||
{
|
||||
var info = kvp.Value;
|
||||
uint id = unchecked((uint)(kvp.Key >> 32));
|
||||
int family = unchecked((int)(kvp.Key & 0xFFFFFFFF));
|
||||
lines.Add($"shield|{id}|{family}|{info.CastAt.Ticks}|{info.ExpiresAt.Ticks}|{info.SpellLevel}|{info.SpellName}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>One "shield|..." line of bufftimers.txt; false when the line is something else.</summary>
|
||||
private bool LoadShieldTimer(string[] p)
|
||||
{
|
||||
if (p[0] != "shield") return false;
|
||||
if (p.Length < 7) return true;
|
||||
if (!uint.TryParse(p[1], out uint id) || !int.TryParse(p[2], out int family)
|
||||
|| !long.TryParse(p[3], out long cast) || !long.TryParse(p[4], out long expires) || !int.TryParse(p[5], out int level))
|
||||
return true;
|
||||
var expiresAt = new DateTime(expires);
|
||||
if (expiresAt > RynthClock.Now)
|
||||
_shieldSpellTimers[ShieldKey(unchecked((int)id), family)] = new ItemSpellRecord
|
||||
{
|
||||
CastAt = new DateTime(cast), ExpiresAt = expiresAt, SpellLevel = level, SpellName = p[6],
|
||||
};
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>/ra buffs and /ra buffs item: the shield's timers.</summary>
|
||||
private void PrintShieldSpellTimers()
|
||||
{
|
||||
if (_shieldSpellTimers.Count == 0) return;
|
||||
_host.WriteToChat($"[RynthAi] -- Shield spells ({_shieldSpellTimers.Count}) --", 1);
|
||||
foreach (var kvp in _shieldSpellTimers)
|
||||
{
|
||||
var info = kvp.Value;
|
||||
int id = unchecked((int)(uint)(kvp.Key >> 32));
|
||||
TimeSpan left = info.ExpiresAt - RynthClock.Now;
|
||||
_host.WriteToChat(left.TotalSeconds <= 0
|
||||
? $"[RynthAi] {ItemName(id)}: {info.SpellName} (Lvl {info.SpellLevel}): EXPIRED"
|
||||
: $"[RynthAi] {ItemName(id)}: {info.SpellName} (Lvl {info.SpellLevel}): {Math.Round(left.TotalMinutes, 1)}m left / {Math.Round((info.ExpiresAt - info.CastAt).TotalMinutes, 0)}m total", 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Shield spell timers recorded (tests, status).</summary>
|
||||
internal int ShieldSpellCount => _shieldSpellTimers.Count;
|
||||
}
|
||||
|
|
@ -916,6 +916,9 @@ public partial class BuffManager : IDisposable
|
|||
var info = kvp.Value;
|
||||
lines.Add($"item|{kvp.Key}|{info.CastAt.Ticks}|{info.ExpiresAt.Ticks}|{info.SpellLevel}|{info.SpellName}");
|
||||
}
|
||||
// Last: a build from before the shield's lines reads them as old-style lines that
|
||||
// expired long ago (no exception, so the lines above are loaded either way).
|
||||
SaveShieldTimers(lines);
|
||||
// The "char doesn't know this spell" blacklist is NO LONGER persisted.
|
||||
// Persisting it meant one lag-induced no-chat timeout permanently
|
||||
// poisoned a KNOWN spell across all future sessions, collapsing the
|
||||
|
|
@ -934,9 +937,11 @@ public partial class BuffManager : IDisposable
|
|||
{
|
||||
_ramBuffTimers.Clear();
|
||||
_itemSpellTimers.Clear();
|
||||
_shieldSpellTimers.Clear();
|
||||
foreach (string line in System.IO.File.ReadAllLines(_buffTimerPath))
|
||||
{
|
||||
string[] p = line.Split('|');
|
||||
if (LoadShieldTimer(p)) continue;
|
||||
|
||||
if (p[0] == "item" && p.Length >= 6)
|
||||
{
|
||||
|
|
@ -973,9 +978,10 @@ public partial class BuffManager : IDisposable
|
|||
_ramBuffTimers[family] = new RamTimerInfo { Expiration = expiration, SpellLevel = level, SpellName = name };
|
||||
}
|
||||
}
|
||||
int total = _ramBuffTimers.Count + _itemSpellTimers.Count;
|
||||
int total = _ramBuffTimers.Count + _itemSpellTimers.Count + _shieldSpellTimers.Count;
|
||||
if (total > 0)
|
||||
_host.WriteToChat($"[RynthAi] Restored {_ramBuffTimers.Count} player + {_itemSpellTimers.Count} item spell timer(s).", 1);
|
||||
_host.WriteToChat($"[RynthAi] Restored {_ramBuffTimers.Count} player + {_itemSpellTimers.Count} item spell timer(s)" +
|
||||
(_shieldSpellTimers.Count > 0 ? $" + {_shieldSpellTimers.Count} on the shield." : "."), 1);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
|
@ -1020,6 +1026,7 @@ public partial class BuffManager : IDisposable
|
|||
_upgradeParkedUntil.Clear();
|
||||
_ramBuffTimers.Clear();
|
||||
_itemSpellTimers.Clear();
|
||||
ResetShieldBuffs(); // the shield's timers, rests and park too
|
||||
EndPendingUpgrade(_pendingSpellId, "a new Force Rebuff");
|
||||
_pendingSpellId = 0;
|
||||
_lastCastAttempt = DateTime.MinValue;
|
||||
|
|
@ -1522,6 +1529,20 @@ public partial class BuffManager : IDisposable
|
|||
// switch in mid-cast.
|
||||
if (_pendingSpellId != 0) { TryEmergencyHealWhilePending(); Hold("buff cast in flight", pendingSpell.Name); return; }
|
||||
}
|
||||
else if (pendingIsArmor && PendingIsShield)
|
||||
{
|
||||
// An armor spell aimed at the shield (BuffManager.Shield.cs): chat is authoritative,
|
||||
// as for the armor, but a give-up counts against the shield only. No blacklist (the
|
||||
// same spell just went on the armor) and no family park for the armor.
|
||||
if (PendingGiveUpReached(NoChatResolveTimeoutMs))
|
||||
{
|
||||
ShieldCastNoShow(pendingSpell);
|
||||
_pendingSpellId = 0;
|
||||
_pendingShieldId = 0;
|
||||
_onCastResolved?.Invoke("no-chat timeout (shield)");
|
||||
}
|
||||
if (_pendingSpellId != 0) { TryEmergencyHealWhilePending(); Hold("item spell in flight", pendingSpell?.Name ?? ""); return; }
|
||||
}
|
||||
else if (pendingIsArmor)
|
||||
{
|
||||
// ARMOR/ITEM: chat is authoritative. No-chat valve abandons a cast
|
||||
|
|
@ -2299,6 +2320,7 @@ public partial class BuffManager : IDisposable
|
|||
// ever come; setting pending anyway waited 2.5 s and counted a no-show
|
||||
// strike. Mirror the buff path: not handled, so the potion gets its turn.
|
||||
_pendingSpellId = spellId;
|
||||
_pendingShieldId = 0; // on the player, not the shield
|
||||
_pendingVitalSpellId = spellId; // instant: confirmed by chat, never by the registry
|
||||
_pendingVitalLabel = label;
|
||||
_pendingVitalBase = what;
|
||||
|
|
@ -2785,7 +2807,8 @@ public partial class BuffManager : IDisposable
|
|||
continue;
|
||||
if (!IsBuffActive(spellId, thresholdSec)) return true;
|
||||
}
|
||||
return false;
|
||||
// The shield's armor spells start a batch the same way (BuffManager.Shield.cs).
|
||||
return ShieldBuffBelowThreshold(desiredBuffs, thresholdSec);
|
||||
}
|
||||
|
||||
// "[FR] skip ..." lines while a rebuff runs: the selector runs every tick (~30 ms), and a
|
||||
|
|
@ -2912,6 +2935,7 @@ public partial class BuffManager : IDisposable
|
|||
int upgradeFrom = spellInfo != null && buffFamily != 0 ? ActiveLevelBelow(buffFamily, upgradeTo) : 0;
|
||||
|
||||
_pendingSpellId = spellId;
|
||||
_pendingShieldId = 0; // on the player, not the shield
|
||||
if (buffFamily != 0)
|
||||
{
|
||||
_lastCastSpellIdByFamily[buffFamily] = spellId;
|
||||
|
|
@ -2967,7 +2991,8 @@ public partial class BuffManager : IDisposable
|
|||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
// Everything on the character is on: the shield's armor spells (BuffManager.Shield.cs).
|
||||
return CastShieldBuffs(desiredBuffs, diagnose);
|
||||
}
|
||||
|
||||
/// <summary>Casts that replaced an active buff of the same family at a lower level (tests, status).</summary>
|
||||
|
|
@ -3310,6 +3335,7 @@ public partial class BuffManager : IDisposable
|
|||
{
|
||||
_forceRebuffCastFamilies.Clear();
|
||||
_runConfirmedLevelByFamily.Clear();
|
||||
_shieldRunLevels.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -3572,10 +3598,12 @@ public partial class BuffManager : IDisposable
|
|||
// left them "active" for up to an hour and the bot fought unbuffed (reported as
|
||||
// "buffing skips missile weapons"). The player's registry dropping to zero (a death,
|
||||
// or logging in after one) is the signal: forget them so they get recast.
|
||||
if (count == 0 && _lastLivePlayerEnchantCount != 0 && _itemSpellTimers.Count > 0)
|
||||
if (count == 0 && _lastLivePlayerEnchantCount != 0 && (_itemSpellTimers.Count > 0 || _shieldSpellTimers.Count > 0))
|
||||
{
|
||||
_host.Log($"[BuffDiag] player enchantments dropped to 0 (was {_lastLivePlayerEnchantCount}) - clearing {_itemSpellTimers.Count} item-spell timer(s) so weapon/armor buffs recast");
|
||||
_host.Log($"[BuffDiag] player enchantments dropped to 0 (was {_lastLivePlayerEnchantCount}) - clearing {_itemSpellTimers.Count} item-spell timer(s)" +
|
||||
$"{(_shieldSpellTimers.Count > 0 ? $" and {_shieldSpellTimers.Count} on the shield" : "")} so weapon/armor buffs recast");
|
||||
_itemSpellTimers.Clear();
|
||||
_shieldSpellTimers.Clear();
|
||||
}
|
||||
_lastLivePlayerEnchantCount = count;
|
||||
|
||||
|
|
@ -3808,7 +3836,7 @@ public partial class BuffManager : IDisposable
|
|||
_host.WriteToChat($"[RynthAi] ServerTime={Math.Round(serverNow)} (no live read: serverTime=0 or API missing)", 1);
|
||||
}
|
||||
|
||||
if (_ramBuffTimers.Count == 0 && _itemSpellTimers.Count == 0)
|
||||
if (_ramBuffTimers.Count == 0 && _itemSpellTimers.Count == 0 && _shieldSpellTimers.Count == 0)
|
||||
{
|
||||
_host.WriteToChat("[RynthAi] No buff timers active.", 1);
|
||||
return;
|
||||
|
|
@ -3819,6 +3847,7 @@ public partial class BuffManager : IDisposable
|
|||
_host.WriteToChat($"[RynthAi] -- Item spells ({_itemSpellTimers.Count}) --", 1);
|
||||
PrintItemSpellTimers();
|
||||
}
|
||||
PrintShieldSpellTimers();
|
||||
|
||||
if (_ramBuffTimers.Count > 0)
|
||||
{
|
||||
|
|
@ -3882,13 +3911,17 @@ public partial class BuffManager : IDisposable
|
|||
|
||||
public void PrintItemBuffDebug()
|
||||
{
|
||||
if (_itemSpellTimers.Count == 0)
|
||||
if (_itemSpellTimers.Count == 0 && _shieldSpellTimers.Count == 0)
|
||||
{
|
||||
_host.WriteToChat("[RynthAi] No item spell timers recorded yet.", 1);
|
||||
return;
|
||||
}
|
||||
_host.WriteToChat($"[RynthAi] -- Item spells ({_itemSpellTimers.Count}) --", 1);
|
||||
PrintItemSpellTimers();
|
||||
if (_itemSpellTimers.Count > 0)
|
||||
{
|
||||
_host.WriteToChat($"[RynthAi] -- Item spells ({_itemSpellTimers.Count}) --", 1);
|
||||
PrintItemSpellTimers();
|
||||
}
|
||||
PrintShieldSpellTimers();
|
||||
}
|
||||
|
||||
private void PrintItemSpellTimers()
|
||||
|
|
@ -4228,8 +4261,9 @@ public partial class BuffManager : IDisposable
|
|||
// Only clear pending if this enchantment matches what we were casting.
|
||||
// Armor/item enchantments fire on the item, not the player — clearing
|
||||
// _pendingSpellId unconditionally would lose track of pending item casts
|
||||
// and prevent the chat handler from recording their timers.
|
||||
if (_pendingSpellId != 0)
|
||||
// and prevent the chat handler from recording their timers. A cast at the shield never
|
||||
// lands on the player: only its chat line resolves it.
|
||||
if (_pendingSpellId != 0 && !PendingIsShield)
|
||||
{
|
||||
var pendingSpell = SpellTableStub.GetById(_pendingSpellId);
|
||||
if (pendingSpell != null && pendingSpell.Family == spellInfo.Family)
|
||||
|
|
@ -4368,12 +4402,12 @@ public partial class BuffManager : IDisposable
|
|||
else if (_pendingSpellId != 0)
|
||||
{
|
||||
var pendingSpell = SpellTableStub.GetById(_pendingSpellId);
|
||||
if (pendingSpell != null && IsItemEnchantment(pendingSpell.Name))
|
||||
if (pendingSpell != null && IsItemEnchantment(pendingSpell.Name) && !PendingIsShield) // the shield's refusal leaves the armor's timer
|
||||
{
|
||||
_itemSpellTimers.Remove(pendingSpell.Family);
|
||||
SaveBuffTimers();
|
||||
}
|
||||
_host.Log($"[BuffChat] PARKED pending={_pendingSpellId} — AC too busy (cast gesture in progress); throttle kept, backing off before re-issue.");
|
||||
_host.Log($"[BuffChat] PARKED pending={_pendingSpellId}{(PendingIsShield ? " (on the shield)" : "")} — AC too busy (cast gesture in progress); throttle kept, backing off before re-issue.");
|
||||
if (_pendingSpellId != _pendingVitalSpellId)
|
||||
_chain.TooBusyLine(_pendingSpellId, s => _host.Log(s));
|
||||
}
|
||||
|
|
@ -4432,6 +4466,14 @@ public partial class BuffManager : IDisposable
|
|||
_noComponentsUntil[_pendingSpellId] = RynthClock.Now.AddSeconds(NoComponentsLevelSec);
|
||||
_host.WriteToChat($"[RynthAi] No components for {pendingSpell.Name}: using a lower level for {NoComponentsLevelSec / 60:0} min.", 2);
|
||||
}
|
||||
else if (pendingSpell != null && PendingIsShield)
|
||||
{
|
||||
// Aimed at the shield: the family rests on the shield only; the armor's is on.
|
||||
bool noComps = lower.Contains("components") || lower.Contains("missing some required");
|
||||
ShieldCastRefused(pendingSpell, "hard rejection", BuffFailCooldownSec);
|
||||
_host.WriteToChat($"[RynthAi] Skipping {pendingSpell.Name} on the shield for {BuffFailCooldownSec / 60:0} min " +
|
||||
$"({(noComps ? "no components for it" : "the server refused it")}).", 2);
|
||||
}
|
||||
else if (pendingSpell != null)
|
||||
{
|
||||
if (IsItemEnchantment(pendingSpell.Name))
|
||||
|
|
@ -4481,7 +4523,9 @@ public partial class BuffManager : IDisposable
|
|||
return;
|
||||
}
|
||||
double restSec = LowManaFamilyRestSec;
|
||||
if (pendingSpell != null)
|
||||
if (pendingSpell != null && PendingIsShield)
|
||||
ShieldCastRefused(pendingSpell, "not enough mana", restSec); // rests on the shield; the armor's timer stays
|
||||
else if (pendingSpell != null)
|
||||
{
|
||||
if (IsItemEnchantment(pendingSpell.Name))
|
||||
{
|
||||
|
|
@ -4515,12 +4559,12 @@ public partial class BuffManager : IDisposable
|
|||
if (_pendingSpellId != 0)
|
||||
{
|
||||
var pendingSpell = SpellTableStub.GetById(_pendingSpellId);
|
||||
if (pendingSpell != null && IsItemEnchantment(pendingSpell.Name))
|
||||
if (pendingSpell != null && IsItemEnchantment(pendingSpell.Name) && !PendingIsShield) // a fizzle at the shield leaves the armor's timer
|
||||
{
|
||||
_itemSpellTimers.Remove(pendingSpell.Family);
|
||||
SaveBuffTimers();
|
||||
}
|
||||
_host.Log($"[BuffChat] CLEARED pending={_pendingSpellId} via soft-fail in '{text}'");
|
||||
_host.Log($"[BuffChat] CLEARED pending={_pendingSpellId}{(PendingIsShield ? " (on the shield)" : "")} via soft-fail in '{text}'");
|
||||
}
|
||||
_lastCastAttempt = DateTime.MinValue;
|
||||
EndPendingUpgrade(_pendingSpellId, "fizzled");
|
||||
|
|
@ -4529,6 +4573,19 @@ public partial class BuffManager : IDisposable
|
|||
return;
|
||||
}
|
||||
|
||||
// "Flame Bane VI cannot be cast on Kite Shield." (ACE IsInvalidTarget: an item that takes no
|
||||
// spells). Read only for a cast at the shield: shield buffing rests; the armor carries on.
|
||||
if (PendingIsShield && lower.Contains(" cannot be cast on "))
|
||||
{
|
||||
_cast.Result(null, "refused by the server", atStart: true);
|
||||
_host.Log($"[BuffChat] CLEARED pending={_pendingSpellId} on the shield 0x{(uint)_pendingShieldId:X8} - '{text}'");
|
||||
ParkShield(_pendingShieldId, "the server says these spells can't be cast on it");
|
||||
_pendingSpellId = 0;
|
||||
_pendingShieldId = 0;
|
||||
_onCastResolved?.Invoke("can't be cast on the shield");
|
||||
return;
|
||||
}
|
||||
|
||||
// A script heal (a transfer such as Vitality Siphon) cast at a monster that resists it:
|
||||
// "Doorheld Surveyor resists your spell" is its only result, no "due to casting" line
|
||||
// follows. Closed here as CombatManager reads the same line for its own casts.
|
||||
|
|
@ -4605,6 +4662,11 @@ public partial class BuffManager : IDisposable
|
|||
if (spellInfo == null && _pendingSpellId != 0)
|
||||
spellInfo = SpellTableStub.GetById(_pendingSpellId);
|
||||
|
||||
// An armor spell's line for the shield (its own cast, a late line, or a self-cast that
|
||||
// reached a worn shield) goes on the shield's timer, not the armor's (BuffManager.Shield.cs).
|
||||
if (spellInfo != null && !viaDueToCasting && ShieldCastLine(spellInfo, afterCast))
|
||||
return;
|
||||
|
||||
// A result that names another spell than the pending one is not the pending cast's
|
||||
// result: the pending cast keeps waiting for its own (or its give-up time).
|
||||
var pendingInfo = _pendingSpellId != 0 ? SpellTableStub.GetById(_pendingSpellId) : null;
|
||||
|
|
@ -5428,7 +5490,7 @@ public partial class BuffManager : IDisposable
|
|||
return WandSwapFailed(_wandSwap.Abandon("no pack with room"), forBuff, wandId, now);
|
||||
}
|
||||
bool offhand = hands.TryGetValue(step.Id, out int slot) && (slot & HandSwapSequence.ShieldSlot) != 0;
|
||||
if (offhand) OffhandStowed?.Invoke(step.Id); // combat puts it back after
|
||||
if (offhand) OffhandPutAway(step.Id); // combat puts it back after (and it is buffed in the pack)
|
||||
_host.MoveItemInternal((uint)step.Id, (uint)pack, 0, 1); // amount>=1 (engine rejects 0)
|
||||
_wandSwap.Sent(step, now);
|
||||
_wandSwapLastMoved = step.Id;
|
||||
|
|
@ -5554,7 +5616,7 @@ public partial class BuffManager : IDisposable
|
|||
if (!_host.ChangeCombatModeFor(CombatMode.NonCombat, "Buff", "wand swap burst: peace, the hands and the wand at once")) return 1;
|
||||
foreach (int id in moves)
|
||||
{
|
||||
if (hands.TryGetValue(id, out int slot) && (slot & HandSwapSequence.ShieldSlot) != 0) OffhandStowed?.Invoke(id);
|
||||
if (hands.TryGetValue(id, out int slot) && (slot & HandSwapSequence.ShieldSlot) != 0) OffhandPutAway(id);
|
||||
_host.PutItemInContainer(unchecked((uint)id), unchecked((uint)pack), 0);
|
||||
}
|
||||
_host.WieldItem(unchecked((uint)wandId), HeldSlot);
|
||||
|
|
|
|||
|
|
@ -147,6 +147,22 @@ public sealed class WeaponSwapGate
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True while <paramref name="itemId"/> may still be on its way into or out of a hand: a
|
||||
/// multi-step swap holds the gate, or the last claimed swap noted a move of this item and the
|
||||
/// next swap would still wait for it (MinIntervalMs). Buffing doesn't aim a spell at a shield
|
||||
/// then (BuffManager.Shield.cs).
|
||||
/// </summary>
|
||||
public bool MayBeMoving(int itemId)
|
||||
{
|
||||
long now = NowMs();
|
||||
lock (_lock)
|
||||
{
|
||||
if (_heldBy.Length > 0 && now < _heldUntilMs) return true;
|
||||
return itemId != 0 && _movingId == itemId && now - _lastSwapTickMs < MinIntervalMs;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Milliseconds since the last successful swap (diagnostics).</summary>
|
||||
public long MsSinceLastSwap
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1006,6 +1006,13 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
}
|
||||
ImGui.EndTable();
|
||||
}
|
||||
ImGui.Checkbox("Buff the shield", ref _settings.BuffShield);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(
|
||||
"Cast the ticked Impenetrability and Banes on your shield too, after\n" +
|
||||
"the armor, renewed with it. The shield is the one in the Items list\n" +
|
||||
"(Shield) that you wear: buffing puts it in a pack for the wand, so it\n" +
|
||||
"is buffed there. On by default. No shield listed: nothing changes.");
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Separator();
|
||||
|
|
|
|||
|
|
@ -2055,7 +2055,8 @@ internal sealed partial class LegacyDashboardRenderer
|
|||
dst.FastBuffChain = tmp.FastBuffChain;
|
||||
dst.SkipUnusableBuffs = tmp.SkipUnusableBuffs;
|
||||
dst.DisabledBuffs = tmp.DisabledBuffs;
|
||||
dst.BlacklistAttempts = tmp.BlacklistAttempts;
|
||||
dst.BuffShield = tmp.BuffShield;
|
||||
dst.BlacklistAttempts = tmp.BlacklistAttempts;
|
||||
dst.BlacklistTimeoutSec = tmp.BlacklistTimeoutSec;
|
||||
// 0 is never meant (every UI floors it at 250+) and is what the Settings-panel bug
|
||||
// saved into profiles: it judges each cast before its damage can land.
|
||||
|
|
@ -2870,6 +2871,7 @@ internal sealed partial class LegacyDashboardRenderer
|
|||
switch (cmd.Cmd)
|
||||
{
|
||||
case "startNav":
|
||||
_settings.RearmFinishedNavRoute(); // the player's Start Navigation re-runs a finished Once route
|
||||
_settings.IsMacroRunning = true;
|
||||
_settings.EnableNavigation = true;
|
||||
if (_settings.BotAction != "Navigating")
|
||||
|
|
@ -3202,7 +3204,12 @@ internal sealed partial class LegacyDashboardRenderer
|
|||
{
|
||||
case 0: _settings.EnableCombat = enabled; break;
|
||||
case 1: _settings.EnableBuffing = enabled; break;
|
||||
case 2: _settings.EnableNavigation = enabled; break;
|
||||
case 2:
|
||||
// The player switching nav on over a finished Once route re-runs it (a meta's
|
||||
// enablenav doesn't, NavigationEngine.HandleRouteEnd).
|
||||
if (enabled && !_settings.EnableNavigation) _settings.RearmFinishedNavRoute();
|
||||
_settings.EnableNavigation = enabled;
|
||||
break;
|
||||
case 3: _settings.EnableLooting = enabled; break;
|
||||
case 4: _settings.EnableMeta = enabled; break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ internal sealed class LegacyNavigationUi
|
|||
ImGui.PushStyleColor(ImGuiCol.ButtonActive, new Vector4(0.08f, 0.28f, 0.08f, 1f));
|
||||
if (ImGui.Button("Start Navigation", new Vector2(-1, 28)))
|
||||
{
|
||||
_settings.RearmFinishedNavRoute(); // a finished Once route runs again
|
||||
_settings.IsMacroRunning = true;
|
||||
_settings.EnableNavigation = true;
|
||||
if (_settings.BotAction != "Navigating")
|
||||
|
|
|
|||
|
|
@ -389,6 +389,14 @@ public sealed class LegacyUiSettings
|
|||
else next.Add(buffBaseName);
|
||||
_disabledBuffs = next;
|
||||
}
|
||||
/// <summary>
|
||||
/// Cast the armor spells (Impenetrability and the Banes still ticked above) on the shield
|
||||
/// listed in the Items list too, after the armor, on the armor's timers (BuffManager.Shield.cs).
|
||||
/// The self-cast never reaches it: ACE won't wield the wand beside a shield, so buffing puts
|
||||
/// the shield into a pack first. On by default; a profile saved before this setting existed
|
||||
/// loads it as on. No shield listed: nothing changes.
|
||||
/// </summary>
|
||||
public bool BuffShield = true;
|
||||
public bool StartMacroOnLogin;
|
||||
public bool PatrolOnLogin;
|
||||
/// <summary>
|
||||
|
|
@ -726,6 +734,32 @@ public sealed class LegacyUiSettings
|
|||
[JsonIgnore] public NavRouteParser CurrentRoute { get; set; } = new();
|
||||
public int ActiveNavIndex;
|
||||
|
||||
/// <summary>
|
||||
/// True for a Once route that has walked off its last point (the nav engine leaves the
|
||||
/// index past the end). It stays finished over a macro stop/start and a meta turning nav
|
||||
/// on, until it is loaded again, edited, or restarted (/ra nav restart, or
|
||||
/// <see cref="RearmFinishedNavRoute"/> from the player's own nav-on controls).
|
||||
/// </summary>
|
||||
public bool NavRouteFinished()
|
||||
{
|
||||
var route = CurrentRoute;
|
||||
return route != null && route.RouteType == NavRouteType.Once
|
||||
&& route.Points.Count > 0 && ActiveNavIndex >= route.Points.Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The player turned nav on (the Nav switch, a Start Navigation button): a finished Once
|
||||
/// route runs again from [0], as re-enabling nav did before 2026-10-28. Metas and scripts
|
||||
/// that switch nav on don't call this, so a stop/start replaying a meta's
|
||||
/// "/vt opt set enablenav true" no longer re-runs a finished route. True if it rewound.
|
||||
/// </summary>
|
||||
public bool RearmFinishedNavRoute()
|
||||
{
|
||||
if (!NavRouteFinished()) return false;
|
||||
ActiveNavIndex = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ShowAdvancedWindow;
|
||||
public int SelectedAdvancedTab;
|
||||
|
||||
|
|
|
|||
|
|
@ -3701,6 +3701,7 @@ internal sealed partial class ExpressionEngine
|
|||
["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),
|
||||
["BuffShield"] = (() => B(s.BuffShield), v => s.BuffShield = 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),
|
||||
|
|
|
|||
|
|
@ -76,6 +76,22 @@ internal sealed class MetaManager
|
|||
private long _evalChatSeq; // newest chat line its condition matched
|
||||
private Match? _lastChatMatch;
|
||||
|
||||
// ── Macro stop/start replay ──────────────────────────────────────────────
|
||||
// Starting the macro re-arms every rule of the state it is in (so a meta puts back a
|
||||
// route the player changed or cleared while it was stopped). The rules that had already
|
||||
// fired in that state before the stop "replay" when they fire again. A replayed nav load
|
||||
// (EmbedNav, /vt nav load, /ra nav load) of the route that is still loaded and unchanged
|
||||
// keeps the route where it was: its waypoint, a Linear route's direction, a finished
|
||||
// Once route finished; a replayed "/ra nav restart" is skipped. Reloading here restarted
|
||||
// Once routes on every stop/start (2026-10-28). Cleared by the next real state entry; a
|
||||
// rule that first fires after the start is not a replay, and its nav load starts the
|
||||
// route fresh as before.
|
||||
private readonly HashSet<MetaRule> _replayRules = new(ReferenceEqualityComparer.Instance);
|
||||
private bool _replaying; // the action running now belongs to a replayed rule
|
||||
|
||||
/// <summary>Where a meta's nav names are looked for as .nav files. Tests point it at a scratch folder.</summary>
|
||||
internal string NavFolder { get; set; } = Path.Combine(RynthCore.Install.RynthInstallPaths.RynthAiDir, "NavProfiles");
|
||||
|
||||
// ── Call stack (CallMetaState / ReturnFromCall) ──────────────────────────
|
||||
private readonly Stack<string> _stateStack = new();
|
||||
|
||||
|
|
@ -236,6 +252,73 @@ internal sealed class MetaManager
|
|||
? 0
|
||||
: FindNearestWaypoint(route);
|
||||
|
||||
/// <summary>
|
||||
/// A replayed nav load (see <see cref="_replayRules"/>): true, and nothing reloaded, when
|
||||
/// <paramref name="path"/> is the route loaded now and it still has the points of its source
|
||||
/// <paramref name="source"/> (not edited, reversed or swapped for another since). The route
|
||||
/// keeps its waypoint and a Linear route its direction (the engine sees the same route
|
||||
/// object); nav is switched on as the load would, except for a finished Once route, which
|
||||
/// stays finished. False: the caller loads the route fresh, as before.
|
||||
/// </summary>
|
||||
private bool KeepRunningRoute(string path, NavRouteParser source, string what)
|
||||
{
|
||||
var cur = _settings.CurrentRoute;
|
||||
if (cur == null || cur.Points.Count == 0 || source.Points.Count == 0) return false;
|
||||
if (!SameNavPath(_settings.CurrentNavPath, path)) return false;
|
||||
if (!SameLines(cur.ToLines(), source.ToLines())) return false;
|
||||
|
||||
bool finished = _settings.NavRouteFinished();
|
||||
if (!finished) _settings.EnableNavigation = true;
|
||||
RynthLog.Write(LogCat.Meta, finished
|
||||
? $"[Meta] {what}: the macro started again on the same route, which is finished - it stays finished (/ra nav restart re-runs it)"
|
||||
: $"[Meta] {what}: the macro started again on the same route - it carries on at [{_settings.ActiveNavIndex}] instead of starting over");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>A replayed "/vt nav load" or "/ra nav load" of the .nav file that is still the loaded, unchanged route.</summary>
|
||||
private bool KeepRunningNavFile(string rawName)
|
||||
{
|
||||
string name = NewProfileFiles.Tidy(rawName, NewProfileFiles.NavExtensions, out _);
|
||||
if (NewProfileFiles.Validate(name) != null) return false;
|
||||
string path = Path.Combine(NavFolder, name + ".nav");
|
||||
if (!File.Exists(path)) return false;
|
||||
return KeepRunningRoute(path, NavRouteParser.Load(path), $"nav load '{name}'");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A replayed /ra nav command that would start the route over: "/ra nav load" of the running,
|
||||
/// unchanged route, or "/ra nav restart". True: skipped, the nav stays where it was.
|
||||
/// </summary>
|
||||
private bool SkipReplayedNavCommand(string cmd)
|
||||
{
|
||||
string[] parts = cmd.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||
if (parts.Length < 3 || !parts[1].Equals("nav", StringComparison.OrdinalIgnoreCase)) return false;
|
||||
if (parts[2].Equals("restart", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
RynthLog.Write(LogCat.Meta, "[Meta] /ra nav restart: not run again for the macro start (it ran when the rule first fired)");
|
||||
return true;
|
||||
}
|
||||
return parts[2].Equals("load", StringComparison.OrdinalIgnoreCase) && parts.Length >= 4
|
||||
&& KeepRunningNavFile(string.Join(" ", parts, 3, parts.Length - 3));
|
||||
}
|
||||
|
||||
private static bool SameNavPath(string? a, string? b)
|
||||
{
|
||||
if (string.IsNullOrEmpty(a) || string.IsNullOrEmpty(b)) return false;
|
||||
if (string.Equals(a, b, StringComparison.OrdinalIgnoreCase)) return true;
|
||||
if (a.StartsWith('<') || b.StartsWith('<')) return false; // "<embedded:...>" is not a file
|
||||
try { return string.Equals(Path.GetFullPath(a), Path.GetFullPath(b), StringComparison.OrdinalIgnoreCase); }
|
||||
catch { return false; }
|
||||
}
|
||||
|
||||
private static bool SameLines(List<string> a, List<string> b)
|
||||
{
|
||||
if (a.Count != b.Count) return false;
|
||||
for (int i = 0; i < a.Count; i++)
|
||||
if (!string.Equals(a[i], b[i], StringComparison.Ordinal)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public ExpressionEngine Expressions => _expressions ??= CreateExpressionEngine();
|
||||
|
||||
private ExpressionEngine CreateExpressionEngine()
|
||||
|
|
@ -312,7 +395,10 @@ internal sealed class MetaManager
|
|||
// Macro just started — force reset so rules re-evaluate even if state
|
||||
// name matches where we stopped. Otherwise HasFired stays latched across
|
||||
// a stop/start cycle and IF:Always rules like EmbedNav never re-fire.
|
||||
if (!_lastMacroRunning)
|
||||
// The rules that had already fired replay (see _replayRules): a replayed nav
|
||||
// load of the route still running keeps its place instead of starting it over.
|
||||
bool macroStarted = !_lastMacroRunning;
|
||||
if (macroStarted)
|
||||
_settings.ForceStateReset = true;
|
||||
_lastMacroRunning = true;
|
||||
|
||||
|
|
@ -343,9 +429,21 @@ internal sealed class MetaManager
|
|||
_statePStartTime = _statePResume is double resumed ? Clock().AddSeconds(-resumed) : Clock();
|
||||
_statePResume = null;
|
||||
_settings.ForceStateReset = false;
|
||||
// A bare stop/start (no state entry, no meta load pending) replays the rules that
|
||||
// had fired; any other reset is a real state entry and nothing is a replay.
|
||||
bool replay = macroStarted && !realStateEntry && !metaReloaded;
|
||||
lock (_settings.MetaRulesLock)
|
||||
foreach (var r in _settings.MetaRules) r.HasFired = false;
|
||||
{
|
||||
_replayRules.Clear();
|
||||
foreach (var r in _settings.MetaRules)
|
||||
{
|
||||
if (replay && r.HasFired) _replayRules.Add(r);
|
||||
r.HasFired = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (stateChanged)
|
||||
_replayRules.Clear();
|
||||
_lastState = _settings.CurrentState;
|
||||
|
||||
double secondsInState = (Clock() - _stateStartTime).TotalSeconds;
|
||||
|
|
@ -434,7 +532,9 @@ internal sealed class MetaManager
|
|||
if (_settings.MetaDebug)
|
||||
_host.WriteToChat($"[Meta] {rule.State} | {DescribeCondition(rule)} → {DescribeAction(rule)}", 1);
|
||||
|
||||
ExecuteAction(rule);
|
||||
_replaying = _replayRules.Contains(rule);
|
||||
try { ExecuteAction(rule); }
|
||||
finally { _replaying = false; }
|
||||
|
||||
// If state changed during this action, stop evaluating further rules this tick
|
||||
if (_settings.CurrentState != _lastState || _settings.ForceStateReset)
|
||||
|
|
@ -888,7 +988,10 @@ internal sealed class MetaManager
|
|||
if (cmd.StartsWith("/ra ", StringComparison.OrdinalIgnoreCase)
|
||||
|| cmd.Equals("/ra", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_raCommandHandler?.Invoke(cmd);
|
||||
// A replayed "/ra nav load" of the route still running, or "/ra nav restart",
|
||||
// would start the route over: skipped.
|
||||
if (!(_replaying && SkipReplayedNavCommand(cmd)))
|
||||
_raCommandHandler?.Invoke(cmd);
|
||||
}
|
||||
else if (_host.HasInvokeChatParser)
|
||||
_host.InvokeChatParser(cmd);
|
||||
|
|
@ -977,7 +1080,7 @@ internal sealed class MetaManager
|
|||
// circular hunt through every cell of this dungeon, no nav file). The Meta panel
|
||||
// offers it first in Embedded Nav Route's list. A real route called Patrol wins.
|
||||
if (IsPatrolRoute(routeName) && !_settings.EmbeddedNavs.ContainsKey(routeName)
|
||||
&& !File.Exists(Path.Combine(RynthCore.Install.RynthInstallPaths.RynthAiDir, "NavProfiles", routeName + ".nav")))
|
||||
&& !File.Exists(Path.Combine(NavFolder, routeName + ".nav")))
|
||||
{
|
||||
_host.Log("[Meta] EmbedNav: Patrol -> /ra dunnav-patrol");
|
||||
if (_raCommandHandler != null) _raCommandHandler("/ra dunnav-patrol");
|
||||
|
|
@ -1002,6 +1105,8 @@ internal sealed class MetaManager
|
|||
if (_settings.EmbeddedNavs.TryGetValue(routeName, out var embedded))
|
||||
{
|
||||
var newRoute = NavRouteParser.LoadFromLines(embedded);
|
||||
// The macro was started again: the route still running keeps its place.
|
||||
if (_replaying && KeepRunningRoute($"<embedded:{routeName}>", newRoute, $"EmbedNav '{routeName}'")) break;
|
||||
_settings.CurrentNavPath = $"<embedded:{routeName}>";
|
||||
_settings.CurrentRoute = newRoute;
|
||||
_settings.ActiveNavIndex = StartIndexForRoute(newRoute);
|
||||
|
|
@ -1012,11 +1117,11 @@ internal sealed class MetaManager
|
|||
}
|
||||
|
||||
// Fallback: a standalone .nav file in NavProfiles.
|
||||
string navFolder = System.IO.Path.Combine(RynthCore.Install.RynthInstallPaths.RynthAiDir, "NavProfiles");
|
||||
string fullPath = Path.Combine(navFolder, routeName + ".nav");
|
||||
string fullPath = Path.Combine(NavFolder, routeName + ".nav");
|
||||
if (File.Exists(fullPath))
|
||||
{
|
||||
var newRoute = NavRouteParser.Load(fullPath);
|
||||
if (_replaying && KeepRunningRoute(fullPath, newRoute, $"EmbedNav file '{routeName}'")) break;
|
||||
_settings.CurrentNavPath = fullPath;
|
||||
_settings.CurrentRoute = newRoute;
|
||||
_settings.ActiveNavIndex = StartIndexForRoute(newRoute);
|
||||
|
|
@ -1257,6 +1362,9 @@ internal sealed class MetaManager
|
|||
|| parts[2].Equals("save", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
string name = string.Join(" ", parts, 3, parts.Length - 3);
|
||||
// The macro was started again: the route still running keeps its place.
|
||||
if (_replaying && parts[2].Equals("load", StringComparison.OrdinalIgnoreCase) && KeepRunningNavFile(name))
|
||||
return true;
|
||||
_raCommandHandler?.Invoke($"/ra nav {parts[2].ToLowerInvariant()} {name}");
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -763,8 +763,9 @@ internal sealed class NavigationEngine
|
|||
/// Points the route at the waypoint nearest the player (macro start). Circular
|
||||
/// and Linear routes pick from the whole route; a Once route only from the
|
||||
/// current waypoint onward, so finished steps (a recall, a portal) aren't
|
||||
/// repeated. Only plain waypoints are candidates; if the current one is a
|
||||
/// Recall/Portal/Chat/Pause step it is kept. With <c>NavResumeNearest</c> off the
|
||||
/// repeated, and a finished Once route stays finished. Only plain waypoints are
|
||||
/// candidates; if the current one is a Recall/Portal/Chat/Pause step it is kept.
|
||||
/// A Linear route keeps its direction. With <c>NavResumeNearest</c> off the
|
||||
/// route keeps its last waypoint, unless <paramref name="always"/> (hazard escapes
|
||||
/// and corpse runs, which leave the route behind).
|
||||
/// </summary>
|
||||
|
|
@ -781,6 +782,9 @@ internal sealed class NavigationEngine
|
|||
var route = _settings.CurrentRoute;
|
||||
if (route == null || route.Points.Count == 0) return;
|
||||
if (route.RouteType == NavRouteType.Follow) return;
|
||||
// A finished Once route (index left past its end) is done: picking from [0] here
|
||||
// used to turn it back on at the nearest point, so a stop + start re-ran it.
|
||||
if (_settings.NavRouteFinished()) return;
|
||||
if (!TryGetPos(out double ns, out double ew)) return;
|
||||
|
||||
int cur = _settings.ActiveNavIndex;
|
||||
|
|
@ -922,6 +926,23 @@ internal sealed class NavigationEngine
|
|||
_hasGoodHeading = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// /ra nav restart: the loaded route starts over from its first point, as when it was
|
||||
/// loaded with NavResumeNearest off (a Linear route heading out again, a finished Once
|
||||
/// route running again). Nav is switched on; the macro is left as it is. False (nothing
|
||||
/// done) with no waypoints to walk (none loaded, or a Follow route).
|
||||
/// </summary>
|
||||
public bool RestartRoute()
|
||||
{
|
||||
var route = _settings.CurrentRoute;
|
||||
if (route == null || route.Points.Count == 0 || route.RouteType == NavRouteType.Follow) return false;
|
||||
ResetRouteState();
|
||||
_settings.ActiveNavIndex = 0;
|
||||
_settings.EnableNavigation = true;
|
||||
_host.Log($"Nav: route restarted from [0] ({route.RouteType}, {route.Points.Count} pts)");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// One-shot view of everything the nav engine is keying off. Nav had no
|
||||
/// snapshot (Combat/Buff/Meta did), so a wedged route meant guessing which
|
||||
|
|
@ -1454,14 +1475,17 @@ internal sealed class NavigationEngine
|
|||
/// A finite (Once) route ran off its last point: stop and disable nav, but leave
|
||||
/// the points intact. This used to <c>Points.Clear()</c> the in-memory route, so
|
||||
/// re-enabling nav was a silent no-op until the profile was reloaded
|
||||
/// (2026-06-03 audit P2). The index is left past the end; re-enabling nav lands
|
||||
/// in <see cref="HandleRouteEnd"/>, which rewinds it for a genuine re-run.
|
||||
/// (2026-06-03 audit P2). The index is left past the end, which marks the route
|
||||
/// finished (<see cref="LegacyUiSettings.NavRouteFinished"/>): it stays finished
|
||||
/// over a macro stop/start and a meta turning nav on, and runs again when it is
|
||||
/// loaded again, edited, or restarted (/ra nav restart, or the player's Nav switch /
|
||||
/// Start Navigation button, <see cref="LegacyUiSettings.RearmFinishedNavRoute"/>).
|
||||
/// </summary>
|
||||
private void CompleteOnceRoute(NavRouteParser route)
|
||||
{
|
||||
_settings.EnableNavigation = false;
|
||||
StopMovement();
|
||||
_host.Log($"Nav: Once route complete ({route.Points.Count} pts) — nav disabled, route retained for re-run");
|
||||
_host.Log($"Nav: Once route complete ({route.Points.Count} pts) — nav disabled, route retained (load it again or /ra nav restart to re-run)");
|
||||
}
|
||||
|
||||
private void HandleRouteEnd(NavRouteParser route)
|
||||
|
|
@ -1472,16 +1496,19 @@ internal sealed class NavigationEngine
|
|||
return;
|
||||
}
|
||||
|
||||
// Nav was re-enabled on a finished Once route (CompleteOnceRoute leaves the
|
||||
// index past the end). Rewind so the re-run actually walks instead of
|
||||
// silently doing nothing. Cannot loop: completion always disables nav, and
|
||||
// Tick returns early while it is disabled.
|
||||
if (route.RouteType == NavRouteType.Once
|
||||
&& _settings.ActiveNavIndex >= route.Points.Count
|
||||
&& route.Points.Count > 0)
|
||||
// Nav was switched on over a finished Once route (CompleteOnceRoute leaves the
|
||||
// index past the end). This used to rewind it to [0], so anything that turned nav
|
||||
// on re-ran the route: a meta's "/vt opt set enablenav true" replayed by a macro
|
||||
// start, an expression. It stays finished, as a finished VTank Once route (its
|
||||
// points used up) does; the player's Nav switch / Start Navigation button and
|
||||
// /ra nav restart rewind it before nav gets here. Nav goes off again so the
|
||||
// arbiter doesn't hold "Navigating" (above combat with BoostNavPriority) for a
|
||||
// route with nothing left to walk.
|
||||
if (_settings.NavRouteFinished())
|
||||
{
|
||||
_host.Log("Nav: Once route re-armed — restarting from point [0]");
|
||||
_settings.ActiveNavIndex = 0;
|
||||
_settings.EnableNavigation = false;
|
||||
StopMovement();
|
||||
_host.Log($"Nav: the Once route is finished ({route.Points.Count} pts) — nav stays off; load it again or /ra nav restart to re-run it");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ public sealed partial class RynthAiPlugin
|
|||
ChatLine("[RynthAi] /ra nav save [name] — save the route; a name saves it as <name>.nav");
|
||||
ChatLine("[RynthAi] /ra nav load <name> — load a nav from NavProfiles (none by that name: a new empty one)");
|
||||
ChatLine("[RynthAi] /ra nav list — list the navs in NavProfiles");
|
||||
ChatLine("[RynthAi] /ra nav restart — run the loaded route again from its first point (a stop/start keeps its place; a finished Once route stays done)");
|
||||
ChatLine("[RynthAi] /ra meta load <name> — load a meta from MetaFiles (none by that name: a new blank one)");
|
||||
ChatLine("[RynthAi] /ra meta new <name> — create a blank meta and load it");
|
||||
ChatLine("[RynthAi] /ra meta list — list the metas in MetaFiles");
|
||||
|
|
@ -1148,8 +1149,24 @@ public sealed partial class RynthAiPlugin
|
|||
var names = _dashboard.NavFileNames();
|
||||
ChatLine(names.Count == 0 ? "[RynthAi] No navs in NavProfiles." : $"[RynthAi] Navs ({names.Count}): {string.Join(", ", names)}");
|
||||
break;
|
||||
case "restart":
|
||||
{
|
||||
// Stopping and starting the macro keeps the route where it was (a finished Once
|
||||
// route stays finished); this is the way to run it again from the top on purpose.
|
||||
var route = _dashboard.Settings.CurrentRoute;
|
||||
if (_navigationEngine == null) { ChatLine("[RynthAi] Navigation engine not ready."); break; }
|
||||
if (!_navigationEngine.RestartRoute())
|
||||
{
|
||||
ChatLine(route != null && route.RouteType == NavRouteType.Follow && route.FollowTargetName.Length > 0
|
||||
? "[RynthAi] A Follow route has no waypoints to restart."
|
||||
: "[RynthAi] No nav route loaded to restart.");
|
||||
break;
|
||||
}
|
||||
ChatLine($"[RynthAi] Nav route restarted from its first point ({route!.RouteType}, {route.Points.Count} waypoints).");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ChatLine("[RynthAi] /ra nav save [name] | /ra nav load <name> | /ra nav list");
|
||||
ChatLine("[RynthAi] /ra nav save [name] | /ra nav load <name> | /ra nav list | /ra nav restart");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1795,7 +1795,10 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
// The hold timer keys off wantBuffRaw, NOT off the decision: keying it
|
||||
// off the decision would reset it on the bypass tick itself and the
|
||||
// ~10s retry cadence would silently become "once every 5 minutes".
|
||||
if (!wantBuffRaw)
|
||||
// Only while the macro runs (2026-10-28): stopped mid-heal, buffing still "wanted"
|
||||
// a vital recharge nothing acts on, and 5 min later a stopped character was told
|
||||
// buffing was stuck (stance wedge?) with nothing wrong.
|
||||
if (!wantBuffRaw || !settings.IsMacroRunning)
|
||||
{
|
||||
_buffingHeldSince = DateTime.MinValue;
|
||||
_buffComaWarned = false;
|
||||
|
|
|
|||
Loading…
Reference in a new issue