Snapshot for release 2026.10.22.2 (internal e613280)
This commit is contained in:
parent
10c58b53b6
commit
893973d0dd
16 changed files with 871 additions and 188 deletions
|
|
@ -6,23 +6,25 @@
|
|||
// Measured by health, not by counting heal attempts: a round of FailsafeRoundMs
|
||||
// with no rise of FailsafeRiseMinPct counts as a failed round (whatever the
|
||||
// reason: a stuck cast, 'too busy', no mana, no kits).
|
||||
// 1. FailsafeRoundsToBreak failed rounds: ActionPacer.ForceBreak (a jump; on
|
||||
// ACE's fast tick it fails the cast in progress, Player.HandleActionJump).
|
||||
// Starts are held until landed, then the vitals step heals again.
|
||||
// 2. FailsafeRoundsToRecall more failed rounds after the break: recall to the
|
||||
// lifestone ("/lifestone", ACE GameAction TeleToLifestone) when
|
||||
// HpFailsafeRecall is on. The macro is switched off first, because ACE
|
||||
// cancels the recall when the character moves during its animation and
|
||||
// refuses it while busy (Player_Location.HandleActionTeleToLifestone).
|
||||
// 3. No "<our name> is recalling to the lifestone." after RecallMaxSends tries
|
||||
// (ACE refuses the recall while busy, under a PK timer or with recalls
|
||||
// disabled, which is just the stuck state this is for): the macro is
|
||||
// switched back on, so the heals and kits run again, and the failsafe
|
||||
// re-arms; the next recall waits RecallCooldownMs. A failed recall must not
|
||||
// leave the character standing at low health with nothing running. Only a
|
||||
// macro the failsafe itself stopped is switched back on, never past a VTank
|
||||
// yield (MayRestartMacro), and a death drops the pending recall (the player's
|
||||
// Stop Macro On Death stands).
|
||||
// 1. FailsafeRoundsToBreak failed rounds (FailsafeRoundsToRecallBreak with
|
||||
// HpFailsafeRecall on): ActionPacer.ForceBreak (a jump; on ACE's fast tick it
|
||||
// fails the cast in progress, Player.HandleActionJump). Starts are held until
|
||||
// landed, then the vitals step heals again.
|
||||
// 2. HpFailsafeRecall on: at once, with the jump, the Lifestone Recall SPELL
|
||||
// (RecallSpellId), not "/lifestone" (2026-10-22: /lifestone's long kneel was
|
||||
// killing characters, and a move during it cancels it). The macro is switched
|
||||
// off first so nothing else casts, swings or moves over it; the recall goes on
|
||||
// the next heartbeat, through the emergency heal's Magic stance step, and is
|
||||
// cast again every RecallResendMs until portal space shows it went. No recall
|
||||
// for a character without the spell or the mana for it: it keeps healing.
|
||||
// Recall off: FailsafeRoundsToRecall more failed rounds are only logged.
|
||||
// 3. No portal space after RecallMaxSends casts, or by RecallGiveUpMs (refused:
|
||||
// busy, out of mana, a fizzle run): the macro is switched back on, so the
|
||||
// heals and kits run again, and the failsafe re-arms; the next recall waits
|
||||
// RecallCooldownMs. A failed recall must not leave the character standing at
|
||||
// low health with nothing running. Only a macro the failsafe itself stopped is
|
||||
// switched back on, never past a VTank yield (MayRestartMacro), and a death
|
||||
// drops the pending recall (the player's Stop Macro On Death stands).
|
||||
// Health back over the line (or 100%) ends the episode. Nothing counts in portal space.
|
||||
// The failsafe (jump included) is for a character that can heal: it arms only with a heal that went
|
||||
// out in the last minute, or a heal spell / kit / health potion at hand (HealCapableNow). A melee
|
||||
|
|
@ -38,17 +40,20 @@ public partial class BuffManager
|
|||
{
|
||||
internal const double FailsafeRoundMs = 2500;
|
||||
internal const int FailsafeRoundsToBreak = 3;
|
||||
/// <summary>With HpFailsafeRecall on, the jump (and the recall with it) comes sooner: 5 s, not 7.5 s.</summary>
|
||||
internal const int FailsafeRoundsToRecallBreak = 2;
|
||||
internal const int FailsafeRoundsToRecall = 3;
|
||||
// A rise this large (health %) means a heal landed; natural regeneration is smaller.
|
||||
private const int FailsafeRiseMinPct = 3;
|
||||
// The recall goes this long after the macro stop (the stop edge runs on the next tick),
|
||||
// and is sent again this often, a few times, until our "is recalling to the lifestone" is seen.
|
||||
private const double RecallFirstDelayMs = 600;
|
||||
private const double RecallResendMs = 1500;
|
||||
private const int RecallMaxSends = 3;
|
||||
/// <summary>Lifestone Recall, the spell (SpellDatabase).</summary>
|
||||
internal const int RecallSpellId = 1635;
|
||||
// The recall is cast again this often until portal space shows it went (a fizzle, a refusal),
|
||||
// at most RecallMaxSends times, and given up RecallGiveUpMs after the macro stop.
|
||||
internal const double RecallResendMs = 3000;
|
||||
internal const int RecallMaxSends = 3;
|
||||
internal const double RecallGiveUpMs = 12_000;
|
||||
/// <summary>After a recall that never started, the next one waits this long (the heals run meanwhile).</summary>
|
||||
internal const double RecallCooldownMs = 30_000;
|
||||
internal const string RecallCommand = "/lifestone";
|
||||
|
||||
private bool _fsActive;
|
||||
private DateTime _fsRoundStart;
|
||||
|
|
@ -59,9 +64,11 @@ public partial class BuffManager
|
|||
private DateTime _fsRecallNotBefore = DateTime.MinValue;
|
||||
|
||||
private bool _recallPending;
|
||||
private bool _recallSeen;
|
||||
private int _recallSends;
|
||||
private DateTime _recallNextAt;
|
||||
private DateTime _recallStartedAt;
|
||||
private string _recallWait = "";
|
||||
private bool _fsNoRecallLogged;
|
||||
|
||||
/// <summary>Set by the plugin: the rest of a /ra stop (nav stop, pause cancel) for the recall.</summary>
|
||||
internal Action? MacroStopForRecall { get; set; }
|
||||
|
|
@ -70,7 +77,6 @@ public partial class BuffManager
|
|||
|
||||
// The macro is off because the failsafe stopped it for a recall (only then does it switch it back on).
|
||||
private bool _macroStoppedByFailsafe;
|
||||
private bool _recallNameLogged;
|
||||
|
||||
internal int HpFailsafeBreaks { get; private set; }
|
||||
internal int HpFailsafeRecalls { get; private set; }
|
||||
|
|
@ -121,19 +127,30 @@ public partial class BuffManager
|
|||
_fsFailedRounds++;
|
||||
_fsRoundStart = now;
|
||||
double failedSec = _fsFailedRounds * FailsafeRoundMs / 1000.0;
|
||||
bool recallOn = _settings.HpFailsafeRecall;
|
||||
if (!_fsBroken)
|
||||
{
|
||||
if (_fsFailedRounds < FailsafeRoundsToBreak) return;
|
||||
if (_fsFailedRounds < (recallOn ? FailsafeRoundsToRecallBreak : FailsafeRoundsToBreak)) return;
|
||||
string why = $"HP failsafe: health {hp}% at or under Emergency Heal At {at}%, no heal landed in {failedSec:0.#} s";
|
||||
bool jumped = ActionPacer.ForceBreak(_host, why);
|
||||
if (jumped) HpFailsafeBreaks++;
|
||||
_host.Log($"[Vitals] {why}: {(jumped ? "breaking the cast with a jump, then healing again" : "no jump available (or one under way), healing again")}.");
|
||||
_fsBroken = true;
|
||||
_fsFailedRounds = 0;
|
||||
string? noRecall = recallOn ? RecallUnavailable(now) : null;
|
||||
if (recallOn && noRecall == null)
|
||||
{
|
||||
// No more waiting: the jump frees a stuck cast and the recall goes on the next heartbeat.
|
||||
_host.Log($"[Vitals] {why}: {(jumped ? "breaking the cast with a jump" : "no jump available (or one under way)")}, then Lifestone Recall at once.");
|
||||
StartFailsafeRecall(now, hp, failedSec);
|
||||
return;
|
||||
}
|
||||
_host.Log($"[Vitals] {why}: {(jumped ? "breaking the cast with a jump, then healing again" : "no jump available (or one under way), healing again")}" +
|
||||
(noRecall != null ? $"; no recall: {noRecall}" : "") + ".");
|
||||
if (noRecall != null) _fsNoRecallLogged = true;
|
||||
return;
|
||||
}
|
||||
if (_fsFailedRounds < FailsafeRoundsToRecall) return;
|
||||
if (!_settings.HpFailsafeRecall)
|
||||
if (!recallOn)
|
||||
{
|
||||
if (!_fsRecallLogged)
|
||||
{
|
||||
|
|
@ -149,9 +166,35 @@ public partial class BuffManager
|
|||
_fsFailedRounds = 0;
|
||||
return;
|
||||
}
|
||||
string? cannot = RecallUnavailable(now);
|
||||
if (cannot != null)
|
||||
{
|
||||
if (!_fsNoRecallLogged)
|
||||
{
|
||||
_fsNoRecallLogged = true;
|
||||
_host.Log($"[Vitals] HP failsafe: health {hp}%, heals still failing {failedSec:0.#} s after the break; no recall: {cannot}.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
StartFailsafeRecall(now, hp, failedSec);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Why the Lifestone Recall spell can't go now (null = it can): the cooldown after one that never
|
||||
/// started, a spellbook that hasn't got it, or less mana than it costs. The character keeps healing.
|
||||
/// </summary>
|
||||
private string? RecallUnavailable(DateTime now)
|
||||
{
|
||||
if (now < _fsRecallNotBefore)
|
||||
return $"the last recall never started, the next in {(_fsRecallNotBefore - now).TotalSeconds:0} s";
|
||||
if (_spellManager.IsKnownSnapshotWarm && !_spellManager.IsKnownSpellId(RecallSpellId))
|
||||
return "this character doesn't know Lifestone Recall";
|
||||
int cost = SpellManaCost(RecallSpellId);
|
||||
if (cost > 0 && _vitals.MaxMana > 0 && _vitals.CurrentMana < cost)
|
||||
return $"mana {_vitals.CurrentMana} is under Lifestone Recall's cost ({cost})";
|
||||
return null;
|
||||
}
|
||||
|
||||
// A heal (spell, kit or potion) that actually went out: the failsafe's proof the character can heal.
|
||||
private DateTime _lastHealSentAt = DateTime.MinValue;
|
||||
private DateTime _healCapableCheckAt = DateTime.MinValue;
|
||||
|
|
@ -211,6 +254,7 @@ public partial class BuffManager
|
|||
_fsFailedRounds = 0;
|
||||
_fsBroken = false;
|
||||
_fsRecallLogged = false;
|
||||
_fsNoRecallLogged = false;
|
||||
}
|
||||
|
||||
private void StartFailsafeRecall(DateTime now, int hp, double failedSec)
|
||||
|
|
@ -218,28 +262,33 @@ public partial class BuffManager
|
|||
HpFailsafeRecalls++;
|
||||
_settings.IsMacroRunning = false;
|
||||
_macroStoppedByFailsafe = true;
|
||||
_recallNameLogged = false;
|
||||
MacroStopForRecall?.Invoke();
|
||||
// The heal the jump broke is not waited on, here or by the pacer: a stuck cast may never be
|
||||
// answered, and the recall must not wait for its breaker steps (seconds). It still waits to
|
||||
// land from the jump (ActionPacer's airborne hold is kept).
|
||||
if (_pendingSpellId != 0 && _pendingSpellId == _pendingVitalSpellId) _pendingSpellId = 0;
|
||||
ActionPacer.Forget("HP failsafe recall");
|
||||
_recallPending = true;
|
||||
_recallSeen = false;
|
||||
_recallSends = 0;
|
||||
_recallNextAt = now.AddMilliseconds(RecallFirstDelayMs);
|
||||
string line = $"HP failsafe: health {hp}%, heals still failing {failedSec:0.#} s after the break: macro stopped, recalling to the lifestone.";
|
||||
_recallStartedAt = now;
|
||||
_recallNextAt = now; // the next heartbeat: the macro-stop edge has run by then
|
||||
_recallWait = "";
|
||||
string line = $"HP failsafe: health {hp}%, no heal landed in {failedSec:0.#} s: casting Lifestone Recall (macro off until it goes; back on if it can't).";
|
||||
_host.Log("[Vitals] " + line);
|
||||
_host.WriteToChat("[RynthAi] " + line, 2);
|
||||
ResetHpFailsafe();
|
||||
}
|
||||
|
||||
/// <summary>Every heartbeat, macro running or not: sends a pending recall, or gives up on it.</summary>
|
||||
/// <summary>Every heartbeat, macro running or not: casts a pending recall, or gives up on it.</summary>
|
||||
private void TickFailsafeRecall()
|
||||
{
|
||||
if (!_recallPending) return;
|
||||
DateTime now = Now;
|
||||
if (_recallSeen)
|
||||
if (Portaling())
|
||||
{
|
||||
_recallPending = false;
|
||||
_macroStoppedByFailsafe = false;
|
||||
_host.Log("[Vitals] HP failsafe: the recall started.");
|
||||
_host.Log($"[Vitals] HP failsafe: the recall went (portal space, {(now - _recallStartedAt).TotalMilliseconds:0} ms after the stop, {_recallSends} cast(s)).");
|
||||
return;
|
||||
}
|
||||
if (_vitals.MaxHealth > 0 && _vitals.CurrentHealth == 0)
|
||||
|
|
@ -255,15 +304,16 @@ public partial class BuffManager
|
|||
_host.Log("[Vitals] HP failsafe: the macro was started again; the recall is dropped.");
|
||||
return;
|
||||
}
|
||||
if (now < _recallNextAt) return;
|
||||
if (_recallSends >= RecallMaxSends || !_host.HasInvokeChatParser)
|
||||
bool spent = _recallSends >= RecallMaxSends && now >= _recallNextAt;
|
||||
bool late = (now - _recallStartedAt).TotalMilliseconds >= RecallGiveUpMs;
|
||||
if (spent || late || !_host.HasCastSpell)
|
||||
{
|
||||
_recallPending = false;
|
||||
HpFailsafeRecallsFailed++;
|
||||
_fsRecallNotBefore = now.AddMilliseconds(RecallCooldownMs);
|
||||
string why = _host.HasInvokeChatParser
|
||||
? $"no recall seen after {_recallSends} tries of {RecallCommand} (refused: busy, a PK timer or recalls disabled)"
|
||||
: "this engine has no chat parser, so no recall";
|
||||
string why = !_host.HasCastSpell ? "this engine can't cast, so no recall"
|
||||
: _recallSends == 0 ? $"Lifestone Recall couldn't be cast in {RecallGiveUpMs / 1000:0} s ({(_recallWait.Length > 0 ? _recallWait : "no reason seen")})"
|
||||
: $"no portal space after {_recallSends} cast(s) of Lifestone Recall (refused or fizzled)";
|
||||
string what;
|
||||
if (!_macroStoppedByFailsafe) what = "the macro stays as it is";
|
||||
else if (MayRestartMacro != null && !MayRestartMacro()) what = "the macro stays off (VTank yield)";
|
||||
|
|
@ -278,14 +328,45 @@ public partial class BuffManager
|
|||
_host.WriteToChat("[RynthAi] " + line, 2);
|
||||
return;
|
||||
}
|
||||
_host.InvokeChatParser(RecallCommand);
|
||||
if (now < _recallNextAt || _recallSends >= RecallMaxSends) return;
|
||||
string wait = RecallCastHolds();
|
||||
if (wait.Length > 0)
|
||||
{
|
||||
if (wait != _recallWait) _host.Log($"[Vitals] HP failsafe: Lifestone Recall waits: {wait}.");
|
||||
_recallWait = wait;
|
||||
return;
|
||||
}
|
||||
_recallWait = "";
|
||||
uint me = unchecked((uint)_host.GetPlayerId());
|
||||
bool sent = me != 0 && _host.CastSpellFor(me, RecallSpellId, "HpFailsafe", "Lifestone Recall");
|
||||
_lastCastAttempt = RynthClock.Now;
|
||||
if (!sent)
|
||||
{
|
||||
_recallWait = "the client refused the cast";
|
||||
_recallNextAt = now.AddMilliseconds(500);
|
||||
return;
|
||||
}
|
||||
_recallSends++;
|
||||
_recallNextAt = now.AddMilliseconds(RecallResendMs);
|
||||
_host.Log($"[Vitals] HP failsafe: Lifestone Recall cast ({_recallSends}/{RecallMaxSends}, {(now - _recallStartedAt).TotalMilliseconds:0} ms after the stop).");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// What holds the recall cast back now ("" = nothing): the Magic stance (the emergency heal's step,
|
||||
/// wand swap included) and the pacer at emergency health (in the air after the jump, a server
|
||||
/// answer it must wait for). Nothing else of RynthAi runs meanwhile: the macro is off.
|
||||
/// </summary>
|
||||
private string RecallCastHolds()
|
||||
{
|
||||
if (!EnsureMagicMode(urgentHeal: true))
|
||||
return _magicModeBlocked ? "can't switch to Magic mode" : "wand swap / Magic stance";
|
||||
if (!PacerAllows(out string pacerWhy)) return "the server: " + pacerWhy;
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The plugin's death hold (and a 0-health read): a pending recall is dropped and the macro is
|
||||
/// left off, so nothing re-sends /lifestone or restarts the macro after the respawn.
|
||||
/// left off, so nothing casts the recall again or restarts the macro after the respawn.
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// A death or a portal dropped whatever the server had open: a wand use in flight is forgotten,
|
||||
|
|
@ -306,32 +387,4 @@ public partial class BuffManager
|
|||
_macroStoppedByFailsafe = false;
|
||||
_host.Log($"[Vitals] HP failsafe: the pending recall is dropped ({why}); the macro stays off.");
|
||||
}
|
||||
|
||||
/// <summary>OnChatWindowText: "<our name> is recalling to the lifestone." while a recall is pending.</summary>
|
||||
private void ObserveRecallLine(string lower)
|
||||
{
|
||||
if (!_recallPending || !lower.Contains("is recalling to the lifestone")) return;
|
||||
string me = "";
|
||||
try
|
||||
{
|
||||
uint id = unchecked((uint)_host.GetPlayerId());
|
||||
if (id != 0 && _host.HasGetObjectName && _host.TryGetObjectName(id, out string n)) me = n ?? "";
|
||||
}
|
||||
catch { me = ""; }
|
||||
// Someone else's recall ("Bob is recalling to the lifestone.") is not ours. The chat layer
|
||||
// can drop a line's first letter ("ou cast ..."), so the name may arrive without it.
|
||||
if (me.Length > 0)
|
||||
{
|
||||
string who = lower.Substring(0, lower.IndexOf(" is recalling to the lifestone", StringComparison.Ordinal)).Trim();
|
||||
string mine = me.ToLowerInvariant();
|
||||
bool ours = who == mine || (who.Length == mine.Length - 1 && who.Length > 0 && mine.EndsWith(who, StringComparison.Ordinal));
|
||||
if (!ours) return;
|
||||
}
|
||||
else if (!_recallNameLogged)
|
||||
{
|
||||
_recallNameLogged = true;
|
||||
_host.Log("[Vitals] HP failsafe: our name could not be read; any 'is recalling to the lifestone' line is taken as ours.");
|
||||
}
|
||||
_recallSeen = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4272,7 +4272,6 @@ public partial class BuffManager : IDisposable
|
|||
public void OnChatWindowText(string text, int chatType)
|
||||
{
|
||||
string lower = text.ToLowerInvariant();
|
||||
ObserveRecallLine(lower);
|
||||
|
||||
// A scroll read that taught a spell (ACE: "The scroll is destroyed."): read the spellbook on
|
||||
// the next buff check, so a newly learned higher level is cast (an upgrade) at once.
|
||||
|
|
|
|||
|
|
@ -672,10 +672,12 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
ImGui.Checkbox("HP Failsafe Recall", ref _settings.HpFailsafeRecall);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(
|
||||
"At or under Emergency Heal At with heals failing: break the\n" +
|
||||
"stuck cast with a jump and heal again; if that fails too,\n" +
|
||||
"recall to the lifestone. Off by default; only a character that\n" +
|
||||
"can heal (a heal spell, kit or potion) is ever recalled.");
|
||||
"At or under Emergency Heal At with no heal landing for 5 s:\n" +
|
||||
"break the stuck cast with a jump and cast Lifestone Recall at\n" +
|
||||
"once (the spell, not /ls). The macro waits while it casts and\n" +
|
||||
"comes back on if the recall can't go. Needs the spell and its\n" +
|
||||
"mana; only a character that can heal (a heal spell, kit or\n" +
|
||||
"potion) is ever recalled. Off: the jump only, after 7.5 s.");
|
||||
|
||||
ImGui.SetNextItemWidth(180);
|
||||
ImGui.SliderInt("Attack Spell Delay (ms)", ref _settings.AttackSpellIntervalMs, 0, 5000);
|
||||
|
|
|
|||
|
|
@ -451,9 +451,14 @@ public sealed class LegacyUiSettings
|
|||
|
||||
/// <summary>
|
||||
/// HP failsafe: at or under Emergency Heal At with heals failing for a while, the stuck-cast
|
||||
/// breaker runs and the heal is tried again; when that fails too, recall to the lifestone.
|
||||
/// breaker runs and the Lifestone Recall spell is cast at once (BuffManager.HpFailsafe.cs).
|
||||
/// Off: the breaker still runs, no recall.
|
||||
/// Saved under a new name since 2026-10-22, so it is off for everyone until ticked again: the
|
||||
/// recall stops the macro (heals included) in the middle of a fight, and it was killing players.
|
||||
/// The 10-18 default change only reached profiles that never saved it; an old saved
|
||||
/// "HpFailsafeRecall": true (the default until then) no longer loads.
|
||||
/// </summary>
|
||||
[JsonPropertyName("HpFailsafeRecallOptIn")]
|
||||
public bool HpFailsafeRecall = false;
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -205,6 +205,12 @@ internal sealed partial class ExpressionEngine
|
|||
private KillClock? _killClock;
|
||||
public void SetKillClock(KillClock? clock) => _killClock = clock;
|
||||
|
||||
// ratargetcount[] (RynthAi only, 2026-10-22): the targets that passed every combat filter in combat's
|
||||
// last scan (CombatManager.LastScanPossible). -1 before the first scan or with no combat manager. The
|
||||
// self-test meta uses it to tell "nothing here to fight" from "a fight that never happened":
|
||||
// wobjectfindnearestmonster[] also finds attackable NPCs (a buff bot) combat rightly leaves alone.
|
||||
internal Func<int>? CombatTargetCount { get; set; }
|
||||
|
||||
// ── Backward-compat shim ──────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Executes an expression for its side effects. Always returns true.</summary>
|
||||
|
|
@ -386,6 +392,7 @@ internal sealed partial class ExpressionEngine
|
|||
"getunixtime" => DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
// Whole seconds since our last kill; before the first, since the macro start (or login).
|
||||
"secondssincelastkill" => (_killClock?.SecondsSinceLastKill() ?? 0).ToString(CultureInfo.InvariantCulture),
|
||||
"ratargetcount" => (CombatTargetCount?.Invoke() ?? -1).ToString(CultureInfo.InvariantCulture),
|
||||
|
||||
// ── World object queries ──────────────────────────────────────────
|
||||
"wobjectfindnearestbytemplatetype" => EvalWobjectFindNearestByTemplateType(A(0)),
|
||||
|
|
|
|||
|
|
@ -188,6 +188,14 @@ internal sealed class MetaManager
|
|||
if (_expressions != null) _expressions.CorpseOpenedByMe = check;
|
||||
}
|
||||
|
||||
// Combat's target count for ratargetcount[] (the last scan's candidates).
|
||||
private Func<int>? _combatTargetCount;
|
||||
public void SetCombatTargetCount(Func<int>? count)
|
||||
{
|
||||
_combatTargetCount = count;
|
||||
if (_expressions != null) _expressions.CombatTargetCount = count;
|
||||
}
|
||||
|
||||
public void SetPlayerId(uint id)
|
||||
{
|
||||
_playerId = id;
|
||||
|
|
@ -241,6 +249,7 @@ internal sealed class MetaManager
|
|||
engine.SetCreatureStore(_creatureStore);
|
||||
engine.SetKillClock(_killClock);
|
||||
engine.CorpseOpenedByMe = _corpseOpenedByMe;
|
||||
engine.CombatTargetCount = _combatTargetCount;
|
||||
// vtsetsetting[] / vtgetsetting[] take VTank names and units, as '/vt opt set|get' does.
|
||||
engine.VtOptionSetter = TrySetVtOption;
|
||||
engine.VtOptionGetter = GetVtOption;
|
||||
|
|
|
|||
|
|
@ -791,6 +791,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
_metaManager.SetCreatureStore(_creatureStore);
|
||||
_metaManager.SetKillClock(_killClock);
|
||||
_metaManager.SetCorpseOpenedCheck(id => _completedCorpses.ContainsKey(id));
|
||||
_metaManager.SetCombatTargetCount(() => _combatManager?.LastScanPossible ?? -1);
|
||||
if (_dashboard != null)
|
||||
_dashboard.MetaSnapshotProvider = () => _metaManager?.GetStateSnapshot();
|
||||
|
||||
|
|
|
|||
|
|
@ -45,17 +45,56 @@ internal sealed class Atlas
|
|||
public string Generated { get; }
|
||||
public string Path { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The recalls' landing spots as places of type <see cref="RecallType"/> (2026-10-22), for
|
||||
/// finding a place by name (<see cref="Search"/>, <see cref="FindBest"/>): the world database
|
||||
/// names only the /telepoi towns, so "neft" found nothing while Lost City of Neftet Recall lands
|
||||
/// there. Kept out of <see cref="Locations"/>, which the route planner reads. The engine's
|
||||
/// Atlas panel lists the same places (RynthCore UI/Data/RynthNavAtlasRecalls.cs).
|
||||
/// </summary>
|
||||
public IReadOnlyList<AtlasLocation> RecallPlaces { get; }
|
||||
public const string RecallType = "Recall";
|
||||
|
||||
private readonly Dictionary<int, AtlasLocation> _byId = new();
|
||||
|
||||
private Atlas(List<AtlasLocation> locations, List<AtlasRecall> recalls, string generated, string path)
|
||||
{
|
||||
Locations = locations;
|
||||
Recalls = recalls;
|
||||
RecallPlaces = RecallPlacesOf(recalls);
|
||||
Generated = generated;
|
||||
Path = path;
|
||||
foreach (var l in locations) _byId[l.Id] = l;
|
||||
}
|
||||
|
||||
private static List<AtlasLocation> RecallPlacesOf(List<AtlasRecall> recalls)
|
||||
{
|
||||
var places = new List<AtlasLocation>();
|
||||
var seen = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var r in recalls)
|
||||
{
|
||||
string name = r.Name.Trim();
|
||||
// A spell listed twice for one spot (Ulgrim's Recall) is one place.
|
||||
string key = string.Create(CultureInfo.InvariantCulture, $"{name}|{r.OnMap}|{r.Ns:0.00}|{r.Ew:0.00}|{r.In}");
|
||||
if (name.Length == 0 || !seen.Add(key)) continue;
|
||||
places.Add(new AtlasLocation
|
||||
{
|
||||
Id = -r.SpellId, // locations have positive ids
|
||||
Name = name, Type = RecallType, OnMap = r.OnMap, Ns = r.Ns, Ew = r.Ew,
|
||||
Place = r.OnMap ? "outdoor" : "dungeon",
|
||||
Desc = r.In.Length > 0 ? "in " + r.In : "",
|
||||
});
|
||||
}
|
||||
return places;
|
||||
}
|
||||
|
||||
/// <summary>What a name search looks through: the locations, then the recall places.</summary>
|
||||
private IEnumerable<AtlasLocation> Searchable()
|
||||
{
|
||||
foreach (var l in Locations) yield return l;
|
||||
foreach (var l in RecallPlaces) yield return l;
|
||||
}
|
||||
|
||||
public static Atlas Load(string path) => Parse(File.ReadAllText(path), path);
|
||||
|
||||
public static Atlas Parse(string json, string path = "")
|
||||
|
|
@ -185,6 +224,7 @@ internal sealed class Atlas
|
|||
"Town" => 0,
|
||||
"Dungeon" => 1,
|
||||
"Landmark" => 2,
|
||||
RecallType => 2,
|
||||
"Lifestone" => 3,
|
||||
"Bindstone" => 4,
|
||||
"Portal" => 5,
|
||||
|
|
@ -205,7 +245,7 @@ internal sealed class Atlas
|
|||
AtlasLocation? best = null;
|
||||
int bestScore = 0, bestRank = int.MaxValue;
|
||||
double bestDist = double.MaxValue;
|
||||
foreach (var l in Locations)
|
||||
foreach (var l in Searchable())
|
||||
{
|
||||
if (!l.OnMap) continue;
|
||||
int s = MatchScore(l.Name, q);
|
||||
|
|
@ -229,7 +269,7 @@ internal sealed class Atlas
|
|||
{
|
||||
string q = query.Trim();
|
||||
var hits = new List<(AtlasLocation L, int S)>();
|
||||
foreach (var l in Locations)
|
||||
foreach (var l in Searchable())
|
||||
{
|
||||
if (!string.IsNullOrEmpty(type) && !l.Type.Equals(type, StringComparison.OrdinalIgnoreCase)) continue;
|
||||
int s = MatchScore(l.Name, q);
|
||||
|
|
|
|||
Loading…
Reference in a new issue