feat: port SK test branch (2026.10.18.24) onto sk
Squash of test/hotbuild-2026-10-16 as merged onto aelrynth main 2026.10.17.1, matching the 2026.10.18.24 test installer. The test branch wins where both changed the same lines; sk-only changes kept; duplicate features cut to the test branch's copy. RynthAi HandWrittenVersion stays 0.5.0-legacy-ui on sk. Highlights: RynthOracle 0.6.0 (Legendary, Markers, Dynamic Stamps and Temple guardians merged into the Quests list, RynthNav Go to), RynthILT 0.2.20 (ub-IT auto-chunk rules, rating level, RynthILT.Data v3), RynthAi ub-IT /ub and VT/MT meta compatibility and the loot attribute checklist, RynthNav destination alternatives. Changelog/2026-10-18-sk-port-test-branch-2026.10.18.24.md.
This commit is contained in:
parent
23efcfee87
commit
7797901d69
287 changed files with 22602 additions and 1090 deletions
|
|
@ -4,7 +4,8 @@
|
|||
ServerData.cs holds what is known about the server. -->
|
||||
<PropertyGroup>
|
||||
<AssemblyName>RynthCore.Plugin.RynthAChard</AssemblyName>
|
||||
<Version>0.1.0</Version>
|
||||
<!-- Previous release: 0.1.2. -->
|
||||
<Version>0.1.4</Version>
|
||||
<RynthPluginServerId>achard</RynthPluginServerId>
|
||||
<RynthPluginServerName>AChard</RynthPluginServerName>
|
||||
<RynthPluginServerHosts>a-chard.ddns.net</RynthPluginServerHosts>
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@
|
|||
The build is shared (..\Shared\ServerPack\ServerPlugin.props); ServerData.cs holds what is known. -->
|
||||
<PropertyGroup>
|
||||
<AssemblyName>RynthCore.Plugin.RynthAelrynth</AssemblyName>
|
||||
<Version>0.1.0</Version>
|
||||
<!-- Previous release: 0.1.2. -->
|
||||
<Version>0.1.4</Version>
|
||||
<RynthPluginServerId>aelrynth</RynthPluginServerId>
|
||||
<RynthPluginServerName>Aelrynth</RynthPluginServerName>
|
||||
<RynthPluginServerHosts>aelrynth.com</RynthPluginServerHosts>
|
||||
<RynthPluginServerHosts>aelrynth.com|144.217.84.148</RynthPluginServerHosts>
|
||||
<RynthPluginServerWorldNames>Aelrynth*|Aeshnidae*</RynthPluginServerWorldNames>
|
||||
<RynthPluginDescription>Aelrynth only: the server card (its mods, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ internal static class ServerData
|
|||
public static ServerPackInfo Create() =>
|
||||
new(RynthPluginInfo.ServerId, RynthPluginInfo.ServerName, RynthPluginInfo.ServerHosts, RynthPluginInfo.ServerWorldNames)
|
||||
{
|
||||
// The live world; staging runs on 9030 on the same host.
|
||||
Port = 9020,
|
||||
Emulator = "ACE",
|
||||
Ruleset = "PvE",
|
||||
|
|
@ -18,6 +19,7 @@ internal static class ServerData
|
|||
"Skill Mastery mod (RynthCore shows mastery progress).",
|
||||
"Account vault for mules (RynthCore reads its contents).",
|
||||
"RynthOracle has an Aelrynth quest pack (quests.aelrynth.csv).",
|
||||
"A staging world runs on port 9030 of the same host.",
|
||||
"The world was named Aeshnidae before; both names count.",
|
||||
},
|
||||
Website = "https://aelrynth.com",
|
||||
|
|
|
|||
119
Plugins/RynthCore.Plugin.RynthAi/Combat/AttackPowerPlanner.cs
Normal file
119
Plugins/RynthCore.Plugin.RynthAi/Combat/AttackPowerPlanner.cs
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
using System;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi;
|
||||
|
||||
// ============================================================================
|
||||
// Per-monster attack power (2026-10-12): MonsterRule.AttackPower.
|
||||
//
|
||||
// Default the DEFAULT line's choice; on the DEFAULT line, the global
|
||||
// Melee/Missile Power settings (Auto = 100%, or 80% with Use
|
||||
// Recklessness and the skill trained)
|
||||
// High 100% every swing or shot
|
||||
// Reckless 80%: inside the band where Recklessness adds damage (ACE:
|
||||
// 10%-90% of the bar, retail wiki: 20%-80%, so 80% is in both)
|
||||
// Variable a new random power each attack, Variable Power Min..Max
|
||||
// Reckless + Variable random each attack, inside the Recklessness band (20%-80%)
|
||||
// and the Variable range
|
||||
//
|
||||
// Recklessness only adds damage when the skill is trained or specialized; with it
|
||||
// untrained a reckless choice falls back to High (or Variable), since a short bar
|
||||
// would only cost damage. Magic doesn't use attack power.
|
||||
// ============================================================================
|
||||
|
||||
/// <summary>Names and resolution of <see cref="MonsterRule.AttackPower"/>.</summary>
|
||||
public static class AttackPowerModes
|
||||
{
|
||||
public const string Default = "Default";
|
||||
public const string High = "High";
|
||||
public const string Reckless = "Reckless";
|
||||
public const string Variable = "Variable";
|
||||
public const string RecklessVariable = "Reckless + Variable";
|
||||
|
||||
/// <summary>Every choice, in the order the editors list them.</summary>
|
||||
public static readonly string[] All = { Default, High, Reckless, Variable, RecklessVariable };
|
||||
|
||||
/// <summary>The bar fraction a fixed reckless attack uses.</summary>
|
||||
public const float RecklessPower = 0.8f;
|
||||
/// <summary>The Recklessness band used for a varied reckless attack (retail wiki: 20%-80%).</summary>
|
||||
public const int RecklessBandMinPct = 20;
|
||||
public const int RecklessBandMaxPct = 80;
|
||||
|
||||
/// <summary>A saved value as one of <see cref="All"/>; blank or unknown is Default.</summary>
|
||||
public static string Normalize(string? value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value)) return Default;
|
||||
string v = value.Trim();
|
||||
foreach (string m in All)
|
||||
if (m.Equals(v, StringComparison.OrdinalIgnoreCase)) return m;
|
||||
// Hand-typed and meta spellings: "RecklessVariable", "reckless+variable".
|
||||
string squeezed = v.Replace(" ", "").Replace("+", "");
|
||||
if (squeezed.Equals("RecklessVariable", StringComparison.OrdinalIgnoreCase)) return RecklessVariable;
|
||||
return Default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The mode that applies to a monster: its own rule's, else the DEFAULT line's, else
|
||||
/// Default (the global settings). <paramref name="defaultRule"/> may be the same object.
|
||||
/// </summary>
|
||||
public static string Effective(MonsterRule? rule, MonsterRule? defaultRule)
|
||||
{
|
||||
string own = Normalize(rule?.AttackPower);
|
||||
if (own != Default) return own;
|
||||
return Normalize(defaultRule?.AttackPower);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The power bar fraction (0..1) for one attack.
|
||||
/// <paramref name="globalPct"/> is the global Melee/Missile Power (-1 = Auto);
|
||||
/// <paramref name="random01"/> returns a value in [0, 1).
|
||||
/// </summary>
|
||||
public static float Resolve(string mode, int globalPct, bool useRecklessness, bool recklessTrained,
|
||||
int variableMinPct, int variableMaxPct, Func<double> random01)
|
||||
{
|
||||
switch (Normalize(mode))
|
||||
{
|
||||
case High:
|
||||
return 1.0f;
|
||||
|
||||
case Reckless:
|
||||
return recklessTrained ? RecklessPower : 1.0f;
|
||||
|
||||
case Variable:
|
||||
{
|
||||
var (lo, hi) = VariableRange(variableMinPct, variableMaxPct);
|
||||
return Pick(lo, hi, random01);
|
||||
}
|
||||
|
||||
case RecklessVariable:
|
||||
{
|
||||
var (lo, hi) = VariableRange(variableMinPct, variableMaxPct);
|
||||
if (!recklessTrained) return Pick(lo, hi, random01);
|
||||
int rlo = Math.Max(lo, RecklessBandMinPct);
|
||||
int rhi = Math.Min(hi, RecklessBandMaxPct);
|
||||
// The Variable range doesn't overlap the band (e.g. 85-100): the whole band.
|
||||
if (rlo > rhi) { rlo = RecklessBandMinPct; rhi = RecklessBandMaxPct; }
|
||||
return Pick(rlo, rhi, random01);
|
||||
}
|
||||
|
||||
default:
|
||||
if (globalPct < 0)
|
||||
return useRecklessness && recklessTrained ? RecklessPower : 1.0f;
|
||||
return Math.Clamp(globalPct, 0, 100) / 100f;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The Variable range in percent, clamped to 0..100 and put in order.</summary>
|
||||
public static (int Lo, int Hi) VariableRange(int minPct, int maxPct)
|
||||
{
|
||||
int lo = Math.Clamp(minPct, 0, 100), hi = Math.Clamp(maxPct, 0, 100);
|
||||
return lo <= hi ? (lo, hi) : (hi, lo);
|
||||
}
|
||||
|
||||
private static float Pick(int loPct, int hiPct, Func<double> random01)
|
||||
{
|
||||
double r = Math.Clamp(random01(), 0.0, 1.0);
|
||||
double pct = loPct + (hiPct - loPct) * r;
|
||||
return (float)(Math.Round(pct) / 100.0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,523 @@
|
|||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi;
|
||||
|
||||
/// <summary>
|
||||
/// Environment-impact throttle (2026-10-12). Rules and bookkeeping in EnvironmentImpact.cs.
|
||||
///
|
||||
/// missile "Your missile attack hit the environment." in Missile mode counts one hit on the
|
||||
/// target the server's attack is bound to.
|
||||
/// magic each single-target war/void cast is watched: our projectiles (named like the
|
||||
/// shape, "Flame Bolt") are claimed as they appear next to the player, followed until
|
||||
/// they stop or vanish, and the cast counts one hit when every projectile stopped
|
||||
/// short of the target (ProjectileImpactJudge) and no hit, resist or evade line came
|
||||
/// back for it. Rings and walls aren't watched: they don't fly at the target.
|
||||
///
|
||||
/// At EnvironmentImpactLimit hits within the window the throttle trips: the server's attack is
|
||||
/// released (a magic cast in flight finishes first) and the chosen response runs: an approach
|
||||
/// (autorun toward the target, at most EnvironmentApproachMeters, never nearer than
|
||||
/// EnvironmentMinDistance, bounded in time and by progress), or a new target (this one skipped
|
||||
/// for EnvironmentSkipSec). Off = no detection at all.
|
||||
/// </summary>
|
||||
public partial class CombatManager
|
||||
{
|
||||
/// <summary>Clock for the throttle and the projectile watch; tests replace it.</summary>
|
||||
internal Func<DateTime> EnvClock { get; set; } = () => DateTime.Now;
|
||||
|
||||
internal EnvironmentImpactThrottle EnvThrottle { get; } = new();
|
||||
|
||||
/// <summary>The start of the chat line ACE sends the shooter (ProjectileCollisionHelper.OnCollideEnvironment,
|
||||
/// a Broadcast line). Matched at the line's start only: a player's copy has their name in front.</summary>
|
||||
internal const string MissileEnvironmentText = "Your missile attack hit the environment";
|
||||
|
||||
// A cast's projectiles appear once its windup ends (up to ~2.5 s for a high tier).
|
||||
private const double CastClaimWindowMs = 4000;
|
||||
// Our projectile spawns at the caster; farther than this at its first sight it isn't ours.
|
||||
private const double ClaimRadiusMeters = 8.0;
|
||||
// Still this long after flying counts as stopped (ACE zeroes its velocity on impact).
|
||||
private const double StoppedForMs = 250;
|
||||
private const double StillMeters = 0.05;
|
||||
// A projectile still flying after this is dropped from the watch (no verdict).
|
||||
private const double ProjectileMaxFlightMs = 8000;
|
||||
// After the last projectile stops, a hit/resist/evade line still has this long to arrive.
|
||||
private const double ImpactEvidenceGraceMs = 1000;
|
||||
private const int MaxCastWatches = 4;
|
||||
// An approach that hasn't gained this much ground in ApproachNoProgressMs is blocked.
|
||||
private const double ApproachProgressMeters = 0.5;
|
||||
private const double ApproachNoProgressMs = 2500;
|
||||
private const double ApproachMaxMs = 8000;
|
||||
private const double ApproachRunRefreshMs = 1000;
|
||||
private const double ApproachTurnRefreshMs = 300;
|
||||
private const double ApproachFaceToleranceDeg = 10;
|
||||
// Think stopped driving the approach (buffing took over, out of range): let go of autorun.
|
||||
private const double ApproachOrphanMs = 1500;
|
||||
|
||||
private enum EnvKind { Missile, Magic }
|
||||
|
||||
private sealed class TrackedProjectile
|
||||
{
|
||||
public uint Id;
|
||||
public double StartX, StartY, StartZ;
|
||||
public double LastX, LastY, LastZ;
|
||||
public DateTime FirstSeen, LastMoved;
|
||||
public double Travel;
|
||||
public bool Resolved, Short;
|
||||
}
|
||||
|
||||
private sealed class CastWatch
|
||||
{
|
||||
public int TargetId;
|
||||
public string SpellName = "";
|
||||
public DateTime CastAt;
|
||||
public double CasterX, CasterY, CasterZ;
|
||||
public bool HasCasterPos;
|
||||
public readonly List<TrackedProjectile> Projectiles = new();
|
||||
public DateTime LastImpactAt = DateTime.MinValue;
|
||||
}
|
||||
|
||||
// Creates are queued and claimed by the heartbeat poll (the name lands a moment later).
|
||||
private readonly ConcurrentQueue<(uint Id, DateTime At)> _envCreated = new();
|
||||
private readonly List<(uint Id, DateTime At)> _envCandidates = new();
|
||||
private readonly List<CastWatch> _castWatches = new();
|
||||
private readonly Dictionary<int, DateTime> _envSkipUntil = new();
|
||||
private DateTime _envLastEvidenceAt = DateTime.MinValue;
|
||||
|
||||
// The trip waiting for Think, and the approach in progress.
|
||||
private int _envPendingTargetId;
|
||||
private EnvKind _envPendingKind;
|
||||
private int _envApproachTargetId;
|
||||
private EnvKind _envApproachKind;
|
||||
private double _envApproachGoal, _envApproachBestDist;
|
||||
private DateTime _envApproachStartedAt, _envApproachProgressAt, _envApproachRunAt, _envApproachTurnAt, _envApproachTickAt;
|
||||
private bool _envApproachUsedMotions;
|
||||
|
||||
/// <summary>True while combat is walking toward a target for its environment hits.</summary>
|
||||
internal bool EnvironmentApproachActive => _envApproachTargetId != 0;
|
||||
|
||||
private EnvironmentResponse ResponseFor(EnvKind kind) => EnvironmentImpactPlanner.Parse(
|
||||
kind == EnvKind.Missile ? _settings.MissileEnvironmentResponse : _settings.MagicEnvironmentResponse);
|
||||
|
||||
// ── Signals ────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>A new object. Only queued while the macro runs with magic detection on
|
||||
/// (the heartbeat poll that drains the queue runs only then). Separate from OnObjectCreated,
|
||||
/// which feeds the ghost tracker on every create.</summary>
|
||||
public void OnEnvironmentObjectCreated(uint objectId)
|
||||
{
|
||||
if (objectId == 0 || _settings.MagicEnvironmentResponse == 0 || !_settings.IsMacroRunning) return;
|
||||
_envCreated.Enqueue((objectId, EnvClock()));
|
||||
}
|
||||
|
||||
/// <summary>From OnObjectDeleted: a projectile that vanished has hit something, and a
|
||||
/// monster id that's gone forgets its hits, approaches and skip.</summary>
|
||||
private void OnEnvironmentObjectDeleted(uint objectId)
|
||||
{
|
||||
int id = (int)objectId;
|
||||
EnvThrottle.Forget(id);
|
||||
_envSkipUntil.Remove(id);
|
||||
if (_castWatches.Count == 0) return;
|
||||
DateTime now = EnvClock();
|
||||
foreach (var w in _castWatches)
|
||||
foreach (var p in w.Projectiles)
|
||||
if (p.Id == objectId && !p.Resolved) ResolveProjectile(w, p, now);
|
||||
}
|
||||
|
||||
/// <summary>The missile line, from HandleChatForDamage. True when it was that line.</summary>
|
||||
private bool NoteMissileEnvironmentChat(string text)
|
||||
{
|
||||
if (!ChatSource.StartsWithMarker(text, MissileEnvironmentText, StringComparison.OrdinalIgnoreCase)) return false;
|
||||
if (ResponseFor(EnvKind.Missile) == EnvironmentResponse.Off) return true;
|
||||
if (CurrentCombatMode != CombatMode.Missile) return true;
|
||||
int target = _serverAttackTargetId != 0 ? _serverAttackTargetId : activeTargetId;
|
||||
if (target != 0) RecordEnvironmentImpact(target, EnvKind.Missile, "missile hit the environment");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Any sign an attack reached a monster (hit, resist, evade, a health drop):
|
||||
/// a cast with one of these after it didn't only hit the environment.</summary>
|
||||
private void NoteEnvironmentEvidence() => _envLastEvidenceAt = EnvClock();
|
||||
|
||||
/// <summary>A single-target cast just went out (AttackWithMagic): watch its projectiles.</summary>
|
||||
internal void RegisterCastWatch(int targetId, string spellName)
|
||||
{
|
||||
if (ResponseFor(EnvKind.Magic) == EnvironmentResponse.Off || targetId == 0) return;
|
||||
DateTime now = EnvClock();
|
||||
var w = new CastWatch { TargetId = targetId, SpellName = spellName, CastAt = now };
|
||||
if (TryGetPlayerGlobal(out double px, out double py, out double pz))
|
||||
{
|
||||
w.CasterX = px; w.CasterY = py; w.CasterZ = pz; w.HasCasterPos = true;
|
||||
}
|
||||
if (_castWatches.Count >= MaxCastWatches) _castWatches.RemoveAt(0);
|
||||
_castWatches.Add(w);
|
||||
}
|
||||
|
||||
/// <summary>Counts one environment hit; at the limit, arms the response for Think.</summary>
|
||||
private void RecordEnvironmentImpact(int targetId, EnvKind kind, string detail)
|
||||
{
|
||||
DateTime now = EnvClock();
|
||||
int limit = Math.Max(1, _settings.EnvironmentImpactLimit);
|
||||
int window = Math.Max(1, _settings.EnvironmentImpactWindowSec);
|
||||
int n = EnvThrottle.Record(targetId, now, window);
|
||||
string name = _worldFilter[targetId]?.Name ?? "";
|
||||
_host.Log($"[EnvImpact] {kind.ToString().ToLowerInvariant()}: {detail} — 0x{(uint)targetId:X8} '{name}' {n}/{limit} in {window}s");
|
||||
if (n < limit || targetId != activeTargetId) return;
|
||||
if (_envApproachTargetId == targetId) return; // already moving closer to it
|
||||
_envPendingTargetId = targetId;
|
||||
_envPendingKind = kind;
|
||||
}
|
||||
|
||||
// ── Heartbeat: projectile watch and the approach's safety net ─────────────
|
||||
|
||||
/// <summary>Every heartbeat while the macro runs (pump thread).</summary>
|
||||
internal void PollEnvironmentImpact()
|
||||
{
|
||||
DateTime now = EnvClock();
|
||||
|
||||
if (_settings.MagicEnvironmentResponse == 0)
|
||||
{
|
||||
while (_envCreated.TryDequeue(out _)) { }
|
||||
_envCandidates.Clear();
|
||||
_castWatches.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
while (_envCreated.TryDequeue(out var c)) _envCandidates.Add(c);
|
||||
ClaimProjectiles(now);
|
||||
TrackProjectiles(now);
|
||||
JudgeCastWatches(now);
|
||||
}
|
||||
|
||||
// Think drives the approach; when it stops (another activity, out of range, combat off)
|
||||
// or the deadline passes, autorun must not be left on.
|
||||
if (_envApproachTargetId != 0
|
||||
&& ((now - _envApproachTickAt).TotalMilliseconds > ApproachOrphanMs
|
||||
|| (now - _envApproachStartedAt).TotalMilliseconds > ApproachMaxMs + ApproachOrphanMs
|
||||
|| !_settings.EnableCombat))
|
||||
EndEnvironmentApproach("combat stopped driving it");
|
||||
|
||||
// Same for the re-sync sidestep's movement key: Think releases it after ResyncStepMs,
|
||||
// but only while it keeps ticking in magic mode.
|
||||
if (_resyncState == 2 && (TargetClock() - _resyncAt).TotalMilliseconds > ResyncStepMs + ApproachOrphanMs)
|
||||
AbandonResync("combat stopped driving it");
|
||||
}
|
||||
|
||||
private void ClaimProjectiles(DateTime now)
|
||||
{
|
||||
if (_envCandidates.Count == 0) return;
|
||||
bool havePlayer = TryGetPlayerGlobal(out double px, out double py, out double pz);
|
||||
for (int i = _envCandidates.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var (id, at) = _envCandidates[i];
|
||||
string name = _worldFilter[(int)id]?.Name ?? "";
|
||||
if (name.Length == 0 && _host.TryGetObjectName(id, out string n2)) name = n2;
|
||||
if (name.Length == 0)
|
||||
{
|
||||
// The name lands a moment after the create; give it a second.
|
||||
if ((now - at).TotalMilliseconds > 1000) _envCandidates.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
_envCandidates.RemoveAt(i);
|
||||
if (!IsWatchedProjectileName(name)) continue;
|
||||
if (!havePlayer || !TryGetObjectGlobal(id, out double x, out double y, out double z)) continue;
|
||||
if (Dist(px, py, pz, x, y, z) > ClaimRadiusMeters) continue;
|
||||
|
||||
// The newest cast still taking projectiles (a blast's several share one cast).
|
||||
CastWatch? owner = null;
|
||||
for (int w = _castWatches.Count - 1; w >= 0; w--)
|
||||
{
|
||||
double age = (at - _castWatches[w].CastAt).TotalMilliseconds;
|
||||
if (age >= -50 && age <= CastClaimWindowMs) { owner = _castWatches[w]; break; }
|
||||
}
|
||||
if (owner == null) continue;
|
||||
owner.Projectiles.Add(new TrackedProjectile
|
||||
{
|
||||
Id = id, StartX = x, StartY = y, StartZ = z, LastX = x, LastY = y, LastZ = z,
|
||||
FirstSeen = now, LastMoved = now,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A war/void projectile: the shape names (SpellShapes/VoidSpellShapes), or any
|
||||
/// name ending in a flying shape (lore-named projectiles of the same shapes).</summary>
|
||||
internal static bool IsWatchedProjectileName(string name)
|
||||
{
|
||||
if (IsSpellProjectileName(name)) return !name.EndsWith(" Ring", StringComparison.OrdinalIgnoreCase);
|
||||
return name.EndsWith(" Bolt", StringComparison.OrdinalIgnoreCase)
|
||||
|| name.EndsWith(" Streak", StringComparison.OrdinalIgnoreCase)
|
||||
|| name.EndsWith(" Arc", StringComparison.OrdinalIgnoreCase)
|
||||
|| name.EndsWith(" Blast", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private void TrackProjectiles(DateTime now)
|
||||
{
|
||||
foreach (var w in _castWatches)
|
||||
{
|
||||
foreach (var p in w.Projectiles)
|
||||
{
|
||||
if (p.Resolved) continue;
|
||||
if ((now - p.FirstSeen).TotalMilliseconds > ProjectileMaxFlightMs)
|
||||
{
|
||||
p.Resolved = true; // no verdict: treated as not short
|
||||
continue;
|
||||
}
|
||||
if (!TryGetObjectGlobal(p.Id, out double x, out double y, out double z)) continue;
|
||||
if (Dist(x, y, z, p.LastX, p.LastY, p.LastZ) > StillMeters)
|
||||
{
|
||||
p.LastX = x; p.LastY = y; p.LastZ = z;
|
||||
p.LastMoved = now;
|
||||
p.Travel = Math.Max(p.Travel, Dist(x, y, z, p.StartX, p.StartY, p.StartZ));
|
||||
continue;
|
||||
}
|
||||
if (p.Travel >= ProjectileImpactJudge.MinTravelMeters
|
||||
&& (now - p.LastMoved).TotalMilliseconds >= StoppedForMs)
|
||||
ResolveProjectile(w, p, now);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ResolveProjectile(CastWatch w, TrackedProjectile p, DateTime now)
|
||||
{
|
||||
p.Resolved = true;
|
||||
w.LastImpactAt = now;
|
||||
if (p.Travel < ProjectileImpactJudge.MinTravelMeters) return;
|
||||
if (!TryGetObjectGlobal((uint)w.TargetId, out double tx, out double ty, out double tz)) return;
|
||||
double cx = w.CasterX, cy = w.CasterY, cz = w.CasterZ;
|
||||
if (!w.HasCasterPos) { cx = p.StartX; cy = p.StartY; cz = p.StartZ; }
|
||||
p.Short = ProjectileImpactJudge.StoppedShort(
|
||||
Dist(p.LastX, p.LastY, p.LastZ, tx, ty, tz),
|
||||
Dist(cx, cy, cz, p.LastX, p.LastY, p.LastZ),
|
||||
Dist(cx, cy, cz, tx, ty, tz));
|
||||
}
|
||||
|
||||
private void JudgeCastWatches(DateTime now)
|
||||
{
|
||||
for (int i = _castWatches.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var w = _castWatches[i];
|
||||
double age = (now - w.CastAt).TotalMilliseconds;
|
||||
if (w.Projectiles.Count == 0)
|
||||
{
|
||||
if (age > CastClaimWindowMs + 500) _castWatches.RemoveAt(i); // refused or never seen
|
||||
continue;
|
||||
}
|
||||
// A blast's projectiles all appear together; wait out the claim window only briefly.
|
||||
bool allResolved = w.Projectiles.TrueForAll(p => p.Resolved);
|
||||
if (!allResolved) continue;
|
||||
if ((now - w.LastImpactAt).TotalMilliseconds < ImpactEvidenceGraceMs) continue;
|
||||
_castWatches.RemoveAt(i);
|
||||
|
||||
bool reached = _envLastEvidenceAt >= w.CastAt;
|
||||
bool allShort = w.Projectiles.TrueForAll(p => p.Short);
|
||||
if (!reached && allShort)
|
||||
RecordEnvironmentImpact(w.TargetId, EnvKind.Magic,
|
||||
$"'{w.SpellName}' stopped short of the target ({w.Projectiles.Count} projectile{(w.Projectiles.Count == 1 ? "" : "s")})");
|
||||
}
|
||||
}
|
||||
|
||||
// ── Think: the response ───────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// In ThinkCore once the target is valid and in reach. True = this tick belongs to the
|
||||
/// response (an approach under way, or the target just switched): no attack.
|
||||
/// </summary>
|
||||
internal bool RunEnvironmentImpact(WorldObject targetObj, double currentDist)
|
||||
{
|
||||
DateTime now = EnvClock();
|
||||
if (_envApproachTargetId != 0)
|
||||
{
|
||||
if (_envApproachTargetId == activeTargetId)
|
||||
return ContinueEnvironmentApproach(targetObj, currentDist, now);
|
||||
EndEnvironmentApproach("the target changed");
|
||||
}
|
||||
|
||||
if (_envPendingTargetId == 0) return false;
|
||||
if (_envPendingTargetId != activeTargetId) { _envPendingTargetId = 0; return false; }
|
||||
EnvKind kind = _envPendingKind;
|
||||
// The cast in flight finishes first: turning or running now would cancel it.
|
||||
if (kind == EnvKind.Magic && IsCastInFlight()) return true;
|
||||
// A re-sync sidestep already holding a movement key finishes first: running or turning
|
||||
// over it would send two movement states at once.
|
||||
if (_resyncState == 2) return true;
|
||||
|
||||
int id = activeTargetId;
|
||||
_envPendingTargetId = 0;
|
||||
EnvThrottle.ResetHits(id);
|
||||
EnvironmentResponse response = ResponseFor(kind);
|
||||
int minDist = Math.Max(1, _settings.EnvironmentMinDistance);
|
||||
EnvironmentAction action = EnvironmentImpactPlanner.Decide(response, EnvThrottle.Approaches(id),
|
||||
currentDist, minDist, HasAlternateTarget(id));
|
||||
string who = $"0x{(uint)id:X8} '{targetObj.Name}' at {currentDist:0.0}m";
|
||||
string why = kind == EnvKind.Missile ? "missiles" : "spells";
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case EnvironmentAction.NewTarget:
|
||||
{
|
||||
if (_serverAttackTargetId != 0) ReleaseServerAttack("environment hits", log: false);
|
||||
int skip = Math.Max(1, _settings.EnvironmentSkipSec);
|
||||
_envSkipUntil[id] = now.AddSeconds(skip);
|
||||
_host.Log($"[EnvImpact] {why} keep hitting the environment: leaving {who}, skipping it {skip}s ({EnvironmentImpactPlanner.Name((int)response)})");
|
||||
SupersedeResync("a new target");
|
||||
ForgetScanned(id);
|
||||
DropTarget("environment hits: new target");
|
||||
return true;
|
||||
}
|
||||
case EnvironmentAction.Approach:
|
||||
{
|
||||
if (_serverAttackTargetId != 0) ReleaseServerAttack("environment hits", log: false);
|
||||
double goal = EnvironmentImpactPlanner.ApproachGoal(currentDist, _settings.EnvironmentApproachMeters, minDist);
|
||||
EnvThrottle.NoteApproach(id);
|
||||
_envApproachTargetId = id;
|
||||
_envApproachKind = kind;
|
||||
_envApproachGoal = goal;
|
||||
_envApproachBestDist = currentDist;
|
||||
_envApproachStartedAt = _envApproachProgressAt = _envApproachTickAt = now;
|
||||
_envApproachRunAt = _envApproachTurnAt = DateTime.MinValue;
|
||||
_envApproachUsedMotions = false;
|
||||
_host.Log($"[EnvImpact] {why} keep hitting the environment: moving closer to {who}, stopping at {goal:0.0}m ({EnvironmentImpactPlanner.Name((int)response)})");
|
||||
SupersedeResync("moving closer");
|
||||
return ContinueEnvironmentApproach(targetObj, currentDist, now);
|
||||
}
|
||||
default:
|
||||
_host.Log($"[EnvImpact] {why} keep hitting the environment on {who}, but it's the only monster in reach and already close: attacking on");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The throttle acted on misses the magic re-sync (TickResyncStep) was also counting. The
|
||||
/// misses are explained (a wall in the way), so the re-sync's count starts over, and a
|
||||
/// sidestep that is wanted but not yet started is dropped. Moving closer is itself real
|
||||
/// movement, which re-syncs the server's copy of our position anyway.
|
||||
/// </summary>
|
||||
private void SupersedeResync(string by)
|
||||
{
|
||||
_magicMissesSinceHit = 0;
|
||||
if (_resyncState != 1) return;
|
||||
_resyncState = 0;
|
||||
_host.Log($"[EnvImpact] re-sync sidestep dropped: {by} answers the misses");
|
||||
}
|
||||
|
||||
/// <summary>Stops a re-sync sidestep where it is, letting go of its movement key if held.</summary>
|
||||
private void AbandonResync(string why)
|
||||
{
|
||||
if (_resyncState == 0) return;
|
||||
if (_resyncState == 2) _host.SetMotionBy("Combat/Resync", _resyncMotion, false);
|
||||
_resyncState = 0;
|
||||
_host.Log($"[CombatCast] re-sync sidestep stopped: {why}");
|
||||
}
|
||||
|
||||
private bool ContinueEnvironmentApproach(WorldObject targetObj, double currentDist, DateTime now)
|
||||
{
|
||||
_envApproachTickAt = now;
|
||||
if (currentDist <= _envApproachGoal)
|
||||
{
|
||||
EndEnvironmentApproach($"reached {currentDist:0.0}m");
|
||||
return false;
|
||||
}
|
||||
if ((now - _envApproachStartedAt).TotalMilliseconds > ApproachMaxMs)
|
||||
{
|
||||
EndEnvironmentApproach($"timed out at {currentDist:0.0}m");
|
||||
return false;
|
||||
}
|
||||
if (currentDist < _envApproachBestDist - ApproachProgressMeters)
|
||||
{
|
||||
_envApproachBestDist = currentDist;
|
||||
_envApproachProgressAt = now;
|
||||
}
|
||||
else if ((now - _envApproachProgressAt).TotalMilliseconds > ApproachNoProgressMs)
|
||||
{
|
||||
EndEnvironmentApproach($"no progress (blocked?) at {currentDist:0.0}m");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Face the target, then run. A held call (the pacer, a use) is simply tried next tick.
|
||||
if ((now - _envApproachTurnAt).TotalMilliseconds >= ApproachTurnRefreshMs
|
||||
&& TryGetHeadingTo(activeTargetId, out double desiredDeg, out double err)
|
||||
&& err > ApproachFaceToleranceDeg)
|
||||
{
|
||||
if (_host.HasTurnToHeading)
|
||||
{
|
||||
if (_host.TurnToHeadingBy("Combat/Approach", (float)desiredDeg)) _envApproachTurnAt = now;
|
||||
}
|
||||
else
|
||||
{
|
||||
FaceTarget(activeTargetId);
|
||||
_envApproachUsedMotions = true;
|
||||
_envApproachTurnAt = now;
|
||||
}
|
||||
}
|
||||
if ((now - _envApproachRunAt).TotalMilliseconds >= ApproachRunRefreshMs
|
||||
&& _host.SetAutoRunBy("Combat/Approach", true))
|
||||
_envApproachRunAt = now;
|
||||
|
||||
_stallWatch.Hold(now);
|
||||
LastCombatSkipReason = "env-approach"; // D4 record-only
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Stops an approach in progress (autorun off). Safe to call when none is.</summary>
|
||||
private void EndEnvironmentApproach(string why)
|
||||
{
|
||||
if (_envApproachTargetId == 0) return;
|
||||
int id = _envApproachTargetId;
|
||||
_envApproachTargetId = 0;
|
||||
if (_envApproachRunAt != DateTime.MinValue) _host.SetAutoRunBy("Combat/Approach", false);
|
||||
if (_envApproachUsedMotions) ClearCombatTurnMotions();
|
||||
_host.Log($"[EnvImpact] {_envApproachKind.ToString().ToLowerInvariant()} approach to 0x{(uint)id:X8} ended: {why}");
|
||||
}
|
||||
|
||||
/// <summary>True while <paramref name="id"/> is being skipped for its environment hits.</summary>
|
||||
private bool IsEnvironmentSkipped(int id)
|
||||
{
|
||||
if (_envSkipUntil.Count == 0 || !_envSkipUntil.TryGetValue(id, out DateTime until)) return false;
|
||||
if (EnvClock() < until) return true;
|
||||
_envSkipUntil.Remove(id);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>Clears every environment-impact state (macro stop, new character).</summary>
|
||||
private void ResetEnvironmentImpact(string why)
|
||||
{
|
||||
EndEnvironmentApproach(why);
|
||||
AbandonResync(why);
|
||||
_envPendingTargetId = 0;
|
||||
_castWatches.Clear();
|
||||
_envCandidates.Clear();
|
||||
while (_envCreated.TryDequeue(out _)) { }
|
||||
EnvThrottle.Clear();
|
||||
_envSkipUntil.Clear();
|
||||
}
|
||||
|
||||
// ── Positions (global metres: landblock x/y * 192 + the in-block offset) ──
|
||||
|
||||
private bool TryGetObjectGlobal(uint id, out double x, out double y, out double z)
|
||||
{
|
||||
x = y = z = 0;
|
||||
if (!_host.TryGetObjectPosition(id, out uint cell, out float lx, out float ly, out float lz)) return false;
|
||||
x = ((cell >> 24) & 0xFF) * 192.0 + lx;
|
||||
y = ((cell >> 16) & 0xFF) * 192.0 + ly;
|
||||
z = lz;
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool TryGetPlayerGlobal(out double x, out double y, out double z)
|
||||
{
|
||||
x = y = z = 0;
|
||||
if (!_host.TryGetPlayerPose(out uint cell, out float lx, out float ly, out float lz,
|
||||
out _, out _, out _, out _)) return false;
|
||||
x = ((cell >> 24) & 0xFF) * 192.0 + lx;
|
||||
y = ((cell >> 16) & 0xFF) * 192.0 + ly;
|
||||
z = lz;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static double Dist(double ax, double ay, double az, double bx, double by, double bz)
|
||||
{
|
||||
double dx = ax - bx, dy = ay - by, dz = az - bz;
|
||||
return Math.Sqrt(dx * dx + dy * dy + dz * dz);
|
||||
}
|
||||
}
|
||||
246
Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.Kite.cs
Normal file
246
Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.Kite.cs
Normal file
|
|
@ -0,0 +1,246 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using RynthCore.Plugin.Shared; // TurnToHeadingBy / SetAutoRunBy
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi;
|
||||
|
||||
/// <summary>
|
||||
/// Kite / pull-away (2026-10-16). Rules in KiteModes.cs; distance in LegacyUiSettings.KitePullMeters.
|
||||
///
|
||||
/// When the effective monster rule is PullAway, combat tags the mob (one hit window), then
|
||||
/// autoruns away from its lock-spot origin until the mob has been dragged that many metres
|
||||
/// clear of where it stood, then stops and kills it. Default and per-mob via MonsterRule.Kite.
|
||||
/// </summary>
|
||||
public partial class CombatManager
|
||||
{
|
||||
/// <summary>Clock for the kite state machine; tests replace it.</summary>
|
||||
internal Func<DateTime> KiteClock { get; set; } = () => DateTime.Now;
|
||||
|
||||
// Face-away + autorun cadence (mirrors EnvironmentApproach).
|
||||
private const double KiteTurnRefreshMs = 300;
|
||||
private const double KiteRunRefreshMs = 1000;
|
||||
// Think stopped driving the kite (buffing took over): let go of autorun.
|
||||
private const double KiteOrphanMs = 1500;
|
||||
// Tag window: allow attacks so aggro sticks before we turn and run.
|
||||
private const double KiteTagMaxMs = 2500;
|
||||
// A pull that never gets far enough (blocked, mob leashed) gives up and fights in place.
|
||||
private const double KiteMaxMs = 20000;
|
||||
// Don't outrun the chase: stop autorun when farther than this from the mob.
|
||||
private const double KiteCatchUpSlackMeters = 1.5;
|
||||
// Progress toward the pull goal; no gain in this long ⇒ blocked / leashed.
|
||||
private const double KiteProgressMeters = 0.75;
|
||||
private const double KiteNoProgressMs = 4000;
|
||||
|
||||
private enum KitePhase { None, Tag, Flee, Done }
|
||||
|
||||
private int _kiteTargetId;
|
||||
private KitePhase _kitePhase = KitePhase.None;
|
||||
private double _kiteOriginX, _kiteOriginY, _kiteOriginZ;
|
||||
private bool _kiteHasOrigin;
|
||||
private double _kiteBestPull;
|
||||
private DateTime _kiteStartedAt, _kiteProgressAt, _kiteRunAt, _kiteTurnAt, _kiteTickAt;
|
||||
private bool _kiteUsedMotions;
|
||||
// Targets already pulled this engagement (object id): do not re-kite mid-fight.
|
||||
private readonly HashSet<int> _kiteDoneIds = new();
|
||||
|
||||
/// <summary>True while combat is tagging or running a pull-away for the locked target.</summary>
|
||||
internal bool KiteActive => _kitePhase is KitePhase.Tag or KitePhase.Flee;
|
||||
|
||||
/// <summary>
|
||||
/// In ThinkCore once the target is valid. True = this tick belongs to the kite (flee under
|
||||
/// way): no attack. Tag phase returns false so the first hit(s) can land.
|
||||
/// </summary>
|
||||
internal bool RunKite(WorldObject targetObj, double currentDist)
|
||||
{
|
||||
DateTime now = KiteClock();
|
||||
int id = activeTargetId;
|
||||
if (id == 0) { EndKite("no target"); return false; }
|
||||
|
||||
// Already pulled this object id for this engagement: fight in place.
|
||||
if (_kiteDoneIds.Contains(id))
|
||||
{
|
||||
if (_kiteTargetId == id) EndKite("already pulled");
|
||||
return false;
|
||||
}
|
||||
|
||||
var rule = GetRuleForTarget(targetObj);
|
||||
if (!KiteModes.WantsPullAway(rule, DefaultMonsterRule()))
|
||||
{
|
||||
if (_kiteTargetId == id) EndKite("rule Off");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Start (or retarget) a pull for this lock.
|
||||
if (_kiteTargetId != id || _kitePhase == KitePhase.None)
|
||||
{
|
||||
if (_kiteTargetId != 0 && _kiteTargetId != id)
|
||||
EndKite("the target changed");
|
||||
BeginKite(id, targetObj, now);
|
||||
}
|
||||
|
||||
_kiteTickAt = now;
|
||||
double pullMeters = Math.Max(3.0, _settings.KitePullMeters);
|
||||
|
||||
if (_kitePhase == KitePhase.Tag)
|
||||
{
|
||||
bool tagged = _lastDamageDealtAt != DateTime.MinValue && _lastDamageDealtAt >= _kiteStartedAt;
|
||||
bool tagTimedOut = (now - _kiteStartedAt).TotalMilliseconds >= KiteTagMaxMs;
|
||||
if (!_settings.KiteTagFirst || tagged || tagTimedOut)
|
||||
{
|
||||
_kitePhase = KitePhase.Flee;
|
||||
_kiteBestPull = PullDistance(id);
|
||||
_kiteProgressAt = now;
|
||||
_kiteRunAt = _kiteTurnAt = DateTime.MinValue;
|
||||
string why = !_settings.KiteTagFirst ? "tag skipped"
|
||||
: tagged ? "tagged"
|
||||
: "tag timed out";
|
||||
_host.Log($"[Kite] pull-away on 0x{(uint)id:X8} '{targetObj.Name}': fleeing ({why}), goal {pullMeters:0}m from origin");
|
||||
EndEnvironmentApproach("kite pull-away");
|
||||
}
|
||||
else
|
||||
{
|
||||
LastCombatSkipReason = "kite-tag";
|
||||
return false; // let Think attack once so aggro sticks
|
||||
}
|
||||
}
|
||||
|
||||
if (_kitePhase != KitePhase.Flee) return false;
|
||||
|
||||
double pulled = PullDistance(id);
|
||||
if (pulled >= pullMeters)
|
||||
{
|
||||
FinishKite(id, $"pulled {pulled:0.0}m");
|
||||
return false;
|
||||
}
|
||||
if ((now - _kiteStartedAt).TotalMilliseconds > KiteMaxMs)
|
||||
{
|
||||
FinishKite(id, $"timed out at {pulled:0.0}m");
|
||||
return false;
|
||||
}
|
||||
if (pulled > _kiteBestPull + KiteProgressMeters)
|
||||
{
|
||||
_kiteBestPull = pulled;
|
||||
_kiteProgressAt = now;
|
||||
}
|
||||
else if ((now - _kiteProgressAt).TotalMilliseconds > KiteNoProgressMs)
|
||||
{
|
||||
FinishKite(id, $"no progress (blocked/leashed?) at {pulled:0.0}m");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't outrun the chase past disengage: wait for the mob to catch up.
|
||||
double catchUp = Math.Max(1.0, DisengageDistance - KiteCatchUpSlackMeters);
|
||||
bool waiting = currentDist > catchUp;
|
||||
|
||||
// Face away from the mob while fleeing; face it while waiting for catch-up.
|
||||
if ((now - _kiteTurnAt).TotalMilliseconds >= KiteTurnRefreshMs
|
||||
&& TryGetHeadingTo(id, out double towardDeg, out _))
|
||||
{
|
||||
double faceDeg = waiting ? towardDeg : (towardDeg + 180.0) % 360.0;
|
||||
if (_host.HasTurnToHeading)
|
||||
{
|
||||
if (_host.TurnToHeadingBy("Combat/Kite", (float)faceDeg)) _kiteTurnAt = now;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No heading snap: FaceTarget only faces toward the mob (useful while waiting).
|
||||
if (waiting) { FaceTarget(id); _kiteUsedMotions = true; }
|
||||
_kiteTurnAt = now;
|
||||
}
|
||||
}
|
||||
|
||||
if (waiting)
|
||||
{
|
||||
if (_kiteRunAt != DateTime.MinValue)
|
||||
{
|
||||
_host.SetAutoRunBy("Combat/Kite", false);
|
||||
_kiteRunAt = DateTime.MinValue;
|
||||
}
|
||||
LastCombatSkipReason = "kite-wait";
|
||||
_stallWatch.Hold(now);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((now - _kiteRunAt).TotalMilliseconds >= KiteRunRefreshMs
|
||||
&& _host.SetAutoRunBy("Combat/Kite", true))
|
||||
_kiteRunAt = now;
|
||||
|
||||
_stallWatch.Hold(now);
|
||||
LastCombatSkipReason = "kite-flee";
|
||||
return true;
|
||||
}
|
||||
|
||||
private void BeginKite(int id, WorldObject targetObj, DateTime now)
|
||||
{
|
||||
_kiteTargetId = id;
|
||||
_kitePhase = _settings.KiteTagFirst ? KitePhase.Tag : KitePhase.Flee;
|
||||
_kiteHasOrigin = TryGetObjectGlobal((uint)id, out _kiteOriginX, out _kiteOriginY, out _kiteOriginZ);
|
||||
if (!_kiteHasOrigin)
|
||||
_kiteHasOrigin = TryGetPlayerGlobal(out _kiteOriginX, out _kiteOriginY, out _kiteOriginZ);
|
||||
_kiteBestPull = 0;
|
||||
_kiteStartedAt = _kiteProgressAt = _kiteTickAt = now;
|
||||
_kiteRunAt = _kiteTurnAt = DateTime.MinValue;
|
||||
_kiteUsedMotions = false;
|
||||
string phase = _kitePhase == KitePhase.Tag ? "tag then flee" : "flee";
|
||||
_host.Log($"[Kite] pull-away start 0x{(uint)id:X8} '{targetObj.Name}' ({phase}, {_settings.KitePullMeters}m)");
|
||||
if (_kitePhase == KitePhase.Flee)
|
||||
EndEnvironmentApproach("kite pull-away");
|
||||
}
|
||||
|
||||
/// <summary>How far the mob has been dragged from its lock-spot origin (metres).</summary>
|
||||
private double PullDistance(int id)
|
||||
{
|
||||
if (!_kiteHasOrigin) return 0;
|
||||
if (!TryGetObjectGlobal((uint)id, out double x, out double y, out double z))
|
||||
return _kiteBestPull;
|
||||
return Dist(x, y, z, _kiteOriginX, _kiteOriginY, _kiteOriginZ);
|
||||
}
|
||||
|
||||
/// <summary>Pull succeeded or gave up: remember the id and fight in place.</summary>
|
||||
private void FinishKite(int id, string why)
|
||||
{
|
||||
_kiteDoneIds.Add(id);
|
||||
if (_kiteDoneIds.Count > 64) _kiteDoneIds.Clear();
|
||||
EndKite(why);
|
||||
_host.Log($"[Kite] pull-away done 0x{(uint)id:X8}: {why} — attacking");
|
||||
}
|
||||
|
||||
/// <summary>Stops a kite in progress (autorun off). Safe to call when none is.</summary>
|
||||
private void EndKite(string why)
|
||||
{
|
||||
if (_kitePhase == KitePhase.None && _kiteTargetId == 0) return;
|
||||
int id = _kiteTargetId;
|
||||
bool wasRunning = _kiteRunAt != DateTime.MinValue;
|
||||
_kiteTargetId = 0;
|
||||
_kitePhase = KitePhase.None;
|
||||
_kiteHasOrigin = false;
|
||||
if (wasRunning) _host.SetAutoRunBy("Combat/Kite", false);
|
||||
if (_kiteUsedMotions) ClearCombatTurnMotions();
|
||||
_kiteRunAt = _kiteTurnAt = DateTime.MinValue;
|
||||
if (id != 0)
|
||||
_host.Log($"[Kite] ended 0x{(uint)id:X8}: {why}");
|
||||
}
|
||||
|
||||
/// <summary>Clears kite state (macro stop, new character).</summary>
|
||||
private void ResetKite(string why)
|
||||
{
|
||||
EndKite(why);
|
||||
_kiteDoneIds.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pump-thread orphan watch: Think drives the flee; when it stops (another activity,
|
||||
/// combat off) autorun must not be left on.
|
||||
/// </summary>
|
||||
internal void PollKite()
|
||||
{
|
||||
// The Handler-ring run-away has the same orphan rule (autorun must not outlive Think).
|
||||
PollRingEscape();
|
||||
if (_kitePhase == KitePhase.None) return;
|
||||
DateTime now = KiteClock();
|
||||
if ((now - _kiteTickAt).TotalMilliseconds > KiteOrphanMs
|
||||
|| !_settings.EnableCombat
|
||||
|| !_settings.IsMacroRunning)
|
||||
EndKite("combat stopped driving it");
|
||||
}
|
||||
}
|
||||
|
|
@ -1033,6 +1033,9 @@ public partial class CombatManager : IDisposable
|
|||
// A ghost (the server doesn't have it for us): skipped until it shows it is real.
|
||||
if (Ghosts.IsGhost(wo.Id)) { _ghostsSkippedInScan++; continue; }
|
||||
|
||||
// Left for hitting the environment (New target): skipped for EnvironmentSkipSec.
|
||||
if (IsEnvironmentSkipped(wo.Id)) continue;
|
||||
|
||||
// Just killed (KillerNotification) but not yet a corpse — skip so we
|
||||
// don't re-lock and cast at it during its death animation.
|
||||
if (_recentlyKilled.ContainsKey(wo.Id)) continue;
|
||||
|
|
@ -1135,6 +1138,7 @@ public partial class CombatManager : IDisposable
|
|||
_hitAt.Remove(id);
|
||||
_blacklistManager.ForgetTarget(id);
|
||||
Ghosts.NoteDeleted(id);
|
||||
OnEnvironmentObjectDeleted(objectId);
|
||||
|
||||
if (id == activeTargetId || id == _lockedTargetId || id == _lastAttackedTargetId)
|
||||
_awaitingCastResolution = false;
|
||||
|
|
@ -1436,13 +1440,15 @@ public partial class CombatManager : IDisposable
|
|||
_damageStore!.RecordTaken(src, name, ElementFromWord(m.Groups["type"].Value), amount);
|
||||
}
|
||||
|
||||
/// <summary>A chat line for the damage meter and the stall watchdog.
|
||||
/// <summary>A chat line for the damage meter, the stall watchdog and the environment throttle.
|
||||
/// <paramref name="chatType"/> is the line's eChatTypes (-1 = not known).</summary>
|
||||
public void HandleChatForDamage(string text, int chatType = -1)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text)) return;
|
||||
// Combat lines come from the server; one in a player's chat type is someone's imitation.
|
||||
if (RynthCore.Plugin.Shared.ChatSource.IsPlayerAuthored(chatType)) return;
|
||||
if (ChatSource.IsPlayerAuthored(chatType)) return;
|
||||
// An arrow into a wall: the environment-impact throttle's missile signal.
|
||||
if (NoteMissileEnvironmentChat(text)) return;
|
||||
// A miss is a swing too (stall watchdog). "You evaded X!" is the monster's miss, not ours.
|
||||
if (text.IndexOf(" evaded your attack", StringComparison.OrdinalIgnoreCase) > 0)
|
||||
NoteSwingEvidence("miss");
|
||||
|
|
@ -1455,6 +1461,7 @@ public partial class CombatManager : IDisposable
|
|||
if (critLine) _lastCritChatAt = now;
|
||||
|
||||
if (!CombatText.TryParseOutgoingHit(text, out string victim, out int amount)) return;
|
||||
NoteEnvironmentEvidence(); // a cast that hit something didn't only hit the environment
|
||||
bool crit = critLine || (now - _lastCritChatAt).TotalMilliseconds <= CRIT_WINDOW_MS;
|
||||
|
||||
// Which monster the line is about. One spell can hurt several (rings, walls, blasts,
|
||||
|
|
@ -1878,14 +1885,24 @@ public partial class CombatManager : IDisposable
|
|||
/// <summary>Test seam: one judged magic cast with no damage.</summary>
|
||||
internal void MagicMissForTest(int tid) => NoteMagicMissForResync(tid);
|
||||
|
||||
// ── Empyrean Handler lethal-ring evade (chat-triggered back-jump) ─────────
|
||||
// ── Empyrean Handler / Chaser lethal-ring evade (chat-triggered run-away) ──
|
||||
// ACECustom Handler emote: "The handler briefly channels infused Empyrean hatred
|
||||
// to release a lethal ring." The ring can't be melee-evaded — if the character is
|
||||
// inside its cast radius they die. On that line, when still in range of a Handler,
|
||||
// cancel the current swing/cast and back-jump away, then resume combat (target kept).
|
||||
private const string HandlerRingChannelHint = "channels infused Empyrean hatred to release a lethal ring";
|
||||
private const string HandlerRingChannelStart = "The handler briefly channels";
|
||||
private const string HandlerNameHint = "Empyrean Handler";
|
||||
// 2026-10-17: Empyrean Chasers cast the same lethal ring. Their emote isn't in any log yet, so
|
||||
// the line is matched loosely: "The handler ..." / "The chaser ..." naming a lethal ring, or
|
||||
// (any non-speech line) the ring phrase itself. The emote heard is logged once per session.
|
||||
private const string RingReleaseHint = "release a lethal ring";
|
||||
/// <summary>The ring casters: the monster name and the word their emote starts with ("The handler").</summary>
|
||||
private static readonly (string Name, string Subject)[] RingCasters =
|
||||
{
|
||||
("Empyrean Handler", "handler"),
|
||||
("Empyrean Chaser", "chaser"),
|
||||
};
|
||||
private bool _ringLineLogged;
|
||||
/// <summary>Yards: Handler lethal ring is treated as at least this wide (RingRange when larger).</summary>
|
||||
internal const double HandlerRingDangerYards = 12.0;
|
||||
/// <summary>Back-jump charge (ms) — run-back + jump must clear ~ring radius.</summary>
|
||||
|
|
@ -1897,6 +1914,27 @@ public partial class CombatManager : IDisposable
|
|||
private int _handlerRingEvadeId;
|
||||
private bool _handlerRingJumpStarted;
|
||||
|
||||
// Run-away escape (2026-10-17): one back-jump covered a few metres (backwards is AC's slowest
|
||||
// motion, and the 150 ms turn settle let it jump the wrong way): Silentkelpie died 1.5 m from
|
||||
// the Handler 3.2 s after the channel line. Now: face away and run forward (the fastest
|
||||
// motion), re-aiming away from the Handler, until outside the ring plus a margin.
|
||||
/// <summary>Yards past the ring radius to run before stopping.</summary>
|
||||
private const double HandlerRingSafeMarginYards = 4.0;
|
||||
/// <summary>Longest the run lasts (the ring has gone off by then).</summary>
|
||||
private const double HandlerRingRunMaxMs = 5_000;
|
||||
/// <summary>Attacks are held at least this long after the channel line (the ring's cast time).</summary>
|
||||
private const double HandlerRingHoldMinMs = 3_500;
|
||||
private const double HandlerRingTurnRefreshMs = 250;
|
||||
private const double HandlerRingRunRefreshMs = 1_000;
|
||||
/// <summary>Pump-thread orphan watch: Think stopped driving the run this long ago -> autorun off.</summary>
|
||||
private const double HandlerRingOrphanMs = 1_500;
|
||||
private const string RingEscapeSource = "Combat/RingEscape";
|
||||
private bool _ringRunActive;
|
||||
private bool _ringRunning; // autorun is on (else holding at a safe distance)
|
||||
private double _ringSafeYards;
|
||||
private double _ringDanger;
|
||||
private DateTime _ringRunAt = DateTime.MinValue, _ringTurnAt = DateTime.MinValue, _ringTickAt = DateTime.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Plugin wires this to <c>Jumper.Start("xs", faceHeading, ms)</c> — face the Handler
|
||||
/// then run-back jump (x+s) so the body moves away. Returns false if the jumper refused.
|
||||
|
|
@ -1906,9 +1944,9 @@ public partial class CombatManager : IDisposable
|
|||
/// <summary>True while the wired jumper is mid-turn / charge / settle.</summary>
|
||||
public Func<bool>? JumpBusy { get; set; }
|
||||
|
||||
/// <summary>True while a Handler-ring evade is holding combat (jump or settle).</summary>
|
||||
/// <summary>True while a Handler-ring evade is holding combat (run, wait, or jump/settle).</summary>
|
||||
public bool RingEvadeActive =>
|
||||
_handlerRingEvadeUntil != DateTime.MinValue && DateTime.Now < _handlerRingEvadeUntil;
|
||||
_ringRunActive || (_handlerRingEvadeUntil != DateTime.MinValue && DateTime.Now < _handlerRingEvadeUntil);
|
||||
|
||||
/// <summary>
|
||||
/// Chat line from RynthAiPlugin.OnChatWindowText. Starts a back-jump evade when the
|
||||
|
|
@ -1920,10 +1958,20 @@ public partial class CombatManager : IDisposable
|
|||
// Handler channel is an Emote (0x0C). ChatSource.IsPlayerAuthored treats Emote as
|
||||
// player speech, which would skip every real Handler line — anchor on the unique
|
||||
// phrase starting the line instead (player copies are "Name says, \"...\").
|
||||
bool anchored =
|
||||
RynthCore.Plugin.Shared.ChatSource.StartsWithMarker(text, HandlerRingChannelStart, StringComparison.OrdinalIgnoreCase)
|
||||
|| (RynthCore.Plugin.Shared.ChatSource.StartsWithMarker(text, "The handler", StringComparison.OrdinalIgnoreCase)
|
||||
&& text.IndexOf(HandlerRingChannelHint, StringComparison.OrdinalIgnoreCase) >= 0);
|
||||
bool mentionsRing = text.IndexOf(HandlerRingChannelHint, StringComparison.OrdinalIgnoreCase) >= 0
|
||||
|| text.IndexOf(RingReleaseHint, StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
if (!mentionsRing) return;
|
||||
|
||||
// Which caster the emote names ("The handler ..." / "The chaser ..."), or null.
|
||||
string? subject = null;
|
||||
foreach ((string _, string word) in RingCasters)
|
||||
if (RynthCore.Plugin.Shared.ChatSource.StartsWithMarker(text, "The " + word, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
subject = word;
|
||||
break;
|
||||
}
|
||||
bool anchored = subject != null
|
||||
|| RynthCore.Plugin.Shared.ChatSource.StartsWithMarker(text, HandlerRingChannelStart, StringComparison.OrdinalIgnoreCase);
|
||||
if (!anchored)
|
||||
{
|
||||
// Mid-line only when the type is clearly not player speech (some clients strip "The ").
|
||||
|
|
@ -1935,64 +1983,91 @@ public partial class CombatManager : IDisposable
|
|||
or RynthCore.Plugin.Shared.ChatSource.Allegiance
|
||||
or RynthCore.Plugin.Shared.ChatSource.Fellowship)
|
||||
return;
|
||||
if (text.IndexOf(HandlerRingChannelHint, StringComparison.OrdinalIgnoreCase) < 0) return;
|
||||
if (text.IndexOf(" says,", StringComparison.OrdinalIgnoreCase) >= 0
|
||||
|| text.IndexOf(" tells you,", StringComparison.OrdinalIgnoreCase) >= 0)
|
||||
return;
|
||||
}
|
||||
|
||||
// The wording that triggered, once per session (the Chaser's emote wasn't known when this
|
||||
// was written; the log shows it the first time one is heard).
|
||||
if (!_ringLineLogged)
|
||||
{
|
||||
_ringLineLogged = true;
|
||||
_host.Log($"[CombatEvade] lethal-ring line heard (type 0x{chatType:X2}): \"{text.Trim()}\"");
|
||||
}
|
||||
|
||||
DateTime now = DateTime.Now;
|
||||
if (_handlerRingEvadeAt != DateTime.MinValue
|
||||
&& (now - _handlerRingEvadeAt).TotalMilliseconds < HandlerRingEvadeCooldownMs)
|
||||
return;
|
||||
|
||||
if (!TryFindHandlerForRingEvade(out int handlerId, out double dist, out string name))
|
||||
if (!TryFindHandlerForRingEvade(subject, out int handlerId, out double dist, out string name))
|
||||
{
|
||||
_host.Log("[CombatEvade] Handler lethal-ring channel heard, but no Empyrean Handler is nearby — no jump.");
|
||||
_host.Log("[CombatEvade] Lethal-ring channel heard, but no Empyrean Handler or Chaser is nearby — no evade.");
|
||||
return;
|
||||
}
|
||||
|
||||
double danger = Math.Max(HandlerRingDangerYards, Math.Max(1, _settings.RingRange));
|
||||
if (dist > danger)
|
||||
{
|
||||
_host.Log($"[CombatEvade] Handler lethal-ring channel; '{name}' at {dist:0.0} m (outside {danger:0.#} m) — staying put.");
|
||||
_host.Log($"[CombatEvade] Lethal-ring channel; '{name}' at {dist:0.0} m (outside {danger:0.#} m) — staying put.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Face the Handler, then Jumper "xs" (back + run) moves the body away from it.
|
||||
// Facing away + back-jump would leap into the ring.
|
||||
float faceHandler = 0f;
|
||||
if (TryGetHeadingTo(handlerId, out double toHandler, out _))
|
||||
faceHandler = (float)(toHandler % 360.0);
|
||||
else if (_host.TryGetPlayerHeading(out float curr))
|
||||
faceHandler = curr;
|
||||
bool haveHeading = TryGetHeadingTo(handlerId, out double toHandler, out _);
|
||||
|
||||
_handlerRingEvadeAt = now;
|
||||
_handlerRingEvadeId = handlerId;
|
||||
_handlerRingJumpStarted = false;
|
||||
// Hold combat long enough for turn + charge + land + one re-engage tick.
|
||||
_handlerRingEvadeUntil = now.AddMilliseconds(HandlerRingJumpHoldMs + 2_200);
|
||||
|
||||
// Stop the bound melee/missile attack so the jump isn't eaten by the swing servo.
|
||||
// Stop the bound melee/missile attack (and any kite run) so the escape isn't eaten by
|
||||
// the swing servo or steered by the pull-away.
|
||||
try
|
||||
{
|
||||
if (_host.HasCancelAttack) _host.CancelAttack();
|
||||
ReleaseHeldTurn();
|
||||
EndKite("Handler lethal ring");
|
||||
}
|
||||
catch { }
|
||||
|
||||
// Run away: face directly away from the Handler and autorun (forward is the fastest motion).
|
||||
if (haveHeading && _host.HasTurnToHeading && _host.HasSetAutoRun)
|
||||
{
|
||||
float away = (float)((toHandler + 180.0) % 360.0);
|
||||
_host.TurnToHeadingBy(RingEscapeSource, away);
|
||||
bool running = _host.SetAutoRunBy(RingEscapeSource, true);
|
||||
_ringRunActive = true;
|
||||
_ringRunning = running;
|
||||
_ringDanger = danger;
|
||||
_ringSafeYards = danger + HandlerRingSafeMarginYards;
|
||||
_ringRunAt = running ? now : DateTime.MinValue;
|
||||
_ringTurnAt = _ringTickAt = now;
|
||||
_handlerRingEvadeUntil = DateTime.MinValue;
|
||||
_host.Log($"[CombatEvade] Lethal ring — running away from '{name}' at {dist:0.0} m " +
|
||||
$"(ring {danger:0.#} m, stop at {_ringSafeYards:0.#} m), heading {away:0}°" +
|
||||
(running ? "." : " (autorun refused; holding and re-trying)."));
|
||||
return;
|
||||
}
|
||||
|
||||
// No heading snap / autorun on this engine: the older back-jump. Face the Handler, then
|
||||
// Jumper "xs" (back + run) moves the body away from it.
|
||||
float faceHandler = haveHeading ? (float)(toHandler % 360.0)
|
||||
: _host.TryGetPlayerHeading(out float curr) ? curr : 0f;
|
||||
// Hold combat long enough for turn + charge + land + one re-engage tick.
|
||||
_handlerRingEvadeUntil = now.AddMilliseconds(HandlerRingJumpHoldMs + 2_200);
|
||||
|
||||
bool started = RequestBackJump?.Invoke(faceHandler, HandlerRingJumpHoldMs) == true;
|
||||
if (started)
|
||||
{
|
||||
_handlerRingJumpStarted = true;
|
||||
_host.Log($"[CombatEvade] Empyrean Handler lethal ring — back-jump away from '{name}' " +
|
||||
_host.Log($"[CombatEvade] Lethal ring — back-jump away from '{name}' " +
|
||||
$"at {dist:0.0} m (danger {danger:0.#} m), face {faceHandler:0}° then xs.");
|
||||
}
|
||||
else
|
||||
{
|
||||
_handlerRingEvadeUntil = DateTime.MinValue;
|
||||
_handlerRingEvadeId = 0;
|
||||
_host.Log("[CombatEvade] Empyrean Handler lethal ring heard in range, but the back-jump did not start.");
|
||||
_host.Log("[CombatEvade] Lethal ring heard in range, but the back-jump did not start.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2002,6 +2077,7 @@ public partial class CombatManager : IDisposable
|
|||
/// </summary>
|
||||
private bool TickRingEvade()
|
||||
{
|
||||
if (_ringRunActive) return TickRingRun();
|
||||
if (_handlerRingEvadeUntil == DateTime.MinValue) return false;
|
||||
DateTime now = DateTime.Now;
|
||||
bool jumperBusy = JumpBusy?.Invoke() == true;
|
||||
|
|
@ -2012,7 +2088,7 @@ public partial class CombatManager : IDisposable
|
|||
_handlerRingEvadeUntil = DateTime.MinValue;
|
||||
_handlerRingEvadeId = 0;
|
||||
_handlerRingJumpStarted = false;
|
||||
_host.Log("[CombatEvade] Handler ring evade done — re-engaging.");
|
||||
_host.Log("[CombatEvade] Ring evade done — re-engaging.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -2026,28 +2102,140 @@ public partial class CombatManager : IDisposable
|
|||
_handlerRingEvadeUntil = DateTime.MinValue;
|
||||
_handlerRingEvadeId = 0;
|
||||
_handlerRingJumpStarted = false;
|
||||
_host.Log("[CombatEvade] Handler ring evade done — re-engaging.");
|
||||
_host.Log("[CombatEvade] Ring evade done — re-engaging.");
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>Nearest Empyrean Handler (active target preferred when it is one).</summary>
|
||||
private bool TryFindHandlerForRingEvade(out int handlerId, out double dist, out string name)
|
||||
/// <summary>
|
||||
/// The run-away escape, from Think: run (re-aiming away from the Handler) until outside the
|
||||
/// ring plus a margin or the run times out, then hold attacks until the ring has gone off
|
||||
/// (running again if the Handler closes back inside the ring). Keeps the target, so combat
|
||||
/// re-engages after.
|
||||
/// </summary>
|
||||
private bool TickRingRun()
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
_ringTickAt = now;
|
||||
double elapsed = (now - _handlerRingEvadeAt).TotalMilliseconds;
|
||||
int me = _host.GetPlayerId() == 0 ? 0 : (int)_host.GetPlayerId();
|
||||
double d = me != 0 && _handlerRingEvadeId != 0 ? _worldFilter.Distance(me, _handlerRingEvadeId) : -1;
|
||||
bool gone = d < 0;
|
||||
|
||||
if (_ringRunning)
|
||||
{
|
||||
string? stopWhy = gone ? "the caster is gone"
|
||||
: d >= _ringSafeYards ? "outside the ring"
|
||||
: elapsed >= HandlerRingRunMaxMs ? "run timed out"
|
||||
: null;
|
||||
if (stopWhy != null)
|
||||
{
|
||||
_host.SetAutoRunBy(RingEscapeSource, false);
|
||||
_ringRunning = false;
|
||||
_ringRunAt = DateTime.MinValue;
|
||||
_host.Log($"[CombatEvade] Ring run stopped after {elapsed:0} ms: {stopWhy}" +
|
||||
(gone ? "." : $" ({d:0.0} m from the caster)."));
|
||||
}
|
||||
}
|
||||
else if (!gone && d < _ringDanger && elapsed < HandlerRingHoldMinMs)
|
||||
{
|
||||
// Holding, but the Handler came back inside the ring before it went off: run again.
|
||||
_ringRunning = true;
|
||||
_ringTurnAt = _ringRunAt = DateTime.MinValue;
|
||||
_host.Log($"[CombatEvade] Caster back inside the ring ({d:0.0} m) — running again.");
|
||||
}
|
||||
|
||||
if (_ringRunning)
|
||||
{
|
||||
if ((now - _ringTurnAt).TotalMilliseconds >= HandlerRingTurnRefreshMs
|
||||
&& TryGetHeadingTo(_handlerRingEvadeId, out double toward, out _))
|
||||
{
|
||||
_host.TurnToHeadingBy(RingEscapeSource, (float)((toward + 180.0) % 360.0));
|
||||
_ringTurnAt = now;
|
||||
}
|
||||
if ((now - _ringRunAt).TotalMilliseconds >= HandlerRingRunRefreshMs
|
||||
&& _host.SetAutoRunBy(RingEscapeSource, true))
|
||||
_ringRunAt = now;
|
||||
LastCombatSkipReason = "handler-ring-run";
|
||||
_tickWait = CombatLatencyTracker.Wait.Other;
|
||||
_stallWatch.Hold(now);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!gone && elapsed < HandlerRingHoldMinMs)
|
||||
{
|
||||
LastCombatSkipReason = "handler-ring-wait";
|
||||
_tickWait = CombatLatencyTracker.Wait.Other;
|
||||
_stallWatch.Hold(now);
|
||||
return true;
|
||||
}
|
||||
|
||||
EndRingRun();
|
||||
_host.Log($"[CombatEvade] Ring evade done after {elapsed:0} ms" +
|
||||
(gone ? "." : $" ({d:0.0} m away) — re-engaging."));
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>Clears the run-away escape (autorun off if it was on).</summary>
|
||||
private void EndRingRun()
|
||||
{
|
||||
if (_ringRunning) _host.SetAutoRunBy(RingEscapeSource, false);
|
||||
_ringRunActive = _ringRunning = false;
|
||||
_ringRunAt = _ringTurnAt = DateTime.MinValue;
|
||||
_handlerRingEvadeUntil = DateTime.MinValue;
|
||||
_handlerRingEvadeId = 0;
|
||||
}
|
||||
|
||||
/// <summary>Stops a Handler-ring escape now (macro stop, death). Safe to call when none is running.</summary>
|
||||
public void StopRingEscape(string why)
|
||||
{
|
||||
if (!_ringRunActive) return;
|
||||
EndRingRun();
|
||||
_host.Log($"[CombatEvade] Ring escape stopped: {why}.");
|
||||
}
|
||||
|
||||
/// <summary>Pump-thread orphan watch: Think drives the run; when it stops (death, another
|
||||
/// activity, combat or the macro off) autorun must not be left on.</summary>
|
||||
internal void PollRingEscape()
|
||||
{
|
||||
if (!_ringRunActive) return;
|
||||
if ((DateTime.Now - _ringTickAt).TotalMilliseconds > HandlerRingOrphanMs
|
||||
|| !_settings.EnableCombat
|
||||
|| !_settings.IsMacroRunning)
|
||||
StopRingEscape("combat stopped driving it");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The nearest ring caster (Empyrean Handler or Chaser). When the emote named one ("The chaser
|
||||
/// ..."), the nearest of that kind is taken if there is one in range of the scan; otherwise the
|
||||
/// nearest of either kind.
|
||||
/// </summary>
|
||||
private bool TryFindHandlerForRingEvade(string? subject, out int handlerId, out double dist, out string name)
|
||||
{
|
||||
handlerId = 0; dist = double.MaxValue; name = "";
|
||||
int me = _host.GetPlayerId() == 0 ? 0 : (int)_host.GetPlayerId();
|
||||
if (me == 0) return false;
|
||||
|
||||
int bestId = 0;
|
||||
double bestDist = double.MaxValue;
|
||||
string bestName = "";
|
||||
string? preferred = null;
|
||||
if (subject != null)
|
||||
foreach ((string n, string word) in RingCasters)
|
||||
if (word == subject) preferred = n;
|
||||
|
||||
int bestId = 0, prefId = 0;
|
||||
double bestDist = double.MaxValue, prefDist = double.MaxValue;
|
||||
string bestName = "", prefName = "";
|
||||
|
||||
void Consider(int id, string? nm)
|
||||
{
|
||||
if (id == 0 || string.IsNullOrEmpty(nm)) return;
|
||||
if (nm.IndexOf(HandlerNameHint, StringComparison.OrdinalIgnoreCase) < 0) return;
|
||||
bool caster = false;
|
||||
foreach ((string n, string _) in RingCasters)
|
||||
if (nm.IndexOf(n, StringComparison.OrdinalIgnoreCase) >= 0) { caster = true; break; }
|
||||
if (!caster) return;
|
||||
double d = _worldFilter.Distance(me, id);
|
||||
if (d < 0 || d >= bestDist) return;
|
||||
bestDist = d; bestId = id; bestName = nm;
|
||||
if (d < 0) return;
|
||||
if (d < bestDist) { bestDist = d; bestId = id; bestName = nm; }
|
||||
if (preferred != null && nm.IndexOf(preferred, StringComparison.OrdinalIgnoreCase) >= 0 && d < prefDist)
|
||||
{ prefDist = d; prefId = id; prefName = nm; }
|
||||
}
|
||||
|
||||
if (activeTargetId != 0)
|
||||
|
|
@ -2070,6 +2258,7 @@ public partial class CombatManager : IDisposable
|
|||
catch { }
|
||||
}
|
||||
|
||||
if (prefId != 0) { handlerId = prefId; dist = prefDist; name = prefName; return true; }
|
||||
if (bestId == 0) return false;
|
||||
handlerId = bestId; dist = bestDist; name = bestName;
|
||||
return true;
|
||||
|
|
@ -2081,6 +2270,7 @@ public partial class CombatManager : IDisposable
|
|||
// Damage / health change on the cast we're judging → that cast HIT.
|
||||
if (targetId == _pendingJudgeTargetId)
|
||||
_damageSincePendingCast = true;
|
||||
NoteEnvironmentEvidence();
|
||||
// Immediate positive feedback on the engaged target clears the streak.
|
||||
if (targetId == _lastAttackedTargetId)
|
||||
_consecutiveCastMisses = 0;
|
||||
|
|
@ -2101,6 +2291,7 @@ public partial class CombatManager : IDisposable
|
|||
int i = text.IndexOf(" evaded your attack", StringComparison.OrdinalIgnoreCase);
|
||||
if (i < 0) i = text.IndexOf(" resists your spell", StringComparison.OrdinalIgnoreCase);
|
||||
if (i <= 0) return;
|
||||
NoteEnvironmentEvidence(); // the spell or swing reached a monster
|
||||
string who = text.Substring(0, i).Trim();
|
||||
if (who.StartsWith("The ", StringComparison.Ordinal)) who = who.Substring(4);
|
||||
if (who.Length == 0) return;
|
||||
|
|
@ -2422,6 +2613,9 @@ public partial class CombatManager : IDisposable
|
|||
_host.Log($"[RynthAi] DropTarget 0x{activeTargetId:X8}: {reason} [{DescribeTargetPos(activeTargetId)}]");
|
||||
activeTargetId = 0;
|
||||
_lockedTargetId = 0;
|
||||
EndKite("target dropped");
|
||||
EndEnvironmentApproach("target dropped");
|
||||
_envPendingTargetId = 0;
|
||||
// A turn held toward the dropped target must be let go, or the character keeps
|
||||
// spinning until something else happens to release it.
|
||||
if (_facingTarget) ClearCombatTurnMotions();
|
||||
|
|
@ -2924,6 +3118,7 @@ public partial class CombatManager : IDisposable
|
|||
int id = _scannedTargets[i].Id;
|
||||
if (id == excludeId) continue;
|
||||
if (_recentlyKilled.ContainsKey(id)) continue;
|
||||
if (IsEnvironmentSkipped(id)) continue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -3179,7 +3374,7 @@ public partial class CombatManager : IDisposable
|
|||
ForgetScanned(activeTargetId);
|
||||
DropTarget("hp=0");
|
||||
}
|
||||
else if (target != null &&
|
||||
else if (target != null && !KiteActive &&
|
||||
_worldFilter.Distance(_host.GetPlayerId() == 0 ? 0 : (int)_host.GetPlayerId(), activeTargetId) > disengageLimit)
|
||||
DropTarget("out of range");
|
||||
// If target == null here it's a transient world-filter miss — keep the lock,
|
||||
|
|
@ -3299,9 +3494,18 @@ public partial class CombatManager : IDisposable
|
|||
// step-back — instead of dropping to peace and restarting the approach.
|
||||
double currentDist = _worldFilter.Distance(
|
||||
_host.GetPlayerId() == 0 ? 0 : (int)_host.GetPlayerId(), activeTargetId);
|
||||
// Pull-away kite runs before the disengage gate: fleeing intentionally stretches
|
||||
// range, and the kite itself waits for catch-up rather than idling here.
|
||||
if (RunKite(targetObj, currentDist))
|
||||
return true;
|
||||
if (currentDist > disengageLimit)
|
||||
return true;
|
||||
|
||||
// Environment-impact throttle: too many missiles/spells into walls short of this target
|
||||
// stop the attack and move closer or switch target (CombatManager.EnvironmentImpact.cs).
|
||||
if (RunEnvironmentImpact(targetObj, currentDist))
|
||||
return true;
|
||||
|
||||
// Melee/missile stall safety net (see CombatStallWatchdog). Holds the attack while
|
||||
// one of its steps is settling.
|
||||
if (RunStallWatchdog(targetObj, currentDist))
|
||||
|
|
@ -4130,6 +4334,9 @@ public partial class CombatManager : IDisposable
|
|||
{
|
||||
_wasMacroRunning = false;
|
||||
ClearCombatTurnMotions();
|
||||
ResetEnvironmentImpact("macro stopped");
|
||||
ResetKite("macro stopped");
|
||||
StopRingEscape("macro stopped");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -4137,6 +4344,13 @@ public partial class CombatManager : IDisposable
|
|||
|
||||
LogCombatStateIfChanged();
|
||||
|
||||
// Environment-impact throttle: follow our spell projectiles, judge finished casts, and
|
||||
// let go of an approach Think stopped driving.
|
||||
try { PollEnvironmentImpact(); }
|
||||
catch (Exception ex) { _host.Log($"[EnvImpact] poll crashed: {ex.Message}"); }
|
||||
try { PollKite(); }
|
||||
catch (Exception ex) { _host.Log($"[Kite] poll crashed: {ex.Message}"); }
|
||||
|
||||
// A combat mode change ends the server's attack (HandleActionChangeCombatMode →
|
||||
// HandleActionCancelAttack), so out of Melee/Missile there is nothing bound to release.
|
||||
if (_serverAttackTargetId != 0)
|
||||
|
|
@ -4217,6 +4431,8 @@ public partial class CombatManager : IDisposable
|
|||
{
|
||||
if (_scannedTargets.Count == 0) return;
|
||||
if (TryLockForcedTarget()) return; // Target lock (/ra targetlock): CombatManager.TargetLock.cs
|
||||
// Pull-away in progress: keep the incumbent until the kite ends (do not switch mid-flee).
|
||||
if (KiteActive && _lockedTargetId != 0) return;
|
||||
// Boost Loot Priority: the next target waits for the last kill's corpse. Without this the
|
||||
// next lock went out a few ms after each kill, 1-3 s before ACE creates the corpse, so the
|
||||
// arbiter always saw combat engaged and corpses were looted in batches (2026-10-14).
|
||||
|
|
@ -6080,17 +6296,19 @@ public partial class CombatManager : IDisposable
|
|||
return false;
|
||||
}
|
||||
|
||||
float power;
|
||||
// Power: the monster rule's Attack Power (High / Reckless / Variable / Reckless +
|
||||
// Variable), else the global Melee/Missile Power (AttackPowerPlanner.cs).
|
||||
int powerPct = isMissile ? _settings.MissileAttackPower : _settings.MeleeAttackPower;
|
||||
if (powerPct < 0)
|
||||
bool recklessTrained = _charSkills == null || _charSkills[AcSkillType.Recklessness].Training >= 2;
|
||||
var powerTarget = _worldFilter[activeTargetId];
|
||||
string powerMode = AttackPowerModes.Effective(GetRuleForTarget(powerTarget), DefaultMonsterRule());
|
||||
float power = AttackPowerModes.Resolve(powerMode, powerPct, _settings.UseRecklessness, recklessTrained,
|
||||
_settings.VariablePowerMin, _settings.VariablePowerMax, PowerRandom);
|
||||
if (powerMode != AttackPowerModes.Default && _powerLoggedTargetId != activeTargetId)
|
||||
{
|
||||
power = 1.0f;
|
||||
if (_settings.UseRecklessness && (_charSkills == null || _charSkills[AcSkillType.Recklessness].Training >= 2))
|
||||
power = 0.8f;
|
||||
}
|
||||
else
|
||||
{
|
||||
power = powerPct / 100f;
|
||||
_powerLoggedTargetId = activeTargetId;
|
||||
_host.Log($"[AttackPower] 0x{targetId:X8} '{powerTarget?.Name}': {powerMode}" +
|
||||
(recklessTrained ? "" : " (Recklessness untrained: no reckless band)") + $", first attack at {power * 100:0}%");
|
||||
}
|
||||
|
||||
int uiHeight = isMissile ? _settings.MissileAttackHeight : _settings.MeleeAttackHeight;
|
||||
|
|
@ -6151,10 +6369,17 @@ public partial class CombatManager : IDisposable
|
|||
if (matches) return r;
|
||||
}
|
||||
|
||||
return _settings.MonsterRules.FirstOrDefault(
|
||||
m => m.Name.Equals("Default", StringComparison.OrdinalIgnoreCase));
|
||||
return DefaultMonsterRule();
|
||||
}
|
||||
|
||||
/// <summary>The Monsters tab's DEFAULT line (the catch-all rule), or null.</summary>
|
||||
private MonsterRule? DefaultMonsterRule() => _settings.MonsterRules.FirstOrDefault(
|
||||
m => m.Name.Equals("Default", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
/// <summary>Random source for Variable attack power, [0, 1); tests replace it.</summary>
|
||||
internal Func<double> PowerRandom { get; set; } = Random.Shared.NextDouble;
|
||||
private int _powerLoggedTargetId;
|
||||
|
||||
private void AttackWithMagic(WorldObject target)
|
||||
{
|
||||
_wallFaceHeld = false;
|
||||
|
|
@ -6331,6 +6556,10 @@ public partial class CombatManager : IDisposable
|
|||
_pendingOffensiveCastAt = DateTime.Now;
|
||||
_pendingOffensiveTargetId = activeTargetId;
|
||||
NoteOffensiveSeq();
|
||||
// Environment-impact throttle: follow this cast's projectiles (rings and walls
|
||||
// don't fly at the target, so they aren't judged).
|
||||
if (!multiTarget)
|
||||
RegisterCastWatch(activeTargetId, SpellTableStub.GetById(offensiveSpellId)?.Name ?? $"spell {offensiveSpellId}");
|
||||
|
||||
// Tag this cast's weapon + element + tier so the pushed damage event
|
||||
// can be attributed to it, count it for casts-to-kill learning, then
|
||||
|
|
|
|||
178
Plugins/RynthCore.Plugin.RynthAi/Combat/EnvironmentImpact.cs
Normal file
178
Plugins/RynthCore.Plugin.RynthAi/Combat/EnvironmentImpact.cs
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi;
|
||||
|
||||
// ============================================================================
|
||||
// Environment-impact throttle (2026-10-12): pure rules and bookkeeping.
|
||||
//
|
||||
// A missile or a war/void projectile that hits a wall, a pillar, the ceiling
|
||||
// or another object short of the target does no damage, and before this the bot
|
||||
// kept firing into it until the no-damage blacklist (several settle windows) or
|
||||
// the no-progress timeout gave up. Now, once a target has taken
|
||||
// EnvironmentImpactLimit such hits within EnvironmentImpactWindowSec, combat
|
||||
// stops attacking it and does what the player chose for that kind of combat:
|
||||
// move closer, pick another target, or move closer once and then pick another.
|
||||
//
|
||||
// The signals (CombatManager.EnvironmentImpact.cs):
|
||||
// missile ACE ProjectileCollisionHelper.OnCollideEnvironment sends the shooter
|
||||
// "Your missile attack hit the environment." (also when the arrow hits
|
||||
// an object that isn't its target).
|
||||
// magic ACE sends nothing (SpellProjectile.OnCollideEnvironment only
|
||||
// explodes the projectile), so the bot follows its own projectiles and
|
||||
// judges where they stopped (ProjectileImpactJudge).
|
||||
//
|
||||
// Everything here is pure (no host, no clock of its own) so the host tests can
|
||||
// drive it directly.
|
||||
// ============================================================================
|
||||
|
||||
/// <summary>What combat does once a target has taken too many environment hits.
|
||||
/// Stored as an int in the settings (MissileEnvironmentResponse / MagicEnvironmentResponse).</summary>
|
||||
public enum EnvironmentResponse
|
||||
{
|
||||
/// <summary>No detection; keep attacking (the behaviour before 2026-10-12).</summary>
|
||||
Off = 0,
|
||||
/// <summary>Move toward the target each time; once already close, pick another target.</summary>
|
||||
MoveCloser = 1,
|
||||
/// <summary>Skip the target for a while and pick another (moves closer when there is no other).</summary>
|
||||
NewTarget = 2,
|
||||
/// <summary>Move closer once; if the shots still hit the environment, pick another target.</summary>
|
||||
CloserThenNewTarget = 3,
|
||||
}
|
||||
|
||||
/// <summary>The step combat takes for one throttle trip.</summary>
|
||||
public enum EnvironmentAction { None, Approach, NewTarget }
|
||||
|
||||
/// <summary>Choices and the decision for one throttle trip.</summary>
|
||||
public static class EnvironmentImpactPlanner
|
||||
{
|
||||
/// <summary>Combo labels, in <see cref="EnvironmentResponse"/> order (plugin and engine settings panels).</summary>
|
||||
public static readonly string[] ResponseNames =
|
||||
{ "Off", "Move closer", "New target", "Move closer, then new target" };
|
||||
|
||||
/// <summary>Approaching is pointless within this much of the closest allowed distance.</summary>
|
||||
public const double ApproachSlackMeters = 0.5;
|
||||
|
||||
/// <summary>A saved int as a response; anything out of range is Off.</summary>
|
||||
public static EnvironmentResponse Parse(int value)
|
||||
=> value is >= 0 and <= 3 ? (EnvironmentResponse)value : EnvironmentResponse.Off;
|
||||
|
||||
/// <summary>The label for a saved value (logs and the settings panels).</summary>
|
||||
public static string Name(int value) => ResponseNames[(int)Parse(value)];
|
||||
|
||||
/// <summary>
|
||||
/// The step for a throttle trip on a target <paramref name="distance"/> metres away that
|
||||
/// has already been approached <paramref name="approachesDone"/> times for this reason.
|
||||
/// Never approaches nearer than <paramref name="minDistance"/>. A new target needs another
|
||||
/// monster in reach: skipping the only one would leave it free to hit the bot while combat
|
||||
/// idles, so then the bot moves closer if it still can, or keeps attacking (None).
|
||||
/// </summary>
|
||||
public static EnvironmentAction Decide(EnvironmentResponse response, int approachesDone,
|
||||
double distance, double minDistance, bool hasAlternateTarget)
|
||||
{
|
||||
bool canApproach = double.IsFinite(distance) && distance > minDistance + ApproachSlackMeters;
|
||||
EnvironmentAction approachElseNone = canApproach ? EnvironmentAction.Approach : EnvironmentAction.None;
|
||||
EnvironmentAction newTargetElse = hasAlternateTarget ? EnvironmentAction.NewTarget : approachElseNone;
|
||||
return response switch
|
||||
{
|
||||
EnvironmentResponse.MoveCloser => canApproach ? EnvironmentAction.Approach : newTargetElse,
|
||||
EnvironmentResponse.NewTarget => newTargetElse,
|
||||
EnvironmentResponse.CloserThenNewTarget => approachesDone == 0 && canApproach
|
||||
? EnvironmentAction.Approach : newTargetElse,
|
||||
_ => EnvironmentAction.None,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Where an approach stops: <paramref name="stepMeters"/> nearer than now, never nearer
|
||||
/// than <paramref name="minDistance"/>.
|
||||
/// </summary>
|
||||
public static double ApproachGoal(double distance, double stepMeters, double minDistance)
|
||||
=> Math.Max(Math.Max(0.5, minDistance), distance - Math.Max(1.0, stepMeters));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Environment hits per target inside a sliding window, and how many times each target has
|
||||
/// been approached for them. Pump thread only.
|
||||
/// </summary>
|
||||
public sealed class EnvironmentImpactThrottle
|
||||
{
|
||||
private readonly Dictionary<int, List<DateTime>> _hits = new();
|
||||
private readonly Dictionary<int, int> _approaches = new();
|
||||
// A long session meets thousands of monsters; ids are forgotten on delete, this is the backstop.
|
||||
private const int MaxTracked = 256;
|
||||
|
||||
/// <summary>Records one hit on <paramref name="targetId"/> and returns the hits within the window.</summary>
|
||||
public int Record(int targetId, DateTime now, double windowSec)
|
||||
{
|
||||
if (targetId == 0) return 0;
|
||||
if (_hits.Count >= MaxTracked && !_hits.ContainsKey(targetId)) _hits.Clear();
|
||||
if (!_hits.TryGetValue(targetId, out var list)) _hits[targetId] = list = new List<DateTime>(4);
|
||||
list.Add(now);
|
||||
Prune(list, now, windowSec);
|
||||
return list.Count;
|
||||
}
|
||||
|
||||
/// <summary>Hits on <paramref name="targetId"/> within the window (no new hit).</summary>
|
||||
public int Count(int targetId, DateTime now, double windowSec)
|
||||
{
|
||||
if (!_hits.TryGetValue(targetId, out var list)) return 0;
|
||||
Prune(list, now, windowSec);
|
||||
return list.Count;
|
||||
}
|
||||
|
||||
/// <summary>Starts the count again (after the bot acted on it).</summary>
|
||||
public void ResetHits(int targetId) => _hits.Remove(targetId);
|
||||
|
||||
public int Approaches(int targetId) => _approaches.TryGetValue(targetId, out int n) ? n : 0;
|
||||
|
||||
public void NoteApproach(int targetId)
|
||||
{
|
||||
if (_approaches.Count >= MaxTracked && !_approaches.ContainsKey(targetId)) _approaches.Clear();
|
||||
_approaches[targetId] = Approaches(targetId) + 1;
|
||||
}
|
||||
|
||||
/// <summary>The object is gone (deleted): a respawn reusing the id starts clean.</summary>
|
||||
public void Forget(int targetId)
|
||||
{
|
||||
_hits.Remove(targetId);
|
||||
_approaches.Remove(targetId);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_hits.Clear();
|
||||
_approaches.Clear();
|
||||
}
|
||||
|
||||
private static void Prune(List<DateTime> list, DateTime now, double windowSec)
|
||||
{
|
||||
double window = Math.Max(1.0, windowSec);
|
||||
list.RemoveAll(t => (now - t).TotalSeconds > window);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Where a spell projectile stopped, against where the target is. A projectile that reaches
|
||||
/// the target stops at its surface; one that hits the environment stops short of it, toward
|
||||
/// the caster. Both conditions must hold, so a large monster (its surface a few metres from its
|
||||
/// centre) isn't read as a wall. The caller also requires that no hit, resist or evade line
|
||||
/// arrived for the cast: that is the final word for a large monster or an odd stop.
|
||||
/// </summary>
|
||||
public static class ProjectileImpactJudge
|
||||
{
|
||||
/// <summary>A stop farther than this from the target's centre didn't touch it.</summary>
|
||||
public const double MissRadiusMeters = 4.0;
|
||||
/// <summary>A stop at least this much nearer to the caster than the target is "short".</summary>
|
||||
public const double ShortByMeters = 2.0;
|
||||
/// <summary>A projectile that flew less than this never really left (or was never ours).</summary>
|
||||
public const double MinTravelMeters = 1.0;
|
||||
|
||||
/// <summary>True when the projectile stopped short of the target and away from it.</summary>
|
||||
public static bool StoppedShort(double impactToTarget, double casterToImpact, double casterToTarget)
|
||||
{
|
||||
if (!double.IsFinite(impactToTarget) || !double.IsFinite(casterToImpact) || !double.IsFinite(casterToTarget))
|
||||
return false;
|
||||
return impactToTarget > MissRadiusMeters && casterToImpact + ShortByMeters < casterToTarget;
|
||||
}
|
||||
}
|
||||
79
Plugins/RynthCore.Plugin.RynthAi/Combat/KiteModes.cs
Normal file
79
Plugins/RynthCore.Plugin.RynthAi/Combat/KiteModes.cs
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
using System;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi;
|
||||
|
||||
// ============================================================================
|
||||
// Per-monster kite / pull-away (2026-10-16): MonsterRule.Kite.
|
||||
//
|
||||
// Default the DEFAULT line's choice; on the DEFAULT line, Off (fight in place)
|
||||
// Off engage and kill where the mob stands
|
||||
// PullAway after a brief tag, run away until the mob has been pulled
|
||||
// KitePullMeters from its lock-spot origin, then kill it alone
|
||||
//
|
||||
// Resolution matches AttackPowerModes: a rule's own value wins; "Default" falls
|
||||
// through to the DEFAULT row; blank/unknown is Default (→ Off via the DEFAULT row).
|
||||
// ============================================================================
|
||||
|
||||
/// <summary>Names and resolution of <see cref="MonsterRule.Kite"/>.</summary>
|
||||
public static class KiteModes
|
||||
{
|
||||
public const string Default = "Default";
|
||||
public const string Off = "Off";
|
||||
public const string PullAway = "PullAway";
|
||||
|
||||
/// <summary>Every choice, in the order the editors list them.</summary>
|
||||
public static readonly string[] All = { Default, Off, PullAway };
|
||||
|
||||
/// <summary>Combo labels (plugin Advanced + engine Monsters/Damage panels).</summary>
|
||||
public static readonly string[] DisplayNames = { "Default", "Off", "Pull away" };
|
||||
|
||||
/// <summary>A saved value as one of <see cref="All"/>; blank or unknown is Default.</summary>
|
||||
public static string Normalize(string? value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value)) return Default;
|
||||
string v = value.Trim();
|
||||
foreach (string m in All)
|
||||
if (m.Equals(v, StringComparison.OrdinalIgnoreCase)) return m;
|
||||
// Hand-typed / UI spellings: "Pull away", "pull-away", "Kite".
|
||||
string squeezed = v.Replace(" ", "").Replace("-", "").Replace("_", "");
|
||||
if (squeezed.Equals("PullAway", StringComparison.OrdinalIgnoreCase)
|
||||
|| squeezed.Equals("Kite", StringComparison.OrdinalIgnoreCase)
|
||||
|| squeezed.Equals("Pull", StringComparison.OrdinalIgnoreCase))
|
||||
return PullAway;
|
||||
if (squeezed.Equals("None", StringComparison.OrdinalIgnoreCase)
|
||||
|| squeezed.Equals("Disabled", StringComparison.OrdinalIgnoreCase))
|
||||
return Off;
|
||||
return Default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The mode that applies to a monster: its own rule's, else the DEFAULT line's.
|
||||
/// On the DEFAULT line, Default resolves to Off (safe: no pull until the player opts in).
|
||||
/// </summary>
|
||||
public static string Effective(MonsterRule? rule, MonsterRule? defaultRule)
|
||||
{
|
||||
string own = Normalize(rule?.Kite);
|
||||
if (own != Default) return own;
|
||||
// The DEFAULT row itself: Default means Off.
|
||||
if (rule != null && defaultRule != null
|
||||
&& ReferenceEquals(rule, defaultRule))
|
||||
return Off;
|
||||
if (rule != null && string.Equals(rule.Name, "Default", StringComparison.OrdinalIgnoreCase))
|
||||
return Off;
|
||||
string fromDefault = Normalize(defaultRule?.Kite);
|
||||
return fromDefault == Default ? Off : fromDefault;
|
||||
}
|
||||
|
||||
/// <summary>True when combat should pull this monster before finishing it.</summary>
|
||||
public static bool WantsPullAway(MonsterRule? rule, MonsterRule? defaultRule)
|
||||
=> Effective(rule, defaultRule) == PullAway;
|
||||
|
||||
/// <summary>Label for logs and tooltips.</summary>
|
||||
public static string Name(string? value) => Normalize(value) switch
|
||||
{
|
||||
PullAway => "Pull away",
|
||||
Off => "Off",
|
||||
_ => "Default",
|
||||
};
|
||||
}
|
||||
|
|
@ -54,6 +54,17 @@ public class MissileCraftingManager
|
|||
private const int EQUIP_DELAY_MS = 500;
|
||||
private const int ERROR_BACKOFF_MS = 60000;
|
||||
|
||||
// An ammo wield the server ignores (ammo that doesn't fit the launcher really in hand) came
|
||||
// round again every AMMO_CHECK_INTERVAL_MS, and each try stopped nav while it waited for the
|
||||
// answer: Silentkelpie stood still ~3.5 s of every 5 on 2026-10-15. The same item sent more
|
||||
// than MAX_EQUIP_REPEATS times inside EQUIP_REPEAT_WINDOW_MS backs off instead.
|
||||
private const int EQUIP_REPEAT_WINDOW_MS = 30000;
|
||||
private const int MAX_EQUIP_REPEATS = 2;
|
||||
private const int EQUIP_IGNORED_BACKOFF_MS = 120000;
|
||||
private int _lastEquipSentId;
|
||||
private DateTime _lastEquipSentAt = DateTime.MinValue;
|
||||
private int _equipRepeats;
|
||||
|
||||
private int _headBundleId = 0;
|
||||
private int _shaftBundleId = 0;
|
||||
private AmmoRecipe? _currentRecipe = null;
|
||||
|
|
@ -145,13 +156,15 @@ public class MissileCraftingManager
|
|||
_lastAmmoCheck = DateTime.Now;
|
||||
|
||||
var inv = GetInventory(forceRefresh: true);
|
||||
if (!TryGetWieldedMissileCategory(inv, out WeaponCategory category))
|
||||
if (!TryGetWieldedMissileCategory(inv, out WeaponCategory category, out WorldObject? launcher))
|
||||
return;
|
||||
|
||||
_lastWeaponCategory = category;
|
||||
if (HasWieldedAmmo(inv, category))
|
||||
return;
|
||||
|
||||
_host.Log($"[RynthAi] MissileCraft: no {GetCategoryLabel(category)} wielded with launcher " +
|
||||
$"0x{launcher!.Id:X8} '{launcher.Name}' (slot {launcher.WieldedLocation}); evaluating");
|
||||
ChatLog($"No wielded {GetCategoryLabel(category)}s. Evaluating...");
|
||||
SetState(CraftState.Evaluating);
|
||||
}
|
||||
|
|
@ -350,6 +363,18 @@ public class MissileCraftingManager
|
|||
|
||||
if (targetId != 0)
|
||||
{
|
||||
if (!NoteEquipSent(targetId))
|
||||
{
|
||||
string name = inv.FirstOrDefault(i => i.Id == targetId)?.Name ?? $"0x{targetId:X8}";
|
||||
string why = $"The server didn't wield {name} after {MAX_EQUIP_REPEATS} tries; " +
|
||||
$"leaving the ammo alone for {EQUIP_IGNORED_BACKOFF_MS / 60000} minutes";
|
||||
_host.Log($"[RynthAi] MissileCraft: {why} (0x{targetId:X8})");
|
||||
Reset(why);
|
||||
_equipRepeats = 0;
|
||||
_lastAmmoCheck = DateTime.Now.AddMilliseconds(EQUIP_IGNORED_BACKOFF_MS - AMMO_CHECK_INTERVAL_MS);
|
||||
return;
|
||||
}
|
||||
|
||||
_host.UseFor((uint)targetId, "Crafting", "missile crafting: wield the new ammo");
|
||||
ChatLog($"Equipped ammo (id=0x{targetId:X8})");
|
||||
Reset($"Done: {_currentRecipe?.OutputName ?? "ammo"}");
|
||||
|
|
@ -382,9 +407,9 @@ public class MissileCraftingManager
|
|||
private List<WorldObject> GetInventory(bool forceRefresh = false)
|
||||
=> _objectCache?.GetDirectInventory(forceRefresh).ToList() ?? new();
|
||||
|
||||
private WeaponCategory ResolveWeaponCategory(IEnumerable<WorldObject> inventory)
|
||||
private WeaponCategory ResolveWeaponCategory(List<WorldObject> inventory)
|
||||
{
|
||||
if (TryGetWieldedMissileCategory(inventory, out WeaponCategory category))
|
||||
if (TryGetWieldedMissileCategory(inventory, out WeaponCategory category, out _))
|
||||
{
|
||||
_lastWeaponCategory = category;
|
||||
return category;
|
||||
|
|
@ -393,24 +418,29 @@ public class MissileCraftingManager
|
|||
return _lastWeaponCategory;
|
||||
}
|
||||
|
||||
private bool TryGetWieldedMissileCategory(IEnumerable<WorldObject> inventory, out WeaponCategory category)
|
||||
private bool TryGetWieldedMissileCategory(List<WorldObject> inventory, out WeaponCategory category,
|
||||
out WorldObject? launcher)
|
||||
{
|
||||
foreach (var item in inventory)
|
||||
foreach (var item in WornCandidates(inventory))
|
||||
{
|
||||
if (!IsPlayerWielded(item) || !LooksLikeMissileWeapon(item))
|
||||
// AC files ammo as a missile weapon: wielded quarrels must not pass for the launcher
|
||||
// (no "crossbow" in the name reads as a bow, and arrows went on at the crossbow).
|
||||
if (WorldObjectCache.IsAmmo(item) || !IsPlayerWielded(item) || !LooksLikeMissileWeapon(item))
|
||||
continue;
|
||||
|
||||
category = GetWeaponCategory(item.Name);
|
||||
launcher = item;
|
||||
return true;
|
||||
}
|
||||
|
||||
category = WeaponCategory.Bow;
|
||||
launcher = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool HasWieldedAmmo(IEnumerable<WorldObject> inventory, WeaponCategory category)
|
||||
private bool HasWieldedAmmo(List<WorldObject> inventory, WeaponCategory category)
|
||||
{
|
||||
foreach (var item in inventory)
|
||||
foreach (var item in WornCandidates(inventory))
|
||||
{
|
||||
if (!IsPlayerWielded(item))
|
||||
continue;
|
||||
|
|
@ -422,16 +452,62 @@ public class MissileCraftingManager
|
|||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The direct scan plus the cache-known items it left out. The scan merges worn gear only when
|
||||
/// its slot reads above 0, and the slot reads 0 for gear wielded after login (a launcher combat
|
||||
/// swapped in, and its ammo), so the launcher really in hand was missing from the scan alone.
|
||||
/// </summary>
|
||||
private IEnumerable<WorldObject> WornCandidates(List<WorldObject> inventory)
|
||||
{
|
||||
foreach (var item in inventory)
|
||||
yield return item;
|
||||
|
||||
if (_objectCache == null)
|
||||
yield break;
|
||||
|
||||
var listed = new HashSet<int>(inventory.Select(i => i.Id));
|
||||
foreach (var item in _objectCache.GetInventory())
|
||||
if (listed.Add(item.Id))
|
||||
yield return item;
|
||||
}
|
||||
|
||||
private bool IsPlayerWielded(WorldObject item)
|
||||
{
|
||||
if (item.WieldedLocation <= 0)
|
||||
// Found inside a pack by the direct scan: AC's container lists never hold worn gear. A
|
||||
// launcher put away after a swap keeps its old wielder and slot in the client's object
|
||||
// description, so the slot alone said a stowed bow was in hand while a crossbow was, and
|
||||
// arrows were wielded at it every 5 s (Silentkelpie, 2026-10-15).
|
||||
if (item.DirectContainerId != 0)
|
||||
return false;
|
||||
|
||||
uint playerId = _host.GetPlayerId();
|
||||
if (playerId == 0)
|
||||
return false;
|
||||
|
||||
return item.Wielder == 0 || item.Wielder == unchecked((int)playerId);
|
||||
if (item.WieldedLocation > 0)
|
||||
return item.Wielder == 0 || item.Wielder == unchecked((int)playerId);
|
||||
|
||||
// The slot reads 0 for gear wielded after login; the wielder still names the player.
|
||||
return _host.HasGetObjectWielderInfo
|
||||
&& _host.TryGetObjectWielderInfo(unchecked((uint)item.Id), out uint wielder, out _)
|
||||
&& wielder == playerId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Counts an ammo wield about to go out; false once the same item was already sent
|
||||
/// <see cref="MAX_EQUIP_REPEATS"/> times inside <see cref="EQUIP_REPEAT_WINDOW_MS"/>.
|
||||
/// </summary>
|
||||
private bool NoteEquipSent(int targetId)
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
if (targetId == _lastEquipSentId && (now - _lastEquipSentAt).TotalMilliseconds < EQUIP_REPEAT_WINDOW_MS)
|
||||
_equipRepeats++;
|
||||
else
|
||||
_equipRepeats = 1;
|
||||
|
||||
_lastEquipSentId = targetId;
|
||||
_lastEquipSentAt = now;
|
||||
return _equipRepeats <= MAX_EQUIP_REPEATS;
|
||||
}
|
||||
|
||||
private static bool LooksLikeMissileWeapon(WorldObject item)
|
||||
|
|
|
|||
|
|
@ -574,6 +574,8 @@ public sealed partial class RynthAiPlugin
|
|||
public override void OnVendorClose(uint vendorId)
|
||||
{
|
||||
_metaManager?.OnVendorClose(vendorId);
|
||||
// /mt vendor addbuy / addsell lists belong to the vendor that was open.
|
||||
ClearMtVendorLists();
|
||||
|
||||
var autoVendor = _autoVendor;
|
||||
if (autoVendor != null)
|
||||
|
|
|
|||
209
Plugins/RynthCore.Plugin.RynthAi/GameInput.cs
Normal file
209
Plugins/RynthCore.Plugin.RynthAi/GameInput.cs
Normal file
|
|
@ -0,0 +1,209 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi;
|
||||
|
||||
/// <summary>
|
||||
/// Key and mouse input posted to AC's own window, for the Mag-Tools <c>/mt</c> verbs that drive the
|
||||
/// client directly: <c>send</c>, <c>click</c>, <c>movement</c>, <c>strafe</c>, <c>get xy</c>,
|
||||
/// <c>client</c>. A port of Mag-Tools' PostMessageTools (Mag-Plugins\Shared\PostMessageTools.cs):
|
||||
/// the same virtual keys, scan codes (lParam) and click spots, so metas written for Mag-Tools
|
||||
/// behave the same.
|
||||
///
|
||||
/// The window is the one in this process with AC's class ("Turbine Device Class"), found once.
|
||||
/// PostMessage is safe from any thread; a key held for a time is released by a one-shot timer.
|
||||
/// </summary>
|
||||
internal static class GameInput
|
||||
{
|
||||
private const uint WM_KEYDOWN = 0x0100, WM_KEYUP = 0x0101, WM_MOUSEMOVE = 0x0200,
|
||||
WM_LBUTTONDOWN = 0x0201, WM_LBUTTONUP = 0x0202;
|
||||
private const byte VK_RETURN = 0x0D, VK_SHIFT = 0x10, VK_CONTROL = 0x11, VK_PAUSE = 0x13,
|
||||
VK_SPACE = 0x20, VK_DELETE = 0x2E, VK_F4 = 0x73, VK_F12 = 0x7B;
|
||||
private const int SW_MINIMIZE = 6, SW_RESTORE = 9;
|
||||
|
||||
private static IntPtr _hwnd;
|
||||
// Pending key releases: kept alive until they fire.
|
||||
private static readonly System.Collections.Generic.List<Timer> Pending = new();
|
||||
|
||||
/// <summary>AC's game window in this process, or IntPtr.Zero.</summary>
|
||||
public static IntPtr GameWindow
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_hwnd != IntPtr.Zero && IsWindow(_hwnd)) return _hwnd;
|
||||
// Every top-level AC window on the desktop, keeping this process's (several clients run).
|
||||
// FindWindowEx rather than EnumWindows: no callback delegate to marshal under NativeAOT.
|
||||
uint pid = (uint)Environment.ProcessId;
|
||||
IntPtr found = IntPtr.Zero, h = IntPtr.Zero;
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
h = FindWindowEx(IntPtr.Zero, h, "Turbine Device Class", null);
|
||||
if (h == IntPtr.Zero) break;
|
||||
GetWindowThreadProcessId(h, out uint p);
|
||||
if (p == pid) { found = h; break; }
|
||||
}
|
||||
_hwnd = found;
|
||||
return found;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Available => GameWindow != IntPtr.Zero;
|
||||
|
||||
// ── Keys (Mag-Tools PostMessageTools) ──────────────────────────────────────
|
||||
|
||||
public static void SendEnter() => Key(VK_RETURN, 0x001C0001, 0xC01C0001);
|
||||
public static void SendPause() => Key(VK_PAUSE, 0x00450001, 0xC0450001);
|
||||
public static void SendDel() => Key(VK_DELETE, 0x01530001, 0x01530001);
|
||||
/// <summary>F4: opens / closes the fellowship panel.</summary>
|
||||
public static void SendF4() => Key(VK_F4, 0x003E0001, 0xC03E0001);
|
||||
/// <summary>F12: opens / closes the main pack.</summary>
|
||||
public static void SendF12() => Key(VK_F12, 0x00580001, 0xC0580001);
|
||||
|
||||
/// <summary>Ctrl + a letter.</summary>
|
||||
public static void SendCntrl(char ch)
|
||||
{
|
||||
Post(WM_KEYDOWN, VK_CONTROL, 0x001D0001);
|
||||
Post(WM_KEYDOWN, CharCode(ch), 0x00100001);
|
||||
Post(WM_KEYUP, CharCode(ch), 0xC0100001);
|
||||
Post(WM_KEYUP, VK_CONTROL, 0xC01D0001);
|
||||
}
|
||||
|
||||
/// <summary>Types <paramref name="msg"/> key by key (letters, space and "/"; as Mag-Tools).</summary>
|
||||
public static void SendMsg(string msg)
|
||||
{
|
||||
foreach (char ch in msg)
|
||||
{
|
||||
uint lparam = (uint)((ScanCode(ch) << 16) | 1);
|
||||
Post(WM_KEYDOWN, CharCode(ch), lparam);
|
||||
Post(WM_KEYUP, CharCode(ch), 0xC0000000 | lparam);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Space (a jump), held <paramref name="msToHoldDown"/> ms, with the shift / w z x c keys
|
||||
/// pressed as it is released (Mag-Tools /mt jump).</summary>
|
||||
public static void SendSpace(int msToHoldDown = 0, bool shift = false, bool w = false, bool z = false, bool x = false, bool c = false)
|
||||
{
|
||||
Post(WM_KEYDOWN, VK_SPACE, 0x00390001);
|
||||
void Release()
|
||||
{
|
||||
if (shift) Post(WM_KEYDOWN, VK_SHIFT, 0x002A0001);
|
||||
if (w) Post(WM_KEYDOWN, CharCode('w'), 0x00110001);
|
||||
if (z) Post(WM_KEYDOWN, CharCode('z'), 0x002C0001);
|
||||
if (x) Post(WM_KEYDOWN, CharCode('x'), 0x002D0001);
|
||||
if (c) Post(WM_KEYDOWN, CharCode('c'), 0x002E0001);
|
||||
Post(WM_KEYUP, VK_SPACE, 0xC0390001);
|
||||
if (w) Post(WM_KEYUP, CharCode('w'), 0xC0110001);
|
||||
if (z) Post(WM_KEYUP, CharCode('z'), 0xC02C0001);
|
||||
if (x) Post(WM_KEYUP, CharCode('x'), 0xC02D0001);
|
||||
if (c) Post(WM_KEYUP, CharCode('c'), 0xC02E0001);
|
||||
if (shift) Post(WM_KEYUP, VK_SHIFT, 0xC02A0001);
|
||||
}
|
||||
After(msToHoldDown, Release);
|
||||
}
|
||||
|
||||
/// <summary>A movement key (a letter of AC's keymap) held <paramref name="msToHoldDown"/> ms.</summary>
|
||||
public static void SendMovement(char ch, int msToHoldDown = 0)
|
||||
{
|
||||
uint scan = (uint)ScanCode(ch) * 0x10000;
|
||||
Post(WM_KEYDOWN, CharCode(ch), 0x00000001 + scan);
|
||||
After(msToHoldDown, () => Post(WM_KEYUP, CharCode(ch), 0xC0000001 + scan));
|
||||
}
|
||||
|
||||
// ── Mouse ─────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>A left click at window coordinates (<paramref name="x"/>, <paramref name="y"/>).</summary>
|
||||
public static void SendMouseClick(int x, int y)
|
||||
{
|
||||
uint loc = (uint)((y << 16) | (x & 0xFFFF));
|
||||
Post(WM_MOUSEMOVE, 0, loc);
|
||||
Post(WM_LBUTTONDOWN, 1, loc);
|
||||
Post(WM_LBUTTONUP, 0, loc);
|
||||
}
|
||||
|
||||
// AC's confirmation box buttons, relative to the window's centre. Three heights each, as Mag-Tools:
|
||||
// windowed and windowless clients put the box a few pixels apart.
|
||||
public static void ClickOK() => ClickCentre(0);
|
||||
public static void ClickYes() => ClickCentre(-80);
|
||||
public static void ClickNo() => ClickCentre(80);
|
||||
|
||||
private static void ClickCentre(int dx)
|
||||
{
|
||||
if (!GetWindowRect(GameWindow, out RECT r)) return;
|
||||
int w = r.Right - r.Left, h = r.Bottom - r.Top;
|
||||
foreach (int dy in new[] { 18, 25, 31 })
|
||||
SendMouseClick(w / 2 + dx, h / 2 + dy);
|
||||
}
|
||||
|
||||
/// <summary>The cursor relative to the game window's top-left (Mag-Tools /mt get xy), or false.</summary>
|
||||
public static bool TryCursorInWindow(out int x, out int y)
|
||||
{
|
||||
x = y = 0;
|
||||
if (!GetCursorPos(out POINT p) || !GetWindowRect(GameWindow, out RECT r)) return false;
|
||||
x = p.X - r.Left;
|
||||
y = p.Y - r.Top;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ── Window ───────────────────────────────────────────────────────────────
|
||||
|
||||
public static bool Minimize() => ShowWindow(GameWindow, SW_MINIMIZE);
|
||||
public static bool Restore() => ShowWindow(GameWindow, SW_RESTORE);
|
||||
|
||||
// ── Internals ────────────────────────────────────────────────────────────
|
||||
|
||||
private static void Key(byte vk, uint down, uint up)
|
||||
{
|
||||
Post(WM_KEYDOWN, vk, down);
|
||||
Post(WM_KEYUP, vk, up);
|
||||
}
|
||||
|
||||
private static void Post(uint msg, uint wParam, uint lParam)
|
||||
{
|
||||
IntPtr h = GameWindow;
|
||||
if (h != IntPtr.Zero) PostMessage(h, msg, (IntPtr)wParam, (IntPtr)unchecked((int)lParam));
|
||||
}
|
||||
|
||||
/// <summary>Runs <paramref name="action"/> now, or after <paramref name="ms"/> on a one-shot timer.</summary>
|
||||
private static void After(int ms, Action action)
|
||||
{
|
||||
if (ms <= 0) { action(); return; }
|
||||
Timer? t = null;
|
||||
t = new Timer(_ =>
|
||||
{
|
||||
try { action(); }
|
||||
catch (Exception ex) { Debug.WriteLine("GameInput release failed: " + ex.Message); }
|
||||
finally { lock (Pending) { if (t != null) Pending.Remove(t); } t?.Dispose(); }
|
||||
}, null, Timeout.Infinite, Timeout.Infinite);
|
||||
lock (Pending) Pending.Add(t);
|
||||
t.Change(ms, Timeout.Infinite);
|
||||
}
|
||||
|
||||
private static byte ScanCode(char ch) => char.ToLowerInvariant(ch) switch
|
||||
{
|
||||
'a' => 0x1E, 'b' => 0x30, 'c' => 0x2E, 'd' => 0x20, 'e' => 0x12, 'f' => 0x21, 'g' => 0x22, 'h' => 0x23,
|
||||
'i' => 0x17, 'j' => 0x24, 'k' => 0x25, 'l' => 0x26, 'm' => 0x32, 'n' => 0x31, 'o' => 0x18, 'p' => 0x19,
|
||||
'q' => 0x10, 'r' => 0x13, 's' => 0x1F, 't' => 0x14, 'u' => 0x16, 'v' => 0x2F, 'w' => 0x11, 'x' => 0x2D,
|
||||
'y' => 0x15, 'z' => 0x2C, '/' => 0x35, ' ' => 0x39,
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
private static byte CharCode(char ch)
|
||||
{
|
||||
char c = char.ToLowerInvariant(ch);
|
||||
if (c >= 'a' && c <= 'z') return (byte)(0x41 + (c - 'a'));
|
||||
return c == '/' ? (byte)0xBF : (byte)0x20;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)] private struct RECT { public int Left, Top, Right, Bottom; }
|
||||
[StructLayout(LayoutKind.Sequential)] private struct POINT { public int X, Y; }
|
||||
[DllImport("user32.dll")] private static extern bool PostMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
private static extern IntPtr FindWindowEx(IntPtr parent, IntPtr after, string className, string? title);
|
||||
[DllImport("user32.dll")] private static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint pid);
|
||||
[DllImport("user32.dll")] private static extern bool IsWindow(IntPtr hWnd);
|
||||
[DllImport("user32.dll")] private static extern bool GetWindowRect(IntPtr hWnd, out RECT rect);
|
||||
[DllImport("user32.dll")] private static extern bool GetCursorPos(out POINT p);
|
||||
[DllImport("user32.dll")] private static extern bool ShowWindow(IntPtr hWnd, int cmd);
|
||||
}
|
||||
|
|
@ -579,7 +579,7 @@ internal sealed class HudController
|
|||
/// Mini Remote drawer, or with <paramref name="window"/> the engine's Mini Remote window)
|
||||
/// and returns the content size it wants. Render thread.
|
||||
/// </summary>
|
||||
public System.Numerics.Vector2 RenderEmbedded(bool window = false, bool tabs = true)
|
||||
public System.Numerics.Vector2 RenderEmbedded(bool window = false, bool tabs = true, bool popped = false)
|
||||
{
|
||||
long now = NowMs;
|
||||
System.Threading.Interlocked.Exchange(ref _embeddedDrawnAt, now);
|
||||
|
|
@ -587,7 +587,7 @@ internal sealed class HudController
|
|||
int pushed = LegacyDashboardRenderer.PushDashboardStyle();
|
||||
try
|
||||
{
|
||||
return _miniRemote.RenderEmbedded(window, tabs);
|
||||
return _miniRemote.RenderEmbedded(window, tabs, popped);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ internal sealed class HudSetupUi
|
|||
|
||||
private void RenderItemLists(HudState s)
|
||||
{
|
||||
ImGui.TextWrapped("Left = shown on the HUD. Right = in your pack but not on the HUD. "
|
||||
SafeImGui.TextWrapped("Left = shown on the HUD. Right = in your pack but not on the HUD. "
|
||||
+ "< pins the highlighted right row; > removes the highlighted left row. "
|
||||
+ "Add from inventory uses the item selected in the game.");
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,11 @@ public sealed class HudState
|
|||
public bool MiniShowTarget = true;
|
||||
/// <summary>Pet row: the summon that is out (health, time left), else the next combat essence.</summary>
|
||||
public bool MiniShowPet = true;
|
||||
/// <summary>
|
||||
/// Pet capture row (ILT / ACECustom): auto-capture enable, lens pick, and status.
|
||||
/// The same AutoCaptureEnabled setting as Mini Remote > Pets > Monster capture.
|
||||
/// </summary>
|
||||
public bool MiniShowCapture = true;
|
||||
public bool MiniShowGems = true;
|
||||
public bool MiniShowToggles = true;
|
||||
public bool MiniShowBank = true;
|
||||
|
|
|
|||
|
|
@ -11,8 +11,9 @@
|
|||
// Quest Timers and Fellowship, Skills, Inventory, Item Count, Inventory HUDs: windows every server
|
||||
// has), then "Server: <name>", i.e. the installed server plugins' windows for the world you're on,
|
||||
// which RynthCore sends (ServerMenuModel), or a link to RynthCore's Options > Diagnostics (where a
|
||||
// server is forced) when none matches. The Options button opens RynthAi Settings; right-click it for
|
||||
// the Mini Remote's own section/layout settings.
|
||||
// server is forced) when none matches. Options: docked left-click opens RynthAi Settings
|
||||
// (right-click = Mini Remote section/layout popup); undocked left-click opens that expanded
|
||||
// Options popup. Float / Dock next to Options (and in the popup) call /rc miniremote undock|dock.
|
||||
// The V/H button stacks the sections (vertical) or lays them out in three columns (horizontal).
|
||||
//
|
||||
// Remote sections (each can be hidden from the Options menu):
|
||||
|
|
@ -74,6 +75,7 @@ internal sealed class MiniRemoteHud
|
|||
private bool _columnOpen; // horizontal layout: a column was already started this frame (next one goes SameLine)
|
||||
private bool _embedded; // true only inside RenderEmbedded (an engine surface)
|
||||
private bool _inWindow; // with _embedded: the engine's Mini Remote window, not the dashboard drawer
|
||||
private bool _popped; // engine Mini Remote is in its own floating window (:popout)
|
||||
// A tab switch asked for by a command or the engine (any thread), applied by the next tab bar;
|
||||
// null = none. Starts as the saved tab so the first tab bar restores it.
|
||||
private string? _pendingTab;
|
||||
|
|
@ -139,12 +141,13 @@ internal sealed class MiniRemoteHud
|
|||
/// themselves from the result) instead of a window of their own. Returns the content size it
|
||||
/// wants: the selected tab's width, and the height drawn.
|
||||
/// </summary>
|
||||
public Vector2 RenderEmbedded(bool window = false, bool tabs = true)
|
||||
public Vector2 RenderEmbedded(bool window = false, bool tabs = true, bool popped = false)
|
||||
{
|
||||
var s = _hud.State;
|
||||
_slotMenuIndex = -1;
|
||||
_embedded = true;
|
||||
_inWindow = window;
|
||||
_popped = popped;
|
||||
float startY = ImGui.GetCursorPosY();
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(4, 3));
|
||||
try
|
||||
|
|
@ -166,6 +169,7 @@ internal sealed class MiniRemoteHud
|
|||
_slotMenuIndex = -1;
|
||||
_embedded = false;
|
||||
_inWindow = false;
|
||||
_popped = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -308,7 +312,7 @@ internal sealed class MiniRemoteHud
|
|||
float colW = ColumnWidth(s);
|
||||
if (!s.MiniRemoteHorizontal) return colW;
|
||||
int cols = 0;
|
||||
if (s.MiniShowStats || s.MiniShowTarget || s.MiniShowPet) cols++;
|
||||
if (s.MiniShowStats || s.MiniShowTarget || s.MiniShowPet || s.MiniShowCapture) cols++;
|
||||
if (s.MiniShowGems || ShowToggles(s)) cols++;
|
||||
if (s.MiniShowBank || s.MiniShowRebuff || s.MiniShowTranslate || s.MiniShowGuardian) cols++;
|
||||
cols = Math.Max(1, cols);
|
||||
|
|
@ -317,7 +321,7 @@ internal sealed class MiniRemoteHud
|
|||
|
||||
// ── Layout ──────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>[V/H] and [Options] buttons. Fixed widths so the auto-resizing window can't grow from them.</summary>
|
||||
/// <summary>[V/H], [Options], and (engine window) Dock/Float buttons. Fixed widths so auto-resize can't grow from them.</summary>
|
||||
private void RenderHeaderRow(HudState s)
|
||||
{
|
||||
if (ImGui.Button((s.MiniRemoteHorizontal ? "H" : "V") + "##mrlayout", new Vector2(HeaderButtonWidth, 0)))
|
||||
|
|
@ -325,15 +329,34 @@ internal sealed class MiniRemoteHud
|
|||
if (ImGui.IsItemHovered())
|
||||
SafeImGui.SetTooltip(s.MiniRemoteHorizontal ? "Horizontal: sections in columns. Click to stack them." : "Vertical: sections stacked. Click to lay them out in columns.");
|
||||
ImGui.SameLine();
|
||||
// Left-click: RynthAi Settings. Right-click: Mini Remote section/layout popup (RenderOptions).
|
||||
// Undocked: left-click opens the expanded Mini Remote Options popup (sections / layout).
|
||||
// Docked: left-click opens RynthAi Settings; right-click always opens the Options popup.
|
||||
if (ImGui.Button("Options##mropts", new Vector2(HeaderButtonWidth, 0)))
|
||||
{
|
||||
if (_hud.Host.HasInvokeChatParser) _hud.RunEngineCommand(MovedTabs.Settings);
|
||||
else _openOptions = true; // no chat parser: fall back to the Mini Remote popup
|
||||
if (_popped || !_hud.Host.HasInvokeChatParser)
|
||||
_openOptions = true;
|
||||
else
|
||||
_hud.RunEngineCommand(MovedTabs.Settings);
|
||||
}
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Right)) _openOptions = true;
|
||||
if (ImGui.IsItemHovered())
|
||||
SafeImGui.SetTooltip("Open RynthAi Settings (Advanced Settings).\nRight-click: Mini Remote sections, layout, slot size.");
|
||||
{
|
||||
SafeImGui.SetTooltip(_popped
|
||||
? "Mini Remote sections, layout, slot size (undocked).\nSettings is in this Options menu."
|
||||
: "Open RynthAi Settings (Advanced Settings).\nRight-click: Mini Remote sections, layout, slot size.\nUse Float to undock for a larger Options window.");
|
||||
}
|
||||
// Engine Mini Remote window only: dock / undock without hunting the title ↗.
|
||||
if (_inWindow && _hud.Host.HasInvokeChatParser)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
string dockLabel = _popped ? "Dock" : "Float";
|
||||
if (ImGui.Button(dockLabel + "##mrdock", new Vector2(HeaderButtonWidth, 0)))
|
||||
_hud.RunEngineCommand(_popped ? "/rc miniremote dock" : "/rc miniremote undock");
|
||||
if (ImGui.IsItemHovered())
|
||||
SafeImGui.SetTooltip(_popped
|
||||
? "Dock Mini Remote back into the game window (/rc miniremote dock)."
|
||||
: "Undock Mini Remote into a floating window for expanded Options (/rc miniremote undock).");
|
||||
}
|
||||
}
|
||||
|
||||
private void RenderVertical(HudState s, MiniRemoteController? remote)
|
||||
|
|
@ -353,7 +376,7 @@ internal sealed class MiniRemoteHud
|
|||
{
|
||||
float colW = ColumnWidth(s);
|
||||
_columnOpen = false;
|
||||
if (s.MiniShowStats || s.MiniShowTarget || s.MiniShowPet)
|
||||
if (s.MiniShowStats || s.MiniShowTarget || s.MiniShowPet || s.MiniShowCapture)
|
||||
{
|
||||
BeginColumn("##mrcolstatus", colW);
|
||||
RenderStatusSections(s, remote);
|
||||
|
|
@ -409,6 +432,7 @@ internal sealed class MiniRemoteHud
|
|||
if (s.MiniShowStats) RenderStats(remote);
|
||||
if (s.MiniShowTarget) RenderTarget(combat);
|
||||
if (s.MiniShowPet) RenderPet(remote, combat);
|
||||
if (s.MiniShowCapture) RenderCapture(remote);
|
||||
if (s.MiniShowStats) RenderStatButtons(remote);
|
||||
}
|
||||
|
||||
|
|
@ -549,6 +573,42 @@ internal sealed class MiniRemoteHud
|
|||
SafeImGui.TextColored(col, status);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ILT siphon-lens auto-capture: same enable / lens as Pets > Monster capture, on the Remote
|
||||
/// so Options > Pet capture can show it without opening the Pets tab.
|
||||
/// </summary>
|
||||
private static void RenderCapture(MiniRemoteController? remote)
|
||||
{
|
||||
if (!IltActive(remote))
|
||||
{
|
||||
ImGui.TextDisabled("Capture: ILT only");
|
||||
return;
|
||||
}
|
||||
var pets = remote!.Pets;
|
||||
bool captureOff = remote.Ilt.IsOff(RynthIltHub.FeatureMonsterCapture);
|
||||
ImGui.BeginDisabled(captureOff);
|
||||
bool en = pets.AutoCaptureEnabled;
|
||||
if (ImGui.Checkbox("Auto-capture##mrcapture", ref en))
|
||||
pets.AutoCaptureEnabled = en;
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
SafeImGui.SetTooltip(
|
||||
"Uses the selected siphon lens on the nearest attackable creature within 5 m once it is\n" +
|
||||
"at or below 20% health or under 20 HP (ACECustom MonsterCapture). Asheron's Lens skips\n" +
|
||||
"the health gate. Same setting as Mini Remote > Pets > Monster capture.");
|
||||
}
|
||||
ImGui.SameLine();
|
||||
ImGui.SetNextItemWidth(110);
|
||||
int lens = Math.Clamp(pets.CaptureLensIndex, 0, PetCaptureRules.LensNames.Length - 1);
|
||||
if (ImGui.Combo("##mrcapturelens", ref lens, PetCaptureRules.LensNames, PetCaptureRules.LensNames.Length))
|
||||
pets.CaptureLensIndex = lens;
|
||||
ImGui.EndDisabled();
|
||||
if (captureOff)
|
||||
SafeImGui.TextDisabled("Capture disabled on this server");
|
||||
else
|
||||
SafeImGui.TextDisabled(pets.CaptureStatus);
|
||||
}
|
||||
|
||||
private static void RenderSummon(MiniRemoteController? remote, CombatHudSnapshot c)
|
||||
{
|
||||
ImGui.TextColored(ColLabel, "Summon:");
|
||||
|
|
@ -800,6 +860,7 @@ internal sealed class MiniRemoteHud
|
|||
Flag("Session stats", ref s.MiniShowStats);
|
||||
Flag("Attack target", ref s.MiniShowTarget);
|
||||
Flag("Pet / summon", ref s.MiniShowPet);
|
||||
Flag("Pet capture", ref s.MiniShowCapture);
|
||||
Flag("Item slots", ref s.MiniShowGems);
|
||||
// The drawer's dashboard has these switches already; the setting is for the windows.
|
||||
if (!InDrawer) Flag("Toggles", ref s.MiniShowToggles);
|
||||
|
|
@ -812,6 +873,21 @@ internal sealed class MiniRemoteHud
|
|||
RenderSlotSizeSlider(s);
|
||||
if (embedded && _inWindow)
|
||||
{
|
||||
// Docked Options used to jump straight to Settings; undocked left-click opens this
|
||||
// popup, so keep a Settings entry here.
|
||||
if (_popped && _hud.Host.HasInvokeChatParser
|
||||
&& ImGui.MenuItem("RynthAi Settings...", MovedTabs.Settings))
|
||||
_hud.RunEngineCommand(MovedTabs.Settings);
|
||||
if (_hud.Host.HasInvokeChatParser)
|
||||
{
|
||||
if (ImGui.MenuItem(_popped ? "Dock Mini Remote" : "Undock Mini Remote",
|
||||
_popped ? "/rc miniremote dock" : "/rc miniremote undock"))
|
||||
_hud.RunEngineCommand(_popped ? "/rc miniremote dock" : "/rc miniremote undock");
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(_popped
|
||||
? "Dock back into the game window."
|
||||
: "Pop out so this Options menu has more room.");
|
||||
}
|
||||
if (ImGui.MenuItem("Inventory HUDs setup...")) s.ShowSetup = true;
|
||||
}
|
||||
else if (embedded)
|
||||
|
|
|
|||
|
|
@ -34,8 +34,59 @@ internal sealed class Jumper
|
|||
private bool _pausedNav;
|
||||
private bool _prevEnableNavigation;
|
||||
|
||||
// Face only (/mt face, /ub face; ub-IT's DoFace): navigation is held while turning, the turn
|
||||
// is sent again every 100 ms until the heading is within 1 degree, and given up after 5 s.
|
||||
private bool _faceOnly;
|
||||
private DateTime _lastFaceTurnAt;
|
||||
private const double FaceToleranceDeg = 1.0;
|
||||
private static readonly TimeSpan FaceRetry = TimeSpan.FromMilliseconds(100);
|
||||
private static readonly TimeSpan FaceTimeout = TimeSpan.FromSeconds(5);
|
||||
|
||||
public bool IsBusy => _isTurning || _needToJump || _charging || _waitingForJump;
|
||||
|
||||
/// <summary>Turns to <paramref name="heading"/> (any degrees; normalized to 0-360), holding nav meanwhile.</summary>
|
||||
public bool Face(double heading)
|
||||
{
|
||||
if (IsBusy && !_faceOnly)
|
||||
{
|
||||
_chat("[RynthAi] You are jumping. Try again later.");
|
||||
return false;
|
||||
}
|
||||
if (!_host.HasTurnToHeading)
|
||||
{
|
||||
_chat("[RynthAi] TurnToHeading not available.");
|
||||
return false;
|
||||
}
|
||||
_targetHeading = (float)(((heading % 360) + 360) % 360);
|
||||
if (!_faceOnly) PauseNav();
|
||||
_faceOnly = true;
|
||||
_isTurning = true;
|
||||
_turningStartedAt = _lastFaceTurnAt = DateTime.UtcNow;
|
||||
_host.TurnToHeadingBy("Face", _targetHeading);
|
||||
RynthLog.Write(LogCat.Jumper, $"[Jumper] Face -> {_targetHeading:F1}");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>The face turn: done within <see cref="FaceToleranceDeg"/>, else turn again; nav back when done.</summary>
|
||||
private void TickFace()
|
||||
{
|
||||
DateTime now = DateTime.UtcNow;
|
||||
if (now - _lastFaceTurnAt < FaceRetry) return;
|
||||
_lastFaceTurnAt = now;
|
||||
bool read = _host.TryGetPlayerHeading(out float current);
|
||||
double off = read ? Math.Abs(((current - _targetHeading) % 360 + 540) % 360 - 180) : 0;
|
||||
if (read && off >= FaceToleranceDeg && now - _turningStartedAt < FaceTimeout)
|
||||
{
|
||||
_host.TurnToHeadingBy("Face", _targetHeading);
|
||||
return;
|
||||
}
|
||||
_isTurning = _faceOnly = false;
|
||||
RestoreNav();
|
||||
RynthLog.Write(LogCat.Jumper, read && off >= FaceToleranceDeg
|
||||
? $"[Jumper] Face {_targetHeading:F1}: still {off:F1} deg off after {FaceTimeout.TotalSeconds:0} s, gave up"
|
||||
: $"[Jumper] Face {_targetHeading:F1} done (heading {(read ? current.ToString("F1") : "?")})");
|
||||
}
|
||||
|
||||
public Jumper(RynthCoreHost host, LegacyUiSettings settings, Action<string> chat)
|
||||
{
|
||||
_host = host;
|
||||
|
|
@ -45,6 +96,12 @@ internal sealed class Jumper
|
|||
|
||||
public bool Start(string directionLetters, float? faceHeading, int msToHoldDown)
|
||||
{
|
||||
// A face still turning (a meta's "/mt face 90" then "/ub jumpw 90") gives way to the jump.
|
||||
if (_faceOnly)
|
||||
{
|
||||
_faceOnly = _isTurning = false;
|
||||
RestoreNav();
|
||||
}
|
||||
if (IsBusy)
|
||||
{
|
||||
_chat("[RynthAi] You are already jumping. Try again later.");
|
||||
|
|
@ -101,7 +158,7 @@ internal sealed class Jumper
|
|||
public void Cancel()
|
||||
{
|
||||
RestoreNav();
|
||||
_isTurning = _needToJump = _charging = _waitingForJump = false;
|
||||
_isTurning = _needToJump = _charging = _waitingForJump = _faceOnly = false;
|
||||
_addW = _addX = _addZ = _addC = _addShift = false;
|
||||
}
|
||||
|
||||
|
|
@ -111,6 +168,11 @@ internal sealed class Jumper
|
|||
|
||||
try
|
||||
{
|
||||
if (_faceOnly)
|
||||
{
|
||||
TickFace();
|
||||
return;
|
||||
}
|
||||
// TurnToHeading is an instant quaternion snap; the heading read
|
||||
// doesn't always reflect it immediately, so just wait a short
|
||||
// settle window rather than polling for a match.
|
||||
|
|
|
|||
|
|
@ -15,6 +15,30 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
// Server Features list being edited (committed on Enter / focus loss); null = show the saved list.
|
||||
|
||||
private static readonly string[] AttackHeights = { "Low", "Medium", "High" };
|
||||
|
||||
/// <summary>
|
||||
/// The environment-impact throttle's shared numbers (one set for missiles and magic), drawn
|
||||
/// under each response combo. <paramref name="id"/> keeps the two copies' ImGui ids apart.
|
||||
/// </summary>
|
||||
private void DrawEnvironmentThrottleKnobs(string id)
|
||||
{
|
||||
ImGui.Indent();
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.SliderInt($"Hits to trip##envlimit{id}", ref _settings.EnvironmentImpactLimit, 1, 10);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("Environment hits on one target, within the window, before combat reacts.\nShared by missiles and magic.");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.SliderInt($"Window (s)##envwin{id}", ref _settings.EnvironmentImpactWindowSec, 5, 120);
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.SliderInt($"Move closer by (m)##envstep{id}", ref _settings.EnvironmentApproachMeters, 1, 30);
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.SliderInt($"Closest (m)##envmin{id}", ref _settings.EnvironmentMinDistance, 1, 30);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("Never moves nearer than this. Already this close, a new target is picked instead.");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.SliderInt($"Skip target (s)##envskip{id}", ref _settings.EnvironmentSkipSec, 5, 300);
|
||||
ImGui.Unindent();
|
||||
}
|
||||
private static readonly string[] NavLabelModeNames = { "Off", "Numbers", "Numbers and names" };
|
||||
private const string NavResumeNearestTip =
|
||||
"On: starting the macro, loading a Circular or Linear route, and carrying on after a fight, loot, buff or door\n" +
|
||||
|
|
@ -210,12 +234,12 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.InputInt(label, ref value);
|
||||
if (ImGui.IsItemHovered())
|
||||
SafeImGui.SetTooltip(tip);
|
||||
ImGui.SetTooltip(tip);
|
||||
ImGui.SameLine();
|
||||
if (value == baseline)
|
||||
ImGui.TextDisabled("baseline");
|
||||
else
|
||||
SafeImGui.TextColored(new Vector4(0.9f, 0.7f, 0.2f, 1.0f), $"baseline {baseline}");
|
||||
ImGui.TextColored(new Vector4(0.9f, 0.7f, 0.2f, 1.0f), $"baseline {baseline}");
|
||||
}
|
||||
|
||||
/// <summary>Writes the six loot timers' baseline values (LootBaseline.cs) into the settings.</summary>
|
||||
|
|
@ -521,6 +545,45 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.Combo("Missile Attack Height", ref _settings.MissileAttackHeight, AttackHeights, AttackHeights.Length);
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Text("Variable Power (monster rules)");
|
||||
if (ImGui.IsItemHovered())
|
||||
SafeImGui.SetTooltip("A monster rule's Power column picks per monster: Default (these settings),\n" +
|
||||
"High (100%), Reckless (80%, needs Recklessness trained), Variable (a new\n" +
|
||||
"random power each attack in this range), or Reckless + Variable (random,\n" +
|
||||
"kept inside the Recklessness band 20-80%).");
|
||||
ImGui.SetNextItemWidth(150);
|
||||
ImGui.SliderInt("Variable Min %", ref _settings.VariablePowerMin, 0, 100);
|
||||
ImGui.SetNextItemWidth(150);
|
||||
ImGui.SliderInt("Variable Max %", ref _settings.VariablePowerMax, 0, 100);
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Text("Missiles Hitting the Environment");
|
||||
ImGui.SetNextItemWidth(220);
|
||||
ImGui.Combo("Missile Response", ref _settings.MissileEnvironmentResponse,
|
||||
EnvironmentImpactPlanner.ResponseNames, EnvironmentImpactPlanner.ResponseNames.Length);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("When arrows or bolts keep hitting walls or objects instead of the target\n" +
|
||||
"(\"Your missile attack hit the environment.\"), stop shooting and:\n" +
|
||||
" Move closer - run toward the target for a clearer shot\n" +
|
||||
" New target - skip this one for a while and fight another\n" +
|
||||
" Move closer, then new target - one approach, then switch\n" +
|
||||
"The only monster in reach is never skipped.");
|
||||
DrawEnvironmentThrottleKnobs("missile");
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Text("Pull Away (Kite)");
|
||||
ImGui.SetNextItemWidth(150);
|
||||
ImGui.SliderInt("Pull Distance (m)", ref _settings.KitePullMeters, 3, 100);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("When a monster rule's Kite is Pull away (or Default follows the\n" +
|
||||
"DEFAULT row set to Pull away), tag the mob then run until it has\n" +
|
||||
"been dragged this many metres from where it stood, then kill it.\n" +
|
||||
"Set per mob on the Monsters / Damage panels.");
|
||||
ImGui.Checkbox("Tag Before Fleeing", ref _settings.KiteTagFirst);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("Land a hit before running so aggro sticks. Off = flee as soon as locked.");
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Text("Weapon Swaps");
|
||||
ImGui.SetNextItemWidth(150);
|
||||
|
|
@ -618,6 +681,20 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
"The character turns to face the target first. 0 = no walls.");
|
||||
ImGui.InputInt("Min Wall Targets", ref _settings.MinWallTargets);
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Text("Spells Hitting the Environment");
|
||||
ImGui.SetNextItemWidth(220);
|
||||
ImGui.Combo("Magic Response", ref _settings.MagicEnvironmentResponse,
|
||||
EnvironmentImpactPlanner.ResponseNames, EnvironmentImpactPlanner.ResponseNames.Length);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("When bolts, streaks, arcs or blasts keep stopping short of the target\n" +
|
||||
"(a wall, a pillar, the ceiling) with no hit or resist, stop casting and:\n" +
|
||||
" Move closer - run toward the target for a clearer line\n" +
|
||||
" New target - skip this one for a while and fight another\n" +
|
||||
" Move closer, then new target - one approach, then switch\n" +
|
||||
"Rings and walls aren't judged. The only monster in reach is never skipped.");
|
||||
DrawEnvironmentThrottleKnobs("magic");
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Separator();
|
||||
ImGui.Text("Spell Difficulty (Min Buffed Skill)");
|
||||
|
|
|
|||
|
|
@ -391,19 +391,32 @@ internal sealed partial class LegacyDashboardRenderer
|
|||
CopySettings(new LegacyUiSettings(), _settings);
|
||||
_lastSavedJson = string.Empty;
|
||||
}
|
||||
else if (TryReadProfile(_settingsFilePath, out LegacyUiSettings? loaded, out string loadedJson, out string readError))
|
||||
{
|
||||
CopySettings(loaded!, _settings);
|
||||
_lastSavedJson = loadedJson;
|
||||
}
|
||||
else if (TryReadProfile(_settingsFilePath + BackupSuffix, out LegacyUiSettings? fromBak, out string bakJson, out _))
|
||||
{
|
||||
// The profile didn't read (cut off by a client that died mid-save, say): the copy
|
||||
// kept by the last good save is used, and saved back as the profile on the next change.
|
||||
CopySettings(fromBak!, _settings);
|
||||
_lastSavedJson = bakJson;
|
||||
KeepUnreadableProfile(_settingsFilePath);
|
||||
_host.Log($"[RynthAi] Settings: {_settingsFilePath} didn't read ({readError}); loaded the backup instead.");
|
||||
_host.WriteToChat($"[RynthAi] Your settings file didn't read ({readError}); restored the backup copy.", 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
string json = File.ReadAllText(_settingsFilePath);
|
||||
var loaded = JsonSerializer.Deserialize(json, RynthAiJsonContext.Default.LegacyUiSettings);
|
||||
if (loaded != null)
|
||||
{
|
||||
CopySettings(loaded, _settings);
|
||||
_lastSavedJson = json;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
// Neither reads. Before, the defaults kept here were autosaved over the profile at once,
|
||||
// so one bad read reset the character for good. Now the file is set aside and nothing is
|
||||
// written until a setting is actually changed.
|
||||
CopySettings(new LegacyUiSettings(), _settings);
|
||||
KeepUnreadableProfile(_settingsFilePath);
|
||||
try { _lastSavedJson = JsonSerializer.Serialize(_settings, RynthAiJsonContext.Default.LegacyUiSettings); }
|
||||
catch { _lastSavedJson = string.Empty; }
|
||||
_host.Log($"[RynthAi] Settings: {_settingsFilePath} didn't read ({readError}) and there's no good backup; using defaults without saving over it.");
|
||||
_host.WriteToChat($"[RynthAi] Your settings file didn't read ({readError}). A copy was kept next to it (.unreadable); defaults are in use until you change something.", 1);
|
||||
}
|
||||
_packSetup = freshProfile ? PackSetup.FillNew
|
||||
: _settings.ProfileItemsChecked ? PackSetup.None : PackSetup.CheckExisting;
|
||||
|
|
@ -505,9 +518,51 @@ internal sealed partial class LegacyDashboardRenderer
|
|||
DataWriteGuard.TrySave("the settings profile", path, () =>
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path)!);
|
||||
File.WriteAllText(path, json);
|
||||
// Written beside it and swapped in, the previous file kept as .bak: File.WriteAllText
|
||||
// emptied the profile first, so a client closed or killed mid-save (relaunching for a
|
||||
// DXVK change, the launcher's stuck-client kill) left a cut-off file that then loaded
|
||||
// as defaults.
|
||||
string tmp = path + "." + Environment.ProcessId + ".tmp";
|
||||
File.WriteAllText(tmp, json);
|
||||
if (File.Exists(path)) File.Replace(tmp, path, path + BackupSuffix, ignoreMetadataErrors: true);
|
||||
else File.Move(tmp, path);
|
||||
}, out reason, callerShows);
|
||||
|
||||
/// <summary>The last good profile kept by each save (profile path + this).</summary>
|
||||
private const string BackupSuffix = ".bak";
|
||||
|
||||
/// <summary>Reads and parses a settings profile; false (with the reason) when it's missing or doesn't parse.</summary>
|
||||
private static bool TryReadProfile(string path, out LegacyUiSettings? settings, out string json, out string error)
|
||||
{
|
||||
settings = null; json = string.Empty; error = "";
|
||||
try
|
||||
{
|
||||
if (!File.Exists(path)) { error = "missing"; return false; }
|
||||
json = File.ReadAllText(path);
|
||||
if (string.IsNullOrWhiteSpace(json)) { error = "the file is empty"; return false; }
|
||||
settings = JsonSerializer.Deserialize(json, RynthAiJsonContext.Default.LegacyUiSettings);
|
||||
if (settings == null) { error = "the file holds no settings"; return false; }
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
error = ex.GetType().Name + ": " + ex.Message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Copies a profile that didn't read to "<name>.unreadable-<time>" so its contents can be recovered.</summary>
|
||||
private void KeepUnreadableProfile(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!File.Exists(path)) return;
|
||||
string copy = path + ".unreadable-" + DateTime.Now.ToString("yyyyMMdd-HHmmss");
|
||||
File.Copy(path, copy, overwrite: false);
|
||||
}
|
||||
catch (Exception ex) { _host.Log($"[RynthAi] Settings: keeping a copy of {path} failed: {ex.Message}"); }
|
||||
}
|
||||
|
||||
private static bool WriteSettingsFile(string path, string json) => WriteSettingsFile(path, json, out _);
|
||||
|
||||
/// <summary>After a failed autosave, when CheckAndSave may try again (not every tick).</summary>
|
||||
|
|
@ -983,12 +1038,46 @@ internal sealed partial class LegacyDashboardRenderer
|
|||
incoming.Insert(0, existingDefault ?? new MonsterRule { Name = "Default" });
|
||||
}
|
||||
|
||||
// An engine without the Power column (before 2026-10-12) sends no AttackPower, which
|
||||
// would reset every rule to Default: keep each rule's own (same name and expression).
|
||||
if (json.IndexOf("\"AttackPower\"", StringComparison.OrdinalIgnoreCase) < 0)
|
||||
CarryAttackPower(_settings.MonsterRules, incoming);
|
||||
// Same for kite (2026-10-16): an older Monsters panel omits Kite and would wipe PullAway.
|
||||
if (json.IndexOf("\"Kite\"", StringComparison.OrdinalIgnoreCase) < 0)
|
||||
CarryKite(_settings.MonsterRules, incoming);
|
||||
|
||||
_settings.MonsterRules = incoming;
|
||||
SaveMonstersFile();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
/// <summary>Copies AttackPower from <paramref name="current"/> onto the matching rules of
|
||||
/// <paramref name="incoming"/> (same Name and MatchExpression, case-insensitive).</summary>
|
||||
internal static void CarryAttackPower(List<MonsterRule> current, List<MonsterRule> incoming)
|
||||
{
|
||||
foreach (var r in incoming)
|
||||
{
|
||||
var old = current.FirstOrDefault(o =>
|
||||
string.Equals(o.Name, r.Name, StringComparison.OrdinalIgnoreCase)
|
||||
&& string.Equals(o.MatchExpression ?? "", r.MatchExpression ?? "", StringComparison.OrdinalIgnoreCase));
|
||||
if (old != null) r.AttackPower = old.AttackPower;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Copies Kite from <paramref name="current"/> onto the matching rules of
|
||||
/// <paramref name="incoming"/> (same Name and MatchExpression, case-insensitive).</summary>
|
||||
internal static void CarryKite(List<MonsterRule> current, List<MonsterRule> incoming)
|
||||
{
|
||||
foreach (var r in incoming)
|
||||
{
|
||||
var old = current.FirstOrDefault(o =>
|
||||
string.Equals(o.Name, r.Name, StringComparison.OrdinalIgnoreCase)
|
||||
&& string.Equals(o.MatchExpression ?? "", r.MatchExpression ?? "", StringComparison.OrdinalIgnoreCase));
|
||||
if (old != null) r.Kite = old.Kite;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Settings bridge (engine-side Avalonia SettingsPanel) ─────────────────
|
||||
|
||||
public string BuildSettingsJson()
|
||||
|
|
@ -1069,10 +1158,21 @@ internal sealed partial class LegacyDashboardRenderer
|
|||
UseNativeAttack = s.UseNativeAttack,
|
||||
SummonPets = s.SummonPets,
|
||||
PetMinMonsters = s.PetMinMonsters,
|
||||
// Spell Combat
|
||||
VariablePowerMin = s.VariablePowerMin,
|
||||
VariablePowerMax = s.VariablePowerMax,
|
||||
MissileEnvironmentResponse = s.MissileEnvironmentResponse,
|
||||
MagicEnvironmentResponse = s.MagicEnvironmentResponse,
|
||||
EnvironmentImpactLimit = s.EnvironmentImpactLimit,
|
||||
EnvironmentImpactWindowSec = s.EnvironmentImpactWindowSec,
|
||||
EnvironmentApproachMeters = s.EnvironmentApproachMeters,
|
||||
EnvironmentMinDistance = s.EnvironmentMinDistance,
|
||||
EnvironmentSkipSec = s.EnvironmentSkipSec,
|
||||
KitePullMeters = s.KitePullMeters,
|
||||
KiteTagFirst = s.KiteTagFirst,
|
||||
WeaponSwapSettleMs = s.WeaponSwapSettleMs,
|
||||
WeaponSwapMinHealthPct = s.WeaponSwapMinHealthPct,
|
||||
WeaponSwapMinGainPct = s.WeaponSwapMinGainPct,
|
||||
// Spell Combat
|
||||
SpellCastIntervalMs = s.SpellCastIntervalMs,
|
||||
AttackSpellIntervalMs = s.AttackSpellIntervalMs,
|
||||
CastDispelSelf = s.CastDispelSelf,
|
||||
|
|
@ -1312,10 +1412,22 @@ internal sealed partial class LegacyDashboardRenderer
|
|||
s.UseNativeAttack = p.UseNativeAttack;
|
||||
s.SummonPets = p.SummonPets;
|
||||
s.PetMinMonsters = p.PetMinMonsters;
|
||||
// Spell Combat
|
||||
// Absent (an engine without these controls) = unchanged.
|
||||
if (p.VariablePowerMin is int vpMin) s.VariablePowerMin = vpMin;
|
||||
if (p.VariablePowerMax is int vpMax) s.VariablePowerMax = vpMax;
|
||||
if (p.MissileEnvironmentResponse is int envMis) s.MissileEnvironmentResponse = envMis;
|
||||
if (p.MagicEnvironmentResponse is int envMag) s.MagicEnvironmentResponse = envMag;
|
||||
if (p.EnvironmentImpactLimit is int envLimit) s.EnvironmentImpactLimit = envLimit;
|
||||
if (p.EnvironmentImpactWindowSec is int envWin) s.EnvironmentImpactWindowSec = envWin;
|
||||
if (p.EnvironmentApproachMeters is int envStep) s.EnvironmentApproachMeters = envStep;
|
||||
if (p.EnvironmentMinDistance is int envMinDist) s.EnvironmentMinDistance = envMinDist;
|
||||
if (p.EnvironmentSkipSec is int envSkip) s.EnvironmentSkipSec = envSkip;
|
||||
if (p.KitePullMeters is int kitePull) s.KitePullMeters = Math.Clamp(kitePull, 3, 100);
|
||||
if (p.KiteTagFirst is bool kiteTag) s.KiteTagFirst = kiteTag;
|
||||
if (p.WeaponSwapSettleMs is int wsSettle) s.WeaponSwapSettleMs = Math.Clamp(wsSettle, 0, 3000);
|
||||
if (p.WeaponSwapMinHealthPct is int wsHealth) s.WeaponSwapMinHealthPct = Math.Clamp(wsHealth, 0, 100);
|
||||
if (p.WeaponSwapMinGainPct is int wsGain) s.WeaponSwapMinGainPct = Math.Clamp(wsGain, 0, 200);
|
||||
// Spell Combat
|
||||
s.SpellCastIntervalMs = p.SpellCastIntervalMs;
|
||||
if (p.AttackSpellIntervalMs is int attackDelay) s.AttackSpellIntervalMs = attackDelay; // absent = unchanged
|
||||
s.CastDispelSelf = p.CastDispelSelf;
|
||||
|
|
@ -1871,6 +1983,17 @@ internal sealed partial class LegacyDashboardRenderer
|
|||
dst.MeleeAttackPower = tmp.MeleeAttackPower;
|
||||
dst.MissileAttackPower = tmp.MissileAttackPower;
|
||||
dst.UseRecklessness = tmp.UseRecklessness;
|
||||
dst.VariablePowerMin = tmp.VariablePowerMin;
|
||||
dst.VariablePowerMax = tmp.VariablePowerMax;
|
||||
dst.MissileEnvironmentResponse = tmp.MissileEnvironmentResponse;
|
||||
dst.MagicEnvironmentResponse = tmp.MagicEnvironmentResponse;
|
||||
dst.EnvironmentImpactLimit = tmp.EnvironmentImpactLimit;
|
||||
dst.EnvironmentImpactWindowSec = tmp.EnvironmentImpactWindowSec;
|
||||
dst.EnvironmentApproachMeters = tmp.EnvironmentApproachMeters;
|
||||
dst.EnvironmentMinDistance = tmp.EnvironmentMinDistance;
|
||||
dst.EnvironmentSkipSec = tmp.EnvironmentSkipSec;
|
||||
dst.KitePullMeters = Math.Clamp(tmp.KitePullMeters, 3, 100);
|
||||
dst.KiteTagFirst = tmp.KiteTagFirst;
|
||||
dst.WeaponSwapSettleMs = Math.Clamp(tmp.WeaponSwapSettleMs, 0, 3000);
|
||||
dst.WeaponSwapMinHealthPct = Math.Clamp(tmp.WeaponSwapMinHealthPct, 0, 100);
|
||||
dst.WeaponSwapMinGainPct = Math.Clamp(tmp.WeaponSwapMinGainPct, 0, 200);
|
||||
|
|
|
|||
|
|
@ -472,6 +472,41 @@ public sealed class LegacyUiSettings
|
|||
public bool UseNativeAttack = false;
|
||||
public bool UseRecklessness;
|
||||
/// <summary>
|
||||
/// The range a monster rule's "Variable" attack power picks from, in percent of the bar
|
||||
/// (a new value every swing or shot). "Reckless + Variable" also stays inside the
|
||||
/// Recklessness band (20-80%). See AttackPowerPlanner.
|
||||
/// </summary>
|
||||
public int VariablePowerMin = 50;
|
||||
public int VariablePowerMax = 100;
|
||||
|
||||
// ── Environment hits (2026-10-12, Combat/EnvironmentImpact.cs) ─────────────
|
||||
/// <summary>
|
||||
/// What missile combat does once a target has taken EnvironmentImpactLimit "Your missile
|
||||
/// attack hit the environment." within EnvironmentImpactWindowSec: an EnvironmentResponse
|
||||
/// (0 Off, 1 Move closer, 2 New target, 3 Move closer then new target). Off by default.
|
||||
/// </summary>
|
||||
public int MissileEnvironmentResponse;
|
||||
/// <summary>The same for war/void casts whose projectiles stop short of the target. Off by default.</summary>
|
||||
public int MagicEnvironmentResponse;
|
||||
/// <summary>Environment hits on one target, within the window, that trip the response.</summary>
|
||||
public int EnvironmentImpactLimit = 2;
|
||||
/// <summary>The window (seconds) the hits are counted in.</summary>
|
||||
public int EnvironmentImpactWindowSec = 20;
|
||||
/// <summary>How far (metres) each "move closer" goes toward the target.</summary>
|
||||
public int EnvironmentApproachMeters = 6;
|
||||
/// <summary>Never approaches nearer than this (metres); already this close, a new target is picked.</summary>
|
||||
public int EnvironmentMinDistance = 3;
|
||||
/// <summary>How long (seconds) a target left for its environment hits is skipped.</summary>
|
||||
public int EnvironmentSkipSec = 30;
|
||||
/// <summary>
|
||||
/// Pull-away kite (2026-10-16, Combat/KiteModes.cs): how far (metres) to drag a PullAway
|
||||
/// monster from its lock-spot origin before stopping to kill it. Per-mob on/off is
|
||||
/// MonsterRule.Kite (Default follows the DEFAULT row).
|
||||
/// </summary>
|
||||
public int KitePullMeters = 20;
|
||||
/// <summary>Land a hit before fleeing so aggro sticks (Off = run immediately).</summary>
|
||||
public bool KiteTagFirst = true;
|
||||
/// <summary>
|
||||
/// Combat and buffing only ever wield weapons from the Items list. With this on (the
|
||||
/// default), a character whose Items list has no wand at all may still buff and cast with a
|
||||
/// caster from its pack (by object class, never by name). Any listed wand turns it off.
|
||||
|
|
@ -821,6 +856,13 @@ public sealed class MonsterRule
|
|||
/// <summary>Debuffs the player typed in (Damage panel), comma separated: a spell's base
|
||||
/// name ("Corrosion Vulnerability Other") casts its best known tier; a full name casts as is.</summary>
|
||||
public string CustomDebuffs { get; set; } = "";
|
||||
/// <summary>Melee/missile attack power against the monsters this rule covers: one of
|
||||
/// AttackPowerModes.All. "Default" = the DEFAULT line's choice (on the DEFAULT line: the global
|
||||
/// Melee/Missile Power settings). Rules saved before 2026-10-12 load as Default.</summary>
|
||||
public string AttackPower { get; set; } = AttackPowerModes.Default;
|
||||
/// <summary>Combat pull-away for this rule: one of KiteModes.All. "Default" = the DEFAULT
|
||||
/// line's choice (on the DEFAULT line: Off). Rules saved before 2026-10-16 load as Default.</summary>
|
||||
public string Kite { get; set; } = "Default";
|
||||
}
|
||||
|
||||
public sealed class BuffRule
|
||||
|
|
@ -1061,7 +1103,20 @@ public sealed class SettingsBridgePayload
|
|||
public bool UseNativeAttack { get; set; }
|
||||
public bool SummonPets { get; set; }
|
||||
public int PetMinMonsters { get; set; }
|
||||
|
||||
// Variable attack power and the environment-impact throttle (2026-10-12). Null = sent by an
|
||||
// engine without these controls, which leaves the plugin's own values alone.
|
||||
public int? VariablePowerMin { get; set; }
|
||||
public int? VariablePowerMax { get; set; }
|
||||
public int? MissileEnvironmentResponse { get; set; }
|
||||
public int? MagicEnvironmentResponse { get; set; }
|
||||
public int? EnvironmentImpactLimit { get; set; }
|
||||
public int? EnvironmentImpactWindowSec { get; set; }
|
||||
public int? EnvironmentApproachMeters { get; set; }
|
||||
public int? EnvironmentMinDistance { get; set; }
|
||||
public int? EnvironmentSkipSec { get; set; }
|
||||
// Pull-away kite (2026-10-16). Null = sender without these controls; leave plugin values alone.
|
||||
public int? KitePullMeters { get; set; }
|
||||
public bool? KiteTagFirst { get; set; }
|
||||
// Weapon swaps (only when the sender includes them).
|
||||
public int? WeaponSwapSettleMs { get; set; }
|
||||
public int? WeaponSwapMinHealthPct { get; set; }
|
||||
|
|
|
|||
|
|
@ -184,7 +184,9 @@ internal sealed class LootEditorBridge
|
|||
d.ItemId = id;
|
||||
var match = (LootItemMatch)Math.Clamp(req.Match, 0, 2);
|
||||
d.IncludeT11 = req.IncludeT11;
|
||||
LootItemFacts? facts = Items.Facts(id, match == LootItemMatch.Like, req.IncludeT11);
|
||||
d.AttributesSupported = true;
|
||||
// The checklist shows every attribute whatever the match, so the item is always read in full.
|
||||
LootItemFacts? facts = Items.Facts(id, true, req.IncludeT11 || req.Choices != null);
|
||||
if (facts == null) return Refuse(d, $"RynthAi doesn't know item 0x{id:X8} yet. Select it again in a moment.");
|
||||
d.IsT11 = facts.T11?.IsT11 == true;
|
||||
d.ItemName = facts.Name;
|
||||
|
|
@ -211,9 +213,11 @@ internal sealed class LootEditorBridge
|
|||
KeepCount = req.KeepCount < 0 ? null : req.KeepCount,
|
||||
RuleName = req.RuleName,
|
||||
IncludeT11 = req.IncludeT11,
|
||||
Choices = req.Choices,
|
||||
};
|
||||
LootItemRuleDraft? draft = LootItemRules.Build(facts, options, out string error);
|
||||
if (draft == null) return Refuse(d, error);
|
||||
foreach (LootItemAttribute row in draft.Attributes) d.Attributes.Add(row.ToWire());
|
||||
d.Match = (int)draft.Match;
|
||||
d.Action = (int)draft.Action;
|
||||
d.KeepCount = draft.KeepCount;
|
||||
|
|
|
|||
383
Plugins/RynthCore.Plugin.RynthAi/MagToolsCommands.Extra.cs
Normal file
383
Plugins/RynthCore.Plugin.RynthAi/MagToolsCommands.Extra.cs
Normal file
|
|
@ -0,0 +1,383 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using RynthCore.PluginSdk;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi;
|
||||
|
||||
/// <summary>
|
||||
/// The rest of Mag-Tools' <c>/mt</c> verbs (2026-10-17; checked against Mag-Tools PluginCore and
|
||||
/// ub-IT's MagToUbCommandTranslator): send (keys), jump / sjump, trade, vendor buy/sell lists,
|
||||
/// autopack, dumpspells, click, get xy, movement, client, plus ub-IT's config and strafe.
|
||||
/// Partial class of RynthAiPlugin; dispatched from <see cref="HandleMtCommand"/>.
|
||||
/// </summary>
|
||||
public sealed partial class RynthAiPlugin
|
||||
{
|
||||
// /mt vendor addbuy/addsell lists, sent by "/mt vendor buy" / "sell" (Mag-Tools keeps them in Decal).
|
||||
private readonly List<(uint Id, string Name, int Amount)> _mtBuyList = new();
|
||||
private readonly List<(uint Id, string Name)> _mtSellList = new();
|
||||
|
||||
/// <summary>The verbs this file handles, from <see cref="HandleMtCommand"/>'s default branch.</summary>
|
||||
private bool TryHandleMtExtra(string cmd, string[] parts, string fullCommand)
|
||||
{
|
||||
// jump, sjump, jumpw, sjumpwz ... (Mag-Tools matches "jump" anywhere after /mt).
|
||||
if (cmd.StartsWith("jump", StringComparison.Ordinal) || cmd.StartsWith("sjump", StringComparison.Ordinal))
|
||||
return HandleMtJump(cmd, parts);
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case "test":
|
||||
ChatLine("[RynthAi] /mt test: Mag-Tools' debug command - nothing to do.");
|
||||
return true;
|
||||
case "trade": return HandleMtTrade(parts);
|
||||
case "vendor": return HandleMtVendor(parts);
|
||||
case "autopack":
|
||||
// Mag-Tools packs by its own rules; RynthAi's equivalent is a cram + stack pass.
|
||||
_inventoryManager?.RunManual(cram: true, stack: true);
|
||||
ChatLine("[RynthAi] Autopack: cramming items into side packs and stacking them.");
|
||||
return true;
|
||||
case "dumpspells": return HandleMtDumpSpells();
|
||||
case "click": return HandleMtClick(parts);
|
||||
case "get":
|
||||
if (parts.Length >= 3 && parts[2].Equals("xy", StringComparison.OrdinalIgnoreCase)) return HandleMtCursor();
|
||||
ChatLine("[RynthAi] Usage: /mt get xy");
|
||||
return true;
|
||||
case "cursor": return HandleMtCursor();
|
||||
case "movement": return HandleMtMovement(parts);
|
||||
case "strafe": return HandleMtStrafe(parts);
|
||||
case "client": return HandleMtClient(parts);
|
||||
case "config":
|
||||
// ub-IT: /mt config = /mt opt (list when bare).
|
||||
return parts.Length < 3 ? HandleMtOpt(new[] { "/mt", "opt", "list" }) : HandleMtOpt(parts);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ── send: keys, as Mag-Tools ────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// /mt send enter|pause|del|space|f4|f12|cntrl+<letter>|msg <text>: presses keys in the
|
||||
/// game window, as Mag-Tools. A line starting with "/" is still sent as a chat command (what
|
||||
/// this verb did before, which some metas use).
|
||||
/// </summary>
|
||||
private bool HandleMtSend(string[] parts, string fullCommand)
|
||||
{
|
||||
if (parts.Length < 3) { ChatLine("[RynthAi] Usage: /mt send enter|pause|del|space|f4|f12|cntrl+<letter>|msg <text>"); return true; }
|
||||
string arg = parts[2].ToLowerInvariant();
|
||||
if (parts[2].StartsWith('/'))
|
||||
{
|
||||
if (Host.HasInvokeChatParser) Host.InvokeChatParser(string.Join(" ", parts, 2, parts.Length - 2));
|
||||
return true;
|
||||
}
|
||||
if (!GameInput.Available) { ChatLine("[RynthAi] /mt send: the game window wasn't found."); return true; }
|
||||
switch (arg)
|
||||
{
|
||||
case "enter": GameInput.SendEnter(); return true;
|
||||
case "pause": GameInput.SendPause(); return true;
|
||||
case "del": GameInput.SendDel(); return true;
|
||||
case "space": GameInput.SendSpace(); return true;
|
||||
case "f4": GameInput.SendF4(); return true;
|
||||
case "f12": GameInput.SendF12(); return true;
|
||||
case "msg":
|
||||
int at = fullCommand.IndexOf(" msg ", StringComparison.OrdinalIgnoreCase);
|
||||
if (at < 0 || at + 5 >= fullCommand.Length) { ChatLine("[RynthAi] Usage: /mt send msg <text>"); return true; }
|
||||
GameInput.SendMsg(fullCommand[(at + 5)..]);
|
||||
return true;
|
||||
}
|
||||
if (arg.StartsWith("cntrl+", StringComparison.Ordinal) && arg.Length >= 7)
|
||||
{
|
||||
GameInput.SendCntrl(arg[6]);
|
||||
return true;
|
||||
}
|
||||
ChatLine("[RynthAi] Usage: /mt send enter|pause|del|space|f4|f12|cntrl+<letter>|msg <text>");
|
||||
return true;
|
||||
}
|
||||
|
||||
// ── jump ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>/mt jump[w|z|x|c] [ms] and /mt sjump... (shift): RynthAi's jumper (the engine's own
|
||||
/// jump), else the keys as Mag-Tools.</summary>
|
||||
private bool HandleMtJump(string cmd, string[] parts)
|
||||
{
|
||||
bool shift = cmd.StartsWith("sjump", StringComparison.Ordinal);
|
||||
string suffix = cmd[(shift ? 5 : 4)..];
|
||||
bool w = suffix.Contains('w'), z = suffix.Contains('z'), x = suffix.Contains('x'), c = suffix.Contains('c');
|
||||
int ms = 0;
|
||||
if (parts.Length >= 3) int.TryParse(parts[2], out ms);
|
||||
ms = Math.Clamp(ms, 0, 1000);
|
||||
|
||||
string letters = (w ? "w" : "") + (x ? "x" : "") + (z ? "z" : "") + (c ? "c" : "") + (shift ? "s" : "");
|
||||
if (_jumper != null && _jumper.Start(letters, null, ms)) return true;
|
||||
if (_jumper?.IsBusy == true) return true; // it said so in chat
|
||||
if (!GameInput.Available) { ChatLine("[RynthAi] /mt jump: no jump hook and no game window."); return true; }
|
||||
GameInput.SendSpace(ms, shift, w, z, x, c);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ── trade ────────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>/mt trade add|addp <item> | accept | decline | reset | end.</summary>
|
||||
private bool HandleMtTrade(string[] parts)
|
||||
{
|
||||
if (parts.Length < 3) { ChatLine("[RynthAi] Usage: /mt trade add|addp <item> | accept | decline | reset | end"); return true; }
|
||||
if (!Host.HasTrade) { ChatLine("[RynthAi] Trading needs a newer RynthCore engine."); return true; }
|
||||
string sub = parts[2].ToLowerInvariant();
|
||||
switch (sub)
|
||||
{
|
||||
case "add":
|
||||
case "addp":
|
||||
{
|
||||
if (parts.Length < 4) { ChatLine($"[RynthAi] Usage: /mt trade {sub} <item>"); return true; }
|
||||
string name = string.Join(" ", parts, 3, parts.Length - 3);
|
||||
var item = FindObject(name, inv: true, land: false, partial: sub == "addp");
|
||||
if (item == null) { ChatLine($"[RynthAi] Item not found: '{name}'"); return true; }
|
||||
ChatLine(Host.TradeAdd(unchecked((uint)item.Id))
|
||||
? $"[RynthAi] Added {item.Name} to the trade." : "[RynthAi] Could not add it to the trade.");
|
||||
return true;
|
||||
}
|
||||
case "accept": Host.TradeAccept(); return true;
|
||||
case "decline": Host.TradeDecline(); return true;
|
||||
case "reset": Host.TradeReset(); return true;
|
||||
case "end": Host.TradeClose(); return true;
|
||||
default:
|
||||
ChatLine("[RynthAi] Usage: /mt trade add|addp <item> | accept | decline | reset | end");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// ── vendor ───────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// /mt vendor addbuy|addbuyp <item> [count] | addsell|addsellp <item> | buy | clearbuy | sell |
|
||||
/// clearsell, with a vendor open: lists kept here, sent in one transaction by buy / sell.
|
||||
/// </summary>
|
||||
private bool HandleMtVendor(string[] parts)
|
||||
{
|
||||
const string usage = "[RynthAi] Usage: /mt vendor addbuy|addbuyp <item> [count] | addsell|addsellp <item> | buy | clearbuy | sell | clearsell";
|
||||
if (parts.Length < 3) { ChatLine(usage); return true; }
|
||||
if (!Host.HasVendorTrade) { ChatLine("[RynthAi] Vendor trading needs a newer RynthCore engine."); return true; }
|
||||
if (!Host.TryGetVendorInfo(out VendorInfo info) || info.VendorId == 0)
|
||||
{
|
||||
ChatLine("[RynthAi] No vendor is open.");
|
||||
return true;
|
||||
}
|
||||
string sub = parts[2].ToLowerInvariant();
|
||||
switch (sub)
|
||||
{
|
||||
case "addbuy":
|
||||
case "addbuyp":
|
||||
{
|
||||
if (parts.Length < 4) { ChatLine($"[RynthAi] Usage: /mt vendor {sub} <item> [count]"); return true; }
|
||||
var words = parts.Skip(3).ToList();
|
||||
int count = 1;
|
||||
if (words.Count > 1 && int.TryParse(words[^1], out int n) && n > 0) { count = n; words.RemoveAt(words.Count - 1); }
|
||||
string name = string.Join(" ", words);
|
||||
bool partial = sub == "addbuyp";
|
||||
VendorItem? item = Host.GetVendorItems().FirstOrDefault(v => partial
|
||||
? v.Name.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0
|
||||
: string.Equals(v.Name, name, StringComparison.OrdinalIgnoreCase));
|
||||
if (item == null) { ChatLine($"[RynthAi] {info.Name} doesn't sell '{name}'."); return true; }
|
||||
_mtBuyList.Add((item.ObjectId, item.Name, count));
|
||||
ChatLine($"[RynthAi] Buy list: {count} x {item.Name} ({_mtBuyList.Count} entr{(_mtBuyList.Count == 1 ? "y" : "ies")}).");
|
||||
return true;
|
||||
}
|
||||
case "addsell":
|
||||
case "addsellp":
|
||||
{
|
||||
if (parts.Length < 4) { ChatLine($"[RynthAi] Usage: /mt vendor {sub} <item>"); return true; }
|
||||
string name = string.Join(" ", parts, 3, parts.Length - 3);
|
||||
var item = FindObject(name, inv: true, land: false, partial: sub == "addsellp");
|
||||
if (item == null) { ChatLine($"[RynthAi] Item not found: '{name}'"); return true; }
|
||||
uint id = unchecked((uint)item.Id);
|
||||
if (!_mtSellList.Any(s => s.Id == id)) _mtSellList.Add((id, item.Name));
|
||||
ChatLine($"[RynthAi] Sell list: {item.Name} ({_mtSellList.Count} item(s)).");
|
||||
return true;
|
||||
}
|
||||
case "buy":
|
||||
{
|
||||
if (_mtBuyList.Count == 0) { ChatLine("[RynthAi] The buy list is empty (/mt vendor addbuy <item> [count])."); return true; }
|
||||
var entries = _mtBuyList.Select(b => new VendorTradeEntryNative(b.Id, b.Amount)).ToList();
|
||||
uint sent = Host.VendorBuy(info.VendorId, entries);
|
||||
ChatLine(sent != 0 ? $"[RynthAi] Buying {_mtBuyList.Count} entr{(_mtBuyList.Count == 1 ? "y" : "ies")} from {info.Name}."
|
||||
: "[RynthAi] The buy could not be sent.");
|
||||
if (sent != 0) _mtBuyList.Clear();
|
||||
return true;
|
||||
}
|
||||
case "clearbuy":
|
||||
_mtBuyList.Clear();
|
||||
ChatLine("[RynthAi] Buy list cleared.");
|
||||
return true;
|
||||
case "sell":
|
||||
{
|
||||
if (_mtSellList.Count == 0) { ChatLine("[RynthAi] The sell list is empty (/mt vendor addsell <item>)."); return true; }
|
||||
uint sent = Host.VendorSell(info.VendorId, _mtSellList.Select(s => s.Id).ToList());
|
||||
ChatLine(sent != 0 ? $"[RynthAi] Selling {_mtSellList.Count} item(s) to {info.Name}." : "[RynthAi] The sell could not be sent.");
|
||||
if (sent != 0) _mtSellList.Clear();
|
||||
return true;
|
||||
}
|
||||
case "clearsell":
|
||||
_mtSellList.Clear();
|
||||
ChatLine("[RynthAi] Sell list cleared.");
|
||||
return true;
|
||||
default:
|
||||
ChatLine(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The vendor closed: its buy / sell lists no longer mean anything.</summary>
|
||||
private void ClearMtVendorLists()
|
||||
{
|
||||
_mtBuyList.Clear();
|
||||
_mtSellList.Clear();
|
||||
}
|
||||
|
||||
// ── dumpspells ───────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>/mt dumpspells: the spell table to RynthAi's folder (spelldump.txt: id, name, family, difficulty).</summary>
|
||||
private bool HandleMtDumpSpells()
|
||||
{
|
||||
try
|
||||
{
|
||||
Dictionary<string, int> byName = SpellDatabase.BuildNameToIdMap();
|
||||
var rows = byName.Select(kv => (Id: kv.Value, Name: kv.Key)).Distinct().OrderBy(r => r.Id).ToList();
|
||||
string path = Path.Combine(RynthCore.Install.RynthInstallPaths.RynthAiDir, "spelldump.txt");
|
||||
using (var w = new StreamWriter(path, false, new System.Text.UTF8Encoding(false)))
|
||||
{
|
||||
w.WriteLine("Id\tName\tFamily\tDifficulty");
|
||||
foreach (var (id, name) in rows)
|
||||
{
|
||||
SpellDatabase.TryGetSpellMeta(id, out int family, out int difficulty);
|
||||
w.WriteLine($"{id}\t{name}\t{family}\t{difficulty}");
|
||||
}
|
||||
}
|
||||
ChatLine($"[RynthAi] {rows.Count} spells written to {path}");
|
||||
}
|
||||
catch (Exception ex) { ChatLine($"[RynthAi] /mt dumpspells failed: {ex.Message}"); }
|
||||
return true;
|
||||
}
|
||||
|
||||
// ── /ra equipfor (VTank /vt equipitemsfor) ───────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// /ra equipfor <monster> (VTank's /vt equipitemsfor): wield the weapon and off hand set on that
|
||||
/// monster's rule (the rule named exactly, else one whose name the monster's contains, else
|
||||
/// Default). Items already wielded are left; a rule with no set weapon says so (combat picks
|
||||
/// one itself when it fights).
|
||||
/// </summary>
|
||||
private void HandleEquipForCommand(string[] parts)
|
||||
{
|
||||
if (parts.Length < 3) { ChatLine("[RynthAi] Usage: /ra equipfor <monster name>"); return; }
|
||||
var rules = _dashboard?.Settings?.MonsterRules;
|
||||
if (rules == null || rules.Count == 0) { ChatLine("[RynthAi] No monster rules loaded."); return; }
|
||||
string monster = string.Join(" ", parts, 2, parts.Length - 2).Trim();
|
||||
|
||||
var rule = rules.FirstOrDefault(r => string.Equals(r.Name, monster, StringComparison.OrdinalIgnoreCase))
|
||||
?? rules.Where(r => !string.Equals(r.Name, "Default", StringComparison.OrdinalIgnoreCase)
|
||||
&& r.Name.Length > 0 && monster.IndexOf(r.Name, StringComparison.OrdinalIgnoreCase) >= 0)
|
||||
.OrderByDescending(r => r.Name.Length).FirstOrDefault()
|
||||
?? rules.FirstOrDefault(r => string.Equals(r.Name, "Default", StringComparison.OrdinalIgnoreCase));
|
||||
if (rule == null) { ChatLine($"[RynthAi] No monster rule for '{monster}'."); return; }
|
||||
|
||||
var ids = new List<int>();
|
||||
if (rule.WeaponId != 0) ids.Add(rule.WeaponId);
|
||||
if (rule.OffhandId != 0) ids.Add(rule.OffhandId);
|
||||
if (ids.Count == 0)
|
||||
{
|
||||
ChatLine($"[RynthAi] '{rule.Name}' has no set weapon (combat picks one when it fights '{monster}').");
|
||||
return;
|
||||
}
|
||||
if (!Host.HasUseObject) { ChatLine("[RynthAi] UseObject not available."); return; }
|
||||
|
||||
int sent = 0;
|
||||
foreach (int id in ids)
|
||||
{
|
||||
var wo = _objectCache?[id];
|
||||
if (wo == null) { ChatLine($"[RynthAi] '{rule.Name}': item 0x{(uint)id:X8} isn't carried."); continue; }
|
||||
if (wo.Values(LongValueKey.CurrentWieldedLocation, 0) > 0) continue; // already wielded
|
||||
Host.UseFor(unchecked((uint)id), "Command", "/ra equipfor", UseKind.Asked);
|
||||
sent++;
|
||||
}
|
||||
ChatLine(sent > 0 ? $"[RynthAi] Equipping for '{monster}' ({rule.Name}): {sent} item(s)."
|
||||
: $"[RynthAi] '{rule.Name}' gear for '{monster}' is already wielded.");
|
||||
}
|
||||
|
||||
// ── click, cursor, movement, strafe, client ─────────────────────────────────
|
||||
|
||||
/// <summary>/mt click ok|yes|no|<x> <y>: a click in the game window (window coordinates).</summary>
|
||||
private bool HandleMtClick(string[] parts)
|
||||
{
|
||||
if (parts.Length < 3) { ChatLine("[RynthAi] Usage: /mt click ok|yes|no|<x> <y>"); return true; }
|
||||
if (!GameInput.Available) { ChatLine("[RynthAi] /mt click: the game window wasn't found."); return true; }
|
||||
switch (parts[2].ToLowerInvariant())
|
||||
{
|
||||
case "ok": GameInput.ClickOK(); return true;
|
||||
case "yes": GameInput.ClickYes(); return true;
|
||||
case "no": GameInput.ClickNo(); return true;
|
||||
}
|
||||
if (parts.Length >= 4 && int.TryParse(parts[2], out int x) && int.TryParse(parts[3], out int y))
|
||||
{
|
||||
GameInput.SendMouseClick(x, y);
|
||||
return true;
|
||||
}
|
||||
ChatLine("[RynthAi] Usage: /mt click ok|yes|no|<x> <y>");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>/mt get xy (and ub-IT's /mt cursor): the cursor relative to the game window.</summary>
|
||||
private bool HandleMtCursor()
|
||||
{
|
||||
ChatLine(GameInput.TryCursorInWindow(out int x, out int y)
|
||||
? $"[RynthAi] Current cursor position: {x},{y}"
|
||||
: "[RynthAi] The cursor position couldn't be read.");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>/mt movement <key> <ms>: hold a movement key (AC's keymap letter) for ms.</summary>
|
||||
private bool HandleMtMovement(string[] parts)
|
||||
{
|
||||
if (parts.Length != 4 || parts[2].Length != 1 || !int.TryParse(parts[3], out int ms) || ms < 0)
|
||||
{
|
||||
ChatLine("[RynthAi] Usage: /mt movement <key> <ms> (e.g. /mt movement w 1500)");
|
||||
return true;
|
||||
}
|
||||
if (!GameInput.Available) { ChatLine("[RynthAi] /mt movement: the game window wasn't found."); return true; }
|
||||
GameInput.SendMovement(parts[2][0], ms);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>ub-IT's /mt strafe left|l|right|r <ms>: hold the side-step key (Z / C) for ms.</summary>
|
||||
private bool HandleMtStrafe(string[] parts)
|
||||
{
|
||||
if (parts.Length != 4 || !int.TryParse(parts[3], out int ms) || ms < 0)
|
||||
{
|
||||
ChatLine("[RynthAi] Usage: /mt strafe left|l|right|r <ms>");
|
||||
return true;
|
||||
}
|
||||
char key = parts[2].ToLowerInvariant() switch { "left" or "l" => 'z', "right" or "r" => 'c', _ => '\0' };
|
||||
if (key == '\0') { ChatLine("[RynthAi] /mt strafe: left, l, right or r."); return true; }
|
||||
if (!GameInput.Available) { ChatLine("[RynthAi] /mt strafe: the game window wasn't found."); return true; }
|
||||
GameInput.SendMovement(key, ms);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>/mt client minimize|restore (ub-IT's frame apply|restore points to Settings > Display).</summary>
|
||||
private bool HandleMtClient(string[] parts)
|
||||
{
|
||||
string sub = parts.Length >= 3 ? parts[2].ToLowerInvariant() : "";
|
||||
switch (sub)
|
||||
{
|
||||
case "minimize": GameInput.Minimize(); return true;
|
||||
case "restore": GameInput.Restore(); return true;
|
||||
case "frame":
|
||||
ChatLine("[RynthAi] The window frame is RynthCore's: Settings > Display (Borderless Windowed, Reset Window Borders) or /rc window reset.");
|
||||
return true;
|
||||
default:
|
||||
ChatLine("[RynthAi] Usage: /mt client minimize | restore");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -92,14 +92,14 @@ public sealed partial class RynthAiPlugin
|
|||
if (Host.HasInvokeChatParser) Host.InvokeChatParser("/rc quit");
|
||||
return true;
|
||||
|
||||
// ── Send a chat line / slash command (VTank /mt send) ────────────
|
||||
// ── Keys in the game window (Mag-Tools /mt send); a "/" line is still sent as a command ──
|
||||
case "send":
|
||||
if (parts.Length >= 3 && Host.HasInvokeChatParser)
|
||||
Host.InvokeChatParser(string.Join(" ", parts, 2, parts.Length - 2));
|
||||
return true;
|
||||
return HandleMtSend(parts, fullCommand);
|
||||
|
||||
default:
|
||||
return false;
|
||||
// jump, trade, vendor, autopack, dumpspells, click, get xy, movement, client, config,
|
||||
// strafe, test (MagToolsCommands.Extra.cs).
|
||||
return TryHandleMtExtra(cmd, parts, fullCommand);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -302,11 +302,45 @@ public sealed partial class RynthAiPlugin
|
|||
|
||||
private bool HandleMtFace(string[] parts)
|
||||
{
|
||||
// /mt face <degrees>
|
||||
if (parts.Length < 3 || !float.TryParse(parts[2], out float degrees)) return false;
|
||||
if (!Host.HasTurnToHeading) { ChatLine("[RynthAi] TurnToHeading not available."); return true; }
|
||||
// /mt face <degrees> (Mag-Tools) and /ub face <degrees> (ub-IT, translated here). The heading
|
||||
// may have decimals (getheadingto[] gives them), read the same on every PC; or a coordinate
|
||||
// ("42.1N, 33.6E") to face that spot.
|
||||
if (parts.Length < 3) return false;
|
||||
string arg = string.Join(" ", parts, 2, parts.Length - 2).Trim();
|
||||
double heading;
|
||||
if (double.TryParse(arg, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out double deg))
|
||||
heading = deg;
|
||||
else if (!TryHeadingToCoords(arg, out heading))
|
||||
return false;
|
||||
|
||||
Host.TurnToHeadingBy("Command", degrees);
|
||||
// The jumper holds navigation while it turns (nav would turn the character back) and turns
|
||||
// again until it faces the heading, as ub-IT does; without it, one plain turn.
|
||||
if (_jumper != null) _jumper.Face(heading);
|
||||
else if (Host.HasTurnToHeading) Host.TurnToHeadingBy("Command", (float)(((heading % 360) + 360) % 360));
|
||||
else ChatLine("[RynthAi] TurnToHeading not available.");
|
||||
return true;
|
||||
}
|
||||
|
||||
private static readonly System.Text.RegularExpressions.Regex FaceCoordsRx = new(
|
||||
@"^\s*(?<ns>\d+(?:\.\d+)?)\s*(?<nsc>[NnSs])[\s,]*(?<ew>\d+(?:\.\d+)?)\s*(?<ewc>[EeWw])\s*$",
|
||||
System.Text.RegularExpressions.RegexOptions.CultureInvariant);
|
||||
|
||||
/// <summary>
|
||||
/// The heading from the character to a "42.1N, 33.6E" coordinate (AC's: 0 north, 90 east, the
|
||||
/// same as getheadingto[]). False when the text isn't a coordinate or our position is unknown.
|
||||
/// </summary>
|
||||
private bool TryHeadingToCoords(string text, out double heading)
|
||||
{
|
||||
heading = 0;
|
||||
var m = FaceCoordsRx.Match(text);
|
||||
if (!m.Success || !NavCoordinateHelper.TryGetNavCoords(Host, out double myNs, out double myEw)) return false;
|
||||
var inv = System.Globalization.CultureInfo.InvariantCulture;
|
||||
double ns = double.Parse(m.Groups["ns"].Value, inv) * (char.ToUpperInvariant(m.Groups["nsc"].Value[0]) == 'S' ? -1 : 1);
|
||||
double ew = double.Parse(m.Groups["ew"].Value, inv) * (char.ToUpperInvariant(m.Groups["ewc"].Value[0]) == 'W' ? -1 : 1);
|
||||
double dNs = ns - myNs, dEw = ew - myEw;
|
||||
if (Math.Abs(dNs) < 1e-6 && Math.Abs(dEw) < 1e-6) return false;
|
||||
heading = Math.Atan2(dEw, dNs) * (180.0 / Math.PI);
|
||||
if (heading < 0) heading += 360.0;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,373 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.Meta;
|
||||
|
||||
/// <summary>
|
||||
/// ub-IT expression functions that were missing (2026-10-18 meta-compatibility pass), with
|
||||
/// ub-IT's names, arguments and return values. Where RynthAi has no matching data (character
|
||||
/// select, Decal views, ub-IT's own HUDs) the function still answers, with the value ub-IT gives
|
||||
/// when there is nothing to report, so an expression that calls it keeps working.
|
||||
/// </summary>
|
||||
internal sealed partial class ExpressionEngine
|
||||
{
|
||||
/// <summary>Corpses this character has opened (the plugin's loot bookkeeping), for
|
||||
/// hascorpsebeenopenedbyme[] and getcorpsesunopenedbyme[]. Null: none known.</summary>
|
||||
internal Func<int, bool>? CorpseOpenedByMe { get; set; }
|
||||
|
||||
/// <summary>The meta manager's '/vt opt set' (VTank names, distances in landblock units, the
|
||||
/// special options), for vtsetsetting[]; null: the plain settings map (an engine without one).</summary>
|
||||
internal Func<string, string, bool>? VtOptionSetter { get; set; }
|
||||
|
||||
/// <summary>The meta manager's '/vt opt get' (values read back in VTank's units), for vtgetsetting[].</summary>
|
||||
internal Func<string, string?>? VtOptionGetter { get; set; }
|
||||
|
||||
// getcooldownexpiration: shared cooldowns are enchantments whose spell id has this bit.
|
||||
private const uint CooldownSpellFlag = 0x8000;
|
||||
|
||||
// ub-IT's QuestRefreshCooldownSeconds default (canrefreshquests[]).
|
||||
private const double QuestRefreshCooldownSeconds = 60;
|
||||
|
||||
// Character property ids (PropertyInt64): total experience, available luminance.
|
||||
private const uint QuadTotalExperience = 1;
|
||||
private const uint QuadAvailableLuminance = 6;
|
||||
// PropertyInt StackSize.
|
||||
private const uint IntStackSize = 12;
|
||||
|
||||
// XP meter (xpreset/xpmeter/xpduration/xptotal/lumtotal/xpavg/lumavg). Starts on the
|
||||
// first call after login or a reset; luminance counts gains only (spending isn't earning).
|
||||
private long _xpStartMs = -1;
|
||||
private long _xpBase, _lumLast, _lumGained;
|
||||
|
||||
// Functions with no RynthAi data already logged (one line each per session).
|
||||
private readonly HashSet<string> _ubNoDataLogged = new(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>
|
||||
/// The functions above. Returns false for any other name, so the caller's unknown-function
|
||||
/// fallback still logs real typos.
|
||||
/// </summary>
|
||||
private bool TryEvalUbCompat(string funcName, List<string> rawArgs, Func<int, string> A, out string value)
|
||||
{
|
||||
value = funcName switch
|
||||
{
|
||||
// ── Inventory actions (1 = attempted, 0 = busy or not possible) ──────
|
||||
"actiontrymove" => EvalActionTryMove(A(0), A(1), rawArgs.Count > 2 ? A(2) : "0", rawArgs.Count > 3 ? A(3) : "1"),
|
||||
"actiontrysplit" => EvalActionTrySplit(A(0), A(1), rawArgs.Count > 2 ? A(2) : "", rawArgs.Count > 3 ? A(3) : "0"),
|
||||
"actiontrydrop" => NoData("actiontrydrop", "0"),
|
||||
|
||||
// ── Vitals of an object (current values; the selected target or yourself) ──
|
||||
"wobjectgethealthvalue" => EvalWobjectVital(A(0), 0),
|
||||
"wobjectgetstaminavalue" => EvalWobjectVital(A(0), 1),
|
||||
"wobjectgetmanavalue" => EvalWobjectVital(A(0), 2),
|
||||
|
||||
// ── Corpses ──────────────────────────────────────────────────────────
|
||||
"hascorpsebeenopenedbyme" => EvalCorpseOpenedByMe(A(0)),
|
||||
"getcorpsesunopenedbyme" => EvalCorpsesUnopenedByMe(),
|
||||
|
||||
// ── Casting, cooldowns, spell data ───────────────────────────────────
|
||||
"iscasting" => _host.HasGetCastBusyState && _host.GetCastBusyState() != 0 ? "1" : "0",
|
||||
"getcooldownexpiration" => EvalCooldownExpiration(A(0)),
|
||||
"spelldata" => EvalSpellData(A(0)),
|
||||
|
||||
// ── Macro state and delayed expressions ──────────────────────────────
|
||||
"vtmacroenabled" => _settings?.IsMacroRunning == true ? "1" : "0",
|
||||
"clearexec" => EvalClearExec(A(0)),
|
||||
|
||||
// ── Quests (myquests throttle; ACECustom quest bonus lives in RynthILT) ──
|
||||
"canrefreshquests" => EvalCanRefreshQuests(),
|
||||
"testquestbonus" => NoData("testquestbonus", "0"),
|
||||
"isrefreshingquestbonuses" => "0",
|
||||
"enlightenmentmaterials" => EvalEnlightenmentTokens(A(0), A(1)),
|
||||
|
||||
// ── XP meter ─────────────────────────────────────────────────────────
|
||||
"xpreset" => EvalXpReset(),
|
||||
"xpduration" => FormatNumber(XpSeconds()),
|
||||
"xptotal" => FormatNumber(XpTotal()),
|
||||
"lumtotal" => FormatNumber(LumTotal()),
|
||||
"xpavg" => FormatNumber(PerHour(XpTotal())),
|
||||
"lumavg" => FormatNumber(PerHour(LumTotal())),
|
||||
"xpmeter" => EvalXpMeterText(),
|
||||
|
||||
// ── No RynthAi equivalent: ub-IT's "nothing here" values ─────────────
|
||||
"getcharacterindex" => NoData("getcharacterindex", "-1"),
|
||||
"setnextlogin" => NoData("setnextlogin", "0"),
|
||||
"clearnextlogin" => NoData("clearnextlogin", "1"),
|
||||
"netclients" => NoData("netclients", "[]"),
|
||||
"statushud" => NoData("statushud", "1"),
|
||||
"statushudcolored" => NoData("statushudcolored", "1"),
|
||||
// Decal views: none exist here, so no view is found or shown.
|
||||
"uiviewexists" => NoData("uiviewexists", "0"),
|
||||
"uiviewvisible" => NoData("uiviewvisible", "0"),
|
||||
"uisetvisible" => NoData("uisetvisible", "0"),
|
||||
"uisetlabel" => NoData("uisetlabel", "0"),
|
||||
"uigetcontrol" => NoData("uigetcontrol", "0"),
|
||||
_ => null!,
|
||||
};
|
||||
return value != null;
|
||||
}
|
||||
|
||||
/// <summary>The fixed answer of a function RynthAi has no data for; logged once per session.</summary>
|
||||
private string NoData(string funcName, string result)
|
||||
{
|
||||
if (_ubNoDataLogged.Add(funcName))
|
||||
_host.Log($"[RynthAi] Expression {funcName}[]: ub-IT feature with no RynthAi equivalent; returns {result}.");
|
||||
return result;
|
||||
}
|
||||
|
||||
// ── Inventory actions ────────────────────────────────────────────────────
|
||||
|
||||
private bool IsBusy() => _host.HasGetBusyState && _host.GetBusyState() > 0;
|
||||
|
||||
private int StackSizeOf(uint id)
|
||||
{
|
||||
if (_worldObjectCache != null)
|
||||
{
|
||||
int n = _worldObjectCache.GetIntProperty(unchecked((int)id), IntStackSize, 0);
|
||||
if (n > 0) return n;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// <summary>actiontrymove[obj, container, slot=0, addToStack=1]: into a stack of the same
|
||||
/// name in that container when there is one (and addToStack), else into the slot.</summary>
|
||||
private string EvalActionTryMove(string objArg, string destArg, string slotArg, string stackArg)
|
||||
{
|
||||
if (!TryParseWobjectHandle(objArg, out uint id, out _) || id == 0) return "0";
|
||||
if (!TryParseWobjectHandle(destArg, out uint dest, out _) || dest == 0) return "0";
|
||||
if (IsBusy()) return "0";
|
||||
|
||||
if (ToBool(stackArg) && _worldObjectCache != null && _host.HasMergeStackInternal)
|
||||
{
|
||||
string name = _worldObjectCache[unchecked((int)id)]?.Name ?? "";
|
||||
foreach (var wo in _worldObjectCache.GetContainedItems(unchecked((int)dest)))
|
||||
{
|
||||
if (unchecked((uint)wo.Id) == id || !string.Equals(wo.Name, name, StringComparison.Ordinal)) continue;
|
||||
if (StackSizeOf(unchecked((uint)wo.Id)) <= 1 && StackSizeOf(id) <= 1) continue;
|
||||
return _host.MergeStackInternal(id, unchecked((uint)wo.Id)) ? "1" : "0";
|
||||
}
|
||||
}
|
||||
|
||||
if (!_host.HasMoveItemInternal) return "0";
|
||||
int slot = (int)Math.Max(0, ToDouble(slotArg));
|
||||
return _host.MoveItemInternal(id, dest, slot, StackSizeOf(id)) ? "1" : "0";
|
||||
}
|
||||
|
||||
/// <summary>actiontrysplit[obj, newStackSize, container=player, slot=0]: splits newStackSize off the stack.</summary>
|
||||
private string EvalActionTrySplit(string objArg, string countArg, string destArg, string slotArg)
|
||||
{
|
||||
if (!TryParseWobjectHandle(objArg, out uint id, out _) || id == 0) return "0";
|
||||
int count = (int)ToDouble(countArg);
|
||||
if (count < 1 || count >= StackSizeOf(id)) return "0";
|
||||
uint dest = TryParseWobjectHandle(destArg, out uint d, out _) && d != 0 ? d : _playerId;
|
||||
if (dest == 0 || IsBusy() || !_host.HasSplitStackInternal) return "0";
|
||||
int slot = (int)Math.Max(0, ToDouble(slotArg));
|
||||
return _host.SplitStackInternal(id, dest, slot, count) ? "1" : "0";
|
||||
}
|
||||
|
||||
// ── Vitals ───────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Current health (0), stamina (1) or mana (2) of the object; -1 when unknown. The
|
||||
/// game reports these for yourself and for the target you've selected (as ub-IT notes).</summary>
|
||||
private string EvalWobjectVital(string objArg, int which)
|
||||
{
|
||||
if (!TryParseWobjectHandle(objArg, out uint id, out _) || id == 0) return "-1";
|
||||
uint hp, st, mp;
|
||||
if (id == _playerId)
|
||||
{
|
||||
if (!_host.TryGetPlayerVitals(out hp, out _, out st, out _, out mp, out _)) return "-1";
|
||||
}
|
||||
else if (!_host.TryGetTargetVitals(id, out hp, out _, out st, out _, out mp, out _))
|
||||
{
|
||||
return "-1";
|
||||
}
|
||||
uint v = which switch { 0 => hp, 1 => st, _ => mp };
|
||||
return v.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
// ── Corpses ──────────────────────────────────────────────────────────────
|
||||
|
||||
private string EvalCorpseOpenedByMe(string objArg)
|
||||
{
|
||||
if (!TryParseWobjectHandle(objArg, out uint id, out _) || id == 0) return "0";
|
||||
return CorpseOpenedByMe?.Invoke(unchecked((int)id)) == true ? "1" : "0";
|
||||
}
|
||||
|
||||
/// <summary>Corpses in view this character hasn't opened, as a list of objects.</summary>
|
||||
private string EvalCorpsesUnopenedByMe()
|
||||
{
|
||||
if (_worldObjectCache == null) return "[]";
|
||||
var items = new List<string>();
|
||||
var seen = new HashSet<int>();
|
||||
foreach (var wo in _worldObjectCache.GetLandscape())
|
||||
{
|
||||
if (wo.ObjectClass != AcObjectClass.Corpse || !seen.Add(wo.Id)) continue;
|
||||
if (CorpseOpenedByMe?.Invoke(wo.Id) == true) continue;
|
||||
items.Add(MakeWobjectHandle(unchecked((uint)wo.Id), wo.Name));
|
||||
}
|
||||
return NewList(items);
|
||||
}
|
||||
|
||||
// ── Casting, cooldowns, spell data ───────────────────────────────────────
|
||||
|
||||
/// <summary>Seconds until shared cooldown <paramref name="idArg"/> ends; 0 when it isn't running.</summary>
|
||||
private string EvalCooldownExpiration(string idArg)
|
||||
{
|
||||
int want = (int)ToDouble(idArg);
|
||||
if (want <= 0 || !_host.HasReadPlayerEnchantments || !_host.HasGetServerTime) return "0";
|
||||
double now = _host.GetServerTime();
|
||||
if (now <= 0) return "0";
|
||||
const int Max = 512;
|
||||
uint[] ids = new uint[Max];
|
||||
double[] expiry = new double[Max];
|
||||
int count = _host.ReadPlayerEnchantments(ids, expiry, Max);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if ((ids[i] & CooldownSpellFlag) == 0 || (ids[i] & 0xFFF) != want) continue;
|
||||
double left = expiry[i] - now;
|
||||
return left > 0 ? ((int)Math.Ceiling(left)).ToString(CultureInfo.InvariantCulture) : "0";
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
|
||||
/// <summary>spelldata[id]: a dictionary of what RynthAi's spell table knows (Id, Name, Family,
|
||||
/// Difficulty, Category, Power, Level). Empty for an unknown spell, as in ub-IT.</summary>
|
||||
private string EvalSpellData(string idArg)
|
||||
{
|
||||
int id = (int)ToDouble(idArg);
|
||||
var d = new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
if (id > 0 && SpellDatabase.HasSpell(id))
|
||||
{
|
||||
d["Id"] = id.ToString(CultureInfo.InvariantCulture);
|
||||
d["Name"] = SpellDatabase.GetSpellName(id);
|
||||
if (SpellDatabase.TryGetSpellMeta(id, out int family, out int difficulty))
|
||||
{
|
||||
d["Family"] = family.ToString(CultureInfo.InvariantCulture);
|
||||
d["Difficulty"] = difficulty.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
if (SpellDatabase.TryGetCategoryAndPower(id, out int category, out int power))
|
||||
{
|
||||
d["Category"] = category.ToString(CultureInfo.InvariantCulture);
|
||||
d["Power"] = power.ToString(CultureInfo.InvariantCulture);
|
||||
d["Level"] = SpellDatabase.LevelFromPower(power).ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
return NewDict(d);
|
||||
}
|
||||
|
||||
// ── Delayed expressions ──────────────────────────────────────────────────
|
||||
|
||||
/// <summary>clearexec[id]: cancels the delayexec that returned that id. 1 if one was pending.</summary>
|
||||
private string EvalClearExec(string idArg)
|
||||
{
|
||||
long id = (long)ToDouble(idArg);
|
||||
int removed = _delayedExecs.RemoveAll(e => e.Id == id);
|
||||
return removed > 0 ? "1" : "0";
|
||||
}
|
||||
|
||||
// ── Quests ───────────────────────────────────────────────────────────────
|
||||
|
||||
private string EvalCanRefreshQuests()
|
||||
{
|
||||
if (_questTracker == null) return "1";
|
||||
if (_questTracker.IsRefreshing) return "0";
|
||||
return (DateTime.UtcNow - _questTracker.LastRefreshUtc).TotalSeconds >= QuestRefreshCooldownSeconds ? "1" : "0";
|
||||
}
|
||||
|
||||
/// <summary>enlightenmentmaterials[current, target]: ub-IT's token count. Levels 6-150 cost
|
||||
/// (level - 5) tokens each; levels 1-5 cost none and later levels cost other items.</summary>
|
||||
private static string EvalEnlightenmentTokens(string curArg, string tgtArg)
|
||||
{
|
||||
int cur = (int)ToDouble(curArg), tgt = (int)ToDouble(tgtArg);
|
||||
long tokens = 0;
|
||||
for (int level = Math.Max(cur + 1, 6); level <= Math.Min(tgt, 150); level++)
|
||||
tokens += level - 5;
|
||||
return tokens.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
// ── XP meter ─────────────────────────────────────────────────────────────
|
||||
|
||||
private long ReadQuad(uint stype)
|
||||
=> _playerId != 0 && _host.HasGetObjectQuadProperty && _host.TryGetObjectQuadProperty(_playerId, stype, out long v) ? v : 0;
|
||||
|
||||
/// <summary>Starts the meter on first use and folds in luminance gained since the last look.</summary>
|
||||
private void SampleXpMeter()
|
||||
{
|
||||
long lum = ReadQuad(QuadAvailableLuminance);
|
||||
if (_xpStartMs < 0)
|
||||
{
|
||||
_xpStartMs = TickMs();
|
||||
_xpBase = ReadQuad(QuadTotalExperience);
|
||||
_lumLast = lum;
|
||||
_lumGained = 0;
|
||||
return;
|
||||
}
|
||||
if (lum > _lumLast) _lumGained += lum - _lumLast;
|
||||
_lumLast = lum;
|
||||
}
|
||||
|
||||
/// <summary>Forgets the meter when the character changes (called from SetPlayerId).</summary>
|
||||
private void ResetXpMeter() => _xpStartMs = -1;
|
||||
|
||||
private string EvalXpReset()
|
||||
{
|
||||
ResetXpMeter();
|
||||
SampleXpMeter();
|
||||
return "1";
|
||||
}
|
||||
|
||||
private double XpSeconds()
|
||||
{
|
||||
SampleXpMeter();
|
||||
return Math.Max(0, (TickMs() - _xpStartMs) / 1000.0);
|
||||
}
|
||||
|
||||
private double XpTotal()
|
||||
{
|
||||
SampleXpMeter();
|
||||
return Math.Max(0, ReadQuad(QuadTotalExperience) - _xpBase);
|
||||
}
|
||||
|
||||
private double LumTotal()
|
||||
{
|
||||
SampleXpMeter();
|
||||
return _lumGained;
|
||||
}
|
||||
|
||||
private double PerHour(double amount)
|
||||
{
|
||||
double s = XpSeconds();
|
||||
return s <= 0 ? 0 : amount / s * 3600;
|
||||
}
|
||||
|
||||
/// <summary>ub-IT's meter text: "500m XP and 2k LUM, 51s, 35.39b XP/hr and 140k LUM/hr".</summary>
|
||||
private string EvalXpMeterText()
|
||||
{
|
||||
double xp = XpTotal(), lum = LumTotal(), s = XpSeconds();
|
||||
string head = lum > 0 ? $"{ShortNumber(xp)} XP and {ShortNumber(lum)} LUM" : $"{ShortNumber(xp)} XP";
|
||||
string rate = lum > 0 ? $"{ShortNumber(PerHour(xp))} XP/hr and {ShortNumber(PerHour(lum))} LUM/hr" : $"{ShortNumber(PerHour(xp))} XP/hr";
|
||||
return $"{head}, {ShortDuration(s)}, {rate}";
|
||||
}
|
||||
|
||||
private static string FormatNumber(double v) => Math.Round(v, 2).ToString("0.##", CultureInfo.InvariantCulture);
|
||||
|
||||
/// <summary>1234 -> 1.23k, 5.6e8 -> 560m, as ub-IT's formatExperience.</summary>
|
||||
private static string ShortNumber(double v)
|
||||
{
|
||||
string[] units = { "", "k", "m", "b", "t", "q" };
|
||||
int u = 0;
|
||||
while (Math.Abs(v) >= 1000 && u < units.Length - 1) { v /= 1000; u++; }
|
||||
return (u == 0 ? Math.Round(v).ToString("0", CultureInfo.InvariantCulture)
|
||||
: v.ToString("0.##", CultureInfo.InvariantCulture)) + units[u];
|
||||
}
|
||||
|
||||
private static string ShortDuration(double seconds)
|
||||
{
|
||||
var t = TimeSpan.FromSeconds(Math.Max(0, seconds));
|
||||
if (t.TotalHours >= 1) return $"{(int)t.TotalHours}h {t.Minutes}m";
|
||||
if (t.TotalMinutes >= 1) return $"{t.Minutes}m {t.Seconds}s";
|
||||
return $"{t.Seconds}s";
|
||||
}
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ namespace RynthCore.Plugin.RynthAi.Meta;
|
|||
/// Lists are text ("[a,b]"); the list functions that change a list write it back to the
|
||||
/// variable it came from. Dictionaries and stopwatches are handles ("D:0", "SW:0").
|
||||
/// </summary>
|
||||
internal sealed class ExpressionEngine
|
||||
internal sealed partial class ExpressionEngine
|
||||
{
|
||||
private readonly RynthCoreHost _host;
|
||||
private WorldObjectCache? _worldObjectCache;
|
||||
|
|
@ -71,7 +71,7 @@ internal sealed class ExpressionEngine
|
|||
if (_pvars != null) foreach (string v in _pvars.Values) Scan(v);
|
||||
if (_gvars != null) foreach (string v in _gvars.Values) Scan(v);
|
||||
foreach (string v in _options.Values) Scan(v);
|
||||
foreach (var (_, expr) in _delayedExecs) Scan(expr);
|
||||
foreach (var (_, _, expr) in _delayedExecs) Scan(expr);
|
||||
while (todo.Count > 0)
|
||||
foreach (var (k, v) in _dicts[todo.Dequeue()]) { Scan(k); Scan(v); }
|
||||
|
||||
|
|
@ -133,7 +133,8 @@ internal sealed class ExpressionEngine
|
|||
// hot-reload to fire into a freed engine). Instance-scoped so a hot-reload
|
||||
// discards pending execs. Single-threaded access (Evaluate and the pump
|
||||
// both run on the plugin-tick thread) → no lock needed.
|
||||
private readonly List<(long DueMs, string Expr)> _delayedExecs = new();
|
||||
private readonly List<(long Id, long DueMs, string Expr)> _delayedExecs = new();
|
||||
private long _nextDelayedExecId;
|
||||
|
||||
private uint _playerId;
|
||||
private LegacyUiSettings? _settings;
|
||||
|
|
@ -187,6 +188,7 @@ internal sealed class ExpressionEngine
|
|||
FlushVars(force: true); // persist the old char's pending pvars first
|
||||
_pvars = null;
|
||||
_pvarPathCached = null;
|
||||
ResetXpMeter();
|
||||
}
|
||||
_playerId = id;
|
||||
}
|
||||
|
|
@ -557,8 +559,12 @@ internal sealed class ExpressionEngine
|
|||
// UB vtgetmeta[]: the loaded meta's name (file name without extension).
|
||||
"vtgetmeta" or "ragetmeta" => string.IsNullOrEmpty(_settings?.CurrentMetaPath)
|
||||
? "" : Path.GetFileNameWithoutExtension(_settings!.CurrentMetaPath),
|
||||
"rasetsetting" or "vtsetsetting" => EvalVtSetSetting(Text(0), A(1)),
|
||||
"ragetsetting" or "vtgetsetting" or "vtankgetsetting" => EvalVtGetSetting(Text(0)),
|
||||
// vt*: VTank option names and units (landblock distances), the same as '/vt opt set|get';
|
||||
// ra*: RynthAi's own setting names, as they are.
|
||||
"vtsetsetting" => VtOptionSetter != null && Text(0).Length > 0 ? (VtOptionSetter(Text(0), A(1)) ? "1" : "0") : EvalVtSetSetting(Text(0), A(1)),
|
||||
"vtgetsetting" or "vtankgetsetting" => VtOptionGetter != null && Text(0).Length > 0 ? VtOptionGetter(Text(0)) ?? "" : EvalVtGetSetting(Text(0)),
|
||||
"rasetsetting" => EvalVtSetSetting(Text(0), A(1)),
|
||||
"ragetsetting" => EvalVtGetSetting(Text(0)),
|
||||
|
||||
// ── Dynamic evaluation ────────────────────────────────────────────
|
||||
"exec" => Evaluate(A(0)),
|
||||
|
|
@ -583,7 +589,8 @@ internal sealed class ExpressionEngine
|
|||
// "Strings support slices like arrays. ie test[1:]": a word that isn't a function,
|
||||
// followed by [start:stop].
|
||||
_ when TopLevelColon(argsStr) >= 0 => SliceBy(expr.Substring(0, lb).Trim(), argsStr),
|
||||
_ => EvalUnknownFunction(funcName)
|
||||
// ub-IT's remaining functions (ExpressionEngine.UbCompat.cs), then a real unknown.
|
||||
_ => TryEvalUbCompat(funcName, rawArgs, A, out string ubValue) ? ubValue : EvalUnknownFunction(funcName)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -3049,7 +3056,7 @@ internal sealed class ExpressionEngine
|
|||
|
||||
DateTime mtime = File.GetLastWriteTime(profilePath);
|
||||
|
||||
// Each pulse: fire MoveItemExternal for the first matching item still in inventory.
|
||||
// Each pulse: give (whole object) the first matching item still in inventory.
|
||||
// We retry the same item until it vanishes from the cache (server confirmed).
|
||||
// Once gone, the next iteration naturally picks up the next item.
|
||||
// Returns 1 while matching items remain, 0 when inventory is clear.
|
||||
|
|
@ -3629,6 +3636,17 @@ internal sealed class ExpressionEngine
|
|||
["CastDispelSelf"] = (() => B(s.CastDispelSelf), v => s.CastDispelSelf = ToDouble(v) != 0),
|
||||
["AutoFellowMgmt"] = (() => B(s.AutoFellowMgmt), v => s.AutoFellowMgmt = ToDouble(v) != 0),
|
||||
["UseRecklessness"] = (() => B(s.UseRecklessness), v => s.UseRecklessness = ToDouble(v) != 0),
|
||||
// The range a monster rule's Variable attack power picks from (percent of the bar).
|
||||
["VariablePowerMin"] = (() => I(s.VariablePowerMin), v => { if (int.TryParse(v, out int i)) s.VariablePowerMin = Math.Clamp(i, 0, 100); }),
|
||||
["VariablePowerMax"] = (() => I(s.VariablePowerMax), v => { if (int.TryParse(v, out int i)) s.VariablePowerMax = Math.Clamp(i, 0, 100); }),
|
||||
// Environment hits: 0 Off, 1 Move closer, 2 New target, 3 Move closer then new target.
|
||||
["MissileEnvironmentResponse"] = (() => I(s.MissileEnvironmentResponse), v => { if (int.TryParse(v, out int i)) s.MissileEnvironmentResponse = Math.Clamp(i, 0, 3); }),
|
||||
["MagicEnvironmentResponse"] = (() => I(s.MagicEnvironmentResponse), v => { if (int.TryParse(v, out int i)) s.MagicEnvironmentResponse = Math.Clamp(i, 0, 3); }),
|
||||
["EnvironmentImpactLimit"] = (() => I(s.EnvironmentImpactLimit), v => { if (int.TryParse(v, out int i)) s.EnvironmentImpactLimit = Math.Clamp(i, 1, 10); }),
|
||||
["EnvironmentImpactWindowSec"] = (() => I(s.EnvironmentImpactWindowSec), v => { if (int.TryParse(v, out int i)) s.EnvironmentImpactWindowSec = Math.Clamp(i, 5, 120); }),
|
||||
["EnvironmentApproachMeters"] = (() => I(s.EnvironmentApproachMeters), v => { if (int.TryParse(v, out int i)) s.EnvironmentApproachMeters = Math.Clamp(i, 1, 30); }),
|
||||
["EnvironmentMinDistance"] = (() => I(s.EnvironmentMinDistance), v => { if (int.TryParse(v, out int i)) s.EnvironmentMinDistance = Math.Clamp(i, 1, 30); }),
|
||||
["EnvironmentSkipSec"] = (() => I(s.EnvironmentSkipSec), v => { if (int.TryParse(v, out int i)) s.EnvironmentSkipSec = Math.Clamp(i, 5, 300); }),
|
||||
["WeaponSwapSettleMs"] = (() => I(s.WeaponSwapSettleMs), v => { if (int.TryParse(v, out int i)) s.WeaponSwapSettleMs = Math.Clamp(i, 0, 3000); }),
|
||||
["WeaponSwapMinHealthPct"] = (() => I(s.WeaponSwapMinHealthPct), v => { if (int.TryParse(v, out int i)) s.WeaponSwapMinHealthPct = Math.Clamp(i, 0, 100); }),
|
||||
["WeaponSwapMinGainPct"] = (() => I(s.WeaponSwapMinGainPct), v => { if (int.TryParse(v, out int i)) s.WeaponSwapMinGainPct = Math.Clamp(i, 0, 200); }),
|
||||
|
|
@ -3665,6 +3683,7 @@ internal sealed class ExpressionEngine
|
|||
["CorpseApproachRangeMin"] = (() => D(s.CorpseApproachRangeMin), v => { if (double.TryParse(v, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out double d)) s.CorpseApproachRangeMin = d; }),
|
||||
["ManaStoneKeepCount"] = (() => I(s.ManaStoneKeepCount), v => { if (int.TryParse(v, out int i)) s.ManaStoneKeepCount = i; }),
|
||||
["RebuffSecondsRemaining"] = (() => I(s.RebuffSecondsRemaining), v => { if (int.TryParse(v, out int i)) s.RebuffSecondsRemaining = i; }),
|
||||
["BlacklistTimeoutSec"] = (() => I(s.BlacklistTimeoutSec), v => { if (double.TryParse(v, NumberStyles.Float, CultureInfo.InvariantCulture, out double d) && d >= 0) s.BlacklistTimeoutSec = (int)Math.Round(d); }),
|
||||
["RebuffTopOffSecondsRemaining"] = (() => I(s.RebuffTopOffSecondsRemaining), v => { if (int.TryParse(v, out int i)) s.RebuffTopOffSecondsRemaining = i; }),
|
||||
["CastBuffsOverItemBuffs"] = (() => B(s.CastBuffsOverItemBuffs), v => s.CastBuffsOverItemBuffs = ToDouble(v) != 0),
|
||||
["FastBuffChain"] = (() => B(s.FastBuffChain), v => s.FastBuffChain = ToDouble(v) != 0),
|
||||
|
|
@ -3722,8 +3741,10 @@ internal sealed class ExpressionEngine
|
|||
CultureInfo.InvariantCulture, out double delayMs))
|
||||
delayMs = 0;
|
||||
long ms = (long)Math.Max(0, delayMs);
|
||||
_delayedExecs.Add((TickMs() + ms, exprArg));
|
||||
return "1";
|
||||
// ub-IT returns the job's id (for clearexec); ids start at 1 so the result stays true.
|
||||
long id = ++_nextDelayedExecId;
|
||||
_delayedExecs.Add((id, TickMs() + ms, exprArg));
|
||||
return id.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1608,7 +1608,9 @@ ITEM GIVING
|
|||
|
||||
actiontrygiveprofile[lootprofile, target]
|
||||
Gives all inventory items matching Keep rules in the specified loot profile to a
|
||||
nearby player or NPC named target.
|
||||
nearby NPC or vendor named target, with AC's give action. Never to a player: a
|
||||
shared meta must not be able to hand your inventory to someone's character.
|
||||
To give to a player, type /ra ig <profile> to <player>.
|
||||
|
||||
Supports both VTank .utl profiles and native RynthAi .json profiles.
|
||||
Profile files are loaded from:
|
||||
|
|
@ -1620,10 +1622,13 @@ actiontrygiveprofile[lootprofile, target]
|
|||
the target was not found in the nearby world, no items matched, or the profile
|
||||
could not be loaded.
|
||||
|
||||
Param #0: lootprofile — filename (or full path) of the loot profile (.utl or .json).
|
||||
Param #0: lootprofile — filename of the loot profile (.utl or .json), inside ItemGiver\
|
||||
(a subfolder of it is fine). Full paths, drive letters, ':' and anything
|
||||
that climbs out with ..\ are refused (logged once, returns "0").
|
||||
Bare names without extension resolve as .utl from ItemGiver\.
|
||||
Regex-escaped dots in UB examples (e.g. salvage\.utl) are just literal dots.
|
||||
Param #1: target — exact name (case-insensitive) of the player or NPC to give to.
|
||||
Param #1: target — exact name (case-insensitive) of the NPC or vendor to give to.
|
||||
A player with that name is skipped.
|
||||
|
||||
Known limitations (TODO):
|
||||
- Currently gives one item per meta pulse. Full rapid-fire batch transfer not yet
|
||||
|
|
@ -1632,10 +1637,10 @@ actiontrygiveprofile[lootprofile, target]
|
|||
all item types correctly (e.g. salvage ObjectClass known issue).
|
||||
- Only .utl and .json profiles are supported; no fallback between profile directories.
|
||||
|
||||
Test in chat: /ra mexec actiontrygiveprofile[salvage.utl,My Salvage Mule]
|
||||
Example: actiontrygiveprofile[salvage.utl,My Salvage Mule]
|
||||
Test in chat: /ra mexec actiontrygiveprofile[salvage.utl,Town Crier]
|
||||
Example: actiontrygiveprofile[salvage.utl,Town Crier]
|
||||
→ "1" if items were given (VTank profile)
|
||||
Example: actiontrygiveprofile[mysalvage.json,My Salvage Mule]
|
||||
Example: actiontrygiveprofile[mysalvage.json,Town Crier]
|
||||
→ "1" if items were given (native JSON profile)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -179,6 +179,15 @@ internal sealed class MetaManager
|
|||
_expressions?.SetKillClock(clock);
|
||||
}
|
||||
|
||||
// Corpses this character opened (the plugin's loot bookkeeping), for ub-IT's
|
||||
// hascorpsebeenopenedbyme[] / getcorpsesunopenedbyme[].
|
||||
private Func<int, bool>? _corpseOpenedByMe;
|
||||
public void SetCorpseOpenedCheck(Func<int, bool>? check)
|
||||
{
|
||||
_corpseOpenedByMe = check;
|
||||
if (_expressions != null) _expressions.CorpseOpenedByMe = check;
|
||||
}
|
||||
|
||||
public void SetPlayerId(uint id)
|
||||
{
|
||||
_playerId = id;
|
||||
|
|
@ -231,6 +240,10 @@ internal sealed class MetaManager
|
|||
engine.SetSettings(_settings);
|
||||
engine.SetCreatureStore(_creatureStore);
|
||||
engine.SetKillClock(_killClock);
|
||||
engine.CorpseOpenedByMe = _corpseOpenedByMe;
|
||||
// vtsetsetting[] / vtgetsetting[] take VTank names and units, as '/vt opt set|get' does.
|
||||
engine.VtOptionSetter = TrySetVtOption;
|
||||
engine.VtOptionGetter = GetVtOption;
|
||||
return engine;
|
||||
}
|
||||
|
||||
|
|
@ -1171,6 +1184,39 @@ internal sealed class MetaManager
|
|||
return true;
|
||||
}
|
||||
|
||||
// /vt e — VTank's macro toggle (ub-IT sends it to switch VTank on or off).
|
||||
if (sub == "e")
|
||||
{
|
||||
_raCommandHandler?.Invoke(_settings.IsMacroRunning ? "/ra stop" : "/ra start");
|
||||
return true;
|
||||
}
|
||||
|
||||
// /vt jump [heading] [shift true|false] [holdms] — VTank's jump (universalremote.met, ub-IT):
|
||||
// RynthAi's jumper through /ra jump[s] [heading] [holdtime].
|
||||
if (sub == "jump")
|
||||
{
|
||||
string heading = parts.Length >= 3 ? parts[2] : "";
|
||||
bool shift = parts.Length >= 4 && (parts[3].Equals("true", StringComparison.OrdinalIgnoreCase) || parts[3] == "1");
|
||||
string hold = parts.Length >= 5 ? parts[4] : "";
|
||||
_raCommandHandler?.Invoke(("/ra jump" + (shift ? "s" : "") + " " + heading + " " + hold).Trim());
|
||||
return true;
|
||||
}
|
||||
|
||||
// /vt tapjump — a quick jump with no charge.
|
||||
if (sub == "tapjump")
|
||||
{
|
||||
if (!(_host.HasTapJump && _host.TapJump()))
|
||||
_host.WriteToChat("[RynthAi] /vt tapjump: the engine's jump isn't available.", 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
// /vt equipitemsfor <monster> — wield what that monster's rule names (weapon, off hand).
|
||||
if (sub == "equipitemsfor" && parts.Length >= 3)
|
||||
{
|
||||
_raCommandHandler?.Invoke("/ra equipfor " + string.Join(" ", parts, 2, parts.Length - 2));
|
||||
return true;
|
||||
}
|
||||
|
||||
// /vt meta load <name> — the same load as /ra meta load (LegacyDashboardRenderer.LoadMetaByName):
|
||||
// a meta in MetaFiles, or, when there is none by that name, a new blank one (2026-10-13).
|
||||
if (sub == "meta" && parts.Length >= 4 &&
|
||||
|
|
@ -1193,8 +1239,8 @@ internal sealed class MetaManager
|
|||
return true;
|
||||
}
|
||||
|
||||
// /vt loot load <name> — load a loot profile
|
||||
if ((sub == "loot" || sub == "lootprofile") && parts.Length >= 4 &&
|
||||
// /vt loot load <name> — load a loot profile ("looting load" too: FoundryIzexi.met, Meta_Society.met)
|
||||
if ((sub == "loot" || sub == "lootprofile" || sub == "looting") && parts.Length >= 4 &&
|
||||
parts[2].Equals("load", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
string name = string.Join(" ", parts, 3, parts.Length - 3).Trim().Trim('"');
|
||||
|
|
@ -1231,8 +1277,20 @@ internal sealed class MetaManager
|
|||
return true;
|
||||
}
|
||||
|
||||
// /vt settings load / loadchar — ignore silently
|
||||
if (sub == "settings") return true;
|
||||
// /vt settings loadchar|savechar <name> — RynthAi's settings profiles (/ra settings ...);
|
||||
// universalremote.met switches profiles this way. Any other /vt settings verb is ignored.
|
||||
if (sub == "settings")
|
||||
{
|
||||
if (parts.Length >= 4 && (parts[2].Equals("loadchar", StringComparison.OrdinalIgnoreCase)
|
||||
|| parts[2].Equals("savechar", StringComparison.OrdinalIgnoreCase)))
|
||||
_raCommandHandler?.Invoke($"/ra settings {parts[2].ToLowerInvariant()} {string.Join(" ", parts, 3, parts.Length - 3)}");
|
||||
return true;
|
||||
}
|
||||
|
||||
// /vt <option> <value> — an option written as a verb (DerethExploration: "/vt navclosestoprange
|
||||
// 0.005"): the same as /vt opt set, for the VTank options RynthAi maps.
|
||||
if (parts.Length == 3 && (VtOptionMap.ContainsKey(sub) || IsSpecialVtOption(sub)))
|
||||
return TrySetVtOption(sub, parts[2]);
|
||||
|
||||
// /vt <verb> aliases → existing /ra handlers (Phase 1.3 VTank-meta migration).
|
||||
// Re-dispatch through the /ra path (_raCommandHandler → HandleRaCommand).
|
||||
|
|
@ -1249,10 +1307,23 @@ internal sealed class MetaManager
|
|||
System.Globalization.CultureInfo.InvariantCulture, out double bar))
|
||||
{
|
||||
int pct = Math.Clamp((int)Math.Round(bar * 100), 0, 100);
|
||||
_lastAttackBarPct = pct;
|
||||
_raCommandHandler?.Invoke("/ra power " + pct.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
return true;
|
||||
}
|
||||
|
||||
// /vt deletemonster (S_Colo, leaving the arena): no RynthAi equivalent is known. Accepted so
|
||||
// it doesn't go on to AC's chat parser as an unknown command; logged once.
|
||||
if (sub == "deletemonster")
|
||||
{
|
||||
if (!_deleteMonsterLogged)
|
||||
{
|
||||
_deleteMonsterLogged = true;
|
||||
RynthLog.Write(LogCat.Meta, "[Meta] /vt deletemonster accepted and ignored (no RynthAi equivalent).");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// /vt reverseroute — reverse the active nav route in place (shared settings;
|
||||
// the engine re-reads CurrentRoute each tick, so the flip takes effect next tick).
|
||||
if (sub == "reverseroute")
|
||||
|
|
@ -1351,15 +1422,143 @@ internal sealed class MetaManager
|
|||
// converts it into FollowNavMin, the nav point reach (see ExpressionEngine).
|
||||
["navclosestoprange"] = "NavCloseStopRange",
|
||||
["follownavmin"] = "FollowNavMin", // RynthAi's own name, yards
|
||||
// 2026-10-17: options the metas in MetaFiles / MetaProfiles set that had no mapping.
|
||||
["navclosetoprange"] = "NavCloseStopRange", // the same option, misspelt in some metas
|
||||
["attackrange"] = "MonsterRange",
|
||||
["ringdistance"] = "RingRange",
|
||||
["minimumringtargets"] = "MinRingTargets",
|
||||
["corpseapproachrange"] = "CorpseApproachRangeMax",
|
||||
["corpseapproachrange-max"] = "CorpseApproachRangeMax",
|
||||
["corpseapproachrange-min"] = "CorpseApproachRangeMin",
|
||||
// 2026-10-18: the sample metas (S_*, Colo) set these and nothing read them.
|
||||
["rebufftimeremainingseconds"] = "RebuffSecondsRemaining", // VTank's spelling (the one above is a typo)
|
||||
["petcustomrange"] = "CustomPetRange", // landblock units -> whole yards
|
||||
["blacklistmonstertimeoutseconds"] = "BlacklistTimeoutSec",
|
||||
};
|
||||
|
||||
/// <summary>VTank options given in landblock units (x240 = yards) whose RynthAi setting is yards.
|
||||
/// NavCloseStopRange converts itself (the settings map takes landblock units).</summary>
|
||||
private static readonly HashSet<string> VtDistanceOptions = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
"attackdistance", "attackrange", "approachdistance", "dooropenrange", "opendoorrange", "ringdistance",
|
||||
"corpseapproachrange", "corpseapproachrange-max", "corpseapproachrange-min", "petcustomrange",
|
||||
};
|
||||
|
||||
/// <summary>RynthAi distance settings kept in whole yards (their setter refuses a decimal).</summary>
|
||||
private static readonly HashSet<string> IntYardSettings = new(StringComparer.Ordinal)
|
||||
{
|
||||
"MonsterRange", "ApproachRange", "RingRange", "CustomPetRange",
|
||||
};
|
||||
|
||||
/// <summary>A RynthAi yards value as VTank's landblock units (yards / 240), for reading a distance back.</summary>
|
||||
internal static string YardsToVtDistance(string yards)
|
||||
{
|
||||
if (!double.TryParse(yards, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out double v))
|
||||
return yards;
|
||||
return (v / 240.0).ToString("0.######", System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A VTank distance as RynthAi yards: a value up to 1 is landblock units (x240; VTank's own
|
||||
/// unit), a larger one is taken as yards already (typed by hand). Invariant culture.
|
||||
/// </summary>
|
||||
internal static string VtDistanceToYards(string value, bool wholeYards)
|
||||
{
|
||||
if (!double.TryParse(value, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out double v))
|
||||
return value; // not a number (an unexpanded expression): left for the setter to refuse
|
||||
double yards = v > 0 && v <= 1.0 ? v * 240.0 : v;
|
||||
return wholeYards
|
||||
? Math.Max(0, (int)Math.Round(yards)).ToString(System.Globalization.CultureInfo.InvariantCulture)
|
||||
: yards.ToString("0.###", System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
/// <summary>VTank options handled by <see cref="TrySetSpecialVtOption"/> (no 1:1 RynthAi setting).</summary>
|
||||
private static bool IsSpecialVtOption(string vtName) => vtName.ToLowerInvariant() is
|
||||
"defaultmeleeattackheight" or "lootfellowcorpses" or "lootallcorpses" or "usearcs" or "minimumhealkitsuccesschance"
|
||||
or "autoattackpower";
|
||||
|
||||
// The last /vt setattackbar power (percent), for AutoAttackPower false after it was on (-1 = none yet).
|
||||
private int _lastAttackBarPct = -1;
|
||||
private bool _deleteMonsterLogged;
|
||||
|
||||
/// <summary>
|
||||
/// The VTank options whose value means something else in RynthAi:
|
||||
/// DefaultMeleeAttackHeight 1-3 (low/medium/high) is RynthAi's 0-2; LootFellowCorpses /
|
||||
/// LootAllCorpses pick the loot-ownership mode (my kills / fellowship / all); UseArcs is a VTank
|
||||
/// mode number (2, 3 in the metas) for RynthAi's on/off; MinimumHealKitSuccessChance is a
|
||||
/// percent (a fraction up to 1 is scaled). False when <paramref name="vtName"/> isn't one of them.
|
||||
/// </summary>
|
||||
private bool TrySetSpecialVtOption(string vtName, string value)
|
||||
{
|
||||
var inv = System.Globalization.CultureInfo.InvariantCulture;
|
||||
bool num = double.TryParse(value, System.Globalization.NumberStyles.Float, inv, out double n);
|
||||
switch (vtName.ToLowerInvariant())
|
||||
{
|
||||
case "defaultmeleeattackheight":
|
||||
if (!num) return true;
|
||||
_settings.MeleeAttackHeight = Math.Clamp((int)Math.Round(n) - 1, 0, 2);
|
||||
return true;
|
||||
case "lootfellowcorpses":
|
||||
if (!num) return true;
|
||||
if (n != 0 && _settings.LootOwnership < 1) _settings.LootOwnership = 1;
|
||||
else if (n == 0 && _settings.LootOwnership == 1) _settings.LootOwnership = 0;
|
||||
return true;
|
||||
case "lootallcorpses":
|
||||
if (!num) return true;
|
||||
if (n != 0) _settings.LootOwnership = 2;
|
||||
else if (_settings.LootOwnership == 2) _settings.LootOwnership = 0;
|
||||
return true;
|
||||
case "usearcs":
|
||||
if (!num) return true;
|
||||
_settings.UseArcs = n != 0;
|
||||
return true;
|
||||
case "minimumhealkitsuccesschance":
|
||||
if (!num) return true;
|
||||
_settings.KitMinSuccessPct = Math.Clamp((int)Math.Round(n > 0 && n <= 1 ? n * 100 : n), 0, 100);
|
||||
return true;
|
||||
case "autoattackpower":
|
||||
// On: RynthAi picks the power itself (-1, its "auto"). Off: the attack bar's value,
|
||||
// the last /vt setattackbar (a power already set by hand stays as it is).
|
||||
if (!num) return true;
|
||||
if (n != 0)
|
||||
{
|
||||
_settings.MeleeAttackPower = _settings.MissileAttackPower = -1;
|
||||
}
|
||||
else if (_settings.MeleeAttackPower < 0 || _settings.MissileAttackPower < 0)
|
||||
{
|
||||
if (_lastAttackBarPct >= 0)
|
||||
_settings.MeleeAttackPower = _settings.MissileAttackPower = _lastAttackBarPct;
|
||||
else
|
||||
RynthLog.Write(LogCat.Meta, "[Meta] AutoAttackPower off with no /vt setattackbar value yet: attack power stays automatic.");
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The special options as VTank reads them back (height 1-3, ownership as two flags).</summary>
|
||||
private string? GetSpecialVtOption(string vtName) => vtName.ToLowerInvariant() switch
|
||||
{
|
||||
"defaultmeleeattackheight" => (_settings.MeleeAttackHeight + 1).ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
"lootfellowcorpses" => _settings.LootOwnership >= 1 ? "true" : "false",
|
||||
"lootallcorpses" => _settings.LootOwnership == 2 ? "true" : "false",
|
||||
"usearcs" => _settings.UseArcs ? "true" : "false",
|
||||
"minimumhealkitsuccesschance" => _settings.KitMinSuccessPct.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
"autoattackpower" => _settings.MeleeAttackPower < 0 ? "true" : "false",
|
||||
_ => null,
|
||||
};
|
||||
|
||||
/// <summary>A VTank option's current value (mapped setting, else a stored generic option).</summary>
|
||||
private string? GetVtOption(string vtName)
|
||||
{
|
||||
if (GetSpecialVtOption(vtName) is string special) return special;
|
||||
var map = Expressions.BuildSettingsMapPublic();
|
||||
if (VtOptionMap.TryGetValue(vtName, out string? raName))
|
||||
{
|
||||
if (map.TryGetValue(raName, out var entry)) return entry.Get();
|
||||
// Distances read back in VTank's landblock units, as they were set (6 yd reads 0.025).
|
||||
if (map.TryGetValue(raName, out var entry))
|
||||
return VtDistanceOptions.Contains(vtName) ? YardsToVtDistance(entry.Get()) : entry.Get();
|
||||
}
|
||||
// A RynthAi setting named directly (EnableCombat, OpenDoors, NavCloseStopRange...).
|
||||
if (map.TryGetValue(vtName, out var direct)) return direct.Get();
|
||||
|
|
@ -1372,6 +1571,15 @@ internal sealed class MetaManager
|
|||
// Translate VTank bool strings to numeric
|
||||
string value = NormalizeVtValue(vtValue);
|
||||
|
||||
// Options whose value means something else in RynthAi (a scale, an offset, a mode).
|
||||
if (TrySetSpecialVtOption(vtName, value)) return true;
|
||||
|
||||
// VTank distances are in landblock units (1 = 240 yd: AttackDistance .01666 is 4 yd); RynthAi's
|
||||
// are yards. Converted here, rounded where RynthAi keeps whole yards (an int setting refused
|
||||
// "0.01666" outright, so every meta's attack / approach distance was dropped).
|
||||
if (VtDistanceOptions.Contains(vtName) && VtOptionMap.TryGetValue(vtName, out string? distName))
|
||||
value = VtDistanceToYards(value, IntYardSettings.Contains(distName));
|
||||
|
||||
var map = Expressions.BuildSettingsMapPublic();
|
||||
if (VtOptionMap.TryGetValue(vtName, out string? raName))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,126 @@
|
|||
// RingChain.cs - Infinite Leaftide's ring inscription chain (Crafting > Rings), from UB-IT's
|
||||
// ImbueSpellCraftDefinitions / SpellcraftInventoryPolicy.
|
||||
//
|
||||
// Step 1: Quill of Infliction used on a Trophy -> Enlightened Quill of Infliction
|
||||
// Step 2: Enlightened Quill used on Ink of Partition -> partition quill
|
||||
// Step 3: partition quill used on a Glyph -> "Inscription of ..." scroll
|
||||
// Then each scroll is used on a ring / jewelry / weapon.
|
||||
//
|
||||
// Pure: ingredient matching (case-insensitive substrings with alternates and one exclude), the
|
||||
// craft queue order and the scroll-to-target pairing. RingChainRunner does the using.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.MiniRemote.Crafting;
|
||||
|
||||
/// <summary>One ingredient: the first of <see cref="Names"/> found in an item's name, unless it also has <see cref="Exclude"/>.</summary>
|
||||
internal sealed record RingIngredient(string Label, string[] Names, string Exclude = "");
|
||||
|
||||
/// <summary>One combine: <see cref="Tool"/> is used on <see cref="Target"/>.</summary>
|
||||
/// <param name="Tier">1 quill + trophy, 2 + ink, 3 + glyph: the queue runs every tier-1 run first.</param>
|
||||
/// <param name="ScrollMarkers">Step 3: the words the resulting inscription scroll's name carries.</param>
|
||||
internal sealed record RingRecipe(string Id, int Tier, string Name, string Notes,
|
||||
RingIngredient Tool, RingIngredient Target, string[] ScrollMarkers);
|
||||
|
||||
internal static class RingChain
|
||||
{
|
||||
/// <summary>Every inscription scroll's name has this.</summary>
|
||||
public const string InscriptionMarker = "Inscription of";
|
||||
/// <summary>Most runs of one recipe the tab queues.</summary>
|
||||
public const int MaxRuns = 99;
|
||||
|
||||
private static readonly RingIngredient PartitionQuill = new("Enlightened Infliction Quill of Partition",
|
||||
new[] { "Enlightened Infliction Quill of Partition", "Enlightened Quill of Infliction of Partition" });
|
||||
|
||||
private static RingRecipe Glyph(string id, string element, string scroll) => new(
|
||||
id, 3, $"Step 3: {element} glyph - {scroll}",
|
||||
$"Partition quill used on Glyph of {element} -> Inscription of {scroll} scroll.",
|
||||
PartitionQuill,
|
||||
// The full glyph name: a short one can match the wrong stack.
|
||||
new RingIngredient($"Glyph of {element}", new[] { $"Glyph of {element}" }),
|
||||
new[] { scroll, element });
|
||||
|
||||
/// <summary>The chain, in UB-IT's order.</summary>
|
||||
public static readonly RingRecipe[] Recipes =
|
||||
{
|
||||
new("ring2_step1_quill_trophy", 1, "Step 1: Quill of Infliction + Trophy",
|
||||
"Quill of Infliction used on a Trophy -> Enlightened Quill of Infliction.",
|
||||
new RingIngredient("Quill of Infliction", new[] { "Quill of Infliction", "Infliction Quill" }, Exclude: "Enlightened"),
|
||||
// Not plain "Trophy": scrolls and kits carry that word too.
|
||||
new RingIngredient("Trophy", new[] { "Royal Summons", "Empyrean Trophy", "Summoning Gem" }),
|
||||
Array.Empty<string>()),
|
||||
new("ring2_step2_ink", 2, "Step 2: Enlightened Quill + Ink of Partition",
|
||||
"Enlightened Quill of Infliction (from Step 1) used on Ink of Partition -> partition quill.",
|
||||
new RingIngredient("Enlightened Quill of Infliction",
|
||||
new[] { "Enlightened Quill of Infliction", "Enlightened Infliction Quill", "Enlightened Infliction Quill of" }, Exclude: "Partition"),
|
||||
new RingIngredient("Ink of Partition", new[] { "Ink of Partition", "Partition Ink" }),
|
||||
Array.Empty<string>()),
|
||||
Glyph("ring2_glyph_bludgeoning", "Bludgeoning", "Tectonic Rifts"),
|
||||
Glyph("ring2_glyph_lightning", "Lightning", "Eye of the Storm"),
|
||||
Glyph("ring2_glyph_piercing", "Piercing", "Nuhmudira's Spines"),
|
||||
Glyph("ring2_glyph_nether", "Nether", "Clouded Soul"),
|
||||
Glyph("ring2_glyph_corrosion", "Corrosion", "Searing Disc"),
|
||||
Glyph("ring2_glyph_frost", "Frost", "Halo of Frost"),
|
||||
Glyph("ring2_glyph_slashing", "Slashing", "Horizon's Blades"),
|
||||
Glyph("ring2_glyph_flame", "Flame", "Cassius' Ring of Fire"),
|
||||
};
|
||||
|
||||
/// <summary>True when an item's name is this ingredient.</summary>
|
||||
public static bool Matches(string? name, RingIngredient ing)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name)) return false;
|
||||
if (ing.Exclude.Length > 0 && name.IndexOf(ing.Exclude, StringComparison.OrdinalIgnoreCase) >= 0) return false;
|
||||
foreach (string n in ing.Names)
|
||||
if (n.Length > 0 && name.IndexOf(n, StringComparison.OrdinalIgnoreCase) >= 0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The craft queue: every Step 1 run, then every Step 2 run, then the glyphs, each tier in
|
||||
/// definition order (a later tier's ingredients come out of the earlier one).
|
||||
/// </summary>
|
||||
public static List<RingRecipe> Expand(Func<string, int> runs)
|
||||
{
|
||||
var queue = new List<RingRecipe>();
|
||||
foreach (var r in Recipes.OrderBy(r => r.Tier))
|
||||
{
|
||||
int n = Math.Clamp(runs(r.Id), 0, MaxRuns);
|
||||
for (int i = 0; i < n; i++) queue.Add(r);
|
||||
}
|
||||
return queue;
|
||||
}
|
||||
|
||||
/// <summary>The glyph recipe a scroll came from (null when its name has no known marker).</summary>
|
||||
public static RingRecipe? GlyphOf(string? scrollName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(scrollName)) return null;
|
||||
foreach (var r in Recipes)
|
||||
foreach (string m in r.ScrollMarkers)
|
||||
if (scrollName.IndexOf(m, StringComparison.OrdinalIgnoreCase) >= 0) return r;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static bool IsInscriptionScroll(string? name)
|
||||
=> !string.IsNullOrEmpty(name) && name.IndexOf(InscriptionMarker, StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
|
||||
/// <summary>
|
||||
/// Pairs scrolls with targets the way UB-IT does: scrolls by glyph recipe id (unknown ones
|
||||
/// last, by name), targets by object id, one scroll per target.
|
||||
/// </summary>
|
||||
public static List<(int Scroll, int Target)> PairScrolls(IEnumerable<(int Id, string Name)> scrolls, IEnumerable<int> targets)
|
||||
{
|
||||
var ordered = scrolls
|
||||
.OrderBy(s => GlyphOf(s.Name)?.Id ?? "zzz_" + s.Name, StringComparer.Ordinal)
|
||||
.ThenBy(s => s.Id)
|
||||
.ToList();
|
||||
var pairs = new List<(int, int)>();
|
||||
int i = 0;
|
||||
foreach (int t in targets.Distinct().OrderBy(x => x))
|
||||
{
|
||||
if (i >= ordered.Count) break;
|
||||
pairs.Add((ordered[i++].Id, t));
|
||||
}
|
||||
return pairs;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,387 @@
|
|||
// RingChainRunner.cs - Crafts Infinite Leaftide's ring inscription chain and applies the scrolls
|
||||
// (Crafting > Rings).
|
||||
//
|
||||
// Pump thread only (the tab's Render reads the volatile snapshots and posts the commands).
|
||||
// Crafting: the queue from RingChain.Expand, one combine at a time:
|
||||
// 1. gates: peace mode (unless the server allows combat crafting), not busy, ActionPacer;
|
||||
// 2. find the tool and the target by name; a later step's ingredients come out of the earlier
|
||||
// combine, so a missing one is looked for again for a while (inventory lag) before giving up;
|
||||
// 3. arm the engine's confirmation answer (Yes: the player queued it) and use tool on target;
|
||||
// 4. the combine is done when the tool or the target stack shrinks or the output shows up.
|
||||
// No sign of it stops the job instead of retrying, so nothing is crafted twice.
|
||||
// Scrolls: each "Inscription of ..." scroll is used on its target (the item selected in AC, or
|
||||
// the last Jewelry / weapon scan's items paired the UB-IT way) and is done when it leaves the pack.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using RynthCore.Loot;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.PluginSdk;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.MiniRemote.Crafting;
|
||||
|
||||
/// <summary>One line of the Rings scan: a recipe header (Found null) or an ingredient.</summary>
|
||||
/// <param name="State">0 found, 1 comes from an earlier step, 2 missing.</param>
|
||||
internal sealed record RingScanLine(string Text, string? Found, int State);
|
||||
|
||||
internal sealed class RingChainRunner
|
||||
{
|
||||
private const uint ErrorYoureTooBusy = 0x1D;
|
||||
private const long StepTimeoutMs = 15_000;
|
||||
/// <summary>The player answers AC's own dialog: give them time.</summary>
|
||||
private const long ManualTimeoutMs = 60_000;
|
||||
private const long StepGapMs = 700;
|
||||
private const long RetryDelayMs = 1_500;
|
||||
private const int MaxBusyRetries = 3;
|
||||
/// <summary>A missing ingredient is looked for this often and this many times (~10 s).</summary>
|
||||
private const long LookAgainMs = 250;
|
||||
private const int LookTries = 40;
|
||||
|
||||
private static readonly Regex CannotUse = new(@"^The .+ cannot be used on the .+\.$", RegexOptions.Compiled | RegexOptions.CultureInvariant);
|
||||
|
||||
private enum Mode { Idle, Craft, Apply }
|
||||
|
||||
private readonly MiniRemoteContext _ctx;
|
||||
/// <summary>True while another crafting job (the tinker runner) owns the pack.</summary>
|
||||
private readonly Func<bool> _blocked;
|
||||
|
||||
// Job (pump thread)
|
||||
private Mode _mode;
|
||||
private List<RingRecipe> _queue = new();
|
||||
private List<(int Scroll, int Target)> _pairs = new();
|
||||
private int _index, _crafted, _lookTries, _busyRetries, _confSeq, _errSeq;
|
||||
private bool _waiting, _manual;
|
||||
private long _stepAt, _nextAt;
|
||||
// Counts before the current combine (craft) / the scroll's stack (apply).
|
||||
private long _toolBefore, _targetBefore, _outputBefore;
|
||||
private int _scrollStackBefore;
|
||||
|
||||
// Render snapshots
|
||||
private volatile string _status = "idle";
|
||||
private volatile RingScanLine[] _scan = Array.Empty<RingScanLine>();
|
||||
private volatile (int Id, string Name)[] _scrolls = Array.Empty<(int, string)>();
|
||||
private volatile bool _running;
|
||||
|
||||
public RingChainRunner(MiniRemoteContext ctx, Func<bool> blocked)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_blocked = blocked;
|
||||
}
|
||||
|
||||
public bool Running => _running;
|
||||
public string Status => _status;
|
||||
public RingScanLine[] ScanLines => _scan;
|
||||
/// <summary>The inscription scrolls the last scan found.</summary>
|
||||
public (int Id, string Name)[] Scrolls => _scrolls;
|
||||
|
||||
private RynthCoreHost Host => _ctx.Host;
|
||||
private MiniRemoteInventory Inv => _ctx.Inventory;
|
||||
private CraftingTabState C => _ctx.State.Crafting;
|
||||
|
||||
private int Runs(string id)
|
||||
{
|
||||
var map = C.RingRuns;
|
||||
lock (map) return map.TryGetValue(id, out int n) ? n : 0;
|
||||
}
|
||||
|
||||
// ── Inventory ───────────────────────────────────────────────────────────
|
||||
|
||||
private IEnumerable<WorldObject> Carried() => Inv.Items().Where(w => !Inv.IsEquipped(w));
|
||||
|
||||
private WorldObject? Find(RingIngredient ing) => Carried().FirstOrDefault(w => RingChain.Matches(w.Name, ing));
|
||||
|
||||
private long Count(RingIngredient ing) => Carried().Where(w => RingChain.Matches(w.Name, ing)).Sum(w => (long)Inv.StackSize(w));
|
||||
|
||||
private long ScrollCount() => Carried().Where(w => RingChain.IsInscriptionScroll(w.Name)).Sum(w => (long)Inv.StackSize(w));
|
||||
|
||||
/// <summary>What a recipe makes, counted: Step 1 the enlightened quill, Step 2 the partition quill, Step 3 a scroll.</summary>
|
||||
private long OutputCount(RingRecipe r) => r.Tier switch
|
||||
{
|
||||
1 => Count(RingChain.Recipes[1].Tool),
|
||||
2 => Count(RingChain.Recipes[2].Tool),
|
||||
_ => ScrollCount(),
|
||||
};
|
||||
|
||||
// ── Scan ────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// Lists every queued recipe's ingredients, marking the ones a later step only gets from an
|
||||
/// earlier combine (UB-IT's "(after Step 1)"), and the carried inscription scrolls.
|
||||
/// </summary>
|
||||
public void Scan()
|
||||
{
|
||||
var lines = new List<RingScanLine>();
|
||||
bool Stocked(int tier) => RingChain.Recipes
|
||||
.Where(r => r.Tier == tier && Runs(r.Id) > 0)
|
||||
.All(r => Find(r.Tool) != null && Find(r.Target) != null);
|
||||
bool tier1 = Stocked(1), tier2 = Stocked(2);
|
||||
bool any = false, blocking = false;
|
||||
foreach (var r in RingChain.Recipes)
|
||||
{
|
||||
int runs = Runs(r.Id);
|
||||
if (runs <= 0) continue;
|
||||
any = true;
|
||||
lines.Add(new RingScanLine($"{r.Name} x{runs}", null, 0));
|
||||
foreach (var ing in new[] { r.Tool, r.Target })
|
||||
{
|
||||
var found = Find(ing);
|
||||
if (found != null) { lines.Add(new RingScanLine(ing.Label, $"{found.Name} ({Count(ing)})", 0)); continue; }
|
||||
string? later = r.Tier == 2 && !tier1 ? "(after Step 1)"
|
||||
: r.Tier == 3 && !tier1 ? "(after Step 1)"
|
||||
: r.Tier == 3 && !tier2 ? "(after Step 2)"
|
||||
: null;
|
||||
if (later == null) blocking = true;
|
||||
lines.Add(new RingScanLine(ing.Label, later ?? "(not found)", later == null ? 2 : 1));
|
||||
}
|
||||
}
|
||||
_scan = lines.ToArray();
|
||||
RefreshScrolls();
|
||||
_status = !any ? "set how many times to craft at least one recipe"
|
||||
: blocking ? "missing ingredients are marked (not found)"
|
||||
: "ready: Create runs every Step 1, then Step 2, then Step 3";
|
||||
}
|
||||
|
||||
private void RefreshScrolls()
|
||||
=> _scrolls = Carried().Where(w => RingChain.IsInscriptionScroll(w.Name))
|
||||
.Select(w => (w.Id, w.Name ?? string.Empty))
|
||||
.OrderBy(s => RingChain.GlyphOf(s.Item2)?.Id ?? "zzz_" + s.Item2, StringComparer.Ordinal)
|
||||
.ToArray();
|
||||
|
||||
// ── Job control ─────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Crafts the queued recipes (pump thread, after the tab's confirm).</summary>
|
||||
public void Create()
|
||||
{
|
||||
if (_running) return;
|
||||
if (_blocked()) { _status = "a tinkering job is running"; return; }
|
||||
var queue = RingChain.Expand(Runs);
|
||||
if (queue.Count == 0) { _status = "set how many times to craft at least one recipe"; return; }
|
||||
Begin(Mode.Craft);
|
||||
_queue = queue;
|
||||
_status = $"crafting {queue.Count} combine(s)";
|
||||
RynthLog.Write(LogCat.Crafting, $"[Crafting] Rings: create, {queue.Count} combine(s)");
|
||||
}
|
||||
|
||||
/// <summary>Uses one scroll on the item selected in AC.</summary>
|
||||
public void ApplyToSelected(int scrollId)
|
||||
{
|
||||
uint sel = Host.GetSelectedItemId();
|
||||
if (sel == 0) { _status = "select the ring or item in AC first"; return; }
|
||||
if (unchecked((int)sel) == scrollId) { _status = "the scroll itself is selected: select the ring or item"; return; }
|
||||
ApplyPairs(new List<(int, int)> { (scrollId, unchecked((int)sel)) });
|
||||
}
|
||||
|
||||
/// <summary>Pairs the carried scrolls with these items (the last Jewelry / weapon scan) and uses them.</summary>
|
||||
public void ApplyToItems(IReadOnlyList<int> targetIds)
|
||||
{
|
||||
RefreshScrolls();
|
||||
if (_scrolls.Length == 0) { _status = "no inscription scroll in the pack (name has \"Inscription of\")"; return; }
|
||||
if (targetIds.Count == 0) { _status = "scan the Jewelry or a Weapons tab first: its items are the targets"; return; }
|
||||
ApplyPairs(RingChain.PairScrolls(_scrolls, targetIds));
|
||||
}
|
||||
|
||||
private void ApplyPairs(List<(int Scroll, int Target)> pairs)
|
||||
{
|
||||
if (_running) return;
|
||||
if (_blocked()) { _status = "a tinkering job is running"; return; }
|
||||
if (pairs.Count == 0) { _status = "nothing to apply"; return; }
|
||||
Begin(Mode.Apply);
|
||||
_pairs = pairs;
|
||||
_status = $"applying {pairs.Count} inscription(s)";
|
||||
RynthLog.Write(LogCat.Crafting, $"[Crafting] Rings: apply {pairs.Count} inscription(s)");
|
||||
}
|
||||
|
||||
private void Begin(Mode mode)
|
||||
{
|
||||
_mode = mode;
|
||||
_index = 0;
|
||||
_crafted = 0;
|
||||
_lookTries = 0;
|
||||
_busyRetries = 0;
|
||||
_waiting = false;
|
||||
_nextAt = 0;
|
||||
_running = true;
|
||||
}
|
||||
|
||||
public void Stop(string why)
|
||||
{
|
||||
if (_waiting && Host.HasConfirmationAnswers) Host.ArmConfirmation(RynthCoreHost.ConfirmationKind.CraftInteraction, 0, 0);
|
||||
_mode = Mode.Idle;
|
||||
_waiting = false;
|
||||
_running = false;
|
||||
_queue = new List<RingRecipe>();
|
||||
_pairs = new List<(int, int)>();
|
||||
_status = why;
|
||||
}
|
||||
|
||||
public void OnLogout()
|
||||
{
|
||||
Stop("idle");
|
||||
_scan = Array.Empty<RingScanLine>();
|
||||
_scrolls = Array.Empty<(int, string)>();
|
||||
}
|
||||
|
||||
// ── Tick (pump thread) ──────────────────────────────────────────────────
|
||||
|
||||
public void Tick(long nowMs)
|
||||
{
|
||||
if (_mode == Mode.Idle) return;
|
||||
if (_waiting) { Wait(nowMs); return; }
|
||||
if (nowMs < _nextAt) return;
|
||||
if (!C.AllowInCombat && !Inv.InPeaceMode) { _status = "waiting for peace mode"; return; }
|
||||
if (Inv.IsBusy) return;
|
||||
if (!ActionPacer.MayStart(Host, "Crafting", HealNeed.None, out string why)) { _status = "waiting: " + why; return; }
|
||||
|
||||
if (_mode == Mode.Craft) NextCombine(nowMs);
|
||||
else NextScroll(nowMs);
|
||||
}
|
||||
|
||||
private void NextCombine(long nowMs)
|
||||
{
|
||||
if (_index >= _queue.Count)
|
||||
{
|
||||
Stop($"done - {_crafted} combine(s)");
|
||||
RefreshScrolls();
|
||||
RynthLog.Write(LogCat.Crafting, $"[Crafting] Rings: done, {_crafted} combine(s)");
|
||||
return;
|
||||
}
|
||||
var r = _queue[_index];
|
||||
var tool = Find(r.Tool);
|
||||
var target = Find(r.Target);
|
||||
if (tool == null || target == null)
|
||||
{
|
||||
string label = tool == null ? r.Tool.Label : r.Target.Label;
|
||||
if (++_lookTries <= LookTries)
|
||||
{
|
||||
_nextAt = nowMs + LookAgainMs;
|
||||
_status = $"{r.Name}: looking for {label}";
|
||||
return;
|
||||
}
|
||||
Stop($"{r.Name}: no {label} in the pack");
|
||||
return;
|
||||
}
|
||||
_lookTries = 0;
|
||||
|
||||
_toolBefore = Count(r.Tool);
|
||||
_targetBefore = Count(r.Target);
|
||||
_outputBefore = OutputCount(r);
|
||||
if (!Use(tool, target, $"Rings: {r.Name} ({_index + 1}/{_queue.Count})"))
|
||||
{
|
||||
Stop($"{r.Name}: the use request didn't go out");
|
||||
return;
|
||||
}
|
||||
string ask = _manual ? " - click Yes in AC's craft dialog" : "";
|
||||
_status = $"{r.Name} ({_index + 1}/{_queue.Count}): {tool.Name} on {target.Name}{ask}";
|
||||
}
|
||||
|
||||
private void NextScroll(long nowMs)
|
||||
{
|
||||
if (_index >= _pairs.Count)
|
||||
{
|
||||
Stop($"done - {_crafted} inscription(s) applied");
|
||||
RefreshScrolls();
|
||||
return;
|
||||
}
|
||||
var (scrollId, targetId) = _pairs[_index];
|
||||
var scroll = Inv.Cache?[scrollId];
|
||||
var target = Inv.Cache?[targetId];
|
||||
if (scroll == null || target == null)
|
||||
{
|
||||
// UB-IT moves on past a pair whose scroll or item is gone.
|
||||
_status = $"inscription {_index + 1}: the scroll or the item is gone - skipped";
|
||||
_index++;
|
||||
_nextAt = nowMs + StepGapMs;
|
||||
return;
|
||||
}
|
||||
if (Inv.IsEquipped(target)) { Stop($"{target.Name} is equipped: take it off to inscribe it"); return; }
|
||||
_scrollStackBefore = Inv.StackSize(scroll);
|
||||
if (!Use(scroll, target, $"Rings: {scroll.Name} on {target.Name}"))
|
||||
{
|
||||
Stop("the use request didn't go out");
|
||||
return;
|
||||
}
|
||||
string ask = _manual ? " - click Yes in AC's dialog" : "";
|
||||
_status = $"inscription {_index + 1}/{_pairs.Count}: {scroll.Name} on {target.Name}{ask}";
|
||||
}
|
||||
|
||||
/// <summary>Arms the dialog answer (Yes: the player asked for this) and uses source on target.</summary>
|
||||
private bool Use(WorldObject source, WorldObject target, string why)
|
||||
{
|
||||
_manual = !(C.AnswerCraftDialog && Host.HasConfirmationAnswers
|
||||
&& Host.ArmConfirmation(RynthCoreHost.ConfirmationKind.CraftInteraction, 0, (int)StepTimeoutMs) == 1);
|
||||
_confSeq = Host.TryGetLastConfirmation(out int cs, out _, out _, out _, out _) ? cs : 0;
|
||||
_errSeq = Host.TryGetLastWeenieError(out int es, out _, out _, out _) ? es : 0;
|
||||
if (!Host.UseOnFor(unchecked((uint)source.Id), unchecked((uint)target.Id), "Crafting", why, UseKind.Asked))
|
||||
{
|
||||
if (!_manual) Host.ArmConfirmation(RynthCoreHost.ConfirmationKind.CraftInteraction, 0, 0);
|
||||
return false;
|
||||
}
|
||||
_waiting = true;
|
||||
_stepAt = Environment.TickCount64;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void Wait(long nowMs)
|
||||
{
|
||||
if (Host.TryGetLastConfirmation(out int seq, out uint type, out int pct, out int outcome, out _)
|
||||
&& seq != _confSeq && type == RynthCoreHost.ConfirmationKind.CraftInteraction)
|
||||
{
|
||||
_confSeq = seq;
|
||||
if (outcome == RynthCoreHost.ConfirmationOutcome.Declined) { Stop("the craft dialog was answered No"); return; }
|
||||
if (outcome is RynthCoreHost.ConfirmationOutcome.Shown or RynthCoreHost.ConfirmationOutcome.SendFailed)
|
||||
{
|
||||
_manual = true;
|
||||
_status = $"click Yes in AC's craft dialog ({(pct >= 0 ? pct + "%" : "chance not shown")})";
|
||||
}
|
||||
}
|
||||
|
||||
if (Host.TryGetLastWeenieError(out int es, out uint error, out _, out _) && es != _errSeq)
|
||||
{
|
||||
_errSeq = es;
|
||||
// Busy: the server did nothing, so the same combine can go again.
|
||||
if (error == ErrorYoureTooBusy && ++_busyRetries <= MaxBusyRetries)
|
||||
{
|
||||
_waiting = false;
|
||||
_nextAt = nowMs + RetryDelayMs;
|
||||
_status = $"server says busy - trying again ({_busyRetries}/{MaxBusyRetries})";
|
||||
return;
|
||||
}
|
||||
Stop($"the server refused it (error 0x{error:X})");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Done()) { Next(nowMs); return; }
|
||||
|
||||
if (nowMs - _stepAt > (_manual ? ManualTimeoutMs : StepTimeoutMs))
|
||||
Stop(_manual ? "no answer to AC's dialog - stopped" : "no result seen - stopped (check the pack before going on)");
|
||||
}
|
||||
|
||||
/// <summary>The current combine or inscription went through.</summary>
|
||||
private bool Done()
|
||||
{
|
||||
if (_mode == Mode.Craft)
|
||||
{
|
||||
var r = _queue[_index];
|
||||
return Count(r.Tool) < _toolBefore || Count(r.Target) < _targetBefore || OutputCount(r) > _outputBefore;
|
||||
}
|
||||
var scroll = Inv.Cache?[_pairs[_index].Scroll];
|
||||
return scroll == null || Inv.StackSize(scroll) < _scrollStackBefore;
|
||||
}
|
||||
|
||||
private void Next(long nowMs)
|
||||
{
|
||||
_waiting = false;
|
||||
_busyRetries = 0;
|
||||
_crafted++;
|
||||
_index++;
|
||||
_nextAt = nowMs + StepGapMs;
|
||||
}
|
||||
|
||||
/// <summary>"cannot be used on" ends the job: the names didn't match what the server expects.</summary>
|
||||
public void OnChat(string text)
|
||||
{
|
||||
if (!_waiting || string.IsNullOrEmpty(text)) return;
|
||||
if (CannotUse.IsMatch(text)) Stop(text);
|
||||
}
|
||||
}
|
||||
|
|
@ -5,11 +5,12 @@
|
|||
// mana / retain. Every retail tinker (imbues too) uses one of the item's 10 tinker slots and the
|
||||
// success chance follows RecipeManager.GetTinkerChance (TinkerMath).
|
||||
//
|
||||
// Server: the connected server's own recipes come from the plugin that owns it (its
|
||||
// "RynthServer.Profile" JSON's "salvage" list, read by FromServerPlugin): a server plugin, or
|
||||
// RynthILT for Infinite Leaftide. Nothing server-specific lives here. Their chances are the
|
||||
// server's: the Crafting runner relies on the confirmation's percent.
|
||||
// The player adds their own rows per world (CraftingTabState.CustomByWorld).
|
||||
// Server: Infinite Leaftide / ACECustom extras, taken from UB-IT (LeaftideImbueHelper): jewelry
|
||||
// rating salvages (Copper, Silver, Green Jade, Tourmaline, Serpentine, Steel), the weapon crit
|
||||
// lines (Yellow Garnet, Turquoise, White Quartz, Abyssal-Touched gems, Tourmaline, Wool), Tiger
|
||||
// Eye on missile weapons and Leather as the post-cap tink. ILT's recipes live in its database,
|
||||
// so their chances are the server's: the Crafting runner relies on the confirmation's percent.
|
||||
// Other custom shards add their own rows per world (CraftingTabState.CustomByWorld).
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using RynthCore.Loot;
|
||||
|
|
@ -25,7 +26,7 @@ internal enum TinkerBench
|
|||
Caster,
|
||||
Jewelry,
|
||||
Items,
|
||||
/// <summary>Trinkets (compass, goggles, scarab...): server salvage, often tier-prepared.</summary>
|
||||
/// <summary>Infinite Leaftide trinkets (compass, goggles, scarab...): tier-prepared salvage.</summary>
|
||||
Trinkets,
|
||||
}
|
||||
|
||||
|
|
@ -34,9 +35,14 @@ internal enum TinkerOrigin
|
|||
{
|
||||
/// <summary>Stock ACE (retail) tinkering.</summary>
|
||||
Retail,
|
||||
/// <summary>Infinite Leaftide / ACECustom recipe.</summary>
|
||||
Server,
|
||||
/// <summary>A row the player added for this server.</summary>
|
||||
Custom,
|
||||
/// <summary>A row the server's own plugin defines (its profile's "salvage" list, ServerPackInfo.Salvage).</summary>
|
||||
/// <summary>
|
||||
/// A row the server's own plugin defines (its profile's "salvage" list, ServerPackInfo.Salvage).
|
||||
/// Kept apart from <see cref="Server"/> so the Leaftide-only planner rules never apply to it.
|
||||
/// </summary>
|
||||
Plugin,
|
||||
}
|
||||
|
||||
|
|
@ -47,24 +53,20 @@ internal enum TinkerKind
|
|||
Tink,
|
||||
/// <summary>One imbue per item (ImbuedEffect): a second imbue of any kind is refused.</summary>
|
||||
Imbue,
|
||||
/// <summary>One application (retain, heritage, a server's flag recipes...).</summary>
|
||||
/// <summary>One application, tracked by its own flag (ILT jewelry ratings, retain...).</summary>
|
||||
Once,
|
||||
}
|
||||
|
||||
/// <summary>One salvage a tab can apply.</summary>
|
||||
/// <param name="Id">MaterialType (131); <see cref="TinkerCatalog.RendId"/> = the weapon's damage-type rend.</param>
|
||||
/// <param name="UsesTinkSlot">Counts toward the 10-tink cap.</param>
|
||||
/// <param name="AppliedInt">An int property of the item: the material is on it when it reads 2 (0 = none).</param>
|
||||
/// <param name="NameMatch">The bag must have this in its name (server bags that share a material id).</param>
|
||||
/// <param name="AppliedInt">ILT flag int: the material is on the item when it reads 2 (0 = none).</param>
|
||||
/// <param name="NameMatch">The bag must have this in its name (ILT bags that share a material id).</param>
|
||||
/// <param name="Order">Apply order (lower first).</param>
|
||||
/// <param name="Prepared">The bag must first be prepared on tier Ammunition: its name then carries the tier.</param>
|
||||
/// <param name="AfterCap">Goes on last, and only once the item's tink slots are full.</param>
|
||||
/// <param name="StackGroup">Rows with the same group share <paramref name="StackCap"/> per item ("" = none).</param>
|
||||
/// <param name="StackCap">The group's combined cap per item.</param>
|
||||
/// <param name="Prepared">The bag must first be prepared on tier Ammunition (ILT trinkets): its name then carries the tier.</param>
|
||||
internal sealed record TinkerMaterial(
|
||||
int Id, string Name, TinkerOrigin Origin, TinkerKind Kind, string Effect, int Order,
|
||||
bool UsesTinkSlot = true, int AppliedInt = 0, string NameMatch = "", int Skill = 0, bool Prepared = false,
|
||||
bool AfterCap = false, string StackGroup = "", int StackCap = 0);
|
||||
bool UsesTinkSlot = true, int AppliedInt = 0, string NameMatch = "", int Skill = 0, bool Prepared = false);
|
||||
|
||||
internal static class TinkerCatalog
|
||||
{
|
||||
|
|
@ -91,9 +93,19 @@ internal static class TinkerCatalog
|
|||
|
||||
public const int Diamond = 20, Ruby = 38, GromnieHide = 54, Pyreal = 62;
|
||||
|
||||
/// <summary>Prepared salvage tiers: the word in the Ammunition's and the prepared bag's name.</summary>
|
||||
// ILT jewelry flag ints (applied = 2).
|
||||
public const int IntJewelCopper = 370, IntJewelGreenJade = 371, IntJewelSerpentine = 372,
|
||||
IntJewelSilver = 374, IntJewelTourmaline = 375, IntJewelSteel = 376;
|
||||
|
||||
// ILT trinket flag ints (applied = 2).
|
||||
public const int IntTrinketDiamond = 384, IntTrinketRuby = 385, IntTrinketGromnie = 386, IntTrinketPyreal = 387;
|
||||
|
||||
/// <summary>Trinket salvage tiers: the word in the Ammunition's and the prepared bag's name.</summary>
|
||||
public static readonly string[] TrinketTiers = { "Minor", "Moderate", "Major" };
|
||||
|
||||
/// <summary>Steel and Serpentine stack on ILT jewelry, at most this many combined.</summary>
|
||||
public const int JewelryStackCap = 10;
|
||||
|
||||
/// <summary>The ordinary tinker slots on an item.</summary>
|
||||
public const int MaxTinks = 10;
|
||||
|
||||
|
|
@ -180,14 +192,66 @@ internal static class TinkerCatalog
|
|||
[TinkerBench.Trinkets] = Array.Empty<TinkerMaterial>(),
|
||||
};
|
||||
|
||||
private static readonly Dictionary<TinkerBench, TinkerMaterial[]> Server = new()
|
||||
{
|
||||
[TinkerBench.Armor] = Array.Empty<TinkerMaterial>(),
|
||||
[TinkerBench.Melee] = new TinkerMaterial[]
|
||||
{
|
||||
new(YellowGarnet, "Yellow Garnet", TinkerOrigin.Server, TinkerKind.Once, "Biting Strike (no tink slot)", 70, UsesTinkSlot: false),
|
||||
new(Turquoise, "Turquoise", TinkerOrigin.Server, TinkerKind.Once, "Crushing Blow (no tink slot)", 80, UsesTinkSlot: false),
|
||||
new(WhiteQuartz, "White Quartz", TinkerOrigin.Server, TinkerKind.Once, "Cleaving (no tink slot)", 90, UsesTinkSlot: false),
|
||||
new(BlackGarnet, "Abyssal-Touched Gems", TinkerOrigin.Server, TinkerKind.Once, "Crit line (bag of Abyssal-Touched Gems)", 100, NameMatch: "Abyssal"),
|
||||
new(Tourmaline, "Tourmaline", TinkerOrigin.Server, TinkerKind.Once, "Crit line (no tink slot)", 104, UsesTinkSlot: false),
|
||||
new(Wool, "Wool", TinkerOrigin.Server, TinkerKind.Once, "Biting Strike (no tink slot)", 108, UsesTinkSlot: false),
|
||||
new(Leather, "Leather", TinkerOrigin.Server, TinkerKind.Once, "100% tink once the 10 ordinary tinks are on", 995, UsesTinkSlot: false),
|
||||
},
|
||||
[TinkerBench.Missile] = new TinkerMaterial[]
|
||||
{
|
||||
new(YellowGarnet, "Yellow Garnet", TinkerOrigin.Server, TinkerKind.Once, "Biting Strike (no tink slot)", 70, UsesTinkSlot: false),
|
||||
new(Turquoise, "Turquoise", TinkerOrigin.Server, TinkerKind.Once, "Crushing Blow (no tink slot)", 80, UsesTinkSlot: false),
|
||||
new(BlackGarnet, "Abyssal-Touched Gems", TinkerOrigin.Server, TinkerKind.Once, "Crit line (bag of Abyssal-Touched Gems)", 100, NameMatch: "Abyssal"),
|
||||
new(Tourmaline, "Tourmaline", TinkerOrigin.Server, TinkerKind.Once, "Crit line (no tink slot)", 104, UsesTinkSlot: false),
|
||||
new(Wool, "Wool", TinkerOrigin.Server, TinkerKind.Once, "Biting Strike (no tink slot)", 108, UsesTinkSlot: false),
|
||||
new(TigerEye, "Tiger Eye", TinkerOrigin.Server, TinkerKind.Tink, "+missile defense bonus", 230),
|
||||
new(Leather, "Leather", TinkerOrigin.Server, TinkerKind.Once, "100% tink once the 10 ordinary tinks are on", 995, UsesTinkSlot: false),
|
||||
},
|
||||
[TinkerBench.Caster] = new TinkerMaterial[]
|
||||
{
|
||||
new(YellowGarnet, "Yellow Garnet", TinkerOrigin.Server, TinkerKind.Once, "Biting Strike (no tink slot)", 70, UsesTinkSlot: false),
|
||||
new(Turquoise, "Turquoise", TinkerOrigin.Server, TinkerKind.Once, "Crushing Blow (no tink slot)", 80, UsesTinkSlot: false),
|
||||
new(Leather, "Leather", TinkerOrigin.Server, TinkerKind.Once, "100% tink once the 10 ordinary tinks are on", 995, UsesTinkSlot: false),
|
||||
},
|
||||
[TinkerBench.Jewelry] = new TinkerMaterial[]
|
||||
{
|
||||
// ILT keeps these in their own ints (370-376) with their own cap, not the 10 tinker slots.
|
||||
new(Silver, "Silver", TinkerOrigin.Server, TinkerKind.Once, "+1 critical damage rating", 10, UsesTinkSlot: false, AppliedInt: IntJewelSilver),
|
||||
new(Copper, "Copper", TinkerOrigin.Server, TinkerKind.Once, "+1 damage rating", 20, UsesTinkSlot: false, AppliedInt: IntJewelCopper),
|
||||
new(GreenJade, "Green Jade", TinkerOrigin.Server, TinkerKind.Once, "+1 damage resist rating", 30, UsesTinkSlot: false, AppliedInt: IntJewelGreenJade),
|
||||
new(Tourmaline, "Tourmaline", TinkerOrigin.Server, TinkerKind.Once, "+1 critical damage resist rating", 40, UsesTinkSlot: false, AppliedInt: IntJewelTourmaline),
|
||||
new(Serpentine, "Serpentine", TinkerOrigin.Server, TinkerKind.Tink, "+1 critical rating (stacks with Steel, 10 max)", 50, UsesTinkSlot: false),
|
||||
new(Steel, "Steel", TinkerOrigin.Server, TinkerKind.Tink, "Steel stack tier (stacks with Serpentine, 10 max)", 60, UsesTinkSlot: false),
|
||||
},
|
||||
[TinkerBench.Items] = Array.Empty<TinkerMaterial>(),
|
||||
// UB-IT LeaftideImbueHelper trinket imbues: Diamond, Ruby, Gromnie Hide, Pyreal, in that order.
|
||||
[TinkerBench.Trinkets] = new TinkerMaterial[]
|
||||
{
|
||||
new(Diamond, "Diamond", TinkerOrigin.Server, TinkerKind.Once, "Trinket tier: Diamond", 10, UsesTinkSlot: false, AppliedInt: IntTrinketDiamond, Prepared: true),
|
||||
new(Ruby, "Ruby", TinkerOrigin.Server, TinkerKind.Once, "Trinket tier: Ruby", 20, UsesTinkSlot: false, AppliedInt: IntTrinketRuby, Prepared: true),
|
||||
new(GromnieHide, "Gromnie Hide", TinkerOrigin.Server, TinkerKind.Once, "Trinket tier: Gromnie Hide", 30, UsesTinkSlot: false, AppliedInt: IntTrinketGromnie, Prepared: true),
|
||||
new(Pyreal, "Pyreal", TinkerOrigin.Server, TinkerKind.Once, "Trinket tier: Pyreal", 40, UsesTinkSlot: false, AppliedInt: IntTrinketPyreal, Prepared: true),
|
||||
},
|
||||
};
|
||||
|
||||
/// <summary>The retail rows of a tab.</summary>
|
||||
public static IReadOnlyList<TinkerMaterial> RetailFor(TinkerBench bench) => Retail[bench];
|
||||
|
||||
/// <summary>The Infinite Leaftide / ACECustom rows of a tab.</summary>
|
||||
public static IReadOnlyList<TinkerMaterial> ServerFor(TinkerBench bench) => Server[bench];
|
||||
|
||||
/// <summary>
|
||||
/// A server plugin's salvage rows for one tab (its profile's "salvage" list). Rows for other
|
||||
/// tabs, unknown tab names and unknown kinds are left out. A row's own "order" decides where it
|
||||
/// runs; without one, imbues run before tinks and one-application rows after them, each in the
|
||||
/// plugin's list order.
|
||||
/// tabs, unknown tab names and unknown kinds are left out; imbues run before tinks, and
|
||||
/// one-application rows after them, each in the plugin's own order.
|
||||
/// </summary>
|
||||
public static List<TinkerMaterial> FromServerPlugin(TinkerBench bench, IEnumerable<RynthCore.Plugin.Shared.ServerSalvageView>? salvage)
|
||||
{
|
||||
|
|
@ -212,23 +276,18 @@ internal static class TinkerCatalog
|
|||
TinkerKind.Once => 600,
|
||||
_ => 400,
|
||||
} + i++;
|
||||
if (s.Order != 0) order = s.Order;
|
||||
string group = s.StackCap > 0 ? (s.StackGroup ?? string.Empty).Trim() : string.Empty;
|
||||
rows.Add(new TinkerMaterial(s.Material, MaterialName(s.Material), TinkerOrigin.Plugin, kind.Value,
|
||||
string.IsNullOrWhiteSpace(s.Effect) ? "server recipe" : s.Effect.Trim(), order,
|
||||
UsesTinkSlot: s.UsesTinkSlot, AppliedInt: s.AppliedInt, NameMatch: s.NameMatch ?? string.Empty,
|
||||
Prepared: s.Prepared, AfterCap: s.AfterCap, StackGroup: group, StackCap: group.Length > 0 ? s.StackCap : 0));
|
||||
UsesTinkSlot: s.UsesTinkSlot, NameMatch: s.NameMatch ?? string.Empty));
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Settings key for a row: retail and server rows of one tab share ids (Wool, Steel...). Keys
|
||||
/// with the old "s" prefix (RynthAi's own Leaftide rows before they moved to RynthILT) match no row.
|
||||
/// </summary>
|
||||
/// <summary>Settings key for a row: retail and server rows of one tab share ids (Wool, Steel...).</summary>
|
||||
public static string Key(TinkerMaterial m) => m.Origin switch
|
||||
{
|
||||
TinkerOrigin.Retail => "r" + m.Id,
|
||||
TinkerOrigin.Server => "s" + m.Id,
|
||||
TinkerOrigin.Plugin => "p" + m.Id,
|
||||
_ => "c" + m.Id,
|
||||
};
|
||||
|
|
@ -247,8 +306,8 @@ internal static class TinkerCatalog
|
|||
};
|
||||
|
||||
/// <summary>
|
||||
/// Trinkets (compass, goggles, scarab, watch, puzzle box, tops) are jewelry the Jewelry tab
|
||||
/// leaves alone: they take the Trinkets tab's recipes instead (UB-IT IsLeaftideTrinketJewelry).
|
||||
/// ILT trinkets (compass, goggles, scarab, watch, puzzle box, tops) are jewelry the Jewelry
|
||||
/// tab leaves alone: they take the trinket recipes instead (UB-IT IsLeaftideTrinketJewelry).
|
||||
/// </summary>
|
||||
public static bool IsTrinket(string name)
|
||||
{
|
||||
|
|
@ -301,7 +360,7 @@ internal static class TinkerCatalog
|
|||
};
|
||||
}
|
||||
|
||||
/// <summary>The rend gem a Foolproof bag's name advertises (server bags may not set Material), else 0.</summary>
|
||||
/// <summary>The rend gem a Foolproof bag's name advertises (ILT bags may not set Material), else 0.</summary>
|
||||
public static int RendFromFoolproofName(string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name) || name.IndexOf("Foolproof", StringComparison.OrdinalIgnoreCase) < 0) return 0;
|
||||
|
|
|
|||
|
|
@ -2,17 +2,17 @@
|
|||
//
|
||||
// Pure: the scan reads the item into TinkerItemFacts and the runner re-plans from fresh facts,
|
||||
// so these rules are the only place the apply order and caps live (and the host tests drive
|
||||
// them directly). Server rows say which rules apply to them (TinkerMaterial, from the server
|
||||
// plugin's profile); nothing here knows a server:
|
||||
// * rows run in TinkerMaterial.Order (imbues and server crit lines before stat tinks; with
|
||||
// them directly):
|
||||
// * rows run in TinkerMaterial.Order (imbues and ILT crit lines before stat tinks; with
|
||||
// "rend last" the rend moves to the end, the way UB-IT's foolproof-rend option does);
|
||||
// * a tink-slot row is cut to the free slots (10 minus the item's tinks); no-slot rows aren't;
|
||||
// * a tink-slot row is cut to the free slots (10 minus the item's tinks); ILT's no-slot
|
||||
// salvages aren't;
|
||||
// * one imbue per item (the item's own, or the first planned one);
|
||||
// * a row with an applied int is skipped once that int reads 2 on the item;
|
||||
// * rows of one stack group stop at the group's cap combined;
|
||||
// * an after-cap row goes on last, once, and only when the tink slots are full;
|
||||
// * a prepared row needs a bag prepared at the chosen tier (its name says Minor, Moderate or
|
||||
// Major); a raw bag becomes one on that tier's Ammunition.
|
||||
// * an ILT flag row (jewelry Copper...) is skipped once its flag reads 2;
|
||||
// * ILT jewelry Steel + Serpentine stop at 10 combined;
|
||||
// * ILT Leather on a weapon goes on once, after the 10 ordinary tinks are on;
|
||||
// * an ILT trinket salvage needs a bag prepared at the chosen tier (its name says Minor,
|
||||
// Moderate or Major); a raw bag becomes one on that tier's Ammunition.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
@ -39,7 +39,7 @@ internal sealed class TinkerItemFacts
|
|||
/// <summary>ItemMaxMana (108).</summary>
|
||||
public int MaxMana;
|
||||
public bool Equipped;
|
||||
/// <summary>Reads an int property of the item (a row's applied int: 2 = that salvage is on).</summary>
|
||||
/// <summary>Reads an ILT flag int (370-376); 2 = that salvage is on.</summary>
|
||||
public Func<int, int> FlagInt = _ => 0;
|
||||
}
|
||||
|
||||
|
|
@ -51,9 +51,16 @@ internal readonly record struct TinkerBagChoice(int Id, double Workmanship, doub
|
|||
|
||||
internal static class TinkerPlanner
|
||||
{
|
||||
/// <summary>
|
||||
/// The rows a tab offers on this world: retail, the server's (ILT-like worlds) and the
|
||||
/// player's custom rows for this world.
|
||||
/// </summary>
|
||||
public static List<TinkerMaterial> Rows(TinkerBench bench, bool iltWorld, IEnumerable<CustomTinker>? custom)
|
||||
=> Rows(bench, iltWorld ? TinkerCatalog.ServerFor(bench) : null, custom);
|
||||
|
||||
/// <summary>
|
||||
/// The rows a tab offers: retail, then <paramref name="server"/> (the connected server's own
|
||||
/// salvage, from the plugin that owns it), then the player's custom rows.
|
||||
/// salvage: RynthAi's Leaftide rows on ILT, or the server plugin's), then the player's custom rows.
|
||||
/// </summary>
|
||||
public static List<TinkerMaterial> Rows(TinkerBench bench, IEnumerable<TinkerMaterial>? server, IEnumerable<CustomTinker>? custom)
|
||||
{
|
||||
|
|
@ -91,8 +98,8 @@ internal static class TinkerPlanner
|
|||
/// <summary>
|
||||
/// The ordered steps for one item (empty when nothing ticked applies).
|
||||
/// <paramref name="attempted"/> is how many times this run already tried a row key on the
|
||||
/// item: the item's tinks count failures too, but no-slot server rows and the ticked counts
|
||||
/// don't show on it, so a re-plan would otherwise repeat them.
|
||||
/// item: the item's tinks count failures too, but ILT rows and the ticked counts don't show
|
||||
/// on it, so a re-plan would otherwise repeat them.
|
||||
/// </summary>
|
||||
public static List<TinkerStep> Plan(TinkerBench bench, TinkerItemFacts item, TinkerBenchSettings s,
|
||||
IReadOnlyList<TinkerMaterial> rows, Func<string, int>? attempted = null)
|
||||
|
|
@ -100,8 +107,9 @@ internal static class TinkerPlanner
|
|||
var steps = new List<TinkerStep>();
|
||||
int free = Math.Max(0, TinkerCatalog.MaxTinks - item.Tinks);
|
||||
bool imbueTaken = item.Imbued;
|
||||
Dictionary<string, int>? stacked = null;
|
||||
List<TinkerStep>? afterCap = null;
|
||||
int jewelryStack = 0;
|
||||
TinkerStep? leatherLast = null;
|
||||
bool weapon = bench is TinkerBench.Melee or TinkerBench.Missile or TinkerBench.Caster;
|
||||
|
||||
foreach (var row in rows.OrderBy(r => OrderOf(r, s)))
|
||||
{
|
||||
|
|
@ -121,16 +129,15 @@ internal static class TinkerPlanner
|
|||
imbueTaken = true;
|
||||
}
|
||||
if (row.AppliedInt != 0 && item.FlagInt(row.AppliedInt) == 2) continue;
|
||||
if (row.StackGroup.Length > 0 && row.StackCap > 0)
|
||||
if (bench == TinkerBench.Jewelry && row.Origin == TinkerOrigin.Server
|
||||
&& material is TinkerCatalog.Steel or TinkerCatalog.Serpentine)
|
||||
{
|
||||
stacked ??= new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||
int used = stacked.TryGetValue(row.StackGroup, out int u) ? u : 0;
|
||||
n = Math.Min(n, row.StackCap - used);
|
||||
stacked[row.StackGroup] = used + Math.Max(0, n);
|
||||
n = Math.Min(n, TinkerCatalog.JewelryStackCap - jewelryStack);
|
||||
jewelryStack += Math.Max(0, n);
|
||||
}
|
||||
if (row.AfterCap)
|
||||
if (weapon && row.Origin == TinkerOrigin.Server && material == TinkerCatalog.Leather)
|
||||
{
|
||||
(afterCap ??= new List<TinkerStep>()).Add(new TinkerStep(row, material));
|
||||
leatherLast = new TinkerStep(row, material);
|
||||
continue;
|
||||
}
|
||||
if (row.UsesTinkSlot)
|
||||
|
|
@ -140,7 +147,7 @@ internal static class TinkerPlanner
|
|||
}
|
||||
for (int i = 0; i < n; i++) steps.Add(new TinkerStep(row, material));
|
||||
}
|
||||
if (afterCap != null && free == 0) steps.AddRange(afterCap);
|
||||
if (leatherLast is TinkerStep leather && free == 0) steps.Add(leather);
|
||||
return steps;
|
||||
}
|
||||
|
||||
|
|
@ -158,7 +165,7 @@ internal static class TinkerPlanner
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether a salvage bag can serve a step: a full bag (100 units) of the material, server bags
|
||||
/// Whether a salvage bag can serve a step: a full bag (100 units) of the material, ILT bags
|
||||
/// matched by name (Abyssal-Touched Gems share Black Garnet's id, Foolproof rend bags may not
|
||||
/// carry a material at all).
|
||||
/// </summary>
|
||||
|
|
@ -176,7 +183,7 @@ internal static class TinkerPlanner
|
|||
return step.Row.Id == TinkerCatalog.RendId && TinkerCatalog.RendFromFoolproofName(bagName) == step.Material;
|
||||
}
|
||||
|
||||
/// <summary>The prepared tier a name carries (0 Minor, 1 Moderate, 2 Major), else -1.</summary>
|
||||
/// <summary>The trinket tier a name carries (0 Minor, 1 Moderate, 2 Major), else -1.</summary>
|
||||
public static int TierOf(string name)
|
||||
{
|
||||
name ??= string.Empty;
|
||||
|
|
@ -185,11 +192,11 @@ internal static class TinkerPlanner
|
|||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>A full, not yet prepared bag of a prepared row's salvage (no tier in its name).</summary>
|
||||
/// <summary>A full, not yet prepared bag of a trinket salvage (no tier in its name).</summary>
|
||||
public static bool IsRawTrinketBag(int material, string bagName, int bagMaterial, int bagUses)
|
||||
=> bagUses >= 100 && bagMaterial == material && TierOf(bagName) < 0;
|
||||
|
||||
/// <summary>The Ammunition that prepares a raw bag into a tier bag.</summary>
|
||||
/// <summary>The Ammunition that prepares a raw trinket bag into a tier bag.</summary>
|
||||
public static bool IsTierAmmunition(string name, int tier)
|
||||
=> (name ?? string.Empty).IndexOf("Ammunition", StringComparison.OrdinalIgnoreCase) >= 0
|
||||
&& TierOf(name!) == Math.Clamp(tier, 0, TinkerCatalog.TrinketTiers.Length - 1);
|
||||
|
|
|
|||
|
|
@ -11,11 +11,10 @@
|
|||
// confirmation, "cannot be used on", or a WeenieError (YoureTooBusy retries).
|
||||
// Without the v81 engine (or with dialog answering off) AC shows its own dialog and the player
|
||||
// clicks it; the runner waits longer for that.
|
||||
// Prepared rows (a server's trinket salvage): with no bag prepared at the chosen tier, a raw bag
|
||||
// is first used on that tier's Ammunition (UB-IT's "prep salvage") and the step runs once the
|
||||
// prepared bag shows up.
|
||||
// Items a run finished are left out of later scans this session, so server rows that don't show
|
||||
// on the item aren't applied twice and "auto next batch" moves on to the next items.
|
||||
// Trinkets: with no bag prepared at the chosen tier, a raw bag is first used on that tier's
|
||||
// Ammunition (UB-IT's "prep salvage") and the step runs once the prepared bag shows up.
|
||||
// Items a run finished are left out of later scans this session, so ILT rows that don't show on
|
||||
// the item aren't applied twice and "auto next batch" moves on to the next items.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
@ -56,7 +55,7 @@ internal sealed class TinkerRunner
|
|||
private const int MaxRetries = 3;
|
||||
/// <summary>Appraisal requests one scan may send (the Items tab sees the whole pack).</summary>
|
||||
private const int MaxAppraisalsPerScan = 25;
|
||||
/// <summary>UB-IT polls up to ~30 s for the prepared bag.</summary>
|
||||
/// <summary>UB-IT polls up to ~30 s for the prepared trinket bag.</summary>
|
||||
private const long PrepTimeoutMs = 30_000;
|
||||
/// <summary>Auto next batch: re-scan while items are still being appraised, this often and this many times.</summary>
|
||||
private const long AutoRescanDelayMs = 3_000;
|
||||
|
|
@ -89,7 +88,7 @@ internal sealed class TinkerRunner
|
|||
private bool _manual;
|
||||
private long _stepAt, _nextAt;
|
||||
private Dictionary<int, TinkerRow> _byId = new();
|
||||
/// <summary>The wait is for a bag being prepared, not a tinker.</summary>
|
||||
/// <summary>The wait is for a trinket bag being prepared, not a tinker.</summary>
|
||||
private bool _prep;
|
||||
private int _prepsThisItem;
|
||||
/// <summary>Bags this batch used up (auto next batch stops after a batch that used none).</summary>
|
||||
|
|
@ -117,6 +116,8 @@ internal sealed class TinkerRunner
|
|||
/// <summary>A job is on (set by Start, cleared by Stop: the queue empties before the batch-done step runs).</summary>
|
||||
public bool Running => _active;
|
||||
private volatile bool _active;
|
||||
/// <summary>True while another crafting job (the Rings chain) owns the pack.</summary>
|
||||
public Func<bool> Blocked { get; set; } = () => false;
|
||||
public TinkerBench Bench => _bench;
|
||||
public string Status => _status;
|
||||
/// <summary>The last scan's rows (for <see cref="ScannedBench"/>).</summary>
|
||||
|
|
@ -238,6 +239,7 @@ internal sealed class TinkerRunner
|
|||
public void Start(TinkerBench bench)
|
||||
{
|
||||
if (Running) return;
|
||||
if (Blocked()) { _status = "the Rings chain is running"; return; }
|
||||
if (_scannedBench != (int)bench || _scan.Length == 0) { _status = "scan first"; return; }
|
||||
_bench = bench;
|
||||
_queue.Clear();
|
||||
|
|
@ -434,7 +436,7 @@ internal sealed class TinkerRunner
|
|||
_status = $"{facts.Name}: applying {_bagName}{pctText}{ask}";
|
||||
}
|
||||
|
||||
/// <summary>The full bags that can serve a step (prepared rows: prepared at the chosen tier).</summary>
|
||||
/// <summary>The full bags that can serve a step (trinket steps: prepared at the chosen tier).</summary>
|
||||
private List<WorldObject> BagsFor(TinkerStep step)
|
||||
=> Inv.Items()
|
||||
.Where(b => b.ObjectClass == AcObjectClass.Salvage
|
||||
|
|
@ -442,7 +444,7 @@ internal sealed class TinkerRunner
|
|||
.ToList();
|
||||
|
||||
/// <summary>
|
||||
/// No prepared bag: use a raw one on the tier's Ammunition (UB-IT's prep). The wait
|
||||
/// No prepared trinket bag: use a raw one on the tier's Ammunition (UB-IT's prep). The wait
|
||||
/// ends when a prepared bag shows up; the next tick then applies it.
|
||||
/// </summary>
|
||||
private void Prepare(long nowMs, TinkerStep step, string key, string matName)
|
||||
|
|
@ -464,7 +466,7 @@ internal sealed class TinkerRunner
|
|||
_step = step;
|
||||
_prep = true;
|
||||
if (!Host.UseOnFor(unchecked((uint)raw.Id), unchecked((uint)ammo.Id), "Crafting",
|
||||
$"{TinkerCatalog.Label(_bench)}: prepare {matName} on {ammo.Name}", UseKind.Asked))
|
||||
$"Trinkets: prepare {matName} on {ammo.Name}", UseKind.Asked))
|
||||
{
|
||||
if (!_manual) Host.ArmConfirmation(RynthCoreHost.ConfirmationKind.CraftInteraction, 0, 0);
|
||||
Retry(nowMs, "the prepare request didn't go out");
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
// CraftingTab.cs - The Mini Remote's universal "Crafting" tab (every world, like Quests and Pets).
|
||||
//
|
||||
// UB-IT's crafting benches, one sub-tab each: Armor, Weapons (Melee / Missile / Caster),
|
||||
// Jewelry, Trinkets and Items tinkering. (Infinite Leaftide's own crafting - chunking / clap,
|
||||
// split arrows, the Rings inscription chain - belongs in RynthILT.) Every tinker tab has two
|
||||
// sections:
|
||||
// Jewelry, Trinkets and Items tinkering, and the Rings inscription chain. (Infinite Leaftide's
|
||||
// chunking / clap and split-arrow tools stay on RynthILT's Gear tab.) Every tinker tab has
|
||||
// two sections:
|
||||
// * Retail tinkering - stock ACE salvage (TinkerCatalog.Retail), chance from TinkerMath;
|
||||
// * Server tinkering - the connected server's own salvage, from the plugin that owns it (its
|
||||
// "RynthServer.Profile" JSON's "salvage" list, MiniRemoteContext.ServerSalvage; RynthILT's on
|
||||
// Infinite Leaftide), then the player's own rows for this world (CraftingTabState.CustomByWorld).
|
||||
// With none defined it says so.
|
||||
// One TinkerRunner works one tab's scan at a time.
|
||||
// * Server tinkering - the connected server's own salvage: RynthAi's built-in rows on
|
||||
// Infinite Leaftide, otherwise the active server plugin's (its profile's "salvage" list,
|
||||
// MiniRemoteContext.ServerSalvage), then the player's own rows for this world
|
||||
// (CraftingTabState.CustomByWorld). With none defined it says so.
|
||||
// One TinkerRunner works one tab's scan at a time; the RingChainRunner and it never run together.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
@ -25,6 +25,7 @@ internal sealed class CraftingTab
|
|||
private readonly MiniRemoteContext _ctx;
|
||||
|
||||
public TinkerRunner Runner { get; }
|
||||
public RingChainRunner Rings { get; }
|
||||
|
||||
// Custom-row editor (render thread only)
|
||||
private int _newMaterial = TinkerCatalog.Steel;
|
||||
|
|
@ -39,6 +40,8 @@ internal sealed class CraftingTab
|
|||
{
|
||||
_ctx = ctx;
|
||||
Runner = new TinkerRunner(ctx, RowsFor, SettingsFor);
|
||||
Rings = new RingChainRunner(ctx, () => Runner.Running);
|
||||
Runner.Blocked = () => Rings.Running;
|
||||
}
|
||||
|
||||
private CraftingTabState C => _ctx.State.Crafting;
|
||||
|
|
@ -69,20 +72,35 @@ internal sealed class CraftingTab
|
|||
private IReadOnlyList<TinkerMaterial> RowsFor(TinkerBench bench)
|
||||
=> TinkerPlanner.Rows(bench, ServerRowsFor(bench), CustomRows());
|
||||
|
||||
/// <summary>The connected server's own salvage for a bench: what its plugin's profile defines.</summary>
|
||||
/// <summary>
|
||||
/// The connected server's own salvage for a bench: RynthAi's built-in rows on Infinite Leaftide
|
||||
/// (RynthILT says so), otherwise what the active server plugin's profile defines.
|
||||
/// </summary>
|
||||
private IReadOnlyList<TinkerMaterial> ServerRowsFor(TinkerBench bench)
|
||||
=> TinkerCatalog.FromServerPlugin(bench, _ctx.ServerSalvage);
|
||||
=> _ctx.Ilt.IsIltWorld ? TinkerCatalog.ServerFor(bench) : TinkerCatalog.FromServerPlugin(bench, _ctx.ServerSalvage);
|
||||
|
||||
/// <summary>The connected server defines salvage for at least one bench.</summary>
|
||||
private bool ServerHasSalvage => _ctx.ServerSalvage.Count > 0;
|
||||
private bool ServerHasSalvage => _ctx.Ilt.IsIltWorld || _ctx.ServerSalvage.Count > 0;
|
||||
|
||||
// ── Lifecycle (MiniRemoteController) ─────────────────────────────────────────────────────────
|
||||
|
||||
public void Tick(long nowMs) => Runner.Tick(nowMs);
|
||||
public void Tick(long nowMs)
|
||||
{
|
||||
Runner.Tick(nowMs);
|
||||
Rings.Tick(nowMs);
|
||||
}
|
||||
|
||||
public void OnChat(string text) => Runner.OnChat(text);
|
||||
public void OnChat(string text)
|
||||
{
|
||||
Runner.OnChat(text);
|
||||
Rings.OnChat(text);
|
||||
}
|
||||
|
||||
public void OnLogout() => Runner.OnLogout();
|
||||
public void OnLogout()
|
||||
{
|
||||
Runner.OnLogout();
|
||||
Rings.OnLogout();
|
||||
}
|
||||
|
||||
// ── UI (render thread) ──────────────────────────────────────────────────
|
||||
|
||||
|
|
@ -103,13 +121,26 @@ internal sealed class CraftingTab
|
|||
}
|
||||
if (ImGui.BeginTabItem("Jewelry")) { RenderBench(TinkerBench.Jewelry); ImGui.EndTabItem(); }
|
||||
if (ImGui.BeginTabItem("Trinkets")) { RenderBench(TinkerBench.Trinkets); ImGui.EndTabItem(); }
|
||||
if (ImGui.BeginTabItem("Rings"))
|
||||
{
|
||||
IltOnlyNote();
|
||||
RenderRings();
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
if (ImGui.BeginTabItem("Items")) { RenderBench(TinkerBench.Items); ImGui.EndTabItem(); }
|
||||
ImGui.EndTabBar();
|
||||
}
|
||||
|
||||
private void IltOnlyNote()
|
||||
{
|
||||
if (!_ctx.Ilt.IsIltWorld)
|
||||
ImGui.TextColored(LegacyDashboardRenderer.ColAmber, "Infinite Leaftide recipes: this server may not have them.");
|
||||
}
|
||||
|
||||
private void RenderBench(TinkerBench bench)
|
||||
{
|
||||
var s = SettingsFor(bench);
|
||||
bool ilt = _ctx.Ilt.IsIltWorld;
|
||||
string world = _ctx.WorldName;
|
||||
bool weapon = bench is TinkerBench.Melee or TinkerBench.Missile or TinkerBench.Caster;
|
||||
ImGui.PushID((int)bench);
|
||||
|
|
@ -133,8 +164,8 @@ internal sealed class CraftingTab
|
|||
if (serverRows.Count > 0)
|
||||
{
|
||||
RenderRows(s, serverRows, "server");
|
||||
if (serverRows.Any(r => !r.UsesTinkSlot && r.AppliedInt == 0))
|
||||
ImGui.TextDisabled("Rows without a tink slot don't show on the item: a run applies each once, and items\n"
|
||||
if (ilt && weapon)
|
||||
SafeImGui.TextDisabled("These weapon lines don't show on the item: a run applies each once, and items\n"
|
||||
+ "finished this session are left out of later scans (Forget brings them back).");
|
||||
}
|
||||
else if (ServerHasSalvage)
|
||||
|
|
@ -178,7 +209,7 @@ internal sealed class CraftingTab
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>Trinkets: the prepared salvage tier and whether to prepare raw bags on the tier's Ammunition.</summary>
|
||||
/// <summary>Trinkets: the salvage tier and whether to prepare raw bags on the tier's Ammunition.</summary>
|
||||
private void RenderTrinketOptions()
|
||||
{
|
||||
int tier = Math.Clamp(C.TrinketTier, 0, TinkerCatalog.TrinketTiers.Length - 1);
|
||||
|
|
@ -253,7 +284,7 @@ internal sealed class CraftingTab
|
|||
if (world.Length == 0) { ImGui.TextDisabled("Log in to add rows for this server."); return; }
|
||||
|
||||
var mine = CustomRows().Where(c => c.Bench == (int)bench).ToList();
|
||||
var rows = TinkerPlanner.Rows(bench, null, mine).Where(r => r.Origin == TinkerOrigin.Custom).ToList();
|
||||
var rows = TinkerPlanner.Rows(bench, false, mine).Where(r => r.Origin == TinkerOrigin.Custom).ToList();
|
||||
if (rows.Count == 0) ImGui.TextDisabled("None yet.");
|
||||
for (int i = 0; i < rows.Count; i++)
|
||||
{
|
||||
|
|
@ -370,7 +401,7 @@ internal sealed class CraftingTab
|
|||
if (ImGui.SmallButton("Forget")) _ctx.Post(() => Runner.ForgetDone(bench));
|
||||
ImGui.EndDisabled();
|
||||
if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled))
|
||||
ImGui.SetTooltip("Let finished items show in scans again (server rows that don't show on the item could go on twice).");
|
||||
ImGui.SetTooltip("Let finished items show in scans again (Leaftide lines that don't show on the item could go on twice).");
|
||||
}
|
||||
|
||||
bool running = Runner.Running;
|
||||
|
|
@ -378,7 +409,7 @@ internal sealed class CraftingTab
|
|||
ImGui.BeginDisabled(running);
|
||||
if (ImGui.Button("Scan")) _ctx.Post(() => Runner.Scan(bench));
|
||||
ImGui.SameLine();
|
||||
ImGui.BeginDisabled(!mine || Runner.Rows.Length == 0);
|
||||
ImGui.BeginDisabled(!mine || Runner.Rows.Length == 0 || Rings.Running);
|
||||
if (ImGui.Button("Start"))
|
||||
{
|
||||
int n = Runner.Rows.Length;
|
||||
|
|
@ -398,6 +429,8 @@ internal sealed class CraftingTab
|
|||
ImGui.SameLine();
|
||||
if (running && Runner.Bench != bench)
|
||||
SafeImGui.TextColored(LegacyDashboardRenderer.ColAmber, $"{TinkerCatalog.Label(Runner.Bench)} is running");
|
||||
else if (Rings.Running)
|
||||
ImGui.TextColored(LegacyDashboardRenderer.ColAmber, "the Rings chain is running");
|
||||
else
|
||||
SafeImGui.TextDisabled(Runner.Status);
|
||||
|
||||
|
|
@ -431,4 +464,125 @@ internal sealed class CraftingTab
|
|||
}
|
||||
ImGui.EndTable();
|
||||
}
|
||||
|
||||
// ── Rings ───────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>The ring inscription chain: runs per recipe, Scan / Create / Stop, then the scrolls.</summary>
|
||||
private void RenderRings()
|
||||
{
|
||||
ImGui.TextDisabled("Quill of Infliction -> Enlightened Quill -> partition quill -> glyph -> Inscription scroll -> ring.");
|
||||
if (ImGui.BeginTable("##ringrecipes", 2, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingStretchProp))
|
||||
{
|
||||
ImGui.TableSetupColumn("Runs", ImGuiTableColumnFlags.WidthFixed, 100);
|
||||
ImGui.TableSetupColumn("Recipe");
|
||||
var runs = C.RingRuns;
|
||||
foreach (var r in RingChain.Recipes)
|
||||
{
|
||||
ImGui.PushID(r.Id);
|
||||
ImGui.TableNextRow();
|
||||
ImGui.TableNextColumn();
|
||||
int n;
|
||||
lock (runs) n = runs.TryGetValue(r.Id, out int v) ? v : 0;
|
||||
ImGui.SetNextItemWidth(90);
|
||||
if (ImGui.InputInt("##runs", ref n, 1))
|
||||
{
|
||||
n = Math.Clamp(n, 0, RingChain.MaxRuns);
|
||||
lock (runs)
|
||||
{
|
||||
if (n == 0) runs.Remove(r.Id);
|
||||
else runs[r.Id] = n;
|
||||
}
|
||||
}
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(r.Name);
|
||||
if (ImGui.IsItemHovered()) SafeImGui.SetTooltip(r.Notes);
|
||||
ImGui.PopID();
|
||||
}
|
||||
ImGui.EndTable();
|
||||
}
|
||||
|
||||
bool running = Rings.Running;
|
||||
bool tinkering = Runner.Running;
|
||||
ImGui.BeginDisabled(running);
|
||||
if (ImGui.Button("Scan##rings")) _ctx.Post(() => Rings.Scan());
|
||||
ImGui.SameLine();
|
||||
ImGui.BeginDisabled(tinkering);
|
||||
if (ImGui.Button("Create"))
|
||||
{
|
||||
int total = RingChain.Expand(id => { lock (C.RingRuns) return C.RingRuns.TryGetValue(id, out int v) ? v : 0; }).Count;
|
||||
_ctx.Confirm("Rings chain", $"Craft {total} combine(s)?\n\nEvery Step 1 run goes first, then Step 2, then Step 3.\nThe ingredients are used up.",
|
||||
() => Rings.Create(), "Create");
|
||||
}
|
||||
ImGui.EndDisabled();
|
||||
ImGui.EndDisabled();
|
||||
ImGui.SameLine();
|
||||
ImGui.BeginDisabled(!running);
|
||||
if (ImGui.Button("Stop##rings")) _ctx.Post(() => Rings.Stop("stopped by player"));
|
||||
ImGui.EndDisabled();
|
||||
ImGui.SameLine();
|
||||
if (tinkering) SafeImGui.TextColored(LegacyDashboardRenderer.ColAmber, $"{TinkerCatalog.Label(Runner.Bench)} tinkering is running");
|
||||
else SafeImGui.TextDisabled(Rings.Status);
|
||||
|
||||
var lines = Rings.ScanLines;
|
||||
if (lines.Length > 0 && ImGui.BeginTable("##ringscan", 2, ImGuiTableFlags.RowBg | ImGuiTableFlags.Borders | ImGuiTableFlags.SizingStretchProp))
|
||||
{
|
||||
foreach (var l in lines)
|
||||
{
|
||||
ImGui.TableNextRow();
|
||||
ImGui.TableNextColumn();
|
||||
if (l.Found == null) { SafeImGui.TextColored(LegacyDashboardRenderer.ColTeal, l.Text); continue; }
|
||||
ImGui.TextUnformatted(" " + l.Text);
|
||||
ImGui.TableNextColumn();
|
||||
if (l.State == 0) ImGui.TextUnformatted(l.Found);
|
||||
else if (l.State == 1) SafeImGui.TextDisabled(l.Found);
|
||||
else SafeImGui.TextColored(LegacyDashboardRenderer.ColAmber, l.Found);
|
||||
}
|
||||
ImGui.EndTable();
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
RenderScrolls(running || tinkering);
|
||||
}
|
||||
|
||||
/// <summary>The carried inscription scrolls: one to the selected item, or all to the last scan's items.</summary>
|
||||
private void RenderScrolls(bool busy)
|
||||
{
|
||||
ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Inscription scrolls");
|
||||
var scrolls = Rings.Scrolls;
|
||||
if (scrolls.Length == 0) { ImGui.TextDisabled("None carried (Scan to look again)."); return; }
|
||||
|
||||
ImGui.BeginDisabled(busy);
|
||||
foreach (var (id, name) in scrolls)
|
||||
{
|
||||
ImGui.PushID(id);
|
||||
if (ImGui.SmallButton("Apply to selected"))
|
||||
{
|
||||
int scrollId = id;
|
||||
string scrollName = name;
|
||||
_ctx.Confirm("Ring inscription", $"Use {scrollName} on the item selected in AC?",
|
||||
() => Rings.ApplyToSelected(scrollId), "Apply");
|
||||
}
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(name);
|
||||
ImGui.PopID();
|
||||
}
|
||||
|
||||
// UB-IT pairs the scrolls with the last Jewelry or weapon scan's items.
|
||||
int scanned = Runner.ScannedBench;
|
||||
bool usable = scanned is (int)TinkerBench.Jewelry or (int)TinkerBench.Melee or (int)TinkerBench.Missile or (int)TinkerBench.Caster;
|
||||
var targets = usable ? Runner.Rows.Select(r => r.Id).ToList() : new List<int>();
|
||||
string from = usable ? TinkerCatalog.Label((TinkerBench)scanned) : "Jewelry / Weapons";
|
||||
ImGui.BeginDisabled(targets.Count == 0);
|
||||
if (ImGui.Button($"Apply all to the last {from} scan ({targets.Count})"))
|
||||
{
|
||||
int pairs = Math.Min(targets.Count, scrolls.Length);
|
||||
_ctx.Confirm("Ring inscriptions", $"Use {pairs} inscription scroll(s) on the items of the last {from} scan, one each?",
|
||||
() => Rings.ApplyToItems(targets), "Apply");
|
||||
}
|
||||
ImGui.EndDisabled();
|
||||
if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled))
|
||||
SafeImGui.SetTooltip("Scrolls in glyph order go on the scanned items in id order (UB-IT's pairing).\n"
|
||||
+ "Scan the Jewelry or a Weapons tab first.");
|
||||
ImGui.EndDisabled();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ internal sealed class MiniRemoteController
|
|||
|
||||
/// <summary>Where the quest UI went (chat reply for the retired "/ra quests" verbs and tab names).</summary>
|
||||
public const string QuestsMovedText =
|
||||
"[Mini Remote] Quests moved to RynthOracle: /ro (Quests tab: timers, tracking, rewards), /ro timers (Quest Timers window).";
|
||||
"[Mini Remote] Quests moved to RynthOracle: /ro (Quests tab: timers, tracking, rewards, /qb), /ro timers (Quest Timers window).";
|
||||
|
||||
private readonly MiniRemoteContext _ctx;
|
||||
private readonly Func<QuestTracker?> _quests;
|
||||
|
|
@ -45,7 +45,7 @@ internal sealed class MiniRemoteController
|
|||
private bool _confirmOpened;
|
||||
|
||||
public PetsTab Pets { get; }
|
||||
/// <summary>The Crafting tab (tinker benches and server salvage; any world). SilentKelpie's.</summary>
|
||||
/// <summary>The Crafting tab (tinker benches and the Rings chain; any world).</summary>
|
||||
public CraftingTab Crafting { get; }
|
||||
public VTankUsdImporter Usd { get; }
|
||||
|
||||
|
|
@ -113,13 +113,14 @@ internal sealed class MiniRemoteController
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>Pump-thread chat line (the heal pet's heal). Never eats.</summary>
|
||||
/// <summary>Pump-thread chat line (the heal pet's heal, a tinker run's results). Never eats.</summary>
|
||||
public void OnChat(string text)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text)) return;
|
||||
try { Pets.OnChat(text.TrimEnd('\r', '\n')); }
|
||||
string line = text.TrimEnd('\r', '\n');
|
||||
try { Pets.OnChat(line); }
|
||||
catch (Exception ex) { RynthLog.Exception(LogCat.Pets, ex, "PetsTab.OnChat"); }
|
||||
try { Crafting.OnChat(text.TrimEnd('\r', '\n')); }
|
||||
try { Crafting.OnChat(line); }
|
||||
catch (Exception ex) { RynthLog.Exception(LogCat.Crafting, ex, "CraftingTab.OnChat"); }
|
||||
}
|
||||
|
||||
|
|
@ -220,11 +221,10 @@ internal sealed class MiniRemoteController
|
|||
// ── Commands ────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// "/ra hub [show|hide|toggle|open pets|crafting [show|hide|toggle]|open breeding|tab pets|crafting|breeding|remote]",
|
||||
/// "/ra hub [show|hide|toggle|open pets|breeding|crafting [show|hide|toggle]|tab pets|breeding|crafting|remote]",
|
||||
/// "/ra quests [refresh]", "/ra pets [show|hide|toggle]"; every other "/ra hub ..." verb,
|
||||
/// "/ra guardian ..." and "/ra bounty|bounties|bountys ..." go to RynthILT. The retired quest
|
||||
/// verbs and tab names ("/ra quests window", "/ra hub open quests", ...) say where quests went,
|
||||
/// and "/ra hub open|tab character" opens RynthOracle's Character tab (Huds/MovedTabs.cs).
|
||||
/// verbs and tab names ("/ra quests window", "/ra hub open quests", ...) say where quests went.
|
||||
/// Returns false if not handled.
|
||||
/// </summary>
|
||||
public bool HandleCommand(string verb, string[] args)
|
||||
|
|
@ -254,14 +254,22 @@ internal sealed class MiniRemoteController
|
|||
_ctx.Chat(QuestsMovedText);
|
||||
return true;
|
||||
}
|
||||
// "/ra hub open|tab character": the Character tab left the Mini Remote (2026-10-13);
|
||||
// HudController.HandleTabCommand opens RynthOracle's Character tab.
|
||||
// "/ra hub open|tab character|charms|banking": those left the Mini Remote (2026-10-13);
|
||||
// HudController.HandleTabCommand opens RynthOracle's Character tab or Global Inventory > Banking.
|
||||
if (cmd is "open" or "tab" && args.Length > 1 && Huds.MovedTabs.CommandFor(args[1]) != null)
|
||||
{
|
||||
string? reply = MiniRemoteTabCommand?.Invoke(args[1].Trim().ToLowerInvariant(), "show");
|
||||
if (cmd == "open" && reply != null) _ctx.Chat("[Mini Remote] " + reply);
|
||||
return true;
|
||||
}
|
||||
// "/ra hub open|tab breeding": the Pets tab on its Breeding sub-tab (RynthOracle's Pet Breeding tab links here).
|
||||
if (cmd is "open" or "tab" && args.Length > 1 && args[1].Trim().ToLowerInvariant() is "breeding" or "breed")
|
||||
{
|
||||
Pets.SelectBreeding();
|
||||
if (cmd == "open") OpenTab(MiniRemoteTabs.Pets, "show");
|
||||
else MiniRemoteTabCommand?.Invoke(MiniRemoteTabs.Pets, "select");
|
||||
return true;
|
||||
}
|
||||
switch (cmd)
|
||||
{
|
||||
case "show":
|
||||
|
|
@ -270,9 +278,6 @@ internal sealed class MiniRemoteController
|
|||
// The Mini Remote is the Hub's main window.
|
||||
_ctx.Chat(MiniRemoteCommand != null ? MiniRemoteCommand(cmd) : "[Mini Remote] The Mini Remote is not available yet.");
|
||||
return true;
|
||||
case "open" or "tab" when args.Length > 1 && IsBreedingTabName(args[1]):
|
||||
OpenBreeding(cmd);
|
||||
return true;
|
||||
case "open" when args.Length > 1 && MiniRemoteTabs.Parse(args[1]) is { } openTab:
|
||||
OpenTab(openTab, args.Length > 2 ? args[2] : "toggle");
|
||||
return true;
|
||||
|
|
@ -299,37 +304,10 @@ internal sealed class MiniRemoteController
|
|||
|
||||
private void PrintHelp()
|
||||
{
|
||||
_ctx.Chat("[Mini Remote] /ra hub [show|hide|toggle] (Mini Remote) /ra hub open pets|crafting [show|hide|toggle] /ra hub open breeding (ILT)");
|
||||
_ctx.Chat("[Mini Remote] /ra hub [show|hide|toggle] (Mini Remote) /ra hub open pets|crafting [show|hide|toggle]");
|
||||
_ctx.Chat("[Mini Remote] /ra quests refresh (quiet /myquests) /ra pets [show|hide] Quest list, timers and rewards: RynthOracle (/ro).");
|
||||
_ctx.Chat("[Mini Remote] Banking, gear, charms, games, the Guardian, bounties, /ra hub attr ...: Infinite Leaftide, the RynthILT plugin.");
|
||||
_ctx.Chat("[Mini Remote] Character overview and session: RynthOracle (/ro character). Force a server: /rc diagnostics.");
|
||||
}
|
||||
|
||||
/// <summary>"breeding" / "breed": the Pets tab's Breeding sub-tab (RynthILT's tracker, Infinite Leaftide).</summary>
|
||||
private static bool IsBreedingTabName(string text) => text.Trim().ToLowerInvariant() is "breeding" or "breed";
|
||||
|
||||
/// <summary>
|
||||
/// "/ra hub open|tab breeding": the Pets tab on its Breeding sub-tab when RynthILT offers it. "open"
|
||||
/// shows the Mini Remote and says why when there is no Breeding sub-tab; "tab" (the engine's
|
||||
/// dashboard) only switches tabs, to the Pets roster when there is none.
|
||||
/// </summary>
|
||||
private void OpenBreeding(string cmd)
|
||||
{
|
||||
bool offered = Pets.BreedingOffered;
|
||||
if (offered) Pets.SelectBreeding();
|
||||
if (cmd == "tab")
|
||||
{
|
||||
MiniRemoteTabCommand?.Invoke(MiniRemoteTabs.Pets, "select");
|
||||
return;
|
||||
}
|
||||
if (!offered)
|
||||
{
|
||||
_ctx.Chat("[Mini Remote] " + (!_ctx.Ilt.Loaded ? IltClient.NotLoaded
|
||||
: !_ctx.Ilt.IsIltWorld ? "Pet breeding is an Infinite Leaftide feature; this world isn't Infinite Leaftide."
|
||||
: "This server reports pet breeding off."));
|
||||
return;
|
||||
}
|
||||
OpenTab(MiniRemoteTabs.Pets, "show");
|
||||
_ctx.Chat("[Mini Remote] Gear, games, the Guardian, bounties, /ra hub attr ...: Infinite Leaftide, the RynthILT plugin.");
|
||||
_ctx.Chat("[Mini Remote] Character and charms: RynthOracle (/ro character). Banking: Global Inventory (/ginv bank). Force a server: /rc diagnostics.");
|
||||
}
|
||||
|
||||
private static bool IsRemoteTabName(string text)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public sealed class MiniRemoteState
|
|||
public int SchemaVersion = 1;
|
||||
public PetTabState Pet = new();
|
||||
public QuestsTabState Quests = new();
|
||||
/// <summary>The Crafting tab (tinker benches); the ILT Hub's Crafting before.</summary>
|
||||
/// <summary>The Crafting tab (tinker benches, Rings chain); the ILT Hub's Crafting before.</summary>
|
||||
public CraftingTabState Crafting = new();
|
||||
/// <summary>Last VTank .usd file the importer read (the ILT Hub's Gear.LastUsdPath before).</summary>
|
||||
public string LastUsdPath = string.Empty;
|
||||
|
|
@ -44,17 +44,18 @@ public sealed class CraftingTabState
|
|||
public bool AutoNextBatch;
|
||||
/// <summary>...and start it without asking again.</summary>
|
||||
public bool AutoStartNextBatch;
|
||||
/// <summary>Prepared salvage tier: 0 Minor, 1 Moderate, 2 Major (TinkerCatalog.TrinketTiers).</summary>
|
||||
/// <summary>Trinket salvage tier: 0 Minor, 1 Moderate, 2 Major (TinkerCatalog.TrinketTiers).</summary>
|
||||
public int TrinketTier;
|
||||
/// <summary>Prepare a raw bag on the tier's Ammunition when no prepared bag is carried.</summary>
|
||||
/// <summary>Prepare a raw trinket bag on the tier's Ammunition when no prepared bag is carried.</summary>
|
||||
public bool TrinketPrep;
|
||||
// "RingRuns" (the Rings chain, now left to RynthILT) may still be in older files: it is ignored.
|
||||
/// <summary>Rings chain: recipe id (RingChain) to how many times to craft it.</summary>
|
||||
public Dictionary<string, int> RingRuns = new();
|
||||
}
|
||||
|
||||
/// <summary>One tinker bench's choices.</summary>
|
||||
public sealed class TinkerBenchSettings
|
||||
{
|
||||
/// <summary>Row key (TinkerCatalog.Key: r/p/c + material id) to how many times (imbues and flags: 0 or 1).</summary>
|
||||
/// <summary>Row key (TinkerCatalog.Key: r/s/c + material id) to how many times (imbues and flags: 0 or 1).</summary>
|
||||
public Dictionary<string, int> Counts = new();
|
||||
/// <summary>Skip a step whose chance is under this percent (0 = any chance).</summary>
|
||||
public int MinChancePercent;
|
||||
|
|
@ -123,7 +124,7 @@ public sealed class PetTabState
|
|||
// Auto siphon-lens capture (ACECustom MonsterCapture; Mini Remote > Pets).
|
||||
/// <summary>When on, use the selected siphon lens on a nearby creature once it is weak enough.</summary>
|
||||
public bool AutoCaptureEnabled;
|
||||
/// <summary>Index into <see cref="PetCaptureRules.Lenses"/> (Flawed to Asheron).</summary>
|
||||
/// <summary>Index into <see cref="PetCaptureRules.Lenses"/> (Flawed…Asheron's).</summary>
|
||||
public int CaptureLensIndex;
|
||||
}
|
||||
|
||||
|
|
@ -264,6 +265,7 @@ internal sealed class MiniRemoteStore
|
|||
s.Crafting ??= new CraftingTabState();
|
||||
s.Crafting.Benches ??= new();
|
||||
s.Crafting.CustomByWorld ??= new();
|
||||
s.Crafting.RingRuns ??= new();
|
||||
s.Crafting.BatchSize = Math.Clamp(s.Crafting.BatchSize, 1, 200);
|
||||
s.Crafting.TrinketTier = Math.Clamp(s.Crafting.TrinketTier, 0, 2);
|
||||
s.LastUsdPath ??= string.Empty;
|
||||
|
|
|
|||
124
Plugins/RynthCore.Plugin.RynthAi/MiniRemote/PetDamageTint.cs
Normal file
124
Plugins/RynthCore.Plugin.RynthAi/MiniRemote/PetDamageTint.cs
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
// PetDamageTint.cs — damage-type colours and pet essence school picking, after UB-ILT.
|
||||
//
|
||||
// Palette: UB-ILT Lib\LeaftideDamageTypeVtColors.ForDamageTypeFlag (the Virindi Tank / Leaftide
|
||||
// label colours its Items, Spell and Pets tabs share). The engine's Items panel uses the same
|
||||
// values (RynthCore ImGui\Panels\DamageTypeColors.cs); keep the two tables in step.
|
||||
// School picking: UB-ILT Lib\PetDamageTypeTintPolicy.PickFlag (v2.0.1119).
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.MiniRemote;
|
||||
|
||||
/// <summary>ACE damage-type flags, colours per school, and the pet essence school pick.</summary>
|
||||
internal static class PetDamageTint
|
||||
{
|
||||
public const uint Slash = 1, Pierce = 2, Bludgeon = 4, SlashPierce = 3, Cold = 8, Fire = 16,
|
||||
Acid = 32, Lightning = 64, Nether = 1024;
|
||||
|
||||
/// <summary>Text colour when the school is unknown (white, as UB for an essence in the pack).</summary>
|
||||
public static readonly Vector4 Unknown = new(0.95f, 0.95f, 0.95f, 1f);
|
||||
|
||||
// Combined masks are read in this order (UB DamageProbeOrder): elements before physical.
|
||||
private static readonly uint[] ProbeOrder = { Nether, Lightning, Acid, Fire, Cold, Bludgeon, SlashPierce, Pierce, Slash };
|
||||
|
||||
/// <summary>Colour for a school name as RynthAi writes it (Slash, Pierce, Bludgeon, Fire, Cold, Lightning, Acid, Nether).</summary>
|
||||
public static Vector4 ForName(string? school) => school switch
|
||||
{
|
||||
"Slash" or "Slashing" => Rgb(255, 180, 120),
|
||||
"Pierce" or "Piercing" => Rgb(240, 200, 140),
|
||||
"Bludgeon" or "Bludgeoning" => Rgb(220, 190, 140),
|
||||
"Slash/Pierce" => Rgb(255, 160, 100),
|
||||
"Cold" or "Frost" => Rgb(160, 210, 255),
|
||||
"Fire" => Rgb(255, 130, 70),
|
||||
"Acid" => Rgb(160, 255, 140),
|
||||
"Lightning" or "Electric" or "Storm" => Rgb(255, 240, 120),
|
||||
"Nether" => Rgb(200, 160, 255),
|
||||
_ => Unknown,
|
||||
};
|
||||
|
||||
/// <summary>School name for one flag (empty for 0 or an undefined value).</summary>
|
||||
public static string Name(uint flag) => flag switch
|
||||
{
|
||||
Slash => "Slash",
|
||||
Pierce => "Pierce",
|
||||
Bludgeon => "Bludgeon",
|
||||
SlashPierce => "Slash/Pierce",
|
||||
Cold => "Cold",
|
||||
Fire => "Fire",
|
||||
Acid => "Acid",
|
||||
Lightning => "Lightning",
|
||||
Nether => "Nether",
|
||||
_ => string.Empty,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// One school for a pet essence: the captured source's damage (ACE 9054), else the essence's
|
||||
/// DamageType mask (45), else the name ("Fire Banshee Essence", "Incendiary Knight"). 0 = unknown.
|
||||
/// ILT reuses 9054 as the min-summon-aug id on some builds, where 1/2/4 read as Slash/Pierce/
|
||||
/// Bludgeon; an elemental name wins over such a physical-only property read.
|
||||
/// </summary>
|
||||
public static uint PickPetFlag(int capturedSourceDamageType, int damageTypeMask, string? displayName)
|
||||
{
|
||||
uint fromProps = PickFromProperties(capturedSourceDamageType, damageTypeMask);
|
||||
uint fromName = InferFromName(displayName);
|
||||
if (fromName != 0 && IsPhysicalOnly(fromProps)) return fromName;
|
||||
return fromProps != 0 ? fromProps : fromName;
|
||||
}
|
||||
|
||||
/// <summary>School from Mag-Tools essence names and ILT catalog adjectives (whole words only).</summary>
|
||||
public static uint InferFromName(string? displayName)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(displayName)) return 0;
|
||||
string n = displayName.ToLowerInvariant();
|
||||
if (HasAny(n, "nether")) return Nether;
|
||||
if (HasAny(n, "lightning", "electric", "voltaic", "galvanic", "electrified", "shocked", "excited", "volt", "shock"))
|
||||
return Lightning;
|
||||
if (HasAny(n, "acid", "caustic", "corrosion", "blistered", "blistering", "corrosive")) return Acid;
|
||||
if (HasAny(n, "fire", "flaming", "incendiary", "charred", "volcanic", "scorched", "pyre", "magma", "ember"))
|
||||
return Fire;
|
||||
if (HasAny(n, "frost", "glacial", "frozen", "frigid", "freezing", "arctic", "blizzard", "ice", "chill"))
|
||||
return Cold;
|
||||
if (HasAny(n, "bludgeon", "bludgeoning")) return Bludgeon;
|
||||
if (HasAny(n, "slash", "slashing")) return Slash;
|
||||
if (HasAny(n, "pierce", "piercing")) return Pierce;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static uint PickFromProperties(int captured, int mask)
|
||||
{
|
||||
if (IsDefined(captured)) return (uint)captured;
|
||||
if (IsDefined(mask)) return (uint)mask;
|
||||
if (mask <= 0) return 0;
|
||||
uint m = unchecked((uint)mask);
|
||||
foreach (uint v in ProbeOrder)
|
||||
if ((m & v) == v) return v;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static bool IsDefined(int raw) => raw > 0 && Name(unchecked((uint)raw)).Length > 0;
|
||||
|
||||
private static bool IsPhysicalOnly(uint flag) => flag is Slash or Pierce or Bludgeon or SlashPierce;
|
||||
|
||||
private static bool HasAny(string haystack, params string[] tokens)
|
||||
{
|
||||
foreach (string t in tokens)
|
||||
if (HasToken(haystack, t)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>True when <paramref name="token"/> appears as a whole word ("ice" not in "Novice").</summary>
|
||||
private static bool HasToken(string haystack, string token)
|
||||
{
|
||||
int i = 0;
|
||||
while ((i = haystack.IndexOf(token, i, StringComparison.Ordinal)) >= 0)
|
||||
{
|
||||
int end = i + token.Length;
|
||||
if ((i == 0 || !char.IsLetter(haystack[i - 1])) && (end >= haystack.Length || !char.IsLetter(haystack[end])))
|
||||
return true;
|
||||
i++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Vector4 Rgb(int r, int g, int b) => new(r / 255f, g / 255f, b / 255f, 1f);
|
||||
}
|
||||
|
|
@ -152,9 +152,9 @@ internal static class PetStatsReader
|
|||
_ => string.Empty,
|
||||
};
|
||||
|
||||
int dmg = inv.Int(wo, IntCapturedDamageType);
|
||||
if (dmg <= 0) dmg = inv.Int(wo, IntDamageType);
|
||||
s.DamageType = DamageTypeName(dmg);
|
||||
// Most essences carry neither property; the name then gives the school (UB-ILT v2.0.1119).
|
||||
s.DamageType = PetDamageTint.Name(PetDamageTint.PickPetFlag(
|
||||
inv.Int(wo, IntCapturedDamageType), inv.Int(wo, IntDamageType), wo.Name));
|
||||
|
||||
// Gear ratings first (what Mag ItemInfo shows), else the base rating ids.
|
||||
s.D = inv.Int(wo, IntGearDamage);
|
||||
|
|
@ -290,20 +290,6 @@ internal static class PetStatsReader
|
|||
return sb.Length > 0 ? "[" + sb + "]" : string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>Single AC DamageType flag → name (combined flags return empty).</summary>
|
||||
private static string DamageTypeName(int flags) => flags switch
|
||||
{
|
||||
1 => "Slash",
|
||||
2 => "Pierce",
|
||||
4 => "Bludgeon",
|
||||
8 => "Cold",
|
||||
16 => "Fire",
|
||||
32 => "Acid",
|
||||
64 => "Lightning",
|
||||
1024 => "Nether",
|
||||
_ => string.Empty,
|
||||
};
|
||||
|
||||
private static bool TryBool(RynthCoreHost host, uint id, uint stype, out bool v)
|
||||
{
|
||||
v = false;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
// * Healing pet (UB HealingBuddy subset): summons a heal pet when HP drops, dismisses it
|
||||
// after the heal lands, holds PetManager's combat summons while it is out.
|
||||
// * Auto siphon capture (ACECustom MonsterCapture): when enabled, uses the chosen lens on the
|
||||
// nearest attackable creature within 5 m once it is <=20% health or under 20 HP (Asheron's
|
||||
// nearest attackable creature within 5 m once it is ≤20% health or under 20 HP (Asheron's
|
||||
// Lens skips the health gate). Resonance still needs a prior failed capture on the server.
|
||||
// * /pets and /shinies logs: RynthILT's (RynthILT.Hub section "pets-logs", ILT only).
|
||||
// * Breeding sub-tab (Infinite Leaftide only): the tab becomes Roster | Breeding when RynthILT
|
||||
|
|
@ -475,8 +475,6 @@ internal sealed class PetsTab
|
|||
if (essence != null) _ctx.Inventory.Use(essence);
|
||||
}
|
||||
|
||||
// ── Active pet ──────────────────────────────────────────────────────────
|
||||
|
||||
// ── Auto siphon capture (ACECustom MonsterCapture) ───────────────────────
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -611,6 +609,8 @@ internal sealed class PetsTab
|
|||
return true;
|
||||
}
|
||||
|
||||
// ── Active pet ──────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>The live "<Me>'s …" creature (server pet naming), or null.</summary>
|
||||
private WorldObject? FindOwnPet()
|
||||
{
|
||||
|
|
@ -899,19 +899,23 @@ internal sealed class PetsTab
|
|||
/// <summary>Shows the Breeding sub-tab on the next frame (any thread).</summary>
|
||||
public void SelectBreeding() => _selectBreeding = true;
|
||||
|
||||
/// <summary>
|
||||
/// RynthILT offers the Breeding sub-tab: it calls this world Infinite Leaftide and the server
|
||||
/// hasn't reported pet breeding off. False without RynthILT. Any thread.
|
||||
/// </summary>
|
||||
public bool BreedingOffered => _ctx.Ilt.IsIltWorld && !_ctx.Ilt.IsOff(RynthIltHub.FeaturePetBreeding);
|
||||
|
||||
/// <summary>Whether auto siphon-lens capture is on (Mini Remote Capture toggle; settings on the roster).</summary>
|
||||
/// <summary>Whether auto siphon-lens capture is on (Mini Remote Options / Pets roster).</summary>
|
||||
public bool AutoCaptureEnabled
|
||||
{
|
||||
get => S.AutoCaptureEnabled;
|
||||
set => S.AutoCaptureEnabled = value;
|
||||
}
|
||||
|
||||
/// <summary>Selected siphon lens index (<see cref="PetCaptureRules.LensNames"/>).</summary>
|
||||
public int CaptureLensIndex
|
||||
{
|
||||
get => S.CaptureLensIndex;
|
||||
set => S.CaptureLensIndex = value;
|
||||
}
|
||||
|
||||
/// <summary>Live auto-capture status line for the Mini Remote capture row.</summary>
|
||||
public string CaptureStatus => _captureStatus;
|
||||
|
||||
/// <summary>
|
||||
/// Mini Remote Pet toggle on: enable combat auto-summon and summon the Pets tab's active
|
||||
/// combat essence now (first ticked priority, or the highlighted row). Pump thread.
|
||||
|
|
@ -932,19 +936,14 @@ internal sealed class PetsTab
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Pets tab: the universal roster, and on Infinite Leaftide the Roster | Breeding sub-tabs
|
||||
/// (Breeding is drawn by RynthILT).
|
||||
/// The Pets tab: the universal Roster, and Breeding (RynthILT's breeding tracker, section
|
||||
/// "pets-breeding", the same tracker as RynthOracle's Pet Breeding tab).
|
||||
/// </summary>
|
||||
public void Render()
|
||||
{
|
||||
var settings = _ctx.Settings;
|
||||
if (settings == null) { ImGui.TextDisabled("Not logged in."); return; }
|
||||
|
||||
if (!BreedingOffered)
|
||||
{
|
||||
RenderRoster(settings);
|
||||
return;
|
||||
}
|
||||
if (!ImGui.BeginTabBar("##petsub")) return;
|
||||
if (ImGui.BeginTabItem("Roster##petroster"))
|
||||
{
|
||||
|
|
@ -955,9 +954,7 @@ internal sealed class PetsTab
|
|||
_selectBreeding = false;
|
||||
if (BeginTab(BreedingTabLabel, breedFlags))
|
||||
{
|
||||
// RynthILT's tracker; an older RynthILT (before 0.3.1) has no such section and draws nothing.
|
||||
if (!_ctx.Ilt.RenderSection(RynthIltHub.SectionPetBreeding))
|
||||
ImGui.TextDisabled("This RynthILT has no pet breeding tracker; update RynthILT to 0.3.1 or later.");
|
||||
RenderBreeding();
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
ImGui.EndTabBar();
|
||||
|
|
@ -965,16 +962,33 @@ internal sealed class PetsTab
|
|||
|
||||
private static readonly byte[] BreedingTabLabel = System.Text.Encoding.UTF8.GetBytes("Breeding##petbreeding\0");
|
||||
|
||||
/// <summary>
|
||||
/// BeginTabItem with flags but no close button (ImGui.NET pairs the flags overload with p_open,
|
||||
/// which draws an X on the tab).
|
||||
/// </summary>
|
||||
/// <summary>BeginTabItem with flags but no close button (ImGui.NET pairs the flags overload with p_open, which draws an X).</summary>
|
||||
private static unsafe bool BeginTab(byte[] labelUtf8Z, ImGuiTabItemFlags flags)
|
||||
{
|
||||
fixed (byte* label = labelUtf8Z)
|
||||
return ImGuiNative.igBeginTabItem(label, null, flags) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Breeding is Infinite Leaftide's and RynthILT's: drawn by RynthILT, with a pointer when it
|
||||
/// isn't loaded or this isn't an ILT world.
|
||||
/// </summary>
|
||||
private void RenderBreeding()
|
||||
{
|
||||
if (!_ctx.Ilt.Loaded)
|
||||
{
|
||||
ImGui.TextDisabled("Pet breeding is tracked by RynthILT (the Infinite Leaftide plugin), which isn't loaded.");
|
||||
return;
|
||||
}
|
||||
if (!_ctx.Ilt.IsIltWorld)
|
||||
{
|
||||
ImGui.TextDisabled("Pet breeding is an Infinite Leaftide feature; this world isn't Infinite Leaftide.");
|
||||
return;
|
||||
}
|
||||
if (!_ctx.Ilt.RenderSection(RynthIltHub.SectionPetBreeding))
|
||||
ImGui.TextDisabled("This RynthILT has no breeding tracker yet; update RynthILT to 0.2.7 or later.");
|
||||
}
|
||||
|
||||
/// <summary>The universal roster: types, summons, ILT charms, healing pets and RynthILT's /pets logs.</summary>
|
||||
private void RenderRoster(LegacyUiSettings settings)
|
||||
{
|
||||
|
|
@ -1050,7 +1064,7 @@ internal sealed class PetsTab
|
|||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Dismiss the pet that is out.");
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("Scan pack")) _ctx.Post(ScanPack);
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Appraise every pet to refresh bond, potency and breeding, and check pet-named items\n(an \"... Essence\" name alone isn't enough — the item must be a summoning pet device).");
|
||||
if (ImGui.IsItemHovered()) SafeImGui.SetTooltip("Appraise every pet to refresh bond, potency and breeding, and check pet-named items\n(an \"... Essence\" name alone isn't enough — the item must be a summoning pet device).");
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("Add sel.")) _ctx.Post(() => AddSelectedAs(summonKind));
|
||||
if (ImGui.IsItemHovered()) SafeImGui.SetTooltip($"Make the item selected in your pack a {KindNames[(int)kind].ToLowerInvariant()} pet.");
|
||||
|
|
@ -1148,7 +1162,7 @@ internal sealed class PetsTab
|
|||
_highlightId = _highlightId == r.Id ? 0 : r.Id;
|
||||
RenderRowContextMenu(r);
|
||||
ImGui.SetCursorPos(start);
|
||||
SafeImGui.TextColored(DamageColor(r.DamageType), r.Line1);
|
||||
SafeImGui.TextColored(PetDamageTint.ForName(r.DamageType), r.Line1);
|
||||
SafeImGui.TextColored(LegacyDashboardRenderer.ColAmber, " " + r.Line2);
|
||||
if (r.UsesMax > 0 && r.UsesCur == 0) SafeImGui.TextColored(LegacyDashboardRenderer.ColHp, " " + r.Line3);
|
||||
else SafeImGui.TextDisabled(" " + r.Line3);
|
||||
|
|
@ -1183,17 +1197,6 @@ internal sealed class PetsTab
|
|||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
/// <summary>Line-1 colour by the pet's damage type (white when unknown / not appraised).</summary>
|
||||
private static Vector4 DamageColor(string damageType) => damageType switch
|
||||
{
|
||||
"Fire" => new Vector4(1.00f, 0.55f, 0.30f, 1f),
|
||||
"Cold" => new Vector4(0.55f, 0.80f, 1.00f, 1f),
|
||||
"Acid" => new Vector4(0.55f, 0.95f, 0.45f, 1f),
|
||||
"Lightning" => new Vector4(0.85f, 0.70f, 1.00f, 1f),
|
||||
"Nether" => new Vector4(0.75f, 0.50f, 0.90f, 1f),
|
||||
_ => new Vector4(0.95f, 0.95f, 0.95f, 1f),
|
||||
};
|
||||
|
||||
private void RenderCharms()
|
||||
{
|
||||
ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Pet charms");
|
||||
|
|
|
|||
|
|
@ -140,7 +140,10 @@ public static unsafe class PluginExports
|
|||
{
|
||||
if (surface == null) return 0;
|
||||
ReadOnlySpan<byte> name = MemoryMarshal.CreateReadOnlySpanFromNullTerminated(surface);
|
||||
if (name.EndsWith(":popout"u8)) name = name[..^":popout"u8.Length];
|
||||
// Engine tags popped-out embeds with ":popout" so the Mini Remote can show Dock
|
||||
// and open expanded Options in the floating window.
|
||||
bool popped = name.EndsWith(":popout"u8);
|
||||
if (popped) name = name[..^":popout"u8.Length];
|
||||
var plugin = Runtime.Plugin;
|
||||
if (plugin == null) return 0;
|
||||
System.Numerics.Vector2 want;
|
||||
|
|
@ -161,7 +164,7 @@ public static unsafe class PluginExports
|
|||
bool remote = name.SequenceEqual("miniremote-remote"u8);
|
||||
bool window = remote || name.SequenceEqual("miniremote-window"u8);
|
||||
if (!window && !name.SequenceEqual("miniremote"u8)) return 0;
|
||||
if (!plugin.RenderEmbeddedMiniRemote(window, out want, tabs: !remote)) return 0;
|
||||
if (!plugin.RenderEmbeddedMiniRemote(window, out want, tabs: !remote, popped: popped)) return 0;
|
||||
}
|
||||
if (wantWidth != null) *wantWidth = want.X;
|
||||
if (wantHeight != null) *wantHeight = want.Y;
|
||||
|
|
|
|||
|
|
@ -243,6 +243,7 @@ public static class VirindiTankProfileImporter
|
|||
dst.OffhandId = src.OffhandId;
|
||||
dst.PreferredAmmoItemId = src.PreferredAmmoItemId;
|
||||
dst.PetDamage = src.PetDamage;
|
||||
dst.AttackPower = src.AttackPower;
|
||||
}
|
||||
|
||||
private static MonsterRule CloneMonsterRule(MonsterRule row) =>
|
||||
|
|
@ -268,6 +269,7 @@ public static class VirindiTankProfileImporter
|
|||
OffhandId = row.OffhandId,
|
||||
PreferredAmmoItemId = row.PreferredAmmoItemId,
|
||||
PetDamage = row.PetDamage,
|
||||
AttackPower = row.AttackPower,
|
||||
PreferredDamage = row.PreferredDamage,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1553,8 +1553,9 @@ public sealed partial class RynthAiPlugin
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// What a loot rule can be built from: the item's name, class, stack, key properties and
|
||||
/// T11 reading, from the object cache. <paramref name="like"/> adds its spells;
|
||||
/// What a loot rule can be built from: the item's name, class, stack, every property the
|
||||
/// attribute checklist offers (LootItemAttributes) and T11 reading, from the object cache.
|
||||
/// <paramref name="like"/> adds its spells (the popup always asks: its checklist lists them);
|
||||
/// <paramref name="t11"/> asks for an ID when a T11 item's text hasn't arrived.
|
||||
/// </summary>
|
||||
private RynthCore.Loot.Editing.LootItemFacts? BuildLootItemFacts(uint itemId, bool like, bool t11)
|
||||
|
|
@ -1568,6 +1569,8 @@ public sealed partial class RynthAiPlugin
|
|||
ObjectClass = (int)wo.ObjectClass,
|
||||
StackSize = Math.Max(1, wo.Values(LongValueKey.StackCount, 1)),
|
||||
MaxStackSize = Math.Max(1, wo.Values(LongValueKey.MaxStackSize, 1)),
|
||||
// The Pets tab's test (WCID block, summoning-gem icon, Summoning use requirement): the essence group.
|
||||
IsPetEssence = _miniRemote?.Pets.IsPetDevice(wo) == true,
|
||||
};
|
||||
foreach (int key in RynthCore.Loot.Editing.LootItemRules.IntKeys)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -329,14 +329,16 @@ public sealed partial class RynthAiPlugin
|
|||
return current != IntPtr.Zero ? current : Host.ImGuiContext;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// RynthPluginRenderEmbed "miniremote" / "miniremote-window": the Mini Remote inside the
|
||||
/// engine's RynthAi dashboard drawer, or (<paramref name="window"/>) inside the engine's Mini
|
||||
/// Remote window, docked or popped out, drawn into the engine's current ImGui window (and
|
||||
/// context, see <see cref="EmbedContext"/>). False (nothing drawn) until login and the HUDs
|
||||
/// context, see <see cref="EmbedContext"/>). <paramref name="popped"/> is true when the
|
||||
/// engine tagged the surface with ":popout". False (nothing drawn) until login and the HUDs
|
||||
/// exist. Render thread.
|
||||
/// </summary>
|
||||
public bool RenderEmbeddedMiniRemote(bool window, out System.Numerics.Vector2 want, bool tabs = true)
|
||||
public bool RenderEmbeddedMiniRemote(bool window, out System.Numerics.Vector2 want, bool tabs = true, bool popped = false)
|
||||
{
|
||||
want = default;
|
||||
var huds = _huds;
|
||||
|
|
@ -347,7 +349,7 @@ public sealed partial class RynthAiPlugin
|
|||
ImGui.SetCurrentContext(EmbedContext());
|
||||
try
|
||||
{
|
||||
want = huds.RenderEmbedded(window, tabs);
|
||||
want = huds.RenderEmbedded(window, tabs, popped);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
|
|
@ -96,6 +96,8 @@ public sealed partial class RynthAiPlugin
|
|||
{
|
||||
Log("[RynthAi] Died — holding all actions until respawned and out of portal space.");
|
||||
_combatManager?.ReleaseHeldTurn();
|
||||
// A Handler-ring run-away holds autorun: never carry it through the death portal.
|
||||
_combatManager?.StopRingEscape("died");
|
||||
_navigationEngine?.Stop();
|
||||
RynthCore.Plugin.Shared.ActionPacer.Forget("death"); // the server dropped whatever was open
|
||||
_buffManager?.CancelPendingRecall("death"); // no /lifestone or macro restart after the respawn
|
||||
|
|
|
|||
|
|
@ -731,7 +731,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
|
||||
_metaManager = new MetaManager(_dashboard.Settings, Host, _vitals);
|
||||
_metaManager.SetPlayerId(_playerId);
|
||||
_metaManager.SetMtCommandHandler(HandleMtCommand);
|
||||
_metaManager.SetMtCommandHandler(HandleMetaChatCommand);
|
||||
_metaManager.SetRaCommandHandler(HandleRaCommand);
|
||||
if (_objectCache != null) _metaManager.SetObjectCache(_objectCache);
|
||||
_metaManager.SetFellowshipTracker(_fellowshipTracker);
|
||||
|
|
@ -739,6 +739,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
if (_buffManager != null) _metaManager.SetBuffManager(_buffManager);
|
||||
_metaManager.SetCreatureStore(_creatureStore);
|
||||
_metaManager.SetKillClock(_killClock);
|
||||
_metaManager.SetCorpseOpenedCheck(id => _completedCorpses.ContainsKey(id));
|
||||
if (_dashboard != null)
|
||||
_dashboard.MetaSnapshotProvider = () => _metaManager?.GetStateSnapshot();
|
||||
|
||||
|
|
@ -1023,6 +1024,10 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
["HealOthersAt"] = (0, 100), ["RestamOthersAt"] = (0, 100), ["InfuseOthersAt"] = (0, 100),
|
||||
["MeleeAttackPower"] = (-1, 100), ["MissileAttackPower"] = (-1, 100),
|
||||
["MeleeAttackHeight"] = (0, 2), ["MissileAttackHeight"] = (0, 2),
|
||||
["VariablePowerMin"] = (0, 100), ["VariablePowerMax"] = (0, 100),
|
||||
["MissileEnvironmentResponse"] = (0, 3), ["MagicEnvironmentResponse"] = (0, 3),
|
||||
["EnvironmentImpactLimit"] = (1, 10), ["EnvironmentImpactWindowSec"] = (5, 120),
|
||||
["EnvironmentApproachMeters"] = (1, 30), ["EnvironmentMinDistance"] = (1, 30), ["EnvironmentSkipSec"] = (5, 300),
|
||||
["WeaponSwapSettleMs"] = (0, 3000), ["WeaponSwapMinHealthPct"] = (0, 100), ["WeaponSwapMinGainPct"] = (0, 200),
|
||||
["PetMinMonsters"] = (1, 20),
|
||||
["SpellCastIntervalMs"] = (100, 1500), ["StuckCastBreakMs"] = (0, 60000), ["RecoveryRetryMs"] = (200, 5000), ["AttackSpellIntervalMs"] = (0, 5000), ["MinRingTargets"] = (1, 20), ["MinBlastTargets"] = (1, 20), ["BlastRange"] = (0, 100), ["MinWallTargets"] = (1, 20), ["WallRange"] = (0, 100),
|
||||
|
|
@ -2355,7 +2360,11 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
{
|
||||
try { _combatManager?.OnObjectCreated(objectId); } catch { }
|
||||
_sessionStats?.OnCreateObject(objectId);
|
||||
try { _objectCache?.OnCreateObject(objectId); }
|
||||
try
|
||||
{
|
||||
_objectCache?.OnCreateObject(objectId);
|
||||
_combatManager?.OnEnvironmentObjectCreated(objectId); // spell projectiles for the environment-impact throttle
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Host.Log($"[RynthAi] OnCreateObject EXCEPTION on id=0x{objectId:X8}: {ex.GetType().Name}: {ex.Message}");
|
||||
|
|
@ -3623,6 +3632,8 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
}
|
||||
break;
|
||||
case "settings": HandleSettingsCommand(parts); break;
|
||||
// /ra equipfor <monster>: VTank's /vt equipitemsfor (MagToolsCommands.Extra.cs)
|
||||
case "equipfor": HandleEquipForCommand(parts); break;
|
||||
case "autotrade": HandleAutoTradeRaCommand(parts); break;
|
||||
case "trade": HandleTradeCommand(parts); break;
|
||||
case "busyinfo": HandleBusyInfoCommand(); break;
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ public sealed partial class RynthAiPlugin
|
|||
{
|
||||
ServerProfileView? p = ServerProfileView.Parse(_serverState.ProfileJson);
|
||||
ChatLine(p != null
|
||||
? $"[RynthAi] {_serverState.ProfilePlugin} {RynthServerProfileApiV1.InterfaceName}: {p.Summary()}"
|
||||
: $"[RynthAi] {st.ActivePlugin} sent no server settings ({RynthServerProfileApiV1.InterfaceName} not answered - an older plugin?).");
|
||||
? $"[RynthAi] {_serverState.ProfilePlugin} {_serverState.ProfileInterface}: {p.Summary()}"
|
||||
: $"[RynthAi] {st.ActivePlugin} sent no server settings ({ServerStateClient.InterfaceFor(st.ActivePlugin)} not answered - an older plugin?).");
|
||||
}
|
||||
|
||||
bool iltTabs = _ilt != null && _ilt.Loaded;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public sealed partial class RynthAiPlugin
|
|||
private static unsafe class PluginModule
|
||||
{
|
||||
/// <summary>RynthPluginVersion's hand-written string (it never changes between builds).</summary>
|
||||
// Previous release: 0.5.0-legacy-ui (upstream standing).
|
||||
// Upstream sk keeps the standing 0.5.0-legacy-ui (rynth's publish policy); local builds carry 0.5.88-legacy-ui.
|
||||
public const string HandWrittenVersion = "0.5.0-legacy-ui";
|
||||
|
||||
private const uint FromAddress = 0x4, UnchangedRefCount = 0x2;
|
||||
|
|
|
|||
|
|
@ -86,6 +86,14 @@ public sealed partial class RynthAiPlugin
|
|||
|
||||
string cmd = parts[1].ToLower();
|
||||
|
||||
// ub-Rythai's verbs: that plugin answers; handled here only in the sense of "not unknown".
|
||||
if (IsUbRythaiCommand(cmd, SplitUbLine(fullCommand).Args))
|
||||
return true;
|
||||
|
||||
// "/ub vtsetmetastate[State]" and the like: an expression, not a verb.
|
||||
if (TryHandleUbExpression(fullCommand))
|
||||
return true;
|
||||
|
||||
// /ub jump[swzxc] [heading] [holdtime] — see Jumper.cs
|
||||
if (cmd.StartsWith("jump", StringComparison.Ordinal))
|
||||
{
|
||||
|
|
@ -176,6 +184,11 @@ public sealed partial class RynthAiPlugin
|
|||
if (TryHandleUbExtra(cmd, fullCommand))
|
||||
return true;
|
||||
|
||||
// The rest of ub-IT's verbs: aliases, features, and accepted no-ops (UtilityBeltCompatCommands.cs).
|
||||
// Before the /mt translation, so "/ub fellow dismiss" doesn't land on /mt fellow's usage line.
|
||||
if (TryHandleUbCompat(cmd, fullCommand))
|
||||
return true;
|
||||
|
||||
// /ub closestportal: use the nearest portal (UtilityBelt's command).
|
||||
if (cmd == "closestportal")
|
||||
{
|
||||
|
|
|
|||
355
Plugins/RynthCore.Plugin.RynthAi/UtilityBeltCompatCommands.cs
Normal file
355
Plugins/RynthCore.Plugin.RynthAi/UtilityBeltCompatCommands.cs
Normal file
|
|
@ -0,0 +1,355 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.PluginSdk;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi;
|
||||
|
||||
/// <summary>
|
||||
/// The rest of ub-IT's /ub verbs (2026-10-18 meta-compatibility pass). Three kinds:
|
||||
/// 1. Aliases and features with a RynthAi, RynthNav, RynthSort, engine or server equivalent
|
||||
/// (wear, getxy, stfl/stfr, arrow, navgoto, frame limits, fellow dismiss/leader/status,
|
||||
/// qblist, augs, window save, packsort*, miniremote, meta/combat/sloot on|off, debug, lps).
|
||||
/// 2. ub-Rythai's verbs, which RynthAi leaves to that plugin without a reply.
|
||||
/// 3. ub-IT features that mean nothing here (videopatch, chat max, playeroption, ...): accepted
|
||||
/// without error, said once per session, so a meta that sends them keeps running.
|
||||
/// </summary>
|
||||
public sealed partial class RynthAiPlugin
|
||||
{
|
||||
/// <summary>Verbs the ub-Rythai plugin answers. Every plugin sees each /ub line, so RynthAi stays quiet for these.</summary>
|
||||
private static readonly HashSet<string> UbRythaiVerbs = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
"autopercent", "autotradeaccept", "bank", "build", "guard", "guardian", "ilt", "leaftide",
|
||||
"log", "loginq", "p2", "periodic", "xpmeter",
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// ub-IT verbs with no RynthAi equivalent: diagnostics of ub-IT's own tools, Decal UI and
|
||||
/// client patches, and features RynthCore does its own way. Accepted so metas keep running.
|
||||
/// </summary>
|
||||
private static readonly HashSet<string> UbNoEquivalentVerbs = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
"acobject", "autologin", "autoloot", "autosalvage", "autosalvagedebug", "autosalvagereload",
|
||||
"bankparse", "breakallegiance", "bridge", "calcdamage", "chat", "chatfilter", "chunkaeth",
|
||||
"chunkaetheria", "chunkdebug", "chunkreset", "chunkstatus", "clapstatus", "dispel", "dispeltool",
|
||||
"egg", "element", "enlighten", "enlightenment", "getjob", "getui", "invcache", "joke", "keystore",
|
||||
"login", "lsdclearcache", "lsdlb", "mtbridge", "nav", "navfollow", "navfollowarrival",
|
||||
"onetouchheal", "pcap", "perf", "playeroption", "prepclick", "printcolors", "professor",
|
||||
"questbonus", "queuestatus", "refreshqueues", "resolution", "revalidate", "setui", "shittalk",
|
||||
"soak", "spell", "statushud", "storm", "surgingstrength", "swearallegiance", "testassessor",
|
||||
"textures", "tinkcalc", "trace", "tracearmorbuffs", "ubhudrecover", "ucm", "unstack",
|
||||
"vhudbridgestatus", "videopatch", "xp", "xpdebug",
|
||||
};
|
||||
|
||||
// No-equivalent verbs already reported this session (one chat line each, not one per meta pulse).
|
||||
private readonly HashSet<string> _ubNoEquivalentSaid = new(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>True when ub-Rythai owns this /ub verb. "/ub portal use|list" (portal gems) is
|
||||
/// ub-Rythai's; "/ub portal <name>" (the nearest portal) is RynthAi's.</summary>
|
||||
internal static bool IsUbRythaiCommand(string cmd, string args)
|
||||
{
|
||||
if (UbRythaiVerbs.Contains(cmd)) return true;
|
||||
if (!cmd.Equals("portal", StringComparison.OrdinalIgnoreCase)) return false;
|
||||
string first = args.Split(' ', 2, StringSplitOptions.RemoveEmptyEntries) is { Length: > 0 } w ? w[0] : "";
|
||||
return first.Length == 0 || first.Equals("use", StringComparison.OrdinalIgnoreCase)
|
||||
|| first.Equals("list", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>The verb and its arguments from a "/ub verb args" line.</summary>
|
||||
private static (string Cmd, string Args) SplitUbLine(string fullCommand)
|
||||
{
|
||||
string rest = fullCommand.Length > 3 ? fullCommand.Substring(3).Trim() : "";
|
||||
int sp = rest.IndexOf(' ');
|
||||
return sp > 0 ? (rest.Substring(0, sp).ToLowerInvariant(), rest.Substring(sp + 1).Trim())
|
||||
: (rest.ToLowerInvariant(), "");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A meta's chat-command line. /ub lines go to the /ub dispatcher (ub-IT meaning: "/ub give" gives
|
||||
/// every match, where "/mt give" gives one). ub-Rythai's verbs return false, so the meta hands the
|
||||
/// line to the chat parser, which every plugin's chat handler sees. Anything else is /mt.
|
||||
/// </summary>
|
||||
internal bool HandleMetaChatCommand(string cmd)
|
||||
{
|
||||
if (cmd.StartsWith("/ub ", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var (verb, args) = SplitUbLine(cmd);
|
||||
return !IsUbRythaiCommand(verb, args) && HandleUbCommand(cmd);
|
||||
}
|
||||
return HandleMtCommand(cmd);
|
||||
}
|
||||
|
||||
/// <summary>The verbs above. Returns false for anything else.</summary>
|
||||
internal bool TryHandleUbCompat(string cmd, string fullCommand)
|
||||
{
|
||||
string args = SplitUbLine(fullCommand).Args;
|
||||
string[] w = args.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||
string sub = w.Length > 0 ? w[0].ToLowerInvariant() : "";
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
// ── Aliases of commands RynthAi already has ─────────────────────────
|
||||
case "wear": UbWear(args, partial: false); return true;
|
||||
case "wearp": UbWear(args, partial: true); return true;
|
||||
case "getxy": return HandleMtCursor();
|
||||
case "stfl": return HandleMtStrafe(new[] { "/mt", "strafe", "left", args });
|
||||
case "stfr": return HandleMtStrafe(new[] { "/mt", "strafe", "right", args });
|
||||
case "debug": HandleRaCommand(("/ra debug " + args).TrimEnd()); return true;
|
||||
case "close": UbClose(sub); return true;
|
||||
|
||||
case "bgframelimit":
|
||||
case "globalframelimit":
|
||||
UbFrameLimit(background: cmd == "bgframelimit", args);
|
||||
return true;
|
||||
|
||||
case "fellow" when sub is "dismiss" or "dismissp" or "leader" or "leaderp" or "status" or "recruitp":
|
||||
UbFellow(sub, w.Length > 1 ? string.Join(" ", w, 1, w.Length - 1) : "");
|
||||
return true;
|
||||
|
||||
// ── RynthNav: the arrow and travel to coordinates ───────────────────
|
||||
case "arrow":
|
||||
if (sub == "point" && args.Length > 6)
|
||||
SendToPlugin("RynthNav", "rnav", "arrow " + args.Substring(6).Trim(), "/ub arrow needs the RynthNav plugin.");
|
||||
else
|
||||
UbNoEquivalent(cmd, "\"arrow face\" has no RynthNav equivalent");
|
||||
return true;
|
||||
case "navgoto":
|
||||
UbNavGoto(w);
|
||||
return true;
|
||||
|
||||
// ── RynthSort: pack sorting ─────────────────────────────────────────
|
||||
case "packsort":
|
||||
case "packsortscansort":
|
||||
case "packsortscanforcesort":
|
||||
SendToPlugin("RynthSort", "rsort", "now", "/ub packsort needs the RynthSort plugin.");
|
||||
return true;
|
||||
case "packsortshow":
|
||||
case "packsortlist":
|
||||
SendToPlugin("RynthSort", "rsort", "status", "/ub packsort needs the RynthSort plugin.");
|
||||
return true;
|
||||
case "packsortreload":
|
||||
case "packsortscan":
|
||||
case "packsortscanforce":
|
||||
UbNoEquivalent(cmd, "RynthSort reads its rules itself");
|
||||
return true;
|
||||
|
||||
// ── Server commands (ACECustom) ─────────────────────────────────────
|
||||
case "qblist": InvokeServerCommand("/qb list"); return true;
|
||||
case "augs": InvokeServerCommand("/aug"); return true;
|
||||
|
||||
// ── RynthCore's window placement ────────────────────────────────────
|
||||
case "window":
|
||||
if (sub == "save") InvokeServerCommand("/rc window save");
|
||||
else UbNoEquivalent(cmd + " " + sub, "RynthCore restores the saved window at login (/rc window save|reset)");
|
||||
return true;
|
||||
|
||||
// ── RynthAi's Mini Remote ───────────────────────────────────────────
|
||||
case "miniremote":
|
||||
if (sub is "show" or "hide" or "toggle") HandleHudCommand("miniremote", sub);
|
||||
else UbNoEquivalent(cmd + " " + sub, "use /ub miniremote show|hide|toggle");
|
||||
return true;
|
||||
|
||||
// ── Project Storm's switches onto RynthAi's macro features ──────────
|
||||
case "meta": return UbStormSwitch(cmd, sub, "enablemeta", w);
|
||||
case "combat": return UbStormSwitch(cmd, sub, "enablecombat", w);
|
||||
case "sloot": return UbStormSwitch(cmd, sub, "enablelooting", w);
|
||||
|
||||
case "lps":
|
||||
case "lootprofilestatus":
|
||||
{
|
||||
string path = _dashboard?.Settings?.CurrentLootPath ?? "";
|
||||
ChatLine("[RynthAi] Loot profile: " + (path.Length > 0 ? Path.GetFileName(path) : "(none)"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// ── ub-IT features with no RynthAi equivalent ───────────────────────────
|
||||
if (UbNoEquivalentVerbs.Contains(cmd))
|
||||
{
|
||||
UbNoEquivalent(cmd, null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// /ub close corpse|chest (ub-IT): closes the open container when it is that kind (a bare
|
||||
/// "/ub close" closes whatever is open). Metas send it after looting a quest corpse.
|
||||
/// </summary>
|
||||
private void UbClose(string kind)
|
||||
{
|
||||
uint open = Host.HasGetGroundContainerId ? Host.GetGroundContainerId() : 0;
|
||||
if (open == 0) { ChatLine("[RynthAi] No container is currently open."); return; }
|
||||
WorldObject? wo = _objectCache?[unchecked((int)open)];
|
||||
bool fits = kind switch
|
||||
{
|
||||
"corpse" => wo == null || wo.ObjectClass == AcObjectClass.Corpse,
|
||||
"chest" => wo == null || wo.ObjectClass == AcObjectClass.Container,
|
||||
_ => true,
|
||||
};
|
||||
if (!fits) return; // as ub-IT: the open container isn't that kind, nothing to do
|
||||
bool closed = Host.HasCloseContainer ? Host.CloseContainer(open) : Host.UseFor(open, "Command", "/ub close", UseKind.Asked);
|
||||
Log($"[RynthAi] /ub close {kind}: 0x{open:X8} {(closed ? "closed" : "close refused")}.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// "/ub <expression>": a /ub line whose verb is an expression call (S_BulbOfMornings broadcasts
|
||||
/// "/ub bc /ub vtsetmetastate[State]" so every client switches state). ub-IT has no such
|
||||
/// command; RynthAi evaluates the expression, which is what the meta means. True when it was one.
|
||||
/// </summary>
|
||||
internal bool TryHandleUbExpression(string fullCommand)
|
||||
{
|
||||
string rest = fullCommand.Length > 3 ? fullCommand.Substring(3).Trim() : "";
|
||||
int bracket = rest.IndexOf('[');
|
||||
int space = rest.IndexOf(' ');
|
||||
if (bracket <= 0 || (space >= 0 && space < bracket) || !rest.EndsWith("]", StringComparison.Ordinal)) return false;
|
||||
string result = EvalExpr(rest);
|
||||
Log($"[RynthAi] /ub {rest} evaluated as an expression -> '{result}'.");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Says once per session that a /ub verb is accepted and ignored; every use is logged.</summary>
|
||||
private void UbNoEquivalent(string what, string? note)
|
||||
{
|
||||
Log($"[RynthAi] /ub {what}: no RynthAi equivalent; ignored.");
|
||||
if (_ubNoEquivalentSaid.Add(what))
|
||||
ChatLine($"[RynthAi] /ub {what} is a ub-IT feature with no RynthAi equivalent; it is accepted and ignored so metas keep running"
|
||||
+ (note != null ? $" ({note})." : "."));
|
||||
}
|
||||
|
||||
/// <summary>Sends a chat line to the chat parser (server commands, /rc).</summary>
|
||||
private void InvokeServerCommand(string line)
|
||||
{
|
||||
if (Host.HasInvokeChatParser) Host.InvokeChatParser(line);
|
||||
else ChatLine($"[RynthAi] Can't send {line}: the chat parser isn't available.");
|
||||
}
|
||||
|
||||
/// <summary>A command for another plugin through the engine broker.</summary>
|
||||
private void SendToPlugin(string plugin, string action, string value, string missing)
|
||||
{
|
||||
if (!(Host.HasSendPluginCommand && Host.SendPluginCommand(plugin, action, value)))
|
||||
ChatLine("[RynthAi] " + missing);
|
||||
}
|
||||
|
||||
/// <summary>/ub wear[p] <name>: wield a carried item by name, skipping copies already worn
|
||||
/// (using a worn item would take it off).</summary>
|
||||
private void UbWear(string name, bool partial)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name)) { ChatLine("[RynthAi] Usage: /ub wear <item name> (wearp: partial name)"); return; }
|
||||
if (_objectCache == null || !Host.HasUseObject) { ChatLine("[RynthAi] /ub wear: not ready (log in first)."); return; }
|
||||
|
||||
bool sawWorn = false;
|
||||
foreach (var wo in _objectCache.GetInventory())
|
||||
{
|
||||
bool match = partial
|
||||
? wo.Name.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0
|
||||
: string.Equals(wo.Name, name, StringComparison.OrdinalIgnoreCase);
|
||||
if (!match) continue;
|
||||
if (wo.Values(LongValueKey.CurrentWieldedLocation, 0) > 0) { sawWorn = true; continue; }
|
||||
Host.UseFor(unchecked((uint)wo.Id), "Command", "/ub wear", UseKind.Asked);
|
||||
Log($"[RynthAi] /ub wear: {wo.Name} (0x{(uint)wo.Id:X8})");
|
||||
return;
|
||||
}
|
||||
ChatLine(sawWorn ? $"[RynthAi] Already wearing '{name}'." : $"[RynthAi] Item not found: '{name}'");
|
||||
}
|
||||
|
||||
/// <summary>/ub globalframelimit|bgframelimit <fps>: RynthAi's frame limit (Settings, Display).
|
||||
/// 0 turns the limit off (global) or lifts the background cap to its maximum.</summary>
|
||||
private void UbFrameLimit(bool background, string arg)
|
||||
{
|
||||
LegacyUiSettings? s = _dashboard?.Settings;
|
||||
if (s == null) { ChatLine("[RynthAi] Settings aren't loaded yet."); return; }
|
||||
if (!int.TryParse(arg.Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int fps) || fps < 0)
|
||||
{
|
||||
ChatLine($"[RynthAi] Usage: /ub {(background ? "bgframelimit" : "globalframelimit")} <frames per second>");
|
||||
return;
|
||||
}
|
||||
if (background)
|
||||
{
|
||||
s.TargetFPSBackground = fps == 0 ? 60 : Math.Clamp(fps, 5, 60);
|
||||
s.EnableFPSLimit = true;
|
||||
ChatLine($"[RynthAi] Background frame limit: {s.TargetFPSBackground} fps.");
|
||||
}
|
||||
else if (fps == 0)
|
||||
{
|
||||
s.EnableFPSLimit = false;
|
||||
ChatLine("[RynthAi] Frame limit off.");
|
||||
}
|
||||
else
|
||||
{
|
||||
s.TargetFPSFocused = Math.Clamp(fps, 10, 240);
|
||||
s.EnableFPSLimit = true;
|
||||
ChatLine($"[RynthAi] Frame limit: {s.TargetFPSFocused} fps.");
|
||||
}
|
||||
try { _dashboard?.SaveSettings(); } catch { }
|
||||
}
|
||||
|
||||
/// <summary>/ub fellow dismiss[p]|leader[p] <name>, status, recruitp <name> (the p forms match part of a name).</summary>
|
||||
private void UbFellow(string sub, string name)
|
||||
{
|
||||
if (sub == "status") { HandleFellowshipCommand(new[] { "/ra", "fellow", "status" }); return; }
|
||||
if (name.Length == 0) { ChatLine($"[RynthAi] Usage: /ub fellow {sub} <name>"); return; }
|
||||
|
||||
bool partial = sub.EndsWith('p');
|
||||
string resolved = name;
|
||||
if (partial && sub != "recruitp" && _fellowshipTracker != null)
|
||||
{
|
||||
foreach (string member in _fellowshipTracker.GetMemberNames())
|
||||
if (member.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0) { resolved = member; break; }
|
||||
}
|
||||
else if (sub == "recruitp" && FindObject(name, inv: false, land: true, partial: true) is { } wo)
|
||||
{
|
||||
resolved = wo.Name;
|
||||
}
|
||||
|
||||
string verb = sub.TrimEnd('p');
|
||||
InvokeServerCommand($"/fellowship {verb} {resolved}");
|
||||
}
|
||||
|
||||
/// <summary>/ub navgoto <ns> <ew> [walk|run]: ub-IT's signed coordinates (south and west
|
||||
/// negative) to RynthNav's "/rnav go 42.1N, 33.6E". RynthNav picks its own pace.</summary>
|
||||
private void UbNavGoto(string[] w)
|
||||
{
|
||||
if (w.Length < 2
|
||||
|| !double.TryParse(w[0], NumberStyles.Float, CultureInfo.InvariantCulture, out double ns)
|
||||
|| !double.TryParse(w[1], NumberStyles.Float, CultureInfo.InvariantCulture, out double ew))
|
||||
{
|
||||
ChatLine("[RynthAi] Usage: /ub navgoto <ns> <ew> [walk|run] (south and west are negative)");
|
||||
return;
|
||||
}
|
||||
string coords = FormattableString.Invariant($"{Math.Abs(ns):0.0#}{(ns < 0 ? 'S' : 'N')}, {Math.Abs(ew):0.0#}{(ew < 0 ? 'W' : 'E')}");
|
||||
SendToPlugin("RynthNav", "rnav", "go " + coords, "/ub navgoto needs the RynthNav plugin.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Project Storm's /ub meta|combat|sloot: on/off switch the matching RynthAi macro feature
|
||||
/// (enablemeta, enablecombat, enablelooting); "meta load <name>" and "meta state <name>"
|
||||
/// are VTank's meta load and setmetastate. The other Storm verbs have no equivalent.
|
||||
/// </summary>
|
||||
private bool UbStormSwitch(string cmd, string sub, string vtOption, string[] w)
|
||||
{
|
||||
string rest = w.Length > 1 ? string.Join(" ", w, 1, w.Length - 1) : "";
|
||||
if (_metaManager == null) { ChatLine("[RynthAi] Not ready (log in first)."); return true; }
|
||||
|
||||
switch (sub)
|
||||
{
|
||||
case "on" or "off":
|
||||
_metaManager.TryHandleVtCommand($"/vt opt set {vtOption} {(sub == "on" ? "true" : "false")}");
|
||||
return true;
|
||||
case "status" or "":
|
||||
_metaManager.TryHandleVtCommand($"/vt opt get {vtOption}");
|
||||
return true;
|
||||
case "load" when cmd == "meta" && rest.Length > 0:
|
||||
_metaManager.TryHandleVtCommand("/vt meta load " + rest);
|
||||
return true;
|
||||
case "state" when cmd == "meta" && rest.Length > 0:
|
||||
_metaManager.TryHandleVtCommand("/vt setmetastate " + rest);
|
||||
return true;
|
||||
}
|
||||
UbNoEquivalent(cmd + " " + sub, "Project Storm's own engine; RynthAi is the macro here");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,8 @@
|
|||
ServerData.cs holds what is known about the server. -->
|
||||
<PropertyGroup>
|
||||
<AssemblyName>RynthCore.Plugin.RynthColdeve</AssemblyName>
|
||||
<Version>0.1.0</Version>
|
||||
<!-- Previous release: 0.1.2. -->
|
||||
<Version>0.1.4</Version>
|
||||
<RynthPluginServerId>coldeve</RynthPluginServerId>
|
||||
<RynthPluginServerName>Coldeve</RynthPluginServerName>
|
||||
<RynthPluginServerHosts>play.coldeve.ac</RynthPluginServerHosts>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
(..\Shared\ServerPack\ServerPlugin.props); ServerData.cs holds what is known about the server. -->
|
||||
<PropertyGroup>
|
||||
<AssemblyName>RynthCore.Plugin.RynthConquest</AssemblyName>
|
||||
<Version>0.1.0</Version>
|
||||
<!-- Previous release: 0.1.2. -->
|
||||
<Version>0.1.4</Version>
|
||||
<RynthPluginServerId>conquest</RynthPluginServerId>
|
||||
<RynthPluginServerName>Conquest</RynthPluginServerName>
|
||||
<RynthPluginServerHosts>acconquest.ddns.net</RynthPluginServerHosts>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
ServerData.cs holds what is known about the server. -->
|
||||
<PropertyGroup>
|
||||
<AssemblyName>RynthCore.Plugin.RynthDerptide</AssemblyName>
|
||||
<Version>0.1.0</Version>
|
||||
<!-- Previous release: 0.1.2. -->
|
||||
<Version>0.1.4</Version>
|
||||
<RynthPluginServerId>derptide</RynthPluginServerId>
|
||||
<RynthPluginServerName>Derptide</RynthPluginServerName>
|
||||
<RynthPluginServerHosts>ac.derptide.net</RynthPluginServerHosts>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
ServerData.cs holds what is known about the server. -->
|
||||
<PropertyGroup>
|
||||
<AssemblyName>RynthCore.Plugin.RynthEversong</AssemblyName>
|
||||
<Version>0.1.0</Version>
|
||||
<!-- Previous release: 0.1.2. -->
|
||||
<Version>0.1.4</Version>
|
||||
<RynthPluginServerId>eversong</RynthPluginServerId>
|
||||
<RynthPluginServerName>Eversong</RynthPluginServerName>
|
||||
<RynthPluginServerHosts>eversong.abrdns.com</RynthPluginServerHosts>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
is shared (..\Shared\ServerPack\ServerPlugin.props); ServerData.cs holds what is known about the server. -->
|
||||
<PropertyGroup>
|
||||
<AssemblyName>RynthCore.Plugin.RynthFrostACE</AssemblyName>
|
||||
<Version>0.1.0</Version>
|
||||
<!-- Previous release: 0.1.2. -->
|
||||
<Version>0.1.4</Version>
|
||||
<RynthPluginServerId>frostace</RynthPluginServerId>
|
||||
<RynthPluginServerName>FrostACE</RynthPluginServerName>
|
||||
<RynthPluginServerHosts>172.111.230.127</RynthPluginServerHosts>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
ServerData.cs holds what is known about the server. -->
|
||||
<PropertyGroup>
|
||||
<AssemblyName>RynthCore.Plugin.RynthFrostcull</AssemblyName>
|
||||
<Version>0.1.0</Version>
|
||||
<!-- Previous release: 0.1.2. -->
|
||||
<Version>0.1.4</Version>
|
||||
<RynthPluginServerId>frostcull</RynthPluginServerId>
|
||||
<RynthPluginServerName>Frostcull</RynthPluginServerName>
|
||||
<RynthPluginServerHosts>frostcull.ddns.net</RynthPluginServerHosts>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
// DataInterface.cs - RynthILT's side of the "RynthILT.Data" interface (Plugins/Shared/RynthIltDataApi.cs):
|
||||
// the charms list and the bank balances (every character RynthILT has seen on this server) the
|
||||
// Mini Remote's Charms and Banking tabs show, for other plugins to draw, with the charm Toggle and
|
||||
// the bank verbs they send back; since version 2 also the pet breeding tracker's JSON and verbs.
|
||||
// the bank verbs they send back; since version 2 also the pet breeding tracker's JSON and verbs;
|
||||
// since version 3 the Temple guardians' JSON and verbs (RynthOracle's Quests tab).
|
||||
//
|
||||
// The table is allocated once per loaded copy of RynthILT and never freed (a plugin DLL is never
|
||||
// unloaded); after Release() it reports Version 0 and every function answers 0. Before login there
|
||||
|
|
@ -37,6 +38,8 @@ internal static unsafe class DataInterface
|
|||
t->BankCommand = &BankCommand;
|
||||
t->GetPetBreedingJson = &GetPetBreedingJson;
|
||||
t->PetBreedingCommand = &PetBreedingCommand;
|
||||
t->GetGuardianJson = &GetGuardianJson;
|
||||
t->GuardianCommand = &GuardianCommand;
|
||||
t->Version = RynthIltDataApiV1.InterfaceVersion;
|
||||
_table = t;
|
||||
}
|
||||
|
|
@ -128,6 +131,32 @@ internal static unsafe class DataInterface
|
|||
catch { return 0; }
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
private static int GetGuardianJson(byte* buffer, int capacity)
|
||||
{
|
||||
try
|
||||
{
|
||||
string? json = Hub?.GuardianJson;
|
||||
return string.IsNullOrEmpty(json) ? 0 : ProfileInterface.Write(json, buffer, capacity);
|
||||
}
|
||||
catch { return 0; }
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
private static int GuardianCommand(byte* utf8)
|
||||
{
|
||||
try
|
||||
{
|
||||
IltHubController? hub = Hub;
|
||||
if (hub == null) return 0;
|
||||
string? line = ReadVerb(utf8);
|
||||
if (line == null) return 0;
|
||||
hub.RequestGuardianVerb(line);
|
||||
return 1;
|
||||
}
|
||||
catch { return 0; }
|
||||
}
|
||||
|
||||
/// <summary>A reader's verb line, or null when it is empty, too long or not plain ASCII (no control characters reach a chat command).</summary>
|
||||
private static string? ReadVerb(byte* utf8)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,16 +1,27 @@
|
|||
// IltChunkClap.cs — Lugian-hammer chunking and /clap automation (Gear tab).
|
||||
// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13.
|
||||
//
|
||||
// Chunk: uses the Lugian Aetheria Hammer on eligible items, one at a time:
|
||||
// Chunk: uses the Lugian Aetheria Hammer on eligible items, one at a time. The rules follow ub-IT
|
||||
// (Leaftide AetheriaChunkGuard / IsValidCorruptedWep / CorruptedChunkGuard):
|
||||
// Aetheria — "Aetheria"/"Coalesced Aetheria" gems, not equipped, appraised, not flagged
|
||||
// never-chunk (bool 9030), never levelled (ItemTotalXp quad 4 == 0), no kept
|
||||
// C / CD / CDR rating (gear ints 372 / 374 / 375; on by default), and max level
|
||||
// (int 319, up to 10 on ILT) under the configured cap. Coalesced Aetheria has its
|
||||
// level from loot too, so the cap applies to it (it used to skip the cap and could
|
||||
// chunk a level 10 piece).
|
||||
// Corrupted — "Corrupted" melee/missile weapons with no tinks (171), no imbue (179),
|
||||
// not equipped, not never-chunk, cleave (292) <= 1.
|
||||
// Peace mode only unless ChunkInCombat; waits for the result line (10 s max).
|
||||
// never-chunk (bool 9030), not tinkered (171) or imbued (179), never levelled
|
||||
// (ItemTotalXp quad 4 == 0), no kept C / CD / CDR rating (gear ints 372 / 374 / 375;
|
||||
// on by default; only a rating at or above the "rating level" keeps, a lower one
|
||||
// chunks), and max level (int 319, up to 10 on ILT) under the configured cap.
|
||||
// A levelled Coalesced piece gets the cap too; an unlevelled one (319 = 0 after
|
||||
// appraisal, normal for Coalesced) is chunkable, as in ub-IT. RynthILT used to keep
|
||||
// every unlevelled Coalesced piece forever.
|
||||
// Corrupted — "Corrupted" melee/missile weapons, not equipped, not never-chunk, no tinks (171),
|
||||
// no imbue (179), loot-gen workmanship (105) > 0, and cleave (292) <= 1, or <= 2 on a
|
||||
// two-handed weapon that is not a thrust weapon (RynthILT used to cap every weapon
|
||||
// at 1, so no two-handed corrupted weapon was ever chunked). Optional keep rules
|
||||
// (Crushing Blow, Biting Strike, Armor Cleaving, slayer, multi-strike, elemental
|
||||
// bonus, any spell, max damage, spell ids) are all off by default.
|
||||
// Peace mode only unless ChunkInCombat. With ChunkInCombat on, a busy client in combat mode no
|
||||
// longer blocks the hammer (a swinging bot is always busy); peace mode still waits for idle.
|
||||
// Waits for the result line (10 s max); a target that leaves the pack first counts as chunked
|
||||
// (ILT does not always send a known line). Each item's skip reason is logged when it changes
|
||||
// and tallied in the status line.
|
||||
// The tool is the "Lugian Aetheria Hammer" only. The Lugian Hammer weapons (Flaming, Acid, ...)
|
||||
// are loot and chunk nothing on ILT: the server answers "done" with no result line. Matching
|
||||
// them by name ending used the Flaming Lugian Hammer on Silentkelpie's 9 Coalesced Aetheria,
|
||||
|
|
@ -58,6 +69,10 @@ internal sealed class IltChunkClap : IIltFeature
|
|||
private bool _manualPass;
|
||||
private volatile string _chunkStatus = "idle";
|
||||
private int _chunked;
|
||||
// Last skip reason per item, so each reason is logged once instead of every pass.
|
||||
private readonly Dictionary<int, string> _lastSkip = new();
|
||||
// Skip reasons of the current pass (reason -> items), shown in the status line.
|
||||
private readonly Dictionary<string, int> _passSkips = new();
|
||||
|
||||
// Clap state
|
||||
private long _nextClapAt;
|
||||
|
|
@ -79,66 +94,248 @@ internal sealed class IltChunkClap : IIltFeature
|
|||
private WorldObject? FindHammer()
|
||||
=> _ctx.Inventory.Items().FirstOrDefault(wo => IsChunkHammer(wo.Name) && !_ctx.Inventory.IsEquipped(wo));
|
||||
|
||||
/// <summary>True/false when decidable; null when appraisal is still needed.</summary>
|
||||
private bool? IsChunkableAetheria(WorldObject wo)
|
||||
/// <summary>Item kinds the hammer works on (the name and class gate, before any appraisal).</summary>
|
||||
internal enum ChunkKind { None, Aetheria, Corrupted }
|
||||
|
||||
/// <summary>
|
||||
/// Which chunk rules an item falls under, by class and name only. Aetheria chunks and powder
|
||||
/// are clap material, not hammer targets. Pure: the tests drive it.
|
||||
/// </summary>
|
||||
internal static ChunkKind KindOf(AcObjectClass cls, string name)
|
||||
{
|
||||
if (cls == AcObjectClass.Gem)
|
||||
{
|
||||
if (name.Equals("Coalesced Aetheria", StringComparison.OrdinalIgnoreCase)) return ChunkKind.Aetheria;
|
||||
if (name.Contains("Aetheria", StringComparison.OrdinalIgnoreCase)
|
||||
&& !name.Contains("Chunk", StringComparison.OrdinalIgnoreCase)
|
||||
&& !name.Contains("Powder", StringComparison.OrdinalIgnoreCase))
|
||||
return ChunkKind.Aetheria;
|
||||
return ChunkKind.None;
|
||||
}
|
||||
if (cls is AcObjectClass.MeleeWeapon or AcObjectClass.MissileWeapon
|
||||
&& name.Contains("Corrupted", StringComparison.OrdinalIgnoreCase))
|
||||
return ChunkKind.Corrupted;
|
||||
return ChunkKind.None;
|
||||
}
|
||||
|
||||
/// <summary>An aetheria piece's chunk facts, read after appraisal.</summary>
|
||||
internal readonly record struct AetheriaFacts(
|
||||
bool Coalesced, int MaxLevel, bool NeverChunk, long ItemXp, int Tinkers, int Imbue,
|
||||
int Crit, int CritDamage, int CritDamageResist);
|
||||
|
||||
/// <summary>
|
||||
/// Why an aetheria piece is kept, or null when it may be chunked (ub-IT AetheriaChunkGuard plus
|
||||
/// RynthILT's C / CD / CDR keep switches). Pure: the tests drive it.
|
||||
/// </summary>
|
||||
internal static string? AetheriaSkip(IltGearState g, in AetheriaFacts f)
|
||||
{
|
||||
if (f.NeverChunk) return "never-chunk flag";
|
||||
if (f.Tinkers != 0 || f.Imbue != 0) return "tinkered or imbued";
|
||||
if (f.ItemXp != 0) return "has item XP";
|
||||
if (KeptForRatings(g, f.Crit, f.CritDamage, f.CritDamageResist)) return "kept for its C / CD / CDR rating";
|
||||
if (!UnderChunkCap(f.MaxLevel, g.ChunkAetheriaUnderLevel, f.Coalesced))
|
||||
return f.MaxLevel > 0 ? "level at or above the cap" : "no level read";
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Why an aetheria item is kept (null = chunk it); "appraising" while its data is missing.</summary>
|
||||
private string? AetheriaSkip(WorldObject wo)
|
||||
{
|
||||
if (wo.ObjectClass != AcObjectClass.Gem) return false;
|
||||
bool coalesced = wo.Name.Equals("Coalesced Aetheria", StringComparison.OrdinalIgnoreCase);
|
||||
if (!coalesced && (!wo.Name.Contains("Aetheria", StringComparison.OrdinalIgnoreCase) || wo.Name.Contains("Chunk", StringComparison.OrdinalIgnoreCase)))
|
||||
return false;
|
||||
var inv = _ctx.Inventory;
|
||||
if (inv.IsEquipped(wo)) return false;
|
||||
if (!inv.HasAppraisal(wo)) { inv.RequestAppraisal(wo); return null; }
|
||||
if (inv.Bool(wo, IltInventory.BoolNeverChunk)) return false;
|
||||
if (inv.Quad(wo, IltInventory.QuadItemTotalXp) != 0) return false;
|
||||
if (KeptForRatings(G, inv.Int(wo, IltInventory.IntGearCrit), inv.Int(wo, IltInventory.IntGearCritDamage),
|
||||
inv.Int(wo, IltInventory.IntGearCritDamageResist)))
|
||||
return false;
|
||||
return UnderChunkCap(inv.Int(wo, IltInventory.IntItemMaxLevel), G.ChunkAetheriaUnderLevel);
|
||||
if (inv.IsEquipped(wo)) return "equipped";
|
||||
if (!inv.HasAppraisal(wo)) { inv.RequestAppraisal(wo); return Appraising; }
|
||||
var f = new AetheriaFacts(
|
||||
Coalesced: wo.Name.Equals("Coalesced Aetheria", StringComparison.OrdinalIgnoreCase),
|
||||
MaxLevel: inv.Int(wo, IltInventory.IntItemMaxLevel),
|
||||
NeverChunk: inv.Bool(wo, IltInventory.BoolNeverChunk),
|
||||
ItemXp: inv.Quad(wo, IltInventory.QuadItemTotalXp),
|
||||
Tinkers: inv.Int(wo, IltInventory.IntNumTimesTinkered),
|
||||
Imbue: inv.Int(wo, IltInventory.IntImbuedEffect),
|
||||
Crit: inv.Int(wo, IltInventory.IntGearCrit),
|
||||
CritDamage: inv.Int(wo, IltInventory.IntGearCritDamage),
|
||||
CritDamageResist: inv.Int(wo, IltInventory.IntGearCritDamageResist));
|
||||
return AetheriaSkip(G, f);
|
||||
}
|
||||
|
||||
/// <summary>The chunk cap in range: 1 (chunk nothing by level) to one past the ILT maximum (every level).</summary>
|
||||
internal static int ClampUnderLevel(int under) => Math.Clamp(under, 1, IltInventory.AetheriaMaxLevel + 1);
|
||||
|
||||
/// <summary>
|
||||
/// True when an aetheria's max level (int 319) is under the cap. Coalesced Aetheria has its level
|
||||
/// from loot (ACECustom rolls 1-10; level 6+ can carry a rating), so it gets the same cap.
|
||||
/// 0 = no level read: never chunked. Pure: the tests drive it.
|
||||
/// True when an aetheria's max level (int 319) is under the cap. A levelled Coalesced piece
|
||||
/// (ACECustom rolls 1-10; level 6+ can carry a rating) gets the same cap. Level 0 after
|
||||
/// appraisal: an unlevelled Coalesced piece is chunkable (ub-IT: "ItemMaxLevel 0 after assess
|
||||
/// is normal"); any other aetheria with no level is never chunked. Pure: the tests drive it.
|
||||
/// </summary>
|
||||
internal static bool UnderChunkCap(int maxLevel, int under) => maxLevel > 0 && maxLevel < ClampUnderLevel(under);
|
||||
internal static bool UnderChunkCap(int maxLevel, int under, bool coalesced = false)
|
||||
=> maxLevel > 0 ? maxLevel < ClampUnderLevel(under) : coalesced && maxLevel == 0;
|
||||
|
||||
/// <summary>Highest rating level the keep threshold accepts.</summary>
|
||||
internal const int MaxRatingLevel = 50;
|
||||
|
||||
/// <summary>The rating keep threshold in range: 1 (any rating keeps) to <see cref="MaxRatingLevel"/>.</summary>
|
||||
internal static int ClampRatingLevel(int level) => Math.Clamp(level, 1, MaxRatingLevel);
|
||||
|
||||
/// <summary>
|
||||
/// True when an aetheria's C / CD / CDR rating is one the settings keep (any rating above 0 with
|
||||
/// its keep switch on). Pure: the tests drive it.
|
||||
/// True when an aetheria's C / CD / CDR rating is one the settings keep: its keep switch is on and
|
||||
/// the rating is at or above the rating level (<see cref="IltGearState.KeepAetheriaRatingAtLeast"/>).
|
||||
/// A rating below that level does not protect the piece, so e.g. a C 1 Coalesced Aetheria chunks
|
||||
/// with the level at 2 while a C 2 one is kept. Pure: the tests drive it.
|
||||
/// </summary>
|
||||
internal static bool KeptForRatings(IltGearState g, int crit, int critDamage, int critDamageResist)
|
||||
=> (g.KeepAetheriaWithCrit && crit > 0)
|
||||
|| (g.KeepAetheriaWithCritDamage && critDamage > 0)
|
||||
|| (g.KeepAetheriaWithCritDamageResist && critDamageResist > 0);
|
||||
|
||||
private bool? IsChunkableCorrupted(WorldObject wo)
|
||||
{
|
||||
if (wo.ObjectClass is not (AcObjectClass.MeleeWeapon or AcObjectClass.MissileWeapon)) return false;
|
||||
if (!wo.Name.Contains("Corrupted", StringComparison.OrdinalIgnoreCase)) return false;
|
||||
var inv = _ctx.Inventory;
|
||||
if (inv.IsEquipped(wo)) return false;
|
||||
if (!inv.HasAppraisal(wo)) { inv.RequestAppraisal(wo); return null; }
|
||||
if (inv.Bool(wo, IltInventory.BoolNeverChunk)) return false;
|
||||
if (inv.Int(wo, IltInventory.IntNumTimesTinkered) != 0 || inv.Int(wo, IltInventory.IntImbuedEffect) != 0) return false;
|
||||
return inv.Int(wo, IltInventory.IntCleaving) <= 1;
|
||||
int min = ClampRatingLevel(g.KeepAetheriaRatingAtLeast);
|
||||
return (g.KeepAetheriaWithCrit && crit >= min)
|
||||
|| (g.KeepAetheriaWithCritDamage && critDamage >= min)
|
||||
|| (g.KeepAetheriaWithCritDamageResist && critDamageResist >= min);
|
||||
}
|
||||
|
||||
private WorldObject? NextChunkTarget()
|
||||
private const string Appraising = "appraising";
|
||||
private const int SkillTwoHandedCombat = 41;
|
||||
private const int WeaponTypeTwoHanded = 11;
|
||||
private const int AttackTypeThrust = 2;
|
||||
|
||||
/// <summary>A corrupted weapon's chunk facts, read after appraisal.</summary>
|
||||
internal sealed record CorruptedFacts
|
||||
{
|
||||
foreach (var wo in _ctx.Inventory.Items())
|
||||
public bool NeverChunk { get; init; }
|
||||
public int Tinkers { get; init; }
|
||||
public int Imbue { get; init; }
|
||||
public int Workmanship { get; init; }
|
||||
public int AttackType { get; init; }
|
||||
public int Cleaving { get; init; }
|
||||
public int WieldSkill { get; init; }
|
||||
public int WeaponType { get; init; }
|
||||
public double CritFrequency { get; init; }
|
||||
public double CritMultiplier { get; init; }
|
||||
public double IgnoreArmor { get; init; }
|
||||
public int Slayer { get; init; }
|
||||
public int ElementalBonus { get; init; }
|
||||
public int MaxDamage { get; init; }
|
||||
public IReadOnlyList<int> Spells { get; init; } = Array.Empty<int>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The most cleave a chunkable corrupted weapon may have (ub-IT IsValidCorruptedWep): 2 on a
|
||||
/// two-handed weapon that is not a thrust weapon, 1 on everything else. Pure: the tests drive it.
|
||||
/// </summary>
|
||||
internal static int MaxChunkCleave(int wieldSkill, int weaponType, int attackType)
|
||||
=> (wieldSkill == SkillTwoHandedCombat || weaponType == WeaponTypeTwoHanded) && attackType != AttackTypeThrust ? 2 : 1;
|
||||
|
||||
/// <summary>
|
||||
/// Why a corrupted weapon is kept, or null when it may be chunked: ub-IT's hard rules, then its
|
||||
/// IdleActs keep rules from the settings. Pure: the tests drive it.
|
||||
/// </summary>
|
||||
internal static string? CorruptedSkip(IltGearState g, CorruptedFacts f)
|
||||
{
|
||||
// Hard rules (always on).
|
||||
if (f.NeverChunk) return "never-chunk flag";
|
||||
if (f.Tinkers != 0 || f.Imbue != 0) return "tinkered or imbued";
|
||||
if (f.Workmanship <= 0) return "no workmanship";
|
||||
if (f.Cleaving > MaxChunkCleave(f.WieldSkill, f.WeaponType, f.AttackType)) return "cleave over the limit";
|
||||
|
||||
// Keep rules (each off by default).
|
||||
if (g.KeepCorruptedCrushingBlow && f.CritFrequency > 0) return "kept: Crushing Blow";
|
||||
if (g.KeepCorruptedBitingStrike && f.CritMultiplier > 0) return "kept: Biting Strike";
|
||||
if (g.KeepCorruptedArmorCleaving && f.IgnoreArmor > 0) return "kept: Armor Cleaving";
|
||||
if (g.KeepCorruptedAnySlayer && f.Slayer > 0) return "kept: slayer";
|
||||
if (g.KeepCorruptedMultiStrike && f.AttackType is 160 or 166 or 486) return "kept: multi-strike";
|
||||
if (g.KeepCorruptedElementalBonus && f.ElementalBonus > 0) return "kept: elemental bonus";
|
||||
if (g.KeepCorruptedMaxDamageAtLeast > 0 && f.MaxDamage >= g.KeepCorruptedMaxDamageAtLeast) return "kept: max damage";
|
||||
if (f.Spells.Count > 0)
|
||||
{
|
||||
if (_skip.Contains(wo.Id)) continue;
|
||||
if ((G.AutoChunkAetheria || _manualPass) && IsChunkableAetheria(wo) == true) return wo;
|
||||
if ((G.AutoChunkCorrupted || _manualPass) && IsChunkableCorrupted(wo) == true) return wo;
|
||||
if (g.KeepCorruptedAnySpell) return "kept: has a spell";
|
||||
var deny = ParseSpellIds(g.KeepCorruptedSpellIds);
|
||||
if (deny.Count > 0 && f.Spells.Any(deny.Contains)) return "kept: listed spell";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Positive spell ids from a comma / semicolon / whitespace separated list. Pure: the tests drive it.</summary>
|
||||
internal static HashSet<int> ParseSpellIds(string? csv)
|
||||
{
|
||||
var ids = new HashSet<int>();
|
||||
if (string.IsNullOrWhiteSpace(csv)) return ids;
|
||||
foreach (var part in csv.Split(new[] { ',', ';', ' ', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
if (int.TryParse(part, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture, out int id) && id > 0)
|
||||
ids.Add(id);
|
||||
return ids;
|
||||
}
|
||||
|
||||
/// <summary>Why a corrupted weapon is kept (null = chunk it); "appraising" while its data is missing.</summary>
|
||||
private string? CorruptedSkip(WorldObject wo)
|
||||
{
|
||||
var inv = _ctx.Inventory;
|
||||
if (inv.IsEquipped(wo)) return "equipped";
|
||||
if (!inv.HasAppraisal(wo)) { inv.RequestAppraisal(wo); return Appraising; }
|
||||
var f = new CorruptedFacts
|
||||
{
|
||||
NeverChunk = inv.Bool(wo, IltInventory.BoolNeverChunk),
|
||||
Tinkers = inv.Int(wo, IltInventory.IntNumTimesTinkered),
|
||||
Imbue = inv.Int(wo, IltInventory.IntImbuedEffect),
|
||||
Workmanship = inv.Int(wo, IltInventory.IntItemWorkmanship),
|
||||
AttackType = inv.Int(wo, IltInventory.IntAttackType),
|
||||
Cleaving = inv.Int(wo, IltInventory.IntCleaving),
|
||||
WieldSkill = inv.Int(wo, IltInventory.IntWieldSkillType),
|
||||
WeaponType = inv.Int(wo, IltInventory.IntWeaponType),
|
||||
CritFrequency = inv.Double(wo, IltInventory.FloatCriticalFrequency),
|
||||
CritMultiplier = inv.Double(wo, IltInventory.FloatCriticalMultiplier),
|
||||
IgnoreArmor = inv.Double(wo, IltInventory.FloatIgnoreArmor),
|
||||
Slayer = inv.Int(wo, IltInventory.IntSlayerCreatureType),
|
||||
ElementalBonus = inv.Int(wo, IltInventory.IntElementalDamageBonus),
|
||||
MaxDamage = inv.Int(wo, IltInventory.IntDamage),
|
||||
// Spells are only read when a spell rule is on (the read copies the item's spell list).
|
||||
Spells = G.KeepCorruptedAnySpell || !string.IsNullOrWhiteSpace(G.KeepCorruptedSpellIds)
|
||||
? inv.SpellIds(wo) : Array.Empty<int>(),
|
||||
};
|
||||
return CorruptedSkip(G, f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Chunk is allowed while the client is busy only in combat mode with ChunkInCombat on (ub-IT
|
||||
/// AutoChunkCombatBusyPolicy v2.0.1059: a swinging bot is always busy). Peace mode still waits
|
||||
/// for idle so the hammer never interrupts another use. Pure: the tests drive it.
|
||||
/// </summary>
|
||||
internal static bool AllowsChunkWhileBusy(bool isBusy, bool isPeace, bool chunkInCombat)
|
||||
=> !isBusy || (!isPeace && chunkInCombat);
|
||||
|
||||
private WorldObject? NextChunkTarget()
|
||||
{
|
||||
_passSkips.Clear();
|
||||
foreach (var wo in _ctx.Inventory.Items())
|
||||
{
|
||||
if (_skip.Contains(wo.Id)) continue;
|
||||
string? reason;
|
||||
switch (KindOf(wo.ObjectClass, wo.Name))
|
||||
{
|
||||
case ChunkKind.Aetheria when G.AutoChunkAetheria || _manualPass:
|
||||
reason = AetheriaSkip(wo);
|
||||
break;
|
||||
case ChunkKind.Corrupted when G.AutoChunkCorrupted || _manualPass:
|
||||
reason = CorruptedSkip(wo);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
if (reason == null) { _lastSkip.Remove(wo.Id); return wo; }
|
||||
NoteSkip(wo, reason);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Tallies a skip for the status line and logs it once per item and reason.</summary>
|
||||
private void NoteSkip(WorldObject wo, string reason)
|
||||
{
|
||||
_passSkips[reason] = _passSkips.TryGetValue(reason, out int n) ? n + 1 : 1;
|
||||
if (reason == Appraising) return;
|
||||
if (_lastSkip.TryGetValue(wo.Id, out string? last) && last == reason) return;
|
||||
_lastSkip[wo.Id] = reason;
|
||||
RynthLog.Write(LogCat.IltGear, $"chunk: keep 0x{(uint)wo.Id:X8} '{wo.Name}': {reason}");
|
||||
}
|
||||
|
||||
/// <summary>"3 kept for its C / CD / CDR rating, 1 appraising" — the current pass's skips.</summary>
|
||||
private string PassSkipSummary()
|
||||
=> string.Join(", ", _passSkips.OrderByDescending(kv => kv.Value).Select(kv => $"{kv.Value} {kv.Key}"));
|
||||
|
||||
/// <summary>Runs one chunk pass now (both item kinds) regardless of the auto toggles.</summary>
|
||||
public void ChunkNow()
|
||||
{
|
||||
|
|
@ -155,23 +352,37 @@ internal sealed class IltChunkClap : IIltFeature
|
|||
|
||||
if (_waitingOn != 0)
|
||||
{
|
||||
if (now - _waitStartedAt < ChunkResultWaitMs) return;
|
||||
_skip.Add(_waitingOn); // no result line — don't hammer the same item forever
|
||||
RynthLog.Write(LogCat.IltGear, $"chunk: no result line for 0x{(uint)_waitingOn:X8} in {ChunkResultWaitMs / 1000} s, skipped until a manual pass");
|
||||
int id = _waitingOn;
|
||||
switch (WaitOutcome(now - _waitStartedAt, _ctx.Inventory.Items().Any(wo => wo.Id == id)))
|
||||
{
|
||||
case ChunkWait.Waiting:
|
||||
return;
|
||||
case ChunkWait.Gone:
|
||||
_chunked++;
|
||||
RynthLog.Write(LogCat.IltGear, $"chunk: 0x{(uint)id:X8} left the pack with no result line; counted as chunked");
|
||||
break;
|
||||
case ChunkWait.TimedOut:
|
||||
_skip.Add(id); // still carried and no result line: don't hammer the same item forever
|
||||
RynthLog.Write(LogCat.IltGear, $"chunk: no result line for 0x{(uint)id:X8} in {ChunkResultWaitMs / 1000} s, skipped until a manual pass");
|
||||
break;
|
||||
}
|
||||
_waitingOn = 0;
|
||||
}
|
||||
if (now - _lastChunkAt < Math.Max(500, G.ChunkIntervalMs)) return;
|
||||
_lastChunkAt = now;
|
||||
|
||||
if (!G.ChunkInCombat && !_ctx.Inventory.InPeaceMode) { _chunkStatus = "waiting for peace mode"; return; }
|
||||
if (_ctx.Inventory.IsBusy) return;
|
||||
bool peace = _ctx.Inventory.InPeaceMode;
|
||||
if (!G.ChunkInCombat && !peace) { _chunkStatus = "waiting for peace mode"; return; }
|
||||
if (!AllowsChunkWhileBusy(_ctx.Inventory.IsBusy, peace, G.ChunkInCombat)) { _chunkStatus = "waiting for idle"; return; }
|
||||
|
||||
var hammer = FindHammer();
|
||||
if (hammer == null) { _chunkStatus = $"no {HammerName} carried"; _manualPass = false; return; }
|
||||
var target = NextChunkTarget();
|
||||
if (target == null)
|
||||
{
|
||||
string kept = PassSkipSummary();
|
||||
_chunkStatus = (_chunked > 0 ? $"nothing left to chunk ({_chunked} this session)" : "nothing eligible")
|
||||
+ (kept.Length > 0 ? $"; not chunked: {kept}" : "")
|
||||
+ (_skip.Count > 0 ? $"; {_skip.Count} skipped with no answer (Chunk now retries them)" : "");
|
||||
_manualPass = false;
|
||||
return;
|
||||
|
|
@ -300,6 +511,21 @@ internal sealed class IltChunkClap : IIltFeature
|
|||
|
||||
internal enum ChunkResult { None, Busy, Done, Refused }
|
||||
|
||||
/// <summary>Where a chunk in flight stands when no chat line has ended the wait.</summary>
|
||||
internal enum ChunkWait { Waiting, Gone, TimedOut }
|
||||
|
||||
/// <summary>
|
||||
/// The wait for a chunk with no result line yet. The hammer destroys the target, so a target
|
||||
/// that has left the pack was chunked: ILT does not always send a line the classifier knows
|
||||
/// (Silentkelpie 2026-10-18: a Red Aetheria Chunk arrived and UseDone had no error, yet the
|
||||
/// item was still filed as skipped after 10 s). Still carried after the wait = timed out.
|
||||
/// Pure: the tests drive it.
|
||||
/// </summary>
|
||||
internal static ChunkWait WaitOutcome(long elapsedMs, bool targetStillCarried)
|
||||
=> !targetStillCarried ? ChunkWait.Gone
|
||||
: elapsedMs >= ChunkResultWaitMs ? ChunkWait.TimedOut
|
||||
: ChunkWait.Waiting;
|
||||
|
||||
/// <summary>
|
||||
/// What a chat line says about the chunk in flight. ILT names the item and the tool ("You
|
||||
/// smash the Corrupted Sword with the Lugian Aetheria Hammer."), so a line naming a corrupted
|
||||
|
|
@ -343,6 +569,7 @@ internal sealed class IltChunkClap : IIltFeature
|
|||
{
|
||||
_waitingOn = 0;
|
||||
_skip.Clear();
|
||||
_lastSkip.Clear();
|
||||
_manualPass = false;
|
||||
_clapWasEnabled = false;
|
||||
}
|
||||
|
|
@ -361,7 +588,7 @@ internal sealed class IltChunkClap : IIltFeature
|
|||
ImGui.SetNextItemWidth(100);
|
||||
if (ImGui.InputInt("Chunk aetheria with max level below", ref under)) G.ChunkAetheriaUnderLevel = ClampUnderLevel(under);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip($"Infinite Leaftide aetheria goes up to level {IltInventory.AetheriaMaxLevel}; {IltInventory.AetheriaMaxLevel + 1} chunks every level.\nApplies to Coalesced Aetheria too: it has its level before it is revealed.");
|
||||
ImGui.SetTooltip($"Infinite Leaftide aetheria goes up to level {IltInventory.AetheriaMaxLevel}; {IltInventory.AetheriaMaxLevel + 1} chunks every level.\nA levelled Coalesced Aetheria gets the cap too; an unlevelled one (level 0 after appraisal) is chunked, as in ub-IT.");
|
||||
bool kc = G.KeepAetheriaWithCrit, kcd = G.KeepAetheriaWithCritDamage, kcdr = G.KeepAetheriaWithCritDamageResist;
|
||||
ImGui.TextUnformatted("Never chunk aetheria with:");
|
||||
ImGui.SameLine();
|
||||
|
|
@ -373,6 +600,39 @@ internal sealed class IltChunkClap : IIltFeature
|
|||
ImGui.SameLine();
|
||||
if (ImGui.Checkbox("CDR##keepcdr", ref kcdr)) G.KeepAetheriaWithCritDamageResist = kcdr;
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("A Crit Damage Resist rating (GearCritDamageResist).");
|
||||
int ratingAt = G.KeepAetheriaRatingAtLeast;
|
||||
ImGui.SetNextItemWidth(100);
|
||||
if (ImGui.InputInt("Keep when the rating is at least##keeprating", ref ratingAt)) G.KeepAetheriaRatingAtLeast = ClampRatingLevel(ratingAt);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("Rating level for the C / CD / CDR switches above (Coalesced Aetheria and revealed aetheria).\n"
|
||||
+ "At or above this level: kept. Below it: the rating does not protect the piece, so it chunks\n"
|
||||
+ "if the level cap and the other rules allow. 1 = any rating keeps.");
|
||||
if (ImGui.TreeNode("Corrupted weapon keep rules##corrkeep"))
|
||||
{
|
||||
// ub-IT IdleActs > Corr Chunk: each matching rule keeps the weapon.
|
||||
bool cb = G.KeepCorruptedCrushingBlow, bs = G.KeepCorruptedBitingStrike, acl = G.KeepCorruptedArmorCleaving;
|
||||
bool sl = G.KeepCorruptedAnySlayer, ms = G.KeepCorruptedMultiStrike, el = G.KeepCorruptedElementalBonus, sp = G.KeepCorruptedAnySpell;
|
||||
if (ImGui.Checkbox("Crushing Blow##ck", ref cb)) G.KeepCorruptedCrushingBlow = cb;
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Checkbox("Biting Strike##ck", ref bs)) G.KeepCorruptedBitingStrike = bs;
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Checkbox("Armor Cleaving##ck", ref acl)) G.KeepCorruptedArmorCleaving = acl;
|
||||
if (ImGui.Checkbox("Any slayer##ck", ref sl)) G.KeepCorruptedAnySlayer = sl;
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Checkbox("Multi-strike##ck", ref ms)) G.KeepCorruptedMultiStrike = ms;
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Checkbox("Elemental bonus##ck", ref el)) G.KeepCorruptedElementalBonus = el;
|
||||
if (ImGui.Checkbox("Any spell##ck", ref sp)) G.KeepCorruptedAnySpell = sp;
|
||||
int maxDmg = G.KeepCorruptedMaxDamageAtLeast;
|
||||
ImGui.SetNextItemWidth(100);
|
||||
if (ImGui.InputInt("Keep max damage at least (0 = off)##ck", ref maxDmg)) G.KeepCorruptedMaxDamageAtLeast = Math.Max(0, maxDmg);
|
||||
string ids = G.KeepCorruptedSpellIds ?? "";
|
||||
ImGui.SetNextItemWidth(220);
|
||||
if (ImGui.InputText("Keep spell ids##ck", ref ids, 512)) G.KeepCorruptedSpellIds = ids;
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Comma or space separated spell ids: a corrupted weapon carrying any of them is kept.");
|
||||
SafeImGui.TextDisabled("Always kept: tinkered, imbued, no workmanship, cleave over 1 (2 on two-handed, non-thrust).");
|
||||
ImGui.TreePop();
|
||||
}
|
||||
if (ImGui.Button("Chunk eligible items now...")) _ctx.Confirm("Chunk items",
|
||||
"Run one chunk pass now on every eligible aetheria and corrupted weapon?\nChunked items are destroyed.",
|
||||
ChunkNow, "Chunk");
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
// nearest vendor (VendorBuy). Runs as a small pump-thread state machine with timeouts; the
|
||||
// client busy state is respected between steps.
|
||||
// * Attribute tracker: IltTempleAttributes.
|
||||
// * Reader: the same state as JSON with verbs back ("RynthILT.Data" version 3), for RynthOracle's
|
||||
// Quests tab. The automation (auto hand-in, buy if missing) stays here either way.
|
||||
//
|
||||
// Threading: OnChat / Tick / commands run on the pump thread; Render only reads volatile fields
|
||||
// and posts actions through IltHubContext.Post.
|
||||
|
|
@ -426,6 +428,90 @@ internal sealed class IltGuardian : IIltFeature
|
|||
}
|
||||
}
|
||||
|
||||
// ── Reader ("RynthILT.Data" GetGuardianJson / GuardianCommand; RynthOracle's Quests tab) ──
|
||||
|
||||
/// <summary>
|
||||
/// The reader JSON (Plugins/Shared/RynthIltDataApi.cs header has the shape): the switches, the
|
||||
/// last answer and hand-in status, and the attribute turn-in rows. Built on demand: everything it
|
||||
/// reads is volatile or an immutable snapshot. Any thread.
|
||||
/// </summary>
|
||||
public string ReaderJson(string world)
|
||||
{
|
||||
TimeSpan age = LastAnswerAge;
|
||||
return BuildJson(world, S.AutoDetectFromChat, S.AutoHandIn, S.BuyMissingFromVendor, S.CooldownHoursAssumed,
|
||||
_lastAnswer, _lastNpc, age == TimeSpan.MaxValue ? -1 : (long)age.TotalSeconds,
|
||||
IltGuardianPhrasebook.MessageOf(_lastLine), HandInRunning, _handInStatus, Attributes.SyncedUtc, Attributes.Snapshot);
|
||||
}
|
||||
|
||||
/// <summary>The reader JSON from its parts. Pure: the tests drive it.</summary>
|
||||
internal static string BuildJson(string world, bool chat, bool auto, bool buy, int cooldownHours,
|
||||
string answer, string npc, long answerAgeSec, string heard, bool running, string status,
|
||||
DateTime syncedUtc, System.Collections.Generic.IReadOnlyList<IltTempleAttrStatus> rows)
|
||||
{
|
||||
var sb = new System.Text.StringBuilder(1024);
|
||||
sb.Append("{\"available\":true");
|
||||
Str(sb, "world", world);
|
||||
sb.Append(",\"chat\":").Append(chat ? "true" : "false");
|
||||
sb.Append(",\"auto\":").Append(auto ? "true" : "false");
|
||||
sb.Append(",\"buy\":").Append(buy ? "true" : "false");
|
||||
sb.Append(",\"cooldownHours\":").Append(cooldownHours);
|
||||
Str(sb, "answer", answer);
|
||||
Str(sb, "npc", npc);
|
||||
sb.Append(",\"answerAgeSec\":").Append(answerAgeSec);
|
||||
Str(sb, "heard", heard);
|
||||
sb.Append(",\"running\":").Append(running ? "true" : "false");
|
||||
Str(sb, "status", status);
|
||||
Str(sb, "synced", syncedUtc == DateTime.MinValue ? "" : syncedUtc.ToString("yyyy-MM-ddTHH:mm:ssZ", System.Globalization.CultureInfo.InvariantCulture));
|
||||
sb.Append(",\"rows\":[");
|
||||
for (int i = 0; i < rows.Count; i++)
|
||||
{
|
||||
IltTempleAttrStatus r = rows[i];
|
||||
if (i > 0) sb.Append(',');
|
||||
sb.Append('{');
|
||||
Str(sb, "attribute", r.Attribute, first: true);
|
||||
Str(sb, "npc", r.Npc);
|
||||
sb.Append(",\"count\":").Append(r.Count);
|
||||
Str(sb, "status", r.Status);
|
||||
Str(sb, "eta", r.Eta);
|
||||
sb.Append(",\"ready\":").Append(r.Ready ? "true" : "false");
|
||||
sb.Append(",\"exact\":").Append(r.FromMyQuests ? "true" : "false");
|
||||
sb.Append('}');
|
||||
}
|
||||
sb.Append("]}");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static void Str(System.Text.StringBuilder sb, string name, string? value, bool first = false)
|
||||
{
|
||||
if (!first) sb.Append(',');
|
||||
sb.Append('"').Append(name).Append("\":\"").Append(IltStyle.JsonEscape(value ?? string.Empty)).Append('"');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A reader's verb line (header of Plugins/Shared/RynthIltDataApi.cs): handin | stop | refresh |
|
||||
/// chat on|off | auto on|off | buy on|off. The reader shows the new state, so the switches don't
|
||||
/// echo in chat; hand-in and refresh report as the Guardian window's buttons do. Pump thread.
|
||||
/// </summary>
|
||||
public void RunVerb(string line)
|
||||
{
|
||||
string[] parts = line.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||
if (parts.Length == 0) return;
|
||||
string arg = parts.Length > 1 ? parts[1] : "";
|
||||
switch (parts[0].ToLowerInvariant())
|
||||
{
|
||||
case "handin": StartHandIn(_lastAnswer, _lastNpc, asked: true); break;
|
||||
case "stop": StopHandIn(); break;
|
||||
case "refresh": _ctx.Chat("[ILT Guardian] " + Attributes.Refresh()); break;
|
||||
case "chat": S.AutoDetectFromChat = Toggle(arg, S.AutoDetectFromChat); break;
|
||||
case "auto": S.AutoHandIn = Toggle(arg, S.AutoHandIn); break;
|
||||
case "buy": S.BuyMissingFromVendor = Toggle(arg, S.BuyMissingFromVendor); break;
|
||||
default:
|
||||
RynthLog.Trace(LogCat.IltHub, $"[IltGuardian] reader verb ignored: {line}");
|
||||
return;
|
||||
}
|
||||
RynthLog.Write(LogCat.IltHub, $"[IltGuardian] reader verb: {line}");
|
||||
}
|
||||
|
||||
private static bool Toggle(string mode, bool current) => mode.Trim().ToLowerInvariant() switch
|
||||
{
|
||||
"on" or "true" or "1" or "show" => true,
|
||||
|
|
|
|||
|
|
@ -168,6 +168,20 @@ internal sealed class IltHubController
|
|||
Breeding.RunVerb(line);
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// The Temple guardian JSON ("RynthILT.Data" GetGuardianJson): switches, last answer, hand-in
|
||||
/// status and attribute turn-ins. "" off an ILT world. Any thread.
|
||||
/// </summary>
|
||||
public string GuardianJson => _ctx.Options.IsIltLikeWorld ? Guardian.ReaderJson(_ctx.Options.WorldName) : string.Empty;
|
||||
|
||||
/// <summary>A reader's guardian verb line, posted to the pump (IltGuardian.RunVerb). Any thread.</summary>
|
||||
public void RequestGuardianVerb(string line)
|
||||
=> _ctx.Post(() =>
|
||||
{
|
||||
if (!_ctx.Options.IsIltLikeWorld) return;
|
||||
Guardian.RunVerb(line);
|
||||
});
|
||||
|
||||
/// <summary>A reader's bank verb line, posted to the pump (IltBanking.RunVerb). Any thread.</summary>
|
||||
public void RequestBankVerb(string line)
|
||||
=> _ctx.Post(() =>
|
||||
|
|
@ -426,7 +440,11 @@ internal sealed class IltHubController
|
|||
if (r.Lines.Count == 0) return;
|
||||
switch (key)
|
||||
{
|
||||
case IltFeature.Aug: Progression.ApplyAugLines(r.Lines); break;
|
||||
case IltFeature.Aug:
|
||||
Progression.ApplyAugLines(r.Lines);
|
||||
// Probe's OnComplete is not RequestAugs' — drain a queued Refresh current / empty retry.
|
||||
Progression.AfterExternalAugCapture();
|
||||
break;
|
||||
case IltFeature.Pets: PetLogs.ApplyRoster(false, r.Lines); break;
|
||||
case IltFeature.Shinies: PetLogs.ApplyRoster(true, r.Lines); break;
|
||||
case IltFeature.Qb: QuestBonus.ApplyQbProbe(r.Lines); break;
|
||||
|
|
|
|||
|
|
@ -218,6 +218,32 @@ public sealed class IltGearState
|
|||
public bool KeepAetheriaWithCritDamage = true;
|
||||
/// <summary>Never chunk aetheria carrying a Crit Damage Resist rating (CDR, GearCritDamageResist 375).</summary>
|
||||
public bool KeepAetheriaWithCritDamageResist = true;
|
||||
/// <summary>
|
||||
/// Rating level for the C / CD / CDR keep switches: a rating at or above this keeps the piece,
|
||||
/// a lower one does not protect it (it chunks if the other rules allow). 1 = any rating keeps.
|
||||
/// </summary>
|
||||
public int KeepAetheriaRatingAtLeast = 1;
|
||||
|
||||
// Corrupted-weapon keep rules (ub-IT IdleActs > Corr Chunk). All off by default, as in ub-IT:
|
||||
// the hard rules (unmodified, workmanship, cleaving, never-chunk) always apply on top.
|
||||
/// <summary>Never chunk a corrupted weapon with Crushing Blow (CriticalFrequency float 147 > 0).</summary>
|
||||
public bool KeepCorruptedCrushingBlow;
|
||||
/// <summary>Never chunk a corrupted weapon with Biting Strike (CriticalMultiplier float 136 > 0).</summary>
|
||||
public bool KeepCorruptedBitingStrike;
|
||||
/// <summary>Never chunk a corrupted weapon with Armor Cleaving (IgnoreArmor float 155 > 0).</summary>
|
||||
public bool KeepCorruptedArmorCleaving;
|
||||
/// <summary>Never chunk a corrupted weapon with any slayer (SlayerCreatureType int 166 > 0).</summary>
|
||||
public bool KeepCorruptedAnySlayer;
|
||||
/// <summary>Never chunk a multi-strike corrupted weapon (AttackType int 47 = 160 / 166 / 486).</summary>
|
||||
public bool KeepCorruptedMultiStrike;
|
||||
/// <summary>Never chunk a corrupted weapon with an elemental damage bonus (int 204 > 0).</summary>
|
||||
public bool KeepCorruptedElementalBonus;
|
||||
/// <summary>Never chunk a corrupted weapon with any spell on it.</summary>
|
||||
public bool KeepCorruptedAnySpell;
|
||||
/// <summary>Never chunk a corrupted weapon whose max damage (int 44) is at least this. 0 = off.</summary>
|
||||
public int KeepCorruptedMaxDamageAtLeast;
|
||||
/// <summary>Spell ids (comma / space separated): never chunk a corrupted weapon carrying any of them.</summary>
|
||||
public string KeepCorruptedSpellIds = "";
|
||||
|
||||
// Auto-clap (/clap all)
|
||||
public bool AutoClap;
|
||||
|
|
|
|||
|
|
@ -58,6 +58,27 @@ internal sealed class IltInventory
|
|||
public const uint IntNumTimesTinkered = 171;
|
||||
public const uint IntImbuedEffect = 179;
|
||||
public const uint IntCleaving = 292;
|
||||
// Corrupted-weapon chunk rules (ub-IT Leaftide.IsValidCorruptedWep / CorruptedChunkGuard).
|
||||
/// <summary>ACE PropertyInt.Damage — a weapon's max damage.</summary>
|
||||
public const uint IntDamage = 44;
|
||||
/// <summary>ACE PropertyInt.AttackType — 2 = thrust; 160 / 166 / 486 are the multi-strike masks.</summary>
|
||||
public const uint IntAttackType = 47;
|
||||
/// <summary>ACE PropertyInt.ItemWorkmanship — loot-gen Craft (salvage-bag workmanship is not on weapons).</summary>
|
||||
public const uint IntItemWorkmanship = 105;
|
||||
/// <summary>ACE PropertyInt.WieldSkillType — 41 (Two Handed Combat) for two-handed weapons.</summary>
|
||||
public const uint IntWieldSkillType = 159;
|
||||
/// <summary>ACE PropertyInt.SlayerCreatureType.</summary>
|
||||
public const uint IntSlayerCreatureType = 166;
|
||||
/// <summary>ACE PropertyInt.ElementalDamageBonus.</summary>
|
||||
public const uint IntElementalDamageBonus = 204;
|
||||
/// <summary>ACE PropertyInt.WeaponType — 11 = TwoHanded.</summary>
|
||||
public const uint IntWeaponType = 353;
|
||||
/// <summary>ACE PropertyFloat.CriticalMultiplier — Biting Strike.</summary>
|
||||
public const uint FloatCriticalMultiplier = 136;
|
||||
/// <summary>ACE PropertyFloat.CriticalFrequency — Crushing Blow.</summary>
|
||||
public const uint FloatCriticalFrequency = 147;
|
||||
/// <summary>ACE PropertyFloat.IgnoreArmor — Armor Cleaving.</summary>
|
||||
public const uint FloatIgnoreArmor = 155;
|
||||
public const uint IntItemMaxLevel = 319;
|
||||
/// <summary>Highest aetheria level on Infinite Leaftide (ACECustom AetheriaChance rolls up to 10; retail stops at 5).</summary>
|
||||
public const int AetheriaMaxLevel = 10;
|
||||
|
|
@ -190,6 +211,22 @@ internal sealed class IltInventory
|
|||
public long Quad(WorldObject wo, uint stype)
|
||||
=> _host.HasGetObjectQuadProperty && _host.TryGetObjectQuadProperty(unchecked((uint)wo.Id), stype, out long v) ? v : 0;
|
||||
|
||||
/// <summary>A float (PropertyFloat) value; 0 when the host cannot read it or the item has none.</summary>
|
||||
public double Double(WorldObject wo, uint stype)
|
||||
=> _host.HasGetObjectDoubleProperty && _host.TryGetObjectDoubleProperty(unchecked((uint)wo.Id), stype, out double v) ? v : 0;
|
||||
|
||||
/// <summary>The spell ids on an item (empty when none or the host cannot read them).</summary>
|
||||
public IReadOnlyList<int> SpellIds(WorldObject wo)
|
||||
{
|
||||
if (!_host.HasGetObjectSpellIds) return Array.Empty<int>();
|
||||
var buf = new uint[64];
|
||||
int n = _host.GetObjectSpellIds(unchecked((uint)wo.Id), buf, buf.Length);
|
||||
if (n <= 0) return Array.Empty<int>();
|
||||
var ids = new int[Math.Min(n, buf.Length)];
|
||||
for (int i = 0; i < ids.Length; i++) ids[i] = unchecked((int)buf[i]);
|
||||
return ids;
|
||||
}
|
||||
|
||||
public string Str(WorldObject wo, uint stype)
|
||||
=> _host.HasGetObjectStringProperty && _host.TryGetObjectStringProperty(unchecked((uint)wo.Id), stype, out string v) ? v ?? string.Empty : string.Empty;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ internal static class LogEvents
|
|||
public const string IltCommand = "IltHub.Command";
|
||||
public const string IltConfirmation = "IltHub.Confirmation";
|
||||
public const string IltLogout = "IltHub.Logout";
|
||||
/// <summary>/aug ApplyAugLines outcome (Progress Refresh current / login probe).</summary>
|
||||
public const string IltAugLoad = "IltHub.AugLoad";
|
||||
|
||||
/// <summary>Events written as a normal log line; the rest only while their category is traced.</summary>
|
||||
internal static readonly Dictionary<string, (LogCat Cat, bool Info)> Catalog = new(StringComparer.Ordinal)
|
||||
|
|
@ -61,6 +63,7 @@ internal static class LogEvents
|
|||
[IltCommand] = (LogCat.IltHub, false),
|
||||
[IltConfirmation] = (LogCat.IltHub, false),
|
||||
[IltLogout] = (LogCat.IltHub, false),
|
||||
[IltAugLoad] = (LogCat.IltProgression, true),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ internal static class IltParse
|
|||
/// "/aug" level line: "Creature:1,234", "Duration: 1,234", or "Specialize: 2".
|
||||
/// Trailing notes ("Triune Weave: 5 (adds ...)") are allowed; the planner only keeps known keys.
|
||||
/// </summary>
|
||||
public static readonly Regex AugLine = new(@"^(\w+)\s*:\s*([\d,]+)", Opt);
|
||||
public static readonly Regex AugLine = new(@"^(\w+)\s*:\s*(\d[\d,.\s']*)", Opt);
|
||||
|
||||
/// <summary>"/pets" / "/shinies" roster entry: "12. Shiny Drudge Ravener".</summary>
|
||||
public static readonly Regex RosterLine = new(@"^\s*(\d+)\.\s+(.+)$", Opt);
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ internal sealed class IltProgression : IIltFeature
|
|||
private bool _augAutoTried;
|
||||
/// <summary>Second Refresh current while /aug is already queued or in flight (UB coalesces the same way).</summary>
|
||||
private bool _augRefreshAgain;
|
||||
/// <summary>One silent retry after the login probe left Current empty (chat-hold / ArmsIdle race).</summary>
|
||||
private bool _augProbeRetryDone;
|
||||
/// <summary>Passive /aug window: accept AugLine chat until this tick (like T11's report parser).</summary>
|
||||
private long _augPassiveUntilMs;
|
||||
|
||||
|
|
@ -116,7 +118,8 @@ internal sealed class IltProgression : IIltFeature
|
|||
_augStatus = "/aug is off for this world";
|
||||
return;
|
||||
}
|
||||
// Coalesce: a click during an in-flight /aug runs again when that capture finishes (UB).
|
||||
// Coalesce: a click during an in-flight /aug (login probe or a prior Refresh) runs again
|
||||
// when that capture finishes — including via AfterExternalAugCapture for the probe.
|
||||
if (_ctx.Capture.IsPending("/aug"))
|
||||
{
|
||||
_augRefreshAgain = true;
|
||||
|
|
@ -124,15 +127,16 @@ internal sealed class IltProgression : IIltFeature
|
|||
return;
|
||||
}
|
||||
_augStatus = "loading...";
|
||||
_augPassiveUntilMs = IltHubContext.NowMs + 20_000; // also accept lines if capture finishes early
|
||||
_augPassiveUntilMs = IltHubContext.NowMs + 30_000; // also accept lines if capture finishes early
|
||||
_ctx.Capture.Enqueue(new IltChatRequest
|
||||
{
|
||||
Command = "/aug",
|
||||
IsResponseLine = t => t.StartsWith("---") || t.Contains("Augmentation Levels", StringComparison.OrdinalIgnoreCase) || IltParse.AugLine.IsMatch(t),
|
||||
// Idle must not start on the banner alone — chat-hold / pump lag used to finish with 0 level lines.
|
||||
ArmsIdle = t => IltParse.AugLine.IsMatch(t),
|
||||
IdleEndMs = 2000,
|
||||
FirstLineTimeoutMs = 15000,
|
||||
IdleEndMs = 2500,
|
||||
// Login + chat-hold backlog can push Creature: past the old 15s first-line window.
|
||||
FirstLineTimeoutMs = 30_000,
|
||||
Eat = true,
|
||||
OnComplete = r =>
|
||||
{
|
||||
|
|
@ -151,15 +155,36 @@ internal sealed class IltProgression : IIltFeature
|
|||
if (have == 0)
|
||||
_augStatus = "timed out waiting for /aug level lines";
|
||||
}
|
||||
if (_augRefreshAgain)
|
||||
{
|
||||
_augRefreshAgain = false;
|
||||
RequestAugs();
|
||||
}
|
||||
DrainAugRefreshAgain();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Login probe finished its "/aug" capture (or another path applied lines). Drains a queued
|
||||
/// Refresh current and, if the probe left Current empty, retries once.
|
||||
/// </summary>
|
||||
public void AfterExternalAugCapture()
|
||||
{
|
||||
if (DrainAugRefreshAgain()) return;
|
||||
int have;
|
||||
lock (_augLevels) have = _augLevels.Count;
|
||||
if (have > 0 || _augProbeRetryDone || _ctx.Options.IsOff(IltFeature.Aug)) return;
|
||||
if (_ctx.Capture.IsPending("/aug")) return;
|
||||
_augProbeRetryDone = true;
|
||||
RynthLog.Event(LogEvents.IltAugLoad, "aug probe left Current empty — retrying /aug once");
|
||||
RequestAugs();
|
||||
}
|
||||
|
||||
/// <summary>Runs a coalesced Refresh current if one was queued. Returns true when it did.</summary>
|
||||
private bool DrainAugRefreshAgain()
|
||||
{
|
||||
if (!_augRefreshAgain) return false;
|
||||
_augRefreshAgain = false;
|
||||
RequestAugs();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Parses "/aug" output (also fed from the login probe and passive chat).</summary>
|
||||
public void ApplyAugLines(List<string> lines)
|
||||
{
|
||||
|
|
@ -169,8 +194,26 @@ internal sealed class IltProgression : IIltFeature
|
|||
{
|
||||
if (TryApplyAugLine(l)) n++;
|
||||
}
|
||||
_augStatus = n > 0 ? $"{n} aug types @ {DateTime.Now:t}" : "no aug lines in reply";
|
||||
RynthLog.Trace(LogCat.IltProgression, $"ApplyAugLines done: {_augStatus} (raw lines={lines.Count})");
|
||||
if (n > 0)
|
||||
{
|
||||
_augStatus = $"{n} aug types @ {DateTime.Now:t}";
|
||||
_augPassiveUntilMs = IltHubContext.NowMs + 8_000;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool sawBanner = false;
|
||||
foreach (string l in lines)
|
||||
{
|
||||
if (l.Contains("Augmentation Levels", StringComparison.OrdinalIgnoreCase))
|
||||
{ sawBanner = true; break; }
|
||||
}
|
||||
_augStatus = sawBanner
|
||||
? "no level lines yet (banner only — waiting / retry)"
|
||||
: "no aug lines in reply";
|
||||
// Keep the passive reader open so late Creature: lines still fill Current.
|
||||
if (sawBanner) _augPassiveUntilMs = IltHubContext.NowMs + 15_000;
|
||||
}
|
||||
RynthLog.Event(LogEvents.IltAugLoad, $"ApplyAugLines: {_augStatus} (raw={lines.Count})");
|
||||
}
|
||||
|
||||
/// <summary>Applies one "/aug" Type: N line. Returns true when a known planner key was updated.</summary>
|
||||
|
|
@ -252,6 +295,7 @@ internal sealed class IltProgression : IIltFeature
|
|||
lock (_augLevels) _augLevels.Clear();
|
||||
_augAutoTried = false;
|
||||
_augRefreshAgain = false;
|
||||
_augProbeRetryDone = false;
|
||||
_augPassiveUntilMs = 0;
|
||||
_augStatus = "not loaded";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ internal sealed class IltVaultedDungeons : IIltFeature
|
|||
string path = SettingsPath;
|
||||
if (!File.Exists(path)) return;
|
||||
string text = File.ReadAllText(path);
|
||||
var cfg = JsonSerializer.Deserialize<Cfg>(text, JsonOpts);
|
||||
var cfg = JsonSerializer.Deserialize(text, IltVaultedDungeonsJsonContext.Default.Cfg);
|
||||
if (cfg == null) return;
|
||||
_cfg = Sanitize(cfg);
|
||||
_lastGoodJson = text;
|
||||
|
|
@ -136,7 +136,7 @@ internal sealed class IltVaultedDungeons : IIltFeature
|
|||
{
|
||||
string existing = File.ReadAllText(path);
|
||||
if (_lastGoodJson == null)
|
||||
JsonSerializer.Deserialize<Cfg>(existing, JsonOpts); // throws if bad
|
||||
JsonSerializer.Deserialize(existing, IltVaultedDungeonsJsonContext.Default.Cfg); // throws if bad
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -149,7 +149,7 @@ internal sealed class IltVaultedDungeons : IIltFeature
|
|||
catch { /* best effort */ }
|
||||
}
|
||||
}
|
||||
string json = JsonSerializer.Serialize(_cfg, JsonOpts);
|
||||
string json = JsonSerializer.Serialize(_cfg, IltVaultedDungeonsJsonContext.Default.Cfg);
|
||||
File.WriteAllText(path, json);
|
||||
_lastGoodJson = json;
|
||||
}
|
||||
|
|
@ -159,12 +159,6 @@ internal sealed class IltVaultedDungeons : IIltFeature
|
|||
}
|
||||
}
|
||||
|
||||
private static readonly JsonSerializerOptions JsonOpts = new()
|
||||
{
|
||||
WriteIndented = true,
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||
};
|
||||
|
||||
private static Cfg Sanitize(Cfg c)
|
||||
{
|
||||
|
|
@ -676,7 +670,8 @@ internal sealed class IltVaultedDungeons : IIltFeature
|
|||
|
||||
// ── Config / snapshot types ─────────────────────────────────────────────
|
||||
|
||||
private sealed class Cfg
|
||||
// internal (not private) so the source-generated IltVaultedDungeonsJsonContext can reach it.
|
||||
internal sealed class Cfg
|
||||
{
|
||||
public bool Active { get; set; }
|
||||
/// <summary>0 = none, 1..N = Dungeons index.</summary>
|
||||
|
|
@ -706,3 +701,15 @@ internal sealed class IltVaultedDungeons : IIltFeature
|
|||
"paused", null, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Source-generated JSON only: the NativeAOT build (what the installer ships) has reflection-based
|
||||
// serialization turned off, so JsonSerializer.Deserialize<Cfg>(text, options) failed there and the
|
||||
// Vaulted Dungeons settings never loaded or saved. Same file format as before (camelCase,
|
||||
// indented, nulls left out).
|
||||
[JsonSerializable(typeof(IltVaultedDungeons.Cfg))]
|
||||
[JsonSourceGenerationOptions(
|
||||
WriteIndented = true,
|
||||
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
|
||||
PropertyNameCaseInsensitive = true,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
internal partial class IltVaultedDungeonsJsonContext : JsonSerializerContext { }
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@ namespace RynthCore.Plugin.RynthILT;
|
|||
public sealed class RynthILTPlugin : RynthPluginBase
|
||||
{
|
||||
internal static readonly IntPtr NamePointer = Marshal.StringToHGlobalAnsi("RynthILT");
|
||||
// Previous release: 0.2.13 (ProductVersion 2026.10.16.5).
|
||||
internal static readonly IntPtr VersionPointer = Marshal.StringToHGlobalAnsi("0.2.14");
|
||||
// Previous release: 0.2.19 (ProductVersion 2026.10.18.22).
|
||||
internal static readonly IntPtr VersionPointer = Marshal.StringToHGlobalAnsi("0.2.20");
|
||||
|
||||
/// <summary>
|
||||
/// The settings view's surface. No longer in the sections manifest (the force-server override
|
||||
|
|
@ -156,6 +156,9 @@ public sealed class RynthILTPlugin : RynthPluginBase
|
|||
_nextNameTryMs = 0;
|
||||
_nextHubTryMs = 0;
|
||||
_ai?.Reset();
|
||||
// RynthCore's verdict first, so the Hub (and RynthAi's Mini Remote through RynthILT.Hub)
|
||||
// starts on the engine's ILT flag and this character's override, not RynthILT's own list.
|
||||
PollServerState(force: true);
|
||||
TryStartBounties();
|
||||
TryStartHub();
|
||||
}
|
||||
|
|
@ -172,6 +175,7 @@ public sealed class RynthILTPlugin : RynthPluginBase
|
|||
while (_typedBounty.TryDequeue(out _)) { }
|
||||
while (_engineCommands.TryDequeue(out _)) { }
|
||||
_settingsModel.Clear();
|
||||
_serverStateJson = string.Empty; // the next character's verdict is read fresh
|
||||
}
|
||||
|
||||
// Plugin unload (hot reload, update, client closing): keep the list and the Hub state for the
|
||||
|
|
@ -191,6 +195,7 @@ public sealed class RynthILTPlugin : RynthPluginBase
|
|||
try { RynthLog.Pump(); } catch { }
|
||||
if (!_loginComplete) return;
|
||||
_ai?.Tick();
|
||||
PollServerState(force: false);
|
||||
if (_bounties == null) TryStartBounties();
|
||||
if (_hub == null) TryStartHub();
|
||||
DrainTypedBounty();
|
||||
|
|
@ -208,6 +213,31 @@ public sealed class RynthILTPlugin : RynthPluginBase
|
|||
catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "PublishHubFeatures"); }
|
||||
}
|
||||
|
||||
private const long ServerStatePollMs = 2000;
|
||||
private long _serverStateNextAt;
|
||||
private string _serverStateJson = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Plugin tick, every 2 s (and at login): RynthCore's server list (plugin API v86,
|
||||
/// GetServerStateJson) into the settings model, whose "ilt" entry the Hub's world check follows
|
||||
/// (IltEngineVerdict). Parsed only when the text changed. An older engine leaves it empty, and
|
||||
/// RynthILT's own list decides. Without this the engine's verdict and the character's
|
||||
/// "/rc server ilt on|off|auto" override never reached the Hub or the Mini Remote.
|
||||
/// </summary>
|
||||
private void PollServerState(bool force)
|
||||
{
|
||||
long now = Environment.TickCount64;
|
||||
if (!force && now < _serverStateNextAt) return;
|
||||
_serverStateNextAt = now + ServerStatePollMs;
|
||||
try
|
||||
{
|
||||
if (!Host.HasGetServerStateJson || !Host.TryGetServerStateJson(out string json) || json == _serverStateJson) return;
|
||||
_serverStateJson = json;
|
||||
_settingsModel.ApplyServerState(EngineServerState.Parse(json));
|
||||
}
|
||||
catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "PollServerState"); }
|
||||
}
|
||||
|
||||
/// <summary>Plugin tick: runs the settings and fellowship views' chat commands through the engine.</summary>
|
||||
private void DrainChatCommands()
|
||||
{
|
||||
|
|
|
|||
78
Plugins/RynthCore.Plugin.RynthInventory/Data/BankRoster.cs
Normal file
78
Plugins/RynthCore.Plugin.RynthInventory/Data/BankRoster.cs
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthInventory.Data;
|
||||
|
||||
/// <summary>One character on the Banking tab: its saved balances (null = never read) and account.</summary>
|
||||
internal sealed record BankRosterEntry(string Name, string Account, bool Current, IltBankRow? Bank);
|
||||
|
||||
/// <summary>
|
||||
/// The Banking tab's character list (2026-10-13; the Mini Remote's Banking tab moved here). Every
|
||||
/// character RynthILT has bank balances for on this server (its saved per-character state, so every
|
||||
/// account played on this PC), plus every character Global Inventory has recorded on the same
|
||||
/// server without a balance yet, so the list covers the same characters as the inventory does.
|
||||
/// Pure: the tests feed it a parsed bank view and an index.
|
||||
/// </summary>
|
||||
internal static class BankRoster
|
||||
{
|
||||
/// <summary>
|
||||
/// The merged list: the logged-in character first, then by name. A name in both lists keeps
|
||||
/// RynthILT's balances and the inventory's account.
|
||||
/// </summary>
|
||||
public static List<BankRosterEntry> Build(IltBankView bank, InventoryIndex? index)
|
||||
{
|
||||
var byName = new Dictionary<string, BankRosterEntry>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (IltBankRow r in bank.Characters)
|
||||
byName[r.Name] = new BankRosterEntry(r.Name, string.Empty, r.Current, r);
|
||||
|
||||
if (index != null)
|
||||
{
|
||||
foreach (CharacterInfo ci in index.Characters)
|
||||
{
|
||||
// Same server only: a bank belongs to one world.
|
||||
if (!SameServer(ci, bank)) continue;
|
||||
string account = !string.IsNullOrEmpty(ci.Account) && ci.Account != "unknown" ? ci.Account : string.Empty;
|
||||
if (byName.TryGetValue(ci.Name, out BankRosterEntry? have))
|
||||
byName[ci.Name] = have with { Account = account, Current = have.Current || ci.IsCurrentCharacter };
|
||||
else
|
||||
byName[ci.Name] = new BankRosterEntry(ci.Name, account, ci.IsCurrentCharacter, null);
|
||||
}
|
||||
}
|
||||
|
||||
var list = new List<BankRosterEntry>(byName.Values);
|
||||
list.Sort((a, b) => a.Current != b.Current ? (a.Current ? -1 : 1) : string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase));
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A recorded character is on the bank's server: the world RynthILT names when it gave one,
|
||||
/// otherwise the server Global Inventory says you are on now.
|
||||
/// </summary>
|
||||
private static bool SameServer(CharacterInfo ci, IltBankView bank) =>
|
||||
bank.World.Length > 0 ? InventoryIndex.SameName(ci.Server, bank.World) : ci.IsCurrentServer;
|
||||
|
||||
/// <summary>The sums over every character with a balance (one row of the same shape).</summary>
|
||||
public static IltBankRow Totals(IReadOnlyList<BankRosterEntry> roster)
|
||||
{
|
||||
long py = 0, lum = 0, lk = 0, mk = 0, ec = 0, wec = 0, pc = 0;
|
||||
foreach (BankRosterEntry e in roster)
|
||||
{
|
||||
if (e.Bank is not { } b) continue;
|
||||
py += b.Pyreals; lum += b.Luminance; lk += b.LegendaryKeys; mk += b.MythicalKeys;
|
||||
ec += b.EnlightenedCoins; wec += b.WeaklyEnlightenedCoins; pc += b.PrestigeCoins;
|
||||
}
|
||||
return new IltBankRow("Total", false, py, lum, lk, mk, ec, wec, pc, DateTime.MinValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The withdraw / transfer amount typed in the form: a positive whole number (commas and spaces
|
||||
/// allowed), or 0 when it isn't one.
|
||||
/// </summary>
|
||||
public static long ParseAmount(string? text)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text)) return 0;
|
||||
string digits = text.Replace(",", string.Empty).Replace(" ", string.Empty).Trim();
|
||||
return long.TryParse(digits, System.Globalization.NumberStyles.None, System.Globalization.CultureInfo.InvariantCulture, out long n) && n > 0 ? n : 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -35,6 +35,13 @@ internal sealed class InventoryContext
|
|||
public bool IconsAvailable;
|
||||
public DateTime UtcNow;
|
||||
|
||||
/// <summary>RynthILT's "RynthILT.Data" (the Banking tab's balances and bank commands).</summary>
|
||||
public readonly RynthCore.Plugin.Shared.RynthIltDataClient IltData = new();
|
||||
/// <summary>The bank RynthILT last reported (None without RynthILT); read while the window shows.</summary>
|
||||
public RynthCore.Plugin.Shared.IltBankView Bank = RynthCore.Plugin.Shared.IltBankView.None;
|
||||
/// <summary>Set by the plugin: queues a bank verb with RynthILT (IltBankView.*Verb); false when refused.</summary>
|
||||
public Func<string, bool> BankCommand = _ => false;
|
||||
|
||||
public Action RequestRescan = () => { };
|
||||
public Action RequestReload = () => { };
|
||||
/// <summary>Forgets a character (moves its file aside). Returns a message for the player.</summary>
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public static unsafe class PluginExports
|
|||
[UnmanagedCallersOnly(EntryPoint = "RynthPluginVersion", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
public static IntPtr GetVersion()
|
||||
{
|
||||
try { return LiteralPointer("0.1.0"u8); }
|
||||
try { return LiteralPointer("0.1.4"u8); } // = RynthInventoryPlugin.Version
|
||||
catch { return IntPtr.Zero; }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@
|
|||
<ItemGroup>
|
||||
<!-- Server signal vs a player's copy of it (VaultFeed). Also linked by RynthInventory.Tests. -->
|
||||
<Compile Include="..\Shared\ChatSource.cs" Link="Shared\ChatSource.cs" />
|
||||
<!-- RynthILT's "RynthILT.Data" interface: the Banking tab's balances for every character on the server. -->
|
||||
<Compile Include="..\Shared\RynthIltDataApi.cs" Link="Shared\RynthIltDataApi.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,14 @@ namespace RynthCore.Plugin.RynthInventory;
|
|||
/// </summary>
|
||||
public sealed class RynthInventoryPlugin : RynthPluginBase
|
||||
{
|
||||
public const string Version = "0.1.2";
|
||||
// Previous release: 0.1.3. Keep in step with PluginExports.GetVersion.
|
||||
public const string Version = "0.1.4";
|
||||
|
||||
// RynthILT's bank JSON: every BankTabReadMs on the Banking tab, every BankIdleReadMs with the
|
||||
// window on another tab (so the Banking button appears on ILT worlds), never with it closed.
|
||||
private const long BankTabReadMs = 2000, BankIdleReadMs = 10_000;
|
||||
private long _nextBankReadMs;
|
||||
private string _bankJson = string.Empty;
|
||||
|
||||
private const long IdentityRetryMs = 1000;
|
||||
private const long AccountWaitMs = 15_000;
|
||||
|
|
@ -86,6 +93,7 @@ public sealed class RynthInventoryPlugin : RynthPluginBase
|
|||
_c.RequestRescan = () => { _scheduler.RequestFullScan(); _forceWrite = true; };
|
||||
_c.RequestReload = () => { _reloadWanted = true; _files.Clear(); };
|
||||
_c.Forget = ForgetCharacter;
|
||||
_c.BankCommand = SendBankVerb;
|
||||
_ui.Log = msg => Host.Log(msg);
|
||||
_vault = new VaultFeed(text => Host.InvokeChatParser(text));
|
||||
|
||||
|
|
@ -123,9 +131,44 @@ public sealed class RynthInventoryPlugin : RynthPluginBase
|
|||
_carriedIds.Clear();
|
||||
_carriedPacks.Clear();
|
||||
RefreshIconSupport();
|
||||
ClearBank();
|
||||
if (_window != null) { _window.Visible = _c.Settings.MainWindowOpen; _window.NeedsPass = true; }
|
||||
}
|
||||
|
||||
/// <summary>Forgets the last bank read (login, logout): the next character's comes fresh.</summary>
|
||||
private void ClearBank()
|
||||
{
|
||||
_c.Bank = Shared.IltBankView.None;
|
||||
_bankJson = string.Empty;
|
||||
_nextBankReadMs = 0;
|
||||
}
|
||||
|
||||
/// <summary>The Banking tab's actions: a verb line for RynthILT, then a quick re-read for its reply.</summary>
|
||||
private bool SendBankVerb(string verb)
|
||||
{
|
||||
long now = Environment.TickCount64;
|
||||
bool ok = _c.InWorld && _c.IltData.BankCommand(Host, now, verb);
|
||||
_nextBankReadMs = now + 500;
|
||||
if (_window != null) _window.NeedsPass = true;
|
||||
return ok;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads RynthILT's bank JSON while the window is open (more often on the Banking tab) and
|
||||
/// redraws when it changed. Reading is what tells RynthILT someone is looking.
|
||||
/// </summary>
|
||||
private void TickBank(long now)
|
||||
{
|
||||
if (!_c.InWorld || _window == null || _view == null || !_window.Visible) return;
|
||||
if (now < _nextBankReadMs) return;
|
||||
_nextBankReadMs = now + (_view.Tab == InventoryView.TabBanking ? BankTabReadMs : BankIdleReadMs);
|
||||
string json = _c.IltData.ReadBank(Host, now);
|
||||
if (string.Equals(json, _bankJson, StringComparison.Ordinal)) return;
|
||||
_bankJson = json;
|
||||
_c.Bank = Shared.IltBankView.Parse(json);
|
||||
_window.NeedsPass = true;
|
||||
}
|
||||
|
||||
public override void OnLogout()
|
||||
{
|
||||
// Last word for this character: write what it has now (also refreshes its "scanned" time).
|
||||
|
|
@ -138,6 +181,7 @@ public sealed class RynthInventoryPlugin : RynthPluginBase
|
|||
_ui.SubmitEmpty(Host);
|
||||
_c.Live = null;
|
||||
_indexDirty = true;
|
||||
ClearBank();
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
|
|
@ -217,12 +261,6 @@ public sealed class RynthInventoryPlugin : RynthPluginBase
|
|||
case "":
|
||||
if (_window != null) { _window.Visible = !_window.Visible; _window.NeedsPass = true; }
|
||||
break;
|
||||
// Old Mini Remote "Banking" tab ("/ginv bank"): open Global Inventory (don't search
|
||||
// for "bank"). Storage containers still show when Include Storage is on.
|
||||
case "bank":
|
||||
case "banking":
|
||||
if (_window != null) { _window.Visible = true; _window.NeedsPass = true; }
|
||||
break;
|
||||
case "scan":
|
||||
case "rescan":
|
||||
_scheduler.RequestFullScan();
|
||||
|
|
@ -245,9 +283,17 @@ public sealed class RynthInventoryPlugin : RynthPluginBase
|
|||
case "status":
|
||||
PrintStatus();
|
||||
break;
|
||||
case "bank":
|
||||
case "banking":
|
||||
// The Banking tab (the Mini Remote's Banking tab moved here 2026-10-13; RynthCore,
|
||||
// RynthAi and RynthILT link here). Shows, never toggles off.
|
||||
_view?.ShowBanking();
|
||||
_nextBankReadMs = 0;
|
||||
if (_window != null) { _window.Visible = true; _window.NeedsPass = true; }
|
||||
break;
|
||||
case "help":
|
||||
case "?":
|
||||
_c.Print("/ginv (window), /ginv bank (same), /ginv <text> (search), /ginv scan (rescan and save now), /ginv keep (record the open container as storage), /ginv vault (read the Aelrynth account vault now), /ginv reload, /ginv status");
|
||||
_c.Print("/ginv (window), /ginv <text> (search), /ginv bank (every character's Infinite Leaftide bank), /ginv scan (rescan and save now), /ginv keep (record the open container as storage), /ginv vault (read the Aelrynth account vault now), /ginv reload, /ginv status");
|
||||
break;
|
||||
default:
|
||||
_view?.SetSearch(arg);
|
||||
|
|
@ -315,6 +361,7 @@ public sealed class RynthInventoryPlugin : RynthPluginBase
|
|||
}
|
||||
TickWrite(now);
|
||||
TickIndex(now);
|
||||
TickBank(now);
|
||||
|
||||
if (!Host.HasUi || _window == null || _view == null) return;
|
||||
Record(_window, now, 2000, _view.Draw);
|
||||
|
|
|
|||
237
Plugins/RynthCore.Plugin.RynthInventory/Views/BankingTab.cs
Normal file
237
Plugins/RynthCore.Plugin.RynthInventory/Views/BankingTab.cs
Normal file
|
|
@ -0,0 +1,237 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using RynthCore.Plugin.RynthInventory.Data;
|
||||
using RynthCore.Plugin.RynthInventory.Ui;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthInventory.Views;
|
||||
|
||||
/// <summary>
|
||||
/// Banking: the Infinite Leaftide bank of every character on this server (the Mini Remote's Banking
|
||||
/// tab moved here 2026-10-13). Balances, form choices and the last reply come from RynthILT's
|
||||
/// "RynthILT.Data" bank JSON; the character list adds the inventory's characters on the same server
|
||||
/// (BankRoster). Deposits, withdrawals, transfers and balance reads go back to RynthILT as verb lines;
|
||||
/// a transfer is confirmed here first (RynthILT doesn't ask again).
|
||||
/// </summary>
|
||||
internal sealed partial class InventoryView
|
||||
{
|
||||
private const int MaxTransactionsShown = 20;
|
||||
private const float ColPyreals = 150f, ColLum = 270f, ColKeys = 380f, ColCoins = 450f, ColUpdated = 560f;
|
||||
|
||||
private int _depositIndex, _withdrawIndex, _withdrawNote, _transferIndex, _transferNote;
|
||||
private string _withdrawAmount = string.Empty, _transferAmount = string.Empty, _transferTo = string.Empty;
|
||||
/// <summary>The transfer waiting for "Yes, send": its verb line and the sentence shown.</summary>
|
||||
private (string Verb, string Text)? _confirmTransfer;
|
||||
private string _bankMessage = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The Banking tab button shows when RynthILT answered on an ILT world, or when the tab was asked
|
||||
/// for (/ginv bank) so it can say what is missing.
|
||||
/// </summary>
|
||||
private bool BankingShown => Tab == TabBanking || (_c.Bank.Loaded && _c.Bank.Available);
|
||||
|
||||
/// <summary>Opens on the Banking tab ("/ginv bank", RynthAi's and RynthILT's bank links).</summary>
|
||||
public void ShowBanking()
|
||||
{
|
||||
Tab = TabBanking;
|
||||
_confirmTransfer = null;
|
||||
}
|
||||
|
||||
private void DrawBanking(UiWindow w)
|
||||
{
|
||||
IltBankView b = _c.Bank;
|
||||
if (!b.Loaded)
|
||||
{
|
||||
w.TextDisabled("The bank comes from RynthILT (Infinite Leaftide). Load RynthILT to see every character's bank here.");
|
||||
return;
|
||||
}
|
||||
if (!b.Available)
|
||||
{
|
||||
w.TextDisabled("This isn't an Infinite Leaftide world, so there is no bank to show.");
|
||||
return;
|
||||
}
|
||||
|
||||
w.Text($"Bank on {(b.World.Length > 0 ? b.World : "this server")}");
|
||||
w.SameLine();
|
||||
w.SmallButton("Refresh", "b.refresh", () => SendBank(IltBankView.RefreshVerb(), "Reading the balance..."));
|
||||
w.Tooltip("A quiet /bank balance read for the character you're on (other characters update when they log in).");
|
||||
if (b.Enabled == 0) w.TextColored(UiColors.Red, "This server has no /bank command.");
|
||||
else if (b.Enabled < 0) w.TextDisabled("Whether this server has /bank isn't known yet.");
|
||||
if (b.Result.Length > 0) w.TextColored(UiColors.Gold, b.Result);
|
||||
if (_bankMessage.Length > 0) w.TextColored(UiColors.Yellow, _bankMessage);
|
||||
|
||||
List<BankRosterEntry> roster = BankRoster.Build(b, _c.Index);
|
||||
DrawBankTable(w, roster);
|
||||
if (b.Enabled != 0)
|
||||
{
|
||||
DrawDeposit(w, b);
|
||||
DrawWithdraw(w, b);
|
||||
DrawTransfer(w, b, roster);
|
||||
}
|
||||
DrawTransactions(w, b);
|
||||
}
|
||||
|
||||
private void DrawBankTable(UiWindow w, List<BankRosterEntry> roster)
|
||||
{
|
||||
w.SeparatorText($"Characters ({roster.Count})");
|
||||
w.TextDisabled("Character");
|
||||
w.SameLine(ColPyreals); w.TextDisabled("Pyreals");
|
||||
w.SameLine(ColLum); w.TextDisabled("Luminance");
|
||||
w.SameLine(ColKeys); w.TextDisabled("Keys L/M");
|
||||
w.SameLine(ColCoins); w.TextDisabled("Coins E/W/P");
|
||||
w.SameLine(ColUpdated); w.TextDisabled("Updated");
|
||||
foreach (BankRosterEntry e in roster)
|
||||
{
|
||||
string name = e.Current ? e.Name + " (you)" : e.Name;
|
||||
if (e.Bank is { } r)
|
||||
{
|
||||
w.Text(name);
|
||||
if (e.Account.Length > 0) w.Tooltip("Account: " + e.Account);
|
||||
BankCells(w, r);
|
||||
w.SameLine(ColUpdated);
|
||||
w.TextDisabled(r.UpdatedUtc == DateTime.MinValue ? "-" : InventoryIndex.Age(r.UpdatedUtc, _c.UtcNow));
|
||||
}
|
||||
else
|
||||
{
|
||||
w.TextDisabled(name);
|
||||
if (e.Account.Length > 0) w.Tooltip("Account: " + e.Account);
|
||||
w.SameLine(ColPyreals);
|
||||
w.TextDisabled("not read yet: log in with RynthILT loaded");
|
||||
}
|
||||
}
|
||||
if (roster.Count == 0) w.TextDisabled("No characters on this server yet.");
|
||||
else
|
||||
{
|
||||
w.TextColored(UiColors.Gold, "Total");
|
||||
BankCells(w, BankRoster.Totals(roster));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The balance columns of one row (Pyreals .. Coins).</summary>
|
||||
private static void BankCells(UiWindow w, IltBankRow r)
|
||||
{
|
||||
w.SameLine(ColPyreals); w.Text(N(r.Pyreals));
|
||||
w.SameLine(ColLum); w.Text(N(r.Luminance));
|
||||
w.SameLine(ColKeys); w.Text($"{N(r.LegendaryKeys)}/{N(r.MythicalKeys)}");
|
||||
w.SameLine(ColCoins); w.Text($"{N(r.EnlightenedCoins)}/{N(r.WeaklyEnlightenedCoins)}/{N(r.PrestigeCoins)}");
|
||||
}
|
||||
|
||||
private void DrawDeposit(UiWindow w, IltBankView b)
|
||||
{
|
||||
if (b.Deposits.Count == 0) return;
|
||||
w.SeparatorText("Deposit");
|
||||
_depositIndex = Math.Clamp(_depositIndex, 0, b.Deposits.Count - 1);
|
||||
w.Combo("What", "b.dep.what", _depositIndex, b.Deposits, i => _depositIndex = i);
|
||||
w.SameLine();
|
||||
int di = _depositIndex;
|
||||
string label = b.Deposits[di];
|
||||
w.SmallButton("Deposit", "b.dep.go", () => SendBank(IltBankView.DepositVerb(di), "Depositing " + label + "..."));
|
||||
}
|
||||
|
||||
private void DrawWithdraw(UiWindow w, IltBankView b)
|
||||
{
|
||||
if (b.Withdrawals.Count == 0) return;
|
||||
w.SeparatorText("Withdraw");
|
||||
_withdrawIndex = Math.Clamp(_withdrawIndex, 0, b.Withdrawals.Count - 1);
|
||||
w.Combo("Currency", "b.wd.what", _withdrawIndex, Labels(b.Withdrawals), i => _withdrawIndex = i);
|
||||
IltBankChoice choice = b.Withdrawals[_withdrawIndex];
|
||||
w.InputText(choice.Notes ? "Notes" : "Amount", "b.wd.amt", _withdrawAmount, 20, v => _withdrawAmount = v);
|
||||
int note = NoteCombo(w, b, choice, "b.wd.note", _withdrawNote, i => _withdrawNote = i);
|
||||
w.SameLine();
|
||||
int wi = _withdrawIndex;
|
||||
w.SmallButton("Withdraw", "b.wd.go", () =>
|
||||
{
|
||||
long amount = BankRoster.ParseAmount(_withdrawAmount);
|
||||
if (amount <= 0) { _bankMessage = "Type a whole number to withdraw."; return; }
|
||||
SendBank(IltBankView.WithdrawVerb(wi, amount, note), $"Withdrawing {N(amount)} {choice.Label}...");
|
||||
});
|
||||
}
|
||||
|
||||
private void DrawTransfer(UiWindow w, IltBankView b, List<BankRosterEntry> roster)
|
||||
{
|
||||
if (b.Transfers.Count == 0) return;
|
||||
w.SeparatorText("Transfer");
|
||||
_transferIndex = Math.Clamp(_transferIndex, 0, b.Transfers.Count - 1);
|
||||
w.Combo("Currency", "b.tx.what", _transferIndex, Labels(b.Transfers), i => { _transferIndex = i; _confirmTransfer = null; });
|
||||
IltBankChoice choice = b.Transfers[_transferIndex];
|
||||
w.InputText(choice.Notes ? "Notes" : "Amount", "b.tx.amt", _transferAmount, 20, v => { _transferAmount = v; _confirmTransfer = null; });
|
||||
int note = NoteCombo(w, b, choice, "b.tx.note", _transferNote, i => { _transferNote = i; _confirmTransfer = null; });
|
||||
w.InputText("To", "b.tx.to", _transferTo, 40, v => { _transferTo = v; _confirmTransfer = null; });
|
||||
|
||||
// The other characters on this server, to fill "To" with one click.
|
||||
var others = new List<string> { "Pick a character..." };
|
||||
foreach (BankRosterEntry e in roster) if (!e.Current) others.Add(e.Name);
|
||||
if (others.Count > 1)
|
||||
{
|
||||
w.SameLine();
|
||||
w.Combo("##pick", "b.tx.pick", 0, others, i => { if (i > 0 && i < others.Count) { _transferTo = others[i]; _confirmTransfer = null; } });
|
||||
}
|
||||
|
||||
if (_confirmTransfer is { } pending)
|
||||
{
|
||||
w.TextColored(UiColors.Red, pending.Text);
|
||||
w.SmallButton("Yes, send", "b.tx.yes", () =>
|
||||
{
|
||||
_confirmTransfer = null;
|
||||
SendBank(pending.Verb, "Transfer sent...");
|
||||
});
|
||||
w.SameLine();
|
||||
w.SmallButton("Cancel", "b.tx.no", () => _confirmTransfer = null);
|
||||
return;
|
||||
}
|
||||
int ti = _transferIndex;
|
||||
w.SmallButton("Transfer...", "b.tx.go", () =>
|
||||
{
|
||||
long amount = BankRoster.ParseAmount(_transferAmount);
|
||||
string to = (_transferTo ?? string.Empty).Trim();
|
||||
if (amount <= 0) { _bankMessage = "Type a whole number to transfer."; return; }
|
||||
if (to.Length == 0) { _bankMessage = "Type (or pick) who gets the transfer."; return; }
|
||||
string what = choice.Notes && note < b.Notes.Count ? $"{N(amount)} x {b.Notes[note].Label}" : $"{N(amount)} {choice.Label}";
|
||||
_confirmTransfer = (IltBankView.TransferVerb(ti, amount, note, to), $"Send {what} to {to}? This can't be undone.");
|
||||
_bankMessage = string.Empty;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The trade-note combo for a choice that counts notes; returns the note index in use (0 when
|
||||
/// the choice isn't notes). A pick arrives as an event and lands in <paramref name="set"/>.
|
||||
/// </summary>
|
||||
private static int NoteCombo(UiWindow w, IltBankView b, IltBankChoice choice, string id, int index, Action<int> set)
|
||||
{
|
||||
if (!choice.Notes || b.Notes.Count == 0) return 0;
|
||||
var labels = new List<string>(b.Notes.Count);
|
||||
foreach (IltBankNote n in b.Notes) labels.Add($"{n.Label} ({N(n.Value)} pyreals)");
|
||||
index = Math.Clamp(index, 0, b.Notes.Count - 1);
|
||||
w.Combo("Note", id, index, labels, set);
|
||||
return index;
|
||||
}
|
||||
|
||||
private void DrawTransactions(UiWindow w, IltBankView b)
|
||||
{
|
||||
if (b.Transactions.Count == 0) return;
|
||||
if (!w.CollapsingHeader($"Recent transfers ({b.Transactions.Count})", "b.txlog")) return;
|
||||
int shown = 0;
|
||||
foreach (IltBankTx t in b.Transactions)
|
||||
{
|
||||
if (shown++ >= MaxTransactionsShown) { w.TextDisabled($"...and {b.Transactions.Count - MaxTransactionsShown} more."); break; }
|
||||
string dir = t.Type.Length > 0 ? t.Type : "?";
|
||||
w.Text($"{t.When} {dir} {N(t.Amount)} {t.Currency}{(t.Player.Length > 0 ? " - " + t.Player : "")}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Hands a verb to RynthILT; says so when it was refused.</summary>
|
||||
private void SendBank(string verb, string sending)
|
||||
{
|
||||
_bankMessage = _c.BankCommand(verb) ? sending : "RynthILT didn't take that (is it loaded, and are you logged in?).";
|
||||
}
|
||||
|
||||
private static List<string> Labels(IReadOnlyList<IltBankChoice> choices)
|
||||
{
|
||||
var list = new List<string>(choices.Count);
|
||||
foreach (IltBankChoice c in choices) list.Add(c.Label);
|
||||
return list;
|
||||
}
|
||||
|
||||
private static string N(long n) => n.ToString("N0", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
|
@ -8,12 +8,12 @@ namespace RynthCore.Plugin.RynthInventory.Views;
|
|||
|
||||
/// <summary>
|
||||
/// The Global Inventory window: a search page (every character on every server, filters,
|
||||
/// totals, results, details) and a characters page (snapshot ages, forget). Recorded on the
|
||||
/// pump thread, replayed by the engine.
|
||||
/// totals, results, details), a characters page (snapshot ages, forget) and, with RynthILT, a
|
||||
/// Banking page (Views\BankingTab.cs). Recorded on the pump thread, replayed by the engine.
|
||||
/// </summary>
|
||||
internal sealed class InventoryView
|
||||
internal sealed partial class InventoryView
|
||||
{
|
||||
public const int TabSearch = 0, TabCharacters = 1;
|
||||
public const int TabSearch = 0, TabCharacters = 1, TabBanking = 2;
|
||||
private const int PageSize = 100;
|
||||
private const float RowIcon = 18f, DetailIcon = 32f, DetailsHeight = 190f;
|
||||
|
||||
|
|
@ -58,10 +58,21 @@ internal sealed class InventoryView
|
|||
w.SameLine();
|
||||
int chars = _c.Index?.Characters.Count ?? 0;
|
||||
w.ToggleButton($"Characters ({chars})", "tab.chars", Tab == TabCharacters, () => Tab = TabCharacters, small: true);
|
||||
if (BankingShown)
|
||||
{
|
||||
w.SameLine();
|
||||
w.ToggleButton("Banking", "tab.bank", Tab == TabBanking, () => Tab = TabBanking, small: true);
|
||||
}
|
||||
w.SameLine();
|
||||
w.TextDisabled(StatusLine());
|
||||
w.Separator();
|
||||
|
||||
// The bank comes from RynthILT, not the inventory files: it draws before they are read.
|
||||
if (Tab == TabBanking)
|
||||
{
|
||||
DrawBanking(w);
|
||||
return;
|
||||
}
|
||||
if (_c.Index == null)
|
||||
{
|
||||
w.TextDisabled(_c.Loading ? "Reading the inventory files..." : "No inventory read yet.");
|
||||
|
|
|
|||
178
Plugins/RynthCore.Plugin.RynthJuice/EnvCellTransforms.cs
Normal file
178
Plugins/RynthCore.Plugin.RynthJuice/EnvCellTransforms.cs
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using RynthCore.Install;
|
||||
using RynthCore.Plugin.RynthAi.Raycasting; // DatDatabase lives in the RynthCore.TerrainData assembly under this namespace
|
||||
|
||||
namespace RynthCore.Plugin.RynthJuice;
|
||||
|
||||
/// <summary>
|
||||
/// Converts an INDOOR (dungeon) object's CELL-LOCAL origin into LANDBLOCK-RELATIVE
|
||||
/// coordinates by reading the object's EnvCell transform (position + rotation)
|
||||
/// from the client's cell.dat. The engine builds its view matrix in landblock
|
||||
/// space even indoors (GameMatrixCapture reads AC's pre-composed viewer pose), so
|
||||
/// once a mob's position is landblock-relative the existing WorldToScreen pipeline
|
||||
/// projects it correctly inside dungeons.
|
||||
///
|
||||
/// Uses the shared TerrainData <see cref="DatDatabase"/> (the same parser
|
||||
/// RynthVision uses) — this does NOT pull in RynthAi. Outdoor cells (low word
|
||||
/// < 0x100) pass through unchanged. cell.dat is opened lazily on first indoor
|
||||
/// use, from the running client's own folder, and per-cell transforms are cached.
|
||||
/// </summary>
|
||||
internal sealed class EnvCellTransforms : IDisposable
|
||||
{
|
||||
private DatDatabase? _cellDat;
|
||||
private bool _tried;
|
||||
private bool _ready;
|
||||
private readonly Dictionary<uint, Cell> _cache = new();
|
||||
|
||||
private struct Cell
|
||||
{
|
||||
public bool Ok;
|
||||
public float Px, Py, Pz; // cell position within the landblock
|
||||
public float Rw, Rx, Ry, Rz; // cell rotation quaternion
|
||||
}
|
||||
|
||||
public bool Ready => _ready;
|
||||
public string Status { get; private set; } = "uninitialized";
|
||||
|
||||
/// <summary>
|
||||
/// If <paramref name="cellId"/> is indoor, rewrites (e,n,u) from cell-local to
|
||||
/// landblock-relative and returns true; returns false if the transform can't be
|
||||
/// resolved (no cell.dat / no record). Outdoor cells return true unchanged.
|
||||
/// </summary>
|
||||
public bool ToLandblockRelative(uint cellId, ref float e, ref float n, ref float u)
|
||||
{
|
||||
if ((cellId & 0xFFFF) < 0x100)
|
||||
return true; // outdoor: origin is already landblock-local
|
||||
|
||||
if (!EnsureOpen())
|
||||
return false;
|
||||
if (!TryGetCell(cellId, out Cell c) || !c.Ok)
|
||||
return false;
|
||||
|
||||
// world_landblock = rotate(local, quat) + cellPos (matches DungeonLOS.TransformVertex)
|
||||
float lx = e, ly = n, lz = u;
|
||||
float cx = c.Ry * lz - c.Rz * ly;
|
||||
float cy = c.Rz * lx - c.Rx * lz;
|
||||
float cz = c.Rx * ly - c.Ry * lx;
|
||||
float cx2 = c.Ry * cz - c.Rz * cy;
|
||||
float cy2 = c.Rz * cx - c.Rx * cz;
|
||||
float cz2 = c.Rx * cy - c.Ry * cx;
|
||||
e = lx + 2f * (c.Rw * cx + cx2) + c.Px;
|
||||
n = ly + 2f * (c.Rw * cy + cy2) + c.Py;
|
||||
u = lz + 2f * (c.Rw * cz + cz2) + c.Pz;
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool EnsureOpen()
|
||||
{
|
||||
if (_tried) return _ready;
|
||||
_tried = true;
|
||||
|
||||
// The running client's own folder may hold cell.dat with an exclusive lock
|
||||
// (AC opened it first, before our share-hook, when launched by another tool).
|
||||
// cell.dat is identical across installs, so fall back to any other AC copy
|
||||
// whose handle isn't locked. Surface the exact per-path failure for diag.
|
||||
var tried = new List<string>();
|
||||
var seen = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (string folder in CandidateFolders())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(folder) || !Directory.Exists(folder)) continue;
|
||||
string? path = FindDat(folder, "client_cell_1.dat", "cell.dat");
|
||||
if (path == null) { tried.Add($"{folder}=no-dat"); continue; }
|
||||
if (!seen.Add(Path.GetFullPath(path))) continue; // don't retry the same file
|
||||
|
||||
var db = new DatDatabase();
|
||||
if (db.Open(path))
|
||||
{
|
||||
_cellDat = db;
|
||||
_ready = true;
|
||||
Status = $"ready: {path}";
|
||||
return true;
|
||||
}
|
||||
string err = db.DiagLog.Count > 0 ? db.DiagLog[db.DiagLog.Count - 1] : "open=false";
|
||||
tried.Add($"{path} -> {err}");
|
||||
try { db.Dispose(); } catch { }
|
||||
}
|
||||
catch (Exception ex) { tried.Add($"{folder} -> {ex.Message}"); }
|
||||
}
|
||||
|
||||
Status = "cell.dat open failed; tried: " + (tried.Count > 0 ? string.Join(" | ", tried) : "(no candidates)");
|
||||
return false;
|
||||
}
|
||||
|
||||
// cell.dat search locations, in priority order: the running client's folder
|
||||
// first, then well-known AC installs. Identical data in each, so any that
|
||||
// opens works.
|
||||
private static IEnumerable<string> CandidateFolders()
|
||||
{
|
||||
string? exe = Environment.ProcessPath;
|
||||
string? exeDir = string.IsNullOrEmpty(exe) ? null : Path.GetDirectoryName(exe);
|
||||
if (!string.IsNullOrEmpty(exeDir)) yield return exeDir!;
|
||||
yield return Path.Combine(RynthInstallPaths.CoreDir, "AcClient"); // RynthCore's private client copy
|
||||
yield return @"C:\Turbine\Asheron's Call";
|
||||
yield return @"C:\Games\Asheron's Call";
|
||||
yield return @"C:\Program Files (x86)\Turbine\Asheron's Call";
|
||||
yield return @"C:\Program Files\Turbine\Asheron's Call";
|
||||
}
|
||||
|
||||
private bool TryGetCell(uint cellId, out Cell c)
|
||||
{
|
||||
if (_cache.TryGetValue(cellId, out c))
|
||||
return true;
|
||||
c = default;
|
||||
try
|
||||
{
|
||||
byte[]? data = _cellDat!.GetFileData(cellId);
|
||||
if (data != null && data.Length >= 0x30)
|
||||
ParseEnvCell(data, ref c);
|
||||
}
|
||||
catch { c.Ok = false; }
|
||||
_cache[cellId] = c; // cache failures too (avoid re-reading missing cells)
|
||||
return true;
|
||||
}
|
||||
|
||||
// EnvCell header (matches RynthAi DungeonLOS.ParseEnvCellHeader exactly):
|
||||
// u32 id, u32 flags, u32 cellId, u8 numSurfaces, u8 numPortals,
|
||||
// u16 numVisibleCells, [numSurfaces × u16], u16 envId, u16 cellStruct,
|
||||
// f32 PosX, PosY, PosZ, RotW, RotX, RotY, RotZ
|
||||
private static void ParseEnvCell(byte[] data, ref Cell c)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var ms = new MemoryStream(data);
|
||||
using var r = new BinaryReader(ms);
|
||||
r.ReadUInt32(); r.ReadUInt32(); r.ReadUInt32();
|
||||
byte numSurfaces = r.ReadByte();
|
||||
r.ReadByte(); // numPortals
|
||||
r.ReadUInt16(); // numVisibleCells
|
||||
ms.Seek(numSurfaces * 2, SeekOrigin.Current);
|
||||
r.ReadUInt16(); // envId
|
||||
r.ReadUInt16(); // cellStruct
|
||||
c.Px = r.ReadSingle(); c.Py = r.ReadSingle(); c.Pz = r.ReadSingle();
|
||||
c.Rw = r.ReadSingle(); c.Rx = r.ReadSingle(); c.Ry = r.ReadSingle(); c.Rz = r.ReadSingle();
|
||||
c.Ok = true;
|
||||
}
|
||||
catch { c.Ok = false; }
|
||||
}
|
||||
|
||||
private static string? FindDat(string folder, params string[] names)
|
||||
{
|
||||
foreach (string nm in names)
|
||||
{
|
||||
string p = Path.Combine(folder, nm);
|
||||
if (File.Exists(p)) return p;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
try { _cellDat?.Dispose(); } catch { }
|
||||
_cellDat = null;
|
||||
_ready = false;
|
||||
}
|
||||
}
|
||||
419
Plugins/RynthCore.Plugin.RynthJuice/JuiceEffects.cs
Normal file
419
Plugins/RynthCore.Plugin.RynthJuice/JuiceEffects.cs
Normal file
|
|
@ -0,0 +1,419 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using RynthCore.PluginSdk;
|
||||
|
||||
namespace RynthCore.Plugin.RynthJuice;
|
||||
|
||||
/// <summary>
|
||||
/// Owns the live combat-juice effects and renders them every tick through the
|
||||
/// engine's Nav3D world-space API. Floating numbers are drawn as billboarded
|
||||
/// vector-digit glyphs (quads built from <see cref="RynthCoreHost.Nav3DAddTriangle"/>);
|
||||
/// kill bursts are expanding rings.
|
||||
///
|
||||
/// Coordinate frames (see GameMatrixCapture / RadarRingOverlay):
|
||||
/// • Object/player positions are AC convention: x=EW(east), y=NS(north), z=height(up),
|
||||
/// local to that object's LANDBLOCK (0–192), outdoors only.
|
||||
/// • Nav3D and WorldToScreen want a Y-up player-landblock-local frame: (east, up, north).
|
||||
/// • A target in a different landblock than the player is shifted by
|
||||
/// (Δlandblock × 192) per axis before projecting — mirroring the engine's own
|
||||
/// camera re-anchor in GameMatrixCapture.
|
||||
/// </summary>
|
||||
internal sealed class JuiceEffects
|
||||
{
|
||||
public enum Kind { MobDamage, Heal, PlayerDamage }
|
||||
|
||||
private sealed class Effect
|
||||
{
|
||||
public bool IsBurst;
|
||||
public uint CellId;
|
||||
public float E0, N0, U0; // anchor in the effect's own landblock-local frame (AC: E,N,U)
|
||||
public string Text = "";
|
||||
public uint Color;
|
||||
public bool Crit;
|
||||
public Kind Kind;
|
||||
public long BirthMs;
|
||||
public float Life; // seconds
|
||||
}
|
||||
|
||||
private readonly List<Effect> _fx = new();
|
||||
private readonly object _lock = new();
|
||||
private EnvCellTransforms? _cells;
|
||||
|
||||
private const int MaxEffects = 48;
|
||||
private const float CritScale = 1.5f;
|
||||
|
||||
/// <summary>Wires the dungeon EnvCell transform reader (enables indoor numbers).</summary>
|
||||
public void SetCells(EnvCellTransforms cells) => _cells = cells;
|
||||
|
||||
// Diagnostics (read by /juice diag): why Render last bailed + what it emitted.
|
||||
public string LastRenderStatus { get; private set; } = "(not ticked yet)";
|
||||
public int LastDrawnEffects { get; private set; }
|
||||
public int LastTriangles { get; private set; }
|
||||
private int _frameDrawn, _frameTris;
|
||||
|
||||
// ── Spawning (called from event handlers) ────────────────────────────────
|
||||
|
||||
public void SpawnDamage(uint cellId, float e, float n, float u, int amount, bool crit)
|
||||
=> Add(cellId, e, n, u, FormatAmount(amount, crit), crit ? Gold : DamageColor(amount), crit, Kind.MobDamage);
|
||||
|
||||
public void SpawnHeal(uint cellId, float e, float n, float u, int amount)
|
||||
=> Add(cellId, e, n, u, "+" + amount.ToString(), Green, false, Kind.Heal);
|
||||
|
||||
public void SpawnPlayerDamage(uint cellId, float e, float n, float u, int amount, bool crit)
|
||||
=> Add(cellId, e, n, u, FormatAmount(amount, crit), crit ? Gold : PlayerRed, crit, Kind.PlayerDamage);
|
||||
|
||||
public void SpawnKillBurst(uint cellId, float e, float n, float u, bool crit, long nowMs)
|
||||
{
|
||||
if (!Resolve(cellId, ref e, ref n, ref u)) return;
|
||||
lock (_lock)
|
||||
{
|
||||
TrimLocked();
|
||||
_fx.Add(new Effect
|
||||
{
|
||||
IsBurst = true,
|
||||
CellId = cellId, E0 = e, N0 = n, U0 = u,
|
||||
Color = 0xFF60FFFF, // bright cyan — max visibility for the "is it working?" test
|
||||
BirthMs = nowMs,
|
||||
Life = 1.6f,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Upgrade the most recent damage number to a crit (handles crit chat
|
||||
/// arriving just after the health packet). Returns true if one was upgraded.</summary>
|
||||
public bool UpgradeRecentToCrit(long nowMs, int windowMs)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
for (int i = _fx.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var f = _fx[i];
|
||||
if (f.IsBurst || f.Kind == Kind.Heal || f.Crit) continue;
|
||||
if (nowMs - f.BirthMs > windowMs) break; // list is append-ordered; older beyond window
|
||||
f.Crit = true;
|
||||
f.Color = Gold;
|
||||
f.Text = EnsureBang(f.Text);
|
||||
f.Life = MathF.Max(f.Life, 1.7f);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>Overwrite the most recent matching damage number with the exact
|
||||
/// amount parsed from the combat log (the health-packet anchor stays). Returns
|
||||
/// true if one was updated within the window.</summary>
|
||||
public bool ApplyExactToRecent(long nowMs, int windowMs, Kind kind, int amount, bool crit)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
for (int i = _fx.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var f = _fx[i];
|
||||
if (nowMs - f.BirthMs > windowMs) break; // append-ordered → all earlier are older
|
||||
if (f.IsBurst || f.Kind != kind) continue;
|
||||
f.Crit = f.Crit || crit;
|
||||
f.Text = FormatAmount(amount, f.Crit);
|
||||
f.Color = f.Crit ? Gold : (kind == Kind.PlayerDamage ? PlayerRed : DamageColor(amount));
|
||||
if (f.Crit) f.Life = MathF.Max(f.Life, 1.7f);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Clear() { lock (_lock) _fx.Clear(); }
|
||||
public int Count { get { lock (_lock) return _fx.Count; } }
|
||||
|
||||
private void Add(uint cellId, float e, float n, float u, string text, uint color, bool crit, Kind kind)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text)) return;
|
||||
if (!Resolve(cellId, ref e, ref n, ref u)) return; // indoor w/o cell transform → skip
|
||||
lock (_lock)
|
||||
{
|
||||
TrimLocked();
|
||||
_fx.Add(new Effect
|
||||
{
|
||||
CellId = cellId, E0 = e, N0 = n, U0 = u,
|
||||
Text = text, Color = color, Crit = crit, Kind = kind,
|
||||
BirthMs = Environment.TickCount64,
|
||||
Life = crit ? 1.7f : (kind == Kind.Heal ? 1.15f : 1.35f),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void TrimLocked()
|
||||
{
|
||||
// Drop the oldest non-burst effect if we're at the cap (keep bursts; they're brief).
|
||||
while (_fx.Count >= MaxEffects)
|
||||
{
|
||||
int idx = _fx.FindIndex(f => !f.IsBurst);
|
||||
_fx.RemoveAt(idx >= 0 ? idx : 0);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Rendering (called from OnTick) ───────────────────────────────────────
|
||||
|
||||
public void Render(RynthCoreHost host, JuiceSettings cfg, long nowMs)
|
||||
{
|
||||
if (!host.HasNav3D || !host.HasNav3DTriangle)
|
||||
{ LastRenderStatus = $"no-nav3d (nav={host.HasNav3D} tri={host.HasNav3DTriangle})"; return; }
|
||||
|
||||
if (!host.TryGetPlayerPose(out uint pCell, out float pE, out float pN, out float pU,
|
||||
out _, out _, out _, out _))
|
||||
{ LastRenderStatus = "no-pose"; return; }
|
||||
if ((pCell >> 16) == 0)
|
||||
{ LastRenderStatus = "portalspace"; return; }
|
||||
// Indoors, convert the player's cell-local pose to landblock-relative so
|
||||
// distance math agrees with the (already landblock-relative) anchors.
|
||||
if (!Resolve(pCell, ref pE, ref pN, ref pU))
|
||||
{ LastRenderStatus = "player-resolve-fail (indoor cell.dat unavailable?)"; return; }
|
||||
uint playerLb = pCell >> 16;
|
||||
|
||||
_frameDrawn = 0; _frameTris = 0;
|
||||
int culFar = 0, culDist = 0;
|
||||
lock (_lock)
|
||||
{
|
||||
for (int i = _fx.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var f = _fx[i];
|
||||
float age = (nowMs - f.BirthMs) / 1000f;
|
||||
if (age >= f.Life) { _fx.RemoveAt(i); continue; }
|
||||
if (f.CellId >> 16 == 0) { _fx.RemoveAt(i); continue; }
|
||||
|
||||
// Shift the effect's own-landblock anchor into the player's frame.
|
||||
int dXb = (int)(((f.CellId >> 16 >> 8) & 0xFF)) - (int)((playerLb >> 8) & 0xFF);
|
||||
int dYb = (int)(((f.CellId >> 16) & 0xFF)) - (int)(playerLb & 0xFF);
|
||||
if (Math.Abs(dXb) > 3 || Math.Abs(dYb) > 3) { culFar++; continue; } // too far / region junk
|
||||
float aE = f.E0 + dXb * 192f;
|
||||
float aN = f.N0 + dYb * 192f;
|
||||
|
||||
// Distance cull (horizontal).
|
||||
float dE = aE - pE, dN = aN - pN;
|
||||
if (dE * dE + dN * dN > cfg.MaxDistance * cfg.MaxDistance) { culDist++; continue; }
|
||||
|
||||
if (f.IsBurst) { RenderBurst(host, f, aE, aN, age); _frameDrawn++; }
|
||||
else RenderNumber(host, cfg, f, aE, aN, age); // self-counts _frameDrawn on success
|
||||
}
|
||||
}
|
||||
LastDrawnEffects = _frameDrawn;
|
||||
LastTriangles = _frameTris;
|
||||
LastRenderStatus = $"ok fx={_fx.Count} drawn={_frameDrawn} tris={_frameTris} culFar={culFar} culDist={culDist}";
|
||||
}
|
||||
|
||||
private static void RenderBurst(RynthCoreHost host, Effect f, float aE, float aN, float age)
|
||||
{
|
||||
float t = age / f.Life; // 0→1
|
||||
float alpha = 1f - t;
|
||||
uint col = WithAlpha(f.Color, alpha);
|
||||
float baseU = f.U0 + 0.3f;
|
||||
|
||||
// Big expanding ground ring.
|
||||
float groundR = 0.6f + 8f * t;
|
||||
host.Nav3DAddRingEx(aE, baseU, aN, groundR, 0.6f, 0.5f, col);
|
||||
|
||||
// A tall bright PILLAR of stacked rings (~10 m), so a kill is unmistakable
|
||||
// even if the subtle stuff isn't landing yet. Tapers toward the top.
|
||||
const int rings = 11;
|
||||
for (int i = 0; i < rings; i++)
|
||||
{
|
||||
float h = baseU + i * 1.0f;
|
||||
float pr = 2.0f * (1f - i / (float)rings) + 0.4f;
|
||||
host.Nav3DAddRingEx(aE, h, aN, pr, 0.35f, 0.3f, col);
|
||||
}
|
||||
}
|
||||
|
||||
private void RenderNumber(RynthCoreHost host, JuiceSettings cfg, Effect f, float aE, float aN, float age)
|
||||
{
|
||||
// Animation: rise in world-up, pop-scale early, fade late.
|
||||
float rise = 1.15f * age;
|
||||
float aU = f.U0 + cfg.HeightOffset + rise;
|
||||
|
||||
float pop = 1f + (f.Crit ? 0.6f : 0.35f) * MathF.Max(0f, 1f - age / (f.Crit ? 0.14f : 0.10f));
|
||||
float kindScale = f.Kind == Kind.PlayerDamage ? 1.15f : 1f;
|
||||
float critScale = f.Crit ? CritScale : 1f;
|
||||
|
||||
float alpha = 1f;
|
||||
float fadeStart = 0.55f * f.Life;
|
||||
if (age > fadeStart) alpha = MathF.Max(0f, 1f - (age - fadeStart) / (f.Life - fadeStart));
|
||||
alpha *= MathF.Min(1f, age / 0.06f); // quick fade-in
|
||||
uint col = WithAlpha(f.Color, alpha);
|
||||
|
||||
// Size, then draw via the shared glyph routine.
|
||||
float heightPx = 22f * cfg.Scale * pop * kindScale * critScale;
|
||||
DrawGlyphs(host, aE, aU, aN, f.Text, heightPx, col);
|
||||
}
|
||||
|
||||
/// <summary>Live monster-health readout: a "NN" percentage floating over each
|
||||
/// actively-damaged mob, green→red by ratio. Persistent (re-drawn every tick so
|
||||
/// it tracks the mob and updates as it's hit), unlike the transient numbers.</summary>
|
||||
public void RenderMobHealth(RynthCoreHost host, JuiceSettings cfg, List<MobHp> mobs)
|
||||
{
|
||||
if (mobs.Count == 0 || !host.HasNav3D || !host.HasNav3DTriangle) return;
|
||||
if (!host.TryGetPlayerPose(out uint pCell, out float pE, out float pN, out float pU, out _, out _, out _, out _)) return;
|
||||
if ((pCell >> 16) == 0) return;
|
||||
if (!Resolve(pCell, ref pE, ref pN, ref pU)) return;
|
||||
uint playerLb = pCell >> 16;
|
||||
|
||||
foreach (MobHp m in mobs)
|
||||
{
|
||||
if ((m.CellId >> 16) == 0) continue;
|
||||
int dXb = (int)(((m.CellId >> 16 >> 8) & 0xFF)) - (int)((playerLb >> 8) & 0xFF);
|
||||
int dYb = (int)(((m.CellId >> 16) & 0xFF)) - (int)(playerLb & 0xFF);
|
||||
if (Math.Abs(dXb) > 3 || Math.Abs(dYb) > 3) continue;
|
||||
float aE = m.E0 + dXb * 192f;
|
||||
float aN = m.N0 + dYb * 192f;
|
||||
float dE = aE - pE, dN = aN - pN;
|
||||
if (dE * dE + dN * dN > cfg.MaxDistance * cfg.MaxDistance) continue;
|
||||
|
||||
int pct = (int)MathF.Round(Math.Clamp(m.Ratio, 0f, 1f) * 100f);
|
||||
float aU = m.U0 + cfg.HeightOffset + 0.9f; // just above the damage-number lane
|
||||
DrawGlyphs(host, aE, aU, aN, pct.ToString(), 15f * cfg.Scale, HealthColor(m.Ratio));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Billboarded vector-glyph text at a world anchor — shared by the
|
||||
/// damage numbers and the live monster-health %. False if it couldn't project.</summary>
|
||||
private bool DrawGlyphs(RynthCoreHost host, float aE, float aU, float aN, string text, float heightPx, uint col)
|
||||
{
|
||||
if (!ComputeBillboard(host, aE, aU, aN, out Vector3 uVec, out Vector3 vVec, out _, out _))
|
||||
return false;
|
||||
_frameDrawn++;
|
||||
|
||||
float cell = heightPx / VectorFont.GlyphHeight; // px per grid unit
|
||||
float halfW = MathF.Max(1.0f, cell * 0.16f); // stroke half-thickness, px
|
||||
float startGridX = -VectorFont.MeasureWidth(text) / 2f;
|
||||
|
||||
for (int ci = 0; ci < text.Length; ci++)
|
||||
{
|
||||
var strokes = VectorFont.Strokes(text[ci]);
|
||||
float charX = startGridX + ci * VectorFont.Advance;
|
||||
foreach (var s in strokes)
|
||||
{
|
||||
var p1 = new Vector2((charX + s.X) * cell, (s.Y - VectorFont.GlyphHeight / 2f) * cell);
|
||||
var p2 = new Vector2((charX + s.Z) * cell, (s.W - VectorFont.GlyphHeight / 2f) * cell);
|
||||
EmitStrokeQuad(host, aE, aU, aN, uVec, vVec, p1, p2, halfW, col);
|
||||
_frameTris += 2;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public readonly record struct MobHp(uint CellId, float E0, float N0, float U0, float Ratio);
|
||||
|
||||
private static uint HealthColor(float ratio)
|
||||
{
|
||||
if (ratio > 0.6f) return 0xFF40FF40; // green
|
||||
if (ratio > 0.3f) return 0xFFFFF040; // yellow
|
||||
if (ratio > 0.12f) return 0xFFFFA030; // orange
|
||||
return 0xFFFF3030; // red
|
||||
}
|
||||
|
||||
/// <summary>Builds one rounded-cap stroke as two world-space triangles.</summary>
|
||||
private static void EmitStrokeQuad(RynthCoreHost host, float aE, float aU, float aN,
|
||||
Vector3 u, Vector3 v, Vector2 p1, Vector2 p2, float halfW, uint col)
|
||||
{
|
||||
Vector2 d = p2 - p1;
|
||||
float len = d.Length();
|
||||
if (len < 0.0001f) return;
|
||||
d /= len;
|
||||
Vector2 perp = new(-d.Y, d.X);
|
||||
Vector2 ext = d * halfW; // extend ends so segments overlap at joints
|
||||
perp *= halfW;
|
||||
|
||||
Vector2 c0 = p1 - ext + perp;
|
||||
Vector2 c1 = p2 + ext + perp;
|
||||
Vector2 c2 = p2 + ext - perp;
|
||||
Vector2 c3 = p1 - ext - perp;
|
||||
|
||||
// px-offset → world (Nav3D frame x=E, y=U, z=N)
|
||||
(float, float, float) W(Vector2 px) =>
|
||||
(aE + px.X * u.X + px.Y * v.X,
|
||||
aU + px.X * u.Y + px.Y * v.Y,
|
||||
aN + px.X * u.Z + px.Y * v.Z);
|
||||
|
||||
var (w0e, w0u, w0n) = W(c0);
|
||||
var (w1e, w1u, w1n) = W(c1);
|
||||
var (w2e, w2u, w2n) = W(c2);
|
||||
var (w3e, w3u, w3n) = W(c3);
|
||||
|
||||
host.Nav3DAddTriangle(w0e, w0u, w0n, w1e, w1u, w1n, w2e, w2u, w2n, col);
|
||||
host.Nav3DAddTriangle(w0e, w0u, w0n, w2e, w2u, w2n, w3e, w3u, w3n, col);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finite-difference Jacobian of WorldToScreen at the anchor, then its
|
||||
/// 2×3 pseudo-inverse, giving world vectors u,v that move the projection by
|
||||
/// exactly +1px in screen x and y respectively. Constant on-screen size +
|
||||
/// automatic camera-facing billboard, with no engine-side camera basis.
|
||||
/// </summary>
|
||||
private static bool ComputeBillboard(RynthCoreHost host, float aE, float aU, float aN,
|
||||
out Vector3 u, out Vector3 v, out float sx, out float sy)
|
||||
{
|
||||
u = default; v = default; sx = sy = 0f;
|
||||
if (!host.HasWorldToScreen) return false;
|
||||
|
||||
const float h = 0.1f;
|
||||
if (!host.WorldToScreen(aE, aU, aN, out float s0x, out float s0y)) return false;
|
||||
if (!host.WorldToScreen(aE + h, aU, aN, out float eX, out float eY)) return false;
|
||||
if (!host.WorldToScreen(aE, aU + h, aN, out float uX, out float uY)) return false;
|
||||
if (!host.WorldToScreen(aE, aU, aN + h, out float nX, out float nY)) return false;
|
||||
sx = s0x; sy = s0y;
|
||||
|
||||
// Jacobian columns (screen px / metre) for the E, U, N axes.
|
||||
float jEx = (eX - s0x) / h, jEy = (eY - s0y) / h;
|
||||
float jUx = (uX - s0x) / h, jUy = (uY - s0y) / h;
|
||||
float jNx = (nX - s0x) / h, jNy = (nY - s0y) / h;
|
||||
|
||||
// J Jᵀ (2×2, symmetric) and its inverse.
|
||||
float a = jEx * jEx + jUx * jUx + jNx * jNx;
|
||||
float b = jEx * jEy + jUx * jUy + jNx * jNy;
|
||||
float dd = jEy * jEy + jUy * jUy + jNy * jNy;
|
||||
float det = a * dd - b * b;
|
||||
if (MathF.Abs(det) < 1e-7f) return false;
|
||||
float i00 = dd / det, i01 = -b / det, i11 = a / det;
|
||||
|
||||
// u = Jᵀ·(i00,i01) (screen +x); v = Jᵀ·(i01,i11) (screen +y)
|
||||
u = new Vector3(jEx * i00 + jEy * i01, jUx * i00 + jUy * i01, jNx * i00 + jNy * i01);
|
||||
v = new Vector3(jEx * i01 + jEy * i11, jUx * i01 + jUy * i11, jNx * i01 + jNy * i11);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ── Helpers ──────────────────────────────────────────────────────────────
|
||||
|
||||
// Anchor coords pass through unchanged. The diag PROVED the indoor camera/view
|
||||
// matrix is CELL-LOCAL (the player's own raw cell-local pos projects to screen
|
||||
// centre @799/1598), so RAW object coords project correctly for objects in the
|
||||
// player's cell — the EnvCell→landblock transform actually moved them OFF
|
||||
// (projXform was wrong, projRaw was right). Outdoor coords are landblock-local
|
||||
// and the per-landblock shift in Render handles cross-landblock. Indoor
|
||||
// cross-cell mobs (a different EnvCell than the player) land far away in raw
|
||||
// coords and get distance-culled rather than mis-drawn — acceptable for v1.
|
||||
private bool Resolve(uint cellId, ref float e, ref float n, ref float u) => true;
|
||||
|
||||
private const uint Gold = 0xFFFFD700;
|
||||
private const uint Green = 0xFF50FF50;
|
||||
private const uint PlayerRed = 0xFFFF2828;
|
||||
private const uint BurstOrange = 0xFFFF8C20;
|
||||
|
||||
private static uint DamageColor(int amt)
|
||||
{
|
||||
if (amt < 25) return 0xFFFFFFFF; // white
|
||||
if (amt < 60) return 0xFFFFF080; // pale yellow
|
||||
if (amt < 120) return 0xFFFFA030; // orange
|
||||
return 0xFFFF3828; // red
|
||||
}
|
||||
|
||||
private static uint WithAlpha(uint argb, float a)
|
||||
{
|
||||
uint aa = (uint)Math.Clamp(a * 255f, 0f, 255f);
|
||||
return (argb & 0x00FFFFFF) | (aa << 24);
|
||||
}
|
||||
|
||||
private static string FormatAmount(int amount, bool crit) =>
|
||||
crit ? amount.ToString() + "!" : amount.ToString();
|
||||
|
||||
private static string EnsureBang(string s) =>
|
||||
s.EndsWith("!", StringComparison.Ordinal) ? s : s + "!";
|
||||
}
|
||||
85
Plugins/RynthCore.Plugin.RynthJuice/JuiceSettings.cs
Normal file
85
Plugins/RynthCore.Plugin.RynthJuice/JuiceSettings.cs
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
namespace RynthCore.Plugin.RynthJuice;
|
||||
|
||||
/// <summary>
|
||||
/// RynthJuice tunables, persisted as a tiny key=value file at
|
||||
/// %APPDATA%\RynthCore\rynthjuice.cfg. Plain text (no JSON serializer) to stay
|
||||
/// trivially NativeAOT-safe and hand-editable.
|
||||
/// </summary>
|
||||
internal sealed class JuiceSettings
|
||||
{
|
||||
public bool Enabled = true;
|
||||
public bool ShowHeals = true; // green "+N" when a target's health rises
|
||||
public bool ShowPlayerDamage = true; // red numbers over your own character when hit
|
||||
public float Scale = 1.0f; // global size multiplier for numbers
|
||||
public float HeightOffset = 1.8f; // metres above the target origin to anchor numbers
|
||||
public float MaxDistance = 55f; // metres; skip numbers for targets farther than this
|
||||
public int MinDamage = 1; // ignore deltas below this (filters regen ticks)
|
||||
|
||||
private string _path = "";
|
||||
|
||||
public void Load()
|
||||
{
|
||||
try
|
||||
{
|
||||
string dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RynthCore");
|
||||
_path = Path.Combine(dir, "rynthjuice.cfg");
|
||||
if (!File.Exists(_path))
|
||||
return;
|
||||
|
||||
foreach (string raw in File.ReadAllLines(_path))
|
||||
{
|
||||
string line = raw.Trim();
|
||||
if (line.Length == 0 || line[0] == '#') continue;
|
||||
int eq = line.IndexOf('=');
|
||||
if (eq <= 0) continue;
|
||||
string key = line.Substring(0, eq).Trim().ToLowerInvariant();
|
||||
string val = line.Substring(eq + 1).Trim();
|
||||
Apply(key, val);
|
||||
}
|
||||
}
|
||||
catch { /* defaults stand */ }
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(_path))
|
||||
{
|
||||
string dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RynthCore");
|
||||
Directory.CreateDirectory(dir);
|
||||
_path = Path.Combine(dir, "rynthjuice.cfg");
|
||||
}
|
||||
var ic = CultureInfo.InvariantCulture;
|
||||
File.WriteAllText(_path,
|
||||
"# RynthCore RynthJuice settings\n" +
|
||||
$"enabled={(Enabled ? 1 : 0)}\n" +
|
||||
$"heals={(ShowHeals ? 1 : 0)}\n" +
|
||||
$"playerdamage={(ShowPlayerDamage ? 1 : 0)}\n" +
|
||||
$"scale={Scale.ToString("0.##", ic)}\n" +
|
||||
$"height={HeightOffset.ToString("0.##", ic)}\n" +
|
||||
$"maxdist={MaxDistance.ToString("0.##", ic)}\n" +
|
||||
$"mindamage={MinDamage}\n");
|
||||
}
|
||||
catch { /* non-fatal */ }
|
||||
}
|
||||
|
||||
private void Apply(string key, string val)
|
||||
{
|
||||
var ic = CultureInfo.InvariantCulture;
|
||||
switch (key)
|
||||
{
|
||||
case "enabled": Enabled = val is "1" or "true"; break;
|
||||
case "heals": ShowHeals = val is "1" or "true"; break;
|
||||
case "playerdamage": ShowPlayerDamage = val is "1" or "true"; break;
|
||||
case "scale": if (float.TryParse(val, NumberStyles.Float, ic, out var s)) Scale = Math.Clamp(s, 0.3f, 4f); break;
|
||||
case "height": if (float.TryParse(val, NumberStyles.Float, ic, out var h)) HeightOffset = Math.Clamp(h, 0f, 8f); break;
|
||||
case "maxdist": if (float.TryParse(val, NumberStyles.Float, ic, out var m)) MaxDistance = Math.Clamp(m, 5f, 200f); break;
|
||||
case "mindamage": if (int.TryParse(val, NumberStyles.Integer, ic, out var d)) MinDamage = Math.Max(0, d); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
62
Plugins/RynthCore.Plugin.RynthJuice/PluginExports.cs
Normal file
62
Plugins/RynthCore.Plugin.RynthJuice/PluginExports.cs
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using RynthCore.PluginCore;
|
||||
using RynthCore.PluginSdk;
|
||||
|
||||
namespace RynthCore.Plugin.RynthJuice;
|
||||
|
||||
/// <summary>
|
||||
/// C ABI exports the engine's PluginLoader resolves by name (GetProcAddress).
|
||||
/// Note there is intentionally NO RynthPluginRender export: that drives plugin
|
||||
/// ImGui drawing, which RynthJuice doesn't use. All geometry is submitted from
|
||||
/// the tick (RynthPluginTick) through the engine's Nav3D renderer, which has its
|
||||
/// own draw hook and runs regardless of the ImGui shell.
|
||||
/// </summary>
|
||||
public static unsafe class PluginExports
|
||||
{
|
||||
private static readonly RynthPluginRuntime<RynthJuicePlugin> Runtime = new();
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "RynthPluginInit", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
private static int Init(RynthCoreApiNative* api) => Runtime.Init(api);
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "RynthPluginShutdown", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
public static void Shutdown() => Runtime.Shutdown();
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "RynthPluginName", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
public static IntPtr GetName() => RynthJuicePlugin.NamePointer;
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "RynthPluginVersion", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
public static IntPtr GetVersion() => RynthJuicePlugin.VersionPointer;
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "RynthPluginTick", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
public static void Tick() => Runtime.OnTick();
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "RynthPluginOnLoginComplete", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
public static void OnLoginComplete() => Runtime.OnLoginComplete();
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "RynthPluginOnLogout", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
public static void OnLogout() => Runtime.OnLogout();
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "RynthPluginOnUpdateHealth", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
public static void OnUpdateHealth(uint targetId, float healthRatio, uint currentHealth, uint maxHealth)
|
||||
=> Runtime.OnUpdateHealth(targetId, healthRatio, currentHealth, maxHealth);
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "RynthPluginOnCombatDamage", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
public static void OnCombatDamage(uint damage, uint damageType, uint crit, uint isAttacker)
|
||||
=> Runtime.OnCombatDamage(damage, damageType, crit, isAttacker);
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "RynthPluginOnDeleteObject", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
public static void OnDeleteObject(uint objectId) => Runtime.OnDeleteObject(objectId);
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "RynthPluginOnCreateObject", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
public static void OnCreateObject(uint objectId) => Runtime.OnCreateObject(objectId);
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "RynthPluginOnChatWindowText", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
public static void OnChatWindowText(IntPtr textUtf16, int chatType, IntPtr eatFlag)
|
||||
=> Runtime.OnChatWindowText(textUtf16, chatType, eatFlag);
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "RynthPluginOnChatBarEnter", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
public static void OnChatBarEnter(IntPtr textUtf16, IntPtr eatFlag)
|
||||
=> Runtime.OnChatBarEnter(textUtf16, eatFlag);
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0-windows</TargetFramework>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
|
||||
<OutputType>Library</OutputType>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Nullable>enable</Nullable>
|
||||
<PublishAot>true</PublishAot>
|
||||
<NativeLib>Shared</NativeLib>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
<IlcOptimizationPreference>Size</IlcOptimizationPreference>
|
||||
<StripSymbols>false</StripSymbols>
|
||||
<RootNamespace>RynthCore.Plugin.RynthJuice</RootNamespace>
|
||||
<AssemblyName>RynthCore.Plugin.RynthJuice</AssemblyName>
|
||||
<Platforms>x86</Platforms>
|
||||
<!-- Keep in step with VersionPointer in RynthJuicePlugin.cs. -->
|
||||
<!-- Previous release: 0.1.2 (crit window passed before the first crit, so early hits drew as crits). -->
|
||||
<Version>0.1.3</Version>
|
||||
<AssemblyVersion>0.1.3.0</AssemblyVersion>
|
||||
<FileVersion>0.1.3.0</FileVersion>
|
||||
<InformationalVersion>0.1.3-experimental</InformationalVersion>
|
||||
<!-- Publish straight into the launcher-registered deploy home so a bare
|
||||
`dotnet publish` lands where the engine hot-reloads it (mirrors
|
||||
RynthVision). Deploy-RynthCore.ps1 points its copy step here too and
|
||||
detects source == dest to skip the redundant self-copy. -->
|
||||
<PublishDir>C:\Games\RynthSuite\RynthJuice\</PublishDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- No ImGui.NET: RynthJuice draws purely through the engine's Nav3D world-
|
||||
space renderer (lines/rings/triangles), which has its own
|
||||
DrawIndexedPrimitive hook independent of the ImGui shell. That keeps the
|
||||
plugin alive in EnableImGuiShell=false mode and off the fragile ImGui
|
||||
path entirely. -->
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\RynthCore\src\RynthCore.PluginCore\RynthCore.PluginCore.csproj" />
|
||||
<ProjectReference Include="..\..\..\RynthCore\src\RynthCore.PluginSdk\RynthCore.PluginSdk.csproj" />
|
||||
<!-- Shared DAT reader (same lib RynthVision uses; carries NO RynthAi
|
||||
dependency) — used to read per-EnvCell transforms from cell.dat for
|
||||
dungeon (indoor) damage-number placement. -->
|
||||
<ProjectReference Include="..\..\Shared\RynthCore.TerrainData\RynthCore.TerrainData.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- Install-folder resolver shared with RynthCore (Software\Rynth CoreDir/SuiteDir). -->
|
||||
<Compile Include="..\Shared\RynthInstallPaths.cs" Link="Shared\RynthInstallPaths.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
683
Plugins/RynthCore.Plugin.RynthJuice/RynthJuicePlugin.cs
Normal file
683
Plugins/RynthCore.Plugin.RynthJuice/RynthJuicePlugin.cs
Normal file
|
|
@ -0,0 +1,683 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Runtime.InteropServices;
|
||||
using RynthCore.PluginCore;
|
||||
|
||||
namespace RynthCore.Plugin.RynthJuice;
|
||||
|
||||
/// <summary>
|
||||
/// Combat "juice" for RynthCore: floating vector-digit damage numbers over
|
||||
/// monsters (white→orange→red by size, GOLD + bigger on crit), green heal
|
||||
/// numbers, red numbers over your own character when hit, and an expanding ring
|
||||
/// burst when a damaged monster dies. Pure Nav3D — no ImGui — so it runs in
|
||||
/// EnableImGuiShell=false mode and stays fully isolated from RynthAi. Outdoor
|
||||
/// only in v1 (dungeon coords are cell-local). Toggle with /juice.
|
||||
/// </summary>
|
||||
public sealed class RynthJuicePlugin : RynthPluginBase
|
||||
{
|
||||
internal static readonly IntPtr NamePointer = Marshal.StringToHGlobalAnsi("RynthJuice");
|
||||
internal static readonly IntPtr VersionPointer = Marshal.StringToHGlobalAnsi("0.1.3");
|
||||
|
||||
private sealed class HState
|
||||
{
|
||||
public bool HasCurrent;
|
||||
public uint LastCurrent;
|
||||
public uint KnownMax;
|
||||
public float LastRatio;
|
||||
public uint Cell;
|
||||
public float E, N, U; // last known position (own-landblock frame)
|
||||
public long LastDmgMs;
|
||||
public long LastSeenMs;
|
||||
}
|
||||
|
||||
private readonly JuiceSettings _cfg = new();
|
||||
private readonly JuiceEffects _fx = new();
|
||||
private readonly EnvCellTransforms _cells = new();
|
||||
private readonly Dictionary<uint, HState> _health = new();
|
||||
private readonly HashSet<uint> _killedIds = new();
|
||||
private readonly List<JuiceEffects.MobHp> _mobHpScratch = new();
|
||||
// Object tracking is split in two so a busy area (~700 created objects, mostly items)
|
||||
// can't starve mob polling:
|
||||
// * candidates: dynamic objects not yet known to be attackable. Checked in ROTATION
|
||||
// (queue: dequeue, decide, re-enqueue at the back) with a per-poll budget, so every
|
||||
// candidate is reached within a few polls. Known non-creatures are dropped.
|
||||
// * mobs: confirmed attackable. Polled every cycle (budgeted + rotated only if there
|
||||
// are more than MobPollBudget) so health bars stay continuous.
|
||||
// Membership lives in the sets; the queues may hold stale ids (deleted / moved), which
|
||||
// are discarded lazily when dequeued.
|
||||
private readonly HashSet<uint> _candidateSet = new();
|
||||
private readonly Queue<uint> _candidateQueue = new();
|
||||
private readonly HashSet<uint> _candidateQueued = new(); // ids physically in _candidateQueue (no duplicates after delete+recreate)
|
||||
private readonly HashSet<uint> _mobSet = new();
|
||||
private readonly Queue<uint> _mobQueue = new();
|
||||
private readonly HashSet<uint> _mobQueued = new(); // ids physically in _mobQueue
|
||||
private int _droppedNonCreatures;
|
||||
private bool _trackCapLogged;
|
||||
private int _pollLogCount;
|
||||
private int _createLogCount;
|
||||
private readonly Random _rng = new();
|
||||
|
||||
private uint _playerId;
|
||||
private bool _loginComplete;
|
||||
private long _lastCritMs = long.MinValue;
|
||||
private int _tick;
|
||||
private bool _debugChat;
|
||||
private bool _autoDiagDone;
|
||||
private PendingExact _pending;
|
||||
|
||||
private const int CritWindowMs = 450;
|
||||
|
||||
/// <summary>
|
||||
/// True when the last crit line came at most <see cref="CritWindowMs"/> before <paramref name="now"/>.
|
||||
/// <c>_lastCritMs</c> is <c>long.MinValue</c> until the first crit, and <c>now - long.MinValue</c>
|
||||
/// wraps negative, which would pass the window test and draw every hit as a crit.
|
||||
/// </summary>
|
||||
private bool WithinCritWindow(long now) => _lastCritMs != long.MinValue && (now - _lastCritMs) <= CritWindowMs;
|
||||
private const int ExactWindowMs = 600; // pair a combat-log amount with its health packet
|
||||
private const int HealMinDelta = 8; // filters small regen ticks
|
||||
private const long DeleteKillRecentDamageMs = 8_000; // delete counts as a kill only if we hit it this recently
|
||||
private const long ForgetMs = 60_000; // prune untouched health entries
|
||||
|
||||
private const int CandidateCheckBudget = 80; // candidates classified per poll (rotating)
|
||||
private const int MobPollBudget = 64; // confirmed mobs polled per poll (rotating if more)
|
||||
private const int MaxTrackedObjects = 4096; // safety cap (candidates + mobs); non-creatures are dropped, so this is rarely reached
|
||||
private const uint ItemTypeCreature = 0x10; // AC ITEM_TYPE.TYPE_CREATURE
|
||||
|
||||
// An exact combat-log amount whose health packet hasn't arrived yet (reverse order).
|
||||
private struct PendingExact { public bool Has; public int Amount; public bool Crit; public bool Incoming; public long Ts; }
|
||||
|
||||
public override int Initialize()
|
||||
{
|
||||
_cfg.Load();
|
||||
_fx.SetCells(_cells);
|
||||
Host.Log("[RynthJuice] Initialized. /juice [on|off|test|heals|playerdmg|scale N|height N|help]. " +
|
||||
"Needs a clean (no-Decal) client; works with the ImGui shell on or off; outdoors + dungeons.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override void OnLoginComplete()
|
||||
{
|
||||
_playerId = Host.GetPlayerId();
|
||||
_loginComplete = true;
|
||||
_autoDiagDone = false;
|
||||
_health.Clear();
|
||||
_fx.Clear();
|
||||
if (!Host.HasNav3DTriangle)
|
||||
Host.Log("[RynthJuice] WARNING: engine has no Nav3D triangle API — numbers can't draw. Update the engine.");
|
||||
Host.Log($"[RynthJuice] Ready (enabled={_cfg.Enabled}).");
|
||||
}
|
||||
|
||||
public override void OnLogout()
|
||||
{
|
||||
_loginComplete = false;
|
||||
_health.Clear();
|
||||
_killedIds.Clear();
|
||||
ClearTracking();
|
||||
_fx.Clear();
|
||||
}
|
||||
|
||||
public override void Shutdown() { _fx.Clear(); _cells.Dispose(); }
|
||||
|
||||
public override void OnUpdateHealth(uint targetId, float healthRatio, uint currentHealth, uint maxHealth)
|
||||
{
|
||||
if (!_loginComplete || !_cfg.Enabled) return;
|
||||
|
||||
long now = Environment.TickCount64;
|
||||
bool isPlayer = targetId == _playerId;
|
||||
|
||||
if (!_health.TryGetValue(targetId, out var st))
|
||||
{
|
||||
st = new HState();
|
||||
_health[targetId] = st;
|
||||
}
|
||||
|
||||
uint prevCur = st.LastCurrent;
|
||||
float prevRatio = st.LastRatio;
|
||||
bool hadPrev = st.HasCurrent;
|
||||
|
||||
// Update tracked state.
|
||||
if (maxHealth > 0 && maxHealth > st.KnownMax) st.KnownMax = maxHealth;
|
||||
st.LastRatio = healthRatio;
|
||||
st.LastCurrent = currentHealth;
|
||||
st.HasCurrent = true;
|
||||
st.LastSeenMs = now;
|
||||
|
||||
// Cache the mob's current position every update — the live health readout and
|
||||
// the kill effect both need a spot, and the position cache can be empty by the
|
||||
// time the object is deleted.
|
||||
if (!isPlayer && Host.TryGetObjectPosition(targetId, out uint upCell, out float upE, out float upN, out float upU))
|
||||
{ st.Cell = upCell; st.E = upE; st.N = upN; st.U = upU; }
|
||||
|
||||
// Kill detection by HEALTH RATIO → 0. Fires at the killing blow (no
|
||||
// OnDeleteObject corpse-removal delay) and works for ALL mobs — ratio is the
|
||||
// reliable signal; absolute currentHealth reads 0 for unappraised mobs.
|
||||
// _killedIds dedups (fires once); OnDeleteObject stays as a fallback.
|
||||
if (!isPlayer && healthRatio < 0.001f)
|
||||
{
|
||||
if (_killedIds.Add(targetId))
|
||||
{
|
||||
int killAmt = (maxHealth > 0) ? (int)Math.Round(prevRatio * maxHealth) : 0;
|
||||
bool kcrit = WithinCritWindow(now);
|
||||
if (_pending.Has && (now - _pending.Ts) <= ExactWindowMs && !_pending.Incoming)
|
||||
{
|
||||
killAmt = _pending.Amount;
|
||||
kcrit = kcrit || _pending.Crit;
|
||||
_pending.Has = false;
|
||||
}
|
||||
|
||||
// Verification scaffolding — chat only in debug mode, or every
|
||||
// kill spams the chat window once this goes live.
|
||||
if (_debugChat) Reply("[RynthJuice] *** KILL ***");
|
||||
|
||||
// Anchor: live position → last cached → player (so it ALWAYS fires).
|
||||
uint kc; float ke, kn, ku;
|
||||
bool gotPos = Host.TryGetObjectPosition(targetId, out kc, out ke, out kn, out ku);
|
||||
if (!gotPos && (st.Cell >> 16) != 0) { kc = st.Cell; ke = st.E; kn = st.N; ku = st.U; gotPos = true; }
|
||||
if (!gotPos) gotPos = Host.TryGetPlayerPose(out kc, out ke, out kn, out ku, out _, out _, out _, out _);
|
||||
|
||||
if (gotPos)
|
||||
{
|
||||
if (killAmt >= _cfg.MinDamage) _fx.SpawnDamage(kc, ke, kn, ku, killAmt, kcrit);
|
||||
_fx.SpawnKillBurst(kc, ke, kn, ku, kcrit, now);
|
||||
Host.Log($"[RynthJuice] KILL tgt=0x{targetId:X8} amt={killAmt} cell=0x{kc:X8} fx={_fx.Count}");
|
||||
}
|
||||
}
|
||||
_health.Remove(targetId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hadPrev) return; // first non-death packet — establish baseline only
|
||||
|
||||
// Resolve a damage/heal amount, preferring absolute HP when the server
|
||||
// gave us real numbers, falling back to ratio × best-known max.
|
||||
int delta;
|
||||
bool isDamage;
|
||||
if (maxHealth > 0 && (currentHealth > 0 || prevCur > 0))
|
||||
{
|
||||
long ad = (long)prevCur - currentHealth;
|
||||
isDamage = ad > 0;
|
||||
delta = (int)Math.Abs(ad);
|
||||
}
|
||||
else
|
||||
{
|
||||
float rd = prevRatio - healthRatio;
|
||||
float baseMax = st.KnownMax > 0 ? st.KnownMax : 100f;
|
||||
isDamage = rd > 0;
|
||||
delta = (int)MathF.Round(Math.Abs(rd) * baseMax);
|
||||
}
|
||||
if (delta <= 0) return;
|
||||
|
||||
// Capture anchor position (mob via object cache, player via pose).
|
||||
uint cell; float e, n, u;
|
||||
if (isPlayer)
|
||||
{
|
||||
if (!Host.TryGetPlayerPose(out cell, out e, out n, out u, out _, out _, out _, out _))
|
||||
return;
|
||||
}
|
||||
else if (!Host.TryGetObjectPosition(targetId, out cell, out e, out n, out u))
|
||||
{
|
||||
if (_debugChat) Host.Log($"[RynthJuice] dmg tgt=0x{targetId:X8} delta={delta} POS-FAIL (no anchor — skipped)");
|
||||
return;
|
||||
}
|
||||
st.Cell = cell; st.E = e; st.N = n; st.U = u;
|
||||
|
||||
if (isDamage)
|
||||
{
|
||||
if (delta < _cfg.MinDamage) return;
|
||||
st.LastDmgMs = now;
|
||||
int amount = delta;
|
||||
bool crit = WithinCritWindow(now);
|
||||
// Prefer the exact combat-log value if its line already arrived (reverse order).
|
||||
if (_pending.Has && (now - _pending.Ts) <= ExactWindowMs && _pending.Incoming == isPlayer)
|
||||
{
|
||||
amount = _pending.Amount;
|
||||
crit = crit || _pending.Crit;
|
||||
_pending.Has = false;
|
||||
}
|
||||
if (isPlayer)
|
||||
{
|
||||
if (_cfg.ShowPlayerDamage) _fx.SpawnPlayerDamage(cell, e, n, u, amount, crit);
|
||||
}
|
||||
else
|
||||
{
|
||||
_fx.SpawnDamage(cell, e, n, u, amount, crit);
|
||||
}
|
||||
if (_debugChat) Host.Log($"[RynthJuice] dmg tgt=0x{targetId:X8} amt={amount} crit={crit} isPlayer={isPlayer} cell=0x{cell:X8} indoor={(cell & 0xFFFF) >= 0x100} fx={_fx.Count}");
|
||||
}
|
||||
else if (_cfg.ShowHeals && delta >= HealMinDelta)
|
||||
{
|
||||
_fx.SpawnHeal(cell, e, n, u, delta);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnChatWindowText(string? text, int chatType, ref int eat)
|
||||
{
|
||||
if (!_loginComplete || !_cfg.Enabled || string.IsNullOrEmpty(text)) return;
|
||||
if (_debugChat) Host.Log($"[RynthJuice] chat[{chatType}]: {text}");
|
||||
|
||||
long now = Environment.TickCount64;
|
||||
bool isCrit = text.IndexOf("critical", StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
|
||||
// Exact damage from the combat log: "... for N points of <type> damage".
|
||||
// The health packet anchors it to the right object; this overwrites the
|
||||
// estimate with the true value. Requires "damage" so heal/mana/stamina
|
||||
// "points of" lines are ignored.
|
||||
if (TryParseDamage(text, out int amount, out bool incoming))
|
||||
{
|
||||
bool crit = isCrit || WithinCritWindow(now);
|
||||
if (isCrit) _lastCritMs = now;
|
||||
var kind = incoming ? JuiceEffects.Kind.PlayerDamage : JuiceEffects.Kind.MobDamage;
|
||||
// Correct an already-spawned number, else stash for the health packet.
|
||||
if (!_fx.ApplyExactToRecent(now, ExactWindowMs, kind, amount, crit))
|
||||
_pending = new PendingExact { Has = true, Amount = amount, Crit = crit, Incoming = incoming, Ts = now };
|
||||
return;
|
||||
}
|
||||
|
||||
// A standalone crit line (no parsable amount): mark window + retro-upgrade.
|
||||
if (isCrit)
|
||||
{
|
||||
_lastCritMs = now;
|
||||
_fx.UpgradeRecentToCrit(now, CritWindowMs);
|
||||
}
|
||||
}
|
||||
|
||||
// Parses AC combat-log damage lines, e.g.:
|
||||
// "You slash the Drudge for 47 points of slashing damage!" (outgoing)
|
||||
// "The Drudge Slinker hits you for 12 points of bludgeoning damage!" (incoming)
|
||||
// Extracts the integer before "points" and the direction. Returns false for
|
||||
// non-damage "points of" lines (heals/mana/stamina lack "damage").
|
||||
private static bool TryParseDamage(string text, out int amount, out bool incoming)
|
||||
{
|
||||
amount = 0; incoming = false;
|
||||
int pts = text.IndexOf("points of", StringComparison.OrdinalIgnoreCase);
|
||||
if (pts < 0) return false;
|
||||
if (text.IndexOf("damage", pts, StringComparison.OrdinalIgnoreCase) < 0) return false;
|
||||
|
||||
int i = pts - 1;
|
||||
while (i >= 0 && text[i] == ' ') i--;
|
||||
long val = 0, mult = 1; bool any = false;
|
||||
while (i >= 0 && (char.IsDigit(text[i]) || text[i] == ','))
|
||||
{
|
||||
if (text[i] != ',') { val += (text[i] - '0') * mult; mult *= 10; any = true; }
|
||||
i--;
|
||||
}
|
||||
if (!any || val <= 0 || val > 1_000_000) return false;
|
||||
amount = (int)val;
|
||||
|
||||
// Defender (incoming) lines target "you for"; attacker lines start "You ".
|
||||
incoming = text.IndexOf("you for", StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Exact per-hit damage from the structured AC packet (AttackerNotification /
|
||||
// DefenderNotification), surfaced by the engine. This is the real damage value
|
||||
// even for one-shots/overkill. It carries no object id (the packet identifies
|
||||
// the target by name), so correlate it to the health packet — which has the id
|
||||
// + position — by recency, reusing the same _pending mechanism.
|
||||
public override void OnCombatDamage(uint damage, uint damageType, bool crit, bool isAttacker)
|
||||
{
|
||||
if (!_loginComplete || !_cfg.Enabled || damage == 0) return;
|
||||
long now = Environment.TickCount64;
|
||||
if (crit) _lastCritMs = now;
|
||||
var kind = isAttacker ? JuiceEffects.Kind.MobDamage : JuiceEffects.Kind.PlayerDamage;
|
||||
// Overwrite a number that already spawned from the health packet, else stash
|
||||
// the exact value for the imminent health update / kill to pick up.
|
||||
if (!_fx.ApplyExactToRecent(now, ExactWindowMs, kind, (int)damage, crit))
|
||||
_pending = new PendingExact { Has = true, Amount = (int)damage, Crit = crit, Incoming = !isAttacker, Ts = now };
|
||||
if (_debugChat) Host.Log($"[RynthJuice] COMBATDMG dmg={damage} type={damageType} crit={crit} atk={isAttacker}");
|
||||
}
|
||||
|
||||
// Track dynamic objects so we can poll mob health — the streaming-health hook is
|
||||
// dead on this client, so polling is how we read monster HP. New objects start as
|
||||
// candidates; the poll promotes attackable ones to mobs and drops non-creatures.
|
||||
public override void OnCreateObject(uint objectId)
|
||||
{
|
||||
// No login/enabled gate: the engine REPLAYS creates for pre-existing objects
|
||||
// at plugin init (possibly before OnLoginComplete), and mobs already in the
|
||||
// room must be tracked. Polling itself is gated by login/enabled in OnTick.
|
||||
if ((objectId & 0x80000000u) == 0) return; // dynamic objects only
|
||||
if (_mobSet.Contains(objectId)) return; // already a confirmed mob
|
||||
|
||||
// Known non-creature (item, portal, …): never a mob — don't track it at all.
|
||||
if (IsKnownNonCreature(objectId)) { _droppedNonCreatures++; return; }
|
||||
|
||||
if (_candidateSet.Count + _mobSet.Count >= MaxTrackedObjects)
|
||||
{
|
||||
if (!_trackCapLogged)
|
||||
{
|
||||
_trackCapLogged = true;
|
||||
Host.Log($"[RynthJuice] tracking cap {MaxTrackedObjects} reached — new objects not tracked until some are deleted");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!_candidateSet.Add(objectId)) return;
|
||||
EnqueueCandidate(objectId);
|
||||
if (_createLogCount < 8) { _createLogCount++; Host.Log($"[RynthJuice] create 0x{objectId:X8} candidates={_candidateSet.Count}"); }
|
||||
}
|
||||
|
||||
public override void OnDeleteObject(uint objectId)
|
||||
{
|
||||
// Queue entries for this id are discarded lazily (set membership is the truth).
|
||||
_candidateSet.Remove(objectId);
|
||||
_mobSet.Remove(objectId);
|
||||
// Capture state BEFORE removing it — LastDmgMs is the recent-damage
|
||||
// gate below; the old order destroyed it first.
|
||||
bool hadState = _health.TryGetValue(objectId, out HState? st);
|
||||
_health.Remove(objectId);
|
||||
if (!_loginComplete || !_cfg.Enabled) return;
|
||||
|
||||
// An appraised mob already got its effect from the health=0 path — don't double.
|
||||
if (_killedIds.Remove(objectId)) return;
|
||||
if (_killedIds.Count > 1024) _killedIds.Clear();
|
||||
|
||||
// AC sends deletes for range-out / teleport / despawn too — only treat
|
||||
// a delete as a DEATH if we damaged the creature recently. Without this
|
||||
// gate, walking out of a spawn field or portaling fired a burst per
|
||||
// nearby mob (anchored at the PLAYER via the old pose fallback, since
|
||||
// the position cache was already empty).
|
||||
long now = Environment.TickCount64;
|
||||
if (!hadState || st!.LastDmgMs == 0 || now - st.LastDmgMs > DeleteKillRecentDamageMs)
|
||||
return;
|
||||
|
||||
if (!Host.ObjectIsAttackable(objectId)) return;
|
||||
|
||||
// Anchor at the mob's live or last-cached position only — never the
|
||||
// player. A delete with no known position gives a wrong-place burst.
|
||||
uint kc; float ke, kn, ku;
|
||||
if (!Host.TryGetObjectPosition(objectId, out kc, out ke, out kn, out ku))
|
||||
{
|
||||
if ((st.Cell >> 16) == 0) return;
|
||||
kc = st.Cell; ke = st.E; kn = st.N; ku = st.U;
|
||||
}
|
||||
if (_debugChat) Reply("[RynthJuice] *** KILL ***");
|
||||
_fx.SpawnKillBurst(kc, ke, kn, ku, crit: false, now);
|
||||
}
|
||||
|
||||
public override void OnTick()
|
||||
{
|
||||
if (!_loginComplete) return;
|
||||
_tick++;
|
||||
|
||||
// Auto-diagnostic: ~150 ticks after login, log the full pipeline state once
|
||||
// (no command / on-screen output needed). Fires even when disabled so the
|
||||
// log shows enabled=False if that's the cause.
|
||||
if (!_autoDiagDone && _tick >= 150) { _autoDiagDone = true; RunDiag(); }
|
||||
|
||||
if (!_cfg.Enabled) return;
|
||||
|
||||
long now = Environment.TickCount64;
|
||||
_fx.Render(Host, _cfg, now);
|
||||
if ((_tick & 1) == 0) PollMobHealth(now); // poll mob vitals every other tick
|
||||
|
||||
if ((_tick & 0xFF) == 0) PruneHealth(now); // ~every 256 ticks
|
||||
}
|
||||
|
||||
public override void OnChatBarEnter(string? text, ref int eat)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text) || !text.StartsWith("/juice", StringComparison.OrdinalIgnoreCase))
|
||||
return;
|
||||
|
||||
eat = 1; // consume — never send to the server as chat
|
||||
|
||||
string rest = text.Length > 6 ? text.Substring(6).Trim() : "";
|
||||
string[] parts = rest.Length == 0 ? Array.Empty<string>() : rest.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||
string cmd = parts.Length > 0 ? parts[0].ToLowerInvariant() : "";
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case "":
|
||||
case "toggle":
|
||||
_cfg.Enabled = !_cfg.Enabled;
|
||||
if (!_cfg.Enabled) _fx.Clear();
|
||||
_cfg.Save();
|
||||
Reply($"[RynthJuice] {(_cfg.Enabled ? "ON" : "OFF")}.");
|
||||
break;
|
||||
case "on": _cfg.Enabled = true; _cfg.Save(); Reply("[RynthJuice] ON."); break;
|
||||
case "off": _cfg.Enabled = false; _fx.Clear(); _cfg.Save(); Reply("[RynthJuice] OFF."); break;
|
||||
case "heals":
|
||||
_cfg.ShowHeals = !_cfg.ShowHeals; _cfg.Save();
|
||||
Host.Log($"[RynthJuice] heal numbers {(_cfg.ShowHeals ? "on" : "off")}.");
|
||||
break;
|
||||
case "playerdmg":
|
||||
_cfg.ShowPlayerDamage = !_cfg.ShowPlayerDamage; _cfg.Save();
|
||||
Host.Log($"[RynthJuice] player-damage numbers {(_cfg.ShowPlayerDamage ? "on" : "off")}.");
|
||||
break;
|
||||
case "scale":
|
||||
if (parts.Length > 1 && float.TryParse(parts[1], NumberStyles.Float, CultureInfo.InvariantCulture, out float sc))
|
||||
{ _cfg.Scale = Math.Clamp(sc, 0.3f, 4f); _cfg.Save(); Host.Log($"[RynthJuice] scale = {_cfg.Scale:0.##}."); }
|
||||
else Host.Log("[RynthJuice] usage: /juice scale 1.5");
|
||||
break;
|
||||
case "height":
|
||||
if (parts.Length > 1 && float.TryParse(parts[1], NumberStyles.Float, CultureInfo.InvariantCulture, out float hh))
|
||||
{ _cfg.HeightOffset = Math.Clamp(hh, 0f, 8f); _cfg.Save(); Host.Log($"[RynthJuice] height = {_cfg.HeightOffset:0.##} m."); }
|
||||
else Host.Log("[RynthJuice] usage: /juice height 1.8");
|
||||
break;
|
||||
case "test": SpawnTest(); break;
|
||||
case "debug":
|
||||
_debugChat = !_debugChat;
|
||||
Host.Log($"[RynthJuice] combat-log debug {(_debugChat ? "ON" : "OFF")} (logs chat lines to RynthCore.log so we can verify the damage-text format).");
|
||||
break;
|
||||
case "help":
|
||||
default:
|
||||
Host.Log("[RynthJuice] /juice [on|off|toggle|test|heals|playerdmg|scale N|height N|debug|help]");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Command feedback to BOTH the unified log and the in-game chat window.
|
||||
private void Reply(string msg)
|
||||
{
|
||||
Host.Log(msg);
|
||||
if (Host.HasWriteToChat) Host.WriteToChat(msg, 1);
|
||||
}
|
||||
|
||||
/// <summary>/juice diag — dumps the full render-pipeline state to chat + log so
|
||||
/// we can pinpoint why numbers aren't appearing (especially indoors). Run it
|
||||
/// outdoors AND inside a dungeon and compare.</summary>
|
||||
private void RunDiag()
|
||||
{
|
||||
bool nav = Host.HasNav3D, tri = Host.HasNav3DTriangle, w2s = Host.HasWorldToScreen;
|
||||
bool poseOk = Host.TryGetPlayerPose(out uint cell, out float e, out float n, out float u, out _, out _, out _, out _);
|
||||
Host.TryGetViewportSize(out uint vpw, out uint vph);
|
||||
bool indoor = poseOk && (cell & 0xFFFF) >= 0x100;
|
||||
|
||||
// Project a point ~2m ABOVE the player (where numbers anchor — not the
|
||||
// player's feet, which sit at the camera and never project). Test BOTH the
|
||||
// raw cell-local coords and the EnvCell-transformed landblock-relative
|
||||
// coords; whichever projects tells us the frame the indoor camera uses.
|
||||
float upU = u + 2f;
|
||||
float rrx = 0, rry = 0, xsx = 0, xsy = 0;
|
||||
bool projRaw = poseOk && w2s && Host.WorldToScreen(e, upU, n, out rrx, out rry);
|
||||
float xe = e, xn = n, xu = upU;
|
||||
bool resolveOk = poseOk && _cells.ToLandblockRelative(cell, ref xe, ref xn, ref xu);
|
||||
bool projXform = resolveOk && w2s && Host.WorldToScreen(xe, xu, xn, out xsx, out xsy);
|
||||
|
||||
Reply($"[RynthJuice] DIAG enabled={_cfg.Enabled} tick={_tick} fx={_fx.Count} nav={nav} tri={tri} w2s={w2s} vp={vpw}x{vph}");
|
||||
Reply($"[RynthJuice] DIAG pose={poseOk} cell=0x{cell:X8} indoor={indoor} cellsReady={_cells.Ready} resolve={resolveOk}");
|
||||
Reply($"[RynthJuice] DIAG raw=({e:F1},{n:F1},{u:F1}) projRaw={projRaw}@({rrx:F0},{rry:F0}) | xform=({xe:F1},{xn:F1},{xu:F1}) projXform={projXform}@({xsx:F0},{xsy:F0})");
|
||||
Reply($"[RynthJuice] DIAG render: {_fx.LastRenderStatus} | lastDrawn={_fx.LastDrawnEffects} lastTris={_fx.LastTriangles} writeToChat={Host.HasWriteToChat}");
|
||||
if (indoor && !_cells.Ready) Reply($"[RynthJuice] DIAG cell.dat status: {_cells.Status}");
|
||||
}
|
||||
|
||||
// Polls each tracked mob's vitals directly (TryGetTargetVitals) — the streaming
|
||||
// health hook doesn't install on this client, so polling is how we read monster
|
||||
// HP. Drives both the live health % and instant (no-delay) death detection.
|
||||
private void PollMobHealth(long now)
|
||||
{
|
||||
if (_candidateSet.Count == 0 && _mobSet.Count == 0)
|
||||
{
|
||||
if ((_tick & 0x7F) == 0) Host.Log("[RynthJuice] pollcycle tracked=0 (OnCreateObject delivered no ids)");
|
||||
return;
|
||||
}
|
||||
_mobHpScratch.Clear();
|
||||
|
||||
// 1) Classify a rotating slice of candidates first, so a mob promoted this poll is
|
||||
// polled below in the same cycle.
|
||||
int promoted = CheckCandidates();
|
||||
|
||||
// 2) Poll confirmed mobs. Each is dequeued and either re-enqueued at the back or
|
||||
// dropped, so with more than MobPollBudget mobs the poll still rotates fairly.
|
||||
int atk = 0, vit = 0;
|
||||
int mobChecks = Math.Min(_mobQueue.Count, MobPollBudget);
|
||||
for (int i = 0; i < mobChecks; i++)
|
||||
{
|
||||
uint id = _mobQueue.Dequeue();
|
||||
_mobQueued.Remove(id);
|
||||
if (!_mobSet.Contains(id)) continue; // stale entry (deleted / demoted)
|
||||
if (id == _playerId) { _mobSet.Remove(id); continue; }
|
||||
|
||||
if (!Host.ObjectIsAttackable(id))
|
||||
{
|
||||
// No longer attackable (e.g. died between polls, became friendly): back to
|
||||
// candidates so it is re-checked in rotation instead of polled every cycle.
|
||||
_mobSet.Remove(id);
|
||||
if (_candidateSet.Add(id)) EnqueueCandidate(id);
|
||||
continue;
|
||||
}
|
||||
atk++;
|
||||
EnqueueMob(id); // stays a mob unless the kill path below removes it
|
||||
|
||||
if (!Host.TryGetTargetVitals(id, out uint h, out uint mx, out _, out _, out _, out _) || (h == 0 && mx == 0))
|
||||
continue; // can't read this tick
|
||||
vit++;
|
||||
|
||||
if (_pollLogCount < 12)
|
||||
{
|
||||
_pollLogCount++;
|
||||
Host.Log($"[RynthJuice] poll 0x{id:X8} h={h} mx={mx}");
|
||||
}
|
||||
|
||||
if (!Host.TryGetObjectPosition(id, out uint cell, out float e, out float n, out float u))
|
||||
continue;
|
||||
|
||||
// Death by poll: HP hit 0 — instant, no OnDeleteObject corpse-removal delay.
|
||||
if (mx > 0 && h == 0)
|
||||
{
|
||||
if (_killedIds.Add(id))
|
||||
{
|
||||
if (_debugChat) Reply("[RynthJuice] *** KILL ***");
|
||||
_fx.SpawnKillBurst(cell, e, n, u, crit: false, now);
|
||||
Host.Log($"[RynthJuice] KILL(poll) tgt=0x{id:X8} cell=0x{cell:X8}");
|
||||
}
|
||||
_mobSet.Remove(id); // its re-enqueued queue entry is discarded lazily
|
||||
continue;
|
||||
}
|
||||
|
||||
float ratio = mx > 0 ? Math.Clamp((float)h / mx, 0f, 1f) : 1f;
|
||||
_mobHpScratch.Add(new JuiceEffects.MobHp(cell, e, n, u, ratio));
|
||||
}
|
||||
|
||||
if ((_tick & 0x3F) == 0)
|
||||
Host.Log($"[RynthJuice] pollcycle candidates={_candidateSet.Count} mobs={_mobSet.Count} promoted={promoted} " +
|
||||
$"droppedNonCreatures={_droppedNonCreatures} attackable={atk} vitals={vit} bars={_mobHpScratch.Count}");
|
||||
if (_mobHpScratch.Count > 0) _fx.RenderMobHealth(Host, _cfg, _mobHpScratch);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks up to <see cref="CandidateCheckBudget"/> candidates from the front of the
|
||||
/// rotation queue. Each is dropped (player / known non-creature), promoted to a mob
|
||||
/// (attackable), or re-enqueued at the back — so successive polls walk the whole list
|
||||
/// instead of re-checking the same first slice. Returns the number promoted.
|
||||
/// </summary>
|
||||
private int CheckCandidates()
|
||||
{
|
||||
int promoted = 0;
|
||||
int checks = Math.Min(_candidateQueue.Count, CandidateCheckBudget);
|
||||
for (int i = 0; i < checks; i++)
|
||||
{
|
||||
uint id = _candidateQueue.Dequeue();
|
||||
_candidateQueued.Remove(id);
|
||||
if (!_candidateSet.Contains(id)) continue; // stale entry (deleted / promoted)
|
||||
|
||||
if (id == _playerId) { _candidateSet.Remove(id); continue; }
|
||||
|
||||
// Type can arrive after create; once it says "not a creature", stop checking.
|
||||
if (IsKnownNonCreature(id))
|
||||
{
|
||||
_candidateSet.Remove(id);
|
||||
_droppedNonCreatures++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Host.ObjectIsAttackable(id))
|
||||
{
|
||||
_candidateSet.Remove(id);
|
||||
if (_mobSet.Add(id)) EnqueueMob(id);
|
||||
promoted++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Unknown type or a non-attackable creature (NPC, pet): keep in rotation —
|
||||
// attackable state can lag behind create by several ticks.
|
||||
EnqueueCandidate(id);
|
||||
}
|
||||
return promoted;
|
||||
}
|
||||
|
||||
/// <summary>True when the object's ItemType is known and lacks TYPE_CREATURE.
|
||||
/// Type 0 / unreadable counts as unknown (kept as a candidate).</summary>
|
||||
private bool IsKnownNonCreature(uint id)
|
||||
=> Host.HasGetItemType
|
||||
&& Host.TryGetItemType(id, out uint typeFlags)
|
||||
&& typeFlags != 0
|
||||
&& (typeFlags & ItemTypeCreature) == 0;
|
||||
|
||||
private void EnqueueCandidate(uint id)
|
||||
{
|
||||
if (_candidateQueued.Add(id)) _candidateQueue.Enqueue(id);
|
||||
}
|
||||
|
||||
private void EnqueueMob(uint id)
|
||||
{
|
||||
if (_mobQueued.Add(id)) _mobQueue.Enqueue(id);
|
||||
}
|
||||
|
||||
private void ClearTracking()
|
||||
{
|
||||
_candidateSet.Clear();
|
||||
_candidateQueue.Clear();
|
||||
_candidateQueued.Clear();
|
||||
_mobSet.Clear();
|
||||
_mobQueue.Clear();
|
||||
_mobQueued.Clear();
|
||||
_droppedNonCreatures = 0;
|
||||
_trackCapLogged = false;
|
||||
}
|
||||
|
||||
private void PruneHealth(long now)
|
||||
{
|
||||
// Allocation-light prune of stale targets.
|
||||
List<uint>? dead = null;
|
||||
foreach (var kv in _health)
|
||||
if (now - kv.Value.LastSeenMs > ForgetMs)
|
||||
(dead ??= new List<uint>()).Add(kv.Key);
|
||||
if (dead != null)
|
||||
foreach (uint id in dead) _health.Remove(id);
|
||||
}
|
||||
|
||||
/// <summary>/juice test — spawn a spread of demo numbers + a burst at the
|
||||
/// player so the render path can be verified without combat.</summary>
|
||||
private void SpawnTest()
|
||||
{
|
||||
if (!Host.TryGetPlayerPose(out uint cell, out float e, out float n, out float u, out _, out _, out _, out _))
|
||||
{
|
||||
Host.Log("[RynthJuice] test: player pose unavailable (are you in the world, outdoors?).");
|
||||
return;
|
||||
}
|
||||
if ((cell >> 16) == 0)
|
||||
{
|
||||
Host.Log("[RynthJuice] test: not in the world yet.");
|
||||
return;
|
||||
}
|
||||
long now = Environment.TickCount64;
|
||||
_lastCritMs = long.MinValue; // don't accidentally crit the demo numbers
|
||||
_fx.SpawnDamage(cell, e + 2f, n + 2f, u, 18, crit: false);
|
||||
_fx.SpawnDamage(cell, e - 2f, n + 1f, u, 73, crit: false);
|
||||
_fx.SpawnDamage(cell, e + 1f, n - 2f, u, 142, crit: false);
|
||||
_fx.SpawnDamage(cell, e - 1f, n - 1f, u, 891, crit: true);
|
||||
if (_cfg.ShowHeals) _fx.SpawnHeal(cell, e + 3f, n, u, 64);
|
||||
_fx.SpawnKillBurst(cell, e, n + 3f, u, crit: true, now);
|
||||
Host.Log("[RynthJuice] test numbers spawned around you.");
|
||||
}
|
||||
}
|
||||
74
Plugins/RynthCore.Plugin.RynthJuice/VectorFont.cs
Normal file
74
Plugins/RynthCore.Plugin.RynthJuice/VectorFont.cs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
using System.Numerics;
|
||||
|
||||
namespace RynthCore.Plugin.RynthJuice;
|
||||
|
||||
/// <summary>
|
||||
/// A tiny stroke-based vector font. Nav3D has no text primitive, so each glyph
|
||||
/// is defined as a set of line segments on a normalized 2×4 grid (x ∈ [0,2],
|
||||
/// y ∈ [0,4], y increasing DOWNWARD to match screen space). The renderer
|
||||
/// (<see cref="JuiceEffects"/>) turns every stroke into a thin billboarded quad.
|
||||
///
|
||||
/// Only the characters combat juice needs are defined: digits 0-9, '+' (heals),
|
||||
/// '!' and the letters C R I T (for the "CRIT!" tag). Unknown chars render as a
|
||||
/// blank advance.
|
||||
/// </summary>
|
||||
internal static class VectorFont
|
||||
{
|
||||
public const float GlyphWidth = 2f; // max x in grid units
|
||||
public const float GlyphHeight = 4f; // max y in grid units
|
||||
public const float Advance = 3f; // per-char horizontal step (glyph + gap)
|
||||
|
||||
// Seven-segment grid points:
|
||||
// (0,0)──A──(2,0)
|
||||
// │ │
|
||||
// F B
|
||||
// │ │
|
||||
// (0,2)──G──(2,2)
|
||||
// │ │
|
||||
// E C
|
||||
// │ │
|
||||
// (0,4)──D──(2,4)
|
||||
private static readonly Vector4 A = new(0, 0, 2, 0); // top
|
||||
private static readonly Vector4 B = new(2, 0, 2, 2); // upper-right
|
||||
private static readonly Vector4 C = new(2, 2, 2, 4); // lower-right
|
||||
private static readonly Vector4 D = new(0, 4, 2, 4); // bottom
|
||||
private static readonly Vector4 E = new(0, 2, 0, 4); // lower-left
|
||||
private static readonly Vector4 F = new(0, 0, 0, 2); // upper-left
|
||||
private static readonly Vector4 G = new(0, 2, 2, 2); // middle
|
||||
|
||||
private static readonly Vector4[] Zero = { A, B, C, D, E, F };
|
||||
private static readonly Vector4[] One = { B, C };
|
||||
private static readonly Vector4[] Two = { A, B, G, E, D };
|
||||
private static readonly Vector4[] Three = { A, B, G, C, D };
|
||||
private static readonly Vector4[] Four = { F, G, B, C };
|
||||
private static readonly Vector4[] Five = { A, F, G, C, D };
|
||||
private static readonly Vector4[] Six = { A, F, G, E, C, D };
|
||||
private static readonly Vector4[] Seven = { A, B, C };
|
||||
private static readonly Vector4[] Eight = { A, B, C, D, E, F, G };
|
||||
private static readonly Vector4[] Nine = { A, B, C, D, F, G };
|
||||
|
||||
private static readonly Vector4[] Plus = { new(0, 2, 2, 2), new(1, 1, 1, 3) };
|
||||
private static readonly Vector4[] Bang = { new(1, 0, 1, 2.6f), new(1, 3.4f, 1, 4f) };
|
||||
|
||||
private static readonly Vector4[] LetterC = { A, F, E, D };
|
||||
// R: left bar + top + upper-right + middle + diagonal leg
|
||||
private static readonly Vector4[] LetterR = { F, E, A, B, G, new(1, 2, 2, 4) };
|
||||
private static readonly Vector4[] LetterI = { new(1, 0, 1, 4) };
|
||||
private static readonly Vector4[] LetterT = { A, new(1, 0, 1, 4) };
|
||||
|
||||
private static readonly Vector4[] Empty = System.Array.Empty<Vector4>();
|
||||
|
||||
/// <summary>Strokes for a glyph, in grid units. Empty array = blank advance.</summary>
|
||||
public static Vector4[] Strokes(char c) => c switch
|
||||
{
|
||||
'0' => Zero, '1' => One, '2' => Two, '3' => Three, '4' => Four,
|
||||
'5' => Five, '6' => Six, '7' => Seven, '8' => Eight, '9' => Nine,
|
||||
'+' => Plus, '!' => Bang,
|
||||
'C' => LetterC, 'R' => LetterR, 'I' => LetterI, 'T' => LetterT,
|
||||
_ => Empty,
|
||||
};
|
||||
|
||||
/// <summary>Total grid width of a string (for centering): N chars × Advance, trimmed of the trailing gap.</summary>
|
||||
public static float MeasureWidth(string s) =>
|
||||
s.Length == 0 ? 0f : s.Length * Advance - (Advance - GlyphWidth);
|
||||
}
|
||||
|
|
@ -4,7 +4,8 @@
|
|||
(..\Shared\ServerPack\ServerPlugin.props); ServerData.cs holds what is known about the server. -->
|
||||
<PropertyGroup>
|
||||
<AssemblyName>RynthCore.Plugin.RynthLeafDawn</AssemblyName>
|
||||
<Version>0.1.0</Version>
|
||||
<!-- Previous release: 0.1.2. -->
|
||||
<Version>0.1.4</Version>
|
||||
<RynthPluginServerId>leafdawn</RynthPluginServerId>
|
||||
<RynthPluginServerName>LeafDawn</RynthPluginServerName>
|
||||
<RynthPluginServerHosts>leafdawn.hopto.org</RynthPluginServerHosts>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
(..\Shared\ServerPack\ServerPlugin.props); ServerData.cs holds what is known about the server. -->
|
||||
<PropertyGroup>
|
||||
<AssemblyName>RynthCore.Plugin.RynthLeafdawning</AssemblyName>
|
||||
<Version>0.1.0</Version>
|
||||
<!-- Previous release: 0.1.2. -->
|
||||
<Version>0.1.4</Version>
|
||||
<RynthPluginServerId>leafdawning</RynthPluginServerId>
|
||||
<RynthPluginServerName>Leafdawning</RynthPluginServerName>
|
||||
<RynthPluginServerHosts>leafdawning.duckdns.org</RynthPluginServerHosts>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!-- RynthLevistras: the Levistras server plugin (a botting-free server). The build is shared
|
||||
(..\Shared\ServerPack\ServerPlugin.props); ServerData.cs holds what is known about the server. -->
|
||||
<PropertyGroup>
|
||||
<AssemblyName>RynthCore.Plugin.RynthLevistras</AssemblyName>
|
||||
<!-- Previous release: 0.1.2. -->
|
||||
<Version>0.1.4</Version>
|
||||
<RynthPluginServerId>levistras</RynthPluginServerId>
|
||||
<RynthPluginServerName>Levistras</RynthPluginServerName>
|
||||
<RynthPluginServerHosts>levistras.acportalstorm.com</RynthPluginServerHosts>
|
||||
<RynthPluginServerWorldNames>Levistras</RynthPluginServerWorldNames>
|
||||
<RynthPluginDescription>Levistras only: the server card (rules, account limits, its no-botting rule, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||
|
||||
</Project>
|
||||
25
Plugins/RynthCore.Plugin.RynthLevistras/ServerData.cs
Normal file
25
Plugins/RynthCore.Plugin.RynthLevistras/ServerData.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// ServerData.cs - What is known about Levistras (RynthLevistras). Identity (id, hosts, world names) is in the csproj.
|
||||
namespace RynthCore.Plugin.ServerPack;
|
||||
|
||||
internal static class ServerData
|
||||
{
|
||||
public static ServerPackInfo Create() =>
|
||||
new(RynthPluginInfo.ServerId, RynthPluginInfo.ServerName, RynthPluginInfo.ServerHosts, RynthPluginInfo.ServerWorldNames)
|
||||
{
|
||||
Port = 9000,
|
||||
Emulator = "ACE",
|
||||
Ruleset = "PvE",
|
||||
Status = "Stable",
|
||||
Summary = "A 100% Botting-Free PvE Server! Open access! 2 account limit",
|
||||
Facts = new[]
|
||||
{
|
||||
"Open access.",
|
||||
"RynthOracle has a Levistras quest pack (quests.levistras.csv).",
|
||||
},
|
||||
AccountLimit = "2 accounts",
|
||||
Botting = BottingPolicy.Forbidden,
|
||||
BottingNote = "\"100% Botting-Free\" (the server's own description)",
|
||||
Discord = "https://discord.gg/TtkcWbv",
|
||||
Source = "public AC server list (acresources/serverslist), checked 2026-10-13",
|
||||
};
|
||||
}
|
||||
|
|
@ -144,6 +144,22 @@ internal sealed class Atlas
|
|||
// ── Search ───────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>How well <paramref name="name"/> matches <paramref name="q"/> (lower case): 0 = not at all.</summary>
|
||||
/// <summary>
|
||||
/// "a || b || c": the first candidate that is coordinates, or that names a place on the map as a
|
||||
/// whole word or more (<see cref="MatchScore"/> 60+: "Mite Maze" yes, "Bur" inside "Burun" no),
|
||||
/// so a loose candidate never picks an unrelated place. Null when none does.
|
||||
/// </summary>
|
||||
public string? FirstOnMap(string alternatives, bool hasPos, double ns, double ew)
|
||||
{
|
||||
foreach (string raw in alternatives.Split("||", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries))
|
||||
{
|
||||
if (NavCoords.TrySplitCoordsAndName(raw, out _, out _, out _)) return raw;
|
||||
AtlasLocation? best = FindBest(raw, hasPos, ns, ew);
|
||||
if (best != null && MatchScore(best.Name, raw) >= 60) return raw;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int MatchScore(string name, string q)
|
||||
{
|
||||
if (q.Length == 0) return 1;
|
||||
|
|
|
|||
|
|
@ -669,6 +669,25 @@ public sealed partial class RynthNavPlugin
|
|||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// "a || b || c": the first candidate that is coordinates, or that names a place on the map
|
||||
/// as a whole word or more (Atlas.MatchScore 60+: "Mite Maze" yes, "Bur" inside "Burun" no),
|
||||
/// so a loose candidate never sends the character to an unrelated place. False (and why)
|
||||
/// when none does.
|
||||
/// </summary>
|
||||
private bool PickAlternative(string text, out string picked, out string why)
|
||||
{
|
||||
why = "";
|
||||
bool hasPos = PlayerMapPos(out double pns, out double pew);
|
||||
picked = _atlas.FirstOnMap(text, hasPos, pns, pew) ?? "";
|
||||
if (picked.Length > 0) return true;
|
||||
// Coordinates are always taken, so here every candidate was a name.
|
||||
why = _atlas.Locations.Count == 0
|
||||
? "the Atlas isn't loaded (" + _atlasStatus + ")"
|
||||
: "none of these is a place on the map: " + text.Replace("||", ",");
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>The Atlas place the last ResolveTarget picked (null for bare coordinates). Tick thread.</summary>
|
||||
private AtlasLocation? _resolvedPlace;
|
||||
|
||||
|
|
@ -995,6 +1014,12 @@ public sealed partial class RynthNavPlugin
|
|||
int sp = raw.IndexOf(' ');
|
||||
string cmd = (sp < 0 ? raw : raw.Substring(0, sp)).ToLowerInvariant();
|
||||
string rest = sp < 0 ? string.Empty : raw.Substring(sp + 1).Trim();
|
||||
// "go a || b || c" (Oracle's Dynamic Stamps, any caller): the first candidate on the map.
|
||||
if (cmd is "go" or "goto" or "route" or "arrow" && rest.Contains("||", StringComparison.Ordinal))
|
||||
{
|
||||
if (!PickAlternative(rest, out string picked, out string why)) { Note(why); return; }
|
||||
rest = picked;
|
||||
}
|
||||
switch (cmd)
|
||||
{
|
||||
case "":
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace RynthCore.Plugin.RynthNav;
|
|||
public sealed partial class RynthNavPlugin : RynthPluginBase
|
||||
{
|
||||
internal static readonly IntPtr NamePointer = Marshal.StringToHGlobalAnsi("RynthNav");
|
||||
internal const string PluginVersion = "0.6.7";
|
||||
internal const string PluginVersion = "0.6.8";
|
||||
internal static readonly IntPtr VersionPointer = Marshal.StringToHGlobalAnsi(PluginVersion);
|
||||
|
||||
/// <summary>Lets PluginExports log through this plugin's host (the base Log is protected).</summary>
|
||||
|
|
|
|||
152
Plugins/RynthCore.Plugin.RynthOracle/Data/DynamicStamps.cs
Normal file
152
Plugins/RynthCore.Plugin.RynthOracle/Data/DynamicStamps.cs
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace RynthCore.Plugin.RynthOracle.Data;
|
||||
|
||||
/// <summary>
|
||||
/// One Infinite Leaftide Dynamic Stamp (dynstamps.csv): an NPC hand-in that puts a
|
||||
/// "Dynamic_N_..." quest flag on the character. List from the players' "ExtraDyn" sheet
|
||||
/// (10.13.2026, one sheet per area, the wiki's Dynamic Stamps page); NPCs that give no stamp
|
||||
/// are left out. A stamp is a one-time flag: having it in /myquests means it's done.
|
||||
/// </summary>
|
||||
internal sealed class DynamicStamp
|
||||
{
|
||||
public string Area = "";
|
||||
/// <summary>Where in the area (a town, a dungeon, coordinates), or "".</summary>
|
||||
public string Place = "";
|
||||
public string Npc = "";
|
||||
/// <summary>What the NPC gives back (the sheet's "X gives you Y"), or "".</summary>
|
||||
public string Reward = "";
|
||||
/// <summary>The quest flag, lower case (as QuestFlagStore keys it).</summary>
|
||||
public string Stamp = "";
|
||||
public string Note = "";
|
||||
|
||||
/// <summary>The NPC, else the place (a few sheet rows only name the spot).</summary>
|
||||
public string Label => Npc.Length > 0 ? Npc : Place;
|
||||
|
||||
/// <summary>
|
||||
/// The flag this character has for the stamp, or null. The sheet has a few stamps copied
|
||||
/// without their closing "!" or cut short: those also match with "!" added and, when at
|
||||
/// least <see cref="MinPrefixLength"/> long, the one Dynamic flag on the character starting
|
||||
/// with them.
|
||||
/// </summary>
|
||||
public string? MatchedFlag(QuestFlagStore flags)
|
||||
{
|
||||
if (flags.TryGet(Stamp, out _)) return Stamp;
|
||||
if (Stamp.EndsWith('!')) return null;
|
||||
if (flags.TryGet(Stamp + "!", out _)) return Stamp + "!";
|
||||
if (Stamp.Length < MinPrefixLength) return null;
|
||||
string? only = null;
|
||||
foreach (string key in flags.Flags.Keys)
|
||||
{
|
||||
if (!key.StartsWith(Stamp, StringComparison.OrdinalIgnoreCase)) continue;
|
||||
if (only != null) return null; // more than one: can't tell which
|
||||
only = key;
|
||||
}
|
||||
return only;
|
||||
}
|
||||
|
||||
public bool Have(QuestFlagStore flags) => MatchedFlag(flags) != null;
|
||||
|
||||
// Sheet areas that are groupings, not places on the map.
|
||||
private static readonly HashSet<string> NotPlaces = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
"Looking Around", "Odd Stamps", "Odd Stamps 2",
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Where RynthNav should go for this stamp, best first (RynthNav takes the first that is on its
|
||||
/// map): the coordinates in the note or the place, the place and its parts ("Mhoire Castle -
|
||||
/// Great Hall" also tries "Mhoire Castle"), the NPC, then the area. Empty when there is nothing.
|
||||
/// </summary>
|
||||
public List<string> NavCandidates()
|
||||
{
|
||||
var list = new List<string>();
|
||||
void Add(string s)
|
||||
{
|
||||
s = s.Trim().Trim('.', ',', ';', ':').Trim();
|
||||
if (s.Length >= 4 && !char.IsDigit(s[0]) && !list.Contains(s, StringComparer.OrdinalIgnoreCase)) list.Add(s);
|
||||
}
|
||||
|
||||
foreach (string text in new[] { Note, Place })
|
||||
if (NavTargets.FirstCoords(text) is string c && !list.Contains(c)) list.Add(c);
|
||||
|
||||
string place = NavTargets.WithoutCoords(Place);
|
||||
place = System.Text.RegularExpressions.Regex.Replace(place, @"\b(at|in the|nearby)\b", " ", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
|
||||
place = System.Text.RegularExpressions.Regex.Replace(place, @"\s+", " ").Trim();
|
||||
Add(place);
|
||||
foreach (string part in place.Split(new[] { " - ", " / ", "(", ")" }, StringSplitOptions.RemoveEmptyEntries))
|
||||
Add(part);
|
||||
Add(Npc);
|
||||
if (!NotPlaces.Contains(Area)) Add(Area);
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>A truncated stamp shorter than this is matched exactly only (too many flags share a short stem).</summary>
|
||||
public const int MinPrefixLength = 14;
|
||||
}
|
||||
|
||||
internal static class DynamicStampList
|
||||
{
|
||||
/// <summary>Dynamic stamp quest flags start with this (lower case).</summary>
|
||||
public const string FlagPrefix = "dynamic_";
|
||||
|
||||
public static List<DynamicStamp> All { get; } = Load();
|
||||
|
||||
/// <summary>The areas in list order (Facility Hub, Looking Around, ...).</summary>
|
||||
public static List<string> Areas { get; } = BuildAreas();
|
||||
|
||||
/// <summary>
|
||||
/// Dynamic stamps on this character that the list doesn't have (new or unlisted NPCs), so the
|
||||
/// tab can show them and the count isn't only what the sheet knows.
|
||||
/// </summary>
|
||||
public static List<string> Unlisted(QuestFlagStore flags)
|
||||
{
|
||||
var matched = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (DynamicStamp s in All)
|
||||
if (s.MatchedFlag(flags) is string f) matched.Add(f);
|
||||
var extra = new List<string>();
|
||||
foreach (string key in flags.Flags.Keys)
|
||||
if (key.StartsWith(FlagPrefix, StringComparison.OrdinalIgnoreCase) && !matched.Contains(key))
|
||||
extra.Add(key);
|
||||
extra.Sort(StringComparer.OrdinalIgnoreCase);
|
||||
return extra;
|
||||
}
|
||||
|
||||
private static List<DynamicStamp> Load()
|
||||
{
|
||||
var list = new List<DynamicStamp>();
|
||||
using StreamReader r = Csv.OpenEmbedded("dynstamps.csv");
|
||||
Dictionary<string, int> col = Csv.MapColumns(r.ReadLine() ?? "");
|
||||
int cArea = Csv.Column(col, "Area"), cPlace = Csv.Column(col, "Place"), cNpc = Csv.Column(col, "Npc"),
|
||||
cReward = Csv.Column(col, "Reward"), cStamp = Csv.Column(col, "Stamp"), cNote = Csv.Column(col, "Note");
|
||||
var seen = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
while (r.ReadLine() is string line)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(line)) continue;
|
||||
string[] f = Csv.ParseLine(line);
|
||||
string stamp = Csv.Field(f, cStamp).Trim().ToLowerInvariant();
|
||||
if (!stamp.StartsWith(FlagPrefix, StringComparison.Ordinal) || !seen.Add(stamp)) continue;
|
||||
list.Add(new DynamicStamp
|
||||
{
|
||||
Area = Csv.Field(f, cArea),
|
||||
Place = Csv.Field(f, cPlace),
|
||||
Npc = Csv.Field(f, cNpc),
|
||||
Reward = Csv.Field(f, cReward),
|
||||
Stamp = stamp,
|
||||
Note = Csv.Field(f, cNote),
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static List<string> BuildAreas()
|
||||
{
|
||||
var areas = new List<string>();
|
||||
foreach (DynamicStamp s in All)
|
||||
if (!areas.Contains(s.Area)) areas.Add(s.Area);
|
||||
return areas;
|
||||
}
|
||||
}
|
||||
117
Plugins/RynthCore.Plugin.RynthOracle/Data/Legendary.cs
Normal file
117
Plugins/RynthCore.Plugin.RynthOracle/Data/Legendary.cs
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace RynthCore.Plugin.RynthOracle.Data;
|
||||
|
||||
/// <summary>
|
||||
/// One Legendary Key quest (legendary.csv; list and notes from the "Arwic John Route" sheet).
|
||||
/// The quest's own /myquests flags say whether it was ever done and when it can be run again:
|
||||
/// the first flag is its completion stamp, any others only add their repeat timers (a key pickup
|
||||
/// timer, say). John in Arwic counts 30 different ones (legendaryquestcounter_0913).
|
||||
/// </summary>
|
||||
internal sealed class LegendaryQuest
|
||||
{
|
||||
public string Group = "";
|
||||
public string Name = "";
|
||||
/// <summary>The short name players use ("RTW", "HMD"), or "".</summary>
|
||||
public string CommonName = "";
|
||||
public int Luminance;
|
||||
public string[] Flags = Array.Empty<string>();
|
||||
public string Url = "";
|
||||
public string Note = "";
|
||||
public string Video = "";
|
||||
|
||||
/// <summary>The short name when the sheet has one, else the quest name.</summary>
|
||||
public string Label => CommonName.Length > 0 ? $"{Name} ({CommonName})" : Name;
|
||||
|
||||
/// <summary>Done at least once: any of its flags is on this character.</summary>
|
||||
public bool Have(QuestFlagStore flags)
|
||||
{
|
||||
foreach (string f in Flags)
|
||||
if (flags.TryGet(f, out _)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Time until it can be run again: the longest wait among its flags that have a repeat timer;
|
||||
/// zero when every timer is up (or it has none). Null when it was never done.
|
||||
/// </summary>
|
||||
public TimeSpan? TimeLeft(QuestFlagStore flags, DateTime utcNow)
|
||||
{
|
||||
bool any = false;
|
||||
TimeSpan left = TimeSpan.Zero;
|
||||
foreach (string f in Flags)
|
||||
{
|
||||
if (!flags.TryGet(f, out QuestFlag q)) continue;
|
||||
any = true;
|
||||
if (q.RepeatTime <= TimeSpan.Zero || q.CompletedOnUtc == DateTime.MinValue) continue;
|
||||
TimeSpan d = q.NextAvailableTime(utcNow);
|
||||
if (d > left) left = d;
|
||||
}
|
||||
return any ? left : null;
|
||||
}
|
||||
|
||||
/// <summary>"missing", "ready" or the time left ("14h 3m").</summary>
|
||||
public string Status(QuestFlagStore flags, DateTime utcNow)
|
||||
{
|
||||
TimeSpan? left = TimeLeft(flags, utcNow);
|
||||
if (left == null) return "missing";
|
||||
return left.Value.TotalSeconds > 0 ? TimeText.Friendly(left.Value) : "ready";
|
||||
}
|
||||
}
|
||||
|
||||
internal static class LegendaryList
|
||||
{
|
||||
/// <summary>John's count of different Legendary Key quests done (needs 30).</summary>
|
||||
public const string CounterFlag = "legendaryquestcounter_0913";
|
||||
/// <summary>Legendary Key quests John asks for.</summary>
|
||||
public const int JohnTarget = 30;
|
||||
|
||||
public static List<LegendaryQuest> All { get; } = Load();
|
||||
|
||||
/// <summary>The groups in list order (Graveyard, Rynthid, ...).</summary>
|
||||
public static List<string> Groups { get; } = BuildGroups();
|
||||
|
||||
/// <summary>John's counter for this character; null when /myquests doesn't have it (not started).</summary>
|
||||
public static int? JohnCount(QuestFlagStore flags) =>
|
||||
flags.TryGet(CounterFlag, out QuestFlag q) ? q.Solves : null;
|
||||
|
||||
private static List<LegendaryQuest> Load()
|
||||
{
|
||||
var list = new List<LegendaryQuest>();
|
||||
using StreamReader r = Csv.OpenEmbedded("legendary.csv");
|
||||
Dictionary<string, int> col = Csv.MapColumns(r.ReadLine() ?? "");
|
||||
int cGroup = Csv.Column(col, "Group"), cName = Csv.Column(col, "Quest"), cCommon = Csv.Column(col, "CommonName"),
|
||||
cLum = Csv.Column(col, "Luminance"), cFlags = Csv.Column(col, "Flags"), cUrl = Csv.Column(col, "Url"),
|
||||
cNote = Csv.Column(col, "Note"), cVideo = Csv.Column(col, "Video");
|
||||
while (r.ReadLine() is string line)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(line)) continue;
|
||||
string[] f = Csv.ParseLine(line);
|
||||
string name = Csv.Field(f, cName);
|
||||
if (name.Length == 0) continue;
|
||||
list.Add(new LegendaryQuest
|
||||
{
|
||||
Group = Csv.Field(f, cGroup),
|
||||
Name = name,
|
||||
CommonName = Csv.Field(f, cCommon),
|
||||
Luminance = int.TryParse(Csv.Field(f, cLum), out int lum) ? lum : 0,
|
||||
Flags = Csv.Field(f, cFlags).ToLowerInvariant()
|
||||
.Split(';', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries),
|
||||
Url = Csv.Field(f, cUrl),
|
||||
Note = Csv.Field(f, cNote),
|
||||
Video = Csv.Field(f, cVideo),
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static List<string> BuildGroups()
|
||||
{
|
||||
var groups = new List<string>();
|
||||
foreach (LegendaryQuest q in All)
|
||||
if (!groups.Contains(q.Group)) groups.Add(q.Group);
|
||||
return groups;
|
||||
}
|
||||
}
|
||||
86
Plugins/RynthCore.Plugin.RynthOracle/Data/NavTargets.cs
Normal file
86
Plugins/RynthCore.Plugin.RynthOracle/Data/NavTargets.cs
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace RynthCore.Plugin.RynthOracle.Data;
|
||||
|
||||
/// <summary>
|
||||
/// Coordinates in Oracle's text (quest walkthroughs, Dynamic Stamp notes) as RynthNav targets.
|
||||
/// The lists write them every which way: "59.6S 88.0W", "8.8S, 53.1E", "42.6n 62.4e".
|
||||
/// </summary>
|
||||
internal static class NavTargets
|
||||
{
|
||||
private static readonly Regex CoordsRx = new(
|
||||
@"(?<ns>\d+(?:\.\d+)?)\s*(?<nsc>[NnSs])[\s,]*(?<ew>\d+(?:\.\d+)?)\s*(?<ewc>[EeWw])\b",
|
||||
RegexOptions.CultureInvariant);
|
||||
|
||||
/// <summary>One place to go: what the text calls it (may be empty) and its coordinates ("59.6S, 88.0W").</summary>
|
||||
internal readonly record struct Stop(string Label, string Coords)
|
||||
{
|
||||
/// <summary>The RynthNav target: the coordinates, then the label (RynthNav uses an Atlas
|
||||
/// place of that name there, e.g. a dungeon's entrance).</summary>
|
||||
public string Target => Label.Length > 0 ? Coords + " " + Label : Coords;
|
||||
|
||||
/// <summary>How a picker shows it: "Kill Mukkir Progenitor - 86.5N, 57.3E".</summary>
|
||||
public string Display => Label.Length > 0 ? Label + " - " + Coords : Coords;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A named place with no coordinates (an exploration marker's location): its name is the whole
|
||||
/// RynthNav target, and RynthNav finds it on its Atlas.
|
||||
/// </summary>
|
||||
public static Stop Place(string name) => new("", name.Trim());
|
||||
|
||||
/// <summary>The first coordinates in <paramref name="text"/>, written "8.8S, 53.1E", or null.</summary>
|
||||
public static string? FirstCoords(string? text)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text)) return null;
|
||||
Match m = CoordsRx.Match(text);
|
||||
return m.Success ? Format(m) : null;
|
||||
}
|
||||
|
||||
/// <summary><paramref name="text"/> with its coordinates taken out.</summary>
|
||||
public static string WithoutCoords(string? text) => string.IsNullOrEmpty(text) ? "" : CoordsRx.Replace(text, " ");
|
||||
|
||||
/// <summary>
|
||||
/// Every coordinate pair in <paramref name="text"/>, in order, each labelled with the words just
|
||||
/// before it in its step (walkthroughs separate steps with " - "): "Speak with Hoshar ibn Jalaq
|
||||
/// 59.6S 88.0W - Kill Mukkir Progenitor 86.5N 57.3E" gives two stops. The same coordinates
|
||||
/// twice are one stop.
|
||||
/// </summary>
|
||||
public static List<Stop> Stops(string? text)
|
||||
{
|
||||
var stops = new List<Stop>();
|
||||
if (string.IsNullOrEmpty(text)) return stops;
|
||||
foreach (Match m in CoordsRx.Matches(text))
|
||||
{
|
||||
string coords = Format(m);
|
||||
if (stops.Exists(s => s.Coords == coords)) continue;
|
||||
stops.Add(new Stop(LabelBefore(text, m.Index), coords));
|
||||
}
|
||||
return stops;
|
||||
}
|
||||
|
||||
/// <summary>The words between the previous step break (" - ", ". ", "; ", "|") or coordinates and <paramref name="at"/>.</summary>
|
||||
private static string LabelBefore(string text, int at)
|
||||
{
|
||||
int from = 0;
|
||||
foreach (string sep in new[] { " - ", ". ", "; ", "|", "(" })
|
||||
{
|
||||
int i = text.LastIndexOf(sep, Math.Max(0, at - 1), StringComparison.Ordinal);
|
||||
if (i >= 0 && i + sep.Length <= at) from = Math.Max(from, i + sep.Length);
|
||||
}
|
||||
// Not back past the previous coordinates ("Cragstone 26.0N 47.0E Speak with ...").
|
||||
foreach (Match m in CoordsRx.Matches(text.Substring(0, at)))
|
||||
from = Math.Max(from, m.Index + m.Length);
|
||||
string label = text.Substring(from, at - from).Trim(' ', ',', ':', '-', '.', '(', ')');
|
||||
// "at 42.1N ..." and "Meet at 42.1N ...": the little words around the coordinates aren't the place.
|
||||
label = Regex.Replace(label, @"^(at|in|near|to)\s+|\s+(at|in|near|to)$", "", RegexOptions.IgnoreCase).Trim();
|
||||
return label.Length > 60 ? label.Substring(0, 60).TrimEnd() : label;
|
||||
}
|
||||
|
||||
private static string Format(Match m) =>
|
||||
string.Create(CultureInfo.InvariantCulture,
|
||||
$"{m.Groups["ns"].Value}{char.ToUpperInvariant(m.Groups["nsc"].Value[0])}, {m.Groups["ew"].Value}{char.ToUpperInvariant(m.Groups["ewc"].Value[0])}");
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ internal sealed class QuestFlag
|
|||
}
|
||||
|
||||
/// <summary>What one chat line is, as far as /myquests goes.</summary>
|
||||
internal enum MyQuestsLine { None, Quest, Empty, Disabled }
|
||||
internal enum MyQuestsLine { None, Quest, Empty, Disabled, Throttled }
|
||||
|
||||
/// <summary>
|
||||
/// The character's quest flags, read from the server's /myquests reply (ACE: one Broadcast line
|
||||
|
|
@ -55,10 +55,21 @@ internal sealed class QuestFlagStore
|
|||
|
||||
public const string EmptyText = "Quest list is empty.";
|
||||
public const string DisabledText = "The command \"myquests\" is not currently enabled on this server.";
|
||||
/// <summary>ACECustom's per-session throttle reply ("... may only be run once every 60 seconds.").</summary>
|
||||
public const string ThrottledText = "[MyQuests] This command may only be run once every";
|
||||
|
||||
private const int QuietMs = 1500; // a reply is complete once no line came for this long
|
||||
private const int RequestTimeoutMs = 10_000;
|
||||
private const int MinRequestGapMs = 5_000;
|
||||
/// <summary>ACECustom answers one /myquests a minute per session (whoever sent the last one).</summary>
|
||||
private const int ServerThrottleMs = 60_000;
|
||||
/// <summary>
|
||||
/// A reply this much smaller than the flags already held is taken as cut short (chat lines
|
||||
/// dropped before they reached the plugin), so it updates the flags instead of replacing them.
|
||||
/// </summary>
|
||||
private const double PartialReplyRatio = 0.8;
|
||||
/// <summary>Below this many flags held, a smaller reply always replaces (nothing much to lose).</summary>
|
||||
private const int PartialReplyMinHeld = 20;
|
||||
|
||||
public Dictionary<string, QuestFlag> Flags { get; private set; } = new(StringComparer.OrdinalIgnoreCase);
|
||||
private Dictionary<string, QuestFlag>? _pending;
|
||||
|
|
@ -66,6 +77,15 @@ internal sealed class QuestFlagStore
|
|||
|
||||
public DateTime LastReadUtc { get; private set; } = DateTime.MinValue;
|
||||
public bool ServerDisabled { get; private set; }
|
||||
/// <summary>The server refused the last /myquests (its once-a-minute limit) until this tick.</summary>
|
||||
public long ThrottledUntilMs { get; private set; } = long.MinValue / 2;
|
||||
/// <summary>This server has shown its throttle line this session, so every reply starts its minute.</summary>
|
||||
private bool _serverThrottles;
|
||||
/// <summary>
|
||||
/// Set when the last reply looked cut short and was merged into the held flags (lines in the
|
||||
/// reply, flags held before it). The plugin logs it once and clears it.
|
||||
/// </summary>
|
||||
public (int Got, int Had)? LastPartialReply { get; set; }
|
||||
/// <summary>Bumps whenever the flags change (views rebuild their caches on it).</summary>
|
||||
public int Revision { get; private set; }
|
||||
|
||||
|
|
@ -77,10 +97,16 @@ internal sealed class QuestFlagStore
|
|||
|
||||
public bool Loading => _pending != null || AwaitingOurs;
|
||||
|
||||
/// <summary>Seconds left on the server's /myquests limit (0 when a request would be answered).</summary>
|
||||
public int ThrottleSecondsLeft(long nowMs) =>
|
||||
nowMs < ThrottledUntilMs ? (int)((ThrottledUntilMs - nowMs + 999) / 1000) : 0;
|
||||
|
||||
/// <summary>Sends /myquests unless one went out moments ago. Returns false if nothing was sent.</summary>
|
||||
public bool Request(Func<string, bool> invokeChat, long nowMs)
|
||||
{
|
||||
if (nowMs - _requestedMs < MinRequestGapMs) return false;
|
||||
// The server would only answer with its throttle line; don't spend the request.
|
||||
if (nowMs < ThrottledUntilMs) return false;
|
||||
_requestedMs = nowMs;
|
||||
Interlocked.Increment(ref _selfSends);
|
||||
if (!invokeChat("/myquests"))
|
||||
|
|
@ -120,6 +146,16 @@ internal sealed class QuestFlagStore
|
|||
Revision++;
|
||||
return MyQuestsLine.Disabled;
|
||||
}
|
||||
if (line.Contains(ThrottledText, StringComparison.Ordinal))
|
||||
{
|
||||
// No reply is coming: stop "Reading..." and keep the flags already held. The minute
|
||||
// really started at the last answered request; a full minute from now is the safe side.
|
||||
_serverThrottles = true;
|
||||
ThrottledUntilMs = nowMs + ServerThrottleMs;
|
||||
AwaitingOurs = false;
|
||||
Revision++;
|
||||
return MyQuestsLine.Throttled;
|
||||
}
|
||||
if (line.IndexOf(" solves (", StringComparison.Ordinal) < 0) return MyQuestsLine.None;
|
||||
|
||||
QuestFlag? flag = Parse(line);
|
||||
|
|
@ -139,9 +175,27 @@ internal sealed class QuestFlagStore
|
|||
|
||||
if (_pending != null && nowMs - _lastLineMs >= QuietMs)
|
||||
{
|
||||
Flags = _pending;
|
||||
Dictionary<string, QuestFlag> reply = _pending;
|
||||
_pending = null;
|
||||
int had = Flags.Count;
|
||||
// A full reply replaces the list (a flag the server dropped goes away). One much
|
||||
// smaller than what is held lost lines on the way (the engine's chat queue drops the
|
||||
// oldest of a long burst): update what came and keep the rest, rather than blanking.
|
||||
if (had >= PartialReplyMinHeld && reply.Count > 0 && reply.Count < had * PartialReplyRatio)
|
||||
{
|
||||
var merged = new Dictionary<string, QuestFlag>(Flags, StringComparer.OrdinalIgnoreCase);
|
||||
foreach (KeyValuePair<string, QuestFlag> kv in reply) merged[kv.Key] = kv.Value;
|
||||
Flags = merged;
|
||||
LastPartialReply = (reply.Count, had);
|
||||
}
|
||||
else
|
||||
{
|
||||
Flags = reply;
|
||||
}
|
||||
LastReadUtc = DateTime.UtcNow;
|
||||
// On a throttling server any reply (ours, the player's, RynthAi's poll) starts its minute.
|
||||
if (_serverThrottles)
|
||||
ThrottledUntilMs = nowMs + ServerThrottleMs - QuietMs;
|
||||
AwaitingOurs = false;
|
||||
Revision++;
|
||||
}
|
||||
|
|
@ -158,6 +212,9 @@ internal sealed class QuestFlagStore
|
|||
AwaitingOurs = false;
|
||||
LastReadUtc = DateTime.MinValue;
|
||||
ServerDisabled = false;
|
||||
ThrottledUntilMs = long.MinValue / 2;
|
||||
_serverThrottles = false;
|
||||
LastPartialReply = null;
|
||||
Revision++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,14 @@ internal sealed class OracleContext
|
|||
|
||||
/// <summary>Set by the plugin: sends a verb to RynthILT's breeding tracker (RynthIltDataApi PetBreedingCommand).</summary>
|
||||
public Func<string, bool> BreedingCommand = _ => false;
|
||||
/// <summary>RynthILT's Temple guardians (None without RynthILT 0.2.20+); read while the Quests tab shows on Infinite Leaftide.</summary>
|
||||
public RynthCore.Plugin.Shared.IltGuardianView Guardian = RynthCore.Plugin.Shared.IltGuardianView.None;
|
||||
/// <summary>Goes up each time <see cref="Guardian"/> changes, so the Quests list rebuilds its guardian rows.</summary>
|
||||
public int GuardianRevision;
|
||||
/// <summary>The last guardian button's outcome, shown under the guardian controls.</summary>
|
||||
public string GuardianMessage = "";
|
||||
/// <summary>Set by the plugin: sends a verb to RynthILT's guardians (RynthIltDataApi GuardianCommand).</summary>
|
||||
public Func<string, bool> GuardianCommand = _ => false;
|
||||
/// <summary>RynthCore's server list (API v86) and the active server owner's settings; State null on older engines.</summary>
|
||||
public readonly RynthCore.Plugin.Shared.ServerStateClient ServerState = new();
|
||||
/// <summary>ConquestAC-only data (tag Conquest); fed only while on ConquestAC.</summary>
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public static unsafe class PluginExports
|
|||
public static IntPtr GetVersion()
|
||||
{
|
||||
// Keep in step with RynthOraclePlugin.Version (a u8 literal can't be built from a const string).
|
||||
try { return LiteralPointer("0.3.1"u8); }
|
||||
try { return LiteralPointer("0.4.0"u8); }
|
||||
catch { return IntPtr.Zero; }
|
||||
}
|
||||
|
||||
|
|
|
|||
244
Plugins/RynthCore.Plugin.RynthOracle/Resources/dynstamps.csv
Normal file
244
Plugins/RynthCore.Plugin.RynthOracle/Resources/dynstamps.csv
Normal file
|
|
@ -0,0 +1,244 @@
|
|||
Area,Place,Npc,Reward,Stamp,Note
|
||||
"Facility Hub","Folthid Cellar","Raxanza Folthid","O-Yoroi Leggings","Dynamic_1_Aq2hMsFmW!",""
|
||||
"Facility Hub","Folthid Cellar","Felscuda","Healing Rabbit Pie","Dynamic_1_&9jiyTB!","8.8S, 53.1E"
|
||||
"Facility Hub","Folthid Cellar","Mi Krau-Li","examines your Parchment","Dynamic_1_WAuFukcRLoL5!",""
|
||||
"Looking Around","","Le-Ai Rea","Blue Molly","Dynamic_1_XH!!nh#^NaRp!","75.9S 57.3E"
|
||||
"Looking Around","Frost Haven","Robert","Greater Celdon Shadow Sleeves","Dynamic_1_HLq&!",""
|
||||
"Looking Around","Frost Haven","Elijah","Homemade Stout","Dynamic_1_MpBeVDU!",""
|
||||
"Looking Around","Frost Haven","Emma","Frost Slingshot","Dynamic_1_bEt6H5ECwGb2!",""
|
||||
"Looking Around","Frost Haven","Chef Pleist","Stone Mace","Dynamic_1_HgaUKA#hxa!",""
|
||||
"Looking Around","Frost Haven","The Mayor","Fried Egg","Dynamic_1_MRfxp5!g!",""
|
||||
"Looking Around","Frost Haven","Numb","Perfect Coruscating Isparian Mace","Dynamic_1_z8LpGZpe4rq!",""
|
||||
"Looking Around","Land Bridge Staging Complex","Director's Majordomo","Spitter Trochanter Metamorphi","Dynamic_1_FZYLYrAW1Zb!",""
|
||||
"Looking Around","Frost Haven","Mossy Chamber","Broken Virindi","Dynamic_1_ANND",""
|
||||
"Looking Around","Freebooter","Jusad the Collector","Renegade Atlatl of the Mountains","Dynamic_1_!mqkm9M!",""
|
||||
"Looking Around","Lum Seer","Shade of Lady Adja","Frost Board with Nail","Dynamic_1_ps6iG^P!ndH!",""
|
||||
"Looking Around","Frost Haven","Ka'hiri","Hearty Spiced Applesauce","Dynamic_1_s5MAzDcP9!",""
|
||||
"Looking Around","Frost Haven","Liam of Gelid","Composite Crossbow with Handle","Dynamic_1_7cv3O^MTLLKzs&!",""
|
||||
"Looking Around","84.1N, 44.1E","Aerlinthe Node Golem","Silifi of Crimson Stars","Dynamic_1_D6YxLUyUIW!","84.1N, 44.1E"
|
||||
"Looking Around","62.0N, 18.0E","Esper Node Golem","Composite Bow with Handle","Dynamic_1_LE5V8SVHG!","62.0N, 18.0E"
|
||||
"Looking Around","93.8N, 67.4W","Halaetan Node Golem","Slashing Longbow","Dynamic_1_QfLhcZJ64Hkold!","93.8N, 67.4W"
|
||||
"Looking Around","64.8S, 59.3E","Linvak Node Golem","Greater Celdon Shadow Girth","Dynamic_1_V8&t5$!","64.8S, 59.3E"
|
||||
"Looking Around","Ulgrim Island","Ulgrim the Unappreciated","Applesauce","Dynamic_1_x!zs79y!",""
|
||||
"Looking Around","Fake Niffis Crate Quest","Chef Jonus","Fish","Dynamic_1_j&T!ZrQwKvo!",""
|
||||
"Looking Around","Frost Haven","Larnia","Acid Hand Axe","Dynamic_1_88P$YBwEl!",""
|
||||
"Looking Around","Tanada Chamber of Scroll / Fire","Tanada Han-Tu","Hearty Ice Cream","Dynamic_1_STjY86!0Iu8x!",""
|
||||
"Looking Around","Frost Haven","Tanada Hido","Acid Mace","Dynamic_1_3ZhBEF!",""
|
||||
"Looking Around","Frost Haven","Tanada Shouka","Pouch of Dried Meat","Dynamic_1_YgClBFy!",""
|
||||
"Looking Around","Gerent's Compound at 87.2S, 17.5W","Representative of the Singularity","Fish","Dynamic_1_qkU0b^i!","87.2S, 17.5W"
|
||||
"Odd Stamps","93.2N, 48.2W in the Shattered Outlands","Arialle du Bellenesse","Healing Holtburger","Dynamic_1_ADm5RsrDGCbT!","93.2N, 48.2W"
|
||||
"Odd Stamps","Crater","Silencia's Magma Golem","Slicing Royal Atlatl","Dynamic_1_fR730X5VsPULE5!",""
|
||||
"Odd Stamps","Colosseum","Master Arbitrator","Palenqual's Tewhate","Dynamic_1_XnFt&!",""
|
||||
"Odd Stamps","","Colosseum Ticket Vendor","Silifi of Crimson Stars","Dynamic_1_luguukhgZg!",""
|
||||
"Odd Stamps","Beach Fort","Suzuhara Sheshumi","Silifi of Crimson Stars","Dynamic_1_n5u2imCs!",""
|
||||
"Odd Stamps","Obsidian Plains","Varetha","Major Smoldering Atlan Bow","Dynamic_1_P1&xxk5!","44.3S, 62.5W"
|
||||
"Odd Stamps","Crystal Crag","Oorjit","Perfect Shimmering Isparian Bow","Dynamic_1_lPn&BaZ!",""
|
||||
"Odd Stamps","","Jyotsana","Cragstone Farms Mac&Cheese","Dynamic_1_YCGJJ7cA!",""
|
||||
"Odd Stamps","","Tokashi Ando","Perfect Dissolving Isparian Crossbow","Dynamic_1_R#HIf!",""
|
||||
"Odd Stamps","Ries Woron's Story","Thrungus","Expired Stamina Draught","Dynamic_1_eMJVhyPzaa$aGn!",""
|
||||
"Odd Stamps","Mite Maze","Roderick","Apple Pie","Dynamic_1_#C^p&w0gV$$!",""
|
||||
"Odd Stamps","Sawato","Ssavish","Composite Bow with Handle","Dynamic_1_NMlDXfx2t!",""
|
||||
"Odd Stamps","dryreach rescue","Dansha-Ki","Composite Bow with Handle","Dynamic_1_FnXoHWS&kaM!",""
|
||||
"Odd Stamps","Seat of Knorr","Arikas, Warden of Knorr","Hearty Healing Rabbit Noodle","Dynamic_1_aWOWTc30f4",""
|
||||
"Odd Stamps","Swamp Garden","Terese","Diforsa Bracers","Dynamic_1_PTy0kqqTLP1Dn^!",""
|
||||
"Odd Stamps","Dark Isle","Tyrina of Arwic","Major Shadow Gauntlets","Dynamic_1_zJNxGBc!","84.7n 58.7e"
|
||||
"Odd Stamps","Dark Isle","Francois di Terli","Habraeloi","Dynamic_1_3!Og!",""
|
||||
"Odd Stamps 2","Aun Settlement 82.7N 21.2E.","Aun Tikakhe","Good Chilling Isparian Mace","Dynamic_1_hafO$cQvbkg!","82.7N 21.2E"
|
||||
"Odd Stamps 2","","Aun Saritea","Health Tonic","Dynamic_1_7yW17JvMHKu!",""
|
||||
"Odd Stamps 2","","Aun Aulakhe","Mana Rabbit Pie","Dynamic_1_5xE2TM!",""
|
||||
"Odd Stamps 2","Lost Wish Cottages (Arwic) 42.6n 62.4e","Lartorus","Pants","Dynamic_1_$GB72K!","42.6n 62.4e"
|
||||
"Odd Stamps 2","Catacombs of Opposition","Ripper","Gladiatorial Tunic","Dynamic_1_69Rjbany2pKD!",""
|
||||
"Odd Stamps 2","","Rat Nose","Fine Atlan Staff","Dynamic_1_eBlku!",""
|
||||
"Odd Stamps 2","","Nanoc, Basher of Bugs","Mana Potion","Dynamic_1_XCTiy!",""
|
||||
"Odd Stamps 2","","Narg","Iron Rusted Mace","Dynamic_1_S!AhI!",""
|
||||
"Odd Stamps 2","","Scout Luzumin Abigwei","Alduressa Helm","Dynamic_1_NFf5!",""
|
||||
"Odd Stamps 2","","Teela","Orange Molly","Dynamic_1_Bl#Y!",""
|
||||
"Odd Stamps 2","","Scout Tel al-Arat","Envoy's Heaume","Dynamic_1_AJ3Wm9Bk!",""
|
||||
"Odd Stamps 2","","Pincer Danta","Olthoi Sollerets","Dynamic_1_VezOOBWbn43KU!!",""
|
||||
"Odd Stamps 2","Vissidal","Merwart Pelagurg","Superior Smoldering Atlan Staff","Dynamic_1_DOIC1!",""
|
||||
"Odd Stamps 2","Vissidal","Merwart Urglurg","Butter Knife of Slaying","Dynamic_1_&!iRR#RrhnGA!",""
|
||||
"Odd Stamps 2","Vissidal","Dayla Bint Kazm","Hearty Healing Chicken Pie","Dynamic_1_nDAXG!",""
|
||||
"Odd Stamps 2","Vissidal","Peng-Ya","Major Dissolving Isparian Crossbow","Dynamic_1_sx^9H^&Mnqp!",""
|
||||
"Odd Stamps 2","Vissidal","Colista Fluress","Lesser Amuli Shadow Leggings","Dynamic_1_Ej!Zz!",""
|
||||
"Odd Stamps 2","99.7S 96.7W","Surloshen Realaidain","Hammer of Lightning","Dynamic_1_tiiFC!","99.7S 96.7W"
|
||||
"Odd Stamps 2","Silyiun - 89.1N 47.6W","Fiun Gaya","Enhanced Shadow Gauntlets","Dynamic_1_hev0!","89.1N 47.6W"
|
||||
"Odd Stamps 2","Hermit - Thrungus Hole","Hermit","Scored Amuli Leggings","Dynamic_1_rDBG!",""
|
||||
"Odd Stamps 2","93.2N 48.2W - Eastwatch","Commander Rylane di Cinghalle","Acid Crossbow","Dynamic_1_pZpx41&!","93.2N 48.2W"
|
||||
"Odd Stamps 2","32.0N, 43.2W - Virindi Crafters","Crafter of Arbelests","Healing Carrot Soup","Dynamic_1_L3Hb3O!","32.0N, 43.2W"
|
||||
"Odd Stamps 2","32.0N, 43.2W - Virindi Crafters","Crafter of Fists","Platemail Breastplate","Dynamic_1_xj&USOHNL9K&!","32.0N, 43.2W"
|
||||
"Odd Stamps 2","32.0N, 43.2W - Virindi Crafters","Crafter of Bows","Tasty Stout","Dynamic_1_hw2LNdjT6!","32.0N, 43.2W"
|
||||
"Odd Stamps 2","32.0N, 43.2W - Virindi Crafters","Crafter of Atlatls","Composite Crossbow with Handle","Dynamic_1_P6!!","32.0N, 43.2W"
|
||||
"Odd Stamps 2","32.0N, 43.2W - Virindi Crafters","Crafter of Axes","Three Eyed Guppy","Dynamic_1_xX^IHjOo##J$8E!","32.0N, 43.2W"
|
||||
"Odd Stamps 2","32.0N, 43.2W - Virindi Crafters","Crafter of Blades","Flaming Weeping Dagger","Dynamic_1_iFuvP!","32.0N, 43.2W"
|
||||
"Odd Stamps 2","32.0N, 43.2W - Virindi Crafters","Crafter of Staves","Composite Crossbow","Dynamic_1_J$JV&VKf!","32.0N, 43.2W"
|
||||
"Odd Stamps 2","32.0N, 43.2W - Virindi Crafters","Crafter of Orbs","Health Tincture","Dynamic_1_S&JMdWiBDy!","32.0N, 43.2W"
|
||||
"Odd Stamps 2","32.0N, 43.2W - Virindi Crafters","Crafter of Maces","Wooden Scarecrow Guise","Dynamic_1_^pTx!","32.0N, 43.2W"
|
||||
"Odd Stamps 2","32.0N, 43.2W - Virindi Crafters","Crafter of Knives","Scalemail Hauberk","Dynamic_1_6ZR$k^$Srwc3g!","32.0N, 43.2W"
|
||||
"Odd Stamps 2","83.4S 97.2E - Ithaenc","Abbess Zik'Lir","Hearty Fish Noodle","Dynamic_1_jmCfm1p5a!","83.4S 97.2E"
|
||||
"Odd Stamps 2","72.8N,25.0W - Stonehold nearby","Lord Pyrovor","Enhanced Shadow Greaves","Dynamic_1_Tw$7Zwmutan!","72.8N,25.0W"
|
||||
"Odd Stamps 2","VoD Encampment","Guard Alfric","Bowl of Rice","Dynamic_1_LZkvsu4Ln2$h!",""
|
||||
"Odd Stamps 2","VoD Encampment","Guard Taziq","Blackfire Shadow Sollerets","Dynamic_1_t9uxr!",""
|
||||
"Odd Stamps 2","VoD Encampment","Guard Q'alia","Ancient Relic Gauntlets","Dynamic_1_m1KeUXELMuH!",""
|
||||
"Odd Stamps 2","VoD Encampment","Guard Li","Frost Hatchet","Dynamic_1_XgrV$!",""
|
||||
"Odd Stamps 2","77.7S 97.0E Ithaenc","Shah-hi","Katar","Dynamic_1_G3N9HSXlowLT$!","77.7S 97.0E"
|
||||
"Odd Stamps 2","Releasing the Light - Reward Room","Calitoth","Fish","Dynamic_1_mu^91#T!",""
|
||||
"Odd Stamps 2","VoD Encampment","Guardian of the Forbidden","Princely Runed Dart Flinger","Dynamic_1_#BELoT72Ib!","Small Creepy Statue"
|
||||
"Odd Stamps 2","Shattered Outlands 94.0n 45.9w","Torgash","examines your Parchment","Dynamic_1_S","94.0n 45.9w"
|
||||
"Odd Stamps 2","Hoshino Must Die last room","Spirit of Bist'elle","Enhanced Shadow Breastplate","Dynamic_1_b!",""
|
||||
"Bandit Castle","","Karwin, the Lunatic","Chainmail Pauldrons","Dynamic_1_HIlMkY!",""
|
||||
"Bandit Castle","","Kiriel Shadowborn","Healing Apple Pie","Dynamic_1_WBzVFJpFUzHkC!",""
|
||||
"Bandit Castle","","Jourgensson","Hearty Healing Mushroom Pie","Dynamic_1_$W&Pl4!",""
|
||||
"Bandit Castle","","Gillian the Poacher","Peppermint Ice Cream","Dynamic_1_5oLp!",""
|
||||
"Bandit Castle","","Alison Dulane","Amuli Shadow Leggings","Dynamic_1_079u9!",""
|
||||
"Bandit Castle","","Arianna the Adept","Expired Stamina Draught","Dynamic_1_hZIsyYE!!OmcQ!",""
|
||||
"Bandit Castle","","Shanrek the Forger","Sparring Shirt","Dynamic_1_fbcmDRC!",""
|
||||
"Bandit Castle","","Neela Nashua","Perfect Dissolving Isparian Spear","Dynamic_1_4tXQFu&&o!",""
|
||||
"Bandit Castle","","Gwillim, the Apprentice","Lightning Flanged Mace","Dynamic_1_is#X6rBaprU!",""
|
||||
"Bur","","Drogur","Frost Yari","Dynamic_1_KS8e32dtk7t!",""
|
||||
"Bur","","Collector Golem","Upper Exoskeleton Metamorphi","Dynamic_1_4xdYA1QvaiDf^!",""
|
||||
"Bur","","Kuurak","Hearty Healing Chicken Noodle","Dynamic_1_Zapx!",""
|
||||
"Bur","","Furgal","Spitter Thorax Metamorphi","Dynamic_1_4rk&MTz!",""
|
||||
"Bur","","Tibik","Gear Crossbow","Dynamic_1_!Ce^d!",""
|
||||
"Bur","","Nimeruuk","Greater Celdon Shadow Sleeves","Dynamic_1_zIX1Sf6FJt!",""
|
||||
"Bur","","Kurket","Acidic Rejuvenation","Dynamic_1_snVaz#0Ze3R#4M!",""
|
||||
"Bur","","Brogosh","Lugian Morning Star","Dynamic_1_$9YdvC2jYTxWZ!",""
|
||||
"Bur","","Mohor","Quality Isparian Crossbow","Dynamic_1_qpXiWqwBTN4!",""
|
||||
"Bur","","Kushuk","Silifi of Crimson Stars","Dynamic_1_3ISBG!",""
|
||||
"Bur","","Borsh","Health Tonic","Dynamic_1_Jh4!",""
|
||||
"Bur","","Kuuru","Electric Compound Bow","Dynamic_1_vNktko1!",""
|
||||
"Bur","","Torgluuk, High Shaman of Kor-Gursha","Stout","Dynamic_1_2yxpXSMY!",""
|
||||
"Bur","","Scout Leader Tmauruk","Hood","Dynamic_1_fEiU!",""
|
||||
"Bur","","Gruuk'lar","Rynthid Tentacle Dagger","Dynamic_1_xFipmT1!",""
|
||||
"Gear Knight","Inner Sea Gearknight Invasion","Lieutenant Micham","Dabus","Dynamic_1_CQxkFJvoJrVx!",""
|
||||
"Gear Knight","Inner Sea Gearknight Invasion","Sir Oakley","Composite Crossbow with Handle","Dynamic_1_lh9wOaXR0!",""
|
||||
"Gear Knight","Inner Sea Gearknight Invasion","Lieutenant Faen","Blunt Bow","Dynamic_1_Vz#gp!",""
|
||||
"Gear Knight","Inner Sea Gearknight Invasion","Sir Stavitor","Red Tea","Dynamic_1_ogt05i!",""
|
||||
"Gear Knight","Inner Sea Gearknight Invasion","Dame Alistra","Superb Flaming Isparian Claw","Dynamic_1_y!",""
|
||||
"Gear Knight","Direland Gearknight Invasion","Sir Yanov","Major Shadow Greaves","Dynamic_1_BlAckAuHU#!",""
|
||||
"Gear Knight","Direland Gearknight Invasion","Sir Durnstad","Silifi of Crimson Stars","Dynamic_1_#Dfd!",""
|
||||
"Gear Knight","Direland Gearknight Invasion","Squire Tylaen","Good Coruscating Isparian Atlatl","Dynamic_1_i1Cxg8Bt!",""
|
||||
"Gear Knight","Direland Gearknight Invasion","Dame Trielle","Frost Yari","Dynamic_1_h^MdsKZ$6SSD!",""
|
||||
"Gear Knight","Direland Gearknight Invasion","T'ing Douzen","Panaq","Dynamic_1_p0BEy$e!",""
|
||||
"Gear Knight","Atamarr Tasks Dungeon","Bronze Gauntlet Knight-Commander","Frost Greataxe","Dynamic_1_REv&biyDw!",""
|
||||
"Gear Knight","Direland Gearknight Invasion","Copper Cog Craftsmaster","Greater Amuli Leggings of Frost","Dynamic_1_4uls5J!",""
|
||||
"Wai Jhou","","Kreavon","Skeleton Fish","Dynamic_1_KrPl9N5!",""
|
||||
"Wai Jhou","","Aun Teverea","Singularity Crossbow","Dynamic_1_Y9wg!RfKHoyL!",""
|
||||
"Wai Jhou","","Nona","Fish","Dynamic_1_JrzQr8U!",""
|
||||
"Wai Jhou","","Zho Heishan","Bandit Dagger","Dynamic_1_Abm8qK2!",""
|
||||
"Wai Jhou","","Sarkin Killcrane","Shadow Tassets","Dynamic_1_mb7NAtZEdBaz!",""
|
||||
"Wai Jhou","","Riordin Nightbane","Hafted Serpent Spear","Dynamic_1_cCzQdsl5JxLC!",""
|
||||
"Wai Jhou","","Lacarra Avanthi","Shou-jen Shozoku Trousers","Dynamic_1_ip&NsyQ!",""
|
||||
"Wai Jhou","","Xanda Har","Gold Fish","Dynamic_1_1CiKW8^x^$!",""
|
||||
"Rynthid","","Lohrn","Shreth Hide Shoes","Dynamic_1_cS!mivYZ^b!cAA!",""
|
||||
"Rynthid","","Rhys","Plate Leggings","Dynamic_1_A!!",""
|
||||
"Rynthid","","Morgethais","Silifi of Crimson Stars","Dynamic_1_wDTf#!",""
|
||||
"Rynthid","","Geilla","Audetaunga's Korua of the Mountains","Dynamic_1_&dNG5U4!",""
|
||||
"Rynthid","","Rinne Gorber","Brilliant Celdon Leggings","Dynamic_1_ln!Lx!",""
|
||||
"Rynthid","","Aun Ol'tra","Small Beer","Dynamic_1_&^3Hve4JXH^!",""
|
||||
"Rynthid","","Ranulf","Prismatic Celdon Sleeves","Dynamic_1_8n2l!",""
|
||||
"Rynthid","","Sylvanus","Ursuin Hide Coat","Dynamic_1_veaD!",""
|
||||
"Rynthid","","Marcus","Fish","Dynamic_1_bpNCu!rsf45Fk!",""
|
||||
"Rynthid","","Ilte Krongal","Hearty Mana Rabbit Noodle","Dynamic_1_AusVgDl!",""
|
||||
"Rynthid","","The Bringer of Light","Peppermint Hot Chocolate","Dynamic_1_LrpV!62!",""
|
||||
"Paradox Camp","Paradox Olthoi Camp","Ethan Wintermaine","Superb Flaming Isparian Bow","Dynamic_1_PPtO6!7dB!",""
|
||||
"Paradox Camp","","Adrien Swiftblade","Oak Stormwood Crossbow","Dynamic_1_R^1Uv!J8k!",""
|
||||
"Paradox Camp","","Alicia Swiftblade","Badlands Siraluun Dress","Dynamic_1_G0Rn1lOZKj7C!",""
|
||||
"Paradox Camp","","Tomihino","Dart Flinger","Dynamic_1_!$cc!",""
|
||||
"Paradox Camp","North Olthoi Burrow","Peda's Assistant","examines your Parchment","Dynamic_1_3ddaHUzi!",""
|
||||
"Paradox Camp","North Olthoi Burrow","Peda","examines your Parchment","Dynamic_1_1R9O85L$b!",""
|
||||
"Paradox Camp","North Olthoi Burrow","Crusher","examines your Parchment","Dynamic_1_a&Z2!",""
|
||||
"Paradox Camp","North Olthoi Burrow","Deena","examines your Parchment","Dynamic_1_cIZV2uDB6B!",""
|
||||
"Paradox Camp","North Olthoi Burrow","Mac","examines your Parchment","Dynamic_1_5x^G2$X9!",""
|
||||
"Paradox Camp","North Olthoi Burrow","Swift-Eye","examines your Parchment","Dynamic_1_o$yT7al7ZTxv!",""
|
||||
"Paradox Camp","North Olthoi Burrow","Sasha","examines your Parchment","Dynamic_1_CvzZIz!",""
|
||||
"Paradox Camp","North Olthoi Burrow","Dead-Eye","examines your Parchment","Dynamic_1_fP9y!",""
|
||||
"Paradox Camp","North Olthoi Burrow","Lash","examines your Parchment","Dynamic_1_AniHdl4wtIuF0!",""
|
||||
"Paradox Camp","North Olthoi Burrow","Long-Shot","examines your Parchment","Dynamic_1_jJ^yEFc#m^M!",""
|
||||
"Graveyard","","Renata","Singularity Spear","Dynamic_1_1fDZO3!",""
|
||||
"Graveyard","","Yoite","Composite Bow with Handle","Dynamic_1_OG6jdId!",""
|
||||
"Graveyard","","Gadi","Scored Celdon Girth","Dynamic_1_ELgh#!",""
|
||||
"Graveyard","","Aethelswith","Leather Helm","Dynamic_1_cF!",""
|
||||
"Graveyard","","Mhoire Soldier","Superb Isparian Bow","Dynamic_1_VgB#WcZOIA!","North Soldier - Opposite side of bunker"
|
||||
"Graveyard","","Mhoire Soldier","Hafted Gromnie Banner with Crest","Dynamic_1_z$DX!","South Soldier - Opposite side of bunker"
|
||||
"Graveyard","","Apep-tek the Tolerant","Spectacular Lager","Dynamic_1_Y55^MqgC!","Above ground, outside bunker 65.3w 44.0w"
|
||||
"Graveyard","","Laylana","Stiletto","Dynamic_1_&SRgbH!","Above ground, outside bunker 65.2s 44.3w"
|
||||
"Graveyard","","Lo Shoen","Amateur Explorer Pants","Dynamic_1_102!pkgn8wAYSe!","Floating Platform - Level 50 req"
|
||||
"Graveyard","","Slubbley","Healing Cake","Dynamic_1_mDaEh7!",""
|
||||
"Graveyard","","Jailer","Good Shimmering Isparian Bow","Dynamic_1_2Hm6DL!","NE bunker aboveground 64.9s 44.1w"
|
||||
"Graveyard","","Kousu Temo","Fried Mushroom Rice Dough","Dynamic_1_QUXbn6!","EW Initiation guy, 64.2s 44.0w"
|
||||
"Graveyard","","Candrus Steady-Hand","Academy Mana Potion","Dynamic_1_BKq6N6nXoR!","CH Initiation guy, 65.8s 45.3w"
|
||||
"Graveyard","","Ancient Stones","Bandit Flaming Jambiya","Dynamic_1_xL!g4ZoCuv!H","Pile of stones at 66.5s 44.7w"
|
||||
"Graveyard","Mhoire Castle - Great Hall","Ancient Throne","Taiaha","Dynamic_1_&y4ettwcivZ5Nm!",""
|
||||
"Graveyard","Mhoire Castle - Great Hall","Shade of Antemy","Left Peg Leg","Dynamic_1_CphV&!",""
|
||||
"Graveyard","Mhoire Castle - Great Hall","Shade of Fordroth","Perfect Chilling Isparian Atlatl","Dynamic_1_M0u7js^$E!",""
|
||||
"Graveyard","Mhoire Castle - Great Hall","Shade of Terelev","Silifi of Crimson Stars","Dynamic_1_XPvw!",""
|
||||
"Graveyard","Mhoire Castle - Great Hall","Guliant","Celdon Girth of Acid","Dynamic_1_aCEEdQil42!",""
|
||||
"Neftet","","T'ing Setsuko","Flaming Broad Sword","Dynamic_1_JfmjJmY0O8r!",""
|
||||
"Neftet","","Nephthys","Red Tea","Dynamic_1_mnJCjm5QR$s&!",""
|
||||
"Neftet","","Fahneph","Gear Crossbow","Dynamic_1_owGS9WGJ1Q!",""
|
||||
"Neftet","","Nekshla","Mana Pumpkin Pie","Dynamic_1_AAQ1#!",""
|
||||
"Neftet","","Sir Hassim bin Tamarek","Enhanced Shadow Greaves","Dynamic_1_r7zID$U!",""
|
||||
"Neftet","","Sir Adarl","Bobo's Stout","Dynamic_1_SoBgM6JPckOY9!",""
|
||||
"Neftet","","Sir Ibreh bin Kassim","Expired Mana Tincture","Dynamic_1_aVMuY!",""
|
||||
"Neftet","","Sir Daeglan","Quality Coruscating Isparian Crossbow","Dynamic_1_n!",""
|
||||
"Neftet","","Bemeth the Gatherer","Lesser Koujia Breastplate of Acid","Dynamic_1_bda1WYoI!",""
|
||||
"Neftet","","Hammah al Rundik","Olthoi Greaves","Dynamic_1_9v^POv6ADt3r!",""
|
||||
"Neftet","22.2S 8.7E","Kaltus","Composite Bow with Handle","Dynamic_1_xWYS3fqIjPN!","22.2S 8.7E Not Dangerous run"
|
||||
"Frozen Valley","","Sir Donovan","Pickled Egg","Dynamic_1_ypu2L!",""
|
||||
"Frozen Valley","","Sir Learth","Royal Cabbage","Dynamic_1_xpAJDzm$!",""
|
||||
"Frozen Valley","","Lady Daenerah","Acid Spadone","Dynamic_1_$SDp1uWx8wq$!",""
|
||||
"Frozen Valley","","Gregoria, Gurog Destroyer","Chocolate Gromnie","Dynamic_1_!vr&1c1Ug1XI!",""
|
||||
"Frozen Valley","","Hunter","Hearty Healing Chicken Pie","Dynamic_1_Sy!9l0FAJFI!",""
|
||||
"Frozen Valley","","Leilah","Lightning Silifi","Dynamic_1_uyoL!",""
|
||||
"Frozen Valley","","Halvor","Noble Quarterstaff","Dynamic_1_LfLac!",""
|
||||
"Frozen Valley","","Kumiko","Expired Health Potion","Dynamic_1_TB!q!",""
|
||||
"Frozen Valley","","Archmage Ichihiri","Arbalest","Dynamic_1_HzvCs4B2!",""
|
||||
"Hoshino Tent","","Sergeant Trebuus","Soldier Pincer Metamorphi","Dynamic_1_GQIb1mF!",""
|
||||
"Hoshino Tent","","Sergeant Freng","Lightning War Axe","Dynamic_1_wVJm&#Lpz7AQ#F",""
|
||||
"Hoshino Tent","","Aun Kirtal","Arena Bow","Dynamic_1_V9ffGx!",""
|
||||
"Hoshino Tent","","Lieutenant Aurin","Enhanced Smoldering Atlan Sword","Dynamic_1_4qlVcAWbM!",""
|
||||
"Hoshino Tent","","Lord Eorlinde","Major Shadow Gauntlets","Dynamic_1_zkzTna!",""
|
||||
"Hoshino Tent","","Griffon","Mana Elixir","Dynamic_1_b4^F&M1^uG!",""
|
||||
"Hoshino Tent","","Hanamoto Aki'ko","Lightning Nekode","Dynamic_1_3Qlg!",""
|
||||
"Hoshino Tent","","Corporal Irashi","Lesser Koujia Shadow Leggings","Dynamic_1_2DBoreKEH!",""
|
||||
"Hoshino Tent","","Lieutenant Takamaki","Silifi of Crimson Stars","Dynamic_1_#hzL!",""
|
||||
"Hoshino Tent","","Lieutenant Roothe","Fried Rabbit","Dynamic_1_XuH!z7l!",""
|
||||
"Viridian Rise","","Brellegia","Greater Celdon Breastplate of Acid","Dynamic_1_mCyu9F!","Requires Viridian Rise Recall Gem"
|
||||
"Viridian Rise","","Summercrown","Tachi","Dynamic_1_R8H6nh!",""
|
||||
"Viridian Rise","","Aangesilus","Slashing Compound Bow","Dynamic_1_2LJyvGJL!",""
|
||||
"Viridian Rise","","Dridge","Greater Amuli Leggings of Flame","Dynamic_1_LP3Ee7tH!",""
|
||||
"Viridian Rise","","Kervim'telek","Ursuin Hide Coat","Dynamic_1_E5$S!",""
|
||||
"Viridian Rise","","Swift","Fried Chicken","Dynamic_1_hYVV!",""
|
||||
"Ayan","","Aludi al-Jaladh","Seasoned Explorer Gauntlets","Dynamic_1_7$I7bC!",""
|
||||
"Ayan","","Aun Javhalrea, the Game Warden","Frost Ono","Dynamic_1_UdRA9W!",""
|
||||
"Ayan","","Aun Khekierea","Rich Mocha","Dynamic_1_Yt1uiSkCgK!",""
|
||||
"Ayan","","Aun Aukherea","Chocolate Cookie","Dynamic_1_G$iqi763E!",""
|
||||
"Ayan","","Shuthoth","Silifi of Crimson Stars","Dynamic_1_CkuPj0IwP!",""
|
||||
"Ayan","","Yuan Hanzu","Acid Hatchet","Dynamic_1_t^CiJAt2TBz17!",""
|
||||
"Ayan","","Joku Shunja","Dho Life Apprentice Robe","Dynamic_1_&X4EDhy!",""
|
||||
"Ayan","","Aaminah","Upgraded Marksman's Robe","Dynamic_1_YlHC^cbS!",""
|
||||
"Ayan","","Anfram Mellow","Ulgrim's Bunny Slippers","Dynamic_1_$MJj0ytiSy0CKN!",""
|
||||
"Ayan","","Alishia bint Aldan","Lightning Hatchet","Dynamic_1_87z&&Ok2o&jo!",""
|
||||
"Ayan","","Vierana du Canamorra","Fine Shadow Atlan Mace","Dynamic_1_qtZdY0C!ae!",""
|
||||
"Ayan","","Qurakh al-Taal","Hearty Mana Beef Stew","Dynamic_1_Ug2snTqb44!",""
|
||||
"Ayan","","Laedron the Geomancer","Fine Stinging Atlan Spear","Dynamic_1_2lXQdqHWxPU!",""
|
||||
"Ayan","","Rohula bint Ludun","Arena Staff","Dynamic_1_SjjPqyCHNigY!",""
|
||||
"Ayan","","Guard Winterborn","Silifi of Crimson Stars","Dynamic_1_!fzudXFZV0Je3!",""
|
||||
"Ayan","","Ennio di Cinghalle","Perfect Chilling Isparian Claw","Dynamic_1_fYP!",""
|
||||
"Ayan","","Lydda","Pathwarden Scale Hauberk","Dynamic_1_neYBz15!",""
|
||||
"Ayan","","Gaston Shadowbound","Major Shadow Tassets","Dynamic_1_jdMT!",""
|
||||
"Ayan","","Harkwull the Discreet","Quality Flaming Isparian Crossbow","Dynamic_1_Bq7Brhg!",""
|
||||
"Ayan","","Tanami Kei","Souldrinker","Dynamic_1_en!",""
|
||||
"Ayan","","Lamorda Loschi","Major Shadow Sollerets","Dynamic_1_2xn4LwsUdh!",""
|
||||
"Ayan","","Soju Bo-Ki","Composite Crossbow with Handle","Dynamic_1_ADDKG!",""
|
||||
"Ayan","","Hoshar ibn Jalaq","High Balance Testing Coat","Dynamic_1_bZ4bc!",""
|
||||
"Ayan","","Guard Bey","Tasty Stout","Dynamic_1_&!4f5YlXZ!",""
|
||||
"Ayan","","Ishaq the Philosopher","Enhanced Skeletal Atlatl","Dynamic_1_H3UNETkRXTX!",""
|
||||
"Candeth Keep","","Morathe gives you","Superb Isparian Atlatl","Dynamic_1_g9M7bV3z3#S!",""
|
||||
"Candeth Keep","","Aun Autuorea gives you","Singularity Katar","Dynamic_1_5kEI0!",""
|
||||
"Candeth Keep","","Talira Dain","Composite Bow","Dynamic_1_5i1z1Mb!","No text about being given item, it just shows up in backpack"
|
||||
"Candeth Keep","","Dalius Kendmar gives you","Undead Guise","Dynamic_1_YFrw!",""
|
||||
"Candeth Keep","","Grania the Bold gives you","Composite Crossbow with Handle","Dynamic_1_DaevbVP!",""
|
||||
"Candeth Keep","","Yukara Miko the Collector","Acid Longbow","Dynamic_1_F1r^qTQ!",""
|
||||
"Candeth Keep","","Ryukai Hiro","Good Olthoi Pauldrons","Dynamic_1_HeucrAy6c!",""
|
||||
"Candeth Keep","","Garaena the Emissary","Seasoned Explorer Arbalest","Dynamic_1_es^0FY!","Aerlinthe Portal NPC"
|
||||
|
41
Plugins/RynthCore.Plugin.RynthOracle/Resources/legendary.csv
Normal file
41
Plugins/RynthCore.Plugin.RynthOracle/Resources/legendary.csv
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
Group,Quest,CommonName,Luminance,Flags,Url,Note,Video
|
||||
"Graveyard","Count Phainor's Amulet","",10000,"graverobbercompleted_0213","https://acportalstorm.com/wiki/Count_Phainor's_Amulet","Not too long, but long enough that its noot wworth 10k to do daily, but easy to do once in a while to get to 30 quests.","https://youtu.be/JRmFOlC-EFw"
|
||||
"Graveyard","Mhoire Castle","",15000,"cleansingthethronewaiting_1209","https://acportalstorm.com/wiki/Castle_of_Lord_Mhoire_Quest","DON'T RECOMMEND: Don't hand this in, do it and keep your Oubliette flag open. You need to only flag once in the 3 towers and then you can skip straight to the boss daily if you like (I wouldn't, but I'd do it to get to 30). Flagging is easy if you use a flame rare for the SE/SW towers UPDATE: this was bugged for me, it does lock you out of the castle and you need to re-do the flag each time to get in. This is more of a pain to use it now, but the only way to get to Oubliette","https://youtu.be/2ww40h-MUIE"
|
||||
"Graveyard","Oubliette of Mhoire Castle Quest","Oubliette",30000,"pickeduptokenoublietteboss_0112;startedoublietteboss_0112","https://acportalstorm.com/wiki/Oubliette_of_Mhoire_Castle_Quest","Time consuming but once you're flagged you can run it right after defeating the shade of Lord R in Mhoire castle, just need to collect so many of those stupid portal gems. UPDATE: Don't hand in Shade of Lord R for Mhoire castle and you can skip all that flagging and just run this each time, I recommend that, have to do Mhoire castle just the first time if done that way","https://youtu.be/HmskwQDBel0"
|
||||
"Rynthid","Defeating the Curator of Torment","RTW",90000,"rtwcompleted_1013","https://acportalstorm.com/wiki/Defeating_the_Curator_of_Torment","Done by the server daily at 8:30 PM EST. Also done like 30 more times throughout the day, just join in, or learn how to open and do it yourself :D","https://youtu.be/uqkV3clTne8"
|
||||
"Rynthid","Fear Factory Quest","",12000,"fearfactoryreleased_0813","https://acportalstorm.com/wiki/Fear_Factory_Quest","Small lum, so I wouldn't run it daily since its a bit out of the way, but its super easy. Run through rynthid talking to 5 shadows in a neat dungeon. One of the more unique dungeons.","https://youtu.be/rWa_8pngbWc"
|
||||
"Rynthid","Rynthid Foundry Quest","",10000,"changinggearscompleted_0813","https://acportalstorm.com/wiki/Rynthid_Foundry_Quest","Not worth 10k Lum, but soloable. Dont' alert the guards in the first 2 rooms, then destroy the door once you're through the first door you can run through and hand out your 3 oils in a linear path","https://youtu.be/bZEBCl9vztk"
|
||||
"Rynthid","Seed of Power","",15000,"visitors4completed_0713","https://acportalstorm.com/wiki/Seed_of_Power","Pain in the ass, 4 dungeons. Run through hitting switches, or doing jumps and finally following the lightning on the floor in a tedius walk through room. (There is a skip for this, search discord for Nan's youtube video showing the skip of the last room)",""
|
||||
"Rynthid","Rynthid Foothold","Rynthid Recall",27500,"genesiscompleted_0813","https://acportalstorm.com/wiki/Rynthid_Foothold","Rynth recall. If you want to solo it, bring a lightning rare and its simplified",""
|
||||
"Rynthid","Shroud of Emotion","",20000,"spiritedcompleted_0813","https://acportalstorm.com/wiki/Shroud_of_Emotion","Gives a great necklace, a bit too long to be a daily quest. Can easily be solo'd if you're able to navigate rynthid Virindi, if not you can easily get through with 1-2 friends.","https://youtu.be/n-75FEZXp-w"
|
||||
"Rynthid","Rynthid Training","",20000,"rynthidtrainingcompleted_1013","https://acportalstorm.com/wiki/Rynthid_Training","Incredibly easy, though a bit buggy and you may need to reset from time to time, hopefully it gets fixed. Either way, Easy as hell to run.","https://youtu.be/oMRiCPELW5g"
|
||||
"Rynthid","Lugian Assault","LA",20000,"lugianassaultcompleted_0913","https://acportalstorm.com/wiki/Lugian_Assault","Followed by Curator daily, also easy to solo.","https://youtu.be/BCqrQS2mloI"
|
||||
"Rynthid","End of Days","EoD",15000,"eodcompleted_1013","https://acportalstorm.com/wiki/End_of_Days","Followed by Lugian Assault daily, also easy to solo.","https://youtu.be/Pnw9QcFm_Ag"
|
||||
"Hoshino","Save Karul","",20000,"deconstructioncompleted_0213","https://acportalstorm.com/wiki/Save_Karul","Hosh quest, short dungeon, boss fight has a lot of tanky friends but with enough melee D they dont' really hit you. Bring a friend to make this fight go quicker.","https://youtu.be/U5GczhliqKg"
|
||||
"Hoshino","Ninja Academy","",15000,"ninjaacademyfinished_0812","https://acportalstorm.com/wiki/Ninja_Academy","More Hosh, this one I feel needed at least 1 other person, can be solo'd but the enemies hit so hard and the last room has a bit if you run too quickly through to it as it locks you in.","https://youtu.be/HfPZj2SUNss"
|
||||
"Hoshino","Tanada Intercept and Slaughter","",30000,"tanadaslaughterfinished_0912","https://acportalstorm.com/wiki/Tanada_Intercept","This is two quests but it only counts as 1, each give 15k lum each. One is collecting 6 items in the dungeon and the other is defeating the boss at the end of the dungeon, so do them together. Part of the Ninja academy quest chain and for some reason is easier than part 1","https://youtu.be/6MHFjofk55Y"
|
||||
"Hoshino","Nanjou Stockade","",15000,"nanjoustockadefinished_1012","https://acportalstorm.com/wiki/Nanjou_Stockade","Third part of the quest chain, still easier than part 1, lol. Just do them all together but I probably wouldn't do these daily but to get to 30.. yes","https://youtu.be/XjrU-tdHhXg"
|
||||
"Hoshino","Hoshino Must Die","HMD",100000,"defeathoshinokeicompleted_0113","https://acportalstorm.com/wiki/Defeat_Hoshino_Kei","Best done with a large group, don't see this run enough.",""
|
||||
"Hoshino","Hoshino Fortress Infiltration","HFI",48000,"hoshinotowercomplete_0812","https://acportalstorm.com/wiki/Hoshino_Fortress_Infiltration","Would love to see this done daily but it definitely needs a group. Okay people can solo this, but its better off with a group. Update: There is a nice wall jump skip you can see an ATW youtube video showing this, makes it easier to solo.",""
|
||||
"Frozen Valley","Halt Dericost Ritual Quest","Halt",40000,"ritualtimecompleted_0411","https://acportalstorm.com/wiki/Halt_Dericost_Ritual_Quest","UPDATE: Been seeing this run more often lately, flag for this quest and its an easy 40k lum and a good check on the john quests. Some people like to do this daily, I've only run it once at this point. Did it with 3 people, seemed like a solid number to do it with, the boss wave hits hard (4th wave)","https://youtu.be/AKRt1mST5zc"
|
||||
"Frozen Valley","Deewain's Dark Cavern","",30000,"deewaincompleted0211;deewainlegkeypickuptimer","https://acportalstorm.com/wiki/Deewain's_Dark_Cavern","Another good daily you should be doing if you're not learn the maze and the jumps and you can be through it quick for some nice lum.","https://youtu.be/PWfd9Hz7Yes"
|
||||
"Frozen Valley","Bloodstone Investigation","BS3",45000,"bloodstonefactorycompleted_0211","https://acportalstorm.com/wiki/Bloodstone_Investigation","Hoard bs3s in your inventory and do this one daily, best source of lum, a bit harder than the previous quests but easily soloable.","https://youtu.be/pdos-PebuiM"
|
||||
"Frozen Valley","Geraine's Study","",30000,"geraineslibrarycompleted0312","https://acportalstorm.com/wiki/Mhoire_Infiltration","I'd put this further down the list but its so convientent to do right after bs3, the exit of bs3 brings you right to study, getting the pages and the symbols are a pain and Geraine takes a while to go down. Bring a friend to make it tolerable","https://youtu.be/HzfzkEAP71M"
|
||||
"Frozen Valley","Gurog Creation","",10000,"gurogcreationcompleted_1110;journalnoteturninwait","https://acportalstorm.com/wiki/Gurog_Creation","Really easy, would be up higher if it was better than 10k lum, not worth the time to do daily but easy to throw in next time you're in FV and looking to get up to 30 quests.","https://youtu.be/46oPIQKfWdE"
|
||||
"Neftet","First Sister","Bulb of Mornings",21000,"firstsistercompleted_1012","https://acportalstorm.com/wiki/Harvesting_the_Bulb_of_Mornings","Do all 3 sister quests solo, as they each require you to pick up 10-15 items and hand to a bulb. First sisters, beware the reedsharks, they hit hard. Don't take them lightly.","https://youtu.be/VBYojr1vbns"
|
||||
"Neftet","Slave Master Quest","",30000,"neftetfreehatsheputwait;findmumiyahdevicewait","https://acportalstorm.com/wiki/Slave_Master_Quest","Soloable for sure, but I don't like this quest. Using the scrying rod is stupid, and it makes you do it twice. It also makes you clear out the entire dungeon worth of enemies to proceed, no skipping fights, bah",""
|
||||
"Neftet","Janthef's Release","Escape",20000,"escapecompleted_0213","https://acportalstorm.com/wiki/Janthef's_Release","Neftet recall, talk to NPC. Another daily, just be careful of the void statues.","https://youtu.be/Sx-10_oSt2o"
|
||||
"Neftet","Foundry of Izexi Quest","",15000,"foundryofizexicompleted_1212","https://acportalstorm.com/wiki/Foundry_of_Izexi_Quest","Newly added quest, worthy of being daily I might move this up the list with some more practice. 2 crystals to progress through the dungeon, just be careful of the spirits spamming war, don't get careless like me :D Update: I moved this below Janthef, do them together while at Neftet, might be worth doing daily just less lum than janthef","https://youtu.be/AF0XrmVtr9M"
|
||||
"Neftet","Four Corners of Dereth","",20000,"fourcornerscompleted_1113","https://acportalstorm.com/wiki/Four_Corners_of_Dereth","UPDATE: I moved this up the list. Tge first four dungeons is a flag for the final part in Neftet, do it once then you can do a fairly quick quest for 20k Lum. Not the fastest 20k lum quest but its 100% worth being one of your 30 now. Only reason its so low is it takes time, 4 dungeons on the corners of the map and then another dungeon with a boss room at the end. If you don't like jumping puzzles, you might skip this. Recommend doing this quest at least once though, its a fun one just long. First 4 dungeons are easy, last dungeon picks up the difficulty a little but all soloable","https://youtu.be/qtklyqjjHC8"
|
||||
"Random Locations","Third Sister","Bulb of Twilight",21000,"thirdsistercompleted_1212","https://acportalstorm.com/wiki/Harvesting_the_Bulb_of_Twilight","Needs to spawn more ore, be careful of the war spam in the ore collecting area. Not too bad, do it alone.","https://youtu.be/NTiCEE07MYI"
|
||||
"Random Locations","Second Sister","Bulb of Harvests",21000,"secondsistercompleted_1112","https://acportalstorm.com/wiki/Harvesting_the_Bulb_of_Harvests","Do this to unlock the 3rd sister, and do it as part of your 30 if you have high enough jump (600+) to do it each time. If not, use a jump rare the first time to unlock sister 3 and skip in the future.","https://youtu.be/MFLDhvg5WVQ"
|
||||
"Random Locations","Releasing the Light","",25000,"blessedcavecompleted_0912","https://acportalstorm.com/wiki/Releasing_the_Light","Out of the way quest, wouldn't run this daily. Extra 5k lum if you grab the book from an easy jump puzzle. Easy enough to be in the top 30. First quest in the 3 sister quest chain, follow up with 3 sisters.","https://youtu.be/qpRIxvvFy4M"
|
||||
"Random Locations","Dream Reaver Investigation","DRI",20000,"btmcompleted_0513","https://acportalstorm.com/wiki/Dream_Reaver_Investigation","A good daily, a lot of people wait until someone collects the keys then tags along. I did that too, but then I learned the keys and they're super simple, good daily quest.","https://youtu.be/phB-O5AQTQM"
|
||||
"Random Locations","Purging the Corruption","Purge",20000,"jtmcompleted_0613","https://acportalstorm.com/wiki/Purging_the_Corruption","Another good daily to do, a bit out of the way. Tie to tumerok caves on an alt and have a candeth portal (or get the recall) for quick turn in and it becomes a good daily","https://youtu.be/-eI7A5jBgG0"
|
||||
"Random Locations","Rescuing Mouf P","Mouf",17500,"moufreward","https://acportalstorm.com/wiki/Rescuing_Mouf_P","One of the first legendary quests you probably learned and most people can do with their eyes closed.","https://youtu.be/eqfBYpXbG7o"
|
||||
"Random Locations","Liberation of Uziz","",20000,"abductedcompleted_0313","https://acportalstorm.com/wiki/Liberation_of_Uziz","Another daily many people do, if you don't next time you see someone liberating uziz, tag along its quick and easy.","https://youtu.be/K8o_yoxqGyg"
|
||||
"Random Locations","Lost Lore","",18000,"lostlorepagecompleted_0712","https://acportalstorm.com/wiki/Lost_Lore","This is really easy, just a bit out of the way in my opinion. Honestly could be a decent daily.","https://youtu.be/bO1nOM00Unk"
|
||||
"Random Locations","Serpent Burial Grounds Quest","",18000,"serpentburialgroundsdone","https://acportalstorm.com/wiki/Serpent_Burial_Grounds_Quest","The dungeon is quick to get to, easy to navigate and the boss packs a mean punch. Bring someone who can debuff the boss and tugak his sclavus swarm, that'd be nice. The sclavus have high melee D and the boss hurts, debuff that sword. I recommend 2-3 people though it could be solo'd . UPDATE- I solo'd this, debuff his sword and its a pain in the ass but doable, took too long though solo.","https://youtu.be/h-NAwcVrrIQ"
|
||||
"Random Locations","Empyrean Rescue Quest","",35000,"empyreanrescuecompleted_1010;erqlegkeypickuptimer","https://acportalstorm.com/wiki/Empyrean_Rescue_Quest","The longest part of this was finding the portal in the first dungeon, once you find it and go through to the last dungeon, you can tie to the end and skip most of this quest, but you still have to deal with triangles of death and a boss that will instant kill you. Not TERRIBLe but I still don't care much for it",""
|
||||
"Random Locations","Geraine's Hosts","Hosts",70000,"gerainesbodiescompleted0412","https://acportalstorm.com/wiki/Geraine%27s_Hosts","I wanted to put this above slave master because fuck slave master, but collecting all 7 Geraine's books takes sooo long. I want to confirm you need all 7 and not just the first 1-4 hand in to get credit UPDATE: You only need to hand in books 1-4 for this to count, still time consuming",""
|
||||
"Random Locations","Hive Queen Assault","",40000,"idoqcompleted_0413","https://acportalstorm.com/wiki/Hive_Queen_Assault","Way too time consuming, not hard but dropping 5 forks is long enough as it is. One of last one's I'd do if ever.","https://youtu.be/bafe1w3NQUQ"
|
||||
|
|
|
@ -44,6 +44,10 @@
|
|||
<EmbeddedResource Include="Resources\society.csv" LogicalName="RynthOracle.society.csv" />
|
||||
<EmbeddedResource Include="Resources\titles.csv" LogicalName="RynthOracle.titles.csv" />
|
||||
<EmbeddedResource Include="Resources\markers.csv" LogicalName="RynthOracle.markers.csv" />
|
||||
<!-- Legendary Key quests for the Legendary tab (list and notes: the "Arwic John Route" sheet). -->
|
||||
<EmbeddedResource Include="Resources\legendary.csv" LogicalName="RynthOracle.legendary.csv" />
|
||||
<!-- Infinite Leaftide Dynamic Stamps (the players' ExtraDyn sheet, 10.13.2026): Data\DynamicStamps.cs. -->
|
||||
<EmbeddedResource Include="Resources\dynstamps.csv" LogicalName="RynthOracle.dynstamps.csv" />
|
||||
<EmbeddedResource Include="Resources\customquests.csv" LogicalName="RynthOracle.customquests.csv" />
|
||||
<!-- Spell names and durations: RynthAi's spell table, shared rather than copied. -->
|
||||
<EmbeddedResource Include="..\RynthCore.Plugin.RynthAi\Combat\SpellData.txt" LogicalName="RynthOracle.SpellData.txt" Link="Shared\SpellData.txt" />
|
||||
|
|
|
|||
|
|
@ -18,9 +18,8 @@ namespace RynthCore.Plugin.RynthOracle;
|
|||
/// </summary>
|
||||
public sealed class RynthOraclePlugin : RynthPluginBase
|
||||
{
|
||||
// Previous release: 0.2.5.
|
||||
// Previous release: 0.2.8.
|
||||
public const string Version = "0.3.1";
|
||||
// Previous release: 0.5.4.
|
||||
public const string Version = "0.6.0";
|
||||
|
||||
private const long QuestReadDelayMs = 6000; // after login, before the hidden /myquests
|
||||
private const long CharacterReadMs = 1000;
|
||||
|
|
@ -44,6 +43,8 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
private string _charmsJson = "";
|
||||
private long _nextBreedingMs;
|
||||
private string _breedingJson = "";
|
||||
private long _nextGuardianMs;
|
||||
private string _guardianJson = "";
|
||||
private bool _voidAutoDecided;
|
||||
private bool _dailyCheckStarted;
|
||||
private int _seenFlagRevision = -1, _seenCatalogRevision = -1, _seenVoidRevision = -1, _seenIltRevision = -1;
|
||||
|
|
@ -68,6 +69,7 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
Host.InvokeChatParser(tab < 0 ? "/rc oracle-skills off" : $"/rc oracle-skills {tab}");
|
||||
_c.ToggleCharm = ToggleCharm;
|
||||
_c.BreedingCommand = BreedingCommand;
|
||||
_c.GuardianCommand = GuardianCommand;
|
||||
_ui.Log = msg => Host.Log(msg);
|
||||
|
||||
_mainView = new OracleView(_c);
|
||||
|
|
@ -180,6 +182,10 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
_c.Breeding = Shared.IltBreedingView.None;
|
||||
_breedingJson = "";
|
||||
_c.BreedingMessage = "";
|
||||
_c.Guardian = Shared.IltGuardianView.None;
|
||||
_guardianJson = "";
|
||||
_c.GuardianRevision++;
|
||||
_c.GuardianMessage = "";
|
||||
_c.Session = default;
|
||||
_c.SessionKnown = false;
|
||||
_c.AiSession.Reset();
|
||||
|
|
@ -246,6 +252,44 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
_main.NeedsPass = true;
|
||||
}
|
||||
|
||||
/// <summary>The Quests tab's guardian controls: a verb for RynthILT's guardians, then a quick re-read.</summary>
|
||||
private bool GuardianCommand(string verb)
|
||||
{
|
||||
long now = Environment.TickCount64;
|
||||
bool ok = _c.InWorld && _c.IltData.GuardianCommand(Host, now, verb);
|
||||
_c.GuardianMessage = ok ? "" : "RynthILT didn't take that (not loaded, or older than 0.2.20).";
|
||||
_nextGuardianMs = now + 400;
|
||||
if (_main != null) _main.NeedsPass = true;
|
||||
return ok;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// While the Quests tab is on screen on Infinite Leaftide: RynthILT's Temple guardian JSON every
|
||||
/// <see cref="CharacterExtrasReadMs"/> (the guardian rows, switches and last answer). Nothing is
|
||||
/// read with the window closed, on another tab, or on another server.
|
||||
/// </summary>
|
||||
private void ReadGuardian(long now)
|
||||
{
|
||||
if (_main == null || _mainView == null || !_main.Visible || _mainView.Tab != OracleView.TabQuests) return;
|
||||
if (!_c.Server.Is(ServerTags.InfiniteLeaftide)) return;
|
||||
if (now < _nextGuardianMs) return;
|
||||
_nextGuardianMs = now + CharacterExtrasReadMs;
|
||||
string json = _c.IltData.ReadGuardian(Host, now);
|
||||
if (string.Equals(json, _guardianJson, StringComparison.Ordinal)) return;
|
||||
_guardianJson = json;
|
||||
_c.Guardian = Shared.IltGuardianView.Parse(json);
|
||||
_c.GuardianRevision++;
|
||||
_main.NeedsPass = true;
|
||||
}
|
||||
|
||||
/// <summary>The Quests tab filtered to the trackers (the old Legendary / Markers / Dynamic Stamps tabs' commands).</summary>
|
||||
private void ShowTrackers(QuestKind? kind)
|
||||
{
|
||||
_mainView?.ShowTrackers(kind);
|
||||
if (_main != null) { _main.Visible = true; _main.NeedsPass = true; }
|
||||
_nextGuardianMs = 0; // read at once
|
||||
}
|
||||
|
||||
/// <summary>Shows the main window on a tab (another plugin's link, or a /ro tab command).</summary>
|
||||
private void ShowTab(string tab)
|
||||
{
|
||||
|
|
@ -394,6 +438,37 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
// ILT progression planners (was Skills → Progression).
|
||||
ShowTab(OracleView.TabProgress);
|
||||
break;
|
||||
case "legendary":
|
||||
case "legend":
|
||||
case "john":
|
||||
// John's 30 Legendary Key quests: the Quests tab's Legendary rows (the old Legendary tab).
|
||||
ShowTrackers(QuestKind.Legendary);
|
||||
break;
|
||||
case "markers":
|
||||
case "marker":
|
||||
// The 100 exploration markers: the Quests tab's marker rows (the old Markers tab).
|
||||
ShowTrackers(QuestKind.Marker);
|
||||
break;
|
||||
case "trackers":
|
||||
// Every tracker this server has: Legendary, markers, and on Infinite Leaftide stamps and guardians.
|
||||
ShowTrackers(null);
|
||||
break;
|
||||
case "dynamic":
|
||||
case "dyn":
|
||||
case "dyno":
|
||||
case "stamps":
|
||||
case "guardian":
|
||||
case "guardians":
|
||||
// Infinite Leaftide's trackers: Dynamic Stamps (the old tab) and RynthILT's Temple guardians.
|
||||
bool guardians = arg is "guardian" or "guardians";
|
||||
if (!_c.Server.Is(ServerTags.InfiniteLeaftide))
|
||||
{
|
||||
_c.Print((guardians ? "The Temple guardians are" : "Dynamic stamps are")
|
||||
+ " an Infinite Leaftide quest line; this server isn't recognised as Infinite Leaftide.");
|
||||
ShowTrackers(null);
|
||||
}
|
||||
else ShowTrackers(guardians ? QuestKind.Guardian : QuestKind.Dynamic);
|
||||
break;
|
||||
case "breeding":
|
||||
case "breed":
|
||||
case "pets":
|
||||
|
|
@ -418,13 +493,16 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
_c.Print("Commands: /ro (window), /ro character (Character tab: status, session, charms), "
|
||||
+ "/ro skills|attrs|progress (raise/train and ILT planners), /ro void (Void window), "
|
||||
+ "/ro timers (Quest Timers window), /ro fellowship (Fellowship tab), /ro breeding (Pet Breeding tab, Infinite Leaftide), "
|
||||
+ "/ro trackers (Quests tab, trackers only), /ro legendary (John's 30 key quests), /ro markers, "
|
||||
+ "/ro dynamic and /ro guardians (Infinite Leaftide: NPC stamps, Temple guardians), "
|
||||
+ "/ro quests (read quest flags), /ro status, "
|
||||
+ "/ro about (About tab: settings, server features)");
|
||||
break;
|
||||
}
|
||||
if (arg is "" or "void" or "timers" or "timer" or "fellowship" or "fellow" or "fship" or "character" or "char" or "charms" or "charm"
|
||||
or "skills" or "skill" or "attrs" or "attributes" or "vitals" or "progress" or "progression"
|
||||
or "breeding" or "breed" or "pets" or "about" or "features" && !Host.HasUi && !_noUiLogged)
|
||||
or "breeding" or "breed" or "pets" or "legendary" or "legend" or "john" or "markers" or "marker" or "trackers"
|
||||
or "dynamic" or "dyn" or "dyno" or "stamps" or "guardian" or "guardians" or "about" or "features" && !Host.HasUi && !_noUiLogged)
|
||||
{
|
||||
_noUiLogged = true;
|
||||
_c.Print("This RynthCore engine can't show plugin windows (it needs script windows, API v71, with ImGui on). /ro status still works.");
|
||||
|
|
@ -434,8 +512,14 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
private void RequestQuests()
|
||||
{
|
||||
if (!_c.InWorld) return;
|
||||
if (!_c.Flags.Request(cmd => Host.InvokeChatParser(cmd), Environment.TickCount64))
|
||||
Host.Log("[RynthOracle] /myquests was sent moments ago; waiting for that reply.");
|
||||
long now = Environment.TickCount64;
|
||||
if (!_c.Flags.Request(cmd => Host.InvokeChatParser(cmd), now))
|
||||
{
|
||||
int wait = _c.Flags.ThrottleSecondsLeft(now);
|
||||
Host.Log(wait > 0
|
||||
? $"[RynthOracle] The server answers one /myquests a minute; try again in {wait}s (the flags shown are kept)."
|
||||
: "[RynthOracle] /myquests was sent moments ago; waiting for that reply.");
|
||||
}
|
||||
if (_main != null) _main.NeedsPass = true;
|
||||
}
|
||||
|
||||
|
|
@ -474,6 +558,11 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
private void TickData(long now)
|
||||
{
|
||||
_c.Flags.Tick(now);
|
||||
if (_c.Flags.LastPartialReply is { } partial)
|
||||
{
|
||||
_c.Flags.LastPartialReply = null;
|
||||
Host.Log($"[RynthOracle] /myquests reply looked cut short ({partial.Got} lines, {partial.Had} flags held): merged it instead of replacing the list.");
|
||||
}
|
||||
if (_c.Flags.Revision != _seenFlagRevision)
|
||||
{
|
||||
_seenFlagRevision = _c.Flags.Revision;
|
||||
|
|
@ -519,6 +608,7 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
|
||||
ReadCharacterExtras(now);
|
||||
ReadBreeding(now);
|
||||
ReadGuardian(now);
|
||||
|
||||
// RynthCore's server list (every 2 s): a new pick or override applies now, not at the next character read.
|
||||
_c.ServerState.Poll(Host, now);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ internal sealed partial class OracleView
|
|||
? $"RynthCore: {es.ActiveName} ({es.Active}){(es.Picked ? ", picked by hand" : "")}; settings from {(es.ActivePlugin.Length > 0 ? es.ActivePlugin : "no plugin")}"
|
||||
: "RynthCore: no server active" + (es.Picked ? " (picked by hand)" : ""));
|
||||
if (RynthCore.Plugin.Shared.ServerProfileView.Parse(st.ProfileJson) is { } prof)
|
||||
w.TextDisabled($"{st.ProfilePlugin} ({RynthCore.Plugin.Shared.RynthServerProfileApiV1.InterfaceName}): {prof.Summary()}");
|
||||
w.TextDisabled($"{st.ProfilePlugin} ({st.ProfileInterface}): {prof.Summary()}");
|
||||
else if (es.ActivePlugin.Length > 0)
|
||||
w.TextDisabled($"{es.ActivePlugin} hasn't sent its server settings (an older plugin?).");
|
||||
w.TextDisabled("Change the server: RynthCore Options > Diagnostics > Server, or /rc server pick <id>|auto.");
|
||||
|
|
@ -45,6 +45,8 @@ internal sealed partial class OracleView
|
|||
w.TextDisabled($"This engine is API v{_c.Host.Version}; v86 lets RynthOracle follow RynthCore's server pick and overrides.");
|
||||
if (_c.Host.Version < 75) w.TextDisabled($"This engine is API v{_c.Host.Version}; v75 adds a surer server check and the titles you hold.");
|
||||
|
||||
DrawServerFeatures(w);
|
||||
|
||||
w.SeparatorText("Quest list");
|
||||
QuestCatalog cat = _c.Catalog;
|
||||
w.Text($"{cat.RetailCount} retail quests from the {cat.Source}" +
|
||||
|
|
@ -63,19 +65,81 @@ internal sealed partial class OracleView
|
|||
|
||||
w.SeparatorText("Commands");
|
||||
w.BulletText("/ro open or close this window");
|
||||
w.BulletText("/ro character the Character tab (status, session)");
|
||||
w.BulletText("/ro character the Character tab (status, session, charms)");
|
||||
w.BulletText("/ro skills raise and train skills");
|
||||
w.BulletText("/ro attrs attributes and vitals");
|
||||
w.BulletText("/ro progress ILT progression planners");
|
||||
w.BulletText("/ro timers open or close the Quest Timers window");
|
||||
w.BulletText("/ro fellowship the Fellowship tab");
|
||||
w.BulletText("/ro about this tab (settings, server)");
|
||||
w.BulletText("/ro trackers the Quests tab, trackers only (Legendary, markers, and on ILT stamps and guardians)");
|
||||
w.BulletText("/ro legendary John's Legendary Key quests: have, missing, repeat timers");
|
||||
w.BulletText("/ro markers the 100 exploration markers: found and still to find");
|
||||
if (_c.Server.Is(Data.ServerTags.InfiniteLeaftide))
|
||||
{
|
||||
w.BulletText("/ro dynamic Infinite Leaftide Dynamic Stamps: NPC stamps you have and are missing");
|
||||
w.BulletText("/ro guardians the Temple guardians: riddle answers, auto hand-in, buy if missing, turn-ins");
|
||||
}
|
||||
w.BulletText("/ro about this tab (settings, server features)");
|
||||
w.BulletText("/ro void open or close the Void window");
|
||||
w.BulletText("/ro quests read your quest flags now");
|
||||
w.BulletText("/ro help list the commands in chat");
|
||||
w.TextDisabled("A server quest pack can be replaced without a rebuild: put quests.<server>.csv in %APPDATA%\\RynthCore\\RynthOracle\\packs.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// "Server features": the Leaftide feature list RynthILT keeps (saved per character in its hub
|
||||
/// state and sent in its "RynthILT.Server" profile), drawn group by group in RynthILT's order
|
||||
/// with each feature's state and where it lives. Nothing here is hard-coded: a newer RynthILT
|
||||
/// adds features without an Oracle update.
|
||||
/// </summary>
|
||||
private void DrawServerFeatures(UiWindow w)
|
||||
{
|
||||
IltServerProfile p = _c.Ilt.Profile;
|
||||
if (!p.Available)
|
||||
{
|
||||
if (_c.Server.Is(ServerTags.InfiniteLeaftide))
|
||||
{
|
||||
w.SeparatorText("Server features");
|
||||
w.TextDisabled("Load RynthILT to list the Infinite Leaftide features here.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (p.Features.Count == 0) return;
|
||||
|
||||
w.SeparatorText("Server features");
|
||||
string checkedText = p.CheckedUtc == DateTime.MinValue ? "not checked yet" : $"checked {p.CheckedUtc.ToLocalTime():yyyy-MM-dd HH:mm}";
|
||||
w.TextDisabled(p.Ilt
|
||||
? $"From RynthILT ({(p.World.Length > 0 ? p.World : "this world")}, {checkedText}{(p.Forced ? ", forced on" : "")})."
|
||||
: "From RynthILT: this isn't an Infinite Leaftide world, so no Leaftide feature is claimed.");
|
||||
|
||||
// Groups in the order RynthILT lists them; one table per group.
|
||||
var groups = new System.Collections.Generic.List<string>();
|
||||
foreach (IltFeature f in p.Features)
|
||||
if (!groups.Exists(g => string.Equals(g, f.Group, StringComparison.OrdinalIgnoreCase))) groups.Add(f.Group);
|
||||
|
||||
int on = 0;
|
||||
foreach (IltFeature f in p.Features) if (f.State == RynthCore.Plugin.Shared.RynthIltServer.StateOn) on++;
|
||||
w.TextDisabled($"{on} of {p.Features.Count} on.");
|
||||
|
||||
foreach (string group in groups)
|
||||
{
|
||||
if (!w.CollapsingHeader(group.Length > 0 ? group : "Other", "o.feat.h." + group)) continue;
|
||||
foreach (IltFeature f in p.InGroup(group))
|
||||
{
|
||||
uint color = f.State switch
|
||||
{
|
||||
RynthCore.Plugin.Shared.RynthIltServer.StateOn => UiColors.Green,
|
||||
RynthCore.Plugin.Shared.RynthIltServer.StateOff => UiColors.Red,
|
||||
_ => UiColors.Yellow,
|
||||
};
|
||||
w.TextColored(color, $"[{IltServerProfile.StateText(f.State)}]");
|
||||
w.SameLine();
|
||||
w.Text(f.Label);
|
||||
if (f.Where.Length > 0) w.Tooltip("Where: " + f.Where);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void StartQuestListCheck()
|
||||
{
|
||||
_c.Settings.LastQuestListCheckUtc = DateTime.UtcNow;
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ internal sealed partial class OracleView
|
|||
QuestFlagStore flags = _c.Flags;
|
||||
Func<uint, int> prop = _c.Props;
|
||||
DateTime now = _c.UtcNow;
|
||||
if (flags.LastReadUtc == DateTime.MinValue)
|
||||
w.TextDisabled("Quest flags not read yet (Quests tab, Refresh): gem timers and seer auras show as not done.");
|
||||
QuestFlagsBar(w, "au", "gem timers and seer auras");
|
||||
|
||||
if (w.CollapsingHeader("Augmentation gem quests", "a.gems", defaultOpen: true))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -214,6 +214,6 @@ internal sealed partial class OracleView
|
|||
w.Text(status);
|
||||
}
|
||||
if (!any) w.TextDisabled("No custom quests listed for this server.");
|
||||
if (_c.Flags.LastReadUtc == DateTime.MinValue) w.TextDisabled("Read your quest flags (Quests tab) for their status.");
|
||||
else QuestFlagsBar(w, "cq.cust", "custom quests' status");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue