diff --git a/Changelog/2026-10-15-sk-pet-auto-capture-lens.md b/Changelog/2026-10-15-sk-pet-auto-capture-lens.md new file mode 100644 index 0000000..9baf2f3 --- /dev/null +++ b/Changelog/2026-10-15-sk-pet-auto-capture-lens.md @@ -0,0 +1,22 @@ +# SK: pet auto-capture with the selected siphon lens + +Date: 2026-10-15 +Plugin: RynthCore.Plugin.RynthAi (HandWrittenVersion stays 0.5.0-legacy-ui on sk) +Also: RynthILT 0.2.10 (previous 0.2.9) + +## What + +On Infinite Leaftide (ACECustom), Mini Remote > Pets can auto-use Flawed / Pristine / +Perfect / Resonance / Asheron's siphon lenses when a nearby attackable creature is within +5 m and at ACECustom's health gate (<=20% or under 20 HP; Asheron's skips the gate). + +## Files + +- MiniRemote/PetCaptureRules.cs (new) +- MiniRemote/PetsTab.cs, MiniRemoteState.cs +- Shared/RynthIltHubApi.cs FeatureMonsterCapture +- RynthILT IltFeatureCatalog tip; RynthILT 0.2.10 + +## Tests + +- RynthAiTests PetCaptureRulesTests (4) diff --git a/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/MiniRemoteState.cs b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/MiniRemoteState.cs index 3aa80c7..0d218f0 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/MiniRemoteState.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/MiniRemoteState.cs @@ -119,6 +119,12 @@ public sealed class PetTabState public bool KeepCosmeticOut; /// Seconds to wait before re-summoning the cosmetic pet after it despawns. public int CosmeticRespawnSeconds = 15; + + // Auto siphon-lens capture (ACECustom MonsterCapture; Mini Remote > Pets). + /// When on, use the selected siphon lens on a nearby creature once it is weak enough. + public bool AutoCaptureEnabled; + /// Index into (Flawed to Asheron). + public int CaptureLensIndex; } /// A user's choice of summon type for one essence (matched by name, case-insensitive). @@ -250,6 +256,7 @@ internal sealed class MiniRemoteStore s.Pet.RosterKind = Math.Clamp(s.Pet.RosterKind, 0, 2); s.Pet.RosterSort = Math.Clamp(s.Pet.RosterSort, 0, 6); s.Pet.CosmeticRespawnSeconds = Math.Clamp(s.Pet.CosmeticRespawnSeconds, 5, 600); + s.Pet.CaptureLensIndex = Math.Clamp(s.Pet.CaptureLensIndex, 0, PetCaptureRules.Lenses.Length - 1); s.Quests ??= new QuestsTabState(); s.Quests.QuestFilter ??= string.Empty; s.Quests.QuestFavorites ??= new(); diff --git a/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/PetCaptureRules.cs b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/PetCaptureRules.cs new file mode 100644 index 0000000..e9cf7ff --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/PetCaptureRules.cs @@ -0,0 +1,99 @@ +// PetCaptureRules.cs — ACECustom MonsterCapture thresholds for siphon lenses (pure; no host). +// +// Copied from ACECustom Source/ACE.Server/Entity/MonsterCapture.cs so the client can tell when +// a creature is weak enough to siphon before using a lens. Keep these numbers in lockstep with +// the server: CaptureMaxHealthFraction / CaptureMaxHealthPoints / CaptureRangeM and the lens +// WCID table in PetGuideController. +using System; + +namespace RynthCore.Plugin.RynthAi.MiniRemote; + +/// One siphon lens the Pets tab can auto-use (name, WCID, whether health is gated). +public readonly struct PetCaptureLens +{ + public PetCaptureLens(string name, uint wcid, bool bypassesHealthGate) + { + Name = name; + Wcid = wcid; + BypassesHealthGate = bypassesHealthGate; + } + + public string Name { get; } + public uint Wcid { get; } + /// Asheron's (and Debug) lenses skip the 20% / 20 HP gate. + public bool BypassesHealthGate { get; } +} + +/// +/// When a siphon lens can be used, matching ACECustom MonsterCapture.UseCaptureCrystal. +/// A creature is weak enough when its health fraction is ≤ 20% OR its current HP is under 20 +/// (whichever comes first). Asheron's Lens skips that check. +/// +public static class PetCaptureRules +{ + /// A lens targets the nearest attackable creature within this many meters. + public const float CaptureRangeM = 5.0f; + + /// Siphon once at or below this fraction of max health… + public const float CaptureMaxHealthFraction = 0.20f; + + /// …or below this many hit points (the gate is OR with the fraction). + public const int CaptureMaxHealthPoints = 20; + + /// + /// Lenses the player can pick for auto-capture. Order is the combo index. + /// Resonance needs a prior failed capture (server-side); Asheron's bypasses the health gate. + /// + public static readonly PetCaptureLens[] Lenses = + { + new("Flawed Siphon Lens", 78780001, bypassesHealthGate: false), + new("Pristine Siphon Lens", 78780002, bypassesHealthGate: false), + new("Perfect Siphon Lens", 78780003, bypassesHealthGate: false), + new("Resonance Lens", 78780010, bypassesHealthGate: false), + new("Asheron's Lens", 78780012, bypassesHealthGate: true), + }; + + /// Combo labels for the Pets tab (same order as ). + public static readonly string[] LensNames = + { + "Flawed", "Pristine", "Perfect", "Resonance", "Asheron's", + }; + + public static PetCaptureLens LensAt(int index) + { + int i = Math.Clamp(index, 0, Lenses.Length - 1); + return Lenses[i]; + } + + /// + /// True when ACECustom would accept a siphon on this creature for a normal (non-bypass) lens. + /// Pass current/max when known; when only a 0–1 ratio is known, pass ratio as current and 1 as max + /// (then only the fraction half of the gate can fire). + /// + public static bool IsWeakEnough(uint currentHp, uint maxHp) + { + if (currentHp == 0) return false; // dead — server refuses + if (maxHp == 0) return false; + float pct = (float)currentHp / maxHp; + // Server: refuse when pct > 0.20 AND current >= 20. Allowed otherwise. + return pct <= CaptureMaxHealthFraction || currentHp < CaptureMaxHealthPoints; + } + + /// Same gate from a 0–1 health ratio only (no absolute HP). Dead / unknown = false. + public static bool IsWeakEnoughRatio(float healthRatio) + { + if (healthRatio <= 0f || healthRatio > 1f) return false; + return healthRatio <= CaptureMaxHealthFraction; + } + + /// True when this lens may be used given the creature's vitals (bypass lenses always, if alive). + public static bool CanAttempt(PetCaptureLens lens, uint currentHp, uint maxHp) + { + if (currentHp == 0) return false; + if (lens.BypassesHealthGate) return maxHp == 0 || currentHp > 0; + return IsWeakEnough(currentHp, maxHp); + } + + /// Distance gate: ACECustom CaptureRangeM. + public static bool InRange(double distanceM) => distanceM >= 0 && distanceM <= CaptureRangeM; +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/PetsTab.cs b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/PetsTab.cs index da328a7..1092db3 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/PetsTab.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/PetsTab.cs @@ -23,6 +23,9 @@ // player bools the server stamps. Feeds PetManager.AllowSummonOnEmpty. // * 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 +// 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 // offers it (an ILT world whose server hasn't reported pet breeding off). Its whole body is @@ -57,6 +60,14 @@ internal sealed class PetsTab private long _lastHealThink; private string _healStatus = "idle"; + // Auto siphon-lens capture (ACECustom MonsterCapture). + private long _lastCaptureThink; + private long _captureCooldownUntil; + private volatile string _captureStatus = "off"; + private const long CaptureThinkMs = 250; + private const long CaptureCooldownMs = 2500; + private const long CaptureFailBackoffMs = 8000; + // Roster snapshot (rebuilt on the pump thread, read by the render thread). private volatile PetStats[] _pets = Array.Empty(); private long _lastPetScan; @@ -289,6 +300,11 @@ internal sealed class PetsTab _lastHealThink = nowMs; TickHealing(nowMs); } + if (nowMs - _lastCaptureThink >= CaptureThinkMs) + { + _lastCaptureThink = nowMs; + TickCapture(nowMs); + } if (nowMs - _lastPresenceThink >= 1000) { _lastPresenceThink = nowMs; @@ -334,9 +350,53 @@ internal sealed class PetsTab EndHealCycle(MiniRemoteContext.NowMs, "heal landed"); } } + + // ACECustom MonsterCapture replies — back off after a refuse so we don't burn lenses. + if (S.AutoCaptureEnabled && text.Length > 0) + { + long now = MiniRemoteContext.NowMs; + if (ContainsAny(text, + "successfully siphoned the essence", + "The echo resonates perfectly", + "The essence is captured")) + { + _captureStatus = "captured"; + _captureCooldownUntil = now + CaptureCooldownMs; + } + else if (ContainsAny(text, + "too strong", + "blind rage", + "cannot be siphoned", + "cannot be captured", + "No creatures nearby", + "already dead", + "already being captured", + "hasn't failed a capture", + "echo has faded", + "Failed to consume")) + { + _captureStatus = "refused: " + Truncate(text, 48); + _captureCooldownUntil = now + CaptureFailBackoffMs; + } + else if (ContainsAny(text, "siphon failed", "lens shatters", "resisted your capture", "resonance fades")) + { + _captureStatus = "failed (creature may enrage)"; + _captureCooldownUntil = now + CaptureFailBackoffMs; + } + } return false; } + private static bool ContainsAny(string text, params string[] parts) + { + foreach (string p in parts) + if (text.IndexOf(p, StringComparison.OrdinalIgnoreCase) >= 0) return true; + return false; + } + + private static string Truncate(string s, int max) + => s.Length <= max ? s : s[..(max - 1)] + "…"; + public void OnLogout() { _heal = HealState.Idle; @@ -345,6 +405,8 @@ internal sealed class PetsTab _lastSummonEssenceId = 0; _cosmeticOutEssenceId = 0; _cosmeticNextAt = 0; + _captureCooldownUntil = 0; + _captureStatus = "off"; } // ── Healing pet ───────────────────────────────────────────────────────── @@ -415,6 +477,140 @@ internal sealed class PetsTab // ── Active pet ────────────────────────────────────────────────────────── + // ── Auto siphon capture (ACECustom MonsterCapture) ─────────────────────── + + /// + /// When Auto Capture is on, use the chosen siphon lens on the nearest attackable creature + /// within 5 m once ACECustom's health gate is met (≤20% or under 20 HP; Asheron's skips it). + /// The server picks the nearest creature itself — we only fire when that nearest candidate is + /// already weak enough, so a full-health neighbour closer than the wounded target won't waste a lens. + /// + private void TickCapture(long now) + { + if (!S.AutoCaptureEnabled) + { + _captureStatus = "off"; + return; + } + if (_ctx.Ilt.Loaded && _ctx.Ilt.IsOff(RynthIltHub.FeatureMonsterCapture)) + { + _captureStatus = "monster capture disabled on this server"; + return; + } + if (now < _captureCooldownUntil) + { + long left = (_captureCooldownUntil - now + 999) / 1000; + if (!_captureStatus.StartsWith("waiting", StringComparison.Ordinal)) + _captureStatus = $"waiting {left}s"; + return; + } + if (_ctx.Inventory.IsBusy) { _captureStatus = "busy"; return; } + + var lens = PetCaptureRules.LensAt(S.CaptureLensIndex); + var lensItem = _ctx.Inventory.FindByWcid(lens.Wcid); + if (lensItem == null) + { + _captureStatus = $"no {lens.Name} carried"; + return; + } + + if (!TryFindNearestCaptureTarget(out WorldObject? target, out double distM, out uint curHp, out uint maxHp)) + { + _captureStatus = "no attackable creature within 5 m"; + return; + } + + if (!PetCaptureRules.InRange(distM)) + { + _captureStatus = $"{target!.Name} at {distM:0.0} m (need ≤{PetCaptureRules.CaptureRangeM:0} m)"; + return; + } + + if (!PetCaptureRules.CanAttempt(lens, curHp, maxHp)) + { + float pct = maxHp > 0 ? curHp * 100f / maxHp : -1f; + _captureStatus = pct >= 0 + ? $"{target!.Name} at {pct:0}% / {curHp} HP (need ≤{PetCaptureRules.CaptureMaxHealthFraction:P0} or <{PetCaptureRules.CaptureMaxHealthPoints} HP)" + : $"{target!.Name}: health unknown"; + return; + } + + if (!_ctx.Inventory.Use(lensItem)) + { + _captureStatus = "UseObject refused"; + return; + } + + float shown = maxHp > 0 ? curHp * 100f / maxHp : 0f; + _captureStatus = $"using {lens.Name} on {target!.Name} ({shown:0}% / {curHp} HP)"; + _captureCooldownUntil = now + CaptureCooldownMs; + RynthLog.Write(LogCat.Pets, + $"[Pets] auto-capture: {lens.Name} -> 0x{target.Id:X8} '{target.Name}' d={distM:0.0}m hp={curHp}/{maxHp}"); + } + + /// + /// Nearest attackable landscape creature within capture range, with vitals from the host when + /// available else the cache health ratio (fraction-only gate). + /// + private bool TryFindNearestCaptureTarget(out WorldObject? best, out double bestDist, out uint curHp, out uint maxHp) + { + best = null; + bestDist = double.MaxValue; + curHp = maxHp = 0; + var cache = _ctx.Inventory.Cache; + if (cache == null) return false; + uint playerId = _ctx.Inventory.PlayerId; + if (playerId == 0) return false; + int pid = unchecked((int)playerId); + string ownPrefix = _ctx.CharName.Length > 0 ? _ctx.CharName + "'s " : string.Empty; + + foreach (var wo in cache.GetLandscape()) + { + if (wo == null || wo.Id == pid) continue; + if (wo.ObjectClass != AcObjectClass.Monster) continue; + if (ownPrefix.Length > 0 && wo.Name.StartsWith(ownPrefix, StringComparison.Ordinal)) continue; + // Skip corpses / non-attackable when the host can tell. + if (_ctx.Host.HasObjectIsAttackable && !_ctx.Host.ObjectIsAttackable(unchecked((uint)wo.Id))) + continue; + + double d = cache.Distance(pid, wo.Id); + if (d < 0 || d > PetCaptureRules.CaptureRangeM || d >= bestDist) continue; + + if (!TryReadCreatureVitals(wo.Id, cache, out uint c, out uint m)) + continue; + if (c == 0) continue; // dead + + best = wo; + bestDist = d; + curHp = c; + maxHp = m; + } + return best != null; + } + + /// + /// Absolute vitals via TryGetTargetVitals when bound; else cache health ratio as a 0–1000 scale + /// so only the fraction half of ACECustom's gate can fire. + /// + private bool TryReadCreatureVitals(int id, WorldObjectCache cache, out uint cur, out uint max) + { + cur = max = 0; + if (_ctx.Host.HasGetTargetVitals + && _ctx.Host.TryGetTargetVitals(unchecked((uint)id), out uint h, out uint mh, out _, out _, out _, out _) + && mh > 0) + { + cur = h; + max = mh; + return true; + } + float ratio = cache.GetHealthRatio(id); + if (ratio < 0f) return false; + // Synthetic scale: ratio 0.20 → 200/1000 so IsWeakEnough's fraction half matches. + max = 1000; + cur = (uint)Math.Clamp((int)Math.Round(ratio * 1000f), 1, 1000); + return true; + } + /// The live "<Me>'s …" creature (server pet naming), or null. private WorldObject? FindOwnPet() { @@ -764,12 +960,44 @@ internal sealed class PetsTab { ImGui.Separator(); RenderCharms(); + ImGui.Separator(); + RenderCapture(); } ImGui.Separator(); RenderHealing(); _ctx.Ilt.RenderSection(RynthIltHub.SectionPetLogs); } + /// ACECustom siphon-lens auto-capture (ILT only): enable + which lens to use. + private void RenderCapture() + { + ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Monster capture"); + bool captureOff = _ctx.Ilt.IsOff(RynthIltHub.FeatureMonsterCapture); + ImGui.BeginDisabled(captureOff); + bool en = S.AutoCaptureEnabled; + if (ImGui.Checkbox("Auto-capture when a creature is weak enough", ref en)) + S.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. Resonance Lens still needs a prior failed capture on the server."); + } + ImGui.SameLine(); + ImGui.SetNextItemWidth(120); + int lens = Math.Clamp(S.CaptureLensIndex, 0, PetCaptureRules.LensNames.Length - 1); + if (ImGui.Combo("##petcapturelens", ref lens, PetCaptureRules.LensNames, PetCaptureRules.LensNames.Length)) + S.CaptureLensIndex = lens; + if (ImGui.IsItemHovered()) + SafeImGui.SetTooltip("Which siphon lens to use. Must be carried in your pack."); + ImGui.EndDisabled(); + if (captureOff) + SafeImGui.TextDisabled("Monster capture is disabled on this server."); + else + SafeImGui.TextDisabled("Status: " + _captureStatus); + } + /// Type / Sort combos, action buttons, the active-summon line and per-type options. private void RenderRosterHeader(LegacyUiSettings settings) { diff --git a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltFeatureCatalog.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltFeatureCatalog.cs index a0035c7..96b39c0 100644 --- a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltFeatureCatalog.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltFeatureCatalog.cs @@ -111,7 +111,7 @@ internal static class IltFeatureCatalog new("pets", "Pet log", GroupPets, "Mini Remote > Pets tab", "Captured pets, registered with Professor Ruggan (/pets).", IltFeature.Pets, IltKnown.Checked), new("shinies", "Shiny log", GroupPets, "Mini Remote > Pets tab", "Rare shiny creature variants you captured (/shinies).", IltFeature.Shinies, IltKnown.Checked), new("monster_capture", "Monster capture", GroupPets, "Mini Remote > Pets tab", - "Siphon lenses capture a creature's look into a pet essence (lens drops from kills are a separate server switch).", "monster_capture"), + "Siphon lenses capture a creature\'s look into a pet essence (<=20% health or under 20 HP; Asheron\'s Lens skips the gate). Auto-capture is the checkbox on the Pets roster.", "monster_capture"), new("pet_breeding", "Pet breeding", GroupPets, "Mini Remote > Pets > Breeding", "Breed two combat pet devices at the Seedy Motel for inherited and mutated offspring (/dance).", "pet_breeding"), new("pet_maturity", "Pet maturity", GroupPets, "Mini Remote > Pets > Breeding", diff --git a/Plugins/RynthCore.Plugin.RynthILT/RynthILTPlugin.cs b/Plugins/RynthCore.Plugin.RynthILT/RynthILTPlugin.cs index 8b71be6..b57ad97 100644 --- a/Plugins/RynthCore.Plugin.RynthILT/RynthILTPlugin.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/RynthILTPlugin.cs @@ -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.8. - internal static readonly IntPtr VersionPointer = Marshal.StringToHGlobalAnsi("0.2.9"); + // Previous release: 0.2.9. + internal static readonly IntPtr VersionPointer = Marshal.StringToHGlobalAnsi("0.2.10"); /// /// The settings view's surface. No longer in the sections manifest (the force-server override diff --git a/Plugins/Shared/RynthIltHubApi.cs b/Plugins/Shared/RynthIltHubApi.cs index 91028cb..5fff5fa 100644 --- a/Plugins/Shared/RynthIltHubApi.cs +++ b/Plugins/Shared/RynthIltHubApi.cs @@ -60,6 +60,8 @@ public static class RynthIltHub public const string FeatureQuests = "quests"; public const string FeaturePetRefill = "pet_refill"; public const string FeatureUniversalMastery = "universal_mastery"; + /// ACECustom siphon lenses (monster capture into a pet essence). + public const string FeatureMonsterCapture = "monster_capture"; public const string FeatureRequireComps = "require_spell_comps"; /// Pet breeding (the Pets tab's Breeding sub-tab is hidden while the server reports it off). public const string FeaturePetBreeding = "pet_breeding"; diff --git a/Tools/RynthCore.RynthAiTests/Program.cs b/Tools/RynthCore.RynthAiTests/Program.cs index 8aac1ad..3e3a6a6 100644 --- a/Tools/RynthCore.RynthAiTests/Program.cs +++ b/Tools/RynthCore.RynthAiTests/Program.cs @@ -20,6 +20,7 @@ internal static class Program CreatureWeaknessTests.Register(runner); MonsterDamageTierTests.Register(runner); LootBaselineTests.Register(runner); + PetCaptureRulesTests.Register(runner); return runner.Run("RynthAi tests", args.Length > 0 ? args[0] : null); } } diff --git a/Tools/RynthCore.RynthAiTests/RynthCore.RynthAiTests.csproj b/Tools/RynthCore.RynthAiTests/RynthCore.RynthAiTests.csproj index 7406700..ad78cfc 100644 --- a/Tools/RynthCore.RynthAiTests/RynthCore.RynthAiTests.csproj +++ b/Tools/RynthCore.RynthAiTests/RynthCore.RynthAiTests.csproj @@ -30,6 +30,7 @@ + diff --git a/Tools/RynthCore.RynthAiTests/Tests/PetCaptureRulesTests.cs b/Tools/RynthCore.RynthAiTests/Tests/PetCaptureRulesTests.cs new file mode 100644 index 0000000..2d4de20 --- /dev/null +++ b/Tools/RynthCore.RynthAiTests/Tests/PetCaptureRulesTests.cs @@ -0,0 +1,70 @@ +// ACECustom MonsterCapture health / range / lens table — matches Source/ACE.Server/Entity/MonsterCapture.cs. +using RynthCore.Plugin.RynthAi.MiniRemote; +using RynthCore.RynthAiTests.Harness; + +namespace RynthCore.RynthAiTests.Tests; + +internal static class PetCaptureRulesTests +{ + public static void Register(Runner r) + { + r.Add("pet capture: health gate matches ACECustom (≤20% or under 20 HP)", HealthGate); + r.Add("pet capture: Asheron's Lens bypasses the health gate", AsheronsBypass); + r.Add("pet capture: range is 5 m; dead creatures are never capturable", RangeAndDead); + r.Add("pet capture: lens WCIDs match PetGuideController", LensWcids); + } + + private static void HealthGate() + { + // Full health — refuse. + Check.False(PetCaptureRules.IsWeakEnough(100, 100), "100/100 too strong"); + Check.False(PetCaptureRules.IsWeakEnough(21, 100), "21% and ≥20 HP too strong"); + + // Fraction gate. + Check.True(PetCaptureRules.IsWeakEnough(20, 100), "20% exactly is allowed"); + Check.True(PetCaptureRules.IsWeakEnough(1, 100), "1% allowed"); + + // Absolute HP gate (high % but under 20 HP). + Check.True(PetCaptureRules.IsWeakEnough(15, 50), "15/50 = 30% but under 20 HP"); + Check.True(PetCaptureRules.IsWeakEnough(19, 19), "19/19 under 20 HP"); + + // Ratio-only path (no absolute HP): only the fraction half. + Check.True(PetCaptureRules.IsWeakEnoughRatio(0.20f), "ratio 0.20"); + Check.False(PetCaptureRules.IsWeakEnoughRatio(0.21f), "ratio 0.21"); + Check.False(PetCaptureRules.IsWeakEnoughRatio(0f), "ratio 0 = dead"); + Check.False(PetCaptureRules.IsWeakEnough(0, 100), "0 current = dead"); + } + + private static void AsheronsBypass() + { + var asheron = PetCaptureRules.LensAt(4); + Check.Eq(asheron.Wcid, 78780012u, "Asheron's WCID"); + Check.True(asheron.BypassesHealthGate, "bypasses health"); + Check.True(PetCaptureRules.CanAttempt(asheron, 100, 100), "full health ok for Asheron's"); + Check.False(PetCaptureRules.CanAttempt(asheron, 0, 100), "still not when dead"); + + var flawed = PetCaptureRules.LensAt(0); + Check.False(PetCaptureRules.CanAttempt(flawed, 100, 100), "Flawed refuses full health"); + Check.True(PetCaptureRules.CanAttempt(flawed, 10, 100), "Flawed at 10%"); + } + + private static void RangeAndDead() + { + Check.Eq(PetCaptureRules.CaptureRangeM, 5.0f, "5 m range"); + Check.True(PetCaptureRules.InRange(0), "at feet"); + Check.True(PetCaptureRules.InRange(5.0), "at 5 m"); + Check.False(PetCaptureRules.InRange(5.01), "past 5 m"); + Check.False(PetCaptureRules.InRange(-1), "unknown distance"); + } + + private static void LensWcids() + { + Check.Eq(PetCaptureRules.Lenses.Length, 5, "five selectable lenses"); + Check.Eq(PetCaptureRules.LensAt(0).Wcid, 78780001u, "Flawed"); + Check.Eq(PetCaptureRules.LensAt(1).Wcid, 78780002u, "Pristine"); + Check.Eq(PetCaptureRules.LensAt(2).Wcid, 78780003u, "Perfect"); + Check.Eq(PetCaptureRules.LensAt(3).Wcid, 78780010u, "Resonance"); + Check.Eq(PetCaptureRules.LensAt(4).Wcid, 78780012u, "Asheron's"); + Check.Eq(PetCaptureRules.LensNames.Length, PetCaptureRules.Lenses.Length, "combo labels match"); + } +}